Commit 6dcf1f0c sunke

接口重构

1 个父辈 3a32a47e
...@@ -248,6 +248,7 @@ public class DataInitManager { ...@@ -248,6 +248,7 @@ public class DataInitManager {
"barcode", "barcode",
"barcodeSetting", "barcodeSetting",
"taskLog", "taskLog",
"msdSetting",
//"orderSetting",//工单设置 //"orderSetting",//工单设置
"inOutData", //报表->出入库 "inOutData", //报表->出入库
"inventory", //报表->库存 "inventory", //报表->库存
......
...@@ -104,27 +104,16 @@ public class SmfApi { ...@@ -104,27 +104,16 @@ public class SmfApi {
} }
} }
public Barcode resolveBarcode(CodeValidateParam param) throws ValidateException{
for (ISmfApiListener apiListener : apiListenerList) {
Barcode responseBarcode = apiListener.resolveBarcode(inCheckUrl,param);
if(responseBarcode != null){
return responseBarcode;
}
}
return null;
}
/** /**
* 条码解析之前到API验证是否可以入库 * 条码解析之前到API验证是否可以入库
* @param codeStr
* @return * @return
* @throws ValidateException * @throws ValidateException
*/ */
public Barcode canPutInBeforeResolve(String codeStr) throws ValidateException{ public Barcode canPutInBeforeResolve(CodeValidateParam params) throws ValidateException{
if(isUrlExist(inCheckUrl)){ if(isUrlExist(inCheckUrl)){
for (ISmfApiListener apiListener : apiListenerList) { for (ISmfApiListener apiListener : apiListenerList) {
if(apiListener.isForThisApi(apiName)){ if(apiListener.isForThisApi(apiName)){
Barcode responseBarcode = apiListener.canPutInBeforeResolve(inCheckUrl, codeStr); Barcode responseBarcode = apiListener.canPutInBeforeResolve(inCheckUrl, params);
if(responseBarcode != null){ if(responseBarcode != null){
return responseBarcode; return responseBarcode;
} }
......
...@@ -9,6 +9,7 @@ import com.neotel.smfcore.core.api.bean.ApiResult; ...@@ -9,6 +9,7 @@ import com.neotel.smfcore.core.api.bean.ApiResult;
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.api.bean.CodeValidateParam; import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inList.service.manager.IInListManager; import com.neotel.smfcore.core.inList.service.manager.IInListManager;
import com.neotel.smfcore.core.inList.service.po.InList; import com.neotel.smfcore.core.inList.service.po.InList;
import com.neotel.smfcore.core.inList.service.po.InListItem; import com.neotel.smfcore.core.inList.service.po.InListItem;
...@@ -45,6 +46,9 @@ public abstract class BaseSmfApiListener implements ISmfApiListener { ...@@ -45,6 +46,9 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
@Autowired @Autowired
protected InListCache inListCache; protected InListCache inListCache;
@Autowired
protected DataCache dataCache;
@Override @Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task){ public void inTaskStatusChange(String inNotifyUrl, DataLog task){
...@@ -56,11 +60,6 @@ public abstract class BaseSmfApiListener implements ISmfApiListener { ...@@ -56,11 +60,6 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
} }
@Override @Override
public Barcode resolveBarcode(String url, CodeValidateParam param) throws ValidateException {
return null;
}
@Override
public Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException { public Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException {
return null; return null;
} }
...@@ -76,7 +75,7 @@ public abstract class BaseSmfApiListener implements ISmfApiListener { ...@@ -76,7 +75,7 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
} }
@Override @Override
public Barcode canPutInBeforeResolve(String inCheckUrl, String codeStr) throws ValidateException { public Barcode canPutInBeforeResolve(String inCheckUrl, CodeValidateParam params) throws ValidateException {
return null; return null;
} }
} }
...@@ -82,13 +82,6 @@ public class DefaultSmfApiListener extends BaseSmfApiListener { ...@@ -82,13 +82,6 @@ public class DefaultSmfApiListener extends BaseSmfApiListener {
} }
} }
@Override
public Barcode resolveBarcode(String url, CodeValidateParam param) throws ValidateException {
return null;
}
private String getData(Map<String,Object> dataMap, String dataKey){ private String getData(Map<String,Object> dataMap, String dataKey){
Object data = dataMap.get(dataKey); Object data = dataMap.get(dataKey);
if(data == null){ if(data == null){
......
...@@ -25,26 +25,16 @@ public interface ISmfApiListener { ...@@ -25,26 +25,16 @@ public interface ISmfApiListener {
void outTaskStatusChange(String outNotifyUrl, DataLog task); void outTaskStatusChange(String outNotifyUrl, DataLog task);
/** /**
* 传入原始条码,API解析条码,注意条码中带有尺寸信息,此方法会在canPutIn方法之前调用,通常料架使用(其他设备会有尺寸信息且会有多个条码所以不适用此方法)
* @param param
* @return
* @throws ValidateException
*/
Barcode resolveBarcode(String inCheckUrl, CodeValidateParam param) throws ValidateException;
/**
* 是否可入库验证 * 是否可入库验证
*/ */
Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException; Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException;
/** /**
* 入库扫条码后在解析之前进行验证 * 入库扫条码后在解析之前进行验证
* @param inCheckUrl
* @param codeStr
* @return * @return
* @throws ValidateException * @throws ValidateException
*/ */
Barcode canPutInBeforeResolve(String inCheckUrl, String codeStr)throws ValidateException; Barcode canPutInBeforeResolve(String inCheckUrl, CodeValidateParam params)throws ValidateException;
/** /**
* 工单状态改变 * 工单状态改变
......
...@@ -6,6 +6,7 @@ import com.google.common.collect.Lists; ...@@ -6,6 +6,7 @@ import com.google.common.collect.Lists;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.ReelLockPosUtil; import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.core.api.SmfApi; import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.barcode.bean.CodeBean; import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE; import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS; import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS;
...@@ -233,7 +234,8 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -233,7 +234,8 @@ public class BaseDeviceHandler implements IDeviceHandler {
type=COMPONENT_TYPE.FIXTURE; type=COMPONENT_TYPE.FIXTURE;
} }
String codeStr = statusBean.getCode(); String codeStr = statusBean.getCode();
Barcode barcodeSave = smfApi.canPutInBeforeResolve(codeStr); CodeValidateParam params = new CodeValidateParam("",storage.getGroupId(),storage.getId(),codeStr,"");
Barcode barcodeSave = smfApi.canPutInBeforeResolve(params);
if(barcodeSave == null){ if(barcodeSave == null){
barcodeSave = codeResolve.resolveOneValideBarcode(codeStr,type); barcodeSave = codeResolve.resolveOneValideBarcode(codeStr,type);
} }
......
...@@ -94,10 +94,8 @@ public class NLPShelfHandler extends BaseDeviceHandler{ ...@@ -94,10 +94,8 @@ public class NLPShelfHandler extends BaseDeviceHandler{
} }
} }
Barcode barcodeSave = smfApi.resolveBarcode(new CodeValidateParam( loginUser,groupId,storageId,code,token)); CodeValidateParam params = new CodeValidateParam(loginUser,groupId,storageId,code,token);
if(barcodeSave == null){ Barcode barcodeSave = smfApi.canPutInBeforeResolve(params);
barcodeSave = smfApi.canPutInBeforeResolve(code);
}
if(barcodeSave == null){ if(barcodeSave == null){
barcodeSave = codeResolve.resolveOneValideBarcode("=1x1="+code); barcodeSave = codeResolve.resolveOneValideBarcode("=1x1="+code);
......
...@@ -5,6 +5,7 @@ import com.google.common.base.Strings; ...@@ -5,6 +5,7 @@ import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.bean.NLShelfOperateBean; import com.neotel.smfcore.core.device.bean.NLShelfOperateBean;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
...@@ -315,7 +316,7 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -315,7 +316,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
if(resultBean != null){ if(resultBean != null){
return resultBean; return resultBean;
} }
resultBean = putInProcess(code, token, loginUser); resultBean = putInProcess(groupId, storageId, code, token, loginUser);
if(resultBean != null){ if(resultBean != null){
return resultBean; return resultBean;
} }
...@@ -348,11 +349,12 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -348,11 +349,12 @@ public class NLShelfHandler extends BaseDeviceHandler {
} }
return null; return null;
} }
private ResultBean putInProcess(String code, String token,String loginUser){ private ResultBean putInProcess(String groupId, String storageId, String code, String token,String loginUser){
String barcodeStr = "=1x1=" + code;
//扫的是物料条码 //扫的是物料条码
Barcode barcode = smfApi.canPutInBeforeResolve(barcodeStr); CodeValidateParam params = new CodeValidateParam(loginUser,groupId,storageId,code,token);
Barcode barcode = smfApi.canPutInBeforeResolve(params);
if(barcode == null){ if(barcode == null){
String barcodeStr = "=1x1=" + code;
barcode = codeResolve.resolveOneValideBarcode(barcodeStr); barcode = codeResolve.resolveOneValideBarcode(barcodeStr);
} }
barcode = smfApi.canPutInAfterResolve(barcode); barcode = smfApi.canPutInAfterResolve(barcode);
......
...@@ -15,7 +15,7 @@ public class HellaApiHandler extends BaseSmfApiListener { ...@@ -15,7 +15,7 @@ public class HellaApiHandler extends BaseSmfApiListener {
private HellaServiceHandler hellaServiceHandler; private HellaServiceHandler hellaServiceHandler;
@Override @Override
public Barcode resolveBarcode(String url, CodeValidateParam param) throws ValidateException { public Barcode canPutInBeforeResolve(String url, CodeValidateParam param) throws ValidateException {
if (!HellaTcpClient.isEnable()) { if (!HellaTcpClient.isEnable()) {
return null; return null;
} }
......
...@@ -4,12 +4,14 @@ import cn.hutool.core.util.ObjectUtil; ...@@ -4,12 +4,14 @@ import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.HttpHelper; import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil; import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener; import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.bean.CodeBean; import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE; import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager; import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve; import com.neotel.smfcore.core.barcode.utils.CodeResolve;
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.siemens.bean.LotCheckInfo; import com.neotel.smfcore.custom.siemens.bean.LotCheckInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -52,7 +54,7 @@ public class SiemensApi extends BaseSmfApiListener { ...@@ -52,7 +54,7 @@ public class SiemensApi extends BaseSmfApiListener {
public void inTaskStatusChange(String inNotifyUrl, DataLog task) { public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if(task.isFinished()){ if(task.isFinished()){
if(task.isPutInTask()){ if(task.isPutInTask()){
lotInOut(inNotifyUrl, task.getBarcode(),1); lotInOut(inNotifyUrl, task.getBarcode(),1,task.getCid());
} }
} }
} }
...@@ -63,13 +65,13 @@ public class SiemensApi extends BaseSmfApiListener { ...@@ -63,13 +65,13 @@ public class SiemensApi extends BaseSmfApiListener {
if(task.isPutInTask()){ if(task.isPutInTask()){
}else{ }else{
lotInOut(outNotifyUrl, task.getBarcode(),2); lotInOut(outNotifyUrl, task.getBarcode(),2,task.getCid());
} }
} }
} }
private static boolean lotInOut(String url, String lot,int inoutType) { private static boolean lotInOut(String url, String lot,int inoutType,String deviceId) {
//String url=config.url; //String url=config.url;
if (ObjectUtil.isEmpty(url)) { if (ObjectUtil.isEmpty(url)) {
log.info("没有配置Siemens,无需通知"); log.info("没有配置Siemens,无需通知");
...@@ -85,6 +87,7 @@ public class SiemensApi extends BaseSmfApiListener { ...@@ -85,6 +87,7 @@ public class SiemensApi extends BaseSmfApiListener {
Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>();
params.put("LotID", lot); params.put("LotID", lot);
params.put("ACTION", action); params.put("ACTION", action);
params.put("deviceId", deviceId);
String result = HttpHelper.postJson(url, params); String result = HttpHelper.postJson(url, params);
log.info("Siemens[" + url + "]返回料盘[" + lot + "]的[" + action + "]结果:" + result); log.info("Siemens[" + url + "]返回料盘[" + lot + "]的[" + action + "]结果:" + result);
Map<String,Object> returnMap= JsonUtil.toMap(result); Map<String,Object> returnMap= JsonUtil.toMap(result);
...@@ -125,15 +128,20 @@ public class SiemensApi extends BaseSmfApiListener { ...@@ -125,15 +128,20 @@ public class SiemensApi extends BaseSmfApiListener {
} }
@Override @Override
public Barcode canPutInBeforeResolve(String inCheckUrl, String codeStr) throws ValidateException { public Barcode canPutInBeforeResolve(String inCheckUrl, CodeValidateParam params) throws ValidateException {
if (ObjectUtil.isEmpty(inCheckUrl)) { if (ObjectUtil.isEmpty(inCheckUrl)) {
log.info("没有配置Siemens,无需验证"); log.info("没有配置Siemens,无需验证");
return null; return null;
} }
try { try {
Collection<CodeBean> codeBeans = codeResolve.resolveCodeStr(codeStr, COMPONENT_TYPE.COMPONENT); Collection<CodeBean> codeBeans = codeResolve.resolveCodeStr(params.getCode(), COMPONENT_TYPE.COMPONENT);
String cid = "";
Storage storage = dataCache.getStorageById(params.getStorageId());
if(storage != null){
cid = storage.getCid();
}
for (CodeBean codebean : codeBeans) { for (CodeBean codebean : codeBeans) {
LotCheckInfo info = lotCheckIn(codebean.getCodeStr(),inCheckUrl); LotCheckInfo info = lotCheckIn(codebean.getCodeStr(),inCheckUrl,cid);
if (info != null && info.isStatus() && ObjectUtil.isNotEmpty(info.getPartnum()) && ObjectUtil.isNotEmpty(info.getQuantity())) { if (info != null && info.isStatus() && ObjectUtil.isNotEmpty(info.getPartnum()) && ObjectUtil.isNotEmpty(info.getQuantity())) {
//查找元器件是否存在 //查找元器件是否存在
com.neotel.smfcore.core.barcode.service.po.Component component = componentManager.findOneByPN(info.getPartnum()); com.neotel.smfcore.core.barcode.service.po.Component component = componentManager.findOneByPN(info.getPartnum());
...@@ -175,14 +183,14 @@ public class SiemensApi extends BaseSmfApiListener { ...@@ -175,14 +183,14 @@ public class SiemensApi extends BaseSmfApiListener {
return barcode; return barcode;
} }
} }
throw new ValidateException("siemens.barcode.failed","SIEMENS验证条码["+codeStr+"]失败"); throw new ValidateException("siemens.barcode.failed","SIEMENS验证条码["+params.getCode()+"]失败");
} catch (Exception ex) { } catch (Exception ex) {
log.info("siemensCheckCode 验证条码 [" + codeStr + "] 出错:"+ ex.getMessage()); log.info("siemensCheckCode 验证条码 [" + params.getCode() + "] 出错:"+ ex.getMessage());
throw new ValidateException("siemens.barcode.error", ex.getMessage()); throw new ValidateException("siemens.barcode.error", ex.getMessage());
} }
} }
public static LotCheckInfo lotCheckIn(String lot, String url) { public static LotCheckInfo lotCheckIn(String lot, String url,String deviceId) {
if (ObjectUtil.isEmpty(url)) { if (ObjectUtil.isEmpty(url)) {
log.info("没有配置Siemens,无需验证"); log.info("没有配置Siemens,无需验证");
return null; return null;
...@@ -194,6 +202,7 @@ public class SiemensApi extends BaseSmfApiListener { ...@@ -194,6 +202,7 @@ public class SiemensApi extends BaseSmfApiListener {
Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>();
params.put("LotID", lot); params.put("LotID", lot);
params.put("ACTION", action); params.put("ACTION", action);
params.put("deviceId", deviceId);
String result = HttpHelper.postJson(url, params); String result = HttpHelper.postJson(url, params);
log.info("Siemens[" + url + "]返回料盘[" + lot + "]的[" + action + "]结果:" + result); log.info("Siemens[" + url + "]返回料盘[" + lot + "]的[" + action + "]结果:" + result);
Map<String, Object> returnMap = JsonUtil.toMap(result); Map<String, Object> returnMap = JsonUtil.toMap(result);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!