From 4f613bfb28a77452e3b6329d79be2c2112457837 Mon Sep 17 00:00:00 2001
From: gengby <858962040@qq.com>
Date: Sun, 11 Dec 2022 16:40:39 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../maGang/MaGangConveyorDeviceDriver.java    | 21 ++++++++-----
 .../wms/service/impl/AgvToAcsServiceImpl.java |  6 ++--
 .../amb/service/impl/HFHandServiceImpl.java   | 13 +++++++-
 acs/nladmin-ui/.env.production                |  4 +--
 .../device/driver/magang_conveyor_control.vue | 31 +++++++++++++++----
 .../src/views/acs/instruction/index.vue       | 13 +++++---
 acs/nladmin-ui/src/views/acs/task/index.vue   | 15 +++++----
 7 files changed, 72 insertions(+), 31 deletions(-)

diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java
index 4a69f90..cc50f44 100644
--- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java
+++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java
@@ -181,32 +181,37 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen
                     }
                 }
             }
+            String taskType = String.valueOf(this.getExtraValue().get("taskType"));
+            String start_device_code = this.getDevice().getDevice_code();
             if (StrUtil.isEmpty(next_device_code)) {
                 return false;
             }
+            if (StrUtil.equals(taskType, "null") || StrUtil.isEmpty(taskType)) {
+                taskType = "0";
+            }
             TaskDto taskDto = new TaskDto();
             String now = DateUtil.now();
             taskDto.setTask_id(IdUtil.simpleUUID());
             taskDto.setTask_code("-" + CodeUtil.getNewCode("TASK_NO"));
-            taskDto.setTask_type("1");
+            taskDto.setTask_type(taskType);
             taskDto.setRoute_plan_code("normal");
             taskDto.setTask_status("0");
             taskDto.setPriority("101");
             taskDto.setAgv_system_type("1");
-            taskDto.setStart_device_code(this.getDevice().getDevice_code());
-            taskDto.setStart_point_code(this.getDevice().getDevice_code());
+            taskDto.setStart_device_code(start_device_code);
+            taskDto.setStart_point_code(start_device_code);
             taskDto.setNext_point_code(next_device_code);
             taskDto.setNext_point_code(next_device_code);
-            taskDto.setCreate_by(this.getDevice().getDevice_code());
-            taskDto.setUpdate_by(this.getDevice().getDevice_code());
+            taskDto.setCreate_by(start_device_code);
+            taskDto.setUpdate_by(start_device_code);
             taskDto.setUpdate_time(now);
             taskDto.setCreate_time(now);
             try {
                 taskserver.create(taskDto);
             } catch (Exception e) {
-                logServer.deviceExecuteLog(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage()));
+                logServer.deviceExecuteLog(this.device_code, "", "", this.device_code + ":创建任务失败," + String.valueOf(e.getMessage()));
             }
-            logServer.deviceExecuteLog(this.device_code, "", "", device_code + ":创建任务成功");
+            logServer.deviceExecuteLog(this.device_code, "", "", this.device_code + ":创建任务成功");
             this.writing(1);
             this.setRequireSucess(true);
             return true;
