|
@@ -15,10 +15,7 @@ import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
|
import com.bizmatics.common.spring.util.GlobalUtils;
|
|
|
import com.bizmatics.common.spring.util.JsonUtils;
|
|
|
import com.bizmatics.model.*;
|
|
|
-import com.bizmatics.model.vo.DataManagementOneVO;
|
|
|
-import com.bizmatics.model.vo.DataManagementVO;
|
|
|
-import com.bizmatics.model.vo.HtAnalogDataOneVo;
|
|
|
-import com.bizmatics.model.vo.HtAnalogDataVo;
|
|
|
+import com.bizmatics.model.vo.*;
|
|
|
import com.bizmatics.persistence.mapper.HtAnalogDataMapper;
|
|
|
import com.bizmatics.service.*;
|
|
|
import com.bizmatics.service.util.FieldEscapeUtils;
|
|
@@ -33,9 +30,12 @@ import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static com.bizmatics.service.impl.RtAnalogDataServiceImpl.getLastDayOfMonth;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @author yq
|
|
@@ -656,4 +656,259 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
return listOne;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public SingleLoopReportOneVo SingleLoopReportData(String deviceCode, Date time, int type){
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
|
|
|
+ String startTime = null;
|
|
|
+ String endtime = null;
|
|
|
+ if (type == 1) {
|
|
|
+ startTime = sdf.format(time) + " 00:00:00";
|
|
|
+ endtime = sdf.format(time) + " 23:59:59";
|
|
|
+ } else {
|
|
|
+ startTime = sdf1.format(time) + "-01 00:00:00";
|
|
|
+ String time1 = sdf1.format(time) + "-01";
|
|
|
+ try {
|
|
|
+ Date yq = getLastDayOfMonth(sdf.parse(time1));
|
|
|
+ endtime = sdf.format(yq) + " 23:59:59";
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BusinessException("时间错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<SingleLoopReportVo> SingleLoopReportList = baseMapper.SingleLoopReportData(deviceCode,startTime,endtime);
|
|
|
+ if (CollectionUtils.isEmpty(SingleLoopReportList)){
|
|
|
+ throw new BusinessException("暂无数据");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<HtAnalogData> adQuery = Wrappers.lambdaQuery();
|
|
|
+ adQuery.eq(HtAnalogData::getDeviceName, deviceCode)
|
|
|
+ .between(HtAnalogData::getDataTime, startTime, endtime);
|
|
|
+ List<HtAnalogData> RtAnalogDataList = this.list(adQuery);
|
|
|
+ if (CollectionUtils.isEmpty(RtAnalogDataList)) {
|
|
|
+ throw new BusinessException("da不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return analysisCalculation(SingleLoopReportList,RtAnalogDataList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public SingleLoopReportOneVo analysisCalculation(List<SingleLoopReportVo> SingleLoopReportList,List<HtAnalogData> RtAnalogDataList){
|
|
|
+ DecimalFormat df = new DecimalFormat("######0.00");
|
|
|
+ List<Double> checkList = new ArrayList<>();
|
|
|
+ SingleLoopReportOneVo singleLoopReportOneVo = BeanMapperUtils.map(SingleLoopReportList.get(0), SingleLoopReportOneVo.class);
|
|
|
+
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getAvgIa());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getAvgIb());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getAvgIc());
|
|
|
+ //电流不平衡(平均)
|
|
|
+ singleLoopReportOneVo.setAvgElBalun(checkBalun(checkList)*100);
|
|
|
+
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMaxIa());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMaxIb());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMaxIc());
|
|
|
+ //电流不平衡(最大)
|
|
|
+ singleLoopReportOneVo.setMaxElBalun(checkBalun(checkList)*100);
|
|
|
+
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMinIa());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMinIb());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMinIc());
|
|
|
+ //电流不平衡(最小)
|
|
|
+ singleLoopReportOneVo.setMinElBalun(checkBalun(checkList)*100);
|
|
|
+
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getAvgUa());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getAvgUb());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getAvgUc());
|
|
|
+ //电压不平衡(平均)
|
|
|
+ singleLoopReportOneVo.setAvgVtBalun(checkBalun(checkList)*100);
|
|
|
+
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMaxUa());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMaxUb());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMaxUc());
|
|
|
+ //电压不平衡(最大)
|
|
|
+ singleLoopReportOneVo.setMaxVtBalun(checkBalun(checkList)*100);
|
|
|
+
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMinUa());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMinUb());
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMinUc());
|
|
|
+ //电压不平衡(最小)
|
|
|
+ singleLoopReportOneVo.setMinVtBalun(checkBalun(checkList)*100);
|
|
|
+
|
|
|
+ double voltageLevel = Double.parseDouble(singleLoopReportOneVo.getVoltageLevel());
|
|
|
+ double voltageLevelWanting = voltageLevel / 100 * 7;
|
|
|
+
|
|
|
+ //A相电压合格率(平均)
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getAvgUa());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double AvgUaQR = VoltageQr(checkList,voltageLevel);
|
|
|
+ singleLoopReportOneVo.setAvgUa(df.format(SingleLoopReportList.get(0).getAvgUa())+"V("+df.format(AvgUaQR)+"%)");
|
|
|
+ //B相电压合格率(平均)
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getAvgUb());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double AvgUbQR = VoltageQr(checkList,voltageLevel);
|
|
|
+ singleLoopReportOneVo.setAvgUb(df.format(SingleLoopReportList.get(0).getAvgUb())+"V("+df.format(AvgUbQR)+"%)");
|
|
|
+ //C相电压合格率(平均)
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getAvgUc());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double AvgUcQR = VoltageQr(checkList,voltageLevel);
|
|
|
+ singleLoopReportOneVo.setAvgUc(df.format(SingleLoopReportList.get(0).getAvgUc())+"V("+df.format(AvgUcQR)+"%)");
|
|
|
+ //A相电压合格率(最大)
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMaxUa());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double MaxUaQR = VoltageQr(checkList,voltageLevel);
|
|
|
+ singleLoopReportOneVo.setMaxUa(df.format(SingleLoopReportList.get(0).getMaxUa())+"V("+df.format(MaxUaQR)+"%)");
|
|
|
+ //B相电压合格率(最大)
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMaxUb());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double MaxUbQR = VoltageQr(checkList,voltageLevel);
|
|
|
+ singleLoopReportOneVo.setMaxUb(df.format(SingleLoopReportList.get(0).getMaxUb())+"V("+df.format(MaxUbQR)+"%)");
|
|
|
+ //C相电压合格率(最大)
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMaxUc());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double MaxUcQR = VoltageQr(checkList,voltageLevel);
|
|
|
+ singleLoopReportOneVo.setMaxUc(df.format(SingleLoopReportList.get(0).getMaxUc())+"V("+df.format(MaxUcQR)+"%)");
|
|
|
+ //A相电压合格率(最小)
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMinUa());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double MinUaQR = VoltageQr(checkList,voltageLevel);
|
|
|
+ singleLoopReportOneVo.setMinUa(df.format(SingleLoopReportList.get(0).getMinUa())+"V("+df.format(MinUaQR)+"%)");
|
|
|
+ //B相电压合格率(最小)
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMinUb());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double MinUbQR = VoltageQr(checkList,voltageLevel);
|
|
|
+ singleLoopReportOneVo.setMinUb(df.format(SingleLoopReportList.get(0).getMinUb())+"V("+df.format(MinUbQR)+"%)");
|
|
|
+ //C相电压合格率(最小)
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(SingleLoopReportList.get(0).getMinUc());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double MinUcQR = VoltageQr(checkList,voltageLevel);
|
|
|
+ singleLoopReportOneVo.setMinUc(df.format(SingleLoopReportList.get(0).getMinUc())+"V("+df.format(MinUcQR)+"%)");
|
|
|
+
|
|
|
+ //频率(平均)
|
|
|
+ Double cAvgF = 50.00 - SingleLoopReportList.get(0).getAvgF();
|
|
|
+ singleLoopReportOneVo.setAvgF(df.format(SingleLoopReportList.get(0).getAvgF())+"Hz("+df.format(cAvgF)+"Hz)");
|
|
|
+ //频率(最大)
|
|
|
+ Double cMaxF = 50.00 - SingleLoopReportList.get(0).getMaxF();
|
|
|
+ singleLoopReportOneVo.setMaxF(df.format(SingleLoopReportList.get(0).getMaxF())+"Hz("+df.format(cMaxF)+"Hz)");
|
|
|
+ //频率(最小)
|
|
|
+ Double cMinF = 50.00 - SingleLoopReportList.get(0).getMinF();
|
|
|
+ singleLoopReportOneVo.setMinF(df.format(SingleLoopReportList.get(0).getMinF())+"Hz("+df.format(cMinF)+"Hz)");
|
|
|
+
|
|
|
+ int OverrunUa = 0;
|
|
|
+ int OverrunUb = 0;
|
|
|
+ int OverrunUc = 0;
|
|
|
+ int OverrunF = 0;
|
|
|
+ int OverrunElBalun = 0;
|
|
|
+ int OverrunVtBalun = 0;
|
|
|
+ if (RtAnalogDataList.size()>0){
|
|
|
+ for (int i=0;i<RtAnalogDataList.size();i++){
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(RtAnalogDataList.get(i).getUa());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double maxUa = checkList.stream().max(Double::compareTo).get();
|
|
|
+ Double minUa = checkList.stream().min(Double::compareTo).get();
|
|
|
+ Double wantingUa = Arith.sub(maxUa, minUa);
|
|
|
+ if (wantingUa<voltageLevelWanting){
|
|
|
+ OverrunUa += OverrunUa;
|
|
|
+ }
|
|
|
+
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(RtAnalogDataList.get(i).getUb());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double maxUb = checkList.stream().max(Double::compareTo).get();
|
|
|
+ Double minUb = checkList.stream().min(Double::compareTo).get();
|
|
|
+ Double wantingUb = Arith.sub(maxUb, minUb);
|
|
|
+ if (wantingUb<voltageLevelWanting){
|
|
|
+ OverrunUb += OverrunUb;
|
|
|
+ }
|
|
|
+
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(RtAnalogDataList.get(i).getUc());
|
|
|
+ checkList.add(voltageLevel);
|
|
|
+ Double maxUc = checkList.stream().max(Double::compareTo).get();
|
|
|
+ Double minUc = checkList.stream().min(Double::compareTo).get();
|
|
|
+ Double wantingUc = Arith.sub(maxUc, minUc);
|
|
|
+ if (wantingUc<voltageLevelWanting){
|
|
|
+ OverrunUc += OverrunUc;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (RtAnalogDataList.get(i).getF()>50.2||RtAnalogDataList.get(i).getF()<49.8){
|
|
|
+ OverrunF += OverrunF;
|
|
|
+ }
|
|
|
+
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(RtAnalogDataList.get(i).getIa());
|
|
|
+ checkList.add(RtAnalogDataList.get(i).getIb());
|
|
|
+ checkList.add(RtAnalogDataList.get(i).getIc());
|
|
|
+ //电流不平衡
|
|
|
+ Double ElBalun = checkBalun(checkList);
|
|
|
+ if (ElBalun>0.15){
|
|
|
+ OverrunElBalun += OverrunElBalun;
|
|
|
+ }
|
|
|
+
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(RtAnalogDataList.get(i).getUa());
|
|
|
+ checkList.add(RtAnalogDataList.get(i).getUb());
|
|
|
+ checkList.add(RtAnalogDataList.get(i).getUc());
|
|
|
+ //电压不平衡
|
|
|
+ Double VtBalunQ = checkBalun(checkList);
|
|
|
+ if (VtBalunQ>0.15){
|
|
|
+ OverrunVtBalun += OverrunVtBalun;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ singleLoopReportOneVo.setProportionUa(OverrunUa+"/"+singleLoopReportOneVo.getMeasuringPoints());
|
|
|
+ singleLoopReportOneVo.setProportionUb(OverrunUb+"/"+singleLoopReportOneVo.getMeasuringPoints());
|
|
|
+ singleLoopReportOneVo.setProportionUc(OverrunUc+"/"+singleLoopReportOneVo.getMeasuringPoints());
|
|
|
+ singleLoopReportOneVo.setProportionF(OverrunF+"/"+singleLoopReportOneVo.getMeasuringPoints());
|
|
|
+ singleLoopReportOneVo.setProportionElBalun(OverrunElBalun+"/"+singleLoopReportOneVo.getMeasuringPoints());
|
|
|
+ singleLoopReportOneVo.setProportionVtBalun(OverrunVtBalun+"/"+singleLoopReportOneVo.getMeasuringPoints());
|
|
|
+ singleLoopReportOneVo.setQrUa(OverrunUa==0?100.00:Double.valueOf(OverrunUa)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints())*100);
|
|
|
+ singleLoopReportOneVo.setQrUb(OverrunUb==0?100.00:Double.valueOf(OverrunUb)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints())*100);
|
|
|
+ singleLoopReportOneVo.setQrUc(OverrunUc==0?100.00:Double.valueOf(OverrunUc)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints())*100);
|
|
|
+ singleLoopReportOneVo.setQrF(OverrunF==0?100.00:Double.valueOf(OverrunF)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints())*100);
|
|
|
+ singleLoopReportOneVo.setQrElBalun(OverrunElBalun==0?100.00:Double.valueOf(OverrunElBalun)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints()));
|
|
|
+ singleLoopReportOneVo.setQrVtBalun(OverrunVtBalun==0?100.00:Double.valueOf(OverrunVtBalun)/Double.valueOf(singleLoopReportOneVo.getMeasuringPoints()));
|
|
|
+ singleLoopReportOneVo.setVoltageLevelToplimit(voltageLevel+voltageLevelWanting);
|
|
|
+ singleLoopReportOneVo.setVoltageLevelLowerLimit(voltageLevel-voltageLevelWanting);
|
|
|
+ singleLoopReportOneVo.setMhz(50.00);
|
|
|
+ singleLoopReportOneVo.setFToplimit(50.2);
|
|
|
+ singleLoopReportOneVo.setFLowerLimit(49.8);
|
|
|
+ singleLoopReportOneVo.setAppraise(15.00);
|
|
|
+ singleLoopReportOneVo.setBalanceToplimit(15.00);
|
|
|
+ singleLoopReportOneVo.setBalanceLowerLimit(15.00);
|
|
|
+ return singleLoopReportOneVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Double VoltageQr(List<Double> checkList,Double voltageLevel){
|
|
|
+ Double max = checkList.stream().max(Double::compareTo).get();
|
|
|
+ Double min = checkList.stream().min(Double::compareTo).get();
|
|
|
+ Double wanting = Arith.sub(max, min);
|
|
|
+ Double QR = wanting / voltageLevel * 100;
|
|
|
+ return QR;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Double checkBalun(List<Double> list) {
|
|
|
+ long count = list.stream().filter(code -> 0.00 == code).count();
|
|
|
+ if (3 == count) {
|
|
|
+ return 0.00;
|
|
|
+ }
|
|
|
+ Double max = list.stream().max(Double::compareTo).get();
|
|
|
+ Double min = list.stream().min(Double::compareTo).get();
|
|
|
+ return Arith.div(Arith.sub(max, min), max);
|
|
|
+ }
|
|
|
+
|
|
|
}
|