zjh
2023-10-25 8c4968ea3bd61c154c71d40f43a2cc22760fef49
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
package com.ltkj.web.controller.mall;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.framework.config.UserHoder;
import com.ltkj.hosp.domain.TjAskHistorys;
import com.ltkj.hosp.domain.TjAskMedicalHistory;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.service.ITjAskHistorysService;
import com.ltkj.hosp.service.ITjAskMedicalHistoryService;
import com.ltkj.hosp.service.ITjCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * @Company: 西安路泰科技有限公司
 * @Author: zjh
 * @Date: 2023/7/26 08:53
 */
 
 
 
@RestController
@RequestMapping("/cus/history")
@Api(tags = "体检小程序端问诊记录接口")
public class WxTjAskMedicalHistoryController {
 
    @Resource
    private ITjAskMedicalHistoryService tjAskMedicalHistoryService;
    @Resource
    private ITjAskHistorysService historysService;
    @Resource
    private ITjCustomerService customerService;
    @Resource
    private ITjCustomerService tjCustomerService;
 
 
    /**
     * 小程序根据客户身份证号获取问诊详细信息
     */
    @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 AjaxResult.success(tjAskMedicalHistoryService.selectTjAskMedicalHistoryByAskId(one.getAskId()));
            }else {
                TjAskMedicalHistory a=new TjAskMedicalHistory();
                a.setCusId(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) {
        TjCustomer customer = customerService.getOne(new LambdaQueryWrapper<TjCustomer>().eq(TjCustomer::getCusIdcard, tjAskMedicalHistory.getCusIdCard()));
        if(null !=customer){
            LambdaQueryWrapper<TjAskMedicalHistory> wq=new LambdaQueryWrapper<>();
            wq.eq(TjAskMedicalHistory::getCusId,customer.getCusId());
            wq.isNull(TjAskMedicalHistory::getTjNum);
            tjAskMedicalHistoryService.remove(wq);
            tjAskMedicalHistory.setCusId(customer.getCusId());
        }
        tjAskMedicalHistory.setFromBy("小程序端");
        tjAskMedicalHistory.setCreateId(String.valueOf(UserHoder.getWxuser().getId()));
//        tjAskMedicalHistory.setUpdateId(String.valueOf(UserHoder.getWxuser().getId()));
        if (tjAskMedicalHistoryService.saveOrUpdate(tjAskMedicalHistory)){
            List<TjAskHistorys> tjAskHistorysList = tjAskMedicalHistory.getTjAskHistorysList();
            if (tjAskHistorysList!=null&&tjAskHistorysList.size()>0){
                for (TjAskHistorys tjAskHistorys : tjAskMedicalHistory.getTjAskHistorysList()) {
                    tjAskHistorys.setAskId(tjAskMedicalHistory.getAskId());
                    if (!historysService.saveOrUpdate(tjAskHistorys)){
                        return AjaxResult.error();
                    }
                }
            }
            return AjaxResult.success("操作成功!");
        }
        return AjaxResult.error("操作失败!");
    }
}