Browse Source

-- 库位视图-增加初始化空托库存功能
-- 任务管理-显示内容修改,任务删除业务修改
-- 天目系统接口开发

star 1 year ago
parent
commit
ee07a11b97
23 changed files with 1019 additions and 38 deletions
  1. 4 4
      ruoyi-admin/src/main/java/com/ruoyi/init/StartService.java
  2. 6 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/LocationViewSafeController.java
  3. 5 8
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/WcsTaskController.java
  4. 132 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/tm/TsPostApiController.java
  5. 92 0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpRequest.java
  6. 1 0
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
  7. 7 0
      ruoyi-ui/src/api/ams/locationView.js
  8. 16 1
      ruoyi-ui/src/views/ams/inv/locationView/index.vue
  9. 13 16
      ruoyi-ui/src/views/ams/task/index.vue
  10. 1 1
      warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/thread/AutoTaskThread.java
  11. 7 0
      warewms-ams/src/main/java/com/ruoyi/ams/inv/service/IInvLotLocIdService.java
  12. 41 0
      warewms-ams/src/main/java/com/ruoyi/ams/inv/service/impl/InvLotLocIdServiceImpl.java
  13. 4 4
      warewms-ams/src/main/java/com/ruoyi/ams/task/domain/WcsTask.java
  14. 12 0
      warewms-ams/src/main/java/com/ruoyi/ams/task/mapper/WcsTaskMapper.java
  15. 19 0
      warewms-ams/src/main/java/com/ruoyi/ams/task/service/IWcsTaskService.java
  16. 44 2
      warewms-ams/src/main/java/com/ruoyi/ams/task/service/impl/WcsTaskServiceImpl.java
  17. 29 0
      warewms-ams/src/main/java/com/ruoyi/ams/tm/common/TsDataConfiguration.java
  18. 1 1
      warewms-ams/src/main/java/com/ruoyi/ams/tm/entity/TsDataResponse.java
  19. 18 0
      warewms-ams/src/main/java/com/ruoyi/ams/tm/entity/TsRequest.java
  20. 29 0
      warewms-ams/src/main/java/com/ruoyi/ams/tm/entity/TsTaskStateResponse.java
  21. 62 0
      warewms-ams/src/main/java/com/ruoyi/ams/tm/service/ITsTaskService.java
  22. 461 0
      warewms-ams/src/main/java/com/ruoyi/ams/tm/service/impl/TsTaskServiceImpl.java
  23. 15 1
      warewms-ams/src/main/resources/mapper/ams/WcsTaskMapper.xml

+ 4 - 4
ruoyi-admin/src/main/java/com/ruoyi/init/StartService.java

