|
|
|
@ -2,14 +2,17 @@ package com.inspect.metadata.patrolpointmnt.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.inspect.base.core.constant.Color; |
|
|
|
import com.inspect.base.core.domain.DataMsg; |
|
|
|
import com.inspect.base.core.service.SyncDataToUpstreamService; |
|
|
|
import com.inspect.base.core.utils.DateUtils; |
|
|
|
import com.inspect.base.core.utils.SFTPUtil; |
|
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
|
import com.inspect.base.core.utils.xml.GenXmlByBean; |
|
|
|
import com.inspect.metadata.alg.domain.BasedataAlgSubtype; |
|
|
|
import com.inspect.metadata.alg.mapper.BasedataAlgSubtypeMapper; |
|
|
|
import com.inspect.metadata.area.domain.BaseDataArea; |
|
|
|
import com.inspect.metadata.area.mapper.BaseDataAreaMapper; |
|
|
|
import com.inspect.metadata.eqpbook.domain.BasedataEqpBook; |
|
|
|
import com.inspect.metadata.eqpbook.domain.BasedataEqpBookChannel; |
|
|
|
import com.inspect.metadata.eqpbook.domain.vo.PatrolTaskFtp; |
|
|
|
import com.inspect.metadata.eqpbook.mapper.BasedataEqpBookChannelMapper; |
|
|
|
import com.inspect.metadata.eqpbook.mapper.BasedataEqpBookMapper; |
|
|
|
@ -31,19 +34,6 @@ import com.inspect.metadata.prodevmnt.mapper.BasedataDeviceMapper; |
|
|
|
import com.inspect.metadata.prodevmnt.mapper.BasedataDeviceTypeMapper; |
|
|
|
import com.inspect.metadata.station.domain.BasedataStation; |
|
|
|
import com.inspect.metadata.station.mapper.BasedataStationMapper; |
|
|
|
import com.inspect.base.core.domain.DataMsg; |
|
|
|
import com.inspect.base.core.service.SyncDataToUpstreamService; |
|
|
|
import com.inspect.base.core.utils.DateUtils; |
|
|
|
import com.inspect.base.core.utils.SFTPUtil; |
|
|
|
import com.inspect.base.core.utils.xml.GenXmlByBean; |
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
|
|
|
|
import com.inspect.system.base.domain.SysDictData; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
@ -51,14 +41,15 @@ import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class BasedataPatrolPointServiceImpl implements IBasedataPatrolPointService { |
|
|
|
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
@Resource |
|
|
|
private BasedataPatrolPointMapper basedataPatrolpointMapper; |
|
|
|
@Resource |
|
|
|
private BasedataDeviceMapper basedataDeviceMapper; |
|
|
|
@Resource |
|
|
|
BasedataStationMapper basedataStationMapper; |
|
|
|
@Resource |
|
|
|
BasedataDeviceTypeMapper basedataDevicetypeMapper; |
|
|
|
@ -73,6 +64,10 @@ public class BasedataPatrolPointServiceImpl implements IBasedataPatrolPointServi |
|
|
|
@Resource |
|
|
|
SyncDataToUpstreamService syncDataToUpstreamService; |
|
|
|
@Resource |
|
|
|
private BasedataPatrolPointMapper basedataPatrolpointMapper; |
|
|
|
@Resource |
|
|
|
private BasedataDeviceMapper basedataDeviceMapper; |
|
|
|
@Resource |
|
|
|
private BasedataAlgSubtypeMapper basedataAlgSubtypeMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
@ -86,6 +81,7 @@ public class BasedataPatrolPointServiceImpl implements IBasedataPatrolPointServi |
|
|
|
return this.basedataPatrolpointMapper.selectBasedataPatrolPointList(basedataPatrolpoint); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<BasedataPatrolPoint> selectBasedataMonitorList(BasedataPatrolPoint basedataPatrolpoint) { |
|
|
|
List<BasedataPatrolPoint> pointList = basedataPatrolpointMapper.selectBasedataMonitorList(basedataPatrolpoint); |
|
|
|
logger.info("[META] pointList size: {},pointList: {}", pointList.size(), pointList); |
|
|
|
@ -120,22 +116,19 @@ public class BasedataPatrolPointServiceImpl implements IBasedataPatrolPointServi |
|
|
|
algSubtypeMap.put(item.getAlgSubtypeId() + "", item.getAlgSubtypeName()); |
|
|
|
}); |
|
|
|
logger.info("[META] algSubtypeMap: {}", algSubtypeMap); |
|
|
|
// pointList.forEach((item) -> item.loadAlgSubtypeName(algSubtypeMap)); |
|
|
|
Map<String, String> deviceTypeDictMap = getDeviceTypeDictMap(); |
|
|
|
List<SysDictData> dictList = getSysDictDataList("point_device_type"); |
|
|
|
Optional<SysDictData> defaultDictData = dictList.stream() |
|
|
|
.filter(SysDictData::getDefault) |
|
|
|
.findFirst(); |
|
|
|
for (BasedataPatrolPoint basedataPatrolPoint : pointList) { |
|
|
|
basedataPatrolPoint.loadAlgSubtypeName(algSubtypeMap); |
|
|
|
String patrolPointCode = basedataPatrolPoint.getPatrolPointCode(); |
|
|
|
basedataPatrolPoint.setPointTypeName("摄像机"); |
|
|
|
if(StringUtils.isNotEmpty(patrolPointCode) && patrolPointCode.contains("|")) { |
|
|
|
patrolPointCode = patrolPointCode.substring(0, patrolPointCode.indexOf("|")); |
|
|
|
String pointTypeName = deviceTypeDictMap.getOrDefault(patrolPointCode, "未知设备类型"); |
|
|
|
basedataPatrolPoint.setPointTypeName(pointTypeName); |
|
|
|
} |
|
|
|
processPointType(basedataPatrolPoint, dictList, defaultDictData); |
|
|
|
} |
|
|
|
logger.info("[META] pointList size: {},pointList: {}", pointList.size(), pointList); |
|
|
|
return pointList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<BasedataPatrolPoint> selectBasedataMonitorRelationList(BasedataPatrolPoint basedataPatrolpoint) { |
|
|
|
List<BasedataPatrolPoint> pointList = basedataPatrolpointMapper.selectBasedataMonitorRelationList(basedataPatrolpoint); |
|
|
|
|
|
|
|
@ -170,39 +163,59 @@ public class BasedataPatrolPointServiceImpl implements IBasedataPatrolPointServi |
|
|
|
algSubtypeMap.put(item.getAlgSubtypeId() + "", item.getAlgSubtypeName()); |
|
|
|
}); |
|
|
|
logger.info("[META] algSubtypeMap: {}", algSubtypeMap); |
|
|
|
// pointList.forEach((item) -> item.loadAlgSubtypeName(algSubtypeMap)); |
|
|
|
Map<String, String> deviceTypeDictMap = getDeviceTypeDictMap(); |
|
|
|
List<SysDictData> dictList = getSysDictDataList("point_device_type"); |
|
|
|
Optional<SysDictData> defaultDictData = dictList.stream() |
|
|
|
.filter(SysDictData::getDefault) |
|
|
|
.findFirst(); |
|
|
|
for (BasedataPatrolPoint basedataPatrolPoint : pointList) { |
|
|
|
basedataPatrolPoint.loadAlgSubtypeName(algSubtypeMap); |
|
|
|
String patrolPointCode = basedataPatrolPoint.getPatrolPointCode(); |
|
|
|
basedataPatrolPoint.setPointTypeName("摄像机"); |
|
|
|
if(StringUtils.isNotEmpty(patrolPointCode) && patrolPointCode.contains("|")) { |
|
|
|
patrolPointCode = patrolPointCode.substring(0, patrolPointCode.indexOf("|")); |
|
|
|
String pointTypeName = deviceTypeDictMap.getOrDefault(patrolPointCode, "未知设备类型"); |
|
|
|
basedataPatrolPoint.setPointTypeName(pointTypeName); |
|
|
|
} |
|
|
|
processPointType(basedataPatrolPoint, dictList, defaultDictData); |
|
|
|
} |
|
|
|
logger.info("[META] pointList size: {},pointList: {}", pointList.size(), pointList); |
|
|
|
return pointList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询设备类型字典(point_device_type)并转换为 Map |
|
|
|
* 处理点位的设备类型 |
|
|
|
* |
|
|
|
* @param dictList |
|
|
|
* @param basedataPatrolPoint |
|
|
|
*/ |
|
|
|
private Map<String, String> getDeviceTypeDictMap() { |
|
|
|
Map<String, String> dictMap = new HashMap<>(); |
|
|
|
try { |
|
|
|
List<SysDictData> dictDatas = basedataPatrolpointMapper.selectDictDataByType("point_device_type"); |
|
|
|
if (dictDatas != null) { |
|
|
|
dictMap = dictDatas.stream() |
|
|
|
.collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel)); |
|
|
|
private void processPointType(BasedataPatrolPoint basedataPatrolPoint, List<SysDictData> dictList, Optional<SysDictData> defaultDictData) { |
|
|
|
String patrolPointCode = basedataPatrolPoint.getPatrolPointCode(); |
|
|
|
if (StringUtils.isNotEmpty(patrolPointCode)) { |
|
|
|
if (patrolPointCode.contains("|")) { |
|
|
|
String finalPatrolPointCode = patrolPointCode.substring(0, patrolPointCode.indexOf("|")); |
|
|
|
Optional<String> pointTypeName = dictList.stream() |
|
|
|
.filter(dict -> { |
|
|
|
String valueStr = dict.getDictValue(); // 调用 getter |
|
|
|
if (valueStr == null) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return Arrays.stream(valueStr.split(",")) |
|
|
|
.map(String::trim) |
|
|
|
.anyMatch(code -> code.equals(finalPatrolPointCode)); |
|
|
|
}) |
|
|
|
.map(SysDictData::getDictLabel) |
|
|
|
.findFirst(); |
|
|
|
basedataPatrolPoint.setPointTypeName(pointTypeName.orElse("未知设备类型")); |
|
|
|
basedataPatrolPoint.setPointTypeCode(finalPatrolPointCode); |
|
|
|
} else { |
|
|
|
defaultDictData.ifPresent(dict -> { |
|
|
|
basedataPatrolPoint.setPointTypeName(dict.getDictLabel()); |
|
|
|
String[] codes = dict.getDictValue().split(","); |
|
|
|
logger.info("[META] pointTypeCode: {}", codes); |
|
|
|
if (codes.length > 0) { |
|
|
|
basedataPatrolPoint.setPointTypeCode(codes[0]); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("查询字典 point_device_type 失败", e); |
|
|
|
} |
|
|
|
return dictMap; |
|
|
|
} |
|
|
|
|
|
|
|
private List<SysDictData> getSysDictDataList(String dictType) { |
|
|
|
return basedataPatrolpointMapper.selectDictDataByType(dictType); |
|
|
|
} |
|
|
|
|
|
|
|
public BasedataPatrolPoint insertBasedataPatrolPoint(BasedataPatrolPoint basedataPatrolpoint) { |
|
|
|
basedataPatrolpoint.setCreateTime(DateUtils.getNowDate()); |
|
|
|
|