Commit e4fa3efe LN

Merge remote-tracking branch 'origin/master'

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