From 3b6b2e8d625b3d9dfc1a819b52e23da1a493506e Mon Sep 17 00:00:00 2001
From: 杜洪波 <1074825718@qq.com>
Date: 星期四, 06 十一月 2025 10:23:17 +0800
Subject: [PATCH] 图标配置优化
---
src/main/java/com/product/server/report/service/GenerateEChartService.java | 208 +++++++++++++++++++++++++++++-----------------------
1 files changed, 116 insertions(+), 92 deletions(-)
diff --git a/src/main/java/com/product/server/report/service/GenerateEChartService.java b/src/main/java/com/product/server/report/service/GenerateEChartService.java
index 813c664..a20b9ce 100644
--- a/src/main/java/com/product/server/report/service/GenerateEChartService.java
+++ b/src/main/java/com/product/server/report/service/GenerateEChartService.java
@@ -17,12 +17,16 @@
import com.product.core.transfer.Transactional;
import com.product.server.report.config.CmnConst;
import com.product.server.report.config.ReportCode;
+import com.product.server.report.config.SystemCode;
import com.product.server.report.service.idel.IGenerateEChartService;
import com.product.util.BaseUtil;
import com.product.util.SystemParamReplace;
+
+import org.apache.bcel.generic.NEW;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.util.Arrays;
import java.util.List;
/**
@@ -48,6 +52,7 @@
public DataListReportService dataListReportService;
@Autowired
QueryFilterService queryFilterService;
+
@Override
public JSONArray generatePieEChartMaster(FieldSetEntity fse) throws BaseException {
String uuid = fse.getString(CmnConst.UUID);
@@ -76,101 +81,105 @@
@Override
public JSONObject generatePieEChart(FieldSetEntity fse) throws BaseException {
- //鏁版嵁婧恥uid
+ // 鑾峰彇鏁版嵁婧怳UID 鍜� 鎶ヨ〃绫诲瀷UUID
String report_datasource_uuid = fse.getString(CmnConst.REPORT_DATASOURCE_UUID);
- //绫诲瀷uuid
String report_type_config_uuid = fse.getString(CmnConst.REPORT_TYPE_CONFIG_UUID);
if(BaseUtil.strIsNull(report_datasource_uuid) || BaseUtil.strIsNull(report_type_config_uuid)){
return BaseUtil.fieldSetEntityToJson(fse);
}
- //鏌ヨ绫诲瀷琛�
- FieldSetEntity typeField = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_TYPE_CONFIG, report_type_config_uuid,false);
-
- //鑾峰彇閰嶇疆鎶ヨ〃鏁版嵁婧恉ata鏁版嵁琛� .PRODUCT_SYS_report_datasource_config瀛愯〃
- FieldSetEntity datasourceField = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG,report_datasource_uuid,true);
+ // 鑾峰彇鎶ヨ〃绫诲瀷
+ FieldSetEntity fseReportType = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_TYPE_CONFIG, report_type_config_uuid, false);
+ // 鑾峰彇鎶ヨ〃鏁版嵁婧愰厤缃〃鍜屽瓧娈佃〃
+ FieldSetEntity datasourceField = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG, report_datasource_uuid, true);
//鑾峰彇鏌ヨ鐨勬暟鎹畇ql
String sql_text = datasourceField.getString(CmnConst.SQL_TEXT);
//瑙f瀽SQL閲岄潰鐨勭郴缁熷弬鏁�
sql_text = SystemParamReplace.systemParamsReplace(sql_text);
- String type_group = typeField.getString(CmnConst.TYPE_GROUP);
+ String typeGroup = fseReportType.getString(CmnConst.TYPE_GROUP);
//涓哄叧绯诲浘
- if("relationCharts".equals(type_group)){
+ if("relationCharts".equals(typeGroup)){
JSONObject obj = this.chooseRelationship(sql_text);
- String typeGroup = typeField.getString(CmnConst.TYPE_GROUP);
JSONObject object = new JSONObject();
- object.put(CmnConst.TYPE_GROUP,typeGroup);
+ object.put(CmnConst.TYPE_GROUP, typeGroup);
object.put(CmnConst.OPTION,obj);
// object.put("function",this.functionArray(uuid));
return object;
}
+ // 鑾峰彇鎶ヨ〃鏁版嵁婧愭暟鎹�
DataTableEntity valueData = baseDao.listTable(sql_text,new Object[]{});
//鑾峰彇鎶ヨ〃閰嶇疆灞炴�ц〃 鍔爀charts閰嶇疆灞炴��
- //鍙兘鏌ヨ鍒板叧鑱斿睘鎬у�肩殑灞炴�ц〃锛屽鏋滅埗绾у睘鎬т笅鏈夊涓浉鍚屽瓙灞炴�с�傞�氳繃grouping鍒嗙粍銆�
- DataTableEntity attributeData = baseDao.listTable("SELECT a.field_name,a.report_type_attr_value,a.uuid,a.grouping ,b.* FROM product_sys_report_config_attribute a LEFT JOIN product_sys_report_type_attribute b on a.report_type_attr = b.uuid WHERE a.report_config_uuid = ? ORDER BY a.grouping,b.parentAttributeUuid " ,new Object[]{fse.getString(CmnConst.UUID)});
+ //鍙兘鏌ヨ鍒板叧鑱斿睘鎬у�肩殑灞炴�ц〃锛屽鏋滅埗绾у睘鎬т笅鏈夊涓浉鍚屽瓙灞炴�с�傞�氳繃group_sign鍒嗙粍銆�
+ StringBuilder sql = new StringBuilder();
+ sql.append("SELECT a.uuid,a.field_name,a.report_type_attr_value,a.group_sign ,b.* \n");
+ sql.append("FROM product_sys_report_config_attribute a \n");
+ sql.append("LEFT JOIN product_sys_report_type_attribute b on a.report_type_attr = b.uuid \n");
+ sql.append("WHERE a.report_config_uuid = ? \n");
+ sql.append("ORDER BY a.group_sign,b.parent_attribute_uuid");
+ DataTableEntity attributeData = baseDao.listTable(sql.toString() ,new Object[]{fse.getString(CmnConst.UUID)});
+ // 鍒涘缓鍥捐〃灞炴�у鍣�
JSONObject allProperties = new JSONObject();
- if(attributeData.getRows() > 0){
+ if(!BaseUtil.dataTableIsEmpty(attributeData)){
JSONObject propertyObject = new JSONObject();
- String parenUuid1 = attributeData.getString(0,"parentAttributeUuid");
- String grouping1 = attributeData.getString(0,"grouping");
- for (int i = 0,length = attributeData.getRows(); i < length; i++) {
- FieldSetEntity fieldSet = attributeData.getFieldSetEntity(i);
- //涓婄骇uuid
- String parenUuid2 = fieldSet.getString("parentAttributeUuid");
- //涓婄骇name
- String parenName = fieldSet.getString("parentAttributeName");
- //鍥捐〃灞炴�у��
- String attr_value = fieldSet.getString("report_type_attr_value");
- //涓虹┖浼犻粯璁ゅ��
- if(BaseUtil.strIsNull(attr_value)){
- attr_value = fieldSet.getString("default_value");
+ String preParenAttrUuid = attributeData.getString(0, CmnConst.PARENT_ATTRIBUTE_UUID);
+ String preGroupSign = attributeData.getString(0, CmnConst.GROUP_SIGN);
+ for (int i = 0, length = attributeData.getRows(); i < length; i++) {
+ FieldSetEntity fseAttr = attributeData.getFieldSetEntity(i);
+ // 鍥捐〃灞炴�у拰閰嶇疆鍊�
+ String attrName = fseAttr.getString(CmnConst.ATTRIBUTE_NAME);
+ String attrValue = fseAttr.getString(CmnConst.REPORT_TYPE_ATTR_VALUE);
+ if(BaseUtil.strIsNull(attrValue)){
+ // 閰嶇疆鍊间负绌哄垯鐢ㄩ粯璁ゅ��
+ attrValue = fseAttr.getString("default_value");
}
- //鍥捐〃灞�
- String attribute_name = fieldSet.getString("attribute_name");
- //閫氳繃鏁版嵁搴撴彃鍏ユ暟鎹�
- String fieldName = fieldSet.getString(CmnConst.FIELD_NAME);
- //閫氳繃鏁版嵁搴撴彃鍏ユ暟鎹�
- String grouping2 = fieldSet.getString("grouping");
+ // 褰撳墠灞炴�х殑涓婄骇灞炴�uid鍜宯ame
+ String curParenAttrUuid = fseAttr.getString(CmnConst.PARENT_ATTRIBUTE_UUID);
+ String curParenAttrName = fseAttr.getString(CmnConst.PARENT_ATTRIBUTE_NAME);
+
+ // 鑾峰彇褰撳墠灞炴�ч厤缃瓧娈� 鍜� 鍒嗙粍鍊�
+ String fieldName = fseAttr.getString(CmnConst.FIELD_NAME);
+ String curGroupSign = fseAttr.getString(CmnConst.GROUP_SIGN);
+
//鏅�氬睘鎬ч兘鏈変笂绾у睘鎬э紝 鐗规畩鐨勯鑹查鏍煎睘鎬ф棤涓婄骇灞炴�э紝鏈韩灏辨槸椤剁骇灞炴�с��
- if(!BaseUtil.strIsNull(parenUuid2)) {
+ if(!BaseUtil.strIsNull(curParenAttrUuid)) {
//涔嬪墠涓婄骇uuid涓虹┖
- if(BaseUtil.strIsNull(parenUuid1)) {
- parenUuid1 = parenUuid2;
+ if(BaseUtil.strIsNull(preParenAttrUuid)) {
+ preParenAttrUuid = curParenAttrUuid;
//鏈変笉鍚岀殑灞炴�э紝鍏堟妸涔嬪墠鍚屾牱鐨勫睘鎬у皝瑁呫��
- }else if (!BaseUtil.strIsNull(parenUuid1) && !parenUuid2.equals(parenUuid1)) {
+ }else if (!BaseUtil.strIsNull(preParenAttrUuid) && !curParenAttrUuid.equals(preParenAttrUuid)) {
//灏佽涔嬪墠鐨刯son鏁版嵁
- this.getAllProperties(parenUuid1, propertyObject, allProperties);
- parenUuid1 = parenUuid2;
- } else if ((parenUuid2.equals(parenUuid1) && !BaseUtil.strIsNull(grouping2))) {
- if (!grouping2.equals(grouping1)) {
- this.getAllProperties(parenUuid1, propertyObject, allProperties);
+ this.getAllJSONAttrs(preParenAttrUuid, propertyObject, allProperties);
+ preParenAttrUuid = curParenAttrUuid;
+ } else if ((curParenAttrUuid.equals(preParenAttrUuid) && !BaseUtil.strIsNull(curGroupSign))) {
+ if (!curGroupSign.equals(preGroupSign)) {
+ this.getAllJSONAttrs(preParenAttrUuid, propertyObject, allProperties);
}
}
}else{
//涓婄骇灞炴�т负option锛岃鏄庝粬涓烘渶澶у睘鎬ф病鏈変笂绾� 鐩存帴娣诲姞杩沘llProperties
- if("option".equals(parenName)){
- allProperties.put(attribute_name,changeDataFormat(attr_value)[0]);
+ if("option".equals(curParenAttrName)){
+ allProperties.put(attrName, changeDataFormat(attrValue)[0]);
continue;
}
}
- grouping1 = grouping2;
+ preGroupSign = curGroupSign;
//楗肩姸鍥炬彃鍏ユ暟鎹悓灞炰竴涓埗鍏冪礌 澶氫釜鍏冪礌鍜屽搴旂殑鏁版嵁闇�鍏ㄩ儴鎵惧嚭鏉ヤ竴璧峰皝瑁卝son
if(!BaseUtil.strIsNull(fieldName)){
- String parentAttributeName = fieldSet.getString("parentAttributeName");
+ String parentAttributeName = fseAttr.getString(CmnConst.PARENT_ATTRIBUTE_NAME);
//涓嬬骇涓哄璞¤繕鏄暟缁�
- String type = fieldSet.getString("subordinateElementType");
+ String type = fseAttr.getString(CmnConst.SUBORDINATE_ELEMENT_TYPE);
List<String> keys = ListUtils.newArrayList();
List<String> keys2 = ListUtils.newArrayList();
keys.add(fieldName);
- keys2.add(attribute_name);
+ keys2.add(attrName);
//涓烘渶鍚庝竴浣�
while (i < length-1) {
FieldSetEntity fieldSet2 = attributeData.getFieldSetEntity(i+1);
- String parenUuid3 = fieldSet2.getString("parentAttributeUuid");
+ String parenUuid3 = fieldSet2.getString(CmnConst.PARENT_ATTRIBUTE_UUID);
String fieldName3 = fieldSet2.getString(CmnConst.FIELD_NAME);
- if(parenUuid2.equals(parenUuid3) && !BaseUtil.strIsNull(fieldName3)){
+ if(curParenAttrUuid.equals(parenUuid3) && !BaseUtil.strIsNull(fieldName3)){
keys.add(fieldName3);
- keys2.add(fieldSet2.getString("attribute_name"));
+ keys2.add(fieldSet2.getString(CmnConst.ATTRIBUTE_NAME));
}else {
break;
}
@@ -182,21 +191,21 @@
propertyObject.put(parentAttributeName, this.attributesAndValues(valueData, keys, keys2, type));
}
}else {
- propertyObject.put(attribute_name,changeDataFormat(attr_value)[0]);
+ propertyObject.put(attrName, changeDataFormat(attrValue)[0]);
}
if(i == (length - 1)){
//灏佽鏈�鍚庝竴缁勬暟鎹�
- this.getAllProperties(parenUuid1,propertyObject,allProperties);
+ this.getAllJSONAttrs(preParenAttrUuid, propertyObject, allProperties);
}
}
}
- JSONObject s=new JSONObject();
+
//鍥捐〃杈硅窛
+// JSONObject s=new JSONObject();
// s.put("bottom",30);
// s.put("left",30);
// s.put("right",0);
// allProperties.put("grid",s);
- String typeGroup = typeField.getString(CmnConst.TYPE_GROUP);
JSONObject object = BaseUtil.fieldSetEntityToJson(fse);
object.put(CmnConst.TYPE,typeGroup);
object.put(CmnConst.OPTION,allProperties);
@@ -206,38 +215,35 @@
/**
* 鑾峰彇涓婄骇鏁版嵁骞堕�掑綊鎷艰涓婄骇灞炴��
- * @param superiorUuid 涓婄骇uuid
- * @param obj
+ * @param superiorAttrUUID 涓婄骇灞炴�UID
+ * @param noSuperiorJsonAttr 鏈皝瑁呬笂绾х殑JSON灞炴��
+ * @param allProperties 鍥捐〃鎬籎SON灞炴��
* @return
* @throws BaseException
*/
@Override
- public void getAllProperties(String superiorUuid,JSONObject obj,JSONObject allProperties) throws BaseException {
- FieldSetEntity fieldSet = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_TYPE_ATTRIBUTE,superiorUuid,false);
- String attribute_name = fieldSet.getString("attribute_name");
+ public void getAllJSONAttrs(String superiorAttrUUID, JSONObject noSuperiorJsonAttr, JSONObject allProperties) throws BaseException {
+ // 鑾峰彇鏇撮珮绾х埗绾у睘鎬�
+ FieldSetEntity fseAttrInfo = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_TYPE_ATTRIBUTE, superiorAttrUUID, false);
+ String attribute_name = fseAttrInfo.getString(CmnConst.ATTRIBUTE_NAME);
JSONObject superiorObj = new JSONObject();
- JSONArray objSubArray = obj.getJSONArray(attribute_name);
- //纭畾浠栫殑瀛愬睘鎬ф椂(1)array 杩樻槸(0)object
-// if(objSubArray == null){
- if ("1".equals(fieldSet.getString("subordinateElementType"))) {
- JSONArray array = new JSONArray();
- array.add(obj);
- superiorObj.put(attribute_name, array);
- } else {
- superiorObj.put(attribute_name, obj);
- }
-// }else if(objSubArray != null){
-// superiorObj = obj;
-// }
- //涓婄骇灞炴�ame
- superiorUuid = fieldSet.getString("parentAttributeUuid");
- //涓婄骇鍚嶇О
- String parentAttributeName = fieldSet.getString("parentAttributeName");
+ // 鍒ゅ畾灞炴�у�兼槸Object鏁扮粍杩樻槸Object瀵硅薄锛堝嵆瀛愬睘鎬ф槸瀵硅薄杩樻槸鏁扮粍锛�0涓簅bj瀵硅薄锛�1涓篴rray鏁扮粍锛�
+ if ("1".equals(fseAttrInfo.getString(CmnConst.SUBORDINATE_ELEMENT_TYPE))) {
+ JSONArray array = new JSONArray();
+ array.add(noSuperiorJsonAttr);
+ superiorObj.put(attribute_name, array);
+// superiorObj.put(attribute_name, Arrays.asList(noSuperiorJsonAttr));
+ } else {
+ superiorObj.put(attribute_name, noSuperiorJsonAttr);
+ }
+ // 鑾峰彇褰撳墠灞炴�х埗绾у睘鎬UID 鍜� NAME
+ superiorAttrUUID = fseAttrInfo.getString(CmnConst.PARENT_ATTRIBUTE_UUID);
+ String parentAttributeName = fseAttrInfo.getString(CmnConst.PARENT_ATTRIBUTE_NAME);
//濡傛灉鐖跺厓绱爑uid涓虹┖
- if(BaseUtil.strIsNull(superiorUuid)){
+ if(BaseUtil.strIsNull(superiorAttrUUID)){
JSONArray allSubProperties = allProperties.getJSONArray(attribute_name);
if(allSubProperties != null){
- JSONObject subObj = JSONObject.parseObject(obj.toJSONString());
+ JSONObject subObj = JSONObject.parseObject(noSuperiorJsonAttr.toJSONString());
if(allSubProperties.size() > 0){
//鏄墿鍏呭綋鍓嶅瓙鍏冪礌 杩樻槸鍚岀骇鏂板涓�涓瓙鍏冪礌
Boolean is_extend = true;
@@ -257,23 +263,21 @@
for (String key :subObj.keySet()) {
subPropertiesJSONObject.put(key, subObj.get(key));
}
- obj.clear();
+ noSuperiorJsonAttr.clear();
return;
}
}
allSubProperties.add(subObj);
- obj.clear();
+ noSuperiorJsonAttr.clear();
return;
}
- //鍏嬮殕json
- JSONObject copy;
Object o = superiorObj.get(attribute_name);
if(o instanceof JSONArray){
JSONArray oar = (JSONArray) o;
JSONArray arr = JSONObject.parseArray(oar.toJSONString());
allProperties.put(attribute_name,arr);
}else {
- copy = JSONObject.parseObject(superiorObj.toJSONString());
+ JSONObject copy = JSONObject.parseObject(superiorObj.toJSONString());
allProperties.put(attribute_name,copy.getJSONObject(attribute_name));
}
}else {
@@ -294,7 +298,7 @@
}
}
}
- this.getAllProperties(superiorUuid,newObj,allProperties);
+ this.getAllJSONAttrs(superiorAttrUUID, newObj, allProperties);
}else {
JSONObject currentProperty = null;
if(o instanceof JSONArray) {
@@ -320,7 +324,22 @@
if(theOriginalData == null){
currentProperty.put(attribute_name,arr);
}else {
- theOriginalData.add(arr.getJSONObject(arr.size()-1));
+ JSONObject lastJSONObject = theOriginalData.getJSONObject(theOriginalData.size() - 1);
+ JSONObject insertJsonObject = arr.getJSONObject(arr.size()-1);
+ for (String key : insertJsonObject.keySet()) {
+ if (lastJSONObject.containsKey(key)) {
+ // key宸插瓨鍦紝鏂板缓瀵硅薄
+ theOriginalData.add(insertJsonObject);
+ break;
+ } else {
+ // key涓嶅瓨鍦紝鍚堝苟
+ lastJSONObject.putAll(insertJsonObject);
+ break;
+ }
+ }
+// theOriginalData.getJSONObject(theOriginalData.size() - 1)
+// .putAll(JSONObject.parseObject(arr.getJSONObject(arr.size()-1).toJSONString()));
+// theOriginalData.add(arr.getJSONObject(arr.size()-1));
}
}else {
@@ -338,7 +357,7 @@
}
}
}
- obj.clear();
+ noSuperiorJsonAttr.clear();
}
/**
@@ -422,7 +441,7 @@
oArray[0] = subObj;
}
}else {
- oArray[0] = attr_value;
+ oArray[0] = SystemParamReplace.systemParamsReplace(attr_value);
}
return oArray;
}
@@ -527,8 +546,14 @@
*/
@Transactional
@Override
- public List<String> releaseConfig(FieldSetEntity fse, String module_uuid, String parentCode) {
+ public List<String> releaseConfig(FieldSetEntity fse, String parentModuleUUID) {
+ //鑾峰彇鎸囧畾鍙戝竷鐩綍淇℃伅
+ FieldSetEntity fseParentModuleData = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_FUNCTIONS, parentModuleUUID, false);
+ if (fseParentModuleData == null) {
+ throw new BaseException(SystemCode.PUBLISH_REPORT_FAIL_MODULE_NO_EXIST.getValue(), SystemCode.PUBLISH_REPORT_FAIL_MODULE_NO_EXIST.getText());
+ }
+
FieldSetEntity fseReport=baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_CONFIG, fse.getUUID(), false);
//鍒涘缓MVCC淇濆瓨瀵硅薄
@@ -536,11 +561,10 @@
fseFunction.setTableName(CmnConst.PRODUCT_SYS_FUNCTIONS);
//1.鍒涘缓MVC(绯荤粺MVC鐩綍涓�)
//鐢熸垚鍔熻兘缂栫爜
- codeService.createCode(fseFunction,CmnConst.PRODUCT_SYS_FUNCTIONS, CmnConst.TRICODE, parentCode);
+ codeService.createCode(fseFunction,CmnConst.PRODUCT_SYS_FUNCTIONS, CmnConst.TRICODE, fseParentModuleData.getString(CmnConst.TRICODE));
String function_tricode=fseFunction.getString(CmnConst.TRICODE);
fseFunction.setTableName(CmnConst.PRODUCT_SYS_FUNCTIONS);
fseFunction.setValue(CmnConst.TRICODE, function_tricode); //鍔熻兘缂栫爜
- fseFunction.setValue(CmnConst.MODULE_UUID, module_uuid); //鎵�灞炴ā鍧桿UID
fseFunction.setValue(CmnConst.TABLE_UUID, CmnConst.PRODUCT_SYS_REPORT_CONFIG); //鍔熻兘鍏宠仈琛�
fseFunction.setValue(CmnConst.FUNCTION_NAME, fseReport.getString(CmnConst.REPORT_NAME)); //鍔熻兘鍚嶇О
fseFunction.setValue(CmnConst.FUNCTION_DESCRIPTION, fseReport.getString(CmnConst.REPORT_NAME)); //鍔熻兘鎻忚堪
@@ -548,7 +572,7 @@
fseFunction.setValue(CmnConst.FUNCTION_TYPE_UUID, 1); //鍔熻兘绫诲瀷-涓氬姟鍔熻兘
fseFunction.setValue(CmnConst.CLIENT_TYPE_UUID, "web"); //瀹㈡埛绔被鍨�
fseFunction.setValue(CmnConst.VERSION_UUID, "001"); //鐗堟湰uuid
- fseFunction.setValue(CmnConst.TRICODE_PARENT, parentCode);
+ fseFunction.setValue(CmnConst.TRICODE_PARENT, fseParentModuleData.getString(CmnConst.TRICODE));
fseFunction.setValue("data_type", 1); //绫诲瀷 1涓哄姛鑳�
BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fseFunction);
--
Gitblit v1.9.2