zjh
2025-02-06 ce4202406542566234c53c9ed85bd1a03ed47a55
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
218
219
220
221
222
package com.ltkj.web.controller.system;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.common.core.redis.RedisCache;
import com.ltkj.framework.config.MatchUtils;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.dto.SaveTjPureToneTestDetil;
import com.ltkj.hosp.service.*;
import com.ltkj.system.service.ISysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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.common.utils.poi.ExcelUtil;
import com.ltkj.common.core.page.TableDataInfo;
 
/**
 * 纯音听阈测试Controller
 *
 * @author ltkj_赵佳豪&李格
 * @date 2023-04-12
 */
@RestController
@RequestMapping("/pureToneTest/pureToneTest")
@Api(tags = "C==============纯音听阈测试")
public class TjPureToneTestController extends BaseController {
    @Resource
    private ITjPureToneTestService tjPureToneTestService;
    @Resource
    private ITjCustomerService customerService;
    @Autowired
    private ISysConfigService configService;
    @Resource
    private ITjOrderService orderService;
    @Resource
    private TjPureToneTestDetilService toneTestDetilService;
    @Autowired
    private ITjAskWorkLogService tjAskWorkLogService;
    @Resource
    private ITjOrderRemarkService remarkService;
 
 
    @PostMapping("/saveTjPureToneTestDetil")
    @ApiOperation(value = "保存纯音听阈结果测定值接口")
    public AjaxResult saveTjPureToneTestDetil(@RequestBody SaveTjPureToneTestDetil detil) {
        if(null !=detil.getPureToneTestDetils() && detil.getPureToneTestDetils().size()>0){
            String pureTestId = detil.getPureToneTestDetils().get(0).getPureTestId();
            if(null==pureTestId){
                return AjaxResult.error("参数格式有误请检查核对!");
            }
            toneTestDetilService.deletedTjPureToneTestDetilByPureTestId(pureTestId);
            toneTestDetilService.saveBatch(detil.getPureToneTestDetils());
            String selectConfigByKey = configService.selectConfigByKey("cyty_pro_id");
            if(null !=selectConfigByKey){
                TjOrderRemark orderRemark = remarkService.getTjOrderRemarkByTjNumAndProParentId(detil.getTjNum(),selectConfigByKey);
                if(null !=orderRemark){
                    orderRemark.setRemark(detil.getRemark());
                    orderRemark.setDoctorName(detil.getDoctorName());
                    remarkService.updateById(orderRemark);
                }
            }
            return AjaxResult.success();
        }
        return AjaxResult.error("请输入数据!");
    }
 
    @GetMapping("/getTjPureToneTestDetilList")
    @ApiOperation(value = "获取纯音听阈结果测定值接口")
    public AjaxResult getTjPureToneTestDetilList(@RequestParam String pureTestId,@RequestParam String tjNum) {
        Map<String,Object> map=new HashMap<>();
        map.put("detilList",null);
        map.put("remark",null);
        map.put("doctorName",null);
        String selectConfigByKey = configService.selectConfigByKey("cyty_pro_id");
        if(null !=selectConfigByKey){
            TjOrderRemark orderRemark = remarkService.getTjOrderRemarkByTjNumAndProParentId(tjNum,selectConfigByKey);
            if(null !=orderRemark){
                map.put("remark",orderRemark.getRemark());
                map.put("doctorName",orderRemark.getDoctorName());
            }
        }
        List<TjPureToneTestDetil> detilList = toneTestDetilService.list(new LambdaQueryWrapper<TjPureToneTestDetil>().eq(TjPureToneTestDetil::getPureTestId, pureTestId));
        map.put("detilList",detilList);
        return AjaxResult.success(map);
    }
 
 
 
