Prechádzať zdrojové kódy

机构分级接口添加

huangzhiyong 6 rokov pred
rodič
commit
bf9b55860a

+ 36 - 2
src/main/java/com/yihu/ehr/basic/org/controller/OrgEndPoint.java

@ -266,8 +266,8 @@ public class OrgEndPoint extends EnvelopRestEndPoint {
    @ApiOperation(value = "根据名称获取机构编号列表")
    @RequestMapping(value = "/organizations/name", method = RequestMethod.GET)
    public List<String> getIdsByName(
            @ApiParam(name = "name", value = "机构名称", defaultValue = "")
            @RequestParam(value = "name") String name) {
            @ApiParam(name = "name", value = "机构名称",required = false, defaultValue = "")
            @RequestParam(value = "name",required = false) String name) {
        List<String> orgCodes = orgService.getCodesByName(name);
        return orgCodes;
    }
@ -678,4 +678,38 @@ public class OrgEndPoint extends EnvelopRestEndPoint {
        }
        return envelop;
    }
    @RequestMapping(value = "/organizations/list", method = RequestMethod.GET)
    @ApiOperation(value = "机构搜索-上级机构列表")
    public Envelop searchOrgsByFilters(
            @ApiParam(name = "orgName", value = "机构名称", defaultValue = "医院")
            @RequestParam(value = "orgName", required = false) String orgName) throws Exception {
        List<Organization> organizationList = orgService.getOrgsByName( orgName);
        return success(organizationList);
    }
    @RequestMapping(value = "/organizations/basics", method = RequestMethod.GET)
    @ApiOperation(value = "机构搜索-基层机构列表")
    public Envelop searchOrgByBaseCode(
            @ApiParam(name = "parentOrgCode", value = "上级机构编码", defaultValue = "jkzl")
            @RequestParam(value = "parentOrgCode", required = false) String parentOrgCode,
            @ApiParam(name = "orgName", value = "机构名称", defaultValue = "医院")
            @RequestParam(value = "orgName", required = false) String orgName) throws Exception {
        List<Organization> organizationList = orgService.getChildOrgsByName( parentOrgCode,orgName);
        return success(organizationList);
    }
    @RequestMapping(value = "/organizations/relation", method = RequestMethod.POST)
    @ApiOperation(value = "机构关系修改-上下级机构关系设定")
    public Envelop updateOrgRelation(
            @ApiParam(name = "parentOrgCode", value = "上级机构编码", defaultValue = "jkzl")
            @RequestParam(value = "parentOrgCode", required = false) String parentOrgCode,
            @ApiParam(name = "basicOrgCodes", value = "下级机构编码集合", defaultValue = "2,3,4")
            @RequestParam(value = "basicOrgCodes", required = false) List<String> basicOrgCodes) throws Exception {
         orgService.updateOrgRelations( parentOrgCode,basicOrgCodes);
        return success("设置成功!");
    }
}

+ 20 - 3
src/main/java/com/yihu/ehr/basic/org/dao/OrganizationRepository.java

