diff --git a/pqs-common/common-influxdb/src/main/java/com/njcn/influxdb/param/InfluxDBPublicParam.java b/pqs-common/common-influxdb/src/main/java/com/njcn/influxdb/param/InfluxDBPublicParam.java index ae4f9c963..80de6e945 100644 --- a/pqs-common/common-influxdb/src/main/java/com/njcn/influxdb/param/InfluxDBPublicParam.java +++ b/pqs-common/common-influxdb/src/main/java/com/njcn/influxdb/param/InfluxDBPublicParam.java @@ -209,4 +209,26 @@ public interface InfluxDBPublicParam { */ String LIMIT_TARGET = "limit_target"; + /** + * 监测点状态信息表 + */ + String PQS_COMMUNICATE = "pqs_communicate"; + + /** + * 终端在线率表公共字段 + */ + String ONLINEMIN = "onlinemin"; + + String OFFLINEMIN = "offlinemin"; + + /** + * 数据完整性表公共字段 + */ + String DUE = "DUE"; + + String REAL = "REAL"; + + String DEV_INDEX = "dev_id"; + + } diff --git a/pqs-common/common-influxdb/src/test/java/DataTest.java b/pqs-common/common-influxdb/src/test/java/DataTest.java index 1fc6137ed..9b8f7388c 100644 --- a/pqs-common/common-influxdb/src/test/java/DataTest.java +++ b/pqs-common/common-influxdb/src/test/java/DataTest.java @@ -59,7 +59,7 @@ public class DataTest { } public static void main(String[] args) { - InfluxDbUtils influxDBUtil = new InfluxDbUtils("root", "123456789", "http://192.168.1.16:8086", "pqsbase", ""); + InfluxDbUtils influxDBUtil = new InfluxDbUtils("root", "123456789", "http://192.168.1.18:8086", "pqsbase", ""); insert(influxDBUtil); //select(influxDBUtil); } @@ -79,118 +79,195 @@ public class DataTest { // fields.put("result",1); // influxDBUtil.insert("pqs_event_push_logs", tags, fields, time, TimeUnit.MILLISECONDS); - long time = Long.parseLong("1646180719000"); +// long time = Long.parseLong("1654141002000"); Map tags = new HashMap<>(); - tags.put("LineID", "fd4ffb0dd33eafaaf403b07a3fc1afe5"); +// tags.put("line_id", "5e467a40023b299070682eb21f2ec9a1"); +// Map fields = new HashMap<>(); +// fields.put("vu_dev1",5.706); +// fields.put("vu_dev2",5.706); +// fields.put("vu_dev3",5.706); +// fields.put("vu_dev4",5.706); +// fields.put("vu_dev5",5.706); +// fields.put("freq_dev1",0.534); +// fields.put("freq_dev2",0.534); +// fields.put("freq_dev3",2.534); +// fields.put("freq_dev4",0.534); +// fields.put("freq_dev5",0.534); +// fields.put("data_plt1",0.604); +// fields.put("data_plt2",0.0); +// fields.put("data_plt3",0.691); +// fields.put("data_plt4",0.910); +// fields.put("data_plt5",0.691); +// fields.put("v_unbalance1",2.713); +// fields.put("v_unbalance2",2.713); +// fields.put("v_unbalance3",2.713); +// fields.put("v_unbalance4",2.713); +// fields.put("v_unbalance5",2.713); +// fields.put("v_thd1",20.001); +// fields.put("v_thd2",20.003); +// fields.put("v_thd3",20.00); +// fields.put("v_thd4",20.008); +// fields.put("v_thd5",20.00); +// fields.put("event1",1.619); +// fields.put("event2",1.619); +// fields.put("event3",1.619); +// fields.put("event4",1.619); +// fields.put("event5",1.619); +// influxDBUtil.insert("pqs_comasses", tags, fields, time, TimeUnit.MILLISECONDS); +// long time = Long.parseLong("1654141002000"); +// tags.put("line_id", "5e467a40023b299070682eb21f2ec9a1"); +// tags.put("phasic_type","C"); +// Map fields = new HashMap<>(); +// fields.put("alltime",1155); +// fields.put("flicker_alltime",550); +// fields.put("flicker_overtime",0); +// fields.put("freq_dev_overtime",0); +// fields.put("voltage_dev_overtime",0); +// fields.put("ubalance_overtime",0); +// fields.put("uaberrance_overtime",0); +// fields.put("i_neg_overtime",0); +// fields.put("uharm_2_overtime",0); +// fields.put("uharm_3_overtime",0); +// fields.put("uharm_4_overtime",0); +// fields.put("uharm_5_overtime",0); +// fields.put("uharm_6_overtime",0); +// fields.put("uharm_7_overtime",0); +// fields.put("uharm_8_overtime",0); +// fields.put("uharm_9_overtime",0); +// fields.put("uharm_10_overtime",0); +// fields.put("uharm_11_overtime",0); +// fields.put("uharm_12_overtime",0); +// fields.put("uharm_13_overtime",0); +// fields.put("uharm_14_overtime",0); +// fields.put("uharm_15_overtime",0); +// fields.put("uharm_16_overtime",0); +// fields.put("uharm_17_overtime",0); +// fields.put("uharm_18_overtime",0); +// fields.put("uharm_19_overtime",0); +// fields.put("uharm_20_overtime",0); +// fields.put("uharm_21_overtime",0); +// fields.put("uharm_22_overtime",0); +// fields.put("uharm_23_overtime",0); +// fields.put("uharm_24_overtime",0); +// fields.put("uharm_25_overtime",0); +// fields.put("iharm_2_overtime",0); +// fields.put("iharm_3_overtime",0); +// fields.put("iharm_4_overtime",0); +// fields.put("iharm_5_overtime",0); +// fields.put("iharm_6_overtime",0); +// fields.put("iharm_7_overtime",0); +// fields.put("iharm_8_overtime",0); +// fields.put("iharm_9_overtime",0); +// fields.put("iharm_10_overtime",0); +// fields.put("iharm_11_overtime",0); +// fields.put("iharm_12_overtime",0); +// fields.put("iharm_13_overtime",0); +// fields.put("iharm_14_overtime",0); +// fields.put("iharm_15_overtime",0); +// fields.put("iharm_16_overtime",0); +// fields.put("iharm_17_overtime",0); +// fields.put("iharm_18_overtime",0); +// fields.put("iharm_19_overtime",0); +// fields.put("iharm_20_overtime",0); +// fields.put("iharm_21_overtime",0); +// fields.put("iharm_22_overtime",0); +// fields.put("iharm_23_overtime",0); +// fields.put("iharm_24_overtime",0); +// fields.put("iharm_25_overtime",0); +// fields.put("inuharm_1_overtime",0); +// fields.put("inuharm_2_overtime",0); +// fields.put("inuharm_3_overtime",0); +// fields.put("inuharm_4_overtime",0); +// fields.put("inuharm_5_overtime",0); +// fields.put("inuharm_6_overtime",0); +// fields.put("inuharm_7_overtime",0); +// fields.put("inuharm_8_overtime",0); +// fields.put("inuharm_9_overtime",0); +// fields.put("inuharm_10_overtime",0); +// fields.put("inuharm_11_overtime",0); +// fields.put("inuharm_12_overtime",0); +// fields.put("inuharm_13_overtime",0); +// fields.put("inuharm_14_overtime",0); +// fields.put("inuharm_15_overtime",0); +// fields.put("inuharm_16_overtime",0); +// influxDBUtil.insert("limit_rate", tags, fields, time, TimeUnit.MILLISECONDS); + + long time = Long.parseLong("1654141002000"); + tags.put("line_id", "5e467a40023b299070682eb21f2ec9a1"); + tags.put("phasic_type","A"); + tags.put("value_type","CP95"); Map fields = new HashMap<>(); - fields.put("VU_Dev1",5.706); - fields.put("VU_Dev2",5.706); - fields.put("VU_Dev3",5.706); - fields.put("VU_Dev4",5.706); - fields.put("VU_Dev5",5.706); - fields.put("Freq_Dev1",0.534); - fields.put("Freq_Dev2",0.534); - fields.put("Freq_Dev3",2.534); - fields.put("Freq_Dev4",0.534); - fields.put("Freq_Dev5",0.534); - fields.put("Data_PST1",0.604); - fields.put("Data_PST2",0.0); - fields.put("Data_PST3",0.691); - fields.put("Data_PST4",0.910); - fields.put("Data_PST5",0.691); - fields.put("V_Unbalance1",2.713); - fields.put("V_Unbalance2",2.713); - fields.put("V_Unbalance3",2.713); - fields.put("V_Unbalance4",2.713); - fields.put("V_Unbalance5",2.713); - fields.put("V_THD1",20.001); - fields.put("V_THD2",20.003); - fields.put("V_THD3",20.00); - fields.put("V_THD4",20.008); - fields.put("V_THD5",20.00); - fields.put("Event1",1.619); - fields.put("Event2",1.619); - fields.put("Event3",1.619); - fields.put("Event4",1.619); - fields.put("Event5",1.619); - influxDBUtil.insert("PQS_COMASSES", tags, fields, time, TimeUnit.MILLISECONDS); - // long time = Long.parseLong("1647473742000"); - // tags.put("MYINDEX", "df1ff413949f6d1fc07ffdb5440b4907"); - // Map fields = new HashMap<>(); - // fields.put("Phasic_Type","T"); - // fields.put("AllTime",1155); - // fields.put("Flicker_AllTime",550); - // fields.put("Flicker_OverTime",0); - // fields.put("Freq_Dev_OverTime",0); - // fields.put("Voltage_Dev_OverTime",0); - // fields.put("UBalance_OverTime",0); - // fields.put("UAberrance_OverTime",0); - // fields.put("I_Neg_OverTime",0); - // fields.put("UHarm_2_OverTime",0); - // fields.put("UHarm_3_OverTime",0); - // fields.put("UHarm_4_OverTime",0); - // fields.put("UHarm_5_OverTime",0); - // fields.put("UHarm_6_OverTime",0); - // fields.put("UHarm_7_OverTime",0); - // fields.put("UHarm_8_OverTime",0); - // fields.put("UHarm_9_OverTime",0); - // fields.put("UHarm_10_OverTime",0); - // fields.put("UHarm_11_OverTime",0); - // fields.put("UHarm_12_OverTime",0); - // fields.put("UHarm_13_OverTime",0); - // fields.put("UHarm_14_OverTime",0); - // fields.put("UHarm_15_OverTime",0); - // fields.put("UHarm_16_OverTime",0); - // fields.put("UHarm_17_OverTime",0); - // fields.put("UHarm_18_OverTime",0); - // fields.put("UHarm_19_OverTime",0); - // fields.put("UHarm_20_OverTime",0); - // fields.put("UHarm_21_OverTime",0); - // fields.put("UHarm_22_OverTime",0); - // fields.put("UHarm_23_OverTime",0); - // fields.put("UHarm_24_OverTime",0); - // fields.put("UHarm_25_OverTime",0); - // fields.put("IHarm_2_OverTime",0); - // fields.put("IHarm_3_OverTime",0); - // fields.put("IHarm_4_OverTime",0); - // fields.put("IHarm_5_OverTime",0); - // fields.put("IHarm_6_OverTime",0); - // fields.put("IHarm_7_OverTime",0); - // fields.put("IHarm_8_OverTime",0); - // fields.put("IHarm_9_OverTime",0); - // fields.put("IHarm_10_OverTime",0); - // fields.put("IHarm_11_OverTime",0); - // fields.put("IHarm_12_OverTime",0); - // fields.put("IHarm_13_OverTime",0); - // fields.put("IHarm_14_OverTime",0); - // fields.put("IHarm_15_OverTime",0); - // fields.put("IHarm_16_OverTime",0); - // fields.put("IHarm_17_OverTime",0); - // fields.put("IHarm_18_OverTime",0); - // fields.put("IHarm_19_OverTime",0); - // fields.put("IHarm_20_OverTime",0); - // fields.put("IHarm_21_OverTime",0); - // fields.put("IHarm_22_OverTime",0); - // fields.put("IHarm_23_OverTime",0); - // fields.put("IHarm_24_OverTime",0); - // fields.put("IHarm_25_OverTime",0); - // fields.put("InUHARM_1_OverTime",0); - // fields.put("InUHARM_2_OverTime",0); - // fields.put("InUHARM_3_OverTime",0); - // fields.put("InUHARM_4_OverTime",0); - // fields.put("InUHARM_5_OverTime",0); - // fields.put("InUHARM_6_OverTime",0); - // fields.put("InUHARM_7_OverTime",0); - // fields.put("InUHARM_8_OverTime",0); - // fields.put("InUHARM_9_OverTime",0); - // fields.put("InUHARM_10_OverTime",0); - // fields.put("InUHARM_11_OverTime",0); - // fields.put("InUHARM_12_OverTime",0); - // fields.put("InUHARM_13_OverTime",0); - // fields.put("InUHARM_14_OverTime",0); - // fields.put("InUHARM_15_OverTime",0); - // fields.put("InUHARM_16_OverTime",0); - // influxDBUtil.insert("LIMIT_RATE", tags, fields, time, TimeUnit.MILLISECONDS); + fields.put("voltage_dev",3.6); + fields.put("uvoltage_dev",-2.6); + fields.put("ubalance",6); + fields.put("flicker",0.6); + fields.put("uaberrance",2); + fields.put("i_neg",20); + fields.put("uharm_2",0); + fields.put("uharm_3",0); + fields.put("uharm_4",0); + fields.put("uharm_5",0); + fields.put("uharm_6",0); + fields.put("uharm_7",0); + fields.put("uharm_8",0); + fields.put("uharm_9",0); + fields.put("uharm_10",0); + fields.put("uharm_11",10); + fields.put("uharm_12",0); + fields.put("uharm_13",0); + fields.put("uharm_14",0); + fields.put("uharm_15",0); + fields.put("uharm_16",15.3); + fields.put("uharm_17",0); + fields.put("uharm_18",0); + fields.put("uharm_19",0); + fields.put("uharm_20",0); + fields.put("uharm_21",0); + fields.put("uharm_22",0); + fields.put("uharm_23",0); + fields.put("uharm_24",0); + fields.put("uharm_25",0); + fields.put("iharm_2",0); + fields.put("iharm_3",0); + fields.put("iharm_4",0); + fields.put("iharm_5",6.02); + fields.put("iharm_6",0); + fields.put("iharm_7",0); + fields.put("iharm_8",0); + fields.put("iharm_9",0); + fields.put("iharm_10",0); + fields.put("iharm_11",0); + fields.put("iharm_12",0); + fields.put("iharm_13",0); + fields.put("iharm_14",0); + fields.put("iharm_15",3.25); + fields.put("iharm_16",0); + fields.put("iharm_17",0); + fields.put("iharm_18",0); + fields.put("iharm_19",0); + fields.put("iharm_20",0); + fields.put("iharm_21",0); + fields.put("iharm_22",0); + fields.put("iharm_23",0); + fields.put("iharm_24",3.52); + fields.put("iharm_25",0); + fields.put("inuharm_1",0); + fields.put("inuharm_2",0); + fields.put("inuharm_3",3.25); + fields.put("inuharm_4",0); + fields.put("inuharm_5",3.26); + fields.put("inuharm_6",0); + fields.put("inuharm_7",0); + fields.put("inuharm_8",0); + fields.put("inuharm_9",0); + fields.put("inuharm_10",0); + fields.put("inuharm_11",0); + fields.put("inuharm_12",6.25); + fields.put("inuharm_13",0); + fields.put("inuharm_14",0); + fields.put("inuharm_15",0); + fields.put("inuharm_16",0); + influxDBUtil.insert("pqs_abnormaldata", tags, fields, time, TimeUnit.MILLISECONDS); } diff --git a/pqs-common/common-web/pom.xml b/pqs-common/common-web/pom.xml index 3f04bbb03..269cd2967 100644 --- a/pqs-common/common-web/pom.xml +++ b/pqs-common/common-web/pom.xml @@ -53,6 +53,10 @@ com.nimbusds nimbus-jose-jwt + + org.influxdb + influxdb-java + diff --git a/pqs-common/common-web/src/main/java/com/njcn/web/utils/ComAssesUtil.java b/pqs-common/common-web/src/main/java/com/njcn/web/utils/ComAssesUtil.java index b264d2a1c..7050190b8 100644 --- a/pqs-common/common-web/src/main/java/com/njcn/web/utils/ComAssesUtil.java +++ b/pqs-common/common-web/src/main/java/com/njcn/web/utils/ComAssesUtil.java @@ -120,12 +120,13 @@ public class ComAssesUtil { for(int i=0;i @@ -15,9 +20,8 @@ import lombok.Setter; * @author cdf * @since 2022-01-07 */ -@Getter -@Setter -@TableName("pq_communicate") +@Data +@Measurement(name = "pqs_communicate") public class Communicate { private static final long serialVersionUID = 1L; @@ -25,21 +29,26 @@ public class Communicate { /** * 终端Id */ - private String id; - /** * 更新时间 */ - private LocalDateTime updateTime; + @Column(name = "time") + private Instant updateTime; + + @Column(name = "line_id") + private String id; + /** * 事件类型(0:中断;1:正常;2:退出) */ + @Column(name = "type") private Integer type; /** * 备注 */ + @Column(name = "description") private String remark; diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/SubstationDetailVO.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/SubstationDetailVO.java index 3422b87bd..dd4acaecb 100644 --- a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/SubstationDetailVO.java +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/SubstationDetailVO.java @@ -22,4 +22,6 @@ public class SubstationDetailVO implements Serializable { private Double coordX; private String color; + + private String scale; } diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/SubstationMapper.xml b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/SubstationMapper.xml index 7bcd82e1c..51d122ad9 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/SubstationMapper.xml +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/SubstationMapper.xml @@ -7,12 +7,16 @@ line.NAME srbName, sub.Lng coordY, sub.Lat coordX, - "blue" color + "blue" color, + dic.name scale FROM pq_line line, - pq_substation sub + pq_substation sub, + sys_dict_data dic WHERE line.Id = sub.Id + and + sub.scale = dic.id AND sub.Id IN diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/LineServiceImpl.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/LineServiceImpl.java index 24a5d6369..b4c693653 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/LineServiceImpl.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/LineServiceImpl.java @@ -21,6 +21,7 @@ import com.njcn.device.pojo.param.DeviceInfoParam; import com.njcn.device.pojo.po.*; import com.njcn.device.pojo.vo.*; import com.njcn.device.service.LineService; +import com.njcn.influxdb.param.InfluxDBPublicParam; import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.system.api.AreaFeignClient; import com.njcn.system.api.DicDataFeignClient; @@ -38,8 +39,10 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.text.SimpleDateFormat; +import java.time.Instant; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -152,18 +155,17 @@ public class LineServiceImpl extends ServiceImpl implements Li @Override public CommunicateVO getComFlagInfoData(String id, String searchBeginTime, String searchEndTime) { - DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - String devId = getLineIdByDevId(id); - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(Communicate::getId, devId) - .between(Communicate::getUpdateTime, PubUtils.beginTimeToLocalDateTime(searchBeginTime), PubUtils.endTimeToLocalDateTime(searchEndTime)); - queryWrapper.orderBy(true, true, "pq_communicate.update_time"); - List communicateList = communicateMapper.selectList(queryWrapper); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + List communicateList = getCommunicate(id,searchBeginTime,searchEndTime); CommunicateVO communicateVOList = new CommunicateVO(); List updateTime = new ArrayList<>(); List comType = new ArrayList<>(); for (Communicate communicate : communicateList) { - updateTime.add(df.format(communicate.getUpdateTime())); + //转化时间 + Instant now = communicate.getUpdateTime().plusMillis(TimeUnit.HOURS.toMillis(8)); + Long time = now.toEpochMilli(); + String timeText = df.format(time); + updateTime.add(timeText); comType.add(communicate.getType()); } communicateVOList.setUpdateTime(updateTime); @@ -541,6 +543,7 @@ public class LineServiceImpl extends ServiceImpl implements Li stringBuilder.append("dev_index ='").append(devIndexs.get(i)).append("' "); } } + stringBuilder.append(InfluxDBPublicParam.TIME_ZONE); String sql = "select sum(onlinemin)/(sum(onlinemin) +sum(offlinemin))*100 as onlinerate from pqs_onlinerate where " + stringBuilder.toString() + "group by dev_index"; //获取暂降事件 QueryResult result = influxDbUtils.query(sql); @@ -641,4 +644,17 @@ public class LineServiceImpl extends ServiceImpl implements Li return staticsValue; } + public List getCommunicate(String lineIndex, String startTime,String endTime) { + //组装sql语句 + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and "); + stringBuilder.append("line_id = '").append(lineIndex).append("' group by line_id ").append(InfluxDBPublicParam.TIME_ZONE); + String sql = "select * from "+InfluxDBPublicParam.PQS_COMMUNICATE+" where " + stringBuilder.toString(); + //获取暂降事件 + QueryResult result = influxDbUtils.query(sql); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List communicateList = influxDBResultMapper.toPOJO(result, Communicate.class); + return communicateList; + } + } diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/constant/Param.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/constant/Param.java index dc5600b82..7612d3869 100644 --- a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/constant/Param.java +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/constant/Param.java @@ -22,6 +22,7 @@ public interface Param { * 终端在线率表公共字段 */ String ONLINEMIN = "onlinemin"; + String OFFLINEMIN = "offlinemin"; /** diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/AssesServiceImpl.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/AssesServiceImpl.java index 089c4dcc7..e868eea18 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/AssesServiceImpl.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/AssesServiceImpl.java @@ -1,15 +1,18 @@ package com.njcn.harmonic.service.impl; +import com.njcn.device.pojo.po.Communicate; import com.njcn.harmonic.constant.Param; import com.njcn.harmonic.pojo.param.PulicTimeStatisParam; import com.njcn.harmonic.pojo.vo.AssesVO; import com.njcn.harmonic.service.AssesService; +import com.njcn.influxdb.param.InfluxDBPublicParam; import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.web.utils.ComAssesUtil; import com.njcn.web.utils.PqsComasses; import lombok.AllArgsConstructor; import org.apache.commons.lang.StringUtils; import org.influxdb.dto.QueryResult; +import org.influxdb.impl.InfluxDBResultMapper; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -48,88 +51,56 @@ public class AssesServiceImpl implements AssesService { * 查询监测点的数据完整性 */ private Float getCondition(String lineList, String startTime, String endTime) { - List pqsComasses = new ArrayList<>(); float synData; if (!lineList.isEmpty()) { //组装sql语句 StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(Param.TIME + " >= '").append(startTime).append(Param.START_TIME).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append(Param.END_TIME).append("' and ("); + stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and ("); //sql语句 - stringBuilder.append(Param.LINEID + "='").append(lineList).append("')"); + stringBuilder.append(InfluxDBPublicParam.LINE_ID + "='").append(lineList).append("')"); + stringBuilder.append(" group by " + InfluxDBPublicParam.LINE_ID).append(" "); + stringBuilder.append(InfluxDBPublicParam.TIME_ZONE); String sql = "SELECT" + - " MEAN(Freq_Dev1) AS freDev1," + - " MEAN(Freq_Dev2) AS freDev2," + - " MEAN(Freq_Dev3) AS freDev3," + - " MEAN(Freq_Dev4) AS freDev4," + - " MEAN(Freq_Dev5) AS freDev5," + - " MEAN(VU_Dev1) AS vuDev1," + - " MEAN(VU_Dev2) AS vuDev2," + - " MEAN(VU_Dev3) AS vuDev3," + - " MEAN(VU_Dev4) AS vuDev4," + - " MEAN(VU_Dev5) AS vuDev5," + - " MEAN(Data_PLT1) AS dataPlt1," + - " MEAN(Data_PLT2) AS dataPlt2," + - " MEAN(Data_PLT3) AS dataPlt3," + - " MEAN(Data_PLT4) AS dataPlt4," + - " MEAN(Data_PLT5) AS dataPlt5," + - " MEAN(V_Unbalance1) AS vUnbalance1," + - " MEAN(V_Unbalance2) AS vUnbalance2," + - " MEAN(V_Unbalance3) AS vUnbalance3," + - " MEAN(V_Unbalance4) AS vUnbalance4," + - " MEAN(V_Unbalance5) AS vUnbalance5," + - " MEAN(V_THD1) AS vThd1," + - " MEAN(V_THD2) AS vThd2," + - " MEAN(V_THD3) AS vThd3," + - " MEAN(V_THD4) AS vThd4," + - " MEAN(V_THD5) AS vThd5," + - " MEAN(Event1) AS event1," + - " MEAN(Event2) AS event2," + - " MEAN(Event3) AS event3," + - " MEAN(Event4) AS event4," + - " MEAN(Event5) AS event5" + + " MEAN(freq_dev1) AS freq_dev1," + + " MEAN(freq_dev2) AS freq_dev2," + + " MEAN(freq_dev3) AS freq_dev3," + + " MEAN(freq_dev4) AS freq_dev4," + + " MEAN(freq_dev5) AS freq_dev5," + + " MEAN(vu_dev1) AS vu_dev1," + + " MEAN(vu_dev2) AS vu_dev2," + + " MEAN(vu_dev3) AS vu_dev3," + + " MEAN(vu_dev4) AS vu_dev4," + + " MEAN(vu_dev5) AS vu_dev5," + + " MEAN(data_plt1) AS data_plt1," + + " MEAN(data_plt2) AS data_plt2," + + " MEAN(data_plt3) AS data_plt3," + + " MEAN(data_plt4) AS data_plt4," + + " MEAN(data_plt5) AS data_plt5," + + " MEAN(v_unbalance1) AS v_unbalance1," + + " MEAN(v_unbalance2) AS v_unbalance2," + + " MEAN(v_unbalance3) AS v_unbalance3," + + " MEAN(v_unbalance4) AS v_unbalance4," + + " MEAN(v_unbalance5) AS v_unbalance5," + + " MEAN(v_thd1) AS v_thd1," + + " MEAN(v_thd2) AS v_thd2," + + " MEAN(v_thd3) AS v_thd3," + + " MEAN(v_thd4) AS v_thd4," + + " MEAN(v_thd5) AS v_thd5," + + " MEAN(event1) AS event1," + + " MEAN(event2) AS event2," + + " MEAN(event3) AS event3," + + " MEAN(event4) AS event4," + + " MEAN(event5) AS event5" + " FROM" + - " PQS_COMASSES" + - " where " + stringBuilder.toString() + - " group by " + Param.LINEID; + " pqs_comasses" + + " where " + stringBuilder.toString(); //结果集 QueryResult result = influxDbUtils.query(sql); //处理结果集 - List list = result.getResults().get(0).getSeries(); - if (!CollectionUtils.isEmpty(list)) { - List> valueList = list.get(0).getValues(); - PqsComasses pqsComassesData = new PqsComasses(); - List value = valueList.get(0); - pqsComassesData.setFreqDev1(BigDecimal.valueOf(Float.parseFloat(value.get(1).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setFreqDev2(BigDecimal.valueOf(Float.parseFloat(value.get(2).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setFreqDev3(BigDecimal.valueOf(Float.parseFloat(value.get(3).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setFreqDev4(BigDecimal.valueOf(Float.parseFloat(value.get(4).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setFreqDev5(BigDecimal.valueOf(Float.parseFloat(value.get(5).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVuDev1(BigDecimal.valueOf(Float.parseFloat(value.get(6).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVuDev2(BigDecimal.valueOf(Float.parseFloat(value.get(7).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVuDev3(BigDecimal.valueOf(Float.parseFloat(value.get(8).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVuDev4(BigDecimal.valueOf(Float.parseFloat(value.get(9).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVuDev5(BigDecimal.valueOf(Float.parseFloat(value.get(10).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setDataPst1(BigDecimal.valueOf(Float.parseFloat(value.get(11).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setDataPst2(BigDecimal.valueOf(Float.parseFloat(value.get(12).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setDataPst3(BigDecimal.valueOf(Float.parseFloat(value.get(13).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setDataPst4(BigDecimal.valueOf(Float.parseFloat(value.get(14).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setDataPst5(BigDecimal.valueOf(Float.parseFloat(value.get(15).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVUnbalance1(BigDecimal.valueOf(Float.parseFloat(value.get(16).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVUnbalance2(BigDecimal.valueOf(Float.parseFloat(value.get(17).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVUnbalance3(BigDecimal.valueOf(Float.parseFloat(value.get(18).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVUnbalance4(BigDecimal.valueOf(Float.parseFloat(value.get(19).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVUnbalance5(BigDecimal.valueOf(Float.parseFloat(value.get(20).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVThd1(BigDecimal.valueOf(Float.parseFloat(value.get(21).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVThd2(BigDecimal.valueOf(Float.parseFloat(value.get(22).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVThd3(BigDecimal.valueOf(Float.parseFloat(value.get(23).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVThd4(BigDecimal.valueOf(Float.parseFloat(value.get(24).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setVThd5(BigDecimal.valueOf(Float.parseFloat(value.get(25).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setEvent1(BigDecimal.valueOf(Float.parseFloat(value.get(26).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setEvent2(BigDecimal.valueOf(Float.parseFloat(value.get(27).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setEvent3(BigDecimal.valueOf(Float.parseFloat(value.get(28).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setEvent4(BigDecimal.valueOf(Float.parseFloat(value.get(29).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComassesData.setEvent5(BigDecimal.valueOf(Float.parseFloat(value.get(30).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue()); - pqsComasses.add(pqsComassesData); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List communicateList = influxDBResultMapper.toPOJO(result, PqsComasses.class); + if (!CollectionUtils.isEmpty(communicateList)) { + synData = comAssesUtil.getAllComAss(communicateList); } else { //有监测点,但是无数据的处理 return 3.14159f; @@ -138,7 +109,6 @@ public class AssesServiceImpl implements AssesService { //无监测点前台统一替换为“/” return 3.1415f; } - synData = comAssesUtil.getAllComAss(pqsComasses); return synData; } } diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/CommunicateServiceImpl.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/CommunicateServiceImpl.java index fd4a8abf3..6196cac30 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/CommunicateServiceImpl.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/CommunicateServiceImpl.java @@ -7,6 +7,7 @@ import com.njcn.harmonic.pojo.param.PulicTimeParam; import com.njcn.harmonic.pojo.param.PulicTimeStatisParam; import com.njcn.harmonic.pojo.vo.CommunicateStatisticsVO; import com.njcn.harmonic.service.CommunicateService; +import com.njcn.influxdb.param.InfluxDBPublicParam; import com.njcn.influxdb.utils.InfluxDbUtils; import lombok.AllArgsConstructor; import org.apache.commons.lang.StringUtils; @@ -63,16 +64,17 @@ public class CommunicateServiceImpl implements CommunicateService { final Float[] resultList = {0.0f}; //组装sql语句 StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(Param.TIME + " >= '").append(startTime).append(Param.START_TIME).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append(Param.END_TIME).append("' and ("); + stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and ("); //sql语句 String sql = ""; if (state == 0) { - stringBuilder.append(Param.LINE_INDEX + "='").append(lineList).append("')"); - sql = "SELECT SUM(" + Param.REAL + ")/SUM(" + Param.DUE + ") AS integrity FROM PQS_INTEGRITY WHERE " + stringBuilder.toString() + " group by " + Param.LINE_INDEX; + stringBuilder.append(InfluxDBPublicParam.LINE_ID + "='").append(lineList).append("')"); + sql = "SELECT SUM(" + InfluxDBPublicParam.REAL+ ")/SUM(" + InfluxDBPublicParam.DUE + ") AS integrity FROM pqs_integrity WHERE " + stringBuilder.toString() + " group by " + InfluxDBPublicParam.LINE_ID; } else { - stringBuilder.append(Param.DEV_INDEX + "='").append(lineList).append("')"); - sql = "SELECT SUM(" + Param.ONLINEMIN + ")/(SUM(" + Param.OFFLINEMIN + ")+SUM(" + Param.ONLINEMIN + ")) AS onlineRate FROM PQS_ONLINERATE WHERE " + stringBuilder.toString() + " group by " + Param.DEV_INDEX; + stringBuilder.append(InfluxDBPublicParam.DEV_INDEX + "='").append(lineList).append("')"); + sql = "SELECT SUM(" + InfluxDBPublicParam.ONLINEMIN + ")/(SUM(" + InfluxDBPublicParam.OFFLINEMIN + ")+SUM(" + InfluxDBPublicParam.ONLINEMIN + ")) AS onlineRate FROM pqs_onlinerate WHERE " + stringBuilder.toString() + " group by " + InfluxDBPublicParam.DEV_INDEX; } + stringBuilder.append(InfluxDBPublicParam.TIME_ZONE); //结果集 QueryResult result = influxDbUtils.query(sql); //处理结果集 diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java index 0f6e86a6e..beade5525 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java @@ -25,8 +25,10 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.time.Instant; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.TimeUnit; /** * @author denghuajun @@ -45,19 +47,22 @@ public class HistoryResultServiceImpl implements HistoryResultService { @Override public List getHistoryResult(HistoryParam historyParam) { List historyDataResultVOList = new ArrayList<>(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); //获取监测点 String[] points = historyParam.getLineId(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); Integer number = 0; for (int i = 0; i < points.length; i++) { HistoryDataResultVO historyDataResultVO; - List eventDetailList = eventDetailFeignClient.getEventDetailData(points[i],historyParam.getSearchBeginTime(),historyParam.getSearchEndTime()).getData(); + List eventDetailList = eventDetailFeignClient.getEventDetailData(points[i], historyParam.getSearchBeginTime(), historyParam.getSearchEndTime()).getData(); List eventDetailVOList = new ArrayList<>(); if (!eventDetailList.isEmpty()) { for (EventDetail eventdetail : eventDetailList) { + Instant now = eventdetail.getTimeId().plusMillis(TimeUnit.HOURS.toMillis(8)); + Long time = now.toEpochMilli(); + String timeText = format.format(time); EventDetailVO eventDetailVO = new EventDetailVO(); - eventDetailVO.setId(eventdetail.getId()); - eventDetailVO.setTime(formatter.format(eventdetail.getTimeId())); + eventDetailVO.setId(eventdetail.getLineId()); + eventDetailVO.setTime(timeText); eventDetailVOList.add(eventDetailVO); } } @@ -110,12 +115,12 @@ public class HistoryResultServiceImpl implements HistoryResultService { List fValue = new ArrayList<>(); List> objectListData = new ArrayList<>(); if (!CollectionUtils.isEmpty(list)) { - if (queryResult.getResults().size() == 1) { + if (list.size() == 1) { List> listData = queryResult.getResults().get(0).getSeries().get(0).getValues(); for (int i = 0; i < listData.size(); i++) { List objectList = listData.get(i); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); - TimeZone tx = TimeZone.getTimeZone("Asia/Kolkata"); + TimeZone tx = TimeZone.getTimeZone("Asia/Shanghai"); formatter.setTimeZone(tx); Date d = formatter.parse(objectList.get(0).toString()); time.add(d); @@ -133,14 +138,13 @@ public class HistoryResultServiceImpl implements HistoryResultService { historyDataResultVO.setValue(objectListData); } else { - for (int i = 0; i < queryResult.getResults().size(); i++) { - List listData = queryResult.getResults().get(i).getSeries(); - List> values = listData.get(0).getValues(); + for (int i = 0; i < list.size(); i++) { + List> values = list.get(i).getValues(); for (int j = 0; j < values.size(); j++) { List objectList = values.get(j); if (i == 0) { - DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); - TimeZone tx = TimeZone.getTimeZone("Asia/Kolkata"); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); + TimeZone tx = TimeZone.getTimeZone("Asia/Shanghai"); formatter.setTimeZone(tx); Date d = formatter.parse(objectList.get(0).toString()); time.add(d); @@ -208,7 +212,9 @@ public class HistoryResultServiceImpl implements HistoryResultService { default: break; } - stringBuilder.append(" and ").append(Param.VALUETYPE + "='").append(valueTypeName).append("'"); + if (Integer.parseInt(contion) != 60 || Integer.parseInt(contion) != 61 || Integer.parseInt(contion) != 62) { + stringBuilder.append(" and ").append(Param.VALUETYPE + "='").append(valueTypeName).append("'"); + } String sql = ""; List phasicType = new ArrayList<>(); List unit = new ArrayList<>(); @@ -705,7 +711,9 @@ public class HistoryResultServiceImpl implements HistoryResultService { } else if ("C".equals(normHistoryParam.getPhaseType()) || "CA".equals(normHistoryParam.getPhaseType())) { phasicType = "C"; } - stringBuilder.append(" and ").append(Param.VALUETYPE + "='").append(valueTypeName).append("'"); + if (Integer.parseInt(normHistoryParam.getTargetCode()) != 60 || Integer.parseInt(normHistoryParam.getTargetCode()) != 61 || Integer.parseInt(normHistoryParam.getTargetCode()) != 62) { + stringBuilder.append(" and ").append(Param.VALUETYPE + "='").append(valueTypeName).append("'"); + } stringBuilder.append(" and ").append("phasic_type ='").append(phasicType).append("'"); String sql = ""; List unit = new ArrayList<>(); @@ -715,7 +723,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { case 12: //电压偏差 sql = "SELECT time as time, vu_dev as aValue FROM data_v WHERE " + stringBuilder.toString() + - " order by time asc;"; + " order by time asc tz('Asia/Shanghai');"; topLimit = overlimit.getVoltageDev(); lowerLimit = overlimit.getUvoltageDev(); unit.add("%"); @@ -724,7 +732,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { case 13: //三相电压不平衡度 sql = "SELECT time as time, v_unbalance as aValue FROM data_v WHERE " + stringBuilder.toString() + - " order by time asc;"; + " order by time asc tz('Asia/Shanghai');"; topLimit = overlimit.getUbalance(); unit.add("%"); targetName = "三相电压不平衡度"; @@ -732,7 +740,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { case 15: //电压总谐波畸变率 sql = "SELECT time as time, v_thd as aValue FROM data_v WHERE " + stringBuilder.toString() + - " order by time asc;"; + " order by time asc tz('Asia/Shanghai');"; topLimit = overlimit.getUaberrance(); unit.add("%"); targetName = "电压总谐波畸变率"; @@ -740,7 +748,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { case 22: //负序电流 sql = "SELECT time as time, i_neg as aValue FROM data_i WHERE " + stringBuilder.toString() + - " order by time asc;"; + " order by time asc tz('Asia/Shanghai');"; topLimit = overlimit.getINeg(); unit.add("A"); targetName = "负序电流"; @@ -748,7 +756,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { case 30: //频率 V9暂时代表Freq sql = "SELECT time as time, freq as aValue FROM data_v WHERE " + stringBuilder.toString() + - " and phasic_type ='T' order by time asc;"; + " and phasic_type ='T' order by time asc tz('Asia/Shanghai');"; topLimit = 50 + overlimit.getFreqDev(); lowerLimit = 50 - overlimit.getFreqDev(); unit.add("Hz"); @@ -757,11 +765,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { case 40: //谐波电压含有率 sql = "SELECT time as time, v_" + number + " as aValue FROM data_harmrate_v WHERE " + stringBuilder.toString() + - " and phasic_type ='A' order by time asc;" + - "SELECT time as time, v_" + number + " as bValue FROM data_harmrate_v WHERE " + stringBuilder.toString() + - " and phasic_type ='B' order by time asc;" + - "SELECT time as time, v_" + number + " as cValue FROM data_harmrate_v WHERE " + stringBuilder.toString() + - " and phasic_type ='C' order by time asc;"; + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') group by phasic_type order by time asc tz('Asia/Shanghai');"; topLimit = PubUtils.getValueByMethod(overlimit, "getUharm", number); unit.add("%"); targetName = "谐波电压含有率"; @@ -769,22 +773,14 @@ public class HistoryResultServiceImpl implements HistoryResultService { case 41: //谐波电流含有率 sql = "SELECT time as time, i_" + number + " as aValue FROM data_harmrate_i WHERE " + stringBuilder.toString() + - " and phasic_type ='A' order by time asc;" + - "SELECT time as time, i_" + number + " as bValue FROM data_harmrate_i WHERE " + stringBuilder.toString() + - " and phasic_type ='B' order by time asc;" + - "SELECT time as time, i_" + number + " as cValue FROM data_harmrate_i WHERE " + stringBuilder.toString() + - " and phasic_type ='C' order by time asc;"; + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') group by phasic_type order by time asc tz('Asia/Shanghai');"; unit.add("%"); targetName = "谐波电流含有率"; break; case 43: //谐波电流幅值 sql = "SELECT time as time, i_" + number + " as aValue FROM data_i WHERE " + stringBuilder.toString() + - " and phasic_type ='A' order by time asc;" + - "SELECT time as time, i_" + number + " as bValue FROM data_i WHERE " + stringBuilder.toString() + - " and phasic_type ='B' order by time asc;" + - "SELECT time as time, i_" + number + " as cValue FROM data_i WHERE " + stringBuilder.toString() + - " and phasic_type ='C' order by time asc;"; + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') group by phasic_type order by time asc tz('Asia/Shanghai');"; topLimit = PubUtils.getValueByMethod(overlimit, "getIharm", number); unit.add("A"); targetName = "谐波电流幅值"; @@ -793,11 +789,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { case 46: //间谐波电压含有率 sql = "SELECT time as time, v_" + number + " as aValue FROM data_inharmrate_v WHERE " + stringBuilder.toString() + - " and phasic_type ='A' order by time asc;" + - "SELECT time as time, v_" + number + " as bValue FROM data_inharmrate_v WHERE " + stringBuilder.toString() + - " and phasic_type ='B' order by time asc;" + - "SELECT time as time, v_" + number + " as cValue FROM data_inharmrate_v WHERE " + stringBuilder.toString() + - " and phasic_type ='C' order by time asc;"; + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') group by phasic_type order by time asc tz('Asia/Shanghai');"; topLimit = PubUtils.getValueByMethod(overlimit, "getInuharm", number); unit.add("%"); targetName = "间谐波电压含有率"; @@ -805,11 +797,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { case 61: //长时闪变 sql = "SELECT time as time, plt as aValue FROM data_plt WHERE " + stringBuilder.toString() + - " and phasic_type ='A' order by time asc;" + - "SELECT time as time, plt as bValue FROM data_plt WHERE " + stringBuilder.toString() + - " and phasic_type ='B' order by time asc;" + - "SELECT time as time, plt as cValue FROM data_plt WHERE " + stringBuilder.toString() + - " and phasic_type ='C' order by time asc;"; + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') group by phasic_type order by time asc tz('Asia/Shanghai');"; targetName = "长时闪变"; topLimit = overlimit.getFlicker(); break; diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/NormLimitServiceImpl.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/NormLimitServiceImpl.java index fda220673..245bacb31 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/NormLimitServiceImpl.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/NormLimitServiceImpl.java @@ -6,6 +6,7 @@ import com.njcn.harmonic.constant.Param; import com.njcn.harmonic.pojo.param.HistoryHarmOverLimitParam; import com.njcn.harmonic.pojo.vo.HistoryHarmOverLimitVO; import com.njcn.harmonic.service.NormLimitService; +import com.njcn.influxdb.param.InfluxDBPublicParam; import com.njcn.influxdb.utils.InfluxDbUtils; import lombok.AllArgsConstructor; import lombok.SneakyThrows; @@ -13,10 +14,17 @@ import org.influxdb.dto.QueryResult; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.sql.Timestamp; import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.TimeZone; +import java.util.concurrent.TimeUnit; /** * 类介绍 @@ -94,105 +102,48 @@ public class NormLimitServiceImpl implements NormLimitService { if (!lineList.isEmpty()) { //组装sql语句 StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(Param.TIME + " >= '").append(startTime).append(Param.START_TIME).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append(Param.END_TIME).append("' and ("); + stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and ("); //sql语句 - stringBuilder.append("lineid='").append(lineList).append("')"); + stringBuilder.append(InfluxDBPublicParam.LINE_ID).append("='").append(lineList).append("')"); String sql; switch (Integer.parseInt(contion)) { case 12: //电压偏差 - sql = "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, Voltage_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'CP95' order by time asc;"; + sql = "SELECT time as time, voltage_dev as aValue,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() + + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " + + " and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');"; queryResult = influxDbUtils.query(sql); historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "电压偏差", "%"); break; case 13: //三相电压不平衡度 - sql = "SELECT time as time, UBalance as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, UBalance as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, UBalance as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, UBalance as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'CP95' order by time asc;"; + sql = "SELECT time as time, ubalance as aValue,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() + + " and (phasic_type ='T') " + + " and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');"; queryResult = influxDbUtils.query(sql); historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "三相电压不平衡度", "/"); break; case 15: //电压总谐波畸变率 - sql = "SELECT time as time, UAberrance as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, UAberrance as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A'and value_type = 'MIN' order by time asc;" + - "SELECT time as time, UAberrance as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, UAberrance as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'CP95' and value_type = 'AVG' order by time asc;" + - " SELECT time as time, UAberrance as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, UAberrance as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, UAberrance as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'AVG' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, UAberrance as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, UAberrance as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, UAberrance as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, UAberrance as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, UAberrance as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'CP95' order by time asc;"; + sql = "SELECT time as time, uaberrance as aValue,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() + + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " + + " and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');"; queryResult = influxDbUtils.query(sql); historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "电压总谐波畸变率", "%"); break; case 22: //负序电流 - sql = "SELECT time as time, I_Neg as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, I_Neg as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, I_Neg as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, I_Neg as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'CP95' order by time asc;"; + sql = "SELECT time as time, i_neg as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() + + " and (phasic_type ='T') " + + " and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');"; queryResult = influxDbUtils.query(sql); historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "负序电流", "/"); break; case 30: //频率 V9暂时代表Freq - sql = "SELECT time as time, Freq_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, Freq_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, Freq_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, Freq_Dev as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='T' and value_type = 'CP95' order by time asc;"; + sql = "SELECT time as time, freq_dev as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() + + " and (phasic_type ='T') " + + " and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');"; queryResult = influxDbUtils.query(sql); historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "频率", "Hz"); break; @@ -200,30 +151,9 @@ public class NormLimitServiceImpl implements NormLimitService { for (int i = 0; i < number.length; i++) { List harmOverLimitVOList; //谐波电压含有率 - sql = "SELECT time as time, UHarm_" + number[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, UHarm_" + number[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'CP95' order by time asc;"; + sql = "SELECT time as time, uharm_" + number[i] + " as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() + + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " + + " and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');"; queryResult = influxDbUtils.query(sql); harmOverLimitVOList = getNormData(queryResult, contion, lineList, "谐波电压含有率", "%", number[i]); historyHarmOverLimitVOList.addAll(harmOverLimitVOList); @@ -233,30 +163,9 @@ public class NormLimitServiceImpl implements NormLimitService { for (int i = 0; i < number.length; i++) { List harmOverLimitVOList; //谐波电流幅值 - sql = "SELECT time as time, IHarm_" + number[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, IHarm_" + number[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'CP95' order by time asc;"; + sql = "SELECT time as time, iharm_" + number[i] + " as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() + + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " + + " and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');"; queryResult = influxDbUtils.query(sql); harmOverLimitVOList = getNormData(queryResult, contion, lineList, "谐波电流幅值", "A", number[i]); historyHarmOverLimitVOList.addAll(harmOverLimitVOList); @@ -266,30 +175,9 @@ public class NormLimitServiceImpl implements NormLimitService { for (int i = 0; i < inHarmNum.length; i++) { List harmOverLimitVOList; //间谐波电压含有率 - sql = "SELECT time as time, InUHARM_" + inHarmNum[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, InUHARM_" + inHarmNum[i] + " as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'CP95' order by time asc;"; + sql = "SELECT time as time, inuharm_" + inHarmNum[i] + " as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() + + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " + + " and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');"; queryResult = influxDbUtils.query(sql); harmOverLimitVOList = getNormData(queryResult, contion, lineList, "间谐波电压含有率", "%", inHarmNum[i]); historyHarmOverLimitVOList.addAll(harmOverLimitVOList); @@ -297,30 +185,9 @@ public class NormLimitServiceImpl implements NormLimitService { break; case 61: //长时闪变 - sql = "SELECT time as time, Flicker as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, Flicker as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, Flicker as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, Flicker as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='A' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, Flicker as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, Flicker as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, Flicker as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, Flicker as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='B' and value_type = 'CP95' order by time asc;" + - "SELECT time as time, Flicker as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MAX' order by time asc;" + - "SELECT time as time, Flicker as aValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'MIN' order by time asc;" + - "SELECT time as time, Flicker as bValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'AVG' order by time asc;" + - "SELECT time as time, Flicker as cValue FROM PQS_AbnormalData WHERE " + stringBuilder.toString() + - " and phasic_type ='C' and value_type = 'CP95' order by time asc;"; + sql = "SELECT time as time, flicker as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() + + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " + + " and (value_type = 'AVG') group by phasic_type order by time asc tz('Asia/Shanghai');"; queryResult = influxDbUtils.query(sql); historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "长时闪变", "/"); break; @@ -342,143 +209,170 @@ public class NormLimitServiceImpl implements NormLimitService { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + //获取监测点详情 LineDetailDataVO lineDetailDataVO = lineFeignClient.getLineDetailData(lineList).getData(); if (!CollectionUtils.isEmpty(qusery.get(0).getSeries())) { String time = ""; Float aMax = 0.0f, aMin = 0.0f, aAvg = 0.0f, aCp95 = 0.0f, bMax = 0.0f, bMin = 0.0f, bAvg = 0.0f, bCp95 = 0.0f, cMax = 0.0f, cMin = 0.0f, cAvg = 0.0f, cCp95 = 0.0f; - for (int i = 0; i < qusery.get(0).getSeries().get(0).getValues().size(); i++) { - HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO(); - //A相的最大值 - if (!CollectionUtils.isEmpty(qusery.get(0).getSeries())) { - aMax = Float.parseFloat(qusery.get(0).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVO.setMaxValue(aMax); + for (int i = 0; i < qusery.get(0).getSeries().size(); i++) { + List columns = qusery.get(0).getSeries().get(i).getColumns(); + if (qusery.get(0).getSeries().get(i).getTags().get("phasic_type").equals("A")) { + HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO(); + if (!CollectionUtils.isEmpty(qusery.get(0).getSeries().get(i).getValues())) { + for (int j = 0; j < qusery.get(0).getSeries().get(i).getValues().size(); j++) { + List objectList = qusery.get(0).getSeries().get(i).getValues().get(j); + String aa = String.valueOf(objectList.get(0)); + Date sd = dateFormat.parse(aa); + time = dateFormat.format(sd); + if (Integer.parseInt(contion) == 61) { + historyDataResultVO.setMaxValue((float) 3.14159); + historyDataResultVO.setMinValue((float) 3.14159); + historyDataResultVO.setCp95Value((float) 3.14159); + aAvg = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setAvgValue(aAvg); + } else { + if (objectList.get(3).equals("MAX")) { + aMax = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setMaxValue(aMax); + } else if (objectList.get(3).equals("MIN")) { + aMin = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setMinValue(aMin); + } else if (objectList.get(3).equals("AVG")) { + aAvg = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setAvgValue(aAvg); + } else if (objectList.get(3).equals("CP95")) { + aCp95 = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setCp95Value(aCp95); + } + } + } + } + historyDataResultVO.setTime(time); + historyDataResultVO.setLineName(lineDetailDataVO.getLineName()); + historyDataResultVO.setLineId(lineList); + historyDataResultVO.setNumber(0); + historyDataResultVO.setSubName(lineDetailDataVO.getBdName()); + historyDataResultVO.setTargetCode(contion); + historyDataResultVO.setTargetName(phaseName); + if (Integer.parseInt(contion) == 12 || Integer.parseInt(contion) == 15) { + historyDataResultVO.setPhaseType("A"); + historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aMin) ? 3 : 2); + } else if (Integer.parseInt(contion) == 13 || Integer.parseInt(contion) == 22) { + historyDataResultVO.setPhaseType("/"); + historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aCp95) ? 3 : 4); + } else { + historyDataResultVO.setPhaseType("A"); + historyDataResultVO.setStatisticalType(3); + } + historyDataResultVO.setScale(lineDetailDataVO.getScale()); + historyDataResultVO.setUnit(unit); + historyHarmOverLimitVOList.add(historyDataResultVO); } - //A相的最小值 - if (!CollectionUtils.isEmpty(qusery.get(1).getSeries())) { - aMin = Float.parseFloat(qusery.get(1).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVO.setMinValue(aMin); - } - //A相的评价值 - if (!CollectionUtils.isEmpty(qusery.get(2).getSeries())) { - aAvg = Float.parseFloat(qusery.get(2).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVO.setAvgValue(aAvg); - } - //A相的CP95 - if (!CollectionUtils.isEmpty(qusery.get(3).getSeries())) { - time = String.valueOf(qusery.get(3).getSeries().get(0).getValues().get(i).get(0)); - aCp95 = Float.parseFloat(qusery.get(3).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVO.setTime(dateFormat.format(sdf.parse(time))); - historyDataResultVO.setCp95Value(aCp95); - } - historyDataResultVO.setLineName(lineDetailDataVO.getLineName()); - historyDataResultVO.setLineId(lineList); - historyDataResultVO.setNumber(0); - historyDataResultVO.setSubName(lineDetailDataVO.getBdName()); - historyDataResultVO.setTargetCode(contion); - historyDataResultVO.setTargetName(phaseName); - if (Integer.parseInt(contion)==12 || Integer.parseInt(contion)==15){ - historyDataResultVO.setPhaseType("A"); - historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aMin) ? 3 : 2); - }else if(Integer.parseInt(contion)==13 || Integer.parseInt(contion)==22){ - historyDataResultVO.setPhaseType("/"); - historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aCp95) ? 3 : 4); - }else { - historyDataResultVO.setPhaseType("A"); - historyDataResultVO.setStatisticalType(3); - } - historyDataResultVO.setScale(lineDetailDataVO.getScale()); - historyDataResultVO.setUnit(unit); - historyHarmOverLimitVOList.add(historyDataResultVO); - } - if ("12".equals(contion) || "15".equals(contion) || "40".equals(contion) || "61".equals(contion)) { - for (int i = 0; i < qusery.get(4).getSeries().get(0).getValues().size(); i++) { - HistoryHarmOverLimitVO historyDataResultVOB = new HistoryHarmOverLimitVO(); - //B相的最大值 - if (!CollectionUtils.isEmpty(qusery.get(4).getSeries())) { - bMax = Float.parseFloat(qusery.get(4).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVOB.setMaxValue(bMax); + if ("12".equals(contion) || "15".equals(contion) || "40".equals(contion) || "61".equals(contion)) { + if (qusery.get(0).getSeries().get(i).getTags().get("phasic_type").equals("B")) { + HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO(); + if (!CollectionUtils.isEmpty(qusery.get(0).getSeries().get(i).getValues())) { + for (int j = 0; j < qusery.get(0).getSeries().get(i).getValues().size(); j++) { + List objectList = qusery.get(0).getSeries().get(i).getValues().get(j); + String aa = String.valueOf(objectList.get(0)); + Date sd = dateFormat.parse(aa); + time = dateFormat.format(sd); + if (Integer.parseInt(contion) == 61) { + historyDataResultVO.setMaxValue((float) 3.14159); + historyDataResultVO.setMinValue((float) 3.14159); + historyDataResultVO.setCp95Value((float) 3.14159); + aAvg = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setAvgValue(aAvg); + } else { + if (objectList.get(3).equals("MAX")) { + bMax = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setMaxValue(bMax); + } else if (objectList.get(3).equals("MIN")) { + bMin = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setMinValue(bMin); + } else if (objectList.get(3).equals("AVG")) { + bAvg = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setAvgValue(bAvg); + } else if (objectList.get(3).equals("CP95")) { + bCp95 = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setCp95Value(bCp95); + } + } + } + } + historyDataResultVO.setTime(time); + historyDataResultVO.setLineName(lineDetailDataVO.getLineName()); + historyDataResultVO.setLineId(lineList); + historyDataResultVO.setNumber(0); + historyDataResultVO.setSubName(lineDetailDataVO.getBdName()); + historyDataResultVO.setTargetCode(contion); + historyDataResultVO.setTargetName(phaseName); + if (Integer.parseInt(contion) == 12 || Integer.parseInt(contion) == 15) { + historyDataResultVO.setPhaseType("B"); + historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aMin) ? 3 : 2); + } else if (Integer.parseInt(contion) == 13 || Integer.parseInt(contion) == 22) { + historyDataResultVO.setPhaseType("/"); + historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aCp95) ? 3 : 4); + } else { + historyDataResultVO.setPhaseType("B"); + historyDataResultVO.setStatisticalType(3); + } + historyDataResultVO.setScale(lineDetailDataVO.getScale()); + historyDataResultVO.setUnit(unit); + historyHarmOverLimitVOList.add(historyDataResultVO); + } else if (qusery.get(0).getSeries().get(i).getTags().get("phasic_type").equals("C")) { + if (!CollectionUtils.isEmpty(qusery.get(0).getSeries().get(i).getValues())) { + HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO(); + for (int j = 0; j < qusery.get(0).getSeries().get(i).getValues().size(); j++) { + List objectList = qusery.get(0).getSeries().get(i).getValues().get(j); + String aa = String.valueOf(objectList.get(0)); + Date sd = dateFormat.parse(aa); + time = dateFormat.format(sd); + if (Integer.parseInt(contion) == 61) { + historyDataResultVO.setMaxValue((float) 3.14159); + historyDataResultVO.setMinValue((float) 3.14159); + historyDataResultVO.setCp95Value((float) 3.14159); + aAvg = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setAvgValue(aAvg); + } else { + if (objectList.get(3).equals("MAX")) { + cMax = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setMaxValue(cMax); + } else if (objectList.get(3).equals("MIN")) { + cMin = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setMinValue(cMin); + } else if (objectList.get(3).equals("AVG")) { + cAvg = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setAvgValue(cAvg); + } else if (objectList.get(3).equals("CP95")) { + cCp95 = Float.parseFloat(String.valueOf(objectList.get(1))); + historyDataResultVO.setCp95Value(cCp95); + } + } + } + historyDataResultVO.setTime(time); + historyDataResultVO.setLineName(lineDetailDataVO.getLineName()); + historyDataResultVO.setLineId(lineList); + historyDataResultVO.setNumber(0); + historyDataResultVO.setSubName(lineDetailDataVO.getBdName()); + historyDataResultVO.setTargetCode(contion); + historyDataResultVO.setTargetName(phaseName); + if (Integer.parseInt(contion) == 12 || Integer.parseInt(contion) == 15) { + historyDataResultVO.setPhaseType("C"); + historyDataResultVO.setStatisticalType(Math.abs(cMax) > Math.abs(cMin) ? 3 : 2); + } else if (Integer.parseInt(contion) == 13 || Integer.parseInt(contion) == 22) { + historyDataResultVO.setPhaseType("/"); + historyDataResultVO.setStatisticalType(Math.abs(cMax) > Math.abs(cCp95) ? 3 : 4); + } else { + historyDataResultVO.setPhaseType("C"); + historyDataResultVO.setStatisticalType(3); + } + historyDataResultVO.setScale(lineDetailDataVO.getScale()); + historyDataResultVO.setUnit(unit); + historyHarmOverLimitVOList.add(historyDataResultVO); + } } - //B相的最小值 - if (!CollectionUtils.isEmpty(qusery.get(5).getSeries())) { - bMin = Float.parseFloat(qusery.get(5).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVOB.setMinValue(bMin); - } - //B相的平均值 - if (!CollectionUtils.isEmpty(qusery.get(6).getSeries())) { - bAvg = Float.parseFloat(qusery.get(6).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVOB.setAvgValue(bAvg); - } - //B相的CP95 - if (!CollectionUtils.isEmpty(qusery.get(7).getSeries())) { - time = String.valueOf(qusery.get(7).getSeries().get(0).getValues().get(i).get(0)); - bCp95 = Float.parseFloat(qusery.get(7).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVOB.setTime(dateFormat.format(sdf.parse(time))); - historyDataResultVOB.setCp95Value(bCp95); - } - historyDataResultVOB.setLineName(lineDetailDataVO.getLineName()); - historyDataResultVOB.setLineId(lineList); - historyDataResultVOB.setNumber(0); - historyDataResultVOB.setSubName(lineDetailDataVO.getBdName()); - historyDataResultVOB.setTargetCode(contion); - historyDataResultVOB.setTargetName(phaseName); - if (Integer.parseInt(contion)==12 || Integer.parseInt(contion)==15){ - historyDataResultVOB.setPhaseType("B"); - historyDataResultVOB.setStatisticalType(Math.abs(aMax) > Math.abs(aMin) ? 3 : 2); - }else if(Integer.parseInt(contion)==13 || Integer.parseInt(contion)==22){ - historyDataResultVOB.setPhaseType("/"); - historyDataResultVOB.setStatisticalType(Math.abs(aMax) > Math.abs(aCp95) ? 3 : 4); - }else { - historyDataResultVOB.setPhaseType("B"); - historyDataResultVOB.setStatisticalType(3); - } - historyDataResultVOB.setScale(lineDetailDataVO.getScale()); - historyDataResultVOB.setUnit(unit); - historyHarmOverLimitVOList.add(historyDataResultVOB); - } - for (int i = 0; i < qusery.get(8).getSeries().get(0).getValues().size(); i++) { - HistoryHarmOverLimitVO historyDataResultVOC = new HistoryHarmOverLimitVO(); - //C相的最大值 - if (!CollectionUtils.isEmpty(qusery.get(8).getSeries())) { - cMax = Float.parseFloat(qusery.get(8).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVOC.setMaxValue(cMax); - } - //C相的最小值 - if (!CollectionUtils.isEmpty(qusery.get(9).getSeries())) { - cMin = Float.parseFloat(qusery.get(9).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVOC.setMinValue(cMin); - } - //C相的平均值 - if (!CollectionUtils.isEmpty(qusery.get(10).getSeries())) { - cAvg = Float.parseFloat(qusery.get(10).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVOC.setAvgValue(cAvg); - } - //C相的CP95 - if (!CollectionUtils.isEmpty(qusery.get(11).getSeries())) { - time = String.valueOf(qusery.get(11).getSeries().get(0).getValues().get(i).get(0)); - cCp95 = Float.parseFloat(qusery.get(11).getSeries().get(0).getValues().get(i).get(1).toString()); - historyDataResultVOC.setTime(dateFormat.format(sdf.parse(time))); - historyDataResultVOC.setCp95Value(cCp95); - } - historyDataResultVOC.setLineName(lineDetailDataVO.getLineName()); - historyDataResultVOC.setLineId(lineList); - historyDataResultVOC.setNumber(0); - historyDataResultVOC.setSubName(lineDetailDataVO.getBdName()); - historyDataResultVOC.setTargetCode(contion); - historyDataResultVOC.setTargetName(phaseName); - if (Integer.parseInt(contion)==12 || Integer.parseInt(contion)==15){ - historyDataResultVOC.setPhaseType("C"); - historyDataResultVOC.setStatisticalType(Math.abs(aMax) > Math.abs(aMin) ? 3 : 2); - }else if(Integer.parseInt(contion)==13 || Integer.parseInt(contion)==22){ - historyDataResultVOC.setPhaseType("/"); - historyDataResultVOC.setStatisticalType(Math.abs(aMax) > Math.abs(aCp95) ? 3 : 4); - }else { - historyDataResultVOC.setPhaseType("C"); - historyDataResultVOC.setStatisticalType(3); - } - historyDataResultVOC.setScale(lineDetailDataVO.getScale()); - historyDataResultVOC.setUnit(unit); - historyHarmOverLimitVOList.add(historyDataResultVOC); } } } diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/SteadyDataServiceImpl.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/SteadyDataServiceImpl.java index cda519194..71e8e8c53 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/SteadyDataServiceImpl.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/SteadyDataServiceImpl.java @@ -4,6 +4,7 @@ import com.njcn.harmonic.constant.Param; import com.njcn.harmonic.pojo.param.PulicTimeStatisParam; import com.njcn.harmonic.pojo.vo.SteadyInfoData; import com.njcn.harmonic.service.SteadyDataService; +import com.njcn.influxdb.param.InfluxDBPublicParam; import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.web.pojo.vo.SteadyDataVO; import lombok.AllArgsConstructor; @@ -49,24 +50,25 @@ public class SteadyDataServiceImpl implements SteadyDataService { if (!lineList.isEmpty() || StringUtils.isNotBlank(lineList)) { //组装sql语句 StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(Param.TIME + " >= '").append(startTime).append(Param.START_TIME).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append(Param.END_TIME).append("' and ("); + stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and ("); //sql语句 - stringBuilder.append(Param.MYINDEX + "='").append(lineList).append("')"); + stringBuilder.append(InfluxDBPublicParam.LINE_ID + "='").append(lineList).append("') "); + stringBuilder.append(InfluxDBPublicParam.TIME_ZONE); String sql = "SELECT" + - " SUM( AllTime ) AS allTime," + - " SUM( Flicket_AllTime ) AS frequency," + - " SUM( Freq_Dev_OverTime ) AS uBalance," + - " SUM( I_Neg_OverTime ) AS iNeg," + - " SUM( IHarm_13_OverTime) AS harmElec," + - " SUM( UHarm_4_OverTime) AS harmVoltage," + - " SUM( Flicker_OverTime ) AS flicker," + - " SUM( Flicket_AllTime ) AS allFlicker," + - " SUM( Voltage_Dev_OverTime ) AS voltageDeviation," + - " SUM( InUHARM_9_OverTime ) AS inUharm" + + " SUM( alltime ) AS alltime," + + " SUM( freq_dev_overtime ) AS frequency," + + " SUM( ubalance_overtime ) AS uBalance," + + " SUM( i_neg_overtime ) AS iNeg," + + " SUM( iharm_13_overtime) AS harmElec," + + " SUM( uharm_4_overtime) AS harmVoltage," + + " SUM( flicker_overtime ) AS flicker," + + " SUM( flicker_alltime ) AS allFlicker," + + " SUM( voltage_dev_overtime ) AS voltageDeviation," + + " SUM( inuharm_9_overtime ) AS inUharm" + " FROM" + - " LIMIT_RATE" + + " limit_rate" + " WHERE" + - " Phasic_Type = 'T'" + + " phasic_type = 'T'" + " AND " + stringBuilder.toString(); //结果集 QueryResult result = influxDbUtils.query(sql); diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/AreaMapper.java b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/AreaMapper.java index 33a252154..e86fd3e5b 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/AreaMapper.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/AreaMapper.java @@ -60,7 +60,7 @@ public interface AreaMapper extends BaseMapper { * * @return 行政区域树(首次) */ - List getAreaDeptTree(@Param("type") Integer type, @Param("state")Integer state); + List getAreaDeptTree(@Param("id")String id,@Param("type") Integer type, @Param("state")Integer state); /** * 查询所有区域 diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/AreaMapper.xml b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/AreaMapper.xml index 0a9de217a..dd41352b0 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/AreaMapper.xml +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/AreaMapper.xml @@ -63,7 +63,9 @@ sys_area.lng lng, sys_area.lat lat FROM sys_area sys_area - WHERE sys_area.type = #{type} + WHERE sys_area.id = #{id} + or sys_area.pid = #{id} + and sys_area.type = #{type} AND sys_area.state = #{state} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/AreaServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/AreaServiceImpl.java index beb141f7c..3016f9f83 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/AreaServiceImpl.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/AreaServiceImpl.java @@ -187,7 +187,7 @@ public class AreaServiceImpl extends ServiceImpl implements IA id = deptFeignClient.getAreaIdByDeptId(RequestUtil.getDeptIndex()).getData(); } - areaTreeVOList = this.baseMapper.getAreaDeptTree(type, DataStateEnum.ENABLE.getCode()); + areaTreeVOList = this.baseMapper.getAreaDeptTree(id,type, DataStateEnum.ENABLE.getCode()); List finalAreaTreeVOList = areaTreeVOList; String finalId = id; areaTreeVOS = areaTreeVOList.stream().filter(deptTreeVO -> diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/DeptServiceImpl.java b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/DeptServiceImpl.java index 5c5b25797..ad16f28d8 100644 --- a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/DeptServiceImpl.java +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/DeptServiceImpl.java @@ -185,22 +185,6 @@ public class DeptServiceImpl extends ServiceImpl implements ID treeDTO.setName(treeDTO.getName() + "(已被绑定)"); treeDTO.setIsFalse(1); } - if (treeDTO.getChildren().size() != 0) { - for (AreaTreeDTO areaTreeDTO : treeDTO.getChildren()) { - if (areaTreeVO.contains(areaTreeDTO.getId())) { - areaTreeDTO.setName(areaTreeDTO.getName() + "(已被绑定)"); - areaTreeDTO.setIsFalse(1); - } - if (areaTreeDTO.getChildren().size() != 0) { - for (AreaTreeDTO dto : areaTreeDTO.getChildren()) { - if (areaTreeVO.contains(dto.getId())) { - dto.setName(dto.getName() + "(已被绑定)"); - dto.setIsFalse(1); - } - } - } - } - } } } }