From 80910dbac6969e3a7024a9c974b30df2ee827dbe Mon Sep 17 00:00:00 2001 From: linfso Date: Wed, 25 Sep 2024 22:45:08 +0800 Subject: [PATCH] md --- ...__org_bouncycastle_bcpkix_jdk15on_1_69.xml | 13 -- ...__org_bouncycastle_bcutil_jdk15on_1_69.xml | 13 -- .../erp/oms/web/Oms2cCommonController.java | 40 ++++ emis-oms-biz/emis-oms-biz.iml | 13 +- emis-oms-biz/pom.xml | 10 +- .../erp/oms/domain/EmisSmsSendRecord.java | 73 +++++++ .../xdadan/erp/oms/mapper/EmisBaseMapper.java | 6 - .../oms/mapper/EmisSmsSendRecordMapper.java | 38 ++++ .../erp/oms/mapper/EmisWaybillMapper.java | 4 + .../erp/oms/service/OmsBaseService.java | 180 ++++++++++++++++++ .../mapper/EmisSmsSendRecordMapper.xml | 57 ++++++ .../resources/mapper/EmisWaybillMapper.xml | 8 + 12 files changed, 415 insertions(+), 40 deletions(-) delete mode 100644 .idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_69.xml delete mode 100644 .idea/libraries/Maven__org_bouncycastle_bcutil_jdk15on_1_69.xml create mode 100644 emis-oms-biz/src/main/java/com/xdadan/erp/oms/domain/EmisSmsSendRecord.java create mode 100644 emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisSmsSendRecordMapper.java create mode 100644 emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/OmsBaseService.java create mode 100644 emis-oms-biz/src/main/resources/mapper/EmisSmsSendRecordMapper.xml diff --git a/.idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_69.xml b/.idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_69.xml deleted file mode 100644 index b63e1b7..0000000 --- a/.idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_69.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_bouncycastle_bcutil_jdk15on_1_69.xml b/.idea/libraries/Maven__org_bouncycastle_bcutil_jdk15on_1_69.xml deleted file mode 100644 index ffd08d0..0000000 --- a/.idea/libraries/Maven__org_bouncycastle_bcutil_jdk15on_1_69.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/emis-oms-biz-web/src/main/java/com/xdadan/erp/oms/web/Oms2cCommonController.java b/emis-oms-biz-web/src/main/java/com/xdadan/erp/oms/web/Oms2cCommonController.java index b912e24..99c4488 100644 --- a/emis-oms-biz-web/src/main/java/com/xdadan/erp/oms/web/Oms2cCommonController.java +++ b/emis-oms-biz-web/src/main/java/com/xdadan/erp/oms/web/Oms2cCommonController.java @@ -79,6 +79,10 @@ public class Oms2cCommonController extends BaseController private WxMaService wxMaService; + @Autowired + private OmsBaseService omsBaseService; + + /** * 获取电子面单单号 */ @@ -272,6 +276,18 @@ public class Oms2cCommonController extends BaseController /** * 发送小程序通知 + * + * + * 发件通知:d8mnoZdXWn7rQjcFTUuEWCa6acOEhVZsGL2nZCr9mgE + * 快递单号 + * {{character_string3.DATA}} + * + * 寄件时间 + * {{date2.DATA}} + * + * 备注 + * {{thing6.DATA}} + * */ @Log(title = "发送小程序通知", businessType = BusinessType.OTHER) @RequestMapping(value = "/sendWxSappNotifyToUser") @@ -295,4 +311,28 @@ public class Oms2cCommonController extends BaseController } + @Log(title = "触发小程序通知", businessType = BusinessType.OTHER) + @RequestMapping(value = "/triggerSendWxSappNotify") + public AjaxResult triggerSendWxSappNotify() + { + + String lockKey="triggerSendWxSappNotify"; + log.error("triggerSendWxSappNotify start"); + + // 加锁查询 + redissonService.lock(lockKey,300); + try{ + omsBaseService.autoDoWxSappNotifySend(); + }catch(Exception ex){ + ex.printStackTrace(); + log.error("triggerSendWxSappNotify exception:"+ex.getMessage()); + } + log.error("triggerSendWxSappNotify end"); + + redissonService.unlock(lockKey); + return AjaxResult.success("发送成功"); + + } + + } diff --git a/emis-oms-biz/emis-oms-biz.iml b/emis-oms-biz/emis-oms-biz.iml index 8bd3e0f..c8c03ba 100644 --- a/emis-oms-biz/emis-oms-biz.iml +++ b/emis-oms-biz/emis-oms-biz.iml @@ -126,7 +126,6 @@ - @@ -212,8 +211,6 @@ - - @@ -223,5 +220,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/emis-oms-biz/pom.xml b/emis-oms-biz/pom.xml index 8d32665..c21c0ab 100644 --- a/emis-oms-biz/pom.xml +++ b/emis-oms-biz/pom.xml @@ -82,11 +82,11 @@ 3.1.7 - - - - - + + com.github.binarywang + weixin-java-miniapp + 4.3.0 + diff --git a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/domain/EmisSmsSendRecord.java b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/domain/EmisSmsSendRecord.java new file mode 100644 index 0000000..87a0d47 --- /dev/null +++ b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/domain/EmisSmsSendRecord.java @@ -0,0 +1,73 @@ +/** + * @Project: emis + * @Title: EmisSmsSendRecord.java + * @author linfso + * @date 2024-06-16 09:33:47 + * @Copyright: ShangHai Duta 2022 All rights reserved. + * @version v1.0 + * @Description:

短信发送记录表 实体类

+ */ + +package com.xdadan.erp.oms.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.xdadan.erp.oms.common.core.domain.BaseEntity; +import lombok.Data; + +import java.util.Date; + + +/** + * @ClassName EmisSmsSendRecord + * @Description 短信发送记录表 + * @author linfso + * @date 2024-06-16 09:33:47 + */ + @Data +public class EmisSmsSendRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /* id */ + private Long id; + /* 运单号 */ + private String billCode; + /* 发送站点编码 */ + private String sendSiteCode; + /* 站点名称 */ + private String sendSiteName; + /* 发件人名称 */ + private String sendManName; + /* 发送人编码 */ + private String sendManCode; + /* 短信类型 1-发件 2-签收 */ + private String smsType; + /* 目标号码 */ + private String phone; + /* 短信内容 */ + private String content; + /* 单条发送费用 */ + private String fee; + /* 发送渠道 */ + private String smsChannel; + /* 发送时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date sendDate; + /* 渠道发送状态 0-未发送 1-已发送 -1 发送错误 */ + private String sendStatus; + /* 渠道错误代码 */ + private String errCode; + /* 渠道错误信息 */ + private String errMsg; + /* 任务处理时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date taskDate; + /* 微信通知状态 0-未发送 1-已发送 -1 发送错误 */ + private String wxNotifyStatus; + /* 微信通知发送时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date wxNotifyDate; + /* 微信通知返回信息 */ + private String wxNotifyMsg; + +} diff --git a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisBaseMapper.java b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisBaseMapper.java index 455103f..a028c06 100644 --- a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisBaseMapper.java +++ b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisBaseMapper.java @@ -55,10 +55,4 @@ public interface EmisBaseMapper extends BaseMapper - - - - - - } diff --git a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisSmsSendRecordMapper.java b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisSmsSendRecordMapper.java new file mode 100644 index 0000000..d653469 --- /dev/null +++ b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisSmsSendRecordMapper.java @@ -0,0 +1,38 @@ +/** + * @Project: emis + * @Title: EmisSmsSendRecordMapper.java + * @author linfso + * @date 2024-06-16 09:33:47 + * @Copyright: ShangHai Doitinfo 2022 All rights reserved. + * @version v1.0 + * @Description:

短信发送记录表 Mapper 接口

+ * Warning : This file is generate by ai tools,don't edit!!! + */ +package com.xdadan.erp.oms.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.xdadan.erp.oms.domain.EmisSmsSendRecord; + +import java.util.List; + +/** + * @ClassName EmisSmsSendRecordMapper + * @Description

短信发送记录表 Mapper 接口

+ * @author linfso + * @date 2024-06-16 09:33:47 + */ +public interface EmisSmsSendRecordMapper extends BaseMapper +{ + + /** + * 查询列表 + * @return 集合 + */ + public List selectWxSappNotifyList(); + + + public int updateWxSappNotifyStatus(EmisSmsSendRecord emisSmsSendRecord); + + +} diff --git a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisWaybillMapper.java b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisWaybillMapper.java index 0195ff3..3c40466 100644 --- a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisWaybillMapper.java +++ b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/mapper/EmisWaybillMapper.java @@ -26,6 +26,10 @@ import org.apache.ibatis.annotations.Param; public interface EmisWaybillMapper extends BaseMapper { + + public EmisWaybill selectWaybillBaseInfoByBillCode(@Param("billCode")String billCode); + + /** * 查询列表 * diff --git a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/OmsBaseService.java b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/OmsBaseService.java new file mode 100644 index 0000000..4333673 --- /dev/null +++ b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/OmsBaseService.java @@ -0,0 +1,180 @@ + /** + * @Project: emis + * @Title: EmisWaybillServiceImpl.java + * @author linfso + * @date 2024-02-29 08:15:14 + * @Copyright: ShangHai Duta 2022 All rights reserved. + * @version v1.0 + * @Description:

运单列表 实体类

+ */ + +package com.xdadan.erp.oms.service; + + import cn.binarywang.wx.miniapp.api.WxMaService; + import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; + import cn.hutool.core.collection.CollectionUtil; + import com.alibaba.fastjson.JSON; + import com.alibaba.fastjson.JSONObject; + + import com.xdadan.erp.oms.common.core.domain.entity.SysOmsUser; + import com.xdadan.erp.oms.common.core.redis.RedissonService; + import com.xdadan.erp.oms.common.utils.DateUtils; + import com.xdadan.erp.oms.domain.EmisSmsSendRecord; + import com.xdadan.erp.oms.domain.EmisWaybill; + import com.xdadan.erp.oms.mapper.EmisSmsSendRecordMapper; + import com.xdadan.erp.oms.mapper.EmisWaybillMapper; + import com.xdadan.erp.oms.system.service.ISysOmsUserService; + import lombok.extern.slf4j.Slf4j; + import me.chanjar.weixin.common.error.WxErrorException; + import org.apache.commons.collections.MapUtils; + import org.apache.commons.lang3.StringUtils; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + import org.springframework.util.CollectionUtils; + + import java.math.BigDecimal; + import java.util.*; + + /** + * Service业务层处理 + * + * @author linfso + * @date 2024-02-29 08:15:14 + */ +@Service +@Slf4j +public class OmsBaseService { + + + @Autowired + private RedissonService redissonService; + + + @Autowired + private ISysOmsUserService sysOmsUserService; + + + @Autowired + private EmisSmsSendRecordMapper emisSmsSendRecordMapper; + + @Autowired + private EmisWaybillMapper emisWaybillMapper; + + @Autowired + private WxMaService wxMaService; + + + /** + * 通知发送发送 + */ + public void autoDoWxSappNotifySend() { + + List list = emisSmsSendRecordMapper.selectWxSappNotifyList(); + if(!CollectionUtil.isEmpty(list)){ + for(EmisSmsSendRecord dt:list){ + log.error("===>Start 发送微信通知:"+dt.getBillCode()+","+dt.getPhone()+" :smsType:"+dt.getSmsType()); + + EmisWaybill emisWaybill=emisWaybillMapper.selectWaybillBaseInfoByBillCode(dt.getBillCode()); + if(emisWaybill==null){ + continue; + } + + // 获取openId + SysOmsUser omsUser = sysOmsUserService.selectUserByUserName(emisWaybill.getCustomerCode()); + if(omsUser==null){ + log.error("===>Start 发送失败 用户不存在:"+emisWaybill.getCustomerCode()); + + continue; + } + + EmisSmsSendRecord upd = new EmisSmsSendRecord(); + upd.setId(dt.getId()); + // 如果openId是空的则更新为不成功 + if(StringUtils.isEmpty(omsUser.getOpenid())){ + log.error("===>Start 发送失败 用户Openid为空:"+emisWaybill.getCustomerCode()); + upd.setWxNotifyStatus("-1"); + upd.setWxNotifyMsg("openId为空"); + emisSmsSendRecordMapper.updateWxSappNotifyStatus(upd); + continue; + } + + try { + + WxMaSubscribeMessage wxMaSubscribeMessage = null; + // 发件短信 + if ("1".equals(dt.getSmsType())) { + wxMaSubscribeMessage = WxMaSubscribeMessage.builder() + .toUser(omsUser.getOpenid()) + .templateId("d8mnoZdXWn7rQjcFTUuEWCa6acOEhVZsGL2nZCr9mgE") + .page("pages/post/query?billCode="+dt.getBillCode()) + .build(); + /* + 快递单号 + {{character_string3.DATA}} + 寄件时间 + {{date2.DATA}} + 备注 + {{thing6.DATA}} + */ + + wxMaSubscribeMessage.addData(new WxMaSubscribeMessage.MsgData("character_string3", dt.getBillCode())); + wxMaSubscribeMessage.addData(new WxMaSubscribeMessage.MsgData("date2",DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,emisWaybill.getSendDate()))); + wxMaSubscribeMessage.addData(new WxMaSubscribeMessage.MsgData("thing6", dt.getContent())); + + } + // 签收短信 + else if ("2".equals(dt.getSmsType())) { + + wxMaSubscribeMessage = WxMaSubscribeMessage.builder() + .toUser(omsUser.getOpenid()) + .templateId("C_jnzC5bIXrJI_N7H1bzZpM61xW4MNHZJaZ5eLcTrDw") + .page("pages/post/query?billCode="+dt.getBillCode()) + .build(); + /* + 快递单号 + {{character_string2.DATA}} + + 寄方信息 + {{thing1.DATA}} + + 签收时间 + {{time11.DATA}} + */ + + wxMaSubscribeMessage.addData(new WxMaSubscribeMessage.MsgData("character_string2", dt.getBillCode())); + wxMaSubscribeMessage.addData(new WxMaSubscribeMessage.MsgData("thing1", emisWaybill.getSendName())); + wxMaSubscribeMessage.addData(new WxMaSubscribeMessage.MsgData("time11",DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,emisWaybill.getSignDate()))); + + } + // 问题件 + else if ("3".equals(dt.getSmsType())) { + continue; + } + else{ + continue; + } + + + wxMaService.getMsgService().sendSubscribeMsg(wxMaSubscribeMessage); + upd.setWxNotifyStatus("1"); + upd.setWxNotifyMsg("通知成功"); + + }catch (Exception ex){ + ex.printStackTrace(); + upd.setWxNotifyStatus("-1"); + upd.setWxNotifyMsg(ex.getMessage()); + } + + + emisSmsSendRecordMapper.updateWxSappNotifyStatus(upd); + log.error("===>End 发送微信通知"); + + } + } + + } + + + + + } \ No newline at end of file diff --git a/emis-oms-biz/src/main/resources/mapper/EmisSmsSendRecordMapper.xml b/emis-oms-biz/src/main/resources/mapper/EmisSmsSendRecordMapper.xml new file mode 100644 index 0000000..d50894e --- /dev/null +++ b/emis-oms-biz/src/main/resources/mapper/EmisSmsSendRecordMapper.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, bill_code, send_site_code, send_site_name, send_man_name, send_man_code, sms_type, phone, content, fee, sms_channel, send_date, send_status, err_code, err_msg, task_date, wx_notify_status, wx_notify_date, wx_notify_msg, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_sms_send_record + + + + + + + + update emis_sms_send_record + + wx_notify_date = now(), + wx_notify_status = #{wxNotifyStatus}, + wx_notify_msg = #{wxNotifyMsg}, + + where id = #{id} + + + + \ No newline at end of file diff --git a/emis-oms-biz/src/main/resources/mapper/EmisWaybillMapper.xml b/emis-oms-biz/src/main/resources/mapper/EmisWaybillMapper.xml index e101868..f958200 100644 --- a/emis-oms-biz/src/main/resources/mapper/EmisWaybillMapper.xml +++ b/emis-oms-biz/src/main/resources/mapper/EmisWaybillMapper.xml @@ -300,6 +300,14 @@ + +