@ -1,10 +1,12 @@
package com.yihu.ehr.basic.org.dao;
import com.yihu.ehr.basic.org.model.Organization;
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.query.Param;
import javax.transaction.Transactional;
import java.util.List;
/**
@ -21,7 +23,7 @@ public interface OrganizationRepository extends PagingAndSortingRepository<Organ
    List<String> fingIdsByFullnameOrShortName(@Param("name") String name);
    @Query("select org from Organization org where org.admin = :adminLoginCode and org.orgCode = :orgCode")
    List<Organization>findByOrgAdmin(@Param("orgCode")  String orgCode,@Param("adminLoginCode")  String adminLoginCode);
    List<Organization> findByOrgAdmin(@Param("orgCode") String orgCode, @Param("adminLoginCode") String adminLoginCode);
    @Query("select org from Organization org where org.orgCode in (:orgCodes)")
    List<Organization> findByOrgCodes(@Param("orgCodes") List<String> orgCodes);
@ -39,7 +41,7 @@ public interface OrganizationRepository extends PagingAndSortingRepository<Organ
    List<Organization> findOrgByCode(@Param("orgCode") String orgCode);
    @Query("select org from Organization org where org.id=:orgId and org.parentHosId=:orgPId")
    List<Organization> checkSunOrg(@Param("orgPId") int orgPId,@Param("orgId")  long orgId);
    List<Organization> checkSunOrg(@Param("orgPId") int orgPId, @Param("orgId") long orgId);
    @Query("select org from Organization org where org.fullName like %:name% or org.shortName like %:name%")
    List<Organization> fingorgByFullnameOrShortName(@Param("name") String name);
@ -65,7 +67,7 @@ public interface OrganizationRepository extends PagingAndSortingRepository<Organ
    @Query("select org.id from Organization org where org.orgCode in(:orgCode)")
    List<String> getIdByOrgCode(@Param("orgCode") List<String> orgCode);
    @Query("select org from Organization org where org.orgType='Hospital' and org.ing !='' and  org.ing is not null and org.lat!='' and org.lat is not null" )
    @Query("select org from Organization org where org.orgType='Hospital' and org.ing !='' and  org.ing is not null and org.lat!='' and org.lat is not null")
    List<Organization> getHospital();
    @Query(value = "SELECT org.* from Organizations org WHERE org.administrative_division in(SELECT id from address_dict where pid = :pid)", nativeQuery = true)
@ -79,4 +81,19 @@ public interface OrganizationRepository extends PagingAndSortingRepository<Organ
    @Query(value = "SELECT org.* from Organizations org WHERE org.administrative_division = :administrativeDivision and org.full_name like %:fullName% ", nativeQuery = true)
    List<Organization> getOrgListByAreaidAndParam(@Param("administrativeDivision") Integer administrativeDivision, @Param("fullName") String fullName);
    List<Organization> findByBaseOrgCodeIsNull();
    List<Organization> findByBaseOrgCodeIsNullAndFullNameLike(String fullName);
    List<Organization> findByBaseOrgCode(String baseOrgCode);
    List<Organization> findByBaseOrgCodeAndFullNameLike(String baseOrgCode, String fullName);
    Organization findFirstByOrgCode(String orgCode);
    @Modifying
    @Transactional
    @Query(value = "update Organization p set p.baseOrgCode=:baseOrgCode where p.orgCode in (:orgCodes)")
    void updateByOrgCodes(@Param("baseOrgCode") String baseOrgCode, @Param("orgCodes") List<String> orgCodes);
}

+ 10 - 1
src/main/java/com/yihu/ehr/basic/org/model/Organization.java

@ -249,7 +249,8 @@ public class Organization  {
    @Column(name = "term_validity_end", nullable = true)
    private String termValidityEnd;    //	有效期止
    @Column(name = "base_org_code", nullable = true)
    private String baseOrgCode;     // 上级机构编码
    public Organization() {
@ -869,4 +870,12 @@ public class Organization  {
    public void setTermValidityEnd(String termValidityEnd) {
        this.termValidityEnd = termValidityEnd;
    }
    public String getBaseOrgCode() {
        return baseOrgCode;
    }
    public void setBaseOrgCode(String baseOrgCode) {
        this.baseOrgCode = baseOrgCode;
    }
}

+ 45 - 0
src/main/java/com/yihu/ehr/basic/org/service/OrgService.java

@ -429,4 +429,49 @@ public class OrgService extends BaseJpaService<Organization, OrganizationReposit
        List<Organization> list = organizationRepository.getOrgListByAreaidAndParam(area, fullName);
        return list;
    }
    /**
     *  获取上级机构的机构列表
     *
     * @param fullName
     * @return
     */
    public List<Organization> getOrgsByName( String fullName) {
        List<Organization> list = null;
        if (StringUtils.isNotEmpty(fullName)) {
            fullName = "%" + fullName +"%";
            list = organizationRepository.findByBaseOrgCodeIsNullAndFullNameLike(fullName);
        }else {
            list = organizationRepository.findByBaseOrgCodeIsNull();
        }
        return list;
    }
    /**
     *  获取下级级机构的机构列表
     *
     * @param fullName
     * @return
     */
    public List<Organization> getChildOrgsByName(String baseOrgCode, String fullName) {
        List<Organization> list = null;
        if (StringUtils.isNotEmpty(fullName)) {
            fullName = "%" + fullName +"%";
            list = organizationRepository.findByBaseOrgCodeAndFullNameLike(baseOrgCode,fullName);
        }else {
            list = organizationRepository.findByBaseOrgCode(baseOrgCode);
        }
        return list;
    }
    /**
     * 更新机构上下级关系
     *
     * @param orgCode  上级机构编码
     * @param basicOrgCodes  下级机构编码
     */
    public void updateOrgRelations(String orgCode, List<String> basicOrgCodes) {
        organizationRepository.updateByOrgCodes(orgCode,basicOrgCodes);
    }
}