Răsfoiți Sursa

pms 保养查询导出

zhangcl 2 zile în urmă
părinte
comite
7f48350e04

+ 57 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorder/IotMainWorkOrderController.java

@@ -12,6 +12,7 @@ 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.iotmainworkorder.vo.*;
 import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorderbom.vo.IotMainWorkOrderBomPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceExportRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorder.IotMainWorkOrderDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorderbom.IotMainWorkOrderBomDO;
@@ -21,7 +22,9 @@ import cn.iocoder.yudao.module.pms.service.iotmainworkorderbom.IotMainWorkOrderB
 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
+import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -61,6 +64,8 @@ public class IotMainWorkOrderController {
     private DeptService deptService;
     @Autowired
     private IotDevicePersonService iotDevicePersonService;
+    @Resource
+    private DictDataService dictDataService;
 
     @PostMapping("/create")
     @Operation(summary = "创建保养工单")
@@ -232,6 +237,17 @@ public class IotMainWorkOrderController {
         Map<Long, Long> deviceOrderPair = new HashMap<>();
         // key设备id      value正在执行的保养工单id
         Map<Long, Long> deviceRunningOrderPair = new HashMap<>();
+        // key设备状态数据字典value   value设备状态数据字典label
+        Map<String, String> deviceStatusPair = new HashMap<>();
+
+        // 施工状态 字典数据
+        List<DictDataDO> deviceStatusData = dictDataService.getDictDataListByDictType("pms_device_status");
+        if (CollUtil.isNotEmpty(deviceStatusData)) {
+            deviceStatusData.forEach(data -> {
+                deviceStatusPair.put(data.getValue(), data.getLabel());
+            });
+        }
+
         if (CollUtil.isNotEmpty(orderBoms)) {
             orderBoms.forEach(bom -> {
                 orderIds.add(bom.getWorkOrderId());
@@ -339,4 +355,45 @@ public class IotMainWorkOrderController {
                         BeanUtils.toBean(list, IotMainWorkOrderRespVO.class));
     }
 
+    @GetMapping("/exportMaintenances")
+    @Operation(summary = "导出保养查询列表 Excel")
+    @PreAuthorize("@ss.hasPermission('pms:iot-main-work-order:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportMaintenances(@Valid IotMainWorkOrderPageReqVO pageReqVO,
+                                            HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<IotDeviceRespVO> maintenances = iotMainWorkOrderService.deviceMainDistances(pageReqVO).getList();
+        // List<IotMainWorkOrderDO> list = iotMainWorkOrderService.getIotMainWorkOrderPage(pageReqVO).getList();
+        // key设备状态数据字典value   value设备状态数据字典label
+        Map<String, String> deviceStatusPair = new HashMap<>();
+
+        // 施工状态 字典数据
+        List<DictDataDO> deviceStatusData = dictDataService.getDictDataListByDictType("pms_device_status");
+        if (CollUtil.isNotEmpty(deviceStatusData)) {
+            deviceStatusData.forEach(data -> {
+                deviceStatusPair.put(data.getValue(), data.getLabel());
+            });
+        }
+        List<IotDeviceRespVO> deviceDistances = buildDeviceDistanceList(maintenances);
+        List<IotDeviceExportRespVO> deviceDistancesResult = BeanUtils.toBean(deviceDistances, IotDeviceExportRespVO.class);
+        if (CollUtil.isNotEmpty(deviceDistancesResult)) {
+            deviceDistancesResult.forEach(distance -> {
+                // 设置施工状态 label
+                if (deviceStatusPair.containsKey(distance.getDeviceStatus())) {
+                    distance.setDeviceStatusLabel(deviceStatusPair.get(distance.getDeviceStatus()));
+                }
+                // 设置工单状态 未生成工单;已生成工单未执行
+                if (distance.isShouldWorkOrder() && distance.isRunningWorkOrder()) {
+                    distance.setOrderStatus("已生成工单未执行");
+                }
+                if (distance.isShouldWorkOrder() && !distance.isRunningWorkOrder()) {
+                    distance.setOrderStatus("未生成工单");
+                }
+            });
+        }
+        // 导出 Excel
+        ExcelUtils.write(response, "保养查询.xls", "保养查询", IotDeviceExportRespVO.class,
+                deviceDistancesResult);
+    }
+
 }

+ 232 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotDeviceExportRespVO.java

@@ -0,0 +1,232 @@
+package cn.iocoder.yudao.module.pms.controller.admin.vo;
+
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicematerial.vo.IotDeviceMaterialRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.vo.IotDeviceRunLogRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotmaintenancebom.vo.IotMaintenanceBomRespVO;
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Schema(description = "管理后台 - 保养查询 导出 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotDeviceExportRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "6797")
+    private Long id;
+
+    @Schema(description = "资产编码", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("设备编码")
+    private String deviceCode;
+
+    @Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
+    @ExcelProperty("设备名称")
+    private String deviceName;
+
+    @Schema(description = "距离保养时间 单位可能是 H D KM")
+    @ExcelProperty("距离保养")
+    private String mainDistance;
+
+    @Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Long brand;
+
+    @Schema(description = "规格型号")
+    private String model;
+
+    @Schema(description = "所在部门", requiredMode = Schema.RequiredMode.REQUIRED, example = "8581")
+    private Long deptId;
+
+    @Schema(description = "设备状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
+    private String deviceStatus;
+
+    @Schema(description = "设备状态 标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
+    @ExcelProperty("设备状态")
+    private String deviceStatusLabel;
+
+    @Schema(description = "工单状态 已生成工单未执行 未生成工单", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
+    @ExcelProperty("工单状态")
+    private String orderStatus;
+
+    @Schema(description = "资产性质", requiredMode = Schema.RequiredMode.REQUIRED)
+    private String assetProperty;
+
+    @Schema(description = "图片", example = "https://www.iocoder.cn")
+    private String picUrl;
+
+    @Schema(description = "备注", example = "你说的对")
+    private String remark;
+
+    @Schema(description = "制造商id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1695")
+    private Long manufacturerId;
+
+    @Schema(description = "供应商id", example = "18330")
+    private Long supplierId;
+
+    @Schema(description = "生产日期", requiredMode = Schema.RequiredMode.REQUIRED)
+    private LocalDateTime manDate;
+
+    @Schema(description = "铭牌信息")
+    private String nameplate;
+
+    @Schema(description = "质保到期")
+    private LocalDateTime expires;
+
+    @Schema(description = "采购/租赁价格", example = "14766")
+    private Integer plPrice;
+
+    @Schema(description = "采购/租赁日期")
+    private LocalDateTime plDate;
+
+    @Schema(description = "折旧年限")
+    private Integer plYear;
+
+    @Schema(description = "折旧开始日期")
+    private LocalDateTime plStartDate;
+
+    @Schema(description = "已提折旧月数")
+    private Integer plMonthed;
+
+    @Schema(description = "已提折旧金额")
+    private Double plAmounted;
+
+    @Schema(description = "剩余金额")
+    private Double remainAmount;
+
+    @Schema(description = "资料分类id", example = "5597")
+    private Long infoId;
+
+    @Schema(description = "资料类型", example = "1")
+    private String infoType;
+
+    @Schema(description = "资料名称", example = "王五")
+    private String infoName;
+
+    @Schema(description = "资料备注", example = "你说的对")
+    private String infoRemark;
+
+    @Schema(description = "资料附件", example = "https://www.iocoder.cn")
+    private String infoUrl;
+
+    @Schema(description = "动态模板信息")
+    private String templateJson;
+
+    @Schema(description = "资产类别")
+    private Long assetClass;
+    @Schema(description = "资产类别名称")
+    private String assetClassName;
+    @Schema(description = "创建时间")
+    private LocalDateTime createTime;
+    @Schema(description = "部门名称")
+    @ExcelProperty("部门名称")
+    private String deptName;
+    @Schema(description = "品牌型号")
+    private String brandName;
+    @Schema(description = "制造商名称")
+    private String zzName;
+    @Schema(description = "供应商名称")
+    private String supplierName;
+    @Schema(description = "规格名称")
+    private String modelName;
+
+    @Schema(description = "责任人")
+    private String chargeName;
+
+    /**
+     * 设备关联bom相关信息
+     */
+    @Schema(description = "bom节点id")
+    private String bomNodeId;
+    @Schema(description = "bom节点名称")
+    private String name;
+    @Schema(description = "bom节点编码 累计运行时长属性名称")
+    private String code;
+    @Schema(description = "bom节点类型 累计运行公里数属性名称")
+    private String type;
+    @Schema(description = "设备分类BOM同步状态 1已同步 0未同步")
+    private Integer bomSyncStatus;
+    @Schema(description = "当前设备是否已经配置了保养BOM")
+    private boolean hasSetMaintenanceBom = false;
+
+    /**
+     * 计算字段
+     */
+    @Schema(description = "设备累计运行里程")
+    private BigDecimal totalMileage;
+    @Schema(description = "设备累计运行时间")
+    private BigDecimal totalRunTime;
+    @Schema(description = "是否在线")
+    private Integer ifInline;
+
+    @Schema(description = "最后在线时间")
+    private String lastInlineTime;
+
+    @Schema(description = "负责人姓名 逗号分隔")
+    @ExcelProperty("责任人")
+    private String responsibleNames;
+
+    @Schema(description = "排序字段")
+    private Integer sortColumn;
+
+    @Schema(description = "保养工单id")
+    private String workOrderId;
+    @Schema(description = "保养计划id")
+    private String planId;
+
+    @Schema(description = "车辆id")
+    private Long carId;
+
+    @Schema(description = "经度")
+    private Double lng;
+    @Schema(description = "纬度")
+    private Double lat;
+    private String location;
+
+    /**
+     * 扩展属性
+     */
+    @Schema(description = "模板中涉及多个累计运转时长的属性集合")
+    private List<IotDeviceRunLogRespVO> timeAccumulatedAttrs;
+
+    @Schema(description = "模板中涉及多个累计运行公里数的属性集合")
+    private List<IotDeviceRunLogRespVO> mileageAccumulatedAttrs;
+
+    @Schema(description = "启用日期")
+    private String enableDate;
+
+    @Schema(description = "设备对应的 BOM分组 最短保养距离集合")
+    private List<IotMaintenanceBomRespVO> groupBomDistances;
+
+    @Schema(description = "生产厂家")
+    private String manufacturer;
+
+    @Schema(description = "根据设备保养项规则 应该生成保养工单 标识")
+    private boolean shouldWorkOrder = false;
+
+    @Schema(description = "存在正在执行中的保养工单 标识")
+    private boolean runningWorkOrder = false;
+
+    private String vehicleName;
+    private String assetOwnership;
+    private String useProject;
+
+    @Schema(description = "保养/维修项关联的设备bom物料列表")
+    private List<IotDeviceMaterialRespVO> deviceBomMaterials;
+
+    @Schema(description = "编码分类")
+    private String yfClass;
+
+    @Schema(description = "油服设备编码")
+    private String yfDeviceCode;
+    private String carOnline;
+    private String company;
+    private String project;
+
+    private String carNo;
+    private String address;
+    private String deviceNo;
+}