Browse Source

提取常量类、修正查询环境数据逻辑

wangchenghong 4 years ago
parent
commit
02ee02bf39

+ 19 - 0
src/main/java/com/persagy/apm/energy/report/common/DataConstants.java

@@ -0,0 +1,19 @@
+package com.persagy.apm.energy.report.common;
+
+/**
+ * 常量类
+ *
+ **/
+public class DataConstants {
+
+    public static final String USER_ID = "systemId";
+
+    public static final String PD = "123";
+
+    public static final String LOGIN_DEVICE = "PC";
+
+    public static final String ENV_TYPE_ID = "Temp";
+
+    public static final String ENV_PARENT_TYPE_ID = "Humiture";
+
+}

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

@@ -1,6 +1,8 @@
 package com.persagy.apm.energy.report.common.service.impl;
 
+import com.persagy.apm.common.model.dto.PoemsPuser;
 import com.persagy.apm.common.response.PoemsFeignResponse;
+import com.persagy.apm.energy.report.common.DataConstants;
 import com.persagy.apm.energy.report.common.service.CommonService;
 import com.persagy.apm.energy.report.saasweb.model.dto.QueryProjectDTO;
 import com.persagy.apm.energy.report.saasweb.model.vo.PoemsProjectVO;
@@ -22,7 +24,15 @@ public class CommonServiceImpl implements CommonService {
 
     @Override
     public List<String> getPjNameByPjId(List<String> pjIdList) {
+        if(CollectionUtils.isEmpty(pjIdList)){
+            return new ArrayList<>();
+        }
         QueryProjectDTO queryProjectDTO = new QueryProjectDTO();
+        PoemsPuser poemsPuser = new PoemsPuser();
+        poemsPuser.setUserId(DataConstants.USER_ID);
+        poemsPuser.setLoginDevice(DataConstants.LOGIN_DEVICE);
+        poemsPuser.setPd(DataConstants.PD);
+        queryProjectDTO.setPuser(poemsPuser);
         PoemsFeignResponse<PoemsProjectVO> projectsResponse = saasWebClientWrapper.queryProjects(queryProjectDTO);
         List<PoemsProjectVO> projectVOList = projectsResponse.getContent();
         if (!CollectionUtils.isEmpty(projectVOList)) {
@@ -31,10 +41,10 @@ public class CommonServiceImpl implements CommonService {
                 if (!pjIdList.contains(poemsProjectVO.getProjectId())) {
                     continue;
                 }
-                pjNameList.add(poemsProjectVO.getProjectName());
+                pjNameList.add(poemsProjectVO.getProjectLocalName());
             }
             return pjNameList;
         }
-        return null;
+        return new ArrayList<>();
     }
 }

+ 4 - 3
src/main/java/com/persagy/apm/energy/report/environment/service/impl/IEnvironmentWebServiceImpl.java

@@ -1,6 +1,7 @@
 package com.persagy.apm.energy.report.environment.service.impl;
 
 import com.persagy.apm.common.response.PoemsFeignResponse;
+import com.persagy.apm.energy.report.common.DataConstants;
 import com.persagy.apm.energy.report.common.dto.QueryAreaPlatformParamDTO;
 import com.persagy.apm.energy.report.common.dto.QueryPjPlatformParamDTO;
 import com.persagy.apm.energy.report.common.service.CommonService;
