zjh
2025-06-20 ac544c1d85c53e7f51e4ea76aa2489a14aef03d9
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
package com.ltkj.web.controller.api;
 
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.domain.TjOrder;
import com.ltkj.hosp.mapper.TjCustomerMapper;
import com.ltkj.hosp.service.ITjOrderService;
import com.ltkj.web.controller.system.TjCheckController;
import com.ltkj.web.controller.system.TjReportController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * @Company: 西安路泰科技有限公司
 * @Author: zhaowenxuan
 * @Date: 2025/2/18 10:59
 */
@RequestMapping("/api")
@RestController
public class DefaultController {
 
    @Autowired
    private TjReportController tjReportController;
    @Autowired
    private TjCheckController tjCheckController;
    @Autowired
    private TjCustomerMapper tjCustomerMapper;
    @Autowired
    private ITjOrderService tjOrderService;
 
    /**
     * 提供给三方调用的报告查看接口
     * @param response
     * @param json
     */
    @PostMapping("/viewReport")
    public void viewReport(HttpServletResponse response, @RequestBody String json) throws IOException {
        JSONObject entries = JSONUtil.parseObj(json);
        String tjNum = entries.getStr("tjNum");
        LambdaQueryWrapper<TjOrder> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TjOrder::getHeshouStatus,1);
        wrapper.eq(TjOrder::getTjNumber,tjNum);
        List<TjOrder> list = tjOrderService.list(wrapper);
        if (list.isEmpty()){
            return;
        }
        tjReportController.preview(response,true,tjNum);
    }
 
    /**
     * 提供给三方调用的报告数据接口
     * @param json
     * @return
     */
    @PostMapping("/reportData")
    public AjaxResult reportData(@RequestBody String json){
        String tjNum = JSONUtil.parseObj(json).getStr("tjNum");
        LambdaQueryWrapper<TjOrder> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TjOrder::getHeshouStatus,1);
        wrapper.eq(TjOrder::getTjNumber,tjNum);
        List<TjOrder> list = tjOrderService.list(wrapper);
        if (list.isEmpty()){
            return AjaxResult.error("暂无数据!!");
        }
        JSONObject entries = JSONUtil.parseObj(tjCheckController.updateCheckType(tjNum));
        removeNullFields(entries);
        return JSONUtil.toBean(entries, AjaxResult.class);
    }
 
    /**
     * 根据身份证号查询返回体检记录:包含姓名、身份证号、性别、出生日期、年龄、体检号、联系电话,体检日期,报告状态
     * @param json
     * @return
     */
    @PostMapping("/getInfo")
    public AjaxResult getInfo(@RequestBody String json){
        JSONObject entries = JSONUtil.parseObj(json);
        String card = entries.getStr("card");
//        TjCustomer customer = tjCustomerMapper.getCusInfo(card);
        List<Map<String ,Object>> customer = tjCustomerMapper.getCusInfoList(card);
        return AjaxResult.success(customer);
    }
 
    /**
     * 对于小程序提供
     * 根据身份证号查询返回体检记录:包含姓名、身份证号、性别、出生日期、年龄、体检号、联系电话,体检日期,报告状态
     * @param json
     * @return
     */
    @PostMapping("/getCusInfo")
    public AjaxResult getInfoCus(@RequestBody String json){
        JSONObject entries = JSONUtil.parseObj(json);
        String card = entries.getStr("card");
        String name = entries.getStr("name");
        List<Map<String ,Object>> customer = tjCustomerMapper.getCusInfoListByCardAndName(card,name);
        return AjaxResult.success(customer);
    }
 
    public static void removeNullFields(JSONObject jsonObject) {
        ArrayList<String> strings = new ArrayList<>();
        strings.add("orderId");
        strings.add("updateTime");
        strings.add("orderDetailId");
        strings.add("flowingWaterId");
        strings.add("createBy");
        strings.add("deleted");
        strings.add("createTime");
        strings.add("updateBy");
        strings.add("createId");
        strings.add("prosId");
        strings.add("params");
 
        List<String> keysToRemove = new ArrayList<>();
        jsonObject.forEach((key, value) -> {
            if (strings.contains(key)) {
                keysToRemove.add(key);
            } else if (value == null) {
                keysToRemove.add(key);
            } else if (value instanceof JSONObject) {
                removeNullFields((JSONObject) value);
            } else if (value instanceof JSONArray) {
                JSONArray jsonArray = (JSONArray) value;
                for (Object arrayItem : jsonArray) {
                    if (arrayItem instanceof JSONObject) {
                        removeNullFields((JSONObject) arrayItem);
                    }
                }
            }
        });
        for (String key : keysToRemove) {
            jsonObject.remove(key);
        }
    }
 
}