|
@@ -2,6 +2,7 @@ package com.github.zuihou.business.externalApi.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.github.zuihou.base.R;
|
|
|
import com.github.zuihou.base.service.SuperCacheServiceImpl;
|
|
@@ -23,7 +24,9 @@ import com.github.zuihou.business.productionReadyCenter.entity.Box;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.MMeterial;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.Tray;
|
|
|
import com.github.zuihou.business.util.MsgUtil;
|
|
|
+import com.github.zuihou.business.wms.ApiCallLog;
|
|
|
import com.github.zuihou.business.wms.WmsTransferTask;
|
|
|
+import com.github.zuihou.business.wms.dao.ApiCallLogMapper;
|
|
|
import com.github.zuihou.business.wms.dao.WmsTransferTaskMapper;
|
|
|
import com.github.zuihou.common.constant.CacheKey;
|
|
|
import com.github.zuihou.common.constant.CodeRuleModule;
|
|
@@ -39,10 +42,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static com.github.zuihou.common.constant.CacheKey.TENANT;
|
|
|
|
|
@@ -81,6 +81,8 @@ public class WmsAgvInfoServiceImpl extends SuperCacheServiceImpl<WmsAgvInfoMappe
|
|
|
private TrayMapper trayMapper;
|
|
|
@Autowired
|
|
|
private BoxMapper boxMapper;
|
|
|
+ @Autowired
|
|
|
+ private ApiCallLogMapper apiCallLogMapper;
|
|
|
|
|
|
@Override
|
|
|
protected String getRegion() {
|
|
@@ -105,11 +107,10 @@ public class WmsAgvInfoServiceImpl extends SuperCacheServiceImpl<WmsAgvInfoMappe
|
|
|
if(StringUtil.isEmpty(taskNo)){
|
|
|
R.fail("任务编号不能为空");
|
|
|
}
|
|
|
- List<WmsAgvInfo> WmsAgvInfoList = baseMapper.selectList(Wraps.<WmsAgvInfo>lbQ().eq(WmsAgvInfo::getTaskNo, taskNo));
|
|
|
- if(CollectionUtil.isEmpty(WmsAgvInfoList)){
|
|
|
+ WmsAgvInfo item = baseMapper.selectOne(Wraps.<WmsAgvInfo>lbQ().eq(WmsAgvInfo::getTaskNo, taskNo));
|
|
|
+ if(ObjectUtil.isEmpty(item)){
|
|
|
R.fail("找不到相对应的任务编号");
|
|
|
}
|
|
|
- WmsAgvInfo item = WmsAgvInfoList.get(0);
|
|
|
item.setStatus(true);
|
|
|
item.setWmsStart(wmsAgvInfo.getStart());
|
|
|
item.setWmsGoal(wmsAgvInfo.getGoal());
|
|
@@ -121,21 +122,17 @@ public class WmsAgvInfoServiceImpl extends SuperCacheServiceImpl<WmsAgvInfoMappe
|
|
|
wmsAgvInfo.setTaskType(item.getTaskType());
|
|
|
wmsAgvInfo.setIsCallback(true);
|
|
|
baseMapper.insert(wmsAgvInfo);
|
|
|
-/* WmsTransferTask wmsTransferTask = wmsTransferTaskMapper.selectOne(Wraps.<WmsTransferTask>lbQ().eq(WmsTransferTask::getId, item.getWmsTransferTaskId()));
|
|
|
+ WmsTransferTask wmsTransferTask = wmsTransferTaskMapper.selectOne(Wraps.<WmsTransferTask>lbQ().eq(WmsTransferTask::getId, item.getWmsTransferTaskId()));
|
|
|
int status = wmsTransferTask.getStatus().intValue();
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
status = status==4 ? 2 : status+1;
|
|
|
//任务状态(0:已发送 1:产线 2:三坐标 3:入库完成 4:暂时入库)
|
|
|
|
|
|
- //TODO 数量未全部满足
|
|
|
//正常流程走
|
|
|
//如果等于4,表示从仓库中出到三坐标
|
|
|
wmsTransferTask.setStatus(status);
|
|
|
- wmsTransferTaskMapper.updateById(wmsTransferTask);*/
|
|
|
+ wmsTransferTaskMapper.updateById(wmsTransferTask);
|
|
|
|
|
|
Storge endStorge = storgeMapper.selectOne(Wraps.<Storge>lbQ().eq(Storge::getPointId, wmsAgvInfo.getGoal()));
|
|
|
|
|
@@ -189,8 +186,24 @@ public class WmsAgvInfoServiceImpl extends SuperCacheServiceImpl<WmsAgvInfoMappe
|
|
|
//TODO 如果是入库类型,判断出库数量和入库数量是否一致,修改wms_transfer_task 状态
|
|
|
|
|
|
|
|
|
+ //记录日志
|
|
|
+ logAgvCallback(wmsAgvInfo,null,true,null,0l);
|
|
|
return R.success();
|
|
|
}
|
|
|
+
|
|
|
+ public void logAgvCallback(WmsAgvInfo wmsAgvInfo, String responseJson, boolean success, String errMsg, long startTime) {
|
|
|
+ ApiCallLog apiCallLog = new ApiCallLog();
|
|
|
+ apiCallLog.setInterfaceName("AGV_CALLBACK");
|
|
|
+ apiCallLog.setRequestUrl("/agvCallBack");
|
|
|
+ apiCallLog.setRequestParams(JSON.toJSONString(wmsAgvInfo));
|
|
|
+ apiCallLog.setRequestTime(new Date(startTime));
|
|
|
+ apiCallLog.setResponseData(responseJson);
|
|
|
+ apiCallLog.setSuccess(success ? 1 : 0);
|
|
|
+ apiCallLog.setErrorMessage(errMsg);
|
|
|
+ apiCallLog.setResponseTime(new Date());
|
|
|
+ apiCallLog.setDurationMs((int)(System.currentTimeMillis() - startTime));
|
|
|
+ apiCallLogMapper.insert(apiCallLog);
|
|
|
+ }
|
|
|
private void insertTrayAndBox(String trayNo,String boxNo,Long storgeId){
|
|
|
Tray tray = trayMapper.selectOne(Wraps.<Tray>lbQ().eq(Tray::getNo, trayNo));
|
|
|
if(tray==null){
|