|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xy.collections.list.JArrayList;
|
|
|
import com.xy.collections.map.JMap;
|
|
|
import com.xy.dto.DeviceFaultInfoDto;
|
|
|
+import com.xy.dto.DeviceFaultInfoFlowDto;
|
|
|
import com.xy.dto.be.MercDto;
|
|
|
import com.xy.entity.DeviceFaultInfo;
|
|
|
import com.xy.entity.DeviceFaultLog;
|
|
@@ -23,6 +24,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -52,6 +54,7 @@ public class DeviceFaultInfoServiceImpl extends ServiceImpl<DeviceFaultInfoMappe
|
|
|
private final DeviceFaultLogServiceImpl deviceFaultLogService;
|
|
|
private final MercService mercService;
|
|
|
private final DeviceInfoServiceImpl deviceInfoService;
|
|
|
+ private final DeviceFaultInfoFlowServiceImpl deviceFaultInfoFlowService;
|
|
|
|
|
|
@PostMapping("obj")
|
|
|
@ApiOperation("对象查询")
|
|
@@ -120,7 +123,13 @@ public class DeviceFaultInfoServiceImpl extends ServiceImpl<DeviceFaultInfoMappe
|
|
|
@PostMapping("resolve")
|
|
|
@ApiOperation("标记已解决")
|
|
|
public R resolve(@RequestBody @Validated DeviceFaultInfoDto.Update update) {
|
|
|
- DeviceFaultInfo deviceFaultInfo = this.getById(update.getFaultId());
|
|
|
+ resolveDone(update);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void resolveDone( DeviceFaultInfoDto.Update update){
|
|
|
+ Long faultId = update.getFaultId();
|
|
|
+ DeviceFaultInfo deviceFaultInfo = this.getById(faultId);
|
|
|
if (deviceFaultInfo == null) {
|
|
|
throw new CommRuntimeException("操作对象不存在!");
|
|
|
}
|
|
@@ -129,11 +138,14 @@ public class DeviceFaultInfoServiceImpl extends ServiceImpl<DeviceFaultInfoMappe
|
|
|
updateInfo.setFaultLevel(-1);
|
|
|
boolean b = updateById(updateInfo);
|
|
|
if (b) {
|
|
|
+ DeviceFaultInfoFlowDto.Save save = new DeviceFaultInfoFlowDto.Save();
|
|
|
+ save.setFaultId(faultId);
|
|
|
+ save.setContent("故障已解决");
|
|
|
+ deviceFaultInfoFlowService.save(save);
|
|
|
//清理日志 故障信息表标记已解决,清除日志表中对应设备事件在标记已解决时间之前所有事件。
|
|
|
deviceFaultLogService.remove(Wrappers.<DeviceFaultLog>lambdaUpdate().le(DeviceFaultLog::getEventTime, LocalDateTime.now()));
|
|
|
//更新故障等级为正常
|
|
|
deviceInfoService.updateById(new DeviceInfo().setDeviceId(deviceFaultInfo.getDeviceId()).setFaultLevel(-1));
|
|
|
}
|
|
|
- return R.ok();
|
|
|
}
|
|
|
}
|