| | |
| | | return baseDao.listTable(Cmnconst.PRODUCT_PROJECT_QXLW, null, null, new Object[]{CoreConst.UUID, Cmnconst.PROJECT_NAME}); |
| | | } |
| | | |
| | | /** |
| | | * 项目数据分析 |
| | | * |
| | | * @param project_uuid |
| | | * @return |
| | | */ |
| | | public JSONObject statistAnalysis(String project_uuid) { |
| | | |
| | | JSONObject returnJson = new JSONObject(); |
| | | |
| | | //获取数据库原始数据 |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("WITH outbound AS(") |
| | | .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(" 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 ( ") |
| | | .append(" SELECT project_uuid,project_itemize,SUM(outbound_weight)total_outbound_weight ") |
| | | .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(" ORDER BY project_itemize,material_code"); |
| | | DataTableEntity dtItemizeInfo = baseDao.listTable(sb.toString(), new Object[]{project_uuid}); |
| | | if (!BaseUtil.dataTableIsEmpty(dtItemizeInfo)) { |
| | | |
| | | Map<String, FieldSetEntity> convertData = new HashMap<>(); |
| | | String[] materialTypes = new String[3]; |
| | | |
| | | //通过Java循环将"材料"和"出库量"数据行转列 |
| | | for (int i = 0; i < dtItemizeInfo.getRows(); i++) { |
| | | FieldSetEntity fseItemize = dtItemizeInfo.getFieldSetEntity(i); |
| | | |
| | | //获取材料编码,材料类型,出库量 |
| | | String materialCode = fseItemize.getString(Cmnconst.MATERIAL_CODE); |
| | | String outboundWeight = fseItemize.getString(Cmnconst.OUTBOUND_WEIGHT); |
| | | Integer materialType = fseItemize.getInteger(Cmnconst.MATERIAL_TYPE); |
| | | |
| | | //收集获取所有表头列(材料编码) |
| | | if (BaseUtil.strIsNull(materialTypes[materialType])) { |
| | | materialTypes[materialType] = materialCode; |
| | | } else { |
| | | if(materialTypes[fseItemize.getInteger(Cmnconst.MATERIAL_TYPE)].indexOf(materialCode)<0) { |
| | | materialTypes[fseItemize.getInteger(Cmnconst.MATERIAL_TYPE)] += "," + materialCode; |
| | | } |
| | | } |
| | | |
| | | //收集行转列数据 |
| | | String itemize = fseItemize.getString(Cmnconst.PROJECT_ITEMIZE); |
| | | if (convertData.containsKey(itemize)) { |
| | | convertData.get(itemize).setValue(materialCode, outboundWeight); |
| | | } else { |
| | | FieldSetEntity fseConvertData = new FieldSetEntity(Cmnconst.PRODUCT_PROJECT_QXLW); |
| | | fseConvertData.setValue(Cmnconst.PROJECT_ITEMIZE, itemize); |
| | | fseConvertData.setValue(Cmnconst.TOTAL_OUTBOUND_WEIGHT, fseItemize.getString(Cmnconst.TOTAL_OUTBOUND_WEIGHT)); |
| | | fseConvertData.setValue(materialCode, outboundWeight); |
| | | convertData.put(itemize, fseConvertData); |
| | | } |
| | | } |
| | | //将数据转为DataTableEntity返回 |
| | | if (!convertData.isEmpty()) { |
| | | DataTableEntity finalConvertData = new DataTableEntity(); |
| | | convertData.forEach((k, v) -> { |
| | | finalConvertData.addFieldSetEntity(v); |
| | | }); |
| | | returnJson.set("data", BaseUtil.dataTableEntityToJson(finalConvertData)); |
| | | } |
| | | for (int i = 0; i < materialTypes.length; i++) { |
| | | if (!BaseUtil.strIsNull(materialTypes[i])) { |
| | | returnJson.set("type" + i, materialTypes[i]); |
| | | } |
| | | } |
| | | } |
| | | return returnJson; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除子项验证(已经生成预算的子项不能删除) |
| | |
| | | public void deleteItemizeValidate(String uuid) { |
| | | DataTableEntity dtBudget = baseDao.listTable(Cmnconst.PRODUCT_PROJECT_BUDGET, "budget_code=?", new Object[]{uuid}); |
| | | if (!BaseUtil.dataTableIsEmpty(dtBudget)) { |
| | | throw new BaseException(SystemCode.PROJECT_MANAGEMENT_ITEMIZE_DEL_FAIL.getValue(), SystemCode.PROJECT_MANAGEMENT_ITEMIZE_DEL_FAIL.getText()); |
| | | throw new BaseException(SystemCode.PROJECT_ITEMIZE_DEL_FAIL_HAS_BUDGET.getValue(), SystemCode.PROJECT_ITEMIZE_DEL_FAIL_HAS_BUDGET.getText()); |
| | | } |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | public DataTableEntity listItemizeBudget(String projectUUID, String itemizeCode, Integer capge, Integer pageSize) { |
| | | |
| | | |
| | | String filter; |
| | | List<String> params = new ArrayList<>(); |
| | |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * 更具仓库和材料获取库存 |
| | | * @return |
| | |
| | | public FieldSetEntity findInventoryV(String warehouse_uuid, String material_uuid) { |
| | | return baseDao.getFieldSetByFilter("product_project_inventory_v","warehouse_uuid=? and uuid=?",new String[]{warehouse_uuid,material_uuid},false); |
| | | } |
| | | |
| | | /** |
| | | * 根据项目uuid获取项目分项树结构 |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | |
| | | public JSONArray getTreeProjectItem(String uuid) { |
| | | 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); |