工艺模块,相关接口,相关工艺校验,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);
|
||||
|
||||
@ -308,8 +308,10 @@ public class BomDetailsController extends BaseController {
|
||||
// 获取单元格的值,假设它是字符串类型
|
||||
return chenpin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性 替换成金蝶属性编码
|
||||
*
|
||||
* @param stats
|
||||
* @return
|
||||
*/
|
||||
@ -373,6 +375,8 @@ 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);
|
||||
@ -382,6 +386,121 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@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
|
||||
物料清单保存方法
|
||||
*/
|
||||
@ -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");
|
||||
@ -998,6 +1123,7 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*FB父级物料保存接口
|
||||
单位 是台
|
||||
* */
|
||||
@ -1163,9 +1289,11 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 物料验证
|
||||
* 验证物料在金蝶中是否存在
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int isMaterialVerification(String DrawingNumber, String name) {
|
||||
@ -1347,7 +1475,6 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 创建SubHeadEntity5对象,并加入Model
|
||||
JsonObject subHeadEntity5 = new JsonObject();
|
||||
model.add("SubHeadEntity5", subHeadEntity5);
|
||||
@ -1407,6 +1534,7 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//创建电气物料
|
||||
public int loadMaterialToDQ(BomDetails bomDetails1, String states) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
@ -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 "卷":
|
||||
@ -1686,7 +1817,6 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 创建SubHeadEntity5对象,并加入Model
|
||||
JsonObject subHeadEntity5 = new JsonObject();
|
||||
model.add("SubHeadEntity5", subHeadEntity5);
|
||||
@ -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 "卷":
|
||||
|
||||
@ -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
|
||||
@ -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) {
|
||||
@ -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("上传物料成功");
|
||||
@ -241,7 +251,6 @@ public class ProcessRouteController extends BaseController {
|
||||
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,9 +291,29 @@ 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 = "更新计划时间")
|
||||
@ -292,10 +322,11 @@ public class ProcessRouteController extends BaseController {
|
||||
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")
|
||||
@ -304,7 +335,7 @@ public class ProcessRouteController extends BaseController {
|
||||
return iProcessRouteService.addRoute(list);
|
||||
}
|
||||
|
||||
@SaCheckPermission("system:route:add")
|
||||
@SaCheckPermission("system:route:deleteRoute")
|
||||
@Log(title = "删除工艺路线", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/deleteRoute")
|
||||
@ -319,18 +350,29 @@ public class ProcessRouteController extends BaseController {
|
||||
@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);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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,21 +94,62 @@ 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;
|
||||
|
||||
// 检查目录是否存在,如果不存在则创建
|
||||
File directory = new File(directoryPath);
|
||||
if (!directory.exists()) {
|
||||
boolean isCreated = directory.mkdirs();
|
||||
if (!isCreated) {
|
||||
throw new RuntimeException("无法创建目录: " + directoryPath);
|
||||
}
|
||||
} else {
|
||||
// 如果目录存在,删除其中的所有文件
|
||||
File[] files = directory.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (!file.delete()) {
|
||||
System.err.println("无法删除文件: " + file.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;
|
||||
// 获取第一序的工序名称
|
||||
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";
|
||||
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 = "";
|
||||
}
|
||||
|
||||
String pdfFileName = fProcessName + "_" + materialCode1.replace("/", "_") + "_独立" + ".pdf";
|
||||
|
||||
File existingFile = findFileWithMaterialCode(directoryPath, materialCode1);
|
||||
String pdfPath;
|
||||
@ -114,7 +159,8 @@ public class PDFGenerator {
|
||||
System.out.println("未找到物料编码对应的PDF文件: " + materialCode + "。将单独生成新PDF。");
|
||||
pdfPath = directoryPath + "\\" + pdfFileName;
|
||||
} else {
|
||||
pdfPath = directoryPath + "\\" + fProcessName + "_" + materialCode1.replace("/", "_") + "_generated.pdf";
|
||||
pdfPath = directoryPath + "\\" + fProcessName + "_" + materialCode1.replace("/", "_")
|
||||
+ "_generated.pdf";
|
||||
}
|
||||
|
||||
try {
|
||||
@ -122,7 +168,8 @@ public class PDFGenerator {
|
||||
PDDocument document = new PDDocument();
|
||||
PDPage page = new PDPage();
|
||||
document.addPage(page);
|
||||
PDType0Font font;
|
||||
PDType0Font font = PDType0Font.load(document, new File(fontPath));
|
||||
|
||||
try {
|
||||
font = PDType0Font.load(document, new File(fontPath));
|
||||
} catch (IllegalArgumentException e) {
|
||||
@ -150,16 +197,21 @@ public class PDFGenerator {
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
productionOrderNumber, combinedVo.getOrderNumber(), combinedVo.getMaterialName(),
|
||||
combinedVo.getMaterialCode(),
|
||||
String.valueOf(fmoQty), fDepartmentName, "1", "" }, document, page, rowHeight, pageHeight);
|
||||
|
||||
// 绘制工序表格
|
||||
float processTableStartY = yStart - 2 * rowHeight - 10;
|
||||
@ -167,23 +219,29 @@ public class PDFGenerator {
|
||||
yStart = processTableStartY;
|
||||
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, processColWidths, new String[] {
|
||||
"工序号", "工序名称", "数量", "工作中心", "工时(分)", "工序说明", "控制码", "开始时间", "结束时间"}, document, page, rowHeight, pageHeight);
|
||||
"工序号", "工序名称", "数量", "工作中心", "工时(分)", "工序说明", "控制码", "开始时间", "结束时间" }, 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(),
|
||||
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())) : ""
|
||||
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;
|
||||
yStart = yStart - 2 * rowHeight - 40;
|
||||
|
||||
contentStream.beginText();
|
||||
contentStream.setFont(font, 12);
|
||||
@ -218,7 +276,8 @@ public class PDFGenerator {
|
||||
yStart = pageHeight - margin;
|
||||
|
||||
// 绘制用料清单表头
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, materialColWidths, new String[]{
|
||||
drawTableRow(contentStream, font, margin, yStart, tableWidth, materialColWidths,
|
||||
new String[] {
|
||||
"序号", "物料编码", "物料名称", "规格型号", "单位", "应发数", "已领数", "仓库", "备注"
|
||||
}, document, page, rowHeight, pageHeight);
|
||||
yStart -= rowHeight;
|
||||
@ -226,24 +285,29 @@ public class PDFGenerator {
|
||||
|
||||
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(),
|
||||
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()),
|
||||
String.valueOf(material.getRequiredQty()),
|
||||
String.valueOf(material.getPickedQty()),
|
||||
|
||||
material.getStockName(), material.getRemarks() != null ? material.getRemarks() : ""
|
||||
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 后,调用重命名和移动文件的方法
|
||||
@ -253,6 +317,58 @@ public class PDFGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 生成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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 文件搜索方法:根据物料编码在文件夹中查找文件名包含该编码的PDF文件
|
||||
public static File findFileWithMaterialCode(String directoryPath, String materialCode) {
|
||||
@ -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());
|
||||
}
|
||||
// 更新数量,更新实体类
|
||||
|
||||
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 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
|
||||
@ -53,7 +53,6 @@ import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ruoyi.common.core.domain.R.fail;
|
||||
import static com.ruoyi.system.controller.BomDetailsController.*;
|
||||
import static com.ruoyi.system.runner.JsonConverter.createProcessModel;
|
||||
import static com.ruoyi.system.runner.updatePcessPlanConver.updatePcessPlan1;
|
||||
@ -108,25 +107,33 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
@Override
|
||||
public List<ProcessRouteVo> queryList(ProcessRouteBo bo) {
|
||||
LambdaQueryWrapper<ProcessRoute> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
List<ProcessRouteVo> routeVoList = baseMapper.selectVoList(lqw);
|
||||
// 对这个集合进行重新排序,按照物料编码排序
|
||||
routeVoList.sort(Comparator.comparing(ProcessRouteVo::getMaterialCode));
|
||||
|
||||
return routeVoList;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<ProcessRoute> buildQueryWrapper(ProcessRouteBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<ProcessRoute> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getRouteDescription()), ProcessRoute::getRouteDescription, bo.getRouteDescription());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getRouteDescription()), ProcessRoute::getRouteDescription,
|
||||
bo.getRouteDescription());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialCode()), ProcessRoute::getMaterialCode, bo.getMaterialCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getMaterialName()), ProcessRoute::getMaterialName, bo.getMaterialName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBomUnit()), ProcessRoute::getBomUnit, bo.getBomUnit());
|
||||
lqw.eq(bo.getProcessNo() != null, ProcessRoute::getProcessNo, bo.getProcessNo());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getWorkCenter()), ProcessRoute::getWorkCenter, bo.getWorkCenter());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getProcessName()), ProcessRoute::getProcessName, bo.getProcessName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getRawMaterialCode()), ProcessRoute::getRawMaterialCode, bo.getRawMaterialCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getRawMaterialName()), ProcessRoute::getRawMaterialName, bo.getRawMaterialName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getRawMaterialCode()), ProcessRoute::getRawMaterialCode,
|
||||
bo.getRawMaterialCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getRawMaterialName()), ProcessRoute::getRawMaterialName,
|
||||
bo.getRawMaterialName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBomMaterial()), ProcessRoute::getBomMaterial, bo.getBomMaterial());
|
||||
lqw.eq(bo.getDiscWeight() != null, ProcessRoute::getDiscWeight, bo.getDiscWeight());
|
||||
lqw.eq(bo.getDiscUsage() != null, ProcessRoute::getDiscUsage, bo.getDiscUsage());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getProcessDescription()), ProcessRoute::getProcessDescription, bo.getProcessDescription());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getProcessDescription()), ProcessRoute::getProcessDescription,
|
||||
bo.getProcessDescription());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getProcessControl()), ProcessRoute::getProcessControl, bo.getProcessControl());
|
||||
lqw.eq(bo.getActivityDuration() != null, ProcessRoute::getActivityDuration, bo.getActivityDuration());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getActivityUnit()), ProcessRoute::getActivityUnit, bo.getActivityUnit());
|
||||
@ -149,9 +156,21 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
|
||||
ProcessRoute add = BeanUtil.toBean(bo, ProcessRoute.class);
|
||||
// 查询最大序为多少
|
||||
if (baseMapper.existsByProcessNoAndMaterialCode(add.getProcessNo(), add.getMaterialCode(), add.getProcessDescription())) {
|
||||
if (baseMapper.existsByProcessNoAndMaterialCode(add.getProcessNo(), add.getMaterialCode(),
|
||||
add.getProcessDescription())) {
|
||||
throw new ServiceException("序号重复,请重新输入");
|
||||
}
|
||||
// 1.查询当前物料的所有工序关系
|
||||
LambdaQueryWrapper<ProcessRoute> route = new LambdaQueryWrapper<>();
|
||||
route.eq(ProcessRoute::getMaterialCode, add.getMaterialCode())
|
||||
.eq(ProcessRoute::getMaterialName, add.getMaterialName())
|
||||
.eq(ProcessRoute::getRouteDescription, add.getRouteDescription());
|
||||
List<ProcessRoute> routeList = baseMapper.selectList(route);
|
||||
// 2. 校验连续工序中相同工作中心的工序控制码
|
||||
if (!routeList.isEmpty()) {
|
||||
setoProcessControl(routeList);
|
||||
}
|
||||
|
||||
// 2. 更新所有比新序号大的工艺路线,将它们的 processNo
|
||||
baseMapper.updateProcessNoAfterInsert(add.getProcessNo(), add.getMaterialCode(), add.getProcessDescription());
|
||||
validEntityBeforeSave(add);
|
||||
@ -162,6 +181,45 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void setoProcessControl(List<ProcessRoute> routeList) {
|
||||
if (routeList == null || routeList.size() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 按工序号排序
|
||||
routeList.sort(Comparator.comparing(ProcessRoute::getProcessNo));
|
||||
|
||||
// 遍历处理连续相同工作中心的工序
|
||||
for (int i = 0; i < routeList.size(); i++) {
|
||||
ProcessRoute current = routeList.get(i);
|
||||
|
||||
// 委外中心特殊处理
|
||||
if ("委外中心".equals(current.getWorkCenter())) {
|
||||
current.setProcessControl("委外+汇报");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 查找连续相同工作中心的最后一个工序
|
||||
int j = i;
|
||||
while (j + 1 < routeList.size() &&
|
||||
routeList.get(j + 1).getWorkCenter().equals(current.getWorkCenter())) {
|
||||
j++;
|
||||
}
|
||||
|
||||
// 设置工序控制码
|
||||
if (i == j) {
|
||||
// 单个工序设置为"汇报+质量"
|
||||
current.setProcessControl("汇报+质量");
|
||||
} else {
|
||||
// 连续工序,最后一个设置为"汇报+质量",其他为"汇报+免检"
|
||||
for (int k = i; k <= j; k++) {
|
||||
ProcessRoute route = routeList.get(k);
|
||||
route.setProcessControl(k == j ? "汇报+质量" : "汇报+免检");
|
||||
}
|
||||
i = j; // 跳过已处理的工序
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改工艺路线
|
||||
@ -196,9 +254,36 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 直接更新全部字段
|
||||
// 3. 获取当前物料的所有工序关系
|
||||
LambdaQueryWrapper<ProcessRoute> route = new LambdaQueryWrapper<>();
|
||||
route.eq(ProcessRoute::getMaterialCode, update.getMaterialCode())
|
||||
.eq(ProcessRoute::getMaterialName, update.getMaterialName())
|
||||
.eq(ProcessRoute::getRouteDescription, update.getRouteDescription());
|
||||
List<ProcessRoute> routeList = baseMapper.selectList(route);
|
||||
|
||||
// 4. 更新当前记录到列表中
|
||||
boolean found = false;
|
||||
for (int i = 0; i < routeList.size(); i++) {
|
||||
if (routeList.get(i).getId().equals(update.getId())) {
|
||||
routeList.set(i, update);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
routeList.add(update);
|
||||
}
|
||||
|
||||
// 5. 按工序号排序
|
||||
routeList.sort(Comparator.comparing(ProcessRoute::getProcessNo));
|
||||
|
||||
// 6. 校验连续工序中相同工作中心的工序控制码
|
||||
setoProcessControl(routeList);
|
||||
|
||||
// 7. 更新数据库
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
@ -212,6 +297,12 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
List<ProcessRoute> cunList = new ArrayList<>();
|
||||
for (Long id : ids) {
|
||||
ProcessRoute processRoute = baseMapper.selectById(id);
|
||||
if (processRoute.getProcessNo() == 10) {
|
||||
throw new ServiceException("最少保留首序");
|
||||
}
|
||||
}
|
||||
// 这里你到时候改成通过ids查询出来 这个ids是你传过来要删除的,你不能通过去排序和查询en
|
||||
for (Long id : ids) {
|
||||
// 存储删掉的数据
|
||||
@ -256,7 +347,6 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean saveData(List<ProcessRouteVo> routeVoList, List<ProductionOrderVo> productionOrderVos) {
|
||||
// 将 ProcessRouteVo 转换为 ProcessRoute
|
||||
List<ProcessRoute> processRoutes = BeanUtil.copyToList(routeVoList, ProcessRoute.class);
|
||||
@ -297,14 +387,39 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
if (isDuplicateWelding && processedWeldingMaterials.contains(processRoute.getMaterialCode())) {
|
||||
continue;
|
||||
}
|
||||
List<ProcessRouteSelectDTO> selectProcessRoute = getSelectProcessRoute(processRoute.getMaterialCode());
|
||||
|
||||
// 生成4个默认工序
|
||||
for (int i = 0; i <2; i++) {
|
||||
if (!selectProcessRoute.isEmpty()) {
|
||||
for (ProcessRouteSelectDTO processRouteSelectDTO : selectProcessRoute) {
|
||||
ProcessRoute processRoute1 = new ProcessRoute();
|
||||
// 复制基本信息
|
||||
processRoute1.setMaterialCode(processRoute.getMaterialCode());
|
||||
processRoute1.setMaterialName(processRoute.getMaterialName());
|
||||
processRoute1.setRouteDescription(processRoute.getRouteDescription());
|
||||
processRoute1.setMaterial(processRoute.getMaterial());
|
||||
processRoute1.setDiscWeight(processRoute.getDiscWeight());
|
||||
|
||||
// 复制工艺信息
|
||||
processRoute1.setProcessNo(processRouteSelectDTO.getProcessNo());
|
||||
processRoute1.setProcessName(processRouteSelectDTO.getProcessName());
|
||||
processRoute1.setProcessDescription(processRouteSelectDTO.getProcessDescription());
|
||||
processRoute1.setWorkCenter(processRouteSelectDTO.getWorkCenter());
|
||||
processRoute1.setProcessControl(processRouteSelectDTO.getProcessControl());
|
||||
processRoute1.setActivityDuration(processRouteSelectDTO.getActivityDuration());
|
||||
processRoute1.setActivityUnit("分");
|
||||
|
||||
// 设置时间
|
||||
processRoute1.setCreateTime(new Date());
|
||||
processRoute1.setUpdateTime(new Date());
|
||||
|
||||
routeArrayList.add(processRoute1);
|
||||
}
|
||||
} else {
|
||||
ProcessRoute defaultRoute = new ProcessRoute();
|
||||
BeanUtil.copyProperties(processRoute, defaultRoute);
|
||||
|
||||
// 设置工序号 (10, 20, 30, 40)
|
||||
defaultRoute.setProcessNo((long) ((i + 1) * 10));
|
||||
defaultRoute.setProcessNo((long) (10));
|
||||
|
||||
// 清空工序相关信息
|
||||
defaultRoute.setWorkCenter(null);
|
||||
@ -312,13 +427,15 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
defaultRoute.setProcessDescription(null);
|
||||
defaultRoute.setProcessControl(null);
|
||||
defaultRoute.setActivityDuration(null);
|
||||
defaultRoute.setActivityUnit(null);
|
||||
defaultRoute.setActivityUnit("分");
|
||||
|
||||
// 设置创建时间和更新时间
|
||||
defaultRoute.setCreateTime(new Date());
|
||||
defaultRoute.setUpdateTime(new Date());
|
||||
|
||||
routeArrayList.add(defaultRoute);
|
||||
|
||||
log.info("为物料 {} 生成了默认工序,因为在金蝶中未找到对应工艺路线", processRoute.getMaterialCode());
|
||||
}
|
||||
|
||||
// 如果是重复的组焊件,标记为已处理
|
||||
@ -351,7 +468,8 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
String unit = processRoute.getBomUnit();
|
||||
String materialType = processRoute.getBomMaterial();
|
||||
Double quantity = processRoute.getDiscUsage() != null ? processRoute.getDiscUsage() : 0;
|
||||
if (projectNumber == null || parentMaterialCode == null || parentMaterialName == null || unit == null || materialType == null) {
|
||||
if (projectNumber == null || parentMaterialCode == null || parentMaterialName == null || unit == null
|
||||
|| materialType == null) {
|
||||
// 处理空值情况,例如记录日志或抛出异常
|
||||
log.error("必填字段为空: {}", processRoute);
|
||||
continue;
|
||||
@ -365,14 +483,15 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
materialBom.setMaterialName(processRoute.getRawMaterialName());
|
||||
materialBom.setUnit(unit);
|
||||
materialBom.setMaterialType(materialType);
|
||||
materialBom.setQuantity(quantity);
|
||||
materialBom.setQuantity(String.valueOf(quantity));
|
||||
// 这里插入 materialBom 数据
|
||||
materialBomMapper.insert(materialBom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<BomDetailsVo> processBomDetails(List<ProcessRoute> processRoutes, List<ProductionOrderVo> productionOrderVos) {
|
||||
private List<BomDetailsVo> processBomDetails(List<ProcessRoute> processRoutes,
|
||||
List<ProductionOrderVo> productionOrderVos) {
|
||||
List<BomDetailsVo> bomDetailsVos = new ArrayList<>();
|
||||
// 是否已处理过总装部件
|
||||
boolean hasProcessedAssemblyPart = false;
|
||||
@ -389,7 +508,8 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
hasProcessedAssemblyPart = true;
|
||||
continue;
|
||||
}
|
||||
if (processRoute.getRawMaterialCode() != null || processRoute.getRawMaterialName() != null || processRoute.getBomMaterial() != null || processRoute.getBomUnit() != null) {
|
||||
if (processRoute.getRawMaterialCode() != null || processRoute.getRawMaterialName() != null
|
||||
|| processRoute.getBomMaterial() != null || processRoute.getBomUnit() != null) {
|
||||
BomDetailsVo bomDetails = createBomDetails(processRoute);
|
||||
bomDetailsVos.add(bomDetails);
|
||||
}
|
||||
@ -417,7 +537,6 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
bomDetails.setDenominator(1.0);
|
||||
}
|
||||
|
||||
|
||||
// 根据 RawMaterialCode 判断是否外购
|
||||
if (isOutsourced(processRoute.getRawMaterialCode())) {
|
||||
bomDetails.setStats("外购");
|
||||
@ -430,7 +549,8 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
return bomDetails;
|
||||
}
|
||||
|
||||
private void createAssemblyBomDetails(String zFlinghao, String zFnumber, String zFname, List<ProductionOrderVo> productionOrderVos) {
|
||||
private void createAssemblyBomDetails(String zFlinghao, String zFnumber, String zFname,
|
||||
List<ProductionOrderVo> productionOrderVos) {
|
||||
ArrayList<BomDetailsVo> bomDetailsVos = new ArrayList<>();
|
||||
for (ProductionOrderVo productionOrderVo : productionOrderVos) {
|
||||
if (productionOrderVo != null) {
|
||||
@ -449,7 +569,8 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
String drawingNo = productionOrderVo.getDrawingNo();
|
||||
String remark = productionOrderVo.getRemark();
|
||||
if (drawingNo != null) {
|
||||
if ((isOutsourced(drawingNo) || (remark != null && remark.contains("外购件")) || drawingNo.startsWith(" ")) || drawingNo.startsWith("009")) {
|
||||
if ((isOutsourced(drawingNo) || (remark != null && remark.contains("外购件"))
|
||||
|| drawingNo.startsWith(" ")) || drawingNo.startsWith("009")) {
|
||||
bomDetails.setStats("外购");
|
||||
} else {
|
||||
bomDetails.setStats("自制");
|
||||
@ -598,12 +719,10 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
subHeadEntity6.addProperty("FCheckReturnMtrl", true);
|
||||
}
|
||||
|
||||
|
||||
// 创建SubHeadEntity5对象,并加入Model
|
||||
JsonObject subHeadEntity5 = new JsonObject();
|
||||
model.add("SubHeadEntity5", subHeadEntity5);
|
||||
|
||||
|
||||
// 创建FProduceUnitId对象,并加入SubHeadEntity5
|
||||
JsonObject fProduceUnitId = new JsonObject();
|
||||
fProduceUnitId.addProperty("FNumber", "jian");
|
||||
@ -713,7 +832,6 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
materialsToAdd.add(bomDetails);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 新增不存在的物料
|
||||
@ -740,7 +858,8 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
List<ProcessRoute> processRoutes = baseMapper.selectList();
|
||||
ArrayList<ProcessRoute> routeArrayList = new ArrayList<>();
|
||||
for (ProcessRoute processRoute : processRoutes) {
|
||||
if (processRoute.getMaterial().equals("组焊件") && processRoute.getMaterialCode().equals(Bo.getMaterialCode())) {
|
||||
if (processRoute.getMaterial().equals("组焊件")
|
||||
&& processRoute.getMaterialCode().equals(Bo.getMaterialCode())) {
|
||||
routeArrayList.add(processRoute);
|
||||
}
|
||||
}
|
||||
@ -775,9 +894,14 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
@Override
|
||||
public List<ProcessRoute> getRawBom(String rooteProdet) {
|
||||
LambdaQueryWrapper<ProcessRoute> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProcessRoute::getRouteDescription, rooteProdet).ne(ProcessRoute::getMaterial, "组焊件").isNotNull(ProcessRoute::getRawMaterialCode).ne(ProcessRoute::getRawMaterialCode, "").isNotNull(ProcessRoute::getRawMaterialName).ne(ProcessRoute::getRawMaterialName, "").and(wrapper1 -> wrapper1.likeRight(ProcessRoute::getRawMaterialCode, "015").or().likeRight(ProcessRoute::getRawMaterialCode, "AB"));
|
||||
|
||||
|
||||
wrapper.eq(ProcessRoute::getRouteDescription, rooteProdet)
|
||||
.ne(ProcessRoute::getMaterial, "组焊件")
|
||||
.isNotNull(ProcessRoute::getRawMaterialCode)
|
||||
.ne(ProcessRoute::getRawMaterialCode, "")
|
||||
.isNotNull(ProcessRoute::getRawMaterialName)
|
||||
.ne(ProcessRoute::getRawMaterialName, "")
|
||||
.and(wrapper1 -> wrapper1.likeRight(ProcessRoute::getRawMaterialCode, "015")
|
||||
.or().likeRight(ProcessRoute::getRawMaterialCode, "AB"));
|
||||
return baseMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
@ -838,24 +962,82 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
* 查询这个项目下的所有工艺路线,材料bom ,原材料bom集合
|
||||
*/
|
||||
public List<ProcessRoute> getRawBomList(String rooteProdet) {
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<ProcessRoute>().eq(ProcessRoute::getRouteDescription, rooteProdet));
|
||||
return baseMapper
|
||||
.selectList(new LambdaQueryWrapper<ProcessRoute>().eq(ProcessRoute::getRouteDescription, rooteProdet));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProcessRouteXuDTO> pushRouteBom(String rooteProdet) {
|
||||
public ProcessRoutePushResultDTO pushRouteBom(String rooteProdet) {
|
||||
List<ProcessRouteXuDTO> rawBomList = getProcessRoute(rooteProdet);
|
||||
List<ProcessRouteXuDTO> successfulRoutes = new ArrayList<>();
|
||||
List<ProcessRouteXuDTO> failedRoutes = new ArrayList<>();
|
||||
List<String> duplicateRoutes = new ArrayList<>();
|
||||
for (ProcessRouteXuDTO processRouteXuDTO : rawBomList) {
|
||||
// 获取金蝶中的此物料工艺路线,在金蝶查询可能有多条工艺路线
|
||||
List<ProcessRouteSelectDTO> jdProcessRoute = getSelectProcessRoute(processRouteXuDTO.getMaterialCode());
|
||||
Map<String, List<ProcessRouteSelectDTO>> groupedByFNumber = jdProcessRoute.stream()
|
||||
.collect(Collectors.groupingBy(ProcessRouteSelectDTO::getFNumber));
|
||||
// 当前物料的工艺路线
|
||||
List<ProcessRouteDTO> processRouteDT = processRouteXuDTO.getProcessRouteDT();
|
||||
// 比较工艺路线
|
||||
boolean isDifferent = compareProcessRoutes(processRouteDT, groupedByFNumber);
|
||||
if (isDifferent) {
|
||||
log.info("工艺路线不同,进行更新: " + processRouteXuDTO.getMaterialCode());
|
||||
|
||||
// 保存工艺路线
|
||||
LoadBomResult result = loadBillOfMaterialsPreservation(processRouteXuDTO);
|
||||
// 处理返回结果
|
||||
if (result.isSuccess()) {
|
||||
System.out.println("工艺路线保存保存成功: " + processRouteXuDTO.getMaterialCode() + result.getResultData());
|
||||
log.info("工艺路线保存成功: " + processRouteXuDTO.getMaterialCode() + result.getResultData());
|
||||
successfulRoutes.add(processRouteXuDTO);
|
||||
} else {
|
||||
System.out.println("工艺路线保存保存失败: " + processRouteXuDTO.getMaterialCode() + result.getMessage());
|
||||
log.info("工艺路线保存失败: " + processRouteXuDTO.getMaterialCode() + result.getMessage());
|
||||
failedRoutes.add(processRouteXuDTO);
|
||||
}
|
||||
}
|
||||
return rawBomList; //
|
||||
} else {
|
||||
log.info("工艺路线相同,无需更新: " + processRouteXuDTO.getMaterialCode());
|
||||
duplicateRoutes.add(processRouteXuDTO.getMaterialCode());
|
||||
}
|
||||
|
||||
}
|
||||
// 封装结果
|
||||
ProcessRoutePushResultDTO resultDTO = new ProcessRoutePushResultDTO();
|
||||
resultDTO.setSuccessfulRoutes(successfulRoutes);
|
||||
resultDTO.setFailedRoutes(failedRoutes);
|
||||
resultDTO.setDuplicateRoutes(duplicateRoutes);
|
||||
return resultDTO;
|
||||
}
|
||||
|
||||
private boolean compareProcessRoutes(List<ProcessRouteDTO> processRouteDT, Map<String, List<ProcessRouteSelectDTO>> groupedByFNumber) {
|
||||
// 对当前物料的工艺路线进行排序
|
||||
processRouteDT.sort(Comparator.comparing(ProcessRouteDTO::getProcessNo));
|
||||
for (List<ProcessRouteSelectDTO> jdRoutes : groupedByFNumber.values()) {
|
||||
// 对金蝶中的工艺路线进行排序
|
||||
jdRoutes.sort(Comparator.comparing(ProcessRouteSelectDTO::getProcessNo));
|
||||
// 检查是否有任何一个金蝶工艺路线与当前物料的工艺路线相同
|
||||
if (areRoutesEqual(processRouteDT, jdRoutes)) {
|
||||
return false; // 找到相同的工艺路线,不需要更新
|
||||
}
|
||||
}
|
||||
return true; // 没有找到相同的工艺路线,需要更新
|
||||
}
|
||||
private boolean areRoutesEqual (List<ProcessRouteDTO> processRouteDT, List<ProcessRouteSelectDTO> jdRoutes ) {
|
||||
if (processRouteDT.size() != jdRoutes.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < processRouteDT.size(); i++) {
|
||||
ProcessRouteDTO localRoute = processRouteDT.get(i);
|
||||
ProcessRouteSelectDTO jdRoute = jdRoutes.get(i);
|
||||
if (!Objects.equals(localRoute.getProcessNo(), jdRoute.getProcessNo()) ||
|
||||
!Objects.equals(localRoute.getProcessName(), jdRoute.getProcessName()) ||
|
||||
!Objects.equals(localRoute.getWorkCenter(), jdRoute.getWorkCenter()) ||
|
||||
!Objects.equals(localRoute.getProcessControl(), jdRoute.getProcessControl()) ||
|
||||
!Objects.equals(localRoute.getActivityDuration(), jdRoute.getActivityDuration())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 查询工艺路线单据体
|
||||
*
|
||||
@ -865,7 +1047,7 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
@Override
|
||||
public List<CombinedDTO> getSelecPlanRouteList(String rooteProdet) {
|
||||
// 根据生产令号查询生产订单编码,获取计划单据编号和工艺路线
|
||||
List<PlanOrderVo> planOrderList = getSelectProceOrder(rooteProdet);
|
||||
List<PlanOrderVo> planOrderList = getSelectProceOrder1(rooteProdet);
|
||||
|
||||
log.info("获取计划单号集合: planOrderList=====>" + planOrderList);
|
||||
|
||||
@ -881,7 +1063,8 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
// 请求参数,要求为json字符串
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("FormId", "SFC_OperationPlanning");
|
||||
json.addProperty("FieldKeys", "FBillNo,FOperNumber,FProcessId.FName,FOptCtrlCodeId.FName,FActivity1BaseQty,FOperPlanStartTime,FOperPlanFinishTime,FOperQty,FDepartmentId.FName,FWorkCenterId.FName,FOperDescription,FPlanStartTime,FPlanFinishTime,FMOQty,FOperUnitId.FName");
|
||||
json.addProperty("FieldKeys",
|
||||
"FBillNo,FOperNumber,FProcessId.FName,FOptCtrlCodeId.FName,FActivity1BaseQty,FOperPlanStartTime,FOperPlanFinishTime,FOperQty,FDepartmentId.FName,FWorkCenterId.FName,FOperDescription,FPlanStartTime,FPlanFinishTime,FMOQty,FOperUnitId.FName");
|
||||
// 创建过滤条件
|
||||
JsonArray filterString = new JsonArray();
|
||||
JsonObject filterObject = new JsonObject();
|
||||
@ -908,11 +1091,11 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
|
||||
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
List<PlannedProcessVo> plannedProcessList = objectMapper.readValue(jsonArray.toString(), new TypeReference<List<PlannedProcessVo>>() {
|
||||
List<PlannedProcessVo> plannedProcessList = objectMapper.readValue(jsonArray.toString(),
|
||||
new TypeReference<List<PlannedProcessVo>>() {
|
||||
|
||||
});
|
||||
|
||||
|
||||
// 检查 plannedProcessList 是否为 null,避免空指针异常
|
||||
if (plannedProcessList != null && !plannedProcessList.isEmpty()) {
|
||||
plannedProcesses.addAll(plannedProcessList); // 将非空列表添加到最终列表中
|
||||
@ -939,19 +1122,19 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CombinedDTO> generatePDFs(String rooteProdet) {
|
||||
public String generatePDFs(String rooteProdet) {
|
||||
List<CombinedDTO> selecPlanRouteList = getSelecPlanRouteList(rooteProdet);
|
||||
PDFGenerator.writeToPdf(selecPlanRouteList, rooteProdet);
|
||||
return null;
|
||||
String pathZIP = PDFGenerator.writeToPdf(selecPlanRouteList, rooteProdet);
|
||||
return pathZIP;
|
||||
}
|
||||
|
||||
|
||||
public 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, F_UCHN_BaseProperty_qtr");
|
||||
json.addProperty("FieldKeys",
|
||||
"F_HBYT_SCLH,FBillNo ,FMaterialId.FNumber,FMaterialName, F_UCHN_BaseProperty_qtr");
|
||||
JsonArray filterString = new JsonArray();
|
||||
JsonObject filterObject = new JsonObject();
|
||||
filterObject.addProperty("FieldName", "F_HBYT_SCLH");
|
||||
@ -977,7 +1160,8 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
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>>() {
|
||||
List<PlanOrderVo> planOrders = objectMapper.readValue(jsonArray.toString(),
|
||||
new TypeReference<List<PlanOrderVo>>() {
|
||||
});
|
||||
// 输出或返回结果
|
||||
System.out.println(planOrders);
|
||||
@ -989,14 +1173,79 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
}
|
||||
}
|
||||
|
||||
//获取计划订单列表
|
||||
public List<PlanOrderVo> getSelectProceOrder1(String rooteProdet) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
|
||||
// 第一次查询:使用 F_HBYT_SCLH
|
||||
List<PlanOrderVo> result = queryWithFieldName(client, "F_HBYT_SCLH", rooteProdet);
|
||||
|
||||
/*
|
||||
* // 如果第一次查询结果为空,使用 子生产令号 重新查询
|
||||
* if (result == null || result.isEmpty()) {
|
||||
* result = queryWithFieldName(client, "F_HBYT_ZSCLH", rooteProdet);
|
||||
* }
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
// 将查询方法提取为私有方法
|
||||
private List<PlanOrderVo> queryWithFieldName(K3CloudApi client, String fieldName, String rooteProdet) {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("FormId", "PRD_MO");
|
||||
json.addProperty("FieldKeys",
|
||||
"F_HBYT_SCLH,FBillNo ,FMaterialId.FNumber,FMaterialName, F_UCHN_BaseProperty_qtr");
|
||||
|
||||
JsonArray filterString = new JsonArray();
|
||||
JsonObject filterObject = new JsonObject();
|
||||
filterObject.addProperty("FieldName", fieldName); // 使用传入的 fieldName
|
||||
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", "");
|
||||
|
||||
try {
|
||||
String jsonData = json.toString();
|
||||
String resultJson = String.valueOf(client.billQuery(jsonData));
|
||||
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
|
||||
|
||||
// 检查结果是否为空
|
||||
if (jsonArray == null || jsonArray.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 转换结果
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
List<PlanOrderVo> planOrders = objectMapper.readValue(
|
||||
jsonArray.toString(),
|
||||
new TypeReference<List<PlanOrderVo>>() {
|
||||
});
|
||||
|
||||
return planOrders;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用料清单列表
|
||||
public List<MaterialUsageDTO> getSelectMaterialUseList(String FBillNo) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
// 请求参数,要求为json字符串
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("FormId", "PRD_PPBOM");
|
||||
|
||||
json.addProperty("FieldKeys", "FBillNo,FMaterialID2.FNumber,FMaterialName1,FMaterialModel1,F_HBYT_CZ,FMaterialType,FMustQty,FPickedQty,FStockID.FName,FMEMO1,FUnitID2.FName,FNumerator,FDenominator");
|
||||
json.addProperty("FieldKeys",
|
||||
"FBillNo,FMaterialID2.FNumber,FMaterialName1,FMaterialModel1,F_HBYT_CZ,FMaterialType,FMustQty,FPickedQty,FStockID.FName,FMEMO1,FUnitID2.FName,FNumerator,FDenominator");
|
||||
JsonArray filterString = new JsonArray();
|
||||
JsonObject filterObject = new JsonObject();
|
||||
filterObject.addProperty("FieldName", "FMOBillNO");
|
||||
@ -1021,9 +1270,8 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
|
||||
// 将JsonArray转为PlanOrder列表
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
List<MaterialUsageDTO> planOrders = objectMapper.readValue(jsonArray.toString(), new TypeReference<List<MaterialUsageDTO>>() {
|
||||
return objectMapper.readValue(jsonArray.toString(), new TypeReference<List<MaterialUsageDTO>>() {
|
||||
});
|
||||
return planOrders;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
@ -1141,37 +1389,84 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
|
||||
@Override
|
||||
public R<Void> addRoute(List<ProcessRouteVo> list) {
|
||||
|
||||
List<ProcessRoute> routeArrayList = new ArrayList<>();
|
||||
for (ProcessRouteVo vo : list) {
|
||||
list.sort(Comparator.comparing(ProcessRouteVo::getProcessNo));
|
||||
ProcessRouteVo previousVo = null;
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ProcessRouteVo vo = list.get(i);
|
||||
ProcessRoute route = new ProcessRoute();
|
||||
route.setRouteDescription(vo.getRouteDescription());
|
||||
route.setMaterialCode(vo.getMaterialCode());
|
||||
route.setMaterialName(vo.getMaterialName());
|
||||
route.setProcessNo(vo.getProcessNo());
|
||||
route.setWorkCenter(vo.getWorkCenter());
|
||||
String workCenter = vo.getWorkCenter();
|
||||
route.setWorkCenter(workCenter);
|
||||
route.setDiscWeight(vo.getDiscWeight());
|
||||
route.setMaterial(vo.getMaterial());
|
||||
route.setProcessName(vo.getProcessName());
|
||||
route.setProcessControl(vo.getProcessControl());
|
||||
// 工序控制码的逻辑判断 如果传进来的多个工序控制码中 连续的几个工序有相同的工作中心,其中相同的工序中,最大的工序号为控制码为汇报+质量 其余的为汇报+免检
|
||||
// 如果传进来的多个工序控制码中没有相同的工作中心,则直接返回汇报+质量
|
||||
|
||||
// 判断是否为最后一道工序
|
||||
boolean isLastProcess = (i == list.size() - 1);
|
||||
// 设置工序控制码
|
||||
String processControl = determineProcessControl(vo, previousVo, isLastProcess);
|
||||
route.setProcessControl(processControl);
|
||||
|
||||
route.setProcessDescription(vo.getProcessDescription());
|
||||
route.setActivityDuration(vo.getActivityDuration());
|
||||
route.setActivityUnit("分");
|
||||
routeArrayList.add(route);
|
||||
|
||||
previousVo = vo; // 更新 previousVo 为当前工序
|
||||
}
|
||||
// 对工序列表进行工序控制码校验和设置
|
||||
setoProcessControl(routeArrayList);
|
||||
if (baseMapper.insertBatch(routeArrayList)) {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
return null;
|
||||
return R.fail("添加工艺路线失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定工序控制码
|
||||
*
|
||||
* @param currentVo 当前工序
|
||||
* @param previousVo 上一道工序
|
||||
* @return 工序控制码
|
||||
*/
|
||||
private String determineProcessControl(ProcessRouteVo currentVo, ProcessRouteVo previousVo, boolean isLastProcess) {
|
||||
// 工序控制码的逻辑判断 如果传进来的多个工序控制码中有相同的工作中心,其中相同的工序中,最大的工序号为控制码为汇报+质量 其余的为汇报+免检
|
||||
// 如果传进来的多个工序控制码中没有相同的工作中心,则直接返回汇报+质量
|
||||
|
||||
// 1. 如果是委外中心,直接返回"委外+质量"
|
||||
|
||||
if ("委外中心".equals(currentVo.getWorkCenter())) {
|
||||
return "委外+质量";
|
||||
}
|
||||
|
||||
// 2. 如果是最后一道工序,返回"汇报+质量"
|
||||
if (isLastProcess) {
|
||||
return "汇报+质量";
|
||||
}
|
||||
|
||||
// 3. 检查与上一道工序的工作中心是否相同(如果存在上一道工序)
|
||||
if (previousVo != null && currentVo.getWorkCenter().equals(previousVo.getWorkCenter())) {
|
||||
return "汇报+免检";
|
||||
}
|
||||
|
||||
// 4. 默认返回"汇报+质量"
|
||||
return "汇报+免检";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询材料bom
|
||||
*/
|
||||
@Override
|
||||
public List<MaterialBom> getProcessMaterialList(String materialCode, String materialName, String productionOrderNo) {
|
||||
public List<MaterialBom> getProcessMaterialList(String materialCode, String materialName,
|
||||
String productionOrderNo) {
|
||||
if (materialCode == null) {
|
||||
logger.error("做工艺的物料不存在");
|
||||
throw new IllegalArgumentException("做工艺的物料不能为空");
|
||||
@ -1184,11 +1479,13 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
|
||||
return materialBomMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
// 是否是按图定制的物料
|
||||
public Boolean insertByBoToBom(MaterialBomBo bo) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除工序
|
||||
*/
|
||||
@ -1220,6 +1517,7 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
|
||||
/**
|
||||
* 导入更新时间
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
@ -1241,12 +1539,12 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入更新时间
|
||||
*
|
||||
* @param list 工艺路线列表
|
||||
* @return 更新后的工艺路线列表
|
||||
*/
|
||||
@ -1279,15 +1577,13 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
|
||||
// 3. 建立复合键映射关系,用于快速查找
|
||||
Map<String, List<ProcessRoute>> routeMap = allProcessRoutes.stream()
|
||||
.collect(Collectors.groupingBy(route ->
|
||||
generateKey(route.getRouteDescription(),
|
||||
.collect(Collectors.groupingBy(route -> generateKey(route.getRouteDescription(),
|
||||
route.getMaterialCode(),
|
||||
route.getProcessNo(),
|
||||
route.getMaterialName(),
|
||||
route.getProcessName(),
|
||||
route.getProcessControl(),
|
||||
route.getActivityDuration())
|
||||
));
|
||||
route.getActivityDuration())));
|
||||
|
||||
// 4. 批量更新数据
|
||||
List<ProcessRoute> updatedRoutes = new ArrayList<>();
|
||||
@ -1328,6 +1624,7 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
|
||||
/**
|
||||
* 是否是按图订购
|
||||
*
|
||||
* @param materialCode
|
||||
* @return
|
||||
*/
|
||||
@ -1361,11 +1658,12 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
StringUtils.defaultString(processControl, ""),
|
||||
activityDuration == null ? "" : activityDuration.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取计划订单编号,然后获取计划订单详情 单据内码 行内码
|
||||
*/
|
||||
public List<Model> getSelecPlan(String rooteProdet) {
|
||||
List<PlanOrderVo> planOrderList = getSelectProceOrder(rooteProdet);
|
||||
List<PlanOrderVo> planOrderList = getSelectProceOrder1(rooteProdet);
|
||||
log.info("获取计划单号集合: planOrderList=====>" + planOrderList);
|
||||
List<PlanPrcessNumDTO> plannedProcesses = new ArrayList<>();
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
@ -1375,7 +1673,9 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
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," +
|
||||
json.addProperty("FieldKeys",
|
||||
"FID,FSubEntity_FDetailID,FProductId.FNumber,FOperNumber,FEntity_FEntryID,FProcessId.FName,FSeqNumber,FSeqName,FPlanStartTime,FPlanFinishTime,"
|
||||
+
|
||||
"FOperPlanStartTime,FOperPlanFinishTime");
|
||||
|
||||
JsonArray filterString = new JsonArray();
|
||||
@ -1399,8 +1699,7 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
try {
|
||||
String resultJson = String.valueOf(client.billQuery(jsonData));
|
||||
System.out.println(
|
||||
"生成查询计划订单查询 " + planOrder.getFBillNo() + " 的结果: " + resultJson
|
||||
);
|
||||
"生成查询计划订单查询 " + planOrder.getFBillNo() + " 的结果: " + resultJson);
|
||||
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
|
||||
if (jsonArray == null || jsonArray.size() == 0) {
|
||||
log.info("查询订单 {} 时没有返回数据", planOrder.getFBillNo());
|
||||
@ -1408,7 +1707,8 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
List<PlanPrcessNumDTO> plannedProcessList = objectMapper.readValue(jsonArray.toString(), new TypeReference<List<PlanPrcessNumDTO>>() {
|
||||
List<PlanPrcessNumDTO> plannedProcessList = objectMapper.readValue(jsonArray.toString(),
|
||||
new TypeReference<List<PlanPrcessNumDTO>>() {
|
||||
});
|
||||
if (plannedProcessList != null && !plannedProcessList.isEmpty()) {
|
||||
plannedProcesses.addAll(plannedProcessList);
|
||||
@ -1430,7 +1730,7 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
// 使用 Map 结构暂存 Model 对象
|
||||
Map<Integer, Model> modelMap = new HashMap<>();
|
||||
for (PlanPrcessNumDTO dto : plannedProcesses) {
|
||||
// 获取或创建 Model 对象
|
||||
// <EFBFBD><EFBFBD>取或创建 Model 对象
|
||||
Model model = modelMap.computeIfAbsent(dto.getFID(), fid -> {
|
||||
Model newModel = new Model();
|
||||
newModel.setFID(fid);
|
||||
@ -1504,5 +1804,45 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
return timeInfo;
|
||||
}
|
||||
|
||||
// 获取存在工艺
|
||||
public List<ProcessRouteSelectDTO> getSelectProcessRoute(String materialCode) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
// 请求参数,要求为json字符串
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("FormId", "ENG_Route");
|
||||
|
||||
json.addProperty("FieldKeys",
|
||||
"FNumber,FMATERIALID.FNumber,FMATERIALNAME,FOperNumber,FProcessProperty,FWorkCenterId.FName,FOperDescription,FOptCtrlCodeId.FName,FActivity1Qty");
|
||||
JsonArray filterString = new JsonArray();
|
||||
JsonObject filterObject = new JsonObject();
|
||||
filterObject.addProperty("FieldName", "FMATERIALID.FNumber");
|
||||
filterObject.addProperty("Compare", "67");
|
||||
filterObject.addProperty("Value", materialCode);
|
||||
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));
|
||||
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
|
||||
// 将JsonArray转为PlanOrder列表
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
return objectMapper.readValue(jsonArray.toString(), new TypeReference<List<ProcessRouteSelectDTO>>() {
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user