|
@@ -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, "删除科室分类失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|