| 
					
				 | 
			
			
				@ -5,9 +5,11 @@ import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.fasterxml.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.PatientMedicareCardDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.user.UserDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.util.ConstantUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.utils.security.MD5; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -109,20 +111,32 @@ public class BasePatientService extends BaseJpaService<BasePatientDO, BasePatien 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject jsonObject = JSONObject.parseObject(jsonData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject patient = jsonObject.getJSONObject("patient"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray patientMedicareCards = jsonObject.getJSONArray("medicareCard"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(null == patient || CollectionUtils.isEmpty(patientMedicareCards)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(null == patient){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return ConstantUtils.FAIL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO basePatientDO = objectMapper.readValue(patient.toJSONString(),BasePatientDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<PatientMedicareCardDO> list = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientMedicareCards.forEach((card)->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                list.add(objectMapper.readValue(card.toString(),PatientMedicareCardDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        basePatientDO.setSalt(randomString(5)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String password = basePatientDO.getPassword(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (org.springframework.util.StringUtils.isEmpty(password)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            password = basePatientDO.getIdcard().substring(0, 5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        basePatientDO.setPassword(MD5.md5Hex(password + "{" + basePatientDO.getSalt() + "}")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        this.save(basePatientDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        basePatientMedicardCardService.batchInsert(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<PatientMedicareCardDO> list = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!CollectionUtils.isEmpty(patientMedicareCards)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientMedicareCards.forEach((one)->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    PatientMedicareCardDO card = objectMapper.readValue(one.toString(),PatientMedicareCardDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    card.setPatientCode(basePatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    list.add(card); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientMedicardCardService.batchInsert(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ConstantUtils.SUCCESS; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -143,7 +157,10 @@ public class BasePatientService extends BaseJpaService<BasePatientDO, BasePatien 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isEmpty(basePatientDO.getId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return ConstantUtils.FAIL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO oldPatient = basePatientDao.findOne(basePatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 保存修改的居民信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        basePatientDO.setSalt(oldPatient.getSalt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        basePatientDO.setPassword(oldPatient.getPassword()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        this.save(basePatientDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Set<Object> cardIdList = basePatientMedicardCardService.findIdListByPatientCode(basePatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 有些卡可能是新增或修改的,一条一条修改居民相关的卡的信息 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -161,4 +178,5 @@ public class BasePatientService extends BaseJpaService<BasePatientDO, BasePatien 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ConstantUtils.SUCCESS; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |