|
@@ -45,6 +45,7 @@ import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -139,6 +140,18 @@ public class ProjectService {
|
|
|
project.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
project.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
|
project.setUpdateTime(now);
|
|
project.setUpdateTime(now);
|
|
|
project.setCompanyId(headerData.getCompanyId());
|
|
project.setCompanyId(headerData.getCompanyId());
|
|
|
|
|
+ project.setProjectType(projectAddDto.getProjectType());
|
|
|
|
|
+ List<KwsProject> projectList = projectMapper.selectListByType(projectAddDto.getProjectType());
|
|
|
|
|
+ if (projectList.size() > 99) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, "当前类型项目已经增加上限!");
|
|
|
|
|
+ }
|
|
|
|
|
+ String projectNo = "1";
|
|
|
|
|
+ if (Objects.isNull(projectList)) {
|
|
|
|
|
+ projectNo = StringUtils.addZeroForNum(projectNo, 2);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ projectNo = StringUtils.addZeroForNum(String.valueOf(projectList.size() + 1), 2);
|
|
|
|
|
+ }
|
|
|
|
|
+ project.setProjectNo(projectAddDto.getProjectType() + projectNo);
|
|
|
projectMapper.insert(project);
|
|
projectMapper.insert(project);
|
|
|
KwsProjectArea area = new KwsProjectArea();
|
|
KwsProjectArea area = new KwsProjectArea();
|
|
|
area.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
area.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
@@ -177,7 +190,11 @@ public class ProjectService {
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return PageRes.build(pageInfo, list);
|
|
return PageRes.build(pageInfo, list);
|
|
|
}
|
|
}
|
|
|
|
|
+ Map<String, SystemDict> projectType = commonService.getDictByDictCode(DictEnum.PROJECT_TYPE);
|
|
|
for (ProjectVo vo : list) {
|
|
for (ProjectVo vo : list) {
|
|
|
|
|
+ vo.setProjectTypeLabel(vo.getProjectType() == null ? null :
|
|
|
|
|
+ (projectType.get(vo.getProjectType()) == null ? vo.getProjectType() :
|
|
|
|
|
+ projectType.get(vo.getProjectType()).getLabel()));
|
|
|
vo.setDeviceTotal(projectDeviceMapper.selectCount(new LambdaQueryWrapper<KwsProjectDevice>().eq(KwsProjectDevice::getProjectId, vo.getId())).intValue());
|
|
vo.setDeviceTotal(projectDeviceMapper.selectCount(new LambdaQueryWrapper<KwsProjectDevice>().eq(KwsProjectDevice::getProjectId, vo.getId())).intValue());
|
|
|
KwsProjectArea area = projectAreaMapper.selectOne(new LambdaQueryWrapper<KwsProjectArea>().eq(KwsProjectArea::getProjectId, vo.getId()));
|
|
KwsProjectArea area = projectAreaMapper.selectOne(new LambdaQueryWrapper<KwsProjectArea>().eq(KwsProjectArea::getProjectId, vo.getId()));
|
|
|
vo.setFence(area == null ? null : area.getFence());
|
|
vo.setFence(area == null ? null : area.getFence());
|
|
@@ -187,6 +204,7 @@ public class ProjectService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public HttpResult detail(String id, HttpServletRequest response) {
|
|
public HttpResult detail(String id, HttpServletRequest response) {
|
|
|
|
|
+ Map<String, SystemDict> projectType = commonService.getDictByDictCode(DictEnum.PROJECT_TYPE);
|
|
|
KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>()
|
|
KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>()
|
|
|
.eq(KwsProject::getId, id)
|
|
.eq(KwsProject::getId, id)
|
|
|
/**.eq(KwsProject::getCompanyId, commonService.getHeaderData(response).getCompanyId())*/);
|
|
/**.eq(KwsProject::getCompanyId, commonService.getHeaderData(response).getCompanyId())*/);
|
|
@@ -195,6 +213,9 @@ public class ProjectService {
|
|
|
KwsProjectArea area = projectAreaMapper.selectOne(new LambdaQueryWrapper<KwsProjectArea>().eq(KwsProjectArea::getProjectId, vo.getId()));
|
|
KwsProjectArea area = projectAreaMapper.selectOne(new LambdaQueryWrapper<KwsProjectArea>().eq(KwsProjectArea::getProjectId, vo.getId()));
|
|
|
vo.setFence(area == null ? null : area.getFence());
|
|
vo.setFence(area == null ? null : area.getFence());
|
|
|
vo.setArea(area == null ? null : area.getArea());
|
|
vo.setArea(area == null ? null : area.getArea());
|
|
|
|
|
+ vo.setProjectTypeLabel(vo.getProjectType() == null ? null :
|
|
|
|
|
+ (projectType.get(vo.getProjectType()) == null ? vo.getProjectType() :
|
|
|
|
|
+ projectType.get(vo.getProjectType()).getLabel()));
|
|
|
return HttpResult.ok(vo);
|
|
return HttpResult.ok(vo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -240,7 +261,7 @@ public class ProjectService {
|
|
|
throw new BusinessException("项目存在关联设备,不允许删除!");
|
|
throw new BusinessException("项目存在关联设备,不允许删除!");
|
|
|
}
|
|
}
|
|
|
int update = projectMapper.update(null, new LambdaUpdateWrapper<KwsProject>().in(KwsProject::getId, list).set(KwsProject::getDelFlag, "1"));
|
|
int update = projectMapper.update(null, new LambdaUpdateWrapper<KwsProject>().in(KwsProject::getId, list).set(KwsProject::getDelFlag, "1"));
|
|
|
- projectAreaMapper.update(null,new LambdaUpdateWrapper<KwsProjectArea>().in(KwsProjectArea::getProjectId,list).set(KwsProjectArea::getDelFlag,1));
|
|
|
|
|
|
|
+ projectAreaMapper.update(null, new LambdaUpdateWrapper<KwsProjectArea>().in(KwsProjectArea::getProjectId, list).set(KwsProjectArea::getDelFlag, 1));
|
|
|
Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
logMap.put("projectName", project.getName());
|
|
logMap.put("projectName", project.getName());
|
|
|
logMap.put("mountainName", project.getMountainName());
|
|
logMap.put("mountainName", project.getMountainName());
|
|
@@ -315,6 +336,9 @@ public class ProjectService {
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public HttpResult deviceBind(BindDevice bindDevice, HttpServletRequest request) {
|
|
public HttpResult deviceBind(BindDevice bindDevice, HttpServletRequest request) {
|
|
|
|
|
+// if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
|
|
|
|
|
+// return HttpResult.error("安装设备时间不能为空");
|
|
|
|
|
+// }
|
|
|
HeaderData headerData = commonService.getHeaderData(request);
|
|
HeaderData headerData = commonService.getHeaderData(request);
|
|
|
Long projectId = Long.parseLong(bindDevice.getProjectId());
|
|
Long projectId = Long.parseLong(bindDevice.getProjectId());
|
|
|
KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>().eq(KwsProject::getId, projectId));
|
|
KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>().eq(KwsProject::getId, projectId));
|
|
@@ -378,6 +402,13 @@ public class ProjectService {
|
|
|
projectDeviceMapper.insert(device);
|
|
projectDeviceMapper.insert(device);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ LocalDateTime localDateTime;
|
|
|
|
|
+ if (StringUtils.isNotBlank(bindDevice.getInstallTime())) {
|
|
|
|
|
+ String installTime = bindDevice.getInstallTime();
|
|
|
|
|
+ localDateTime = DateUtil.strToLocalDateTime(installTime);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ localDateTime = null;
|
|
|
|
|
+ }
|
|
|
//设备修改状态
|
|
//设备修改状态
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
list.forEach(id -> {
|
|
list.forEach(id -> {
|
|
@@ -387,6 +418,7 @@ public class ProjectService {
|
|
|
if (kwsDevice == null) {
|
|
if (kwsDevice == null) {
|
|
|
throw new BusinessException("所属主设备id错误!");
|
|
throw new BusinessException("所属主设备id错误!");
|
|
|
}
|
|
}
|
|
|
|
|
+ kwsDevice.setInstallTime(localDateTime);
|
|
|
kwsDevice.setRelevanceLevel(level);
|
|
kwsDevice.setRelevanceLevel(level);
|
|
|
kwsDevice.setUpdateTime(LocalDateTime.now());
|
|
kwsDevice.setUpdateTime(LocalDateTime.now());
|
|
|
kwsDevice.setUpdateBy(headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
kwsDevice.setUpdateBy(headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
@@ -396,6 +428,7 @@ public class ProjectService {
|
|
|
deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
|
|
deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
|
|
|
.eq(KwsDevice::getId, id)
|
|
.eq(KwsDevice::getId, id)
|
|
|
.set(KwsDevice::getRelevanceLevel, level)
|
|
.set(KwsDevice::getRelevanceLevel, level)
|
|
|
|
|
+ .set(KwsDevice::getInstallTime,localDateTime)
|
|
|
.set(KwsDevice::getStatus, DeviceEnum.BE_CHECKING.getCode())
|
|
.set(KwsDevice::getStatus, DeviceEnum.BE_CHECKING.getCode())
|
|
|
.set(KwsDevice::getOnline, 1)
|
|
.set(KwsDevice::getOnline, 1)
|
|
|
.set(KwsDevice::getAlias, bindDevice.getAlias() == null ? kwsDevice.getName() : bindDevice.getAlias())
|
|
.set(KwsDevice::getAlias, bindDevice.getAlias() == null ? kwsDevice.getName() : bindDevice.getAlias())
|
|
@@ -1216,7 +1249,7 @@ public class ProjectService {
|
|
|
.ne(KwsDeviceRelation::getRelateDeviceId, deviceId)
|
|
.ne(KwsDeviceRelation::getRelateDeviceId, deviceId)
|
|
|
);
|
|
);
|
|
|
//主设备数据
|
|
//主设备数据
|
|
|
- KwsDeviceRelation deviceRelation = deviceRelationMapper.selectOne(
|
|
|
|
|
|
|
+ List<KwsDeviceRelation> deviceRelation = deviceRelationMapper.selectList(
|
|
|
new LambdaQueryWrapper<KwsDeviceRelation>()
|
|
new LambdaQueryWrapper<KwsDeviceRelation>()
|
|
|
.eq(KwsDeviceRelation::getDeviceId, deviceId)
|
|
.eq(KwsDeviceRelation::getDeviceId, deviceId)
|
|
|
.eq(KwsDeviceRelation::getDelFlag, 0)
|
|
.eq(KwsDeviceRelation::getDelFlag, 0)
|
|
@@ -1224,7 +1257,7 @@ public class ProjectService {
|
|
|
.eq(KwsDeviceRelation::getRelateDeviceId, deviceId)
|
|
.eq(KwsDeviceRelation::getRelateDeviceId, deviceId)
|
|
|
);
|
|
);
|
|
|
if (deviceRelation != null) {
|
|
if (deviceRelation != null) {
|
|
|
- deleteList.add(deviceRelation.getId());
|
|
|
|
|
|
|
+ deleteList.addAll(deviceRelation.stream().map(KwsDeviceRelation::getId).distinct().collect(Collectors.toList()));
|
|
|
}
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(deviceRelationList) && deviceRelationList.size() > 0) {
|
|
if (!CollectionUtils.isEmpty(deviceRelationList) && deviceRelationList.size() > 0) {
|
|
|
deleteList = deviceRelationList.stream().map(KwsDeviceRelation::getId).collect(Collectors.toList());
|
|
deleteList = deviceRelationList.stream().map(KwsDeviceRelation::getId).collect(Collectors.toList());
|
|
@@ -1272,6 +1305,7 @@ public class ProjectService {
|
|
|
.eq(KwsDevice::getMountainId, headerData.getMountainId())
|
|
.eq(KwsDevice::getMountainId, headerData.getMountainId())
|
|
|
.eq(KwsDevice::getDelFlag, 0)
|
|
.eq(KwsDevice::getDelFlag, 0)
|
|
|
.set(KwsDevice::getRelevanceLevel, 0)
|
|
.set(KwsDevice::getRelevanceLevel, 0)
|
|
|
|
|
+ .set(KwsDevice::getInstallTime, null)
|
|
|
.set(KwsDevice::getLogicAlt, null)
|
|
.set(KwsDevice::getLogicAlt, null)
|
|
|
.set(KwsDevice::getLogicLat, null)
|
|
.set(KwsDevice::getLogicLat, null)
|
|
|
.set(KwsDevice::getLogicLng, null)
|
|
.set(KwsDevice::getLogicLng, null)
|
|
@@ -1494,9 +1528,9 @@ public class ProjectService {
|
|
|
if (alarmStatus.equals(String.valueOf(threshold.getLevel()))) {
|
|
if (alarmStatus.equals(String.valueOf(threshold.getLevel()))) {
|
|
|
List<KwsAlarmDetail> alarmDetails = alarmDetailMapper.selectList(
|
|
List<KwsAlarmDetail> alarmDetails = alarmDetailMapper.selectList(
|
|
|
new LambdaQueryWrapper<KwsAlarmDetail>()
|
|
new LambdaQueryWrapper<KwsAlarmDetail>()
|
|
|
- .eq(KwsAlarmDetail::getPid, threshold.getId())
|
|
|
|
|
- .eq(KwsAlarmDetail::getStatus, 0)
|
|
|
|
|
- .eq(KwsAlarmDetail::getDelFlag, 0)
|
|
|
|
|
|
|
+ .eq(KwsAlarmDetail::getPid, threshold.getId())
|
|
|
|
|
+ .eq(KwsAlarmDetail::getStatus, 0)
|
|
|
|
|
+ .eq(KwsAlarmDetail::getDelFlag, 0)
|
|
|
);
|
|
);
|
|
|
if (!CollectionUtils.isEmpty(alarmDetails) && alarmDetails.size() > 0) {
|
|
if (!CollectionUtils.isEmpty(alarmDetails) && alarmDetails.size() > 0) {
|
|
|
thresholdId = alarmDetails.get(0).getAlarmId().toString();
|
|
thresholdId = alarmDetails.get(0).getAlarmId().toString();
|
|
@@ -1539,12 +1573,17 @@ public class ProjectService {
|
|
|
bindSelectVO.setRelateDeviceId(relateDeviceId);
|
|
bindSelectVO.setRelateDeviceId(relateDeviceId);
|
|
|
bindSelectVO.setRelateDeviceName(relateDevice == null ? null : relateDevice.getName());
|
|
bindSelectVO.setRelateDeviceName(relateDevice == null ? null : relateDevice.getName());
|
|
|
bindSelectVO.setRelateDeviceAlias(relateDevice == null ? null : relateDevice.getAlias());
|
|
bindSelectVO.setRelateDeviceAlias(relateDevice == null ? null : relateDevice.getAlias());
|
|
|
|
|
+ bindSelectVO.setInstallTime(kwsDevice.getInstallTime() == null ? null :
|
|
|
|
|
+ cn.hutool.core.date.DateUtil.format(kwsDevice.getInstallTime(), "yyyy-MM-dd"));
|
|
|
}
|
|
}
|
|
|
return HttpResult.ok(bindSelectVO);
|
|
return HttpResult.ok(bindSelectVO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public HttpResult updateDeviceBind(BindDevice bindDevice, HttpServletRequest request) {
|
|
public HttpResult updateDeviceBind(BindDevice bindDevice, HttpServletRequest request) {
|
|
|
|
|
+// if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
|
|
|
|
|
+// return HttpResult.error("安装设备时间不能为空");
|
|
|
|
|
+// }
|
|
|
String deviceRelationId = bindDevice.getDeviceRelationId();
|
|
String deviceRelationId = bindDevice.getDeviceRelationId();
|
|
|
if (StringUtils.isBlank(deviceRelationId)) {
|
|
if (StringUtils.isBlank(deviceRelationId)) {
|
|
|
return HttpResult.error("关联主键id不能为空");
|
|
return HttpResult.error("关联主键id不能为空");
|
|
@@ -1647,6 +1686,14 @@ public class ProjectService {
|
|
|
projectDeviceMapper.insert(device);
|
|
projectDeviceMapper.insert(device);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ LocalDateTime localDateTime;
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(bindDevice.getInstallTime())) {
|
|
|
|
|
+ String installTime = bindDevice.getInstallTime();
|
|
|
|
|
+ installTime = installTime + " 00:00:00";
|
|
|
|
|
+ localDateTime = LocalDateTime.parse(installTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ localDateTime = null;
|
|
|
|
|
+ }
|
|
|
//设备修改状态
|
|
//设备修改状态
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
list.forEach(id -> {
|
|
list.forEach(id -> {
|
|
@@ -1656,6 +1703,7 @@ public class ProjectService {
|
|
|
if (kwsDevice == null) {
|
|
if (kwsDevice == null) {
|
|
|
throw new BusinessException("所属主设备id错误!");
|
|
throw new BusinessException("所属主设备id错误!");
|
|
|
}
|
|
}
|
|
|
|
|
+ kwsDevice.setInstallTime(localDateTime);
|
|
|
kwsDevice.setRelevanceLevel(level);
|
|
kwsDevice.setRelevanceLevel(level);
|
|
|
kwsDevice.setUpdateTime(LocalDateTime.now());
|
|
kwsDevice.setUpdateTime(LocalDateTime.now());
|
|
|
kwsDevice.setUpdateBy(headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
kwsDevice.setUpdateBy(headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
@@ -1666,6 +1714,7 @@ public class ProjectService {
|
|
|
.eq(KwsDevice::getId, id)
|
|
.eq(KwsDevice::getId, id)
|
|
|
.set(KwsDevice::getRelevanceLevel, level)
|
|
.set(KwsDevice::getRelevanceLevel, level)
|
|
|
.set(KwsDevice::getStatus, DeviceEnum.BE_CHECKING.getCode())
|
|
.set(KwsDevice::getStatus, DeviceEnum.BE_CHECKING.getCode())
|
|
|
|
|
+ .set(KwsDevice::getInstallTime, localDateTime)
|
|
|
.set(KwsDevice::getOnline, 1)
|
|
.set(KwsDevice::getOnline, 1)
|
|
|
.set(KwsDevice::getAlias, bindDevice.getAlias() == null ? kwsDevice.getName() : bindDevice.getAlias())
|
|
.set(KwsDevice::getAlias, bindDevice.getAlias() == null ? kwsDevice.getName() : bindDevice.getAlias())
|
|
|
.set(KwsDevice::getUpdateTime, LocalDateTime.now())
|
|
.set(KwsDevice::getUpdateTime, LocalDateTime.now())
|