Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/V1' into V1

zhengqiang 5 rokov pred
rodič
commit
554abf45ef

+ 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> 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> 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);
 
         //人员识别成功,温度超过限定时发送模板消息给监管者
-        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) {
 
         try {
@@ -133,10 +141,9 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
 
             List<String> idList = Arrays.asList(companyInfo.getCode().split(","));
 
-            List<WarningPusher> warningPusherList = warningPusherService.findByIdList(idList);
+            List<WarningPusher> warningPusherList = warningPusherService.findByCompanyIdList(idList);
             if (warningPusherList.size() > 0) {
 
-
                 for (WarningPusher warningPusher : warningPusherList) {
                     Map<String, Object> searchParams = new HashMap<>();
                     searchParams.put("deviceNo", personDeviceLog.getDeviceNo());
@@ -148,7 +155,6 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
                     List<PersonDeviceLog> personDeviceLogList = personDeviceLogDAO.search(searchParams, sortList);
 
                     if (personDeviceLogList.size() >= warningPusher.getTimes()) {
-                        log.warn("开始发送模板消息");
                         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
-	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 详情跳转地址
 	 * @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;
 
@@ -440,6 +440,7 @@ public class WechatMessageUtil {
 		sendData.put("keyword2", keyword2);
 		sendData.put("remark", remark);
 
+
 		//w8Zk_VQMFIEVSIBPZid7zSrvHmBdrgnqF76u8PLCZEs cs
 		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");
 		//sendNoticeMessage("测试", "sdfsdfasfasdfafasdfasdf", "oHjCawgwCGen5k1-hAsimdEX5lZo", "2222","vsw6sb9lMA3bcsE8MdeaGENvI1HSUy2ht9B8hS3jEzA","wx7e70eb62a8459869","909d17e353268da57c4f18cc09798049");
-		//sendTemperatureAlarmInfo("oLowyuOQ9ULF3LUGt6h3fTrsnbVE","荆鹏软件_门房考勤机","wx0b3c41a903053808","43557bd62f77b0c3d6670e991872f0e7","Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M");
+		sendTemperatureAlarmInfo("oLowyuOQ9ULF3LUGt6h3fTrsnbVE","荆鹏软件_门房考勤机","wx0b3c41a903053808","43557bd62f77b0c3d6670e991872f0e7","Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M");
 		getContent("<p>内容</p>");
 
 	}

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

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

+ 22 - 6
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceRelationController.java

@@ -105,6 +105,8 @@ public class PersonDeviceRelationController {
                             throw new Exception("添加失败:" + lapiMsgResult.getMsg());
                     }
                     }
+                }else{
+                    throw new Exception("添加失败:人员没有上传照片" );
                 }
                 msgResult.setResult(true);
                 msgResult.setData(personDeviceRelation);
@@ -277,6 +279,21 @@ public class PersonDeviceRelationController {
                         PersonInfo personInfo = personInfoService.get(personId);
                         //如果人员照片为空
                         if(StringUtils.isEmpty(personInfo.getFaceImageUrl())){
+                            HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
+                            HSSFCell cell1 = row.createCell(0);
+                            cell1.setCellValue(personInfo.getName());
+                            HSSFCell cell2 = row.createCell(1);
+                            cell2.setCellValue("");
+                            HSSFCell cell3 = row.createCell(2);
+                            cell3.setCellValue("添加失败:");
+                            HSSFCell cell4 = row.createCell(3);
+                            cell4.setCellValue("人员没有上传照片");
+                            addCount++;
+                            //删除绑定关系
+                            item.setDelFlag(true);
+                            item.setUpdateBy(subject);
+                            item.setUpdateTime(new Date());
+                            personDeviceRelationService.update(item);
                             continue;
                         }
 
@@ -295,16 +312,15 @@ public class PersonDeviceRelationController {
                                 HSSFCell cell2 = row.createCell(1);
                                 cell2.setCellValue(resultMap.get("deviceAliasName").toString());
                                 HSSFCell cell3 = row.createCell(2);
-                                cell3.setCellValue("添加失败:" + lapiMsgResult.getMsg());
+                                cell3.setCellValue("添加失败:");
                                 HSSFCell cell4 = row.createCell(3);
                                 cell4.setCellValue(lapiMsgResult.getMsg());
 
                                 //删除绑定关系
-                                PersonDeviceRelation personDeviceRelation = personDeviceRelationService.findByDeviceIdAndPersonId(deviceId,personId);
-                                personDeviceRelation.setDelFlag(true);
-                                personDeviceRelation.setUpdateBy(subject);
-                                personDeviceRelation.setUpdateTime(new Date());
-                                personDeviceRelationService.update(personDeviceRelation);
+                                item.setDelFlag(true);
+                                item.setUpdateBy(subject);
+                                item.setUpdateTime(new Date());
+                                personDeviceRelationService.update(item);
                                 addCount ++;
                             }
                         }

+ 58 - 0
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonInfoApiController.java

@@ -10,6 +10,7 @@ import com.jpsoft.smart.modules.base.service.PersonDeviceRelationService;
 import com.jpsoft.smart.modules.base.service.PersonInfoService;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.common.dto.Sort;
+import com.jpsoft.smart.modules.common.utils.CheckIdCard;
 import com.jpsoft.smart.modules.common.utils.OSSUtil;
 import com.jpsoft.smart.modules.common.utils.PojoUtils;
 import com.jpsoft.smart.modules.common.utils.SMSUtil;
@@ -451,4 +452,61 @@ public class PersonInfoApiController {
 
         return messageResult;
     }
+
+    @ApiOperation(value="保存人员信息并将照片上传到终端")
+    @PostMapping("saveDetail")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="name",value = "姓名",required = false,paramType = "form"),
+            @ApiImplicitParam(name="phone",value = "手机号码",required = false,paramType = "form"),
+            @ApiImplicitParam(name="idCard",value = "身份证号",required = false,paramType = "form"),
+            @ApiImplicitParam(name="wechatNoticeEnabled",value = "是否接收微信通知",required = false,paramType = "form",dataType = "Boolean"),
+            @ApiImplicitParam(name="openId",value = "微信openId",required = true,paramType = "form"),
+            @ApiImplicitParam(name="token",value = "令牌",paramType = "form")
+    })
+    public MessageResult<PersonInfo> saveDetail(String name,String phone,String idCard,Boolean wechatNoticeEnabled,String openId,String token){
+        MessageResult<PersonInfo> messageResult = new MessageResult<>();
+
+        try {
+            PersonInfo personInfo = personInfoService.findByOpenId(openId);
+
+            if (personInfo==null){
+                throw new Exception("人员信息不存在!");
+            }
+
+            CheckIdCard cic = null;
+            if (StringUtils.isEmpty(idCard)) {
+//                    msgResult.setMessage("身份证不能为空!");
+//                    msgResult.setResult(false);
+//                    return msgResult;
+            } else {
+                personInfo.setIdCard(idCard.trim().toUpperCase());
+
+                cic = new CheckIdCard(personInfo.getIdCard());
+                if (!cic.validate()) {
+                    messageResult.setMessage("身份证验证失败!");
+                    messageResult.setResult(false);
+                    return messageResult;
+                }
+            }
+
+            personInfo.setName(name);
+            personInfo.setPhone(phone);
+            if(wechatNoticeEnabled != null) personInfo.setWechatNoticeEnabled(wechatNoticeEnabled);
+            personInfo.setUpdateTime(new Date());
+
+            personInfoService.update(personInfo);
+
+            messageResult.setData(personInfo);
+            messageResult.setResult(true);
+
+            messageResult.setCode(200);
+        } catch (Exception e) {
+            logger.error(e.getMessage(),e);
+
+            messageResult.setResult(false);
+            messageResult.setMessage(e.getMessage());
+        }
+
+        return messageResult;
+    }
 }

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

