zjh
2023-11-02 23bc1f7e7728f05d5df625427c9f5e435493c5d8
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
package com.ltkj.web.controller.system;
 
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.service.*;
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-08-30
 */
@RestController
@RequestMapping("/hosp/rules")
@Api(tags = "规则+病种接口")
public class TjRulesController extends BaseController {
    @Autowired
    private ITjRulesService tjRulesService;
 
    @Autowired
    private ITjRuleAdviceService tjRuleAdviceService;
 
    @Resource
    private ITjOrderService orderService;
 
    @Resource
    private ITjCustomerService customerService;
 
    @Autowired
    private ITjGroupingProService groupingProService;
    @Resource
    private ITjProjectService projectService;
 
    /**
     * 查询规则+病种列表
     */
    //@PreAuthorize("@ss.hasPermi('hosp:rules:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询规则+病种列表")
    public TableDataInfo list(TjRules tjRules) {
        startPage();
        LambdaQueryWrapper<TjRules> wq=new LambdaQueryWrapper<>();
        if (tjRules.getProId()!=null){
            wq.eq(TjRules::getProId,tjRules.getProId());
        }
        if (tjRules.getProName()!=null){
            wq.like(TjRules::getProName,tjRules.getProName());
        }
        if (tjRules.getRuleType()!=null){
            wq.eq(TjRules::getRuleType,tjRules.getRuleType());
        }
        if (tjRules.getRuleStr()!=null){
            wq.like(TjRules::getRuleStr,tjRules.getRuleStr());
        }
        if (tjRules.getBingzhong()!=null){
            wq.like(TjRules::getBingzhong,tjRules.getBingzhong());
        }
        if (tjRules.getBzPinyin()!=null){
            wq.like(TjRules::getBzPinyin,tjRules.getBzPinyin());
        }
        if (tjRules.getSex()!=null){
            wq.eq(TjRules::getSex,tjRules.getSex());
        }
        wq.orderByAsc(TjRules::getSort);
        List<TjRules> list = tjRulesService.list(wq);
        if (list!=null){
            for (TjRules rules : list) {
                LambdaQueryWrapper<TjRuleAdvice> wq1=new LambdaQueryWrapper<>();
                wq1.eq(TjRuleAdvice::getBz,rules.getAid());
                final List<TjRuleAdvice> list1 = tjRuleAdviceService.list(wq1);
                rules.setRuleAdvices(list1);
            }
        }
        return getDataTable(list);
    }
 
 
    /**
     * 查询规则+病种列表
     */
    @GetMapping("/listByRuleStr")
    @ApiOperation(value = "查询规则+病种列表")
    public TableDataInfo listByRuleStr(@ApiParam(value = "项目id") @RequestParam String proId,
                                       @ApiParam(value = "体检号") @RequestParam String tjNumber,
                                       @ApiParam(value = "体检号") @RequestParam String ruleStr) {
        TjOrder one = orderService.getOrderByTjNum(tjNumber);
        TjCustomer customer = customerService.getById(one.getUserId());
        LambdaQueryWrapper<TjRules> wq=new LambdaQueryWrapper<>();
        if (proId!=null){
            wq.eq(TjRules::getProId,proId);
        }
        if (ruleStr!=null){
            wq.like(TjRules::getRuleStr,ruleStr);
        }
        if (customer.getCusSex()!=null){
            wq.eq(TjRules::getSex,customer.getCusSex());
        }
        wq.orderByAsc(TjRules::getSort);
        List<TjRules> list = tjRulesService.list(wq);
        if (list!=null){
            for (TjRules rules : list) {
                LambdaQueryWrapper<TjRuleAdvice> wq1=new LambdaQueryWrapper<>();
                wq1.eq(TjRuleAdvice::getBz,rules.getAid());
                final List<TjRuleAdvice> list1 = tjRuleAdviceService.list(wq1);
                rules.setRuleAdvices(list1);
            }
        }
        return getDataTable(list);
    }
 
    /**
     * 导出规则+病种列表
     */
    //@PreAuthorize("@ss.hasPermi('hosp:rules:export')")
    @Log(title = "规则+病种", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出规则+病种列表")
    public void export(HttpServletResponse response, TjRules tjRules) {
        LambdaQueryWrapper<TjRules> wq=new LambdaQueryWrapper<>();
        if (tjRules.getProName()!=null){
            wq.like(TjRules::getProName,tjRules.getProName());
        }
        if (tjRules.getRuleType()!=null){
            wq.eq(TjRules::getRuleType,tjRules.getRuleType());
        }
        if (tjRules.getBingzhong()!=null){
            wq.like(TjRules::getBingzhong,tjRules.getBingzhong());
        }
        if (tjRules.getBzPinyin()!=null){
            wq.like(TjRules::getBzPinyin,tjRules.getBzPinyin());
        }
        if (tjRules.getSex()!=null){
            wq.eq(TjRules::getSex,tjRules.getSex());
        }
        List<TjRules> list = tjRulesService.list(wq);
        ExcelUtil<TjRules> util = new ExcelUtil<TjRules>(TjRules.class);
        util.exportExcel(response, list, "规则+病种数据");
    }
 
    /**
     * 获取规则+病种详细信息
     */
    //@PreAuthorize("@ss.hasPermi('hosp:rules:query')")
    @GetMapping(value = "/{aid}")
    @ApiOperation(value = "获取规则+病种详细信息")
    public AjaxResult getInfo(@PathVariable("aid") String aid) {
        return success(tjRulesService.getById(aid));
    }
 
    /**
     * 新增规则+病种
     */
    // @PreAuthorize("@ss.hasPermi('hosp:rules:add')")
    @Log(title = "规则+病种", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增规则+病种")
    public AjaxResult add(@RequestBody TjRules tjRules) {
        return toAjax(tjRulesService.save(tjRules));
    }
 
    /**
     * 修改规则+病种
     */
    //@PreAuthorize("@ss.hasPermi('hosp:rules:edit')")
    @Log(title = "规则+病种", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改规则+病种")
    public AjaxResult edit(@RequestBody TjRules tjRules) {
        return toAjax(tjRulesService.saveOrUpdate(tjRules));
    }
 
    /**
     * 删除规则+病种
     */
    //@PreAuthorize("@ss.hasPermi('hosp:rules:remove')")
    @Log(title = "规则+病种", businessType = BusinessType.DELETE)
    @DeleteMapping("/{aids}")
    @ApiOperation(value = "删除规则+病种")
    public AjaxResult remove(@PathVariable String[] aids) {
        for (String aid : aids) {
            tjRulesService.removeById(aid);
        }
        return toAjax(true);
    }
}