|
@@ -6,14 +6,23 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.inspect.order.vo.IotInspectOrderDetailPageReqVO;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.inspect.order.vo.IotInspectOrderDetailRespVO;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.inspect.order.vo.IotInspectOrderDetailSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.inspect.order.vo.*;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectOrderDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectOrderDetailDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.IotDeviceServiceImpl;
|
|
|
import cn.iocoder.yudao.module.pms.service.inspect.IotInspectOrderDetailService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.inspect.IotInspectOrderService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.inspect.IotInspectOrderServiceImpl;
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
+import com.google.common.collect.ImmutableList;
|
|
|
+import com.google.common.collect.ImmutableMap;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -22,7 +31,10 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.List;
|
|
|
+import java.io.Serializable;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@@ -36,6 +48,14 @@ public class IotInspectOrderDetailController {
|
|
|
|
|
|
@Resource
|
|
|
private IotInspectOrderDetailService iotInspectOrderDetailService;
|
|
|
+ @Autowired
|
|
|
+ private IotInspectOrderServiceImpl iotInspectOrderServiceImpl;
|
|
|
+ @Autowired
|
|
|
+ private IotDeviceService iotDeviceService;
|
|
|
+ @Autowired
|
|
|
+ private IotInspectOrderService iotInspectOrderService;
|
|
|
+ @Autowired
|
|
|
+ private DeptService deptService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建巡检工单巡检明细")
|
|
@@ -91,4 +111,51 @@ public class IotInspectOrderDetailController {
|
|
|
BeanUtils.toBean(list, IotInspectOrderDetailRespVO.class));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @GetMapping("/status")
|
|
|
+ @Operation(summary = "获得巡检项状态数量")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-item:query')")
|
|
|
+ public CommonResult<ImmutableList> getIotInspectItemStatus(IotCountDataDO vo) {
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ if (Objects.nonNull(vo.getDeptId())) {
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(vo.getDeptId());
|
|
|
+ ids.add(vo.getDeptId());
|
|
|
+ }
|
|
|
+ List<IotInspectOrderDetailDO> all = iotInspectOrderDetailService.getListStat(vo, ids);
|
|
|
+ long need = all.stream().filter(e -> Objects.isNull(e.getIfNormal())).count();
|
|
|
+ long normal = all.stream().filter(e -> Objects.nonNull(e.getIfNormal())&&e.getIfNormal()).count();
|
|
|
+ long exception = all.stream().filter(e -> Objects.nonNull(e.getIfNormal())&&!e.getIfNormal()).count();
|
|
|
+ ImmutableMap<String, ? extends Serializable> map = ImmutableMap.of("name", "待填写", "value", need);
|
|
|
+ ImmutableMap<String, ? extends Serializable> map1 = ImmutableMap.of("name", "正常", "value", normal);
|
|
|
+ ImmutableMap<String, ? extends Serializable> map2 = ImmutableMap.of("name", "异常", "value", exception);
|
|
|
+ return success(ImmutableList.of(map,map1,map2));
|
|
|
+ }
|
|
|
+ @GetMapping("/item")
|
|
|
+ public CommonResult<PageResult<IotInspectOrderDetailRespVO>> getItemStatus(IotInspectOrderDetailPageReqVO pageReqVO){
|
|
|
+
|
|
|
+ PageResult<IotInspectOrderDetailDO> deviceStatus = iotInspectOrderDetailService.getOrderDetailItem(pageReqVO);
|
|
|
+ List<IotInspectOrderDetailRespVO> collect = deviceStatus.getList().stream().map(e -> {
|
|
|
+ IotInspectOrderDetailRespVO iotInspectOrderDetailRespVO = new IotInspectOrderDetailRespVO();
|
|
|
+ BeanUtils.copyProperties(e, iotInspectOrderDetailRespVO);
|
|
|
+
|
|
|
+ if (Objects.nonNull(e.getDeviceId())) {
|
|
|
+ IotDeviceDO iotDevice = iotDeviceService.getIotDevice(e.getDeviceId());
|
|
|
+ if (Objects.nonNull(iotDevice)) {
|
|
|
+ iotInspectOrderDetailRespVO.setDeviceCode(iotDevice.getDeviceCode());
|
|
|
+ iotInspectOrderDetailRespVO.setDeviceName(iotDevice.getDeviceName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(e.getOrderId())) {
|
|
|
+ IotInspectOrderDO iotInspectOrder = iotInspectOrderService.getIotInspectOrder(e.getOrderId());
|
|
|
+ if (Objects.nonNull(iotInspectOrder)) {
|
|
|
+ iotInspectOrderDetailRespVO.setOrderName(iotInspectOrder.getInspectOrderTitle());
|
|
|
+ iotInspectOrderDetailRespVO.setCharge(iotInspectOrder.getChargeName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return iotInspectOrderDetailRespVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return success(new PageResult<>(collect, deviceStatus.getTotal()));
|
|
|
+ }
|
|
|
}
|