Переглянути джерело

获取医生选中的机构/职务,机构/科室树形结构

LiTaohong 6 роки тому
батько
коміт
038ce49a40

+ 2 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorHospitalDO.java

@ -60,7 +60,7 @@ public class BaseDoctorHospitalDO extends IntegerIdentityEntity {
	    this.doctorDutyName = doctorDutyName;
    }
	@Column(name = "hosp_code")
	@Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;
    }
@ -68,7 +68,7 @@ public class BaseDoctorHospitalDO extends IntegerIdentityEntity {
        this.orgCode = orgCode;
    }
	@Column(name = "hosp_name")
	@Column(name = "org_name")
    public String getOrgName() {
        return orgName;
    }

+ 33 - 7
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/doctor/BaseDoctorRoleVO.java

@ -27,10 +27,22 @@ public class BaseDoctorRoleVO extends IntegerIdentityVO{
    private String doctorCode;
    /**
	 * 医生角色code
	 * 医生业务模块角色code
	 */
	@ApiModelProperty(value = "医生角色id", example = "")
    private String roleCode;
	@ApiModelProperty(value = "医生业务模块角色code", example = "")
    private String roleModuleCode;
    /**
	 * 医生业务模块角色名称
	 */
	@ApiModelProperty(value = "医生业务模块角色名称", example = "")
    private String name;
	/**
	 * 医生业务模块角色名称
	 */
	@ApiModelProperty(value = "医生业务模块角色说明", example = "")
    private String description;
    /**
	 * 作废标识,1正常,0作废
@ -45,11 +57,11 @@ public class BaseDoctorRoleVO extends IntegerIdentityVO{
        this.doctorCode = doctorCode;
    }
    public String getRoleCode() {
        return roleCode;
    public String getRoleModuleCode() {
        return roleModuleCode;
    }
    public void setRoleCode(String roleCode) {
        this.roleCode = roleCode;
    public void setRoleModuleCode(String roleModuleCode) {
        this.roleModuleCode = roleModuleCode;
    }
    public String getDel() {
@ -59,5 +71,19 @@ public class BaseDoctorRoleVO extends IntegerIdentityVO{
        this.del = del;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 26 - 6
sql/init.sql

@ -781,6 +781,26 @@ create table `base_message_type`
)
  ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息类型字典';
-- 功能菜单角色表
drop table IF EXISTS `base_role_menu`;
create table `base_role_menu`
(
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
  `saasid` varchar(50) DEFAULT NULL COMMENT 'saasid,每个租户',
  `code` varchar(100) DEFAULT NULL COMMENT '角色标识',
  `name` varchar(100) DEFAULT NULL COMMENT '角色名称',
  `module_id` varchar(50) not null COMMENT '业务模块id,多个用逗号分割',
  `del` varchar(1) not null COMMENT '状态,0失效,1有效',
  `create_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人名',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人',
  `update_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人名',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  primary key (id),
  key `code` (`code`)
)
  ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='业务模块角色';
-- 业务模块角色表
drop table IF EXISTS `base_role_module`;
@ -791,12 +811,12 @@ create table `base_role_module`
  `name` varchar(100) DEFAULT NULL COMMENT '角色名称',
  `module_id` varchar(50) not null COMMENT '业务模块id,多个用逗号分割',
  `del` varchar(1) not null COMMENT '状态,0失效,1有效',
  `create_user` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT '创建人',
  `create_user_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '创建人名',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_user` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT '修改人',
  `update_user_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '修改人名',
  `update_time` datetime NOT NULL COMMENT '修改时间',
  `create_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人名',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人',
  `update_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人名',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  primary key (id),
  key `code` (`code`)
)

+ 22 - 9
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/doctor/BaseDoctorEndpoint.java

@ -127,7 +127,7 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getString("msg"));
        return success(jsonObject.getJSONObject("msg"));
    }
    /**
@ -188,11 +188,16 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
     */
    @GetMapping(value = BaseRequestMapping.BaseDoctor.getOrgListByTown)
    @ApiOperation(value = "根据区域获取机构列表")
    public Envelop enableOrDisableDoctor(
    public Envelop getOrgListByTown(
            @ApiParam(name = "doctorCode", value = "townCode")
            @RequestParam(value = "doctorCode", required = true) String doctorCode,
            @ApiParam(name = "townCode", value = "townCode")
            @RequestParam(value = "townCode", required = true) String townCode) throws Exception {
        List<Map<String, Object>> result = orgTreeService.findOrgListByParentCode(townCode);
        return success(JavaBeanUtils.getInstance().mapListJson(result));
        JSONObject jsonObject = baseDoctorService.getOrgListByTownAndDoctorCode(doctorCode,townCode);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getJSONArray("msg"));
    }
    /**
@ -203,11 +208,15 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
     * @throws Exception
     */
    @GetMapping(value = BaseRequestMapping.BaseDoctor.docOrgDutyTreeInfo)
    @ApiOperation(value = "获取医生所属机构树形结构数据")
    @ApiOperation(value = "获取医生 机构/职务 树形结构数据")
    public Envelop getOrgDutyTree(
            @ApiParam(name = "doctorCode", value = "doctorCode")
            @RequestParam(value = "doctorCode", required = true) String doctorCode) throws Exception {
        return success(baseDoctorService.getDoctorDutyTree(doctorCode));
        JSONObject jsonObject = baseDoctorService.getDoctorDutyTree(doctorCode);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.get("msg"));
    }
    /**
@ -218,11 +227,15 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
     * @throws Exception
     */
    @GetMapping(value = BaseRequestMapping.BaseDoctor.docOrgDeptTreeInfo)
    @ApiOperation(value = "获取医生所属机构树形结构数据")
    @ApiOperation(value = "获取医生 机构/科室 树形结构数据")
    public Envelop getOrgDeptTree(
            @ApiParam(name = "doctorCode", value = "doctorCode")
            @RequestParam(value = "doctorCode", required = true) String doctorCode) throws Exception {
        return success(baseDoctorService.getDoctorDeptTree(doctorCode));
        JSONObject jsonObject = baseDoctorService.getDoctorDeptTree(doctorCode);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getJSONArray("msg"));
    }
    @GetMapping(value = BaseRequestMapping.BaseDoctor.getDoctorListByDept)
