diff --git a/backend/pom.xml b/backend/pom.xml index 829a08f..3c5e33d 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -40,7 +40,7 @@ 1.7.2 1.6.2 1.21 - + 2.10.1 @@ -309,17 +309,23 @@ 15.4 + - com.zny.platform - dec-framework-kendo - 0.4.0.5-SNAPSHOT - - - dm.jdbc.driver - 18 - - + com.google.code.gson + gson + ${gson.version} + + + + + + + + + + + diff --git a/backend/src/main/java/com/yfd/platform/common/FilterFieldMeta.java b/backend/src/main/java/com/yfd/platform/common/FilterFieldMeta.java new file mode 100644 index 0000000..505e39e --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/common/FilterFieldMeta.java @@ -0,0 +1,44 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.yfd.platform.common; + +import java.util.List; +import java.util.Map; + +public class FilterFieldMeta { + private DataSourceRequest.FilterDescriptor filterDescriptor; + private Map fieldMeta; + private List orderByList; + + public FilterFieldMeta(DataSourceRequest.FilterDescriptor filterDescriptor, Map fieldMeta) { + this.filterDescriptor = filterDescriptor; + this.fieldMeta = fieldMeta; + } + + public DataSourceRequest.FilterDescriptor getFilterDescriptor() { + return this.filterDescriptor; + } + + public void setFilterDescriptor(DataSourceRequest.FilterDescriptor filterDescriptor) { + this.filterDescriptor = filterDescriptor; + } + + public Map getFieldMeta() { + return this.fieldMeta; + } + + public void setFieldMeta(Map fieldMeta) { + this.fieldMeta = fieldMeta; + } + + public List getOrderByList() { + return this.orderByList; + } + + public void setOrderByList(List orderByList) { + this.orderByList = orderByList; + } +} diff --git a/backend/src/main/java/com/yfd/platform/common/Group.java b/backend/src/main/java/com/yfd/platform/common/Group.java new file mode 100644 index 0000000..9e0a9e3 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/common/Group.java @@ -0,0 +1,200 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.yfd.platform.common; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +public class Group { + private Object key; + private String keyName; + private Map keyExt; + @JsonIgnore + private Object field; + private List items; + private int count = 0; + private Object[] summary; + private Map aggregates; + + public Group() { + } + + public Object getKey() { + return this.key; + } + + public String getKeyName() { + return this.keyName; + } + + public Map getKeyExt() { + return this.keyExt; + } + + public Object getField() { + return this.field; + } + + public List getItems() { + return this.items; + } + + public int getCount() { + return this.count; + } + + public Object[] getSummary() { + return this.summary; + } + + public Map getAggregates() { + return this.aggregates; + } + + public void setKey(final Object key) { + this.key = key; + } + + public void setKeyName(final String keyName) { + this.keyName = keyName; + } + + public void setKeyExt(final Map keyExt) { + this.keyExt = keyExt; + } + + @JsonIgnore + public void setField(final Object field) { + this.field = field; + } + + public void setItems(final List items) { + this.items = items; + } + + public void setCount(final int count) { + this.count = count; + } + + public void setSummary(final Object[] summary) { + this.summary = summary; + } + + public void setAggregates(final Map aggregates) { + this.aggregates = aggregates; + } + + public boolean equals(final Object o) { + if (o == this) { + return true; + } else if (!(o instanceof Group)) { + return false; + } else { + Group other = (Group)o; + if (!other.canEqual(this)) { + return false; + } else if (this.getCount() != other.getCount()) { + return false; + } else { + Object this$key = this.getKey(); + Object other$key = other.getKey(); + if (this$key == null) { + if (other$key != null) { + return false; + } + } else if (!this$key.equals(other$key)) { + return false; + } + + Object this$keyName = this.getKeyName(); + Object other$keyName = other.getKeyName(); + if (this$keyName == null) { + if (other$keyName != null) { + return false; + } + } else if (!this$keyName.equals(other$keyName)) { + return false; + } + + Object this$keyExt = this.getKeyExt(); + Object other$keyExt = other.getKeyExt(); + if (this$keyExt == null) { + if (other$keyExt != null) { + return false; + } + } else if (!this$keyExt.equals(other$keyExt)) { + return false; + } + + Object this$field = this.getField(); + Object other$field = other.getField(); + if (this$field == null) { + if (other$field != null) { + return false; + } + } else if (!this$field.equals(other$field)) { + return false; + } + + Object this$items = this.getItems(); + Object other$items = other.getItems(); + if (this$items == null) { + if (other$items != null) { + return false; + } + } else if (!this$items.equals(other$items)) { + return false; + } + + if (!Arrays.deepEquals(this.getSummary(), other.getSummary())) { + return false; + } else { + Object this$aggregates = this.getAggregates(); + Object other$aggregates = other.getAggregates(); + if (this$aggregates == null) { + if (other$aggregates != null) { + return false; + } + } else if (!this$aggregates.equals(other$aggregates)) { + return false; + } + + return true; + } + } + } + } + + protected boolean canEqual(final Object other) { + return other instanceof Group; + } + + public int hashCode() { + int PRIME = 59; + int result = 1; + result = result * 59 + this.getCount(); + Object $key = this.getKey(); + result = result * 59 + ($key == null ? 43 : $key.hashCode()); + Object $keyName = this.getKeyName(); + result = result * 59 + ($keyName == null ? 43 : $keyName.hashCode()); + Object $keyExt = this.getKeyExt(); + result = result * 59 + ($keyExt == null ? 43 : $keyExt.hashCode()); + Object $field = this.getField(); + result = result * 59 + ($field == null ? 43 : $field.hashCode()); + Object $items = this.getItems(); + result = result * 59 + ($items == null ? 43 : $items.hashCode()); + result = result * 59 + Arrays.deepHashCode(this.getSummary()); + Object $aggregates = this.getAggregates(); + result = result * 59 + ($aggregates == null ? 43 : $aggregates.hashCode()); + return result; + } + + public String toString() { + return "Group(key=" + this.getKey() + ", keyName=" + this.getKeyName() + ", keyExt=" + this.getKeyExt() + ", field=" + this.getField() + ", items=" + this.getItems() + ", count=" + this.getCount() + ", summary=" + Arrays.deepToString(this.getSummary()) + ", aggregates=" + this.getAggregates() + ")"; + } +} diff --git a/backend/src/main/java/com/yfd/platform/common/GroupHelper.java b/backend/src/main/java/com/yfd/platform/common/GroupHelper.java new file mode 100644 index 0000000..7931e4a --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/common/GroupHelper.java @@ -0,0 +1,189 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.yfd.platform.common; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GroupHelper { + public GroupHelper() { + } + + public List group(List> data, List groupInfo) { + List groups = this.group(data, (GroupingInfo)groupInfo.get(0)); + if (groupInfo.size() > 1 && CollectionUtil.isNotEmpty(groups)) { + for(Group group : groups) { + group.setItems(this.group(group.getItems(), groupInfo.subList(1, groupInfo.size()))); + } + } + + return groups; + } + + public List faltGroup(List> data, List groupInfo) { + List result = new ArrayList(); + + for(Map item : data) { + result.add(this.flatGroupResult(item, groupInfo)); + } + + return result; + } + + private Map flatGroupResult(Map item, List groupInfos) { + Map group = new HashMap(); + + for(GroupingInfo groupInfo : groupInfos) { + Object groupKey = this.getKey(item, groupInfo); + if (CollectionUtil.isNotEmpty(groupInfo.getSummaryInfos())) { + for(SummaryInfo summaryInfo : groupInfo.getSummaryInfos()) { + String summaryType = summaryInfo.getSummaryType(); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(summaryType).append("_").append(summaryInfo.getSelector()); + String key = stringBuilder.toString(); + Object tempCount = item.get(key); + if (tempCount == null) { + tempCount = item.get(key.toUpperCase()); + } + + if (tempCount != null) { + if (tempCount instanceof Number) { + group.put(key, tempCount); + } else { + Integer count = NumberUtil.parseInt(tempCount.toString()); + group.put(key, count); + } + } + } + } else { + Object tempCount = item.get("count_" + groupInfo.getSelector()); + if (tempCount == null) { + tempCount = item.get("COUNT_" + groupInfo.getSelector().toUpperCase()); + } + + if (tempCount != null) { + Integer count = NumberUtil.parseInt(tempCount.toString()); + group.put("count_" + groupInfo.getSelector(), count); + } + } + + group.put(groupInfo.getSelector(), groupKey); + group.put(groupInfo.getSelector() + "_value", groupKey); + group.put(groupInfo.getSelector() + "_ext", (Object)null); + } + + return group; + } + + public List group(List> data, GroupingInfo groupInfo) { + Map groupsIndex = new HashMap(); + List groups = new ArrayList(); + + for(Map item : data) { + Object groupKey = this.getKey(item, groupInfo); + Object groupIndexKey = groupKey != null ? groupKey : null; + Object tempCount = item.get("count_" + groupInfo.getSelector()); + if (tempCount == null) { + tempCount = item.get("COUNT_" + groupInfo.getSelector().toUpperCase()); + } + + if (!groupsIndex.containsKey(groupIndexKey)) { + Group newGroup = new Group(); + newGroup.setKey(groupKey); + newGroup.setField(groupInfo.getSelector()); + if (tempCount != null) { + newGroup.setCount(NumberUtil.parseInt(tempCount.toString())); + } + + if (CollectionUtil.isNotEmpty(groupInfo.getSummaryInfos())) { + Map groupSummarys = new HashMap(); + + for(SummaryInfo summaryInfo : groupInfo.getSummaryInfos()) { + String summaryType = summaryInfo.getSummaryType(); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(summaryType).append("_").append(summaryInfo.getSelector()); + String key = stringBuilder.toString(); + Object summaryValue = item.get(key); + if (summaryValue == null) { + summaryValue = item.get(key.toUpperCase()); + } + + groupSummarys.put(key, summaryValue); + } + + newGroup.setAggregates(groupSummarys); + } + + groupsIndex.put(groupIndexKey, newGroup); + groups.add(newGroup); + } else { + Group newGroup = (Group)groupsIndex.get(groupIndexKey); + if (tempCount != null) { + newGroup.setCount(newGroup.getCount() + NumberUtil.parseInt(tempCount.toString())); + } + } + + Group group = (Group)groupsIndex.get(groupIndexKey); + if (group.getItems() == null) { + group.setItems(new ArrayList()); + group.getItems().add(item); + } else { + group.getItems().add(item); + } + } + + return groups; + } + + private Object getKey(Map obj, GroupingInfo groupInfo) { + Object memberValue = obj.get(groupInfo.getSelector()); + if (memberValue == null) { + memberValue = obj.get(groupInfo.getSelector().toUpperCase()); + } + + String intervalString = groupInfo.getGroupInterval(); + if (!StrUtil.isEmpty(intervalString) && memberValue != null) { + if (NumberUtil.isNumber(intervalString)) { + BigDecimal number = NumberUtil.toBigDecimal((Number)memberValue); + BigDecimal interval = NumberUtil.toBigDecimal(intervalString); + return number.subtract(number.divideAndRemainder(interval)[1]); + } else { + switch (intervalString) { + case "year": + return toDateTime(memberValue).getYear(); + case "month": + return toDateTime(memberValue).getMonth(); + case "day": + return toDateTime(memberValue).getDayOfYear(); + case "dayOfWeek": + return toDateTime(memberValue).getDayOfWeek(); + case "hour": + return toDateTime(memberValue).getHour(); + case "minute": + return toDateTime(memberValue).getMinute(); + case "second": + return toDateTime(memberValue).getSecond(); + default: + throw new RuntimeException("memberValue字段解析失败"); + } + } + } else { + return memberValue; + } + } + + static LocalDateTime toDateTime(Object value) { + return value instanceof LocalDateTime ? (LocalDateTime)value : LocalDateTime.parse(value.toString()); + } +} diff --git a/backend/src/main/java/com/yfd/platform/common/GuidStringSerialize.java b/backend/src/main/java/com/yfd/platform/common/GuidStringSerialize.java new file mode 100644 index 0000000..9004e70 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/common/GuidStringSerialize.java @@ -0,0 +1,28 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.yfd.platform.common; + +import cn.hutool.core.util.StrUtil; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import java.io.IOException; + +public class GuidStringSerialize extends JsonSerializer { + private final String GUID_EMPTY = "00000000-0000-0000-0000-000000000000"; + + public GuidStringSerialize() { + } + + public void serialize(String value, JsonGenerator jGen, SerializerProvider sProvider) throws IOException { + if ("00000000-0000-0000-0000-000000000000".equals(value) || StrUtil.isBlank(value)) { + value = null; + } + + jGen.writeString(value); + } +} diff --git a/backend/src/main/java/com/yfd/platform/common/ItemEntity.java b/backend/src/main/java/com/yfd/platform/common/ItemEntity.java new file mode 100644 index 0000000..0cb3365 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/common/ItemEntity.java @@ -0,0 +1,63 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.yfd.platform.common; + +import cn.hutool.core.util.StrUtil; + +public class ItemEntity { + private String filterItem; + private String itemMap; + private String alias; + private String fieldSql; + + public ItemEntity(String filterItem, String itemMap, String alias) { + this.filterItem = filterItem; + this.itemMap = itemMap; + this.alias = alias; + } + + public String getFieldSql() { + if (StrUtil.isNotBlank(this.fieldSql)) { + return this.fieldSql; + } else { + if (StrUtil.isNotBlank(this.alias)) { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(this.alias); + stringBuilder.append("."); + stringBuilder.append(this.itemMap); + this.fieldSql = stringBuilder.toString(); + } else { + this.fieldSql = this.itemMap; + } + + return this.fieldSql; + } + } + + public String getFilterItem() { + return this.filterItem; + } + + public void setFilterItem(String filterItem) { + this.filterItem = filterItem; + } + + public String getItemMap() { + return this.itemMap; + } + + public void setItemMap(String itemMap) { + this.itemMap = itemMap; + } + + public String getAlias() { + return this.alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } +} diff --git a/backend/src/main/java/com/yfd/platform/common/OrderBy.java b/backend/src/main/java/com/yfd/platform/common/OrderBy.java new file mode 100644 index 0000000..609bbaf --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/common/OrderBy.java @@ -0,0 +1,33 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.yfd.platform.common; + +import java.util.Set; +import org.apache.commons.lang3.StringUtils; + +public class OrderBy { + public static final String ORDER_ASC = "asc"; + public static final String ORDER_DESC = "desc"; + private final String sort; + private final String order; + + public OrderBy(String sort, String order) { + this.sort = sort; + this.order = order; + } + + public String getSort() { + return this.sort; + } + + public String getOrder() { + return this.order; + } + + public boolean isValid(Set fieldSet) { + return fieldSet.contains(this.sort) && (StringUtils.isBlank(this.order) || "asc".equalsIgnoreCase(this.order) || "desc".equalsIgnoreCase(this.order)); + } +} diff --git a/backend/src/main/java/com/yfd/platform/common/PageInfo.java b/backend/src/main/java/com/yfd/platform/common/PageInfo.java new file mode 100644 index 0000000..ab4c7f6 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/common/PageInfo.java @@ -0,0 +1,85 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.yfd.platform.common; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +public class PageInfo { + private Boolean hasPageInfo; + private Page page; + + public PageInfo() { + } + + public Boolean getHasPageInfo() { + return this.hasPageInfo; + } + + public Page getPage() { + return this.page; + } + + public void setHasPageInfo(final Boolean hasPageInfo) { + this.hasPageInfo = hasPageInfo; + } + + public void setPage(final Page page) { + this.page = page; + } + + public boolean equals(final Object o) { + if (o == this) { + return true; + } else if (!(o instanceof PageInfo)) { + return false; + } else { + PageInfo other = (PageInfo)o; + if (!other.canEqual(this)) { + return false; + } else { + Object this$hasPageInfo = this.getHasPageInfo(); + Object other$hasPageInfo = other.getHasPageInfo(); + if (this$hasPageInfo == null) { + if (other$hasPageInfo != null) { + return false; + } + } else if (!this$hasPageInfo.equals(other$hasPageInfo)) { + return false; + } + + Object this$page = this.getPage(); + Object other$page = other.getPage(); + if (this$page == null) { + if (other$page != null) { + return false; + } + } else if (!this$page.equals(other$page)) { + return false; + } + + return true; + } + } + } + + protected boolean canEqual(final Object other) { + return other instanceof PageInfo; + } + + public int hashCode() { + int PRIME = 59; + int result = 1; + Object $hasPageInfo = this.getHasPageInfo(); + result = result * 59 + ($hasPageInfo == null ? 43 : $hasPageInfo.hashCode()); + Object $page = this.getPage(); + result = result * 59 + ($page == null ? 43 : $page.hashCode()); + return result; + } + + public String toString() { + return "PageInfo(hasPageInfo=" + this.getHasPageInfo() + ", page=" + this.getPage() + ")"; + } +} diff --git a/backend/src/main/java/com/yfd/platform/eng/controller/EngEqController.java b/backend/src/main/java/com/yfd/platform/eng/controller/EngEqController.java index 1026f72..7dda132 100644 --- a/backend/src/main/java/com/yfd/platform/eng/controller/EngEqController.java +++ b/backend/src/main/java/com/yfd/platform/eng/controller/EngEqController.java @@ -1,14 +1,11 @@ package com.yfd.platform.eng.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; -//import com.yfd.platform.common.GroupResult; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.GroupResult; import com.yfd.platform.config.ResponseResult; import com.yfd.platform.eng.service.EngEqService; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; -import com.zny.dec.framework.kendo.entity.mapping.GroupResult; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.web.bind.annotation.PostMapping; diff --git a/backend/src/main/java/com/yfd/platform/eng/controller/EngEqDataController.java b/backend/src/main/java/com/yfd/platform/eng/controller/EngEqDataController.java index fa1cd7c..6b0f1a9 100644 --- a/backend/src/main/java/com/yfd/platform/eng/controller/EngEqDataController.java +++ b/backend/src/main/java/com/yfd/platform/eng/controller/EngEqDataController.java @@ -1,23 +1,19 @@ package com.yfd.platform.eng.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; -//import com.yfd.platform.config.ResponseResult; -//import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.config.ResponseResult; import com.yfd.platform.eng.service.EngEqDataService; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; import java.util.Map; /** diff --git a/backend/src/main/java/com/yfd/platform/eng/controller/EngEqIntervalController.java b/backend/src/main/java/com/yfd/platform/eng/controller/EngEqIntervalController.java index aef8393..c70a96d 100644 --- a/backend/src/main/java/com/yfd/platform/eng/controller/EngEqIntervalController.java +++ b/backend/src/main/java/com/yfd/platform/eng/controller/EngEqIntervalController.java @@ -2,32 +2,25 @@ package com.yfd.platform.eng.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yfd.platform.annotation.Log; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; -//import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.DataSourceLoadOptionsBase; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.config.ResponseResult; import com.yfd.platform.eng.domain.MsEngEq; import com.yfd.platform.eng.service.EngEqIntervalService; import com.yfd.platform.eng.service.EngEqService; -import com.zny.dec.core.common.util.SpringContextHolder; -import com.zny.dec.core.tenant.TenantContextHolder; -import com.zny.dec.framework.kendo.api.KendoParamGroupServiceApi; -import com.zny.dec.framework.kendo.entity.dto.devextreme.DataSourceLoadOptionsBase; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; -import com.zny.dec.framework.kendo.entity.mapping.GroupResult; -import com.zny.dec.framework.kendo.util.KendoUtil; -import com.zny.dec.framework.kendo.util.QueryWrapperUtil; +import com.yfd.platform.utils.KendoUtil; +import com.yfd.platform.utils.QgcQueryWrapperUtil; +import com.yfd.platform.utils.QueryWrapperUtil; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; - import java.util.Map; /** @@ -84,9 +77,9 @@ public class EngEqIntervalController { public ResponseResult getQgcHourKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) { String kendoGroupCode = "EngEqHour"; // Map filterResult = KendoUtil.getGroupResultMap(dataSourceRequest, null, EngEqIntervalController.class); - String groupBy = KendoUtil.getGroupBy(dataSourceRequest); +// String groupBy = KendoUtil.getGroupBy(dataSourceRequest); Page page = KendoUtil.getPage(dataSourceRequest); - DataSourceResult result = eqIntervalService.getQgcHourKendoListCust(dataSourceRequest, null, page, groupBy); + DataSourceResult result = eqIntervalService.getQgcHourKendoListCust(dataSourceRequest, null, page, null); // eqIntervalService.processKendoGetListLoadResult(dataSourceRequest, result); return ResponseResult.successData(result); } @@ -117,7 +110,7 @@ public class EngEqIntervalController { // @Log(module = "生态流量", value = "生态流量达标率统计") public ResponseResult getQgcStaticData(@RequestBody DataSourceRequest dataSourceRequest) { DataSourceLoadOptionsBase loadOptionsBase = dataSourceRequest.toDevRequest(); - String type = QueryWrapperUtil.getFilterFieldValue(loadOptionsBase, "type"); + String type = QgcQueryWrapperUtil.getFilterFieldValue(loadOptionsBase, "type"); ResponseResult r; if("hour".equals(type)){ r = this.getQgcHourKendoListCust(dataSourceRequest); diff --git a/backend/src/main/java/com/yfd/platform/eng/controller/EngEqStatController.java b/backend/src/main/java/com/yfd/platform/eng/controller/EngEqStatController.java index 11b9243..d88865b 100644 --- a/backend/src/main/java/com/yfd/platform/eng/controller/EngEqStatController.java +++ b/backend/src/main/java/com/yfd/platform/eng/controller/EngEqStatController.java @@ -1,22 +1,20 @@ package com.yfd.platform.eng.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.GroupResult; import com.yfd.platform.config.ResponseResult; import com.yfd.platform.eng.service.EngEqService; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; -import com.zny.dec.framework.kendo.entity.mapping.GroupResult; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; import java.util.Map; /** diff --git a/backend/src/main/java/com/yfd/platform/eng/controller/EngSpecialController.java b/backend/src/main/java/com/yfd/platform/eng/controller/EngSpecialController.java index 56d420b..194bea9 100644 --- a/backend/src/main/java/com/yfd/platform/eng/controller/EngSpecialController.java +++ b/backend/src/main/java/com/yfd/platform/eng/controller/EngSpecialController.java @@ -1,22 +1,19 @@ package com.yfd.platform.eng.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; -//import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.config.ResponseResult; import com.yfd.platform.eng.entity.EqSpecial; import com.yfd.platform.eng.service.EngSpecialService; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import jakarta.annotation.Resource; import java.util.Map; /** diff --git a/backend/src/main/java/com/yfd/platform/eng/service/EngEqDataService.java b/backend/src/main/java/com/yfd/platform/eng/service/EngEqDataService.java index da0788a..2fe5749 100644 --- a/backend/src/main/java/com/yfd/platform/eng/service/EngEqDataService.java +++ b/backend/src/main/java/com/yfd/platform/eng/service/EngEqDataService.java @@ -1,10 +1,8 @@ package com.yfd.platform.eng.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; import java.util.Map; diff --git a/backend/src/main/java/com/yfd/platform/eng/service/EngEqIntervalService.java b/backend/src/main/java/com/yfd/platform/eng/service/EngEqIntervalService.java index f675700..a4b224e 100644 --- a/backend/src/main/java/com/yfd/platform/eng/service/EngEqIntervalService.java +++ b/backend/src/main/java/com/yfd/platform/eng/service/EngEqIntervalService.java @@ -1,12 +1,10 @@ package com.yfd.platform.eng.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.GroupResult; import com.yfd.platform.eng.domain.MsEngEq; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; -import com.zny.dec.framework.kendo.entity.mapping.GroupResult; import java.util.Map; diff --git a/backend/src/main/java/com/yfd/platform/eng/service/EngEqService.java b/backend/src/main/java/com/yfd/platform/eng/service/EngEqService.java index c55bd4e..288aa9e 100644 --- a/backend/src/main/java/com/yfd/platform/eng/service/EngEqService.java +++ b/backend/src/main/java/com/yfd/platform/eng/service/EngEqService.java @@ -1,14 +1,12 @@ package com.yfd.platform.eng.service; -import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; -//import com.yfd.platform.common.GroupResult; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.GroupResult; import com.yfd.platform.eng.domain.MsEngEq; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; -import com.zny.dec.framework.kendo.entity.mapping.GroupResult; + import java.util.Map; diff --git a/backend/src/main/java/com/yfd/platform/eng/service/EngSpecialService.java b/backend/src/main/java/com/yfd/platform/eng/service/EngSpecialService.java index dd25f10..0c3a884 100644 --- a/backend/src/main/java/com/yfd/platform/eng/service/EngSpecialService.java +++ b/backend/src/main/java/com/yfd/platform/eng/service/EngSpecialService.java @@ -1,11 +1,9 @@ package com.yfd.platform.eng.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.eng.entity.EqSpecial; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; import java.util.Map; diff --git a/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqDataServiceImpl.java b/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqDataServiceImpl.java index c5178ec..2fc6bc4 100644 --- a/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqDataServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqDataServiceImpl.java @@ -1,11 +1,10 @@ package com.yfd.platform.eng.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.eng.service.EngEqDataService; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; + import org.springframework.stereotype.Service; import java.util.ArrayList; diff --git a/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqIntervalServiceImpl.java b/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqIntervalServiceImpl.java index acc247d..992bf23 100644 --- a/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqIntervalServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqIntervalServiceImpl.java @@ -1,29 +1,18 @@ package com.yfd.platform.eng.service.impl; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; -import com.yfd.platform.common.DynamicSQLMapper; +import com.yfd.platform.common.*; import com.yfd.platform.common.enums.QecIntervalEnum; import com.yfd.platform.common.enums.ShowEnum; import com.yfd.platform.eng.domain.MsEngEq; import com.yfd.platform.eng.service.EngEqIntervalService; import com.yfd.platform.utils.QueryWrapperUtil; -import com.zny.dec.core.common.util.ObjectUtil; -import com.zny.dec.core.common.util.StringUtil; -import com.zny.dec.framework.kendo.entity.dto.devextreme.DataSourceLoadOptionsBase; -import com.zny.dec.framework.kendo.entity.dto.devextreme.GroupingInfo; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; -import com.zny.dec.framework.kendo.entity.mapping.GroupResult; -import com.zny.dec.framework.kendo.mybatis.devExtreme.helper.GroupHelper; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; -import java.math.BigDecimal; import java.util.*; /** @@ -58,11 +47,11 @@ public class EngEqIntervalServiceImpl implements EngEqIntervalService { sql.append(" FROM "); sql.append("(select MSB.STCD,MSB.STNM as ENNM,MSB.BASESTEPSORT,MSB.SITESTEPSORT,MSB.RVCDSTEPSORT,MSB.RSTCDSTEPSORT ,MSB.BASE_NAME,MSB.BASE_ID,MSB.ORDER_INDEX orderIndex,MSB.HBRVCD ,MSB.HBRVCD_NAME,MSB.ADDVCD_NAME ,MSB.STTP_CODE,'ENG' as sttp,MSB.LGTD,MSB.LTTD,MSB.DTMEL ,MSB.TTPWR,MSB.NORMZ,MSB.DTIN_ENV,MSB.AVQ ,SQR.QEC_RATE,SQR.MWR_RATE,SQR.AVQ_RATE,SHR.QI,SHR.QO,SHR.RZ,SHR.QO_SUM,SHR.QI_SUM,(CASE WHEN SQR.STCD IS NULL and qecR.stcd is null THEN 'QEC_STLL_5_EMPTY' WHEN SQR.STCD IS NULL and qecR.stcd is not null THEN 'QEC_STLL_6_NOEQMN' WHEN SQR.STCD IS NOT NULL AND SQR.QR = -2 THEN 'QEC_STLL_6_NOEQMN' WHEN SQR.STCD IS NOT NULL AND SQR.QR = -1 THEN 'QEC_STLL_5_EMPTY' WHEN SQR.QEC_RATE >= 95 THEN 'QEC_STLL_1_DY95' WHEN SQR.QEC_RATE >= 90 AND 95 > SQR.QEC_RATE THEN 'QEC_STLL_2_90AND95' WHEN SQR.QEC_RATE >= 80 AND 90 > SQR.QEC_RATE THEN 'QEC_STLL_3_80AND90' WHEN 80 > SQR.QEC_RATE THEN 'QEC_STLL_4_XY80' END) AS QEC_INTERVAL ,(CASE WHEN SQR.STCD IS NULL and mwrR.stcd is null THEN 'QEC_STLL_5_EMPTY' WHEN SQR.STCD IS NULL and mwrR.stcd is not null THEN 'QEC_STLL_6_NOEQMN' WHEN SQR.STCD IS NOT NULL AND SQR.MQR = -2 THEN 'QEC_STLL_6_NOEQMN' WHEN SQR.STCD IS NOT NULL AND SQR.MQR = -1 THEN 'QEC_STLL_5_EMPTY' WHEN SQR.MWR_RATE >= 95 THEN 'QEC_STLL_1_DY95' WHEN SQR.MWR_RATE >= 90 AND 95 > SQR.MWR_RATE THEN 'QEC_STLL_2_90AND95' WHEN SQR.MWR_RATE >= 80 AND 90 > SQR.MWR_RATE THEN 'QEC_STLL_3_80AND90' WHEN 80 > SQR.MWR_RATE THEN 'QEC_STLL_4_XY80' END) AS MWR_INTERVAL ,(CASE WHEN MSB.AVQ is not null AND SQR.AVQ_RATE IS NULL THEN 'QEC_STLL_5_EMPTY' WHEN MSB.AVQ is null THEN 'QEC_STLL_6_NOEQMN' WHEN SQR.AVQ_RATE >= 95 THEN 'QEC_STLL_1_DY95' WHEN SQR.AVQ_RATE >= 90 AND 95 > SQR.AVQ_RATE THEN 'QEC_STLL_2_90AND95' WHEN SQR.AVQ_RATE >= 80 AND 90 > SQR.AVQ_RATE THEN 'QEC_STLL_3_80AND90' WHEN 80 > SQR.AVQ_RATE THEN 'QEC_STLL_4_XY80' END) AS AVQ_INTERVAL ,(case when SQR.QEC_RATE is null and MSB.PRSC = 1 then 'eef_1_none' when SQR.QEC_RATE >=95 and MSB.PRSC = 1 then 'eef_1_1' when SQR.QEC_RATE >=90 and 95 > SQR.QEC_RATE and MSB.PRSC = 1 then 'eef_1_2' when SQR.QEC_RATE >=80 and 90 > SQR.QEC_RATE and MSB.PRSC = 1 then 'eef_1_3' when 80 > SQR.QEC_RATE and MSB.PRSC = 1 then 'eef_1_4' when SQR.QEC_RATE is null and MSB.PRSC in (2,3) then 'eef_2_none' when SQR.QEC_RATE >=95 and MSB.PRSC in (2,3) then 'eef_2_1' when SQR.QEC_RATE >=90 and 95 > SQR.QEC_RATE and MSB.PRSC in (2,3) then 'eef_2_2' when SQR.QEC_RATE >=80 and 90 > SQR.QEC_RATE and MSB.PRSC in (2,3) then 'eef_2_3' when 80 > SQR.QEC_RATE and MSB.PRSC in (2,3) then 'eef_2_4' end) as ANCHO_POINT_STATE ,(case when SQR.MWR_RATE is null and MSB.PRSC = 1 then 'eef_1_none' when SQR.MWR_RATE >=95 and MSB.PRSC = 1 then 'eef_1_1' when SQR.MWR_RATE >=90 and 95 > SQR.MWR_RATE and MSB.PRSC = 1 then 'eef_1_2' when SQR.MWR_RATE >=80 and 90 > SQR.MWR_RATE and MSB.PRSC = 1 then 'eef_1_3' when 80 > SQR.MWR_RATE and MSB.PRSC = 1 then 'eef_1_4' when SQR.MWR_RATE is null and MSB.PRSC in (2,3) then 'eef_2_none' when SQR.MWR_RATE >=95 and MSB.PRSC in (2,3) then 'eef_2_1' when SQR.MWR_RATE >=90 and 95 > SQR.MWR_RATE and MSB.PRSC in (2,3) then 'eef_2_2' when SQR.MWR_RATE >=80 and 90 > SQR.MWR_RATE and MSB.PRSC in (2,3) then 'eef_2_3' when 80 > SQR.MWR_RATE and MSB.PRSC in (2,3) then 'eef_2_4' end) as MWR_POINT_STATE ,(case when SQR.AVQ_RATE is null and MSB.PRSC = 1 then 'eef_1_none' when SQR.AVQ_RATE >=95 and MSB.PRSC = 1 then 'eef_1_1' when SQR.AVQ_RATE >=90 and 95 > SQR.AVQ_RATE and MSB.PRSC = 1 then 'eef_1_2' when SQR.AVQ_RATE >=80 and 90 > SQR.AVQ_RATE and MSB.PRSC = 1 then 'eef_1_3' when 80 > SQR.AVQ_RATE and MSB.PRSC = 1 then 'eef_1_4' when SQR.AVQ_RATE is null and MSB.PRSC in (2,3) then 'eef_2_none' when SQR.AVQ_RATE >=95 and MSB.PRSC in (2,3) then 'eef_2_1' when SQR.AVQ_RATE >=90 and 95 > SQR.AVQ_RATE and MSB.PRSC in (2,3) then 'eef_2_2' when SQR.AVQ_RATE >=80 and 90 > SQR.AVQ_RATE and MSB.PRSC in (2,3) then 'eef_2_3' when 80 > SQR.AVQ_RATE and MSB.PRSC in (2,3) then 'eef_2_4' end) as AVQ_POINT_STATE from V_MS_STBPRP_T MSB left join (select STCD ,(case when sum(case when SFDB =1 or SFDB =0 then 1 else 0 end) =0 then null else (sum(case when SFDB =1 then 1 else 0 end)/sum(case when SFDB =1 or SFDB =0 then 1 else 0 end)) end)*100 QEC_RATE ,(case when sum(case when MWR_SFDB =1 or MWR_SFDB =0 then 1 else 0 end) =0 then null else (sum(case when MWR_SFDB =1 then 1 else 0 end)/sum(case when MWR_SFDB =1 or MWR_SFDB =0 then 1 else 0 end)) end)*100 MWR_RATE ,(case when sum(case when AVQ_SFDB =1 or AVQ_SFDB =0 then 1 else 0 end) =0 then null else (sum(case when AVQ_SFDB =1 then 1 else 0 end)/sum(case when AVQ_SFDB =1 or AVQ_SFDB =0 then 1 else 0 end)) end)*100 AVQ_RATE ,case when count(1)=sum(case when SFDB =2 then 1 else 0 end) then -1 when count(1)=sum(case when SFDB =3 then 1 else 0 end) then -2 WHEN sum(CASE WHEN SFDB = 2 THEN 1 ELSE 0 END) >0 and count(1) = sum(CASE WHEN SFDB = 2 THEN 1 ELSE 0 END)+sum(CASE WHEN SFDB = 3 THEN 1 ELSE 0 END)+sum(CASE WHEN SFDB is null THEN 1 ELSE 0 END) then -1 WHEN sum(CASE WHEN SFDB = 2 THEN 1 ELSE 0 END) =0 and count(1) = sum(CASE WHEN SFDB = 2 THEN 1 ELSE 0 END)+sum(CASE WHEN SFDB = 3 THEN 1 ELSE 0 END)+sum(CASE WHEN SFDB is null THEN 1 ELSE 0 END) then -2 end qr ,case when count(1)=sum(case when MWR_SFDB =2 then 1 else 0 end) then -1 when count(1)=sum(case when MWR_SFDB =3 then 1 else 0 end) then -2 WHEN sum(CASE WHEN MWR_SFDB = 2 THEN 1 ELSE 0 END) >0 and count(1) = sum(CASE WHEN MWR_SFDB = 2 THEN 1 ELSE 0 END)+sum(CASE WHEN MWR_SFDB = 3 THEN 1 ELSE 0 END)+sum(CASE WHEN MWR_SFDB is null THEN 1 ELSE 0 END) then -1 WHEN sum(CASE WHEN MWR_SFDB = 2 THEN 1 ELSE 0 END) =0 and count(1) = sum(CASE WHEN MWR_SFDB = 2 THEN 1 ELSE 0 END)+sum(CASE WHEN MWR_SFDB = 3 THEN 1 ELSE 0 END)+sum(CASE WHEN MWR_SFDB is null THEN 1 ELSE 0 END) then -2 end mqr ,case when count(1)=sum(case when AVQ_SFDB =2 then 1 else 0 end) then -1 when count(1)=sum(case when AVQ_SFDB =3 then 1 else 0 end) then -2 end aqr from SD_QEC_R where 1=1 "); Map params = QueryWrapperUtil.buildSqlConditionsByField(loadOptions); - if(StringUtil.isNotBlank(params.get("TM"))){ + if(StrUtil.isNotBlank(params.get("TM"))){ sql.append(" and ").append(params.get("TM")); } sql.append(" group by STCD) SQR on MSB.STCD=SQR.STCD left join (SELECT stcd, avg(QI) QI, avg(QO) QO, avg(qec) qec,avg(RZ) RZ,SUM(QI) QI_SUM,SUM(QO) QO_SUM from SD_HYDROPW_R where 1=1 "); - if(StringUtil.isNotBlank(params.get("TM"))){ + if(StrUtil.isNotBlank(params.get("TM"))){ sql.append(" and ").append(params.get("TM")); } sql.append(" group by STCD) SHR on SHR.STCD = MSB.STCD left join (select STCD from MS_STBPRP_T where is_deleted=0 and sttp_code ='ENG' and stcd not in (select distinct A.STCD from MS_WARN_RULE_STBPRP_B a INNER JOIN MS_WARN_RULE_DETAIL_B b ON a.RULE_ID = b.RULE_ID and b.is_deleted=0 INNER JOIN MS_WARN_RULE_B c ON c.ID = b.RULE_ID where a.is_deleted=0 and b.is_deleted=0 and c.RULE_TYPE in('EQMN') and c.is_deleted=0)) qecR on qecR.STCD =MSB.STCD left join (select STCD from MS_STBPRP_T where is_deleted=0 and sttp_code ='ENG' and stcd not in (select distinct A.STCD from MS_WARN_RULE_STBPRP_B a INNER JOIN MS_WARN_RULE_DETAIL_B b ON a.RULE_ID = b.RULE_ID and b.is_deleted=0 INNER JOIN MS_WARN_RULE_B c ON c.ID = b.RULE_ID where a.is_deleted=0 and b.is_deleted=0 and c.RULE_TYPE in('EQMNMWR') and c.is_deleted=0)) mwrR on mwrR.STCD =MSB.STCD where MSB.STTP_CODE='ENG' and MSB.DTIN=1 and MSB.IS_DELETED = 0 and MSB.BLDSTT_CCODE = 2 and MSB.RUN_STATE=4 )"); @@ -77,7 +66,7 @@ public class EngEqIntervalServiceImpl implements EngEqIntervalService { { groupFields.add("avg(" + item.getField() + ") as "+item.getField()); } - temp.append(StringUtil.join(groupFields)); + temp.append(StrUtil.join(",", groupFields)); sql = temp.append(" from ( ").append(sql).append(" ) "); } if (CollUtil.isNotEmpty(dataSourceRequest.getAggregate()) && "average".equals(dataSourceRequest.getAggregate().get(0).getAggregate())){ diff --git a/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqServiceImpl.java b/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqServiceImpl.java index ec0aaa4..516de82 100644 --- a/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/eng/service/impl/EngEqServiceImpl.java @@ -2,21 +2,13 @@ package com.yfd.platform.eng.service.impl; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.*; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceRequest; -import com.yfd.platform.common.MicroservicDynamicSQLMapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yfd.platform.common.*; import com.yfd.platform.eng.domain.MsEngEq; import com.yfd.platform.eng.mapper.EngEqMapper; import com.yfd.platform.eng.service.EngEqService; -import com.zny.dec.framework.kendo.entity.dto.devextreme.GroupingInfo; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; -import com.zny.dec.framework.kendo.entity.mapping.GroupResult; -import com.zny.dec.framework.kendo.mybatis.devExtreme.helper.GroupHelper; -import com.zny.dec.framework.kendo.util.KendoUtil; +import com.yfd.platform.utils.KendoUtil; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; diff --git a/backend/src/main/java/com/yfd/platform/eng/service/impl/EngSpecialServiceImpl.java b/backend/src/main/java/com/yfd/platform/eng/service/impl/EngSpecialServiceImpl.java index 7c96d9a..0854231 100644 --- a/backend/src/main/java/com/yfd/platform/eng/service/impl/EngSpecialServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/eng/service/impl/EngSpecialServiceImpl.java @@ -1,12 +1,10 @@ package com.yfd.platform.eng.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.yfd.platform.common.DataSourceRequest; -//import com.yfd.platform.common.DataSourceResult; +import com.yfd.platform.common.DataSourceRequest; +import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.eng.entity.EqSpecial; import com.yfd.platform.eng.service.EngSpecialService; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceRequest; -import com.zny.dec.framework.kendo.entity.dto.kendo.DataSourceResult; import org.springframework.stereotype.Service; import java.util.ArrayList; diff --git a/backend/src/main/java/com/yfd/platform/utils/KendoUtil.java b/backend/src/main/java/com/yfd/platform/utils/KendoUtil.java new file mode 100644 index 0000000..8701ea0 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/utils/KendoUtil.java @@ -0,0 +1,104 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.yfd.platform.utils; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yfd.platform.common.DataSourceRequest; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KendoUtil extends ReflectUtil { + public KendoUtil() { + } + +// public static Map getGroupResultMap(DataSourceRequest dataSourceRequest, String filter, Class clas) { +// SearcherBuilder.BeanSearcherBuilder beanSearcher = SearcherBuilder.beanSearcher(); +// GroupViewModel groupViewModel = null; +// if (filter == null) { +// groupViewModel = new GroupViewModel(clas, (String)null); +// } else { +// groupViewModel = new GroupViewModel(GroupViewModel.class, filter); +// } +// +// return beanSearcher.build().constructGroupSql(groupViewModel, dataSourceRequest); +// } + + public static String getGroupBy(DataSourceRequest dataSourceRequest) { + String groupBy = null; + List groupDescriptorList = dataSourceRequest.getGroup(); + if (CollectionUtil.isNotEmpty(groupDescriptorList)) { + StringBuilder groupByBuilder = new StringBuilder(); + StringBuilder orderByBuilder = new StringBuilder(); + int groupInfoCount = groupDescriptorList.size(); + + for(int i = 0; i < groupInfoCount; ++i) { + DataSourceRequest.GroupDescriptor groupingInfo = (DataSourceRequest.GroupDescriptor)groupDescriptorList.get(i); + String selector = groupingInfo.getField(); + String dir = groupingInfo.getDir(); + groupByBuilder.append(selector); + if (groupingInfo.getNeedSortFlag()) { + if ("desc".equals(dir)) { + orderByBuilder.append(selector).append(" desc"); + } else { + orderByBuilder.append(selector).append(" asc"); + } + } + + if (i < groupInfoCount - 1) { + groupByBuilder.append(", "); + orderByBuilder.append(", "); + } + } + + if (groupInfoCount > 0) { + StringBuilder groupResult = new StringBuilder(); + groupResult.append(" group by ").append(groupByBuilder.toString()); + if (StrUtil.isNotBlank(orderByBuilder.toString())) { + groupResult.append(" order by ").append(orderByBuilder.toString()); + } + + groupBy = groupResult.toString(); + } + } + + return groupBy; + } + + public static Page getPage(DataSourceRequest dataSourceRequest) { + if (dataSourceRequest.getTake() != 0) { + Page page = new Page(); + page.setSize((long)dataSourceRequest.getTake()); + page.setCurrent((long)(dataSourceRequest.getSkip() / dataSourceRequest.getTake() + 1)); + return page; + } else { + return null; + } + } + + public static Map getFieldValues(Object obj) { + if (null != obj) { + Field[] fields = getFields(obj instanceof Class ? (Class)obj : obj.getClass()); + if (null != fields) { + Map valueMap = new HashMap(); + + for(int i = 0; i < fields.length; ++i) { + Object value = getFieldValue(obj, fields[i]); + valueMap.put(fields[i].getName(), value); + } + + return valueMap; + } + } + + return null; + } +} diff --git a/backend/src/main/java/com/yfd/platform/utils/QgcQueryWrapperUtil.java b/backend/src/main/java/com/yfd/platform/utils/QgcQueryWrapperUtil.java new file mode 100644 index 0000000..bdbb6ac --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/utils/QgcQueryWrapperUtil.java @@ -0,0 +1,679 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.yfd.platform.utils; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; +import com.baomidou.mybatisplus.core.metadata.TableInfo; +import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.gson.*; +import com.yfd.platform.common.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.util.*; +import java.util.stream.Collectors; + +public class QgcQueryWrapperUtil { + private static final Logger log = LoggerFactory.getLogger(QgcQueryWrapperUtil.class); + public static final List FIELDNULL = new ArrayList(); + + public QgcQueryWrapperUtil() { + } + + public static String getJsonFieldNull(String columName) { + return FIELDNULL.contains(columName) ? "00000000-0000-0000-0000-000000000000" : null; + } + + public static String getFilterFieldValue(DataSourceLoadOptionsBase loadOptions, String fieldName) { + try { + JsonElement jsonElement = (new JsonParser()).parse(JSONUtil.toJsonStr(loadOptions.getFilter())); + if (jsonElement instanceof JsonNull) { + return null; + } + + JsonArray jArray = (JsonArray)jsonElement; + StringBuffer fieldValue = new StringBuffer(); + parseJArrayConditions(jArray, fieldName, fieldValue); + if (fieldValue != null && StrUtil.isNotBlank(fieldValue.toString())) { + return fieldValue.toString(); + } + } catch (Exception ex) { + log.error("获取值异常", ex); + } + + return null; + } + + public static PageInfo getPageInfo(DataSourceLoadOptionsBase loadOptions) { + PageInfo pageInfo = new PageInfo(); + if (loadOptions.getTake() != null && loadOptions.getTake() != 0) { + Page page = null; + if (loadOptions.getSkip() != null && loadOptions.getSkip() != 0) { + page = new Page((long)(loadOptions.getSkip() / loadOptions.getTake() + 1), (long)loadOptions.getTake()); + } else { + loadOptions.setSkip(0); + page = new Page(1L, (long)loadOptions.getTake()); + } + + pageInfo.setHasPageInfo(true); + pageInfo.setPage(page); + return pageInfo; + } else { + pageInfo.setHasPageInfo(false); + return pageInfo; + } + } + + private static void parseJArrayConditions(JsonArray jsonArray, String fieldName, StringBuffer fieldValue) { + if (jsonArray != null && jsonArray.size() != 0) { + if (jsonArray.get(0).isJsonPrimitive()) { + String columnName = jsonArray.get(0).getAsString(); + String condition = jsonArray.get(1).getAsString(); + Object value = null; + Object tempValue = jsonArray.get(2); + if (((JsonElement)tempValue).isJsonPrimitive()) { + JsonPrimitive jsonPrimitive = ((JsonElement)tempValue).getAsJsonPrimitive(); + if (jsonPrimitive.isBoolean()) { + value = jsonPrimitive.getAsBoolean(); + } + + if (jsonPrimitive.isNumber()) { + Object var10 = jsonPrimitive.getAsNumber(); + if (var10.toString().contains(".")) { + value = ((Number)var10).doubleValue(); + } else { + value = ((Number)var10).longValue(); + } + } + + if (jsonPrimitive.isString()) { + value = jsonPrimitive.getAsString(); + } + + if (jsonPrimitive.isJsonNull()) { + value = getJsonFieldNull(columnName); + } + } else if (tempValue instanceof JsonNull) { + value = null; + } else { + value = ((JsonElement)tempValue).getAsJsonArray(); + if (value != null) { + value = value.toString(); + } + } + + if (columnName != null && columnName.equals(fieldName)) { + if (StrUtil.isEmpty((CharSequence) value)) { + StringBuffer var9 = null; + return; + } + + if (StrUtil.isBlank(fieldValue)) { + fieldValue.append(value); + } else { + fieldValue.append(",").append(value); + } + } + } else { + if (!jsonArray.get(0).isJsonArray()) { + throw new RuntimeException("Unknown data type in json array."); + } + + parseArrayConditions(jsonArray, fieldName, fieldValue); + } + + } else { + StringBuffer var8 = null; + } + } + + private static void parseArrayConditions(JsonArray jsonArray, String fieldName, StringBuffer fieldValue) { + if (jsonArray != null && jsonArray.size() != 0) { + if (jsonArray.size() == 1) { + parseJArrayConditions(jsonArray.get(0).getAsJsonArray(), fieldName, fieldValue); + } else { + for(int i = 0; i <= jsonArray.size(); i += 2) { + JsonElement jsonItem = jsonArray.get(i); + if (i == 0) { + parseJArrayConditions(jsonArray.get(0).getAsJsonArray(), fieldName, fieldValue); + } else { + String condition = jsonArray.get(i - 1).getAsString(); + if (condition.equals("and")) { + if (jsonItem.getAsJsonArray().get(0).isJsonPrimitive()) { + parseJArrayConditions(jsonItem.getAsJsonArray(), fieldName, fieldValue); + } else { + parseJArrayConditions(jsonItem.getAsJsonArray(), fieldName, fieldValue); + } + } else if (condition.equals("or")) { + if (jsonItem.getAsJsonArray().get(0).isJsonPrimitive()) { + parseJArrayConditions(jsonItem.getAsJsonArray(), fieldName, fieldValue); + } else { + parseJArrayConditions(jsonItem.getAsJsonArray(), fieldName, fieldValue); + } + } else { + throwIfUnknownCondition(condition); + } + } + } + + } + } else { + StringBuffer var6 = null; + } + } + + private static void parseJArrayConditions(JsonArray jsonArray, QueryWrapper queryWrapper, Map fieldsMap, List removeFields, Class modelClass, Boolean validateColumn) { + if (jsonArray.get(0).isJsonPrimitive()) { + String columnName = jsonArray.get(0).getAsString(); + String condition = jsonArray.get(1).getAsString(); + Object value = null; + Object tempValue = jsonArray.get(2); + if (((JsonElement)tempValue).isJsonPrimitive()) { + JsonPrimitive jsonPrimitive = ((JsonElement)tempValue).getAsJsonPrimitive(); + if (jsonPrimitive.isBoolean()) { + value = jsonPrimitive.getAsBoolean(); + } + + if (jsonPrimitive.isNumber()) { + Object var15 = jsonPrimitive.getAsNumber(); + if (var15.toString().contains(".")) { + value = ((Number)var15).doubleValue(); + } else { + value = ((Number)var15).longValue(); + } + } + + if (jsonPrimitive.isString()) { + value = jsonPrimitive.getAsString(); + } + + if (jsonPrimitive.isJsonNull()) { + value = getJsonFieldNull(columnName); + } + } + + if (removeFields != null && CollectionUtil.contains((Collection) removeFields.iterator(), columnName)) { + return; + } + + String databaseColumnName = (String)fieldsMap.get(columnName); + if (databaseColumnName == null) { + if (validateColumn) { + throw new RuntimeException(columnName + "字段不存在"); + } + + databaseColumnName = columnName; + } + + if (value == null) { + Field field = ReflectUtil.getField(modelClass, columnName); + if (null != field) { + Annotation[] annotations = field.getDeclaredAnnotations(); + if (ArrayUtil.isNotEmpty(annotations)) { + for(Annotation annotation : Arrays.asList(annotations)) { + if (annotation.annotationType().equals(JsonSerialize.class) && ((JsonSerialize)annotation).using().equals(GuidStringSerialize.class)) { + value = "00000000-0000-0000-0000-000000000000"; + break; + } + } + } + } + } + + if (value instanceof Boolean) { + Boolean var17 = (Boolean)value; + } + + if (condition.equals("contains")) { + queryWrapper.like(databaseColumnName, value); + } else if (condition.equals("notcontains")) { + queryWrapper.notLike(databaseColumnName, value); + } else if (condition.equals("startswith")) { + queryWrapper.likeRight(databaseColumnName, value); + } else if (condition.equals("endswith")) { + queryWrapper.likeLeft(databaseColumnName, value); + } else if (condition.equals("=")) { + if (value == null) { + queryWrapper.isNull(databaseColumnName); + } else { + queryWrapper.eq(databaseColumnName, value); + } + } else if (condition.equals("!=")) { + queryWrapper.ne(databaseColumnName, value); + } else if (condition.equals("<>")) { + queryWrapper.ne(databaseColumnName, value); + } else if (condition.equals("<")) { + queryWrapper.lt(databaseColumnName, value); + } else if (condition.equals("<=")) { + queryWrapper.le(databaseColumnName, value); + } else if (condition.equals(">")) { + queryWrapper.gt(databaseColumnName, value); + } else if (condition.equals(">=")) { + queryWrapper.ge(databaseColumnName, value); + } else { + throwIfUnknownCondition(condition); + } + } else { + if (!jsonArray.get(0).isJsonArray()) { + throw new RuntimeException("Unknown data type in json array."); + } + + parseArrayConditions(jsonArray, queryWrapper, fieldsMap, removeFields, modelClass, validateColumn); + } + + } + + private static void getJArrayFilterFields(JsonArray jsonArray, List filterFieldEmptyValueList, List filterFieldList, Class modelClass) { + if (jsonArray.get(0).isJsonPrimitive()) { + String columnName = jsonArray.get(0).getAsString(); + Object value = null; + Object tempValue = jsonArray.get(2); + if (((JsonElement)tempValue).isJsonPrimitive()) { + JsonPrimitive jsonPrimitive = ((JsonElement)tempValue).getAsJsonPrimitive(); + if (jsonPrimitive.isBoolean()) { + Object var8 = jsonPrimitive.getAsBoolean(); + } + + if (jsonPrimitive.isNumber()) { + Object var9 = jsonPrimitive.getAsNumber(); + if (var9.toString().contains(".")) { + Object var10 = ((Number)var9).doubleValue(); + } else { + Object var11 = ((Number)var9).longValue(); + } + } + + if (jsonPrimitive.isString()) { + Object var12 = jsonPrimitive.getAsString(); + } + + if (jsonPrimitive.isJsonNull()) { + Object var13 = getJsonFieldNull(columnName); + } + } + + filterFieldList.add(columnName); + } else { + if (!jsonArray.get(0).isJsonArray()) { + throw new RuntimeException("Unknown data type in json array."); + } + + getArrayFilterFields(jsonArray, filterFieldEmptyValueList, filterFieldList, modelClass); + } + + } + + private static void getArrayFilterFields(JsonArray jsonArray, List filterFieldEmptyValueList, List filterFieldList, Class modelClass) { + if (jsonArray.size() == 1) { + getJArrayFilterFields(jsonArray.get(0).getAsJsonArray(), filterFieldEmptyValueList, filterFieldList, modelClass); + } else { + for(int i = 0; i <= jsonArray.size(); i += 2) { + JsonElement jsonItem = jsonArray.get(i); + if (i == 0) { + getJArrayFilterFields(jsonArray.get(0).getAsJsonArray(), filterFieldEmptyValueList, filterFieldList, modelClass); + } else { + String condition = jsonArray.get(i - 1).getAsString(); + if (condition.equals("and")) { + if (jsonItem.getAsJsonArray().get(0).isJsonPrimitive()) { + getJArrayFilterFields(jsonItem.getAsJsonArray(), filterFieldEmptyValueList, filterFieldList, modelClass); + } else { + getJArrayFilterFields(jsonItem.getAsJsonArray(), filterFieldEmptyValueList, filterFieldList, modelClass); + } + } else if (condition.equals("or")) { + if (jsonItem.getAsJsonArray().get(0).isJsonPrimitive()) { + getJArrayFilterFields(jsonItem.getAsJsonArray(), filterFieldEmptyValueList, filterFieldList, modelClass); + } else { + getJArrayFilterFields(jsonItem.getAsJsonArray(), filterFieldEmptyValueList, filterFieldList, modelClass); + } + } else { + throwIfUnknownCondition(condition); + } + } + } + + } + } + + private static void parseJArrayConditions(JsonArray jsonArray, QueryWrapper queryWrapper, Class modelClass, Boolean validateColumn) { + if (jsonArray.get(0).isJsonPrimitive()) { + String columnName = jsonArray.get(0).getAsString(); + String condition = jsonArray.get(1).getAsString(); + Object value = null; + Object tempValue = jsonArray.get(2); + if (((JsonElement)tempValue).isJsonPrimitive()) { + JsonPrimitive jsonPrimitive = ((JsonElement)tempValue).getAsJsonPrimitive(); + if (jsonPrimitive.isBoolean()) { + value = jsonPrimitive.getAsBoolean(); + } + + if (jsonPrimitive.isNumber()) { + Object var12 = jsonPrimitive.getAsNumber(); + if (var12.toString().contains(".")) { + value = ((Number)var12).doubleValue(); + } else { + value = ((Number)var12).longValue(); + } + } + + if (jsonPrimitive.isString()) { + value = jsonPrimitive.getAsString(); + } + + if (jsonPrimitive.isJsonNull()) { + value = getJsonFieldNull(columnName); + } + } + + String databaseColumnName = getDBColumnName(modelClass, columnName, validateColumn); + if (value == null) { + Annotation[] annotations = ReflectUtil.getField(modelClass, columnName).getDeclaredAnnotations(); + if (ArrayUtil.isNotEmpty(annotations)) { + for(Annotation annotation : Arrays.asList(annotations)) { + if (annotation.annotationType().equals(JsonSerialize.class) && ((JsonSerialize)annotation).using().equals(GuidStringSerialize.class)) { + value = "00000000-0000-0000-0000-000000000000"; + break; + } + } + } + } + + if (condition.equalsIgnoreCase("contains")) { + queryWrapper.like(databaseColumnName, value); + } else if (condition.equalsIgnoreCase("notcontains")) { + queryWrapper.notLike(databaseColumnName, value); + } else if (condition.equalsIgnoreCase("startswith")) { + queryWrapper.likeRight(databaseColumnName, value); + } else if (condition.equalsIgnoreCase("endswith")) { + queryWrapper.likeLeft(databaseColumnName, value); + } else if (condition.equalsIgnoreCase("=")) { + if (value == null) { + queryWrapper.isNull(databaseColumnName); + } else { + queryWrapper.eq(databaseColumnName, value); + } + } else if (condition.equalsIgnoreCase("!=")) { + queryWrapper.ne(databaseColumnName, value); + } else if (condition.equalsIgnoreCase("<>")) { + queryWrapper.ne(databaseColumnName, value); + } else if (condition.equalsIgnoreCase("<")) { + queryWrapper.lt(databaseColumnName, value); + } else if (condition.equalsIgnoreCase("<=")) { + queryWrapper.le(databaseColumnName, value); + } else if (condition.equalsIgnoreCase(">")) { + queryWrapper.gt(databaseColumnName, value); + } else if (condition.equalsIgnoreCase(">=")) { + queryWrapper.ge(databaseColumnName, value); + } else { + throwIfUnknownCondition(condition); + } + } else { + if (!jsonArray.get(0).isJsonArray()) { + throw new RuntimeException("Unknown data type in json array."); + } + + parseArrayConditions(jsonArray, queryWrapper, modelClass, validateColumn); + } + + } + + private static void parseArrayConditions(JsonArray jsonArray, QueryWrapper queryWrapper, Map fieldsMap, List removeFields, Class modelClass, Boolean validateColumn) { + if (jsonArray.size() == 1) { + parseJArrayConditions(jsonArray.get(0).getAsJsonArray(), queryWrapper, fieldsMap, removeFields, modelClass, validateColumn); + } else { + for(int i = 0; i <= jsonArray.size(); i += 2) { + JsonElement jsonItem = jsonArray.get(i); + if (i == 0) { + if (jsonArray.get(0).getAsJsonArray().get(0).isJsonPrimitive()) { + parseJArrayConditions(jsonArray.get(0).getAsJsonArray(), queryWrapper, fieldsMap, removeFields, modelClass, validateColumn); + } else if (jsonArray.get(0).getAsJsonArray().size() == 1) { + parseJArrayConditions(jsonArray.get(0).getAsJsonArray().get(0).getAsJsonArray(), queryWrapper, fieldsMap, removeFields, modelClass, validateColumn); + } else { + queryWrapper.and((wrapper) -> parseJArrayConditions(jsonArray.get(0).getAsJsonArray(), wrapper, fieldsMap, removeFields, modelClass, validateColumn)); + } + } else { + String condition = jsonArray.get(i - 1).getAsString(); + if (condition.equals("and")) { + if (jsonItem.getAsJsonArray().get(0).isJsonPrimitive()) { + parseJArrayConditions(jsonItem.getAsJsonArray(), queryWrapper, fieldsMap, removeFields, modelClass, validateColumn); + } else if (jsonArray.get(0).getAsJsonArray().size() == 1) { + parseJArrayConditions(jsonArray.get(0).getAsJsonArray().get(0).getAsJsonArray(), queryWrapper, fieldsMap, removeFields, modelClass, validateColumn); + } else { + queryWrapper.and((wrapper) -> parseJArrayConditions(jsonItem.getAsJsonArray(), wrapper, fieldsMap, removeFields, modelClass, validateColumn)); + } + } else if (condition.equals("or")) { + if (jsonItem.getAsJsonArray().get(0).isJsonPrimitive()) { + queryWrapper.or(); + parseJArrayConditions(jsonItem.getAsJsonArray(), queryWrapper, fieldsMap, removeFields, modelClass, validateColumn); + } else if (jsonArray.get(0).getAsJsonArray().size() == 1) { + parseJArrayConditions(jsonArray.get(0).getAsJsonArray().get(0).getAsJsonArray(), queryWrapper, fieldsMap, removeFields, modelClass, validateColumn); + } else { + queryWrapper.or((wrapper) -> parseJArrayConditions(jsonItem.getAsJsonArray(), wrapper, fieldsMap, removeFields, modelClass, validateColumn)); + } + } else { + throwIfUnknownCondition(condition); + } + } + } + + } + } + + private static void parseArrayConditions(JsonArray jsonArray, QueryWrapper queryWrapper, Class modelClass, Boolean validateColumn) { + if (jsonArray.size() == 1) { + parseJArrayConditions(jsonArray.get(0).getAsJsonArray(), queryWrapper, modelClass, validateColumn); + } else { + for(int i = 0; i <= jsonArray.size(); i += 2) { + JsonElement jsonItem = jsonArray.get(i); + if (i == 0) { + if (jsonArray.get(0).getAsJsonArray().get(0).isJsonPrimitive()) { + parseJArrayConditions(jsonArray.get(0).getAsJsonArray(), queryWrapper, modelClass, validateColumn); + } else { + queryWrapper.and((wrapper) -> parseJArrayConditions(jsonArray.get(0).getAsJsonArray(), wrapper, modelClass, validateColumn)); + } + } else { + String condition = jsonArray.get(i - 1).getAsString(); + if (condition.equals("and")) { + if (jsonItem.getAsJsonArray().get(0).isJsonPrimitive()) { + parseJArrayConditions(jsonItem.getAsJsonArray(), queryWrapper, modelClass, validateColumn); + } else { + queryWrapper.and((wrapper) -> parseJArrayConditions(jsonItem.getAsJsonArray(), wrapper, modelClass, validateColumn)); + } + } else if (condition.equals("or")) { + if (jsonItem.getAsJsonArray().get(0).isJsonPrimitive()) { + queryWrapper.or(); + parseJArrayConditions(jsonItem.getAsJsonArray(), queryWrapper, modelClass, validateColumn); + } else { + queryWrapper.or((wrapper) -> parseJArrayConditions(jsonItem.getAsJsonArray(), wrapper, modelClass, validateColumn)); + } + } else { + throwIfUnknownCondition(condition); + } + } + } + + } + } + + private static void throwIfUnknownCondition(String condition) { + switch (condition) { + case "=": + case "<>": + case "!=": + case "<": + case ">": + case "<=": + case ">=": + return; + default: + throw new RuntimeException(String.format("Unknown condition %s", condition)); + } + } + + public static String getDBColumnName(Class modelClass, String cloumn) { + TableInfo tableInfo = TableInfoHelper.getTableInfo(modelClass); + if (cloumn.equals(tableInfo.getKeyProperty())) { + return tableInfo.getKeyColumn(); + } else { + List fieldInfos = (List)tableInfo.getFieldList().stream().filter((tableFieldInfo) -> cloumn.equals(tableFieldInfo.getProperty())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(fieldInfos)) { + return ((TableFieldInfo)fieldInfos.get(0)).getColumn(); + } else { + throw new RuntimeException(cloumn + "列找不到"); + } + } + } + + public static String getDBColumnName(Class modelClass, String cloumn, Boolean validateColumn) { + TableInfo tableInfo = TableInfoHelper.getTableInfo(modelClass); + if (cloumn.equals(tableInfo.getKeyProperty())) { + return tableInfo.getKeyColumn(); + } else { + List fieldInfos = (List)tableInfo.getFieldList().stream().filter((tableFieldInfo) -> cloumn.equals(tableFieldInfo.getProperty())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(fieldInfos)) { + return ((TableFieldInfo)fieldInfos.get(0)).getColumn(); + } else if (validateColumn) { + throw new RuntimeException(cloumn + "列找不到"); + } else { + return cloumn; + } + } + } + + public static String getDBTableName(Class modelClass) { + TableInfo tableInfo = TableInfoHelper.getTableInfo(modelClass); + return tableInfo.getTableName(); + } + + public static String toHyphenation(String src, String hyphenation) { + StringBuilder sb = new StringBuilder(src); + int cnt = 0; + + for(int i = 1; i < src.length(); ++i) { + if (Character.isUpperCase(src.charAt(i))) { + sb.insert(i + cnt, hyphenation); + cnt += hyphenation.length(); + } + } + + return sb.toString().toLowerCase(); + } + + public static String toUnderline(String src) { + return toHyphenation(src, "_"); + } + + public static Map groupConvertByFieldMeta(DataSourceRequest dataSourceRequest, Map> groupItemMapping) { + if (dataSourceRequest.getFilter() != null) { + Map result = new HashMap(); + if (groupItemMapping.size() == 1) { + String group = (String)groupItemMapping.keySet().toArray()[0]; + FilterFieldMeta filterFieldMeta = new FilterFieldMeta(dataSourceRequest.getFilter(), (Map)groupItemMapping.get(group)); + constructOrderByFieldMeta(dataSourceRequest.getSort(), filterFieldMeta); + result.put(group, filterFieldMeta); + } else { + groupItemMapping.forEach((key, value) -> { + FilterFieldMeta filterFieldMeta = constructFilterFieldMeta(dataSourceRequest.getFilter(), value); + constructOrderByFieldMeta(dataSourceRequest.getSort(), filterFieldMeta); + result.put(key, filterFieldMeta); + }); + } + + return result; + } else { + return null; + } + } + + private static FilterFieldMeta constructOrderByFieldMeta(List sortDescriptors, FilterFieldMeta filterFieldMeta) { + if (CollectionUtil.isNotEmpty(sortDescriptors)) { + List orderByList = new ArrayList(); + + for(DataSourceRequest.SortDescriptor sortDescriptor : sortDescriptors) { + if (filterFieldMeta.getFieldMeta().containsKey(sortDescriptor.getField())) { + OrderBy orderBy = new OrderBy(sortDescriptor.getField(), sortDescriptor.getDir()); + orderByList.add(orderBy); + } + } + + if (CollectionUtil.isNotEmpty(orderByList)) { + filterFieldMeta.setOrderByList(orderByList); + } + } + + return filterFieldMeta; + } + + private static FilterFieldMeta constructFilterFieldMeta(DataSourceRequest.FilterDescriptor filter, Map fieldMeta) { + DataSourceRequest.FilterDescriptor groupFilter = new DataSourceRequest.FilterDescriptor(); + constructGroupFilter(filter, groupFilter, fieldMeta); + deleteEmptyNode(groupFilter); + FilterFieldMeta result = new FilterFieldMeta(groupFilter, fieldMeta); + return result; + } + + private static Boolean deleteEmptyNode(DataSourceRequest.FilterDescriptor groupFilter) { + if (groupFilter != null) { + List filterDescriptors = groupFilter.getFilters(); + if (StrUtil.isEmpty(groupFilter.getField()) && StrUtil.isEmpty(groupFilter.getOperator()) && CollectionUtil.isNotEmpty(filterDescriptors)) { + Iterator iterator = filterDescriptors.iterator(); + + while(iterator.hasNext()) { + if (deleteEmptyNode((DataSourceRequest.FilterDescriptor)iterator.next())) { + iterator.remove(); + } + } + } + + if (StrUtil.isEmpty(groupFilter.getField()) && StrUtil.isEmpty(groupFilter.getOperator()) && CollectionUtil.isEmpty(filterDescriptors)) { + return true; + } + } + + return false; + } + + private static void constructGroupFilter(DataSourceRequest.FilterDescriptor filter, DataSourceRequest.FilterDescriptor groupFilter, Map fieldMeta) { + if (filter != null) { + List filters = filter.getFilters(); + if (CollectionUtil.isNotEmpty(filters)) { + groupFilter.setLogic(filter.getLogic()); + + for(DataSourceRequest.FilterDescriptor entry : filters) { + if (CollectionUtil.isNotEmpty(entry.getFilters())) { + DataSourceRequest.FilterDescriptor nodeFilter = new DataSourceRequest.FilterDescriptor(); + nodeFilter.setLogic(entry.getLogic()); + groupFilter.getFilters().add(nodeFilter); + constructGroupFilter(entry, nodeFilter, fieldMeta); + } else if (null != fieldMeta.get(entry.getField())) { + DataSourceRequest.FilterDescriptor nodeFilter = new DataSourceRequest.FilterDescriptor(); + nodeFilter.setLogic(entry.getLogic()); + nodeFilter.setField(entry.getField()); + nodeFilter.setOperator(entry.getOperator()); + nodeFilter.setValue(entry.getValue()); + nodeFilter.setDataType(entry.getDataType()); + groupFilter.getFilters().add(nodeFilter); + } + } + } + } + + } + + + static { + FIELDNULL.add("parentId"); + } +} diff --git a/backend/src/main/java/com/yfd/platform/utils/QueryWrapperUtil.java b/backend/src/main/java/com/yfd/platform/utils/QueryWrapperUtil.java index ca1142c..35151a1 100644 --- a/backend/src/main/java/com/yfd/platform/utils/QueryWrapperUtil.java +++ b/backend/src/main/java/com/yfd/platform/utils/QueryWrapperUtil.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.zny.dec.framework.kendo.entity.dto.devextreme.DataSourceLoadOptionsBase; +import com.yfd.platform.common.DataSourceLoadOptionsBase; import java.lang.reflect.Field; import java.lang.reflect.Modifier; diff --git a/backend/src/main/resources/application-devtw.yml b/backend/src/main/resources/application-devtw.yml index be7a29c..d571469 100644 --- a/backend/src/main/resources/application-devtw.yml +++ b/backend/src/main/resources/application-devtw.yml @@ -40,7 +40,7 @@ swagger-ui: enabled: true mybatis-plus: - mapper-locations: classpath*:**/mapper/*Mapper.xml,classpath*:**/mapping/*Mapper.xml +# mapper-locations: classpath*:**/mapper/*Mapper.xml,classpath*:**/mapping/*Mapper.xml global-config: banner: false db-config: