|
@@ -6,11 +6,9 @@ import com.github.pagehelper.PageHelper;
|
|
import com.jpsoft.smart.config.OSSConfig;
|
|
import com.jpsoft.smart.config.OSSConfig;
|
|
import com.jpsoft.smart.config.WxConfig;
|
|
import com.jpsoft.smart.config.WxConfig;
|
|
import com.jpsoft.smart.modules.base.dao.*;
|
|
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.PersonDeviceLogService;
|
|
|
|
+import com.jpsoft.smart.modules.base.service.WarningPusherService;
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
import com.jpsoft.smart.modules.common.utils.*;
|
|
import com.jpsoft.smart.modules.common.utils.*;
|
|
import com.jpsoft.smart.modules.common.utils.Base64;
|
|
import com.jpsoft.smart.modules.common.utils.Base64;
|
|
@@ -46,6 +44,8 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
|
|
@Autowired
|
|
@Autowired
|
|
private WxConfig wxConfig;
|
|
private WxConfig wxConfig;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private WarningPusherService warningPusherService;
|
|
|
|
|
|
|
|
|
|
@Resource(name = "personDeviceLogDAO")
|
|
@Resource(name = "personDeviceLogDAO")
|
|
@@ -61,7 +61,6 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
|
|
private DeviceInfoDAO deviceInfoDAO;
|
|
private DeviceInfoDAO deviceInfoDAO;
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) {
|
|
public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) {
|
|
String retFileUrl = "";
|
|
String retFileUrl = "";
|
|
@@ -83,7 +82,6 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
|
|
retFileUrl = OSSUtil.upload(ossConfig, "/devicePersonLog", faceImageJson.getStr("Name"), inputStream);
|
|
retFileUrl = OSSUtil.upload(ossConfig, "/devicePersonLog", faceImageJson.getStr("Name"), inputStream);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("保存图片路径错误" + e.getMessage());
|
|
log.error("保存图片路径错误" + e.getMessage());
|
|
- // e.printStackTrace();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -108,12 +106,9 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
|
|
personDeviceLog.setFaceImage(retFileUrl);
|
|
personDeviceLog.setFaceImage(retFileUrl);
|
|
personDeviceLogDAO.insert(personDeviceLog);
|
|
personDeviceLogDAO.insert(personDeviceLog);
|
|
|
|
|
|
- //人员识别成功,温度超过37.3时发送模板消息给监管者
|
|
|
|
|
|
+ //人员识别成功,温度超过限定时发送模板消息给监管者
|
|
if (personDeviceLog.getPersonId() != 0) {
|
|
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) {
|
|
public void sendTemperatureAlarmsyncTask(PersonDeviceLog personDeviceLog) {
|
|
|
|
|
|
try {
|
|
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) {
|
|
} catch (Exception e) {
|
|
- log.error(e.getMessage());
|
|
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -172,6 +172,11 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public PersonDeviceLog get(String id) {
|
|
|
|
+ return personDeviceLogDAO.get(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<PersonDeviceLog> findByPersonAndDate(Long personId, String startDate, String endDate) {
|
|
public List<PersonDeviceLog> findByPersonAndDate(Long personId, String startDate, String endDate) {
|
|
return personDeviceLogDAO.findByPersonAndDate(personId, startDate, endDate);
|
|
return personDeviceLogDAO.findByPersonAndDate(personId, startDate, endDate);
|