@@ -40,16 +40,16 @@ public class StartService implements CommandLineRunner {
     @Override
     public void run(String... args) throws Exception {
         //自动下发任务
-        if (initTaskConfig.getAutoSend()) {
+/*        if (initTaskConfig.getAutoSend()) {
             Thread thread = new Thread(new AutoTaskThread(businessService));
             thread.start();
-        }
+        }*/
 
         //ndc下发
-        if (initTaskConfig.getAciService()) {
+/*        if (initTaskConfig.getAciService()) {
             Thread thread = new Thread(new AciServiceThread(aciService));
             thread.start();
-        }
+        }*/
     }
 
 

+ 6 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/LocationViewSafeController.java

@@ -75,6 +75,12 @@ public class LocationViewSafeController extends BaseController {
         return invLotLocIdService.adjLocationIsEmpty(id.toString(), Constant.WAREHOUSE_ID, logger.getName());
     }
 
+    @Log(title = "库位空托库存添加", businessType = BusinessType.CLEAN)
+    @GetMapping(value = "/addEmptyInv/{id}")
+    public AjaxResult adjaddEmptyInv(@PathVariable("id") Long id) {
+        return invLotLocIdService.adjAddEmpty(id.toString(), Constant.WAREHOUSE_ID, logger.getName());
+    }
+
     @GetMapping(value = "/locationLotatt/{locationId}")
     public AjaxResult locationLotatt(@PathVariable("locationId") Long locationId) {
         List<InvLotLocIdLotattVO> invLotLocIdLotattVOS = invLotLocIdService.selectInvLocIdLotattByLocationId(locationId);

+ 5 - 8
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/WcsTaskController.java

@@ -1,20 +1,15 @@
 package com.ruoyi.web.controller.warewms.ams;
 
-import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
 
 import com.ruoyi.ams.task.domain.form.TaskDispositionForm;
 import com.ruoyi.ams.task.form.AddTaskForm;
+import com.ruoyi.ams.tm.service.ITsTaskService;
 import com.ruoyi.base.constant.Constant;
-import com.ruoyi.base.utils.IdSequenceUtils;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.utils.StringUtils;
-import io.swagger.annotations.ApiModelProperty;
-import io.swagger.annotations.ApiOperation;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -46,6 +41,8 @@ import com.ruoyi.common.core.page.TableDataInfo;
 public class WcsTaskController extends BaseController {
     @Autowired
     private IWcsTaskService wcsTaskService;
+    @Autowired
+    private ITsTaskService tsTaskService;
 
     /**
      * 查询AGV任务列表
@@ -133,7 +130,7 @@ public class WcsTaskController extends BaseController {
         if (StringUtils.isNotEmpty(wcsTask.getAgvNo())) {
             agvNo = Integer.parseInt(wcsTask.getAgvNo());
         }
-        return wcsTaskService.callBack(wcsTask.getTaskNo(), 4, agvNo);
+        return wcsTaskService.callBack(wcsTask.getTaskNo(), 6, agvNo);
     }
 
     @Log(title = "任务取消", businessType = BusinessType.INSERT)
@@ -143,7 +140,7 @@ public class WcsTaskController extends BaseController {
         if (wcsTask == null) {
             AjaxResult.error("任务查询不存在");
         }
-        wcsTaskService.cancelTask(wcsTask);
+        wcsTaskService.delTaskByTM(wcsTask);
         return AjaxResult.success("任务取消指令下发成功!");
     }
 

+ 132 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/tm/TsPostApiController.java

@@ -0,0 +1,132 @@
+package com.ruoyi.web.controller.warewms.tm;
+
+import com.alibaba.fastjson.JSON;
+import com.ruoyi.ams.task.domain.WcsTask;
+import com.ruoyi.ams.task.service.IWcsTaskService;
+import com.ruoyi.ams.tm.entity.TsDataResponse;
+import com.ruoyi.ams.tm.entity.TsRequest;
+import com.ruoyi.ams.tm.entity.TsTaskStateResponse;
+import com.ruoyi.ams.tm.service.ITsTaskService;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.core.page.TableSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@Slf4j
+@Api("TS任务反馈接口")
+@RestController
+@RequestMapping("/api/tstaskapi")
+public class TsPostApiController {
+
+    @Autowired
+    private ITsTaskService iTsTaskService;
+    @Autowired
+    private IWcsTaskService wcsTaskService;
+
+
+    /**
+     * TS-天目取卸货申请
+     */
+    @ApiOperation("TS-天目取卸货申请")
+    @PostMapping("/applyUpAndUnload")
+    public TsTaskStateResponse applyUpAndUnload(TsRequest tsRequest) {
+
+        log.info("-----------TS-天目取卸货申请:" + JSON.toJSONString(tsRequest));
+        return iTsTaskService.confirmAnalysis(tsRequest.getTsOrder(),tsRequest.getReqType(),tsRequest.getAgvNo());
+    }
+
+    /**
+     * TS-天目任务状态反馈
+     */
+    @ApiOperation("TS-天目任务状态反馈")
+    @PostMapping("/responseTaskState")
+    public TsTaskStateResponse responseTaskState(TsRequest tsRequest) {
+
+        log.info("-----------TS-天目任务状态反馈:" + JSON.toJSONString(tsRequest));
+        return iTsTaskService.tsTaskStateBack(tsRequest.getTsOrder(),tsRequest.getReqState(),tsRequest.getAgvNo());
+    }
+
+    /**
+     * TS-创建一个TS订单
+     */
+    @ApiOperation("TS-创建一个TS订单")
+    @PostMapping("/sendTsTaskOrder")
+    public TsDataResponse sendTsTaskOrder(WcsTask wcsTask) {
+        wcsTask = wcsTaskService.selectWcsTaskByTaskNo(wcsTask.getTaskNo());
+        if(wcsTask == null){
+            return new TsDataResponse();
+        }
+        log.info("-----------TS-创建一个TS订单:" + JSON.toJSONString(wcsTask));
+        return iTsTaskService.sendTaskOrder(wcsTask);
+    }
+
+    /**
+     * TS-根据订单名获取 TS 订单信息
+     */
+    @ApiOperation("TS-根据 TS index 获取 TS 订单信息")
+    @PostMapping("/obtainOrderInfoByIndex")
+    public TsDataResponse obtainOrderInfoByIndex(String tsIndex) {
+        WcsTask wcsTask = wcsTaskService.selectWcsTaskByTsIndex(tsIndex);
+        if(wcsTask == null){
+            return new TsDataResponse();
+        }
+        log.info("-----------TS-根据订单名获取 TS 订单信息:" + JSON.toJSONString(tsIndex));
+        return iTsTaskService.queryOrderInfoByIndex(tsIndex);
+    }
+
+    /**
+     * TS-获取全部 TS 订单信息
+     */
+    @ApiOperation("TS-获取全部 TS 订单信息")
+    @PostMapping("/obtainOrderInfo")
+    public TsDataResponse obtainOrderInfo() {
+
+        log.info("-----------TS-获取全部 TS 订单信息" );
+        return iTsTaskService.queryOrderInfo();
+    }
+
+    /**
+     * TS-根据订单名取消订单
+     */
+    @ApiOperation("TS-根据订单名取消订单")
+    @PostMapping("/cancelOrderByIndex")
+    public TsDataResponse cancelOrderByIndex(String tsIndex) {
+        WcsTask wcsTask = wcsTaskService.selectWcsTaskByTsIndex(tsIndex);
+        if(wcsTask == null){
+            return new TsDataResponse();
+        }
+        log.info("-----------TS-根据订单名取消订单:" + JSON.toJSONString(tsIndex));
+        return iTsTaskService.delOrderByIndex(tsIndex);
+    }
+
+    /**
+     * TS-根据车号取消订单
+     */
+    @ApiOperation("TS-根据车号取消订单")
+    @PostMapping("/cancelOrderByAgvNo")
+    public TsDataResponse cancelOrderByAgvNo(String agvNo) {
+        WcsTask wcsTask = wcsTaskService.selectWcsTaskByAgvNo(agvNo);
+        if(wcsTask == null){
+            return new TsDataResponse();
+        }
+        log.info("-----------TS-根据车号取消订单:" + JSON.toJSONString(agvNo));
+        return iTsTaskService.delOrderByAgvNo(agvNo);
+    }
+
+    /**
+         * TS-创建充电任务
+     */
+    @ApiOperation("TS-创建充电任务")
+    @PostMapping("/sendChargeOrder")
+    public TsDataResponse sendChargeOrder(String agvNo,String loc) {
+
+        log.info("-----------TS-创建充电任务:车号{},充电点位{}" ,agvNo,loc);
+        return iTsTaskService.sendChargeJob(agvNo,loc);
+    }
+}

+ 92 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpRequest.java

@@ -1,18 +1,24 @@
 package com.ruoyi.common.utils.http;
 
+import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.HttpEntity;
 import org.apache.http.NameValuePair;
 import org.apache.http.StatusLine;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.util.EntityUtils;
 
+import java.io.IOException;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -169,4 +175,90 @@ public class HttpRequest {
         return nameValueList.toArray(new NameValuePair[nameValueList.size()]);
     }
 
+
+    public synchronized static String postData(String url, JSONObject json) throws Exception {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPost httpPost = new HttpPost(url);
+        httpPost.setHeader("Content-Type", "application/json;charset=UTF-8");
+        httpPost.setEntity(new StringEntity(json.toJSONString(), StandardCharsets.UTF_8));
+        CloseableHttpResponse response = httpclient.execute(httpPost);
+        String result = "";
+        try {
+            StatusLine statusLine = response.getStatusLine();
+            HttpEntity entity = response.getEntity();
+            log.info("======postDataA-0:"+ statusLine.getStatusCode());
+            // do something useful with the response body
+            if (entity != null) {
+                result = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
+            }else{
+                System.out.println(("httpRequest postData2 error entity = null code = " + statusLine.getStatusCode()));
+            }
+            // and ensure it is fully consumed
+            //消耗掉response
+            EntityUtils.consume(entity);
+        } finally {
+            response.close();
+        }
+
+        return result;
+    }
+
+    public synchronized static String getData(String url) throws Exception {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpGet httpget = new HttpGet(url);
+        CloseableHttpResponse response = httpclient.execute(httpget);
+        String result = "";
+        try {
+            StatusLine statusLine = response.getStatusLine();
+            HttpEntity entity = response.getEntity();
+            // do something useful with the response body
+            if (entity != null) {
+                result = EntityUtils.toString(entity, "UTF-8");
+            }else{
+                log.error("httpRequest getData2 error entity = null code = "+statusLine.getStatusCode());
+            }
+            // and ensure it is fully consumed
+            //消耗掉response
+            EntityUtils.consume(entity);
+        } finally {
+            response.close();
+        }
+
+        return result;
+    }
+
+    public synchronized static String getData(String url,String key,String Json) throws Exception {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String result = "";
+        try {
+            // 创建uri
+            URIBuilder builder = new URIBuilder(url);
+            builder.addParameter(key, Json);
+            URI uri = builder.build();
+
+            // 创建http GET请求
+            HttpGet httpGet = new HttpGet(uri);
+
+            // 执行请求
+            response = httpclient.execute(httpGet);
+
+            // 判断返回状态是否为200
+            if (response.getStatusLine().getStatusCode() == 200) {
+                result = EntityUtils.toString(response.getEntity(), "UTF-8");
+            }
+
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return result;
+    }
 }

+ 1 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -114,6 +114,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/druid/**").anonymous()
                 .antMatchers("/wcs/**").anonymous()
                 .antMatchers("/api/wcstask/**").permitAll()
+                .antMatchers("/api/tstaskapi/**").permitAll()
                 .antMatchers("/test/**").permitAll()
                 // 库位视图
                 .antMatchers("/ams/locationView/**").permitAll()

+ 7 - 0
ruoyi-ui/src/api/ams/locationView.js

@@ -32,6 +32,13 @@ export function clearLocRequest(id) {
   })
 }
 
+export function addEmptyRequest(id) {
+  return request({
+    url: '/ams/safe/locationView/addEmptyInv/'+id,
+    method: 'get'
+  })
+}
+
 export function occupyLocRequest(id) {
   return request({
     url: '/ams/safe/locationView/setIsEmpty/'+id,

+ 16 - 1
ruoyi-ui/src/views/ams/inv/locationView/index.vue

@@ -164,7 +164,7 @@
           <el-button type="primary" @click="lockLoc()">锁定/解锁</el-button>
           <el-button type="primary" @click="occupyLoc()">有货/无货</el-button>
           <el-button type="primary" @click="clearLoc()">清空</el-button>
-          <!--<el-button type="primary" @click="submitForm">初始化一个空托盘</el-button>-->
+          <el-button type="primary" @click="addEmpty()">初始化一个空托盘</el-button>
         </el-form-item>
       </el-form>
       <el-divider content-position="center">批次属性信息</el-divider>
@@ -209,6 +209,7 @@ import {
   lotattConfigList,
   lotattInfo,
   occupyLocRequest,
+  addEmptyRequest,
   queryWarehouseDict,
 } from "@/api/ams/locationView";
 
@@ -367,6 +368,20 @@ export default {
         });
       });
     },
+    addEmpty() {
+      let that = this;
+      this.$modal.confirm("是否确认要添加一个空托库存?").then(function () {
+        addEmptyRequest(that.currentSelect).then((response) => {
+          if (response.code === 200) {
+            that.open = false;
+            that.$modal.msgSuccess(response.msg);
+            that.search();
+          } else {
+            that.$modal.msgError(response.msg);
+          }
+        });
+      });
+    },
     clearLoc() {
       let that = this;
       this.$modal.confirm("是否确认要清空库存?").then(function () {

+ 13 - 16
ruoyi-ui/src/views/ams/task/index.vue

@@ -41,15 +41,6 @@
         />
       </el-form-item>
 
-      <el-form-item label="终点点位" prop="locationTo">
-        <el-input
-          v-model="queryParams.locationTo"
-          placeholder="请输入终点点位"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
       <el-form-item label="终点区域" prop="areaTo">
         <!--        <el-input-->
         <!--          v-model="queryParams.areaTo"-->
@@ -68,6 +59,16 @@
           />
         </el-select>
       </el-form-item>
+      <el-form-item label="终点点位" prop="locationTo">
+        <el-input
+          v-model="queryParams.locationTo"
+          placeholder="请输入终点点位"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+
       <el-form-item label="ִ状态" prop="state">
 <!--        <el-input-->
 <!--          v-model="queryParams.state"-->
@@ -195,15 +196,12 @@
     <el-table v-loading="loading" :data="wcsTaskList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="任务编号" align="center" prop="taskNo"  width="180"/>
-      <!--<el-table-column label="仓库" align="center" prop="shopId" />-->
-      <!--<el-table-column label="调用系统名称" align="center" prop="sysName" />-->
-      <!--<el-table-column label="调用设备名称" align="center" prop="deviceName" />-->
+      <el-table-column label="TS任务号" align="center" prop="deviceName" />
       <el-table-column label="起始区域" align="center" prop="areaFrom" />
       <el-table-column label="起始点位" align="center" prop="locationFrom" />
-      <el-table-column label="终点点位" align="center" prop="locationTo" />
-      <el-table-column label="AGV站点" align="center" prop="agvStation" />
       <el-table-column label="终点区域" align="center" prop="areaTo" />
-      <!--      <el-table-column label="优先级" align="center" prop="priority" />-->
+      <el-table-column label="终点点位" align="center" prop="locationTo" />
+      <el-table-column label="车号" align="center" prop="agvNo" />
       <el-table-column label="ִ状态" align="center" prop="state" >
         <template slot-scope="scope">
           <div v-if="scope.row.state === 1">开始</div>
@@ -229,7 +227,6 @@
       <el-table-column label="任务开始时间" align="center" prop="startTime"/>
       <el-table-column label="任务结束时间" align="center" prop="endTime"/>
       <!--<el-table-column label="父任务单号" align="center" prop="parentTask" />-->
-      <!--<el-table-column label="AGV接收车号" align="center" prop="agvNo" />-->
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button

+ 1 - 1
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/thread/AutoTaskThread.java

@@ -17,7 +17,7 @@ public class AutoTaskThread implements Runnable {
         log.info("-------------------------自动下发任务服务启动---------------------->");
         while (true) {
             try {
-                Thread.sleep(1000L);
+                Thread.sleep(5000L);
                 businessService.autoSend();
             } catch (Exception e) {
                 e.printStackTrace();

+ 7 - 0
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/IInvLotLocIdService.java

@@ -134,6 +134,13 @@ public interface IInvLotLocIdService {
      */
     AjaxResult adjLocationIsEmpty(String locationId, Long warehouseId, String updateBy);
 
+    /**
+     * 添加空托盘库存
+     *
+     * @return
+     */
+    AjaxResult adjAddEmpty(String locationId, Long warehouseId, String updateBy);
+
     /**
      * 新增库位库存信息
      *

+ 41 - 0
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/impl/InvLotLocIdServiceImpl.java

@@ -18,6 +18,7 @@ import com.ruoyi.ams.inv.service.IInvLotLocIdService;
 import com.ruoyi.ams.task.domain.WcsTask;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
+import com.ruoyi.base.mapper.BaseLocationInfoMapper;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.utils.IdSequenceUtils;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -51,6 +52,8 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
     @Autowired
     private InvLotAttMapper invLotAttMapper;
     @Autowired
+    private BaseLocationInfoMapper baseLocationInfoMapper;
+    @Autowired
     private IBaseLocationInfoService baseLocationInfoService;
     @Autowired
     private IdSequenceUtils idSequenceUtils;
@@ -404,6 +407,44 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
         return AjaxResult.success("操作成功!");
     }
 
+
+    @Override
+    public AjaxResult adjAddEmpty(String locationId, Long warehouseId, String updateBy) {
+        Long id; // 库位ID
+        BaseLocationInfo baseLocationInfo = baseLocationInfoService.selectBaseLocationInfoByIdOrNo(locationId, warehouseId);
+        if (baseLocationInfo == null) {
+            return AjaxResult.error("不存在对应库位:" + locationId);
+        }
+        id = baseLocationInfo.getId();
+
+        String lotnum = idSequenceUtils.generateId("LOTNUMBER");
+        //添加批次
+        InvLotAtt invAtt = new InvLotAtt();
+        invAtt.setLotnum(lotnum);
+        invAtt.setCustomerId(Constant.CUSTOMER_ID);
+        invAtt.setSku("EMPTY_TRAY");
+        invAtt.setCreateTime(DateUtils.getNowDate());
+        invLotAttMapper.insertInvLotAtt(invAtt);
+        //添加库存
+        InvLotLocId invLotLocId = new InvLotLocId();
+        invLotLocId.setLotnum(lotnum);
+        invLotLocId.setLocationId(id.toString());
+        invLotLocId.setSku("EMPTY_TRAY");
+        invLotLocId.setCustomerId(Constant.CUSTOMER_ID);
+        invLotLocId.setQty(new BigDecimal(1));
+        invLotLocId.setQtyEach(new BigDecimal(1));
+        invLotLocId.setQtyallocated(BigDecimal.ZERO);
+        invLotLocId.setQtyallocatedEach(BigDecimal.ZERO);
+        invLotLocId.setQtypa(BigDecimal.ZERO);
+        invLotLocId.setQtyrpin(BigDecimal.ZERO);
+        invLotLocId.setCreateTime(new Date());
+        invLotLocIdMapper.insertInvLotLocId(invLotLocId);
+
+        baseLocationInfo.setIsEmpty(Constant.IS_YES.N.name());
+        baseLocationInfoMapper.updateBaseLocationInfo(baseLocationInfo);
+        return AjaxResult.success("添加成功!");
+    }
+
     /**
      * 新增库位库存信息
      *

+ 4 - 4
warewms-ams/src/main/java/com/ruoyi/ams/task/domain/WcsTask.java

@@ -83,7 +83,7 @@ public class WcsTask extends BaseEntity
     private Date createDate;
 
     /** 编辑人 */
-    private Long updateUser;
+    private String updateUser;
 
     /** 编辑时间 */
     private Date updateDate;
@@ -306,16 +306,16 @@ public class WcsTask extends BaseEntity
     {
         return createDate;
     }
-    public void setUpdateUser(Long updateUser) 
+    public void setUpdateUser(String updateUser)
     {
         this.updateUser = updateUser;
     }
 
-    public Long getUpdateUser() 
+    public String getUpdateUser()
     {
         return updateUser;
     }
-    public void setUpdateDate(Date updateDate) 
+    public void setUpdateDate(Date updateDate)
     {
         this.updateDate = updateDate;
     }

+ 12 - 0
warewms-ams/src/main/java/com/ruoyi/ams/task/mapper/WcsTaskMapper.java

@@ -21,6 +21,18 @@ public interface WcsTaskMapper
      */
      WcsTask selectWcsTaskByTaskNo(String taskNo);
 
+    /**
+     * 根据TS任务号查询AGV任务
+     * @param tsIndex TS任务号
+     */
+    WcsTask selectWcsTaskByTsIndex(String tsIndex);
+
+    /**
+     * 根据车号查询AGV任务
+     * @param agvNo TS任务号
+     */
+    WcsTask selectWcsTaskByAgvNo(String agvNo);
+
     /**
      * 查询AGV任务列表
      *

+ 19 - 0
warewms-ams/src/main/java/com/ruoyi/ams/task/service/IWcsTaskService.java

@@ -22,6 +22,18 @@ public interface IWcsTaskService {
      */
     WcsTask selectWcsTaskByTaskNo(String taskNo);
 
+    /**
+     * 根据TS任务号查询AGV任务
+     * @param tsIndex TS任务号
+     */
+    WcsTask selectWcsTaskByTsIndex(String tsIndex);
+
+    /**
+     * 根据车号查询AGV任务
+     * @param agvNo TS任务号
+     */
+    WcsTask selectWcsTaskByAgvNo(String agvNo);
+
     /**
      * 查询AGV任务列表
      *
@@ -106,6 +118,13 @@ public interface IWcsTaskService {
      */
     AjaxResult cancelTask(WcsTask wcsTask);
 
+    /**
+     * 天目系统取消任务
+     *
+     * @param wcsTask
+     */
+    AjaxResult delTaskByTM(WcsTask wcsTask);
+
     /**
      * 库存处理
      *

+ 44 - 2
warewms-ams/src/main/java/com/ruoyi/ams/task/service/impl/WcsTaskServiceImpl.java

@@ -18,6 +18,8 @@ import com.ruoyi.ams.inv.mapper.InvLotLocIdMapper;
 import com.ruoyi.ams.inv.service.IInvLotAttService;
 import com.ruoyi.ams.inv.service.IInvLotLocIdService;
 import com.ruoyi.ams.task.dto.WcsTaskLocationDTO;
+import com.ruoyi.ams.tm.entity.TsDataResponse;
+import com.ruoyi.ams.tm.service.ITsTaskService;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.service.IBaseLocationInfoService;
@@ -72,12 +74,12 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
     private IAmsTaskService iAmsTaskService;
     @Autowired
     private AutoDoorClient autoDoorClient;
-
     @Autowired
     PlcConnectServiceRunner plcConnectServiceRunner;
-
     @Autowired
     private IBaseLocationInfoService iBaseLocationInfoService;
+    @Autowired
+    private ITsTaskService tsTaskService;
 
     //任务状态翻译
     private String codeConvert(int code) {
@@ -113,6 +115,24 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
         return wcsTaskMapper.selectWcsTaskByTaskNo(taskNo);
     }
 
+    /**
+     * 根据TS任务号查询AGV任务
+     * @param tsIndex AGV任务主键
+     */
+    @Override
+    public WcsTask selectWcsTaskByTsIndex(String tsIndex) {
+        return wcsTaskMapper.selectWcsTaskByTsIndex(tsIndex);
+    }
+
+    /**
+     * 根据车号查询AGV任务
+     * @param agvNo TS任务号
+     */
+    @Override
+    public WcsTask selectWcsTaskByAgvNo(String agvNo) {
+        return wcsTaskMapper.selectWcsTaskByAgvNo(agvNo);
+    }
+
     /**
      * 查询AGV任务列表
      *
@@ -303,6 +323,28 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
         return AjaxResult.success("取消任务指令已下发!");
     }
 
+    @Transactional
+    @Override
+    public AjaxResult delTaskByTM(WcsTask wcsTask) {
+
+        if (wcsTask.getState() == Constant.TASK_STS.TASK9.getValue().longValue()
+                || wcsTask.getState() == Constant.TASK_STS.TASK10.getValue().longValue()) {
+            return callBack(wcsTask.getTaskNo(), 7, null);
+        }else{
+
+            if("".equals(wcsTask.getDeviceName()) || wcsTask.getDeviceName() == null){
+                return AjaxResult.error("已下发的任务取消需要TS任务号!");
+            }
+
+            TsDataResponse tsResult = tsTaskService.delOrderByIndex(wcsTask.getDeviceName());
+            if("true".equals(tsResult.getSuccess())){
+                tsTaskService.tsTaskStateBack(wcsTask.getDeviceName(),"7",wcsTask.getAgvNo());
+                return AjaxResult.success("取消成功!");
+            }else{
+                return AjaxResult.error("取消失败!错误码:"+tsResult.getError_code()+",错误信息:"+tsResult.getMsg());
+            }
+        }
+    }
     @Override
     public void invDisposition(WcsTask wcsTask, String result) {
         BaseLocationInfo bf = baseLocationInfoService.selectBaseLocationInfoById(Long.parseLong(wcsTask.getLocationFrom()));

+ 29 - 0
warewms-ams/src/main/java/com/ruoyi/ams/tm/common/TsDataConfiguration.java

@@ -0,0 +1,29 @@
+package com.ruoyi.ams.tm.common;
+
+
+public class TsDataConfiguration {
+
+
+
+    //-----------------------------------TS 天目系统对接url-----------------------------------
+
+    //创建一个 TS 订单
+    public static final String SEND_JOB_TS = "http://localhost:55200/v1/orderByTS";
+    //根据 TS index 获取 TS 订单信息
+    public static final String QUERY_ORDER_INFO_TS_INDEX = "http://localhost:55200/v1/transportStructureOrder";
+    //获取所有订单信息
+    public static final String QUERY_ORDER_INFO = "http://localhost:55200/v1/transportStructureOrders";
+    //根据订单名取消订单
+    public static final String DEL_ORDER_TS_INDEX = "http://localhost:55200/v1/orderByTS/withdrawalTSOrder";
+    //根据车辆名称取消订单
+    public static final String DEL_ORDER_AGV_NO = "http://localhost:55200/v1/vehicles/withdrawalTSOrder";
+    //创建充电订单
+    public static final String SEND_CHARGE_JOB = "http://localhost:55200/v1/transportOrders";
+
+    //------------------------------------------end------------------------------------------
+
+
+
+
+
+}

+ 1 - 1
warewms-ams/src/main/java/com/ruoyi/ams/tm/entity/TsDataResponse.java

@@ -5,7 +5,7 @@ import lombok.Data;
 @Data
 public class TsDataResponse {
 
-    //是否成功
+    //是否成功 true/false
     private String success;
     //错误码
     private String error_code;

+ 18 - 0
warewms-ams/src/main/java/com/ruoyi/ams/tm/entity/TsRequest.java

@@ -0,0 +1,18 @@
+package com.ruoyi.ams.tm.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TsRequest {
+
+    //ts任务号
+    private String tsOrder;
+    //取卸货编号 (1:取货申请 2:卸货申请)
+    private String reqType;
+    //任务状态编号
+    private String reqState;
+    //车号
+    private String agvNo;
+}

+ 29 - 0
warewms-ams/src/main/java/com/ruoyi/ams/tm/entity/TsTaskStateResponse.java

@@ -11,4 +11,33 @@ public class TsTaskStateResponse {
     private String resultMsg;
     //数据
     private String data;
+
+    public TsTaskStateResponse() {
+    }
+    public TsTaskStateResponse(String resultCode,String resultMsg) {
+        this.resultCode = resultCode;
+        this.resultMsg = resultMsg;
+    }
+    public TsTaskStateResponse(String resultCode,String resultMsg,String data) {
+        this.resultCode = resultCode;
+        this.resultMsg = resultMsg;
+        this.data = data;
+    }
+
+
+    public static TsTaskStateResponse success(String resultMsg,String data) {
+        TsTaskStateResponse tsTaskStateResponse = new TsTaskStateResponse();
+        tsTaskStateResponse.setResultCode("0");
+        tsTaskStateResponse.setResultMsg(resultMsg);
+        tsTaskStateResponse.setData(data);
+        return tsTaskStateResponse;
+    }
+
+    public static TsTaskStateResponse error(String resultMsg,String data) {
+        TsTaskStateResponse tsTaskStateResponse = new TsTaskStateResponse();
+        tsTaskStateResponse.setResultCode("1");
+        tsTaskStateResponse.setResultMsg(resultMsg);
+        tsTaskStateResponse.setData(data);
+        return tsTaskStateResponse;
+    }
 }

+ 62 - 0
warewms-ams/src/main/java/com/ruoyi/ams/tm/service/ITsTaskService.java

@@ -0,0 +1,62 @@
+package com.ruoyi.ams.tm.service;
+
+
+import com.ruoyi.ams.task.domain.WcsTask;
+import com.ruoyi.ams.tm.entity.TsDataResponse;
+import com.ruoyi.ams.tm.entity.TsTaskStateResponse;
+import com.ruoyi.common.core.domain.AjaxResult;
+
+public interface ITsTaskService {
+
+
+    /**
+     * TS-天目取卸货申请
+     * tsOrder ts任务号
+     * reqType 取卸货编号 (1-取货申请,2-卸货申请)
+     * agvNo 车号
+     */
+    TsTaskStateResponse confirmAnalysis(String tsOrder,String reqType, String agvNo);
+
+    /**
+     * TS-天目任务状态反馈
+     * tsOrder ts任务号
+     * reqType 任务状态编号
+     * agvNo 车号
+     */
+    TsTaskStateResponse tsTaskStateBack(String tsOrder,String reqState, String agvNo);
+
+    /**
+     * TS-创建一个TS订单
+     */
+    TsDataResponse sendTaskOrder(WcsTask wcsTask);
+
+    /**
+     * TS-根据订单名获取 TS 订单信息
+     * tsIndex ——TS index号
+     */
+    TsDataResponse queryOrderInfoByIndex(String tsIndex);
+
+    /**
+     * TS-获取全部 TS 订单信息
+     */
+    TsDataResponse queryOrderInfo();
+
+    /**
+     * TS-根据订单名取消订单
+     * tsIndex ——TS index号
+     */
+    TsDataResponse delOrderByIndex(String tsIndex);
+
+    /**
+     * TS-根据车号取消订单
+     * agvNo ——车辆名称
+     */
+    TsDataResponse delOrderByAgvNo(String agvNo);
+
+
+    /**
+     * TS-创建充电任务
+     * agvNo ——车辆名称
+     */
+    TsDataResponse sendChargeJob(String agvNo,String loc);
+}

+ 461 - 0
warewms-ams/src/main/java/com/ruoyi/ams/tm/service/impl/TsTaskServiceImpl.java

@@ -0,0 +1,461 @@
+package com.ruoyi.ams.tm.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.ams.task.domain.WcsTask;
+import com.ruoyi.ams.task.service.IWcsTaskService;
+import com.ruoyi.ams.task.service.impl.WcsTaskServiceImpl;
+import com.ruoyi.ams.tm.common.TsDataConfiguration;
+import com.ruoyi.ams.tm.entity.Destinations;
+import com.ruoyi.ams.tm.entity.OrderSequence;
+import com.ruoyi.ams.tm.entity.TsDataResponse;
+import com.ruoyi.ams.tm.entity.TsTaskStateResponse;
+import com.ruoyi.ams.tm.service.ITsTaskService;
+import com.ruoyi.base.constant.Constant;
+import com.ruoyi.base.service.IBaseLocationInfoService;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.http.HttpRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import sun.security.krb5.internal.crypto.Des;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+
+@Slf4j
+@Service
+public class TsTaskServiceImpl implements ITsTaskService {
+
+    @Autowired
+    private RedisCache redisCache;
+    @Autowired
+    private IWcsTaskService wcsTaskService;
+    @Autowired
+    private WcsTaskServiceImpl wcsTaskServiceImpl;
+    @Autowired
+    private IBaseLocationInfoService baseLocationInfoService;
+
+
+    //任务状态翻译
+    private Integer tsStateConvert(String code) {
+
+        switch (code) {
+            case "tsOrderStarted":
+                return 1;
+            case "tsOrderFinished":
+                return 2;
+            case "Fetching":
+                return 3;
+            case "Fetched":
+                return 4;
+            case "Delivering":
+                return 5;
+            case "Delivered":
+                return 6;
+            case "tsOrderFailed":
+                return 7;
+        }
+        return 0;
+    }
+
+
+    @Override
+    public synchronized TsTaskStateResponse confirmAnalysis(String tsOrder,String reqType, String agvNo) {
+
+
+        //根据TSOrder 查询任务
+        WcsTask wcsTask = wcsTaskServiceImpl.selectWcsTaskByTaskNo(tsOrder);
+        if(wcsTask == null){
+            return TsTaskStateResponse.error("未查询到对应任务!","");
+        }
+        log.info("TsTaskServiceImpl---confirmAnalysis:" + JSON.toJSONString(wcsTask));
+        return TsTaskStateResponse.success("","");
+
+    }
+
+
+    /**
+     *   tsOrderStarted      ——(TS 任务开始) 1
+     *   tsOrderFinished     ——(TS任务完成)  2
+     *   Fetching            ——(取货中)      3
+     *   Fetched             ——(取货完成)    4
+     *   Delivering          ——(卸货中)      5
+     *   Delivered           ——(卸货完成)    6
+     *   tsOrderFailed       ——(TS 任务失败) 7
+     */
+    @Transactional
+    @Override
+    public synchronized TsTaskStateResponse tsTaskStateBack(String tsOrder,String reqState, String agvNo) {
+        log.info("TS-天目任务状态反馈------------->TS任务号:{},状态:{},车号:{}" ,tsOrder,reqState,agvNo);
+
+        //根据TSOrder 查询任务
+        WcsTask wcsTask = wcsTaskServiceImpl.selectWcsTaskByTsIndex(tsOrder);
+        if(wcsTask == null){
+            log.info("TsTaskServiceImpl---tsTaskStateBack:未查询到任务数据!");
+            return TsTaskStateResponse.error("未查询到任务数据!","");
+        }
+
+        //获取任务状态
+        Integer state = tsStateConvert(reqState);
+        if(state == 0){
+            log.info("TsTaskServiceImpl---tsTaskStateBack:未匹配到任务状态!");
+            return TsTaskStateResponse.error("未匹配到任务状态!","");
+        }
+        if (state == 2) {
+            log.info("TsTaskServiceImpl---tsTaskStateBack:已完成的任务无需反馈!");
+            return TsTaskStateResponse.error("已完成的任务无需反馈!","");
+        }
+        if (state == 7 && wcsTask.getState() == 7) {
+            log.info("TsTaskServiceImpl---tsTaskStateBack:已取消的任务无需重复取消!");
+            return TsTaskStateResponse.error("已取消的任务无需重复取消!","");
+        }
+
+
+        try {
+
+            switch (state) {
+                case 1:
+                    wcsTask.setStartTime(new Date());
+                    break;
+                case 2:
+                    if (wcsTask.getState() == 3 || wcsTask.getState() == 4) {
+                        log.info("任务未取货,不能直接完成!" + wcsTask.getTaskNo());
+                        return TsTaskStateResponse.error("任务未取货,不能直接完成!" ,"");
+                    }
+                    // 解锁终点库位
+                    baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo()), Constant.WAREHOUSE_ID, "TS-TM");
+                    // 将中间缓存位库存移动到终点
+                    wcsTaskServiceImpl.moveMiddleCacheToDestination(wcsTask);
+                    //释放redis锁
+                    if (!StringUtils.isEmpty(wcsTask.getExt8())) {
+                        redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
+                    }
+                    break;
+                case 3:
+                    break;
+                case 4:
+                    if (wcsTask.getState() == 4) {
+                        log.info("不能重复取货!" + wcsTask.getTaskNo());
+                        return TsTaskStateResponse.error("不能重复取货!","");
+                    }
+                    // 解锁起始库位
+                    baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationFrom()), Constant.WAREHOUSE_ID, "TS-TM");
+                    // 将起始点库存移动到中间缓存位
+                    wcsTaskServiceImpl.moveStartingPointToMiddleCache(wcsTask);
+                    //释放redis锁
+                    if (!StringUtils.isEmpty(wcsTask.getExt8())) {
+                        redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()), wcsTask.getLocationFrom());
+                    }
+                    break;
+                case 5:
+                    break;
+                case 6:
+                    if (wcsTask.getState() == 3 || wcsTask.getState() == 4) {
+                        log.info("任务未取货,不能直接卸货!" + wcsTask.getTaskNo());
+                        return TsTaskStateResponse.error("任务未取货,不能直接卸货!","");
+                    }
+                    if (wcsTask.getState() == 6) {
+                        log.info("不能重复卸货!" + wcsTask.getTaskNo());
+                        return TsTaskStateResponse.error("不能重复卸货!","");
+                    }
+                    // 解锁终点库位
+                    baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo()), Constant.WAREHOUSE_ID, "TS-TM");
+                    // 将中间缓存位库存移动到终点
+                    wcsTaskServiceImpl.moveMiddleCacheToDestination(wcsTask);
+                    //释放redis锁
+                    if (!StringUtils.isEmpty(wcsTask.getExt8())) {
+                        redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
+                    }
+                    break;
+                case 7:
+                    //如果取到货就只解锁终点库位
+                    if (wcsTask.getState() == 4 || wcsTask.getState() == 5) {
+                        // 解锁终点库位
+                        baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo()), Constant.WAREHOUSE_ID, "TS-TM");
+                    } else {
+                        // 解锁终点和起始库位
+                        baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationFrom()), Long.parseLong(wcsTask.getLocationTo()), Constant.WAREHOUSE_ID, "TS-TM");
+                    }
+                    //释放redis锁
+                    if (!StringUtils.isEmpty(wcsTask.getExt8())) {
+                        redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
+                    }
+                    break;
+                default:
+                    break;
+            }
+
+        } catch (Exception e) {
+            log.info(wcsTask.getTaskNo() + "-----" + "回调状态:" + state + "异常", e);
+            wcsTask.setRemark("回调状态:" + state + "异常");
+            //释放redis锁
+            if (!StringUtils.isEmpty(wcsTask.getExt8())) {
+                redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
+            }
+            throw new RuntimeException();
+        }
+
+        wcsTask.setEndTime(new Date());
+        wcsTask.setState(state.longValue());
+        wcsTask.setUpdateUser("TS-TM");
+        wcsTask.setUpdateDate(new Date());
+        wcsTaskService.updateWcsTask(wcsTask);
+        return TsTaskStateResponse.success("操作成功!","");
+    }
+
+
+    @Transactional
+    @Override
+    public synchronized TsDataResponse sendTaskOrder(WcsTask wcsTask) {
+
+        try {
+            List<OrderSequence> orderSequenceList = new ArrayList<>();
+
+            //起始点位
+            Destinations deLocF = new Destinations();
+            deLocF.setLocationName(wcsTask.getLocationFrom());
+            deLocF.setOperation("Floor0_Take");
+            List<Destinations> desFList = new ArrayList<>();
+            desFList.add(deLocF);
+            OrderSequence orderLocF = new OrderSequence();
+            orderLocF.setStep("1");
+            orderLocF.setDestinations(desFList);
+            //目标点位
+            Destinations deLocT = new Destinations();
+            deLocT.setLocationName(wcsTask.getLocationTo());
+            deLocT.setOperation("Floor0_Place");
+            List<Destinations> desTList = new ArrayList<>();
+            desTList.add(deLocT);
+            OrderSequence orderLocT = new OrderSequence();
+            orderLocT.setStep("2");
+            orderLocT.setDestinations(desTList);
+
+            orderSequenceList.add(orderLocF);
+            orderSequenceList.add(orderLocT);
+
+            JSONObject jsonObject=  new JSONObject();
+            jsonObject.put("priority",wcsTask.getPriority());    //任务优先级
+            jsonObject.put("intendedVehicle","");                //计划车辆(不指定的话不传参数)
+            jsonObject.put("orderType","");                      //TS 流程编号(默认值由 TS 的 json 文件给出)
+            jsonObject.put("circulation","");                    //循环执行订单(给1则表示循环,不需要循环可以不给改参数)
+            jsonObject.put("orderSequence",orderSequenceList);   //点位 列表
+
+            log.info("TsTaskServiceImpl---sendTaskOrder:创建TS任务单:"+ JSON.toJSONString(jsonObject));
+            //String str = HttpRequest.postData(TsDataConfiguration.SEND_JOB_TS,jsonObject);
+            String str = "{\n" +
+                    " \"success\": true,\n" +
+                    " \"error_code\": \"0000\",\n" +
+                    " \"msg\": \"\",\n" +
+                    " \"data\": \"TSOrder-0003\"\n" +
+                    "}";
+            log.info("TsTaskServiceImpl---sendTaskOrder:TS任务单创建结果:"+ JSON.toJSONString(str));
+            TsDataResponse tsData = JSONObject.parseObject(str, TsDataResponse.class);
+
+            if("true".equals(tsData.getSuccess())){
+
+                wcsTask.setState(10L);
+                wcsTask.setDeviceName(tsData.getData().toString());
+            }else{
+
+                wcsTask.setRemark("错误码:"+tsData.getError_code()+",错误信息:"+tsData.getMsg());
+            }
+            wcsTaskService.updateWcsTask(wcsTask);
+            return tsData;
+
+        }catch (Exception e){
+            e.printStackTrace();
+            wcsTask.setRemark("任务下发异常:"+e);
+            return new TsDataResponse();
+        }
+    }
+
+
+    @Transactional
+    @Override
+    public synchronized TsDataResponse queryOrderInfoByIndex(String tsIndex) {
+
+        try {
+
+            //String str = HttpRequest.getData(TsDataConfiguration.QUERY_ORDER_INFO_TS_INDEX,":orderIndex",tsIndex);
+            String str = "{\n" +
+                    "\t\"success\": true,\n" +
+                    "\t\"error_code\": \"0000\",\n" +
+                    "\t\"msg\": \"\",\n" +
+                    "\t\"data\": {\n" +
+                    "\t\t\"tsOrderIndex\": \"TSOrder-0002\",\n" +
+                    "\t\t\"tsOrderState\": \"tsOrder Finished\",\n" +
+                    "\t\t\"processingVehicle\": \"Vehicle-0001\",\n" +
+                    "\t\t\"createdTime\": \"2022-04-26T09:49:26.959Z\",\n" +
+                    "\t\t\"finishedTime\": \"2022-04-26T09:50:10.077Z\",\n" +
+                    "\t\t\"destinations\": [\n" +
+                    "\t\t\t\"Location-0001\",\n" +
+                    "\t\t\t\"Location-0004\"\n" +
+                    "\t\t]\n" +
+                    "\t}\n" +
+                    "}";
+            log.info("TsTaskServiceImpl---queryOrderInfoByIndex:获取订单信息结果:"+ JSON.toJSONString(str));
+            TsDataResponse tsData = JSONObject.parseObject(str, TsDataResponse.class);
+            return tsData;
+
+        }catch (Exception e){
+            e.printStackTrace();
+            return new TsDataResponse();
+        }
+    }
+
+
+    @Transactional
+    @Override
+    public synchronized TsDataResponse queryOrderInfo() {
+
+        try {
+
+            //String str = HttpRequest.getData(TsDataConfiguration.QUERY_ORDER_INFO);
+            String str = "{\n" +
+                    "\t\"success\": true,\n" +
+                    "\t\"error_code\": \"0000\",\n" +
+                    "\t\"msg\": \"\",\n" +
+                    "\t\"data\": [\n" +
+                    "\t\t{\n" +
+                    "\t\t\t\"tsOrderIndex\": \"TSOrder-0003\",\n" +
+                    "\t\t\t\"tsOrderState\": \"tsOrder Finished\",\n" +
+                    "\t\t\t\"processingVehicle\": \"Vehicle-0001\",\n" +
+                    "\t\t\t\"createdTime\": \"2022-04-26T10:42:06.601Z\",\n" +
+                    "\t\t\t\"finishedTime\": \"2022-04-26T10:43:57.451Z\",\n" +
+                    "\t\t\t\"destinations\": [\n" +
+                    "\t\t\t\t\"Location-0001\",\n" +
+                    "\t\t\t\t\"Location-0004\"\n" +
+                    "\t\t\t]\n" +
+                    "\t\t},\n" +
+                    "\t\t{\n" +
+                    "\t\t\t\"tsOrderIndex\": \"TSOrder-0002\",\n" +
+                    "\t\t\t\"tsOrderState\": \"tsOrder Finished\",\n" +
+                    "\t\t\t\"processingVehicle\": \"Vehicle-0001\",\n" +
+                    "\t\t\t\"createdTime\": \"2022-04-26T10:42:05.604Z\",\n" +
+                    "\t\t\t\"finishedTime\": \"2022-04-26T10:43:17.428Z\",\n" +
+                    "\t\t\t\"destinations\": [\n" +
+                    "\t\t\t\t\"Location-0001\",\n" +
+                    "\t\t\t\t\"Location-0004\"\n" +
+                    "\t\t\t]\n" +
+                    "\t\t},\n" +
+                    "\t\t{\n" +
+                    "\t\t\t\"tsOrderIndex\": \"TSOrder-0001\",\n" +
+                    "\t\t\t\"tsOrderState\": \"tsOrder Finished\",\n" +
+                    "\t\t\t\"processingVehicle\": \"Vehicle-0001\",\n" +
+                    "\t\t\t\"createdTime\": \"2022-04-26T10:42:04.480Z\",\n" +
+                    "\t\t\t\"finishedTime\": \"2022-04-26T10:42:37.095Z\",\n" +
+                    "\t\t\t\"destinations\": [\n" +
+                    "\t\t\t\t\"Location-0001\",\n" +
+                    "\t\t\t\t\"Location-0004\"\n" +
+                    "\t\t\t]\n" +
+                    "\t\t},\n" +
+                    "\t\t{\n" +
+                    "\t\t\t\"tsOrderIndex\": \"TSOrder-0000\",\n" +
+                    "\t\t\t\"tsOrderState\": \"tsOrder Failed\",\n" +
+                    "\t\t\t\"processingVehicle\": \"Vehicle-0001\",\n" +
+                    "\t\t\t\"createdTime\": \"2022-04-26T10:40:44.192Z\",\n" +
+                    "\t\t\t\"finishedTime\": null,\n" +
+                    "\t\t\t\"destinations\": [\n" +
+                    "\t\t\t\t\"Location-0001\",\n" +
+                    "\t\t\t\t\"Location-0004\"\n" +
+                    "\t\t\t]\n" +
+                    "\t\t}\n" +
+                    "\t]\n" +
+                    "}";
+            log.info("TsTaskServiceImpl---queryOrderInfo:全部订单信息结果:"+ JSON.toJSONString(str));
+            TsDataResponse tsData = JSONObject.parseObject(str, TsDataResponse.class);
+            return tsData;
+
+        }catch (Exception e){
+            e.printStackTrace();
+            return new TsDataResponse();
+        }
+    }
+
+
+    @Transactional
+    @Override
+    public synchronized TsDataResponse delOrderByIndex(String tsIndex) {
+
+        try {
+
+            if(tsIndex == null || "".equals(tsIndex)){
+                return new TsDataResponse();
+            }
+
+            JSONObject jsonObject=  new JSONObject();
+            jsonObject.put(":TSIndex",tsIndex);
+
+            //String str = HttpRequest.postData(TsDataConfiguration.DEL_ORDER_TS_INDEX,jsonObject);
+            String str = "{\n" +
+                    "\"success\": true, \"error_code\": \"0000\", \"msg\": \"\", \"data\": \"\" }";
+            log.info("TsTaskServiceImpl---delOrderByIndex:取消结果:"+ JSON.toJSONString(str));
+            TsDataResponse tsData = JSONObject.parseObject(str, TsDataResponse.class);
+            return tsData;
+
+        }catch (Exception e){
+            e.printStackTrace();
+            return new TsDataResponse();
+        }
+    }
+
+
+    @Transactional
+    @Override
+    public synchronized TsDataResponse delOrderByAgvNo(String agvNo) {
+
+        try {
+
+            JSONObject jsonObject=  new JSONObject();
+            jsonObject.put(":VehicleName",agvNo);
+
+            //String str = HttpRequest.postData(TsDataConfiguration.DEL_ORDER_AGV_NO,jsonObject);
+            String str = "{\n" +
+                    "\"success\": true, \"error_code\": \"0000\", \"msg\": \"\", \"data\": \"\" }";
+            log.info("TsTaskServiceImpl---delOrder:取消结果:"+ JSON.toJSONString(str));
+            TsDataResponse tsData = JSONObject.parseObject(str, TsDataResponse.class);
+            return tsData;
+
+        }catch (Exception e){
+            e.printStackTrace();
+            return new TsDataResponse();
+        }
+    }
+
+    @Transactional
+    @Override
+    public synchronized TsDataResponse sendChargeJob(String agvNo,String loc) {
+
+        try {
+
+            //设置充电机位置
+            Destinations destination = new Destinations();
+            destination.setLocationName(loc);    //充电机点位
+            destination.setOperation("Charge");
+            List<Destinations> desList = new ArrayList<>();
+            desList.add(destination);
+
+            JSONObject jsonObject=  new JSONObject();
+            jsonObject.put("deadline","");              //截至时间
+            jsonObject.put("intendedVehicle",agvNo);    //车号
+            jsonObject.put("destinations",desList);
+
+            log.info("TsTaskServiceImpl---sendChargeJob:发送充电任务:"+ JSON.toJSONString(jsonObject));
+            //String str = HttpRequest.postData(TsDataConfiguration.SEND_CHARGE_JOB,jsonObject);
+            String str = "{\n" +
+                    "\"success\": true, \"error_code\": \"0000\", \"msg\": \"\", \"data\": \"\" }";
+            log.info("TsTaskServiceImpl---sendChargeJob:充电消息发送结果:"+ JSON.toJSONString(str));
+            TsDataResponse tsData = JSONObject.parseObject(str, TsDataResponse.class);
+            return tsData;
+
+        }catch (Exception e){
+            e.printStackTrace();
+            return new TsDataResponse();
+        }
+    }
+}

