Browse Source

其他出库Ifs

master
han\hanst 7 months ago
parent
commit
23c37f27c9
  1. 15
      src/main/java/com/gaotao/modules/api/service/impl/IfsApiIssueAndReturnServiceImpl.java
  2. 35
      src/main/java/com/gaotao/modules/other/service/impl/InventoryMoveServiceImpl.java
  3. 15
      src/main/java/com/gaotao/modules/other/service/impl/OtherInboundServiceImpl.java
  4. 58
      src/main/java/com/gaotao/modules/other/service/impl/OtherOutboundServiceImpl.java
  5. 2
      src/main/java/com/gaotao/modules/po/service/impl/PoServiceImpl.java

15
src/main/java/com/gaotao/modules/api/service/impl/IfsApiIssueAndReturnServiceImpl.java

@ -364,7 +364,7 @@ public class IfsApiIssueAndReturnServiceImpl implements IfsApiIssueAndReturnServ
try {
Map<String, Object> params = new HashMap<>();
params.put("ifsDBName", ifsDBName);
params.put("domainUserID", domainUserID);
params.put("domainUserID", getCurrentDomainUserID());
params.put("ifsSiteID", otherTransactionIfsDto.getIfsSiteID());
params.put("ifsPartNo", otherTransactionIfsDto.getIfsPartNo());
params.put("ifsConfigurationID", "*");
@ -376,6 +376,7 @@ public class IfsApiIssueAndReturnServiceImpl implements IfsApiIssueAndReturnServ
params.put("ifsHandlingUntiID", otherTransactionIfsDto.getIfsHandlingUnitID());
params.put("ifsQtyReceived", otherTransactionIfsDto.getIfsQuantity());
params.put("ifsPartOwnershipDb", "COMPANY OWNED");
params.put("ifsNote", otherTransactionIfsDto.getIfsReason());
ObjectMapper objectMapper = new ObjectMapper();
String jsonBody = objectMapper.writeValueAsString(params);
@ -394,24 +395,22 @@ public class IfsApiIssueAndReturnServiceImpl implements IfsApiIssueAndReturnServ
try {
Map<String, Object> params = new HashMap<>();
params.put("ifsDBName", ifsDBName);
params.put("domainUserID", domainUserID);
params.put("domainUserID", getCurrentDomainUserID());
params.put("ifsSiteID", otherTransactionIfsDto.getIfsSiteID());
params.put("ifsPartNo", otherTransactionIfsDto.getIfsPartNo());
params.put("ifsConfigurationID", "*");
params.put("ifsLocationNo", otherTransactionIfsDto.getIfsLocationNo());
params.put("ifsLotBatchNo", otherTransactionIfsDto.getIfsLotBatchNo());
params.put("ifsSerialNo", otherTransactionIfsDto.getIfsSerialNo());
params.put("ifsWdrNo", otherTransactionIfsDto.getIfsWdrNo());
params.put("ifsEngChgLevel", otherTransactionIfsDto.getIfsEngChgLevel());
params.put("ifsActivitySeq", otherTransactionIfsDto.getIfsActivitySeq());
params.put("ifsHandlingUntiID", otherTransactionIfsDto.getIfsHandlingUnitID());
params.put("ifsQuantity", otherTransactionIfsDto.getIfsQuantity());
params.put("ifsTransactionType", otherTransactionIfsDto.getIfsTransactionType());
params.put("ifsReason", otherTransactionIfsDto.getIfsReason());
params.put("ifsOperator", otherTransactionIfsDto.getIfsOperator());
params.put("ifsQtyIssued", otherTransactionIfsDto.getIfsQuantity());
params.put("ifsNote", otherTransactionIfsDto.getIfsReason());
ObjectMapper objectMapper = new ObjectMapper();
String jsonBody = objectMapper.writeValueAsString(params);
String ifsResponse = HttpUtils.doPost(ifsUrl + "OtherOutbound", jsonBody, null);
String ifsResponse = HttpUtils.doPost(ifsUrl + "IssueInventoryPart", jsonBody, null);
return ifsResponse;
} catch (Exception e) {

35
src/main/java/com/gaotao/modules/other/service/impl/InventoryMoveServiceImpl.java

@ -31,10 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 库存移库服务实现类
@ -135,15 +132,23 @@ public class InventoryMoveServiceImpl implements InventoryMoveService {
}
// 4. 合并相同条件的HandlingUnit后调用IFS接口在更新HU之前
syncToIFSBatch(dto, handlingUnits);
syncToIFSBatchForPallet(dto, handlingUnits);
// 5. 按库存主键字段汇总HandlingUnit数据
Map<String, InventoryGroup> inventoryGroups = groupHandlingUnitsByInventoryKey(handlingUnits, originalLocations, dto.getTargetLocationId());
// 根据库位获取仓库ID
String warehouseId = null;
Location location = locationService.getByLocationIdAndSite(dto.getSite(), dto.getTargetLocationId());
if (location != null) {
warehouseId = location.getWarehouseId();
} else {
throw new XJException("目标库位不存在: " + dto.getTargetLocationId());
}
// 6. 批量处理库存操作出库和入库
for (InventoryGroup group : inventoryGroups.values()) {
// 从原库位出库
/* inventoryStockService.changeInventoryStock(
if (!"TEMP".equals(group.warehouseId)) {
inventoryStockService.changeInventoryStock(
group.site,
group.warehouseId,
group.partNo,
@ -151,21 +156,19 @@ public class InventoryMoveServiceImpl implements InventoryMoveService {
group.originalLocationId,
group.totalQty,
group.wdr,
"OUT"
);*/
"OUT");
}
// 到目标库位入库
inventoryStockService.createStockWithLock(
inventoryStockService.changeInventoryStock(
group.site,
group.warehouseId,
warehouseId,
group.partNo,
group.batchNo,
group.targetLocationId,
group.wdr,
group.originalLocationId,
group.totalQty,
"Y"
);
group.wdr,
"IN");
// 创建汇总的出库和入库事务记录
createOutboundTransactionForGroup(dto, group, currentUser);
createInboundTransactionForGroup(dto, group, currentUser);

15
src/main/java/com/gaotao/modules/other/service/impl/OtherInboundServiceImpl.java

@ -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);
}

