Browse Source

Merge branch 'master' into 'master'

新增科室字典

See merge request lighter/web-server!58
huangshuhua 1 year ago
parent
commit
3bd20cdc89

+ 61 - 0
src/main/java/thyyxxk/webserver/controller/dictionary/PersonnelDictController.java

@@ -0,0 +1,61 @@
+package thyyxxk.webserver.controller.dictionary;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.dictionary.ZdUnitCode;
+import thyyxxk.webserver.service.dictionary.PersonnelDictService;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 人事字典
+ * @Author: hsh
+ * @CreateTime: 2023-10-16  16:30
+ * @Version: 1.0
+ */
+@RestController
+@RequestMapping("/personnel")
+public class PersonnelDictController {
+
+    private final PersonnelDictService service;
+
+    @Autowired
+    public PersonnelDictController(PersonnelDictService service) {
+        this.service = service;
+    }
+
+    @GetMapping("/selectDeptDict")
+    public ResultVo<List<ZdUnitCode>> selectDeptDict(@RequestParam("text") String text){
+        return service.selectDeptDict(text);
+    }
+
+    @GetMapping("/selectDeptDictForEffective")
+    public ResultVo<List<ZdUnitCode>> selectDeptDictForEffective(){
+        return service.selectDeptDictForEffective();
+    }
+
+    @GetMapping("/selectUnitClass")
+    public ResultVo<List<Map<String, Object>>> selectUnitClass(){
+        return service.selectUnitClass();
+    }
+
+    @GetMapping("/selectDeptDictByCode")
+    public ResultVo<ZdUnitCode> selectDeptDictByCode(@RequestParam("code") String code){
+        return service.selectDeptDictByCode(code);
+    }
+
+
+    @PostMapping("/saveDeptDict")
+    public ResultVo<Map<String, Object>> saveDeptDict(@RequestBody @Validated ZdUnitCode zdUnitCode){
+        return service.saveDeptDict(zdUnitCode);
+    }
+
+}

+ 15 - 0
src/main/java/thyyxxk/webserver/dao/his/dictionary/PersonnelDictDao.java

@@ -0,0 +1,15 @@
+package thyyxxk.webserver.dao.his.dictionary;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface PersonnelDictDao {
+
+    @Select(" select cz.code, cz.name, cz.py_code, cz.d_code from zd_unit_class cz ")
+    List<Map<String, Object>> selectUnitClass();
+
+}

+ 128 - 0
src/main/java/thyyxxk/webserver/dao/his/dictionary/ZdUnitCodeDao.java

