杜洪波
2025-09-17 6c0c3557e791dc46948190dd3745335ed043d051
src/main/java/com/product/server/report/service/GenerateEChartService.java
@@ -17,6 +17,7 @@
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;
@@ -104,21 +105,30 @@
//            object.put("function",this.functionArray(uuid));
            return object;
        }
        sql_text = "SELECT user_id,SUM(countNo) countNo, type \n" +
                "FROM ( \t\n" +
                "\tSELECT receiver user_id,COUNT(receiver) countNo,'待办' as type \n" +
                "\tFROM product_oa_cooperate_flow_node \n" +
                "\tWHERE  status IN (0,1) \n" +
                "\tGROUP BY receiver \t\n" +
                ") a \n" +
                "WHERE user_id=13563 \n" +
                "GROUP BY user_id,type";
        DataTableEntity valueData = baseDao.listTable(sql_text,new Object[]{});
        //获取报表配置属性表  加echarts配置属性
        //只能查询到关联属性值的属性表,如果父级属性下有多个相同子属性。通过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)});
        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.parent_attribute_uuid " ,new Object[]{fse.getString(CmnConst.UUID)});
        JSONObject allProperties = new JSONObject();
        if(attributeData.getRows() > 0){
            JSONObject propertyObject = new JSONObject();
            String parenUuid1 = attributeData.getString(0,"parentAttributeUuid");
            String parenUuid1 = attributeData.getString(0,"parent_attribute_uuid");
            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");
                String parenUuid2 = fieldSet.getString("parent_attribute_uuid");
                //上级name
                String parenName = fieldSet.getString("parentAttributeName");
                String parenName = fieldSet.getString("parent_attribute_name");
                //图表属性值
                String attr_value = fieldSet.getString("report_type_attr_value");
                //为空传默认值
@@ -156,9 +166,9 @@
                grouping1 = grouping2;
                //饼状图插入数据同属一个父元素  多个元素和对应的数据需全部找出来一起封装json
                if(!BaseUtil.strIsNull(fieldName)){
                    String parentAttributeName = fieldSet.getString("parentAttributeName");
                    String parentAttributeName = fieldSet.getString(CmnConst.PARENT_ATTRIBUTE_NAME);
                    //下级为对象还是数组
                    String type = fieldSet.getString("subordinateElementType");
                    String type = fieldSet.getString("subordinate_element_ype");
                    List<String> keys = ListUtils.newArrayList();
                    List<String> keys2 = ListUtils.newArrayList();
                    keys.add(fieldName);
@@ -166,7 +176,7 @@
                    //为最后一位
                    while (i < length-1) {
                        FieldSetEntity fieldSet2 = attributeData.getFieldSetEntity(i+1);
                        String parenUuid3 = fieldSet2.getString("parentAttributeUuid");
                        String parenUuid3 = fieldSet2.getString("parent_attribute_uuid");
                        String fieldName3 = fieldSet2.getString(CmnConst.FIELD_NAME);
                        if(parenUuid2.equals(parenUuid3) && !BaseUtil.strIsNull(fieldName3)){
                            keys.add(fieldName3);
@@ -219,7 +229,7 @@
        JSONArray objSubArray = obj.getJSONArray(attribute_name);
        //确定他的子属性时(1)array 还是(0)object
//        if(objSubArray == null){
            if ("1".equals(fieldSet.getString("subordinateElementType"))) {
            if ("1".equals(fieldSet.getString(CmnConst.SUBORDINATE_ELEMENT_TYPE))) {
                JSONArray array = new JSONArray();
                array.add(obj);
                superiorObj.put(attribute_name, array);
@@ -230,9 +240,9 @@
//            superiorObj = obj;
//        }
        //上级属性name
        superiorUuid = fieldSet.getString("parentAttributeUuid");
        superiorUuid = fieldSet.getString(CmnConst.PARENT_ATTRIBUTE_UUID);
        //上级名称
        String parentAttributeName = fieldSet.getString("parentAttributeName");
        String parentAttributeName = fieldSet.getString(CmnConst.PARENT_ATTRIBUTE_NAME);
        //如果父元素uuid为空
        if(BaseUtil.strIsNull(superiorUuid)){
            JSONArray allSubProperties = allProperties.getJSONArray(attribute_name);
@@ -527,7 +537,13 @@
     */
    @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);
@@ -536,11 +552,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);   //所属模块UUID
        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 +563,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);
@@ -674,12 +689,15 @@
        Integer pageSize = fieldSetEntity.getInteger(CmnConst.PAGE_SIZE);
        StringBuffer sql = new StringBuffer();
//        sql.append(" select * from ( ")
        sql.append(" select rc.uuid,rc.report_name,'图表' type_name,t1.role_info,mp.menu_name tricode_parent,m.menu_icon,m.menu_name,rc.function_uuid ")
        sql.append(" select rc.uuid,rc.report_name,'图表' type_name,mp.menu_name tricode_parent,m.menu_icon,m.menu_name,rc.function_uuid ")
//        sql.append(" select rc.uuid,rc.report_name,'图表' type_name,t1.role_info,mp.menu_name tricode_parent,m.menu_icon,m.menu_name,rc.function_uuid ")
                .append(" FROM product_sys_report_config rc ")
                .append(" inner join ( ")
                .append(" select function_uuid,group_concat(role_info separator ',') role_info ")
                .append(" select function_uuid ")
//                .append(" select function_uuid,group_concat(role_info separator ',') role_info ")   //Duird解析不了这个函数用法
                .append(" from ( ")
                .append(" select function_uuid,concat(c.client_name,'/',o.org_level_name,'/',role_name) role_info ")
//                .append(" select function_uuid,concat(c.client_name,'/',o.org_level_name,'/',role_name) role_info ")
                .append(" select function_uuid ")
                .append(" FROM product_sys_clients c ")
                .append(" inner join product_sys_org_levels o on o.client_uuid=c.uuid ")
                .append(" inner join ( ")