工艺模块,相关接口,相关工艺校验,bom校验
This commit is contained in:
parent
085ee1403c
commit
a648158686
@ -1463,7 +1463,7 @@ public class JdUtils {
|
||||
//请求参数,要求为json字符串
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("FormId", "BD_MATERIAL");
|
||||
json.addProperty("FieldKeys", "FNumber,FName,FCategoryID.FNumber,F_SVRI_Assistant.FNumber,FErpClsID");
|
||||
json.addProperty("FieldKeys", "FNumber,FName,FCategoryID.FNumber,F_SVRI_Assistant.FNumber,FErpClsID,FBaseUnitId.FName");
|
||||
JsonArray filterString = new JsonArray();
|
||||
log.debug("构建查询条件...");
|
||||
json.add("FilterString", filterString);
|
||||
|
||||
@ -63,7 +63,7 @@ public class BomDetailsController extends BaseController {
|
||||
|
||||
private final IBomDetailsService iBomDetailsService;
|
||||
|
||||
private final IMaterialPropertiesService iMaterialPropertiesService ;
|
||||
private final IMaterialPropertiesService iMaterialPropertiesService;
|
||||
|
||||
private final IProcessRouteService iProcessRouteService;
|
||||
private static final Logger log = LoggerFactory.getLogger(BomDetailsController.class);
|
||||
@ -87,7 +87,7 @@ public class BomDetailsController extends BaseController {
|
||||
if (parent == null) {
|
||||
parent = new BomDetailsVo();
|
||||
parent.setId(generateUniqueParentId(bomDetailsVo.getId()));
|
||||
// parent.setUnitWeight(bomDetailsVo.getUnitWeight());
|
||||
// parent.setUnitWeight(bomDetailsVo.getUnitWeight());
|
||||
parent.setParentCodeAndName(parentCodeAndName);
|
||||
parent.setFNumber(bomDetailsVo.getFNumber());
|
||||
parent.setFName(bomDetailsVo.getFName());
|
||||
@ -213,17 +213,17 @@ public class BomDetailsController extends BaseController {
|
||||
//成品物料
|
||||
HashMap<String, String> bomFinishedProduct = getBomFinishedProduct(file);
|
||||
//新增成品父级物流
|
||||
if (loadChengPinMaterialPreservation(bomFinishedProduct)==1){
|
||||
if (loadChengPinMaterialPreservation(bomFinishedProduct) == 1) {
|
||||
log.info("新增成品父级物流成功");
|
||||
}
|
||||
// loadChengPinMaterialPreservation()
|
||||
// loadChengPinMaterialPreservation()
|
||||
for (BomDetailsVo bomDetailsvo : bomDetailsVos) {
|
||||
BomDetails bomDetails = BeanUtil.toBean(bomDetailsvo, BomDetails.class);
|
||||
|
||||
// 校验属性、材质、数量是否为空,并记录提示信息
|
||||
if (bomDetails.getStats() == null || bomDetails.getMaterial() == null || bomDetails.getQuantity() == null) {
|
||||
String warningMessage = String.format("记录 %s 缺少必要字段: 属性=%s, 材质=%s, 数量=%s",
|
||||
bomDetails.getPartNumber(), bomDetails.getStats(), bomDetails.getMaterial(), bomDetails.getQuantity());
|
||||
bomDetails.getPartNumber(), bomDetails.getStats(), bomDetails.getMaterial(), bomDetails.getQuantity());
|
||||
missingFieldsWarnings.add(warningMessage);
|
||||
}
|
||||
// 验证物料是否存在
|
||||
@ -233,7 +233,7 @@ public class BomDetailsController extends BaseController {
|
||||
bomDetails.setUnitWeight("是");
|
||||
} else {
|
||||
if (bomDetails.getStats() == null || bomDetails.getStats().equals("外购") || bomDetails.getFName().startsWith("009") || bomDetails.getFName().startsWith("AA")
|
||||
|| bomDetails.getFName().startsWith("AB") || bomDetails.getFName().startsWith("AC")|| bomDetails.getFName().startsWith("015")) {
|
||||
|| bomDetails.getFName().startsWith("AB") || bomDetails.getFName().startsWith("AC") || bomDetails.getFName().startsWith("015")) {
|
||||
materialsToAdd.add(bomDetails);
|
||||
} else if (bomDetails.getStats().equals("自制")) {
|
||||
materialsToAdd.add(bomDetails);
|
||||
@ -266,17 +266,17 @@ public class BomDetailsController extends BaseController {
|
||||
System.out.println("state:=======================>" + state);
|
||||
//判断是否是电器物料
|
||||
int result;
|
||||
if (material.getTotalWeight().contains("DQ")){
|
||||
if (material.getTotalWeight().contains("DQ")) {
|
||||
log.info("开始新增不存在的电气物料==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
result = loadMaterialToDQ(material, state);
|
||||
}else{
|
||||
result = loadMaterialToDQ(material, state);
|
||||
} else {
|
||||
log.info("开始新增不存在的物料==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
result = loadMaterialPreservation(material, state);
|
||||
result = loadMaterialPreservation(material, state);
|
||||
}
|
||||
if (result == 1) {
|
||||
log.info("新增物料成功==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
material.setUnitWeight("新增成功");
|
||||
bomDetails.add(material);
|
||||
bomDetails.add(material);
|
||||
} else {
|
||||
log.error("新增物料失败==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
material.setUnitWeight("新增成功");
|
||||
@ -284,7 +284,7 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
BomDetailsBo bean = BeanUtil.toBean(bomDetails, BomDetailsBo.class);
|
||||
iBomDetailsService.updateByBo(bean);
|
||||
}
|
||||
}
|
||||
// 保存当前记录
|
||||
|
||||
return R.ok("导入成功");
|
||||
@ -293,7 +293,7 @@ public class BomDetailsController extends BaseController {
|
||||
/**
|
||||
* @param file
|
||||
*/
|
||||
private HashMap<String, String> getBomFinishedProduct(MultipartFile file ) throws IOException {
|
||||
private HashMap<String, String> getBomFinishedProduct(MultipartFile file) throws IOException {
|
||||
Sheet sheetAt = WorkbookFactory.create(file.getInputStream()).getSheetAt(0);
|
||||
Row firstRow = sheetAt.getRow(1);
|
||||
HashMap<String, String> chenpin = new HashMap<>();
|
||||
@ -303,19 +303,21 @@ public class BomDetailsController extends BaseController {
|
||||
|
||||
Cell cell1 = firstRow.getCell(2);
|
||||
log.info("获取到第一行第二列的值为:" + cell1.toString());
|
||||
chenpin.put("fnumber",cell.toString());
|
||||
chenpin.put("fname",cell1.toString());
|
||||
chenpin.put("fnumber", cell.toString());
|
||||
chenpin.put("fname", cell1.toString());
|
||||
// 获取单元格的值,假设它是字符串类型
|
||||
return chenpin;
|
||||
return chenpin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性 替换成金蝶属性编码
|
||||
*
|
||||
* @param stats
|
||||
* @return
|
||||
*/
|
||||
public static String determineState(BomDetails stats) {
|
||||
if (stats == null || stats.getStats().equals("外购") || stats.getFName().startsWith("009")||
|
||||
stats.getFName().startsWith("AA")|| stats.getFName().startsWith("AB")|| stats.getFName().startsWith("AC")) {
|
||||
if (stats == null || stats.getStats().equals("外购") || stats.getFName().startsWith("009") ||
|
||||
stats.getFName().startsWith("AA") || stats.getFName().startsWith("AB") || stats.getFName().startsWith("AC")) {
|
||||
return "1";
|
||||
} else if (stats.getStats().equals("自制")) {
|
||||
return "2";
|
||||
@ -343,15 +345,15 @@ public class BomDetailsController extends BaseController {
|
||||
if (bomDetails != null && !bomDetails.isEmpty()) {
|
||||
//物料清单保存方法
|
||||
int i1 = loadBillOfMaterialsPreservation(bomDetails);
|
||||
if (i1==1){
|
||||
if (i1 == 1) {
|
||||
return R.ok("bom上传成功");
|
||||
}else if (i1==0){
|
||||
} else if (i1 == 0) {
|
||||
return R.fail("bom上传失败");
|
||||
}
|
||||
bomDetailsList.addAll(bomDetails);
|
||||
}
|
||||
}
|
||||
return R.ok("bom上传成功",bomDetailsList);
|
||||
return R.ok("bom上传成功", bomDetailsList);
|
||||
}
|
||||
|
||||
|
||||
@ -373,14 +375,131 @@ public class BomDetailsController extends BaseController {
|
||||
System.out.println("处理物料编码:" + fnumber + ", 生产令号:" + totalWeight);
|
||||
|
||||
if (bomDetails != null && !bomDetails.isEmpty()) {
|
||||
// 检查金蝶中是否存在该物料的BOM
|
||||
//JsonArray existingBom = checkBomExists(fnumber);
|
||||
// 物料清单保存方法
|
||||
FBloadBillOfMaterialsPreservation(bomDetails);
|
||||
bomDetailsList.addAll(bomDetails);
|
||||
}
|
||||
}
|
||||
return R.ok("成功", bomDetailsList);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@PostMapping("/updateFBMaterial")
|
||||
public R updateFBMaterial1(@RequestBody List<Map<String, String>> bomDetailParams) {
|
||||
List<BomDetails> bomDetailsList = new ArrayList<>();
|
||||
|
||||
// 遍历前端传来的数据
|
||||
for (Map<String, String> param : bomDetailParams) {
|
||||
String fnumber = param.get("fnumber"); // 物料编码
|
||||
String totalWeight = param.get("totalWeight"); // 生产令号
|
||||
|
||||
// 根据物料编码和生产令号查询
|
||||
List<BomDetails> bomDetails = iBomDetailsService.selectByFNumberAndTotalWeight(fnumber, totalWeight);
|
||||
|
||||
System.out.println("处理物料编码:" + fnumber + ", 生产令号:" + totalWeight);
|
||||
|
||||
if (bomDetails != null && !bomDetails.isEmpty()) {
|
||||
// 检查金蝶中是否存在该物料的BOM
|
||||
JsonArray existingBom = checkBomExists(fnumber);
|
||||
|
||||
if (existingBom != null && !existingBom.isEmpty()) {
|
||||
// BOM已存在,需要比对用量和子项
|
||||
if (compareBomDetails(existingBom, bomDetails)) {
|
||||
// BOM一致,跳过
|
||||
log.info("物料{}的BOM已存在且一致,无需更新", fnumber);
|
||||
continue;
|
||||
} else {
|
||||
// BOM不一致,需要更新
|
||||
log.info("物料{}的BOM已存在但不一致,准备更新", fnumber);
|
||||
deleteBom(fnumber); // 删除已有BOM
|
||||
}
|
||||
}
|
||||
|
||||
// 新增BOM
|
||||
FBloadBillOfMaterialsPreservation(bomDetails);
|
||||
bomDetailsList.addAll(bomDetails);
|
||||
}
|
||||
}
|
||||
return R.ok("成功",bomDetailsList);
|
||||
}
|
||||
|
||||
private boolean compareBomDetails(JsonArray existingBom, List<BomDetails> bomDetails) {
|
||||
try {
|
||||
// 获取现有BOM的子项和用量
|
||||
Map<String, Double> existingItems = new HashMap<>();
|
||||
for (JsonElement element : existingBom) {
|
||||
JsonObject item = element.getAsJsonObject();
|
||||
JsonArray treeEntity = item.getAsJsonArray("FTreeEntity");
|
||||
for (JsonElement treeItem : treeEntity) {
|
||||
String materialNo = treeItem.getAsJsonObject()
|
||||
.get("FMATERIALIDCHILD")
|
||||
.getAsJsonObject()
|
||||
.get("FNumber")
|
||||
.getAsString();
|
||||
double usage = treeItem.getAsJsonObject()
|
||||
.get("FNUMERATOR")
|
||||
.getAsDouble();
|
||||
existingItems.put(materialNo, usage);
|
||||
}
|
||||
}
|
||||
|
||||
// 比对新BOM
|
||||
for (BomDetails detail : newBom) {
|
||||
Double existingUsage = existingItems.get(detail.getPartNumber());
|
||||
if (existingUsage == null ||
|
||||
Math.abs(existingUsage - detail.getQuantity()) > 0.000001) {
|
||||
return false;
|
||||
}
|
||||
existingItems.remove(detail.getPartNumber());
|
||||
}
|
||||
|
||||
// 检查是否有多余的子项
|
||||
return existingItems.isEmpty();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("比对BOM失败:", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* 检查金蝶中是否存在该物料的BOM
|
||||
*//*
|
||||
|
||||
|
||||
private JsonArray checkBomExists(String fnumber) {
|
||||
try {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
String formId = "ENG_BOM";
|
||||
|
||||
JsonObject queryParam = new JsonObject();
|
||||
queryParam.addProperty("FormId", formId);
|
||||
queryParam.addProperty("FieldKeys", "FID,FMATERIALID.FNumber,FTreeEntity.FMATERIALIDCHILD.FNumber,FTreeEntity.FNUMERATOR");
|
||||
|
||||
JsonArray filterArray = new JsonArray();
|
||||
JsonObject filter = new JsonObject();
|
||||
filter.addProperty("Field", "FMATERIALID.FNumber");
|
||||
filter.addProperty("Value", fnumber);
|
||||
filterArray.add(filter);
|
||||
queryParam.add("FilterString", filterArray);
|
||||
|
||||
String resultJson = client.executeBillQuery(queryParam.toString());
|
||||
Gson gson = new Gson();
|
||||
JsonArray result = gson.fromJson(resultJson, JsonArray.class);
|
||||
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("查询BOM失败:", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*s
|
||||
物料清单保存方法
|
||||
@ -395,10 +514,10 @@ public class BomDetailsController extends BaseController {
|
||||
String fName = bomDetails.getFName();
|
||||
String fNumber = bomDetails.getFNumber();
|
||||
// 验证物料是否存在
|
||||
if ( isMaterialVerification(fNumber,fName)==0){
|
||||
if (isMaterialVerification(fNumber, fName) == 0) {
|
||||
log.debug("物料不存在");
|
||||
//增加父级物料图号
|
||||
if (loadMaterialPreservation(bomDetails)==1){
|
||||
if (loadMaterialPreservation(bomDetails) == 1) {
|
||||
log.debug("物料增加成功");
|
||||
}
|
||||
|
||||
@ -488,32 +607,32 @@ public class BomDetailsController extends BaseController {
|
||||
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
|
||||
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
|
||||
log.debug("物料清单bom 保存成功===================>" + "图号:" + bomDetails.getFNumber());
|
||||
return 1;
|
||||
return 1;
|
||||
} else {
|
||||
log.error("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
|
||||
log.error("物料清单bom 保存失败===================>" + "图号:" + bomDetails.getFNumber());
|
||||
return 0 ;
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
R.fail(e.getMessage());
|
||||
}
|
||||
// 输出生成的Json
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//FBOM物料清单保存
|
||||
public void FBloadBillOfMaterialsPreservation(List<BomDetails> bomlist) {
|
||||
public void FBloadBillOfMaterialsPreservation(List<BomDetails> bomlist) {
|
||||
|
||||
BomDetails bomDetails1 = bomlist.get(0);
|
||||
int verification = isMaterialVerification(bomDetails1.getFNumber(), bomDetails1.getFName());
|
||||
// 验证父级物料是否存在
|
||||
if (verification==0){
|
||||
if (verification == 0) {
|
||||
log.debug("父级物料物料不存在");
|
||||
//父级物料不存在,即调用物料新增接口
|
||||
int materialVerificationResult = loadFBMaterialPreservation(bomDetails1);
|
||||
if (materialVerificationResult ==1){
|
||||
if (materialVerificationResult == 1) {
|
||||
log.debug("父级物料保存成功");
|
||||
}else {
|
||||
} else {
|
||||
log.error("父级物料保存失败");
|
||||
}
|
||||
}
|
||||
@ -572,16 +691,22 @@ public class BomDetailsController extends BaseController {
|
||||
// 添加FTreeEntity字段
|
||||
fTreeEntityItem.addProperty("FReplaceGroup", 1);
|
||||
|
||||
if (details.getPartNumber() != null){
|
||||
if (iProcessRouteService.isAnTuDingGou(details.getPartNumber())) {
|
||||
fTreeEntityItem.addProperty("FSupplyType", "C");
|
||||
} else if (details.getRemarks().equals("伊特")) {
|
||||
|
||||
fTreeEntityItem.addProperty("FSupplyType", "C");
|
||||
|
||||
} else{
|
||||
fTreeEntityItem.addProperty("FSupplyType", " ");
|
||||
if (details != null) {
|
||||
String partNumber = details.getPartNumber();
|
||||
String remarks = details.getRemarks();
|
||||
// 先设置默认值
|
||||
String supplyType = " ";
|
||||
if (partNumber != null) {
|
||||
// 检查是否为安徒定购
|
||||
if (iProcessRouteService.isAnTuDingGou(partNumber)) {
|
||||
supplyType = "C";
|
||||
}
|
||||
// 检查是否为伊特
|
||||
else if ("伊特".equals(remarks)) {
|
||||
supplyType = "C";
|
||||
}
|
||||
}
|
||||
fTreeEntityItem.addProperty("FSupplyType", supplyType);
|
||||
}
|
||||
|
||||
fTreeEntityItem.addProperty("FMATERIALTYPE", "1");
|
||||
@ -653,10 +778,10 @@ public class BomDetailsController extends BaseController {
|
||||
model.addProperty("FNumber", bomDetails.getFNumber());
|
||||
model.addProperty("FName", bomDetails.getFName());
|
||||
json.add("Model", model);
|
||||
MaterialProperties materialProperties = iMaterialPropertiesService.selectByAttribute(bomDetails.getMaterial());
|
||||
MaterialProperties materialProperties = iMaterialPropertiesService.selectByAttribute(bomDetails.getMaterial());
|
||||
JsonObject FSVRIAssistant = new JsonObject();
|
||||
FSVRIAssistant.addProperty("FNumber", materialProperties.getMaterialAttributeId());
|
||||
model.add("F_SVRI_Assistant",FSVRIAssistant);
|
||||
model.add("F_SVRI_Assistant", FSVRIAssistant);
|
||||
|
||||
// 创建FMaterialGroup对象,并加入Model
|
||||
JsonObject fMaterialGroup = new JsonObject();
|
||||
@ -744,16 +869,16 @@ public class BomDetailsController extends BaseController {
|
||||
JsonObject subHeadEntity6 = new JsonObject();
|
||||
model.add("SubHeadEntity6", subHeadEntity6);
|
||||
//不同的属性不同的检验方案
|
||||
if (bomDetails.getStats().equals("1")){
|
||||
if (bomDetails.getStats().equals("1")) {
|
||||
//外购
|
||||
subHeadEntity6.addProperty("FCheckIncoming", true);
|
||||
}
|
||||
if (bomDetails.getStats().equals("2")){
|
||||
if (bomDetails.getStats().equals("2")) {
|
||||
//自制
|
||||
subHeadEntity6.addProperty("FCheckProduct", true);
|
||||
subHeadEntity6.addProperty("FCheckReturnMtrl", true);
|
||||
}
|
||||
if (bomDetails.getStats().equals("3")){
|
||||
if (bomDetails.getStats().equals("3")) {
|
||||
//委外
|
||||
subHeadEntity6.addProperty("FCheckIncoming", true);
|
||||
subHeadEntity6.addProperty("FCheckProduct", true);
|
||||
@ -818,7 +943,7 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
/*FB父级物料保存接口
|
||||
* */
|
||||
* */
|
||||
public static int loadFBMaterialPreservation(BomDetails bomDetail) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
// 创建一个空的JsonObject
|
||||
@ -927,16 +1052,16 @@ public class BomDetailsController extends BaseController {
|
||||
JsonObject subHeadEntity6 = new JsonObject();
|
||||
model.add("SubHeadEntity6", subHeadEntity6);
|
||||
//不同的属性不同的检验方案
|
||||
if (bomDetail.getStats().equals("1")){
|
||||
if (bomDetail.getStats().equals("1")) {
|
||||
//外购
|
||||
subHeadEntity6.addProperty("FCheckIncoming", true);
|
||||
}
|
||||
if (bomDetail.getStats().equals("2")){
|
||||
if (bomDetail.getStats().equals("2")) {
|
||||
//自制
|
||||
subHeadEntity6.addProperty("FCheckProduct", true);
|
||||
subHeadEntity6.addProperty("FCheckReturnMtrl", true);
|
||||
}
|
||||
if (bomDetail.getStats().equals("3")){
|
||||
if (bomDetail.getStats().equals("3")) {
|
||||
//委外
|
||||
subHeadEntity6.addProperty("FCheckIncoming", true);
|
||||
subHeadEntity6.addProperty("FCheckProduct", true);
|
||||
@ -998,10 +1123,11 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*FB父级物料保存接口
|
||||
单位 是台
|
||||
* */
|
||||
public int loadChengPinMaterialPreservation(HashMap <String, String> bomDetail) {
|
||||
public int loadChengPinMaterialPreservation(HashMap<String, String> bomDetail) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
// 创建一个空的JsonObject
|
||||
JsonObject json = new JsonObject();
|
||||
@ -1050,7 +1176,7 @@ public class BomDetailsController extends BaseController {
|
||||
subHeadEntity.addProperty("FIsPurchase", true);
|
||||
subHeadEntity.addProperty("FIsInventory", true);
|
||||
//成品不允许委外
|
||||
// subHeadEntity.addProperty("FIsSubContract", true);
|
||||
// subHeadEntity.addProperty("FIsSubContract", true);
|
||||
subHeadEntity.addProperty("FIsSale", true);
|
||||
subHeadEntity.addProperty("FIsProduce", true);
|
||||
|
||||
@ -1065,8 +1191,8 @@ public class BomDetailsController extends BaseController {
|
||||
// 创建FStockId对象,并加入SubHeadEntity1
|
||||
JsonObject fStockId = new JsonObject();
|
||||
//判断是产成品还是企标
|
||||
String cangKu = "CK011";
|
||||
fStockId.addProperty("FNumber", cangKu);
|
||||
String cangKu = "CK011";
|
||||
fStockId.addProperty("FNumber", cangKu);
|
||||
subHeadEntity1.add("FStockId", fStockId);
|
||||
|
||||
// 创建FCurrencyId对象,并加入SubHeadEntity1
|
||||
@ -1104,8 +1230,8 @@ public class BomDetailsController extends BaseController {
|
||||
// 创建SubHeadEntity6对象,并加入Model 检验项
|
||||
JsonObject subHeadEntity6 = new JsonObject();
|
||||
model.add("SubHeadEntity6", subHeadEntity6);
|
||||
subHeadEntity6.addProperty("FCheckProduct", true);
|
||||
subHeadEntity6.addProperty("FCheckReturn", true);
|
||||
subHeadEntity6.addProperty("FCheckProduct", true);
|
||||
subHeadEntity6.addProperty("FCheckReturn", true);
|
||||
|
||||
// 创建SubHeadEntity5对象,并加入Model
|
||||
JsonObject subHeadEntity5 = new JsonObject();
|
||||
@ -1163,9 +1289,11 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 物料验证
|
||||
* 验证物料在金蝶中是否存在
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int isMaterialVerification(String DrawingNumber, String name) {
|
||||
@ -1231,15 +1359,15 @@ public class BomDetailsController extends BaseController {
|
||||
model.addProperty("FNumber", bomDetails1.getPartNumber());
|
||||
model.addProperty("FName", bomDetails1.getName());
|
||||
MaterialProperties materialProperties = iMaterialPropertiesService.selectByAttribute(bomDetails1.getMaterial());
|
||||
if (materialProperties!=null){
|
||||
if (materialProperties != null) {
|
||||
JsonObject FSVRIAssistant = new JsonObject();
|
||||
FSVRIAssistant.addProperty("FNumber", materialProperties.getMaterialAttributeId());
|
||||
model.add("F_SVRI_Assistant",FSVRIAssistant);
|
||||
}else {
|
||||
model.add("F_SVRI_Assistant", FSVRIAssistant);
|
||||
} else {
|
||||
//没写材料为默认为空
|
||||
JsonObject FSVRIAssistant = new JsonObject();
|
||||
FSVRIAssistant.addProperty("FNumber", "17");
|
||||
model.add("F_SVRI_Assistant",FSVRIAssistant);
|
||||
model.add("F_SVRI_Assistant", FSVRIAssistant);
|
||||
}
|
||||
// 创建FMaterialGroup对象,并加入Model
|
||||
JsonObject fMaterialGroup = new JsonObject();
|
||||
@ -1257,9 +1385,9 @@ public class BomDetailsController extends BaseController {
|
||||
|
||||
// 创建FCategoryID对象,并加入SubHeadEntity
|
||||
JsonObject fCategoryID = new JsonObject();
|
||||
if (states.equals("2") || states.equals("3")){
|
||||
if (states.equals("2") || states.equals("3")) {
|
||||
fCategoryID.addProperty("FNumber", "007");
|
||||
}else{
|
||||
} else {
|
||||
fCategoryID.addProperty("FNumber", "006");
|
||||
}
|
||||
|
||||
@ -1274,11 +1402,11 @@ public class BomDetailsController extends BaseController {
|
||||
JsonObject fBaseUnitId = new JsonObject();
|
||||
fBaseUnitId.addProperty("FNumber", "jian");
|
||||
subHeadEntity.add("FBaseUnitId", fBaseUnitId);
|
||||
if (states.equals("1")){
|
||||
if (states.equals("1")) {
|
||||
subHeadEntity.addProperty("FIsPurchase", true);
|
||||
subHeadEntity.addProperty("FIsSale", true);
|
||||
subHeadEntity.addProperty("FIsInventory", true);
|
||||
}else{
|
||||
} else {
|
||||
subHeadEntity.addProperty("FIsPurchase", true);
|
||||
subHeadEntity.addProperty("FIsInventory", true);
|
||||
subHeadEntity.addProperty("FIsSubContract", true);
|
||||
@ -1330,16 +1458,16 @@ public class BomDetailsController extends BaseController {
|
||||
JsonObject subHeadEntity6 = new JsonObject();
|
||||
model.add("SubHeadEntity6", subHeadEntity6);
|
||||
//不同的属性不同的检验方案
|
||||
if (states.equals("1")){
|
||||
if (states.equals("1")) {
|
||||
//外购
|
||||
subHeadEntity6.addProperty("FCheckIncoming", true);
|
||||
}
|
||||
if (states.equals("2")){
|
||||
if (states.equals("2")) {
|
||||
//自制
|
||||
subHeadEntity6.addProperty("FCheckProduct", true);
|
||||
subHeadEntity6.addProperty("FCheckReturnMtrl", true);
|
||||
}
|
||||
if (states.equals("3")){
|
||||
if (states.equals("3")) {
|
||||
//委外
|
||||
subHeadEntity6.addProperty("FCheckIncoming", true);
|
||||
subHeadEntity6.addProperty("FCheckProduct", true);
|
||||
@ -1347,7 +1475,6 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 创建SubHeadEntity5对象,并加入Model
|
||||
JsonObject subHeadEntity5 = new JsonObject();
|
||||
model.add("SubHeadEntity5", subHeadEntity5);
|
||||
@ -1367,9 +1494,9 @@ public class BomDetailsController extends BaseController {
|
||||
JsonObject fBOMUnitId = new JsonObject();
|
||||
fBOMUnitId.addProperty("FNumber", "jian");
|
||||
subHeadEntity5.add("FBOMUnitId", fBOMUnitId);
|
||||
if (states.equals("1")){
|
||||
if (states.equals("1")) {
|
||||
subHeadEntity5.addProperty("FIsMainPrd", false);
|
||||
}else {
|
||||
} else {
|
||||
subHeadEntity5.addProperty("FIsMainPrd", true);
|
||||
}
|
||||
subHeadEntity5.addProperty("FIssueType", "1");
|
||||
@ -1407,6 +1534,7 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//创建电气物料
|
||||
public int loadMaterialToDQ(BomDetails bomDetails1, String states) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
@ -1425,15 +1553,15 @@ public class BomDetailsController extends BaseController {
|
||||
model.addProperty("FNumber", bomDetails1.getPartNumber());
|
||||
model.addProperty("FName", bomDetails1.getName());
|
||||
MaterialProperties materialProperties = iMaterialPropertiesService.selectByAttribute(bomDetails1.getMaterial());
|
||||
if (materialProperties!=null){
|
||||
if (materialProperties != null) {
|
||||
JsonObject FSVRIAssistant = new JsonObject();
|
||||
FSVRIAssistant.addProperty("FNumber", materialProperties.getMaterialAttributeId());
|
||||
model.add("F_SVRI_Assistant",FSVRIAssistant);
|
||||
}else {
|
||||
model.add("F_SVRI_Assistant", FSVRIAssistant);
|
||||
} else {
|
||||
//没写材料为默认为空
|
||||
JsonObject FSVRIAssistant = new JsonObject();
|
||||
FSVRIAssistant.addProperty("FNumber", "17");
|
||||
model.add("F_SVRI_Assistant",FSVRIAssistant);
|
||||
model.add("F_SVRI_Assistant", FSVRIAssistant);
|
||||
}
|
||||
// 创建FMaterialGroup对象,并加入Model
|
||||
JsonObject fMaterialGroup = new JsonObject();
|
||||
@ -1451,9 +1579,9 @@ public class BomDetailsController extends BaseController {
|
||||
|
||||
// 创建FCategoryID对象,并加入SubHeadEntity
|
||||
JsonObject fCategoryID = new JsonObject();
|
||||
if (states.equals("2") || states.equals("3")){
|
||||
if (states.equals("2") || states.equals("3")) {
|
||||
fCategoryID.addProperty("FNumber", "007");
|
||||
}else{
|
||||
} else {
|
||||
fCategoryID.addProperty("FNumber", "006");
|
||||
}
|
||||
|
||||
@ -1479,7 +1607,7 @@ public class BomDetailsController extends BaseController {
|
||||
case "根":
|
||||
fBaseUnitId.addProperty("FNumber", "003");
|
||||
break;
|
||||
case "米":
|
||||
case "米":
|
||||
fBaseUnitId.addProperty("FNumber", "005");
|
||||
break;
|
||||
case "卷":
|
||||
@ -1500,16 +1628,16 @@ public class BomDetailsController extends BaseController {
|
||||
case "条":
|
||||
fBaseUnitId.addProperty("FNumber", "017");
|
||||
break;
|
||||
case "套":
|
||||
case "套":
|
||||
fBaseUnitId.addProperty("FNumber", "007");
|
||||
break;
|
||||
}
|
||||
subHeadEntity.add("FBaseUnitId", fBaseUnitId);
|
||||
if (states.equals("1")){
|
||||
if (states.equals("1")) {
|
||||
subHeadEntity.addProperty("FIsPurchase", true);
|
||||
subHeadEntity.addProperty("FIsSale", true);
|
||||
subHeadEntity.addProperty("FIsInventory", true);
|
||||
}else{
|
||||
} else {
|
||||
subHeadEntity.addProperty("FIsPurchase", true);
|
||||
subHeadEntity.addProperty("FIsInventory", true);
|
||||
subHeadEntity.addProperty("FIsSubContract", true);
|
||||
@ -1534,7 +1662,8 @@ public class BomDetailsController extends BaseController {
|
||||
break;
|
||||
case "根":
|
||||
fBaseUnitId.addProperty("FNumber", "003");
|
||||
break; case "米":
|
||||
break;
|
||||
case "米":
|
||||
fBaseUnitId.addProperty("FNumber", "005");
|
||||
break;
|
||||
case "卷":
|
||||
@ -1591,7 +1720,8 @@ public class BomDetailsController extends BaseController {
|
||||
break;
|
||||
case "根":
|
||||
fBaseUnitId.addProperty("FNumber", "003");
|
||||
break; case "米":
|
||||
break;
|
||||
case "米":
|
||||
fBaseUnitId.addProperty("FNumber", "005");
|
||||
break;
|
||||
case "卷":
|
||||
@ -1636,7 +1766,8 @@ public class BomDetailsController extends BaseController {
|
||||
break;
|
||||
case "根":
|
||||
fBaseUnitId.addProperty("FNumber", "003");
|
||||
break; case "米":
|
||||
break;
|
||||
case "米":
|
||||
fBaseUnitId.addProperty("FNumber", "005");
|
||||
break;
|
||||
case "卷":
|
||||
@ -1669,16 +1800,16 @@ public class BomDetailsController extends BaseController {
|
||||
JsonObject subHeadEntity6 = new JsonObject();
|
||||
model.add("SubHeadEntity6", subHeadEntity6);
|
||||
//不同的属性不同的检验方案
|
||||
if (states.equals("1")){
|
||||
if (states.equals("1")) {
|
||||
//外购
|
||||
subHeadEntity6.addProperty("FCheckIncoming", true);
|
||||
}
|
||||
if (states.equals("2")){
|
||||
if (states.equals("2")) {
|
||||
//自制
|
||||
subHeadEntity6.addProperty("FCheckProduct", true);
|
||||
subHeadEntity6.addProperty("FCheckReturnMtrl", true);
|
||||
}
|
||||
if (states.equals("3")){
|
||||
if (states.equals("3")) {
|
||||
//委外
|
||||
subHeadEntity6.addProperty("FCheckIncoming", true);
|
||||
subHeadEntity6.addProperty("FCheckProduct", true);
|
||||
@ -1686,7 +1817,6 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 创建SubHeadEntity5对象,并加入Model
|
||||
JsonObject subHeadEntity5 = new JsonObject();
|
||||
model.add("SubHeadEntity5", subHeadEntity5);
|
||||
@ -1707,7 +1837,7 @@ public class BomDetailsController extends BaseController {
|
||||
case "根":
|
||||
fBaseUnitId.addProperty("FNumber", "003");
|
||||
break;
|
||||
case "米":
|
||||
case "米":
|
||||
fBaseUnitId.addProperty("FNumber", "005");
|
||||
break;
|
||||
case "卷":
|
||||
@ -1753,7 +1883,8 @@ public class BomDetailsController extends BaseController {
|
||||
break;
|
||||
case "根":
|
||||
fBaseUnitId.addProperty("FNumber", "003");
|
||||
break; case "米":
|
||||
break;
|
||||
case "米":
|
||||
fBaseUnitId.addProperty("FNumber", "005");
|
||||
break;
|
||||
case "卷":
|
||||
@ -1779,9 +1910,9 @@ public class BomDetailsController extends BaseController {
|
||||
break;
|
||||
}
|
||||
subHeadEntity5.add("FBOMUnitId", fBOMUnitId);
|
||||
if (states.equals("1")){
|
||||
if (states.equals("1")) {
|
||||
subHeadEntity5.addProperty("FIsMainPrd", false);
|
||||
}else {
|
||||
} else {
|
||||
subHeadEntity5.addProperty("FIsMainPrd", true);
|
||||
}
|
||||
subHeadEntity5.addProperty("FIssueType", "1");
|
||||
|
||||
@ -16,6 +16,8 @@ import com.ruoyi.system.domain.MaterialBom;
|
||||
import com.ruoyi.system.domain.ProcessRoute;
|
||||
import com.ruoyi.system.domain.bo.ProcessRouteBo;
|
||||
import com.ruoyi.system.domain.dto.CombinedDTO;
|
||||
import com.ruoyi.system.domain.dto.ProcessRoutePushResultDTO;
|
||||
import com.ruoyi.system.domain.dto.ProcessRouteSelectDTO;
|
||||
import com.ruoyi.system.jdmain.rouplan.Model;
|
||||
import com.ruoyi.system.domain.dto.ProcessRouteXuDTO;
|
||||
import com.ruoyi.system.domain.vo.ProcessRouteVo;
|
||||
@ -24,6 +26,8 @@ import com.ruoyi.system.service.IProcessRouteService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -33,10 +37,13 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 工艺路线
|
||||
*
|
||||
* @date 2024-10-09
|
||||
*/
|
||||
@Validated
|
||||
@ -48,7 +55,7 @@ public class ProcessRouteController extends BaseController {
|
||||
private final IProcessRouteService iProcessRouteService;
|
||||
private static final Logger log = LoggerFactory.getLogger(ProcessRouteController.class);
|
||||
|
||||
private Long generateUniqueParentId( Long originalId) {
|
||||
private Long generateUniqueParentId(Long originalId) {
|
||||
return originalId + 1000;
|
||||
}
|
||||
|
||||
@ -60,7 +67,8 @@ public class ProcessRouteController extends BaseController {
|
||||
public TableDataInfo<ProcessRouteVo> list(ProcessRouteBo bo, PageQuery pageQuery) {
|
||||
try {
|
||||
// 查询工艺路线数据
|
||||
TableDataInfo<ProcessRouteVo> processRouteVoTableDataInfo = iProcessRouteService.queryPageList(bo, pageQuery);
|
||||
TableDataInfo<ProcessRouteVo> processRouteVoTableDataInfo = iProcessRouteService.queryPageList(bo,
|
||||
pageQuery);
|
||||
// 用于存储父子关系的Map,key为"物料编码_物料名称",值为父级ProcessRouteVo
|
||||
Map<String, ProcessRouteVo> routeMap = new HashMap<>();
|
||||
// 存储顶级列表
|
||||
@ -70,7 +78,8 @@ public class ProcessRouteController extends BaseController {
|
||||
// 遍历所有工艺路线记录
|
||||
for (ProcessRouteVo processRouteVo : rows) {
|
||||
// 组合父级键值,物料编码 + 物料名称
|
||||
String parentCodeAndName = String.format("%s_%s", processRouteVo.getMaterialCode(), processRouteVo.getMaterialName());
|
||||
String parentCodeAndName = String.format("%s_%s", processRouteVo.getMaterialCode(),
|
||||
processRouteVo.getMaterialName());
|
||||
// 查找是否已存在父节点
|
||||
ProcessRouteVo parent = routeMap.get(parentCodeAndName);
|
||||
if (parent == null) {
|
||||
@ -78,7 +87,7 @@ public class ProcessRouteController extends BaseController {
|
||||
parent = new ProcessRouteVo();
|
||||
parent.setId(generateUniqueParentId(processRouteVo.getId()));
|
||||
parent.setRouteDescription(processRouteVo.getRouteDescription());
|
||||
//parent.setParentId((Long.valueOf(generateUniqueParentId(processRouteVo.getId()))));
|
||||
// parent.setParentId((Long.valueOf(generateUniqueParentId(processRouteVo.getId()))));
|
||||
parent.setMaterialCode(processRouteVo.getMaterialCode());
|
||||
parent.setMaterialName(processRouteVo.getMaterialName());
|
||||
parent.setMaterial(processRouteVo.getMaterial());
|
||||
@ -92,7 +101,8 @@ public class ProcessRouteController extends BaseController {
|
||||
topLevelList.add(parent);
|
||||
}
|
||||
// 创建子节点,并将其添加到父节点的子集
|
||||
ProcessRouteVo child = createChildVo(processRouteVo, parent.getId(),parent.getMaterialCode(),parent.getMaterialName());
|
||||
ProcessRouteVo child = createChildVo(processRouteVo, parent.getId(), parent.getMaterialCode(),
|
||||
parent.getMaterialName());
|
||||
parent.getChildren().add(child);
|
||||
}
|
||||
|
||||
@ -113,7 +123,8 @@ public class ProcessRouteController extends BaseController {
|
||||
* @param processRouteVo 原始数据
|
||||
* @return ProcessRouteVo 子节点
|
||||
*/
|
||||
private ProcessRouteVo createChildVo(ProcessRouteVo processRouteVo,Long parentId,String materialCode,String materialName) {
|
||||
private ProcessRouteVo createChildVo(ProcessRouteVo processRouteVo, Long parentId, String materialCode,
|
||||
String materialName) {
|
||||
ProcessRouteVo child = new ProcessRouteVo();
|
||||
child.setId(processRouteVo.getId());
|
||||
child.setParentId(parentId);
|
||||
@ -153,8 +164,7 @@ public class ProcessRouteController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:route:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<ProcessRouteVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
public R<ProcessRouteVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
|
||||
return R.ok(iProcessRouteService.queryById(id));
|
||||
}
|
||||
|
||||
@ -188,20 +198,20 @@ public class ProcessRouteController extends BaseController {
|
||||
@SaCheckPermission("system:route:remove")
|
||||
@Log(title = "工艺路线", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
|
||||
return toAjax(iProcessRouteService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "明细导入", businessType = BusinessType.IMPORT)
|
||||
@SaCheckPermission("system:route:import")
|
||||
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Void> importData(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
log.info("读取文件名: " + originalFilename);
|
||||
ExcelResult<ProcessRouteVo> result = ExcelUtil.importExcelSheet6(file.getInputStream(), ProcessRouteVo.class, true);
|
||||
ExcelResult<ProductionOrderVo> result1 = ExcelUtil.importExcelSheet1(file.getInputStream(), ProductionOrderVo.class, true);
|
||||
ExcelResult<ProcessRouteVo> result = ExcelUtil.importExcelSheet6(file.getInputStream(), ProcessRouteVo.class,
|
||||
true);
|
||||
ExcelResult<ProductionOrderVo> result1 = ExcelUtil.importExcelSheet1(file.getInputStream(),
|
||||
ProductionOrderVo.class, true);
|
||||
List<ProductionOrderVo> list = result1.getList();
|
||||
if (iProcessRouteService.saveData(result.getList(), list)) {
|
||||
return R.ok("上传物料成功");
|
||||
@ -234,14 +244,13 @@ public class ProcessRouteController extends BaseController {
|
||||
* 查询工艺表中所有的需要做工艺的物料
|
||||
*
|
||||
* @return
|
||||
* RequestBody List<ProcessRouteVo> routeVoList
|
||||
* RequestBody List<ProcessRouteVo> routeVoList
|
||||
*/
|
||||
public List<ProcessRoute> getProcessRouteList(@RequestParam String rooteProdet) {
|
||||
List<ProcessRoute> list = iProcessRouteService.pushRawMater(rooteProdet);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "查询工艺工序集合")
|
||||
@SaCheckPermission("system:route:getProcessRoute")
|
||||
@PostMapping("/getProcessRoute")
|
||||
@ -250,9 +259,9 @@ public class ProcessRouteController extends BaseController {
|
||||
}
|
||||
|
||||
@Log(title = "推送工艺工序")
|
||||
@SaCheckPermission("system:route:getProcessRoute")
|
||||
@SaCheckPermission("system:route:pushRouteBom")
|
||||
@PostMapping("/pushRouteBom")
|
||||
public List<ProcessRouteXuDTO> pushRouteBom(@RequestParam String rooteProdet) {
|
||||
public ProcessRoutePushResultDTO pushRouteBom(@RequestParam String rooteProdet) {
|
||||
return iProcessRouteService.pushRouteBom(rooteProdet);
|
||||
}
|
||||
|
||||
@ -265,6 +274,7 @@ public class ProcessRouteController extends BaseController {
|
||||
public ResponseEntity<List<String>> getDistinctProjectCodes(String query) {
|
||||
return ResponseEntity.ok(iProcessRouteService.getDistinctProjectCodes(query));
|
||||
}
|
||||
|
||||
@Log(title = "获取工序列表")
|
||||
@SaCheckPermission("system:route:getRawBom")
|
||||
@GetMapping("/getProcessInfoList")
|
||||
@ -281,56 +291,88 @@ public class ProcessRouteController extends BaseController {
|
||||
|
||||
@Log(title = "生成这个项目的pdf")
|
||||
@SaCheckPermission("system:route:getRawBom")
|
||||
@PostMapping("/generatePDFs")
|
||||
public List<CombinedDTO> generatePDFs(@RequestParam String rooteProdet) {
|
||||
return iProcessRouteService.generatePDFs(rooteProdet);
|
||||
@GetMapping("/generatePDFs")
|
||||
public void generatePDFs(String rooteProdet, HttpServletResponse response) throws IOException {
|
||||
// 调用服务层方法生成 ZIP 文件并获取其路径
|
||||
String zipFilePath = iProcessRouteService.generatePDFs(rooteProdet);
|
||||
System.out.println("ZIP 文件路径: " + zipFilePath);
|
||||
|
||||
// 读取文件为字节数组
|
||||
File zipFile = new File(zipFilePath);
|
||||
if (!zipFile.exists()) {
|
||||
throw new FileNotFoundException("ZIP 文件未找到: " + zipFilePath);
|
||||
}
|
||||
FileInputStream fis = new FileInputStream(zipFile);
|
||||
OutputStream outputStreams = response.getOutputStream();
|
||||
response.setContentType("application/zip");
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
while ((len = fis.read(buffer)) != -1) {
|
||||
outputStreams.write(buffer, 0, len);
|
||||
}
|
||||
outputStreams.flush();
|
||||
|
||||
fis.close();
|
||||
outputStreams.close();
|
||||
}
|
||||
|
||||
@Log(title = "更新计划时间")
|
||||
@SaCheckPermission("system:route:updateProcessPlan")
|
||||
@PostMapping("/updateProcessPlan")
|
||||
public List<Model> updateProcessPlan(@RequestParam String rooteProdet) {
|
||||
public List<Model> updateProcessPlan(@RequestParam String rooteProdet) {
|
||||
return iProcessRouteService.updateProcessPlan(rooteProdet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存工艺路线
|
||||
*/
|
||||
@SaCheckPermission("system:route:add")
|
||||
@SaCheckPermission("system:route:addRoute")
|
||||
@Log(title = "保存工艺路线", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/addRoute")
|
||||
public R<Void> addRoute( @RequestBody List<ProcessRouteVo> list) {
|
||||
public R<Void> addRoute(@RequestBody List<ProcessRouteVo> list) {
|
||||
|
||||
return iProcessRouteService.addRoute(list);
|
||||
}
|
||||
|
||||
@SaCheckPermission("system:route:add")
|
||||
@SaCheckPermission("system:route:deleteRoute")
|
||||
@Log(title = "删除工艺路线", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/deleteRoute")
|
||||
public List<ProcessRoute> deleteRoute( @RequestBody ProcessRoute processRoute) {
|
||||
public List<ProcessRoute> deleteRoute(@RequestBody ProcessRoute processRoute) {
|
||||
return iProcessRouteService.deleteRoute(processRoute);
|
||||
}
|
||||
|
||||
@Log(title = "获取材料bom列表")
|
||||
@SaCheckPermission("system:route:getRawBom")
|
||||
@PostMapping("/getBomInfo")
|
||||
public ResponseEntity<List<MaterialBom>> getProcessMaterialList( @RequestParam String materialCode,
|
||||
@RequestParam String materialName,
|
||||
@RequestParam String productionOrderNo) {
|
||||
public ResponseEntity<List<MaterialBom>> getProcessMaterialList(@RequestParam String materialCode,
|
||||
@RequestParam String materialName,
|
||||
@RequestParam String productionOrderNo) {
|
||||
|
||||
return ResponseEntity.ok(iProcessRouteService.getProcessMaterialList(materialCode,materialName,productionOrderNo));
|
||||
return ResponseEntity
|
||||
.ok(iProcessRouteService.getProcessMaterialList(materialCode, materialName, productionOrderNo));
|
||||
}
|
||||
|
||||
@Log(title = "导入时间", businessType = BusinessType.IMPORT)
|
||||
@SaCheckPermission("system:route:importDataTime")
|
||||
@PostMapping(value = "/importDataTime", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Void> importDataTime(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
log.info("读取文件名: " + originalFilename);
|
||||
ExcelResult<ProcessRouteVo> result = ExcelUtil.importExcelSheet6(file.getInputStream(), ProcessRouteVo.class, true);
|
||||
ExcelResult<ProcessRouteVo> result = ExcelUtil.importExcelSheet6(file.getInputStream(), ProcessRouteVo.class,
|
||||
true);
|
||||
List<ProcessRouteVo> list = result.getList();
|
||||
List<ProcessRoute> list1 = iProcessRouteService.importDataTime(list);
|
||||
List<ProcessRoute> list1 = iProcessRouteService.importDataTime(list);
|
||||
return R.ok("更新成功");
|
||||
}
|
||||
|
||||
@Log(title = "获取金蝶工艺路线")
|
||||
@SaCheckPermission("system:route:getSelectProcessRoute")
|
||||
@PostMapping("/getSelectProcessRoute")
|
||||
public List<ProcessRouteSelectDTO> getSelectProcessRoute(@RequestParam String materilCode) {
|
||||
List<ProcessRouteSelectDTO> list = iProcessRouteService.getSelectProcessRoute(materilCode);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public class ProductionPlanController extends BaseController {
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ProductionPlanBo bo) {
|
||||
|
||||
|
||||
if (iProductionPlanService.selectByProductionCode(bo.getProductionCode()) != null) {
|
||||
if (iProductionPlanService.selectByProductionCode(bo.getProductionCode()) != null) {
|
||||
return R.fail("该生产令号已存在");
|
||||
}
|
||||
return toAjax(iProductionPlanService.insertByBo(bo));
|
||||
|
||||
@ -44,7 +44,7 @@ public class ImMaterial extends BaseEntity {
|
||||
*/
|
||||
private String imCategory;
|
||||
/*
|
||||
所属名称
|
||||
所属名称:danwei
|
||||
*/
|
||||
private String classificationName;
|
||||
/*
|
||||
|
||||
@ -40,7 +40,7 @@ public class MaterialBom extends BaseEntity {
|
||||
/**
|
||||
* 用量
|
||||
*/
|
||||
private Double quantity;
|
||||
private String quantity;
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
|
||||
@ -48,7 +48,7 @@ public class MaterialBomBo extends BaseEntity {
|
||||
* 用量
|
||||
*/
|
||||
@NotNull(message = "用量不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Double quantity;
|
||||
private String quantity;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
|
||||
@ -5,6 +5,7 @@ import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
@ -140,10 +141,12 @@ public class ProcessRouteBo extends BaseEntity {
|
||||
/**
|
||||
* 序开始时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
|
||||
private Date xuStartTime;
|
||||
|
||||
/**
|
||||
* 序结束时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
|
||||
private Date xuEndTime;
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package com.ruoyi.system.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class ProcessRoutePushResultDTO {
|
||||
private List<ProcessRouteXuDTO> successfulRoutes;
|
||||
private List<ProcessRouteXuDTO> failedRoutes;
|
||||
private List<String> duplicateRoutes;
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.ruoyi.system.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ProcessRouteSelectDTO {
|
||||
@JsonProperty("FNumber")
|
||||
private String FNumber;
|
||||
/*
|
||||
* 物料编码
|
||||
*/
|
||||
@JsonProperty("FMATERIALID.FNumber")
|
||||
private String matericalCode;
|
||||
/*
|
||||
* 物料名称
|
||||
*/
|
||||
|
||||
@JsonProperty("FMATERIALNAME")
|
||||
private String matericalName;
|
||||
/**
|
||||
* 工序号
|
||||
*/
|
||||
@JsonProperty("FOperNumber")
|
||||
private Long processNo;
|
||||
/**
|
||||
* 工作中心(加工车间)
|
||||
*/
|
||||
@JsonProperty("FWorkCenterId.FName")
|
||||
private String workCenter;
|
||||
/**
|
||||
* 工序名称
|
||||
*/
|
||||
@JsonProperty("FProcessProperty")
|
||||
private String processName;
|
||||
/**
|
||||
* 工序说明(序描述)
|
||||
*/
|
||||
@JsonProperty("FOperDescription")
|
||||
private String processDescription;
|
||||
/**
|
||||
* 工序控制码
|
||||
*/
|
||||
@JsonProperty("FOptCtrlCodeId.FName")
|
||||
private String processControl;
|
||||
/**
|
||||
* 活动时长
|
||||
*/
|
||||
@JsonProperty("FActivity1Qty")
|
||||
private Double activityDuration;
|
||||
/**
|
||||
* 活动单位
|
||||
*/
|
||||
private String activityUnit;
|
||||
}
|
||||
@ -15,5 +15,8 @@ public class ProcessRouteXuDTO {
|
||||
* 物料名称
|
||||
*/
|
||||
private String materialName;
|
||||
/**
|
||||
* 工艺路线
|
||||
*/
|
||||
private List<ProcessRouteDTO> processRouteDT;
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public class MaterialBomVo {
|
||||
* 用量
|
||||
*/
|
||||
@ExcelProperty(value = "用量")
|
||||
private Double quantity;
|
||||
private String quantity;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
|
||||
@ -28,6 +28,7 @@ public class ProcessRouteVo {
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
private String uuid;
|
||||
/**
|
||||
* 父级id
|
||||
|
||||
@ -85,5 +85,16 @@ public class ProductionOrderVo {
|
||||
@ExcelProperty(value = "上级部件图号")
|
||||
private String parentDrawingNo;
|
||||
|
||||
/**
|
||||
* 主产品图号
|
||||
*/
|
||||
@ExcelProperty(value = "主产品图号")
|
||||
private String mainProducts;
|
||||
|
||||
/**
|
||||
* 主产品名称
|
||||
*/
|
||||
@ExcelProperty(value = "主产品名称")
|
||||
private String mainProductsName;
|
||||
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -27,6 +28,8 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class PDFGenerator {
|
||||
|
||||
@ -36,8 +39,8 @@ public class PDFGenerator {
|
||||
|
||||
// 绘制表格行的方法
|
||||
private static void drawTableRow(PDPageContentStream contentStream, PDType0Font font, float margin, float yStart,
|
||||
float tableWidth, float[] colWidths, String[] cells, PDDocument document,
|
||||
PDPage page, float rowHeight, float pageHeight) throws IOException {
|
||||
float tableWidth, float[] colWidths, String[] cells, PDDocument document,
|
||||
PDPage page, float rowHeight, float pageHeight) throws IOException {
|
||||
float nextX = margin;
|
||||
float nextY = yStart;
|
||||
|
||||
@ -75,7 +78,8 @@ public class PDFGenerator {
|
||||
}
|
||||
|
||||
// 生成二维码
|
||||
private static PDImageXObject generateQRCode(PDDocument document, String text, int width, int height) throws WriterException, IOException {
|
||||
private static PDImageXObject generateQRCode(PDDocument document, String text, int width, int height)
|
||||
throws WriterException, IOException {
|
||||
QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
||||
BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height);
|
||||
|
||||
@ -90,166 +94,278 @@ public class PDFGenerator {
|
||||
return LosslessFactory.createFromImage(document, bufferedImage);
|
||||
}
|
||||
|
||||
|
||||
public static void writeToPdf(List<CombinedDTO> combinedVoList, String rooteProdet) {
|
||||
public static String writeToPdf(List<CombinedDTO> combinedVoList, String rooteProdet) {
|
||||
String fontPath = "C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\Windows\\Fonts\\arial unicode ms.ttf";
|
||||
List<String> pdfPaths = new ArrayList<>();
|
||||
String directoryPath = "C:\\Users\\Administrator\\Desktop\\上传BOM\\" + rooteProdet;
|
||||
|
||||
for (CombinedDTO combinedVo : combinedVoList) {
|
||||
// 获取物料编码
|
||||
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();
|
||||
String materialCode = String.valueOf(combinedVo.getMaterialUsageDTOList().get(0).getBillNumber());
|
||||
String pdfFileName = fProcessName + "_" + materialCode1.replace("/", "_") + ".pdf";
|
||||
|
||||
File existingFile = findFileWithMaterialCode(directoryPath, materialCode1);
|
||||
String pdfPath;
|
||||
|
||||
// 生成 PDF 文件路径
|
||||
if (existingFile == null) {
|
||||
System.out.println("未找到物料编码对应的PDF文件: " + materialCode + "。将单独生成新PDF。");
|
||||
pdfPath = directoryPath + "\\" + pdfFileName;
|
||||
} else {
|
||||
pdfPath = directoryPath + "\\" + fProcessName + "_" + materialCode1.replace("/", "_") + "_generated.pdf";
|
||||
// 检查目录是否存在,如果不存在则创建
|
||||
File directory = new File(directoryPath);
|
||||
if (!directory.exists()) {
|
||||
boolean isCreated = directory.mkdirs();
|
||||
if (!isCreated) {
|
||||
throw new RuntimeException("无法创建目录: " + directoryPath);
|
||||
}
|
||||
|
||||
try {
|
||||
// 创建 PDF 文件并写入内容
|
||||
PDDocument document = new PDDocument();
|
||||
PDPage page = new PDPage();
|
||||
document.addPage(page);
|
||||
PDType0Font font;
|
||||
try {
|
||||
font = PDType0Font.load(document, new File(fontPath));
|
||||
} catch (IllegalArgumentException e) {
|
||||
System.err.println("Font file not found: " + fontPath);
|
||||
throw new RuntimeException("Font file not found", e);
|
||||
}
|
||||
|
||||
PDPageContentStream contentStream = new PDPageContentStream(document, page);
|
||||
|
||||
float margin = 15;
|
||||
float yStart = 740;
|
||||
float rowHeight = 20f;
|
||||
float pageHeight = page.getMediaBox().getHeight();
|
||||
float tableWidth = page.getMediaBox().getWidth() - 2 * margin;
|
||||
|
||||
// 添加标题和右上角的二维码
|
||||
contentStream.beginText();
|
||||
contentStream.setFont(font, 14);
|
||||
contentStream.newLineAtOffset(220, 780);
|
||||
contentStream.showText("工序计划单");
|
||||
contentStream.endText();
|
||||
|
||||
PDImageXObject qrCode1 = generateQRCode(document, productionOrderNumber, 90, 90);
|
||||
contentStream.drawImage(qrCode1, page.getMediaBox().getWidth() - 110, 710);
|
||||
SimpleDateFormat formatte11r = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// 绘制生产订单信息表格
|
||||
float[] colWidths = {60, 95, 110, 110, 60, 60, 55};
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, colWidths, new String[]{"生产令号", rooteProdet,
|
||||
"开始时间", formatte11r.format(starttime), "结束时间", formatte11r.format(endtime)}, document, page, rowHeight, pageHeight);
|
||||
|
||||
yStart -= rowHeight;
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, colWidths, new String[]{"单据编号", "生产订单编号", "产品名称", "产品编码", "数量", "生产车间", "次数"}, document, page, rowHeight, pageHeight);
|
||||
|
||||
yStart -= rowHeight;
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, colWidths, new String[]{
|
||||
productionOrderNumber,combinedVo.getOrderNumber(), combinedVo.getMaterialName(), combinedVo.getMaterialCode(),
|
||||
String.valueOf(combinedVo.getProcesses().get(0).getFMOQty()), combinedVo.getProcesses().get(0).getFDepartmentName(), "1", ""}, document, page, rowHeight, pageHeight);
|
||||
|
||||
// 绘制工序表格
|
||||
float processTableStartY = yStart - 2 * rowHeight - 10;
|
||||
float[] processColWidths = {35, 78, 35, 55, 45, 170, 55, 60, 60};
|
||||
yStart = processTableStartY;
|
||||
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, processColWidths, new String[]{
|
||||
"工序号", "工序名称", "数量", "工作中心", "工时(分)", "工序说明", "控制码", "开始时间", "结束时间"}, document, page, rowHeight, pageHeight);
|
||||
|
||||
for (PlannedProcessVo process : combinedVo.getProcesses()) {
|
||||
SimpleDateFormat formatte1r = new SimpleDateFormat("yyyy-MM-dd");
|
||||
yStart -= rowHeight;
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, processColWidths, new String[]{
|
||||
String.valueOf(process.getFOperNumber()), process.getFProcessName(), String.valueOf(process.getFOperQty()),
|
||||
process.getFWorkCenterName(), String.format("%.2f", process.getFActivity1BaseQty()), process.getFOperDescription(),
|
||||
process.getFOptCtrlCodeIFName(),
|
||||
process.getFSeqPlanStartTime() != null ? formatte1r.format(process.getFSeqPlanStartTime()) : "",
|
||||
process.getFSeqPlanFinishTime() != null ? (formatte1r.format(process.getFSeqPlanFinishTime())) : ""
|
||||
}, document, page, rowHeight, pageHeight);
|
||||
}
|
||||
|
||||
// 添加生产用料清单标题
|
||||
float materialListStartY = yStart - 2 * rowHeight - 40;
|
||||
yStart = materialListStartY;
|
||||
|
||||
contentStream.beginText();
|
||||
contentStream.setFont(font, 12);
|
||||
contentStream.newLineAtOffset(margin, yStart);
|
||||
contentStream.showText("生产用料清单:");
|
||||
contentStream.showText(materialCode);
|
||||
contentStream.endText();
|
||||
|
||||
// 在用料清单标题右侧添加二维码,与右上角二维码对齐
|
||||
PDImageXObject qrCode2 = generateQRCode(document, materialCode, 90, 90);
|
||||
contentStream.drawImage(qrCode2, page.getMediaBox().getWidth() - 110, yStart - 31);
|
||||
|
||||
yStart -= rowHeight;
|
||||
|
||||
// 用料清单表头
|
||||
float[] materialColWidths = {25, 130, 110, 50, 35, 40, 40, 80, 50};
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, materialColWidths, new String[]{
|
||||
"序号", "物料编码", "物料名称", "规格型号", "单位", "应发数", "已领数", "仓库", "备注"
|
||||
}, document, page, rowHeight, pageHeight);
|
||||
|
||||
List<MaterialUsageDTO> materialUsageDTOList = combinedVo.getMaterialUsageDTOList();
|
||||
if (materialUsageDTOList != null && !materialUsageDTOList.isEmpty()) {
|
||||
for (int i = 0; i < materialUsageDTOList.size(); i++) {
|
||||
yStart -= rowHeight;
|
||||
|
||||
// 如果空间不足,则新建页面
|
||||
if (yStart - rowHeight < margin) {
|
||||
contentStream.close();
|
||||
page = new PDPage();
|
||||
document.addPage(page);
|
||||
contentStream = new PDPageContentStream(document, page);
|
||||
yStart = pageHeight - margin;
|
||||
|
||||
// 绘制用料清单表头
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, materialColWidths, new String[]{
|
||||
"序号", "物料编码", "物料名称", "规格型号", "单位", "应发数", "已领数", "仓库", "备注"
|
||||
}, document, page, rowHeight, pageHeight);
|
||||
yStart -= rowHeight;
|
||||
}
|
||||
|
||||
MaterialUsageDTO material = materialUsageDTOList.get(i);
|
||||
SimpleDateFormat formatte1r = new SimpleDateFormat("yyyy-MM-dd");
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, materialColWidths, new String[]{
|
||||
String.valueOf(i + 1), material.getMaterialCode(), material.getMaterialName(),
|
||||
material.getSpecification(), material.getUnit(),
|
||||
String.valueOf(material.getRequiredQty()), String.valueOf(material.getPickedQty()),
|
||||
|
||||
material.getStockName(), material.getRemarks() != null ? material.getRemarks() : ""
|
||||
}, document, page, rowHeight, pageHeight);
|
||||
} else {
|
||||
// 如果目录存在,删除其中的所有文件
|
||||
File[] files = directory.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (!file.delete()) {
|
||||
System.err.println("无法删除文件: " + file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contentStream.close();
|
||||
document.save(pdfPath);
|
||||
System.out.println("PDF 生成成功: " + pdfPath);
|
||||
|
||||
// 如果需要合并 PDF 文件
|
||||
if (existingFile != null) {
|
||||
mergePdfToExisting(pdfPath, existingFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
for (CombinedDTO combinedVo : combinedVoList) {
|
||||
if (!combinedVoList.isEmpty()) {
|
||||
// 获取物料编码
|
||||
String materialCode1 = combinedVo.getMaterialCode();
|
||||
String fProcessName;
|
||||
String productionOrderNumber;
|
||||
Date starttime;
|
||||
Date endtime;
|
||||
String materialCode;
|
||||
Long fmoQty;
|
||||
String fDepartmentName;
|
||||
// 获取第一序的工序名称
|
||||
List<PlannedProcessVo> processes = combinedVo.getProcesses();
|
||||
if (!processes.isEmpty()) {
|
||||
fProcessName = processes.get(0).getFProcessName();
|
||||
productionOrderNumber = String.valueOf(combinedVo.getProcesses().get(0).getFBillNo());
|
||||
starttime = combinedVo.getProcesses().get(0).getFPlanStartTime();
|
||||
endtime = combinedVo.getProcesses().get(0).getFPlanFinishTime();
|
||||
materialCode = String.valueOf(combinedVo.getMaterialUsageDTOList().get(0).getBillNumber());
|
||||
fmoQty = combinedVo.getProcesses().get(0).getFMOQty();
|
||||
fDepartmentName = combinedVo.getProcesses().get(0).getFDepartmentName();
|
||||
// 其他代码...
|
||||
} else {
|
||||
// 处理列表为空的情况
|
||||
fProcessName = "A";
|
||||
productionOrderNumber = "A";
|
||||
starttime = new Date();
|
||||
endtime = new Date();
|
||||
materialCode = "0";
|
||||
fmoQty = 0L;
|
||||
fDepartmentName = "";
|
||||
}
|
||||
|
||||
// 在生成并合并 PDF 后,调用重命名和移动文件的方法
|
||||
processMergedPdfFiles(directoryPath, combinedVo);
|
||||
} catch (IOException | WriterException e) {
|
||||
e.printStackTrace();
|
||||
String pdfFileName = fProcessName + "_" + materialCode1.replace("/", "_") + "_独立" + ".pdf";
|
||||
|
||||
File existingFile = findFileWithMaterialCode(directoryPath, materialCode1);
|
||||
String pdfPath;
|
||||
|
||||
// 生成 PDF 文件路径
|
||||
if (existingFile == null) {
|
||||
System.out.println("未找到物料编码对应的PDF文件: " + materialCode + "。将单独生成新PDF。");
|
||||
pdfPath = directoryPath + "\\" + pdfFileName;
|
||||
} else {
|
||||
pdfPath = directoryPath + "\\" + fProcessName + "_" + materialCode1.replace("/", "_")
|
||||
+ "_generated.pdf";
|
||||
}
|
||||
|
||||
try {
|
||||
// 创建 PDF 文件并写入内容
|
||||
PDDocument document = new PDDocument();
|
||||
PDPage page = new PDPage();
|
||||
document.addPage(page);
|
||||
PDType0Font font = PDType0Font.load(document, new File(fontPath));
|
||||
|
||||
try {
|
||||
font = PDType0Font.load(document, new File(fontPath));
|
||||
} catch (IllegalArgumentException e) {
|
||||
System.err.println("Font file not found: " + fontPath);
|
||||
throw new RuntimeException("Font file not found", e);
|
||||
}
|
||||
|
||||
PDPageContentStream contentStream = new PDPageContentStream(document, page);
|
||||
|
||||
float margin = 15;
|
||||
float yStart = 740;
|
||||
float rowHeight = 20f;
|
||||
float pageHeight = page.getMediaBox().getHeight();
|
||||
float tableWidth = page.getMediaBox().getWidth() - 2 * margin;
|
||||
|
||||
// 添加标题和右上角的二维码
|
||||
contentStream.beginText();
|
||||
contentStream.setFont(font, 14);
|
||||
contentStream.newLineAtOffset(220, 780);
|
||||
contentStream.showText("工序计划单");
|
||||
contentStream.endText();
|
||||
|
||||
PDImageXObject qrCode1 = generateQRCode(document, productionOrderNumber, 90, 90);
|
||||
contentStream.drawImage(qrCode1, page.getMediaBox().getWidth() - 110, 710);
|
||||
SimpleDateFormat formatte11r = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// 绘制生产订单信息表格
|
||||
float[] colWidths = { 60, 95, 110, 110, 60, 60, 55 };
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, colWidths,
|
||||
new String[] { "生产令号", rooteProdet,
|
||||
"开始时间", formatte11r.format(starttime), "结束时间", formatte11r.format(endtime) },
|
||||
document, page, rowHeight, pageHeight);
|
||||
|
||||
yStart -= rowHeight;
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, colWidths,
|
||||
new String[] { "单据编号", "生产订单编号", "产品名称", "产品编码", "数量", "生产车间", "次数" }, document, page,
|
||||
rowHeight, pageHeight);
|
||||
|
||||
yStart -= rowHeight;
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, colWidths, new String[] {
|
||||
productionOrderNumber, combinedVo.getOrderNumber(), combinedVo.getMaterialName(),
|
||||
combinedVo.getMaterialCode(),
|
||||
String.valueOf(fmoQty), fDepartmentName, "1", "" }, document, page, rowHeight, pageHeight);
|
||||
|
||||
// 绘制工序表格
|
||||
float processTableStartY = yStart - 2 * rowHeight - 10;
|
||||
float[] processColWidths = { 35, 78, 35, 55, 45, 170, 55, 60, 60 };
|
||||
yStart = processTableStartY;
|
||||
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, processColWidths, new String[] {
|
||||
"工序号", "工序名称", "数量", "工作中心", "工时(分)", "工序说明", "控制码", "开始时间", "结束时间" }, document, page,
|
||||
rowHeight, pageHeight);
|
||||
|
||||
for (PlannedProcessVo process : combinedVo.getProcesses()) {
|
||||
SimpleDateFormat formatte1r = new SimpleDateFormat("yyyy-MM-dd");
|
||||
yStart -= rowHeight;
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, processColWidths, new String[] {
|
||||
String.valueOf(process.getFOperNumber()), process.getFProcessName(),
|
||||
String.valueOf(process.getFOperQty()),
|
||||
process.getFWorkCenterName(), String.format("%.2f", process.getFActivity1BaseQty()),
|
||||
process.getFOperDescription(),
|
||||
process.getFOptCtrlCodeIFName(),
|
||||
process.getFSeqPlanStartTime() != null
|
||||
? formatte1r.format(process.getFSeqPlanStartTime())
|
||||
: "",
|
||||
process.getFSeqPlanFinishTime() != null
|
||||
? (formatte1r.format(process.getFSeqPlanFinishTime()))
|
||||
: ""
|
||||
}, document, page, rowHeight, pageHeight);
|
||||
}
|
||||
|
||||
// 添加生产用料清单标题
|
||||
yStart = yStart - 2 * rowHeight - 40;
|
||||
|
||||
contentStream.beginText();
|
||||
contentStream.setFont(font, 12);
|
||||
contentStream.newLineAtOffset(margin, yStart);
|
||||
contentStream.showText("生产用料清单:");
|
||||
contentStream.showText(materialCode);
|
||||
contentStream.endText();
|
||||
|
||||
// 在用料清单标题右侧添加二维码,与右上角二维码对齐
|
||||
PDImageXObject qrCode2 = generateQRCode(document, materialCode, 90, 90);
|
||||
contentStream.drawImage(qrCode2, page.getMediaBox().getWidth() - 110, yStart - 31);
|
||||
|
||||
yStart -= rowHeight;
|
||||
|
||||
// 用料清单表头
|
||||
float[] materialColWidths = { 25, 130, 110, 50, 35, 40, 40, 80, 50 };
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, materialColWidths, new String[] {
|
||||
"序号", "物料编码", "物料名称", "规格型号", "单位", "应发数", "已领数", "仓库", "备注"
|
||||
}, document, page, rowHeight, pageHeight);
|
||||
|
||||
List<MaterialUsageDTO> materialUsageDTOList = combinedVo.getMaterialUsageDTOList();
|
||||
if (materialUsageDTOList != null && !materialUsageDTOList.isEmpty()) {
|
||||
for (int i = 0; i < materialUsageDTOList.size(); i++) {
|
||||
yStart -= rowHeight;
|
||||
|
||||
// 如果空间不足,则新建页面
|
||||
if (yStart - rowHeight < margin) {
|
||||
contentStream.close();
|
||||
page = new PDPage();
|
||||
document.addPage(page);
|
||||
contentStream = new PDPageContentStream(document, page);
|
||||
yStart = pageHeight - margin;
|
||||
|
||||
// 绘制用料清单表头
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, materialColWidths,
|
||||
new String[] {
|
||||
"序号", "物料编码", "物料名称", "规格型号", "单位", "应发数", "已领数", "仓库", "备注"
|
||||
}, document, page, rowHeight, pageHeight);
|
||||
yStart -= rowHeight;
|
||||
}
|
||||
|
||||
MaterialUsageDTO material = materialUsageDTOList.get(i);
|
||||
SimpleDateFormat formatte1r = new SimpleDateFormat("yyyy-MM-dd");
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, materialColWidths,
|
||||
new String[] {
|
||||
String.valueOf(i + 1), material.getMaterialCode(),
|
||||
material.getMaterialName(),
|
||||
material.getSpecification(), material.getUnit(),
|
||||
String.valueOf(material.getRequiredQty()),
|
||||
String.valueOf(material.getPickedQty()),
|
||||
|
||||
material.getStockName(),
|
||||
material.getRemarks() != null ? material.getRemarks() : ""
|
||||
}, document, page, rowHeight, pageHeight);
|
||||
}
|
||||
}
|
||||
|
||||
contentStream.close();
|
||||
document.save(pdfPath);
|
||||
pdfPaths.add(pdfPath);
|
||||
System.out.println("PDF 生成成功: " + pdfPath);
|
||||
|
||||
// 如果需要合并 PDF 文件
|
||||
if (existingFile != null) {
|
||||
mergePdfToExisting(pdfPath, existingFile.getAbsolutePath());
|
||||
pdfPaths.add(existingFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
// 在生成并合并 PDF 后,调用重命名和移动文件的方法
|
||||
processMergedPdfFiles(directoryPath, combinedVo);
|
||||
} catch (IOException | WriterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 生成ZIP文件
|
||||
String zipFilePath = directoryPath + "\\" + rooteProdet + "_工序计划单.zip";
|
||||
try {
|
||||
createZipFile(pdfPaths, zipFilePath);
|
||||
System.out.println("ZIP 文件生成成功: " + zipFilePath);
|
||||
return zipFilePath;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("ZIP 文件生成失败: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建ZIP文件
|
||||
*
|
||||
* @param sourceFilePaths PDF文件路径列表
|
||||
* @param zipFilePath 目标ZIP文件路径
|
||||
*/
|
||||
private static void createZipFile(List<String> sourceFilePaths, String zipFilePath) throws IOException {
|
||||
// 确保目标目录存在
|
||||
File zipFile = new File(zipFilePath);
|
||||
if (!zipFile.getParentFile().exists()) {
|
||||
zipFile.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
try (ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFilePath))) {
|
||||
// 设置压缩级别
|
||||
zipOut.setLevel(ZipOutputStream.DEFLATED);
|
||||
|
||||
for (String filePath : sourceFilePaths) {
|
||||
File fileToZip = new File(filePath);
|
||||
if (fileToZip.exists()) {
|
||||
try (FileInputStream fis = new FileInputStream(fileToZip)) {
|
||||
// 创建ZIP条目
|
||||
ZipEntry zipEntry = new ZipEntry(fileToZip.getName());
|
||||
zipOut.putNextEntry(zipEntry);
|
||||
|
||||
// 写入文件内容
|
||||
byte[] bytes = new byte[1024];
|
||||
int length;
|
||||
while ((length = fis.read(bytes)) >= 0) {
|
||||
zipOut.write(bytes, 0, length);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.err.println("文件不存在: " + filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,7 +385,7 @@ public class PDFGenerator {
|
||||
// 合并PDF,将生成的PDF插入到已有PDF的末尾
|
||||
public static void mergePdfToExisting(String generatedPdfPath, String existingPdfPath) throws IOException {
|
||||
try (PDDocument existingDoc = PDDocument.load(new File(existingPdfPath));
|
||||
PDDocument generatedDoc = PDDocument.load(new File(generatedPdfPath))) {
|
||||
PDDocument generatedDoc = PDDocument.load(new File(generatedPdfPath))) {
|
||||
|
||||
PDFMergerUtility merger = new PDFMergerUtility();
|
||||
merger.appendDocument(existingDoc, generatedDoc);
|
||||
@ -283,10 +399,36 @@ public class PDFGenerator {
|
||||
}
|
||||
|
||||
public static void processMergedPdfFiles(String directoryPath, CombinedDTO combinedVo) {
|
||||
String fProcessName;
|
||||
String productionOrderNumber;
|
||||
Date starttime;
|
||||
Date endtime;
|
||||
String materialCode1;
|
||||
Long fmoQty;
|
||||
String fDepartmentName;
|
||||
// 获取第一序的工序名称
|
||||
List<PlannedProcessVo> processes = combinedVo.getProcesses();
|
||||
if (!processes.isEmpty()) {
|
||||
fProcessName = processes.get(0).getFProcessName();
|
||||
productionOrderNumber = String.valueOf(combinedVo.getProcesses().get(0).getFBillNo());
|
||||
starttime = combinedVo.getProcesses().get(0).getFPlanStartTime();
|
||||
endtime = combinedVo.getProcesses().get(0).getFPlanFinishTime();
|
||||
materialCode1 = String.valueOf(combinedVo.getMaterialUsageDTOList().get(0).getBillNumber());
|
||||
fmoQty = combinedVo.getProcesses().get(0).getFMOQty();
|
||||
fDepartmentName = combinedVo.getProcesses().get(0).getFDepartmentName();
|
||||
// 其他代码...
|
||||
} else {
|
||||
// 处理列表为空的情况
|
||||
fProcessName = "A";
|
||||
productionOrderNumber = "A";
|
||||
starttime = new Date();
|
||||
endtime = new Date();
|
||||
materialCode1 = "0";
|
||||
fmoQty = 0L;
|
||||
fDepartmentName = "";
|
||||
}
|
||||
|
||||
// 获取图号和工序名称
|
||||
String materialCode1 = combinedVo.getMaterialCode(); // 图号
|
||||
String fProcessName = combinedVo.getProcesses().get(0).getFProcessName(); // 首序名称
|
||||
String departmentName = combinedVo.getProcesses().get(0).getFDepartmentName(); // 车间名称
|
||||
|
||||
// 找到已合并的文件路径
|
||||
String originalPdfFileName = materialCode1.replace("/", "_") + ".pdf"; // 原始PDF文件名
|
||||
@ -298,7 +440,7 @@ public class PDFGenerator {
|
||||
String newPdfFilePath = directoryPath + "\\" + newPdfFileName;
|
||||
|
||||
// 创建车间文件夹路径
|
||||
File departmentFolder = new File(directoryPath + "\\" + departmentName);
|
||||
File departmentFolder = new File(directoryPath + "\\" + fDepartmentName);
|
||||
if (!departmentFolder.exists()) {
|
||||
departmentFolder.mkdirs(); // 创建车间文件夹
|
||||
}
|
||||
@ -312,7 +454,7 @@ public class PDFGenerator {
|
||||
File sourceFile = new File(sourcePath);
|
||||
File targetFile = new File(departmentFolder, targetPath);
|
||||
|
||||
// 检查目标文件夹是否存在,不存在则创建
|
||||
// 检查目<EFBFBD><EFBFBD><EFBFBD>文件夹是否存在,不存在则创建
|
||||
if (!departmentFolder.exists()) {
|
||||
departmentFolder.mkdirs(); // 创建车间文件夹
|
||||
}
|
||||
@ -339,5 +481,4 @@ public class PDFGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -7,6 +7,8 @@ import com.ruoyi.system.domain.MaterialBom;
|
||||
import com.ruoyi.system.domain.ProcessRoute;
|
||||
import com.ruoyi.system.domain.bo.ProcessRouteBo;
|
||||
import com.ruoyi.system.domain.dto.CombinedDTO;
|
||||
import com.ruoyi.system.domain.dto.ProcessRoutePushResultDTO;
|
||||
import com.ruoyi.system.domain.dto.ProcessRouteSelectDTO;
|
||||
import com.ruoyi.system.jdmain.rouplan.Model;
|
||||
import com.ruoyi.system.domain.dto.ProcessRouteXuDTO;
|
||||
import com.ruoyi.system.domain.vo.ProcessRouteVo;
|
||||
@ -70,14 +72,14 @@ public interface IProcessRouteService {
|
||||
*/
|
||||
List<ProcessRouteXuDTO> getProcessRoute(String rooteProdet);
|
||||
|
||||
List<ProcessRouteXuDTO> pushRouteBom(String rooteProdet);
|
||||
ProcessRoutePushResultDTO pushRouteBom(String rooteProdet);
|
||||
|
||||
List<CombinedDTO> getSelecPlanRouteList(String rooteProdet);
|
||||
|
||||
/**
|
||||
* 生成这个项目的pdf
|
||||
*/
|
||||
List<CombinedDTO> generatePDFs(String rooteProdet);
|
||||
String generatePDFs(String rooteProdet);
|
||||
|
||||
List<Model> updateProcessPlan(String rooteProdet);
|
||||
|
||||
@ -92,4 +94,6 @@ public interface IProcessRouteService {
|
||||
List<ProcessRoute> importDataTime(List<ProcessRouteVo> list);
|
||||
|
||||
boolean isAnTuDingGou(String materialCode);
|
||||
|
||||
List<ProcessRouteSelectDTO> getSelectProcessRoute(String materilCode);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class BomDetailsServiceImpl implements IBomDetailsService {
|
||||
lqw.like(StringUtils.isNotBlank(bo.getName()), BomDetails::getName, bo.getName());
|
||||
lqw.eq(bo.getQuantity() != null, BomDetails::getQuantity, bo.getQuantity());
|
||||
lqw.eq(bo.getDenominator() != null, BomDetails::getDenominator, bo.getDenominator());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFNumber()), BomDetails::getFNumber, bo.getFNumber());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getFNumber()), BomDetails::getFNumber, bo.getFNumber());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterial()), BomDetails::getMaterial, bo.getMaterial());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUnitWeight()), BomDetails::getUnitWeight, bo.getUnitWeight());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getTotalWeight()), BomDetails::getTotalWeight, bo.getTotalWeight());
|
||||
|
||||
@ -181,10 +181,8 @@ public class ImMaterialServiceImpl implements IImMaterialService {
|
||||
}
|
||||
// 调用库存查询方法,优化为批量查询而非逐个查询
|
||||
Map<String, JsonObject> jsonMap = queryAllKuCun(result.getRecords());
|
||||
if (jsonMap != null) {
|
||||
// 更新库存信息
|
||||
updateRecordsWithKuCunInfo(jsonMap, result.getRecords());
|
||||
}
|
||||
// 更新库存信息
|
||||
updateRecordsWithKuCunInfo(jsonMap, result.getRecords());
|
||||
// 更新数量,更新实体类
|
||||
|
||||
result.setRecords(result.getRecords()); // 更新结果集
|
||||
@ -298,6 +296,13 @@ public class ImMaterialServiceImpl implements IImMaterialService {
|
||||
if (unitElement != null && !unitElement.isJsonNull()){
|
||||
record.setUnit(unitElement.getAsString());
|
||||
}
|
||||
String unit = jsonObject.get("FStockUnitId.FName").getAsString();
|
||||
if (unit != null && !unit.isEmpty()) {
|
||||
record.setClassificationName(unit);
|
||||
}else {
|
||||
record.setClassificationName("件");
|
||||
}
|
||||
|
||||
JsonElement qualityElement = jsonObject.get("F_UCHN_BaseProperty");
|
||||
if (qualityElement != null && !qualityElement.isJsonNull()) {
|
||||
record.setMaterialQuality(qualityElement.getAsString());
|
||||
@ -350,7 +355,7 @@ public class ImMaterialServiceImpl implements IImMaterialService {
|
||||
lqw.like(StringUtils.isNotBlank(bo.getClassificationName()), ImMaterial::getClassificationName, bo.getClassificationName());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getImCategory()), ImMaterial::getImCategory, bo.getImCategory());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getMaterialQuality()), ImMaterial::getMaterialQuality, bo.getMaterialQuality());
|
||||
lqw.like(bo.getSingleWeight() != null, ImMaterial::getSingleWeight, bo.getSingleWeight());
|
||||
lqw.eq(bo.getSingleWeight() != null, ImMaterial::getSingleWeight, bo.getSingleWeight());
|
||||
lqw.like(bo.getUnitPrice() != null, ImMaterial::getUnitPrice, bo.getUnitPrice());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getUnit()), ImMaterial::getUnit, bo.getUnit());
|
||||
lqw.like(bo.getFlag() != null, ImMaterial::getFlag, bo.getFlag());
|
||||
@ -696,6 +701,7 @@ public class ImMaterialServiceImpl implements IImMaterialService {
|
||||
String fCategoryID = jsonObject.getStr("FCategoryID.FNumber");
|
||||
String fAssistant = jsonObject.getStr("F.SVRI.Assistant.FNumber");
|
||||
String fErpClsID = jsonObject.getStr("FErpClsID");
|
||||
String unit = jsonObject.getStr("FBaseUnitId.FName");
|
||||
|
||||
String property = MaterialProperties.getMaterialProperty(fAssistant);
|
||||
String fErpClsID1 = MaterialProperties.getItemAttributesMap(fErpClsID);
|
||||
@ -706,7 +712,7 @@ public class ImMaterialServiceImpl implements IImMaterialService {
|
||||
imMaterial.setClassificationNumber(fErpClsID1);
|
||||
imMaterial.setImCategory(getCategory(fCategoryID));
|
||||
imMaterial.setMaterialQuality(property);
|
||||
|
||||
imMaterial.setClassificationName(unit);
|
||||
ImMaterial existingMaterial = existingMaterialsMap.get(fNumber);
|
||||
if (existingMaterial != null) {
|
||||
logger.info("更新物料==> " + existingMaterial.getMaterialCode() + " 物料名称==> " + existingMaterial.getMaterialName());
|
||||
|
||||
@ -109,7 +109,7 @@ public class MaterialBomServiceImpl implements IMaterialBomService {
|
||||
// 更新原材料相关信息
|
||||
processRoute.setRawMaterialCode(bo.getMaterialCode()); // BOM物料编码
|
||||
processRoute.setRawMaterialName(bo.getMaterialName()); // BOM物料名称
|
||||
processRoute.setDiscUsage(bo.getQuantity()); // 用量
|
||||
processRoute.setDiscUsage(Double.valueOf(bo.getQuantity())); // 用量
|
||||
processRoute.setBomUnit(bo.getUnit()); // 单位
|
||||
processRoute.setBomMaterial(bo.getMaterialType());
|
||||
// 更新工艺路线
|
||||
@ -144,7 +144,7 @@ public class MaterialBomServiceImpl implements IMaterialBomService {
|
||||
bomDetails.setName(bo.getMaterialName());
|
||||
bomDetails.setName(bo.getMaterialName());
|
||||
bomDetails.setDenominator(1.0);
|
||||
bomDetails.setQuantity(bo.getQuantity());
|
||||
bomDetails.setQuantity(Double.valueOf(bo.getQuantity()));
|
||||
bomDetails.setStats("外购");
|
||||
bomDetails.setMaterial(bo.getMaterialType());
|
||||
int flag = bomDetailsMapper.insert(bomDetails);
|
||||
@ -160,6 +160,31 @@ public class MaterialBomServiceImpl implements IMaterialBomService {
|
||||
@Override
|
||||
public Boolean updateByBo(MaterialBomBo bo) {
|
||||
MaterialBom update = BeanUtil.toBean(bo, MaterialBom.class);
|
||||
|
||||
// 2. 查找对应的工艺路线
|
||||
LambdaQueryWrapper<ProcessRoute> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProcessRoute::getRouteDescription, bo.getProjectNumber())
|
||||
.eq(ProcessRoute::getProcessNo, "10") // 使用父级物料编码
|
||||
.eq(ProcessRoute::getMaterialCode, bo.getParentMaterialCode()) // 使用父级物料编码
|
||||
.eq(ProcessRoute::getMaterialName, bo.getParentMaterialName()); // 使用父级物料名称
|
||||
|
||||
ProcessRoute processRoute = processRouteMapper.selectOne(wrapper);
|
||||
// 3. 如果找到对应的工艺路线,更新相关字段
|
||||
if (processRoute != null) {
|
||||
processRoute.setId(processRoute.getId());
|
||||
// 更新原材料相关信息
|
||||
processRoute.setRawMaterialCode(bo.getMaterialCode()); // BOM物料编码
|
||||
processRoute.setRawMaterialName(bo.getMaterialName()); // BOM物料名称
|
||||
processRoute.setDiscUsage(Double.valueOf(bo.getQuantity())); // 用量
|
||||
processRoute.setBomUnit(bo.getUnit()); // 单位
|
||||
processRoute.setBomMaterial(bo.getMaterialType());
|
||||
// 更新工艺路线
|
||||
int updateResult = processRouteMapper.updateById(processRoute);
|
||||
if (updateResult <= 0) {
|
||||
throw new ServiceException("更新工艺路线失败");
|
||||
}
|
||||
}
|
||||
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
@ -201,7 +226,7 @@ public class MaterialBomServiceImpl implements IMaterialBomService {
|
||||
materialBomBo.setProjectNumber(bo.getProcessDescription());
|
||||
materialBomBo.setParentMaterialCode(bo.getMaterialCode());
|
||||
materialBomBo.setParentMaterialName(bo.getMaterialName());
|
||||
materialBomBo.setQuantity(bo.getDiscUsage());
|
||||
materialBomBo.setQuantity(String.valueOf(bo.getDiscUsage()));
|
||||
materialBomBo.setUnit(bo.getBomUnit());
|
||||
materialBomBo.setMaterialType(bo.getBomMaterial());
|
||||
materialBomBo.setMaterialCode(bo.getRawMaterialCode());
|
||||
|
||||
@ -70,7 +70,8 @@ public class ProcessOrderProServiceImpl implements IProcessOrderProService {
|
||||
lqw.like(StringUtils.isNotBlank(bo.getProductionName()), ProcessOrderPro::getProductionName, bo.getProductionName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDrawingNo()), ProcessOrderPro::getDrawingNo, bo.getDrawingNo());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDrawingName()), ProcessOrderPro::getDrawingName, bo.getDrawingName());
|
||||
|
||||
//按照创建时间排序,最新的在顶端
|
||||
lqw.orderByDesc(true,ProcessOrderPro::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@ -110,6 +111,12 @@ public class ProcessOrderProServiceImpl implements IProcessOrderProService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
for (Long id : ids) {
|
||||
ProcessOrderProVo processOrderProVo = baseMapper.selectVoById(id);
|
||||
String productionOrderNo = processOrderProVo.getProductionOrderNo();
|
||||
String materialCode = processOrderProVo.getDrawingNo();
|
||||
|
||||
}
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user