#2398 导入居民

병합
shikejing shikejing/dev 에서 Amoy2/dev 로 2 commits 를 머지했습니다 3 년 전

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorDao.java

@ -40,6 +40,9 @@ public interface BaseDoctorDao extends PagingAndSortingRepository<BaseDoctorDO,
    List<BaseDoctorDO> findByIdcard(String idcard);
    List<BaseDoctorDO> findByIdcard(String idcard);
    @Query("from BaseDoctorDO d where d.name = ?1 AND d.del ='1'")
    BaseDoctorDO findByNameAndDel(String name);
    @Query("from BaseDoctorDO d where d.idcard = ?1 AND d.del ='1'")
    @Query("from BaseDoctorDO d where d.idcard = ?1 AND d.del ='1'")
    BaseDoctorDO findByIdcardAndDel(String id);
    BaseDoctorDO findByIdcardAndDel(String id);
    @Query("from BaseDoctorDO d where d.mobile = ?1")
    @Query("from BaseDoctorDO d where d.mobile = ?1")

+ 16 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/servicePackage/ServicePackageRecordDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.base.dao.servicePackage;
import com.yihu.jw.entity.base.servicePackage.ServicePackageRecordDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2021/2/25.
 */
public interface ServicePackageRecordDao extends PagingAndSortingRepository<ServicePackageRecordDO, String>, JpaSpecificationExecutor<ServicePackageRecordDO> {
    List<ServicePackageRecordDO> findBySignId(String signId);
}

+ 6 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/team/BaseTeamDao.java

@ -1,5 +1,6 @@
package com.yihu.jw.base.dao.team;
package com.yihu.jw.base.dao.team;
import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -8,6 +9,7 @@ import com.yihu.jw.entity.base.team.BaseTeamDO;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
import java.util.Set;
/**
/**
 * 
 * 
@ -24,4 +26,8 @@ import java.util.Map;
public interface BaseTeamDao extends PagingAndSortingRepository<BaseTeamDO, String>, JpaSpecificationExecutor<BaseTeamDO>  {
public interface BaseTeamDao extends PagingAndSortingRepository<BaseTeamDO, String>, JpaSpecificationExecutor<BaseTeamDO>  {
    @Query("select orgCode as code,orgName as name from BaseTeamDO")
    @Query("select orgCode as code,orgName as name from BaseTeamDO")
    List<Map<String,Object>> getTeamOrgList();
    List<Map<String,Object>> getTeamOrgList();
    @Query(" from BaseTeamDO t where t.name = ?1")
    BaseTeamDO findByName(String teamCode);
 }
 }

+ 22 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/team/WlyyPatientLabelDao.java

@ -0,0 +1,22 @@
package com.yihu.jw.base.dao.team;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2021/4/7.
 */
public interface WlyyPatientLabelDao extends PagingAndSortingRepository<WlyyPatientLabelDO, String>, JpaSpecificationExecutor<WlyyPatientLabelDO> {
    @Modifying
    @Query("delete WlyyPatientLabelDO a where a.patient=?1 and a.labelType=?2")
    int deleteByPatientAndLabelType(String patient, String labelType) throws Exception;
    @Query("from WlyyPatientLabelDO w where  w.patient=?1 group by w.labelType,w.labelCode order by w.czrq desc")
    List<WlyyPatientLabelDO> findByPatient(String patient);
}

+ 99 - 9
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/patient/BasePatientEndpoint.java

