|
|
|
@ -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<PartAttribute> 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(), |
|
|
|
|