|
@@ -1,12 +1,20 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.stat;
|
|
package cn.iocoder.yudao.module.pms.controller.admin.stat;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.stat.vo.OrderVo;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.stat.vo.OrderVo;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderDeviceMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
@@ -19,6 +27,12 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.annotation.security.PermitAll;
|
|
import javax.annotation.security.PermitAll;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+import java.util.StringJoiner;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
|
|
|
@Tag(name = "报表所有工单接口")
|
|
@Tag(name = "报表所有工单接口")
|
|
|
@RestController
|
|
@RestController
|
|
@@ -30,11 +44,51 @@ public class IotReportOrderController {
|
|
|
private final IotMaintainMapper iotMaintainMapper;
|
|
private final IotMaintainMapper iotMaintainMapper;
|
|
|
private final IotInspectOrderMapper iotInspectOrderMapper;
|
|
private final IotInspectOrderMapper iotInspectOrderMapper;
|
|
|
private final IotOpeationFillMapper iotOpeationFillMapper;
|
|
private final IotOpeationFillMapper iotOpeationFillMapper;
|
|
|
|
|
+ private final DeptUtil deptUtil;
|
|
|
|
|
+ private final DeptService deptService;
|
|
|
|
|
+ private final DeptApi deptApi;
|
|
|
|
|
+ private final IotInspectOrderDeviceMapper iotInspectOrderDeviceMapper;
|
|
|
|
|
|
|
|
@Operation(summary = "各工单状态数量统计")
|
|
@Operation(summary = "各工单状态数量统计")
|
|
|
@GetMapping("/number")
|
|
@GetMapping("/number")
|
|
|
public CommonResult<ImmutableMap> getOrderStat(@Valid IotMaintainPageReqVO pageReqVO) {
|
|
public CommonResult<ImmutableMap> getOrderStat(@Valid IotMaintainPageReqVO pageReqVO) {
|
|
|
- List<OrderVo> orderVos = iotMaintainMapper.selectStatusNumber(pageReqVO);
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ List<OrderVo> maintains = iotMaintainMapper.selectStatusNumber(pageReqVO);
|
|
|
|
|
+ List<OrderVo> inspects = iotInspectOrderMapper.selectStatusNumber(pageReqVO);
|
|
|
|
|
+ List<OrderVo> operations = iotOpeationFillMapper.selectStatusNumber(pageReqVO);
|
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("wx", maintains, "xj", inspects, "yx", operations));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Operation(summary = "各工单统计")
|
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
|
+ public CommonResult<PageResult<OrderVo>> getOrderPage(@Valid IotMaintainPageReqVO pageReqVO) {
|
|
|
|
|
+ Set<Long> ids;
|
|
|
|
|
+ if (Objects.isNull(pageReqVO.getDeptId())){
|
|
|
|
|
+ Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
|
|
+ String companyCode = deptUtil.getCompanyCode(loginUserDeptId);
|
|
|
|
|
+ ids = deptUtil.getDeptIds(companyCode);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
|
|
+ }
|
|
|
|
|
+ pageReqVO.setDeptIds(ids);
|
|
|
|
|
+ IPage<OrderVo> allOrder = iotMaintainMapper.getAllOrder(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO);
|
|
|
|
|
+ PageResult<OrderVo> result = new PageResult<>(allOrder.getRecords(), allOrder.getTotal());
|
|
|
|
|
+ List<OrderVo> collect = result.getList().stream().map(e -> {
|
|
|
|
|
+ if ("巡检工单".equals(e.getType())){
|
|
|
|
|
+ String deviceInfo = iotInspectOrderDeviceMapper.getDeviceInfo(e.getId());
|
|
|
|
|
+ e.setDevice(deviceInfo);
|
|
|
|
|
+ } else if ("运行记录".equals(e.getType())) {
|
|
|
|
|
+ List<IotOpeationFillDO> orderId = iotOpeationFillMapper.selectList("order_id", e.getId());
|
|
|
|
|
+ StringJoiner joiner = new StringJoiner(", ");
|
|
|
|
|
+ for (IotOpeationFillDO fillDO : orderId) {
|
|
|
|
|
+ joiner.add(fillDO.getDeviceCode() + "/" + fillDO.getDeviceName());
|
|
|
|
|
+ }
|
|
|
|
|
+ e.setDevice(joiner.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ return e;
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ return success(new PageResult<>(collect, allOrder.getTotal()));
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|