|
@@ -18,6 +18,7 @@ import com.platform.common.util.*;
|
|
|
import com.platform.dao.bean.MyVOPage;
|
|
|
import com.platform.dao.dto.check.CheckStandardDTO;
|
|
|
import com.platform.dao.dto.part.PartInfoDTO;
|
|
|
+import com.platform.dao.dto.remote.RemoteDegreeLogDTO;
|
|
|
import com.platform.dao.dto.sb.SbInfoDTO;
|
|
|
import com.platform.dao.dto.sb.SbModelSpareBomDTO;
|
|
|
import com.platform.dao.dto.upms.SysDeptDTO;
|
|
@@ -37,7 +38,9 @@ import com.platform.dao.mapper.check.CheckStandardMapper;
|
|
|
import com.platform.dao.mapper.firm.FirmProducerMapper;
|
|
|
import com.platform.dao.mapper.part.PartInfoMapper;
|
|
|
import com.platform.dao.mapper.part.PartTypeMapper;
|
|
|
+import com.platform.dao.mapper.remote.RemoteDegreeLogMapper;
|
|
|
import com.platform.dao.mapper.remote.RemoteDegreeMapper;
|
|
|
+import com.platform.dao.mapper.remote.RemoteMeasureLogMapper;
|
|
|
import com.platform.dao.mapper.remote.RemoteMeasureMapper;
|
|
|
import com.platform.dao.mapper.repair.RepairApplicationFormMapper;
|
|
|
import com.platform.dao.mapper.sb.*;
|
|
@@ -53,6 +56,7 @@ import com.platform.dao.util.compare.FieldComparedUtils;
|
|
|
import com.platform.dao.vo.SysUserDeptVO;
|
|
|
import com.platform.dao.vo.SysUserVO;
|
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
|
+import com.platform.dao.vo.query.remote.RemoteDegreeLogVO;
|
|
|
import com.platform.dao.vo.query.upms.SysDeptVO;
|
|
|
import com.platform.dao.vo.report.SbInfoTypeReportVO;
|
|
|
import com.platform.dao.vo.sb.*;
|
|
@@ -62,6 +66,7 @@ import com.platform.service.business.ActivitiBusinessService;
|
|
|
import com.platform.service.check.CheckStandardService;
|
|
|
import com.platform.service.event.WorkplaceBacklogEvent;
|
|
|
import com.platform.service.part.PartInfoService;
|
|
|
+import com.platform.service.remote.RemoteDegreeLogService;
|
|
|
import com.platform.service.sb.SbInfoService;
|
|
|
import com.platform.service.sb.SbModelSpareBomService;
|
|
|
import com.platform.service.upms.SysDeptRelationService;
|
|
@@ -99,9 +104,13 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbInfoDTO> implements BigScreenSbInfoService {
|
|
|
private final RemoteMeasureMapper remoteMeasureMapper;
|
|
|
- private final RemoteDegreeMapper remoteDegreeMapper;
|
|
|
private final SysDictMapper sysDictMapper;
|
|
|
-
|
|
|
+ private final RemoteDegreeLogMapper remoteDegreeLogMapper;
|
|
|
+ /**
|
|
|
+ * 按照线路汇总统计
|
|
|
+ * @param lineNum
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public JSONObject getGroupByLine(Integer lineNum) {
|
|
|
Weekend<SysDict> weekend = new Weekend<>(SysDict.class);
|
|
@@ -111,45 +120,161 @@ public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, Sb
|
|
|
if (sysDict == null) {
|
|
|
throw new BusinessException("请在数据字典配置设备电力线路,数据值:" + lineNum);
|
|
|
}
|
|
|
- SbInfo sbInfo = new SbInfo();
|
|
|
- sbInfo.setBaoyangTimes(lineNum);
|
|
|
- List<SbInfo> list = mapper.select(sbInfo);
|
|
|
- if(CollectionUtils.isEmpty(list)){
|
|
|
- throw new BusinessException("该电力线路下没有设备,请先在设备详情中添加线路,将设备和线路进行绑定" );
|
|
|
- }
|
|
|
- List<String> ids = list.stream().map(SbInfo::getId).collect(Collectors.toList());
|
|
|
|
|
|
// 查询所有的遥测点位
|
|
|
Weekend<RemoteMeasure> remoteDegreeWeekend = new Weekend<>(RemoteMeasure.class);
|
|
|
WeekendCriteria<RemoteMeasure, Object> remoteDegreeObjectWeekendCriteria = remoteDegreeWeekend.weekendCriteria();
|
|
|
- remoteDegreeObjectWeekendCriteria.andIn(RemoteMeasure::getSbId, ids);
|
|
|
+ remoteDegreeObjectWeekendCriteria.andEqualTo(RemoteMeasure::getLine, lineNum);
|
|
|
List<RemoteMeasure> remoteMeasureList = remoteMeasureMapper.selectByExample(remoteDegreeWeekend);
|
|
|
JSONObject obj = new JSONObject();
|
|
|
- if(CollectionUtil.isNotEmpty(list)){
|
|
|
- obj.put("lineNum", lineNum);
|
|
|
+ if(CollectionUtil.isNotEmpty(remoteMeasureList)){
|
|
|
+ obj.put("line", lineNum);
|
|
|
obj.put("lineName", sysDict.getLabel());
|
|
|
- JSONArray array = new JSONArray();
|
|
|
- obj.put("sbList", array);
|
|
|
- for(SbInfo info : list){
|
|
|
+ Map<String, List<RemoteMeasure>> map = remoteMeasureList.stream().collect(Collectors.groupingBy(RemoteMeasure::getSbName, Collectors.toList()));
|
|
|
+ JSONArray lineArray = new JSONArray();
|
|
|
+ for(String key:map.keySet()){
|
|
|
+ JSONObject dictJsonObject = new JSONObject();
|
|
|
+ dictJsonObject.put("sbName", key);
|
|
|
+ dictJsonObject.put("measureList", map.get(key));
|
|
|
+ lineArray.add(dictJsonObject);
|
|
|
+ }
|
|
|
+ obj.put("dataList", lineArray);
|
|
|
+ }
|
|
|
+ return obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 参数:
|
|
|
+ * 查询月报表、日报表
|
|
|
+ * 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
|
|
|
+ * @param isDay
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public JSONArray 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 = remoteDegreeLogMapper.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.getLine().toString().equals(dict.getValue())) {
|
|
|
+ if (log.getHour().equals(i)) {
|
|
|
+ if (log.getType().equals(1)) {
|
|
|
+ positiveTotal = positiveTotal.add(new BigDecimal(log.getResult()));
|
|
|
+ } else {
|
|
|
+ negativeTotal = 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.lengthOfMonth();
|
|
|
+ for (int i = 1; i <= days; i++) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- array.add(jsonObject);
|
|
|
- jsonObject.put("sbId", info.getId());
|
|
|
- jsonObject.put("sbNo", info.getNo());
|
|
|
- jsonObject.put("sbName", info.getName());
|
|
|
- JSONArray remoteMeasureArray = new JSONArray();
|
|
|
- jsonObject.put("measureList", remoteMeasureArray);
|
|
|
- for(RemoteMeasure remoteMeasure : remoteMeasureList){
|
|
|
- if(remoteMeasure.getSbId().equals(info.getId())){
|
|
|
- JSONObject remoteMeasureObject = new JSONObject();
|
|
|
- remoteMeasureObject.put("description", remoteMeasure.getDescription());
|
|
|
- remoteMeasureObject.put("result", remoteMeasure.getResult());
|
|
|
- remoteMeasureObject.put("unit", remoteMeasure.getUnit());
|
|
|
- remoteMeasureObject.put("type", remoteMeasure.getType());
|
|
|
- remoteMeasureArray.add(remoteMeasureObject);
|
|
|
+ jsonObject.put("time", i);
|
|
|
+ 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.getLine() == null){
|
|
|
+ throw new BusinessException("设备未设置电力线路, 设备名称:" + log.getSbName() + ", 设备编号:" + log.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()));
|
|
|
+ } else {
|
|
|
+ negativeTotal = 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 obj;
|
|
|
+ return jSONArray;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Map<String, List<RemoteMeasure>> map = new HashMap<>();
|
|
|
+ map.put("sbName", new ArrayList<>());
|
|
|
+ JSONObject remoteJson = JSONObject.parseObject(JSONObject.toJSONString(map));
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("remoteList", remoteJson);
|
|
|
+ System.out.println(obj.toJSONString());
|
|
|
}
|
|
|
}
|