@ -3,15 +3,28 @@ package com.yihu.jw.base.endpoint.patient;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.base.dao.servicePackage.ServicePackageRecordDao;
import com.yihu.jw.base.dao.servicePackage.ServicePackageSignRecordDao;
import com.yihu.jw.base.dao.sign.ArchiveDao;
import com.yihu.jw.base.dao.team.BaseTeamDao;
import com.yihu.jw.base.dao.team.WlyyPatientLabelDao;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageRecordDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.restmodel.base.patient.BasePatientVO;
import com.yihu.jw.restmodel.base.patient.BasePatientVO;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.utils.date.DateUtil;
import com.yihu.utils.security.MD5;
import com.yihu.utils.security.MD5;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
@ -47,6 +60,18 @@ public class BasePatientEndpoint extends EnvelopRestEndpoint {
    private BasePatientService basePatientService;
    private BasePatientService basePatientService;
    @Autowired
    @Autowired
    private BasePatientDao basePatientDao;
    private BasePatientDao basePatientDao;
    @Autowired
    private ServicePackageSignRecordDao servicePackageSignRecordDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BaseTeamDao baseTeamDao;
    @Autowired
    private ServicePackageRecordDao servicePackageRecordDao;
    @Autowired
    private ArchiveDao archiveDao;
    @Autowired
    private WlyyPatientLabelDao patientLabelDao;
    @PostMapping(value = BaseRequestMapping.BasePatient.CREATE)
    @PostMapping(value = BaseRequestMapping.BasePatient.CREATE)
    @ApiOperation(value = "创建")
    @ApiOperation(value = "创建")
@ -192,7 +217,12 @@ public class BasePatientEndpoint extends EnvelopRestEndpoint {
    /**
    /**
     *  如果添加失败,注释MultipartConfig配置
     *   如果添加失败,注释MultipartConfig配置
     *   如果导入失败,将Excel修改为97-2003版本.xls
     *   签约服务包id固定
     *   签约日期 开始时间为当前时间,结束时间为2023-12-31 23:59:59
     *   patientLabelDO.setLabelType("1");  居民标签类型 固定为能力完好
     *   patientLabelDO.setLabelCode("0");  居民标签类型 固定为能力完好
     * @param request
     * @param request
     * @param file
     * @param file
     * @return
     * @return
@ -201,6 +231,11 @@ public class BasePatientEndpoint extends EnvelopRestEndpoint {
    @ResponseBody
    @ResponseBody
    public ObjEnvelop importPatientFromExcel(HttpServletRequest request, @ApiParam(value = "文件", required = true)
    public ObjEnvelop importPatientFromExcel(HttpServletRequest request, @ApiParam(value = "文件", required = true)
    @RequestParam(value = "file", required = true) MultipartFile file) {
    @RequestParam(value = "file", required = true) MultipartFile file) {
        Calendar c1 = Calendar.getInstance();
        /**
         * c1  签约结束时间
         */
        c1.set(2023, 12 - 1, 31,23,59,59);
        List errorLs = new ArrayList<>();
        List errorLs = new ArrayList<>();
        List correctLs = new ArrayList<>();
        List correctLs = new ArrayList<>();
        List idcardList = new ArrayList<>();
        List idcardList = new ArrayList<>();
@ -282,25 +317,80 @@ public class BasePatientEndpoint extends EnvelopRestEndpoint {
                String salt = UUID.randomUUID().toString().substring(0,5);
                String salt = UUID.randomUUID().toString().substring(0,5);
                basePatientVO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                basePatientVO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                basePatientVO.setSalt(salt);
                basePatientVO.setSalt(salt);
                correctLs.add(basePatientVO);
                infoMap.put("idcard",idcard);
                infoMap.put("idcard",idcard);
                infoMap.put("signTeam",signTeam);
                infoMap.put("signTeam",signTeam);
                infoMap.put("label",label);
                infoMap.put("label",label);
                correctLs.add(basePatientVO);
                idcardList.add(infoMap);
                idcardList.add(infoMap);
            }
            }
            basePatientDao.save(correctLs);
            basePatientDao.save(correctLs);
            String patient= "";
            /**
            /**
             * 添加签约数据
             * 添加签约数据
             */
             */
            if (idcardList.size() > 0) {
            if (idcardList.size() > 0) {
                for (int i=0;i<idcardList.size();i++) {
                for (int i=0;i<idcardList.size();i++) {
                    idcard = retOne(idcardList.get(i).toString(),"idcard").toString();
                    signTeam = retOne(idcardList.get(i).toString(),"signTeam").toString();
                    label = retOne(idcardList.get(i).toString(),"label").toString();
                    System.out.println(idcard + "   " + signTeam + "    " + label);
                    //330103193308210720   虹园/稻香园服务团队    能力完好
                    ServicePackageSignRecordDO signRecordDO = new ServicePackageSignRecordDO();
                    BasePatientDO basePatientVO = new BasePatientDO();
                    try {
                        idcard = retOne(idcardList.get(i).toString(),"idcard").toString();
                        signTeam = retOne(idcardList.get(i).toString(),"signTeam").toString();
                        label = retOne(idcardList.get(i).toString(),"label").toString();
                        basePatientVO = basePatientDao.findByIdcardAndDel(idcard,"1");
                        if (basePatientVO == null) {
                            errorMsgMap.put(idcard,"居民信息获取失败");
                            continue;
                        }
                        patient = basePatientVO.getId();
                        name = basePatientVO.getName();
                        signRecordDO.setPatient(patient);
                        signRecordDO.setName(name);
                        signRecordDO.setStatus(1);
                        signRecordDO.setStartTime(new Date());
                        signRecordDO.setEndTime(c1.getTime());
                        BaseTeamDO teamDO = baseTeamDao.findByName(signTeam);
                        if (teamDO == null) {
                            errorMsgMap.put(idcard,"团队信息获取失败");
                            continue;
                        }
                        BaseDoctorDO doctorDO = baseDoctorDao.findById(teamDO.getLeaderCode());
                        if (doctorDO == null) {
                            errorMsgMap.put(idcard,"医生信息获取失败");
                            continue;
                        }
                        signRecordDO.setSignDoctor(doctorDO.getId());
                        signRecordDO.setSignDoctorName(doctorDO.getName());
                        signRecordDO = servicePackageSignRecordDao.save(signRecordDO);
                        ServicePackageRecordDO packageRecordDO = new ServicePackageRecordDO();
                        packageRecordDO.setSignId(signRecordDO.getId());
                        packageRecordDO.setServicePackageId("8a92aba97b48824a017b56c5ee710019");
                        packageRecordDO.setPatient(patient);
                        packageRecordDO.setCreateTime(new Date());
                        packageRecordDO.setTeamCode(teamDO.getId());
                        servicePackageRecordDao.save(packageRecordDO);
                        //建档状态
                        ArchiveDO archiveDO = new ArchiveDO();
                        archiveDO.setCreateTime(new Date());
                        archiveDO.setArchiveOperatorName(doctorDO.getName());
                        archiveDO.setDoctorCode(doctorDO.getId());
                        archiveDO.setPatient(patient);
                        archiveDO.setSickName(name);
                        archiveDO.setIdcard(idcard);
                        archiveDO.setSignStatus(1);
                        archiveDao.save(archiveDO);
                        //居民标签
                        WlyyPatientLabelDO patientLabelDO = new WlyyPatientLabelDO();
                        patientLabelDO.setCzrq(new Date());
                        patientLabelDO.setLabelType("1");
                        patientLabelDO.setPatient(patient);
                        patientLabelDO.setLabelCode("0");
                        patientLabelDO.setLabelName(label);
                        patientLabelDao.save(patientLabelDO);
                        basePatientVO.setSignStatus(1);
                        basePatientDao.save(basePatientVO);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                }
            }
            }