| 
					
				 | 
			
			
				@ -36,6 +36,7 @@ import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -82,6 +83,88 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DictService dictService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void addPatientSignList(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String lableCode = "0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //根据idcard/mobile导入居民信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT p.idcard,p.id,p.`name`,d.id AS doctor,d.name AS doctorName,pa.start,pa.end,pa.service_package AS servicePackage,pa.team_code AS teamCode FROM base_patient_add pa,base_patient p,base_doctor d WHERE d.mobile = pa.mobile AND d.del = 1 AND pa.del = 1 AND p.del =1 AND p.idcard = pa.idcard OR p.mobile = pa.mobile group by p.id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ServicePackageSignRecordDO signRecordDO = new ServicePackageSignRecordDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientId = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientName = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctorId = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctorName = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String idcard = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String signId = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i=0;i<mapList.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientId = (String) mapList.get(i).get("id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientName = (String) mapList.get(i).get("name"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                doctorId = (String) mapList.get(i).get("doctor"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                doctorName = (String) mapList.get(i).get("doctorName"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                idcard = (String) mapList.get(i).get("idcard"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<ServicePackageSignRecordDO> signRecordDOs = servicePackageSignRecordDao.findByStatusAndPatient(1,patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (signRecordDOs.size() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    signRecordDO.setPatient(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    signRecordDO.setName(patientName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    signRecordDO.setSignDoctor(doctorId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    signRecordDO.setSignDoctorName(doctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNotBlank((String) mapList.get(i).get("start"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        signRecordDO.setStartTime((Date) mapList.get(i).get("start")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        signRecordDO.setStartTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNotBlank((String) mapList.get(i).get("end"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        signRecordDO.setEndTime((Date) mapList.get(i).get("end")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        signRecordDO.setEndTime(new Date(System.currentTimeMillis() + 365*24*60*60*1000)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    signRecordDO.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    servicePackageSignRecordDao.save(signRecordDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    ServicePackageRecordDO packageRecordDO = new ServicePackageRecordDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    packageRecordDO.setPatient(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    packageRecordDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    packageRecordDO.setSignId(signRecordDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    packageRecordDO.setServicePackageId((String) mapList.get(i).get("servicePackage")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    packageRecordDO.setTeamCode((String) mapList.get(i).get("teamCode")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    servicePackageRecordDao.save(packageRecordDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //建档状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    ArchiveDO archiveDO = new ArchiveDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    archiveDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    archiveDO.setArchiveOperatorName(doctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    archiveDO.setPatient(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    archiveDO.setSickName(patientName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    archiveDO.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    archiveDO.setSignStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    archiveDao.save(archiveDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //居民标签 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    WlyyPatientLabelDO patientLabelDO = new WlyyPatientLabelDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientLabelDO.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientLabelDO.setLabelType("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientLabelDO.setPatient((String) mapList.get(i).get("patient")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientLabelDO.setLabelCode(lableCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientLabelDO.setLabelName(dictService.fingByNameAndCode(ConstantUtil.DICT_SERVICE_TYPE,lableCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientLabelDao.save(patientLabelDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //修改base_patient_add里面的del,状态修改成0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    logger.info("居民已签约,patient:"+patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.info(e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查找签约机构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 |