短信接口开发

pull/520/head
dorion 2024-06-28 00:30:28 +08:00
parent 951bfa9ef6
commit 3ee21d9e42
11 changed files with 144 additions and 94 deletions

View File

@ -154,7 +154,7 @@
</plugin> -->
</plugins>
<finalName>${project.artifactId}</finalName>
<!-- <resources>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
@ -162,7 +162,7 @@
<exclude>*.xml</exclude>
</excludes>
</resource>
</resources>-->
</resources>
</build>

View File

@ -84,6 +84,7 @@ public class WSSmsTaskTblController extends BaseController
@ResponseBody
public AjaxResult addSave(SmsTaskTbl smsTaskTbl)
{
smsTaskTbl.setSmsBusiType("WS");
return toAjax(smsTaskTblService.insertSmsTaskTbl(smsTaskTbl));
}

View File

@ -15,14 +15,6 @@
<input name="taskName" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">短信类型:</label>
<div class="col-sm-8">
<select name="smsBusiType" class="form-control m-b" th:with="type=${@dict.getType('sys_sms_busi_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">单价:</label>
<div class="col-sm-8">
@ -58,7 +50,7 @@
</select>
</div>
</div>
<div class="form-group">
<!-- <div class="form-group">
<label class="col-sm-3 control-label">任务状态:</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('sys_sms_task_status')}">
@ -66,7 +58,7 @@
<label th:for="${'taskStatus_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
</div>-->
</form>
</div>

View File

