Преглед изворни кода

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

xiao547607 пре 5 година
родитељ
комит
1e583198ee

+ 4 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceLogDAO.java

@@ -24,4 +24,8 @@ public interface PersonDeviceLogDAO {
     List<PersonDeviceLog> simpleSearch(Map<String, Object> searchParams, List<Sort> sortList);
 
     List<PersonDeviceLog> findByPersonAndDate(@Param("personId") Long personId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    PersonDeviceLog  get(String id);
+
+
 }

+ 58 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dto/PersonDeviceLogDTO.java

@@ -0,0 +1,58 @@
+package com.jpsoft.smart.modules.base.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-3-23 11:34
+ */
+@Data
+public class PersonDeviceLogDTO {
+    @ApiModelProperty(value = "ID")
+    private String id;
+    @ApiModelProperty(value = "设备序列号")
+    private String deviceNo;
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+    @ApiModelProperty(value = "人员id")
+    private Integer personId;
+    @ApiModelProperty(value = "人员名称")
+    private String personName;
+    @ApiModelProperty(value = "记录温度")
+    private BigDecimal temperature;
+    @ApiModelProperty(value = "匹配状态")
+    private Integer matchStatus;
+    @ApiModelProperty(value = "匹配信息")
+    private String  matchMsg;
+    @ApiModelProperty(value = "匹配人脸 ID")
+    private Integer  matchFaceId;
+    @ApiModelProperty(value = "图片地址")
+    private String faceImage;
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
+    @ApiModelProperty(value = "记录时间")
+    private Date recordTime;
+    @ApiModelProperty(value = "是否删除")
+    private Boolean delFlag;
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    @ApiModelProperty(value = "更新人")
+    private String  updateBy;
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+    @ApiModelProperty(value = "温度是否正常")
+    private Boolean fever;
+
+}

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceLogService.java

@@ -30,4 +30,6 @@ public interface PersonDeviceLogService {
     Page<PersonDeviceLog> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
     List<PersonDeviceLog> findByPersonAndDate(Long personId,String startDate,String endDate);
     Page<PersonDeviceLog> simplePageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
+
+    PersonDeviceLog get(String id);
 }

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

@@ -6,11 +6,9 @@ import com.github.pagehelper.PageHelper;
 import com.jpsoft.smart.config.OSSConfig;
 import com.jpsoft.smart.config.WxConfig;
 import com.jpsoft.smart.modules.base.dao.*;
-import com.jpsoft.smart.modules.base.entity.CompanyInfo;
-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.*;
 import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
+import com.jpsoft.smart.modules.base.service.WarningPusherService;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.utils.*;
 import com.jpsoft.smart.modules.common.utils.Base64;
@@ -46,6 +44,8 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
     @Autowired
     private WxConfig wxConfig;
 
+    @Autowired
+    private WarningPusherService warningPusherService;
 
 
     @Resource(name = "personDeviceLogDAO")
@@ -61,7 +61,6 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
     private DeviceInfoDAO deviceInfoDAO;
 
 
-
     @Override
     public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) {
         String retFileUrl = "";
@@ -83,7 +82,6 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
             retFileUrl = OSSUtil.upload(ossConfig, "/devicePersonLog", faceImageJson.getStr("Name"), inputStream);
         } catch (Exception e) {
             log.error("保存图片路径错误" + e.getMessage());
-            //  e.printStackTrace();
         }
 
 
@@ -108,12 +106,9 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
         personDeviceLog.setFaceImage(retFileUrl);
         personDeviceLogDAO.insert(personDeviceLog);
 
-        //人员识别成功,温度超过37.3时发送模板消息给监管者
+        //人员识别成功,温度超过限定时发送模板消息给监管者
         if (personDeviceLog.getPersonId() != 0) {
-            if (temperature.compareTo(new BigDecimal(37.3)) == 1) {
-                sendTemperatureAlarmsyncTask(personDeviceLog);
-            }
-
+            sendTemperatureAlarmsyncTask(personDeviceLog);
         }
 
     }
