zjh
2024-01-23 3fbed744dae198ae9743f21a611e9e1ff096e0be
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 cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.vodomain.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * @Company: 西安路泰科技有限公司
 * @Author: zjh
 * @Date: 2023/9/1 09:08
 */
 
 
@RestController
@RequestMapping("/group/inspection")
@Api(tags = "团体检查接口集")
public class GroupInspectionController {
 
    @Resource
    private ITjOrderService orderService;
    @Resource
    private ITjCustomerService customerService;
    @Resource
    private ITjDwDeptService dwDeptService;
    @Resource
    private ITjDwGroupingService dwGroupingService;
    @Resource
    private ITjGroupingProService groupingProService;
    @Resource
    private ITjReservationService reservationService;
    @Resource
    private ITjRulesService tjRulesService;
    @Resource
    private ITjOrderDetailRulesService detailRulesService;
 
 
 
    @GetMapping("/getDeptAndDwDeptByComp")
    @ApiOperation(value = "根据单位查询部门和单位部门信息")
    public AjaxResult getDeptAndDwDeptByComp(@ApiParam(value = "单位") @RequestParam(required = false) Long compId){
 
        LambdaQueryWrapper<TjDwDept> wq= new LambdaQueryWrapper<>();
        if(null !=compId){
            wq.eq(TjDwDept::getDwId,compId);
        }
        List<TjDwDept> groupingList = dwDeptService.list(wq);
 
        return AjaxResult.success(groupingList);
    }
 