@ -234,7 +247,7 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getString("msg"));
        return success(jsonObject.getJSONArray("msg"));
    }
}

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/doctor/BaseDoctorRoleEndpoint.java

@ -38,7 +38,7 @@ public class BaseDoctorRoleEndpoint extends EnvelopRestEndpoint {
@Autowired
private BaseDoctorRoleService baseDoctorRoleService;
@PostMapping(value = BaseRequestMapping.BaseDoctorRole.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
@PostMapping(value = BaseRequestMapping.BaseDoctorRole.CREATE)
@ApiOperation(value = "创建")
public ObjEnvelop<BaseDoctorRoleVO> create (
    @ApiParam(name = "json_data", value = "Json数据", required = true)
@ -57,7 +57,7 @@ public ObjEnvelop<BaseDoctorRoleVO> create (
    return success("删除成功");
    }
    @PostMapping(value = BaseRequestMapping.BaseDoctorRole.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.BaseDoctorRole.UPDATE)
    @ApiOperation(value = "更新")
    public ObjEnvelop<BaseDoctorRoleVO> update (
        @ApiParam(name = "json_data", value = "Json数据", required = true)

+ 142 - 56
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -5,12 +5,17 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.dao.doctor.BaseDoctorDao;
import com.yihu.jw.base.service.dict.DictDoctorDutyService;
import com.yihu.jw.base.service.dict.DictHospitalDeptService;
import com.yihu.jw.base.service.org.OrgTree;
import com.yihu.jw.base.service.org.OrgTreeService;
import com.yihu.jw.base.service.org.tree.SimpleTree;
import com.yihu.jw.base.service.org.tree.SimpleTreeNode;
import com.yihu.jw.base.service.org.tree.TreeNode;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.entity.base.dict.DictDoctorDutyDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
@ -24,6 +29,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.text.ParseException;
import java.util.*;
/**
@ -56,6 +62,15 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private OrgTreeService orgTreeService;
    @Autowired
    private DictDoctorDutyService dictDoctorDutyService;
    @Autowired
    private DictHospitalDeptService dictHospitalDeptService;
    /**
     * 获取医生信息
@ -137,10 +152,12 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                "  where  " +
                "    doc.id = hos.doctor_code  " +
                "    and  " +
                "    hos.org_code = dept.org_code " +
                "    and " +
                "    hos.dept_code = dept.code  " +
                "    and  " +
                "    ((doc.idcard like '{idcard}' or ''= '{idcard}'  ) and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}'))  " +
                "      or  " +
                "      and  " +
                "    ((doc.name like '{name}'  or ''= '{name}' )  and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}'))  " +
                "  ) tb  " +
                "GROUP BY tb.id order by tb.create_time desc limit {start},{end} ";
@ -161,10 +178,12 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                "  where " +
                "    doc.id = hos.doctor_code " +
                "    and " +
                "    hos.org_code = dept.org_code " +
                "    and " +
                "    hos.dept_code = dept.code " +
                "    and " +
                "    ((doc.idcard like '{idcard}' or ''= '{idcard}' ) and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}')) " +
                "      or " +
                "      and " +
                "    ((doc.name like '{name}' or ''= '{name}')  and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}')) ";
        String finalCountSql = countSql
                .replace("{idcard}",nameOrIdcardValue)
@ -219,6 +238,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            for(Object object : role){
                baseDoctorRoleDO = objectMapper.readValue(object.toString(),BaseDoctorRoleDO.class);
                baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId());
                baseDoctorDO.setDel("1");
                baseDoctorRoleDOList.add(baseDoctorRoleDO);
            }
        } catch (IOException e) {
@ -265,8 +285,8 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        JSONObject doctor = jsonObject.getJSONObject("doctor");
        JSONArray role = jsonObject.getJSONArray("role");
        JSONArray hospital = jsonObject.getJSONArray("hospital");
        if(null == doctor || CollectionUtils.isEmpty(role) || CollectionUtils.isEmpty(hospital)){
            result.put("msg","parameter doctor or hospital of jsonData is null");
        if(null == doctor || CollectionUtils.isEmpty(role)){
            result.put("msg","parameter role of jsonData is null");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
@ -305,23 +325,26 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        }
        baseDoctorHospitalService.delete(roleIdList.toArray());
        // 修改医生任职机构及职业信息
        BaseDoctorHospitalDO baseDoctorHospitalDO = null;
        Set<Object> hospitalIdList = baseDoctorHospitalService.findDocHospIdList(baseDoctorDO.getId());
        try {
            for(Object object : hospital){
                baseDoctorHospitalDO = objectMapper.readValue(object.toString(),BaseDoctorHospitalDO.class);
                if(hospitalIdList.contains(baseDoctorHospitalDO.getId())){
                    hospitalIdList.remove(baseDoctorHospitalDO.getId());
                }
                baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
                baseDoctorHospitalService.save(baseDoctorHospitalDO);
            }
        } catch (IOException e) {
            result.put("msg","convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause());
            result.put("response",ConstantUtils.FAIL);
        }
        baseDoctorHospitalService.delete(hospitalIdList.toArray());
        // 修改医生任职机构及职业信息,前端不修改就不做任何操作
         if(!CollectionUtils.isEmpty(hospital)){
             BaseDoctorHospitalDO baseDoctorHospitalDO = null;
             Set<Object> hospitalIdList = baseDoctorHospitalService.findDocHospIdList(baseDoctorDO.getId());
             try {
                 for(Object object : hospital){
                     baseDoctorHospitalDO = objectMapper.readValue(object.toString(),BaseDoctorHospitalDO.class);
                     if(hospitalIdList.contains(baseDoctorHospitalDO.getId())){
                         hospitalIdList.remove(baseDoctorHospitalDO.getId());
                     }
                     baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
                     baseDoctorHospitalService.save(baseDoctorHospitalDO);
                 }
             } catch (IOException e) {
                 result.put("msg","convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause());
                 result.put("response",ConstantUtils.FAIL);
             }
             baseDoctorHospitalService.delete(hospitalIdList.toArray());
         }
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg",baseDoctorDO);
        return result.toJSONString();
@ -353,30 +376,79 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    }
    /**
     * 获取医生已选中的机构/职务树形结构
     * 获取医生已选中的区县/机构列表,当有机构是被选中时,要标有checked=true的状态前端加载生成树形机构,
     * @param doctorCode
     * @return
     */
    public String getDoctorDutyTree(String doctorCode){
    public JSONObject getOrgListByTownAndDoctorCode(String doctorCode,String townCode) throws Exception {
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(townCode)){
            result.put("msg","townCode is not allowed to be null");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        List<Map<String, Object>> list = new ArrayList<>();
        list  = orgTreeService.findOrgListByParentCode(townCode);
        if(StringUtils.isEmpty(doctorCode)){
            return "";
            result.put("response", ConstantUtils.SUCCESS);
            result.put("msg",list);
            return result;
        }
        List<BaseDoctorHospitalDO> list = baseDoctorHospitalService.getOrgAndDutyListByDoctorCode(doctorCode);
        Map<String,Map<String, Object>> orgCodeMap = new HashMap<>();
        list.forEach( one-> orgCodeMap.put(String.valueOf(one.get("code")),one));
        List<BaseDoctorHospitalDO> selectedList = baseDoctorHospitalService.getOrgAndDutyListByDoctorCode(doctorCode);
        for(BaseDoctorHospitalDO one : selectedList){
            if(orgCodeMap.containsKey(one.getOrgCode())){
                orgCodeMap.get(one.getOrgCode()).put("checked",true);
            }
        }
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg",JavaBeanUtils.getInstance().mapListJson(orgCodeMap.values()));
        return result;
    }
    /**
     * 获取医生已选中的机构/职务树形结构,当有机构是被选中时,要标有checked=true的状态
     * @param doctorCode
     * @return
     */
    public JSONObject getDoctorDutyTree(String doctorCode) throws Exception {
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(doctorCode)){
            result.put("msg","doctorCode is not allowed to be null");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        List<DictDoctorDutyDO> dutyDOList = dictDoctorDutyService.search(null);
        List<BaseDoctorHospitalDO> selectedDutylist = baseDoctorHospitalService.getOrgAndDutyListByDoctorCode(doctorCode);
        Set<Object> selectedDutySet = new HashSet<>();
        selectedDutylist.forEach( one -> selectedDutySet.add(one.getDoctorDutyCode()) );
        List<OrgTree> orgTreeList = new ArrayList<>();
        for(BaseDoctorHospitalDO one : list){
        for(BaseDoctorHospitalDO one : selectedDutylist){
            OrgTree orgTreeParent = new OrgTree();
            orgTreeParent.setParentCode("");
            orgTreeParent.setCode(one.getOrgCode());
            orgTreeParent.setName(one.getOrgName());
            orgTreeList.add(orgTreeParent);
            OrgTree orgTreeChild = new OrgTree();
            orgTreeChild.setParentCode(one.getOrgCode());
            orgTreeChild.setCode(one.getDoctorDutyCode());
            orgTreeChild.setName(one.getDoctorDutyName());
            orgTreeList.add(orgTreeChild);
            for(DictDoctorDutyDO dictDoctorDutyDO :dutyDOList){
                OrgTree orgTreeChild = new OrgTree();
                orgTreeChild.setParentCode(one.getOrgCode());
                orgTreeChild.setCode(dictDoctorDutyDO.getCode());
                orgTreeChild.setName(dictDoctorDutyDO.getName());
                if(selectedDutySet.contains(dictDoctorDutyDO.getCode())){
                    orgTreeParent.setChecked(true);
                    orgTreeChild.setChecked(true);
                }
                orgTreeList.add(orgTreeChild);
            }
        }
        return getOrgTree(orgTreeList);
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg", objectMapper.readValue(makeTree(orgTreeList),JSONArray.class));
        return result;
    }
    /**
@ -384,50 +456,65 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
     * @param doctorCode
     * @return
     */
    public String getDoctorDeptTree(String doctorCode){
    public JSONObject getDoctorDeptTree(String doctorCode) throws Exception {
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(doctorCode)){
            return "";
            result.put("msg","doctorCode is not allowed to be null");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        String sql = "select" +
        String deptSql = "select" +
                "  hos.doctor_code ," +
                "  hos.hosp_code as parentCode," +
                "  org.name as parentName," +
                "  hos.dept_code as childCode," +
                "  dept.name as childName" +
                "  hos.org_code as orgCode," +
                "  org.name as orgName," +
                "  dept.code as deptCode," +
                "  dept.name as deptName" +
                " 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" +
                "  hos.org_code = org.code" +
                "  and" +
                "  hos.dept_code = dept.code" +
                "  and doctor_code = '{doctorCode}'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.replace("{doctorCode}",doctorCode));
                "  hos.org_code = dept.org_code";
        String doctorSelectedDeptSql = deptSql + " and  hos.dept_code = dept.code and hos.doctor_code = '{doctorCode}'";
        List<Map<String,Object>> selectedDeptlist = jdbcTemplate.queryForList(doctorSelectedDeptSql.replace("{doctorCode}",doctorCode));
        List<Map<String,Object>> deptList = jdbcTemplate.queryForList(deptSql);
        Set<String> selectedDeptCodeSet = new HashSet<>();
        selectedDeptlist.forEach( one -> selectedDeptCodeSet.add(String.valueOf(one.get("orgCode")) + String.valueOf(one.get("deptCode"))));
        List<OrgTree> orgTreeList = new ArrayList<>();
        for(Map<String,Object> one : list){
        for(Map<String,Object> one : selectedDeptlist){
            OrgTree orgTreeParent = new OrgTree();
            orgTreeParent.setParentCode("");
            orgTreeParent.setCode(String.valueOf(one.get("parentCode")));
            orgTreeParent.setName(String.valueOf(one.get("parentName")));
            orgTreeParent.setCode(String.valueOf(one.get("orgCode")));
            orgTreeParent.setName(String.valueOf(one.get("orgName")));
            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);
            for(Map<String,Object> dept :deptList){
                OrgTree orgTreeChild = new OrgTree();
                orgTreeChild.setParentCode(String.valueOf(dept.get("orgCode")));
                orgTreeChild.setCode(String.valueOf(dept.get("deptCode")));
                orgTreeChild.setName(String.valueOf(dept.get("deptName")));
                orgTreeList.add(orgTreeChild);
                if(selectedDeptCodeSet.contains(String.valueOf(dept.get("orgCode")) + dept.get("deptCode"))){
                    orgTreeParent.setChecked(true);
                    orgTreeChild.setChecked(true);
                }
            }
        }
        return getOrgTree(orgTreeList);
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg",objectMapper.readValue(makeTree(orgTreeList),JSONArray.class));
        return result;
    }
    /**
     * 构建树形结构
     * @return
     */
    public String getOrgTree(List<OrgTree> orgTreeList ){
    public String makeTree(List<OrgTree> orgTreeList ){
        List<TreeNode> treeNodes = new ArrayList<>();
        treeNodes.addAll(orgTreeList);
        SimpleTree tree = new SimpleTree(treeNodes);
@ -435,7 +522,6 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
        filter.getExcludes().add("parent");
        filter.getExcludes().add("allChildren");
        filter.getExcludes().add("parentNodeId");
        filter.getExcludes().add("orderNum");
        filter.getExcludes().add("level");
        return JSONObject.toJSONString(treeNode, filter);

+ 16 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/OrgTree.java

@ -6,6 +6,7 @@ import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name = "org_tree")
@ -16,6 +17,8 @@ public class OrgTree extends IntegerIdentityEntity implements TreeNode {
    //当前树节点所在层级,例如省在第一级,用0表示
    private Integer level;
    private boolean checked;
    public enum Level{
        province(0),
        city(1),
@ -63,6 +66,11 @@ public class OrgTree extends IntegerIdentityEntity implements TreeNode {
        return null;
    }
    @Override
    public boolean extractChecked() {
        return this.checked;
    }
    @Column(name = "code", nullable = false)
    public String getCode() {
        return code;
@ -99,4 +107,12 @@ public class OrgTree extends IntegerIdentityEntity implements TreeNode {
        this.level = level;
    }
    @Transient
    public boolean isChecked() {
        return checked;
    }
    public void setChecked(boolean checked) {
        this.checked = checked;
    }
}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/tree/SimpleTree.java

@ -18,7 +18,7 @@ public class SimpleTree implements Tree{
        SimpleTreeNode treeNode = null;
        for(TreeNode item : list){
            treeNode = new SimpleTreeNode(item);
            treeNodesMap.put(treeNode.getNodeId(), treeNode);
            treeNodesMap.put(treeNode.getParentNodeId() + treeNode.getNodeId(), treeNode);
        }
        Iterator<SimpleTreeNode> iter = treeNodesMap.values().iterator();

+ 13 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/tree/SimpleTreeNode.java

@ -21,9 +21,12 @@ public class SimpleTreeNode {
    //节点所在的层级
    @JSONField(ordinal=5)
    private int level;
    //节点是否被选中
    @JSONField(ordinal=6)
    private boolean checked;
    private SimpleTreeNode parent;
    //当前节点的二子节点
    @JSONField(ordinal=6)
    @JSONField(ordinal=7)
    private List<SimpleTreeNode> children = new ArrayList<>();
    //当前节点的子孙节点
    private List<SimpleTreeNode> allChildren = new ArrayList<>();
@ -32,7 +35,7 @@ public class SimpleTreeNode {
        this.nodeId = obj.extractNodeId();
        this.nodeName = obj.extractNodeName();
        this.parentNodeId = obj.extractNodeParentId();
//        this.orderNum = obj.extractOrderNum();
        this.checked = obj.extractChecked();
    }
    public void addChild(SimpleTreeNode treeNode){
        this.children.add(treeNode);
@ -83,6 +86,14 @@ public class SimpleTreeNode {
        this.orderNum = orderNum;
    }
    public boolean isChecked() {
        return checked;
    }
    public void setChecked(boolean checked) {
        this.checked = checked;
    }
    public List<SimpleTreeNode> getAllChildren() {
        if(this.allChildren.isEmpty()){
            for(SimpleTreeNode treeNode : this.children){

+ 1 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/tree/TreeNode.java

@ -5,4 +5,5 @@ public interface TreeNode {
    String extractNodeName();
    String extractNodeParentId();
    Integer extractOrderNum();
    boolean extractChecked();
}

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

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