|
@@ -1,5 +1,6 @@
|
|
|
package com.jpsoft.smart.modules.base.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.github.pagehelper.Page;
|
|
@@ -7,9 +8,10 @@ import com.github.pagehelper.PageHelper;
|
|
|
import com.jpsoft.smart.config.OSSConfig;
|
|
|
import com.jpsoft.smart.modules.base.dao.PersonDeviceFilterLogDAO;
|
|
|
import com.jpsoft.smart.modules.base.dao.PersonDeviceLogDAO;
|
|
|
-import com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog;
|
|
|
-import com.jpsoft.smart.modules.base.entity.PersonInfo;
|
|
|
+import com.jpsoft.smart.modules.base.entity.*;
|
|
|
+import com.jpsoft.smart.modules.base.service.CheckNumCompanyService;
|
|
|
import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
|
|
|
+import com.jpsoft.smart.modules.base.service.PersonInfoService;
|
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
|
import com.jpsoft.smart.modules.common.utils.LApiUtil;
|
|
|
import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
@@ -33,13 +35,19 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Transactional
|
|
|
-@Component(value="personDeviceFilterLogService")
|
|
|
+@Component(value = "personDeviceFilterLogService")
|
|
|
public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogService {
|
|
|
|
|
|
@Autowired
|
|
|
private OSSConfig ossConfig;
|
|
|
|
|
|
- @Resource(name="personDeviceFilterLogDAO")
|
|
|
+ @Autowired
|
|
|
+ private PersonInfoService personInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CheckNumCompanyService checkNumCompanyService;
|
|
|
+
|
|
|
+ @Resource(name = "personDeviceFilterLogDAO")
|
|
|
private PersonDeviceFilterLogDAO personDeviceFilterLogDAO;
|
|
|
|
|
|
@Override
|
|
@@ -51,155 +59,201 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
|
|
|
@Override
|
|
|
public void deviceInsertFilterLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) {
|
|
|
|
|
|
- try{
|
|
|
+ try {
|
|
|
|
|
|
|
|
|
- String retFileUrl = "";
|
|
|
- try{
|
|
|
+ String retFileUrl = "";
|
|
|
+ try {
|
|
|
|
|
|
- BASE64Decoder decoder = new BASE64Decoder();
|
|
|
+ BASE64Decoder decoder = new BASE64Decoder();
|
|
|
|
|
|
- byte[] imgData = decoder.decodeBuffer(faceImageJson.getStr("Data"));
|
|
|
+ byte[] imgData = decoder.decodeBuffer(faceImageJson.getStr("Data"));
|
|
|
|
|
|
- for (int i = 0; i < imgData.length; ++i) {
|
|
|
- if (imgData[i] < 0) {// 调整异常数据
|
|
|
- imgData[i] += 256;
|
|
|
+ for (int i = 0; i < imgData.length; ++i) {
|
|
|
+ if (imgData[i] < 0) {// 调整异常数据
|
|
|
+ imgData[i] += 256;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- ByteArrayInputStream inputStream = new ByteArrayInputStream(imgData);
|
|
|
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(imgData);
|
|
|
|
|
|
|
|
|
+ retFileUrl = OSSUtil.upload(ossConfig, "/devicePersonLog", faceImageJson.getStr("Name"), inputStream);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
- retFileUrl = OSSUtil.upload(ossConfig,"/devicePersonLog",faceImageJson.getStr("Name"), inputStream);
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- //记录的时间段
|
|
|
- String timeZones = DateUtil.format(date, "yyyy-MM-dd-HH");
|
|
|
- Integer personId = LApiUtil.getPersonCode(libMatInfoListJson,matchPersonInfo);
|
|
|
- if (personId !=0 && temperature.compareTo(BigDecimal.ZERO)==1){
|
|
|
- PersonDeviceFilterLog personDeviceFilterLog = personDeviceFilterLogDAO.findByPersonIdAndDeviceNoAndTimeZones(personId,deviceNo,timeZones);
|
|
|
-
|
|
|
- if (personDeviceFilterLog != null){
|
|
|
- BigDecimal oldTemper = personDeviceFilterLog.getTemperature();
|
|
|
- personDeviceFilterLog.setUpdateTime(new Date());
|
|
|
- personDeviceFilterLog.setTemperature(temperature);
|
|
|
- personDeviceFilterLog.setRecordTime(date);
|
|
|
- personDeviceFilterLog.setFaceImage(retFileUrl);
|
|
|
- personDeviceFilterLog.setCreateTime(new Date());
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchStatus"))){
|
|
|
- personDeviceFilterLog.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
|
|
|
- personDeviceFilterLog.setMatchMsg(LApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
|
|
|
- personDeviceFilterLog.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
|
|
|
- }else {
|
|
|
- personDeviceFilterLog.setMatchStatus(0);
|
|
|
- personDeviceFilterLog.setMatchFaceId(0);
|
|
|
- }
|
|
|
+ //记录的时间段
|
|
|
+ String timeZones = DateUtil.format(date, "yyyy-MM-dd-HH");
|
|
|
+ Integer personId = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
|
|
|
+ if (personId != 0 && temperature.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+
|
|
|
+
|
|
|
+ PersonDeviceFilterLog personDeviceFilterLog = personDeviceFilterLogDAO.findByPersonIdAndDeviceNoAndTimeZones(personId, deviceNo, timeZones);
|
|
|
+
|
|
|
+ if (personDeviceFilterLog != null) {
|
|
|
+ BigDecimal oldTemper = personDeviceFilterLog.getTemperature();
|
|
|
+ personDeviceFilterLog.setUpdateTime(new Date());
|
|
|
+ personDeviceFilterLog.setTemperature(temperature);
|
|
|
+ personDeviceFilterLog.setRecordTime(date);
|
|
|
+ personDeviceFilterLog.setFaceImage(retFileUrl);
|
|
|
+ personDeviceFilterLog.setCreateTime(new Date());
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchStatus"))) {
|
|
|
+ personDeviceFilterLog.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
|
|
|
+ personDeviceFilterLog.setMatchMsg(LApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
|
|
|
+ personDeviceFilterLog.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
|
|
|
+ } else {
|
|
|
+ personDeviceFilterLog.setMatchStatus(0);
|
|
|
+ personDeviceFilterLog.setMatchFaceId(0);
|
|
|
+ }
|
|
|
|
|
|
- if (!LApiUtil.compareToInterval(oldTemper,36,37)){
|
|
|
- if (LApiUtil.compareToInterval(temperature,36,37)){
|
|
|
+ if (!LApiUtil.compareToInterval(oldTemper, 36, 37)) {
|
|
|
+ if (LApiUtil.compareToInterval(temperature, 36, 37)) {
|
|
|
|
|
|
- personDeviceFilterLogDAO.update(personDeviceFilterLog);
|
|
|
- }else {
|
|
|
- if (temperature.compareTo(oldTemper)==-1){
|
|
|
personDeviceFilterLogDAO.update(personDeviceFilterLog);
|
|
|
+ } else {
|
|
|
+ if (temperature.compareTo(oldTemper) == -1) {
|
|
|
+ personDeviceFilterLogDAO.update(personDeviceFilterLog);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ PersonDeviceFilterLog personDeviceFilterLog1 = new PersonDeviceFilterLog();
|
|
|
+ personDeviceFilterLog1.setDeviceNo(deviceNo);
|
|
|
+ personDeviceFilterLog1.setPersonId(personId);
|
|
|
+ personDeviceFilterLog1.setTemperature(temperature);
|
|
|
+ if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchStatus"))) {
|
|
|
+ personDeviceFilterLog1.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
|
|
|
+ personDeviceFilterLog1.setMatchMsg(LApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
|
|
|
+ personDeviceFilterLog1.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
|
|
|
+ } else {
|
|
|
+ personDeviceFilterLog1.setMatchStatus(0);
|
|
|
+ personDeviceFilterLog1.setMatchFaceId(0);
|
|
|
+ }
|
|
|
+ personDeviceFilterLog1.setFaceImage(retFileUrl);
|
|
|
+ personDeviceFilterLog1.setRecordTime(date);
|
|
|
+ personDeviceFilterLog1.setTimeZones(timeZones);
|
|
|
+ personDeviceFilterLog1.setDelFlag(false);
|
|
|
+ personDeviceFilterLog1.setCreateTime(new Date());
|
|
|
+
|
|
|
+ personDeviceFilterLogDAO.insert(personDeviceFilterLog1);
|
|
|
}
|
|
|
- }else {
|
|
|
- PersonDeviceFilterLog personDeviceFilterLog1 = new PersonDeviceFilterLog();
|
|
|
- personDeviceFilterLog1.setDeviceNo(deviceNo);
|
|
|
- personDeviceFilterLog1.setPersonId(personId);
|
|
|
- personDeviceFilterLog1.setTemperature(temperature);
|
|
|
- if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchStatus"))){
|
|
|
- personDeviceFilterLog1.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
|
|
|
- personDeviceFilterLog1.setMatchMsg(LApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
|
|
|
- personDeviceFilterLog1.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
|
|
|
- }else {
|
|
|
- personDeviceFilterLog1.setMatchStatus(0);
|
|
|
- personDeviceFilterLog1.setMatchFaceId(0);
|
|
|
- }
|
|
|
- personDeviceFilterLog1.setFaceImage(retFileUrl);
|
|
|
- personDeviceFilterLog1.setRecordTime(date);
|
|
|
- personDeviceFilterLog1.setTimeZones(timeZones);
|
|
|
- personDeviceFilterLog1.setDelFlag(false);
|
|
|
- personDeviceFilterLog1.setCreateTime(new Date());
|
|
|
|
|
|
- personDeviceFilterLogDAO.insert(personDeviceFilterLog1);
|
|
|
+ new Thread(() -> {
|
|
|
+ try {
|
|
|
+ addCheckNumForCompany(personId, temperature, date);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
|
log.error(e.getMessage());
|
|
|
}
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ public void addCheckNumForCompany(Integer personId, BigDecimal temperature, Date date) {
|
|
|
+
|
|
|
+ String recordTime = DateUtil.format(date, "yyyy-MM-dd");
|
|
|
+ PersonInfo personInfo = personInfoService.get(personId.longValue());
|
|
|
+ if (StringUtils.isNotBlank(personInfo.getCompanyId())) {
|
|
|
+ CheckNumCompany checkNumCompany = checkNumCompanyService.findByCompanyIdAndRecordTime(personInfo.getCompanyId(), recordTime);
|
|
|
+ if (checkNumCompany != null) {
|
|
|
+ Integer checkNum = checkNumCompany.getCheckNum().intValue() + 1;
|
|
|
+ checkNumCompany.setCheckNum(checkNum.longValue());
|
|
|
+ checkNumCompanyService.update(checkNumCompany);
|
|
|
+ } else {
|
|
|
+ CheckNumCompany checkNumCompany1 = new CheckNumCompany();
|
|
|
+ checkNumCompany1.setCompanyId(personInfo.getCompanyId());
|
|
|
+ checkNumCompany1.setCheckNum(1L);
|
|
|
+ checkNumCompany1.setDelFlag(false);
|
|
|
+ checkNumCompany1.setRecordTime(recordTime);
|
|
|
+ checkNumCompany1.setCreateTime(new Date());
|
|
|
+ checkNumCompanyService.insert(checkNumCompany1);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Page<PersonDeviceFilterLog> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList){
|
|
|
- Page<PersonDeviceFilterLog> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
|
|
|
- personDeviceFilterLogDAO.search(searchParams,sortList);
|
|
|
+ public Page<PersonDeviceFilterLog> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
|
|
|
+ Page<PersonDeviceFilterLog> page = PageHelper.startPage(pageNumber, pageSize, count).doSelectPage(() -> {
|
|
|
+ personDeviceFilterLogDAO.search(searchParams, sortList);
|
|
|
});
|
|
|
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<PersonDeviceFilterLog> findByPersonAndDate(Long personId,String startDate,String endDate){
|
|
|
- return personDeviceFilterLogDAO.findByPersonAndDate(personId,startDate,endDate);
|
|
|
+ public List<PersonDeviceFilterLog> findByPersonAndDate(Long personId, String startDate, String endDate) {
|
|
|
+ return personDeviceFilterLogDAO.findByPersonAndDate(personId, startDate, endDate);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PersonDeviceFilterLog findByPersonOrderTemperature(Long personId,String startDate,String endDate){
|
|
|
- return personDeviceFilterLogDAO.findByPersonOrderTemperature(personId,startDate,endDate);
|
|
|
+ public PersonDeviceFilterLog findByPersonOrderTemperature(Long personId, String startDate, String endDate) {
|
|
|
+ return personDeviceFilterLogDAO.findByPersonOrderTemperature(personId, startDate, endDate);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PersonDeviceFilterLog lastPersonLog(Long personId){
|
|
|
+ public PersonDeviceFilterLog lastPersonLog(Long personId) {
|
|
|
return personDeviceFilterLogDAO.lastPersonLog(personId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PersonDeviceFilterLog getByPersonIdAndDate(Long personId,String startDate,String endDate){
|
|
|
- return personDeviceFilterLogDAO.getByPersonIdAndDate(personId,startDate,endDate);
|
|
|
+ public PersonDeviceFilterLog getByPersonIdAndDate(Long personId, String startDate, String endDate) {
|
|
|
+ return personDeviceFilterLogDAO.getByPersonIdAndDate(personId, startDate, endDate);
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public List<PersonDeviceFilterLog> list(){
|
|
|
+ public List<PersonDeviceFilterLog> list() {
|
|
|
return personDeviceFilterLogDAO.list();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public long countByTimeRangeAndCompanyCode(String companyCode,Long personId,int status, Date startDate, Date endDate) {
|
|
|
- return personDeviceFilterLogDAO.countByTimeRangeAndCompanyCode(companyCode,personId,status,startDate,endDate);
|
|
|
+ public long countByTimeRangeAndCompanyCode(String companyCode, Long personId, int status, Date startDate, Date endDate) {
|
|
|
+ return personDeviceFilterLogDAO.countByTimeRangeAndCompanyCode(companyCode, personId, status, startDate, endDate);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<PersonDeviceFilterLog> temperatureNormalStatistics(String companyCode, BigDecimal temperature, Date startDate, Date endDate) {
|
|
|
|
|
|
- return personDeviceFilterLogDAO.temperatureNormalStatistics(companyCode,temperature,startDate,endDate);
|
|
|
+ return personDeviceFilterLogDAO.temperatureNormalStatistics(companyCode, temperature, startDate, endDate);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<PersonDeviceFilterLog> temperatureUnusualStatistics(String companyCode, BigDecimal temperature, Date startDate, Date endDate) {
|
|
|
- return personDeviceFilterLogDAO.temperatureUnusualStatistics(companyCode,temperature,startDate,endDate);
|
|
|
+ return personDeviceFilterLogDAO.temperatureUnusualStatistics(companyCode, temperature, startDate, endDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> unusualStatistics(String companyCode, Long personId, BigDecimal temperature, Date startDate, Date endDate) {
|
|
|
+ return personDeviceFilterLogDAO.unusualStatistics(companyCode, personId, temperature, startDate, endDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long countUndetectedByCompanyCode(String companyCode, Long personId, Date startTime, Date endTime) {
|
|
|
+ return personDeviceFilterLogDAO.countUndetectedByCompanyCode(companyCode, personId, startTime, endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer getDayAbnormalNum(Date startTime, Date endTime) {
|
|
|
+ return personDeviceFilterLogDAO.getDayAbnormalNum(startTime,endTime);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> unusualStatistics(String companyCode,Long personId, BigDecimal temperature, Date startDate, Date endDate) {
|
|
|
- return personDeviceFilterLogDAO.unusualStatistics(companyCode,personId,temperature,startDate,endDate);
|
|
|
+ public Integer getDayAbnormalNumByCompanyList(Date startTime, Date endTime, List<CompanyInfo> list) {
|
|
|
+ return personDeviceFilterLogDAO.getDayAbnormalNumByCompanyList(startTime,endTime,list);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public long countUndetectedByCompanyCode(String companyCode,Long personId, Date startTime, Date endTime) {
|
|
|
- return personDeviceFilterLogDAO.countUndetectedByCompanyCode(companyCode,personId,startTime,endTime);
|
|
|
+ public Integer getDayNormalNumByCompanyId(Date startTime,Date endTime, String companyId) {
|
|
|
+ return personDeviceFilterLogDAO.getDayNormalNumByCompanyId(startTime,endTime,companyId);
|
|
|
}
|
|
|
}
|