    @GetMapping("/getDwGroupingByDwDeptId")
    @ApiOperation(value = "根据单位部门查询单位分组信息信息")
    public AjaxResult getDwGroupingByDwDeptId(@ApiParam(value = "单位部门id") @RequestParam(required = false) String dwDeptId){
 
        LambdaQueryWrapper<TjDwGrouping> wq= new LambdaQueryWrapper<>();
        if(null !=dwDeptId){
            wq.eq(TjDwGrouping::getDwDeptId,dwDeptId);
        }
        List<TjDwGrouping> groupingList = dwGroupingService.list(wq);
        return AjaxResult.success(groupingList);
    }
 
 
 
 
    @GetMapping("/getPeopleList")
    @ApiOperation(value = "团检病种页面查询人员列表接口")
    public AjaxResult getPeopleList(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page,
                                    @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                    @ApiParam(value = "单位") @RequestParam(required = false) Long compId,
                                    @ApiParam(value = "部门)") @RequestParam(required = false) String deptName,
                                    @ApiParam(value = "部门分组id") @RequestParam(required = false) String groupingId,
                                    @ApiParam(value = "开始时间") @RequestParam(required = false) String beginTime,
                                    @ApiParam(value = "结束时间") @RequestParam(required = false) String endTime){
 
        LambdaQueryWrapper<TjReservation> wq=new LambdaQueryWrapper<>();
        wq.isNotNull(TjReservation::getTeamNo);
        if (null != beginTime && null != endTime) {
            wq.between(TjReservation::getUpdateTime,DateUtil.beginOfDay(DateUtil.parse(beginTime)),DateUtil.endOfDay(DateUtil.parse(endTime)));
        }
        if(null !=compId) wq.eq(TjReservation::getCompanyId,compId);
        if(null !=deptName)wq.like(TjReservation::getDepartment,deptName);
        if(null !=groupingId)wq.eq(TjReservation::getGroupingId,groupingId);
        List<TjReservation> reservations = reservationService.list(wq);
        List<GetPeopleListVo> reservationPage =new ArrayList<>();
        for (TjReservation record : reservations) {
            TjCustomer customer = customerService.getOne(new LambdaQueryWrapper<TjCustomer>().eq(TjCustomer::getCusIdcard, record.getIdCard()));
            if(null !=customer){
                TjOrder order = orderService.getOne(new LambdaQueryWrapper<TjOrder>().eq(TjOrder::getTeamNo, record.getTeamNo()).eq(TjOrder::getUserId,customer.getCusId()));
                if(null !=order){
                    GetPeopleListVo vo=new GetPeopleListVo();
                    vo.setTjNumber(order.getTjNumber());
                    vo.setName(record.getName());
                    vo.setSex(record.getSex());
                    vo.setDepartment(record.getDepartment());
                    vo.setAge(record.getAge());
                    vo.setCompany(record.getCompany());
                    reservationPage.add(vo);
                }
            }
        }
        List<GetPeopleListVo> voList = reservationPage.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
        Map<String, Object> map = new HashMap<>();
        map.put("voList", voList);
        map.put("total", reservationPage.size());
        return AjaxResult.success(map);
    }
 
 
    /**
     * 查询规则+病种列表
     */
    @GetMapping("/getTjRulesListByGroupingId")
    @ApiOperation(value = "团检页面查询病种字典列表")
    public AjaxResult getTjRulesListByGroupingId(@ApiParam(value = "分组id") @RequestParam(required = false) String groupingId,
                                                 @ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page,
                                                 @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize) {
        LambdaQueryWrapper<TjGroupingPro> wq= new LambdaQueryWrapper<>();
        if(null !=groupingId) wq.eq(TjGroupingPro::getGroupingId, groupingId);
        List<TjGroupingPro> proList = groupingProService.list(wq);
        Set<TjRules> list=new HashSet<>();
        if(null !=proList && proList.size()>0){
            for (TjGroupingPro tjGroupingPro : proList) {
                List<TjRules> rulesList = tjRulesService.getTjRulesListByProId(tjGroupingPro.getProId());
                if(null !=rulesList && rulesList.size()>0){
                    list.addAll(rulesList);
                }
            }
        }
        List<TjRules> rulesList = list.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
        Map<String, Object> map = new HashMap<>();
        map.put("rulesList", rulesList);
        map.put("total", list.size());
        return AjaxResult.success(map);
    }
 
 
    @PostMapping("/getTjRulesStatisticsByTjNumAndAid")
    @ApiOperation(value = "团检页面统计病种接口")
    public AjaxResult getTjRulesStatisticsByTjNumAndAid(@ApiParam(value = "体检号集合") @RequestBody TjRulesStatisticsDto dto ) {
 
        List<String> tjNums = dto.getTjNums();
        List<String> aids = dto.getAids();
 
 
        if(null==tjNums || tjNums.size()==0){
            tjNums= new ArrayList<>();
            tjNums.add("0");
        }
 
        if(null==aids || aids.size()==0){
            aids= new ArrayList<>();
            aids.add("0");
        }
        List<TjRulesStatisticsVo> list = detailRulesService.getTjRulesStatisticsByTjNumAndAid(tjNums,aids);
        return AjaxResult.success(list);
    }
 
 
 
 
    @GetMapping("/getTeamTjDwDeptTreeList")
    @ApiOperation(value = "团检页面报告管理侧面树节点")
    public AjaxResult getTeamTjDwDeptTreeList() {
        List<TjDwDept> dwDeptList = dwDeptService.getDwDeptNameList();
        List<TeamTjDwDeptVo> list=new ArrayList<>();
        if(null !=dwDeptList && dwDeptList.size()>0){
            for (TjDwDept dept : dwDeptList) {
                List<TjDwDept> deptList = dwDeptService.getDwDeptListByTjDwDeptId(dept.getDwId());
                TeamTjDwDeptVo deptVo= new TeamTjDwDeptVo();
                deptVo.setDwName(dept.getDwName());
                deptVo.setDwDepts(deptList);
                list.add(deptVo);
            }
        }
        return AjaxResult.success(list);
    }
 
 
    @GetMapping("/getTeamTjBaoGaoList")
    @ApiOperation(value = "团检页面报告管理数据查询接口")
    public AjaxResult getTeamTjBaoGaoList(@ApiParam(value = "单位部门") @RequestParam String dwDeptId,
                                          @ApiParam(value = "开始时间") @RequestParam String beginTime,
                                          @ApiParam(value = "结束时间") @RequestParam String endTime) {
        DateTime beginTimes = null;
        DateTime endTimes = null;
        if (null != beginTime && null != endTime) {
            beginTimes = DateUtil.beginOfDay(DateUtil.parse(beginTime));
            endTimes = DateUtil.endOfDay(DateUtil.parse(endTime));
        }
        List<TeamTjDwBaoGaoVo> list = dwDeptService.getTeamTjDwBaoGaoVoByTjDwDeptId(dwDeptId, beginTimes, endTimes);
        if(null !=list && list.size()>0){
            for (TeamTjDwBaoGaoVo gaoVo : list) {
                gaoVo.setStartTime(beginTimes);
                gaoVo.setEnfTime(endTimes);
            }
        }
        return AjaxResult.success(list);
    }
 
}