Commit e4fa3efe LN

Merge remote-tracking branch 'origin/master'

2 个父辈 d0e86b7e 6284782a
...@@ -36,6 +36,12 @@ public class SmfApi { ...@@ -36,6 +36,12 @@ public class SmfApi {
protected String inCheckUrl = ""; protected String inCheckUrl = "";
/** /**
* 出库验证
*/
@Value("${api.outCheckUrl:}")
protected String outCheckUrl = "";
/**
* 扫码后,条码解析前进行入库验证 * 扫码后,条码解析前进行入库验证
*/ */
@Value("${api.codeResolveUrl:}") @Value("${api.codeResolveUrl:}")
...@@ -71,6 +77,7 @@ public class SmfApi { ...@@ -71,6 +77,7 @@ public class SmfApi {
apiName = dataCache.getConfigCache("api.name",apiName); apiName = dataCache.getConfigCache("api.name",apiName);
log.info("apiName:" + apiName); log.info("apiName:" + apiName);
inCheckUrl = dataCache.getConfigCache("api.inCheckUrl",inCheckUrl); inCheckUrl = dataCache.getConfigCache("api.inCheckUrl",inCheckUrl);
outCheckUrl = dataCache.getConfigCache("api.outCheckUrl",outCheckUrl);
codeResolveUrl = dataCache.getConfigCache("api.codeResolveUrl",codeResolveUrl); codeResolveUrl = dataCache.getConfigCache("api.codeResolveUrl",codeResolveUrl);
inNotifyUrl = dataCache.getConfigCache("api.inNotifyUrl",inNotifyUrl); inNotifyUrl = dataCache.getConfigCache("api.inNotifyUrl",inNotifyUrl);
outNotifyUrl = dataCache.getConfigCache("api.outNotifyUrl",outNotifyUrl); outNotifyUrl = dataCache.getConfigCache("api.outNotifyUrl",outNotifyUrl);
...@@ -147,6 +154,31 @@ public class SmfApi { ...@@ -147,6 +154,31 @@ public class SmfApi {
} }
/** /**
* 创建出库任务后到API验证是否可以出库
*/
public DataLog outCheck(DataLog dataLog) throws ValidateException{
if(dataLog == null){
return null;
}
if(isUrlExist(outCheckUrl)){
for (ISmfApiListener apiListener : apiListenerList) {
if(apiListener.isForThisApi(apiName)){
try{
DataLog chekcResultDataLog = apiListener.canCheckOut(outCheckUrl, dataLog);
if(chekcResultDataLog != null){
return chekcResultDataLog;
}
}catch (Exception e){
throw new ValidateException("smfcore.api.error","API Error:" + e.getMessage());
}
}
}
}
return dataLog;
}
/**
* 条码解析之后到API验证是否可以入库 * 条码解析之后到API验证是否可以入库
*/ */
public Barcode canPutInAfterResolve(CodeValidateParam params, Barcode barcode) throws ValidateException{ public Barcode canPutInAfterResolve(CodeValidateParam params, Barcode barcode) throws ValidateException{
......
...@@ -79,6 +79,11 @@ public abstract class BaseSmfApiListener implements ISmfApiListener { ...@@ -79,6 +79,11 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
return null; return null;
} }
@Override
public DataLog canCheckOut(String outCheckUrl, DataLog dataLog) throws ValidateException{
return null;
}
protected String getData(Map<String, Object> dataMap, String dataKey) { protected String getData(Map<String, Object> dataMap, String dataKey) {
Object data = dataMap.get(dataKey); Object data = dataMap.get(dataKey);
if (data == null) { if (data == null) {
......
...@@ -30,6 +30,12 @@ public interface ISmfApiListener { ...@@ -30,6 +30,12 @@ public interface ISmfApiListener {
*/ */
Barcode canPutInAfterResolve(String inCheckUrl, CodeValidateParam params, Barcode barcode) throws ValidateException; Barcode canPutInAfterResolve(String inCheckUrl, CodeValidateParam params, Barcode barcode) throws ValidateException;
/**
* 是否可出库验证
*/
DataLog canCheckOut(String outCheckUrl, DataLog dataLog) throws ValidateException;
/** /**
* 入库扫条码后在解析之前进行验证 * 入库扫条码后在解析之前进行验证
* @return * @return
......
...@@ -589,7 +589,12 @@ public class LiteOrderCache { ...@@ -589,7 +589,12 @@ public class LiteOrderCache {
// task.setLightColor(nextColor.getRgb()); // task.setLightColor(nextColor.getRgb());
task.setStatus(OP_STATUS.WAIT.name()); task.setStatus(OP_STATUS.WAIT.name());
// task = dataLogDao.save(task); // task = dataLogDao.save(task);
taskService.addTaskToExecute(task); try{
taskService.addTaskToExecute(task);
}catch (Exception e){
String msg = "工单[" + orderNo + "]["+orderItem.getId()+"]补料出库:仓位[" + pos.getPosName() + "]RI=[" + pos.getBarcode().getBarcode() + "] PN=[" + orderItem.getPn() + "] num:" + pos.getBarcode().getAmount();
log.error("补料生成任务出错["+msg+"]:"+e.getMessage());
}
} }
} }
} }
......
...@@ -164,7 +164,7 @@ public class SolderBoxCache { ...@@ -164,7 +164,7 @@ public class SolderBoxCache {
DataLog outTask = newTask(storage, storagePos,barcode); DataLog outTask = newTask(storage, storagePos,barcode);
outTask.setType(OP.CHECKOUT); outTask.setType(OP.CHECKOUT);
outTask.setMixTime(barcode.getMixTime()); outTask.setMixTime(barcode.getMixTime());
outTask = dataLogDao.save(outTask); //outTask = dataLogDao.save(outTask);
taskService.addTaskToExecute(outTask); taskService.addTaskToExecute(outTask);
//更改状态 //更改状态
...@@ -191,7 +191,7 @@ public class SolderBoxCache { ...@@ -191,7 +191,7 @@ public class SolderBoxCache {
DataLog mixTask = newTask(storage, storagePos,barcode); DataLog mixTask = newTask(storage, storagePos,barcode);
mixTask.setType(OP.MIX); mixTask.setType(OP.MIX);
mixTask.setMixTime(barcode.getMixTime()); mixTask.setMixTime(barcode.getMixTime());
mixTask = dataLogDao.save(mixTask); //mixTask = dataLogDao.save(mixTask);
taskService.addTaskToExecute(mixTask); taskService.addTaskToExecute(mixTask);
//更改状态 //更改状态
...@@ -221,12 +221,12 @@ public class SolderBoxCache { ...@@ -221,12 +221,12 @@ public class SolderBoxCache {
log.info(barcode.getBarcode() + "创建回温移库任务["+storagePos.getPosName()+"]=>" + warmPos.getPosName()); log.info(barcode.getBarcode() + "创建回温移库任务["+storagePos.getPosName()+"]=>" + warmPos.getPosName());
DataLog takingTask = newTask(storage, storagePos,barcode); DataLog takingTask = newTask(storage, storagePos,barcode);
takingTask.setType(OP.REWARM_TAKING); takingTask.setType(OP.REWARM_TAKING);
takingTask = dataLogDao.save(takingTask); //takingTask = dataLogDao.save(takingTask);
taskService.addTaskToExecute(takingTask); taskService.addTaskToExecute(takingTask);
DataLog puttingTask = newTask(storage, warmPos,barcode); DataLog puttingTask = newTask(storage, warmPos,barcode);
puttingTask.setType(OP.REWARM_PUTTING); puttingTask.setType(OP.REWARM_PUTTING);
puttingTask = dataLogDao.save(puttingTask); //puttingTask = dataLogDao.save(puttingTask);
taskService.addTaskToExecute(puttingTask); taskService.addTaskToExecute(puttingTask);
} }
} catch (ValidateException e) { } catch (ValidateException e) {
......
...@@ -169,6 +169,9 @@ public class TaskService { ...@@ -169,6 +169,9 @@ public class TaskService {
} }
} }
} }
if(taskToExecute.isCheckOutTask() && taskToExecute.isWait()){
taskToExecute = smfApi.outCheck(taskToExecute);
}
updateQueueTask(taskToExecute); updateQueueTask(taskToExecute);
} }
...@@ -543,7 +546,7 @@ public class TaskService { ...@@ -543,7 +546,7 @@ public class TaskService {
// return "order.out.notFound"; // return "order.out.notFound";
// } // }
} }
task = dataLogDao.save(task); //task = dataLogDao.save(task);
addTaskToExecute(task); addTaskToExecute(task);
return ""; return "";
} }
......
...@@ -188,7 +188,7 @@ public class AdvantechApi extends BaseSmfApiListener { ...@@ -188,7 +188,7 @@ public class AdvantechApi extends BaseSmfApiListener {
* *
*/ */
@Override @Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task){ public DataLog canCheckOut(String outCheckUrl, DataLog task) throws ValidateException{
if(task.isWait() && !task.isSingleOut()){ if(task.isWait() && !task.isSingleOut()){
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
paramMap.put("webServiceType","AKMU1"); paramMap.put("webServiceType","AKMU1");
...@@ -222,26 +222,27 @@ public class AdvantechApi extends BaseSmfApiListener { ...@@ -222,26 +222,27 @@ public class AdvantechApi extends BaseSmfApiListener {
"</REELS></root>"; "</REELS></root>";
paramMap.put("param",paramStr); paramMap.put("param",paramStr);
try { try {
log.info(task.getBarcode() + "出库通知,参数" + JsonUtil.toJsonStr(paramMap)); log.info(task.getBarcode() + "出库验证,参数" + JsonUtil.toJsonStr(paramMap));
String result = HttpHelper.postJson(outNotifyUrl, paramMap); String result = HttpHelper.postJson(outCheckUrl, paramMap);
log.info(task.getPosName() + "出库通知返回" + result); log.info(task.getBarcode() + "出库验证返回" + result);
//Map<String, Object> resultMap = JsonUtil.toMap(result); //Map<String, Object> resultMap = JsonUtil.toMap(result);
//如果返回失败,取消任务 //如果返回失败,取消任务
boolean success = isOutTaskSuccess(result,task.getBarcode()); boolean success = isOutTaskSuccess(result,task.getBarcode());
if (!success) { if (!success) {
taskService.cancelTask(task.getId()); throw new ValidateException("smfcore.mesApi.outCheck.ng","MES出库验证出错");
}else { }else {
//如果返回成功,把singleOut改为true //如果返回成功,把singleOut改为true
if (ObjectUtils.isNotEmpty(task.getSourceName())) { if (ObjectUtils.isNotEmpty(task.getSourceName())) {
task.setSingleOut(true); task.setSingleOut(true);
} }
taskService.updateQueueTask(task); return task;
} }
log.info(task.getBarcode() + "出库通知返回" + result);
} catch (Exception e) { } catch (Exception e) {
log.error("出库通知接口出错:" , e); log.error("出库通知接口出错:" , e);
throw new ValidateException("smfcore.mesApi.outCheck.ng","MES出库验证出错:"+e.getMessage());
} }
} }
return task;
} }
/** /**
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!