Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

yeshijie 6 years ago
parent
commit
98c8236faf

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

@ -394,6 +394,7 @@ public class BaseRequestMapping {
        public static final String docOrgDutyTreeInfo  = "/docOrgDutyTreeInfo";
        public static final String docOrgDeptTreeInfo  = "/docOrgDeptTreeInfo";
        public static final String getDoctorListByDept  = "/getDoctorListByDept";
        public static final String DOCTOR_INFO_IMPORT  = "/baseDoctorInfoImport";
    }

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictDoctorDutyDao.java

@ -18,4 +18,8 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * @since 1.
 */
public interface DictDoctorDutyDao extends PagingAndSortingRepository<DictDoctorDutyDO, Integer>, JpaSpecificationExecutor<DictDoctorDutyDO>  {
    boolean existsByCode(String code);
    DictDoctorDutyDO findByCode(String code);
}

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

@ -37,4 +37,8 @@ public interface DictHospitalDeptDao extends PagingAndSortingRepository<DictHosp
    Long countByCodeIn(String orgCode);
    boolean existsByCodeAndOrgCode(String code,String orgCode);
    DictHospitalDeptDO findByCode(String code);
}

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

@ -34,4 +34,8 @@ public interface DictJobTitleDao extends PagingAndSortingRepository<DictJobTitle
    List<DictJobTitleDO> findBySaasId(String saasId);
    Long countBySaasId(String saasId);
    DictJobTitleDO findByCode(String code);
    boolean existsByCode(String code);
}

+ 35 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/doctor/BaseDoctorEndpoint.java

