Selaa lähdekoodia

feature 增加推送记录

xiahan 2 kuukautta sitten
vanhempi
commit
a8e1cf75ec

+ 1 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/SwBillManagementUnpaidDao.java

@@ -31,7 +31,7 @@ public interface SwBillManagementUnpaidDao extends BaseMapper<SwBillManagementUn
      * @return 欠费用户信息列表
      */
     @MapKey("ID")
-    List<Map<String, Object>> getWaterFeeArrearsInfo();
+    List<Map<String, Object>> getWaterFeeArrearsInfo(@Param("ids") List<String> ids);
 
 }
 

+ 17 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/SwNoticeRecordDao.java

@@ -0,0 +1,17 @@
+package com.rongwei.zhsw.system.dao;
+
+
+import com.rongwe.zhsw.system.domain.SwNoticeRecordDo;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 缴费记录(SwBillingRecord)表数据库访问层
+ *
+ * @author makejava
+ * @since 2025-03-07 16:35:07
+ */
+@Mapper
+public interface SwNoticeRecordDao extends CommonMapper<SwNoticeRecordDo> {
+
+}
+

+ 16 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/SwNoticeRecordService.java

@@ -0,0 +1,16 @@
+package com.rongwei.zhsw.system.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwe.zhsw.system.domain.SwNoticeRecordDo;
+
+/**
+ * 缴费记录(SwBillingRecord)表服务接口
+ *
+ * @author makejava
+ * @since 2025-03-07 16:35:09
+ */
+public interface SwNoticeRecordService extends IService<SwNoticeRecordDo> {
+
+
+}

+ 18 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwNoticeRecordServiceImpl.java

@@ -0,0 +1,18 @@
+package com.rongwei.zhsw.system.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwe.zhsw.system.domain.SwNoticeRecordDo;
+import com.rongwei.zhsw.system.dao.SwNoticeRecordDao;
+import com.rongwei.zhsw.system.service.SwNoticeRecordService;
+import org.springframework.stereotype.Service;
+
+/**
+ * SwNoticeRecordServiceImpl class
+ *
+ * @author XH
+ * @date 2025/05/15
+ */
+@Service
+public class SwNoticeRecordServiceImpl extends ServiceImpl<SwNoticeRecordDao, SwNoticeRecordDo>
+        implements SwNoticeRecordService {
+}

+ 5 - 0
zhsw-common/src/main/resources/mybatis/zhsw/SwBillManagementUnpaidDao.xml

@@ -44,6 +44,11 @@
             AND (sbmu.STATUS = '2' OR sbmu.STATUS = '5')
             AND um.USERNUMBER IS NOT NULL
             AND suw.WECHATSIGN IS NOT NULL
+            AND suw.REMARK = '历史数据迁移信息'
+            and um.ID IN
+            <foreach collection="ids" open="(" close=")" item="id" separator=",">
+                #{id}
+            </foreach>
         GROUP BY
             um.VILLAGENAME,
             um.USERNUMBER,

+ 57 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/domain/SwNoticeRecordDo.java

@@ -0,0 +1,57 @@
+package com.rongwe.zhsw.system.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.rongwei.rwcommon.base.BaseDo;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 缴费记录(SwBillingRecord)实体类
+ *
+ * @author makejava
+ * @since 2025-03-07 16:35:08
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("sw_notice_record")
+public class SwNoticeRecordDo extends BaseDo implements Serializable {
+    private static final long serialVersionUID = -25780597568495659L;
+    /**
+     * 主键
+     */
+    private String id;
+    /**
+     * 租户ID
+     */
+    private String tenantid;
+    /**
+     * 扩展json格式配置
+     */
+    private String roption;
+    /**
+     * 户号
+     */
+    private String usernum;
+    /**
+     * 通知参数
+     */
+    private String noticepara;
+    /**
+     * 通知时间
+     */
+    private Date noticetime;
+    /**
+     * 通知结果
+     */
+    private String noticestate;
+    /**
+     * 通知人的标识
+     */
+    private String noticesign;
+}
+

+ 53 - 24
zhsw-server/src/main/java/com/rongwei/zhsw/system/controller/WeChatOfficialController.java

@@ -1,23 +1,28 @@
 package com.rongwei.zhsw.system.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.rongwe.zhsw.system.domain.SwEnterpriseConfigInfoDo;
+import com.rongwe.zhsw.system.domain.SwNoticeRecordDo;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.base.exception.CustomException;
+import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.zhsw.system.dao.SwBillManagementUnpaidDao;
-import com.rongwei.zhsw.system.dao.SwEnterpriseConfigInfoDao;
+import com.rongwei.zhsw.system.dao.SwNoticeRecordDao;
 import com.rongwei.zhsw.system.service.impl.SwEnterpriseConfigInfoServiceImpl;
+import com.rongwei.zhsw.system.service.impl.SwNoticeRecordServiceImpl;
 import com.rongwei.zhsw.system.utils.WxMessageUtils;
-import com.rongwe.zhsw.system.domain.SwEnterpriseConfigInfoDo;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
+import com.rongwei.zhsw.system.utils.ZHSWCommonUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
-import lombok.extern.slf4j.Slf4j;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.List;
-import java.util.Arrays;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.*;
 
 @Slf4j
 @RestController
