|
@ -8,6 +8,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
|
|
|
import com.yihu.wlyy.service.app.account.PatientInfoService;
|
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
|
import com.yihu.wlyy.service.message.SendMessageService;
|
|
|
import com.yihu.wlyy.util.IdcardValidator;
|
|
|
import com.yihu.wlyy.util.MD5;
|
|
|
import com.yihu.wlyy.util.RSAUtils;
|
|
@ -26,7 +27,11 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import java.net.URLDecoder;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.UUID;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* 医生端:患者分组管理
|
|
@ -48,6 +53,9 @@ public class PatientInfoController extends BaseController {
|
|
|
private SocialSecurityInfoDao socialSecurityInfoDao;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private SendMessageService sendMessageService;
|
|
|
|
|
|
/**
|
|
|
* 获取患者基本信息
|
|
|
*
|
|
@ -360,4 +368,63 @@ public class PatientInfoController extends BaseController {
|
|
|
return error(-1, "注册失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 修改居民手机号码
|
|
|
* @param patient 居民code
|
|
|
* @param newMobile 新手机号
|
|
|
* @param oldMobile 旧手机号
|
|
|
* @return
|
|
|
*/
|
|
|
@ObserverRequired
|
|
|
@RequestMapping(value = "/updateMobile", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String updatePatientMobile(@ApiParam(value = "居民code", name = "patient") @RequestParam(required = true) String patient,
|
|
|
@ApiParam(value = "新手机号", name = "newMobile") @RequestParam(required = true) String newMobile,
|
|
|
@ApiParam(value = "旧手机号", name = "oldMobile") @RequestParam(required = false) String oldMobile) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(patient)) {
|
|
|
return error(-1, "居民不允许为空!");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(newMobile)) {
|
|
|
return error(-1, "新手机号不允许为空!");
|
|
|
}
|
|
|
String keyword = "新手机号码"+newMobile;
|
|
|
if (StringUtils.isNotEmpty(oldMobile)) {
|
|
|
keyword = "原关联手机号码"+oldMobile+"变更为"+keyword;
|
|
|
}
|
|
|
String reg = "^1[34578][0-9]{9}$";
|
|
|
Pattern pattern = Pattern.compile(reg);
|
|
|
Matcher matcher = pattern.matcher(newMobile);
|
|
|
Boolean flag = matcher.matches();
|
|
|
if (!flag){
|
|
|
return error(-1, "新手机号格式不正确!");
|
|
|
}
|
|
|
Patient patient1 = patientDao.findByCode(patient);
|
|
|
String patientName = patient1.getName();
|
|
|
String openid = patient1.getOpenid();
|
|
|
int result = patientInfoService.updateMobile(patient, newMobile);
|
|
|
|
|
|
if (result == -1) {
|
|
|
return error(-1, "居民信息查找失败");
|
|
|
} else if (result == 1) {
|
|
|
String first = patientName+",您好!\n"+"您的家庭医生已将您账号关联的手机号码进行变更";
|
|
|
String remark = "您可使用新手机号码登录i健康平台";
|
|
|
String url = "/grzx/html/my-detail.html?openid=" + openid + "&toUser=" + patient + "&toName=" + patientName;
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
Boolean mark = sendMessageService.sendTemplate(10,patient,url,first,remark,patientName,format.format(new Date()),keyword);
|
|
|
if (!mark){
|
|
|
String msg = patientName+",您好!您的家庭医生已将您账号关联的手机号码变更:"+keyword+".您可以使用新手机号码登录i健康平台.";
|
|
|
sendMessageService.sendMessage(newMobile,msg);
|
|
|
}
|
|
|
return write(200, "手机号更新成功");
|
|
|
} else {
|
|
|
return write(-1, "手机号更新失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "注册失败!");
|
|
|
}
|
|
|
}
|
|
|
}
|