|
|
@ -22,10 +22,10 @@ import com.ruoyi.dataprocess.mapper.HwDeviceMapper;
|
|
|
|
import com.ruoyi.dataprocess.mapper.HwElectronicFenceMapper;
|
|
|
|
import com.ruoyi.dataprocess.mapper.HwElectronicFenceMapper;
|
|
|
|
import com.ruoyi.dataprocess.mapper.HwFenceAreaMapper;
|
|
|
|
import com.ruoyi.dataprocess.mapper.HwFenceAreaMapper;
|
|
|
|
import com.ruoyi.dataprocess.service.IDataProcessService;
|
|
|
|
import com.ruoyi.dataprocess.service.IDataProcessService;
|
|
|
|
import com.ruoyi.system.api.RemoteFileService;
|
|
|
|
|
|
|
|
import com.ruoyi.tdengine.api.RemoteTdEngineService;
|
|
|
|
import com.ruoyi.tdengine.api.RemoteTdEngineService;
|
|
|
|
import com.ruoyi.tdengine.api.domain.TdField;
|
|
|
|
import com.ruoyi.tdengine.api.domain.TdField;
|
|
|
|
import com.ruoyi.tdengine.api.domain.TdTableVo;
|
|
|
|
import com.ruoyi.tdengine.api.domain.TdTableVo;
|
|
|
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@ -92,6 +92,7 @@ public class DataProcessServiceImpl implements IDataProcessService {
|
|
|
|
for (int i = 0; i < paramArr.size(); i++) {
|
|
|
|
for (int i = 0; i < paramArr.size(); i++) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject paramJson = paramArr.getJSONObject(i);
|
|
|
|
JSONObject paramJson = paramArr.getJSONObject(i);
|
|
|
|
|
|
|
|
String dataType = paramJson.getString(TdEngineConstants.PAYLOAD_DATATYPE);
|
|
|
|
JSONObject dataValueJson = paramJson.getJSONObject(TdEngineConstants.PAYLOAD_DATAVALUE);
|
|
|
|
JSONObject dataValueJson = paramJson.getJSONObject(TdEngineConstants.PAYLOAD_DATAVALUE);
|
|
|
|
deviceCode = dataValueJson.getString(TdEngineConstants.PAYLOAD_DEVICE_CODE).toLowerCase();
|
|
|
|
deviceCode = dataValueJson.getString(TdEngineConstants.PAYLOAD_DEVICE_CODE).toLowerCase();
|
|
|
|
HwDevice hwDevice = hwDeviceMapper.selectHwDeviceByDeviceCode(deviceCode);
|
|
|
|
HwDevice hwDevice = hwDeviceMapper.selectHwDeviceByDeviceCode(deviceCode);
|
|
|
@ -144,17 +145,12 @@ public class DataProcessServiceImpl implements IDataProcessService {
|
|
|
|
String extension = ImageUtils.getImageType(valueStr, imagePatternArr);
|
|
|
|
String extension = ImageUtils.getImageType(valueStr, imagePatternArr);
|
|
|
|
if (StringUtils.isNotBlank(extension)) {
|
|
|
|
if (StringUtils.isNotBlank(extension)) {
|
|
|
|
//保存图片,并返回图片详细地址进行赋值保存
|
|
|
|
//保存图片,并返回图片详细地址进行赋值保存
|
|
|
|
String imageFileName = null;
|
|
|
|
value = getImageFileName(imagePath, imageDomain, imagePrefix, valueStr, deviceId, extension);
|
|
|
|
try {
|
|
|
|
if (value == null) continue;
|
|
|
|
imageFileName = ImageUtils.convertBase64ToImage(imagePath,
|
|
|
|
} else if (dataType.equalsIgnoreCase(TdEngineConstants.PAYLOAD_DEVICE_DATA_TYPE_IMAGE)) {
|
|
|
|
valueStr, "device" + deviceId, extension);
|
|
|
|
if (ImageUtils.checkIsBase64(valueStr)) {//判断没有加前缀的情况
|
|
|
|
if (StringUtils.isNotBlank(imageFileName)) {
|
|
|
|
value = getImageFileName(imagePath, imageDomain, imagePrefix, valueStr, deviceId, "jpg");
|
|
|
|
value = imageDomain + imagePrefix + imageFileName;
|
|
|
|
if (value == null) continue;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
logger.error("转换图片错误:" + e.getMessage(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -201,6 +197,19 @@ public class DataProcessServiceImpl implements IDataProcessService {
|
|
|
|
return paramArr.size();
|
|
|
|
return paramArr.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String getImageFileName(String imagePath, String imageDomain, String imagePrefix, String valueStr, Long deviceId, String extension) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String imageFileName = ImageUtils.convertBase64ToImage(imagePath,
|
|
|
|
|
|
|
|
valueStr, "device" + deviceId, extension);
|
|
|
|
|
|
|
|
return imageDomain + imagePrefix + imageFileName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
logger.error("转换图片错误:" + e.getMessage(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param: deviceId
|
|
|
|
* @param: deviceId
|
|
|
|
* @param: monitorUnitId
|
|
|
|
* @param: monitorUnitId
|
|
|
@ -304,7 +313,9 @@ public class DataProcessServiceImpl implements IDataProcessService {
|
|
|
|
JSONObject json = JSON.parseObject(jsonData);
|
|
|
|
JSONObject json = JSON.parseObject(jsonData);
|
|
|
|
Object value = json.get("base64");
|
|
|
|
Object value = json.get("base64");
|
|
|
|
if (value instanceof String) {
|
|
|
|
if (value instanceof String) {
|
|
|
|
|
|
|
|
|
|
|
|
String valueStr = (String) value;
|
|
|
|
String valueStr = (String) value;
|
|
|
|
|
|
|
|
System.out.println(Base64.isBase64(valueStr));
|
|
|
|
if (StringUtils.isNotBlank(valueStr)) {
|
|
|
|
if (StringUtils.isNotBlank(valueStr)) {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 先判读是否是图片,并获取图片名称, 获取到证明是图片
|
|
|
|
* 先判读是否是图片,并获取图片名称, 获取到证明是图片
|
|
|
|