|
@@ -95,6 +95,8 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
|
private ApsEquipmentCalendarService apsEquipmentCalendarService;
|
|
|
@Autowired
|
|
|
private ApsService apsService;
|
|
|
+ @Autowired
|
|
|
+ private ApsProductionTechnicalRequirementService apsProductionTechnicalRequirementService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -1834,4 +1836,140 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
|
//逻辑删除坯料计划的工艺路线
|
|
|
this.baseMapper.removeMindMappingByBlankId(req.getId());
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public R checkAndUpdateBlankAndOutput(ApsProductionTechnicalRequirementDo req) {
|
|
|
+ String id = req.getId();
|
|
|
+ //查询技术要求
|
|
|
+ ApsProductionTechnicalRequirementDo apsProductionTechnicalRequirementDo = apsProductionTechnicalRequirementService.getById(id);
|
|
|
+ //获取对应的产品明细IDs
|
|
|
+ String orderdetailids = apsProductionTechnicalRequirementDo.getOrderdetailids();
|
|
|
+ if (ObjectUtil.isEmpty(orderdetailids)) {
|
|
|
+ return R.error("技术要求对应的产品明细不能为空");
|
|
|
+ }
|
|
|
+ //查询产品明细对应的输出成品
|
|
|
+ List<String> orderDetailIdList = Arrays.asList(orderdetailids.split(","));
|
|
|
+ List<ApsProcessOutputProductDo> apsProcessOutputProductDoList = apsProcessOutputProductService.list(new QueryWrapper<ApsProcessOutputProductDo>().lambda().in(ApsProcessOutputProductDo::getProductid, orderDetailIdList));
|
|
|
+ //查询涉及到的坯料计划ID
|
|
|
+ List<String> blankIdlist = apsProcessOutputProductDoList.stream().map(ApsProcessOutputProductDo::getBlankid).distinct().collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isEmpty(blankIdlist)) {
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ //查询坯料计划详情
|
|
|
+ List<ApsBlankOrderDo> apsBlankOrderDoList = apsBlankOrderService.list(new QueryWrapper<ApsBlankOrderDo>().lambda().in(ApsBlankOrderDo::getId, blankIdlist));
|
|
|
+
|
|
|
+ //如果坯料计划的生产状态为:待排程(10),待发布(20),待开工(30)
|
|
|
+ //筛选出需要更新的坯料计划
|
|
|
+ List<ApsBlankOrderDo> needUpdateBlankList = apsBlankOrderDoList.stream().filter(item -> Arrays.asList(TO_BE_SCHEDULED, TO_BE_PUBLISHED, TO_BE_STARTED).contains(item.getProductstatus())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //最终需要更新的数组集合
|
|
|
+ List<ApsBlankOrderDo> endNeedUpdateBlankList = new LinkedList<>();
|
|
|
+
|
|
|
+ for (ApsBlankOrderDo apsBlankOrderDo : needUpdateBlankList) {
|
|
|
+ //是否需要更新坯料计划的 输出产品订单字段
|
|
|
+ boolean isNeedUpdateBlank = false;
|
|
|
+
|
|
|
+ //筛选出需要更新的输出成品
|
|
|
+ List<ApsProcessOutputProductDo> needUpdateProductOutputList = apsProcessOutputProductDoList.stream().filter(item -> item.getBlankid().equals(apsBlankOrderDo.getId())).collect(Collectors.toList());
|
|
|
+ for (ApsProcessOutputProductDo apsProcessOutputProductDo : needUpdateProductOutputList) {
|
|
|
+ //获取当前组装输出成品 使用的 字段,(包含替换字段)
|
|
|
+ String alloy = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getAlloy()) ? apsProcessOutputProductDo.getAlloy() : "";
|
|
|
+ String alloystatus = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getAlloystatus()) ? apsProcessOutputProductDo.getAlloystatus() : "";
|
|
|
+ String producttype = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getProducttype()) ? apsProcessOutputProductDo.getProducttype() : "";
|
|
|
+ if (ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getChangealloy())) {
|
|
|
+ alloy = apsProcessOutputProductDo.getChangealloy();
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getChangealloystatus())) {
|
|
|
+ alloystatus = apsProcessOutputProductDo.getChangealloystatus();
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getChangeproducttype())) {
|
|
|
+ producttype = apsProcessOutputProductDo.getChangeproducttype();
|
|
|
+ }
|
|
|
+
|
|
|
+ ApsProcessOutputProductDo endUpdateOutput = BeanUtil.copyProperties(apsProductionTechnicalRequirementDo, ApsProcessOutputProductDo.class);
|
|
|
+ endUpdateOutput.setId(apsProcessOutputProductDo.getId());
|
|
|
+ endUpdateOutput.setProducttype(apsProductionTechnicalRequirementDo.getOrderproducttype());
|
|
|
+ endUpdateOutput.setProducttypeid(apsProductionTechnicalRequirementDo.getOrderproducttypeid());
|
|
|
+ //新的产品类型
|
|
|
+ String newProductType = endUpdateOutput.getProducttype();
|
|
|
+ if (ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getChangeproducttype())) {
|
|
|
+ newProductType = apsProcessOutputProductDo.getChangeproducttype();
|
|
|
+ }
|
|
|
+ //如果技术要求中的 订单产品类型 不等于 输出成品的 产品类型 , 需要重新组装输出成品
|
|
|
+ if (!producttype.equals(newProductType)) {
|
|
|
+ String outputResult = "";
|
|
|
+ outputResult += (alloy + alloystatus + newProductType + " ");
|
|
|
+ //获取长宽高
|
|
|
+ String thickness = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getThickness()) ? removeExtraZerosAndDecimal(apsProcessOutputProductDo.getThickness()) : "";
|
|
|
+ String prowidth = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getProwidth()) ? removeExtraZerosAndDecimal(apsProcessOutputProductDo.getProwidth()) : "";
|
|
|
+ String prolength = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getProlength()) ? removeExtraZerosAndDecimal(apsProcessOutputProductDo.getProlength()) : "";
|
|
|
+ outputResult += ("厚" + thickness + "*宽" + prowidth);
|
|
|
+ if (ObjectUtil.isNotEmpty(prolength)) {
|
|
|
+ outputResult += ("*长" + prolength);
|
|
|
+ }
|
|
|
+ outputResult += ("mm * " + apsProcessOutputProductDo.getPlanoutputorderroll() + "卷");
|
|
|
+
|
|
|
+ endUpdateOutput.setOutputresult(outputResult);
|
|
|
+ isNeedUpdateBlank = true;
|
|
|
+ }
|
|
|
+ apsProcessOutputProductService.updateById(endUpdateOutput);
|
|
|
+ }
|
|
|
+ if (isNeedUpdateBlank) {
|
|
|
+ //如果坯料计划是暂存,不做处理
|
|
|
+ if (apsBlankOrderDo.getIsstag().equals("是")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ApsBlankOrderDo endUpdateBlank = new ApsBlankOrderDo();
|
|
|
+ endUpdateBlank.setId(apsBlankOrderDo.getId());
|
|
|
+ //=============更新坯料计划的 输出订单产品 和 输出成品===========
|
|
|
+ //查询坯料计划对应的输出成品
|
|
|
+ List<ApsProcessOutputProductDo> processOutputProductDoList = apsProcessOutputProductService.list(new QueryWrapper<ApsProcessOutputProductDo>().lambda().eq(ApsProcessOutputProductDo::getBlankid, apsBlankOrderDo.getId()));
|
|
|
+ if (processOutputProductDoList != null && processOutputProductDoList.size() > 0) {
|
|
|
+ //获取所有输出成品的输出成品
|
|
|
+ List<String> outputFinishList = processOutputProductDoList.stream().map(ApsProcessOutputProductDo::getOutputresult).sorted(String::compareTo).collect(Collectors.toList());
|
|
|
+ //输出成品
|
|
|
+ String outputFinishProduct = "";
|
|
|
+
|
|
|
+ for (int i = 0; i < outputFinishList.size(); i++) {
|
|
|
+ outputFinishProduct += "[" + (i + 1) + "]" + outputFinishList.get(i);
|
|
|
+ if (i < outputFinishList.size() - 1) {
|
|
|
+ outputFinishProduct += ",\r\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ endUpdateBlank.setOutputfinishproduct(outputFinishProduct);
|
|
|
+
|
|
|
+ //输出订单产品
|
|
|
+ String outputOrderProduct = "";
|
|
|
+ //获取所有输出成品的输出订单产品
|
|
|
+ List<String> outputOrderProductList = processOutputProductDoList.stream().map(item -> {
|
|
|
+ String outputresult = item.getOutputresult();
|
|
|
+ String[] s = outputresult.split(" ");
|
|
|
+ return s[0] + " " + s[1] + " " + removeExtraZerosAndDecimal(item.getOutputonerollweigth()) + " * " + item.getPlanoutputorderroll() + "卷 = " + removeExtraZerosAndDecimal(item.getPlanoutputonerollweight());
|
|
|
+ }).sorted(String::compareTo).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (int i = 0; i < outputOrderProductList.size(); i++) {
|
|
|
+ outputOrderProduct += "[" + (i + 1) + "]" + outputOrderProductList.get(i);
|
|
|
+ if (i < outputOrderProductList.size() - 1) {
|
|
|
+ outputOrderProduct += ",\r\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ endUpdateBlank.setOutputorderproduct(outputOrderProduct);
|
|
|
+ } else {
|
|
|
+ throw new CustomException("没有找到该坯料计划的输出成品");
|
|
|
+ }
|
|
|
+ endNeedUpdateBlankList.add(endUpdateBlank);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (endNeedUpdateBlankList.size() > 0) {
|
|
|
+ apsBlankOrderService.updateBatchById(endNeedUpdateBlankList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String removeExtraZerosAndDecimal(BigDecimal bd) {
|
|
|
+ bd = bd.stripTrailingZeros();
|
|
|
+ return bd.toPlainString();
|
|
|
+ }
|
|
|
}
|