终端周期检测代码调整
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user