|
@@ -1,14 +1,26 @@
|
|
|
package org.jeecg.modules.interlockCountDay.service.impl;
|
|
|
|
|
|
+import org.jeecg.modules.base.entity.InterlockBase;
|
|
|
+import org.jeecg.modules.base.service.IInterlockBaseService;
|
|
|
+import org.jeecg.modules.dashboardInterface.entity.InterlockAndYbStatus;
|
|
|
+import org.jeecg.modules.dashboardInterface.entity.InterlockTyl;
|
|
|
+import org.jeecg.modules.dashboardInterface.entity.LoopHealthLevel;
|
|
|
+import org.jeecg.modules.detail.entity.InterlockDetail;
|
|
|
import org.jeecg.modules.interlockCountDay.entity.InterlockCountDay;
|
|
|
import org.jeecg.modules.interlockCountDay.mapper.InterlockCountDayMapper;
|
|
|
import org.jeecg.modules.interlockCountDay.service.IInterlockCountDayService;
|
|
|
+import org.jeecg.modules.summary.entity.InterlockSummary;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description: interlock_count_day
|
|
@@ -23,8 +35,132 @@ public class InterlockCountDayServiceImpl extends ServiceImpl<InterlockCountDayM
|
|
|
@SuppressWarnings("all")
|
|
|
private InterlockCountDayMapper mapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private IInterlockBaseService baseService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<InterlockCountDay> getCountByYearmonth(String counttype, String lastmonth) {
|
|
|
return mapper.getCountByYearmonth(counttype, lastmonth);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<InterlockTyl> getTylBySysNameTime(String deviceId,String systemName,String beginDate,String endDate) {
|
|
|
+ return mapper.getTylBySysNameTime(deviceId,systemName,beginDate,endDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, List<LoopHealthLevel>> getLoopHealthLevels(String deviceId, String systemName,String beginDate,String endDate) {
|
|
|
+ HashMap<String, List<LoopHealthLevel>> map = new HashMap<>();
|
|
|
+ List<LoopHealthLevel> list = mapper.getLoopHealthLevels(deviceId,systemName,beginDate,endDate);
|
|
|
+ for (LoopHealthLevel item : list) {
|
|
|
+ if (map.containsKey(item.getLevel())){
|
|
|
+ map.get(item.getLevel()).add(item);
|
|
|
+ }else {
|
|
|
+ ArrayList<LoopHealthLevel> sonList = new ArrayList<>();
|
|
|
+ sonList.add(item);
|
|
|
+ map.put(item.getLevel(),sonList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<LoopHealthLevel> getCurrentLoopHealthLevels(String deviceId, String systemId) {
|
|
|
+ return mapper.getCurrentLoopHealthLevels(deviceId, systemId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<InterlockAndYbStatus> getCurronInterlockStatus(String deviceId, String systemId) {
|
|
|
+ InterlockBase base = baseService.getById(systemId);
|
|
|
+ String tyStatusValue = base.getInterlockStatusTy();
|
|
|
+ String wtyStatusValue = inversionStatus(base.getInterlockStatusTy());
|
|
|
+ List<InterlockAndYbStatus> list = mapper.getCurronInterlockStatus(deviceId, systemId);
|
|
|
+ for (InterlockAndYbStatus item : list) {
|
|
|
+ if (tyStatusValue.equals(item.getStatusName())){
|
|
|
+ item.setStatusName("已投用数");
|
|
|
+ }
|
|
|
+ if (wtyStatusValue.equals(item.getStatusName())){
|
|
|
+ item.setStatusName("未投用数");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<InterlockTyl> getCurrentTylBySysName(String deviceId, String systemId) {
|
|
|
+ ArrayList<InterlockTyl> tylList = new ArrayList<>();
|
|
|
+ InterlockTyl interlockTyl = new InterlockTyl();
|
|
|
+ BigDecimal yty = BigDecimal.valueOf(0);
|
|
|
+ BigDecimal wty = BigDecimal.valueOf(0);
|
|
|
+ List<InterlockAndYbStatus> list = getCurronInterlockStatus(deviceId, systemId);
|
|
|
+ for (InterlockAndYbStatus item : list) {
|
|
|
+ if ("已投用数".equals(item.getStatusName())){
|
|
|
+ yty = new BigDecimal(item.getNumber());
|
|
|
+ }
|
|
|
+ if ("未投用数".equals(item.getStatusName())){
|
|
|
+ wty = new BigDecimal(item.getNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BigDecimal total = yty.add(wty);
|
|
|
+ BigDecimal tyl = BigDecimal.valueOf(0);
|
|
|
+ if ((total.compareTo(BigDecimal.valueOf(0)) != 0)){
|
|
|
+ tyl = yty.divide(total,4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
|
|
|
+ }
|
|
|
+ interlockTyl.setTyl(String.valueOf(tyl));
|
|
|
+ interlockTyl.setTime(list.get(0).getTime());
|
|
|
+ tylList.add(interlockTyl);
|
|
|
+ return tylList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<InterlockAndYbStatus> getYbStatus(String deviceId, String systemId) {
|
|
|
+ ArrayList<InterlockAndYbStatus> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ InterlockBase base = baseService.getById(systemId);
|
|
|
+ String ybStatusNormalValue = base.getInstrumentStatusNormal();
|
|
|
+ String ybStatusAnNormalValue = inversionStatus(ybStatusNormalValue);
|
|
|
+
|
|
|
+ // 查询该系统下的联锁
|
|
|
+ List<InterlockSummary> summaryList = mapper.getSummaryList(deviceId, systemId);
|
|
|
+ int ybNormalNumber = 0; // 该系统下 所有联锁的仪表状态 为正常的数量
|
|
|
+ int ybAnNormalNumber = 0; // 该系统下 所有联锁的仪表状态 为异常的数量
|
|
|
+ for (InterlockSummary summary : summaryList) {
|
|
|
+ // 查询该联锁下的联锁条件
|
|
|
+ List<InterlockDetail> detailList = mapper.getDetailList(summary.getId());
|
|
|
+ for (InterlockDetail detail : detailList) {
|
|
|
+ if (ybStatusAnNormalValue.equals(detail.getInstrumentStatus())){
|
|
|
+ ybAnNormalNumber++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (summaryList.size() > 0){
|
|
|
+ ybNormalNumber = summaryList.size() - ybAnNormalNumber;
|
|
|
+ }
|
|
|
+ InterlockAndYbStatus interlockAndYbStatus1 = new InterlockAndYbStatus();
|
|
|
+ interlockAndYbStatus1.setStatusName("正常");
|
|
|
+ interlockAndYbStatus1.setNumber(String.valueOf(ybNormalNumber));
|
|
|
+
|
|
|
+ InterlockAndYbStatus interlockAndYbStatus2 = new InterlockAndYbStatus();
|
|
|
+ interlockAndYbStatus2.setStatusName("故障");
|
|
|
+ interlockAndYbStatus2.setNumber(String.valueOf(ybAnNormalNumber));
|
|
|
+
|
|
|
+ resultList.add(interlockAndYbStatus1);
|
|
|
+ resultList.add(interlockAndYbStatus2);
|
|
|
+
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * author: dzc
|
|
|
+ * version: 1.0
|
|
|
+ * des: 取反
|
|
|
+ * date: 2024/7/03
|
|
|
+ */
|
|
|
+ private String inversionStatus(String str) {
|
|
|
+ if("0".equals(str)) return "1";
|
|
|
+ else return "0";
|
|
|
+ }
|
|
|
}
|