|
@@ -2,6 +2,7 @@ package com.cpp.web.service.overhaulplan.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
|
|
import com.cpp.web.domain.overhaulplan.OverhaulPlan;
|
|
import com.cpp.web.domain.overhaulplan.OverhaulPlan;
|
|
import com.cpp.web.domain.overhaulplan.OverhaulPlanRecords;
|
|
import com.cpp.web.domain.overhaulplan.OverhaulPlanRecords;
|
|
import com.cpp.web.domain.station.ElectricField;
|
|
import com.cpp.web.domain.station.ElectricField;
|
|
@@ -10,8 +11,6 @@ import com.cpp.web.service.overhaulplan.OverhaulPlanRecordsService;
|
|
import com.cpp.web.service.overhaulplan.OverhaulPlanService;
|
|
import com.cpp.web.service.overhaulplan.OverhaulPlanService;
|
|
import com.cpp.web.service.station.ElectricFieldService;
|
|
import com.cpp.web.service.station.ElectricFieldService;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
-import org.apache.poi.ss.formula.functions.T;
|
|
|
|
-import org.springframework.security.core.parameters.P;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
@@ -72,8 +71,12 @@ public class OverhaulPlanServiceImpl extends ServiceImpl<OverhaulPlanMapper, Ove
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<OverhaulPlan> findByStationCode(String stationCode) {
|
|
public List<OverhaulPlan> findByStationCode(String stationCode) {
|
|
- List<OverhaulPlan> overhaulPlanList = overhaulPlanMapper.findBysStationCode(stationCode);
|
|
|
|
- return overhaulPlanList;
|
|
|
|
|
|
+ QueryWrapper<OverhaulPlan> wrapper = new QueryWrapper<>();
|
|
|
|
+ if (null != stationCode && !"".equals(stationCode)){
|
|
|
|
+ wrapper.eq("station_code",stationCode);
|
|
|
|
+ }
|
|
|
|
+ wrapper.eq("status",1);
|
|
|
|
+ return list(wrapper);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -91,15 +94,22 @@ public class OverhaulPlanServiceImpl extends ServiceImpl<OverhaulPlanMapper, Ove
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 返回修正后数据
|
|
|
|
|
|
+ * 返回修正后数据
|
|
|
|
+ *
|
|
* @param list
|
|
* @param list
|
|
- * @return
|
|
|
|
* @param <T>
|
|
* @param <T>
|
|
|
|
+ * @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public <T> List<T> getCorrectionData(List<T> list) {
|
|
|
|
|
|
+ public <T> List<T> getCorrectionData(List<T> list, String fileType, String fileName) {
|
|
|
|
+
|
|
List<T> resultList = new ArrayList<>();
|
|
List<T> resultList = new ArrayList<>();
|
|
BigDecimal electricFieldCapacity = BigDecimal.ZERO;
|
|
BigDecimal electricFieldCapacity = BigDecimal.ZERO;
|
|
|
|
+ String forecastModel = "";
|
|
|
|
+ String stationCode = "";
|
|
|
|
+ Long id = null;
|
|
|
|
+ Date useStartTime = null;
|
|
|
|
+ Date useEndTime = null;
|
|
for (T tList : list) {
|
|
for (T tList : list) {
|
|
try {
|
|
try {
|
|
Class<?> childClass = tList.getClass();
|
|
Class<?> childClass = tList.getClass();
|
|
@@ -111,7 +121,7 @@ public class OverhaulPlanServiceImpl extends ServiceImpl<OverhaulPlanMapper, Ove
|
|
// 场站编号
|
|
// 场站编号
|
|
Field stationCodeField = superClass.getDeclaredField("stationCode");
|
|
Field stationCodeField = superClass.getDeclaredField("stationCode");
|
|
stationCodeField.setAccessible(true);
|
|
stationCodeField.setAccessible(true);
|
|
- String stationCode = (String) stationCodeField.get(tList);
|
|
|
|
|
|
+ stationCode = (String) stationCodeField.get(tList);
|
|
// 获取场站装机
|
|
// 获取场站装机
|
|
ElectricField electricField = electricFieldService.findByStationCode(stationCode);
|
|
ElectricField electricField = electricFieldService.findByStationCode(stationCode);
|
|
if (null != electricField) {
|
|
if (null != electricField) {
|
|
@@ -127,47 +137,44 @@ public class OverhaulPlanServiceImpl extends ServiceImpl<OverhaulPlanMapper, Ove
|
|
// 预测模型
|
|
// 预测模型
|
|
Field forecastModelField = childClass.getDeclaredField("forecastModel");
|
|
Field forecastModelField = childClass.getDeclaredField("forecastModel");
|
|
forecastModelField.setAccessible(true);
|
|
forecastModelField.setAccessible(true);
|
|
- String forecastModel = (String)forecastModelField.get(tList);
|
|
|
|
- // 根据时间查询检修计划
|
|
|
|
- List<OverhaulPlan> overhaulPlanList = this.findByStationCodeAndTimeBetween(startTime, stationCode);
|
|
|
|
|
|
+ forecastModel = (String) forecastModelField.get(tList);
|
|
|
|
+ // 根据时间查询使用中的检修计划
|
|
|
|
+ List<OverhaulPlan> overhaulPlanList = findByStationCodeAndTimeBetween(startTime, stationCode);
|
|
if (overhaulPlanList.size() > 0) {
|
|
if (overhaulPlanList.size() > 0) {
|
|
|
|
+ int flag = 0;
|
|
|
|
+ if (flag == 0) {
|
|
|
|
+ useStartTime = startTime;
|
|
|
|
+ }
|
|
|
|
+ useEndTime = startTime;
|
|
|
|
+ id = overhaulPlanList.get(0).getId();
|
|
BigDecimal overCapacity = overhaulPlanList.get(0).getOverhaulCapacity();
|
|
BigDecimal overCapacity = overhaulPlanList.get(0).getOverhaulCapacity();
|
|
openCapcityField.set(tList, electricFieldCapacity.subtract(overCapacity));
|
|
openCapcityField.set(tList, electricFieldCapacity.subtract(overCapacity));
|
|
- // 预测数据
|
|
|
|
|
|
+ // 预测数据(短期or超短期)
|
|
Field fpValueFiled = childClass.getDeclaredField("fpValue");
|
|
Field fpValueFiled = childClass.getDeclaredField("fpValue");
|
|
fpValueFiled.setAccessible(true);
|
|
fpValueFiled.setAccessible(true);
|
|
BigDecimal fpValue = (BigDecimal) fpValueFiled.get(tList);
|
|
BigDecimal fpValue = (BigDecimal) fpValueFiled.get(tList);
|
|
// 开机/装机
|
|
// 开机/装机
|
|
BigDecimal ratio = (electricFieldCapacity.subtract(overCapacity)).divide(electricFieldCapacity, 2, RoundingMode.HALF_UP);
|
|
BigDecimal ratio = (electricFieldCapacity.subtract(overCapacity)).divide(electricFieldCapacity, 2, RoundingMode.HALF_UP);
|
|
fpValueFiled.set(tList, fpValue.multiply(ratio));
|
|
fpValueFiled.set(tList, fpValue.multiply(ratio));
|
|
- // 查询检修记录
|
|
|
|
- OverhaulPlanRecords overhaulPlanRecord = overhaulPlanRecordsService.findByStationCodeAndForecastModel(stationCode,forecastModel,overhaulPlanList.get(0).getStartTime(),overhaulPlanList.get(0).getEndTime());
|
|
|
|
- if (null != overhaulPlanRecord) {
|
|
|
|
- overhaulPlanRecord.setUseNum(overhaulPlanRecord.getUseNum() + 1);
|
|
|
|
- overhaulPlanRecord.setUpdateTime(new Date());
|
|
|
|
- overhaulPlanRecordsService.saveOrUpdate(overhaulPlanRecord);
|
|
|
|
- // 使用次数 +1
|
|
|
|
- }else {
|
|
|
|
- OverhaulPlanRecords overhaulPlanRecords = new OverhaulPlanRecords();
|
|
|
|
- overhaulPlanRecords.setOverhaulCapacity(overhaulPlanList.get(0).getOverhaulCapacity());
|
|
|
|
- overhaulPlanRecords.setStartTime(overhaulPlanList.get(0).getStartTime());
|
|
|
|
- overhaulPlanRecords.setEndTime(overhaulPlanList.get(0).getEndTime());
|
|
|
|
- overhaulPlanRecords.setUseNum(overhaulPlanRecords.getUseNum() + 1);
|
|
|
|
- overhaulPlanRecords.setStationCode(stationCode);
|
|
|
|
- overhaulPlanRecords.setForecastModel(forecastModel);
|
|
|
|
- overhaulPlanRecords.setCreateTime(new Date());
|
|
|
|
- overhaulPlanRecordsService.saveOrUpdate(overhaulPlanRecords);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
// 设置开机为装机
|
|
// 设置开机为装机
|
|
- openCapcityField.set(tList,electricFieldCapacity);
|
|
|
|
|
|
+ openCapcityField.set(tList, electricFieldCapacity);
|
|
}
|
|
}
|
|
resultList.add(tList);
|
|
resultList.add(tList);
|
|
|
|
+
|
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (null != id) {
|
|
|
|
+ OverhaulPlanRecords overhaulPlanRecords = new OverhaulPlanRecords();
|
|
|
|
+ overhaulPlanRecords.setForecastModel(forecastModel);
|
|
|
|
+ overhaulPlanRecords.setStationCode(stationCode);
|
|
|
|
+ overhaulPlanRecords.setOpId(id);
|
|
|
|
+ overhaulPlanRecords.setDetails(fileType + ":开始时间:" + useStartTime + "~结束时间:" + useEndTime);
|
|
|
|
+ overhaulPlanRecords.setForecastType(FileTypeEnum.valueOf(fileType));
|
|
|
|
+ overhaulPlanRecordsService.save(overhaulPlanRecords);
|
|
|
|
+ }
|
|
return resultList;
|
|
return resultList;
|
|
}
|
|
}
|
|
}
|
|
}
|