Przeglądaj źródła

字典对接-接口补充

zdm 6 lat temu
rodzic
commit
c454145545

+ 10 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/system/SystemDictEntryVO.java

@ -30,6 +30,8 @@ public class SystemDictEntryVO extends UuidIdentityVO {
	//备注
	//备注
	@ApiModelProperty(value = "备注", example = "我是备注")
	@ApiModelProperty(value = "备注", example = "我是备注")
	private String remark;
	private String remark;
	@ApiModelProperty(value = "所属租户id", example = "1")
	private String saasId;
	public String getDictCode() {
	public String getDictCode() {
		return dictCode;
		return dictCode;
@ -78,4 +80,12 @@ public class SystemDictEntryVO extends UuidIdentityVO {
	public void setRemark(String remark) {
	public void setRemark(String remark) {
		this.remark = remark;
		this.remark = remark;
	}
	}
	public String getSaasId() {
		return saasId;
	}
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
}
}

+ 8 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/system/SystemDictDao.java

@ -4,8 +4,10 @@ import com.yihu.jw.entity.base.system.SystemDictDO;
import feign.Param;
import feign.Param;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@ -19,8 +21,12 @@ public interface SystemDictDao extends PagingAndSortingRepository<SystemDictDO,
    List<SystemDictDO> findBySaasId(String saasId);
    List<SystemDictDO> findBySaasId(String saasId);
    @Query("select code as code,name as name from SystemDictDO where saasId = :saasId")
    @Query("select code as code,name as name from SystemDictDO where saasId = :saasId")
    List<Map<String,Object>> findCodeAndNameBySaasId(@Param("saasId") String saasId, Pageable pageable);
    List<Map<String, Object>> findCodeAndNameBySaasId(@Param("saasId") String saasId, Pageable pageable);
    @Query("select code as code,name as name from SystemDictDO")
    @Query("select code as code,name as name from SystemDictDO")
    List<Map<String,Object>> findCodeAndName(Pageable pageable);
    List<Map<String, Object>> findCodeAndName(Pageable pageable);
    @Modifying
    @Query("delete from SystemDictDO  where code=?1")
    void deleteByCode(String code);
}
}

+ 10 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/dao/system/SystemDictEntryDao.java

@ -2,7 +2,11 @@ package com.yihu.jw.base.dao.system;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.List;
@ -14,5 +18,10 @@ public interface SystemDictEntryDao extends PagingAndSortingRepository<SystemDic
    List<SystemDictEntryDO> findBySaasId(String saasId);
    List<SystemDictEntryDO> findBySaasId(String saasId);
    List<SystemDictEntryDO> findByDictCodeAndCodeAndSaasId(String dictCode,String code,String saasId);
    List<SystemDictEntryDO> findByDictCodeAndCodeAndSaasId(String dictCode, String code, String saasId);
    @Modifying
    @Transactional
    @Query("delete from SystemDictEntryDO  where dictCode=?1")
    void deleteByDictCode(String dictCode);
}
}

+ 5 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/notice/UserNoticeEndpoint.java

@ -11,6 +11,7 @@ import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -40,15 +41,16 @@ public class UserNoticeEndpoint extends EnvelopRestEndpoint {
    }
    }
    @GetMapping(value = BaseRequestMapping.Module.PAGE)
    @GetMapping(value = BaseRequestMapping.Module.PAGE)
    @ApiOperation(value = "获取分页")
    @ApiOperation(value = "获取分页") 
    public PageEnvelop<UserNoticeVO> page(
    public PageEnvelop<UserNoticeVO> page(
//            @ApiParam(name = "userId", value = "用户id")
//            @RequestParam(value = "userId", required = true) String userId,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
            @RequestParam(value = "size") int size) throws Exception {
        String userId = getUID();
        String userId = getUID();
        if(StringUtils.isBlank(userId)){
            return failed("用户信息获取失败!",PageEnvelop.class);
        }
        return userNoticeService.queryPage(page, size, userId);
        return userNoticeService.queryPage(page, size, userId);
    }
    }

+ 7 - 5
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/system/SystemDictEndpoint.java

