瀏覽代碼

报警模板消息发送bug修改

M墨鱼—_mo 5 年之前
父節點
當前提交
b987c57127

+ 1 - 1
common/src/main/java/com/jpsoft/smart/modules/base/dao/WarningPusherDAO.java

@@ -18,5 +18,5 @@ public interface WarningPusherDAO {
 
 
     List<WarningPusher> findByCompanyId(String companyId);
     List<WarningPusher> findByCompanyId(String companyId);
 
 
-    List<WarningPusher> findByIdList(List<String> code);
+    List<WarningPusher> findByCompanyIdList(List<String> code);
 }
 }

+ 1 - 1
common/src/main/java/com/jpsoft/smart/modules/base/service/WarningPusherService.java

@@ -17,5 +17,5 @@ public interface WarningPusherService {
 
 
     List<WarningPusher> findByCompanyId(String companyId);
     List<WarningPusher> findByCompanyId(String companyId);
 
 
-    List<WarningPusher> findByIdList(List<String> idList);
+    List<WarningPusher> findByCompanyIdList(List<String> idList);
 }
 }

+ 13 - 7
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java

@@ -107,13 +107,21 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
         personDeviceLogDAO.insert(personDeviceLog);
         personDeviceLogDAO.insert(personDeviceLog);
 
 
         //人员识别成功,温度超过限定时发送模板消息给监管者
         //人员识别成功,温度超过限定时发送模板消息给监管者
-        if (personDeviceLog.getPersonId() != 0) {
-            sendTemperatureAlarmsyncTask(personDeviceLog);
-        }
+        new Thread(()->{
+            try {
+                if (personDeviceLog.getPersonId() != 0) {
+                    sendTemperatureAlarmsyncTask(personDeviceLog);
+                }
+            }
+            catch (Exception ex){
+                log.error(ex.getMessage(),ex);
+            }
+        }).start();
+
+
 
 
     }
     }
 
 
