From 366cd7b1e17809ea29ba9a2fe03ab5a54156da0a Mon Sep 17 00:00:00 2001 From: mengkuiliang <1464081137@qq.com> Date: Tue, 24 Oct 2023 09:03:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E6=B7=BB=E5=8A=A0=E6=9B=B4=E6=96=B0=E7=AD=BE?= =?UTF-8?q?=E7=BA=A6=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/ResidentPatientInfoMapper.java | 1 + .../impl/ResidentPatientInfoServiceImpl.java | 91 ++++++++++--------- .../register/ResidentPatientInfoMapper.xml | 1 - .../impl/NurseAppLoginServiceImpl.java | 38 +++++++- .../vo/nurseapplogin/PatientAndDiseaseVO.java | 1 + .../nurseapplogin/NurseAppLoginMapper.xml | 1 + .../mapper/patientinfo/PatientInfoMapper.java | 9 ++ .../manage/patientinfo/PatientInfoMapper.xml | 6 ++ 8 files changed, 101 insertions(+), 47 deletions(-) diff --git a/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/mapper/ResidentPatientInfoMapper.java b/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/mapper/ResidentPatientInfoMapper.java index 1a5eccc..e656909 100644 --- a/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/mapper/ResidentPatientInfoMapper.java +++ b/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/mapper/ResidentPatientInfoMapper.java @@ -103,4 +103,5 @@ public interface ResidentPatientInfoMapper { *@return PatientInfo **/ PatientInfo getPatientInfoByPatientCode(String patientCode); + } diff --git a/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/ResidentPatientInfoServiceImpl.java b/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/ResidentPatientInfoServiceImpl.java index a8db06a..3ec65cc 100644 --- a/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/ResidentPatientInfoServiceImpl.java +++ b/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/ResidentPatientInfoServiceImpl.java @@ -26,6 +26,7 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; @@ -49,6 +50,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi private AppletAccessTokenUtils appletAccessTokenUtils; @Resource private RedisTemplate redisTemplate; + /** * @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo * @Author mengkuiliang @@ -109,27 +111,27 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi **/ @Override public AppletPhoneVO getPhone(String code) throws Exception { - JSONObject result; - // 获取token - String token_url = String.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s", appletChatConfig.getAppletId(), appletChatConfig.getSecret()); - SslUtils.ignoreSsl(); - String tokenResult = HttpUtils.sendGet(token_url); - if (tokenResult == null) { - return null; - } - result = JSON.parseObject(tokenResult); - log.info("获取小程序token : {}", result.toJSONString()); - String accessToken = result.getString("access_token"); - if (StringUtils.isEmpty(accessToken)) { - return null; - } - //获取手机号 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-info/phone-number/getPhoneNumber.html - String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber" + "?access_token=" + accessToken; - JSONObject params = new JSONObject(); - params.put("code", code); - SslUtils.ignoreSsl(); - result = httpService.post(url, null, params); - return JSON.parseObject(result.toString(), AppletPhoneVO.class); + JSONObject result; + // 获取token + String token_url = String.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s", appletChatConfig.getAppletId(), appletChatConfig.getSecret()); + SslUtils.ignoreSsl(); + String tokenResult = HttpUtils.sendGet(token_url); + if (tokenResult == null) { + return null; + } + result = JSON.parseObject(tokenResult); + log.info("获取小程序token : {}", result.toJSONString()); + String accessToken = result.getString("access_token"); + if (StringUtils.isEmpty(accessToken)) { + return null; + } + //获取手机号 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-info/phone-number/getPhoneNumber.html + String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber" + "?access_token=" + accessToken; + JSONObject params = new JSONObject(); + params.put("code", code); + SslUtils.ignoreSsl(); + result = httpService.post(url, null, params); + return JSON.parseObject(result.toString(), AppletPhoneVO.class); } /** @@ -154,7 +156,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi public void register(PatientInfoBody body) { if (ObjectUtils.isNotEmpty(body.getCardNo())) { // 修改 - if(!StringUtils.isBlank(body.getPatientCode())) { + if (!StringUtils.isBlank(body.getPatientCode())) { PatientInfo patientInfo = residentPatientInfoMapper.getPatientInfoByPatientCode(body.getPatientCode()); if (ObjectUtils.isNotEmpty(patientInfo)) { BeanUtils.copyBeanProp(patientInfo, body); @@ -164,7 +166,6 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi patientInfo.setDisease("0"); } patientInfo.setLoginFlag(Long.valueOf(1)); - patientInfo.setSignNo(getSignInfo(body.getCityCode(), body.getCardNo())); updatePatientInfo(patientInfo); } // 注册 @@ -175,7 +176,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi if (patientInfo == null) { PatientInfo entity = new PatientInfo(); BeanUtils.copyBeanProp(entity, body); - if(body.getDiseaseList() != null) { + if (body.getDiseaseList() != null) { entity.setDisease(body.getDiseaseList().stream().collect(Collectors.joining(","))); } else { entity.setDisease("0"); @@ -186,7 +187,6 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi entity.setCreateTime(new Date()); entity.setCreateBy(body.getCardNo()); entity.setLoginFlag(Long.valueOf(1)); - entity.setSignNo(getSignInfo(body.getCityCode(), body.getCardNo())); residentPatientInfoMapper.insertPatientInfo(entity); } else { if (!StringUtils.isBlank(patientInfo.getOpenid())) { @@ -203,12 +203,11 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi patientInfo.setHeadPictureUrl(body.getHeadPictureUrl()); patientInfo.setDelFlag(0); patientInfo.setLoginFlag(Long.valueOf(1)); - if(body.getDiseaseList() != null) { + if (body.getDiseaseList() != null) { patientInfo.setDisease(body.getDiseaseList().stream().collect(Collectors.joining(","))); } else { patientInfo.setDisease("0"); } - patientInfo.setSignNo(getSignInfo(body.getCityCode(), body.getCardNo())); residentPatientInfoMapper.updatePatientInfo(patientInfo); } } @@ -218,15 +217,15 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi // 获取签约信息 private String getSignInfo(String region, String identity) { - if(!StringUtils.isBlank(region)) { + if (!StringUtils.isBlank(region)) { try { // 查询签约信息 String result = (String) httpService.get(SpringUtils.getFdUrl(region) + "/resident/signinfo/detail/" + identity, null, String.class); JSONObject jsonObject = JSONObject.parseObject(result); if ("1".equals(jsonObject.get("code"))) { - if(jsonObject.getJSONObject("data") != null) { + if (jsonObject.getJSONObject("data") != null) { SignInfoDetailVo signInfo = JSONObject.parseObject(jsonObject.getJSONObject("data").toJSONString(), SignInfoDetailVo.class); - if(signInfo != null) { + if (signInfo != null) { return signInfo.getSignNo(); } } @@ -278,6 +277,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi * @Param [registerCode] **/ @Override + @Transactional(rollbackFor = Exception.class) public PatientInfo switchResident(String openid, String patientCode) { PatientInfo register = residentPatientInfoMapper.selectPatientInfoByCode(patientCode); if (register == null) { @@ -294,6 +294,8 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi return residentPatientInfoMapper.selectPatientInfoByCode(patientCode); } + /** 判断2个参数是否一样 */ + /** * @return java.lang.String * @Author mengkuiliang @@ -307,25 +309,27 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi if (list == null || list.size() == 0) { return null; } + PatientInfo patientInfo = null; // 获取当前选中的 List currentList = list.stream().filter(p -> p.getIsChecked().equals("1")).collect(Collectors.toList()); if (currentList.size() > 0) { - if(!StringUtils.isBlank(currentList.get(0).getDisease())) { + if (!StringUtils.isBlank(currentList.get(0).getDisease())) { currentList.get(0).setDiseaseList(Arrays.asList(currentList.get(0).getDisease().split(","))); } - return currentList.get(0); - } else { + patientInfo = currentList.get(0); // 没有已选择的,则取最新注册的一条数据 + } else { // 更新选择标识 residentPatientInfoMapper.updateChecked(list.get(0).getPatientCode(), "1"); - if(!StringUtils.isBlank(list.get(0).getDisease())) { + if (!StringUtils.isBlank(list.get(0).getDisease())) { list.get(0).setDiseaseList(Arrays.asList(list.get(0).getDisease().split(","))); } list.get(0).setIsChecked("1"); - return list.get(0); + patientInfo = list.get(0); } + return patientInfo; } /** @@ -341,19 +345,18 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi } /** + * @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo * @Author mengkuiliang * @Description 是否已注册 * @Date 2023-10-11 011 10:46 * @Param [code] - * @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo **/ /*@Override public PatientInfo isRegistered(String code) { return getCurrentResident(getOpenId(code), null); }*/ - @Override - public HashMap login(String loginCode,String phoneCode) throws Exception { + public HashMap login(String loginCode, String phoneCode) throws Exception { HashMap HashMap = new HashMap<>(); try { SslUtils.ignoreSsl(); @@ -367,7 +370,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi throw new ServiceException(json.getString("errmsg")); } String openid = json.getString("openid"); - HashMap.put("openid",openid); + HashMap.put("openid", openid); } catch (Exception e) { throw new ServiceException(e.getMessage()); } @@ -376,17 +379,17 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi String cityCode = ""; AppletPhoneVO phone = getPhone(phoneCode); String phoneNumber = phone.getPhoneInfo().getPhoneNumber(); - HashMap.put("phone",phoneNumber); + HashMap.put("phone", phoneNumber); List infoList = residentPatientInfoMapper.selectPatientInfoByPhone(phoneNumber); - code = infoList.size()== 0 ? "0" : "1"; + code = infoList.size() == 0 ? "0" : "1"; //返回绑定城市 - if ("1".equals(code)){ + if ("1".equals(code)) { for (PatientInfo patientInfo : infoList) { cityCode = patientInfo.getCityCode(); } } - HashMap.put("code",code); - HashMap.put("cityCode",cityCode); + HashMap.put("code", code); + HashMap.put("cityCode", cityCode); return HashMap; } } diff --git a/xinelu-familydoctor/src/main/resources/mapper/register/ResidentPatientInfoMapper.xml b/xinelu-familydoctor/src/main/resources/mapper/register/ResidentPatientInfoMapper.xml index 31960eb..7c11c77 100644 --- a/xinelu-familydoctor/src/main/resources/mapper/register/ResidentPatientInfoMapper.xml +++ b/xinelu-familydoctor/src/main/resources/mapper/register/ResidentPatientInfoMapper.xml @@ -487,7 +487,6 @@ update patient_info set is_checked = #{isChecked} where patient_code = #{patientCode} -