diff --git a/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/PatientInfoServiceImpl.java b/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/PatientInfoServiceImpl.java index e6c8328..b28b943 100644 --- a/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/PatientInfoServiceImpl.java +++ b/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/PatientInfoServiceImpl.java @@ -18,6 +18,7 @@ import com.xinelu.familydoctor.applet.pojo.body.PatientInfoBody; import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo; import com.xinelu.familydoctor.applet.service.IPatientInfoService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -167,32 +168,33 @@ public class PatientInfoServiceImpl implements IPatientInfoService { public void register(PatientInfoBody body) { // 获取当前微信绑定的居民 List list = patientInfoMapper.getList(body.getOpenid(), body.getCityCode()); - - PatientInfo patientInfo = patientInfoMapper.isRegisterByCardNo(body.getCardNo()); - if (patientInfo == null) { - PatientInfo entity = new PatientInfo(); - BeanUtils.copyBeanProp(entity, body); - entity.setPatientCode(IdUtils.fastSimpleUUID()); - entity.setBindingTime(new Date()); - entity.setIsChecked((list == null || list.size() == 0) ? "1" : "0"); - entity.setCreateTime(new Date()); - entity.setCreateBy(body.getCardNo()); - patientInfoMapper.insertPatientInfo(entity); - } else { - if (!StringUtils.isBlank(patientInfo.getOpenid())) { - throw new ServiceException("该身份证号已被注册"); + if (ObjectUtils.isNotEmpty(body.getCardNo())) { + PatientInfo patientInfo = patientInfoMapper.isRegisterByCardNo(body.getCardNo()); + if (patientInfo == null) { + PatientInfo entity = new PatientInfo(); + BeanUtils.copyBeanProp(entity, body); + entity.setPatientCode(IdUtils.fastSimpleUUID()); + entity.setBindingTime(new Date()); + entity.setIsChecked((list == null || list.size() == 0) ? "1" : "0"); + entity.setCreateTime(new Date()); + entity.setCreateBy(body.getCardNo()); + patientInfoMapper.insertPatientInfo(entity); + } else { + if (!StringUtils.isBlank(patientInfo.getOpenid())) { + throw new ServiceException("该身份证号已被注册"); + } + patientInfo.setIsChecked((list == null || list.size() == 0) ? "1" : "0"); + patientInfo.setOpenid(body.getOpenid()); + patientInfo.setUnionid(body.getUnionid()); + patientInfo.setPatientName(body.getPatientName()); + patientInfo.setPhone(body.getPhone()); + patientInfo.setAddress(body.getAddress()); + patientInfo.setUpdateTime(new Date()); + patientInfo.setUpdateBy(body.getCardNo()); + patientInfo.setHeadPictureUrl(body.getHeadPictureUrl()); + patientInfo.setDelFlag(0); + patientInfoMapper.updatePatientInfo(patientInfo); } - patientInfo.setIsChecked((list == null || list.size() == 0) ? "1" : "0"); - patientInfo.setOpenid(body.getOpenid()); - patientInfo.setUnionid(body.getUnionid()); - patientInfo.setPatientName(body.getPatientName()); - patientInfo.setPhone(body.getPhone()); - patientInfo.setAddress(body.getAddress()); - patientInfo.setUpdateTime(new Date()); - patientInfo.setUpdateBy(body.getCardNo()); - patientInfo.setHeadPictureUrl(body.getHeadPictureUrl()); - patientInfo.setDelFlag(0); - patientInfoMapper.updatePatientInfo(patientInfo); } }