更新完善多个接口太多了
This commit is contained in:
parent
6ff8b06703
commit
df99d4cb3a
@ -257,9 +257,16 @@ public class BomDetailsController extends BaseController {
|
||||
|
||||
String state = determineState(material);
|
||||
log.info("开始新增不存在的物料==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
log.info("开始新增不存在的物料==> 材质: " + material.getMaterial() + " 物料名称: " + material.getName());
|
||||
System.out.println("state:=======================>" + state);
|
||||
int result = loadMaterialPreservation(material, state);
|
||||
//判断是否是电器物料
|
||||
int result;
|
||||
if (material.getTotalWeight().contains("DQ")){
|
||||
log.info("开始新增不存在的电气物料==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
result = loadMaterialToDQ(material, state);
|
||||
}else{
|
||||
log.info("开始新增不存在的物料==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
result = loadMaterialPreservation(material, state);
|
||||
}
|
||||
if (result == 1) {
|
||||
log.info("新增物料成功==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
material.setUnitWeight("新增成功");
|
||||
@ -562,10 +569,8 @@ public class BomDetailsController extends BaseController {
|
||||
// 添加供应类型
|
||||
if (details.getRemarks().equals("采购")) {
|
||||
fTreeEntityItem.addProperty("FSupplyType", "C");
|
||||
} else if (details.getRemarks().equals("自制")) {
|
||||
fTreeEntityItem.addProperty("FSupplyType", "Z");
|
||||
} else if (details.getRemarks().equals("委外")) {
|
||||
fTreeEntityItem.addProperty("FSupplyType", "W");
|
||||
} else{
|
||||
fTreeEntityItem.addProperty("FSupplyType", " ");
|
||||
}
|
||||
}
|
||||
fTreeEntityItem.addProperty("FMATERIALTYPE", "1");
|
||||
@ -1198,7 +1203,7 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
public int loadMaterialPreservation1(BomDetails bomDetails1, String states) {
|
||||
public int loadMaterialPreservation(BomDetails bomDetails1, String states) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
// 创建一个空的JsonObject
|
||||
JsonObject json = new JsonObject();
|
||||
@ -1392,7 +1397,7 @@ public class BomDetailsController extends BaseController {
|
||||
return 1;
|
||||
}
|
||||
//创建电气物料
|
||||
public int loadMaterialPreservation(BomDetails bomDetails1, String states) {
|
||||
public int loadMaterialToDQ(BomDetails bomDetails1, String states) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
// 创建一个空的JsonObject
|
||||
JsonObject json = new JsonObject();
|
||||
@ -1484,6 +1489,9 @@ public class BomDetailsController extends BaseController {
|
||||
case "条":
|
||||
fBaseUnitId.addProperty("FNumber", "017");
|
||||
break;
|
||||
case "套":
|
||||
fBaseUnitId.addProperty("FNumber", "007");
|
||||
break;
|
||||
}
|
||||
subHeadEntity.add("FBaseUnitId", fBaseUnitId);
|
||||
if (states.equals("1")){
|
||||
@ -1536,6 +1544,9 @@ public class BomDetailsController extends BaseController {
|
||||
case "条":
|
||||
fBaseUnitId.addProperty("FNumber", "017");
|
||||
break;
|
||||
case "套":
|
||||
fBaseUnitId.addProperty("FNumber", "007");
|
||||
break;
|
||||
}
|
||||
subHeadEntity1.add("FStoreUnitID", fStoreUnitId);
|
||||
subHeadEntity1.addProperty("FUnitConvertDir", "1");
|
||||
@ -1590,6 +1601,9 @@ public class BomDetailsController extends BaseController {
|
||||
case "条":
|
||||
fBaseUnitId.addProperty("FNumber", "017");
|
||||
break;
|
||||
case "套":
|
||||
fBaseUnitId.addProperty("FNumber", "007");
|
||||
break;
|
||||
}
|
||||
subHeadEntity1.add("FPurchaseUnitId", fPurchaseUnitId);
|
||||
|
||||
@ -1632,6 +1646,9 @@ public class BomDetailsController extends BaseController {
|
||||
case "条":
|
||||
fBaseUnitId.addProperty("FNumber", "017");
|
||||
break;
|
||||
case "套":
|
||||
fBaseUnitId.addProperty("FNumber", "007");
|
||||
break;
|
||||
}
|
||||
subHeadEntity3.add("FPurchasePriceUnitId", fPurchasePriceUnitId);
|
||||
|
||||
@ -1700,6 +1717,9 @@ public class BomDetailsController extends BaseController {
|
||||
case "条":
|
||||
fBaseUnitId.addProperty("FNumber", "017");
|
||||
break;
|
||||
case "套":
|
||||
fBaseUnitId.addProperty("FNumber", "007");
|
||||
break;
|
||||
}
|
||||
subHeadEntity5.add("FProduceUnitId", fProduceUnitId);
|
||||
|
||||
@ -1743,6 +1763,9 @@ public class BomDetailsController extends BaseController {
|
||||
case "条":
|
||||
fBaseUnitId.addProperty("FNumber", "017");
|
||||
break;
|
||||
case "套":
|
||||
fBaseUnitId.addProperty("FNumber", "007");
|
||||
break;
|
||||
}
|
||||
subHeadEntity5.add("FBOMUnitId", fBOMUnitId);
|
||||
if (states.equals("1")){
|
||||
|
||||
@ -324,7 +324,7 @@ public class ProcessRouteController extends BaseController {
|
||||
* 保存工艺路线
|
||||
*/
|
||||
@SaCheckPermission("system:route:add")
|
||||
@Log(title = "工艺路线", businessType = BusinessType.INSERT)
|
||||
@Log(title = "保存工艺路线", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/addRoute")
|
||||
public R<Void> addRoute( @RequestBody List<ProcessRoute> list) {
|
||||
@ -332,7 +332,7 @@ public class ProcessRouteController extends BaseController {
|
||||
}
|
||||
|
||||
@SaCheckPermission("system:route:add")
|
||||
@Log(title = "工艺路线", businessType = BusinessType.INSERT)
|
||||
@Log(title = "删除工艺路线", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/deleteRoute")
|
||||
public List<ProcessRoute> deleteRoute( @RequestBody ProcessRoute processRoute) {
|
||||
|
||||
@ -1,16 +1,23 @@
|
||||
package com.ruoyi.system.runner;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
||||
import com.ruoyi.system.domain.dto.PlanPrcessNumDTO;
|
||||
import com.ruoyi.system.domain.vo.ImMaterialVo;
|
||||
import com.ruoyi.system.domain.vo.PlanOrderVo;
|
||||
import com.ruoyi.system.jdmain.rouplan.Model;
|
||||
import com.ruoyi.system.mapper.ImProductionPlanProMapper;
|
||||
import com.ruoyi.system.service.IImProductionPlanProService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -114,7 +121,6 @@ public class JdUtil {
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
查询库存
|
||||
*/
|
||||
@ -179,8 +185,6 @@ public class JdUtil {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static JsonArray selectKuCun1(List<ImMaterialVo> list) {
|
||||
if(list == null || list.isEmpty()) {
|
||||
return new JsonArray();
|
||||
@ -271,4 +275,161 @@ public class JdUtil {
|
||||
}
|
||||
return fBaseQty;
|
||||
}
|
||||
|
||||
|
||||
public static List<Model> getSelecPlan(String rooteProdet) {
|
||||
List<PlanOrderVo> planOrderList = getSelectProceOrder(rooteProdet);
|
||||
List<PlanPrcessNumDTO> plannedProcesses = new ArrayList<>();
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
for (PlanOrderVo planOrder : planOrderList) {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("FormId", "SFC_OperationPlanning");
|
||||
json.addProperty("FieldKeys", "FID,FSubEntity_FDetailID,FProductId.FNumber,FOperNumber,FEntity_FEntryID,FProcessId.FName,FSeqNumber,FSeqName,FPlanStartTime,FPlanFinishTime," +
|
||||
"FOperPlanStartTime,FOperPlanFinishTime");
|
||||
json.addProperty("FieldKeys", "F_HBYT_SCLH,FProductId.FNumber,FProductName,FMOQty , FOperNumber,FWorkCenterId.FName ,FProcessId.FName,FOperDescription,FOptCtrlCodeId.FName,FOperQty ,FOperPlanStartTime ,FOperPlanFinishTime,FPlanStartTime,FPlanFinishTime");
|
||||
JsonArray filterString = new JsonArray();
|
||||
JsonObject filterObject = new JsonObject();
|
||||
filterObject.addProperty("FieldName", "FMONumber");
|
||||
filterObject.addProperty("Compare", "="); // 改为等号运算符
|
||||
filterObject.addProperty("Value", planOrder.getFBillNo());
|
||||
filterObject.addProperty("Left", "");
|
||||
filterObject.addProperty("Right", "");
|
||||
filterObject.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
|
||||
filterString.add(filterObject);
|
||||
|
||||
json.add("FilterString", filterString);
|
||||
json.addProperty("OrderString", "");
|
||||
json.addProperty("TopRowCount", 0);
|
||||
json.addProperty("StartRow", 0);
|
||||
json.addProperty("Limit", 2000);
|
||||
json.addProperty("SubSystemId", "");
|
||||
|
||||
String jsonData = json.toString();
|
||||
try {
|
||||
String resultJson = String.valueOf(client.billQuery(jsonData));
|
||||
System.out.println(
|
||||
"生成查询计划订单查询 " + planOrder.getFBillNo() + " 的结果: " + resultJson
|
||||
);
|
||||
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
|
||||
if (jsonArray == null || jsonArray.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
List<PlanPrcessNumDTO> plannedProcessList = objectMapper.readValue(jsonArray.toString(), new TypeReference<List<PlanPrcessNumDTO>>() {
|
||||
});
|
||||
if (plannedProcessList != null && !plannedProcessList.isEmpty()) {
|
||||
plannedProcesses.addAll(plannedProcessList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
// 转换为 List<Model> 格式
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<PlanOrderVo> getSelectProceOrder(String rooteProdet) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
//请求参数,要求为json字符串
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("FormId", "PRD_MO");
|
||||
json.addProperty("FieldKeys", "F_HBYT_SCLH,FBillNo ,FMaterialId.FNumber,FMaterialName");
|
||||
JsonArray filterString = new JsonArray();
|
||||
JsonObject filterObject = new JsonObject();
|
||||
filterObject.addProperty("FieldName", "F_HBYT_SCLH");
|
||||
filterObject.addProperty("Compare", "67");
|
||||
filterObject.addProperty("Value", rooteProdet);
|
||||
filterObject.addProperty("Left", "");
|
||||
filterObject.addProperty("Right", "");
|
||||
filterObject.addProperty("Logic", 0);
|
||||
filterString.add(filterObject);
|
||||
json.add("FilterString", filterString);
|
||||
json.addProperty("OrderString", "");
|
||||
json.addProperty("TopRowCount", 0);
|
||||
json.addProperty("StartRow", 0);
|
||||
json.addProperty("Limit", 2000);
|
||||
json.addProperty("SubSystemId", "");
|
||||
|
||||
String jsonData = json.toString();
|
||||
String resultJson;
|
||||
try {
|
||||
// 调用API接口
|
||||
resultJson = String.valueOf(client.billQuery(jsonData));
|
||||
// 使用Gson解析为JsonArray,因为返回数据是直接的数组
|
||||
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
|
||||
// 将JsonArray转为PlanOrder列表
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
List<PlanOrderVo> planOrders = objectMapper.readValue(jsonArray.toString(), new TypeReference<List<PlanOrderVo>>() {
|
||||
});
|
||||
// 输出或返回结果
|
||||
System.out.println(planOrders);
|
||||
return planOrders;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
{
|
||||
"FMATERIALID.FNumber": "001HD24.01.01.017.0",
|
||||
"FITEMNAME": "行走原点标定",
|
||||
"FMATERIALIDCHILD.FNumber": "001HD24.01.01.016.2",
|
||||
"FCHILDITEMNAME": "不锈钢标尺",
|
||||
"FNUMERATOR": 1,
|
||||
"FDENOMINATOR": 1,
|
||||
"FChildBaseUnitID.FNumber": "jian"
|
||||
},
|
||||
*/
|
||||
public static List<Model> get物料清单(String materialCode) {
|
||||
List<PlanOrderVo> planOrderList = getSelectProceOrder(materialCode);
|
||||
List<PlanPrcessNumDTO> plannedProcesses = new ArrayList<>();
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
for (PlanOrderVo planOrder : planOrderList) {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("FormId", "ENG_BOM");
|
||||
json.addProperty("FieldKeys", "FMATERIALID.FNumber,FITEMNAME ,FMATERIALIDCHILD.FNumber ,FCHILDITEMNAME ,FNUMERATOR ,FDENOMINATOR,FChildBaseUnitID.FNumbe ");
|
||||
JsonArray filterString = new JsonArray();
|
||||
JsonObject filterObject = new JsonObject();
|
||||
filterObject.addProperty("FieldName", "FMATERIALID.FNumber");
|
||||
filterObject.addProperty("Compare", "="); // 改为等号运算符
|
||||
filterObject.addProperty("Value", planOrder.getFBillNo());
|
||||
filterObject.addProperty("Left", "");
|
||||
filterObject.addProperty("Right", "");
|
||||
filterObject.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
|
||||
filterString.add(filterObject);
|
||||
|
||||
json.add("FilterString", filterString);
|
||||
json.addProperty("OrderString", "");
|
||||
json.addProperty("TopRowCount", 0);
|
||||
json.addProperty("StartRow", 0);
|
||||
json.addProperty("Limit", 2000);
|
||||
json.addProperty("SubSystemId", "");
|
||||
|
||||
String jsonData = json.toString();
|
||||
try {
|
||||
String resultJson = String.valueOf(client.billQuery(jsonData));
|
||||
System.out.println(
|
||||
"生成查询计划订单查询 " + planOrder.getFBillNo() + " 的结果: " + resultJson
|
||||
);
|
||||
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
|
||||
if (jsonArray == null || jsonArray.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
List<PlanPrcessNumDTO> plannedProcessList = objectMapper.readValue(jsonArray.toString(), new TypeReference<List<PlanPrcessNumDTO>>() {
|
||||
});
|
||||
if (plannedProcessList != null && !plannedProcessList.isEmpty()) {
|
||||
plannedProcesses.addAll(plannedProcessList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
// 转换为 List<Model> 格式
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,115 +29,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class PDFGenerator {
|
||||
/* public static void main(String[] args) {
|
||||
// PDF 保存路径
|
||||
String pdfPath = "C:\\Users\\Administrator\\Desktop\\生成代码\\production_plan_v5.pdf";
|
||||
// 字体路径
|
||||
String fontPath = "C:/Windows/Fonts/simhei.ttf"; // Windows上宋体路径,macOS/Linux请自行调整
|
||||
// 生产订单编号(二维码内容)
|
||||
String productionOrderNumber = "MO004034";
|
||||
|
||||
try {
|
||||
// 创建新的PDF文档
|
||||
PDDocument document = new PDDocument();
|
||||
|
||||
// 添加一页
|
||||
PDPage page = new PDPage();
|
||||
document.addPage(page);
|
||||
|
||||
// 加载中文字体
|
||||
PDType0Font font = PDType0Font.load(document, new File(fontPath));
|
||||
|
||||
// 开始编写内容
|
||||
PDPageContentStream contentStream = new PDPageContentStream(document, page);
|
||||
|
||||
// 添加标题
|
||||
contentStream.beginText();
|
||||
contentStream.setFont(font, 14); // 调整标题字体
|
||||
contentStream.newLineAtOffset(220, 780); // 设置文本的开始位置
|
||||
contentStream.showText("工序计划单");
|
||||
contentStream.endText();
|
||||
|
||||
// 添加表格部分
|
||||
contentStream.setFont(font, 10); // 表格字体调整为10
|
||||
float margin = 15;
|
||||
float yStart = 740;
|
||||
float rowHeight = 20f; // 行高
|
||||
float tableWidth = page.getMediaBox().getWidth() - 2 * margin;
|
||||
float[] colWidths = {100, 80, 80, 80, 40, 60, 40, 80}; // 列宽
|
||||
|
||||
// 绘制工序计划表头
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, colWidths, new String[] {
|
||||
"生产令号", "", "子生产令号", "",
|
||||
});
|
||||
drawTableRow(contentStream, font, margin, yStart - rowHeight, tableWidth, colWidths, new String[] {
|
||||
"单据编号", "生产订单编号", "产品名称", "产品编码", "数量", "生产车间", "次数", ""
|
||||
});
|
||||
|
||||
// 添加表格内容
|
||||
drawTableRow(contentStream, font, margin, yStart - 2 * rowHeight, tableWidth, colWidths, new String[] {
|
||||
"XM-WT-024-0226", productionOrderNumber, "行程检测装置", "ELS11-4-WH", "4", "机加车间", "1", ""
|
||||
});
|
||||
|
||||
// 绘制备注信息
|
||||
contentStream.beginText();
|
||||
contentStream.setFont(font, 10);
|
||||
contentStream.newLineAtOffset(margin, yStart - 4 * rowHeight - 10);
|
||||
contentStream.showText("备注:");
|
||||
contentStream.endText();
|
||||
|
||||
// 执行工序表格部分标题,调整间距
|
||||
contentStream.beginText();
|
||||
contentStream.setFont(font, 12);
|
||||
contentStream.newLineAtOffset(margin, yStart - 5 * rowHeight - 10); // 调小间距
|
||||
contentStream.showText("执行工序如下:");
|
||||
contentStream.endText();
|
||||
// 执行工序表头
|
||||
float[] processColWidths = {35, 60, 35, 55, 55, 150, 60, 70, 70}; // 工序表宽度
|
||||
drawTableRow(contentStream, font, margin, yStart - 5.5f * rowHeight - 10, tableWidth, processColWidths, new String[] {
|
||||
"工序号", "工序名称", "数量", "工作中心", "工时(分)", "工序说明", "工序控制码", "计划开始时间", "计划结束时间"
|
||||
});
|
||||
|
||||
// 循环生成10个工序计划行
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// 每行的Y坐标是递减的
|
||||
float currentY = yStart - (5.5F + i) * rowHeight - 30;
|
||||
|
||||
drawTableRow(contentStream, font, margin, currentY, tableWidth, processColWidths, new String[] {
|
||||
String.valueOf(10 + i * 10), // 工序号动态增加
|
||||
"锯床下料", "4", "铆焊工段", "60", "下料长119,外圆见光允许黑皮", "", "2024-10-23", "2024-10-23"
|
||||
});
|
||||
}
|
||||
// 计算工序表格结束后的Y坐标,留出额外的40单位的间距
|
||||
float materialListStartY = yStart - (7 + 10) * rowHeight - 50; // 10行工序之后加40的间距
|
||||
|
||||
|
||||
contentStream.beginText();
|
||||
contentStream.setFont(font, 12); // 标题字体大小
|
||||
contentStream.newLineAtOffset(margin, materialListStartY); // 设置标题的位置
|
||||
contentStream.showText("生产用料清单");
|
||||
contentStream.endText();
|
||||
// 绘制生产用料清单表头
|
||||
// 用料清单表头
|
||||
float[] materialColWidths = {30, 60, 80, 50, 30, 60, 50, 50, 60, 60, 60};
|
||||
drawTableRow(contentStream, font, margin, materialListStartY - rowHeight, tableWidth, materialColWidths, new String[] {
|
||||
"序号", "物料编码", "物料名称", "规格型号", "单位", "子项类型", "应发数量", "已领数量", "需求日期", "仓库", "备注"
|
||||
});
|
||||
|
||||
// 在右上角生成二维码(基于生产订单编号)
|
||||
PDImageXObject qrCodeImage = generateQRCode(document, productionOrderNumber, 90, 90); // 缩小二维码
|
||||
contentStream.drawImage(qrCodeImage, 470, 720); // 设置二维码的绘制位置
|
||||
|
||||
// 保存并关闭文档
|
||||
contentStream.close();
|
||||
document.save(pdfPath);
|
||||
document.close();
|
||||
|
||||
System.out.println("PDF 生成成功!");
|
||||
} catch (IOException | WriterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
// 日期格式化器
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
||||
static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
@ -152,12 +44,14 @@ public class PDFGenerator {
|
||||
int maxColumns = Math.min(cells.length, colWidths.length);
|
||||
|
||||
// 检查是否需要分页
|
||||
if (nextY - rowHeight < margin) { // 如果空间不够绘制下一行
|
||||
contentStream.close(); // 关闭当前内容流
|
||||
page = new PDPage(); // 创建新页面
|
||||
if (nextY - rowHeight < margin) {
|
||||
contentStream.close();
|
||||
// 创建新页面
|
||||
page = new PDPage();
|
||||
document.addPage(page);
|
||||
contentStream = new PDPageContentStream(document, page);
|
||||
nextY = pageHeight - margin; // 重置Y坐标为新页面顶部
|
||||
// 重置Y坐标为新页面顶部
|
||||
nextY = pageHeight - margin;
|
||||
}
|
||||
|
||||
for (int i = 0; i < maxColumns; i++) {
|
||||
@ -165,7 +59,8 @@ public class PDFGenerator {
|
||||
contentStream.beginText();
|
||||
contentStream.setFont(font, 10);
|
||||
contentStream.newLineAtOffset(nextX + 5, nextY - 15);
|
||||
String cellText = cells[i] != null ? cells[i].replace("\n", "") : ""; // 去除换行符
|
||||
// 去除换行符
|
||||
String cellText = cells[i] != null ? cells[i].replace("\n", "") : "";
|
||||
contentStream.showText(cellText);
|
||||
contentStream.endText();
|
||||
|
||||
@ -201,8 +96,10 @@ public class PDFGenerator {
|
||||
String directoryPath = "C:\\Users\\Administrator\\Desktop\\上传BOM\\" + rooteProdet;
|
||||
|
||||
for (CombinedDTO combinedVo : combinedVoList) {
|
||||
String materialCode1 = combinedVo.getMaterialCode(); // 获取物料编码
|
||||
String fProcessName = combinedVo.getProcesses().get(0).getFProcessName(); // 获取第一序的工序名称
|
||||
// 获取物料编码
|
||||
String materialCode1 = combinedVo.getMaterialCode();
|
||||
// 获取第一序的工序名称
|
||||
String fProcessName = combinedVo.getProcesses().get(0).getFProcessName();
|
||||
String productionOrderNumber = String.valueOf(combinedVo.getProcesses().get(0).getFBillNo());
|
||||
Date starttime = combinedVo.getProcesses().get(0).getFPlanStartTime();
|
||||
Date endtime = combinedVo.getProcesses().get(0).getFPlanFinishTime();
|
||||
@ -426,7 +323,7 @@ public class PDFGenerator {
|
||||
System.out.println("目标文件已存在,已删除旧文件: " + targetFile.getAbsolutePath());
|
||||
} else {
|
||||
System.err.println("无法删除已存在的目标文件: " + targetFile.getAbsolutePath());
|
||||
return; // 如果文件删除失败,则返回
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -75,8 +75,6 @@ public interface IProcessRouteService {
|
||||
|
||||
/**
|
||||
* 生成这个项目的pdf
|
||||
* @param rooteProdet
|
||||
* @return
|
||||
*/
|
||||
List<CombinedDTO> generatePDFs(String rooteProdet);
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ruoyi.common.core.domain.R.fail;
|
||||
@ -1075,24 +1076,44 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
List<Model> numDTOS = getSelecPlan(rooteProdet);
|
||||
// 获取原材料工艺路线列表
|
||||
List<ProcessRoute> rawBomList = getRawBomList(rooteProdet);
|
||||
//Map<String, List<Model>> numDTOMap = numDTOS.stream().collect(Collectors.groupingBy(Model::getFProcessId_number));
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(5); // 4是线程池大小,可以根据机器性能调整
|
||||
List<Callable<Void>> tasks = new ArrayList<>();
|
||||
|
||||
for (Model numDTO : numDTOS) {
|
||||
for (ProcessRoute processRoute : rawBomList) {
|
||||
ProcessTimeInfo processTimeInfo = selectProcessRouteByMaterialCode(numDTO.getFProcessId_number());
|
||||
if (numDTO.getFProcessId_number().equals(processRoute.getMaterialCode())) {
|
||||
numDTO.setFPlanStartTime(processTimeInfo.getTenthProcessStartTime());
|
||||
numDTO.setFPlanFinishTime(processTimeInfo.getLastProcessEndTime());
|
||||
List<FEntity> fEntity = numDTO.getFEntity();
|
||||
for (FEntity entity : fEntity) {
|
||||
for (FSubEntity fSubEntity : entity.getFSubEntity()) {
|
||||
if (fSubEntity.getFOperNumber().equals(processRoute.getProcessNo())) {
|
||||
fSubEntity.setFOperPlanStartTime(processRoute.getXuStartTime());
|
||||
fSubEntity.setFOperPlanFinishTime(processRoute.getXuEndTime());
|
||||
tasks.add(() -> {
|
||||
for (ProcessRoute processRoute : rawBomList) {
|
||||
ProcessTimeInfo processTimeInfo = selectProcessRouteByMaterialCode(numDTO.getFProcessId_number());
|
||||
if (numDTO.getFProcessId_number().equals(processRoute.getMaterialCode())) {
|
||||
numDTO.setFPlanStartTime(processTimeInfo.getTenthProcessStartTime());
|
||||
numDTO.setFPlanFinishTime(processTimeInfo.getLastProcessEndTime());
|
||||
List<FEntity> fEntity = numDTO.getFEntity();
|
||||
for (FEntity entity : fEntity) {
|
||||
for (FSubEntity fSubEntity : entity.getFSubEntity()) {
|
||||
if (fSubEntity.getFOperNumber().equals(processRoute.getProcessNo())) {
|
||||
fSubEntity.setFOperPlanStartTime(processRoute.getXuStartTime());
|
||||
fSubEntity.setFOperPlanFinishTime(processRoute.getXuEndTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
// 使用线程池执行任务
|
||||
try {
|
||||
// 执行所有任务并等待所有任务完成
|
||||
List<Future<Void>> futures = executorService.invokeAll(tasks);
|
||||
|
||||
// 等待所有任务完成
|
||||
for (Future<Void> future : futures) {
|
||||
// 阻塞,直到任务完成
|
||||
future.get();
|
||||
}
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("更新过程中发生错误: ", e);
|
||||
} finally {
|
||||
executorService.shutdown();
|
||||
}
|
||||
RepoRet repoRet = updatePcessPlan1(numDTOS);
|
||||
log.info(repoRet.isSuccessfully() ? "更新成功" : "更新失败");
|
||||
@ -1165,14 +1186,10 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
if (rowsAffected > 0) {
|
||||
//获取删除后其他的 工序,然后更新工序号
|
||||
LambdaQueryWrapper<ProcessRoute> wrapper = new LambdaQueryWrapper<>();
|
||||
log.info("Querying ProcessRoute with routeDescription: {}, materialCode: {}, materialName: {}",
|
||||
processRoute.getRouteDescription(),
|
||||
processRoute.getMaterialCode(),
|
||||
processRoute.getMaterialName());
|
||||
wrapper.eq(ProcessRoute::getRouteDescription, processRoute.getRouteDescription())
|
||||
.eq(ProcessRoute::getMaterialCode, processRoute.getMaterialCode())
|
||||
.eq(ProcessRoute::getMaterialName, processRoute.getMaterialName())
|
||||
.ne(ProcessRoute::getProcessNo,null);
|
||||
.isNotNull(ProcessRoute::getProcessNo);
|
||||
List<ProcessRoute> routeList = baseMapper.selectList(wrapper);
|
||||
|
||||
//工序号升序排序
|
||||
@ -1304,15 +1321,11 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
LambdaQueryWrapper<ProcessRoute> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProcessRoute::getMaterialCode, materialCode);
|
||||
List<ProcessRoute> processRoutes = baseMapper.selectList(wrapper);
|
||||
|
||||
|
||||
ProcessTimeInfo timeInfo = new ProcessTimeInfo(); // 创建返回对象
|
||||
|
||||
if (processRoutes.isEmpty()) {
|
||||
System.out.println("没有找到任何工序");
|
||||
return timeInfo; // 返回空信息
|
||||
}
|
||||
|
||||
Date tenthProcessStartTime = null;
|
||||
Date lastProcessEndTime = null;
|
||||
int maxSequenceNumber = -1; // 初始化最大序号
|
||||
|
||||
Loading…
Reference in New Issue
Block a user