+ 15 - 1
warewms-ams/src/main/resources/mapper/ams/WcsTaskMapper.xml

@@ -111,7 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectWcsTaskListVO" parameterType="WcsTask" resultMap="WcsTaskResult">
         select t.task_no, t.business_type,bf.location_no location_from,fz.zone_name area_from,bt.location_no location_to,tz.zone_name area_to,
-        t.state,t.create_date,t.task_type, t.start_time, t.end_time,t.remark
+        t.state,t.create_date,t.task_type, t.start_time, t.end_time,t.remark, t.device_name, t.agv_no
         from wcs_task t
         left join base_location_info bf on t.location_from = bf.id
         left join base_location_info bt on t.location_to = bt.id
@@ -148,6 +148,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where task_no = #{taskNo}
     </select>
 
+    <select id="selectWcsTaskByTsIndex" parameterType="String" resultMap="WcsTaskResult">
+        <include refid="selectWcsTaskVo"/>
+        where device_name = #{tsIndex} or task_no = #{tsIndex}
+        ORDER BY create_date DESC
+        LIMIT 1
+    </select>
+
+    <select id="selectWcsTaskByAgvNo" parameterType="String" resultMap="WcsTaskResult">
+        <include refid="selectWcsTaskVo"/>
+        where agv_no = #{tsIndex} and state in(1,3,4,5,6,9,10)
+        ORDER BY create_date DESC
+        LIMIT 1
+    </select>
+
     <insert id="insertWcsTask" parameterType="WcsTask">
         insert into wcs_task
         <trim prefix="(" suffix=")" suffixOverrides=",">