@@ -220,7 +225,7 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen
     //将扩展表中的字符串数据转换成集合
     public List<String> getExtraDeviceCodes(String extraName) {
         String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
-        if (StrUtil.isEmpty(extraValue)){
+        if (StrUtil.isEmpty(extraValue)) {
             return new ArrayList<>();
         }
         String devicesString = extraValue.substring(1, extraValue.length() - 1);
diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java
index 4c80bbb..113a59b 100644
--- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java
+++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java
@@ -47,7 +47,8 @@ public class AgvToAcsServiceImpl implements AgvToAcsService {
         map.put("status", 200);
         map.put("message", "操作成功");
         if (address.contains("INGET")) {
-            if (maGangConveyorDeviceDriver.getMove() == 1) {
+            maGangConveyorDeviceDriver.writing(4);
+            if (maGangConveyorDeviceDriver.getMove() == 1 && maGangConveyorDeviceDriver.getAction() == 1) {
                 logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString());
                 return map;
             } else {
@@ -64,7 +65,8 @@ public class AgvToAcsServiceImpl implements AgvToAcsService {
                 throw new BadRequestException("请求失败,取货完成后-取货点有货!");
             }
         } else if (address.contains("INPUT")) {
-            if (maGangConveyorDeviceDriver.getMove() == 0) {
+            maGangConveyorDeviceDriver.writing(5);
+            if (maGangConveyorDeviceDriver.getMove() == 0 && maGangConveyorDeviceDriver.getAction() == 2) {
                 logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString());
                 return map;
             } else {
diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/amb/service/impl/HFHandServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/hand/amb/service/impl/HFHandServiceImpl.java
index 9d94d1c..f90fa6a 100644
--- a/acs/nladmin-system/src/main/java/org/nl/hand/amb/service/impl/HFHandServiceImpl.java
+++ b/acs/nladmin-system/src/main/java/org/nl/hand/amb/service/impl/HFHandServiceImpl.java
@@ -17,6 +17,7 @@ import org.nl.acs.device.service.dto.DeviceDto;
 import org.nl.acs.device.service.impl.DeviceServiceImpl;
 import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
 import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
+import org.nl.acs.device_driver.maGang.MaGangConveyorDeviceDriver;
 import org.nl.acs.instruction.service.InstructionService;
 import org.nl.acs.instruction.service.dto.Instruction;
 import org.nl.acs.instruction.service.dto.InstructionDto;
@@ -345,7 +346,17 @@ public class HFHandServiceImpl implements HFHandService {
             resultJson.put("result", "");
             return resultJson;
         }
-
+        Device device = deviceAppService.findDeviceByCode(start_devicecode);
+        if (device.getDeviceDriver() instanceof MaGangConveyorDeviceDriver){
+            MaGangConveyorDeviceDriver maGangConveyorDeviceDriver =
+                    (MaGangConveyorDeviceDriver) device.getDeviceDriver();
+            String taskType = String.valueOf(maGangConveyorDeviceDriver.getExtraValue().get("taskType"));
+            if (StrUtil.equals(taskType,"null") || StrUtil.isEmpty(taskType)){
+                task_type = "0";
+            }else {
+                task_type = taskType;
+            }
+        }
         TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
         TaskDto dto = new TaskDto();
         dto.setIs_active("1");
diff --git a/acs/nladmin-ui/.env.production b/acs/nladmin-ui/.env.production
index 786bd42..762ac12 100644
--- a/acs/nladmin-ui/.env.production
+++ b/acs/nladmin-ui/.env.production
@@ -2,6 +2,6 @@ ENV = 'production'
 
 # 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置
 # 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http
-VUE_APP_BASE_API  = 'http://47.97.157.227:8010'
+VUE_APP_BASE_API  = 'http://127.0.0.1:8010'
 # 如果接口是 http 形式, wss 需要改为 ws
-VUE_APP_WS_API = 'ws://47.97.157.227:8010'
+VUE_APP_WS_API = 'ws://127.0.0.1:8010'
diff --git a/acs/nladmin-ui/src/views/acs/device/driver/magang_conveyor_control.vue b/acs/nladmin-ui/src/views/acs/device/driver/magang_conveyor_control.vue
index 825e925..2bc0f38 100644
--- a/acs/nladmin-ui/src/views/acs/device/driver/magang_conveyor_control.vue
+++ b/acs/nladmin-ui/src/views/acs/device/driver/magang_conveyor_control.vue
@@ -92,6 +92,11 @@
               <el-switch v-model="form.manual_create_task" />
             </el-form-item>
           </el-col>
+          <el-col :span="8">
+            <el-form-item label="是否输入物料" label-width="150px">
+              <el-switch v-model="form.input_material" />
+            </el-form-item>
+          </el-col>
         </el-row>
 
         <el-row>
@@ -112,6 +117,23 @@
               </el-select>
             </el-form-item>
           </el-col>
+          <el-col :span="8">
+            <el-form-item label="任务类型" label-width="150px">
+              <el-select
+                v-model="form.taskType"
+                filterable
+                clearable
+                placeholder="请选择"
+              >
+                <el-option
+                  v-for="item in dict.task_type"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
           <el-col :span="8">
             <el-form-item label="关联三色灯" prop="device_code" label-width="100px">
               <el-select
@@ -129,11 +151,6 @@
               </el-select>
             </el-form-item>
           </el-col>
-          <el-col :span="8">
-            <el-form-item label="是否输入物料" label-width="150px">
-              <el-switch v-model="form.input_material" />
-            </el-form-item>
-          </el-col>
         </el-row>
       </el-form>
     </el-card>
@@ -266,6 +283,7 @@ import deviceCrud from '@/api/acs/device/device'
 
 export default {
   name: 'StandardConveyorControl',
+  dicts: ['task_type'],
   mixins: [crud],
   props: {
     parentForm: {
@@ -297,7 +315,8 @@ export default {
         manual_create_task: true,
         is_pickup: true,
         is_release: true,
-        link_device_code: []
+        link_device_code: [],
+        taskType: ''
       },
       rules: {}
     }
diff --git a/acs/nladmin-ui/src/views/acs/instruction/index.vue b/acs/nladmin-ui/src/views/acs/instruction/index.vue
index 7e82e25..9130599 100644
--- a/acs/nladmin-ui/src/views/acs/instruction/index.vue
+++ b/acs/nladmin-ui/src/views/acs/instruction/index.vue
@@ -109,10 +109,14 @@
         <el-table-column type="selection" width="55" />
         <el-table-column v-if="false" prop="instruction_id" label="指令标识" />
         <el-table-column prop="instruction_code" label="指令编号" />
-        <el-table-column prop="instruction_type" label="指令类型" />
-        <el-table-column prop="link_num" label="关联编号" />
+        <el-table-column prop="instruction_type" label="指令类型">
+          <template slot-scope="scope">
+            {{ dict.label.instruction_type[scope.row.instruction_type] }}
+          </template>
+        </el-table-column>
+<!--        <el-table-column prop="link_num" label="关联编号" />-->
         <el-table-column prop="task_code" label="任务号" />
-        <el-table-column prop="vehicle_code" label="载具号" />
+
         <el-table-column prop="instruction_status" label="指令状态">
           <template slot-scope="scope">
             <span v-if="scope.row.instruction_status=='0' ">就绪</span>
@@ -130,6 +134,7 @@
         <el-table-column prop="start_point_code" label="取货点" />
         <el-table-column prop="put_point_code" label="倒料点" />
         <el-table-column prop="next_point_code" label="放货点" />
+        <el-table-column prop="vehicle_code" label="载具号" />
         <el-table-column prop="carno" label="车号" />
         <el-table-column prop="compound_inst" label="复合指令">
           <template slot-scope="scope">
@@ -213,7 +218,7 @@ const defaultForm = {
   update_time: null
 }
 export default {
-  dicts: ['task_status'],
+  dicts: ['task_status', 'instruction_type'],
   name: 'Instruction',
   components: { crudOperation },
   mixins: [presenter(), header(), form(defaultForm), crud()],
diff --git a/acs/nladmin-ui/src/views/acs/task/index.vue b/acs/nladmin-ui/src/views/acs/task/index.vue
index d95937c..4b5a1db 100644
--- a/acs/nladmin-ui/src/views/acs/task/index.vue
+++ b/acs/nladmin-ui/src/views/acs/task/index.vue
@@ -251,9 +251,11 @@
         <el-table-column type="selection" width="25" />
         <el-table-column v-if="false" prop="task_id" label="任务标识" />
         <el-table-column prop="task_code" label="任务号" />
-        <el-table-column prop="task_type" label="任务类型" />
-        <el-table-column prop="link_num" label="关联编号" />
-        <el-table-column prop="vehicle_code" label="载具号" />
+        <el-table-column prop="task_type" label="任务类型">
+          <template slot-scope="scope">
+            {{ dict.label.task_type[scope.row.task_type] }}
+          </template>
+        </el-table-column>
         <el-table-column prop="task_status" label="任务状态">
           <template slot-scope="scope">
             <span v-if="scope.row.task_status==='0' ">就绪</span>
@@ -261,15 +263,12 @@
             <span v-if="scope.row.task_status==='2' ">完成</span>
           </template>
         </el-table-column>
-        <!--<el-table-column prop="task_type" label="任务类型">
-          <template slot-scope="scope">
-            {{ dict.label.task_type[scope.row.task_type] }}
-          </template>
-        </el-table-column>-->
         <el-table-column prop="priority" label="任务优先级" />
         <el-table-column prop="start_point_code" label="取货点" width="120px" />
         <el-table-column prop="put_point_code" label="倒料点" />
         <el-table-column prop="next_point_code" label="放货点" width="120px" />
+        <el-table-column prop="link_num" label="关联编号" />
+        <el-table-column prop="vehicle_code" label="载具号" />
         <el-table-column prop="compound_task" label="复合任务">
           <template slot-scope="scope">
             <span v-if="scope.row.compound_task==='0' ">否</span>