1
lige
2023-12-04 77b51f625a13a8254eb2e8a9aa53bacf575f7274
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
package com.ltkj.web.controller.system;
 
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.framework.config.MatchUtils;
import com.ltkj.hosp.domain.TjAskHistorys;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.service.ITjAskHistorysService;
import com.ltkj.hosp.service.ITjCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ltkj.common.annotation.Log;
import com.ltkj.common.core.controller.BaseController;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.enums.BusinessType;
import com.ltkj.hosp.domain.TjAskMedicalHistory;
import com.ltkj.hosp.service.ITjAskMedicalHistoryService;
import com.ltkj.common.utils.poi.ExcelUtil;
import com.ltkj.common.core.page.TableDataInfo;
 
/**
 * 问诊Controller
 *
 * @author ltkj_赵佳豪&李格
 * @date 2023-04-11
 */
@RestController
@RequestMapping("/hosp/history")
@Api(tags = "问诊接口")
public class TjAskMedicalHistoryController extends BaseController {
    @Autowired
    private ITjAskMedicalHistoryService tjAskMedicalHistoryService;
    @Autowired
    private ITjAskHistorysService historysService;
    @Autowired
    private ITjCustomerService customerService;
    @Resource
    private ITjCustomerService tjCustomerService;
 
 
    /**
     * 查询问诊列表
     */
//    @PreAuthorize("@ss.hasPermi('hosp:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(TjAskMedicalHistory tjAskMedicalHistory) {
        startPage();
        List<TjAskMedicalHistory> list = tjAskMedicalHistoryService.selectTjAskMedicalHistoryList(tjAskMedicalHistory);
        return getDataTable(list);
    }
 
    /**
     * 导出问诊列表
     */
//    @PreAuthorize("@ss.hasPermi('hosp:history:export')")
    @Log(title = "问诊", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TjAskMedicalHistory tjAskMedicalHistory) {
        List<TjAskMedicalHistory> list = tjAskMedicalHistoryService.selectTjAskMedicalHistoryList(tjAskMedicalHistory);
        ExcelUtil<TjAskMedicalHistory> util = new ExcelUtil<TjAskMedicalHistory>(TjAskMedicalHistory.class);
        util.exportExcel(response, list, "问诊数据");
    }
 
    /**
     * 获取问诊详细信息
     */
