Sfoglia il codice sorgente

修正按工单类型查询问题

wangchenghong 3 anni fa
parent
commit
90d267da78

+ 14 - 6
src/main/java/com/persagy/apm/energy/report/common/service/impl/CommonServiceImpl.java

@@ -12,6 +12,7 @@ import com.persagy.apm.energy.report.common.utils.DataUtils;
 import com.persagy.apm.energy.report.common.utils.DateUtils;
 import com.persagy.apm.energy.report.common.utils.SpringContextHolder;
 import com.persagy.apm.energy.report.common.vo.PlatformAreaInfoVO;
+import com.persagy.apm.energy.report.common.vo.WorkOrderVO;
 import com.persagy.apm.energy.report.emsweather.service.EMSWeatherWebService;
 import com.persagy.apm.energy.report.environment.model.dto.BatchQueryEnvListByParamDTO;
 import com.persagy.apm.energy.report.environment.service.IEnvironmentWebService;
@@ -325,23 +326,30 @@ public class CommonServiceImpl implements CommonService {
             }
             hotelProjectEnergyWorkerOrderInfo.setInitiativeCount(initiativeCount);
             List<String> workOrderIdList = new ArrayList<>();
+            List<WorkOrderVO> workOrderVOList = new ArrayList<>();
             for (WorkOrder workOrder : energySaveRealFinishTimeWorkList) {
                 workOrderIdList.add(workOrder.getOrderId());
+                WorkOrderVO vo = new WorkOrderVO();
+                vo.setOrderId(workOrder.getOrderId());
+                vo.setOrderName(workOrder.getWoName());
+                if (!StringUtils.isEmpty(workOrder.getRealFinishTime())) {
+                    vo.setRealFinishTime(DateUtils.str2Date(workOrder.getRealFinishTime(), DateUtils.SDFSECOND));
+                }
+                workOrderVOList.add(vo);
             }
             // {工单id:工单节能量}
             Map<String, Double> workId_energyMap = iEquipRunManagerService.getEnergySaveWorderMap(workOrderIdList);
             Map<String, Integer> sortMap = new HashMap<>();
             sortMap.put("realFinishTime", -1);
-            DataUtils.sort(energySaveRealFinishTimeWorkList, sortMap);
+            DataUtils.sort(workOrderVOList, sortMap);
             List<HotelProjectEnergyWorkOrderItem> hotelProjectEnergyWorkOrderItemList = new ArrayList<>();
             Double totalEnergySave = null;
-            for (WorkOrder workOrder : energySaveRealFinishTimeWorkList) {
+            for (WorkOrderVO workOrder : workOrderVOList) {
                 HotelProjectEnergyWorkOrderItem hotelProjectEnergyWorkOrderItem = new HotelProjectEnergyWorkOrderItem();
-                hotelProjectEnergyWorkOrderItem.setWorkName(workOrder.getWoName());
+                hotelProjectEnergyWorkOrderItem.setWorkName(workOrder.getOrderName());
                 String completeTimeStr = "";
                 if (!StringUtils.isEmpty(workOrder.getRealFinishTime())) {
-                    Date completeTime = DateUtils.str2Date(workOrder.getRealFinishTime(), DateUtils.SDFSECOND);
-                    completeTimeStr = DateUtils.date2Str(completeTime, DateUtils.SDF_DOT_DAY);
+                    completeTimeStr = DateUtils.date2Str(workOrder.getRealFinishTime(), DateUtils.SDF_DOT_DAY);
                 }
                 hotelProjectEnergyWorkOrderItem.setCompletedTime(completeTimeStr);
                 hotelProjectEnergyWorkOrderItem.setEnergySaved(workId_energyMap.get(workOrder.getOrderId()));
@@ -354,7 +362,7 @@ public class CommonServiceImpl implements CommonService {
             hotelProjectEnergyWorkerOrderInfo.setProjectName(null == reportProjectInfo ? "" : reportProjectInfo.getProjectName());
 
         } catch (Exception e) {
-
+            log.error("获取HotelProjectEnergyWorkerOrderInfo的数据失败:", e);
         }
         return hotelProjectEnergyWorkerOrderInfo;
     }

+ 20 - 0
src/main/java/com/persagy/apm/energy/report/common/vo/WorkOrderVO.java

@@ -0,0 +1,20 @@
+package com.persagy.apm.energy.report.common.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@ApiModel
+@Data
+public class WorkOrderVO {
+    @ApiModelProperty("工单id")
+    private String orderId;
+
+    @ApiModelProperty("工单名称")
+    private String orderName;
+
+    @ApiModelProperty("工单实际完成时间")
+    private Date realFinishTime;
+}

+ 1 - 1
src/main/java/com/persagy/apm/energy/report/workorder/service/impl/IWorkOrderWebServiceImpl.java

@@ -70,7 +70,7 @@ public class IWorkOrderWebServiceImpl implements IWorkOrderWebService {
         }
         if (StringUtils.isNotEmpty(orderType)) {
             List<String> orderTypeList = JSONObject.parseArray(orderType, String.class);
-            queryBuilder.must(QueryBuilders.termsQuery("order_type", orderTypeList));
+            queryBuilder.must(QueryBuilders.termsQuery("order_type.keyword", orderTypeList));
         }
 
         if (StringUtils.isNotEmpty(orderState)) {