@ -11,9 +11,9 @@ import java.util.Date;
/**
* WS sms_task_tbl
*
*
* @author dorion
* @date 2024-06-01
* @date 2024-06-27
*/
public class SmsTaskTbl extends BaseEntity
{
@ -30,6 +30,14 @@ public class SmsTaskTbl extends BaseEntity
@Excel(name = "短信类型")
private String smsBusiType;
/** 接口返回的任务id */
@Excel(name = "接口返回的任务id")
private Long taskId;
/** 渠道id */
@Excel(name = "渠道id")
private String channelId;
/** 单价 */
@Excel(name = "单价")
private BigDecimal price;
@ -48,9 +56,11 @@ public class SmsTaskTbl extends BaseEntity
private String filePath;
/** 物料文件MD5值 */
@Excel(name = "物料文件MD5值")
private String fileMd5;
/** 任务文本内容base64加密字符串 */
@Excel(name = "任务文本内容base64加密字符串")
private String context;
/** 内容类型 */
@ -69,144 +79,178 @@ public class SmsTaskTbl extends BaseEntity
@Excel(name = "物料总数")
private Long issueCount;
public void setIdSmsTask(Long idSmsTask)
/** 用户id */
@Excel(name = "用户id")
private String userId;
public void setIdSmsTask(Long idSmsTask)
{
this.idSmsTask = idSmsTask;
}
public Long getIdSmsTask()
public Long getIdSmsTask()
{
return idSmsTask;
}
public void setTaskName(String taskName)
public void setTaskName(String taskName)
{
this.taskName = taskName;
}
public String getTaskName()
public String getTaskName()
{
return taskName;
}
public void setSmsBusiType(String smsBusiType)
public void setSmsBusiType(String smsBusiType)
{
this.smsBusiType = smsBusiType;
}
public String getSmsBusiType()
public String getSmsBusiType()
{
return smsBusiType;
}
public void setPrice(BigDecimal price)
public void setTaskId(Long taskId)
{
this.taskId = taskId;
}
public Long getTaskId()
{
return taskId;
}
public void setChannelId(String channelId)
{
this.channelId = channelId;
}
public String getChannelId()
{
return channelId;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public BigDecimal getPrice()
public BigDecimal getPrice()
{
return price;
}
public void setTaskBeginTime(Date taskBeginTime)
public void setTaskBeginTime(Date taskBeginTime)
{
this.taskBeginTime = taskBeginTime;
}
public Date getTaskBeginTime()
public Date getTaskBeginTime()
{
return taskBeginTime;
}
public void setFileName(String fileName)
public void setFileName(String fileName)
{
this.fileName = fileName;
}
public String getFileName()
public String getFileName()
{
return fileName;
}
public void setFilePath(String filePath)
public void setFilePath(String filePath)
{
this.filePath = filePath;
}
public String getFilePath()
public String getFilePath()
{
return filePath;
}
public void setFileMd5(String fileMd5)
public void setFileMd5(String fileMd5)
{
this.fileMd5 = fileMd5;
}
public String getFileMd5()
public String getFileMd5()
{
return fileMd5;
}
public void setContext(String context)
public void setContext(String context)
{
this.context = context;
}
public String getContext()
public String getContext()
{
return context;
}
public void setSmsContentType(String smsContentType)
public void setSmsContentType(String smsContentType)
{
this.smsContentType = smsContentType;
}
public String getSmsContentType()
public String getSmsContentType()
{
return smsContentType;
}
public void setTaskStatus(String taskStatus)
public void setTaskStatus(String taskStatus)
{
this.taskStatus = taskStatus;
}
public String getTaskStatus()
public String getTaskStatus()
{
return taskStatus;
}
public void setSuccessRate(String successRate)
public void setSuccessRate(String successRate)
{
this.successRate = successRate;
}
public String getSuccessRate()
public String getSuccessRate()
{
return successRate;
}
public void setIssueCount(Long issueCount)
public void setIssueCount(Long issueCount)
{
this.issueCount = issueCount;
}
public Long getIssueCount()
public Long getIssueCount()
{
return issueCount;
}
public void setUserId(String userId)
{
this.userId = userId;
}
public String getUserId()
{
return userId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("idSmsTask", getIdSmsTask())
.append("taskName", getTaskName())
.append("smsBusiType", getSmsBusiType())
.append("price", getPrice())
.append("taskBeginTime", getTaskBeginTime())
.append("fileName", getFileName())
.append("filePath", getFilePath())
.append("fileMd5", getFileMd5())
.append("context", getContext())
.append("smsContentType", getSmsContentType())
.append("taskStatus", getTaskStatus())
.append("successRate", getSuccessRate())
.append("issueCount", getIssueCount())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
.append("idSmsTask", getIdSmsTask())
.append("taskName", getTaskName())
.append("smsBusiType", getSmsBusiType())
.append("taskId", getTaskId())
.append("channelId", getChannelId())
.append("price", getPrice())
.append("taskBeginTime", getTaskBeginTime())
.append("fileName", getFileName())
.append("filePath", getFilePath())
.append("fileMd5", getFileMd5())
.append("context", getContext())
.append("smsContentType", getSmsContentType())
.append("taskStatus", getTaskStatus())
.append("successRate", getSuccessRate())
.append("issueCount", getIssueCount())
.append("userId", getUserId())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -303,7 +303,7 @@ public class ShiroConfig
// 注册相关
filterChainDefinitionMap.put("/register", "anon,captchaValidate");
filterChainDefinitionMap.put("/api/**", "anon");
filterChainDefinitionMap.put("/common/download", "anon");
filterChainDefinitionMap.put("/profile/upload/**", "anon");
// 系统权限列表
// filterChainDefinitionMap.putAll(SpringUtils.getBean(IMenuService.class).selectPermsAll());

View File

@ -36,7 +36,7 @@ public class UndelegateEnergyTask {
TrxExchangeInfo trxExchangeInfoExample = TrxExchangeInfo.builder()
.delegateStatus(dictValue)
.fcd(DateUtil.offsetDay(new Date(),-2))
// .fcd(DateUtil.offsetDay(new Date(),-2))
.build();
List<TrxExchangeMonitorAccountInfo> trxExchangeMonitorAccountInfoList = trxExchangeInfoService.selectTrxExchangeMonitorAccountInfo(trxExchangeInfoExample);

View File

@ -9,5 +9,5 @@ public interface IU02cxApi {
String getToken(GetTokenRequest getTokenRequest);
String addTask(String requestBody, String token, String appId) throws IOException;
Long addTask(String requestBody, String token, String appId) throws IOException;
}

View File

@ -35,7 +35,7 @@ public class U02cxApiImpl implements IU02cxApi {
}
@Override
public String addTask(String requestBody, String token, String appId) throws IOException {
public Long addTask(String requestBody, String token, String appId) throws IOException {
HttpHeaders httpHeaders = new HttpHeaders();
@ -44,28 +44,17 @@ public class U02cxApiImpl implements IU02cxApi {
httpHeaders.add("appId",appId);
httpHeaders.add("token",token);
// ResponseEntity<AddTaskResponse> responseEntity = RestTemplateUtils.post("http://cot5b.u02cx.com:20086/whatsApi/api/task/addTask", httpHeaders, requestBody, AddTaskResponse.class);
ResponseEntity<String> responseEntity = RestTemplateUtils.post("http://cot5b.u02cx.com:20086/whatsApi/api/task/addTask", httpHeaders, requestBody, String.class);
ResponseEntity<AddTaskResponse> responseEntity = RestTemplateUtils.post("http://cot5b.u02cx.com:20086/whatsApi/api/task/addTask", httpHeaders, requestBody, AddTaskResponse.class);
Preconditions.checkState(responseEntity.getStatusCode().is2xxSuccessful(), "addTask failed");
// AddTaskResponse addTaskResponse = responseEntity.getBody();
String response = responseEntity.getBody();
AddTaskResponse addTaskResponse = responseEntity.getBody();
Preconditions.checkNotNull(addTaskResponse, "addTaskResponse is null");
int status = addTaskResponse.getStatus();
Preconditions.checkState(0 == status, "addTask failed:" + ApiConstants.returnCodeMap.get(status)+",msg:"+addTaskResponse.getMsg());
// CloseableHttpClient httpclient = HttpClients.createDefault();
// HttpPost httpPost = new HttpPost("http://cot5b.u02cx.com:20086/whatsApi/api/task/addTask");
// httpPost.setHeader("Content-Type", "application/json");
// httpPost.setHeader("appId", appId);
// httpPost.setHeader("token", token);
// httpPost.setEntity(new StringEntity(requestBody, "utf8"));
// CloseableHttpResponse reportResponse = httpclient.execute(httpPost);
// String body = EntityUtils.toString(reportResponse.getEntity(), "utf8");
//
// AddTaskResponse addTaskResponse = JSONUtil.toBean(body, AddTaskResponse.class);
return addTaskResponse.getTaskId().toString();
return addTaskResponse.getTaskId();
}
}

View File

@ -136,6 +136,8 @@ public class EnergyTenantTransferHandler {
}
private static TrxExchangeInfo buildTrxExchangeInfo(TenantInfo tenantInfo, String eneryBusiTypeByDay) {
String delegateStatus = DictUtils.getDictValue("sys_delegate_status", "已委托");
//查看有没有没回收的能量,有的话先回收
@ -144,7 +146,7 @@ public class EnergyTenantTransferHandler {
.fromAddress(tenantInfo.getReceiverAddress())
.delegateStatus(delegateStatus)
.energyBusiType(eneryBusiTypeByDay)
.fcd(DateUtil.offsetDay(new Date(), -2))
// .fcd(DateUtil.offsetDay(new Date(), -2))
.build();
return trxExchangeInfo;
}

View File

@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil;
import com.ruoyi.common.core.domain.entity.SmsTaskTbl;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.api.IU02cxApi;
import com.ruoyi.system.api.entity.U02cx.AddTaskRequest;
import com.ruoyi.system.api.entity.U02cx.GetTokenRequest;
@ -79,7 +80,7 @@ public class SmsTaskTblServiceImpl implements ISmsTaskTblService
BeanUtils.copyProperties(smsChannelTbl, getTokenRequest);
String token = u02cxApi.getToken(getTokenRequest);
log.info("token:{}", token);
log.debug("token:{}", token);
AddTaskRequest addTaskRequest = new AddTaskRequest();
addTaskRequest.setTaskName(smsTaskTbl.getTaskName())
.setPrice(smsTaskTbl.getPrice())
@ -91,19 +92,26 @@ public class SmsTaskTblServiceImpl implements ISmsTaskTblService
.setType(Integer.parseInt(smsTaskTbl.getSmsContentType()));
try {
// 将公钥字符串转换为 PublicKey 对象
// PublicKey publicKey = KeyUtils.getPublicKeyFromBase64String(smsChannelTbl.getPublicKey());
// 使用公钥加密数据
String jsonStr = JSONUtil.toJsonStr(addTaskRequest);
log.info("jsonStr:{}", jsonStr);
log.debug("jsonStr:{}", jsonStr);
// String encryptedData = EncryptionUtils.encrypt(jsonStr, publicKey);
String encryptedData = RsaUtils.encryptData(jsonStr, smsChannelTbl.getPublicKey());
String taskId = u02cxApi.addTask(encryptedData,token,smsChannelTbl.getAppId());
Long taskId = u02cxApi.addTask(encryptedData,token,smsChannelTbl.getAppId());
smsTaskTbl.setTaskId(taskId);
smsTaskTbl.setChannelId(smsChannelTbl.getChannelId());
Long userId = ShiroUtils.getUserId();
smsTaskTbl.setUserId(userId.toString());
String loginName = ShiroUtils.getLoginName();
smsTaskTbl.setCreateBy(loginName);
smsTaskTbl.setUpdateBy(loginName);
smsTaskTbl.setTaskStatus("0");
} catch (Exception e) {
throw new RuntimeException(e);
}
smsTaskTbl.setCreateTime(DateUtils.getNowDate());
return smsTaskTblMapper.insertSmsTaskTbl(smsTaskTbl);
}

View File

@ -1,13 +1,15 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SmsTaskTblMapper">
<resultMap type="SmsTaskTbl" id="SmsTaskTblResult">
<result property="idSmsTask" column="id_sms_task" />
<result property="taskName" column="task_name" />
<result property="smsBusiType" column="sms_busi_type" />
<result property="taskId" column="task_id" />
<result property="channelId" column="channel_id" />
<result property="price" column="price" />
<result property="taskBeginTime" column="task_begin_time" />
<result property="fileName" column="file_name" />
@ -18,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="taskStatus" column="task_status" />
<result property="successRate" column="success_rate" />
<result property="issueCount" column="issue_count" />
<result property="userId" column="user_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
@ -25,28 +28,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectSmsTaskTblVo">
select id_sms_task, task_name, sms_busi_type, price, task_begin_time, file_name, file_path, file_md5, context, sms_content_type, task_status, success_rate, issue_count, create_by, create_time, update_by, update_time from sms_task_tbl
select id_sms_task, task_name, sms_busi_type, task_id, channel_id, price, task_begin_time, file_name, file_path, file_md5, context, sms_content_type, task_status, success_rate, issue_count, user_id, create_by, create_time, update_by, update_time from sms_task_tbl
</sql>
<select id="selectSmsTaskTblList" parameterType="SmsTaskTbl" resultMap="SmsTaskTblResult">
<include refid="selectSmsTaskTblVo"/>
<where>
<where>
<if test="taskName != null and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
<if test="smsBusiType != null and smsBusiType != ''"> and sms_busi_type = #{smsBusiType}</if>
<if test="taskStatus != null and taskStatus != ''"> and task_status = #{taskStatus}</if>
<if test="userId != null and userId != ''"> and user_id = #{userId}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
</where>
</select>
<select id="selectSmsTaskTblByIdSmsTask" parameterType="Long" resultMap="SmsTaskTblResult">
<include refid="selectSmsTaskTblVo"/>
where id_sms_task = #{idSmsTask}
</select>
<insert id="insertSmsTaskTbl" parameterType="SmsTaskTbl" useGeneratedKeys="true" keyProperty="idSmsTask">
insert into sms_task_tbl
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskName != null and taskName != ''">task_name,</if>
<if test="smsBusiType != null">sms_busi_type,</if>
<if test="taskId != null">task_id,</if>
<if test="channelId != null">channel_id,</if>
<if test="price != null">price,</if>
<if test="taskBeginTime != null">task_begin_time,</if>
<if test="fileName != null">file_name,</if>
@ -57,14 +64,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="taskStatus != null">task_status,</if>
<if test="successRate != null">success_rate,</if>
<if test="issueCount != null">issue_count,</if>
<if test="userId != null">user_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskName != null and taskName != ''">#{taskName},</if>
<if test="smsBusiType != null">#{smsBusiType},</if>
<if test="taskId != null">#{taskId},</if>
<if test="channelId != null">#{channelId},</if>
<if test="price != null">#{price},</if>
<if test="taskBeginTime != null">#{taskBeginTime},</if>
<if test="fileName != null">#{fileName},</if>
@ -75,11 +85,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="taskStatus != null">#{taskStatus},</if>
<if test="successRate != null">#{successRate},</if>
<if test="issueCount != null">#{issueCount},</if>
<if test="userId != null">#{userId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</trim>
</insert>
<update id="updateSmsTaskTbl" parameterType="SmsTaskTbl">
@ -87,6 +98,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="taskName != null and taskName != ''">task_name = #{taskName},</if>
<if test="smsBusiType != null">sms_busi_type = #{smsBusiType},</if>
<if test="taskId != null">task_id = #{taskId},</if>
<if test="channelId != null">channel_id = #{channelId},</if>
<if test="price != null">price = #{price},</if>
<if test="taskBeginTime != null">task_begin_time = #{taskBeginTime},</if>
<if test="fileName != null">file_name = #{fileName},</if>
@ -97,6 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="taskStatus != null">task_status = #{taskStatus},</if>
<if test="successRate != null">success_rate = #{successRate},</if>
<if test="issueCount != null">issue_count = #{issueCount},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
@ -110,7 +124,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteSmsTaskTblByIdSmsTasks" parameterType="String">
delete from sms_task_tbl where id_sms_task in
delete from sms_task_tbl where id_sms_task in
<foreach item="idSmsTask" collection="array" open="(" separator="," close=")">
#{idSmsTask}
</foreach>