From 8775d6fe01daa56c0b250d86954bcb16e916b37a Mon Sep 17 00:00:00 2001 From: zhangheng <3226558941@qq.com> Date: Wed, 3 Jul 2024 15:45:30 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LabelFieldInfoController.java | 6 +++- .../TaskPartitionDictMapper.java | 3 ++ .../tasktypedict/TaskTypeDictMapper.java | 8 +++++ .../ILabelFieldInfoService.java | 8 ++++- .../impl/LabelFieldInfoServiceImpl.java | 28 +++++++++++++++-- .../SpecialDiseaseNodeVO.java | 2 ++ .../vo/tasktypedict/TaskTypeDictVO.java | 30 +++++++++++++++++++ .../SpecialDiseaseNodeMapper.xml | 16 +++++----- .../TaskPartitionDictMapper.xml | 8 +++++ .../tasktypedict/TaskTypeDictMapper.xml | 6 ++++ 10 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/vo/tasktypedict/TaskTypeDictVO.java diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/labelfieldinfo/LabelFieldInfoController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/labelfieldinfo/LabelFieldInfoController.java index cd525f84..a83e7042 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/labelfieldinfo/LabelFieldInfoController.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/labelfieldinfo/LabelFieldInfoController.java @@ -10,7 +10,6 @@ import com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo; import com.xinelu.manage.dto.labelfieldinfo.LabelFieldInfoAddDTO; import com.xinelu.manage.service.labelfieldinfo.ILabelFieldInfoService; import com.xinelu.manage.vo.labelfieldinfo.LabelFieldTreeVO; -import com.xinelu.manage.vo.labelfieldinfo.LabelFieldVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; @@ -116,4 +115,9 @@ public class LabelFieldInfoController extends BaseController { public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(labelFieldInfoService.deleteLabelFieldInfoByIds(ids)); } + + @GetMapping("/taskTypeGrouping") + public AjaxResult taskTypeGrouping() { + return labelFieldInfoService.taskTypeGrouping(); + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/taskpartitiondict/TaskPartitionDictMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/taskpartitiondict/TaskPartitionDictMapper.java index 413096b9..4ec120fa 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/taskpartitiondict/TaskPartitionDictMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/taskpartitiondict/TaskPartitionDictMapper.java @@ -1,6 +1,7 @@ package com.xinelu.manage.mapper.taskpartitiondict; import com.xinelu.manage.domain.taskpartitiondict.TaskPartitionDict; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -59,4 +60,6 @@ public interface TaskPartitionDictMapper { * @return 结果 */ int deleteTaskPartitionDictByIds(Long[] ids); + + List selectTaskPartitionList( List ids); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/tasktypedict/TaskTypeDictMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/tasktypedict/TaskTypeDictMapper.java index 36374dfb..365b1b94 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/tasktypedict/TaskTypeDictMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/tasktypedict/TaskTypeDictMapper.java @@ -1,6 +1,7 @@ package com.xinelu.manage.mapper.tasktypedict; import com.xinelu.manage.domain.tasktypedict.TaskTypeDict; +import com.xinelu.manage.vo.tasktypedict.TaskTypeDictVO; import java.util.List; @@ -59,4 +60,11 @@ public interface TaskTypeDictMapper { * @return 结果 */ public int deleteTaskTypeDictByIds(Long[] ids); + + /** + * 查询任务类型字典列表 + * + * @return 任务类型字典集合 + */ + List selectTaskTypeDicts(); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldinfo/ILabelFieldInfoService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldinfo/ILabelFieldInfoService.java index 22e55ea6..161964c5 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldinfo/ILabelFieldInfoService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldinfo/ILabelFieldInfoService.java @@ -4,7 +4,6 @@ import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo; import com.xinelu.manage.dto.labelfieldinfo.LabelFieldInfoAddDTO; import com.xinelu.manage.vo.labelfieldinfo.LabelFieldTreeVO; -import com.xinelu.manage.vo.labelfieldinfo.LabelFieldVO; import java.util.List; @@ -75,4 +74,11 @@ public interface ILabelFieldInfoService { * 批量新增标签字段信息 */ int insertLabelFieldInfoList(LabelFieldInfoAddDTO labelFieldInfoAddDTO); + + /** + * 查询任务类型 + * + * @return AjaxResult + */ + AjaxResult taskTypeGrouping(); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldinfo/impl/LabelFieldInfoServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldinfo/impl/LabelFieldInfoServiceImpl.java index 8ee8f694..4a21119a 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldinfo/impl/LabelFieldInfoServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldinfo/impl/LabelFieldInfoServiceImpl.java @@ -1,14 +1,18 @@ package com.xinelu.manage.service.labelfieldinfo.impl; +import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.SecurityUtils; import com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo; +import com.xinelu.manage.domain.taskpartitiondict.TaskPartitionDict; import com.xinelu.manage.dto.labelfieldinfo.LabelFieldInfoAddDTO; -import com.xinelu.manage.mapper.labelfieldcontent.LabelFieldContentMapper; import com.xinelu.manage.mapper.labelfieldinfo.LabelFieldInfoMapper; +import com.xinelu.manage.mapper.taskpartitiondict.TaskPartitionDictMapper; +import com.xinelu.manage.mapper.tasktypedict.TaskTypeDictMapper; import com.xinelu.manage.service.labelfieldinfo.ILabelFieldInfoService; import com.xinelu.manage.vo.labelfieldinfo.LabelFieldTreeVO; import com.xinelu.manage.vo.labelfieldinfo.LabelFieldVO; +import com.xinelu.manage.vo.tasktypedict.TaskTypeDictVO; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -32,9 +36,10 @@ import java.util.stream.Collectors; public class LabelFieldInfoServiceImpl implements ILabelFieldInfoService { @Resource private LabelFieldInfoMapper labelFieldInfoMapper; - @Resource - private LabelFieldContentMapper labelFieldContentMapper; + private TaskTypeDictMapper taskTypeDictMapper; + @Resource + private TaskPartitionDictMapper taskPartitionDictMapper; /** * 查询标签字段信息 @@ -172,4 +177,21 @@ public class LabelFieldInfoServiceImpl implements ILabelFieldInfoService { } return 1; } + + @Override + public AjaxResult taskTypeGrouping() { + List taskTypeDictList = taskTypeDictMapper.selectTaskTypeDicts(); + List ids = taskTypeDictList.stream().filter(Objects::nonNull).map(TaskTypeDictVO::getTaskTypeId).filter(Objects::nonNull).collect(Collectors.toList()); + List taskPartitionDicts = taskPartitionDictMapper.selectTaskPartitionList(ids); + if (CollectionUtils.isEmpty(taskPartitionDicts)) { + return AjaxResult.success(taskPartitionDicts); + } + for (TaskTypeDictVO taskTypeDictVO : taskTypeDictList) { + List collect = taskPartitionDicts.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getTaskTypeId()) && taskTypeDictVO.getTaskTypeId().equals(item.getTaskTypeId())).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + taskTypeDictVO.setTaskPartitionDictList(collect); + } + } + return AjaxResult.success(taskTypeDictList); + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/specialdiseasenode/SpecialDiseaseNodeVO.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/specialdiseasenode/SpecialDiseaseNodeVO.java index 08374d1f..b12537b1 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/specialdiseasenode/SpecialDiseaseNodeVO.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/specialdiseasenode/SpecialDiseaseNodeVO.java @@ -27,4 +27,6 @@ public class SpecialDiseaseNodeVO extends SpecialDiseaseNode { private String taskStatusName; private String taskSubdivisiontemplateType; + + private String flowScheme; } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/tasktypedict/TaskTypeDictVO.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/tasktypedict/TaskTypeDictVO.java new file mode 100644 index 00000000..150d5c9d --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/tasktypedict/TaskTypeDictVO.java @@ -0,0 +1,30 @@ +package com.xinelu.manage.vo.tasktypedict; + +import com.xinelu.manage.domain.taskpartitiondict.TaskPartitionDict; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * 任务类型字典对象 task_type_dict + * + * @author xinelu + * @date 2024-03-11 + */ +@Data +public class TaskTypeDictVO { + + /** + * 主键id + */ + private Long taskTypeId; + + /** + * 任务类型名称 + */ + @ApiModelProperty(value = "任务类型名称") + private String taskTypeName; + + private List taskPartitionDictList; +} diff --git a/postdischarge-manage/src/main/resources/mapper/manage/specialdiseasenode/SpecialDiseaseNodeMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/specialdiseasenode/SpecialDiseaseNodeMapper.xml index 92b8d2cc..337cf90f 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/specialdiseasenode/SpecialDiseaseNodeMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/specialdiseasenode/SpecialDiseaseNodeMapper.xml @@ -125,6 +125,7 @@ + @@ -807,7 +808,7 @@ + select * from task_partition_dict where task_type_id in + + #{ids} + + \ No newline at end of file diff --git a/postdischarge-manage/src/main/resources/mapper/manage/tasktypedict/TaskTypeDictMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/tasktypedict/TaskTypeDictMapper.xml index cb78a349..ac764fb3 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/tasktypedict/TaskTypeDictMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/tasktypedict/TaskTypeDictMapper.xml @@ -137,4 +137,10 @@ #{id} + + \ No newline at end of file From a073c1815ca42d1790a76914ddf90bb26f1eb10f Mon Sep 17 00:00:00 2001 From: zhangheng <3226558941@qq.com> Date: Wed, 3 Jul 2024 16:21:32 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E7=94=BB=E5=83=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/LabelFieldContentServiceImpl.java | 21 ++++++++++------ .../labelfieldinfo/LabelFieldInfoMapper.xml | 25 +++++++++++-------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldcontent/impl/LabelFieldContentServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldcontent/impl/LabelFieldContentServiceImpl.java index 3e195585..20980ed7 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldcontent/impl/LabelFieldContentServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/labelfieldcontent/impl/LabelFieldContentServiceImpl.java @@ -204,6 +204,7 @@ public class LabelFieldContentServiceImpl implements ILabelFieldContentService { } PatientTaskDto patientTaskDto = new PatientTaskDto(); patientTaskDto.setPatientId(patientId); + //暂时不用 List nodeList = signPatientManageRouteNodeMapper.getNodeList(patientTaskDto); List nodeContentList = nodeList.stream().filter(Objects::nonNull).map(SignPatientManageRouteNode::getNodeContent).filter(Objects::nonNull).collect(Collectors.toList()); String nodeContentListJoin = String.join(",", nodeContentList); @@ -233,20 +234,26 @@ public class LabelFieldContentServiceImpl implements ILabelFieldContentService { for (int i = 0; i < declaredFields.length; i++) { strings[i] = declaredFields[i].getName().toUpperCase(); } - List PortraitSnVOS = new ArrayList<>(); List asListStrings = Arrays.asList(strings); for (GroupingValue groupingValue : labelFieldContentList) { - PortraitSnVO portraitSnVO = new PortraitSnVO(); groupingValue.setPatientId(patientId); String s = asListStrings.stream().filter(Objects::nonNull).filter(item -> item.equals(groupingValue.getFieldCode())).findFirst().orElse(new String()); groupingValue.setFieldValue(paramsValue.getOrDefault(s, "").toString()); - portraitSnVO.setPortraitSn(groupingValue.getPortraitSn()); - PortraitSnVOS.add(portraitSnVO); } + List collect = labelFieldContentList.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getTaskPartitionDictId())).map(LabelFieldInfo::getTaskPartitionDictId).distinct().collect(Collectors.toList()); List labelFieldAndPartitionDictList = new ArrayList<>(); - LabelFieldAndPartitionDict labelFieldAndPartitionDict = new LabelFieldAndPartitionDict(); - labelFieldAndPartitionDict.setPortraitSnVOList(PortraitSnVOS); - labelFieldAndPartitionDictList.add(labelFieldAndPartitionDict); + for (Long aLong : collect) { + List PortraitSnVOS = new ArrayList<>(); + LabelFieldAndPartitionDict labelFieldAndPartitionDict = new LabelFieldAndPartitionDict(); + PortraitSnVO portraitSnVO = new PortraitSnVO(); + List collect1 = labelFieldContentList.stream().filter(Objects::nonNull).filter(item -> aLong.equals(item.getTaskPartitionDictId())).collect(Collectors.toList()); + portraitSnVO.setGroupingValues(collect1); + PortraitSnVOS.add(portraitSnVO); + labelFieldAndPartitionDict.setTaskPartitionDictId(aLong); + labelFieldAndPartitionDict.setTaskPartitionDictName(collect1.get(0).getTaskPartitionDictName()); + labelFieldAndPartitionDict.setPortraitSnVOList(PortraitSnVOS); + labelFieldAndPartitionDictList.add(labelFieldAndPartitionDict); + } return labelFieldAndPartitionDictList; } diff --git a/postdischarge-manage/src/main/resources/mapper/manage/labelfieldinfo/LabelFieldInfoMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/labelfieldinfo/LabelFieldInfoMapper.xml index d3877b1e..d6a5ede6 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/labelfieldinfo/LabelFieldInfoMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/labelfieldinfo/LabelFieldInfoMapper.xml @@ -232,17 +232,19 @@ diff --git a/postdischarge-manage/src/main/resources/mapper/manage/labelfieldinfo/LabelFieldInfoMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/labelfieldinfo/LabelFieldInfoMapper.xml index d6a5ede6..d8de48b8 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/labelfieldinfo/LabelFieldInfoMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/labelfieldinfo/LabelFieldInfoMapper.xml @@ -253,7 +253,7 @@ and task_partition_dict_id is null - Order by ttd.task_type_sort,tpd.task_partition_sort + Order by ttd.task_type_sort,tpd.task_partition_sort,lfi.field_sort + + \ No newline at end of file diff --git a/postdischarge-mobile/pom.xml b/postdischarge-mobile/pom.xml index 0ac748c5..8105eba4 100644 --- a/postdischarge-mobile/pom.xml +++ b/postdischarge-mobile/pom.xml @@ -39,5 +39,12 @@ org.simpleframework simple-xml + + + + com.alibaba.cloud + spring-cloud-alicloud-sms + 2.2.0.RELEASE + \ No newline at end of file diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/MobileTestController.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/MobileTestController.java index 8c4fd0e1..a7c878e8 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/MobileTestController.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/MobileTestController.java @@ -1,5 +1,12 @@ package com.xinelu.mobile.controller; +import com.alibaba.fastjson2.JSONObject; +import com.aliyuncs.exceptions.ClientException; +import com.xinelu.common.config.AliYunSmsConfig; +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.utils.uuid.IdUtils; +import com.xinelu.mobile.dto.smssend.SmsInfoDTO; +import com.xinelu.mobile.utils.SmsSendUtils; import com.xinelu.mobile.utils.WeChatAppletUtils; import com.xinelu.mobile.utils.WeChatOfficialAccountUtils; import com.xinelu.mobile.vo.wechatofficialaccountcallback.PatientVO; @@ -22,6 +29,10 @@ public class MobileTestController { private WeChatAppletUtils weChatAppletUtils; @Resource private WeChatOfficialAccountUtils weChatOfficialAccountUtils; + @Resource + private SmsSendUtils smsSendUtils; + @Resource + private AliYunSmsConfig aliYunSmsConfig; /** * 测试获取微信小程序accessToken @@ -54,4 +65,25 @@ public class MobileTestController { public void sendAppletTemplate(PatientVO patientVO) { weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO); } + + /** + *发送短信验证 + */ + @GetMapping("/sendSms") + public AjaxResult sendAppletTemplate(String phoneNum) throws ClientException { + SmsInfoDTO smsInfoDTO = new SmsInfoDTO(); + smsInfoDTO.setPhoneNumbers(phoneNum); + smsInfoDTO.setSignName(aliYunSmsConfig.getSignName()); + smsInfoDTO.setTemplateCode(aliYunSmsConfig.getTemplateCode()); + // 生成六位数验证码 + String code = String.valueOf(IdUtils.generateSixDigitNumber()); + JSONObject obj = new JSONObject(); + obj.put("code", code); + smsInfoDTO.setTemplateParam(obj); + Boolean b = smsSendUtils.sendSms(smsInfoDTO); + if (!b) { + return AjaxResult.error("短信发送失败"); + } + return AjaxResult.success("短信发送成功"); + } } diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java index 2ea19c97..19b67cb9 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java @@ -4,12 +4,11 @@ import com.xinelu.common.core.controller.BaseController; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.core.page.TableDataInfo; import com.xinelu.mobile.dto.appletpersoncenter.HealthRecordDTO; +import com.xinelu.mobile.dto.verifysmscode.VerifySmsCodeDTO; import com.xinelu.mobile.service.appletpersoncenter.AppletPersonCenterService; +import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -80,4 +79,40 @@ public class AppletPersonCenterController extends BaseController { return AjaxResult.success(appletPersonCenterService.getHealthRecordInfoById(id)); } + @ApiOperation("院后微信小程序登录接口") + @GetMapping("/appletLoginV1") + public AjaxResult appletLoginV1(@RequestParam("loginCode") String loginCode) { + if (StringUtils.isBlank(loginCode)) { + return AjaxResult.error("登录凭证编码不能为空!"); + } + return appletPersonCenterService.appletLoginV1(loginCode); + } + + @ApiOperation("小程序登录发送短信验证码") + @GetMapping("/sendSms") + public AjaxResult sendSms(String phoneNum) { + if (StringUtils.isBlank(phoneNum)) { + return AjaxResult.error("手机号码不能为空!"); + } + return appletPersonCenterService.sendSms(phoneNum); + } + + @ApiOperation("小程序登录验证短信验证码") + @PostMapping("/verifySmsCode") + public AjaxResult verifySmsCode(@RequestBody VerifySmsCodeDTO verifySmsCodeDTO) { + if (StringUtils.isBlank(verifySmsCodeDTO.getOpenId())) { + return AjaxResult.error("微信小程序openid不能为空!"); + } + if (StringUtils.isBlank(verifySmsCodeDTO.getPhoneNum())) { + return AjaxResult.error("手机号不能为空!"); + } + if (StringUtils.isBlank(verifySmsCodeDTO.getPatientName())) { + return AjaxResult.error("姓名不能为空"); + } + if (StringUtils.isBlank(verifySmsCodeDTO.getSmsCode())) { + return AjaxResult.error("短信验证码不能为空!"); + } + return appletPersonCenterService.verifySmsCode(verifySmsCodeDTO); + } + } diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/dto/smssend/SmsInfoDTO.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/dto/smssend/SmsInfoDTO.java new file mode 100644 index 00000000..a26afc75 --- /dev/null +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/dto/smssend/SmsInfoDTO.java @@ -0,0 +1,34 @@ +package com.xinelu.mobile.dto.smssend; + +import com.alibaba.fastjson2.JSONObject; +import lombok.Data; + +/** + * @program: PostDischargePatientManage + * @description: 短信发送参数DTO + * @author: yxl + * @create: 2024-07-02 21:05 + **/ +@Data +public class SmsInfoDTO { + + /** + * :短信签名 + */ + private String signName; + + /** + * 待发送手机号,多个用逗号隔开 + */ + private String phoneNumbers; + + /** + * 短信模板Code + */ + private String templateCode; + + /** + * 模板中的变量替换JSON串 + */ + private JSONObject templateParam; +} diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/dto/verifysmscode/VerifySmsCodeDTO.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/dto/verifysmscode/VerifySmsCodeDTO.java new file mode 100644 index 00000000..5a262881 --- /dev/null +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/dto/verifysmscode/VerifySmsCodeDTO.java @@ -0,0 +1,27 @@ +package com.xinelu.mobile.dto.verifysmscode; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @program: PostDischargePatientManage + * @description: 验证短信验证码DTO + * @author: yxl + * @create: 2024-07-03 14:58 + **/ +@Data +public class VerifySmsCodeDTO { + + + @ApiModelProperty(value = "微信小程序openid") + private String openId; + + @ApiModelProperty(value = "手机号") + private String phoneNum; + + @ApiModelProperty(value = "姓名") + private String patientName; + + @ApiModelProperty(value = "短信验证码") + private String smsCode; +} diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java index d66bdd47..a19a72a3 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java @@ -3,6 +3,7 @@ package com.xinelu.mobile.service.appletpersoncenter; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.mobile.dto.appletpersoncenter.HealthRecordDTO; import com.xinelu.mobile.dto.appletpersoncenter.HealthRecordInfoDTO; +import com.xinelu.mobile.dto.verifysmscode.VerifySmsCodeDTO; import java.util.List; @@ -48,4 +49,25 @@ public interface AppletPersonCenterService { */ HealthRecordInfoDTO getHealthRecordInfoById(Long id); + + /** + * 院后微信小程序登录接口 + * @param loginCode 登录凭证 + * @return 微信小程序用户登录信息 + */ + AjaxResult appletLoginV1(String loginCode); + + /** + * 小程序登录发送验证码 + * @param phoneNum 手机号码 + * @return 发送短信验证码信息 + */ + AjaxResult sendSms(String phoneNum); + + /** + * 小程序登录验证短信验证码 + * @param verifySmsCodeDTO 验证短信验证码DTO + * @return 验证短信验证码信息 + */ + AjaxResult verifySmsCode(VerifySmsCodeDTO verifySmsCodeDTO); } diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java index 91a10c3e..bad9c76b 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java @@ -1,26 +1,36 @@ package com.xinelu.mobile.service.appletpersoncenter.Impl; +import com.alibaba.fastjson2.JSONObject; +import com.aliyuncs.exceptions.ClientException; +import com.xinelu.common.config.AliYunSmsConfig; import com.xinelu.common.config.WeChatAppletChatConfig; import com.xinelu.common.constant.Constants; import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.utils.uuid.IdUtils; import com.xinelu.manage.domain.residentinfo.ResidentInfo; import com.xinelu.manage.mapper.residentinfo.ResidentInfoMapper; import com.xinelu.mobile.dto.appletpersoncenter.HealthRecordDTO; import com.xinelu.mobile.dto.appletpersoncenter.HealthRecordInfoDTO; +import com.xinelu.mobile.dto.smssend.SmsInfoDTO; +import com.xinelu.mobile.dto.verifysmscode.VerifySmsCodeDTO; import com.xinelu.mobile.mapper.appletpersoncenter.AppletPersonCenterMapper; import com.xinelu.mobile.service.appletpersoncenter.AppletPersonCenterService; +import com.xinelu.mobile.utils.SmsSendUtils; import com.xinelu.mobile.utils.WeChatAppletUtils; import com.xinelu.mobile.vo.appletpersoncenter.PostDischargeAppletPhoneVO; import com.xinelu.mobile.vo.appletpersoncenter.PostDischargeAppletVO; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.List; import java.util.Objects; +import java.util.concurrent.TimeUnit; /** * @Description 院后小程序个人中心业务层实现类 @@ -37,12 +47,17 @@ public class AppletPersonCenterServiceImpl implements AppletPersonCenterService @Resource private WeChatAppletChatConfig weChatAppletChatConfig; @Resource - private RedisTemplate redisTemplate; + private RedisTemplate redisTemplate; @Resource private ResidentInfoMapper residentInfoMapper; @Resource private AppletPersonCenterMapper appletPersonCenterMapper; + @Resource + private SmsSendUtils smsSendUtils; + @Resource + private AliYunSmsConfig aliYunSmsConfig; + /** * 院后微信小程序一键登录接口 * @@ -156,4 +171,116 @@ public class AppletPersonCenterServiceImpl implements AppletPersonCenterService } return healthRecordInfoDTO; } + + /** + * 院后微信小程序登录接口 + * + * @param loginCode 登录凭证 + * @return 微信小程序用户登录信息 + */ + @Override + public AjaxResult appletLoginV1(String loginCode) { + //根据code获取用户的微信unionId以及openId等信息 + PostDischargeAppletVO appletLoginInfo = weChatAppletUtils.getPostDischargeAppletLogin(weChatAppletChatConfig.getAppletId(), weChatAppletChatConfig.getSecret(), loginCode, weChatAppletChatConfig.getGrantType()); + if (Objects.isNull(appletLoginInfo)) { + return AjaxResult.error("获取院后微信小程序用户信息失败"); + } + if (Objects.nonNull(appletLoginInfo.getErrcode()) && appletLoginInfo.getErrcode() != Constants.SUCCESS_CODE) { + return AjaxResult.error("获取院后微信小程序用户信息失败,失败信息为:" + appletLoginInfo.getErrmsg()); + } + String openId = StringUtils.isBlank(appletLoginInfo.getOpenid()) ? "" : appletLoginInfo.getOpenid(); + ResidentInfo residentInfo = residentInfoMapper.getResidentInfoByPhoneAndOpenId(null, openId); + if (ObjectUtils.isEmpty(residentInfo)) { + return AjaxResult.success("未注册", openId); + } + return AjaxResult.success("已注册", residentInfo); + } + + /** + * 小程序登录发送验证码 + * + * @param phoneNum 手机号码 + * @return 发送短信验证码信息 + */ + @Override + public AjaxResult sendSms(String phoneNum) { + try { + String coolDownKey = Constants.SMS_COOL_DOWN + phoneNum; + String cacheKey = Constants.SMS_CODE + phoneNum; + ValueOperations valueOperations = redisTemplate.opsForValue(); + + // 检查是否处于冷却期 + if (valueOperations.get(coolDownKey) != null) { + return AjaxResult.error("请等待60秒后再尝试发送验证码"); + } + + // 生成并发送新的验证码 + SmsInfoDTO smsInfoDTO = new SmsInfoDTO(); + smsInfoDTO.setPhoneNumbers(phoneNum); + smsInfoDTO.setSignName(aliYunSmsConfig.getSignName()); + smsInfoDTO.setTemplateCode(aliYunSmsConfig.getTemplateCode()); + String code = String.valueOf(IdUtils.generateSixDigitNumber()); + JSONObject obj = new JSONObject(); + obj.put("code", code); + smsInfoDTO.setTemplateParam(obj); + Boolean b = smsSendUtils.sendSms(smsInfoDTO); + if (!b) { + log.error("短信发送失败,手机号:{}", phoneNum); + return AjaxResult.error("短信发送失败"); + } + + // 更新验证码和冷却键 + valueOperations.set(cacheKey, code, 5, TimeUnit.MINUTES); + valueOperations.set(coolDownKey, Constants.SMS_COOL_DOWN_VALUE, 60, TimeUnit.SECONDS); + log.info("手机号为{}的验证码已经生成", phoneNum); + return AjaxResult.success("短信发送成功"); + } catch (ClientException e) { + log.error("短信发送失败,手机号:{},错误原因:{}", phoneNum, e.getMessage(), e); + return AjaxResult.error("短信发送失败"); + } + } + + /** + * 小程序登录验证短信验证码 + * + * @param verifySmsCodeDTO 验证短信验证码DTO + * @return 验证短信验证码信息 + */ + @Override + public AjaxResult verifySmsCode(VerifySmsCodeDTO verifySmsCodeDTO) { + try { + String openId = verifySmsCodeDTO.getOpenId(); + String smsCode = verifySmsCodeDTO.getSmsCode(); + String cacheKey = Constants.SMS_CODE + verifySmsCodeDTO.getPhoneNum(); + ValueOperations valueOperations = redisTemplate.opsForValue(); + String storedCode = valueOperations.get(cacheKey); + + if (storedCode == null) { + log.info("验证码已过期,手机号:{}", verifySmsCodeDTO.getPhoneNum()); + return AjaxResult.error("验证码已过期,请重新获取!"); + } + + if (!storedCode.equals(smsCode)) { + log.info("验证码验证失败,手机号:{},输入的验证码:{},获取的验证码:{}", verifySmsCodeDTO.getPhoneNum(), smsCode, storedCode); + return AjaxResult.error("验证码错误,请重新输入!"); + } + + log.info("验证码验证成功,手机号:{}", verifySmsCodeDTO.getPhoneNum()); + List residentInfos = residentInfoMapper.getResidentInfoByPhoneAndName(verifySmsCodeDTO.getPhoneNum(), verifySmsCodeDTO.getPatientName()); + + if (residentInfos == null || residentInfos.isEmpty()) { + return AjaxResult.error("您的用户信息尚未录入系统,无法执行注册操作!"); + } else if (residentInfos.size() > 1) { + // 存在姓名和手机号重复的情况 + return AjaxResult.error("您的信息存在重复记录,请联系管理员进行操作!"); + } + ResidentInfo residentInfo = residentInfos.get(0); + residentInfo.setOpenId(openId); + residentInfoMapper.updateResidentInfo(residentInfo); + return AjaxResult.success("注册成功!", residentInfo); + } catch (Exception e) { + log.error("验证验证码时发生异常,手机号:{},异常信息:{}", verifySmsCodeDTO.getPhoneNum(), e.getMessage(), e); + return AjaxResult.error("短信验证码验证失败!"); + } + } } diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/SmsSendUtils.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/SmsSendUtils.java new file mode 100644 index 00000000..6f950f95 --- /dev/null +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/SmsSendUtils.java @@ -0,0 +1,86 @@ +package com.xinelu.mobile.utils; + +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.profile.DefaultProfile; +import com.aliyuncs.profile.IClientProfile; +import com.xinelu.common.config.AliYunSmsConfig; +import com.xinelu.common.enums.SmsErrorCodeEnum; +import com.xinelu.common.exception.ServiceException; +import com.xinelu.mobile.dto.smssend.SmsInfoDTO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * @program: PostDischargePatientManage + * @description: 短信发送工具类 + * @author: yxl + * @create: 2024-07-02 20:50 + **/ +@Component +@Slf4j +public class SmsSendUtils { + + private static final String SUCCESS = "OK"; + + @Resource + private AliYunSmsConfig aliyunSmsConfig; + + /** + * 发送短信 + */ + public Boolean sendSms(SmsInfoDTO smsInfoDTO) throws ClientException, ServiceException { + try { + // 短信发送参数非空性判断 + if (ObjectUtils.isEmpty(smsInfoDTO)) { + throw new ServiceException("短信发送参数不能为空!"); + } + if (StringUtils.isBlank(smsInfoDTO.getPhoneNumbers())) { + throw new ServiceException("待发送手机号不能为空!"); + } + if (StringUtils.isBlank(smsInfoDTO.getSignName())) { + throw new ServiceException("短信签名不能为空!"); + } + if (StringUtils.isBlank(smsInfoDTO.getTemplateCode())) { + throw new ServiceException("短信模板Code不能为空!"); + } + + // 设置系统的默认连接超时时间和读取超时时间 + System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); + System.setProperty("sun.net.client.defaultReadTimeout", "10000"); + + // 初始化acsClient,暂不支持region化 + IClientProfile profile = DefaultProfile.getProfile(aliyunSmsConfig.getRegionId(), aliyunSmsConfig.getAccessKeyId(), aliyunSmsConfig.getAccessKeySecret()); + DefaultProfile.addEndpoint(aliyunSmsConfig.getRegionId(), aliyunSmsConfig.getProduct(), aliyunSmsConfig.getDomain()); + IAcsClient acsClient = new DefaultAcsClient(profile); + + // 组装请求对象 + SendSmsRequest request = new SendSmsRequest(); + request.setPhoneNumbers(smsInfoDTO.getPhoneNumbers()); + request.setSignName(smsInfoDTO.getSignName()); + request.setTemplateCode(smsInfoDTO.getTemplateCode()); + request.setTemplateParam(smsInfoDTO.getTemplateParam().toJSONString()); + + SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request); + // 判断响应的结果 + if (!SUCCESS.equals(sendSmsResponse.getCode())) { + SmsErrorCodeEnum errorCode = SmsErrorCodeEnum.getMsgByCode(sendSmsResponse.getCode()); + log.error("短信发送失败,错误码:{},错误信息:{}", sendSmsResponse.getCode(), errorCode.getMessage()); + return false; + } + log.info("短信发送成功:code:{}", sendSmsResponse.getCode()); + return true; + } catch (ClientException e) { + log.error("发送短信出现异常,异常信息:{}", e.getMessage()); + throw e; + } + } +} + From 77b2d8ef4bdac7a7e6f5f0e4ef512da3a1af5360 Mon Sep 17 00:00:00 2001 From: zhangheng <3226558941@qq.com> Date: Wed, 3 Jul 2024 18:19:42 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../taskpartitiondict/TaskPartitionDictMapper.xml | 12 ++++++++---- .../manage/tasktypedict/TaskTypeDictMapper.xml | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/postdischarge-manage/src/main/resources/mapper/manage/taskpartitiondict/TaskPartitionDictMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/taskpartitiondict/TaskPartitionDictMapper.xml index 4305c743..253ce63c 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/taskpartitiondict/TaskPartitionDictMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/taskpartitiondict/TaskPartitionDictMapper.xml @@ -209,9 +209,13 @@ \ No newline at end of file diff --git a/postdischarge-manage/src/main/resources/mapper/manage/tasktypedict/TaskTypeDictMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/tasktypedict/TaskTypeDictMapper.xml index ac764fb3..2bf5bec2 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/tasktypedict/TaskTypeDictMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/tasktypedict/TaskTypeDictMapper.xml @@ -142,5 +142,6 @@ select id taskTypeId, task_type_name from task_type_dict + order by task_type_sort \ No newline at end of file