From ad2e38738cf899e003f7e137e0de50b616fc6a2f Mon Sep 17 00:00:00 2001 From: guoshengxiong <1923636941@qq.com> Date: Tue, 4 Jun 2024 16:02:14 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/WisdomSiteApplication.java | 10 ++--- .../com/zhgd/config/StdOutImplCustom.java | 6 ++- .../java/com/zhgd/mqtt/bean/PushPayload.java | 43 +++++++++++-------- .../basicdata/service/INoticeService.java | 8 ++-- .../basicdata/service/ISystemUserService.java | 16 +++---- .../service/impl/NoticeServiceImpl.java | 38 ++++++++-------- .../service/impl/SystemUserServiceImpl.java | 7 --- .../modules/worker/entity/WorkerInfo.java | 2 + .../service/impl/WorkerInfoServiceImpl.java | 14 +++--- .../impl/XzEmergencyRecordServiceImpl.java | 19 ++++++++ .../XzHikvisionCompareDataServiceImpl.java | 8 ++-- 11 files changed, 97 insertions(+), 74 deletions(-) diff --git a/src/main/java/com/WisdomSiteApplication.java b/src/main/java/com/WisdomSiteApplication.java index f3ba5e5ff..7b17324c9 100644 --- a/src/main/java/com/WisdomSiteApplication.java +++ b/src/main/java/com/WisdomSiteApplication.java @@ -7,6 +7,7 @@ import org.apache.catalina.connector.Connector; import org.junit.Test; import org.mybatis.spring.annotation.MapperScan; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; @@ -39,8 +40,11 @@ import org.springframework.security.web.firewall.StrictHttpFirewall; @EnableDistributedLock public class WisdomSiteApplication extends SpringBootServletInitializer { + public static boolean runSucess = false; + public static void main(String[] args) { SpringApplication.run(WisdomSiteApplication.class, args); + WisdomSiteApplication.runSucess = true; } @Bean @@ -159,10 +163,4 @@ public class WisdomSiteApplication extends SpringBootServletInitializer { firewall.setAllowUrlEncodedSlash(true); return firewall; } - - @Test - public void test() { - System.out.println(); - } - } diff --git a/src/main/java/com/zhgd/config/StdOutImplCustom.java b/src/main/java/com/zhgd/config/StdOutImplCustom.java index a1a7b28b3..71ba53101 100644 --- a/src/main/java/com/zhgd/config/StdOutImplCustom.java +++ b/src/main/java/com/zhgd/config/StdOutImplCustom.java @@ -1,9 +1,13 @@ package com.zhgd.config; +import com.WisdomSiteApplication; import com.zhgd.xmgl.config.TaskAspect; import com.zhgd.xmgl.constant.Cts; import com.zhgd.xmgl.util.ThreadLocalUtil; +import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.logging.Log; +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; import java.util.Objects; @@ -17,7 +21,7 @@ public class StdOutImplCustom implements Log { if (!Objects.equals(TaskAspect.onlyPrintInterface, 1)) { return true; } - return Objects.equals(ThreadLocalUtil.getByKey(Cts.TL_IS_FROM_WEB, Boolean.class), true); + return WisdomSiteApplication.runSucess && Objects.equals(ThreadLocalUtil.getByKey(Cts.TL_IS_FROM_WEB, Boolean.class), true); } @Override diff --git a/src/main/java/com/zhgd/mqtt/bean/PushPayload.java b/src/main/java/com/zhgd/mqtt/bean/PushPayload.java index 6783cf54f..71f9ba210 100644 --- a/src/main/java/com/zhgd/mqtt/bean/PushPayload.java +++ b/src/main/java/com/zhgd/mqtt/bean/PushPayload.java @@ -2,6 +2,7 @@ package com.zhgd.mqtt.bean; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; +import lombok.Data; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -13,8 +14,7 @@ import lombok.extern.slf4j.Slf4j; * @date 2019/11/14$ 15:52$ */ @Slf4j -@Setter -@Getter +@Data public class PushPayload { //推送类型 @@ -29,21 +29,34 @@ public class PushPayload { private String title; //内容 private String content; + //载荷 + private String payload; //数量 private Integer badge = 1; //铃声 private String sound = "default"; - public PushPayload(String type, String accountId, String title, String content, Integer badge , String sound,String itemType){ + + public PushPayload(String type, String accountId, String title, String content, String payload, Integer badge, String sound, String itemType) { this.type = type; this.accountId = accountId; this.title = title; this.content = content; + this.payload = payload; this.badge = badge; this.sound = sound; this.itemType = itemType; } - public static class Builder{ + public static Builder getPushPayloadBuider() { + return new Builder(); + } + + @Override + public String toString() { + return JSON.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect); + } + + public static class Builder { //推送类型 private String type; //推送子类型 @@ -54,6 +67,8 @@ public class PushPayload { private String title; //内容 private String content; + //载荷 + private String payload; //数量 private Integer badge = 1; //铃声 @@ -84,6 +99,11 @@ public class PushPayload { return this; } + public Builder setPayload(String payload) { + this.payload = payload; + return this; + } + public Builder setBadge(Integer badge) { this.badge = badge; return this; @@ -94,20 +114,9 @@ public class PushPayload { return this; } - public PushPayload bulid(){ - return new PushPayload(type,accountId,title,content,badge,sound,itemType); + public PushPayload bulid() { + return new PushPayload(type, accountId, title, content, payload, badge, sound, itemType); } } - - public static Builder getPushPayloadBuider(){ - return new Builder(); - } - - - @Override - public String toString() { - return JSON.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect); - } - } diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/INoticeService.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/INoticeService.java index eb7835ff0..d8d679554 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/INoticeService.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/INoticeService.java @@ -18,8 +18,6 @@ public interface INoticeService extends IService { void addNotice(Notice notice, boolean isSendMqtt); - void addNoticeAndApp(Notice notice, boolean isSendMqtt); - void cleanAllNotice(Map map); void addUserNotice(Long accountId, String msg, String title, String type, String payload); @@ -34,7 +32,7 @@ public interface INoticeService extends IService { */ void addUserNotice(Long accountId, String msg, String title, String type); - void addUserNoticeAndApp(Long accountId, String msg, String title, String type, Object payload); + void addUserNoticeAndApp(Long accountId, String msg, String title, String type, Object jsonPayload); /** * 发通知,给某人和app通知 @@ -49,4 +47,8 @@ public interface INoticeService extends IService { void sendProjectNoicte(String projectSn, String title, String msg, String type); void edit(Notice notice); + + void sendMqttMessage(Notice notice); + + void sendMqttMessage(Notice notice, String subTopic); } diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/ISystemUserService.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/ISystemUserService.java index 2b1cead6b..ffc7b9277 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/ISystemUserService.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/ISystemUserService.java @@ -21,6 +21,13 @@ import java.util.Map; */ public interface ISystemUserService extends IService { + /** + * 根据企业或项目SN查找账号列表 + * + * @return + */ + List getSystemUsersBySn(Map map); + Map login(Map map); void register(Map map); @@ -29,13 +36,6 @@ public interface ISystemUserService extends IService { void updateUserPassWord(Map map); - /** - * 根据企业或项目SN查找账号列表 - * - * @return - */ - List getSystemUsersBySn(Map map); - Long saveSystemUser(SystemUser systemUser); void editSystemUser(SystemUser systemUser); @@ -74,8 +74,6 @@ public interface ISystemUserService extends IService { public void deleteTenantOrSupplier(String userId, String projectSn); - List getSystemUserList(Map map); - Map md5Login(Map map); void xzUpdatePw(SystemUser systemUser); diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/NoticeServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/NoticeServiceImpl.java index 244689808..5bd3d7d1a 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/NoticeServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/NoticeServiceImpl.java @@ -72,24 +72,10 @@ public class NoticeServiceImpl extends ServiceImpl impleme public void addNotice(Notice notice, boolean isSendMqtt) { noticeMapper.insert(notice); if (isSendMqtt) { - sendPushMessage(notice); + sendMqttMessage(notice); } } - @Override - public void addNoticeAndApp(Notice notice, boolean isSendMqtt) { - noticeMapper.insert(notice); - if (isSendMqtt) { - sendPushMessage(notice); - } - SystemUser systemUser = systemUserMapper.selectById(notice.getAccountId()); - if (systemUser == null) { - return; - } - uniPushService.pushToSingleByAlias(systemUser.getClientId(), notice.getTitle(), notice.getMsg(), null); - - } - @Override public void cleanAllNotice(Map map) { QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -108,7 +94,7 @@ public class NoticeServiceImpl extends ServiceImpl impleme notice.setType(type); notice.setPayload(payload); noticeMapper.insert(notice); - sendPushMessage(notice); + sendMqttMessage(notice); } @Override @@ -117,10 +103,10 @@ public class NoticeServiceImpl extends ServiceImpl impleme } @Override - public void addUserNoticeAndApp(Long accountId, String msg, String title, String type, Object payload) { + public void addUserNoticeAndApp(Long accountId, String msg, String title, String type, Object jsonPayload) { final SerializeConfig config = new SerializeConfig(); config.put(Long.class, ToStringSerializer.instance); - addUserNotice(accountId, msg, title, type, payload != null ? JSONObject.toJSONString(payload, config) : null); + addUserNotice(accountId, msg, title, type, jsonPayload != null ? JSONObject.toJSONString(jsonPayload, config) : null); SystemUser systemUser = systemUserMapper.selectById(accountId); if (systemUser == null) { return; @@ -165,18 +151,28 @@ public class NoticeServiceImpl extends ServiceImpl impleme addNotice(notice, true); } - private void sendPushMessage(Notice notice) { + @Override + public void sendMqttMessage(Notice notice) { + sendMqttMessage(notice, ""); + } + + @Override + public void sendMqttMessage(Notice notice, String subTopic) { try { PushPayload pushMessage = PushPayload.getPushPayloadBuider().setAccountId(notice.getAccountId().toString()) .setTitle(notice.getTitle()) .setContent(notice.getMsg()) .setType(notice.getType()) .setItemType("0") + .setPayload(notice.getPayload()) .bulid(); - String kdTopic = scope + notice.getAccountId(); - mqttPushClient.sendToMqtt(kdTopic, pushMessage.toString()); + String kdTopic = scope + notice.getAccountId() + subTopic; + String payload = pushMessage.toString(); + mqttPushClient.sendToMqtt(kdTopic, payload); } catch (Exception e) { log.error("推送mq出现错误:", e); } } + + } diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/SystemUserServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/SystemUserServiceImpl.java index 2d7b29531..5eba321a0 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/SystemUserServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/SystemUserServiceImpl.java @@ -1261,13 +1261,6 @@ public class SystemUserServiceImpl extends ServiceImpl().eq(BaseRoleUser::getUserId, id)); } - - @Override - public List getSystemUserList(Map map) { - companyService.getCompanyType(map); - return companyMapper.getSystemUserList(map); - } - @Override public Map md5Login(Map map) { try { diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/entity/WorkerInfo.java b/src/main/java/com/zhgd/xmgl/modules/worker/entity/WorkerInfo.java index ffb11455c..e6f4c073b 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/entity/WorkerInfo.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/entity/WorkerInfo.java @@ -341,6 +341,8 @@ public class WorkerInfo implements Serializable { private Double safeScore; @ApiModelProperty(value = "下发状态:1成功2失败3部分成功") private Integer sendSuccessStatus; + @ApiModelProperty(value = "退场的安全分数") + private Double exitSafeScore; @TableField(exist = false) @ApiModelProperty(value = "人脸分数") private java.lang.Integer faceScore; diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerInfoServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerInfoServiceImpl.java index 9e4e9efae..f26ffa66d 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerInfoServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerInfoServiceImpl.java @@ -280,18 +280,17 @@ public class WorkerInfoServiceImpl extends ServiceImpl projectUsers = systemUserService.getSystemUsersBySn(new MapBuilder().put(Cts.SN, entity.getProjectSn()).put(Cts.QUERY_TYPE, Cts.PROJECT_LEVEL).build()); + for (SystemUser user : projectUsers) { + Notice notice = new Notice(); + notice.setType("0"); + notice.setMsg("大屏报警弹窗"); + notice.setAccountId(user.getUserId()); + notice.setTitle("大屏报警弹窗"); + notice.setSendTime(DateUtil.now()); + notice.setPayload(JSON.toJSONString(entity)); + noticeService.sendMqttMessage(notice, "/bigScreen/emergency/alert"); + } + } @Override diff --git a/src/main/java/com/zhgd/xmgl/modules/xz/service/impl/XzHikvisionCompareDataServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/xz/service/impl/XzHikvisionCompareDataServiceImpl.java index 601c07ff2..b1f96c3c9 100644 --- a/src/main/java/com/zhgd/xmgl/modules/xz/service/impl/XzHikvisionCompareDataServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/xz/service/impl/XzHikvisionCompareDataServiceImpl.java @@ -60,12 +60,12 @@ public class XzHikvisionCompareDataServiceImpl extends ServiceImpl param) { String projectSn = MapUtils.getString(param, Cts.PROJECT_SN); try { - manualCompareDataAsync(param, projectSn); + xzHikvisionCompareDataService.manualCompareDataAsync(param, projectSn); } catch (Exception e) { log.error("", e); addExceptionShowIfNull(projectSn);