|
|
|
@ -2,6 +2,7 @@ package com.gaotao.modules.other.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.gaotao.common.exception.XJException; |
|
|
|
import com.gaotao.common.utils.IfsErrorMessageUtils; |
|
|
|
import com.gaotao.modules.api.service.IfsApiIssueAndReturnService; |
|
|
|
import com.gaotao.modules.handlingunit.entity.HandlingUnit; |
|
|
|
import com.gaotao.modules.handlingunit.service.HandlingUnitService; |
|
|
|
@ -71,7 +72,7 @@ public class OtherInboundServiceImpl implements OtherInboundService { |
|
|
|
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
|
|
|
// 1. 验证目标库位 |
|
|
|
validateTargetLocation(dto.getSite(), dto.getTargetLocationId()); |
|
|
|
String warehouseId = validateTargetLocation(dto.getSite(), dto.getTargetLocationId()); |
|
|
|
|
|
|
|
// 2. 验证HandlingUnit |
|
|
|
List<HandlingUnit> handlingUnits = validateHandlingUnits(dto); |
|
|
|
@ -84,7 +85,7 @@ public class OtherInboundServiceImpl implements OtherInboundService { |
|
|
|
transRequest.setSubList(subList); |
|
|
|
|
|
|
|
// 5. 调用独立的其它入库方法生成记录和变更库存 |
|
|
|
List<TransDetail> detailList = genOtherInboundTransAndChangeStock(transRequest, "IN"); |
|
|
|
List<TransDetail> detailList = genOtherInboundTransAndChangeStock(transRequest, "IN",warehouseId); |
|
|
|
|
|
|
|
// 6. 调用IFS接口同步入库信息 |
|
|
|
for (TransDetail detail : detailList) { |
|
|
|
@ -104,6 +105,9 @@ public class OtherInboundServiceImpl implements OtherInboundService { |
|
|
|
// 检查IFS响应,如果失败可能需要回滚事务 |
|
|
|
if (!"IFSUpdated".equals(ifsResponse) && !"\"IFSUpdated\"".equals(ifsResponse)) { |
|
|
|
throw new XJException("IFS同步失败,响应: " + ifsResponse); |
|
|
|
} else { |
|
|
|
String errorMessage = IfsErrorMessageUtils.extractOracleErrorMessage(ifsResponse); |
|
|
|
throw new Exception(errorMessage); |
|
|
|
} |
|
|
|
} catch (Exception ifsException) { |
|
|
|
throw new XJException("其它入库IFS同步失败: " + ifsException.getMessage()); |
|
|
|
@ -121,7 +125,7 @@ public class OtherInboundServiceImpl implements OtherInboundService { |
|
|
|
/** |
|
|
|
* 验证目标库位 |
|
|
|
*/ |
|
|
|
private void validateTargetLocation(String site, String targetLocationId) { |
|
|
|
private String validateTargetLocation(String site, String targetLocationId) { |
|
|
|
if (!locationService.validateTargetLocation(site, targetLocationId)) { |
|
|
|
throw new XJException("目标库位无效或未启用: " + targetLocationId); |
|
|
|
} |
|
|
|
@ -136,6 +140,7 @@ public class OtherInboundServiceImpl implements OtherInboundService { |
|
|
|
if ("Y".equals(location.getHold())) { |
|
|
|
throw new XJException("目标库位已被冻结,无法入库: " + targetLocationId); |
|
|
|
} |
|
|
|
return location.getWarehouseId(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -207,7 +212,7 @@ public class OtherInboundServiceImpl implements OtherInboundService { |
|
|
|
* 其它入库独立的事务生成和库存变更方法 |
|
|
|
*/ |
|
|
|
@Transactional |
|
|
|
public List<TransDetail> genOtherInboundTransAndChangeStock(OtherInboundTransRequestDto dto, String fangxiang) { |
|
|
|
public List<TransDetail> genOtherInboundTransAndChangeStock(OtherInboundTransRequestDto dto, String fangxiang,String warehouseId) { |
|
|
|
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
String direction = ""; |
|
|
|
if("OUT".equals(fangxiang)){ |
|
|
|
@ -329,7 +334,7 @@ public class OtherInboundServiceImpl implements OtherInboundService { |
|
|
|
|
|
|
|
for(TransDetail detail : detailList){ |
|
|
|
// 变更库存 |
|
|
|
inventoryStockService.changeInventoryStock(detail.getSite(), detail.getOrderRef4(), detail.getPartNo(), |
|
|
|
inventoryStockService.changeInventoryStock(detail.getSite(), warehouseId, detail.getPartNo(), |
|
|
|
detail.getBatchNo(), detail.getLocationId(), detail.getTransQty(), detail.getWdrNo(), fangxiang); |
|
|
|
} |
|
|
|
|
|
|
|
|