@@ -0,0 +1,128 @@
+package thyyxxk.webserver.dao.his.dictionary;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.entity.dictionary.ZdUnitCode;
+
+import java.util.List;
+
+@Mapper
+public interface ZdUnitCodeDao extends BaseMapper<ZdUnitCode> {
+
+    @Select("<script>" +
+            "  select d.* from zd_unit_code d  " +
+            "   where isnull(d.py_code,'') like '%#{text}' " +
+            "     and isnull(d.d_code,'') like '%#{text}' " +
+            "     and (isnull(d.code,'') like '%#{text}' or isnull(d.n_code,'') like '%#{text}') " +
+            "     and isnull(d.name,'') like '%#{text}' " +
+            "</script>")
+    List<ZdUnitCode> selectZdUnitCode(@Param("text") String text);
+
+    @Select("<script>" +
+            "   select d.code,   " +
+            "          d.name,   " +
+            "          d.class_code,   " +
+            "          c.name as className, " +
+            "          d.py_code,   " +
+            "          d.d_code,   " +
+            "          d.mz_flag,   " +
+            "          d.del_flag,  " +
+            "          d.n_code, " +
+            "          d.yj_flag, " +
+            "          d.mzrc_flag, " +
+            "          d.parent_code, " +
+            "          f.name as parentName, " +
+            "          '0' as new_flag, " +
+            "          d.gh_charge_flag, " +
+            "          d.xnh_dept_code, " +
+            "          d.xnh_dept_name, " +
+            "          d.supply_flag, " +
+            "          d.ghjz_flag, " +
+            "          d.office_pos " +
+            "     from zd_unit_code d with(nolock) " +
+            "left join zd_unit_class c " +
+            "       on d.class_code = c.code  " +
+            "left join zd_unit_code f with(nolock) " +
+            "       on isnull(f.del_flag,'') &lt;&gt; '1' and d.parent_code = f.code " +
+            "    where isnull(d.py_code,'') like ('%' + upper(#{text}) + '%') " +
+            "      and isnull(d.d_code,'') like ('%' + upper(#{text}) + '%') " +
+            "      and (isnull(d.code,'') like ('%' + upper(#{text}) + '%') or isnull(d.n_code,'') like '%${text}%') " +
+            "      and isnull(d.name,'') like '%${text}%' " +
+            "</script>")
+    List<ZdUnitCode> selectDeptDictAll(@Param("text") String text);
+
+    @Select(" select u.code, u.name, u.py_code, u.d_code, n_code from zd_unit_code u where isnull(del_flag,'') <> '1' ")
+    List<ZdUnitCode> selectDeptDictForEffective();
+
+    @Select(" select u.* from zd_unit_code u where u.code = #{code} ")
+    ZdUnitCode selectDeptDictByCode(@Param("code") String code);
+
+    @Update("<script>" +
+            "update zd_unit_code " +
+            "<trim prefix=\"set\" suffixOverrides=\",\">" +
+            "<if test=\"code != null\">" +
+            "id = #{code}, " +
+            "</if>" +
+            "<if test=\"name != null \">" +
+            "name = #{name}, " +
+            "</if>" +
+            "<if test=\"classCode != null\">" +
+            "class_code = #{classCode}, " +
+            "</if>" +
+            "<if test=\"pyCode != null\">" +
+            "py_code = #{pyCode}, " +
+            "</if>" +
+            "<if test=\"dCode != null\">" +
+            "d_code = #{dCode}, " +
+            "</if>" +
+            "<if test=\"mzFlag != null\">" +
+            "mz_flag = #{mzFlag}, " +
+            "</if>" +
+            "<if test=\"delFlag != null\">" +
+            "del_flag = #{delFlag}, " +
+            "</if>" +
+            "<if test=\"opId != null\">" +
+            "op_id = #{opId}, " +
+            "</if>" +
+            "<if test=\"opDate != null\">" +
+            "op_date = #{opDate}, " +
+            "</if>" +
+            "<if test=\"nCode != null\">" +
+            "n_code = #{nCode}, " +
+            "</if>" +
+            "<if test=\"yjFlag != null\">" +
+            "yj_flag = #{yjFlag}, " +
+            "</if>" +
+            "<if test=\"mzrcFlag != null\">" +
+            "mzrc_flag = #{mzrcFlag}, " +
+            "</if>" +
+            "<if test=\"parentCode != null\">" +
+            "parent_code = #{parentCode}, " +
+            "</if>" +
+            "<if test=\"ghChargeFlag != null\">" +
+            "gh_charge_flag = #{ghChargeFlag}, " +
+            "</if>" +
+            "<if test=\"xnhDeptCode != null\">" +
+            "xnh_dept_code = #{xnhDeptCode}, " +
+            "</if>" +
+            "<if test=\"xnhDeptName != null\">" +
+            "xnh_dept_name = #{xnhDeptName}, " +
+            "</if>" +
+            "<if test=\"supplyFlag != null\">" +
+            "supply_flag = #{supplyFlag}, " +
+            "</if>" +
+            "<if test=\"ghjzFlag != null\">" +
+            "ghjz_flag = #{ghjzFlag}, " +
+            "</if>" +
+            "<if test=\"officePos != null\">" +
+            "office_pos = #{officePos}, " +
+            "</if>" +
+            "</trim>" +
+            "where code = #{code} " +
+            "</script>")
+    int updateDeptDictByCode(ZdUnitCode zdUnitCode);
+
+}

+ 71 - 0
src/main/java/thyyxxk/webserver/entity/dictionary/ZdUnitCode.java

@@ -0,0 +1,71 @@
+package thyyxxk.webserver.entity.dictionary;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @Description: 科室字典表
+ * @Author: hsh
+ * @CreateTime: 2023-10-16  15:01
+ * @Version: 1.0
+ */
+@Data
+@TableName(value = "zd_unit_code")
+public class ZdUnitCode implements Serializable {
+
+    private static final long serialVersionUID = -1L;
+
+    private String code;
+    private String name;
+    private String classCode;
+    private String pyCode;
+    private String dCode;
+    private String mzFlag;
+    private String delFlag;
+    private String nCode;
+    private String upperUnit1;
+    private String upperName1;
+    private String kqksCode;
+    private String kqksName;
+    private String flag;
+    private String abbnm;
+    private String yjFlag;
+    private String mzrcFlag;
+    private String parentCode;
+    private String sqFlag;
+    private String ghChargeFlag;
+    private String officePos;
+    private String supplyFlag;
+    private String xnhDeptCode;
+    private String xnhDeptName;
+    private String ghjzFlag;
+    private String parentCodeHs;
+    private String sortCode;
+    private String opId;
+    private String opDate;
+    private String siCaty;
+    private String wjwCode;
+    private Integer inpatientFlag;
+    private Integer unitNum;
+    private BigDecimal ksZkl;
+    private Integer hzDay;
+    private String deptDescribe;
+
+    @TableField(exist = false)
+    private String newFlag;
+    /**
+     * 科室分类名称
+     **/
+    @TableField(exist = false)
+    private String className;
+    /**
+     * 父科室名称
+     **/
+    @TableField(exist = false)
+    private String parentName;
+
+}

