|
|
@@ -16,7 +16,10 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.inspect.order.vo.*;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.stat.DeptUtil;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceSimple;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotReportDeviceRespVO;
|
|
|
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;
|
|
|
@@ -400,6 +403,61 @@ public class IotInspectOrderController {
|
|
|
return success(new PageResult<>(collect, pageResult.getTotal()));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @GetMapping("/report/exception/item/export-excel")
|
|
|
+ @Operation(summary = "导出巡检工单巡检异常点 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-order-detail:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportReportExceptionItem(@Valid IotInspectOrderDetailPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ String companyCode;
|
|
|
+ if (Objects.isNull(pageReqVO.getDeptId())){
|
|
|
+ Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
+ companyCode = deptUtil.getCompanyCode(loginUserDeptId);
|
|
|
+ ids = deptUtil.getDeptIds(companyCode);
|
|
|
+ } else {
|
|
|
+ companyCode = deptUtil.getCompanyCode(pageReqVO.getDeptId());
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
+ }
|
|
|
+ Set<Long> deviceIds = new HashSet<>();
|
|
|
+ if (StringUtils.isNotBlank(pageReqVO.getDeviceCode())) {
|
|
|
+ IotDevicePageReqVO devicePageReqVO = new IotDevicePageReqVO();
|
|
|
+ devicePageReqVO.setDeviceCode(pageReqVO.getDeviceCode());
|
|
|
+ deviceIds = iotDeviceMapper.selectList(devicePageReqVO).stream().map(IotDeviceDO::getId).collect(Collectors.toSet());
|
|
|
+ }
|
|
|
+ Set<Long> orderIds = new HashSet<>();
|
|
|
+ if (StringUtils.isNotBlank(pageReqVO.getOrderName())) {
|
|
|
+ IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
|
|
|
+ iotInspectOrderPageReqVO.setInspectOrderTitle(pageReqVO.getOrderName());
|
|
|
+ orderIds = iotInspectOrderMapper.selectList(iotInspectOrderPageReqVO).stream().map(IotInspectOrderDO::getId).collect(Collectors.toSet());
|
|
|
+ }
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ pageReqVO.setIfNormal(false);
|
|
|
+ List<IotInspectOrderDetailDO> list = iotInspectOrderDetailMapper.selectItemPage(pageReqVO, ids, deviceIds, orderIds).getList();
|
|
|
+ List<IotInspectOrderDetailRespVO> bean = BeanUtils.toBean(list, IotInspectOrderDetailRespVO.class);
|
|
|
+ bean.forEach(e -> {
|
|
|
+ if (Objects.nonNull(e.getDeviceId())) {
|
|
|
+ IotDeviceDO iotDevice = iotDeviceService.getIotDevice(e.getDeviceId());
|
|
|
+ if (Objects.nonNull(iotDevice)) {
|
|
|
+ e.setDeviceCode(iotDevice.getDeviceCode());
|
|
|
+ e.setDeviceName(iotDevice.getDeviceName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(e.getOrderId())) {
|
|
|
+ IotInspectOrderDO iotInspectOrder = iotInspectOrderService.getIotInspectOrder(e.getOrderId());
|
|
|
+ if (Objects.nonNull(iotInspectOrder)) {
|
|
|
+ e.setOrderName(iotInspectOrder.getInspectOrderTitle());
|
|
|
+ e.setCharge(iotInspectOrder.getChargeName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ e.setResult(e.getIfNormal()?"正常":"异常");
|
|
|
+ });
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "巡检工单异常点统计.xls", "数据", IotInspectOrderDetailRespVO.class,
|
|
|
+ BeanUtils.toBean(bean, IotInspectOrderDetailRespVO.class));
|
|
|
+ }
|
|
|
@GetMapping("/exception/device")
|
|
|
public CommonResult<PageResult<IotDeviceSimple>> getExceptionDevice(@Valid IotInspectOrderPageReqVO pageReqVO) {
|
|
|
Set<Long> ids;
|
|
|
@@ -416,4 +474,51 @@ public class IotInspectOrderController {
|
|
|
PageResult<IotDeviceSimple> result = new PageResult<>(exceptionDevicePage.getRecords(), exceptionDevicePage.getTotal());
|
|
|
return success(result);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/report/export-excel")
|
|
|
+ @Operation(summary = "导出巡检工单巡检异常点 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-order-detail:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportReport(@Valid IotInspectOrderPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ Set<Long> ids;
|
|
|
+ if (Objects.isNull(pageReqVO.getDeptId())){
|
|
|
+ Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
+ String companyCode = deptUtil.getCompanyCode(loginUserDeptId);
|
|
|
+ ids = deptUtil.getDeptIds(companyCode);
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
+ } else {
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
+ }
|
|
|
+ pageReqVO.setDeptIds(ids);
|
|
|
+ List<IotInspectOrderRespVO> bean = iotInspectOrderMapper.selectExport(pageReqVO);
|
|
|
+ List<IotReportInspectOrderRespVO> list = BeanUtils.toBean(bean, IotReportInspectOrderRespVO.class);
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "巡检报表统计.xls", "数据", IotReportInspectOrderRespVO.class, list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/report/exception/device/export-excel")
|
|
|
+ @Operation(summary = "导出巡检工单巡检异常点 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-order-detail:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportReportExceptionDevice(@Valid IotInspectOrderPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ 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);
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<IotDeviceSimple> records = iotInspectOrderDetailMapper.getExceptionDevicePage(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO).getRecords();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "巡检异常设备统计.xls", "数据", IotDeviceSimple.class, records);
|
|
|
+ }
|
|
|
+
|
|
|
}
|