zjh
2024-12-04 decc3b9ce027fe35152b8b387a056c175a9aa08f
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
package com.ltkj.web.controller.system;
 
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
 
import cn.hutool.extra.pinyin.PinyinUtil;
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.DictHosp;
import com.ltkj.hosp.domain.DictSfxm;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.domain.TjOrder;
import com.ltkj.hosp.service.IDictHospService;
import com.ltkj.hosp.service.IDictSfxmService;
import com.ltkj.hosp.service.TjAsyncService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.aspectj.weaver.AjAttribute;
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-03-22
 */
@RestController
@RequestMapping("/system/sfxm")
@Api(tags = "收费项目管理")
public class DictSfxmController extends BaseController {
    @Resource
    private IDictSfxmService dictSfxmService;
    @Resource
    private IDictHospService dictHospService;
    @Resource
    private RedisCache redisCache;
    @Resource
    private TjAsyncService asyncService;
 
    /**
     * 查询收费项目列表
     */
//    @PreAuthorize("@ss.hasPermi('system:sfxm:list')")
    @PostMapping("/list")
    @ApiOperation(value = "查询")
    public TableDataInfo list(@RequestBody DictSfxm dictSfxm) {
        startPage();
        String pym = dictSfxm.getPym();
        if(null !=pym && !"".equals(pym)) {
            pym=dictSfxm.getPym().toUpperCase(Locale.ROOT);
            dictSfxm.setPym(pym);
        }
        List<DictSfxm> list = dictSfxmService.selectDictSfxmList(dictSfxm);
        if (null != list && list.size() > 0) {
            for (DictSfxm sfxm : list) {
                DictHosp hosp = dictHospService.getById(sfxm.getYqid());
                if (null != hosp) {
                    sfxm.setYqName(hosp.getHospAreaName());
                }
            }
        }
        return getDataTable(list);
    }
 
    /**
     * 导出收费项目列表
     */
//    @PreAuthorize("@ss.hasPermi('system:sfxm:export')")
    @Log(title = "收费项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出")
    public void export(HttpServletResponse response, DictSfxm dictSfxm) {
        List<DictSfxm> list = dictSfxmService.selectDictSfxmList(dictSfxm);
        ExcelUtil<DictSfxm> util = new ExcelUtil<DictSfxm>(DictSfxm.class);
        util.exportExcel(response, list, "收费项目数据");
    }
 
