Bläddra i källkod

人事基础字典维护

hsh 1 år sedan
förälder
incheckning
5505cdb9e3

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

@@ -9,6 +9,7 @@ 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.ZdUnitClass;
 import thyyxxk.webserver.entity.dictionary.ZdUnitCode;
 import thyyxxk.webserver.service.dictionary.PersonnelDictService;
 
@@ -67,4 +68,19 @@ public class PersonnelDictController {
         return service.delDeptDictByCode(code);
     }
 
+    @GetMapping("/selectDeptClass")
+    public ResultVo<List<ZdUnitClass>> selectDeptClass(){
+        return service.selectDeptClass();
+    }
+
+    @PostMapping("/saveDeptClass")
+    public ResultVo<Map<String, Object>> saveDeptClass(@RequestBody @Validated ZdUnitClass zdUnitclass){
+        return service.saveDeptClass(zdUnitclass);
+    }
+
+    @GetMapping("/delDeptClassByCode")
+    public ResultVo<Map<String, Object>> delDeptClassByCode(@RequestParam("code") String code){
+        return service.delDeptClassByCode(code);
+    }
+
 }

+ 43 - 0
src/main/java/thyyxxk/webserver/dao/his/dictionary/ZdUnitClassDao.java

@@ -0,0 +1,43 @@
+package thyyxxk.webserver.dao.his.dictionary;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.entity.dictionary.ZdUnitClass;
+
+import java.util.List;
+
+public interface ZdUnitClassDao extends BaseMapper<ZdUnitClass> {
+
+    @Select(" select * from zd_unit_class ")
+    List<ZdUnitClass> selectDeptClass();
+
+    @Select(" select * from zd_unit_class where code = #{code} ")
+    ZdUnitClass selectDeptClassByCode(@Param("code") String code);
+
+    @Update("<script>" +
+            "update zd_unit_class " +
+            "<trim prefix=\"set\" suffixOverrides=\",\">" +
+            "<if test=\"code != null\">" +
+            "code = #{code}, " +
+            "</if>" +
+            "<if test=\"name != null \">" +
+            "name = #{name}, " +
+            "</if>" +
+            "<if test=\"pyCode != null\">" +
+            "py_code = #{pyCode}, " +
+            "</if>" +
+            "<if test=\"dCode != null\">" +
+            "d_code = #{dCode}, " +
+            "</if>" +
+            "</trim>" +
+            "where code = #{code} " +
+            "</script>")
+    int updateDeptClassByCode(ZdUnitClass zdUnitClass);
+
+    @Delete(" delete from zd_unit_class where code = #{code} ")
+    int deleteDeptClassByCode(@Param("code") String code);
+
+}

+ 25 - 0
src/main/java/thyyxxk/webserver/entity/dictionary/ZdUnitClass.java

@@ -0,0 +1,25 @@
+package thyyxxk.webserver.entity.dictionary;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @ClassName ZdUnitClass
+ * @Author hsh
+ * @Date 2023/11/16 17:01
+ * @Version 1.0
+ * @Description 科室分类字典
+ **/
+@Data
+@TableName(value = "zd_unit_class")
+public class ZdUnitClass implements Serializable {
+    private static final long serialVersionUID = -1L;
+
+    private String code;
+    private String name;
+    private String pyCode;
+    private String dCode;
+
+}

+ 77 - 2
src/main/java/thyyxxk/webserver/service/dictionary/PersonnelDictService.java

@@ -5,12 +5,18 @@ 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.ZdUnitClassDao;
 import thyyxxk.webserver.dao.his.dictionary.ZdUnitCodeDao;
 import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.dictionary.ZdUnitClass;
 import thyyxxk.webserver.entity.dictionary.ZdUnitCode;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
-import thyyxxk.webserver.utils.*;
+import thyyxxk.webserver.utils.DateUtil;
+import thyyxxk.webserver.utils.PingYinUtils;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
+import thyyxxk.webserver.utils.TokenUtil;
 
 import java.util.HashMap;
 import java.util.List;