@ -39,9 +39,11 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.SystemDict.DELETE)
    @PostMapping(value = BaseRequestMapping.SystemDict.DELETE)
    @ApiOperation(value = "删除")
    @ApiOperation(value = "删除")
    public Envelop delete(
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        systemDictService.delete(ids.split(","));
            @ApiParam(name = "dictId", value = "字典id", required = true)
            @RequestParam(value = "dictId") String dictId,
            @ApiParam(name = "dictType", value = "字典类型")
            @RequestParam(value = "dictType", required = true) String dictType) throws Exception{
        systemDictService.deleteDictByType(dictId,dictType);
        return success("删除成功");
        return success("删除成功");
    }
    }
@ -75,7 +77,7 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
            @RequestParam(value = "size") int size) throws Exception {
        if (StringUtils.isBlank(filters)) {
        if (StringUtils.isBlank(filters)) {
            filters = "saasId=" + saasId;
            filters = "saasId=" + saasId+";";
        } else {
        } else {
            filters = "saasId=" + saasId + ";" + filters;
            filters = "saasId=" + saasId + ";" + filters;
        }
        }
@ -96,7 +98,7 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        if (StringUtils.isBlank(filters)) {
        if (StringUtils.isBlank(filters)) {
            filters = "saasId=" + saasId;
            filters = "saasId=" + saasId+";";
        } else {
        } else {
            filters = "saasId=" + saasId + ";" + filters;
            filters = "saasId=" + saasId + ";" + filters;
        }
        }

+ 17 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/system/SystemDictEntryEndpoint.java

@ -9,6 +9,7 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.utils.pinyin.PinyinUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
@ -48,6 +49,9 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
        if(StringUtils.isBlank(systemDictEntryDO.getSaasId())){
        if(StringUtils.isBlank(systemDictEntryDO.getSaasId())){
            systemDictEntryDO.setSaasId(saasId);
            systemDictEntryDO.setSaasId(saasId);
        }
        }
        if(StringUtils.isNotBlank(systemDictEntryDO.getValue())){
            systemDictEntryDO.setPyCode(PinyinUtil.getPinYinHeadChar(systemDictEntryDO.getValue(), true));
        }
        systemDictEntryDO = systemDictEntryService.save(systemDictEntryDO);
        systemDictEntryDO = systemDictEntryService.save(systemDictEntryDO);
        return success(systemDictEntryDO, SystemDictEntryVO.class);
        return success(systemDictEntryDO, SystemDictEntryVO.class);
    }
    }
@ -70,9 +74,17 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
        if (null == systemDictEntryDO.getId()) {
        if (null == systemDictEntryDO.getId()) {
            return failed("ID不能为空", Envelop.class);
            return failed("ID不能为空", Envelop.class);
        }
        }
        if(StringUtils.isBlank(systemDictEntryDO.getDictCode())){
            return failed("字典编码不能为空!",ObjEnvelop.class);
        }if(StringUtils.isBlank(systemDictEntryDO.getCode())){
            return failed("字典项编码不能为空!",ObjEnvelop.class);
        }
        if(StringUtils.isBlank(systemDictEntryDO.getSaasId())){
        if(StringUtils.isBlank(systemDictEntryDO.getSaasId())){
            systemDictEntryDO.setSaasId(saasId);
            systemDictEntryDO.setSaasId(saasId);
        }
        }
        if(StringUtils.isNotBlank(systemDictEntryDO.getValue())){
            systemDictEntryDO.setPyCode(PinyinUtil.getPinYinHeadChar(systemDictEntryDO.getValue(), true));
        }
        systemDictEntryDO = systemDictEntryService.save(systemDictEntryDO);
        systemDictEntryDO = systemDictEntryService.save(systemDictEntryDO);
        return success(systemDictEntryDO, SystemDictEntryVO.class);
        return success(systemDictEntryDO, SystemDictEntryVO.class);
    }
    }