    /**
     * 查询纯音听阈测试列表
     */
    //@PreAuthorize("@ss.hasPermi('pureToneTest:pureToneTest:list')")
    @GetMapping("/list")
    @ApiOperation(value = "纯音听阈查询(默认自带)")
    public TableDataInfo list(TjPureToneTest tjPureToneTest) {
        startPage();
        List<TjPureToneTest> list = tjPureToneTestService.selectTjPureToneTestList(tjPureToneTest);
        return getDataTable(list);
    }
 
 
    @GetMapping("/getList")
    @ApiOperation(value = "纯音听阈查询(非自带)")
    public AjaxResult getList(@RequestParam(required = false) @ApiParam(value = "体检号") String tjNum,
                              @RequestParam(required = false) @ApiParam(value = "客户姓名") String name,
                              @ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum,
                              @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize)
    {
        LambdaQueryWrapper<TjPureToneTest> wq=new LambdaQueryWrapper<>();
        if(null !=tjNum)wq.eq(TjPureToneTest::getTjNum,tjNum);
        if(null !=name)wq.like(TjPureToneTest::getCusName,name);
        wq.orderByDesc(TjPureToneTest::getCreateTime);
        List<TjPureToneTest> list = tjPureToneTestService.list(wq);
        List<Map<String,Object>> arrayList=new ArrayList<>();
        if(null !=list && list.size()>0){
            Map<String, List<TjPureToneTest>> stringListMap = list.stream().collect(Collectors.groupingBy(TjPureToneTest::getCusId));
            for (Map.Entry<String, List<TjPureToneTest>> entry : stringListMap.entrySet()) {
                Map<String,Object>map=new HashMap<>();
                TjCustomer customer = customerService.getById(entry.getKey());
                if(customer==null) continue;
                customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
                customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
                customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
                customer.setTjNumber(entry.getValue().get(0).getTjNum());
                TjOrder order = orderService.getOrderByTjNum(entry.getValue().get(0).getTjNum());
                if(null !=order){
                    customer.setTjTime(order.getCreateTime());
                    customer.setTjType(order.getTjCategory());
                }
                LambdaQueryWrapper<TjAskWorkLog> wqq = new LambdaQueryWrapper<>();
                wqq.eq(TjAskWorkLog::getTjNumber, customer.getTjNumber());
                List<TjAskWorkLog> workLogs = tjAskWorkLogService.list(wqq);
                if(null !=workLogs && workLogs.size()>0){
                    customer.setWorkLogs(workLogs);
                }
                map.put("list",entry.getValue());
                map.put("customer",customer);
                map.put("picturePath",configService.selectConfigByKey("TjPureToneTest"));
                arrayList.add(map);
            }
        }
        List<Map<String, Object>> collect =null;
        Map<String,Object>map=new HashMap<>();
        if(arrayList.size()>0){
            collect = arrayList.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
        }
        map.put("list",collect);
        map.put("total",arrayList.size());
        return AjaxResult.success(map);
    }
 
 
    /**
     * 导出纯音听阈测试列表
     */
    //@PreAuthorize("@ss.hasPermi('pureToneTest:pureToneTest:export')")
    @Log(title = "纯音听阈测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出纯音听阈测试列表")
    public void export(HttpServletResponse response, TjPureToneTest tjPureToneTest) {
        List<TjPureToneTest> list = tjPureToneTestService.selectTjPureToneTestList(tjPureToneTest);
        ExcelUtil<TjPureToneTest> util = new ExcelUtil<TjPureToneTest>(TjPureToneTest.class);
        util.exportExcel(response, list, "纯音听阈测试数据");
    }
 
    /**
     * 获取纯音听阈测试详细信息
     */
    //@PreAuthorize("@ss.hasPermi('pureToneTest:pureToneTest:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取纯音听阈测试详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(tjPureToneTestService.selectTjPureToneTestById(id));
    }
 
    /**
     * 新增纯音听阈测试
     */
    //@PreAuthorize("@ss.hasPermi('pureToneTest:pureToneTest:add')")
    @Log(title = "纯音听阈测试", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增纯音听阈测试")
    public AjaxResult add(@RequestBody TjPureToneTest tjPureToneTest) {
        return toAjax(tjPureToneTestService.insertTjPureToneTest(tjPureToneTest));
    }
 
    /**
     * 修改纯音听阈测试
     */
    //@PreAuthorize("@ss.hasPermi('pureToneTest:pureToneTest:edit')")
    @Log(title = "纯音听阈测试", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改纯音听阈测试")
    public AjaxResult edit(@RequestBody TjPureToneTest tjPureToneTest) {
        return toAjax(tjPureToneTestService.updateTjPureToneTest(tjPureToneTest));
    }
 
    /**
     * 删除纯音听阈测试
     */
    //@PreAuthorize("@ss.hasPermi('pureToneTest:pureToneTest:remove')")
    @Log(title = "纯音听阈测试", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除纯音听阈测试")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tjPureToneTestService.deleteTjPureToneTestByIds(ids));
    }
}