@@ -32,11 +38,14 @@ public class PersonnelDictService {
 
     private final RedisLikeService redis;
 
+    private final ZdUnitClassDao deptClassDao;
+
     @Autowired
-    public PersonnelDictService(PersonnelDictDao dao, ZdUnitCodeDao deptDao, RedisLikeService redis) {
+    public PersonnelDictService(PersonnelDictDao dao, ZdUnitCodeDao deptDao, RedisLikeService redis, ZdUnitClassDao deptClassDao) {
         this.dao = dao;
         this.deptDao = deptDao;
         this.redis = redis;
+        this.deptClassDao = deptClassDao;
     }
 
     /**
@@ -179,4 +188,70 @@ public class PersonnelDictService {
         }
     }
 
+    /**
+     * 查询科室分类字典
+     * @return ResultVo<ZdUnitClass>
+     */
+    public ResultVo<List<ZdUnitClass>> selectDeptClass(){
+        return ResultVoUtil.success(deptClassDao.selectDeptClass());
+    }
+
+    /**
+     *  保存科室分类
+     * @param zdUnitClass 科室分类信息
+     * @return map
+     */
+    public ResultVo<Map<String, Object>> saveDeptClass(ZdUnitClass zdUnitClass){
+
+        if(null == zdUnitClass || zdUnitClass.getCode() == null){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "科室分类信息不存在,请检查!");
+        }
+
+        Map<String, Object> resultMap = new HashMap<>();
+        String code = zdUnitClass.getCode();
+        ZdUnitClass deptClass = deptClassDao.selectDeptClassByCode(code);
+
+        // 根据名称生成新的拼音码和五笔码
+        zdUnitClass.setPyCode(PingYinUtils.pyShouZiMuDaXie(zdUnitClass.getName()));
+        zdUnitClass.setDCode(PingYinUtils.getWBCode(zdUnitClass.getName()));
+        int num;
+        try{
+            if(null != deptClass){
+                num = deptClassDao.updateDeptClassByCode(zdUnitClass);
+            } else {
+                num = deptClassDao.insert(zdUnitClass);
+            }
+            if(num == 0){
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存科室分类失败!");
+            }
+            resultMap.put("cg", "保存科室分类成功!");
+            return ResultVoUtil.success(resultMap);
+        } catch(Exception e){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存科室分类失败!");
+        }
+    }
+
+    /**
+     *  根据code删除科室分类
+     * @param code 科室分类code
+     * @return map
+     */
+    public ResultVo<Map<String, Object>> delDeptClassByCode(String code) {
+        if (StringUtil.isBlank(code)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有科室分类编码,请检查!");
+        }
+
+        Map<String, Object> resultMap = new HashMap<>();
+        try{
+            int num = deptClassDao.deleteDeptClassByCode(code);
+            if(num == 0){
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除科室分类失败!");
+            }
+            resultMap.put("cg", "删除科室分类成功!");
+            return ResultVoUtil.success(resultMap);
+        } catch(Exception e){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除科室分类失败!");
+        }
+    }
+
 }

+ 2 - 2
src/main/java/thyyxxk/webserver/service/targetmanagement/TargetManagementService.java

@@ -686,13 +686,13 @@ public class TargetManagementService {
     public ResultVo<Map<String, Object>> saveTargetReportResult(List<ZbReportResult> list){
         Map<String, Object> resultMap = new HashMap<>();
 
-        if(list == null || list.size() == 0){
+        if(list == null || list.isEmpty()){
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "指标结果记录不存在,请检查!");
         }
 
         UserInfo user = redis.getUserInfoByCode(TokenUtil.getInstance().getTokenUserId());
         for (ZbReportResult result : list) {
-            result.setOp(user.getName() != null ? user.getName().trim() : user.getName());
+            result.setOp(user.getName() != null ? user.getName().trim() : null);
             result.setOpId(user.getCodeRs());
             result.setOpTime(DateUtil.now());