@ -117,7 +129,7 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
            @RequestParam(value = "size") int size) throws Exception {
        if (StringUtils.isBlank(filters)) {
        if (StringUtils.isBlank(filters)) {
            filters = "saasId=" + saasId;
            filters = "saasId=" + saasId+";";
        } else {
        } else {
            filters = "saasId=" + saasId + ";" + filters;
            filters = "saasId=" + saasId + ";" + filters;
        }
        }
@ -136,7 +148,7 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        if (StringUtils.isBlank(filters)) {
        if (StringUtils.isBlank(filters)) {
            filters = "saasId=" + saasId;
            filters = "saasId=" + saasId+";";
        } else {
        } else {
            filters = "saasId=" + saasId + ";" + filters;
            filters = "saasId=" + saasId + ";" + filters;
        }
        }
@ -146,8 +158,9 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.SystemDictEntry.FINDBYID)
    @GetMapping(value = BaseRequestMapping.SystemDictEntry.FINDBYID)
    @ApiOperation(value = "根据id获取详情")
    @ApiOperation(value = "根据id获取详情")
    public ObjEnvelop<SystemDictEntryVO> getSystemDictEntryById(@ApiParam(name = "dictEntryId", value = "字典项id")
                                                                @RequestParam(value = "dictEntryId", required = true) String dictEntryId) throws Exception {
    public ObjEnvelop<SystemDictEntryVO> getSystemDictEntryById(
            @ApiParam(name = "dictEntryId", value = "字典项id")
            @RequestParam(value = "dictEntryId", required = true) String dictEntryId) throws Exception {
        SystemDictEntryDO systemDictEntryDO = systemDictEntryService.findById(dictEntryId);
        SystemDictEntryDO systemDictEntryDO = systemDictEntryService.findById(dictEntryId);
        return success(systemDictEntryDO, SystemDictEntryVO.class);
        return success(systemDictEntryDO, SystemDictEntryVO.class);
    }
    }

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictDiseaseService.java

@ -48,4 +48,7 @@ public class DictDiseaseService extends BaseJpaService<DictDiseaseDO, DictDiseas
        jsonObject.put(SystemDictEnum.DiseaseDict.toString(),list);
        jsonObject.put(SystemDictEnum.DiseaseDict.toString(),list);
        return jsonObject;
        return jsonObject;
    }
    }
    public void deleteById(Integer id){
        dictDiseaseDao.delete(id);
    }
}
}

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictHealthProblemService.java

@ -54,4 +54,8 @@ public class DictHealthProblemService extends BaseJpaService<DictHealthProblemDO
        return jsonObject;
        return jsonObject;
    }
    }
    public void deleteById(Integer id){
        dictHealthProblemDao.delete(id);
    }
}
}

+ 1 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictHospitalDeptService.java

@ -94,4 +94,5 @@ public class DictHospitalDeptService extends BaseJpaService<DictHospitalDeptDO,
       }
       }
       return dictHospitalDeptDao.findByOrgCode(orgCode);
       return dictHospitalDeptDao.findByOrgCode(orgCode);
    }
    }
}
}

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictIcd10Service.java

@ -52,5 +52,8 @@ public class DictIcd10Service extends BaseJpaService<DictIcd10DO, DictIcd10Dao>
        jsonObject.put(SystemDictEnum.Icd10Dict.toString(),list);
        jsonObject.put(SystemDictEnum.Icd10Dict.toString(),list);
        return jsonObject;
        return jsonObject;
    }
    }
    public void deleteById(Integer id){
        dictIcd10Dao.delete(id);
    }
}
}

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictJobTitleService.java

@ -52,4 +52,8 @@ public class DictJobTitleService extends BaseJpaService<DictJobTitleDO, DictJobT
        return jsonObject;
        return jsonObject;
    }
    }
    public void deleteById(Integer id){
        dictJobTitleDao.delete(id);
    }
}
}

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictMedicineService.java

@ -47,4 +47,7 @@ public class DictMedicineService extends BaseJpaService<DictMedicineDO, DictMedi
        jsonObject.put(SystemDictEnum.DiseaseDict.toString(),list);
        jsonObject.put(SystemDictEnum.DiseaseDict.toString(),list);
        return jsonObject;
        return jsonObject;
    }
    }
    public void deleteById(Integer id){
        dictMedicineDao.delete(id);
    }
}
}

+ 5 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictEntryService.java

