|
|
@ -2,7 +2,6 @@ package com.ccsens.logistics.service; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.ccsens.logistics.Util.Constant; |
|
|
@ -12,7 +11,6 @@ import com.ccsens.logistics.bean.po.LogisticsEquipmentExample; |
|
|
|
import com.ccsens.logistics.bean.po.LogisticsHeatImagingRecord; |
|
|
|
import com.ccsens.logistics.persist.mapper.LogisticsEquipmentMapper; |
|
|
|
import com.ccsens.logistics.persist.mapper.LogisticsHeatImagingRecordMapper; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
@ -23,10 +21,13 @@ import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author 逗 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class) |
|
|
|
public class ThermalImageryService implements IThermalImageryService{ |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
public class ThermalImageryService implements IThermalImageryService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private LogisticsEquipmentMapper logisticsEquipmentMapper; |
|
|
@ -36,7 +37,7 @@ public class ThermalImageryService implements IThermalImageryService{ |
|
|
|
private Snowflake snowflake; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<String> getImagery(){ |
|
|
|
public List<String> getImagery() { |
|
|
|
List<String> str = new ArrayList<>(); |
|
|
|
//查询redis内的热成像摄像头的编号
|
|
|
|
|
|
|
@ -44,8 +45,8 @@ public class ThermalImageryService implements IThermalImageryService{ |
|
|
|
LogisticsEquipmentExample equipmentExample = new LogisticsEquipmentExample(); |
|
|
|
equipmentExample.createCriteria().andEquipmentTypeEqualTo((byte) 4); |
|
|
|
List<LogisticsEquipment> logisticsEquipments = logisticsEquipmentMapper.selectByExample(equipmentExample); |
|
|
|
if(CollectionUtil.isNotEmpty(logisticsEquipments)){ |
|
|
|
for (LogisticsEquipment equipment:logisticsEquipments){ |
|
|
|
if (CollectionUtil.isNotEmpty(logisticsEquipments)) { |
|
|
|
for (LogisticsEquipment equipment : logisticsEquipments) { |
|
|
|
ThermalImageryDto.RequestThermalImagery thermalImagery = new ThermalImageryDto.RequestThermalImagery(); |
|
|
|
thermalImagery.setThing_id(equipment.getEquipmentNumber()); |
|
|
|
String s = JSONObject.toJSONString(thermalImagery); |
|
|
@ -60,29 +61,36 @@ public class ThermalImageryService implements IThermalImageryService{ |
|
|
|
public void disposeMessage(String value) { |
|
|
|
//解析字符串
|
|
|
|
try { |
|
|
|
ThermalImageryDto.RequestThermalImagery thermalImagery = JSONObject.parseObject(value,ThermalImageryDto.RequestThermalImagery.class); |
|
|
|
switch (thermalImagery.getType()){ |
|
|
|
ThermalImageryDto.RequestThermalImagery thermalImagery = JSONObject.parseObject(value, ThermalImageryDto.RequestThermalImagery.class); |
|
|
|
switch (thermalImagery.getType()) { |
|
|
|
case Constant.HEARTBEAT: |
|
|
|
//TODO 心跳不处理
|
|
|
|
break; |
|
|
|
case Constant.THERMAL_IMAGERY: |
|
|
|
if(StrUtil.isNotEmpty(thermalImagery.getData())) { |
|
|
|
ThermalImageryDto.GetThermalImageryDate date = JSONObject.parseObject(thermalImagery.getData(), ThermalImageryDto.GetThermalImageryDate.class); |
|
|
|
LogisticsHeatImagingRecord heatImagingRecord = new LogisticsHeatImagingRecord(); |
|
|
|
heatImagingRecord.setId(snowflake.nextId()); |
|
|
|
heatImagingRecord.setMaxT(new BigDecimal(date.getMaxT())); |
|
|
|
heatImagingRecord.setMaxTx(date.getMaxTx()); |
|
|
|
heatImagingRecord.setMaxTy(date.getMaxTy()); |
|
|
|
heatImagingRecord.setImageData(date.getImageData()); |
|
|
|
heatImagingRecordMapper.insertSelective(heatImagingRecord); |
|
|
|
LogisticsEquipmentExample equipmentExample = new LogisticsEquipmentExample(); |
|
|
|
equipmentExample.createCriteria().andEquipmentNumberEqualTo(thermalImagery.getThing_id()); |
|
|
|
List<LogisticsEquipment> logisticsEquipments = logisticsEquipmentMapper.selectByExample(equipmentExample); |
|
|
|
if (CollectionUtil.isNotEmpty(logisticsEquipments)) { |
|
|
|
LogisticsEquipment equipment = logisticsEquipments.get(0); |
|
|
|
if (StrUtil.isNotEmpty(thermalImagery.getData())) { |
|
|
|
ThermalImageryDto.GetThermalImageryDate date = JSONObject.parseObject(thermalImagery.getData(), ThermalImageryDto.GetThermalImageryDate.class); |
|
|
|
LogisticsHeatImagingRecord heatImagingRecord = new LogisticsHeatImagingRecord(); |
|
|
|
heatImagingRecord.setId(snowflake.nextId()); |
|
|
|
heatImagingRecord.setMaxT(new BigDecimal(date.getMaxT())); |
|
|
|
heatImagingRecord.setMaxTx(date.getMaxTx()); |
|
|
|
heatImagingRecord.setMaxTy(date.getMaxTy()); |
|
|
|
heatImagingRecord.setImageData("data:image/png;base64," + date.getImageData()); |
|
|
|
heatImagingRecord.setRecordTime(System.currentTimeMillis()); |
|
|
|
heatImagingRecord.setEquipmentId(equipment.getId()); |
|
|
|
heatImagingRecordMapper.insertSelective(heatImagingRecord); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
thermalImagery.getType(); |
|
|
|
}catch (Exception e){ |
|
|
|
log.info("解析热成像返回数据异常 {}",e); |
|
|
|
} catch (Exception e) { |
|
|
|
log.info("解析热成像返回数据异常 {}", e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|