|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
|
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
@@ -32,6 +33,7 @@ import lombok.Data;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -247,6 +249,35 @@ public class IotInspectOrderController {
|
|
|
return success(BeanUtils.toBean(pageResult, IotInspectOrderRespVO.class));
|
|
|
}
|
|
|
|
|
|
+ @Data
|
|
|
+ public static class IgnoreOrder{
|
|
|
+ private Long id;
|
|
|
+ private String reason;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/ignore")
|
|
|
+ @Operation(summary = "忽略")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-order:query')")
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public CommonResult<String> ignoreOrder(@Valid IgnoreOrder ignoreOrder) {
|
|
|
+ List<IotInspectOrderDetailDO> details = iotInspectOrderDetailMapper.selectList("order_id", ignoreOrder.getId());
|
|
|
+ long count = details.stream().filter(e -> Objects.nonNull(e.getIfNormal())).count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw new ServiceException(new ErrorCode(133, "该工单已填写巡检项,无法忽略"));
|
|
|
+ }
|
|
|
+ details.forEach(e ->{
|
|
|
+ e.setIgnoreReason(true);
|
|
|
+ iotInspectOrderDetailMapper.updateById(e);
|
|
|
+ });
|
|
|
+ IotInspectOrderDO iotInspectOrder = iotInspectOrderService.getIotInspectOrder(ignoreOrder.getId());
|
|
|
+ IotInspectOrderSaveReqVO iotInspectOrderSaveReqVO = new IotInspectOrderSaveReqVO();
|
|
|
+ BeanUtils.copyProperties(iotInspectOrder, iotInspectOrderSaveReqVO);
|
|
|
+ iotInspectOrderSaveReqVO.setReason(ignoreOrder.getReason());
|
|
|
+ iotInspectOrderSaveReqVO.setStatus("ignore");
|
|
|
+ iotInspectOrderService.updateIotInspectOrder(iotInspectOrderSaveReqVO);
|
|
|
+ return success("完成");
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/export-excel")
|
|
|
@Operation(summary = "导出巡检工单 Excel")
|
|
|
@PreAuthorize("@ss.hasPermission('rq:iot-inspect-order:export')")
|