@ -1,10 +1,15 @@
package com.yihu.jw.base.endpoint.doctor;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.endpoint.common.excel.AExcelReader;
import com.yihu.jw.base.endpoint.common.populationBatchImport.PopulationMsg;
import com.yihu.jw.base.service.doctor.BaseDoctorService;
import com.yihu.jw.base.service.doctor.excelImport.BaseDoctorExcelDO;
import com.yihu.jw.base.service.doctor.excelImport.BaseDoctorExcelDOReader;
import com.yihu.jw.base.service.org.OrgTreeService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.restmodel.base.doctor.BaseDoctorVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -16,12 +21,17 @@ 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.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
/**
 * 医生基础信息控制器
@ -250,4 +260,29 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
        return success(jsonObject.getJSONArray("msg"));
    }
    @PostMapping(value = BaseRequestMapping.BaseDoctor.DOCTOR_INFO_IMPORT)
    @Transactional(rollbackFor = Exception.class)
    @ApiOperation(value = "基础医生信息列表导入")
    public Envelop importData(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestPart(value = "file") MultipartFile file,
            HttpServletRequest request) throws IOException, ManageException {
        try {
            request.setCharacterEncoding("UTF-8");
            AExcelReader excelReader = new BaseDoctorExcelDOReader();
            excelReader.read(file);
            //验证未通过(暂无验证)
            List<BaseDoctorExcelDO> errorLs = excelReader.getErrorLs();
            List<BaseDoctorExcelDO> correctLs = excelReader.getCorrectLs();
            if(correctLs.size()>0){
                Map<String, Object> result = baseDoctorService.batchInsertDoctor(correctLs);
                result.put("errorLs", errorLs);
                return success("导入成功!", result);
            }
        }catch (Exception e){
            e.printStackTrace();
            return failed("导入异常,请检查导入文件格式" + e.getMessage());
        }
        return failed("导入失败");
    }
}

+ 101 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -4,9 +4,15 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.dao.dict.DictDoctorDutyDao;
import com.yihu.jw.base.dao.dict.DictHospitalDeptDao;
import com.yihu.jw.base.dao.dict.DictJobTitleDao;
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.dao.doctor.BaseDoctorHospitalDao;
import com.yihu.jw.base.dao.org.BaseOrgDao;
import com.yihu.jw.base.service.doctor.excelImport.BaseDoctorExcelDO;
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;
@ -16,9 +22,13 @@ 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.dict.DictJobTitleDO;
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;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
@ -61,6 +71,16 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private BaseOrgDao baseOrgDao;
    @Autowired
    private DictHospitalDeptDao deptDao;
    @Autowired
    private DictDoctorDutyDao dutyDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private DictJobTitleDao jobTitleDao;
    @Autowired
    private OrgTreeService orgTreeService;
@ -554,4 +574,85 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        result.put("msg",JavaBeanUtils.getInstance().mapListJson(list));
        return result;
    }
    public Map<String, Object> batchInsertDoctor(List<BaseDoctorExcelDO> doctors) throws ManageException {
        Map<String, Object> result = new HashMap<>();
        //批量存储的集合
//        int correctCount = 0;
//        List<BaseDoctorExcelDO> corrects = new ArrayList<>();
        BaseDoctorDO baseDoctorDO;
        //批量存储
        for(BaseDoctorExcelDO one:doctors){
            baseDoctorDO = new BaseDoctorDO();
            baseDoctorDO.setName(one.getName());
            baseDoctorDO.setDel(one.getDel());
            baseDoctorDO.setSex(one.getSex());
            baseDoctorDO.setIdcard(one.getIdcard());
            baseDoctorDO.setMobile(one.getMobile());
            baseDoctorDO.setIsFamous(one.getIsFamous());
            baseDoctorDO.setExpertise(one.getExpertise());
            baseDoctorDO.setIntroduce(one.getBrief());
            if(!StringUtils.isEmpty(one.getJobTitleName())){
                String[] job = one.getJobTitleName().split(",");
                String jobCode = job[0];
                DictJobTitleDO jobTitleDO = jobTitleDao.findByCode(jobCode);
                baseDoctorDO.setJobTitleCode(jobTitleDO.getCode());
                baseDoctorDO.setJobTitleName(jobTitleDO.getName());
            }
//            baseDoctorDao.save(baseDoctorDO);
            if(!StringUtils.isEmpty(one.getHospitalInfo())){
                BaseOrgDO orgDO = null;
                DictHospitalDeptDO hospitalDeptDO = null;
                DictDoctorDutyDO doctorDutyDO = null;
                String[] hospitals = one.getHospitalInfo().split(";");
                List<BaseDoctorHospitalDO> doctorHospitalList = new ArrayList<>();
                for(String hospital:hospitals){
                    String[] element = hospital.split("/");
                    String[] org = element[0].split(",");//机构
                    String[] dept = element[1].split(",");//部门
                    String[] duty = element[2].split(",");//职务
                    String orgCode = org[0];
                    String deptCode = dept[0];
                    String dutyCode = duty[0];
                    orgDO =baseOrgDao.findByCode(orgCode);
                    hospitalDeptDO = deptDao.findByCode(deptCode);
                    doctorDutyDO = dutyDao.findByCode(dutyCode);
                    //医生执业信息实体
                    BaseDoctorHospitalDO doctorHospitalDO = new BaseDoctorHospitalDO();
                    doctorHospitalDO.setOrgCode(orgDO.getCode());
                    doctorHospitalDO.setOrgName(orgDO.getName());
                    doctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
                    doctorHospitalDO.setDeptCode(hospitalDeptDO.getCode());
                    doctorHospitalDO.setDoctorDutyCode(doctorDutyDO.getCode());
                    doctorHospitalDO.setDoctorDutyName(doctorDutyDO.getName());
                    doctorHospitalDO.setDel("1");
                    doctorHospitalList.add(doctorHospitalDO);
                }
                doctorHospitalDao.save(doctorHospitalList);
                if(!StringUtils.isEmpty(one.getRoleInfo())){
                    BaseDoctorRoleDO baseDoctorRoleDO = null;
                    DictJobTitleDO dictJobTitleDO = null;
                    String[] roles = one.getRoleInfo().split(";");
                    List<BaseDoctorRoleDO> baseDoctorRoleDOList = new ArrayList<>();
                    for(String role:roles){
                        String[] element = role.split(",");
                        String roleCode = element[0];
                        dictJobTitleDO = jobTitleDao.findByCode(roleCode);
                        baseDoctorRoleDO = new BaseDoctorRoleDO();
                        baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId());
                        baseDoctorRoleDO.setRoleModuleCode(dictJobTitleDO.getCode());
                        baseDoctorRoleDO.setName(dictJobTitleDO.getName());
                        baseDoctorRoleDO.setDel("1");
                        baseDoctorRoleDOList.add(baseDoctorRoleDO);
                    }
                    baseDoctorRoleService.batchInsert(baseDoctorRoleDOList);
                }
            }
        }
        result.put("correctCount", doctors.size());
        return result;
    }
}

+ 181 - 11
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/excelImport/BaseDoctorExcelDO.java

@ -15,7 +15,7 @@ import java.util.Map;
import java.util.Set;
/**
 *  基础人口信息列表-excel实体类
 *  医生信息列表-excel实体类
 * @author lith
 * Created at 2018/10/22.
 */