@@ -1,10 +1,16 @@
 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.dto.PersonDeviceLogDTO;
 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.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.utils.WechatMessageUtil;
 import com.jpsoft.smart.modules.lapi.service.ILapiService;
 import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
 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.Arrays;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -32,6 +39,14 @@ public class LApiTest {
     @Autowired
     private WarningPusherDAO warningPusherDAO;
 
+    @Autowired
+    private PersonInfoDAO personInfoDAO;
+
+    @Autowired
+    private PersonDeviceLogServiceImpl personDeviceLogService;
+
+
+
     @Test
     public void testKeepLive(){
         try {
@@ -174,7 +189,7 @@ public class LApiTest {
             String ids = "c6083b40-6025-11ea-9760-f0761c318e92,5cebd719-9e0e-4f0b-8414-4d7abe430ebf";
             List<String> idList = Arrays.asList(ids.split(","));
 
-            List<WarningPusher> list = warningPusherDAO.findByIdList(idList);
+            List<WarningPusher> list = warningPusherDAO.findByCompanyIdList(idList);
 
             System.out.println(list);
         } catch (Exception e) {
@@ -185,9 +200,16 @@ public class LApiTest {
     }
 
     @Test
-    public void testIsSuccessAddPerson(){
+    public void testSendTemperatureAlarmsyncTask(){
         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) {
             e.printStackTrace();