@@ -28,6 +33,8 @@ public class WeChatOfficialController {
 
     @Autowired
     private SwBillManagementUnpaidDao swBillManagementUnpaidDao;
+    @Autowired
+    private SwNoticeRecordServiceImpl swNoticeRecordService;
 
     @PostMapping("/sendRepairMessage")
     public R sendRepairMessage(@RequestBody Map<String, Object> dataInfo) {
@@ -43,7 +50,7 @@ public class WeChatOfficialController {
             Map<String, String> receiverRoleMap = (Map<String, String>) dataInfo.get("receiverrole");
 
             if (mbtypeMap == null || !mbtypeMap.containsKey("value") ||
-                receiverRoleMap == null || !receiverRoleMap.containsKey("value")) {
+                    receiverRoleMap == null || !receiverRoleMap.containsKey("value")) {
                 return R.error("请求参数格式不正确");
             }
 
@@ -77,28 +84,28 @@ public class WeChatOfficialController {
             Map<String, String> firstMap = new HashMap<>();
             firstMap.put("value", ((Map<String, String>) dataInfo.get("first")).get("value"));
             data.put("first", firstMap);
-            
+
             // 新模板字段
             Map<String, String> thing5Map = new HashMap<>();
             thing5Map.put("value", ((Map<String, String>) dataInfo.get("thing5")).get("value"));
             data.put("thing5", thing5Map);
-            
+
             Map<String, String> phoneNumber6Map = new HashMap<>();
             phoneNumber6Map.put("value", ((Map<String, String>) dataInfo.get("phone_number6")).get("value"));
             data.put("phone_number6", phoneNumber6Map);
-            
+
             Map<String, String> thing4Map = new HashMap<>();
             thing4Map.put("value", ((Map<String, String>) dataInfo.get("thing4")).get("value"));
             data.put("thing4", thing4Map);
-            
+
             Map<String, String> time27Map = new HashMap<>();
             time27Map.put("value", ((Map<String, String>) dataInfo.get("time27")).get("value"));
             data.put("time27", time27Map);
-            
+
             Map<String, String> thing11Map = new HashMap<>();
             thing11Map.put("value", ((Map<String, String>) dataInfo.get("thing11")).get("value"));
             data.put("thing11", thing11Map);
-            
+
             Map<String, String> remarkMap = new HashMap<>();
             remarkMap.put("value", "请尽快处理!");
             data.put("remark", remarkMap);
@@ -183,7 +190,10 @@ public class WeChatOfficialController {
                 return R.error("未找到企业配置信息");
             }
             log.info("企业配置信息: {}", config);
-
+            String selectIds = (String) dataInfo.getOrDefault("selectId", "");
+            if (StringUtils.isBlank(selectIds)) {
+                throw new CustomException("参数异常,为选择数据");
+            }
             // 获取模板ID
             JSONObject templateConfig = JSON.parseObject(config.getTemplateconfiguration());
 
@@ -201,18 +211,21 @@ public class WeChatOfficialController {
             if (!"cstz".equals(mbtype)) {
                 return R.error("不支持的模板类型");
             }
-
+            List<String> ids = Arrays.asList(selectIds.split(","));
             // 查询欠费用户信息
-            List<Map<String, Object>> arrearsInfoList = swBillManagementUnpaidDao.getWaterFeeArrearsInfo();
+            List<Map<String, Object>> arrearsInfoList = swBillManagementUnpaidDao.getWaterFeeArrearsInfo(ids);
             if (arrearsInfoList == null || arrearsInfoList.isEmpty()) {
                 return R.error("未找到欠费用户信息");
             }
 
             int successCount = 0;
             int failCount = 0;
-
+            List<SwNoticeRecordDo> saveDataList = new ArrayList<>();
+            SwNoticeRecordDo swNoticeRecordDo = null;
+            SysUserVo currentUser = ZHSWCommonUtils.getCurrentUser();
             // 循环发送消息给每个欠费用户
             for (Map<String, Object> userInfo : arrearsInfoList) {
+
                 String userNumber = String.valueOf(userInfo.get("USERNUMBER"));
                 String userName = String.valueOf(userInfo.get("USERNAME"));
 
@@ -271,7 +284,8 @@ public class WeChatOfficialController {
                             openId,
                             data
                     );
-
+                    // 记录推送记录
+                    saveDataList.add(createNoticeRecord(swNoticeRecordDo, currentUser, result, data, templateId, userNumber, openId));
                     if (result) {
                         successCount++;
                         log.info("成功发送水费缴费通知给用户: {}, 户号: {}", userName, userNumber);
@@ -284,7 +298,7 @@ public class WeChatOfficialController {
                     log.error("发送水费缴费通知给用户 {} ({}) 时发生异常: {}", userName, userNumber, e.getMessage());
                 }
             }
-
+            swNoticeRecordService.saveBatch(saveDataList,2000);
             String message = String.format("水费缴费通知发送完成,成功:%d条,失败:%d条", successCount, failCount);
             log.info(message);
             return R.ok(message);
@@ -294,4 +308,19 @@ public class WeChatOfficialController {
             return R.error("发送水费缴费通知失败:" + e.getMessage());
         }
     }
+
+    public SwNoticeRecordDo createNoticeRecord(SwNoticeRecordDo swNoticeRecordDo, SysUserVo currentUser, boolean result,
+                                               Map<String, Object> tempData, String tempId, String userNum, String sign) {
+        swNoticeRecordDo = new SwNoticeRecordDo();
+        ZHSWCommonUtils.initModelGeneralParameters(swNoticeRecordDo, currentUser);
+        swNoticeRecordDo.setId(SecurityUtil.getUUID());
+
+        swNoticeRecordDo.setUsernum(userNum);
+        tempData.put("tempId", tempId);
+        swNoticeRecordDo.setNoticepara(tempData.toString());
+        swNoticeRecordDo.setNoticetime(new Date());
+        swNoticeRecordDo.setNoticestate(String.valueOf(result));
+        swNoticeRecordDo.setNoticesign(sign);
+        return swNoticeRecordDo;
+    }
 }