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