工艺模版,工艺生产bom的导出,更新

This commit is contained in:
tzy 2025-11-23 23:03:30 +08:00
parent 28dae80058
commit 50630eae22
4 changed files with 118 additions and 3 deletions

5
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/

View File

@ -138,6 +138,12 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-core</artifactId>
<version>1.39.0</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.ortools/ortools-java -->

View File

@ -1453,12 +1453,17 @@ public class ProcessOrderProController extends BaseController {
}
if (!kingdeeBomRows.isEmpty()) {
List<Map<String, Object>> bomDataList2 = convertKingdeeBomToMapList(kingdeeBomRows);
dynamicDataMappingList.addAll(DynamicDataMapping.createOneDataList("KingdeeBomData", bomDataList2));
// 合并到 RouteBomData 中统一按物料分组导出方案A
}
// 添加伊特产品数据
if (!routeList.isEmpty()) {
List<Map<String, Object>> evoRouteDataList = convertRouteDataToMapList(routeList);
dynamicDataMappingList.addAll(DynamicDataMapping.createOneDataList("ProcessRouteExcelDTO", evoRouteDataList));
// 合并到 RouteBomData 中统一按物料分组导出方案A
}
// 方案A合并工艺与BOM为单一数据集并按物料分组
if (!routeList.isEmpty() || !kingdeeBomRows.isEmpty()) {
List<Map<String, Object>> 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=bomBOM行以便模板在同一块中连续展示
*/
private List<Map<String, Object>> convertRouteBomToMapList(List<ProcessRoute> routeDataList,
List<Map<String, Object>> kingdeeBomRows) {
Map<String, List<Map<String, Object>>> grouped = new LinkedHashMap<>();
// 先按工艺数据建立分组与顺序
for (ProcessRoute item : routeDataList) {
String mcode = item.getMaterialCode();
if (mcode == null) mcode = "";
grouped.computeIfAbsent(mcode, k -> new ArrayList<>());
Map<String, Object> 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<String, Object> row : kingdeeBomRows) {
String mcode = Objects.toString(row.get("materialCode"), "");
grouped.computeIfAbsent(mcode, k -> new ArrayList<>());
Map<String, Object> 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<Map<String, Object>> result = new ArrayList<>();
int index = 1;
for (Map.Entry<String, List<Map<String, Object>>> entry : grouped.entrySet()) {
for (Map<String, Object> m : entry.getValue()) {
m.put("index", index++);
result.add(m);
}
}
return result;
}
private List<Map<String, Object>> convertKingdeeBomToMapList(List<Map<String, Object>> kingdeeBomRows) {
List<Map<String, Object>> mapList = new ArrayList<>();
int index = 1;