From 9552fff5a4d2d9817645fbf0fb8af4c605d7b277 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Thu, 6 Nov 2025 16:23:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93=E7=89=A9?= =?UTF-8?q?=E6=96=99=E5=B1=9E=E6=80=A7=E4=B8=8D=E5=AD=98=E5=9C=A8=E5=88=99?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PartAttributeController.java | 10 +-- .../po/service/impl/PoServiceImpl.java | 61 +++++++++++++++++++ .../impl/ProductionInboundServiceImpl.java | 57 +++++++++++++++-- .../automatedWarehouse/AgvTaskMapper.xml | 7 ++- 4 files changed, 123 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gaotao/modules/factory/controller/PartAttributeController.java b/src/main/java/com/gaotao/modules/factory/controller/PartAttributeController.java index 5f1bf9b..5ef6b8b 100644 --- a/src/main/java/com/gaotao/modules/factory/controller/PartAttributeController.java +++ b/src/main/java/com/gaotao/modules/factory/controller/PartAttributeController.java @@ -30,7 +30,7 @@ public class PartAttributeController extends AbstractController { if (queryDto.getSite() == null || queryDto.getSite().trim().isEmpty()) { queryDto.setSite(getUser().getSite()); } - + PageUtils page = partAttributeService.getPartAttributeList(queryDto); return R.ok().put("page", page); } @@ -53,7 +53,7 @@ public class PartAttributeController extends AbstractController { if (partAttribute.getSite() == null || partAttribute.getSite().trim().isEmpty()) { partAttribute.setSite(getUser().getSite()); } - + return partAttributeService.savePartAttribute(partAttribute); } @@ -66,7 +66,7 @@ public class PartAttributeController extends AbstractController { if (partAttribute.getSite() == null || partAttribute.getSite().trim().isEmpty()) { partAttribute.setSite(getUser().getSite()); } - + return partAttributeService.updatePartAttribute(partAttribute); } @@ -74,8 +74,8 @@ public class PartAttributeController extends AbstractController { * 删除料件属性 */ @PostMapping("/delete") - public R delete(@RequestParam String site, @RequestParam String partNo) { - return partAttributeService.deletePartAttribute(site, partNo); + public R delete(@RequestBody PartAttribute partAttribute) { + return partAttributeService.deletePartAttribute(partAttribute.getSite(), partAttribute.getPartNo()); } /** diff --git a/src/main/java/com/gaotao/modules/po/service/impl/PoServiceImpl.java b/src/main/java/com/gaotao/modules/po/service/impl/PoServiceImpl.java index 3ea51c0..fd45bd9 100644 --- a/src/main/java/com/gaotao/modules/po/service/impl/PoServiceImpl.java +++ b/src/main/java/com/gaotao/modules/po/service/impl/PoServiceImpl.java @@ -1,12 +1,15 @@ package com.gaotao.modules.po.service.impl; import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.gaotao.common.exception.XJException; import com.gaotao.common.utils.*; import com.gaotao.modules.factory.dao.AccessSiteMapper; +import com.gaotao.modules.factory.dao.PartAttributeMapper; +import com.gaotao.modules.factory.entity.PartAttribute; import com.gaotao.modules.factory.entity.Site; import lombok.extern.slf4j.Slf4j; @@ -77,6 +80,8 @@ public class PoServiceImpl extends ServiceImpl implemen private com.gaotao.modules.handlingunit.service.HandlingUnitIdLogService handlingUnitIdLogService; @Autowired private LocationService locationService; + @Autowired + private PartAttributeMapper partAttributeMapper; @Value("${custom.ifs-url}") private String ifsUrl; @@ -226,6 +231,8 @@ public class PoServiceImpl extends ServiceImpl implemen if ("N".equals(inData.getNeedCheck())) { genInventoryStock(inData, transHeader, receiptDetail); } + // 处理料件属性(创建或更新) + handlePartAttribute(inData); // 同步到IFS syncToIFS(inData); /* Map weiwaiMap = isWeiwai(inData); @@ -789,6 +796,60 @@ public class PoServiceImpl extends ServiceImpl implemen return poReceiptDetail; } + /** + * 处理料件属性(PartAttribute) + *

业务规则:

+ *
    + *
  • 如果料件属性不存在,则新建,默认值:进立库=Y、常用料=Y、机械臂抓取=Y、高度=传入值
  • + *
  • 如果料件属性已存在且传入了高度,则只更新高度
  • + *
+ * + * @param inData 采购入库数据 + */ + private void handlePartAttribute(TransDetailDto inData) { + try { + String site = inData.getSite(); + String partNo = inData.getPartNo(); + BigDecimal height = inData.getHeight(); + + log.info("开始处理料件属性,site: {}, partNo: {}, height: {}", site, partNo, height); + + // 检查料件属性是否已存在 + PartAttribute existing = partAttributeMapper.getPartAttributeByKey(site, partNo); + + if (existing == null) { + // 不存在则新建,设置默认值 + PartAttribute partAttribute = new PartAttribute(); + partAttribute.setSite(site); + partAttribute.setPartNo(partNo); + partAttribute.setIsInWh("Y"); // 默认进立库 + partAttribute.setIsCommonlyUsed("Y"); // 默认常用料 + partAttribute.setIsRobotPick("Y"); // 默认机械臂抓取 + partAttribute.setHeight(height != null ? height : BigDecimal.ZERO); // 高度不能为空,默认0 + + partAttributeMapper.insert(partAttribute); + log.info("料件属性创建成功,site: {}, partNo: {}, height: {}", site, partNo, height); + } else { + // 已存在且传入了高度,则只更新高度 + if (height != null) { + // 使用 UpdateWrapper 按照联合主键(site + partNo)更新 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(PartAttribute::getSite, site) + .eq(PartAttribute::getPartNo, partNo) + .set(PartAttribute::getHeight, height); + partAttributeMapper.update(null, updateWrapper); + log.info("料件属性高度更新成功,site: {}, partNo: {}, 新高度: {}", site, partNo, height); + } else { + log.debug("料件属性已存在且未传入高度,跳过更新,site: {}, partNo: {}", site, partNo); + } + } + } catch (Exception e) { + // 不抛出异常,避免影响主流程 + log.error("处理料件属性失败,site: {}, partNo: {}, 错误: {}", + inData.getSite(), inData.getPartNo(), e.getMessage(), e); + } + } + @Override public List> getPoReceiveRecords(String poNumber, String site, String warehouseId) { return poReceiptDetailService.getPoReceiveRecords(poNumber, site, warehouseId); diff --git a/src/main/java/com/gaotao/modules/production/service/impl/ProductionInboundServiceImpl.java b/src/main/java/com/gaotao/modules/production/service/impl/ProductionInboundServiceImpl.java index ab8dc1b..b39762d 100644 --- a/src/main/java/com/gaotao/modules/production/service/impl/ProductionInboundServiceImpl.java +++ b/src/main/java/com/gaotao/modules/production/service/impl/ProductionInboundServiceImpl.java @@ -1,5 +1,6 @@ package com.gaotao.modules.production.service.impl; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; @@ -9,6 +10,8 @@ import com.gaotao.common.utils.HttpUtils; import com.gaotao.common.utils.IfsErrorMessageUtils; import com.gaotao.modules.api.entity.IfsShopOrder; import com.gaotao.modules.api.service.IfsApiService; +import com.gaotao.modules.factory.dao.PartAttributeMapper; +import com.gaotao.modules.factory.entity.PartAttribute; import com.gaotao.modules.notify.entity.vo.ShopOrderMaterialVo; import com.gaotao.modules.handlingunit.entity.HandlingUnit; import com.gaotao.modules.handlingunit.entity.HandlingUnitDetail; @@ -86,6 +89,9 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { @Autowired private LocationService locationService; + @Autowired + private PartAttributeMapper partAttributeMapper; + @Autowired private IfsApiService ifsApiService; @@ -644,7 +650,8 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { // 6. 生成库存 genInventoryStock(transDetailDto, transHeader); log.info("生成库存成功"); - + // 处理料件属性(创建或更新) + handlePartAttribute(dto); // 7. 调用IFS接口ManualReceiveShopOrder callIfsManualReceiveShopOrder(dto, transNo); log.info("=== 生产订单入库完成 === 事务号: {}, 创建HU数量: {}", transNo, unitIds.size()); @@ -660,6 +667,46 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { } } + private void handlePartAttribute(ShopOrderInboundDto inData) { + try { + String site = inData.getSite(); + String partNo = inData.getPartNo(); + BigDecimal height = BigDecimal.valueOf(inData.getHeight()!= null ? inData.getHeight() : 0); + + log.info("开始处理料件属性,site: {}, partNo: {}, height: {}", site, partNo, height); + + // 检查料件属性是否已存在 + PartAttribute existing = partAttributeMapper.getPartAttributeByKey(site, partNo); + + if (existing == null) { + // 不存在则新建,设置默认值 + PartAttribute partAttribute = new PartAttribute(); + partAttribute.setSite(site); + partAttribute.setPartNo(partNo); + partAttribute.setIsInWh("Y"); // 默认进立库 + partAttribute.setIsCommonlyUsed("Y"); // 默认常用料 + partAttribute.setIsRobotPick("Y"); // 默认机械臂抓取 + partAttribute.setHeight(height); // 高度不能为空,默认0 + + partAttributeMapper.insert(partAttribute); + log.info("料件属性创建成功,site: {}, partNo: {}, height: {}", site, partNo, height); + } else { + // 已存在且传入了高度,则只更新高度 + // 使用 UpdateWrapper 按照联合主键(site + partNo)更新 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(PartAttribute::getSite, site) + .eq(PartAttribute::getPartNo, partNo) + .set(PartAttribute::getHeight, height); + partAttributeMapper.update(null, updateWrapper); + log.info("料件属性高度更新成功,site: {}, partNo: {}, 新高度: {}", site, partNo, height); + } + } catch (Exception e) { + // 不抛出异常,避免影响主流程 + log.error("处理料件属性失败,site: {}, partNo: {}, 错误: {}", + inData.getSite(), inData.getPartNo(), e.getMessage(), e); + } + } + /** * @Author System * @Description 创建Handling Unit @@ -753,12 +800,12 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { handlingUnit.setOriginalQty(BigDecimal.valueOf(huInfo.getPerQty())); handlingUnit.setReceiveDate(new Date()); handlingUnit.setWdr(dto.getWdr()!=null ? dto.getWdr() : "*"); - + // 设置高度 if (dto.getHeight() != null && dto.getHeight() > 0) { handlingUnit.setHeight(BigDecimal.valueOf(dto.getHeight())); } - + // 保存HandlingUnit主记录并检查返回值 boolean saveResult = handlingUnitService.save(handlingUnit); if (!saveResult) { @@ -771,7 +818,7 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { ); throw new XJException("标签保存失败(save返回false): " + unitId); } - + // 立即验证是否保存成功(防止保存失败但业务继续执行) HandlingUnit savedUnit = handlingUnitService.getById(unitId); if (savedUnit == null) { @@ -785,7 +832,7 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { ); throw new XJException("标签保存失败(验证未通过): " + unitId); } - + // 更新日志为成功 handlingUnitIdLogService.logUnitIdGeneration( unitId, inData.getSite(), "PRODUCTION_INBOUND", dto.getOrderNo(), diff --git a/src/main/resources/mapper/automatedWarehouse/AgvTaskMapper.xml b/src/main/resources/mapper/automatedWarehouse/AgvTaskMapper.xml index a756cde..90ff070 100644 --- a/src/main/resources/mapper/automatedWarehouse/AgvTaskMapper.xml +++ b/src/main/resources/mapper/automatedWarehouse/AgvTaskMapper.xml @@ -57,6 +57,9 @@ AND agv_code = #{data.agvCode} + + AND to_location = #{data.toLocation} + AND pallet_id LIKE CONCAT('%', #{data.palletId}, '%') @@ -134,7 +137,7 @@ WHERE status IN ('已创建','待下发', '未下发', 'PENDING', 'CREATED') AND from_location IS NOT NULL AND to_location IS NOT NULL - ORDER BY + ORDER BY CASE WHEN priority IS NULL THEN 0 ELSE priority END DESC, created_time ASC @@ -220,7 +223,7 @@ UPDATE wms_transport_task - SET + SET status = '已下发', wms_send_time = GETDATE(), updated_time = GETDATE()