-    @Async
     public void sendTemperatureAlarmsyncTask(PersonDeviceLog personDeviceLog) {
     public void sendTemperatureAlarmsyncTask(PersonDeviceLog personDeviceLog) {
 
 
         try {
         try {
@@ -133,10 +141,9 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
 
 
             List<String> idList = Arrays.asList(companyInfo.getCode().split(","));
             List<String> idList = Arrays.asList(companyInfo.getCode().split(","));
 
 
-            List<WarningPusher> warningPusherList = warningPusherService.findByIdList(idList);
+            List<WarningPusher> warningPusherList = warningPusherService.findByCompanyIdList(idList);
             if (warningPusherList.size() > 0) {
             if (warningPusherList.size() > 0) {
 
 
-
                 for (WarningPusher warningPusher : warningPusherList) {
                 for (WarningPusher warningPusher : warningPusherList) {
                     Map<String, Object> searchParams = new HashMap<>();
                     Map<String, Object> searchParams = new HashMap<>();
                     searchParams.put("deviceNo", personDeviceLog.getDeviceNo());
                     searchParams.put("deviceNo", personDeviceLog.getDeviceNo());
@@ -148,7 +155,6 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
                     List<PersonDeviceLog> personDeviceLogList = personDeviceLogDAO.search(searchParams, sortList);
                     List<PersonDeviceLog> personDeviceLogList = personDeviceLogDAO.search(searchParams, sortList);
 
 
                     if (personDeviceLogList.size() >= warningPusher.getTimes()) {
                     if (personDeviceLogList.size() >= warningPusher.getTimes()) {
-                        log.warn("开始发送模板消息");
                         WechatMessageUtil.sendTemperatureAlarmInfo(warningPusher.getOpenId(), companyInfo.getName() + "_" + deviceInfo.getAliasName(), wxConfig.getAppId(), wxConfig.getAppSecret(), personDeviceLog.getId());
                         WechatMessageUtil.sendTemperatureAlarmInfo(warningPusher.getOpenId(), companyInfo.getName() + "_" + deviceInfo.getAliasName(), wxConfig.getAppId(), wxConfig.getAppSecret(), personDeviceLog.getId());
                     }
                     }
                 }
                 }

+ 2 - 2
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/WarningPusherServiceImpl.java

@@ -74,7 +74,7 @@ public class WarningPusherServiceImpl implements WarningPusherService {
 	}
 	}
 
 
 	@Override
 	@Override
-	public List<WarningPusher> findByIdList(List<String> idList) {
-		return warningPusherDAO.findByIdList(idList);
+	public List<WarningPusher> findByCompanyIdList(List<String> idList) {
+		return warningPusherDAO.findByCompanyIdList(idList);
 	}
 	}
 }
 }

+ 3 - 2
common/src/main/java/com/jpsoft/smart/modules/common/utils/WechatMessageUtil.java

@@ -320,7 +320,7 @@ public class WechatMessageUtil {
 	 * @param url 详情跳转地址
 	 * @param url 详情跳转地址
 	 * @return
 	 * @return
 	 */
 	 */
-	private static boolean sendTemplate(JSONObject sendData,String appId,String appSecret,String templateId,String openId,String url){
+	public static boolean sendTemplate(JSONObject sendData,String appId,String appSecret,String templateId,String openId,String url){
 
 
 		boolean result = false;
 		boolean result = false;
 
 
@@ -440,6 +440,7 @@ public class WechatMessageUtil {
 		sendData.put("keyword2", keyword2);
 		sendData.put("keyword2", keyword2);
 		sendData.put("remark", remark);
 		sendData.put("remark", remark);
 
 
+
 		//w8Zk_VQMFIEVSIBPZid7zSrvHmBdrgnqF76u8PLCZEs cs
 		//w8Zk_VQMFIEVSIBPZid7zSrvHmBdrgnqF76u8PLCZEs cs
 		boolean ret = sendTemplate(sendData, appId,appSecret,templateId,openId, "");
 		boolean ret = sendTemplate(sendData, appId,appSecret,templateId,openId, "");
 
 
@@ -470,7 +471,7 @@ public class WechatMessageUtil {
 
 
 		//sendAlarmNoticeMessage("周界入侵警报", "周界入侵,目标ID:1419,区域范围:(0.327,0.698)(0.674,0.936)(0.67,0.985)(0.352,0.973)", "oHjCawgwCGen5k1-hAsimdEX5lZo", "","8dpP8XM1XaiiIByXiuAeFIZeNjEow1AleG_h8O2xyVA","wx7e70eb62a8459869","909d17e353268da57c4f18cc09798049");
 		//sendAlarmNoticeMessage("周界入侵警报", "周界入侵,目标ID:1419,区域范围:(0.327,0.698)(0.674,0.936)(0.67,0.985)(0.352,0.973)", "oHjCawgwCGen5k1-hAsimdEX5lZo", "","8dpP8XM1XaiiIByXiuAeFIZeNjEow1AleG_h8O2xyVA","wx7e70eb62a8459869","909d17e353268da57c4f18cc09798049");
 		//sendNoticeMessage("测试", "sdfsdfasfasdfafasdfasdf", "oHjCawgwCGen5k1-hAsimdEX5lZo", "2222","vsw6sb9lMA3bcsE8MdeaGENvI1HSUy2ht9B8hS3jEzA","wx7e70eb62a8459869","909d17e353268da57c4f18cc09798049");
 		//sendNoticeMessage("测试", "sdfsdfasfasdfafasdfasdf", "oHjCawgwCGen5k1-hAsimdEX5lZo", "2222","vsw6sb9lMA3bcsE8MdeaGENvI1HSUy2ht9B8hS3jEzA","wx7e70eb62a8459869","909d17e353268da57c4f18cc09798049");
-		//sendTemperatureAlarmInfo("oLowyuOQ9ULF3LUGt6h3fTrsnbVE","荆鹏软件_门房考勤机","wx0b3c41a903053808","43557bd62f77b0c3d6670e991872f0e7","Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M");
+		sendTemperatureAlarmInfo("oLowyuOQ9ULF3LUGt6h3fTrsnbVE","荆鹏软件_门房考勤机","wx0b3c41a903053808","43557bd62f77b0c3d6670e991872f0e7","Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M");
 		getContent("<p>内容</p>");
 		getContent("<p>内容</p>");
 
 
 	}
 	}

+ 1 - 1
common/src/main/resources/mapper/base/WarningPusher.xml

@@ -135,7 +135,7 @@
     <select id="findByCompanyId" resultMap="WarningPusherMap">
     <select id="findByCompanyId" resultMap="WarningPusherMap">
         select * from base_warning_pusher where company_id=#{companyId} and del_flag = 0
         select * from base_warning_pusher where company_id=#{companyId} and del_flag = 0
     </select>
     </select>
-    <select id="findByIdList" resultMap="WarningPusherMap">
+    <select id="findByCompanyIdList" resultMap="WarningPusherMap">
         select * from base_warning_pusher where company_id in
         select * from base_warning_pusher where company_id in
         <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item}
         <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item}
         </foreach>
         </foreach>

+ 0 - 25
lapi/src/main/java/com/jpsoft/smart/lapi/handler/PersonVerificationHandler.java

@@ -103,30 +103,5 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
 
 
     }
     }
 
 
-    public static void main(String[] args) {
-        String imgStr = "";
-        try {
-
-            File file = new File("C:\\Users\\Administrator\\Desktop\\异常照片\\3.jpg");
-            FileInputStream fis = new FileInputStream(file);
-            byte[] buffer = new byte[(int) file.length()];
-            int offset = 0;
-            int numRead = 0;
-            while (offset < buffer.length && (numRead = fis.read(buffer, offset, buffer.length - offset)) >= 0) {
-                offset += numRead;
-            }
-
-            if (offset != buffer.length) {
-                throw new IOException("Could not completely read file "
-                        + file.getName());
-            }
-            fis.close();
-            BASE64Encoder encoder = new BASE64Encoder();
-            imgStr = encoder.encode(buffer);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        System.out.print(imgStr.length());
 
 
-    }
 }
 }

+ 24 - 2
web/src/test/java/com/jpsoft/smart/LApiTest.java

@@ -1,10 +1,16 @@
 package com.jpsoft.smart;
 package com.jpsoft.smart;
 
 
+import com.jpsoft.smart.modules.base.dao.PersonInfoDAO;
 import com.jpsoft.smart.modules.base.dao.WarningPusherDAO;
 import com.jpsoft.smart.modules.base.dao.WarningPusherDAO;
 import com.jpsoft.smart.modules.base.dto.PersonDeviceLogDTO;
 import com.jpsoft.smart.modules.base.dto.PersonDeviceLogDTO;
 import com.jpsoft.smart.modules.base.entity.DeviceInfo;
 import com.jpsoft.smart.modules.base.entity.DeviceInfo;
+import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.base.entity.WarningPusher;
 import com.jpsoft.smart.modules.base.entity.WarningPusher;
+import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
+import com.jpsoft.smart.modules.base.service.impl.PersonDeviceLogServiceImpl;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
 import com.jpsoft.smart.modules.lapi.service.ILapiService;
 import com.jpsoft.smart.modules.lapi.service.ILapiService;
 import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
 import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
 import com.jpsoft.smart.modules.lapi.vo.LapiResult;
 import com.jpsoft.smart.modules.lapi.vo.LapiResult;
@@ -16,6 +22,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -32,6 +39,14 @@ public class LApiTest {
     @Autowired
     @Autowired
     private WarningPusherDAO warningPusherDAO;
     private WarningPusherDAO warningPusherDAO;
 
 
+    @Autowired
+    private PersonInfoDAO personInfoDAO;
+
+    @Autowired
+    private PersonDeviceLogServiceImpl personDeviceLogService;
+
+
+
     @Test
     @Test
     public void testKeepLive(){
     public void testKeepLive(){
         try {
         try {
@@ -174,7 +189,7 @@ public class LApiTest {
             String ids = "c6083b40-6025-11ea-9760-f0761c318e92,5cebd719-9e0e-4f0b-8414-4d7abe430ebf";
             String ids = "c6083b40-6025-11ea-9760-f0761c318e92,5cebd719-9e0e-4f0b-8414-4d7abe430ebf";
             List<String> idList = Arrays.asList(ids.split(","));
             List<String> idList = Arrays.asList(ids.split(","));
 
 
-            List<WarningPusher> list = warningPusherDAO.findByIdList(idList);
+            List<WarningPusher> list = warningPusherDAO.findByCompanyIdList(idList);
 
 
             System.out.println(list);
             System.out.println(list);
         } catch (Exception e) {
         } catch (Exception e) {
@@ -185,9 +200,16 @@ public class LApiTest {
     }
     }
 
 
     @Test
     @Test
-    public void testIsSuccessAddPerson(){
+    public void testSendTemperatureAlarmsyncTask(){
         try {
         try {
 
 
+          //  WechatMessageUtil.sendTemperatureAlarmInfo("oLowyuOQ9ULF3LUGt6h3fTrsnbVE","荆鹏软件_门房考勤机","wx0b3c41a903053808","43557bd62f77b0c3d6670e991872f0e7","Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M");
+            PersonDeviceLog personDeviceLog = new PersonDeviceLog();
+            personDeviceLog.setDeviceNo("210235C4C33203000165");
+            personDeviceLog.setPersonId(11622);
+            personDeviceLog.setRecordTime(new Date());
+            personDeviceLog.setId("000733db-2945-4a1f-862f-86c24b50f84c");
+            personDeviceLogService.sendTemperatureAlarmsyncTask(personDeviceLog);
 
 
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();