58
src/main/java/com/gaotao/modules/other/service/impl/OtherOutboundServiceImpl.java

@ -1,6 +1,7 @@
package com.gaotao.modules.other.service.impl;
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;
@ -80,33 +81,36 @@ public class OtherOutboundServiceImpl implements OtherOutboundService {
// 5. 调用独立的其它出库方法生成记录和变更库存
List<TransDetail> detailList = genOtherOutboundTransAndChangeStock(transRequest, "OUT");
// // 6. 调用IFS接口同步出库信息
// for (TransDetail detail : detailList) {
// OtherTransactionIfsDto ifsDto = new OtherTransactionIfsDto();
// ifsDto.setIfsSiteID(dto.getSite());
// ifsDto.setIfsPartNo(detail.getPartNo());
// ifsDto.setIfsLocationNo(detail.getLocationId());
// ifsDto.setIfsLotBatchNo(detail.getBatchNo());
// ifsDto.setIfsSerialNo("*");
// ifsDto.setIfsWdrNo(detail.getWdrNo());
// ifsDto.setIfsEngChgLevel("1");
// ifsDto.setIfsActivitySeq(BigDecimal.ZERO);
// ifsDto.setIfsHandlingUntitID(BigDecimal.ZERO);
// ifsDto.setIfsQuantity(detail.getTransQty());
// ifsDto.setIfsTransactionType("OUT");
// ifsDto.setIfsReason(dto.getOutboundReason());
// ifsDto.setIfsOperator(dto.getOperatorName());
//
// try {
// String ifsResponse = ifsApiIssueAndReturnService.addOtherOutbound(ifsDto);
// // 检查IFS响应如果失败可能需要回滚事务
// if (!"IFSUpdated".equals(ifsResponse) && !"\"IFSUpdated\"".equals(ifsResponse)) {
// throw new XJException("IFS同步失败,响应: " + ifsResponse);
// }
// } catch (Exception ifsException) {
// throw new XJException("其它出库IFS同步失败: " + ifsException.getMessage());
// }
// }
// 6. 调用IFS接口同步出库信息
for (TransDetail detail : detailList) {
OtherTransactionIfsDto ifsDto = new OtherTransactionIfsDto();
ifsDto.setIfsSiteID(dto.getSite());
ifsDto.setIfsPartNo(detail.getPartNo());
ifsDto.setIfsLocationNo(detail.getLocationId());
ifsDto.setIfsLotBatchNo(detail.getBatchNo());
ifsDto.setIfsSerialNo("*");
ifsDto.setIfsWdrNo(detail.getWdrNo());
ifsDto.setIfsEngChgLevel("1");
ifsDto.setIfsActivitySeq(BigDecimal.ZERO);
ifsDto.setIfsHandlingUnitID(BigDecimal.ZERO);
ifsDto.setIfsQuantity(detail.getTransQty());
ifsDto.setIfsTransactionType("OUT");
ifsDto.setIfsReason(dto.getOutboundReason());
ifsDto.setIfsOperator(dto.getOperatorName());
try {
String ifsResponse = ifsApiIssueAndReturnService.addOtherOutbound(ifsDto);
// 检查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());
}
}
// 7. 更新HandlingUnit状态
updateHandlingUnitStatus(handlingUnits, detailList, currentUser);

2
src/main/java/com/gaotao/modules/po/service/impl/PoServiceImpl.java

@ -131,7 +131,7 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen
String poStatus = po.get("objstate") != null ? po.get("objstate").toString() : "";
String authorizationRequired = po.get("authorizationRequired") != null ? po.get("authorizationRequired").toString() : "FALSE";
// inventoryPartDB=false需要剔除
poLineData.removeIf(line -> line.get("inventoryPartDB") != null && "false".equals(line.get("inventoryPartDB").toString()));
poLineData.removeIf(line -> line.get("inventoryPartDB") != null && "FALSE".equals(line.get("inventoryPartDB").toString()));
// 制造日期 供应商批次
for (Map<String, Object> line : poLineData) {
line.put("poStatus", poStatus);

Loading…
Cancel
Save