zjh
2024-02-29 edb81cb36ef2ff4560afdbe7918a747adbad998f
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
package com.ltkj.web.controller.system;
 
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.hosp.domain.TjProject;
import com.ltkj.hosp.domain.TjRules;
import com.ltkj.hosp.service.ITjProjectService;
import com.ltkj.hosp.service.ITjRulesService;
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.hosp.domain.TjRuleAdvice;
import com.ltkj.hosp.service.ITjRuleAdviceService;
import com.ltkj.common.utils.poi.ExcelUtil;
import com.ltkj.common.core.page.TableDataInfo;
 
/**
 * 病种+意见Controller
 *
 * @author ltkj_赵佳豪&李格
 * @date 2023-08-30
 */
@RestController
@RequestMapping("/hosp/ruleAdvice")
public class TjRuleAdviceController extends BaseController {
    @Autowired
    private ITjRulesService tjRulesService;
 
    @Autowired
    private ITjRuleAdviceService tjRuleAdviceService;
 
    @Resource
    private ITjProjectService tjProjectService;
 
    /**
     * 查询病种+意见列表
     */
    //@PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:list')")
    @GetMapping("/list")
    public TableDataInfo list(TjRuleAdvice tjRuleAdvice) {
        startPage();
        LambdaQueryWrapper<TjRuleAdvice> wq = new LambdaQueryWrapper<>();
        if (tjRuleAdvice.getBzmc() != null) {
            wq.like(TjRuleAdvice::getBzmc, tjRuleAdvice.getBzmc());
        }
        if (tjRuleAdvice.getJy() != null) {
            wq.like(TjRuleAdvice::getJy, tjRuleAdvice.getJy());
        }
        if (tjRuleAdvice.getZjf() != null) {
            wq.like(TjRuleAdvice::getZjf, tjRuleAdvice.getZjf());
        }
        List<TjRuleAdvice> list = tjRuleAdviceService.list(wq);
        return getDataTable(list);
    }
 
    /**
     * 导出病种+意见列表
     */
    //@PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:export')")
    @Log(title = "病种+意见", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TjRuleAdvice tjRuleAdvice) {
        LambdaQueryWrapper<TjRuleAdvice> wq = new LambdaQueryWrapper<>();
        if (tjRuleAdvice.getBzmc() != null) {
            wq.like(TjRuleAdvice::getBzmc, tjRuleAdvice.getBzmc());
        }
        if (tjRuleAdvice.getJy() != null) {
            wq.like(TjRuleAdvice::getJy, tjRuleAdvice.getJy());
        }
        if (tjRuleAdvice.getZjf() != null) {
            wq.like(TjRuleAdvice::getZjf, tjRuleAdvice.getZjf());
        }
        List<TjRuleAdvice> list = tjRuleAdviceService.list(wq);
        ExcelUtil<TjRuleAdvice> util = new ExcelUtil<TjRuleAdvice>(TjRuleAdvice.class);
        util.exportExcel(response, list, "病种+意见数据");
    }
 
    /**
     * 获取病种+意见详细信息
     */
    //@PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:query')")
    @GetMapping(value = "/{gid}")
    public AjaxResult getInfo(@PathVariable("gid") String gid) {
        return success(tjRuleAdviceService.getById(gid));
    }
 
    /**
     * 新增病种+意见
     */
    // @PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:add')")
    @Log(title = "病种+意见", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TjRuleAdvice tjRuleAdvice) {
        return toAjax(tjRuleAdviceService.save(tjRuleAdvice));
    }
 
    /**
     * 修改病种+意见
     */
    //@PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:edit')")
    @Log(title = "病种+意见", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TjRuleAdvice tjRuleAdvice) {
        return toAjax(tjRuleAdviceService.saveOrUpdate(tjRuleAdvice));
    }
 
    /**
     * 删除病种+意见
     */
    //@PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:remove')")
    @Log(title = "病种+意见", businessType = BusinessType.DELETE)
    @DeleteMapping("/{gids}")
    public AjaxResult remove(@PathVariable String[] gids) {
        for (String gid : gids) {
            tjRuleAdviceService.removeById(gid);
        }
        return toAjax(true);
    }
 
 
    /**
     * 根据项目id查询病种意见列表
     */
    @GetMapping("/getByProId")
    public TableDataInfo getByProId(@RequestParam(required = false) String proId) {
        startPage();
        List<TjRuleAdvice> list2 = new ArrayList<>();
        final TjProject byId = tjProjectService.getById(proId);
        if (byId.getProParentId() == 0) {
            LambdaQueryWrapper<TjProject> wqqq = new LambdaQueryWrapper<>();
            wqqq.eq(TjProject::getProParentId, byId.getProId());
            final List<TjProject> list = tjProjectService.list(wqqq);
            for (TjProject project : list) {
                LambdaQueryWrapper<TjRules> wq = new LambdaQueryWrapper<>();
                wq.eq(TjRules::getProId, project.getProId());
                wq.orderByAsc(TjRules::getSort);
                List<TjRules> list11 = tjRulesService.list(wq);
 
                for (TjRules tjRules : list11) {
                    LambdaQueryWrapper<TjRuleAdvice> wq1 = new LambdaQueryWrapper<>();
                    wq1.eq(TjRuleAdvice::getBz, tjRules.getAid());
                    List<TjRuleAdvice> list1 = tjRuleAdviceService.list(wq1);
                    list2.addAll(list1);
                }
            }
        } else {
            LambdaQueryWrapper<TjRules> wq = new LambdaQueryWrapper<>();
            if (proId != null) {
                wq.eq(TjRules::getProId, proId);
            }
            wq.orderByAsc(TjRules::getSort);
            List<TjRules> list = tjRulesService.list(wq);
            for (TjRules tjRules : list) {
                LambdaQueryWrapper<TjRuleAdvice> wq1 = new LambdaQueryWrapper<>();
                wq1.eq(TjRuleAdvice::getBz, tjRules.getAid());
                List<TjRuleAdvice> list1 = tjRuleAdviceService.list(wq1);
                list2.addAll(list1);
            }
        }
        return getDataTable(list2);
    }
}