فهرست منبع

字典管理查询修改,机构管理修改,医生管理添加机构/科室树形结构

LiTaohong 6 سال پیش
والد
کامیت
aaa59f5d3d
22فایلهای تغییر یافته به همراه316 افزوده شده و 105 حذف شده
  1. 3 1
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  2. 6 3
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictHealthProblemDao.java
  3. 3 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictHospitalDeptDao.java
  4. 4 2
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictIcd10Dao.java
  5. 4 2
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictJobTitleDao.java
  6. 2 21
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/org/BaseOrgDao.java
  7. 10 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/system/SystemDictDao.java
  8. 19 4
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/doctor/BaseDoctorEndpoint.java
  9. 36 8
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/org/BaseOrgEndpoint.java
  10. 1 3
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/patient/BasePatientEndpoint.java
  11. 10 6
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/system/SystemDictEndpoint.java
  12. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/enums/SystemDictEnum.java
  13. 7 3
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictHealthProblemService.java
  14. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictHospitalDeptService.java
  15. 5 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictIcd10Service.java
  16. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictJobTitleService.java
  17. 47 7
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  18. 71 38
      svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java
  19. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/patient/BasePatientService.java
  20. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/saas/SaasBusinessCardService.java
  21. 74 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java
  22. 3 3
      svr/svr-base/src/main/java/com/yihu/jw/base/util/JavaBeanUtils.java

+ 3 - 1
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -380,7 +380,8 @@ public class BaseRequestMapping {
        public static final String getOrgListByTown  = "/getOrgListByTown";
        public static final String enableOrDis  = "/enableOrDis";
        public static final String docFullInfo  = "/docFullInfo";
        public static final String docOrgTreeInfo  = "/docOrgTreeInfo";
        public static final String docOrgDutyTreeInfo  = "/docOrgDutyTreeInfo";
        public static final String docOrgDeptTreeInfo  = "/docOrgDeptTreeInfo";
    }
@ -416,6 +417,7 @@ public class BaseRequestMapping {
        public static final String check_code  = "/check_code";
        public static final String getOrgAreaTree  = "/getOrgAreaTree";
        public static final String queryOneById  = "/queryOneById";
        public static final String enableOrDis  = "/enableOrDis";
    }

+ 6 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictHealthProblemDao.java

@ -3,6 +3,7 @@ package com.yihu.jw.base.dao.dict;
import com.yihu.jw.entity.base.dict.DictDiseaseDO;
import com.yihu.jw.entity.base.dict.DictIcd10DO;
import feign.Param;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -26,11 +27,13 @@ import java.util.Map;
 */
public interface DictHealthProblemDao extends PagingAndSortingRepository<DictHealthProblemDO, Integer>, JpaSpecificationExecutor<DictHealthProblemDO>  {
    @Query("select code as code,name as name from DictHealthProblemDO where saasId = :saasId")
    List<DictHealthProblemDO> findCodeAndNameBySaasId(@Param("saasId") String saasId);
    @Query("select code as code,name as name from DictHealthProblemDO where saasId = ?1")
    List<Map<String,Object>> findCodeAndNameBySaasId(String saasId, Pageable pageable);
    @Query("select code as code,name as name from DictHealthProblemDO")
    List<Map<String,Object>> findCodeAndName();
    List<Map<String,Object>> findCodeAndName(Pageable pageable);
    List<DictHealthProblemDO> findBySaasId(String saasId);
    Long countBySaasId(String saasId);
}

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictHospitalDeptDao.java

@ -34,4 +34,7 @@ public interface DictHospitalDeptDao extends PagingAndSortingRepository<DictHosp
    List<DictHospitalDeptDO> findByOrgCode(String orgCode);
    List<DictHospitalDeptDO> findByOrgCodeIn(String orgCode);
    Long countByCodeIn(String orgCode);
}

+ 4 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictIcd10Dao.java

@ -24,11 +24,13 @@ import java.util.Map;
 */
public interface DictIcd10Dao extends PagingAndSortingRepository<DictIcd10DO, Integer>, JpaSpecificationExecutor<DictIcd10DO>  {
    @Query("select code as code,name as name from DictIcd10DO where code = ?1")
    List<Map<String,Object>> findCodeAndNameSa(String saasId,Pageable pageable);
    @Query("select code as code,name as name from DictIcd10DO where saasId = ?1")
    List<Map<String,Object>> findCodeAndNameSaasId(String saasId, Pageable pageable);
    @Query("select code as code,name as name from DictIcd10DO")
    List<Map<String,Object>> findCodeAndName(Pageable pageable);
    List<DictIcd10DO> findBySaasId(String saasId);
    Long countBySaasId(String saasId);
}