+ 128 - 0
src/main/java/thyyxxk/webserver/service/dictionary/PersonnelDictService.java

@@ -0,0 +1,128 @@
+package thyyxxk.webserver.service.dictionary;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.dao.his.dictionary.PersonnelDictDao;
+import thyyxxk.webserver.dao.his.dictionary.ZdUnitCodeDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.dictionary.ZdUnitCode;
+import thyyxxk.webserver.entity.login.UserInfo;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.DateUtil;
+import thyyxxk.webserver.utils.PingYinUtils;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.TokenUtil;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 人事字典
+ * @Author: hsh
+ * @CreateTime: 2023-10-16  16:39
+ * @Version: 1.0
+ */
+@Service
+@Slf4j
+public class PersonnelDictService {
+
+    private final PersonnelDictDao dao;
+
+    private final ZdUnitCodeDao deptDao;
+
+    private final RedisLikeService redis;
+
+    @Autowired
+    public PersonnelDictService(PersonnelDictDao dao, ZdUnitCodeDao deptDao, RedisLikeService redis) {
+        this.dao = dao;
+        this.deptDao = deptDao;
+        this.redis = redis;
+    }
+
+    /**
+     * @description: 查询科室字典信息
+     * @author: hsh
+     * @date: 2023/10/16 16:41
+     * @param: [text]
+     * @return: ResultVo<List<ZdUnitCode>>
+     **/
+    public ResultVo<List<ZdUnitCode>> selectDeptDict(String text){
+        return ResultVoUtil.success(deptDao.selectDeptDictAll(text));
+    }
+
+    /**
+     * @description: 查询有效科室
+     * @author: hsh
+     * @date: 2023/10/17 9:48
+     * @param: []
+     * @return: ResultVo<List<ZdUnitCode>>
+     **/
+    public ResultVo<List<ZdUnitCode>> selectDeptDictForEffective(){
+        return ResultVoUtil.success(deptDao.selectDeptDictForEffective());
+    }
+
+    /**
+     * @description: 查询科室分类字典
+     * @author: hsh
+     * @date: 2023/10/17 9:48
+     * @param: []
+     * @return: ResultVo<List<Map<String,Object>>>
+     **/
+    public ResultVo<List<Map<String, Object>>> selectUnitClass(){
+        return ResultVoUtil.success(dao.selectUnitClass());
+    }
+
+    /**
+     * @description: 根据科室code查询科室字典信息
+     * @author: hsh
+     * @date: 2023/10/19 16:23
+     * @param: [code]
+     * @return: ResultVo<ZdUnitCode>
+     **/
+    public ResultVo<ZdUnitCode> selectDeptDictByCode(String code){
+        return ResultVoUtil.success(deptDao.selectDeptDictByCode(code));
+    }
+
+    /**
+     * @description: 保存或更新科室字典信息
+     * @author: hsh
+     * @date: 2023/10/20 16:25
+     * @param: [zdUnitCode]
+     * @return: ResultVo<Map<String,Object>>
+     **/
+    public ResultVo<Map<String, Object>> saveDeptDict(ZdUnitCode zdUnitCode){
+
+        if(null == zdUnitCode || zdUnitCode.getCode() == null){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "科室字典信息不存在,请检查!");
+        }
+
+        Map<String, Object> resultMap = new HashMap<>();
+        String code = zdUnitCode.getCode();
+        ZdUnitCode dept = deptDao.selectDeptDictByCode(code);
+
+        UserInfo user = redis.getUserInfoByCode(TokenUtil.getInstance().getTokenUserId());
+        // 根据名称生成新的拼音码和五笔码
+        zdUnitCode.setPyCode(PingYinUtils.pyShouZiMuDaXie(zdUnitCode.getName()));
+        zdUnitCode.setDCode(PingYinUtils.getWBCode(zdUnitCode.getName()));
+        zdUnitCode.setOpId(user.getCodeRs());
+        zdUnitCode.setOpDate(DateUtil.now());
+        int num = 0;
+        if(null != dept){
+            // 更新科室字典信息(这里仅限于更新老系统科室字典信息,其他信息修改待定)
+            num = deptDao.updateDeptDictByCode(zdUnitCode);
+        } else {
+            // 新增科室字典信息(这里仅限于新增老系统科室字典信息,其他信息新增待定)
+            num = deptDao.insert(zdUnitCode);
+        }
+        if(num == 0){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存科室字典失败!");
+        }
+        resultMap.put("cg", "保存科室字典成功!");
+        return ResultVoUtil.success(resultMap);
+    }
+
+
+}