瀏覽代碼

任务定时调度

wudingsheng 11 月之前
父節點
當前提交
512d6c9490

+ 6 - 1
src/main/java/com/imcs/admin/business/controller/WInventoryTransactionTaskController.java

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
 import com.imcs.admin.business.service.WInventoryTransactionTaskService;
 import com.imcs.admin.common.Result;
 import com.imcs.admin.entity.WInventoryTransactionTask;
+import com.imcs.admin.vo.RequestData;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.http.ResponseEntity;
@@ -84,7 +85,11 @@ public class WInventoryTransactionTaskController {
         return ResponseEntity.ok(this.wInventoryTransactionTaskService.deleteById(id));
     }
 
-
+    @PostMapping("callback")
+    public Result callback(RequestData requestData){
+        wInventoryTransactionTaskService.callback(requestData);
+        return Result.success();
+    }
 
 }
 

+ 7 - 0
src/main/java/com/imcs/admin/business/dao/WStorageLocationManagementDao.java

@@ -8,6 +8,7 @@ import com.imcs.admin.entity.assemble.WInventoryManagementGroup;
 import com.imcs.admin.entity.assemble.WStorageLocationGroup;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.security.core.parameters.P;
 
 import java.util.List;
 
@@ -21,6 +22,8 @@ public interface WStorageLocationManagementDao extends BaseMapper<WStorageLocati
 
     void updateByParentId(@Param("status") int status, @Param("parentId") Long parentId);
 
+    void updateStatusByParentId(@Param("status") int status, @Param("parentId") Long parentId);
+
     List<WStorageLocationManagement> getAllByLocationCode(List<WInventoryManagement> wInventoryManagements);
 
     void updateStatusById(@Param("status") int status, @Param("id") Long id);
@@ -30,4 +33,8 @@ public interface WStorageLocationManagementDao extends BaseMapper<WStorageLocati
     List<WStorageLocationManagement> getStorageLocationRatio();
 
     List<WStorageLocationGroup> getLibraryLocationUsage();
+
+    WStorageLocationManagement getStorageLocation(String point);
+
+    WStorageLocationManagement selectOtherStorage(@Param("storageLocationCode") String storageLocationCode, @Param("parentId") Long parentId);
 }

+ 3 - 0
src/main/java/com/imcs/admin/business/service/WInventoryTransactionTaskService.java

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
 import com.imcs.admin.common.Result;
 import com.imcs.admin.entity.WInventoryTransactionTask;
 import com.imcs.admin.entity.WInventoryTransactionTaskDetail;
+import com.imcs.admin.vo.RequestData;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 
@@ -65,4 +66,6 @@ public interface WInventoryTransactionTaskService {
     List<WInventoryTransactionTask> dailyTaskStatistics();
 
     List<WInventoryTransactionTaskDetail> findMaterialImportAndExportStatistics(Map map);
+
+    void callback(RequestData requestData);
 }

+ 25 - 0
src/main/java/com/imcs/admin/business/service/impl/BaseServiceImpl.java

@@ -300,4 +300,29 @@ public class BaseServiceImpl {
 
         return wWarehouseManagementVos;
     }
+
+
+    /**
+     * 出库修改大库位 小库位状态
+     * @param status
+     * @param locationCode
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void updateStorageStatusFree(int status,String locationCode){
+        LambdaQueryWrapper<WStorageLocationManagement> wrapper = Wrappers.lambdaQuery(WStorageLocationManagement.class).eq(WStorageLocationManagement::getLocationCode,locationCode);
+        WStorageLocationManagement wStorageLocationManagement = storageLocationDao.selectOne(wrapper);
+        //大库位 把大库位和所有小库位都设置为未使用
+        if(wStorageLocationManagement.getPalletType() == 1){
+            storageLocationDao.updateByLocationCode(status,locationCode);
+            storageLocationDao.updateByParentId(status,wStorageLocationManagement.getId());
+        }else if(wStorageLocationManagement.getPalletType() == 2){
+            //小库位  把大库位和小库位设置为未使用
+            storageLocationDao.updateByLocationCode(status,locationCode);
+
+            //根据另一个库位状态修改 大库位状态
+            WStorageLocationManagement otherStorage = storageLocationDao.selectOtherStorage(locationCode, wStorageLocationManagement.getParentId());
+            storageLocationDao.updateStatusById(otherStorage.getStorageLocationStatus(),otherStorage.getId());
+        }
+
+    }
 }

+ 60 - 0
src/main/java/com/imcs/admin/business/service/impl/WInventoryTransactionTaskServiceImpl.java

@@ -2,7 +2,9 @@ package com.imcs.admin.business.service.impl;
 
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.imcs.admin.business.constants.Status;
@@ -12,6 +14,9 @@ import com.imcs.admin.common.constants.Constants;
 import com.imcs.admin.entity.*;
 import com.imcs.admin.entity.assemble.PolicyInputResult;
 import com.imcs.admin.entity.query.PolicyInputQuery;
+import com.imcs.admin.vo.RequestData;
+import lombok.extern.log4j.Log4j;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -28,6 +33,7 @@ import java.util.stream.Collectors;
  * @since 2024-05-27 13:04:45
  */
 @Service("wInventoryTransactionTaskService")
