Browse Source

1、生成任务前判断是否已经有正在进行的任务
2、任务结束反馈时给西门子S1500写数据

LZH 1 year ago
parent
commit
c7b5566e4c

+ 16 - 8
warewms-ams/src/main/java/com/ruoyi/ams/task/mapper/WcsTaskMapper.java

@@ -7,15 +7,15 @@ import org.apache.ibatis.annotations.Param;
 
 /**
  * AGV任务Mapper接口
- * 
+ *
  * @author andy
  * @date 2022-03-10
  */
-public interface WcsTaskMapper 
+public interface WcsTaskMapper
 {
     /**
      * 查询AGV任务
-     * 
+     *
      * @param taskNo AGV任务主键
      * @return AGV任务
      */
@@ -23,12 +23,20 @@ public interface WcsTaskMapper
 
     /**
      * 查询AGV任务列表
-     * 
+     *
      * @param wcsTask AGV任务
      * @return AGV任务集合
      */
      List<WcsTask> selectWcsTaskList(WcsTask wcsTask);
 
+    /**
+     * 根据起始/目标点位 查询状态为未完成的AGV任务列表
+     *
+     * @param wcsTask AGV任务
+     * @return AGV任务集合
+     */
+    List<WcsTask> selectWcsTaskList1(WcsTask wcsTask);
+
     /**
      * 查询物料列表
      * @param wcsTask
@@ -38,7 +46,7 @@ public interface WcsTaskMapper
 
     /**
      * 新增AGV任务
-     * 
+     *
      * @param wcsTask AGV任务
      * @return 结果
      */
@@ -46,7 +54,7 @@ public interface WcsTaskMapper
 
     /**
      * 修改AGV任务
-     * 
+     *
      * @param wcsTask AGV任务
      * @return 结果
      */
@@ -54,7 +62,7 @@ public interface WcsTaskMapper
 
     /**
      * 删除AGV任务
-     * 
+     *
      * @param taskNo AGV任务主键
      * @return 结果
      */
@@ -62,7 +70,7 @@ public interface WcsTaskMapper
 
     /**
      * 批量删除AGV任务
-     * 
+     *
      * @param taskNos 需要删除的数据主键集合
      * @return 结果
      */

+ 241 - 0
warewms-ams/src/main/java/com/ruoyi/ams/task/service/impl/WcsTaskServiceImpl.java

@@ -25,6 +25,7 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.common.utils.uuid.SnowflakeIdWorker;
 import com.ruoyi.hard.modbus.tcp.AutoDoorClient;
+import com.ruoyi.hard.plc.PlcService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -384,6 +385,126 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
                         if (wcsTask.getState() == 6) {
                             return AjaxResult.error("不能重复放货," + taskNo);
                         }
+                        //不合格品左下料结束
+                        if (wcsTask.getLocationFrom().equals("100000")){
+                            PlcService.plcWritepassedNoProductLeftBlankingEnd();
+                            //取消写不合格品左正在下料信号
+                            PlcService.plcWritepassedNoProductLeftBlanking1();
+                            //延时取消写不合格品左下料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedNoProductLeftBlankingEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //不合格品左空托上料结束
+                        if (wcsTask.getLocationTo().equals("100000")){
+                            PlcService.plcWritepassedNoProductLeftSkyEnd();
+                            //取消写不合格品左正在上空托盘
+                            PlcService.plcWritepassedNoProductLeftSky1();
+                            //延时取消写不合格品左空托上料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedNoProductLeftSkyEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //不合格品右下料结束
+                        if (wcsTask.getLocationFrom().equals("100002")){
+                            PlcService.plcWritepassedNoProductRightBlankingEnd();
+                            //取消写不合格品右侧正在下料信号
+                            PlcService.plcWritepassedNoProductRightBlanking1();
+                            //延时取消写不合格品右下料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedNoProductRightBlankingEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //不合格品右空托上料结束
+                        if (wcsTask.getLocationTo().equals("100002")){
+                            PlcService.plcWritepassedNoProductRightSkyEnd();
+                            //取消写不合格品右正在上空托盘
+                            PlcService.plcWritepassedNoProductRightSky1();
+                            //延时取消写不合格品右空托上料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedNoProductRightSkyEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //合格品左下料结束
+                        if (wcsTask.getLocationFrom().equals("100001")){
+                            PlcService.plcWritepassedProductLeftBlankingEnd();
+                            //取消写合格品左正在下料信号
+                            PlcService.plcWritepassedProductLeftBlanking1();
+                            //延时取消写合格品左下料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedProductLeftBlankingEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //合格品左空托上料结束
+                        if (wcsTask.getLocationTo().equals("100001")){
+                            PlcService.plcWritepassedProductLeftSkyEnd();
+                            //取消写合格品左正在上空托
+                            PlcService.plcWritepassedProductLeftSky1();
+                            //延时取消写合格品左空托上料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedProductLeftSkyEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //合格品右下料结束
+                        if (wcsTask.getLocationFrom().equals("100003")){
+                            PlcService.plcWritepassedProductRightBlankingEnd();
+                            //取消写合格品右正在下料
+                            PlcService.plcWritepassedProductRightBlanking1();
+                            //延时取消写合格品右下料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedProductRightBlankingEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //合格品右空托上料结束
+                        if (wcsTask.getLocationTo().equals("100003")){
+                            PlcService.plcWritepassedProductRightSkyEnd();
+                            //取消写合格品右正在上空托
+                            PlcService.plcWritepassedProductRightSky1();
+                            //延时取消写合格品右空托上料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedProductRightSkyEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
                         wcsTask.setEndTime(new Date());
                         // 解锁终点库位
                         baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo())
@@ -434,6 +555,126 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
                         if (wcsTask.getState() == 6) {
                             return AjaxResult.error("不能重复放货," + taskNo);
                         }
+                        //不合格品左下料结束
+                        if (wcsTask.getLocationFrom().equals("100000")){
+                            PlcService.plcWritepassedNoProductLeftBlankingEnd();
+                            //取消写不合格品左正在下料信号
+                            PlcService.plcWritepassedNoProductLeftBlanking1();
+                            //延时取消写不合格品左下料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedNoProductLeftBlankingEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //不合格品左空托上料结束
+                        if (wcsTask.getLocationTo().equals("100000")){
+                            PlcService.plcWritepassedNoProductLeftSkyEnd();
+                            //取消写不合格品左正在上空托盘
+                            PlcService.plcWritepassedNoProductLeftSky1();
+                            //延时取消写不合格品左空托上料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedNoProductLeftSkyEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //不合格品右下料结束
+                        if (wcsTask.getLocationFrom().equals("100002")){
+                            PlcService.plcWritepassedNoProductRightBlankingEnd();
+                            //取消写不合格品右侧正在下料信号
+                            PlcService.plcWritepassedNoProductRightBlanking1();
+                            //延时取消写不合格品右下料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedNoProductRightBlankingEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //不合格品右空托上料结束
+                        if (wcsTask.getLocationTo().equals("100002")){
+                            PlcService.plcWritepassedNoProductRightSkyEnd();
+                            //取消写不合格品右正在上空托盘
+                            PlcService.plcWritepassedNoProductRightSky1();
+                            //延时取消写不合格品右空托上料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedNoProductRightSkyEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //合格品左下料结束
+                        if (wcsTask.getLocationFrom().equals("100001")){
+                            PlcService.plcWritepassedProductLeftBlankingEnd();
+                            //取消写合格品左正在下料信号
+                            PlcService.plcWritepassedProductLeftBlanking1();
+                            //延时取消写合格品左下料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedProductLeftBlankingEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //合格品左空托上料结束
+                        if (wcsTask.getLocationTo().equals("100001")){
+                            PlcService.plcWritepassedProductLeftSkyEnd();
+                            //取消写合格品左正在上空托
+                            PlcService.plcWritepassedProductLeftSky1();
+                            //延时取消写合格品左空托上料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedProductLeftSkyEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //合格品右下料结束
+                        if (wcsTask.getLocationFrom().equals("100003")){
+                            PlcService.plcWritepassedProductRightBlankingEnd();
+                            //取消写合格品右正在下料
+                            PlcService.plcWritepassedProductRightBlanking1();
+                            //延时取消写合格品右下料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedProductRightBlankingEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
+                        //合格品右空托上料结束
+                        if (wcsTask.getLocationTo().equals("100003")){
+                            PlcService.plcWritepassedProductRightSkyEnd();
+                            //取消写合格品右正在上空托
+                            PlcService.plcWritepassedProductRightSky1();
+                            //延时取消写合格品右空托上料结束
+                            new Thread(() -> {
+                                try {
+                                    Thread.sleep(3000);
+                                    PlcService.plcWritepassedProductRightSkyEnd1();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }).start();
+                        }
                         wcsTask.setEndTime(new Date());
                         // 解锁终点库位
                         baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo())

+ 21 - 0
warewms-ams/src/main/resources/mapper/ams/WcsTaskMapper.xml

@@ -109,6 +109,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
+    <select id="selectWcsTaskList1" parameterType="WcsTask" resultMap="WcsTaskResult">
+        <include refid="selectWcsTaskVo"/>
+        <where>
+            <if test="locationFrom != null  and locationFrom != ''"> and location_from = #{locationFrom}</if>
+            <if test="areaFrom != null  and areaFrom != ''"> and area_from = #{areaFrom}</if>
+            <if test="locationTo != null  and locationTo != ''"> and location_to = #{locationTo}</if>
+            <if test="areaTo != null  and areaTo != ''"> and area_to = #{areaTo}</if>
+            <if test="priority != null "> and priority = #{priority}</if>
+            <if test="state != null "> and state = #{state}</if>
+            <if test="createUser != null  and createUser != ''"> and create_user = #{createUser}</if>
+            <if test="createDate != null "> and create_date = #{createDate}</if>
+            <if test="taskType != null  and taskType != ''"> and task_type = #{taskType}</if>
+            <if test="shopId != null  and shopId != ''"> and shop_id = #{shopId}</if>
+            <if test="startTime != null "> and start_time = #{startTime}</if>
+            <if test="endTime != null "> and end_time = #{endTime}</if>
+            <if test="parentTask != null  and parentTask != ''"> and parent_task = #{parentTask}</if>
+            <if test="agvNo != null  and agvNo != ''"> and agv_no like concat('%', #{agvNo}, '%')</if>
+        </where>
+        and state in(1,3,4,5,8,9,10)
+    </select>
+
     <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