终端周期检测代码调整
This commit is contained in:
@@ -21,18 +21,17 @@ public class GenerateCode {
|
||||
|
||||
private static final String TARGET_DIR = "D://code";
|
||||
|
||||
private static final String DB_URL = "jdbc:mysql://192.168.1.24:13306/pqsinfo_jb";
|
||||
private static final String DB_URL = "jdbc:mysql://127.0.0.1:3306/pqsinfo";
|
||||
// private static final String DB_URL = "jdbc:oracle:thin:@192.168.1.170:1521:pqsbase";
|
||||
|
||||
private static final String USERNAME = "root";
|
||||
|
||||
private static final String PASSWORD = "njcnpqs";
|
||||
private static final String PASSWORD = "123456";
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Module> modules = Stream.of(
|
||||
new Module("hongawen", "com.njcn.supervision", "survey", Stream.of(
|
||||
"supervision_survey_plan",
|
||||
"supervision_survey_test"
|
||||
new Module("xy", "com.njcn.supervision", "survey", Stream.of(
|
||||
"supervision_line_warning"
|
||||
).collect(Collectors.toList()), "supervision_")
|
||||
).collect(Collectors.toList());
|
||||
generateJavaFile(modules);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.device.pq.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pq.api.fallback.DeviceFeignClientFallbackFactory;
|
||||
import com.njcn.device.pq.api.fallback.LineFeignClientFallbackFactory;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(
|
||||
value = ServerInfo.DEVICE,
|
||||
path = "/dev",
|
||||
fallbackFactory = DeviceFeignClientFallbackFactory.class,
|
||||
contextId = "dev")
|
||||
public interface DeviceFeignClient {
|
||||
|
||||
/**
|
||||
* 技术监督修改装置定检时间
|
||||
*
|
||||
* @param devId 监测点id
|
||||
* @param thisTimeCheck 起始时间
|
||||
* @param nextTimeCheck 结束时间
|
||||
* @return 终端状态信息
|
||||
*/
|
||||
@PostMapping("/updateDevCheckTime")
|
||||
@ApiOperation("技术监督修改装置定检时间")
|
||||
HttpResult<String> updateDevCheckTime(@RequestParam("devId") String devId,
|
||||
@RequestParam("thisTimeCheck") String thisTimeCheck,
|
||||
@RequestParam("nextTimeCheck") String nextTimeCheck);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.device.pq.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.biz.utils.DeviceEnumUtil;
|
||||
import com.njcn.device.pq.api.DeviceFeignClient;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DeviceFeignClientFallbackFactory implements FallbackFactory<DeviceFeignClient> {
|
||||
@Override
|
||||
public DeviceFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new DeviceFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<String> updateDevCheckTime(String devId, String thisTimeCheck, String nextTimeCheck) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "技术监督修改装置定检时间", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -167,4 +167,13 @@ public class DeviceController extends BaseController {
|
||||
Console.log("string payload : {}", payload);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/updateDevCheckTime")
|
||||
@ApiOperation("技术监督修改装置定检时间")
|
||||
public HttpResult<String> updateDevCheckTime(String devId, String thisTimeCheck, String nextTimeCheck) {
|
||||
String methodDescribe = getMethodDescribe("updateDevCheckTime");
|
||||
iDeviceService.updateDevCheckTime(devId,thisTimeCheck,nextTimeCheck);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -125,4 +125,12 @@ public interface IDeviceService extends IService<Device> {
|
||||
* @Date: 2023/8/17 9:24
|
||||
*/
|
||||
String restartDev(List<String> devList);
|
||||
|
||||
/**
|
||||
* @param devId 装置id
|
||||
* @param thisTimeCheck 本次定检时间
|
||||
* @param nextTimeCheck 下次定检时间
|
||||
* @Description: 技术监督修改装置定检时间
|
||||
*/
|
||||
void updateDevCheckTime(String devId, String thisTimeCheck, String nextTimeCheck);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.device.pq.mapper.DevVersionMapper;
|
||||
import com.njcn.device.pq.mapper.DeviceMapper;
|
||||
@@ -397,5 +398,14 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
return "命令发送成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDevCheckTime(String devId, String thisTimeCheck, String nextTimeCheck) {
|
||||
LambdaUpdateWrapper<Device> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(Device::getId, devId)
|
||||
.set(Device::getThisTimeCheck, thisTimeCheck)
|
||||
.set(Device::getNextTimeCheck, nextTimeCheck);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -43,4 +43,10 @@ public class CheckDeviceParam extends BaseParam implements Serializable {
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "本次定检时间")
|
||||
private String nowCheckTime;
|
||||
|
||||
@ApiModelProperty(value = "状态 0:未处理 1:已处理")
|
||||
private Integer state;
|
||||
|
||||
}
|
||||
|
||||
@@ -36,11 +36,17 @@ public class CheckDevice extends BaseEntity implements Serializable {
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 定检时间
|
||||
* 原来定检时间
|
||||
*/
|
||||
@MppMultiId("check_time")
|
||||
private LocalDate checkTime;
|
||||
|
||||
/**
|
||||
* 本次定检时间
|
||||
*/
|
||||
@MppMultiId("now_check_time")
|
||||
private LocalDate nowCheckTime;
|
||||
|
||||
/**
|
||||
* 逾期天数
|
||||
*/
|
||||
@@ -66,6 +72,11 @@ public class CheckDevice extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 状态 0:未处理 1:已处理
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.njcn.supervision.pojo.vo.device;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -36,6 +38,14 @@ public class CheckDeviceVo extends BaseEntity implements Serializable {
|
||||
@ApiModelProperty("装置名称")
|
||||
private String deviceName;
|
||||
|
||||
@ApiModelProperty("本次定检时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate thisTimeCheck;
|
||||
|
||||
@ApiModelProperty("下次定检时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate nextTimeCheck;
|
||||
|
||||
@ApiModelProperty("逾期天数")
|
||||
private Integer overdueDay;
|
||||
|
||||
|
||||
@@ -7,12 +7,15 @@
|
||||
A.*,
|
||||
B.Name deviceName,
|
||||
B1.Name substation,
|
||||
B2.Name dept
|
||||
B2.Name dept,
|
||||
C.This_Time_Check thisTimeCheck,
|
||||
C.Next_Time_Check nextTimeCheck
|
||||
from
|
||||
supervision_check_device A
|
||||
left join pq_line B on A.device_id = B.Id
|
||||
left join pq_line B1 on B.Pid = B1.Id
|
||||
left join pq_line B2 on B1.Pid = B2.Id
|
||||
left join pq_device C on A.device_id = C.Id
|
||||
<where>
|
||||
and ${ew.sqlSegment}
|
||||
</where>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.njcn.supervision.service.device.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.bpm.api.BpmProcessFeignClient;
|
||||
@@ -18,6 +20,7 @@ import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import com.njcn.device.pq.api.DeviceFeignClient;
|
||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pq.pojo.vo.DevDetail;
|
||||
import com.njcn.supervision.enums.SupervisionKeyEnum;
|
||||
@@ -26,15 +29,20 @@ import com.njcn.supervision.pojo.param.device.CheckDeviceParam;
|
||||
import com.njcn.supervision.pojo.po.device.CheckDevice;
|
||||
import com.njcn.supervision.pojo.po.device.QuitRunningDevice;
|
||||
import com.njcn.supervision.pojo.po.survey.SurveyTest;
|
||||
import com.njcn.supervision.pojo.po.user.UserReportNormalPO;
|
||||
import com.njcn.supervision.pojo.vo.device.CheckDeviceVo;
|
||||
import com.njcn.supervision.service.device.ICheckDeviceService;
|
||||
import com.njcn.supervision.utils.InstanceUtil;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -60,10 +68,15 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
||||
|
||||
private final BpmProcessFeignClient bpmProcessFeignClient;
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final DeviceFeignClient deviceFeignClient;
|
||||
|
||||
@Override
|
||||
public void addCheckDevice() {
|
||||
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
|
||||
deptGetLineParam.setDeptId(RequestUtil.getDeptIndex());
|
||||
Dept data = deptFeignClient.getRootDept().getData();
|
||||
deptGetLineParam.setDeptId(data.getId());
|
||||
List<String> devList = commTerminalGeneralClient.deptGetDevice(deptGetLineParam)
|
||||
.getData()
|
||||
.stream()
|
||||
@@ -79,6 +92,7 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
||||
checkDevice.setDeviceId(item.getDevIndex());
|
||||
checkDevice.setCheckTime(item.getNextTimeCheck());
|
||||
checkDevice.setOverdueDay(new Long(item.getNextTimeCheck().until(LocalDate.now(), ChronoUnit.DAYS)).intValue());
|
||||
checkDevice.setState(0);
|
||||
return checkDevice;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
@@ -113,10 +127,13 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
||||
//默认根据逾期天数排序
|
||||
queryWrapper.orderBy(true, false, "A.overdue_day");
|
||||
}
|
||||
}
|
||||
if (!Objects.isNull(param.getStatus())) {
|
||||
queryWrapper.eq("A.status", param.getStatus());
|
||||
}
|
||||
if (!Objects.isNull(param.getState())) {
|
||||
queryWrapper.eq("A.state", param.getState());
|
||||
}
|
||||
}
|
||||
queryWrapper.le("A.check_time", LocalDate.now());
|
||||
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
}
|
||||
@@ -131,6 +148,7 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
||||
CheckDevice checkDevice = this.baseMapper.selectById(param.getId());
|
||||
checkDevice.setCheckFilePath(param.getReportPath());
|
||||
checkDevice.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
checkDevice.setNowCheckTime(LocalDate.parse(param.getNowCheckTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO();
|
||||
@@ -156,6 +174,7 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
||||
checkDevice.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
checkDevice.setCheckFilePath(param.getReportPath());
|
||||
checkDevice.setDescription(param.getDescription());
|
||||
checkDevice.setNowCheckTime(LocalDate.parse(param.getNowCheckTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO();
|
||||
@@ -184,10 +203,17 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateProcessStatus(String businessId, Integer status) {
|
||||
//流程状态整改
|
||||
CheckDevice checkDevice = this.baseMapper.selectById(businessId);
|
||||
checkDevice.setStatus(status);
|
||||
checkDevice.setState(1);
|
||||
this.updateById(checkDevice);
|
||||
//修改pq_device定检时间和下次定检时间 5年
|
||||
String nowCheckTime = checkDevice.getNowCheckTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
|
||||
String nextCheckTime = checkDevice.getNowCheckTime().plusYears(5).format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
|
||||
deviceFeignClient.updateDevCheckTime(checkDevice.getDeviceId(),nowCheckTime,nextCheckTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user