This commit is contained in:
hzj
2025-04-17 10:21:00 +08:00
parent 829488a680
commit 5a6a8d829d
7 changed files with 209 additions and 3 deletions

View File

@@ -0,0 +1,44 @@
package com.njcn.device.pq.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.web.constant.ValidMessage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* Description:
* Date: 2024/11/5 11:34【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
public class PqIcdPathParam {
//icd文件名
private String fileName;
//icd文件存储的地址
private String filePath;
private String devType;
/**
* 更新操作实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class PqIcdPathUpdateParam extends PqIcdPathParam {
/**
* 表Id
*/
@ApiModelProperty("id")
@NotBlank(message = ValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
private String id;
}
}

View File

@@ -11,6 +11,7 @@ import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.dto.DeviceInfo; import com.njcn.device.pq.pojo.dto.DeviceInfo;
import com.njcn.device.pq.pojo.dto.PqIcdPathDTO; import com.njcn.device.pq.pojo.dto.PqIcdPathDTO;
import com.njcn.device.pq.pojo.param.NodeDeviceParam; import com.njcn.device.pq.pojo.param.NodeDeviceParam;
import com.njcn.device.pq.pojo.param.PqIcdPathParam;
import com.njcn.device.pq.pojo.po.PqIcdPath; import com.njcn.device.pq.pojo.po.PqIcdPath;
import com.njcn.device.pq.service.NodeDeviceService; import com.njcn.device.pq.service.NodeDeviceService;
import com.njcn.device.pq.service.PqIcdPathService; import com.njcn.device.pq.service.PqIcdPathService;
@@ -42,7 +43,7 @@ public class PqIcdPathController extends BaseController {
/** /**
* 根据终端模型获取icd模型如果模型为空则获取全部icd模型 * 根据终端模型获取icd模型如果模型为空则获取全部icd模型
3
*/ */
@ApiOperation("获取icd模型") @ApiOperation("获取icd模型")
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM) @OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
@@ -63,6 +64,25 @@ public class PqIcdPathController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
@ApiOperation("获取icd模型")
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
@PostMapping("addIcdPath")
public HttpResult<Boolean> addIcdPath(@RequestBody PqIcdPathParam pqIcdPathParam){
String methodDescribe = getMethodDescribe("addIcdPath");
Boolean result = pqIcdPathService.addIcdPath(pqIcdPathParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@ApiOperation("更新icd模型")
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
@PostMapping("addIcdPath")
public HttpResult<Boolean> updateIcdPath(@RequestBody PqIcdPathParam.PqIcdPathUpdateParam pqIcdPathUpdateParam){
String methodDescribe = getMethodDescribe("updateIcdPath");
Boolean result = pqIcdPathService.updateIcdPath(pqIcdPathUpdateParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}

View File

@@ -163,7 +163,7 @@ public class TerminalBaseController extends BaseController {
Boolean b = terminalBaseService.terminalSyncDeleteFly(lineId); Boolean b = terminalBaseService.terminalSyncDeleteFly(lineId);
//删除监测点即修改终端通知前置重启 //删除监测点即修改终端通知前置重启
terminalBaseService.askRestartDevice(devId,DeviceRebootType.LEDGER_MODIFY); // terminalBaseService.askRestartDevice(devId,DeviceRebootType.LEDGER_MODIFY);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
} }

View File

@@ -0,0 +1,102 @@
package com.njcn.device.pq.job;
import com.njcn.device.pq.constant.Param;
import com.njcn.device.pq.pojo.po.Line;
import com.njcn.device.pq.pojo.po.PqsTerminalLogs;
import com.njcn.device.pq.service.IPqsTerminalLogsService;
import com.njcn.device.pq.service.TerminalBaseService;
import com.njcn.message.constant.DeviceRebootType;
import com.njcn.redis.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* Description:
* Date: 2025/04/09 上午 10:11【需求编号】
*定时扫描终端日志表是否需要通知前置重启
* @author clam
* @version V1.0.0
*/
@Component
@EnableScheduling
public class ScheduledTasks {
@Autowired
private IPqsTerminalLogsService iPqsTerminalLogsService;
@Autowired
private TerminalBaseService terminalBaseService;
@Scheduled(fixedRate = 1000*60*10) // 每10分钟执行一次
public void reportCurrentTime() {
LocalDateTime now =LocalDateTime.now();
LocalDateTime tenMinutesAgo = now.minusMinutes(-10);
List<PqsTerminalLogs> list = iPqsTerminalLogsService.lambdaQuery()
// .between(PqsTerminalLogs::getCreateTime, tenMinutesAgo, now)
.eq(PqsTerminalLogs::getState, 1).eq(PqsTerminalLogs::getIsPush, 1).list();
if(!CollectionUtils.isEmpty(list)){
//一个是删除操作,其余都算终端设备更新操作
List<PqsTerminalLogs> delDevice = list.stream().filter(temp -> Objects.equals(temp.getOperateType(), Param.DEL) && Objects.equals(temp.getTerminalType(), 4)).distinct().collect(Collectors.toList());
List<String> delDevIds = new ArrayList<>();
if(!CollectionUtils.isEmpty(delDevice)){
delDevice.forEach(temp->{
terminalBaseService.askRestartDevice(temp.getObjIndex(), DeviceRebootType.DELETE_TERMINAL);
delDevIds.add(temp.getObjIndex());
}
);
}
List<String> updateDevIds = new ArrayList<>();
List<String> lineIds = list.stream().filter(temp -> Objects.equals(temp.getTerminalType(), 6)).map(PqsTerminalLogs::getObjIndex).distinct().collect(Collectors.toList());
List<String> devIds = list.stream().filter(temp -> Objects.equals(temp.getTerminalType(), 4)).map(PqsTerminalLogs::getObjIndex).distinct().collect(Collectors.toList());
//更新的终端
List<Line> lineById = terminalBaseService.getLineById(lineIds);
List<String> devIdList = lineById.stream().map(temp -> {
return temp.getPids().split(",")[4];
}).distinct().collect(Collectors.toList());
updateDevIds.addAll(devIdList);
updateDevIds.addAll(devIds);
if(!CollectionUtils.isEmpty(delDevIds)){
updateDevIds.removeAll(delDevIds);
}
updateDevIds.stream().distinct().forEach(temp->{
terminalBaseService.askRestartDevice(temp, DeviceRebootType.LEDGER_MODIFY);
}
);
}
}
public static void main(String[] args) {
List<String> updateDevIds = new ArrayList<>();
List<String> list1 = new ArrayList<>();
List<String> list2 = new ArrayList<>();
List<String> list3 = new ArrayList<>();
list1.add("1");
list1.add("2");
list1.add("3");
list1.add("3");
list2.add("3");
list2.add("4");
list2.add("5");
list3.add("3");
updateDevIds.addAll(list1);
updateDevIds.addAll(list2);
updateDevIds.removeAll(list3);
System.out.println(updateDevIds);
}
}

View File

@@ -1,5 +1,6 @@
package com.njcn.device.pq.service; package com.njcn.device.pq.service;
import com.njcn.device.pq.pojo.param.PqIcdPathParam;
import com.njcn.device.pq.pojo.po.PqIcdPath; import com.njcn.device.pq.pojo.po.PqIcdPath;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**
@@ -13,4 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
public interface PqIcdPathService extends IService<PqIcdPath>{ public interface PqIcdPathService extends IService<PqIcdPath>{
Boolean addIcdPath(PqIcdPathParam pqIcdPathParam);
Boolean updateIcdPath(PqIcdPathParam.PqIcdPathUpdateParam pqIcdPathUpdateParam);
} }

View File

@@ -1,12 +1,20 @@
package com.njcn.device.pq.service.impl; package com.njcn.device.pq.service.impl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pq.pojo.param.PqIcdPathParam;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Objects;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.device.pq.pojo.po.PqIcdPath; import com.njcn.device.pq.pojo.po.PqIcdPath;
import com.njcn.device.pq.mapper.PqIcdPathMapper; import com.njcn.device.pq.mapper.PqIcdPathMapper;
import com.njcn.device.pq.service.PqIcdPathService; import com.njcn.device.pq.service.PqIcdPathService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* *
* Description: * Description:
@@ -18,4 +26,26 @@ import com.njcn.device.pq.service.PqIcdPathService;
@Service @Service
public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath> implements PqIcdPathService{ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath> implements PqIcdPathService{
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean addIcdPath(PqIcdPathParam pqIcdPathParam) {
PqIcdPath pqIcdPath = new PqIcdPath();
PqIcdPath one = this.lambdaQuery().eq(PqIcdPath::getName, pqIcdPathParam.getDevType()).one();
if(Objects.isNull(one)){
throw new BusinessException(pqIcdPathParam.getDevType()+"已存在icd文件");
}
pqIcdPath.setName(pqIcdPathParam.getDevType());
pqIcdPath.setPath(pqIcdPathParam.getFilePath());
pqIcdPath.setUpdateTime(LocalDateTime.now());
this.save(pqIcdPath);
return true;
}
@Override
public Boolean updateIcdPath(PqIcdPathParam.PqIcdPathUpdateParam pqIcdPathUpdateParam) {
this.lambdaUpdate().eq(PqIcdPath::getName, pqIcdPathUpdateParam.getDevType())
.set(PqIcdPath::getPath,pqIcdPathUpdateParam.getFilePath())
.set(PqIcdPath::getUpdateTime,LocalDateTime.now()).update();
return true;
}
} }

View File

@@ -1529,6 +1529,12 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
lineDetailMapper.deleteById(point.getId()); lineDetailMapper.deleteById(point.getId());
overlimitMapper.deleteById(point.getId()); overlimitMapper.deleteById(point.getId());
deptLineMapper.deleteById(point.getId()); deptLineMapper.deleteById(point.getId());
// 通知设备重启
// String[] pids = point.getPids().split(",");
// if (pids.length > 4) {
// askRestartDevice(pids[4], DeviceRebootType.LEDGER_MODIFY);
// }
} }
private List<Line> findChildren(String pid) { private List<Line> findChildren(String pid) {