This commit is contained in:
linfso 2024-09-25 22:45:08 +08:00
parent d68021f92f
commit 80910dbac6
12 changed files with 415 additions and 40 deletions

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: org.bouncycastle:bcpkix-jdk15on:1.69">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/bouncycastle/bcpkix-jdk15on/1.69/bcpkix-jdk15on-1.69.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/bouncycastle/bcpkix-jdk15on/1.69/bcpkix-jdk15on-1.69-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/bouncycastle/bcpkix-jdk15on/1.69/bcpkix-jdk15on-1.69-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: org.bouncycastle:bcutil-jdk15on:1.69">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/bouncycastle/bcutil-jdk15on/1.69/bcutil-jdk15on-1.69.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/bouncycastle/bcutil-jdk15on/1.69/bcutil-jdk15on-1.69-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/bouncycastle/bcutil-jdk15on/1.69/bcutil-jdk15on-1.69-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -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("发送成功");
}
}

View File

@ -126,7 +126,6 @@
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-sts:3.0.0" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-ecs:4.2.0" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-kms:2.7.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.9" level="project" />
<orderEntry type="library" name="Maven: io.minio:minio:8.4.5" level="project" />
<orderEntry type="library" name="Maven: com.carrotsearch.thirdparty:simple-xml-safe:2.7.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:30.1.1-jre" level="project" />
@ -212,8 +211,6 @@
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:3.1.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:3.1.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.11.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcutil-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-openfeign-core:3.1.7" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.5.10" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.7" level="project" />
@ -223,5 +220,15 @@
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.5.5" level="project" />
<orderEntry type="library" name="Maven: io.github.openfeign:feign-core:11.10" level="project" />
<orderEntry type="library" name="Maven: io.github.openfeign:feign-slf4j:11.10" level="project" />
<orderEntry type="library" name="Maven: com.github.binarywang:weixin-java-miniapp:4.3.0" level="project" />
<orderEntry type="library" name="Maven: com.github.binarywang:weixin-java-common:4.3.0" level="project" />
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.19" level="project" />
<orderEntry type="library" name="Maven: io.github.x-stream:mxparser:1.2.2" level="project" />
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.13" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.36" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.9" level="project" />
<orderEntry type="library" name="Maven: org.dom4j:dom4j:2.1.3" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.68" level="project" />
</component>
</module>

View File

@ -82,11 +82,11 @@
<version>3.1.7</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.fastreport</groupId>-->
<!-- <artifactId>fastreport</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies>

View File

@ -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: <p> 短信发送记录表 实体类 </p>
*/
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;
}

View File

@ -55,10 +55,4 @@ public interface EmisBaseMapper extends BaseMapper<BaseEntity>
}

View File

@ -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: <p> 短信发送记录表 Mapper 接口 </p>
* <span style='color:red'> Warning : This file is generate by ai tools,don't edit!!! </span>
*/
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 <p> 短信发送记录表 Mapper 接口 </p>
* @author linfso
* @date 2024-06-16 09:33:47
*/
public interface EmisSmsSendRecordMapper extends BaseMapper<EmisSmsSendRecord>
{
/**
* 查询列表
* @return 集合
*/
public List<EmisSmsSendRecord> selectWxSappNotifyList();
public int updateWxSappNotifyStatus(EmisSmsSendRecord emisSmsSendRecord);
}

View File

@ -26,6 +26,10 @@ import org.apache.ibatis.annotations.Param;
public interface EmisWaybillMapper extends BaseMapper<EmisWaybill>
{
public EmisWaybill selectWaybillBaseInfoByBillCode(@Param("billCode")String billCode);
/**
* 查询列表
*

View File

@ -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: <p> 运单列表 实体类 </p>
*/
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<EmisSmsSendRecord> 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 发送微信通知");
}
}
}
}

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xdadan.erp.oms.mapper.EmisSmsSendRecordMapper">
<resultMap type="EmisSmsSendRecord" id="EmisSmsSendRecordResult" >
<result property="id" column="id" />
<result property="billCode" column="bill_code" />
<result property="sendSiteCode" column="send_site_code" />
<result property="sendSiteName" column="send_site_name" />
<result property="sendManName" column="send_man_name" />
<result property="sendManCode" column="send_man_code" />
<result property="smsType" column="sms_type" />
<result property="phone" column="phone" />
<result property="content" column="content" />
<result property="fee" column="fee" />
<result property="smsChannel" column="sms_channel" />
<result property="sendDate" column="send_date" />
<result property="sendStatus" column="send_status" />
<result property="errCode" column="err_code" />
<result property="errMsg" column="err_msg" />
<result property="taskDate" column="task_date" />
<result property="wxNotifyStatus" column="wx_notify_status" />
<result property="wxNotifyDate" column="wx_notify_date" />
<result property="wxNotifyMsg" column="wx_notify_msg" />
</resultMap>
<sql id="selectEmisSmsSendRecordVo">
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
</sql>
<select id="selectWxSappNotifyList" parameterType="EmisSmsSendRecord" resultMap="EmisSmsSendRecordResult">
<include refid="selectEmisSmsSendRecordVo"/>
<where>
del_flag='0' and wx_notify_status='0'
and create_time <![CDATA[ > ]]> DATE_SUB(CURDATE(), INTERVAL 30 DAY)
and create_time <![CDATA[ < ]]> SUBDATE(now(),INTERVAL 2 hour)
</where>
order by create_time desc
limit 300
</select>
<update id="updateWxSappNotifyStatus" parameterType="EmisSmsSendRecord">
update emis_sms_send_record
<trim prefix="SET" suffixOverrides=",">
wx_notify_date = now(),
<if test="wxNotifyStatus != null and wxNotifyStatus != ''">wx_notify_status = #{wxNotifyStatus},</if>
<if test="wxNotifyMsg != null and wxNotifyMsg != ''">wx_notify_msg = #{wxNotifyMsg},</if>
</trim>
where id = #{id}
</update>
</mapper>

View File

@ -300,6 +300,14 @@
</sql>
<select id="selectWaybillBaseInfoByBillCode" parameterType="String" resultMap="BaseEmisWaybillResult">
<include refid="selectEmisWaybillVo"/>
<where>
a.bill_code = #{billCode}
</where>
limit 1
</select>
<select id="selectUserOrderList" parameterType="EmisWaybill" resultMap="EmisWaybillResult">
<include refid="selectEmisWaybillVo"/>
<where>