|
@@ -78,6 +78,7 @@ import com.platform.service.util.ExecuteSql;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.ibatis.exceptions.TooManyResultsException;
|
|
|
+import org.apache.poi.ss.formula.functions.CalendarFieldFunction;
|
|
|
import org.springframework.core.env.Environment;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
@@ -218,7 +219,18 @@ public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, Sb
|
|
|
record.setSbName("G01");
|
|
|
List<RemoteDegreeLogVO> list = remoteDegreeLogMapper.selectList(record);
|
|
|
JSONArray jSONArray = new JSONArray();
|
|
|
- if (isDay) {//
|
|
|
+ if (isDay) {// 日报,需要减去上个小时的
|
|
|
+ // 找到前天晚上23点的
|
|
|
+ RemoteDegreeLogDTO lastDay = BeanConverterUtil.copyObjectProperties(record, RemoteDegreeLogDTO.class);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.set(lastDay.getYear(), lastDay.getMonth() - 1, lastDay.getDay()-1);
|
|
|
+ DateUtils.getLastDay(calendar);
|
|
|
+ lastDay.setYear(calendar.get(Calendar.YEAR));
|
|
|
+ lastDay.setMonth(calendar.get(Calendar.MONTH) + 1);
|
|
|
+ lastDay.setDay(calendar.get(Calendar.DAY_OF_MONTH));
|
|
|
+ lastDay.setHour(23);
|
|
|
+ List<RemoteDegreeLogVO> lastList = remoteDegreeLogMapper.selectList(lastDay);
|
|
|
+
|
|
|
for (int i = 0; i < 24; i++) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("time", i + ":00");
|
|
@@ -228,19 +240,45 @@ public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, Sb
|
|
|
dictJsonObject.put("name", dict.getLabel());
|
|
|
BigDecimal positiveTotal = new BigDecimal(0.00);// 正向有功
|
|
|
BigDecimal negativeTotal = new BigDecimal(0.00);// 正向无功
|
|
|
- for (RemoteDegreeLogVO log : list) {
|
|
|
- if (log.getLine().toString().equals(dict.getValue())) {
|
|
|
- if (log.getHour().equals(i)) {
|
|
|
- if (log.getType().equals(1)) {
|
|
|
- positiveTotal = positiveTotal.add(new BigDecimal(log.getResult()));
|
|
|
+ for (RemoteDegreeLogVO degreeLog : list) {
|
|
|
+ if (degreeLog.getLine().toString().equals(dict.getValue())) {
|
|
|
+ if (degreeLog.getHour().equals(i)) {
|
|
|
+ if (degreeLog.getType().equals(1)) {
|
|
|
+ positiveTotal = positiveTotal.add(new BigDecimal(degreeLog.getResult()));
|
|
|
+ // 找到上个时间
|
|
|
+ if(i == 0){// 从昨天找
|
|
|
+ Optional<RemoteDegreeLogVO> lastR = lastList.stream().filter(item -> item.getPositionNum().equals(degreeLog.getPositionNum())).findFirst();
|
|
|
+ if(lastR.isPresent()){
|
|
|
+ log.info(lastR.get().toString());
|
|
|
+ positiveTotal = positiveTotal.subtract(new BigDecimal(lastR.get().getResult()));
|
|
|
+ }
|
|
|
+ }else{// 从今天上个时间找,减去上个小时的数据
|
|
|
+ Optional<RemoteDegreeLogVO> lastR = list.stream().filter(item -> item.getPositionNum().equals(degreeLog.getPositionNum()) && item.getHour().equals(degreeLog.getHour()-1)).findFirst();
|
|
|
+ if(lastR.isPresent()){
|
|
|
+ positiveTotal = positiveTotal.subtract(new BigDecimal(lastR.get().getResult()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dictJsonObject.put("positive", positiveTotal.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue());
|
|
|
} else {
|
|
|
- negativeTotal = negativeTotal.add(new BigDecimal(log.getResult()));
|
|
|
+ negativeTotal = negativeTotal.add(new BigDecimal(degreeLog.getResult()));
|
|
|
+ // 找到上个时间
|
|
|
+ if(i == 0){// 从昨天找
|
|
|
+ Optional<RemoteDegreeLogVO> lastR = lastList.stream().filter(item -> item.getPositionNum().equals(degreeLog.getPositionNum())).findFirst();
|
|
|
+ if(lastR.isPresent()){
|
|
|
+ log.info(lastR.get().toString());
|
|
|
+ negativeTotal = negativeTotal.subtract(new BigDecimal(lastR.get().getResult()));
|
|
|
+ }
|
|
|
+ }else{// 从今天上个时间找,减去上个小时的数据
|
|
|
+ Optional<RemoteDegreeLogVO> lastR = list.stream().filter(item -> item.getPositionNum().equals(degreeLog.getPositionNum()) && item.getHour().equals(degreeLog.getHour()-1)).findFirst();
|
|
|
+ if(lastR.isPresent()){
|
|
|
+ negativeTotal = negativeTotal.subtract(new BigDecimal(lastR.get().getResult()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dictJsonObject.put("negative", negativeTotal.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- dictJsonObject.put("positive", positiveTotal.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue());
|
|
|
- dictJsonObject.put("negative", negativeTotal.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue());
|
|
|
lineArray.add(dictJsonObject);
|
|
|
}
|
|
|
jsonObject.put("lines", lineArray);
|
|
@@ -258,16 +296,16 @@ public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, Sb
|
|
|
dictJsonObject.put("name", dict.getLabel());
|
|
|
BigDecimal positiveTotal = new BigDecimal(0.00);// 正向有功
|
|
|
BigDecimal negativeTotal = new BigDecimal(0.00);// 正向无功,不需要吗,后面可以删除,先保存
|
|
|
- for (RemoteDegreeLogVO log : list) {
|
|
|
- if (log.getLine() == null) {
|
|
|
- throw new BusinessException("设备未设置电力线路, 设备名称:" + log.getSbName() + ", 设备编号:" + log.getSbNo());
|
|
|
+ for (RemoteDegreeLogVO degreeLog : list) {
|
|
|
+ if (degreeLog.getLine() == null) {
|
|
|
+ throw new BusinessException("设备未设置电力线路, 设备名称:" + degreeLog.getSbName() + ", 设备编号:" + degreeLog.getSbNo());
|
|
|
}
|
|
|
- if (log.getLine().toString().equals(dict.getValue())) {
|
|
|
- if (log.getDay().equals(i)) {
|
|
|
- if (log.getType().equals(1)) {
|
|
|
- positiveTotal = positiveTotal.add(new BigDecimal(log.getResult()));
|
|
|
+ if (degreeLog.getLine().toString().equals(dict.getValue())) {
|
|
|
+ if (degreeLog.getDay().equals(i)) {
|
|
|
+ if (degreeLog.getType().equals(1)) {
|
|
|
+ positiveTotal = positiveTotal.add(new BigDecimal(degreeLog.getResult()));
|
|
|
} else {
|
|
|
- negativeTotal = negativeTotal.add(new BigDecimal(log.getResult()));
|
|
|
+ negativeTotal = negativeTotal.add(new BigDecimal(degreeLog.getResult()));
|
|
|
}
|
|
|
}
|
|
|
}
|