@ -5,6 +5,7 @@ import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
/**
 * Service - 系统字典项
 * Service - 系统字典项
@ -19,4 +20,8 @@ public class SystemDictEntryService extends BaseJpaService<SystemDictEntryDO, Sy
    public SystemDictEntryDO findById(String id) {
    public SystemDictEntryDO findById(String id) {
        return systemDictEntryDao.findOne(id);
        return systemDictEntryDao.findOne(id);
    }
    }
    public void deleteByDictCode(String dictCode) {
        systemDictEntryDao.deleteByDictCode(dictCode);
    }
}
}

+ 130 - 80
svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.base.dict.*;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.pinyin.PinyinUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
@ -67,28 +68,29 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
    /**
    /**
     * 根据字典类型获取系统所有相关字典,
     * 根据字典类型获取系统所有相关字典,
     *
     * @param saasId
     * @param saasId
     * @return
     * @return
     */
     */
    public JSONArray getDistListBySaasId(String type, String saasId,String name, String sorts, int page, int size) throws Exception {
    public JSONArray getDistListBySaasId(String type, String saasId, String name, String sorts, int page, int size) throws Exception {
        JSONArray jsonArray = new JSONArray();
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictIcd10Service.queryAll(saasId, createPage(page,size,sorts));
            jsonObject = dictIcd10Service.queryAll(saasId, createPage(page, size, sorts));
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHospitalDeptService.queryAll(saasId, createPage(page,size,sorts));
            jsonObject = dictHospitalDeptService.queryAll(saasId, createPage(page, size, sorts));
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictJobTitleService.queryAll(saasId, createPage(page,size,sorts));
            jsonObject = dictJobTitleService.queryAll(saasId, createPage(page, size, sorts));
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHealthProblemService.queryAll(saasId, createPage(page,size,sorts));
            jsonObject = dictHealthProblemService.queryAll(saasId, createPage(page, size, sorts));
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictMedicineService.queryAll(saasId, createPage(page,size,sorts));
            jsonObject = dictMedicineService.queryAll(saasId, createPage(page, size, sorts));
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictDiseaseService.queryAll(saasId, createPage(page,size,sorts));
            jsonObject = dictDiseaseService.queryAll(saasId, createPage(page, size, sorts));
        }
        }
        jsonArray.add(jsonObject);
        jsonArray.add(jsonObject);
        return jsonArray;
        return jsonArray;
@ -96,15 +98,18 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
    /**
    /**
     * 获取系统所有相关字典,
     * 获取系统所有相关字典,
     *
     * @param userId
     * @param userId
     * @return
     * @return
     */
     */
    public JSONArray getAllDistList(String userId){
    public JSONArray getAllDistList(String userId) {
        JSONArray jsonArray = new JSONArray();
        JSONArray jsonArray = new JSONArray();
        return jsonArray;
        return jsonArray;
    }
    }
    /**
    /**
     * 根据字典类型获取系统所有相关字典,
     * 根据字典类型获取系统所有相关字典,
     *
     * @param userId
     * @param userId
     * @return
     * @return
     */
     */
@ -116,23 +121,23 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
        JSONArray jsonArray = new JSONArray();
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictIcd10Service.queryAll(userId, createPage(page,size,sorts));
            jsonObject = dictIcd10Service.queryAll(userId, createPage(page, size, sorts));
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHospitalDeptService.queryAll("", createPage(page,size,sorts));
            jsonObject = dictHospitalDeptService.queryAll("", createPage(page, size, sorts));
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictJobTitleService.queryAll("", createPage(page,size,sorts));
            jsonObject = dictJobTitleService.queryAll("", createPage(page, size, sorts));
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHealthProblemService.queryAll("", createPage(page,size,sorts));
            jsonObject = dictHealthProblemService.queryAll("", createPage(page, size, sorts));
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictMedicineService.queryAll("", createPage(page,size,sorts));
            jsonObject = dictMedicineService.queryAll("", createPage(page, size, sorts));
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictDiseaseService.queryAll("", createPage(page,size,sorts));
        }else{
            jsonObject = this.queryAll("", createPage(page,size,sorts));
            jsonObject = dictDiseaseService.queryAll("", createPage(page, size, sorts));
        } else {
            jsonObject = this.queryAll("", createPage(page, size, sorts));
        }
        }
        jsonArray.add(jsonObject);
        jsonArray.add(jsonObject);
        return jsonArray;
        return jsonArray;