//    @PreAuthorize("@ss.hasPermi('hosp:history:query')")
    @GetMapping(value = "/{askId}")
    public AjaxResult getInfo(@PathVariable("askId") Long askId) {
        return success(tjAskMedicalHistoryService.selectTjAskMedicalHistoryByAskId(askId));
    }
 
    /**
     * 根据客户id获取问诊详细信息
     */
    @GetMapping(value = "/getInfoById")
    @ApiOperation(value = "根据客户id获取问诊详细信息")
    public AjaxResult getInfoById(@RequestParam String userId) {
        if (null != userId && !"".equals(userId)) {
            LambdaQueryWrapper<TjAskMedicalHistory> wq = new LambdaQueryWrapper<>();
            wq.eq(TjAskMedicalHistory::getCusId, Long.valueOf(userId));
            TjAskMedicalHistory one = tjAskMedicalHistoryService.getOne(wq);
            if (one != null) {
                return success(tjAskMedicalHistoryService.selectTjAskMedicalHistoryByAskId(one.getAskId()));
            }
            TjAskMedicalHistory a = new TjAskMedicalHistory();
            a.setCusId(Long.valueOf(userId));
            TjCustomer byId = customerService.getById(a.getCusId());
            if (byId != null) {
                a.setCusName(MatchUtils.hideCusName(byId.getCusName()));
            }
            return AjaxResult.success(a);
        }
        return AjaxResult.success();
    }
 
    /**
     * 新增问诊
     */
    //@PreAuthorize("@ss.hasPermi('hosp:history:add')")
    @Log(title = "问诊", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TjAskMedicalHistory tjAskMedicalHistory) {
        return toAjax(tjAskMedicalHistoryService.insertTjAskMedicalHistory(tjAskMedicalHistory));
    }
 
 
    /**
     * pc端修改问诊
     */
    @ApiOperation(value = "pc端修改问诊")
    //@PreAuthorize("@ss.hasPermi('hosp:history:edit')")
    @Log(title = "问诊", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TjAskMedicalHistory tjAskMedicalHistory) {
        boolean b =false;
        tjAskMedicalHistory.setFromBy("PC端");
        if (tjAskMedicalHistory.getAskId()!=null){
            b = tjAskMedicalHistoryService.updateById(tjAskMedicalHistory);
        }else {
            b = tjAskMedicalHistoryService.save(tjAskMedicalHistory);
        }
        //boolean b = tjAskMedicalHistoryService.saveOrUpdate(tjAskMedicalHistory);
        if (b){
            List<TjAskHistorys> tjAskHistorysList = tjAskMedicalHistory.getTjAskHistorysList();
            if (tjAskHistorysList!=null&&tjAskHistorysList.size()>0){
                for (TjAskHistorys tjAskHistorys : tjAskMedicalHistory.getTjAskHistorysList()) {
                    tjAskHistorys.setAskId(tjAskMedicalHistory.getAskId());
                    boolean b1 = historysService.saveOrUpdate(tjAskHistorys);
                    if (!b1){
                        return AjaxResult.error();
                    }
                }
            }
            return AjaxResult.success();
        }
        return AjaxResult.error();
        //return toAjax(tjAskMedicalHistoryService.updateTjAskMedicalHistory(tjAskMedicalHistory));
    }
 
 
    /**
     * 小程序根据客户身份证号获取问诊详细信息
     */
    @GetMapping(value = "/appGetInfoById")
    @ApiOperation(value = "小程序根据客户身份证号获取问诊详细信息")
    public AjaxResult appGetInfoById(@RequestParam("cusIdCard") String cusIdCard) {
        LambdaQueryWrapper<TjCustomer> wqqq=new LambdaQueryWrapper<>();
        wqqq.eq(TjCustomer::getCusIdcard,cusIdCard);
        TjCustomer one1 = tjCustomerService.getOne(wqqq);
 
        if (one1!=null){
            LambdaQueryWrapper<TjAskMedicalHistory> wq=new LambdaQueryWrapper<>();
            wq.eq(TjAskMedicalHistory::getCusId,one1.getCusId());
            TjAskMedicalHistory one = tjAskMedicalHistoryService.getOne(wq);
            if (one!=null){
                return success(tjAskMedicalHistoryService.selectTjAskMedicalHistoryByAskId(one.getAskId()));
            }else {
                TjAskMedicalHistory a=new TjAskMedicalHistory();
                a.setCusId(Long.valueOf(one1.getCusId()));
                TjCustomer byId = customerService.getById(a.getCusId());
                if (byId!=null){
                    a.setCusName(byId.getCusName());
                }
 
                return AjaxResult.success(a);
            }
        }
        return AjaxResult.error("查无此人");
 
    }
 
    /**
     * 小程序修改问诊
     */
    @ApiOperation(value = "小程序修改问诊")
    @PostMapping("/appEdit")
    public AjaxResult appEdit(@RequestBody TjAskMedicalHistory tjAskMedicalHistory) {
        boolean b =false;
        tjAskMedicalHistory.setFromBy("小程序端");
        if (tjAskMedicalHistory.getAskId()!=null){
            b = tjAskMedicalHistoryService.updateById(tjAskMedicalHistory);
        }else {
            b = tjAskMedicalHistoryService.save(tjAskMedicalHistory);
        }
        if (b){
            List<TjAskHistorys> tjAskHistorysList = tjAskMedicalHistory.getTjAskHistorysList();
            if (tjAskHistorysList!=null&&tjAskHistorysList.size()>0){
                for (TjAskHistorys tjAskHistorys : tjAskMedicalHistory.getTjAskHistorysList()) {
                    tjAskHistorys.setAskId(tjAskMedicalHistory.getAskId());
                    boolean b1 = historysService.saveOrUpdate(tjAskHistorys);
                    if (!b1){
                        return AjaxResult.error();
                    }
                }
            }
            return AjaxResult.success("修改成功");
        }
        return AjaxResult.error("修改失败");
    }
 
    /**
     * 删除问诊
     */
//    @PreAuthorize("@ss.hasPermi('hosp:history:remove')")
    @Log(title = "问诊", businessType = BusinessType.DELETE)
    @DeleteMapping("/{askIds}")
    public AjaxResult remove(@PathVariable Long[] askIds) {
        return toAjax(tjAskMedicalHistoryService.deleteTjAskMedicalHistoryByAskIds(askIds));
    }
}