1
lige
2023-12-04 77b51f625a13a8254eb2e8a9aa53bacf575f7274
ltkj-admin/src/main/java/com/ltkj/web/controller/system/DictSfxmController.java
@@ -1,18 +1,19 @@
package com.ltkj.web.controller.system;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.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.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;
@@ -41,15 +42,24 @@
    private IDictSfxmService dictSfxmService;
    @Resource
    private IDictHospService dictHospService;
    @Resource
    private RedisCache redisCache;
    @Resource
    private TjAsyncService asyncService;
    /**
     * 查询收费项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:sfxm:list')")
//    @PreAuthorize("@ss.hasPermi('system:sfxm:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询")
    public TableDataInfo list(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) {
@@ -65,7 +75,7 @@
    /**
     * 导出收费项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:sfxm:export')")
//    @PreAuthorize("@ss.hasPermi('system:sfxm:export')")
    @Log(title = "收费项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出")
@@ -78,7 +88,7 @@
    /**
     * 获取收费项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sfxm:query')")
//    @PreAuthorize("@ss.hasPermi('system:sfxm:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "详情信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
@@ -88,33 +98,38 @@
    /**
     * 新增收费项目
     */
    @PreAuthorize("@ss.hasPermi('system:sfxm:add')")
//    @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')")
//    @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')")
//    @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));
    }
@@ -122,6 +137,15 @@
    @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) {
@@ -135,7 +159,7 @@
                dictSfxm.setDictSfxms(sfxms);
            }
        }
        return AjaxResult.success(dictSfxms);
        return dictSfxms;
    }
@@ -171,6 +195,14 @@
            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());