+ 4 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictJobTitleDao.java

@ -25,11 +25,13 @@ import java.util.Map;
 */
public interface DictJobTitleDao extends PagingAndSortingRepository<DictJobTitleDO, Integer>, JpaSpecificationExecutor<DictJobTitleDO>  {
    @Query("select code as code,name as name from DictJobTitleDO where saasId = :saasId")
    List<Map<String,Object>> findCodeAndNameBySaasId(@Param("saasId") String saasId, Pageable pageable);
    @Query("select code as code,name as name from DictJobTitleDO where saasId = ?1")
    List<Map<String,Object>> findCodeAndNameBySaasId(String saasId, Pageable pageable);
    @Query("select code as code,name as name from DictJobTitleDO")
    List<Map<String,Object>> findCodeAndName(Pageable pageable);
    List<DictJobTitleDO> findBySaasId(String saasId);
    Long countBySaasId(String saasId);
}

+ 2 - 21
svr/svr-base/src/main/java/com/yihu/jw/base/dao/org/BaseOrgDao.java

@ -24,32 +24,13 @@ import java.util.Map;
 */
public interface BaseOrgDao extends PagingAndSortingRepository<BaseOrgDO, String>, JpaSpecificationExecutor<BaseOrgDO>  {
    @Query("select id as id,code as code,name as name,case del when 1 then '有效' else '失效' end as status,concat(provinceName,cityName,townName,streetName) as address from BaseOrgDO where code like ?1")
    List<Map<String,Object>> findByCode(String code,Pageable pageable);
    @Query("select id as id,code as code,name as name,case del when 1 then '有效' else '失效' end as status,concat(provinceName,cityName,townName,streetName) as address from BaseOrgDO where code like ?1 and del = ?2")
    List<Map<String,Object>> findByCodeAndDel(String code, String del,Pageable pageable);
    @Query("select id as id,code as code,name as name,case del when 1 then '有效' else '失效' end as status,concat(provinceName,cityName,townName,streetName) as address from BaseOrgDO where name like ?1")
    List<Map<String,Object>> findByName(String name,Pageable pageable);
    @Query("select id as id,code as code,name as name,case del when 1 then '有效' else '失效' end as status,concat(provinceName,cityName,townName,streetName) as address from BaseOrgDO where name like ?1 and del = ?2")
    List<Map<String,Object>> findByNameAndDel(String name, String del,Pageable pageable);
    @Query("select id as id,code as code,name as name,case del when 1 then '有效' else '失效' end as status,concat(provinceName,cityName,townName,streetName) as address from BaseOrgDO")
    List<Map<String,Object>> findBaseInfo(Pageable pageable);
    @Query("select id as id,code as code,name as name,case del when 1 then '有效' else '失效' end as status,concat(provinceName,cityName,townName,streetName) as address from BaseOrgDO where del = ?1")
    List<Map<String,Object>> findBaseInfoByDel(String del, Pageable pageable);
    @Query("select new BaseOrgDO(provinceCode,provinceName,cityCode,cityName,townCode,townName,code,name) from BaseOrgDO")
    List<BaseOrgDO> findOrgByArea();
    @Query(value="select b.* from base_org b where b.code= ?1 and b.saasid= ?2 limit 1",nativeQuery = true)
    BaseOrgDO findByCodeAndSaasId(String code,String saasId);
    boolean existsByCode(String code);
    BaseOrgDO findByCode(String code);
    @Modifying
    @Query("delete from BaseOrgDO p where p.saasid=?1 ")
    void deleteBySaasId(String saasId);

+ 10 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/system/SystemDictDao.java

@ -1,10 +1,14 @@
package com.yihu.jw.base.dao.system;
import com.yihu.jw.entity.base.system.SystemDictDO;
import feign.Param;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
import java.util.Map;
/**
 * Dao - 系统字典
@ -13,4 +17,10 @@ import java.util.List;
public interface SystemDictDao extends PagingAndSortingRepository<SystemDictDO, String>, JpaSpecificationExecutor<SystemDictDO> {
    List<SystemDictDO> findBySaasId(String 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);
    @Query("select code as code,name as name from SystemDictDO")
    List<Map<String,Object>> findCodeAndName(Pageable pageable);
}

+ 19 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/doctor/BaseDoctorEndpoint.java

@ -166,7 +166,7 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
     */
    @PostMapping(value = BaseRequestMapping.BaseDoctor.docFullInfo)
    @ApiOperation(value = "获取医生基础信息列表")
    public Envelop getDoctorFullInfolist(
    public PageEnvelop getDoctorFullInfolist(
            @ApiParam(name = "nameOrIdcard", value = "医生姓名或医生身份证号")
            @RequestParam(value = "nameOrIdcard", required = false) String nameOrIdcard,
            @RequestParam(value = "orgCode", required = false) String orgCode,
@ -178,7 +178,7 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        return success(baseDoctorService.getDoctorFullInfo(nameOrIdcard, orgCode, doctorStatus,page,size,sorts));
        return success(baseDoctorService.getDoctorFullInfo(nameOrIdcard, orgCode, doctorStatus,page,size,sorts),0,page,size);
    }
@ -205,12 +205,27 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
     * @return
     * @throws Exception
     */
    @GetMapping(value = BaseRequestMapping.BaseDoctor.docOrgTreeInfo)
    @GetMapping(value = BaseRequestMapping.BaseDoctor.docOrgDutyTreeInfo)
    @ApiOperation(value = "获取医生所属机构树形结构数据")
    public Envelop getOrgAreaTree(
    public Envelop getOrgDutyTree(
            @ApiParam(name = "doctorCode", value = "doctorCode")
            @RequestParam(value = "doctorCode", required = true) String doctorCode) throws Exception {
        return success(baseDoctorService.getDoctorDutyTree(doctorCode));
    }
    /**
     * 获取医生 机构/科室 树形结构数据
     *
     * @param doctorCode
     * @return
     * @throws Exception
     */
    @GetMapping(value = BaseRequestMapping.BaseDoctor.docOrgDeptTreeInfo)
    @ApiOperation(value = "获取医生所属机构树形结构数据")
    public Envelop getOrgDeptTree(
            @ApiParam(name = "doctorCode", value = "doctorCode")
            @RequestParam(value = "doctorCode", required = true) String doctorCode) throws Exception {
        return success(baseDoctorService.getDoctorDeptTree(doctorCode));
    }
}

+ 36 - 8
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/org/BaseOrgEndpoint.java

@ -124,33 +124,61 @@ public class BaseOrgEndpoint extends EnvelopRestEndpoint {
    public Envelop queryOne (
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id) throws Exception {
      return success(baseOrgService.queryOneById(id));
        JSONObject result = baseOrgService.queryOneById(id);
        if(StringUtils.endsWithIgnoreCase(ConstantUtils.FAIL,result.getString("response"))){
            return failed(result.getString("msg"));
        }
      return success(result.get("msg"));
    }
    @PostMapping(value = BaseRequestMapping.BaseOrg.baseInfoList)
    @ApiOperation(value = "获取机构基础信息列表")
    public Envelop queryBaseOrgInfolist(
            @ApiParam(name = "orgCode", value = "机构名称或机构代码")
            @RequestParam(value = "orgCode", required = false) String codeOrName,
    public PageEnvelop queryBaseOrgInfolist(
            @ApiParam(name = "codeOrName", value = "机构名称或机构代码")
            @RequestParam(value = "codeOrName", required = false) String codeOrName,
            @ApiParam(name = "orgStatus", value = "机构状态")
            @RequestParam(value = "orgStatus", required = false) String orgStatus,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        return success(baseOrgService.queryOrgBaseInfoList(codeOrName, orgStatus,page,size));
        JSONObject result = baseOrgService.queryOrgBaseInfoList(codeOrName, orgStatus,page,size);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
    }
    @GetMapping(value = BaseRequestMapping.BaseOrg.check_code)
    @ApiOperation(value = "检查代码是否可用(message=1代表可用,message=0代表不可用)")
    @ApiOperation(value = "检查代码是否可用(message=available代表可用,message=inavailable代表不可用)")
    public Envelop checkCode (
            @ApiParam(name = "code", value = "机构代码", required = true)
            @RequestParam(value = "code", required = false) String code) throws Exception {
        if (baseOrgService.existCode(code)) {
            return success("1");
            return success("inavailable");
        } else {
            return success("0");
            return success("available");
        }
    }
    /**
     * 生效或失效某个机构
     *
     * @param id
     * @param status
     * @return
     * @throws Exception
     */
    @PostMapping(value = BaseRequestMapping.BaseOrg.enableOrDis)
    @ApiOperation(value = "生效或失效某个机构")
    public Envelop enableOrDisableDoctor(
            @ApiParam(name = "id", value = "医生标识")
            @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "status", value = "生效或失效标识")
            @RequestParam(value = "status", required = true) String status) throws Exception {
        String str = baseOrgService.enableOrDisableOrg(id, status);
        JSONObject jsonObject = JSONObject.parseObject(str);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getString("response"));
    }
}

+ 1 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/patient/BasePatientEndpoint.java

@ -5,7 +5,6 @@ import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.restmodel.base.patient.BasePatientVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
@ -14,7 +13,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -78,7 +76,7 @@ public class BasePatientEndpoint extends EnvelopRestEndpoint {
    public Envelop getPatientById(
            @ApiParam(name = "id", value = "居民id")
            @RequestParam(value = "id", required = true) String id) throws Exception {
        String result = basePatientService.getPatientInfo(id);
        String result = basePatientService.getPatientById(id);
        return success(result);
    }

+ 10 - 6
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/system/SystemDictEndpoint.java

@ -1,6 +1,7 @@
package com.yihu.jw.base.endpoint.system;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.service.system.SystemDictService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.entity.base.system.SystemDictDO;
@ -55,9 +56,9 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.SystemDict.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<SystemDictVO> page(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
    public Envelop page(
            @ApiParam(name = "dictType", value = "字典类型")
            @RequestParam(value = "dictType", required = true) String dictType,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
@ -66,9 +67,12 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<SystemDictDO> systemDictDOS = systemDictService.search(fields, filters, sorts, page, size);
        int count = (int) systemDictService.getCount(filters);
        return success(systemDictDOS, count, page, size, SystemDictVO.class);
       JSONObject result =  systemDictService.queryDictPageByType("1",dictType,filters,sorts,page,size);
       if(StringUtils.equalsIgnoreCase(ConstantUtils.FAIL,result.getString("response"))){
           return failed(result.getString("msg"));
       }
        return success(result.getJSONArray("msg"), result.getInteger("count"), page, size);
    }
    @GetMapping(value = BaseRequestMapping.SystemDict.LIST)

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/enums/SystemDictEnum.java

@ -8,5 +8,5 @@ import org.apache.commons.lang3.StringUtils;
 * @project jw2.0
 */
public enum SystemDictEnum {
    Icd10Dict, HospitalDeptDict, JobTitleDict, HealthProblemDict, DiseaseDict, MedicineDict;
    Icd10Dict, HospitalDeptDict, JobTitleDict, HealthProblemDict, DiseaseDict, MedicineDict,SystemDict;
}

+ 7 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictHealthProblemService.java

@ -32,7 +32,7 @@ import java.util.Map;
public class DictHealthProblemService extends BaseJpaService<DictHealthProblemDO, DictHealthProblemDao> {
    @Autowired
    private DictJobTitleDao dictJobTitleDao;
    private DictHealthProblemDao dictHealthProblemDao;
    /**
     * 查询某一租户下的健康问题字典信息,如果saadId为空表示当前用户角色为超级管理员,超级管理员可以看到所有数据
     * @param saasId
@ -41,11 +41,15 @@ public class DictHealthProblemService extends BaseJpaService<DictHealthProblemDO
    public JSONObject queryAll(String saasId, Pageable pageable){
        JSONObject jsonObject = new JSONObject();
        List<Map<String,Object>> list = new ArrayList<>();
        long count = 0;
        if(StringUtils.isEmpty(saasId)){
            list = dictJobTitleDao.findCodeAndName(pageable);
            list = dictHealthProblemDao.findCodeAndName(pageable);
            count = dictHealthProblemDao.count();
        }else{
            list = dictJobTitleDao.findCodeAndNameBySaasId(saasId,pageable);
            list = dictHealthProblemDao.findCodeAndNameBySaasId(saasId,pageable);
            count = dictHealthProblemDao.countBySaasId(saasId);
        }
        jsonObject.put("count",count);
        jsonObject.put(SystemDictEnum.HealthProblemDict.toString(),list);
        return jsonObject;
    }

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

@ -50,12 +50,16 @@ public class DictHospitalDeptService extends BaseJpaService<DictHospitalDeptDO,
    public JSONObject queryAll(String saasId, Pageable pageable) throws Exception{
        JSONObject jsonObject = new JSONObject();
        List<Map<String,Object>> list = new ArrayList<>();
        long count = 0;
        if(StringUtils.isEmpty(saasId)){
            list = dictHospitalDeptDao.findCodeAndName(pageable);
            count = dictHospitalDeptDao.count();
        }else{
            List orgCodeList = baseOrgService.findOrgCodeBySaasId(saasId);
            list = dictHospitalDeptDao.findByOrgCodeIn(objectMapper.writeValueAsString(orgCodeList),pageable);
            count = dictHospitalDeptDao.countByCodeIn(saasId);
        }
        jsonObject.put("count",count);
        jsonObject.put(SystemDictEnum.HospitalDeptDict.toString(),list);
        return jsonObject;
    }

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictIcd10Service.java

@ -40,11 +40,15 @@ public class DictIcd10Service extends BaseJpaService<DictIcd10DO, DictIcd10Dao>
    public JSONObject queryAll(String saasId, Pageable pageable){
        JSONObject jsonObject = new JSONObject();
        List<Map<String,Object>> list = new ArrayList<>();
        long count = 0;
        if(!StringUtils.isEmpty(saasId)){
           list = dictIcd10Dao.findCodeAndName(pageable);
           count = dictIcd10Dao.count();
        }else{
           list = dictIcd10Dao.findCodeAndNameSa(saasId,pageable);
           list = dictIcd10Dao.findCodeAndNameSaasId(saasId,pageable);
            count = dictIcd10Dao.countBySaasId(saasId);
        }
        jsonObject.put("count",count);
        jsonObject.put(SystemDictEnum.Icd10Dict.toString(),list);
        return jsonObject;
    }

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

@ -38,12 +38,16 @@ public class DictJobTitleService extends BaseJpaService<DictJobTitleDO, DictJobT
     */
    public JSONObject queryAll(String saasId, Pageable pageable){
        JSONObject jsonObject = new JSONObject();
        long count = 0;
        List<Map<String,Object>> list = new ArrayList<>();
        if(StringUtils.isEmpty(saasId)){
            list = dictJobTitleDao.findCodeAndName(pageable);
            count = dictJobTitleDao.count();
        }else{
            list = dictJobTitleDao.findCodeAndNameBySaasId(saasId,pageable);
            count = dictJobTitleDao.countBySaasId(saasId);
        }
        jsonObject.put("count",count);
        jsonObject.put(SystemDictEnum.JobTitleDict.toString(),list);
        return jsonObject;
    }

+ 47 - 7
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -100,7 +100,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
     * @param docStatus
     * @return
     */
    public String getDoctorFullInfo(String nameOrIdcard,String orgCode,String docStatus,int page,int size,String sort) throws Exception {
    public JSONArray getDoctorFullInfo(String nameOrIdcard,String orgCode,String docStatus,int page,int size,String sort) throws Exception {
        List<Map<String, Object>> result = new ArrayList<>();
        String pattern = "^\\d+";
        if(StringUtils.isEmpty(nameOrIdcard) && StringUtils.isEmpty(orgCode) && StringUtils.isEmpty(docStatus)){
@ -184,8 +184,6 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        } catch (IOException e) {
            result.put("msg","convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause());
            result.put("response",ConstantUtils.FAIL);
            // 如果异常,将保存的医生信息删除
            this.delete(baseDoctorDO);
            return result.toJSONString();
        }
        baseDoctorRoleService.batchInsert(baseDoctorRoleDOList);
@ -202,9 +200,6 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        } catch (IOException e) {
            result.put("msg","convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause());
            result.put("response",ConstantUtils.FAIL);
            // 如果异常,将保存的医生信息,角色关联关系删除
            this.delete(baseDoctorDO);
            baseDoctorRoleService.delete(baseDoctorRoleDOList);
            return result.toJSONString();
        }
        baseDoctorHospitalService.batchInsert(hospitalDOList);
@ -318,7 +313,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    }
    /**
     * 获取医生已选中的机构职务树形结构
     * 获取医生已选中的机构/职务树形结构
     * @param doctorCode
     * @return
     */
@ -343,6 +338,51 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        }
        return getOrgTree(orgTreeList);
    }
    /**
     * 获取医生已选中的机构/科室树形结构
     * @param doctorCode
     * @return
     */
    public String getDoctorDeptTree(String doctorCode){
        if(StringUtils.isEmpty(doctorCode)){
            return "";
        }
        String sql = "select" +
                "  hos.doctor_code ," +
                "  hos.hosp_code as parentCode," +
                "  org.name as parentName," +
                "  hos.dept_code as childCode," +
                "  dept.name as childName" +
                " from" +
                "  base_doctor_hospital hos," +
                "  base_org org," +
                "  dict_hospital_dept dept" +
                " where" +
                "  hos.hosp_code = org.code" +
                "  and" +
                "  hos.hosp_code = dept.org_code" +
                "  and" +
                "  hos.dept_code = dept.code" +
                "  and doctor_code = '{doctorCode}'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.replace("{doctorCode}",doctorCode));
        List<OrgTree> orgTreeList = new ArrayList<>();
        for(Map<String,Object> one : list){
            OrgTree orgTreeParent = new OrgTree();
            orgTreeParent.setParentCode("");
            orgTreeParent.setCode(String.valueOf(one.get("parentCode")));
            orgTreeParent.setName(String.valueOf(one.get("parentName")));
            orgTreeList.add(orgTreeParent);
            OrgTree orgTreeChild = new OrgTree();
            orgTreeChild.setParentCode(String.valueOf(one.get("parentCode")));
            orgTreeChild.setCode(String.valueOf(one.get("childCode")));
            orgTreeChild.setName(String.valueOf(one.get("childName")));
            orgTreeList.add(orgTreeChild);
        }
        return getOrgTree(orgTreeList);
    }
    /**
     * 构建树形结构
     * @return

+ 71 - 38
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java

@ -20,12 +20,14 @@ import com.yihu.jw.base.service.user.UserRoleService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgUserDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.base.user.UserRoleDO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
@ -78,46 +80,66 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
     * @param orgStatus
     * @return
     */
    public String queryOrgBaseInfoList(String codeOrName,String orgStatus,int page,int size) throws Exception {
        List<Map<String,Object>> result = new ArrayList<>();
    public JSONObject queryOrgBaseInfoList(String codeOrName,String orgStatus,int page,int size) throws Exception {
        JSONObject result = new JSONObject();
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? size = 10 : page  * size;
        String code = null == codeOrName ? "": codeOrName;
        String name = null == codeOrName ? "": codeOrName;
        int end = 0 == size ? size = 10 : page * size;
        String code = null == codeOrName ? "" : codeOrName;
        String name = null == codeOrName ? "" : codeOrName;
        String sql = "select id,code,name,case del when 1 then '有效' else '失效' end as status,concat(province_name,city_name,town_name,address) as address " +
                "from base_org " +
                " from base_org " +
                " where " +
                " (code like '{code}' or ''='{code}')" +
                " ((code like '{code}' or ''='{code}')  and (del = '{orgStatus}' or ''='{orgStatus}'))" +
                " or " +
                " (name like '{name}' or ''='{name}') " +
                " ((name like '{name}' or ''='{name}') and (del = '{orgStatus}' or ''='{orgStatus}'))" +
                " and" +
                " (del = '{orgStatus}' or ''='{orgStatus}')" +
                " limit {start},{end}";
        String finalSql = sql.replace("{code}", "%" + code + "%")
        String finalSql = sql
                .replace("{code}", "%" + code + "%")
                .replace("{name}", "%" + name + "%")
                .replace("{orgStatus}", null == orgStatus ? "": orgStatus).replace("{start}", String.valueOf(start))
                .replace("{orgStatus}", null == orgStatus ? "" : orgStatus).replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
        result = jdbcTemplate.queryForList(finalSql);
        return JavaBeanUtils.getInstance().mapListJson(result);
        String countSql = "SELECT count(id)" +
                " FROM base_org " +
                " WHERE " +
                " ((code like '{code}' or ''='{code}')  and (del = '{orgStatus}' or ''='{orgStatus}'))" +
                " OR " +
                " ((name like '{name}' or ''='{name}') and (del = '{orgStatus}' or ''='{orgStatus}'))" +
                " AND" +
                " (del = '{orgStatus}' OR ''='{orgStatus}')";
        String finalCountSql = countSql
                .replace("{code}", "%" + code + "%")
                .replace("{name}", "%" + name + "%")
                .replace("{orgStatus}", null == orgStatus ? "" : orgStatus);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(finalSql);
        Integer count = jdbcTemplate.queryForObject(finalCountSql, Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
        return result;
    }
    /**
     * 根据id查询机构
     * 根据id查询机构,只查询机构的信息
     * @param id
     * @return
     */
    public String queryOneById(String id) throws JsonProcessingException {
    public JSONObject queryOneById(String id) throws JsonProcessingException {
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(id)){
            return "org not exist for id:"+id;
            result.put("msg","org not exist for id:"+id);
            result.put("response",ConstantUtils.FAIL);
            return result;
        }
        BaseOrgDO baseOrgDO = baseOrgDao.findOne(id);
        if(null == baseOrgDO){
            return "";
            return null;
        }
        List<BaseOrgUserDO> adminList = baseOrgUserService.findAllByOrgCode(baseOrgDO.getCode());
        JSONObject jsonObject = JSONObject.parseObject(objectMapper.writeValueAsString(baseOrgDO));
        jsonObject.put("admin",adminList);
        return jsonObject.toJSONString();
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg",baseOrgDO);
        return result;
    }
    /**
@ -127,13 +149,13 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
     */
    public String createOrUpdateOrg(BaseOrgDO baseOrgDO,JSONObject orgAdminJson){
        UserDO userDO = null;
        String mobile = orgAdminJson.getString("mobile");
        String adminName = orgAdminJson.getString("orgAdmin");
        if(StringUtils.isEmpty(mobile)){
            return "paramter for admin is null";
        }
        //id为空表示新增
        if(StringUtils.isEmpty(baseOrgDO.getId())){
            String mobile = orgAdminJson.getString("mobile");
            String adminName = orgAdminJson.getString("orgAdmin");
            if(StringUtils.isEmpty(mobile)){
                return "paramter for admin is null";
            }
            baseOrgDO.setOrgAdmin(adminName);
            baseOrgDao.save(baseOrgDO);
@ -156,15 +178,10 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
            userRoleDO.setUserId(userDO.getId());
            userRoleService.save(userRoleDO);
        }else{
            String adminId = orgAdminJson.getString("id");
            if(StringUtils.isEmpty(adminId)){
                return "paramter id for admin is null when update";
            }
            BaseOrgDO oldBaseOrgDO = baseOrgDao.findOne(baseOrgDO.getId());
            if(null == oldBaseOrgDO){
                return "no exist this org";
            }
            baseOrgDO.setOrgAdmin(adminName);
            baseOrgDao.save(baseOrgDO);
            if(!baseOrgDO.getTownCode().equalsIgnoreCase(oldBaseOrgDO.getTownCode())){
                orgTreeService.updateOrgTreeNode(oldBaseOrgDO,baseOrgDO,OrgTree.Level.town.getLevelValue());
@ -175,14 +192,6 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
            if(!baseOrgDO.getProvinceCode().equalsIgnoreCase(oldBaseOrgDO.getProvinceCode())){
                orgTreeService.updateOrgTreeNode(oldBaseOrgDO,baseOrgDO,OrgTree.Level.province.getLevelValue());
            }
            userDO = userService.findById(adminId);
            //没有修改就不保存
            if(StringUtils.endsWithIgnoreCase(adminName,userDO.getUsername()) && StringUtils.endsWithIgnoreCase(mobile,userDO.getMobile())){
                return ConstantUtils.SUCCESS;
            }
            userDO.setName(adminName);
            userDO.setMobile(mobile);
            userService.save(userDO);
        }
        return ConstantUtils.SUCCESS;
    }
@ -200,6 +209,30 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
        return baseOrgDao.existsByCode(code);
    }
    /**
     * 生效或失效单个机构
     * @param id
     * @param del
     * @return
     */
    public String enableOrDisableOrg(String id,String del){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(id) || StringUtils.isEmpty(del)){
            result.put("msg","parameter id or del is null");
            result.put("response",ConstantUtils.FAIL);
            return result.toJSONString();
        }
        BaseOrgDO baseOrgDO = baseOrgDao.findOne(id);
        if( null == baseOrgDO ){
            result.put("msg","org not exist for id:" + id);
            result.put("response",ConstantUtils.FAIL);
            return result.toJSONString();
        }
        baseOrgDO.setDel(del);
        this.save(baseOrgDO);
        result.put("response",ConstantUtils.SUCCESS);
        return result.toJSONString();
    }
    /**
     * 构建机构区域树形结构
     * @return

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/patient/BasePatientService.java

@ -49,7 +49,7 @@ public class BasePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @param patientId
     * @return
     */
    public String getPatientInfo(String patientId) throws Exception{
    public String getPatientById(String patientId) throws Exception{
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(patientId)){
            result.put("result","parameter patientId is null");

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/saas/SaasBusinessCardService.java

@ -45,7 +45,7 @@ public class SaasBusinessCardService extends BaseJpaService<SaasBusinessCardDO,
            return card;
        } else if (type == SaasBusinessCardDO.Type.patient) {
            //模拟加载居民数据
            Map<String, Object> source = basePatientService.getPatientInfo(sourceId);
            Map<String, Object> source = basePatientService.getPatientById(sourceId);
            saasBusinessCardDO.forEach(item -> card.put(item.getField(), source.get(item.getField())));
            return card;
        }

+ 74 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java

@ -26,6 +26,7 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
 * Service - 系统字典
@ -34,6 +35,9 @@ import java.util.List;
@Service
public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDao> {
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private DictIcd10Service dictIcd10Service;
@ -100,11 +104,30 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictDiseaseService.queryAll("", createPage(page,size,sorts));
        }else{
            jsonObject = this.queryAll("", createPage(page,size,sorts));
        }
        jsonArray.add(jsonObject);
        return jsonArray;
    }
    /**
     * 查询某一租户下的医院科室字典信息,如果saadId为空表示当前用户角色为超级管理员,超级管理员可以看到所有数据
     * @param saasId
     * @return
     */
    public JSONObject queryAll(String saasId, Pageable pageable) throws Exception{
        JSONObject jsonObject = new JSONObject();
        List<Map<String,Object>> list = new ArrayList<>();
        if(StringUtils.isEmpty(saasId)){
            list = systemDictDao.findCodeAndName(pageable);
        }else{
            list = systemDictDao.findCodeAndNameBySaasId(saasId,pageable);
        }
        jsonObject.put(SystemDictEnum.SystemDict.toString(),list);
        return jsonObject;
    }
    /**
     * 新增字典,包括字典项值
     * "obj": {
@ -157,4 +180,55 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
        return ConstantUtils.SUCCESS;
    }
    /**
     * 查询字典分页信息
     * @param type
     * @param userId
     * @param filters
     * @param sorts
     * @param page
     * @param size
     * @return
     */
    public JSONObject queryDictPageByType( String userId,String type,String filters,String sorts,int page,int size) throws ParseException {
        JSONObject result = new JSONObject();
        if (StringUtils.isEmpty(type) || StringUtils.isEmpty(userId)) {
            result.put("msg","parameter dictType or userId is null");
            result.put("response",ConstantUtils.FAIL);
            return result;
        }
        List list = new ArrayList();
        long count = 0;
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            list = dictIcd10Service.search(null,filters,sorts,page,size);
            count = dictIcd10Service.getCount(filters);
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
            list = dictHospitalDeptService.search(null,filters,sorts,page,size);
            count = dictHospitalDeptService.getCount(filters);
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            list = dictJobTitleService.search(null,filters,sorts,page,size);
            count = dictJobTitleService.getCount(filters);
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            list = dictHealthProblemService.search(null,filters,sorts,page,size);
            count = dictHealthProblemService.getCount(filters);
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            list = dictMedicineService.search(null,filters,sorts,page,size);
            count = dictMedicineService.getCount(filters);
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            list = dictDiseaseService.search(null,filters,sorts,page,size);
            count = dictDiseaseService.getCount(filters);
        }else{
            list = this.search(null,filters,sorts,page,size);
            count = this.getCount(filters);
        }
        result.put("response",ConstantUtils.SUCCESS);
        result.put("count",count);
        result.put("msg",list);
        return result;
    }
}

+ 3 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/util/JavaBeanUtils.java

@ -246,15 +246,15 @@ public class JavaBeanUtils {
     * map转为json
     * @return
     */
    public String mapListJson(List<Map<String, Object>> mapList) throws Exception {
    public JSONArray mapListJson(List<Map<String, Object>> mapList) throws Exception {
        JSONArray jsonArray = new JSONArray();
        if (CollectionUtils.isEmpty(mapList)) {
            return jsonArray.toJSONString();
            return jsonArray;
        }
        for(Map<String, Object> map : mapList){
            JSONObject jsonObject = JSONObject.parseObject(objectMapper.writeValueAsString(map));
            jsonArray.add(jsonObject);
        }
        return jsonArray.toJSONString();
        return jsonArray;
    }
}