diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index d8f9167ac..a3927d96d 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -154,7 +154,7 @@ --> ${project.artifactId} - + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tg/TgMessageTaskController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tg/TgMessageTaskController.java new file mode 100644 index 000000000..fe3f69714 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tg/TgMessageTaskController.java @@ -0,0 +1,131 @@ +package com.ruoyi.web.controller.tg; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.TgMessageInfo; +import com.ruoyi.common.core.domain.entity.TgMessageTask; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.service.ITgMessageInfoService; +import com.ruoyi.system.service.ITgMessageTaskService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * TG消息任务管理Controller + * + * @author dorion + * @date 2024-07-14 + */ +@Controller +@RequestMapping("/tg/task") +public class TgMessageTaskController extends BaseController +{ + private String prefix = "tg/task"; + + @Autowired + private ITgMessageInfoService iTgMessageInfoService; + + @Autowired + private ITgMessageTaskService tgMessageTaskService; + + @RequiresPermissions("tg:task:view") + @GetMapping() + public String task(ModelMap mmap) + { mmap.put("topicTgmessageInfoList", iTgMessageInfoService.selectTgMessageInfoList(new TgMessageInfo())); + return prefix + "/task"; + } + + /** + * 查询TG消息任务管理列表 + */ + @RequiresPermissions("tg:task:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(TgMessageTask tgMessageTask) + { + startPage(); + List list = tgMessageTaskService.selectTgMessageTaskList(tgMessageTask); + return getDataTable(list); + } + + /** + * 导出TG消息任务管理列表 + */ + @RequiresPermissions("tg:task:export") + @Log(title = "TG消息任务管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(TgMessageTask tgMessageTask) + { + List list = tgMessageTaskService.selectTgMessageTaskList(tgMessageTask); + ExcelUtil util = new ExcelUtil(TgMessageTask.class); + return util.exportExcel(list, "TG消息任务管理数据"); + } + + /** + * 新增TG消息任务管理 + */ + @GetMapping("/add") + public String add(ModelMap mmap) + { + mmap.put("topicTgmessageInfoList", iTgMessageInfoService.selectTopicTgMessageInfoList()); + return prefix + "/add"; + } + + /** + * 新增保存TG消息任务管理 + */ + @RequiresPermissions("tg:task:add") + @Log(title = "TG消息任务管理", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(TgMessageTask tgMessageTask) + { + return toAjax(tgMessageTaskService.insertTgMessageTask(tgMessageTask)); + } + + /** + * 修改TG消息任务管理 + */ + @RequiresPermissions("tg:task:edit") + @GetMapping("/edit/{idTgMessageTask}") + public String edit(@PathVariable("idTgMessageTask") Long idTgMessageTask, ModelMap mmap) + { + TgMessageTask tgMessageTask = tgMessageTaskService.selectTgMessageTaskByIdTgMessageTask(idTgMessageTask); + mmap.put("topicTgmessageInfoList", iTgMessageInfoService.selectTopicTgMessageInfoList()); + mmap.put("tgMessageTask", tgMessageTask); + return prefix + "/edit"; + } + + /** + * 修改保存TG消息任务管理 + */ + @RequiresPermissions("tg:task:edit") + @Log(title = "TG消息任务管理", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(TgMessageTask tgMessageTask) + { + return toAjax(tgMessageTaskService.updateTgMessageTask(tgMessageTask)); + } + + /** + * 删除TG消息任务管理 + */ + @RequiresPermissions("tg:task:remove") + @Log(title = "TG消息任务管理", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(tgMessageTaskService.deleteTgMessageTaskByIdTgMessageTasks(ids)); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/trx2Energy/Trx2EnergyMonitorAddressInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/trx2Energy/Trx2EnergyMonitorAddressInfoController.java index 235597bea..40b6152c8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/trx2Energy/Trx2EnergyMonitorAddressInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/trx2Energy/Trx2EnergyMonitorAddressInfoController.java @@ -4,6 +4,7 @@ import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.MonitorAddressInfo; +import com.ruoyi.common.core.domain.entity.TgMessageInfo; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.DictUtils; @@ -11,6 +12,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.vo.MonitorAddressInfoVO; import com.ruoyi.system.service.IAccountAddressInfoService; import com.ruoyi.system.service.IMonitorAddressInfoService; +import com.ruoyi.system.service.ITgMessageInfoService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -35,11 +37,16 @@ public class Trx2EnergyMonitorAddressInfoController extends BaseController private IMonitorAddressInfoService monitorAddressInfoService; @Autowired private IAccountAddressInfoService accountAddressInfoService; + @Autowired + private ITgMessageInfoService tgMessageInfoService; @RequiresPermissions("trx2Energy:monitor:view") @GetMapping() - public String monitor() + public String monitor(ModelMap mmap) { + TgMessageInfo tgMessageInfo = new TgMessageInfo(); + tgMessageInfo.setMessageType(4L); + mmap.put("topicTgmessageInfoList", tgMessageInfoService.selectTgMessageInfoList(tgMessageInfo)); return prefix + "/monitor"; } @@ -80,6 +87,9 @@ public class Trx2EnergyMonitorAddressInfoController extends BaseController { String busiType = DictUtils.getDictValue("sys_busi_type", "TRX兑能量"); mmap.put("accountAddressList", accountAddressInfoService.selectAccountAddressInfoAll(busiType)); + TgMessageInfo tgMessageInfo = new TgMessageInfo(); + tgMessageInfo.setMessageType(4L); + mmap.put("topicTgmessageInfoList", tgMessageInfoService.selectTgMessageInfoList(tgMessageInfo)); return prefix + "/add"; } @@ -106,6 +116,9 @@ public class Trx2EnergyMonitorAddressInfoController extends BaseController MonitorAddressInfo monitorAddressInfo = monitorAddressInfoService.selectMonitorAddressInfoByIdMonitorAddress(idMonitorAddress); mmap.put("monitorAddressInfo", monitorAddressInfo); String busiType = DictUtils.getDictValue("sys_busi_type", "TRX兑能量"); + TgMessageInfo tgMessageInfo = new TgMessageInfo(); + tgMessageInfo.setMessageType(4L); + mmap.put("topicTgmessageInfoList", tgMessageInfoService.selectTgMessageInfoList(tgMessageInfo)); mmap.put("accountAddressList", accountAddressInfoService.selectAccountAddressInfoAll(busiType)); return prefix + "/edit"; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/usdt2Trx/Usdt2TrxMonitorAddressInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/usdt2Trx/Usdt2TrxMonitorAddressInfoController.java index 0fba96d2b..5c7782834 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/usdt2Trx/Usdt2TrxMonitorAddressInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/usdt2Trx/Usdt2TrxMonitorAddressInfoController.java @@ -4,6 +4,7 @@ import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.MonitorAddressInfo; +import com.ruoyi.common.core.domain.entity.TgMessageInfo; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.DictUtils; @@ -11,6 +12,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.vo.MonitorAddressInfoVO; import com.ruoyi.system.service.IAccountAddressInfoService; import com.ruoyi.system.service.IMonitorAddressInfoService; +import com.ruoyi.system.service.impl.TgMessageInfoServiceImpl; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -35,11 +37,16 @@ public class Usdt2TrxMonitorAddressInfoController extends BaseController private IMonitorAddressInfoService monitorAddressInfoService; @Autowired private IAccountAddressInfoService accountAddressInfoService; + @Autowired + private TgMessageInfoServiceImpl tgMessageInfoService; @RequiresPermissions("usdt2Trx:monitor:view") @GetMapping() - public String monitor() + public String monitor(ModelMap mmap) { + TgMessageInfo tgMessageInfo = new TgMessageInfo(); + tgMessageInfo.setMessageType(5L); + mmap.put("topicTgmessageInfoList", tgMessageInfoService.selectTgMessageInfoList(tgMessageInfo)); return prefix + "/monitor"; } @@ -80,6 +87,9 @@ public class Usdt2TrxMonitorAddressInfoController extends BaseController { String busiType = DictUtils.getDictValue("sys_busi_type", "USDT兑TRX"); mmap.put("accountAddressList", accountAddressInfoService.selectAccountAddressInfoAll(busiType)); + TgMessageInfo tgMessageInfo = new TgMessageInfo(); + tgMessageInfo.setMessageType(5L); + mmap.put("topicTgmessageInfoList", tgMessageInfoService.selectTgMessageInfoList(tgMessageInfo)); return prefix + "/add"; } @@ -107,6 +117,9 @@ public class Usdt2TrxMonitorAddressInfoController extends BaseController mmap.put("monitorAddressInfo", monitorAddressInfo); String busiType = DictUtils.getDictValue("sys_busi_type", "USDT兑TRX"); mmap.put("accountAddressList", accountAddressInfoService.selectAccountAddressInfoAll(busiType)); + TgMessageInfo tgMessageInfo = new TgMessageInfo(); + tgMessageInfo.setMessageType(5L); + mmap.put("topicTgmessageInfoList", tgMessageInfoService.selectTgMessageInfoList(tgMessageInfo)); return prefix + "/edit"; } diff --git a/ruoyi-admin/src/main/resources/templates/tg/msg/add.html b/ruoyi-admin/src/main/resources/templates/tg/msg/add.html index e3b315129..aca7e6155 100644 --- a/ruoyi-admin/src/main/resources/templates/tg/msg/add.html +++ b/ruoyi-admin/src/main/resources/templates/tg/msg/add.html @@ -3,65 +3,33 @@ - +
- +
- +
-
+
-
- -
- - -
-
-
- +
-
- - -
-
-
-
- -
- 时分秒/H/M/S - -
-
-
- -
-
- - -
+
- - -
+
@@ -71,7 +39,7 @@
- + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/tg/msg/msg.html b/ruoyi-admin/src/main/resources/templates/tg/msg/msg.html index 5ef98baad..05625f661 100644 --- a/ruoyi-admin/src/main/resources/templates/tg/msg/msg.html +++ b/ruoyi-admin/src/main/resources/templates/tg/msg/msg.html @@ -17,13 +17,13 @@ -
  • +
  • @@ -63,9 +63,9 @@ var editFlag = [[${@permission.hasPermi('tg:msg:edit')}]]; var removeFlag = [[${@permission.hasPermi('tg:msg:remove')}]]; var messageTypeDatas = [[${@dict.getType('sys_tg_sms_msg_type')}]]; - var chatIdDatas = [[${@dict.getType('sys_tg_chat_group_info')}]]; + /* var chatIdDatas = [[${@dict.getType('sys_tg_chat_group_info')}]]; var executionStragyDatas = [[${@dict.getType('sys_tg_msg_exe_stragy')}]]; - var statusDatas = [[${@dict.getType('sys_tg_sms_msg_status')}]]; + var statusDatas = [[${@dict.getType('sys_tg_sms_msg_status')}]];*/ var prefix = ctx + "tg/msg"; $(function() { @@ -83,10 +83,28 @@ field: 'idTgMessageInfo', title: '主键', visible: false + }, { + field: 'messageAbbrName', + title: '消息别名' }, { field: 'messageInfo', - title: '消息内容' + title: '消息内容', + formatter: function(value, row, index) { + // 截取前10个字符 + let shortMessage = value.length > 10 ? value.substring(0, 10) + '...' : value; + + return shortMessage; + /* // 添加超链接 + // 使用JSON.stringify来转义消息内容 + let escapedValue = JSON.stringify(value); + + // 去掉字符串开头和结尾的引号 + escapedValue = escapedValue.slice(1, -1); + + // 添加超链接,并在点击时调用$.modal.msg() + return `${shortMessage}`;*/ + } }, { field: 'messageType', @@ -96,42 +114,28 @@ } }, { - field: 'chatId', - title: 'tg会话id', - formatter: function(value, row, index) { - return $.table.selectDictLabels(chatIdDatas, value); - } + field: 'remark', + title: '备注信息' }, { - field: 'intervalTime', - title: '执行周期' - }, - { - field: 'beginTime', - title: '开始时间' - }, - { - field: 'nextRunTime', - title: '下次执行时间', + field: 'createBy', + title: '创建者', visible: false }, { - field: 'executionStragy', - title: '执行策略', - formatter: function(value, row, index) { - return $.table.selectDictLabel(executionStragyDatas, value); - } + field: 'createTime', + title: '创建时间', + visible: false }, { - field: 'status', - title: '任务状态', - formatter: function(value, row, index) { - return $.table.selectDictLabel(statusDatas, value); - } + field: 'updateBy', + title: '更新者', + visible: false }, { - field: 'remark', - title: '备注信息' + field: 'updateTime', + title: '更新时间', + visible: false }, { title: '操作', @@ -146,6 +150,8 @@ }; $.table.init(options); }); + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/tg/task/add.html b/ruoyi-admin/src/main/resources/templates/tg/task/add.html new file mode 100644 index 000000000..cc9055fe6 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/tg/task/add.html @@ -0,0 +1,84 @@ + + + + + + + + +
    + +
    + +
    + +
    +
    +
    + +
    + + +
    +
    +
    + +
    +
    + + +
    +
    +
    +
    + +
    + 时分秒/H/M/S + +
    +
    +
    + +
    +
    + + +
    +
    +
    +
    + +
    + +
    +
    + +
    + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/tg/task/edit.html b/ruoyi-admin/src/main/resources/templates/tg/task/edit.html new file mode 100644 index 000000000..df66d57dc --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/tg/task/edit.html @@ -0,0 +1,93 @@ + + + + + + + + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + + +
    +
    +
    + +
    + +
    +
    + + +
    +
    +
    +
    + +
    +
    + + +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/tg/task/task.html b/ruoyi-admin/src/main/resources/templates/tg/task/task.html new file mode 100644 index 000000000..1c04fcfb6 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/tg/task/task.html @@ -0,0 +1,161 @@ + + + + + + +
    +
    +
    +
    +
    +
      +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • +  搜索 +  重置 +
    • +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/add.html b/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/add.html index 028aaf32b..8d5ba607a 100644 --- a/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/add.html +++ b/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/add.html @@ -59,13 +59,30 @@
  • + +
    + +
    +
    +
    + +
    + +
    +
    + +
    diff --git a/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/edit.html b/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/edit.html index 00636fc07..b47d6122f 100644 --- a/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/edit.html +++ b/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/edit.html @@ -63,13 +63,30 @@
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    diff --git a/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/monitor.html b/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/monitor.html index 6f59f3671..56be52c2f 100644 --- a/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/monitor.html +++ b/ruoyi-admin/src/main/resources/templates/trx2Energy/monitor/monitor.html @@ -85,9 +85,10 @@ var removeFlag = [[${@permission.hasPermi('trx2Energy:monitor:remove')}]]; var prefix = ctx + "trx2Energy/monitor"; var datas = [[${@dict.getType('sys_yes_no')}]]; - var apiKeyDatas = [[${@dict.getType('sys_tron_api_key')}]]; var busiTypeDatas = [[${@dict.getType('sys_busi_type')}]]; var bindPeriodDatas = [[${@dict.getType('sys_lock_period')}]]; + var groupChatIdDatas = [[${@dict.getType('sys_tg_chat_group_info')}]]; + var topicTgmessageInfoList = [[${topicTgmessageInfoList}]]; $(function () { var options = { url: prefix + "/list", @@ -164,13 +165,7 @@ }, }, - { - field: 'apiKey', - title: 'API_KEY', - formatter: function (value, row, index) { - return $.table.selectDictLabel(apiKeyDatas, value); - } - }, { + { field: 'bindPeriod', title: '绑定时长', formatter: function (value, row, index) { @@ -183,6 +178,34 @@ formatter: function (value, item, index) { return $.table.selectDictLabel(datas, item.isValid); } + },{ + field: 'idTgMessageInfo', + title: '通知消息模版', + formatter: function(value, row, index) { + if ($.common.isEmpty(topicTgmessageInfoList) || $.common.isEmpty(value)) { + return ''; + } + var actions = []; + $.each(topicTgmessageInfoList, function(index, dict) { + if (dict.idTgMessageInfo == ('' + value)) { + var listClass = $.common.equals("default", dict.listClass) || $.common.isEmpty(dict.listClass) ? "" : "badge badge-" + dict.listClass; + var cssClass = $.common.isNotEmpty(dict.cssClass) ? dict.cssClass : listClass; + actions.push($.common.sprintf("%s", cssClass, dict.messageAbbrName)); + return false; + } + }); + if (actions.length === 0) { + actions.push($.common.sprintf("%s", value)) + } + return actions.join(''); + } + }, + { + field: 'groupChatId', + title: '绑定群组', + formatter: function(value, row, index) { + return $.table.selectDictLabel(groupChatIdDatas, value); + } }, { field: 'comment', title: '备注' diff --git a/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/add.html b/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/add.html index ff757b406..eb997a807 100644 --- a/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/add.html +++ b/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/add.html @@ -37,15 +37,24 @@
    -
    - +
    - + + +
    +
    +
    + +
    +
    + +
    diff --git a/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/edit.html b/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/edit.html index 2b97479be..6e62c03e8 100644 --- a/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/edit.html +++ b/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/edit.html @@ -49,10 +49,18 @@
    - +
    - + + +
    +
    +
    + +
    +
    diff --git a/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/monitor.html b/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/monitor.html index e4c478b02..6da917d0e 100644 --- a/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/monitor.html +++ b/ruoyi-admin/src/main/resources/templates/usdt2Trx/monitor/monitor.html @@ -76,9 +76,9 @@ var removeFlag = [[${@permission.hasPermi('usdt2Trx:monitor:remove')}]]; var prefix = ctx + "usdt2Trx/monitor"; var datas = [[${@dict.getType('sys_yes_no')}]]; - var bindPeriodDatas = [[${@dict.getType('sys_lock_period')}]]; - var apiKeyDatas = [[${@dict.getType('sys_tron_api_key')}]]; var busiTypeDatas = [[${@dict.getType('sys_busi_type')}]]; + var groupChatIdDatas = [[${@dict.getType('sys_tg_chat_group_info')}]]; + var topicTgmessageInfoList = [[${topicTgmessageInfoList}]]; $(function() { var options = { url: prefix + "/list", @@ -133,14 +133,6 @@ return "" + value + ""; } }, - - { - field: 'apiKey', - title: 'API_KEY', - formatter: function(value, row, index) { - return $.table.selectDictLabel(apiKeyDatas, value); - } - }, { field: 'isValid', title: '是否有效', @@ -148,6 +140,34 @@ return $.table.selectDictLabel(datas, item.isValid); } },{ + field: 'idTgMessageInfo', + title: '通知消息模版', + formatter: function(value, row, index) { + if ($.common.isEmpty(topicTgmessageInfoList) || $.common.isEmpty(value)) { + return ''; + } + var actions = []; + $.each(topicTgmessageInfoList, function(index, dict) { + if (dict.idTgMessageInfo == ('' + value)) { + var listClass = $.common.equals("default", dict.listClass) || $.common.isEmpty(dict.listClass) ? "" : "badge badge-" + dict.listClass; + var cssClass = $.common.isNotEmpty(dict.cssClass) ? dict.cssClass : listClass; + actions.push($.common.sprintf("%s", cssClass, dict.messageAbbrName)); + return false; + } + }); + if (actions.length === 0) { + actions.push($.common.sprintf("%s", value)) + } + return actions.join(''); + } + }, + { + field: 'groupChatId', + title: '绑定群组', + formatter: function(value, row, index) { + return $.table.selectDictLabel(groupChatIdDatas, value); + } + },{ field: 'comment', title: '备注' }, diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/MonitorAddressInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/MonitorAddressInfo.java index dab66140f..8dcaec545 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/MonitorAddressInfo.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/MonitorAddressInfo.java @@ -53,9 +53,16 @@ public class MonitorAddressInfo extends BaseEntity @Excel(name = "trx或者usdt") private String monitorType; - /** API_KEY */ + /* *//** API_KEY *//* @Excel(name = "API_KEY") - private String apiKey; + private String apiKey;*/ + /** 消息模版 */ + @Excel(name = "消息模版") + private String idTgMessageInfo; + + /** 绑定群组 */ + @Excel(name = "绑定群组") + private String groupChatId; /** 是否有效 */ @Excel(name = "是否有效") diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TgMessageInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TgMessageInfo.java index 6003b2233..816c201db 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TgMessageInfo.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TgMessageInfo.java @@ -1,13 +1,10 @@ package com.ruoyi.common.core.domain.entity; -import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import java.util.Date; - /** * TG消息管理对象 tg_message_info * @@ -29,31 +26,19 @@ public class TgMessageInfo extends BaseEntity @Excel(name = "消息类型") private Long messageType; - /** tg会话id */ - @Excel(name = "tg会话id") - private String chatId; - /** 执行周期 */ - @Excel(name = "执行周期") - private String intervalTime; + @Excel(name = "消息别名") + private String messageAbbrName; - /** 开始时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date beginTime; - /** 下次执行时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "下次执行时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date nextRunTime; - /** 执行策略 */ - @Excel(name = "执行策略") - private Long executionStragy; + public String getMessageAbbrName() { + return messageAbbrName; + } - /** 任务状态 */ - @Excel(name = "任务状态") - private Long status; + public void setMessageAbbrName(String messageAbbrName) { + this.messageAbbrName = messageAbbrName; + } public void setIdTgMessageInfo(Long idTgMessageInfo) { @@ -82,60 +67,6 @@ public class TgMessageInfo extends BaseEntity { return messageType; } - public void setChatId(String chatId) - { - this.chatId = chatId; - } - - public String getChatId() - { - return chatId; - } - - public String getIntervalTime() { - return intervalTime; - } - - public void setIntervalTime(String intervalTime) { - this.intervalTime = intervalTime; - } - - public void setBeginTime(Date beginTime) - { - this.beginTime = beginTime; - } - - public Date getBeginTime() - { - return beginTime; - } - public void setNextRunTime(Date nextRunTime) - { - this.nextRunTime = nextRunTime; - } - - public Date getNextRunTime() - { - return nextRunTime; - } - public void setExecutionStragy(Long executionStragy) - { - this.executionStragy = executionStragy; - } - - public Long getExecutionStragy() - { - return executionStragy; - } - public void setStatus(Long status) - { - this.status = status; - } - - public Long getStatus() - { - return status; - } @Override public String toString() { @@ -143,12 +74,6 @@ public class TgMessageInfo extends BaseEntity .append("idTgMessageInfo", getIdTgMessageInfo()) .append("messageInfo", getMessageInfo()) .append("messageType", getMessageType()) - .append("chatId", getChatId()) - .append("interval", getIntervalTime()) - .append("beginTime", getBeginTime()) - .append("nextRunTime", getNextRunTime()) - .append("executionStragy", getExecutionStragy()) - .append("status", getStatus()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TgMessageTask.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TgMessageTask.java new file mode 100644 index 000000000..db63dd119 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TgMessageTask.java @@ -0,0 +1,145 @@ +package com.ruoyi.common.core.domain.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; + +/** + * TG消息任务管理对象 tg_message_task + * + * @author dorion + * @date 2024-07-14 + */ +public class TgMessageTask extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long idTgMessageTask; + + /** 消息信息 */ + @Excel(name = "消息信息") + private Long idTgMessageInfo; + + /** tg会话id */ + @Excel(name = "tg会话id") + private String chatIds; + + /** 执行周期 */ + @Excel(name = "执行周期") + private String intervalTime; + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date beginTime; + + /** 下次执行时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "下次执行时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date nextRunTime; + + /** 执行策略 */ + @Excel(name = "执行策略") + private Long executionStragy; + + /** 任务状态 */ + @Excel(name = "任务状态") + private Long status; + + public void setIdTgMessageTask(Long idTgMessageTask) + { + this.idTgMessageTask = idTgMessageTask; + } + + public Long getIdTgMessageTask() + { + return idTgMessageTask; + } + public void setIdTgMessageInfo(Long idTgMessageInfo) + { + this.idTgMessageInfo = idTgMessageInfo; + } + + public Long getIdTgMessageInfo() + { + return idTgMessageInfo; + } + public void setChatIds(String chatIds) + { + this.chatIds = chatIds; + } + + public String getChatIds() + { + return chatIds; + } + public void setIntervalTime(String intervalTime) + { + this.intervalTime = intervalTime; + } + + public String getIntervalTime() + { + return intervalTime; + } + public void setBeginTime(Date beginTime) + { + this.beginTime = beginTime; + } + + public Date getBeginTime() + { + return beginTime; + } + public void setNextRunTime(Date nextRunTime) + { + this.nextRunTime = nextRunTime; + } + + public Date getNextRunTime() + { + return nextRunTime; + } + public void setExecutionStragy(Long executionStragy) + { + this.executionStragy = executionStragy; + } + + public Long getExecutionStragy() + { + return executionStragy; + } + public void setStatus(Long status) + { + this.status = status; + } + + public Long getStatus() + { + return status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("idTgMessageTask", getIdTgMessageTask()) + .append("idTgMessageInfo", getIdTgMessageInfo()) + .append("chatIds", getChatIds()) + .append("intervalTime", getIntervalTime()) + .append("beginTime", getBeginTime()) + .append("nextRunTime", getNextRunTime()) + .append("executionStragy", getExecutionStragy()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GetSmsDetailTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GetSmsDetailTask.java index 0252bfbc5..25c2bc96d 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GetSmsDetailTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GetSmsDetailTask.java @@ -1,5 +1,6 @@ package com.ruoyi.quartz.task; +import cn.hutool.core.collection.CollectionUtil; import com.ruoyi.common.core.domain.entity.SmsTaskTbl; import com.ruoyi.system.handler.GetSmsDetailTaskHandler; import com.ruoyi.system.mapper.SmsTaskTblMapper; diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GroupTopicMessageTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GroupTopicMessageTask.java new file mode 100644 index 000000000..782ca7932 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GroupTopicMessageTask.java @@ -0,0 +1,134 @@ +package com.ruoyi.quartz.task; + +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; +import com.ruoyi.common.core.domain.entity.TgMessageTask; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.bot.TgLongPollingBot; +import com.ruoyi.system.bot.utils.SendContent; +import com.ruoyi.system.domain.TgMessageInfoTask; +import com.ruoyi.system.handler.TRX2EneryTransferHandler; +import com.ruoyi.system.handler.Usdt2TrxTransferHandler; +import com.ruoyi.system.mapper.TgMessageTaskMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.telegram.telegrambots.meta.api.methods.ParseMode; +import org.telegram.telegrambots.meta.api.methods.send.SendMessage; +import org.telegram.telegrambots.meta.exceptions.TelegramApiException; + +import java.io.IOException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +@Component("groupTopicMessageTask") +public class GroupTopicMessageTask { + @Autowired + private Usdt2TrxTransferHandler usdt2TrxTransferHandler; + @Autowired + private TRX2EneryTransferHandler trx2EneryTransferHandler; + + @Autowired + private TgMessageTaskMapper tgMessageTaskMapper; + + @Autowired(required = false) + private TgLongPollingBot longPollingBot; + @Autowired + private SendContent sendContent; + + public void doGroupTopicMessageTask() { + + TgMessageTask tgMessageTask = new TgMessageTask(); + tgMessageTask.setStatus(1L); + tgMessageTask.setNextRunTime(DateUtils.getNowDate()); + List tgMessageInfoTaskList = tgMessageTaskMapper.selectTgMessageTaskAndInfoList(tgMessageTask); + + List completableFutureList = new ArrayList<>(); + + for (TgMessageInfoTask tgMessageInfoTask : tgMessageInfoTaskList) { + + CompletableFuture completableFuture = CompletableFuture.runAsync(() -> { + try { + doSendTgMessageInfo(tgMessageInfoTask); + } catch (Exception e) { + throw new RuntimeException(e); + } + }).exceptionally(e -> { + throw new RuntimeException("广播TG消息异常", e); + }); + completableFutureList.add(completableFuture); + } + + CompletableFuture.allOf(completableFutureList.stream().toArray(CompletableFuture[]::new)).join(); + } + + private void doSendTgMessageInfo(TgMessageInfoTask tgMessageInfoTask) throws TelegramApiException, NoSuchAlgorithmException, IOException, InvalidKeyException { + Integer executionStragy = tgMessageInfoTask.getExecutionStragy(); + Integer messageType = tgMessageInfoTask.getMessageType(); + TgMessageTask tgMessageTask = new TgMessageTask(); + tgMessageTask.setIdTgMessageTask(tgMessageInfoTask.getIdTgMessageTask()); + if (0 == executionStragy) { + //周期执行 + doSendTgMessageInfo(tgMessageInfoTask, messageType); + + DateTime nextRuntime = getNextRuntime(tgMessageInfoTask); + tgMessageTask.setNextRunTime(nextRuntime); + } else { + //执行一次的 +// sendCommonTgMessage(tgMessageInfoTask); + doSendTgMessageInfo(tgMessageInfoTask, messageType); + tgMessageTask.setStatus(3L); + } + tgMessageTaskMapper.updateTgMessageTask(tgMessageTask); + } + + private void doSendTgMessageInfo(TgMessageInfoTask tgMessageInfoTask, Integer messageType) throws TelegramApiException, NoSuchAlgorithmException, IOException, InvalidKeyException { + if (1 == messageType) { + //trx兑换消息 + trx2EneryTransferHandler.topicGroupMessage(tgMessageInfoTask); + } else if (2 == messageType) { + //usdt兑换消息 + usdt2TrxTransferHandler.topicGroupMessage(tgMessageInfoTask); + } else { + //普通消息 + sendCommonTgMessage(tgMessageInfoTask); + } + } + + private DateTime getNextRuntime(TgMessageInfoTask tgMessageInfoTask) { + String intervalTime = tgMessageInfoTask.getIntervalTime(); + int length = intervalTime.length(); + String intervalTimeNumber = intervalTime.substring(0, length - 1); + String intervalTimeUnit = intervalTime.substring(length - 1, length); + DateField dateField = null; + if ("h".equalsIgnoreCase(intervalTimeUnit)) { + dateField = DateField.HOUR; + }else if ("m".equalsIgnoreCase(intervalTimeUnit)){ + dateField = DateField.MINUTE; + }else if ("s".equalsIgnoreCase(intervalTimeUnit)){ + dateField = DateField.SECOND; + } + DateTime nextRuntime = DateUtil.offset(DateUtil.date(), dateField, NumberUtil.parseInt(intervalTimeNumber)); + return nextRuntime; + } + + private void sendCommonTgMessage(TgMessageInfoTask tgMessageInfoTask) throws TelegramApiException { + if (longPollingBot == null) { + return; + } + String message = tgMessageInfoTask.getMessageInfo(); + String chatId = tgMessageInfoTask.getChatIds(); + List chatIdList = Arrays.asList(chatId.split(",")); + for (String groupChatId : chatIdList) { + SendMessage sendMessage = sendContent.messageText(groupChatId, message, ParseMode.MARKDOWN); + longPollingBot.execute(sendMessage); + } + } + + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/Usdt2TrxxGroupTopicMessageTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/Usdt2TrxxGroupTopicMessageTask.java deleted file mode 100644 index 507529a6c..000000000 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/Usdt2TrxxGroupTopicMessageTask.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.ruoyi.quartz.task; - -import com.ruoyi.system.handler.Usdt2TrxTransferHandler; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component("usdt2TrxxGroupTopicMessageTask") -public class Usdt2TrxxGroupTopicMessageTask { - @Autowired - private Usdt2TrxTransferHandler usdt2TrxTransferHandler; - - public void doUsdt2TrxxGroupTopicMessageTask(){ - - - usdt2TrxTransferHandler.topicGroupMessage(); - } -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/bot/TgLongPollingBot.java b/ruoyi-system/src/main/java/com/ruoyi/system/bot/TgLongPollingBot.java index 34bebe21d..f4e4f247b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/bot/TgLongPollingBot.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/bot/TgLongPollingBot.java @@ -4,11 +4,12 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; import org.telegram.telegrambots.bots.TelegramLongPollingBot; import org.telegram.telegrambots.meta.api.objects.Update; import org.telegram.telegrambots.meta.exceptions.TelegramApiException; -//@Component +@Component @Slf4j public class TgLongPollingBot extends TelegramLongPollingBot { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/MonitorAddressAccount.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/MonitorAddressAccount.java index 1f6da7a77..516e60837 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/MonitorAddressAccount.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/MonitorAddressAccount.java @@ -37,8 +37,13 @@ public class MonitorAddressAccount implements Serializable { */ private String encryptKey; - private String apiKey; private String bindPeriod; + + private String idTgMessageInfo; + + private String groupChatId; + + private String messageInfo; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TgMessageInfoTask.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TgMessageInfoTask.java new file mode 100644 index 000000000..8de9ebe0e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TgMessageInfoTask.java @@ -0,0 +1,135 @@ +package com.ruoyi.system.domain; + +import java.io.Serializable; +import java.util.Date; + +public class TgMessageInfoTask implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * + */ + private Long idTgMessageTask; + + /** + * + */ + private Long idTgMessageInfo; + + /** + * + */ + private String chatIds; + + /** + * + */ + private String intervalTime; + + /** + * + */ + private Date beginTime; + + /** + * + */ + private Date nextRunTime; + + /** + * + */ + private Integer executionStragy; + + /** + * + */ + private Integer status; + + /** + * + */ + private String messageInfo; + private Integer messageType; + + + public Integer getMessageType() { + return messageType; + } + + public void setMessageType(Integer messageType) { + this.messageType = messageType; + } + + public Long getIdTgMessageTask() { + return idTgMessageTask; + } + + public void setIdTgMessageTask(Long idTgMessageTask) { + this.idTgMessageTask = idTgMessageTask; + } + + public Long getIdTgMessageInfo() { + return idTgMessageInfo; + } + + public void setIdTgMessageInfo(Long idTgMessageInfo) { + this.idTgMessageInfo = idTgMessageInfo; + } + + public String getChatIds() { + return chatIds; + } + + public void setChatIds(String chatIds) { + this.chatIds = chatIds; + } + + public String getIntervalTime() { + return intervalTime; + } + + public void setIntervalTime(String intervalTime) { + this.intervalTime = intervalTime; + } + + public Date getBeginTime() { + return beginTime; + } + + public void setBeginTime(Date beginTime) { + this.beginTime = beginTime; + } + + public Date getNextRunTime() { + return nextRunTime; + } + + public void setNextRunTime(Date nextRunTime) { + this.nextRunTime = nextRunTime; + } + + public Integer getExecutionStragy() { + return executionStragy; + } + + public void setExecutionStragy(Integer executionStragy) { + this.executionStragy = executionStragy; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getMessageInfo() { + return messageInfo; + } + + public void setMessageInfo(String messageInfo) { + this.messageInfo = messageInfo; + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchangeMonitorAccountInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchangeMonitorAccountInfo.java index 2c62f2bb4..1b87d8cc6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchangeMonitorAccountInfo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchangeMonitorAccountInfo.java @@ -63,7 +63,7 @@ public class TrxExchangeMonitorAccountInfo implements Serializable { /** * */ - private String apiKey; +/* private String apiKey;*/ /** * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MonitorAddressInfoVO.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MonitorAddressInfoVO.java index 70ffa70ea..7afc02e68 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MonitorAddressInfoVO.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MonitorAddressInfoVO.java @@ -59,9 +59,7 @@ public class MonitorAddressInfoVO @Excel(name = "trx或者usdt") private String monitorType; - /** API_KEY */ - @Excel(name = "API_KEY") - private String apiKey; + /** 是否有效 */ @Excel(name = "是否有效") @@ -70,6 +68,13 @@ public class MonitorAddressInfoVO /** 绑定时长 */ @Excel(name = "绑定时长") private String bindPeriod; + + @Excel(name = "消息模版") + private String idTgMessageInfo; + + /** 绑定群组 */ + @Excel(name = "绑定群组") + private String groupChatId; /** 备注 */ @Excel(name = "备注") private String comment; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/handler/TRX2EneryTransferHandler.java b/ruoyi-system/src/main/java/com/ruoyi/system/handler/TRX2EneryTransferHandler.java index 9968f9099..b9206014c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/handler/TRX2EneryTransferHandler.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/handler/TRX2EneryTransferHandler.java @@ -18,6 +18,7 @@ import com.ruoyi.common.utils.http.RestTemplateUtils; import com.ruoyi.system.bot.TgLongPollingBot; import com.ruoyi.system.bot.utils.SendContent; import com.ruoyi.system.domain.MonitorAddressAccount; +import com.ruoyi.system.domain.TgMessageInfoTask; import com.ruoyi.system.dto.Contract; import com.ruoyi.system.dto.Data; import com.ruoyi.system.dto.TronGridResponse; @@ -42,6 +43,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.util.UriComponentsBuilder; import org.telegram.telegrambots.meta.api.methods.ParseMode; import org.telegram.telegrambots.meta.api.methods.send.SendMessage; +import org.telegram.telegrambots.meta.exceptions.TelegramApiException; import org.tron.trident.core.ApiWrapper; import org.tron.trident.core.exceptions.IllegalException; import org.tron.trident.proto.Chain; @@ -49,10 +51,8 @@ import org.tron.trident.proto.Common; import org.tron.trident.proto.Response; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; @Component @@ -83,7 +83,8 @@ public class TRX2EneryTransferHandler { public void doMonitorTrxTransferByMonitorAddressInfo(MonitorAddressAccount monitorAddressAccount) { String monitorAddress = monitorAddressAccount.getMonitorAddress(); - String apiKey = monitorAddressAccount.getApiKey(); +/* String apiKey = monitorAddressAccount.getApiKey();*/ + String apiKey = DictUtils.getRandomDictValue("sys_tron_api_key"); ResponseEntity responseEntity = null; try { @@ -293,7 +294,8 @@ public class TRX2EneryTransferHandler { String accountAddress = monitorAddressAccount.getAccountAddress(); String encryptPrivateKey = monitorAddressAccount.getEncryptPrivateKey(); String encryptKey = monitorAddressAccount.getEncryptKey(); - String apiKey = monitorAddressAccount.getApiKey(); + /* String apiKey = monitorAddressAccount.getApiKey();*/ + String apiKey = DictUtils.getRandomDictValue("sys_tron_api_key"); String decryptPrivateKey = Dt.decrypt(encryptPrivateKey, encryptKey); @@ -319,7 +321,7 @@ public class TRX2EneryTransferHandler { } - calcBalanceAndDelegate(txID, apiWrapper, accountAddress, transferCount, ownerAddress, lockPeriod, toAddress, price, sysEnergyBusiType, amount,"TRX","system",Common.ResourceCode.ENERGY.name(),"energy_used"); + calcBalanceAndDelegate(txID, apiWrapper, accountAddress, transferCount, ownerAddress, lockPeriod, toAddress, price, sysEnergyBusiType, amount,"TRX","system",Common.ResourceCode.ENERGY.name(),"energy_used",monitorAddressAccount); //持久化之后放redis redisTemplate.opsForValue().set("transfer_trx_" + txID, txID, 1, TimeUnit.DAYS); if (tenantInfo != null) { @@ -330,18 +332,19 @@ public class TRX2EneryTransferHandler { /** - * @param txID 转账交易订单号 - * @param apiWrapper apiWrapper - * @param accountAddress 出账地址 - * @param transferCount 转账笔数 - * @param ownerAddress 转入地址 - * @param lockPeriod 锁定周期 - * @param toAddress 监听地址 - * @param price 单价 - * @param sysEnergyBusiType 业务类型 - * @param amount 转入金额 - * @param currentUser 当前处理人 + * @param txID 转账交易订单号 + * @param apiWrapper apiWrapper + * @param accountAddress 出账地址 + * @param transferCount 转账笔数 + * @param ownerAddress 转入地址 + * @param lockPeriod 锁定周期 + * @param toAddress 监听地址 + * @param price 单价 + * @param sysEnergyBusiType 业务类型 + * @param amount 转入金额 + * @param currentUser 当前处理人 * @param calcRule + * @param monitorAddressAccount * @throws Exception 异常 */ public void calcBalanceAndDelegate(String txID, @@ -356,7 +359,7 @@ public class TRX2EneryTransferHandler { Long amount, String trxAmountUnit, String currentUser, - String resourceCode, String calcRule) throws Exception { + String resourceCode, String calcRule, MonitorAddressAccount monitorAddressAccount) throws Exception { String systronApiSwitch = configService.selectConfigByKey("sys.tron.api"); Long balance = null; @@ -424,15 +427,28 @@ public class TRX2EneryTransferHandler { TrxExchangeFail trxExchangeFail = new TrxExchangeFail(); trxExchangeFail.setIdTrxExchangeFail(Long.valueOf(cacheidTrxExchangeFail.toString())); - trxExchangeFail.setDelegateStatus("1"); + trxExchangeFail.setDelegateStatus("0"); trxExchangeFail.setUpdateTime(new Date()); trxExchangeFailMapper.updateTrxExchangeFail(trxExchangeFail); redisTemplate.delete("transfer_trx_fail_" + txID); } - String sysenTrxTransferNotice = configService.selectConfigByKey("sys.energy.transaction.notice"); - String sysTgGroupChatId = configService.selectConfigByKey("sys.tg.group.chat.id"); - if (longPollingBot != null && StringUtils.isNotEmpty(sysenTrxTransferNotice) && StringUtils.isNotEmpty(sysTgGroupChatId)) { + + if (longPollingBot != null) { + + CompletableFuture.runAsync(() -> { + String sysenTrxTransferNotice = configService.selectConfigByKey("sys.energy.transaction.notice"); + String sysTgGroupChatId = configService.selectConfigByKey("sys.tg.group.chat.id"); + if (monitorAddressAccount != null){ + String messageInfo = monitorAddressAccount.getMessageInfo(); + if (StringUtils.isNotEmpty(messageInfo)){ + sysenTrxTransferNotice = messageInfo; + } + String groupChatId = monitorAddressAccount.getGroupChatId(); + if (StringUtils.isNotEmpty(groupChatId)){ + sysTgGroupChatId = groupChatId; + } + } /* * 转账TRX:{trxAmount} 单价: {price} @@ -441,18 +457,25 @@ public class TRX2EneryTransferHandler { 交易哈希:{txId} 订单时间:{txTime} * */ - Map arguments = new HashMap<>(); - arguments.put("trxAmount", amount == null ? "" : amount.toString()); - arguments.put("price", price == null ? "" : price.toString()); - arguments.put("transferCount", transferCount); - arguments.put("FromAddress", fromAddress.replaceAll("(.{6})(.*)(.{8})", "$1********$3")); - arguments.put("txId", StringUtils.isEmpty(txID) ? "" : txID.replaceAll("(.{6})(.*)(.{8})", "$1*******************$3")); - arguments.put("txTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); + Map arguments = new HashMap<>(); + arguments.put("trxAmount", amount == null ? "" : amount.toString()); + arguments.put("price", price == null ? "" : price.toString()); + arguments.put("transferCount", transferCount); + arguments.put("FromAddress", fromAddress.replaceAll("(.{6})(.*)(.{8})", "$1********$3")); + arguments.put("txId", StringUtils.isEmpty(txID) ? "" : txID.replaceAll("(.{6})(.*)(.{8})", "$1*******************$3")); + arguments.put("txTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); // String message = MessageFormat.format(sysUsdtTranferNotice, arguments); - StrSubstitutor substitutor = new StrSubstitutor(arguments, "{", "}"); - String message = substitutor.replace(sysenTrxTransferNotice); - SendMessage sendMessage = sendContent.messageText(sysTgGroupChatId, message, ParseMode.HTML); - longPollingBot.execute(sendMessage); + StrSubstitutor substitutor = new StrSubstitutor(arguments, "{", "}"); + String message = substitutor.replace(sysenTrxTransferNotice); + SendMessage sendMessage = sendContent.messageText(sysTgGroupChatId, message, ParseMode.HTML); + try { + longPollingBot.execute(sendMessage); + } catch (TelegramApiException e) { + log.error("longPollingBot execute is null"); + } + }); + + } else { log.warn("longPollingBot OR sysUsdtTranferNotice OR sysTgGroupChatId is null"); } @@ -492,4 +515,17 @@ public class TRX2EneryTransferHandler { return delegateResourceTxid; } + public void topicGroupMessage(TgMessageInfoTask tgMessageInfoTask) throws TelegramApiException { + if (longPollingBot == null){ + return; + } + + String message = tgMessageInfoTask.getMessageInfo(); + String chatId = tgMessageInfoTask.getChatIds(); + List chatIdList = Arrays.asList(chatId.split(",")); + for (String groupChatId : chatIdList) { + SendMessage sendMessage = sendContent.messageText(groupChatId, message, ParseMode.MARKDOWN); + longPollingBot.execute(sendMessage); + } + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/handler/UndelegateEnergyHandler.java b/ruoyi-system/src/main/java/com/ruoyi/system/handler/UndelegateEnergyHandler.java index 6c0bd1cb6..1ac83e7f6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/handler/UndelegateEnergyHandler.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/handler/UndelegateEnergyHandler.java @@ -223,7 +223,7 @@ public class UndelegateEnergyHandler { null, null, "system", - Common.ResourceCode.ENERGY.name(), tenantInfo.getCalcRule()); + Common.ResourceCode.ENERGY.name(), tenantInfo.getCalcRule(), null); } else { Long period = tenantInfo.getPeriod(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/handler/Usdt2TrxTransferHandler.java b/ruoyi-system/src/main/java/com/ruoyi/system/handler/Usdt2TrxTransferHandler.java index b4b58fcd0..7316d8641 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/handler/Usdt2TrxTransferHandler.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/handler/Usdt2TrxTransferHandler.java @@ -9,6 +9,7 @@ import com.google.common.base.Preconditions; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.entity.ErrorLog; import com.ruoyi.common.core.domain.entity.UsdtExchangeInfo; +import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.ForwardCounter; import com.ruoyi.common.utils.LogUtils; import com.ruoyi.common.utils.StringUtils; @@ -21,6 +22,7 @@ import com.ruoyi.system.api.enums.Symbol; import com.ruoyi.system.bot.TgLongPollingBot; import com.ruoyi.system.bot.utils.SendContent; import com.ruoyi.system.domain.MonitorAddressAccount; +import com.ruoyi.system.domain.TgMessageInfoTask; import com.ruoyi.system.dto.Data; import com.ruoyi.system.dto.Token_info; import com.ruoyi.system.dto.TronGridResponse; @@ -49,10 +51,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; @Component @@ -88,7 +87,8 @@ public class Usdt2TrxTransferHandler { try { String monitorAddress = monitorAddressAccount.getMonitorAddress(); - String apiKey = monitorAddressAccount.getApiKey(); + /* String apiKey = monitorAddressAccount.getApiKey();*/ + String apiKey = DictUtils.getRandomDictValue("sys_tron_api_key"); String sysTransferBetween = configService.selectConfigByKey("sys.transfer.between"); // DateTime min_timestamp = DateUtil.offset(new Date(), DateField.MINUTE, Integer.valueOf(sysTransferBetween)); @@ -156,7 +156,7 @@ public class Usdt2TrxTransferHandler { return; } - doTransferUsdtAndStore(oneUsdtToTrxPair, apiKey, decryptPrivateKey, accountAddress, from, trxValue, dataTo, transactionId, transferValue); + doTransferUsdtAndStore(oneUsdtToTrxPair, apiKey, decryptPrivateKey, accountAddress, from, trxValue, dataTo, transactionId, transferValue,monitorAddressAccount); redisTemplate.opsForValue().set("transfer_USDT_" + transactionId, transactionId, 1, TimeUnit.DAYS); } finally { @@ -168,7 +168,7 @@ public class Usdt2TrxTransferHandler { } } - public void doTransferUsdtAndStore(Pair oneUsdtToTrxPair, String apiKey, String decryptPrivateKey, String accountAddress, String from, BigDecimal trxValue, String dataTo, String transactionId, BigDecimal transferValue) throws IllegalException, TelegramApiException { + public void doTransferUsdtAndStore(Pair oneUsdtToTrxPair, String apiKey, String decryptPrivateKey, String accountAddress, String from, BigDecimal trxValue, String dataTo, String transactionId, BigDecimal transferValue, MonitorAddressAccount monitorAddressAccount) throws IllegalException, TelegramApiException { String systronApiSwitch = configService.selectConfigByKey("sys.tron.api"); @@ -194,7 +194,7 @@ public class Usdt2TrxTransferHandler { .setUsdtAmount(transferValue) .setTrxAmount(trxValue) .setExchangeRate(oneUsdtToTrxPair == null ? null : oneUsdtToTrxPair.getFirst()) - .setOrginalExchangeRate(oneUsdtToTrxPair == null ? null :oneUsdtToTrxPair.getSecond()) + .setOrginalExchangeRate(oneUsdtToTrxPair == null ? null : oneUsdtToTrxPair.getSecond()) .setTrxTxId(txId) .setFcu("system") .setLcu("system"); @@ -202,15 +202,28 @@ public class Usdt2TrxTransferHandler { usdtExchangeInfoMapper.insertUsdtExchangeInfo(usdtExchangeInfo); - if (oneUsdtToTrxPair != null){ - doSendTgNotice(oneUsdtToTrxPair.getFirst(), from, trxValue, transferValue, txId); + if (oneUsdtToTrxPair != null) { + doSendTgNotice(oneUsdtToTrxPair.getFirst(), from, trxValue, transferValue, txId,monitorAddressAccount); } } - private void doSendTgNotice(BigDecimal oneUsdtToTrx, String from, BigDecimal trxValue, BigDecimal transferValue, String txId) throws TelegramApiException { - String sysUsdtTranferNotice = configService.selectConfigByKey("sys.usdt.tranfer.notice"); - String sysTgGroupChatId = configService.selectConfigByKey("sys.tg.group.chat.id"); - if (longPollingBot != null && StringUtils.isNotEmpty(sysUsdtTranferNotice) && StringUtils.isNotEmpty(sysTgGroupChatId)) { + private void doSendTgNotice(BigDecimal oneUsdtToTrx, String from, BigDecimal trxValue, BigDecimal transferValue, String txId, MonitorAddressAccount monitorAddressAccount) throws TelegramApiException { + + if (longPollingBot != null ) { + String sysUsdtTranferNotice = configService.selectConfigByKey("sys.usdt.tranfer.notice"); + String sysTgGroupChatId = configService.selectConfigByKey("sys.tg.group.chat.id"); + if (monitorAddressAccount != null){ + String messageInfo = monitorAddressAccount.getMessageInfo(); + if (StringUtils.isNotEmpty(messageInfo)){ + sysUsdtTranferNotice = messageInfo; + } + String groupChatId = monitorAddressAccount.getGroupChatId(); + if (StringUtils.isNotEmpty(groupChatId)){ + sysTgGroupChatId = groupChatId; + } + } + + Map arguments = new HashMap<>(); arguments.put("usdtAmount", transferValue.setScale(2, BigDecimal.ROUND_HALF_DOWN)); arguments.put("exchangeRate", oneUsdtToTrx); @@ -224,7 +237,7 @@ public class Usdt2TrxTransferHandler { SendMessage sendMessage = sendContent.messageText(sysTgGroupChatId, message, ParseMode.HTML); longPollingBot.execute(sendMessage); } else { - log.warn("longPollingBot OR sysUsdtTranferNotice OR sysTgGroupChatId is null"); + log.warn("longPollingBot is null"); } } @@ -296,34 +309,39 @@ public class Usdt2TrxTransferHandler { } - public void topicGroupMessage() { + public void topicGroupMessage(TgMessageInfoTask tgMessageInfoTask) throws TelegramApiException, NoSuchAlgorithmException, IOException, InvalidKeyException { - - String sysUsdtGroupTopic = configService.selectConfigByKey("sys.usdt.group.topic"); - String sysTgGroupChatId = configService.selectConfigByKey("sys.tg.group.chat.id"); - - log.info("longPollingBot:{},sysUsdtGroupTopic:{},sysTgGroupChatId:{}", longPollingBot, sysUsdtGroupTopic, sysTgGroupChatId); - - if (longPollingBot != null && StringUtils.isNotEmpty(sysUsdtGroupTopic) && StringUtils.isNotEmpty(sysTgGroupChatId)) { - log.info("进入这里1"); - try { - BigDecimal oneUsdtToTrx = getOneUsdtToTrx().getFirst(); - BigDecimal tenUsdtToTrx = oneUsdtToTrx.multiply(BigDecimal.TEN); - Map arguments = new HashMap<>(); - arguments.put("tenUsdtToTrx", tenUsdtToTrx); - StrSubstitutor substitutor = new StrSubstitutor(arguments, "{", "}"); - String message = substitutor.replace(sysUsdtGroupTopic); - SendMessage sendMessage = sendContent.messageText(sysTgGroupChatId, message, ParseMode.MARKDOWN); - - longPollingBot.execute(sendMessage); - } catch (Exception e) { - - log.error("广播消息异常", e); - } - } else { - log.info("进入这里2"); - log.warn("sysUsdtTranferNotice OR sysTgGroupChatId is null"); + if (longPollingBot == null) { + return; } +/* String sysUsdtGroupTopic = configService.selectConfigByKey("sys.usdt.group.topic"); + String sysTgGroupChatId = configService.selectConfigByKey("sys.tg.group.chat.id");*/ + + String messageContent = tgMessageInfoTask.getMessageInfo(); + + String chatId = tgMessageInfoTask.getChatIds(); + List chatIdList = Arrays.asList(chatId.split(",")); + + log.info("longPollingBot:{},sysUsdtGroupTopic:{},sysTgGroupChatId:{}", longPollingBot, messageContent, chatId); + + + for (String groupChatId : chatIdList) { + sendGroupMessage(messageContent, groupChatId); + } + + + } + + private void sendGroupMessage(String sysUsdtGroupTopic, String sysTgGroupChatId) throws NoSuchAlgorithmException, InvalidKeyException, IOException, TelegramApiException { + BigDecimal oneUsdtToTrx = getOneUsdtToTrx().getFirst(); + BigDecimal tenUsdtToTrx = oneUsdtToTrx.multiply(BigDecimal.TEN); + Map arguments = new HashMap<>(); + arguments.put("tenUsdtToTrx", tenUsdtToTrx); + StrSubstitutor substitutor = new StrSubstitutor(arguments, "{", "}"); + String message = substitutor.replace(sysUsdtGroupTopic); + SendMessage sendMessage = sendContent.messageText(sysTgGroupChatId, message, ParseMode.MARKDOWN); + + longPollingBot.execute(sendMessage); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TgMessageInfoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TgMessageInfoMapper.java index c1f708777..7e6383958 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TgMessageInfoMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TgMessageInfoMapper.java @@ -60,4 +60,7 @@ public interface TgMessageInfoMapper * @return 结果 */ public int deleteTgMessageInfoByIdTgMessageInfos(String[] idTgMessageInfos); + + List selectTopicTgMessageInfoList(); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TgMessageTaskMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TgMessageTaskMapper.java new file mode 100644 index 000000000..8aafec6de --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TgMessageTaskMapper.java @@ -0,0 +1,66 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.common.core.domain.entity.TgMessageTask; +import com.ruoyi.system.domain.TgMessageInfoTask; + +import java.util.List; + + +/** + * TG消息任务管理Mapper接口 + * + * @author dorion + * @date 2024-07-14 + */ +public interface TgMessageTaskMapper +{ + /** + * 查询TG消息任务管理 + * + * @param idTgMessageTask TG消息任务管理主键 + * @return TG消息任务管理 + */ + public TgMessageTask selectTgMessageTaskByIdTgMessageTask(Long idTgMessageTask); + + /** + * 查询TG消息任务管理列表 + * + * @param tgMessageTask TG消息任务管理 + * @return TG消息任务管理集合 + */ + public List selectTgMessageTaskList(TgMessageTask tgMessageTask); + + /** + * 新增TG消息任务管理 + * + * @param tgMessageTask TG消息任务管理 + * @return 结果 + */ + public int insertTgMessageTask(TgMessageTask tgMessageTask); + + /** + * 修改TG消息任务管理 + * + * @param tgMessageTask TG消息任务管理 + * @return 结果 + */ + public int updateTgMessageTask(TgMessageTask tgMessageTask); + + /** + * 删除TG消息任务管理 + * + * @param idTgMessageTask TG消息任务管理主键 + * @return 结果 + */ + public int deleteTgMessageTaskByIdTgMessageTask(Long idTgMessageTask); + + /** + * 批量删除TG消息任务管理 + * + * @param idTgMessageTasks 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteTgMessageTaskByIdTgMessageTasks(String[] idTgMessageTasks); + + List selectTgMessageTaskAndInfoList(TgMessageTask tgMessageTask); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITgMessageInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITgMessageInfoService.java index 18a598363..1bb0ffbe2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITgMessageInfoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITgMessageInfoService.java @@ -60,4 +60,6 @@ public interface ITgMessageInfoService * @return 结果 */ public int deleteTgMessageInfoByIdTgMessageInfo(Long idTgMessageInfo); + + List selectTopicTgMessageInfoList(); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITgMessageTaskService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITgMessageTaskService.java new file mode 100644 index 000000000..0888e44bc --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITgMessageTaskService.java @@ -0,0 +1,63 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.core.domain.entity.TgMessageTask; + +import java.util.List; + + +/** + * TG消息任务管理Service接口 + * + * @author dorion + * @date 2024-07-14 + */ +public interface ITgMessageTaskService +{ + /** + * 查询TG消息任务管理 + * + * @param idTgMessageTask TG消息任务管理主键 + * @return TG消息任务管理 + */ + public TgMessageTask selectTgMessageTaskByIdTgMessageTask(Long idTgMessageTask); + + /** + * 查询TG消息任务管理列表 + * + * @param tgMessageTask TG消息任务管理 + * @return TG消息任务管理集合 + */ + public List selectTgMessageTaskList(TgMessageTask tgMessageTask); + + /** + * 新增TG消息任务管理 + * + * @param tgMessageTask TG消息任务管理 + * @return 结果 + */ + public int insertTgMessageTask(TgMessageTask tgMessageTask); + + /** + * 修改TG消息任务管理 + * + * @param tgMessageTask TG消息任务管理 + * @return 结果 + */ + public int updateTgMessageTask(TgMessageTask tgMessageTask); + + /** + * 批量删除TG消息任务管理 + * + * @param idTgMessageTasks 需要删除的TG消息任务管理主键集合 + * @return 结果 + */ + public int deleteTgMessageTaskByIdTgMessageTasks(String idTgMessageTasks); + + /** + * 删除TG消息任务管理信息 + * + * @param idTgMessageTask TG消息任务管理主键 + * @return 结果 + */ + public int deleteTgMessageTaskByIdTgMessageTask(Long idTgMessageTask); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MonitorAddressInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MonitorAddressInfoServiceImpl.java index 72153c549..8cce2ddb5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MonitorAddressInfoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MonitorAddressInfoServiceImpl.java @@ -82,6 +82,10 @@ public class MonitorAddressInfoServiceImpl implements IMonitorAddressInfoService }); monitorAddressInfoVOList.add(monitorAddressInfoVO); }); + + /* MonitorAddressInfoVO monitorAddressInfoVO = new MonitorAddressInfoVO(); + BeanUtils.copyProperties(monitorAddressInfo1,monitorAddressInfoVO); + monitorAddressInfoVOList.add(monitorAddressInfoVO);*/ }); List sortedMonitorAddressInfoVOList = monitorAddressInfoVOList.stream().sorted(Comparator.comparingLong(MonitorAddressInfoVO::getIdMonitorAddress)) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TgMessageInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TgMessageInfoServiceImpl.java index 90c371b6b..f9ac383c7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TgMessageInfoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TgMessageInfoServiceImpl.java @@ -2,7 +2,7 @@ package com.ruoyi.system.service.impl; import com.ruoyi.common.core.domain.entity.TgMessageInfo; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.system.mapper.TgMessageInfoMapper; import com.ruoyi.system.service.ITgMessageInfoService; import org.springframework.beans.factory.annotation.Autowired; @@ -12,87 +12,93 @@ import java.util.List; /** * TG消息管理Service业务层处理 - * + * * @author dorion * @date 2024-07-12 */ @Service -public class TgMessageInfoServiceImpl implements ITgMessageInfoService -{ +public class TgMessageInfoServiceImpl implements ITgMessageInfoService { @Autowired private TgMessageInfoMapper tgMessageInfoMapper; /** * 查询TG消息管理 - * + * * @param idTgMessageInfo TG消息管理主键 * @return TG消息管理 */ @Override - public TgMessageInfo selectTgMessageInfoByIdTgMessageInfo(Long idTgMessageInfo) - { + public TgMessageInfo selectTgMessageInfoByIdTgMessageInfo(Long idTgMessageInfo) { return tgMessageInfoMapper.selectTgMessageInfoByIdTgMessageInfo(idTgMessageInfo); } /** * 查询TG消息管理列表 - * + * * @param tgMessageInfo TG消息管理 * @return TG消息管理 */ @Override - public List selectTgMessageInfoList(TgMessageInfo tgMessageInfo) - { + public List selectTgMessageInfoList(TgMessageInfo tgMessageInfo) { return tgMessageInfoMapper.selectTgMessageInfoList(tgMessageInfo); } /** * 新增TG消息管理 - * + * * @param tgMessageInfo TG消息管理 * @return 结果 */ @Override - public int insertTgMessageInfo(TgMessageInfo tgMessageInfo) - { - tgMessageInfo.setCreateTime(DateUtils.getNowDate()); + public int insertTgMessageInfo(TgMessageInfo tgMessageInfo) { + + String loginName = ShiroUtils.getSysUser().getLoginName(); + tgMessageInfo.setCreateBy(loginName); + tgMessageInfo.setUpdateBy(loginName); + return tgMessageInfoMapper.insertTgMessageInfo(tgMessageInfo); } + + + /** * 修改TG消息管理 - * + * * @param tgMessageInfo TG消息管理 * @return 结果 */ @Override - public int updateTgMessageInfo(TgMessageInfo tgMessageInfo) - { - tgMessageInfo.setUpdateTime(DateUtils.getNowDate()); + public int updateTgMessageInfo(TgMessageInfo tgMessageInfo) { + String loginName = ShiroUtils.getSysUser().getLoginName(); + tgMessageInfo.setUpdateBy(loginName); return tgMessageInfoMapper.updateTgMessageInfo(tgMessageInfo); } /** * 批量删除TG消息管理 - * + * * @param idTgMessageInfos 需要删除的TG消息管理主键 * @return 结果 */ @Override - public int deleteTgMessageInfoByIdTgMessageInfos(String idTgMessageInfos) - { + public int deleteTgMessageInfoByIdTgMessageInfos(String idTgMessageInfos) { return tgMessageInfoMapper.deleteTgMessageInfoByIdTgMessageInfos(Convert.toStrArray(idTgMessageInfos)); } /** * 删除TG消息管理信息 - * + * * @param idTgMessageInfo TG消息管理主键 * @return 结果 */ @Override - public int deleteTgMessageInfoByIdTgMessageInfo(Long idTgMessageInfo) - { + public int deleteTgMessageInfoByIdTgMessageInfo(Long idTgMessageInfo) { return tgMessageInfoMapper.deleteTgMessageInfoByIdTgMessageInfo(idTgMessageInfo); } + + @Override + public List selectTopicTgMessageInfoList() { + return tgMessageInfoMapper.selectTopicTgMessageInfoList(); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TgMessageTaskServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TgMessageTaskServiceImpl.java new file mode 100644 index 000000000..291d45dba --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TgMessageTaskServiceImpl.java @@ -0,0 +1,139 @@ +package com.ruoyi.system.service.impl; + +import cn.hutool.core.util.NumberUtil; +import com.google.common.base.Preconditions; +import com.ruoyi.common.core.domain.entity.TgMessageTask; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.system.mapper.TgMessageTaskMapper; +import com.ruoyi.system.service.ITgMessageTaskService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * TG消息任务管理Service业务层处理 + * + * @author dorion + * @date 2024-07-14 + */ +@Service +public class TgMessageTaskServiceImpl implements ITgMessageTaskService +{ + @Autowired + private TgMessageTaskMapper tgMessageTaskMapper; + + /** + * 查询TG消息任务管理 + * + * @param idTgMessageTask TG消息任务管理主键 + * @return TG消息任务管理 + */ + @Override + public TgMessageTask selectTgMessageTaskByIdTgMessageTask(Long idTgMessageTask) + { + return tgMessageTaskMapper.selectTgMessageTaskByIdTgMessageTask(idTgMessageTask); + } + + /** + * 查询TG消息任务管理列表 + * + * @param tgMessageTask TG消息任务管理 + * @return TG消息任务管理 + */ + @Override + public List selectTgMessageTaskList(TgMessageTask tgMessageTask) + { + return tgMessageTaskMapper.selectTgMessageTaskList(tgMessageTask); + } + + /** + * 新增TG消息任务管理 + * + * @param tgMessageTask TG消息任务管理 + * @return 结果 + */ + @Override + public int insertTgMessageTask(TgMessageTask tgMessageTask) + { + Long executionStragy = tgMessageTask.getExecutionStragy(); + if (0 == executionStragy) { + String intervalTime = tgMessageTask.getIntervalTime(); + Preconditions.checkNotNull(intervalTime, "周期执行时间间隔不能为空"); + checkIntervalTime(intervalTime); + tgMessageTask.setNextRunTime(tgMessageTask.getBeginTime()); + } else { + tgMessageTask.setIntervalTime(null); + } + + String loginName = ShiroUtils.getSysUser().getLoginName(); + tgMessageTask.setCreateBy(loginName); + tgMessageTask.setUpdateBy(loginName); + tgMessageTask.setStatus(1L); + return tgMessageTaskMapper.insertTgMessageTask(tgMessageTask); + } + + + private void checkIntervalTime(String intervalTime) { + int length = intervalTime.length(); + String intervalTimeNumber = intervalTime.substring(0, length - 1); + boolean number = NumberUtil.isNumber(intervalTimeNumber); + Preconditions.checkState(number, "时间间隔时间必须全部为数字"); + + String intervalTimeUnit = intervalTime.substring(length - 1, length); + boolean expression = intervalTimeUnit.equalsIgnoreCase("s") + || intervalTimeUnit.equalsIgnoreCase("m") + || intervalTimeUnit.equalsIgnoreCase("h") ; + Preconditions.checkState(expression, "时间间隔单位只能为S、M、H"); + } + + /** + * 修改TG消息任务管理 + * + * @param tgMessageTask TG消息任务管理 + * @return 结果 + */ + @Override + public int updateTgMessageTask(TgMessageTask tgMessageTask) + { + Long executionStragy = tgMessageTask.getExecutionStragy(); + if (0 == executionStragy) { + String intervalTime = tgMessageTask.getIntervalTime(); + checkIntervalTime(intervalTime); + tgMessageTask.setNextRunTime(tgMessageTask.getBeginTime()); + } else { + tgMessageTask.setIntervalTime(null); + tgMessageTask.setNextRunTime(null); + } + String loginName = ShiroUtils.getSysUser().getLoginName(); + tgMessageTask.setUpdateBy(loginName); + tgMessageTask.setUpdateTime(new Date()); + return tgMessageTaskMapper.updateTgMessageTask(tgMessageTask); + } + + /** + * 批量删除TG消息任务管理 + * + * @param idTgMessageTasks 需要删除的TG消息任务管理主键 + * @return 结果 + */ + @Override + public int deleteTgMessageTaskByIdTgMessageTasks(String idTgMessageTasks) + { + return tgMessageTaskMapper.deleteTgMessageTaskByIdTgMessageTasks(Convert.toStrArray(idTgMessageTasks)); + } + + /** + * 删除TG消息任务管理信息 + * + * @param idTgMessageTask TG消息任务管理主键 + * @return 结果 + */ + @Override + public int deleteTgMessageTaskByIdTgMessageTask(Long idTgMessageTask) + { + return tgMessageTaskMapper.deleteTgMessageTaskByIdTgMessageTask(idTgMessageTask); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeFailServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeFailServiceImpl.java index 0718fc005..beccf50ee 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeFailServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeFailServiceImpl.java @@ -159,7 +159,7 @@ public class TrxExchangeFailServiceImpl implements ITrxExchangeFailService trxExchangeFail.getTrxAmount(), trxExchangeFail.getTrxAmountUnit(), ShiroUtils.getLoginName(), - trxExchangeFail.getResourceCode(), trxExchangeFail.getCalcRule()); + trxExchangeFail.getResourceCode(), trxExchangeFail.getCalcRule(), null); }catch (Exception e){ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeInfoServiceImpl.java index 2a89eb126..ea7b9a8ba 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeInfoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeInfoServiceImpl.java @@ -163,7 +163,7 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService { null, null, userName, - trxExchange.getResourceCode(), calcRule); + trxExchange.getResourceCode(), calcRule, null); return 1; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UsdtExchangeInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UsdtExchangeInfoServiceImpl.java index 660391af0..08de47909 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UsdtExchangeInfoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UsdtExchangeInfoServiceImpl.java @@ -107,7 +107,7 @@ public class UsdtExchangeInfoServiceImpl implements IUsdtExchangeInfoService { String fromAddress = usdtExchangeInfo.getFromAddress(); usdt2TrxTransferHandler. - doTransferUsdtAndStore(oneUsdtToTrxPair, apiKey, decryptPrivateKey, accountAddress, fromAddress, trxValue, null, null, usdtAmount); + doTransferUsdtAndStore(oneUsdtToTrxPair, apiKey, decryptPrivateKey, accountAddress, fromAddress, trxValue, null, null, usdtAmount, null); return 1; } diff --git a/ruoyi-system/src/main/resources/mapper/account/MonitorAddressInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/account/MonitorAddressInfoMapper.xml index 5021f5f62..98cb8204d 100644 --- a/ruoyi-system/src/main/resources/mapper/account/MonitorAddressInfoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/account/MonitorAddressInfoMapper.xml @@ -4,7 +4,6 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - @@ -14,7 +13,8 @@ - + + @@ -25,7 +25,7 @@ - select id_monitor_address, busi_type, monitor_address_name, monitor_address, account_address, trx_price, usdt_price, monitor_type, api_key, bind_period, is_valid, comment, fcd, fcu, lcd, lcu from monitor_address_info + select id_monitor_address, busi_type, monitor_address_name, monitor_address, account_address, trx_price, usdt_price, monitor_type, id_tg_message_info, group_chat_id, bind_period, is_valid, comment, fcd, fcu, lcd, lcu from monitor_address_info - select m.monitor_address, - m.account_address, - m.trx_price, - m.usdt_price, - a.encrypt_private_key, - a.encrypt_key, - m.api_key, - m.bind_period - from monitor_address_info m, - account_address_info a - where m.account_address = a.address - and m.is_valid = a.is_valid - and m.busi_type = a.busi_type - and m.busi_type = #{busiType} + + + + + + + + + + + + + diff --git a/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml index c4df07871..e80bacc90 100644 --- a/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml @@ -210,7 +210,7 @@ t.delegate_tx_id, t.un_delegate_tx_id, t.fcd, - m.api_key, + a.encrypt_key, a.encrypt_private_key FROM diff --git a/ruoyi-system/src/main/resources/mapper/system/TgMessageInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TgMessageInfoMapper.xml index 769ed1b0d..9056e9aeb 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TgMessageInfoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TgMessageInfoMapper.xml @@ -6,14 +6,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - - - - - - @@ -22,14 +17,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id_tg_message_info, message_info, message_type, chat_id, interval_time, begin_time, next_run_time, execution_stragy, status, create_by, create_time, update_by, update_time, remark from tg_message_info + select id_tg_message_info,message_abbr_name, message_info, message_type,create_by, create_time, update_by, update_time, remark from tg_message_info t1 @@ -38,52 +32,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id_tg_message_info = #{idTgMessageInfo} - + + insert into tg_message_info + message_abbr_name, message_info, message_type, - chat_id, - interval_time, - begin_time, - next_run_time, - execution_stragy, - status, + create_by, create_time, update_by, update_time, remark, - + + #{messageAbbrName}, #{messageInfo}, #{messageType}, - #{chatId}, - #{intervalTime}, - #{beginTime}, - #{nextRunTime}, - #{executionStragy}, - #{status}, + #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark}, - + update tg_message_info + message_abbr_name = #{messageAbbrName}, message_info = #{messageInfo}, message_type = #{messageType}, - chat_id = #{chatId}, - interval_time = #{intervalTime}, - begin_time = #{beginTime}, - next_run_time = #{nextRunTime}, - execution_stragy = #{executionStragy}, - status = #{status}, + create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, @@ -104,4 +87,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/TgMessageTaskMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TgMessageTaskMapper.xml new file mode 100644 index 000000000..d332c9c59 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/TgMessageTaskMapper.xml @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + select id_tg_message_task, + id_tg_message_info, + chat_ids, + interval_time, + begin_time, + next_run_time, + execution_stragy, + status, + create_by, + create_time, + update_by, + update_time, + remark + from tg_message_task + + + + + + + + insert into tg_message_task + + + id_tg_message_info, + + + chat_ids, + + + interval_time, + + + begin_time, + + + next_run_time, + + + execution_stragy, + + + status, + + + create_by, + + + create_time, + + + update_by, + + + update_time, + + + remark, + + + + + #{idTgMessageInfo}, + + + #{chatIds}, + + + #{intervalTime}, + + + #{beginTime}, + + + #{nextRunTime}, + + + #{executionStragy}, + + + #{status}, + + + #{createBy}, + + + #{createTime}, + + + #{updateBy}, + + + #{updateTime}, + + + #{remark}, + + + + + + update tg_message_task + + + id_tg_message_info = #{idTgMessageInfo}, + + + chat_ids = #{chatIds}, + + + interval_time = #{intervalTime}, + + + begin_time = #{beginTime}, + + + next_run_time = #{nextRunTime}, + + + execution_stragy = #{executionStragy}, + + + status = #{status}, + + + create_by = #{createBy}, + + + create_time = #{createTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + remark = #{remark}, + + + where id_tg_message_task = #{idTgMessageTask} + + + + delete + from tg_message_task + where id_tg_message_task = #{idTgMessageTask} + + + + delete + from tg_message_task where id_tg_message_task in + + #{idTgMessageTask} + + + + + + + + + + + + + + + + + + \ No newline at end of file