Browse Source

agv流程接口

wudingsheng 3 weeks ago
parent
commit
e37bd9f8c6

+ 26 - 13
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/WmsAgvInfoServiceImpl.java

@@ -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){

+ 5 - 7
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/wms/WmsTransferTaskMapper.xml

@@ -7,30 +7,28 @@
         <id column="id" jdbcType="BIGINT" property="id"/>
         <result column="order_id" jdbcType="VARCHAR" property="orderId"/>
         <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
-        <result column="task_type" jdbcType="VARCHAR" property="taskType"/>
-        <result column="from_location" jdbcType="VARCHAR" property="fromLocation"/>
-        <result column="to_location" jdbcType="VARCHAR" property="toLocation"/>
         <result column="status" jdbcType="VARCHAR" property="status"/>
-        <result column="agv_task_no" jdbcType="VARCHAR" property="agvTaskNo"/>
         <result column="priority" jdbcType="INTEGER" property="priority"/>
         <result column="created_time" jdbcType="TIMESTAMP" property="createTime"/>
         <result column="updated_time" jdbcType="TIMESTAMP" property="updateTime"/>
         <result column="remark" jdbcType="VARCHAR" property="remark"/>
         <result column="task_no" jdbcType="VARCHAR" property="taskNo"/>
+        <result column="nowGoal" jdbcType="VARCHAR" property="nowGoal"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id,created_by,
-        order_id, order_no, task_type, from_location, to_location, status, agv_task_no, priority, created_time, updated_time, remark,task_no
+        order_id, order_no,  status,  priority, created_time, updated_time, remark,task_no
     </sql>
 
     <select id="pageList" resultMap="BaseResultMap">
         select
             s.*
         from (
-                 select wtt.*,oo.order_name from wms_transfer_task wtt
-                                                     inner join imcs_o_order oo on wtt.order_id=oo.id
+                 select wtt.*,oo.order_name,,wai.goal as nowGoal from wms_transfer_task wtt
+                  inner join imcs_o_order oo on wtt.order_id=oo.id
+                  left join (select * from wms_agv_info where is_callback=1 order by create_time desc limit 1) wai on wtt.id=wai.wms_transfer_task_id
              ) s ${ew.customSqlSegment}
     </select>
 

+ 4 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/wms/WmsTransferTask.java

@@ -100,6 +100,7 @@ public class WmsTransferTask extends Entity<Long> {
 
 
 
+
     /**
      * 创建时间
      */
@@ -139,5 +140,8 @@ public class WmsTransferTask extends Entity<Long> {
     @TableField(exist = false)
     private Integer priority;
 
+    @TableField(exist = false)
+    private String nowGoal;
+
 
 }