|
@@ -1,8 +1,19 @@
|
|
|
package com.platform.service.remote.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
+import com.platform.common.cache.ConfigCache;
|
|
|
+import com.platform.common.enums.DictTypeEnum;
|
|
|
+import com.platform.common.exception.BusinessException;
|
|
|
import com.platform.common.util.IdGeneratorUtils;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
|
|
|
+import com.platform.dao.entity.upms.SysDict;
|
|
|
+import com.platform.dao.enums.SysConfigEnum;
|
|
|
+import com.platform.dao.enums.YesNoEnum;
|
|
|
+import com.platform.dao.mapper.upms.SysDictMapper;
|
|
|
import com.platform.dao.vo.query.remote.RemoteDegreeLogVO;
|
|
|
import com.platform.dao.dto.remote.RemoteDegreeLogDTO;
|
|
|
import com.platform.dao.entity.remote.RemoteDegreeLog;
|
|
@@ -12,11 +23,15 @@ import org.springframework.cglib.core.Local;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import tk.mybatis.mapper.weekend.Weekend;
|
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -29,6 +44,8 @@ import java.util.List;
|
|
|
@Service("remoteDegreeLogService")
|
|
|
public class RemoteDegreeLogServiceImpl extends BaseServiceImpl<RemoteDegreeLogMapper, RemoteDegreeLog, RemoteDegreeLogDTO> implements RemoteDegreeLogService {
|
|
|
|
|
|
+ private final SysDictMapper sysDictMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
|
Weekend<RemoteDegreeLog> weekend = new Weekend<>(RemoteDegreeLog.class);
|
|
@@ -54,10 +71,129 @@ public class RemoteDegreeLogServiceImpl extends BaseServiceImpl<RemoteDegreeLogM
|
|
|
mapper.insert(remoteDegreeLog);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 参数:
|
|
|
+ * 查询月报表、日报表
|
|
|
+ * 1:根据线路分组,线路1,线路2
|
|
|
+ * 2:日报表
|
|
|
+ * 根据年、月,日,查询出来
|
|
|
+ * 根据小时分组,循环24小时分组
|
|
|
+ * 根据线路分组:累加
|
|
|
+ * <p>
|
|
|
+ * 3:月报表
|
|
|
+ * 根据年、月,查询出来
|
|
|
+ * 根据天分组,循环到当前月有多少天,
|
|
|
+ * 根据月分组:累加
|
|
|
+ * <p>
|
|
|
+ * 日报格式, 月报没有negative数据
|
|
|
+ * [{
|
|
|
+ * time: “00:00”,
|
|
|
+ * lines: [
|
|
|
+ * {name:"line1", "positive ": “00:00”, "negative": “00:00”},
|
|
|
+ * {name:"line2", "positive": “00:00”, "negative": “00:00”},
|
|
|
+ * {name:"line3", "positive": “00:00”, "negative": “00:00”},
|
|
|
+ * {name:"line4", "positive": “00:00”, "negative": “00:00”},
|
|
|
+ * {name:"line5", "positive": “00:00”, "negative": “00:00”},
|
|
|
+ * {name:"line6", "positive": “00:00”, "negative": “00:00”},
|
|
|
+ * ]
|
|
|
+ * },
|
|
|
+ * {
|
|
|
+ * time: “01:00”,
|
|
|
+ * lines: [
|
|
|
+ * {name:"line1", "positive ": “00:00”, "negative": “00:00”},
|
|
|
+ * {name:"line2", "positive": “00:00”, "negative": “00:00”},
|
|
|
+ * {name:"line3", "positive": “00:00”, "negative": “00:00”},
|
|
|
+ * {name:"line4", "positive": “00:00”, "negative": “00:00”},
|
|
|
+ * {name:"line5", "positive": “00:00”, "negative": “00:00”},
|
|
|
+ * {name:"line6", "positive": “00:00”, "negative": “00:00”},
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ * ]
|
|
|
+ *
|
|
|
+ * @param record
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Object getMonthOrDayReport(RemoteDegreeLogDTO record, Boolean isDay) {
|
|
|
+ if (record.getYear() == null) {
|
|
|
+ throw new BusinessException("请选择年份");
|
|
|
+ }
|
|
|
+ if (record.getMonth() == null) {
|
|
|
+ throw new BusinessException("请选择月份");
|
|
|
+ }
|
|
|
+ Weekend<SysDict> weekend = new Weekend<>(SysDict.class);
|
|
|
+ WeekendCriteria<SysDict, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andEqualTo(SysDict::getType, DictTypeEnum.REMOTE_LINE);
|
|
|
+ List<SysDict> sysDictList = sysDictMapper.selectByExample(weekend);
|
|
|
+ if (CollectionUtils.isEmpty(sysDictList)) {
|
|
|
+ throw new BusinessException("请在数据字典配置设备电力线路");
|
|
|
+ }
|
|
|
+ sysDictList.sort(Comparator.comparing(SysDict::getSort));
|
|
|
+ List<RemoteDegreeLogVO> list = mapper.selectList(record);
|
|
|
+ JSONArray jSONArray = new JSONArray();
|
|
|
+ if (isDay) {
|
|
|
+ for (int i = 0; i < 24; i++) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("time", i + ":00");
|
|
|
+ JSONArray lineArray = new JSONArray();
|
|
|
+ for (SysDict dict : sysDictList) {
|
|
|
+ JSONObject dictJsonObject = new JSONObject();
|
|
|
+ dictJsonObject.put("name", dict.getLabel());
|
|
|
+ BigDecimal positiveTotal = new BigDecimal(0.00);// 正向有功
|
|
|
+ BigDecimal negativeTotal = new BigDecimal(0.00);// 正向无功
|
|
|
+ for (RemoteDegreeLogVO log : list) {
|
|
|
+ if (log.getHour().equals(i)) {
|
|
|
+ if(log.getType().equals(YesNoEnum.YES.getValue())){
|
|
|
+ positiveTotal.add(new BigDecimal(log.getResult()));
|
|
|
+ }else{
|
|
|
+ negativeTotal.add(new BigDecimal(log.getResult()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dictJsonObject.put("positive", positiveTotal);
|
|
|
+ dictJsonObject.put("negative", negativeTotal);
|
|
|
+ lineArray.add(dictJsonObject);
|
|
|
+ }
|
|
|
+ jsonObject.put("lines", lineArray);
|
|
|
+ jSONArray.add(jsonObject);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ LocalDate localDate = LocalDate.of(record.getYear(), record.getMonth(), 1);
|
|
|
+ int days = localDate.getDayOfMonth();
|
|
|
+ for (int i = 0; i < days; i++) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("time", i + ":00");
|
|
|
+ JSONArray lineArray = new JSONArray();
|
|
|
+ for (SysDict dict : sysDictList) {
|
|
|
+ JSONObject dictJsonObject = new JSONObject();
|
|
|
+ dictJsonObject.put("name", dict.getLabel());
|
|
|
+ BigDecimal positiveTotal = new BigDecimal(0.00);// 正向有功
|
|
|
+ BigDecimal negativeTotal = new BigDecimal(0.00);// 正向无功,不需要吗,后面可以删除,先保存
|
|
|
+ for (RemoteDegreeLogVO log : list) {
|
|
|
+ if (log.getDay().equals(i)) {
|
|
|
+ if(log.getType().equals(YesNoEnum.YES.getValue())){
|
|
|
+ positiveTotal.add(new BigDecimal(log.getResult()));
|
|
|
+ }else{
|
|
|
+ negativeTotal.add(new BigDecimal(log.getResult()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dictJsonObject.put("positive", positiveTotal);
|
|
|
+ dictJsonObject.put("negative", negativeTotal);
|
|
|
+ lineArray.add(dictJsonObject);
|
|
|
+ }
|
|
|
+ jsonObject.put("lines", lineArray);
|
|
|
+ jSONArray.add(jsonObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public AbstractPageResultBean<RemoteDegreeLog> selectPageInfo(RemoteDegreeLogDTO record, int pageNum, int pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
return new MyPage(mapper.selectList(record));
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+}
|