@@ -35,7 +36,7 @@ public class IEnvironmentWebServiceImpl implements IEnvironmentWebService {
         Date reportDate = queryPjPlatformParamDTO.getReportDate();
         Date startDate = DateUtils.getFirstDayOfYear(reportDate);
         while (startDate.before(DateUtils.getMonthOff(reportDate, 1))) {
-            date_rateMap.put(startDate, getEnvAvgRate(queryPjPlatformParamDTO.getProjectId(), reportDate));
+            date_rateMap.put(startDate, getEnvAvgRate(queryPjPlatformParamDTO.getProjectId(), startDate));
             startDate = DateUtils.getMonthOff(startDate, 1);
         }
         List<Double> monthlySummaries = date_rateMap.values().stream().collect(Collectors.toList());
@@ -47,8 +48,8 @@ public class IEnvironmentWebServiceImpl implements IEnvironmentWebService {
         try {
             QueryEnvListByParamDTO paramDTO = new QueryEnvListByParamDTO();
             paramDTO.setProjectId(pjId);
-            paramDTO.setEnvTypeId("Temp");
-            paramDTO.setEnvParentTypeId("Humiture");
+            paramDTO.setEnvTypeId(DataConstants.ENV_TYPE_ID);
+            paramDTO.setEnvParentTypeId(DataConstants.ENV_PARENT_TYPE_ID);
             paramDTO.setStartTime(DateUtils.date2Str(reportDate, DateUtils.SDF_SECOND));
             paramDTO.setEndTime(DateUtils.date2Str(DateUtils.getMonthOff(reportDate, 1), DateUtils.SDF_SECOND));
             PoemsFeignResponse<EnvAvgRateVO> response = environmentWebClientWrapper.listWorkOrderByParam(paramDTO);

+ 1 - 1
src/main/java/com/persagy/apm/energy/report/iotdataanalysis/service/impl/IDataAnalysisWebServiceImpl.java

@@ -36,7 +36,7 @@ public class IDataAnalysisWebServiceImpl implements IDataAnalysisWebService {
         while (startDate.before(DateUtils.getMonthOff(reportDate, 1))) {
             Double bianSunRate = null;
             Double zongZhiRate = null;
-            getBianSunAndZongZhiRate(queryPjPlatformParamDTO.getUserId(), queryPjPlatformParamDTO.getGroupCode(), queryPjPlatformParamDTO.getProjectId(), bianSunRate, zongZhiRate, reportDate);
+            getBianSunAndZongZhiRate(queryPjPlatformParamDTO.getUserId(), queryPjPlatformParamDTO.getGroupCode(), queryPjPlatformParamDTO.getProjectId(), bianSunRate, zongZhiRate, startDate);
             biansun_date_rateMap.put(startDate, bianSunRate);
             zongzhi_date_rateMap.put(startDate, zongZhiRate);
             startDate = DateUtils.getMonthOff(startDate, 1);

+ 5 - 4
src/main/java/com/persagy/apm/energy/report/manualfilling/controller/ManualFillingController.java

@@ -4,6 +4,7 @@ import com.persagy.apm.common.response.ApmResponseUpsertVO;
 import com.persagy.apm.common.response.CommonResult;
 import com.persagy.apm.common.response.PageList;
 import com.persagy.apm.common.utils.ResultHelper;
+import com.persagy.apm.energy.report.common.DataConstants;
 import com.persagy.apm.energy.report.manualfilling.model.dto.QueryEnergyItemDataDTO;
 import com.persagy.apm.energy.report.manualfilling.model.dto.SaveEnergyItemDataDTO;
 import com.persagy.apm.energy.report.manualfilling.model.vo.EnergyItemInfoVo;
@@ -31,8 +32,8 @@ public class ManualFillingController {
     @ApiOperation(value = "查询报告能耗分项列表")
     @PostMapping("/query")
     public CommonResult<PageList<EnergyItemInfoVo>> queryEnergyItemDataList(
-            @Valid @RequestBody QueryEnergyItemDataDTO queryEnergyItemDataDTO, @RequestParam(value = "userId", defaultValue = "systemId") String userId,
-            @RequestParam(value = "loginDevice", defaultValue = "PC") String loginDevice, @RequestParam(value = "pd", defaultValue = "123") String pd) {
+            @Valid @RequestBody QueryEnergyItemDataDTO queryEnergyItemDataDTO, @RequestParam(value = "userId", defaultValue = DataConstants.USER_ID) String userId,
+            @RequestParam(value = "loginDevice", defaultValue = DataConstants.LOGIN_DEVICE) String loginDevice, @RequestParam(value = "pd", defaultValue = DataConstants.PD) String pd) {
         List<EnergyItemInfoVo> energyItemInfoVoList = iEnergyItemDataService.queryEnergyItemDataList(queryEnergyItemDataDTO);
         return ResultHelper.multi(energyItemInfoVoList);
     }
@@ -40,8 +41,8 @@ public class ManualFillingController {
     @ApiOperation(value = "保存能耗分项数值")
     @PostMapping("/save")
     public CommonResult<ApmResponseUpsertVO> updateReportBusinessDetail(
-            @Valid @RequestBody SaveEnergyItemDataDTO saveEnergyItemDataDTO, @RequestParam(value = "userId", defaultValue = "systemId") String userId,
-            @RequestParam(value = "loginDevice", defaultValue = "PC") String loginDevice, @RequestParam(value = "pd", defaultValue = "123") String pd) {
+            @Valid @RequestBody SaveEnergyItemDataDTO saveEnergyItemDataDTO, @RequestParam(value = "userId", defaultValue = DataConstants.USER_ID) String userId,
+            @RequestParam(value = "loginDevice", defaultValue = DataConstants.LOGIN_DEVICE) String loginDevice, @RequestParam(value = "pd", defaultValue = DataConstants.PD) String pd) {
         iEnergyItemDataService.saveEnergyItemData(saveEnergyItemDataDTO);
         return ResultHelper.single(new ApmResponseUpsertVO());
     }

+ 2 - 0
src/main/java/com/persagy/apm/energy/report/saasweb/model/vo/PoemsProjectVO.java

@@ -17,6 +17,8 @@ public class PoemsProjectVO {
     private String projectName;
     @ApiModelProperty(value = "项目本地编码")
     private String projectLocalID;
+    @ApiModelProperty(value = "项目本地名称")
+    private String projectLocalName;
     @ApiModelProperty(value = "项目功能类型")
     private String functionType;
     @ApiModelProperty(value = "项目功能类型名称")

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

@@ -34,7 +34,7 @@ public class IWorkOrderWebServiceImpl implements IWorkOrderWebService {
         Date reportDate = queryPjPlatformParamDTO.getReportDate();
         Date startDate = DateUtils.getFirstDayOfYear(reportDate);
         while (startDate.before(DateUtils.getMonthOff(reportDate, 1))) {
-            date_rateMap.put(startDate, getWorkOrderCompleteRate(queryPjPlatformParamDTO.getProjectId(), reportDate, queryPjPlatformParamDTO.getUserId()));
+            date_rateMap.put(startDate, getWorkOrderCompleteRate(queryPjPlatformParamDTO.getProjectId(), startDate, queryPjPlatformParamDTO.getUserId()));
             startDate = DateUtils.getMonthOff(startDate, 1);
         }
         List<Double> monthlySummaries = date_rateMap.values().stream().collect(Collectors.toList());