Sfoglia il codice sorgente

feat:“添加设备上下线提醒功能“

soobin 1 anno fa
parent
commit
c34b7b27b6

+ 9 - 4
src/main/java/com/szwl/controller/IndexController.java

@@ -1406,13 +1406,18 @@ public class IndexController {
             LambdaQueryWrapper<TWechat> wechatQuery = Wrappers.lambdaQuery();
             wechatQuery.eq(TWechat::getAdminId, equipment.getAdminId());
             TWechat wechat = wechatService.getOne(wechatQuery);
+            // 查询用户
+            TAdmin admin = adminService.getById(equipment.getAdminId());
             // 如果有绑定微信
-            if (wechat != null && StringUtils.isNotEmpty(wechat.getOpenId())) {
-                // 发送模板消息
-                TAdmin admin = adminService.getById(equipment.getAdminId());
+            if (wechat != null && StringUtils.isNotEmpty(wechat.getOpenId()) && admin != null) {
                 // 查询是申泽还是七云的
                 String companyType = admin.getCompanyType();
-                wechatService.sendOnOffMessage(wechat.getOpenId(), equipment.getClientId(), netTime, companyType, name, eqeStatus);
+                // 查询用户是否开启设备上线提醒功能
+                String onOffNotice = admin.getOnOffNotice();
+                if (StringUtils.isNotEmpty(onOffNotice) && onOffNotice.equals("1")) {
+                    // 发送设备上下线提醒消息
+                    wechatService.sendOnOffMessage(wechat.getOpenId(), equipment.getClientId(), netTime, companyType, name, eqeStatus);
+                }
             }
             if (eqeStatus == 0) {
                 equipment.setCabinetTm("");

+ 21 - 0
src/main/java/com/szwl/controller/TAdminController.java

@@ -1120,5 +1120,26 @@ public class TAdminController {
         tAdminService.updateById(admin);
         return R.ok();
     }
+
+    @ApiOperation(value = "切换设备上下线通知开关")
+    @GetMapping("/updateOnOffNotice")
+    public ResponseModel<?> updateOnOffNotice(String adminId, String onOffNotice) {
+        if (StringUtils.isEmpty(adminId) || StringUtils.isEmpty(onOffNotice)) {
+            return R.fail(ResponseCodesEnum.A0001);
+        }
+        // 查询是否有绑定微信
+        if (onOffNotice.equals("1")) {
+            LambdaQueryWrapper<TWechat> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(TWechat::getAdminId, adminId);
+            TWechat wechat = wechatService.getOne(wrapper);
+            if (wechat == null) {
+                return R.fail(ResponseCodesEnum.A0001, "请先绑定微信");
+            }
+        }
+        TAdmin admin = tAdminService.getById(adminId);
+        admin.setOnOffNotice(onOffNotice);
+        tAdminService.updateById(admin);
+        return R.ok();
+    }
 }
 

File diff suppressed because it is too large
+ 2 - 1
src/main/java/com/szwl/mapper/xml/TAdminMapper.xml


+ 4 - 1
src/main/java/com/szwl/model/entity/TAdmin.java

@@ -19,7 +19,7 @@ import lombok.EqualsAndHashCode;
  * </p>
  *
  * @author wuhs
- * @since 2024-05-10
+ * @since 2024-06-24
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -165,5 +165,8 @@ public class TAdmin implements Serializable {
     @ApiModelProperty(value = "是否显示分佣,0:关闭,1:开启,默认开启")
     private String isDistribution;
 
+    @ApiModelProperty(value = "设备上线提醒,0:关闭,1:开启,默认开启")
+    private String onOffNotice;
+
 
 }