Commit 600bf353 zshaohui

松亚入库判断接口修改

1 个父辈 96fbaa34
......@@ -8,8 +8,11 @@ import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
......@@ -23,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
......@@ -42,11 +46,98 @@ public class SungyaApi extends BaseSmfApiListener {
@Autowired
private DataCache dataCache;
@Autowired
private CodeResolve codeResolve;
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("sungya");
}
@Override
public Barcode canPutInBeforeResolve(String codeResolveUrl, CodeValidateParam codeParams) throws ValidateException {
log.info("向 Sungya[" + codeResolveUrl + "]请求料盘【" + codeParams.getCode() + "】的信息");
Collection<CodeBean> codeBeans = codeResolve.resolveCodeStr(codeParams.getCode(), COMPONENT_TYPE.COMPONENT);
String errorMsg = "";
try {
for (CodeBean codeBean : codeBeans) {
if (codeBean.getReelHeight() <= 0) {
codeBean.setReelHeight(1);
}
if (codeBean.getReelWidth() <= 0) {
codeBean.setReelWidth(1);
}
Barcode barcode = codeBean.getBarcode();
if (codeBean.getBarcode() == null) {
barcode = new Barcode();
barcode.setBarcode(codeBean.getCodeStr());
}
barcode.setPlateSize(codeBean.getReelWidth());
barcode.setHeight(codeBean.getReelHeight());
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("funcname", "INWHCK");
Map<String, String> bodyMap = new HashMap<>();
bodyMap.put("reelId", barcode.getBarcode());
bodyMap.put("fullCode", StringUtils.isBlank(barcode.getFullCode()) ? barcode.getBarcode() : barcode.getFullCode());
paramMap.put("body", bodyMap);
log.info(barcode.getBarcode() + "入库验证,参数:" + JsonUtil.toJsonStr(paramMap));
String result = HttpHelper.postJson(codeResolveUrl, paramMap);
log.info(barcode.getBarcode() + "入库验证,出参:" + result);
SungyaResult sungyaResult = JsonUtil.toObj(result, SungyaResult.class);
if ("1".equals(sungyaResult.getStatus())) {
Item item = sungyaResult.getItem();
//物料编号
if (StringUtils.isNotBlank(item.getPartNum())) {
barcode.setPartNumber(item.getPartNum());
}
//供应商信息
if (StringUtils.isNotBlank(item.getVendor())) {
barcode.setProvider(item.getVendor());
}
//物料数量
if (item.getQty() != null) {
barcode.setAmount(item.getQty());
}
//尺寸
if (item.getW() != null) {
barcode.setPlateSize(item.getW());
}
//厚度
if (item.getH() != null) {
barcode.setHeight(item.getH());
}
//生产日期
if (StringUtils.isNotBlank(item.getProduceDate())) {
barcode.setProduceDate(DateUtil.toDate(item.getProduceDate(), "yyyy-MM-dd HH:mm:ss"));
}
//过期时间
if (StringUtils.isNotBlank(item.getExpireDate())) {
barcode.setExpireDate(DateUtil.toDate(item.getExpireDate(), "yyyy-MM-dd HH:mm:ss"));
}
//批次
if (StringUtils.isNotBlank(item.getBatch())) {
barcode.setBatch(item.getBatch());
}
//搅拌时间(锡膏料仓使用)
if (item.getMixTime() != null) {
barcode.setMixTime(item.getMixTime());
}
return barcode;
} else {
errorMsg = "Sungya [" + barcode.getBarcode() + "] NG:" + result;
}
}
} catch (Exception e) {
String msg = "Request to Sungya[" + codeParams.getCode() + "] Error";
log.error(msg, e);
throw new ValidateException("sungya.error", msg + ":" + e.getMessage());
}
throw new ValidateException(errorMsg, "Sungya验证失败");
}
/**
* 入库判定接口
*
......@@ -58,7 +149,7 @@ public class SungyaApi extends BaseSmfApiListener {
*/
@Override
public Barcode canPutInAfterResolve(String inCheckUrl, CodeValidateParam params, Barcode barcode) throws ValidateException {
try {
/*try {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("funcname", "INWHCK");
Map<String, String> bodyMap = new HashMap<>();
......@@ -116,7 +207,8 @@ public class SungyaApi extends BaseSmfApiListener {
} catch (ApiException e) {
log.error("入库验证接口出错:" + e.getMessage());
throw new ValidateException("smfcore.mesApi.inCheck.error", "MES验证出错:" + e.getMessage());
}
}*/
return null;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!