andy 3 gadi atpakaļ
vecāks
revīzija
d84b06fb51

+ 11 - 0
ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/WarehouseTest.java

@@ -2,10 +2,13 @@ package com.ruoyi.admin.test.base;
 
 import com.alibaba.fastjson.JSON;
 import com.ruoyi.RuoYiApplication;
+import com.ruoyi.ams.config.domain.FlowConfigHeader;
 import com.ruoyi.ams.config.domain.dto.InWarehouseDTO;
 import com.ruoyi.ams.business.IBusinessService;
 import com.ruoyi.ams.config.domain.dto.LotattDTO;
 import com.ruoyi.ams.config.domain.dto.OutWarehouseDTO;
+import com.ruoyi.ams.config.domain.vo.FlowConfigHeaderVO;
+import com.ruoyi.ams.config.service.IFlowConfigHeaderService;
 import com.ruoyi.ams.config.service.LocationAllocationStrategy;
 import com.ruoyi.ams.inv.mapper.InvLotLocIdMapper;
 import com.ruoyi.ams.locationView.domain.form.LocationViewForm;
@@ -59,6 +62,8 @@ public class WarehouseTest {
     private BaseLocationInfoMapper baseLocationInfoMapper;
     @Autowired
     private IBaseLocationInfoService baseLocationInfoService;
+    @Autowired
+    private IFlowConfigHeaderService flowConfigHeaderService;
 
     @Test
     public void test() {
@@ -130,4 +135,10 @@ public class WarehouseTest {
         List<String> colNos = baseLocationInfoMapper.selectSameSkuTypeColNo("2", null);
         System.out.println(colNos);
     }
+
+    @Test
+    public void test5() {
+        List<FlowConfigHeader> flowConfigHeaderVOS = flowConfigHeaderService.sortFlowConfigHeader(8L);
+        System.out.println(JSON.toJSONString(flowConfigHeaderVOS));
+    }
 }

+ 34 - 14
warewms-ams/src/main/java/com/ruoyi/ams/business/BusinessServiceImpl.java

@@ -3,6 +3,7 @@ package com.ruoyi.ams.business;
 import com.alibaba.fastjson.JSON;
 import com.ruoyi.ams.common.Constant;
 import com.ruoyi.ams.config.domain.AsnSoStrategy;
+import com.ruoyi.ams.config.domain.FlowConfigHeader;
 import com.ruoyi.ams.config.domain.dto.AgvCallDTO;
 import com.ruoyi.ams.config.domain.dto.InWarehouseDTO;
 import com.ruoyi.ams.config.domain.dto.LotattDTO;
@@ -84,7 +85,7 @@ public class BusinessServiceImpl implements IBusinessService {
         if (StringUtils.isEmpty(paramLocationFrom)) {
             paramLocationFrom = flowConfigHeaderVO.getLocationFrom();
         }
-        if(StringUtils.isEmpty(paramLocationTo)) {
+        if (StringUtils.isEmpty(paramLocationTo)) {
             paramLocationTo = flowConfigHeaderVO.getLocationTo();
         }
 
@@ -106,19 +107,11 @@ public class BusinessServiceImpl implements IBusinessService {
             locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "MV", asnSoStrategy, agvCallDTO);
         }
 
-        String taskNo = System.currentTimeMillis() + "";
-        WcsTask wcsTask = new WcsTask();
-        wcsTask.setTaskNo(taskNo);
-        wcsTask.setAreaFrom(locationFrom.getZoneId().toString());
-        wcsTask.setLocationFrom(locationFrom.getId().toString());
-        wcsTask.setAreaTo(locationTo.getZoneId() + "");
-        wcsTask.setLocationTo(locationTo.getId().toString());
-        wcsTask.setState(9L);
-        wcsTask.setPriority(1L);
-        wcsTask.setCreateDate(new Date());
-        wcsTask.setBusinessType("01");
-        wcsTask.setTaskType("");
-        return businessService.addTask(wcsTask);
+        List<WcsTask> wcsTaskList = this.genTask(locationFrom,locationTo,flowConfigHeaderVO);
+        for(WcsTask wcsTask : wcsTaskList) {
+            this.addTask(wcsTask);
+        }
+        return AjaxResult.error("任务下发成功");
     }
 
     @Transactional
@@ -327,6 +320,33 @@ public class BusinessServiceImpl implements IBusinessService {
         return locationInfoList;
     }
 
+    @Override
+    public List<WcsTask> genTask(BaseLocationInfo locationFrom, BaseLocationInfo locationTo, FlowConfigHeaderVO flowConfigHeaderVO) {
+        List<WcsTask> wcsTaskList = new ArrayList<>();
+        if (StringUtils.isEmpty(flowConfigHeaderVO.getRootFlow())) {
+            String taskNo = System.currentTimeMillis() + "";
+            WcsTask wcsTask = new WcsTask();
+            wcsTask.setTaskNo(taskNo);
+            wcsTask.setAreaFrom(locationFrom.getZoneId().toString());
+            wcsTask.setLocationFrom(locationFrom.getId().toString());
+            wcsTask.setAreaTo(locationTo.getZoneId() + "");
+            wcsTask.setLocationTo(locationTo.getId().toString());
+            wcsTask.setState(9L);
+            wcsTask.setPriority(1L);
+            wcsTask.setCreateDate(new Date());
+            wcsTask.setBusinessType("01");
+            wcsTask.setTaskType("");
+            wcsTaskList.add(wcsTask);
+        } else {
+            //获取对应的流程
+            List<FlowConfigHeader> headerVOList = flowConfigHeaderService.sortFlowConfigHeader(Long.parseLong(flowConfigHeaderVO.getRootFlow()));
+            for(FlowConfigHeader flowConfigHeader : headerVOList) {
+
+            }
+        }
+        return wcsTaskList;
+    }
+
     @Transactional
     @Override
     public AjaxResult addTask(WcsTask wcsTask) {

+ 7 - 0
warewms-ams/src/main/java/com/ruoyi/ams/business/IBusinessService.java

@@ -60,6 +60,13 @@ public interface IBusinessService {
      */
     List<BaseLocationInfo> convertLocation(String locationNoOrZoneId, Long warehouseId);
 
+    /**
+     * 生成任务
+     * @param flowConfigHeaderVO
+     * @return
+     */
+    List<WcsTask> genTask(BaseLocationInfo locationFrom,BaseLocationInfo locationTo,FlowConfigHeaderVO  flowConfigHeaderVO);
+
     /**
      * 新增任务
      *

+ 7 - 0
warewms-ams/src/main/java/com/ruoyi/ams/config/mapper/FlowConfigHeaderMapper.java

@@ -109,4 +109,11 @@ public interface FlowConfigHeaderMapper
      * @return
      */
     List<FlowConfigLotattVO> selectLotattDetails(Long id);
+
+    /**
+     * 查询流程关联的流程
+     * @param id
+     * @return
+     */
+    List<FlowConfigHeader> selectFlowConfigHeaderRel(Long id);
 }

+ 7 - 0
warewms-ams/src/main/java/com/ruoyi/ams/config/service/IFlowConfigHeaderService.java

@@ -86,4 +86,11 @@ public interface IFlowConfigHeaderService
      * @return
      */
     List<FlowConfigLotattVO> selectLotattDetails(Long id);
+
+    /**
+     * 根据排序查询流程
+     * @param id
+     * @return
+     */
+    List<FlowConfigHeader> sortFlowConfigHeader(Long id);
 }

+ 48 - 8
warewms-ams/src/main/java/com/ruoyi/ams/config/service/impl/FlowConfigHeaderServiceImpl.java

@@ -1,8 +1,6 @@
 package com.ruoyi.ams.config.service.impl;
 
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 import com.ruoyi.ams.config.domain.FlowConfigEvent;
 import com.ruoyi.ams.config.domain.form.FlowConfigForm;
@@ -16,8 +14,6 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-
 import com.ruoyi.common.utils.StringUtils;
 import org.springframework.transaction.annotation.Transactional;
 import com.ruoyi.ams.config.domain.FlowConfigDetails;
@@ -153,14 +149,18 @@ public class FlowConfigHeaderServiceImpl implements IFlowConfigHeaderService {
         flowConfigHeader.setUpdateTime(new Date());
 
         if (!StringUtils.isEmpty(flowConfigForm.getRelFlow())) {
-            FlowConfigHeaderVO headerVO = this.selectFlowConfigHeaderById(flowConfigForm.getId());
+            FlowConfigHeaderVO headerVO = this.selectFlowConfigHeaderById(Long.parseLong(flowConfigForm.getRelFlow()));
             if (StringUtils.isEmpty(headerVO.getRootFlow())) {
-                flowConfigHeader.setRootFlow(headerVO.getId().toString());
+                flowConfigHeader.setRelFlow("");
+                flowConfigHeader.setRootFlow(flowConfigHeader.getId().toString());
+
                 FlowConfigHeader rootFlowHeader = new FlowConfigHeader();
-                rootFlowHeader.setRootFlow(headerVO.getId().toString());
+                rootFlowHeader.setRelFlow(flowConfigHeader.getId().toString());
+                rootFlowHeader.setRootFlow(flowConfigHeader.getId().toString());
                 rootFlowHeader.setId(headerVO.getId());
                 flowConfigHeaderMapper.updateFlowConfigHeader(rootFlowHeader);
             } else {
+                flowConfigHeader.setRelFlow(headerVO.getId().toString());
                 flowConfigHeader.setRootFlow(headerVO.getRootFlow());
             }
         }
@@ -314,4 +314,44 @@ public class FlowConfigHeaderServiceImpl implements IFlowConfigHeaderService {
         }
         return flowConfigLotattVOList;
     }
+
+    @Override
+    public List<FlowConfigHeader> sortFlowConfigHeader(Long id) {
+        FlowConfigHeaderVO query = flowConfigHeaderMapper.selectFlowConfigHeaderById(id);
+        if (!StringUtils.isEmpty(query.getRootFlow())) {
+            List<FlowConfigHeader> list = flowConfigHeaderMapper.selectFlowConfigHeaderRel(Long.parseLong(query.getRootFlow()));
+            //查询出父节点L
+            Long rootId = 0L;
+            List<FlowConfigHeader> sortList = new ArrayList<>();
+            for (FlowConfigHeader vo : list) {
+                if (StringUtils.isEmpty(vo.getRelFlow()) && query.getRootFlow().equals(vo.getRootFlow())) {
+                    rootId = vo.getId();
+                    break;
+                }
+            }
+            return this.sortFlow(list, sortList, rootId);
+        } else {
+            return new ArrayList<>();
+        }
+    }
+
+    private List<FlowConfigHeader> sortFlow(List<FlowConfigHeader> list, List<FlowConfigHeader> sortList, Long rootId) {
+        if (rootId == null) {
+            return sortList;
+        }
+        if (list == null || list.size() == 0) {
+            return sortList;
+        }
+        Iterator<FlowConfigHeader> it = list.iterator();
+        while (it.hasNext()) {
+            FlowConfigHeader vo = it.next();
+            if (vo.getId().longValue() == rootId.longValue()) {
+                sortList.add(vo);
+                it.remove();
+            } else {
+                return this.sortFlow(list, sortList, vo.getId());
+            }
+        }
+        return sortList;
+    }
 }

+ 5 - 0
warewms-ams/src/main/resources/mapper/ams/FlowConfigHeaderMapper.xml

@@ -259,4 +259,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         left join lotatt_config l on d.lotatt_id = l.lotatt_id
         where d.header_id = #{id} and d.lotatt_flag &lt;&gt; 'Hidden'
     </select>
+
+    <select id="selectFlowConfigHeaderRel" parameterType="Long" resultMap="FlowConfigHeaderResult">
+        <include refid="selectFlowConfigHeaderVo"/>
+        where root_flow = #{headerId}
+    </select>
 </mapper>