@ -25,34 +25,37 @@ public class BaseDoctorExcelDO extends ExcelUtil implements Validation {
    @Location(x=0)
    @ValidRepeat
    String name;
    String name;//姓名
    @Location(x=1)
    @ValidRepeat
    String del;
    String del;//状态(1生效,0失效)
    @Location(x=2)
    @ValidRepeat
    String sex;
    Integer sex;//性别(1男2女)
    @Location(x=3)
    @ValidRepeat
    String idcard;
    String idcard;//身份证号
    @Location(x=4)
    @ValidRepeat
    String mobile;
    String mobile;//联系方式
    @Location(x=5)
    @ValidRepeat
    String hospitalInfo;
    String hospitalInfo;//机构/部门/职务
    @Location(x=6)
    @ValidRepeat
    Integer roleInfo;
    String jobTitleName;//职称
    @Location(x=7)
    @ValidRepeat
    String isFamous;
    String roleInfo;//归属业务模块角色
    @Location(x=8)
    @ValidRepeat
    Integer expertise;
    Integer isFamous;//是否名医
    @Location(x=9)
    @ValidRepeat
    String brief;
    String expertise;//专长
    @Location(x=10)
    @ValidRepeat
    String brief;//简介
    private String  saasId;
    //租户创建时间
@ -79,4 +82,171 @@ public class BaseDoctorExcelDO extends ExcelUtil implements Validation {
        return rs;
    }
    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;
    }
    public Integer getSex() {
        return sex;
    }
    public void setSex(Integer sex) {
        this.sex = sex;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getHospitalInfo() {
        return hospitalInfo;
    }
    public void setHospitalInfo(String hospitalInfo) {
        this.hospitalInfo = hospitalInfo;
    }
    public String getRoleInfo() {
        return roleInfo;
    }
    public void setRoleInfo(String roleInfo) {
        this.roleInfo = roleInfo;
    }
    public Integer getIsFamous() {
        return isFamous;
    }
    public void setIsFamous(Integer isFamous) {
        this.isFamous = isFamous;
    }
    public String getExpertise() {
        return expertise;
    }
    public void setExpertise(String expertise) {
        this.expertise = expertise;
    }
    public String getBrief() {
        return brief;
    }
    public void setBrief(String brief) {
        this.brief = brief;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public Date getSaasCreateTime() {
        return saasCreateTime;
    }
    public void setSaasCreateTime(Date saasCreateTime) {
        this.saasCreateTime = saasCreateTime;
    }
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    public String getDistrictCode() {
        return districtCode;
    }
    public void setDistrictCode(String districtCode) {
        this.districtCode = districtCode;
    }
    public String getDistrictName() {
        return districtName;
    }
    public void setDistrictName(String districtName) {
        this.districtName = districtName;
    }
    public Integer getNcdNum() {
        return ncdNum;
    }
    public void setNcdNum(Integer ncdNum) {
        this.ncdNum = ncdNum;
    }
    public int getYearNow() {
        return yearNow;
    }
    public void setYearNow(int yearNow) {
        this.yearNow = yearNow;
    }
    public String getJobTitleName() {
        return jobTitleName;
    }
    public void setJobTitleName(String jobTitleName) {
        this.jobTitleName = jobTitleName;
    }
}

+ 122 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/excelImport/BaseDoctorExcelDOReader.java

@ -0,0 +1,122 @@
package com.yihu.jw.base.service.doctor.excelImport;
import com.yihu.jw.base.dao.dict.DictDoctorDutyDao;
import com.yihu.jw.base.dao.dict.DictHospitalDeptDao;
import com.yihu.jw.base.dao.dict.DictJobTitleDao;
import com.yihu.jw.base.dao.org.BaseOrgDao;
import com.yihu.jw.base.endpoint.common.excel.AExcelReader;
import com.yihu.jw.entity.base.dict.DictJobTitleDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
/**
 * 医生信息列表-excel解析类
 * Created by 刘文彬 on 2018/10/24.
 */
public class BaseDoctorExcelDOReader extends AExcelReader {
    @Autowired
    private BaseOrgDao baseOrgDao;
    @Autowired
    private DictHospitalDeptDao deptDao;
    @Autowired
    private DictDoctorDutyDao dutyDao;
    @Autowired
    private DictJobTitleDao jobTitleDao;
    @Override
    public void read(Workbook rwb) throws Exception {
        try{
            Iterator<Sheet> sheets = rwb.sheetIterator();
            int j = 0, rows;
            BaseDoctorExcelDO baseDoctorExcelDO;
            getRepeat().put("name", new HashSet<>());
            getRepeat().put("del", new HashSet<>());
            getRepeat().put("sex", new HashSet<>());
            getRepeat().put("idcard", new HashSet<>());
            getRepeat().put("mobile", new HashSet<>());
            getRepeat().put("hospitalInfo", new HashSet<>());
            getRepeat().put("jobTitleName", new HashSet<>());
            getRepeat().put("roleInfo", new HashSet<>());
            getRepeat().put("isFamous", new HashSet<>());
            getRepeat().put("expertise", new HashSet<>());
            getRepeat().put("brief", new HashSet<>());
            while (sheets.hasNext()){
                Sheet sheet = sheets.next();
                if ((rows = sheet.getLastRowNum()) == 0) {
                    continue;
                }
                for (int i = 1; i <= rows; i++) {
                    baseDoctorExcelDO = new BaseDoctorExcelDO();
                    baseDoctorExcelDO.setName(replaceBlank(getCellCont(sheet, i, 0)));
                    baseDoctorExcelDO.setDel(replaceBlank(getCellCont(sheet, i, 1)));
                    baseDoctorExcelDO.setSex(null == getCellCont(sheet, i, 2)?null:Integer.valueOf(replaceBlank(getCellCont(sheet, i, 2)).trim()));
                    baseDoctorExcelDO.setIdcard(replaceBlank(getCellCont(sheet, i, 3)));
                    baseDoctorExcelDO.setMobile(replaceBlank(getCellCont(sheet, i, 4)));
                    baseDoctorExcelDO.setHospitalInfo(replaceBlank(getCellCont(sheet, i, 5)));
                    baseDoctorExcelDO.setJobTitleName(replaceBlank(getCellCont(sheet, i, 6)));
                    baseDoctorExcelDO.setRoleInfo(replaceBlank(getCellCont(sheet, i, 7)));
                    baseDoctorExcelDO.setIsFamous(null == getCellCont(sheet, i, 8)?null:Integer.valueOf(replaceBlank(getCellCont(sheet, i, 7)).trim()));
                    baseDoctorExcelDO.setExpertise(replaceBlank(getCellCont(sheet, i, 9)));
                    baseDoctorExcelDO.setBrief(replaceBlank(getCellCont(sheet, i, 10)));
                    baseDoctorExcelDO.setExcelSeq(i);
                    int rs = baseDoctorExcelDO.validate(repeat);
                    if (rs == 0||validate(baseDoctorExcelDO)== 0) {
                        errorLs.add(baseDoctorExcelDO);
                    } else if (rs == 1) {
                        correctLs.add(baseDoctorExcelDO);
                    }
                }
                j++;
            }
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }finally {
            if (rwb != null) {
                rwb.close();
            }
        }
    }
    public int validate(BaseDoctorExcelDO baseDoctorExcelDO) {
        int rs = 1;
        if(StringUtils.isNotEmpty(baseDoctorExcelDO.getHospitalInfo())){
            String[] hospitals = baseDoctorExcelDO.getHospitalInfo().split(";");
            for(String hospital:hospitals){
                String[] element = hospital.split("/");
                String[] org = element[0].split(",");//机构
                String[] dept = element[1].split(",");//部门
                String[] duty = element[1].split(",");//职务
                String orgCode = org[0];
                String deptCode = dept[0];
                String dutyCode = duty[0];
                if(!baseOrgDao.existsByCode(orgCode)){
                    return 0;
                }
                if(!deptDao.existsByCodeAndOrgCode(deptCode,orgCode)){
                    return 0;
                }
                if(!dutyDao.existsByCode(dutyCode)){
                    return 0;
                }
            }
        }
        if(StringUtils.isNotEmpty(baseDoctorExcelDO.getRoleInfo())){
            String[] roles = baseDoctorExcelDO.getRoleInfo().split(";");
            for(String role:roles){
                String[] element = role.split(",");
                String roleCode = element[0];
                if(jobTitleDao.existsByCode(roleCode)){
                    return 0;
                }
            }
        }
        return rs;
    }
}