Browse Source

团队树形结构

LiTaohong 6 years ago
parent
commit
5277a41221

+ 0 - 62
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorRoleDictDO.java

@ -1,62 +0,0 @@
package com.yihu.jw.entity.base.doctor;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 医生角色字典实体
 * 
 * @author Administrator on  2018年09月05日
 *
 */
@Entity
@Table(name = "base_doctor_role_dict")
public class BaseDoctorRoleDictDO extends IntegerIdentityEntity {
    /**
	 * 角色code
	 */
	private String code;
    /**
	 * 角色名称:全科医生、专科医生、健康管理师、管理员等
	 */
	private String name;
    /**
	 * 作废标识,1正常,0作废
	 */
	private String del;
	@Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 0 - 65
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/doctor/BaseDoctorRoleDictVO.java

@ -1,65 +0,0 @@
package com.yihu.jw.restmodel.base.doctor;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 医生角色字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * Administrator 	1.0  2018年09月05日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseDoctorRoleDictVO", description = "医生角色字典")
public class BaseDoctorRoleDictVO extends IntegerIdentityVO{
    /**
	 * 角色code
	 */
	@ApiModelProperty(value = "角色code", example = "")
    private String code;
    /**
	 * 角色名称:全科医生、专科医生、健康管理师、管理员等
	 */
	@ApiModelProperty(value = "角色名称:全科医生、专科医生、健康管理师、管理员等", example = "")
    private String name;
    /**
	 * 作废标识,1正常,0作废
	 */
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "1")
    private String del;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 0 - 28
svr/svr-base/src/main/java/com/yihu/jw/base/dao/doctor/BaseDoctorRoleDictDao.java

@ -1,28 +0,0 @@
package com.yihu.jw.base.dao.doctor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDictDO;
import java.util.Set;
/**
 * 
 * 医生角色字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseDoctorRoleDictDao extends PagingAndSortingRepository<BaseDoctorRoleDictDO, Integer>, JpaSpecificationExecutor<BaseDoctorRoleDictDO>  {
    @Query("select id from BaseDoctorHospitalDO where doctorCode = ?1")
    Set<Object> findIdListByHospCodeAndDoctorCode(String doctorCode);
}

+ 0 - 103
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/doctor/BaseDoctorRoleDictEndpoint.java

@ -1,103 +0,0 @@
package com.yihu.jw.base.endpoint.doctor;
import com.yihu.jw.base.service.doctor.BaseDoctorRoleDictService;
import com.yihu.jw.restmodel.base.doctor.BaseDoctorRoleDictVO;
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;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDictDO;
/**
 * 医生角色字典控制器
 *
 * @version <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.BaseDoctorRoleDict.PREFIX)
@Api(value = "医生角色字典管理", description = "医生角色字典管理服务接口", tags = {"wlyy基础服务 - 医生角色字典管理服务接口"})
public class BaseDoctorRoleDictEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseDoctorRoleDictService baseDoctorRoleDictService;
    @PostMapping(value = BaseRequestMapping.BaseDoctorRoleDict.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<BaseDoctorRoleDictVO> create(
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        BaseDoctorRoleDictDO baseDoctorRoleDict = toEntity(jsonData, BaseDoctorRoleDictDO.class);
        baseDoctorRoleDict = baseDoctorRoleDictService.save(baseDoctorRoleDict);
        return success(baseDoctorRoleDict, BaseDoctorRoleDictVO.class);
    }
    @PostMapping(value = BaseRequestMapping.BaseDoctorRoleDict.DELETE)
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        baseDoctorRoleDictService.delete(ids.split(","));
        return success("删除成功");
    }
    @PostMapping(value = BaseRequestMapping.BaseDoctorRoleDict.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    public ObjEnvelop<BaseDoctorRoleDictVO> update(
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        BaseDoctorRoleDictDO baseDoctorRoleDict = toEntity(jsonData, BaseDoctorRoleDictDO.class);
        if (null == baseDoctorRoleDict.getId()) {
            return failed("ID不能为空", ObjEnvelop.class);
        }
        baseDoctorRoleDict = baseDoctorRoleDictService.save(baseDoctorRoleDict);
        return success(baseDoctorRoleDict, BaseDoctorRoleDictVO.class);
    }
    @GetMapping(value = BaseRequestMapping.BaseDoctorRoleDict.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<BaseDoctorRoleDictVO> page(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @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 {
        List<BaseDoctorRoleDictDO> baseDoctorRoleDicts = baseDoctorRoleDictService.search(fields, filters, sorts, page, size);
        int count = (int) baseDoctorRoleDictService.getCount(filters);
        return success(baseDoctorRoleDicts, count, page, size, BaseDoctorRoleDictVO.class);
    }
    @GetMapping(value = BaseRequestMapping.BaseDoctorRoleDict.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<BaseDoctorRoleDictVO> list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<BaseDoctorRoleDictDO> baseDoctorRoleDicts = baseDoctorRoleDictService.search(fields, filters, sorts);
        return success(baseDoctorRoleDicts, BaseDoctorRoleDictVO.class);
    }
}

+ 0 - 23
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorRoleDictService.java

@ -1,23 +0,0 @@
package com.yihu.jw.base.service.doctor;
import com.yihu.jw.base.dao.doctor.BaseDoctorRoleDictDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDictDO;
/**
 * 
 * 医生角色字典服务service
 * 
 * @version
 *
 * <pre>
 * Author	Version		Date		Changes
 * litaohong    1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@Service
public class BaseDoctorRoleDictService extends BaseJpaService<BaseDoctorRoleDictDO, BaseDoctorRoleDictDao> {
}

+ 82 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/team/BaseTeamService.java

@ -5,8 +5,12 @@ import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.dao.team.BaseTeamDao;
import com.yihu.jw.base.dao.team.BaseTeamMemberDao;
import com.yihu.jw.base.service.dict.DictHospitalDeptService;
import com.yihu.jw.base.service.doctor.BaseDoctorService;
import com.yihu.jw.base.service.org.OrgTree;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
@ -51,6 +55,12 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private BaseDoctorService baseDoctorService;
    @Autowired
    private DictHospitalDeptService dictHospitalDeptService;
    /**
     * 新增团队
     * @param jsonData
@ -186,4 +196,76 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
        result.put("msg",teamInfo);
        return result;
    }
    /**
     * 生成 机构/科室/医生 树形结构
     */
    public JSONObject generateOneOrgDeptDoctorTree(String orgCode,String orgName) throws Exception {
        JSONObject result = new JSONObject();
        if(org.springframework.util.StringUtils.isEmpty(orgCode) || StringUtils.isEmpty(orgName) ){
            result.put("msg","parameter orgCode or orgName is not allowed to be null");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        //获取该机构下的科室列表
        List<DictHospitalDeptDO> deptList = dictHospitalDeptService.findDeptByOrgCode(orgCode);
        StringBuilder sb = new StringBuilder();
        deptList.forEach(one -> sb.append(one.getCode()).append(","));
        //获取该机构下的医生列表
        String sql = " SELECT " +
                "  hos.doctor_code AS doctorCode," +
                "  doc.name AS doctorName," +
                "  org.code  AS orgCode," +
                "  org.name     AS orgName," +
                "  dept.code    AS deptCode," +
                "  dept.name    AS deptName" +
                " FROM " +
                "  base_doctor_hospital hos," +
                "  dict_hospital_dept dept," +
                "  base_org org," +
                "  base_doctor doc" +
                " WHERE " +
                "  hos.doctor_code = doc.id AND" +
                "  hos.org_code = org.code AND" +
                "  hos.org_code = dept.org_code AND" +
                "  hos.dept_code = dept.code AND hos.org_code = '" + orgCode +"'";
        List<Map<String,Object>> doctorList = jdbcTemplate.queryForList(sql);
        Map<String,Map<String,Object>> deptDoctorMap = new HashMap<>();
        for(Map<String,Object> doctorMap : doctorList){
            String deptCode = String.valueOf(deptDoctorMap.get("deptCode"));
            if(deptDoctorMap.containsKey(deptCode)){
                deptDoctorMap.get(deptCode).putAll(doctorMap);
            }else{
                deptDoctorMap.put(deptCode,doctorMap);
            }
        }
        List<OrgTree> orgTreeList = new ArrayList<>();
        // 循环科室医生,组装tree结构
        for(String key : deptDoctorMap.keySet()){
            OrgTree deptTree = new OrgTree();
            deptTree.setParentCode(orgCode);
            deptTree.setCode(String.valueOf(deptDoctorMap.get(key).get("deptCode")));
            deptTree.setCode(String.valueOf(deptDoctorMap.get(key).get("deptName")));
            OrgTree doctorTree = new OrgTree();
            deptTree.setParentCode(String.valueOf(deptDoctorMap.get(key).get("deptCode")));
            deptTree.setCode(String.valueOf(deptDoctorMap.get(key).get("doctorCode")));
            deptTree.setCode(String.valueOf(deptDoctorMap.get(key).get("doctorName")));
            orgTreeList.add(deptTree);
            orgTreeList.add(doctorTree);
        }
        OrgTree orgTree = new OrgTree();
        orgTree.setCode(orgCode);
        orgTree.setName(orgName);
        orgTreeList.add(orgTree);
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg",objectMapper.readValue(baseDoctorService.makeTree(orgTreeList),JSONArray.class));
        return result;
    }
}