diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..10b731c --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 359ab1e..f52b9a9 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -138,6 +138,12 @@ org.springframework.security spring-security-core + + cn.dev33 + sa-token-core + 1.39.0 + compile + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/ProcessOrderProController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/ProcessOrderProController.java index 8d9250e..822e101 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/ProcessOrderProController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/ProcessOrderProController.java @@ -1453,12 +1453,17 @@ public class ProcessOrderProController extends BaseController { } if (!kingdeeBomRows.isEmpty()) { List> bomDataList2 = convertKingdeeBomToMapList(kingdeeBomRows); - dynamicDataMappingList.addAll(DynamicDataMapping.createOneDataList("KingdeeBomData", bomDataList2)); + // 合并到 RouteBomData 中统一按物料分组导出(方案A) } // 添加伊特产品数据 if (!routeList.isEmpty()) { - List> evoRouteDataList = convertRouteDataToMapList(routeList); - dynamicDataMappingList.addAll(DynamicDataMapping.createOneDataList("ProcessRouteExcelDTO", evoRouteDataList)); + // 合并到 RouteBomData 中统一按物料分组导出(方案A) + } + + // 方案A:合并工艺与BOM为单一数据集并按物料分组 + if (!routeList.isEmpty() || !kingdeeBomRows.isEmpty()) { + List> routeBomDataList = convertRouteBomToMapList(routeList, kingdeeBomRows); + dynamicDataMappingList.addAll(DynamicDataMapping.createOneDataList("RouteBomData", routeBomDataList)); } // 使用模板导出Excel @@ -1493,6 +1498,105 @@ public class ProcessOrderProController extends BaseController { } } + /** + * 合并工艺路线与金蝶BOM行,按物料编码分组生成统一的 RouteBomData 列表 + * 每条记录包含两类:rowType=route(工艺行)或 rowType=bom(BOM行),以便模板在同一块中连续展示 + */ + private List> convertRouteBomToMapList(List routeDataList, + List> kingdeeBomRows) { + Map>> grouped = new LinkedHashMap<>(); + + // 先按工艺数据建立分组与顺序 + for (ProcessRoute item : routeDataList) { + String mcode = item.getMaterialCode(); + if (mcode == null) mcode = ""; + grouped.computeIfAbsent(mcode, k -> new ArrayList<>()); + + Map map = new HashMap<>(); + map.put("rowType", "route"); + map.put("routeDescription", item.getRouteDescription()); + map.put("materialCode", item.getMaterialCode()); + map.put("materialName", item.getMaterialName()); + map.put("material", item.getMaterial()); + map.put("discWeight", item.getDiscWeight()); + map.put("processNo", item.getProcessNo()); + map.put("workCenter", item.getWorkCenter()); + map.put("processName", item.getProcessName()); + map.put("processDescription", item.getProcessDescription()); + map.put("processControl", item.getProcessControl()); + map.put("activityDuration", item.getActivityDuration()); + map.put("activityUnit", item.getActivityUnit()); + map.put("unitQuantity", item.getUnitQuantity()); + map.put("batchQuantity", item.getBatchQuantity()); + map.put("firstBatchQuantity", item.getFirstBatchQuantity()); + map.put("planStartTime", formatDate(item.getPlanStartTime())); + map.put("planEndTime", formatDate(item.getPlanEndTime())); + map.put("xuStartTime", formatDate(item.getXuStartTime())); + map.put("xuEndTime", formatDate(item.getXuEndTime())); + + // BOM占位(当前行类型为工艺,BOM字段置空) + map.put("rawMaterialCode", ""); + map.put("rawMaterialName", ""); + map.put("bomMaterial", ""); + map.put("bomDanZhong", ""); + map.put("discUsage", ""); + map.put("bomUnit", ""); + + grouped.get(mcode).add(map); + } + + // 追加BOM数据到对应物料分组;若该物料此前未出现,则在最后新增一个分组 + for (Map row : kingdeeBomRows) { + String mcode = Objects.toString(row.get("materialCode"), ""); + grouped.computeIfAbsent(mcode, k -> new ArrayList<>()); + + Map map = new HashMap<>(); + map.put("rowType", "bom"); + map.put("routeDescription", row.get("routeDescription")); + map.put("materialCode", row.get("materialCode")); + map.put("materialName", row.get("materialName")); + map.put("material", row.get("material")); + map.put("discWeight", row.get("discWeight")); + + // 工艺占位(当前行类型为BOM,工艺字段置空) + map.put("processNo", ""); + map.put("workCenter", ""); + map.put("processName", ""); + map.put("processDescription", ""); + map.put("processControl", ""); + map.put("activityDuration", ""); + map.put("activityUnit", ""); + map.put("unitQuantity", ""); + map.put("batchQuantity", ""); + map.put("firstBatchQuantity", ""); + map.put("planStartTime", ""); + map.put("planEndTime", ""); + map.put("xuStartTime", ""); + map.put("xuEndTime", ""); + + // BOM具体字段 + map.put("rawMaterialCode", row.get("rawMaterialCode")); + map.put("rawMaterialName", row.get("rawMaterialName")); + map.put("bomMaterial", row.get("bomMaterial")); + map.put("bomDanZhong", row.get("bomDanZhong")); + map.put("discUsage", row.get("discUsage")); + map.put("bomUnit", row.get("bomUnit")); + + grouped.get(mcode).add(map); + } + + // 展平为顺序列表并补齐序号 + List> result = new ArrayList<>(); + int index = 1; + for (Map.Entry>> entry : grouped.entrySet()) { + for (Map m : entry.getValue()) { + m.put("index", index++); + result.add(m); + } + } + return result; + } + private List> convertKingdeeBomToMapList(List> kingdeeBomRows) { List> mapList = new ArrayList<>(); int index = 1; diff --git a/ruoyi-system/src/main/resources/jpg/生产及工艺计划模版.xlsx b/ruoyi-system/src/main/resources/jpg/生产及工艺计划模版.xlsx index caaf06d..7f72a34 100644 Binary files a/ruoyi-system/src/main/resources/jpg/生产及工艺计划模版.xlsx and b/ruoyi-system/src/main/resources/jpg/生产及工艺计划模版.xlsx differ