    /**
     * 获取收费项目详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:sfxm:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "详情信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(dictSfxmService.selectDictSfxmById(id));
    }
 
    /**
     * 新增收费项目
     */
//    @PreAuthorize("@ss.hasPermi('system:sfxm:add')")
    @Log(title = "收费项目", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增")
    public AjaxResult add(@RequestBody DictSfxm dictSfxm) {
        asyncService.getDictSfxms();
        dictSfxm.setWbm(MatchUtils.toWubi(dictSfxm.getXmmc()));
        dictSfxm.setPym(PinyinUtil.getFirstLetter(dictSfxm.getXmmc(),"").toUpperCase(Locale.ROOT));
        return toAjax(dictSfxmService.insertDictSfxm(dictSfxm));
    }
 
    /**
     * 修改收费项目
     */
//    @PreAuthorize("@ss.hasPermi('system:sfxm:edit')")
    @Log(title = "收费项目", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改")
    public AjaxResult edit(@RequestBody DictSfxm dictSfxm) {
        asyncService.getDictSfxms();
        return toAjax(dictSfxmService.updateDictSfxm(dictSfxm));
    }
 
    /**
     * 删除收费项目
     */
//    @PreAuthorize("@ss.hasPermi('system:sfxm:remove')")
    @Log(title = "收费项目", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除")
    public AjaxResult remove(@PathVariable Long[] ids) {
        asyncService.getDictSfxms();
        return toAjax(dictSfxmService.deleteDictSfxmByIds(ids));
    }
 
 
    @GetMapping("/getList")
    @ApiOperation(value = "按照项目编码树形查询")
    public AjaxResult getList() {
        if(redisCache.hasKey("getDictSfxms")){
            List<DictSfxm> getDictSfxms = redisCache.getCacheObject("getDictSfxms");
            return AjaxResult.success(getDictSfxms);
        }
        List<DictSfxm> dictSfxms = getDictSfxms();
        return AjaxResult.success(dictSfxms);
    }
 
    private List<DictSfxm> getDictSfxms() {
        List<DictSfxm> dictSfxms = dictSfxmService.getYjDictSfxmList();
        if (null != dictSfxms && dictSfxms.size() > 0) {
            for (DictSfxm dictSfxm : dictSfxms) {
                List<DictSfxm> sfxms = dictSfxmService.getEjDictSfxmList(dictSfxm.getId());
                if (null != sfxms && sfxms.size() > 0) {
                    for (DictSfxm sfxm : sfxms) {
                        List<DictSfxm> sfx = dictSfxmService.getSjDictSfxmList(dictSfxm.getId());
                        sfxm.setDictSfxms(sfx);
                    }
                }
                dictSfxm.setDictSfxms(sfxms);
            }
        }
        return dictSfxms;
    }
 
 
    @GetMapping("/getListByXmId")
    @ApiOperation(value = "按照项目主键查询项目信息")
    public AjaxResult getListByXmbm(@RequestParam @ApiParam(value = "项目主键id") String id,
                                    @ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page,
                                    @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize) {
        DictSfxm service = dictSfxmService.getById(id);
        String xmbm = null;
        if (null != service) {
            xmbm = service.getXmbm();
        }
        Map<String, Object> map = new HashMap<>();
        if (null != xmbm && xmbm.length() == 2) {
            List<DictSfxm> sfxms = dictSfxmService.getEjDictSfxmList(service.getId());
            if (null != sfxms && sfxms.size() > 0) {
                for (DictSfxm sfxm : sfxms) {
                    List<DictSfxm> sfx = dictSfxmService.getSjDictSfxmList(service.getId());
                    sfxm.setDictSfxms(sfx);
                }
                List<DictSfxm> sfxmList = sfxms.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                Collections.reverse(sfxmList);
                map.put("date", sfxmList);
                map.put("total", sfxms.size());
            } else {
                map.put("date", 0);
                map.put("total", 0);
            }
            return AjaxResult.success(map);
        }
        if (null != xmbm && xmbm.length() == 4) {
            List<DictSfxm> sfx = dictSfxmService.getSjDictSfxmList(service.getId());
            if (null != sfx && sfx.size() > 0) {
                List<DictSfxm> sfxmList = sfx.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                if (null != sfxmList && sfxmList.size() > 0) {
                    for (DictSfxm sfxm : sfxmList) {
                        DictHosp hosp = dictHospService.getById(sfxm.getYqid());
                        if (null != hosp) {
                            sfxm.setYqName(hosp.getHospAreaName());
                        }
                    }
                }
                Collections.reverse(sfxmList);
                map.put("date", sfxmList);
                map.put("total", sfx.size());
            } else {
                map.put("date", 0);
                map.put("total", 0);
            }
            return AjaxResult.success(map);
        }
        return AjaxResult.success(map);
    }
 
 
//    /**
//     * 查询收费项目列表
//     */
//    @PostMapping("/getSfxmList")
//    @ApiOperation(value = "查询")
//    public AjaxResult getSfxmList(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page,
//                              @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
//                              @ApiParam(value = "拼音码") @RequestParam(required = false) String pym,
//                              @ApiParam(value = "名称") @RequestParam(required = false) String xmmc,
//                              @ApiParam(value = "id") @RequestParam(required = false) String id) {
//        Map<String, Object> map = new HashMap<>();
//        List<DictSfxm> collect = null;
//        LambdaQueryWrapper<DictSfxm> wq=new LambdaQueryWrapper<>();
//        if(null !=pym && !"".equals(pym)) {
//            pym=pym.toUpperCase(Locale.ROOT);
//            wq.like(DictSfxm::getPym,pym);
//        }
//        if(null !=xmmc && !"".equals(xmmc)) {
//            wq.like(DictSfxm::getXmmc,xmmc);
//        }
//        if(null !=id && !"".equals(id)) {
//            wq.like(DictSfxm::getId,id);
//        }
//        List<DictSfxm> list = dictSfxmService.list(wq);
//        if (null != list && list.size() > 0) {
//            for (DictSfxm sfxm : list) {
//                DictHosp hosp = dictHospService.getById(sfxm.getYqid());
//                if (null != hosp) {
//                    sfxm.setYqName(hosp.getHospAreaName());
//                }
//            }
//        }
//        collect = list.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
//        if (null != collect) {
//            map.put("total", collect.size());
//        } else {
//            map.put("total", 0);
//        }
//        map.put("list", collect);
//        return AjaxResult.success(map);
//    }
}