@ -140,68 +145,68 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
    /**
    /**
     * 查询某一租户下的医院科室字典信息,如果saadId为空表示当前用户角色为超级管理员,超级管理员可以看到所有数据
     * 查询某一租户下的医院科室字典信息,如果saadId为空表示当前用户角色为超级管理员,超级管理员可以看到所有数据
     *
     * @param saasId
     * @param saasId
     * @return
     * @return
     */
     */
    public JSONObject queryAll(String saasId, Pageable pageable) throws Exception{
    public JSONObject queryAll(String saasId, Pageable pageable) throws Exception {
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        List<Map<String,Object>> list = new ArrayList<>();
        if(StringUtils.isEmpty(saasId)){
        List<Map<String, Object>> list = new ArrayList<>();
        if (StringUtils.isEmpty(saasId)) {
            list = systemDictDao.findCodeAndName(pageable);
            list = systemDictDao.findCodeAndName(pageable);
        }else{
            list = systemDictDao.findCodeAndNameBySaasId(saasId,pageable);
        } else {
            list = systemDictDao.findCodeAndNameBySaasId(saasId, pageable);
        }
        }
        jsonObject.put(SystemDictEnum.SystemDict.toString(),list);
        jsonObject.put(SystemDictEnum.SystemDict.toString(), list);
        return jsonObject;
        return jsonObject;
    }
    }
    /**
    /**
     * 新增字典,包括字典项值
     * 新增字典,包括字典项值
     * "obj": {
     * "obj": {
     "      dict:
                {
                code": "SYSTEM_SETTING",
     "          name": "系统设置",
     "          pyCode": "XTSZ",
     "          saasId": "string",
     "          type": "basic"
            }
            valueArr:[
                {
                dictCode:"SYSTEM_SETTING",
                code:"SYSTEM_SETTING_0",
                pyCode:"",
                value:"",
                sort:"",
                remark:"",
                 },{
                ....
                  }
            ]
     }
     *
     * "      dict:
     * {
     * code": "SYSTEM_SETTING",
     * "          name": "系统设置",
     * "          pyCode": "XTSZ",
     * "          saasId": "string",
     * "          type": "basic"
     * }
     * valueArr:[
     * {
     * dictCode:"SYSTEM_SETTING",
     * code:"SYSTEM_SETTING_0",
     * pyCode:"",
     * value:"",
     * sort:"",
     * remark:"",
     * },{
     * ....
     * }
     * ]
     * }
     */
     */
    @Transactional(rollbackFor = Exception.class)
    @Transactional(rollbackFor = Exception.class)
    public String createSystemDict(String jsonData) throws Exception{
        if(StringUtils.isEmpty(jsonData)){
    public String createSystemDict(String jsonData) throws Exception {
        if (StringUtils.isEmpty(jsonData)) {
            return "none params(jsonData)";
            return "none params(jsonData)";
        }
        }
        JSONObject jsonParam = JSONObject.parseObject(jsonData);
        JSONObject jsonParam = JSONObject.parseObject(jsonData);
        if(null == jsonParam.get("dict")){
        if (null == jsonParam.get("dict")) {
            return "no dict element in " + jsonData;
            return "no dict element in " + jsonData;
        }
        }
        JSONObject dictJson = (JSONObject)jsonParam.get("dict");
        SystemDictDO systemDictDO = objectMapper.readValue(dictJson.toString(),SystemDictDO.class);
        if(StringUtils.isBlank(systemDictDO.getSaasId())){
        JSONObject dictJson = (JSONObject) jsonParam.get("dict");
        SystemDictDO systemDictDO = objectMapper.readValue(dictJson.toString(), SystemDictDO.class);
        if (StringUtils.isBlank(systemDictDO.getSaasId())) {
            systemDictDO.setSaasId(saasId);
            systemDictDO.setSaasId(saasId);
        }
        }
        if(StringUtils.isEmpty(systemDictDO.getCode()) || StringUtils.isEmpty(systemDictDO.getName())){
        if (StringUtils.isEmpty(systemDictDO.getCode()) || StringUtils.isEmpty(systemDictDO.getName())) {
            return "code or name of dict is required";
            return "code or name of dict is required";
        }
        }
        List<SystemDictEntryDO> systemDictEntryDOList = new ArrayList<>();
        List<SystemDictEntryDO> systemDictEntryDOList = new ArrayList<>();
        JSONArray dictValueArr = jsonParam.getJSONArray("valueArr");
        JSONArray dictValueArr = jsonParam.getJSONArray("valueArr");
        dictValueArr.forEach((oneObj)->systemDictEntryDOList.add((SystemDictEntryDO)oneObj));
        dictValueArr.forEach((oneObj) -> systemDictEntryDOList.add((SystemDictEntryDO) oneObj));
        save(systemDictDO);
        save(systemDictDO);
@ -212,6 +217,7 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
    /**
    /**
     * 查询字典分页信息
     * 查询字典分页信息
     *
     * @param type
     * @param type
     * @param userId
     * @param userId
     * @param filters
     * @param filters
@ -220,99 +226,143 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
     * @param size
     * @param size
     * @return
     * @return
     */
     */
    public JSONObject queryDictPageByType( String userId,String type,String filters,String sorts,int page,int size) throws ParseException {
    public JSONObject queryDictPageByType(String userId, String type, String filters, String sorts, int page, int size) throws ParseException {
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        if (StringUtils.isEmpty(type) || StringUtils.isEmpty(userId)) {
        if (StringUtils.isEmpty(type) || StringUtils.isEmpty(userId)) {
            result.put("msg","parameter dictType or userId is null");
            result.put("response",ConstantUtils.FAIL);
            result.put("msg", "parameter dictType or userId is null");
            result.put("response", ConstantUtils.FAIL);
            return result;
            return result;
        }
        }
        List list = new ArrayList();
        List list = new ArrayList();
        long count = 0;
        long count = 0;
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            list = dictIcd10Service.search(null,filters,sorts,page,size);
            list = dictIcd10Service.search(null, filters, sorts, page, size);
            count = dictIcd10Service.getCount(filters);
            count = dictIcd10Service.getCount(filters);
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
            list = dictHospitalDeptService.search(null,filters,sorts,page,size);
            list = dictHospitalDeptService.search(null, filters, sorts, page, size);
            count = dictHospitalDeptService.getCount(filters);
            count = dictHospitalDeptService.getCount(filters);
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            list = dictJobTitleService.search(null,filters,sorts,page,size);
            list = dictJobTitleService.search(null, filters, sorts, page, size);
            count = dictJobTitleService.getCount(filters);
            count = dictJobTitleService.getCount(filters);
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            list = dictHealthProblemService.search(null,filters,sorts,page,size);
            list = dictHealthProblemService.search(null, filters, sorts, page, size);
            count = dictHealthProblemService.getCount(filters);
            count = dictHealthProblemService.getCount(filters);
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            list = dictMedicineService.search(null,filters,sorts,page,size);
            list = dictMedicineService.search(null, filters, sorts, page, size);
            count = dictMedicineService.getCount(filters);
            count = dictMedicineService.getCount(filters);
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            list = dictDiseaseService.search(null,filters,sorts,page,size);
            list = dictDiseaseService.search(null, filters, sorts, page, size);
            count = dictDiseaseService.getCount(filters);
            count = dictDiseaseService.getCount(filters);
        }else{
            list = this.search(null,filters,sorts,page,size);
        } else {
            list = this.search(null, filters, sorts, page, size);
            count = this.getCount(filters);
            count = this.getCount(filters);
        }
        }
        result.put("response",ConstantUtils.SUCCESS);
        result.put("count",count);
        result.put("msg",list);
        result.put("response", ConstantUtils.SUCCESS);
        result.put("count", count);
        result.put("msg", list);
        return result;
        return result;
    }
    }
    /**
    /**
     * 查询字典分页信息
     * 查询字典分页信息
     *
     * @param type
     * @param type
     * @param json
     * @param json
     * @return
     * @return
     */
     */
    public JSONObject createDictByType(String type,String json) throws ParseException {
    public JSONObject createDictByType(String type, String json) throws Exception {
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        if (StringUtils.isEmpty(json) || StringUtils.isEmpty(json)) {
        if (StringUtils.isEmpty(json) || StringUtils.isEmpty(json)) {
            result.put("msg","parameter dictType or userId is null");
            result.put("response",ConstantUtils.FAIL);
            result.put("msg", "parameter dictType or userId is null");
            result.put("response", ConstantUtils.FAIL);
            return result;
            return result;
        }
        }
        List list = new ArrayList();
        List list = new ArrayList();
        long count = 0;
        long count = 0;
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            DictIcd10DO dictIcd10DO=convertToModel(json,DictIcd10DO.class);
            DictIcd10DO dictIcd10DO = objectMapper.readValue(json, DictIcd10DO.class);
            dictIcd10DO.setSaasId(saasId);
            dictIcd10DO.setSaasId(saasId);
            dictIcd10Service.save(dictIcd10DO);
            dictIcd10Service.save(dictIcd10DO);
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
            //科室只与机构有关。
            //科室只与机构有关。
            DictHospitalDeptDO dictHospitalDeptDO=convertToModel(json,DictHospitalDeptDO.class);
            DictHospitalDeptDO dictHospitalDeptDO = objectMapper.readValue(json, DictHospitalDeptDO.class);
            dictHospitalDeptService.save(dictHospitalDeptDO);
            dictHospitalDeptService.save(dictHospitalDeptDO);
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            DictJobTitleDO dictJobTitleDO=convertToModel(json,DictJobTitleDO.class);
            DictJobTitleDO dictJobTitleDO = objectMapper.readValue(json, DictJobTitleDO.class);
            dictJobTitleDO.setSaasId(saasId);
            dictJobTitleDO.setSaasId(saasId);
            dictJobTitleService.save(dictJobTitleDO);
            dictJobTitleService.save(dictJobTitleDO);
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            DictHealthProblemDO dictHealthProblemDO=convertToModel(json,DictHealthProblemDO.class);
            DictHealthProblemDO dictHealthProblemDO = objectMapper.readValue(json, DictHealthProblemDO.class);
            dictHealthProblemDO.setSaasId(saasId);
            dictHealthProblemDO.setSaasId(saasId);
            dictHealthProblemService.save(dictHealthProblemDO);
            dictHealthProblemService.save(dictHealthProblemDO);
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            DictMedicineDO dictMedicineDO=convertToModel(json,DictMedicineDO.class);
            DictMedicineDO dictMedicineDO = objectMapper.readValue(json, DictMedicineDO.class);
            dictMedicineDO.setSaasId(saasId);
            dictMedicineDO.setSaasId(saasId);
            dictMedicineService.save(dictMedicineDO);
            dictMedicineService.save(dictMedicineDO);
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            DictDiseaseDO dictDiseaseDO=convertToModel(json,DictDiseaseDO.class);
            DictDiseaseDO dictDiseaseDO = objectMapper.readValue(json, DictDiseaseDO.class);
            dictDiseaseDO.setSaasId(saasId);
            dictDiseaseDO.setSaasId(saasId);
            dictDiseaseService.save(dictDiseaseDO);
            dictDiseaseService.save(dictDiseaseDO);
        }else{
            SystemDictDO systemDictDO=convertToModel(json,SystemDictDO.class);
        } else {
            SystemDictDO systemDictDO = objectMapper.readValue(json, SystemDictDO.class);
            if (StringUtils.isBlank(systemDictDO.getCode())) {
                systemDictDO.setCode(getCode());
            }
            if (StringUtils.isNotBlank(systemDictDO.getName())) {
                systemDictDO.setPyCode(PinyinUtil.getPinYinHeadChar(systemDictDO.getName(), true));
            }
            systemDictDO.setType(SystemDictDO.Type.basic);
            systemDictDO.setSaasId(saasId);
            systemDictDO.setSaasId(saasId);
            this.save(systemDictDO);
            this.save(systemDictDO);
        }
        }
        result.put("response",ConstantUtils.SUCCESS);
        result.put("count",count);
        result.put("msg",list);
        result.put("response", ConstantUtils.SUCCESS);
        result.put("count", count);
        result.put("msg", list);
        return result;
    }
    @Transactional(rollbackFor = Exception.class)
    public JSONObject deleteDictByType(String dictId, String type) throws ParseException {
        JSONObject result = new JSONObject();
        if (StringUtils.isEmpty(type) || StringUtils.isEmpty(dictId)) {
            result.put("msg", "parameter dictType or dictId is null");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            dictIcd10Service.deleteById(Integer.valueOf(dictId));
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
//            暂时不维护
//            dictHospitalDeptService.delete(dictId);
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            dictJobTitleService.deleteById(Integer.valueOf(dictId));
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            dictHealthProblemService.deleteById(Integer.valueOf(dictId));
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            dictMedicineService.deleteById(Integer.valueOf(dictId));
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            dictDiseaseService.deleteById(Integer.valueOf(dictId));
        } else {
            systemDictEntryService.deleteByDictCode(dictId);
            this.deleteByCode(dictId);
        }
        result.put("response", ConstantUtils.SUCCESS);
        return result;
        return result;
    }
    }
    public void deleteByCode(String code) {
        systemDictDao.deleteByCode(code);
    }
}
}