+@Slf4j
 public class WInventoryTransactionTaskServiceImpl extends BaseServiceImpl implements WInventoryTransactionTaskService {
 
     /**
@@ -159,5 +165,59 @@ public class WInventoryTransactionTaskServiceImpl extends BaseServiceImpl implem
         return list;
     }
 
+    @Override
+    @Transactional
+    public void callback(RequestData requestData) {
+        LambdaQueryWrapper<WInventoryTransactionChildTask> wrapper= Wrappers.lambdaQuery(WInventoryTransactionChildTask.class).eq(WInventoryTransactionChildTask::getChildTaskCode,requestData.getTaskNodeId());
+        WInventoryTransactionChildTask wInventoryTransactionChildTask = childTaskDao.selectOne(wrapper);
+        String vectorCode = wInventoryTransactionChildTask.getVectorCode();
+        Integer childTaskType = wInventoryTransactionChildTask.getChildTaskType();
+        if("Get".equals(requestData.getGetOrSend())){
+            wInventoryTransactionChildTask.setGetResult(1);
+            //取完成 表示任务执行中
+            wInventoryTransactionChildTask.setStatus(1);
+        }else if("Send".equals(requestData.getGetOrSend())){
+            wInventoryTransactionChildTask.setSendResult(1);
+            //放完成 表示任务已完成
+            wInventoryTransactionChildTask.setStatus(2);
+
+            //出库
+            if(childTaskType == 1){
+
+                //释放大小库位
+                String startPosition = wInventoryTransactionChildTask.getStartPosition();
+                WStorageLocationManagement storageLocation = storageLocationDao.getStorageLocation(startPosition);
+                updateStorageStatusFree(Status.UNUSED.getCode(),storageLocation.getLocationCode());
+            }else if(childTaskType == 2){
+
+            }else if(childTaskType == 3){
+
+            }
+        }else{
+            log.error("取放类型不能为空!");
+            return;
+        }
+        //修改子任务状态和取 放动作状态
+        childTaskDao.updateById(wInventoryTransactionChildTask);
+
+        LambdaQueryWrapper<WInventoryTransactionChildTask> wr= Wrappers.lambdaQuery(WInventoryTransactionChildTask.class)
+                .eq(WInventoryTransactionChildTask::getWInventoryTransactionTaskId,wInventoryTransactionChildTask.getWInventoryTransactionTaskId())
+                .eq(WInventoryTransactionChildTask::getStatus,Status.COMPLETED.getCode());
+        Long taskCompleteCount = childTaskDao.selectCount(wr);
+
+        //修改主任务状态
+        WInventoryTransactionTask wInventoryTransactionTask=new WInventoryTransactionTask();
+        wInventoryTransactionTask.setId(wInventoryTransactionChildTask.getWInventoryTransactionTaskId());
+        if(taskCompleteCount == 0){
+            wInventoryTransactionTask.setStatus(Status.COMPLETED.getCode());
+
+
+        }else {
+            wInventoryTransactionTask.setStatus(Status.IN_PROGRESS_TASK.getCode());
+        }
+        taskDao.update(wInventoryTransactionTask);
+
+    }
+
 
 }

+ 2 - 1
src/main/java/com/imcs/admin/vo/RequestData.java

@@ -3,7 +3,6 @@ package com.imcs.admin.vo;
 import lombok.Data;
 
 @Data
-
 public class RequestData {
     private String ip;
     private String url;
@@ -11,4 +10,6 @@ public class RequestData {
     private String taskId;//任务编号
     private String taskNodeId;//子任务编号
     private LocationData locationData;
+    private String getOrSend;//取或者放
+    private String tagValue;//取放结果
 }

+ 14 - 0
src/main/resources/mapper/WStorageLocationDao.xml

@@ -74,4 +74,18 @@
             wslm.pallet_Type,
             wsm.id
     </select>
+
+    <select id="getStorageLocation" resultType="com.imcs.admin.entity.WStorageLocationManagement">
+        select * from w_storage_location_management where point=#{point}
+    </select>
+
+
+    <update id="updateStatusByParentId">
+        update w_storage_location_management set storage_location_status=#{status} where parent_id=#{parentId}
+        and not exists( select count(*) from w_storage_location_management where parent_id=#{parentId} and status in ());
+    </update>
+
+    <select id="selectOtherStorage" resultType="com.imcs.admin.entity.WStorageLocationManagement">
+        select * from w_storage_location_management where parent_id=#{parentId} and storage_location_code!={storageLocationCode}
+    </select>
 </mapper>