@@ -122,33 +117,38 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
     public void sendTemperatureAlarmsyncTask(PersonDeviceLog personDeviceLog) {
 
         try {
-            Map<String, Object> searchParams = new HashMap<>();
-            searchParams.put("deviceNo",personDeviceLog.getDeviceNo() );
-            searchParams.put("personId", personDeviceLog.getPersonId());
-            searchParams.put("minTemperature", new BigDecimal(37.3));
-            searchParams.put("beginTime",new Date(personDeviceLog.getRecordTime().getTime() - 300000));
-            List<Sort> sortList = new ArrayList<>();
-            sortList.add(new Sort("record_time","desc"));
-            List<PersonDeviceLog> personDeviceLogList = personDeviceLogDAO.search(searchParams,sortList);
-            if (personDeviceLogList.size()>=3){
-                PersonInfo personInfo =  personInfoDAO.get(personDeviceLog.getPersonId().longValue());
-                if (personInfo == null){
-                    throw new Exception(personDeviceLog.getPersonId()+"对应的人员不存在");
-                }
-                CompanyInfo companyInfo = companyInfoDAO.get(personInfo.getCompanyId());
-                if (companyInfo == null){
-                    throw new Exception(personInfo.getName()+"对应的公司不存在");
-                }
-                DeviceInfo deviceInfo = deviceInfoDAO.findByDeviceNo(personDeviceLog.getDeviceNo());
-                if (deviceInfo == null){
-                    throw new Exception(personDeviceLog.getDeviceNo()+"设备不存在");
+            PersonInfo personInfo = personInfoDAO.get(personDeviceLog.getPersonId().longValue());
+            if (personInfo == null) {
+                throw new Exception(personDeviceLog.getPersonId() + "对应的人员不存在");
+            }
+            CompanyInfo companyInfo = companyInfoDAO.get(personInfo.getCompanyId());
+            if (companyInfo == null) {
+                throw new Exception(personInfo.getName() + "对应的公司不存在");
+            }
+            DeviceInfo deviceInfo = deviceInfoDAO.findByDeviceNo(personDeviceLog.getDeviceNo());
+            if (deviceInfo == null) {
+                throw new Exception(personDeviceLog.getDeviceNo() + "设备不存在");
+            }
+            List<WarningPusher> warningPusherList = warningPusherService.findByCompanyId(personInfo.getCompanyId());
+            if (warningPusherList.size() <= 0) {
+                throw new Exception("对应公司没有体温报警监管者");
+            }
+            for (WarningPusher warningPusher : warningPusherList) {
+                Map<String, Object> searchParams = new HashMap<>();
+                searchParams.put("deviceNo", personDeviceLog.getDeviceNo());
+                searchParams.put("personId", personDeviceLog.getPersonId());
+                searchParams.put("minTemperature", warningPusher.getTemperature());
+                searchParams.put("beginTime", new Date(personDeviceLog.getRecordTime().getTime() - 300000));
+                List<Sort> sortList = new ArrayList<>();
+                sortList.add(new Sort("record_time", "desc"));
+                List<PersonDeviceLog> personDeviceLogList = personDeviceLogDAO.search(searchParams, sortList);
+                if (personDeviceLogList.size() >= warningPusher.getTimes()) {
+                    WechatMessageUtil.sendTemperatureAlarmInfo(warningPusher.getOpenId(), companyInfo.getName() + "_" + deviceInfo.getAliasName(), wxConfig.getAppId(), wxConfig.getAppSecret(),personDeviceLog.getId());
                 }
-
-                WechatMessageUtil.sendTemperatureAlarmInfo("oLowyuM2vn3HHZU6NvYSNoLoeZcc",companyInfo.getName()+"_"+deviceInfo.getAliasName(),wxConfig.getAppId(),wxConfig.getAppSecret(),"Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M");
             }
 
         } catch (Exception e) {
-            log.error(e.getMessage());
+            log.error(e.getMessage(), e);
         }
 
     }
@@ -172,6 +172,11 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
         return page;
     }
 
+    @Override
+    public PersonDeviceLog get(String id) {
+        return personDeviceLogDAO.get(id);
+    }
+
     @Override
     public List<PersonDeviceLog> findByPersonAndDate(Long personId, String startDate, String endDate) {
         return personDeviceLogDAO.findByPersonAndDate(personId, startDate, endDate);

+ 1 - 1
common/src/main/java/com/jpsoft/smart/modules/common/utils/LApiUtil.java

@@ -15,7 +15,7 @@ import java.util.HashMap;
 @Slf4j
 @Component
 public class LApiUtil {
-    private final static int TIMEOUT = 20*1000;
+    private final static int TIMEOUT = 10*1000;
 
     public static JSONObject PostRequest(String url,HashMap map){
         String body = HttpRequest.post(url)

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

@@ -20,7 +20,7 @@ public class WechatMessageUtil {
 
 	private static final String TEMPLATE_REDIRECT_PRE_URL = "http://wuyeopenlocktest-wecat.sudaonline.net";
 
-	private static final String TEMPERATURE_ALARM_PRE_URL = "http://wisdomhousewechat.sudaonline.net/123.jpg";
+	private static final String TEMPERATURE_ALARM_PRE_URL = "http://wisdomhousewechat.sudaonline.net/prevention/addetail_fll.html?id=";
 
 
 
@@ -377,12 +377,12 @@ public class WechatMessageUtil {
 	 * @param place
 	 * @param appId
 	 * @param appSecret
-	 * @param templateId
 	 * @return
 	 */
-	public static boolean sendTemperatureAlarmInfo( String openId,String place,String appId,String appSecret,String templateId) {
+	public static boolean sendTemperatureAlarmInfo( String openId,String place,String appId,String appSecret,String personDeviceLogId) {
 
 
+        String templateId = "Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M";
 		JSONObject sendData = new JSONObject();
 
 		JSONObject first = new JSONObject();
@@ -408,8 +408,8 @@ public class WechatMessageUtil {
 		sendData.put("keyword2", keyword2);
 		sendData.put("remark", remark);
 
-		//w8Zk_VQMFIEVSIBPZid7zSrvHmBdrgnqF76u8PLCZEs cs
-		boolean ret = sendTemplate(sendData, appId,appSecret,templateId,openId, TEMPERATURE_ALARM_PRE_URL);
+
+		boolean ret = sendTemplate(sendData, appId,appSecret,templateId,openId, TEMPERATURE_ALARM_PRE_URL+personDeviceLogId);
 
 		return ret;
 	}
@@ -470,7 +470,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/java/com/jpsoft/smart/modules/lapi/service/ILapiService.java

@@ -53,7 +53,7 @@ public interface ILapiService {
 
 
     /**
-     * 根据设备编码和人员id删除数据
+     * 根据设备ID和人员id删除数据
      * @param id 人员id
      * @param deviceIds 设备id(多个以逗号隔开)
      * @return

+ 23 - 0
common/src/main/resources/mapper/base/PersonDeviceLog.xml

@@ -3,6 +3,25 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.smart.modules.base.dao.PersonDeviceLogDAO">
+    <sql id="Base_Column_List">
+	device_no,
+	person_id,
+	id_,
+	create_by,
+	create_time,
+	update_by,
+	update_time,
+	is_effective,
+	del_flag,
+	device_no,
+	person_id,
+	temperature_,
+	match_status,
+	match_msg,
+	match_face_id,
+	face_image,
+	record_time
+</sql>
     <resultMap id="SimpleMap" type="com.jpsoft.smart.modules.base.entity.PersonDeviceLog">
         <id property="id" column="id_" />
         <result property="createBy" column="create_by" />
@@ -142,4 +161,8 @@
         </foreach>
     </select>
 
+    <select id="get" resultMap="SimpleMap">
+        select * from base_person_device_log where id_=#{0}
+    </select>
+
 </mapper>

+ 3 - 1
web/src/main/java/com/jpsoft/smart/config/WebMvcConfig.java

@@ -65,6 +65,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/personInfoApi/findByNameAndPhone")
 				.excludePathPatterns("/mobile/personInfoApi/getVerifyCode")
 				.excludePathPatterns("/mobile/personInfoApi/validateCode")
-				.excludePathPatterns("/mobile/personInfoApi/findByOpenId");
+				.excludePathPatterns("/mobile/personInfoApi/findByOpenId")
+				.excludePathPatterns("/mobile/personDeviceLogApi/detail")
+		;
 	}
 }

+ 48 - 0
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceLogApiController.java

@@ -3,6 +3,8 @@ package com.jpsoft.smart.modules.mobile.controller;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.util.StringUtil;
 import com.google.common.collect.Lists;
+import com.jpsoft.smart.modules.base.dto.PersonDeviceFilterLogDTO;
+import com.jpsoft.smart.modules.base.dto.PersonDeviceLogDTO;
 import com.jpsoft.smart.modules.base.entity.*;
 import com.jpsoft.smart.modules.base.service.*;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
@@ -618,4 +620,50 @@ public class PersonDeviceLogApiController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="体温记录(异常)")
+    @RequestMapping(value = "detail",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="token",value = "令牌",required = true,paramType = "form"),
+            @ApiImplicitParam(name="id",value = "编号",paramType = "form")
+    })
+    public MessageResult<PersonDeviceLogDTO> detail(String id, String token){
+        MessageResult<PersonDeviceLogDTO> msgResult = new MessageResult<>();
+
+        try {
+            PersonDeviceLog personDeviceLog = personDeviceLogService.get(id);
+            PersonDeviceLogDTO personDeviceLogDTO = new PersonDeviceLogDTO();
+
+            if (personDeviceLog != null) {
+                PojoUtils.map(personDeviceLog, personDeviceLogDTO);
+
+                DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(personDeviceLog.getDeviceNo());
+                PersonInfo personInfo = personInfoService.get(Long.valueOf(personDeviceLog.getPersonId()));
+
+                if(deviceInfo != null) {
+                    personDeviceLogDTO.setDeviceName(deviceInfo.getAliasName());
+                }
+                if(personInfo != null) {
+                    personDeviceLogDTO.setPersonName(personInfo.getName());
+                }
+
+                personDeviceLogDTO.setFever(true);
+
+
+                msgResult.setResult(true);
+                msgResult.setData(personDeviceLogDTO);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            log.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 4 - 0
web/src/test/java/com/jpsoft/smart/LApiTest.java

@@ -1,6 +1,8 @@
 package com.jpsoft.smart;
 
+import com.jpsoft.smart.modules.base.dto.PersonDeviceLogDTO;
 import com.jpsoft.smart.modules.base.entity.DeviceInfo;
+import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.lapi.service.ILapiService;
 import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
 import com.jpsoft.smart.modules.lapi.vo.LapiResult;
@@ -159,4 +161,6 @@ public class LApiTest {
 
     }
 
+
+
 }