354798ggg
2023-07-05 86f70601d3b710f115ac3ded77eec4efee1bd941
product-server-project-management/src/main/java/com/product/project/management/service/ProjectInfoService.java
@@ -6,6 +6,7 @@
import java.util.Map;
import com.alibaba.fastjson.JSONArray;
import com.product.core.websocket.config.CmnConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -93,12 +94,13 @@
        //获取数据库原始数据
        StringBuilder sb = new StringBuilder();
        sb.append("WITH outbound AS(")
                .append(" SELECT A.project_uuid,A.project_itemize,C.material_type,B.material_code,SUM(B.outbound_weight)outbound_weight ")
                .append(" SELECT A.project_uuid,D.itemize project_itemize,C.material_type,B.material_code,SUM(B.outbound_weight)outbound_weight ")
                .append(" FROM product_project_outbound A ")
                .append(" LEFT JOIN product_project_outbound_sub B ON A.uuid=B.outbound_uuid ")
                .append(" LEFT JOIN product_project_base_material C ON B.material_uuid = C.uuid ")
                .append(" WHERE project_uuid = ? ")
                .append(" GROUP BY A.project_uuid,A.project_itemize,C.material_type,B.material_code ")
                .append(" LEFT JOIN product_project_item D ON A.project_itemize = D.uuid ")
                .append(" WHERE A.flow_flag=2 AND A.project_uuid = ? ")
                .append(" GROUP BY A.project_uuid,D.itemize,C.material_type,B.material_code ")
                .append(" ) ")
                .append(" SELECT A.project_uuid,A.project_itemize,A.total_outbound_weight,B.material_type,B.material_code,B.outbound_weight ")
                .append(" FROM ( ")
@@ -106,7 +108,8 @@
                .append(" FROM outbound ")
                .append(" GROUP BY project_uuid,project_itemize ")
                .append(" )A ")
                .append(" RIGHT JOIN outbound B ON A.project_uuid=B.project_uuid AND A.project_itemize=B.project_itemize ");
                .append(" RIGHT JOIN outbound B ON A.project_uuid=B.project_uuid AND A.project_itemize=B.project_itemize ")
              .append(" ORDER BY project_itemize,material_code");
        DataTableEntity dtItemizeInfo = baseDao.listTable(sb.toString(), new Object[]{project_uuid});
        if (!BaseUtil.dataTableIsEmpty(dtItemizeInfo)) {
@@ -126,7 +129,9 @@
                if (BaseUtil.strIsNull(materialTypes[materialType])) {
                    materialTypes[materialType] = materialCode;
                } else {
                    materialTypes[fseItemize.getInteger(Cmnconst.MATERIAL_TYPE)] += "," + materialCode;
                   if(materialTypes[fseItemize.getInteger(Cmnconst.MATERIAL_TYPE)].indexOf(materialCode)<0) {
                      materialTypes[fseItemize.getInteger(Cmnconst.MATERIAL_TYPE)] += "," + materialCode;
                   }
                }
                //收集行转列数据
@@ -198,18 +203,33 @@
        return dtItemizeBudget;
    }
    /**
     * 更具项目分项uuid获取项目分项下的材料
     * @param uuid
     * @param capge
     * @param pageSize
     * @return
     */
    public DataTableEntity listMaterialV(String uuid, Integer capge, Integer pageSize) {
        return baseDao.listTable("product_project_base_material_v","project_itemize_uuid=?",new String[]{uuid},null,null,pageSize, capge);
    }
    /**
     * 根据项目uuid获取项目分项树结构
     * @param uuid
     * @return
     */
    public JSONArray getTreeProjectItem(String uuid) {
        FieldSetEntity fseProject = baseDao.getFieldSetEntity(Cmnconst.PRODUCT_PROJECT_QXLW, uuid, true);
        DataTableEntity newDtProjectItem = BaseUtil.dataTableToTreeTable(fseProject.getSubDataTable(Cmnconst.PRODUCT_PROJECT_ITEM), Cmnconst.ITEMIZE_CODE, Cmnconst.ITEMIZE_PARENT_CODE, null);
        DataTableEntity dtProjectItemize = baseDao.listTable(Cmnconst.PRODUCT_PROJECT_ITEM, "project_uuid=?", new Object[]{uuid}, new Object[]{CoreConst.UUID, Cmnconst.ITEMIZE, Cmnconst.ITEMIZE_CODE, Cmnconst.ITEMIZE_PARENT_CODE});
        DataTableEntity newDtProjectItem = BaseUtil.dataTableToTreeTable(dtProjectItemize, Cmnconst.ITEMIZE_CODE, Cmnconst.ITEMIZE_PARENT_CODE, null);
        JSONArray objects = BaseUtil.dataTableEntityToJson(newDtProjectItem);
        JSONObject json = new JSONObject();
        json.put("itemize", "项目分部分项");
        json.put("children", objects);
        json.put("type", 1);
        json.set("itemize", "项目分部分项");
        json.set("children", objects);
        json.set("type", 1);
        JSONArray array = new JSONArray();
        array.add(json);
        return array;
    }
}