Commit 2f7cec2d 张少辉

1.结构仓入库,出库逻辑修改

1 个父辈 960fed33
...@@ -6,7 +6,7 @@ public class CORRESPONDING_WAREHOUSE { ...@@ -6,7 +6,7 @@ public class CORRESPONDING_WAREHOUSE {
public static final int ELECTRONIC_WAREHOUSE = 0; public static final int ELECTRONIC_WAREHOUSE = 0;
//结构仓 //结构仓
public static final int structural_warehouse = 1; public static final int STRUCTURAL_WAREHOUSE = 1;
//成品仓 //成品仓
public static final int FINISHED_GOODS_WAREHOUSE = 2; public static final int FINISHED_GOODS_WAREHOUSE = 2;
......
...@@ -8,6 +8,8 @@ import com.neotel.smfcore.common.utils.StringUtils; ...@@ -8,6 +8,8 @@ import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener; import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.storage.enums.CORRESPONDING_WAREHOUSE;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.request.GetNewContainerNoRequest; import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.request.GetNewContainerNoRequest;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.request.MergeContainerRequest; import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.request.MergeContainerRequest;
...@@ -15,6 +17,7 @@ import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.request.SplitContain ...@@ -15,6 +17,7 @@ import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.request.SplitContain
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response.GetNewContainerNoResponse; import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response.GetNewContainerNoResponse;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response.MergeContainerResponse; import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response.MergeContainerResponse;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response.SplitContainerResponse; import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response.SplitContainerResponse;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response.StockoutResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -35,6 +38,9 @@ public class MomoApi extends BaseSmfApiListener { ...@@ -35,6 +38,9 @@ public class MomoApi extends BaseSmfApiListener {
@Value("${api.stockInUrl}") @Value("${api.stockInUrl}")
private String stockInUrl; private String stockInUrl;
@Value("${api.stockOutUrl}")
private String stockOutUrl;
@Value("${api.stockReturnUrl}") @Value("${api.stockReturnUrl}")
private String stockReturnUrl; private String stockReturnUrl;
...@@ -52,14 +58,17 @@ public class MomoApi extends BaseSmfApiListener { ...@@ -52,14 +58,17 @@ public class MomoApi extends BaseSmfApiListener {
@Override @Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) { public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (task.isFinished()) { if (task.isFinished()) {
String storageId = task.getStorageId();
Storage storage = dataCache.getStorageById(storageId);
if (storage != null) {
//默认结构仓的
if (storage.getCorrespondingWarehouse() == CORRESPONDING_WAREHOUSE.STRUCTURAL_WAREHOUSE) {
String barcodeStr = task.getBarcode(); String barcodeStr = task.getBarcode();
Barcode barcode = barcodeManager.findByBarcode(barcodeStr); Barcode barcode = barcodeManager.findByBarcode(barcodeStr);
String receiptOrder = barcode.getReceiptOrder(); String receiptOrder = barcode.getReceiptOrder();
if (StringUtils.isNotEmpty(receiptOrder)){ if (StringUtils.isNotEmpty(receiptOrder)) {
stockIn(barcode); stockIn(barcode);
} else { }
if (StringUtils.isNotEmpty(barcode.getStockoutNo())){
stockReturn(barcode);
} }
} }
} }
...@@ -129,34 +138,7 @@ public class MomoApi extends BaseSmfApiListener { ...@@ -129,34 +138,7 @@ public class MomoApi extends BaseSmfApiListener {
@Override @Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) { public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if (!task.isNotifyMomo()) { if (!task.isNotifyMomo()) {
Barcode barcode = barcodeManager.findByBarcode(task.getBarcode());
if (barcode != null && StringUtils.isNotEmpty(barcode.getStockoutNo())){
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("StockoutNo", barcode.getStockoutNo());
List<Map<String, Object>> DetailItems = new ArrayList<>();
Map<String, Object> itemMap = new HashMap<>();
if (StringUtils.isNotEmpty(barcode.getPidBarcode())) {
itemMap.put("Container", barcode.getPidBarcode());
} else {
itemMap.put("Container", task.getBarcode());
}
//itemMap.put("Container", task.getBarcode());
itemMap.put("ProductName", barcode.getDescription());
itemMap.put("ProductNo", task.getPartNumber());
itemMap.put("QuantityOnHand", task.getNum());
itemMap.put("StockoutNoLine", barcode.getStockoutNoLine());
DetailItems.add(itemMap);
paramMap.put("DetailItems", DetailItems);
log.info("接口5:MOM接收WMS的出库结果,请求参数为:" + JSON.toJSONString(paramMap));
try {
String resultStr = HttpHelper.postJson(outNotifyUrl, paramMap);
log.info("接口5:MOM接收WMS的出库结果,返回参数为:" + resultStr);
} catch (ApiException e) {
log.error("接口5:MOM接收WMS的出库结果,请求异常:", e);
}
}
} }
} }
...@@ -240,6 +222,52 @@ public class MomoApi extends BaseSmfApiListener { ...@@ -240,6 +222,52 @@ public class MomoApi extends BaseSmfApiListener {
} }
/**
* 出库结果通知MOM接口
* @param barcode 条码对象
* @return StockoutResponse MOM接口返回的响应结果(异常时返回null/封装错误信息)
*/
public StockoutResponse stockOut(Barcode barcode) {
// 1. 空值校验:条码/出库单号为空时,直接返回null并记录日志
if (barcode == null || StringUtils.isEmpty(barcode.getStockoutNo())) {
log.warn("接口5:MOM接收WMS的出库结果-参数无效,barcode={},stockoutNo={}",
barcode, barcode != null ? barcode.getStockoutNo() : null);
return null;
}
// 2. 构建请求参数
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("StockoutNo", barcode.getStockoutNo());
List<Map<String, Object>> detailItems = new ArrayList<>();
Map<String, Object> itemMap = new HashMap<>();
itemMap.put("Container", StringUtils.isNotEmpty(barcode.getPidBarcode())
? barcode.getPidBarcode() : barcode.getBarcode());
itemMap.put("ProductName", barcode.getDescription());
itemMap.put("ProductNo", barcode.getPartNumber());
itemMap.put("QuantityOnHand", barcode.getAmount());
itemMap.put("StockoutNoLine", barcode.getStockoutNoLine());
detailItems.add(itemMap);
paramMap.put("DetailItems", detailItems);
// 3. 打印请求日志
String paramJson = JSON.toJSONString(paramMap);
log.info("接口5:MOM接收WMS的出库结果,请求参数为:{}", paramJson);
try {
// 4. 调用接口并获取响应
String resultStr = HttpHelper.postJson(stockOutUrl, paramMap);
log.info("接口5:MOM接收WMS的出库结果,返回参数为:{}", resultStr);
// 5. 解析响应为StockoutResponse(核心:返回解析后的结果)
StockoutResponse response = JSON.parseObject(resultStr, StockoutResponse.class);
return response;
} catch (Exception e) {
// 6. 接口调用异常:记录日志,返回封装的错误响应
log.error("接口5:MOM接收WMS的出库结果-请求异常, stockoutNo={}", barcode.getStockoutNo(), e);
StockoutResponse errorResponse = new StockoutResponse();
errorResponse.setIsSuccess(false);
errorResponse.setErrorMessage(e.getMessage());
return errorResponse;
}
}
@Override @Override
public boolean isForThisApi(String apiName) { public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("1643"); return apiName != null && apiName.equalsIgnoreCase("1643");
......
package com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response;
import lombok.Data;
@Data
public class StockoutResponse {
/**
* 内容(JSON中为null,类型设为Object兼容任意值)
*/
private Object Content;
/**
* 是否成功
*/
private Boolean IsSuccess;
/**
* 错误码(空字符串表示无错误)
*/
private String ErrorCode;
/**
* 错误消息(空字符串表示无错误)
*/
private String ErrorMessage;
/**
* 核心业务数据列表
*/
private Object Data;
}
...@@ -22,12 +22,17 @@ import com.neotel.smfcore.custom.aiqingzhiyin1643.bean.CtuCheckOutTask; ...@@ -22,12 +22,17 @@ import com.neotel.smfcore.custom.aiqingzhiyin1643.bean.CtuCheckOutTask;
import com.neotel.smfcore.custom.aiqingzhiyin1643.bean.CtuPutInTask; import com.neotel.smfcore.custom.aiqingzhiyin1643.bean.CtuPutInTask;
import com.neotel.smfcore.custom.aiqingzhiyin1643.bean.Station; import com.neotel.smfcore.custom.aiqingzhiyin1643.bean.Station;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.MomoApi; import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.MomoApi;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.request.GetNewContainerNoRequest;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.request.SplitContainerRequest;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response.GetNewContainerNoResponse;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response.StockoutResponse;
import com.neotel.smfcore.custom.aiqingzhiyin1643.structuralWarehouse.util.BoxUtil; import com.neotel.smfcore.custom.aiqingzhiyin1643.structuralWarehouse.util.BoxUtil;
import com.neotel.smfcore.custom.aiqingzhiyin1643.structuralWarehouse.util.StationCacheUtil; import com.neotel.smfcore.custom.aiqingzhiyin1643.structuralWarehouse.util.StationCacheUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
...@@ -220,11 +225,11 @@ public class AgvDeviceController { ...@@ -220,11 +225,11 @@ public class AgvDeviceController {
opTask.setOutFromPos(true); opTask.setOutFromPos(true);
} }
taskService.updateFinishedTask(opTask); taskService.updateFinishedTask(opTask);
if (!opTask.isNotifyMomo()) { /*if (!opTask.isNotifyMomo()) {
opTask.setNotifyMomo(true); opTask.setNotifyMomo(true);
taskService.moveTaskToFinished(opTask); taskService.moveTaskToFinished(opTask);
dataLogManager.save(opTask); dataLogManager.save(opTask);
} }*/
if (OP_STATUS.FINISHED.name().equals(statusStr)) { if (OP_STATUS.FINISHED.name().equals(statusStr)) {
//已完成,从完成缓存中清除 //已完成,从完成缓存中清除
...@@ -379,8 +384,37 @@ public class AgvDeviceController { ...@@ -379,8 +384,37 @@ public class AgvDeviceController {
} catch (ValidateException e) { } catch (ValidateException e) {
return ResultBean.newErrorResult(-1, e.getMsgKey(), e.getMessage(), e.getMsgParam()); return ResultBean.newErrorResult(-1, e.getMsgKey(), e.getMessage(), e.getMsgParam());
} }
Map<String, Barcode> resultMap = new HashMap<>();
int opQty = num - barcode.getAmount() >= 0 ? barcode.getAmount() : num; int opQty = num - barcode.getAmount() >= 0 ? barcode.getAmount() : num;
barcode.setAmount(barcode.getAmount() - opQty); barcode.setAmount(barcode.getAmount() - opQty);
if (StringUtils.isNotEmpty(barcode.getStockoutNo())) {
if (barcode.getAmount() == 0) {
StockoutResponse stockoutResponse = momoApi.stockOut(barcode);
if (!stockoutResponse.getIsSuccess()) {
return ResultBean.newErrorResult(-1, "smfcore.momo.stockOutError", stockoutResponse.getErrorMessage(), new String[]{});
}
} else {
GetNewContainerNoResponse newContainerNo = momoApi.getNewContainerNo(new GetNewContainerNoRequest(barcode.getProvider()));
if (!"200".equals(newContainerNo.getResult())) {
return ResultBean.newErrorResult(-1, "smfcore.momo.newBarcodeContentError", "获取新的条码内容失败[{0}]", new String[]{newContainerNo.getMessage()});
}
//拆分的条码进行通知momo
Barcode splitBarcode = new Barcode();
BeanUtils.copyProperties(barcode, splitBarcode); // 复制所有属性
splitBarcode.setPidBarcode(newContainerNo.getData());
splitBarcode.setBarcode(newContainerNo.getData());
splitBarcode.setAmount(opQty);
splitBarcode.setNeedStockNum(0);
StockoutResponse stockoutResponse = momoApi.stockOut(splitBarcode);
if (!stockoutResponse.getIsSuccess()) {
return ResultBean.newErrorResult(-1, "smfcore.momo.stockOutError", stockoutResponse.getErrorMessage(), new String[]{});
}
barcodeManager.saveBarcode(barcode);
resultMap.put("splitBarcode", splitBarcode);
resultMap.put("barcode", barcode);
}
}
if (barcode.getAmount() == 0) { if (barcode.getAmount() == 0) {
barcode.setNeedStockNum(0); barcode.setNeedStockNum(0);
} else { } else {
...@@ -395,7 +429,7 @@ public class AgvDeviceController { ...@@ -395,7 +429,7 @@ public class AgvDeviceController {
dataLog.setPartNumber(barcode.getPartNumber()); dataLog.setPartNumber(barcode.getPartNumber());
dataLog.setStatus(OP_STATUS.FINISHED.name()); dataLog.setStatus(OP_STATUS.FINISHED.name());
dataLogManager.save(dataLog); dataLogManager.save(dataLog);
return ResultBean.newOkResult(""); return ResultBean.newOkResult(resultMap);
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!