Forráskód Böngészése

盘点定时任务 和 盘点任务执行

oyq28 1 éve
szülő
commit
7e2eb9df49

+ 1 - 0
src/main/java/com/imcs/admin/business/constants/Status.java

@@ -10,6 +10,7 @@ public enum Status {
     OUT(1,"出库"),
     OUT(1,"出库"),
     IN(2,"入库"),
     IN(2,"入库"),
     MOVE(3,"移库"),
     MOVE(3,"移库"),
+    PLAN(4,"盘库"),
 
 
 
 
     PALLET_STOREHOUSE(1, "托盘立库"),
     PALLET_STOREHOUSE(1, "托盘立库"),

+ 2 - 2
src/main/java/com/imcs/admin/business/controller/WPInventoryCountPalletController.java

@@ -58,8 +58,8 @@ public class WPInventoryCountPalletController {
      * @return 新增结果
      * @return 新增结果
      */
      */
     @PostMapping
     @PostMapping
-    public ResponseEntity<WPInventoryCountPallet> add(WPInventoryCountPallet wPInventoryCountPallet) {
-        return ResponseEntity.ok(this.wPInventoryCountPalletService.insert(wPInventoryCountPallet));
+    public Result add(@RequestBody WPInventoryCountPallet wPInventoryCountPallet) {
+        return Result.success(this.wPInventoryCountPalletService.insert(wPInventoryCountPallet));
     }
     }
 
 
     /**
     /**

+ 79 - 0
src/main/java/com/imcs/admin/business/job/ScheduledPlan.java

@@ -0,0 +1,79 @@
+package com.imcs.admin.business.job;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.imcs.admin.business.constants.Status;
+import com.imcs.admin.business.service.impl.BaseServiceImpl;
+import com.imcs.admin.entity.WPInventoryCountPlan;
+import com.imcs.admin.entity.WPInventoryCountTask;
+import com.imcs.admin.entity.WWarehouseManagement;
+import com.imcs.admin.util.DateUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 盘点计划 定时调度
+ */
+@Slf4j
+@Component
+public class ScheduledPlan extends BaseServiceImpl {
+
+
+
+    /**
+     * 出入库任务定时调度
+     * @throws Exception
+     */
+    //@Scheduled(cron = "0/10 * 1 * * *")
+    public void startPlan() throws Exception{
+        LambdaQueryWrapper<WPInventoryCountPlan> wrapper = Wrappers.lambdaQuery(WPInventoryCountPlan.class).eq(WPInventoryCountPlan::getStatus, 1);
+        List<WPInventoryCountPlan> wpInventoryCountPlans = wPInventoryCountPlanDao.selectList(wrapper);
+
+        wpInventoryCountPlans.stream().forEach(vo->{
+            if(vo.getPlanStrategy().intValue() == 7){
+                String dayOfWeek = DateUtils.getDayOfWeek(vo.getPlanTime());
+                String nowOfWeek = DateUtils.getDayOfWeek(new Date());
+                if(StringUtils.equals(dayOfWeek,nowOfWeek)){
+                    createTask(vo.getId());
+                }
+            }else if(vo.getPlanStrategy().intValue() == 30){
+                Boolean dateInCurrentMonth = DateUtils.isDateInCurrentMonth(vo.getPlanTime());
+                int i = DateUtils.nowDay(new Date());
+                int i1 = DateUtils.nowDay(vo.getPlanTime());
+                if(dateInCurrentMonth ){
+                    if(i==i1){
+                        createTask(vo.getId());
+                    }
+                }else{
+                    Boolean lastDayOfMonth = DateUtils.isLastDayOfMonth(new Date());
+                    if(lastDayOfMonth){
+                        createTask(vo.getId());
+                    }
+                }
+            }else if(vo.getPlanStrategy().intValue() == 365){
+                String monthAndDay = DateUtils.getMonthAndDay(vo.getPlanTime());
+                String nowMonthAndDay = DateUtils.getMonthAndDay(new Date());
+                if(StringUtils.equals(monthAndDay,nowMonthAndDay)){
+                    createTask(vo.getId());
+                }
+            }
+
+
+        });
+    }
+
+    public  void createTask(Long id){
+        WPInventoryCountTask wpInventoryCountTask=new WPInventoryCountTask();
+        wpInventoryCountTask.setTaskCode(generateSerial.generateSerialNumber("planTaskCode"));
+        wpInventoryCountTask.setStatus(0);
+        wpInventoryCountTask.setWPInventoryCountPlanId(id);
+        wpInventoryCountTask.setCreatedAt(new Date());
+        wpInventoryCountTask.setCreatedBy(0l);
+        this.wPInventoryCountTaskDao.insert(wpInventoryCountTask);
+    }
+
+}

+ 9 - 0
src/main/java/com/imcs/admin/business/job/ScheduledTask.java

@@ -28,12 +28,20 @@ import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Objects;
 import java.util.Objects;
 
 
+/**
+ * 出入库任务 定时调度
+ */
 @Slf4j
 @Slf4j
 @Component
 @Component
 public class ScheduledTask extends BaseServiceImpl {
 public class ScheduledTask extends BaseServiceImpl {
 
 
 
 
     public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
     public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
+
+    /**
+     * 出入库任务定时调度
+     * @throws Exception
+     */
     //@Scheduled(cron = "*/10 * * * * *")
     //@Scheduled(cron = "*/10 * * * * *")
     public void startTask() throws Exception{
     public void startTask() throws Exception{
         //查出task表id最小的一条status= 0 1 的数据
         //查出task表id最小的一条status= 0 1 的数据
@@ -99,4 +107,5 @@ public class ScheduledTask extends BaseServiceImpl {
         wApiCallRecords.setCreatedAt(new Date());
         wApiCallRecords.setCreatedAt(new Date());
         wApiCallRecordsDao.insert(wApiCallRecords);
         wApiCallRecordsDao.insert(wApiCallRecords);
     }
     }
+
 }
 }

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

@@ -78,6 +78,8 @@ public class BaseServiceImpl {
 
 
     @Autowired
     @Autowired
     public WPInventoryCountPalletDao wPInventoryCountPalletDao;
     public WPInventoryCountPalletDao wPInventoryCountPalletDao;
+    @Autowired
+    public WPInventoryCountPalletDetailDao wpInventoryCountPalletDetailDao;
 
 
     @Autowired
     @Autowired
     public WPInventoryCountPlanDao wPInventoryCountPlanDao;
     public WPInventoryCountPlanDao wPInventoryCountPlanDao;
@@ -195,6 +197,14 @@ public class BaseServiceImpl {
 
 
     }
     }
 
 
+    /**
+     *
+     * @param endPosition 目标库位
+     * @param subList 子任务集合
+     * @param trTaskId 主任务ID
+     * @param childTaskType 子任务类型
+     * @return
+     */
     public List<WInventoryTransactionChildTask> createSubTask(String endPosition,List<WInventoryTransactionChildTask> subList,Long trTaskId,int childTaskType) {
     public List<WInventoryTransactionChildTask> createSubTask(String endPosition,List<WInventoryTransactionChildTask> subList,Long trTaskId,int childTaskType) {
         //获取endPosition 需要移库的所有库位,获得的顺序为从内侧到外侧(先移动最外侧库位托盘)
         //获取endPosition 需要移库的所有库位,获得的顺序为从内侧到外侧(先移动最外侧库位托盘)
         List<WInventoryManagement> wStorageLocationManagements = checkStorageRelocation(endPosition);
         List<WInventoryManagement> wStorageLocationManagements = checkStorageRelocation(endPosition);

+ 107 - 18
src/main/java/com/imcs/admin/business/service/impl/WPInventoryCountPalletServiceImpl.java

@@ -1,25 +1,26 @@
 package com.imcs.admin.business.service.impl;
 package com.imcs.admin.business.service.impl;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.imcs.admin.business.constants.Status;
 import com.imcs.admin.business.strategy.*;
 import com.imcs.admin.business.strategy.*;
-import com.imcs.admin.entity.WInventoryManagement;
-import com.imcs.admin.entity.WPInventoryCountPallet;
+import com.imcs.admin.common.Result;
+import com.imcs.admin.entity.*;
 import com.imcs.admin.business.dao.WPInventoryCountPalletDao;
 import com.imcs.admin.business.dao.WPInventoryCountPalletDao;
 import com.imcs.admin.business.service.WPInventoryCountPalletService;
 import com.imcs.admin.business.service.WPInventoryCountPalletService;
-import com.imcs.admin.entity.WPInventoryCountPlan;
-import com.imcs.admin.entity.WPInventoryCountTask;
+import com.imcs.admin.entity.assemble.PolicyInputResult;
+import com.imcs.admin.entity.query.PolicyInputQuery;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.PageRequest;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
 
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 /**
 /**
  * 盘点托盘明细(WPInventoryCountPallet)表服务实现类
  * 盘点托盘明细(WPInventoryCountPallet)表服务实现类
@@ -78,9 +79,87 @@ public class WPInventoryCountPalletServiceImpl extends BaseServiceImpl implement
      * @param wPInventoryCountPallet 实例对象
      * @param wPInventoryCountPallet 实例对象
      * @return 实例对象
      * @return 实例对象
      */
      */
+    @Transactional
     @Override
     @Override
     public WPInventoryCountPallet insert(WPInventoryCountPallet wPInventoryCountPallet) {
     public WPInventoryCountPallet insert(WPInventoryCountPallet wPInventoryCountPallet) {
+        wPInventoryCountPallet.setWPInventoryCountTaskId(wPInventoryCountPallet.getTaskId());
         this.wPInventoryCountPalletDao.insert(wPInventoryCountPallet);
         this.wPInventoryCountPalletDao.insert(wPInventoryCountPallet);
+        wPInventoryCountPallet.getDetailList().forEach(vo->{
+            WInventoryManagementDetail wInventoryManagementDetail=new WInventoryManagementDetail();
+            BeanUtils.copyProperties(vo,wInventoryManagementDetail);
+            wInventoryManagementDetail.setAmount(vo.getRealAmount());
+            wInventoryManagementDetailDao.updateById(wInventoryManagementDetail);
+            vo.setId(null);
+            vo.setWPInventoryCountPalletId(wPInventoryCountPallet.getId());
+            wpInventoryCountPalletDetailDao.insert(vo);
+            // TODO 更新库存
+
+
+
+        });
+
+        //这个状态最适合的位置应该是在 wcs入库完成后去更改任务状态
+        /*WPInventoryCountTask wpInventoryCountTask=new WPInventoryCountTask();
+        wpInventoryCountTask.setId(wPInventoryCountPallet.getTaskId());
+        if(wPInventoryCountPallet.getIsFinsh()){
+            wpInventoryCountTask.setStatus(2);
+
+        }else{
+            wpInventoryCountTask.setStatus(1);
+        }
+        //更新盘库任务状态
+        wPInventoryCountTaskDao.update(wpInventoryCountTask);*/
+
+        //入库任务
+        //获取入库口 对应的 大小托盘
+        Dic entryPointPalletType = dicDao.getListByLabel("entryPointPalletType", wPInventoryCountPallet.getEntryPoint());
+        PolicyInputQuery policyQuery = createPolicyQuery(Integer.valueOf(entryPointPalletType.getValue()),null);
+        Result importPolicy = importOrExportPolicyService.findImportPolicy(policyQuery);
+        if(importPolicy.getData() == null){
+            throw new RuntimeException("无可用库位,请联系管理员!");
+        }
+        PolicyInputResult policyResult = (PolicyInputResult)importPolicy.getData();
+        String locationCode = policyResult.getLocationCode();
+
+
+        WInventoryTransactionTask wInventoryTransactionTask=new WInventoryTransactionTask();
+        wInventoryTransactionTask.setTaskCode(generateSerial.generateSerialNumber("inTask"));
+        wInventoryTransactionTask.setStartPosition(wPInventoryCountPallet.getEntryPoint());
+        wInventoryTransactionTask.setEndPosition(locationCode);
+        wInventoryTransactionTask.setVectorCode(wPInventoryCountPallet.getPalletCode());
+        wInventoryTransactionTask.setStatus(0);
+        wInventoryTransactionTask.setTaskType(4);
+        wInventoryTransactionTask.setWPInventoryCountTaskId(wPInventoryCountPallet.getTaskId());
+        wInventoryTransactionTask.setCreatedAt(new Date());
+        wInventoryTransactionTask.setCreatedBy(getUserId());
+        taskDao.insert(wInventoryTransactionTask);
+        Long id = wInventoryTransactionTask.getId();
+
+        //入库任务详情
+        wPInventoryCountPallet.getDetailList().forEach(vo->{
+            WInventoryTransactionTaskDetail taskDetail=new WInventoryTransactionTaskDetail();
+
+           /* taskDetail.setBatchNo(vo.getBatchNo());
+            taskDetail.setUnit(vo.getUnit());
+            taskDetail.setExpirationDate(vo.getExpirationDate());
+            taskDetail.setProductionDate(vo.getProductionDate());*/
+            taskDetail.setMaterialCode(vo.getMaterialCode());
+            taskDetail.setInventoryTransactionTaskId(id);
+            taskDetail.setStatus(0);
+            taskDetail.setCreatedAt(new Date());
+            taskDetail.setCreatedBy(getUserId());
+            taskDetail.setAmount(vo.getRealAmount());
+            taskDetailDao.insert(taskDetail);
+        });
+        List<WInventoryTransactionChildTask> subList=new ArrayList<>();
+        createSubTask(locationCode, subList, id, Status.IN.getCode());
+        //保存移库子任务
+        saveSubTask(subList,null);
+
+        WInventoryTransactionChildTask wInventoryTransactionChildTask=new WInventoryTransactionChildTask(
+                id,generateSerial.generateSerialNumber("childTask"),wInventoryTransactionTask.getStartPosition(),locationCode,wInventoryTransactionTask.getVectorCode(),0,wInventoryTransactionTask.getTaskType(),new Date(),getUserId(),null);
+        childTaskDao.insert(wInventoryTransactionChildTask);
+
         return wPInventoryCountPallet;
         return wPInventoryCountPallet;
     }
     }
 
 
@@ -109,18 +188,28 @@ public class WPInventoryCountPalletServiceImpl extends BaseServiceImpl implement
 
 
     @Override
     @Override
     public List<WInventoryManagement> getPalletList(Long id) {
     public List<WInventoryManagement> getPalletList(Long id) {
-        List<WInventoryManagement> wInventoryManagementList = wPInventoryCountPalletDao.selectInventoryManagementList(id);
-        if(CollectionUtils.isEmpty(wInventoryManagementList)){
-            WPInventoryCountTask wpInventoryCountTask = wPInventoryCountTaskDao.queryById(id);
-            WPInventoryCountPlan wpInventoryCountPlan = wPInventoryCountPlanDao.queryById(wpInventoryCountTask.getWPInventoryCountPlanId());
-            List<WInventoryManagement> execute = strategyMap.get(wpInventoryCountPlan.getPlanType()).execute(wpInventoryCountPlan);
-            return execute;
-        }else{
-            wInventoryManagementList.forEach(vo->{
-                vo.setDetailList(wPInventoryCountPalletDao.selectDetailList(vo.getId()));
-            });
-        }
+        List<WInventoryManagement> wInventoryManagementList=new ArrayList<>();
+        wInventoryManagementList = wPInventoryCountPalletDao.selectInventoryManagementList(id);
+        wInventoryManagementList.forEach(vo->{
+            vo.setDetailList(wPInventoryCountPalletDao.selectDetailList(vo.getId()));
+        });
+
+        WPInventoryCountTask wpInventoryCountTask = wPInventoryCountTaskDao.queryById(id);
+        WPInventoryCountPlan wpInventoryCountPlan = wPInventoryCountPlanDao.queryById(wpInventoryCountTask.getWPInventoryCountPlanId());
+        List<WInventoryManagement> execute = strategyMap.get(wpInventoryCountPlan.getPlanType()).execute(wpInventoryCountPlan);
 
 
+
+        Iterator<WInventoryManagement> iterator = execute.iterator();
+        while (iterator.hasNext()) {
+            WInventoryManagement execItem = iterator.next();
+            for (WInventoryManagement wItem : wInventoryManagementList) {
+                if (wItem.getPalletCode().equals(execItem.getPalletCode())) {
+                    iterator.remove();
+                    break;
+                }
+            }
+        }
+        wInventoryManagementList.addAll(execute);
         return wInventoryManagementList;
         return wInventoryManagementList;
     }
     }
 }
 }

+ 1 - 1
src/main/java/com/imcs/admin/entity/WInventoryTransactionChildTask.java

@@ -53,7 +53,7 @@ public class WInventoryTransactionChildTask implements Serializable {
      */
      */
     private Integer status;
     private Integer status;
 /**
 /**
-     * 任务类型(1 出库 2 入库  3 移库)
+     * 任务类型(1 出库 2 入库  3 移库 )
      */
      */
     private Integer childTaskType;
     private Integer childTaskType;
 /**
 /**

+ 2 - 1
src/main/java/com/imcs/admin/entity/WInventoryTransactionTask.java

@@ -55,7 +55,7 @@ public class WInventoryTransactionTask extends PageSize implements Serializable
      */
      */
     private Integer status;
     private Integer status;
 /**
 /**
-     * 任务类型(1 出库 2 入库  3 移库)
+     * 任务类型(1 出库 2 入库  3 移库 4 盘库)
      */
      */
     private Integer taskType;
     private Integer taskType;
 /**
 /**
@@ -86,6 +86,7 @@ public class WInventoryTransactionTask extends PageSize implements Serializable
      * 修改人
      * 修改人
      */
      */
     private Long updatedBy;
     private Long updatedBy;
+    private Long wPInventoryCountTaskId;
 
 
     @TableField(exist = false)
     @TableField(exist = false)
     private List<WInventoryTransactionTaskDetail> detailList;
     private List<WInventoryTransactionTaskDetail> detailList;

+ 10 - 0
src/main/java/com/imcs/admin/entity/WPInventoryCountPallet.java

@@ -2,8 +2,10 @@ package com.imcs.admin.entity;
 
 
 import java.util.Date;
 import java.util.Date;
 import java.io.Serializable;
 import java.io.Serializable;
+import java.util.List;
 
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.Data;
@@ -53,6 +55,14 @@ public class WPInventoryCountPallet implements Serializable {
 
 
     private Integer status;
     private Integer status;
 
 
+    @TableField(exist = false)
+    private List<WPInventoryCountPalletDetail> detailList;
+    @TableField(exist = false)
+    private String entryPoint;
+    @TableField(exist = false)
+    private Long taskId;
+    @TableField(exist = false)
+    private Boolean isFinsh;
 
 
 }
 }
 
 

+ 2 - 0
src/main/java/com/imcs/admin/entity/WPInventoryCountPlan.java

@@ -6,6 +6,7 @@ import java.io.Serializable;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.Data;
 /**
 /**
  * 盘点计划表(WPInventoryCountPlan)实体类
  * 盘点计划表(WPInventoryCountPlan)实体类
@@ -36,6 +37,7 @@ public class WPInventoryCountPlan extends PageSize implements Serializable {
      */
      */
     private Integer planStrategy;
     private Integer planStrategy;
 
 
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date planTime;
     private Date planTime;
 /**
 /**
      * 盘点类型输入的数据
      * 盘点类型输入的数据

+ 83 - 3
src/main/java/com/imcs/admin/util/DateUtils.java

@@ -1,9 +1,7 @@
 package com.imcs.admin.util;
 package com.imcs.admin.util;
 
 
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.YearMonth;
+import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.*;
 
 
@@ -77,6 +75,88 @@ public class DateUtils {
         return previousMonths;
         return previousMonths;
     }
     }
 
 
+    public static String getDayOfWeek(Date date) {
+        LocalDate localDate = date.toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDate();
+        DayOfWeek dayOfWeek = localDate.getDayOfWeek();
+        return dayOfWeek.toString();
+    }
+    /**
+     * 检查给定日期在当前月份是否存在。
+     *
+     * @param date 要检查的日期对象
+     * @return 如果日期存在于当前月份则返回true,否则返回false
+     */
+    public static boolean isDateInCurrentMonth(Date date) {
+        // 将 Date 转换为 LocalDate
+        LocalDate localDate = date.toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDate();
+
+        // 获取当前日期和当前月份的 YearMonth 对象
+        LocalDate today = LocalDate.now();
+        YearMonth currentYearMonth = YearMonth.now();
+
+        // 获取当前月份的最后一天
+        int lastDayOfMonth = currentYearMonth.lengthOfMonth();
+
+        // 检查给定日期的天是否在当前月份的有效天数范围内
+        return localDate.getMonth() == today.getMonth() &&
+                localDate.getDayOfMonth() <= lastDayOfMonth;
+    }
+
+    public static int nowDay(Date date) {
+        // 将 Date 转换为 LocalDate
+        LocalDate localDate = date.toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDate();
+
+        return localDate.getDayOfMonth();
+    }
+
+    /**
+     * 判断给定日期是否是本月的最后一天。
+     *
+     * @param date 要检查的日期对象
+     * @return 如果日期是本月最后一天则返回true,否则返回false
+     */
+    public static boolean isLastDayOfMonth(Date date) {
+        // 将 Date 转换为 LocalDate
+        LocalDate localDate = date.toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDate();
+
+        // 获取当前月份的 YearMonth 对象
+        YearMonth yearMonth = YearMonth.from(localDate);
+
+        // 获取当前月份的最后一天
+        int lastDayOfMonth = yearMonth.lengthOfMonth();
+
+        // 检查给定日期是否是本月的最后一天
+        return localDate.getDayOfMonth() == lastDayOfMonth;
+    }
+
+
+    /**
+     * 返回给定日期的月份和日期。
+     *
+     * @param date 要提取的日期对象
+     * @return 返回字符串格式的月份和日期,例如 "05-15"
+     */
+    public static String getMonthAndDay(Date date) {
+        // 将 Date 转换为 LocalDate
+        LocalDate localDate = date.toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDate();
+
+        // 提取月份和日期
+        int month = localDate.getMonthValue();
+        int day = localDate.getDayOfMonth();
+
+        // 格式化为 MM-dd 格式的字符串
+        return String.format("%02d-%02d", month, day);
+    }
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {
         System.out.println(getLastYearMonths());
         System.out.println(getLastYearMonths());

+ 2 - 2
src/main/resources/mapper/WPInventoryCountPalletDao.xml

@@ -83,8 +83,8 @@
 
 
     <!--新增所有列-->
     <!--新增所有列-->
     <insert id="insert" keyProperty="id" useGeneratedKeys="true">
     <insert id="insert" keyProperty="id" useGeneratedKeys="true">
-        insert into w_p_inventory_count_pallet(w_p_inventory_count_task_idpallet_codecreated_atcreated_byupdated_atupdated_by)
-        values (#{wPInventoryCountTaskId}#{palletCode}#{createdAt}#{createdBy}#{updatedAt}#{updatedBy})
+        insert into w_p_inventory_count_pallet(w_p_inventory_count_task_id,pallet_code,created_at,created_by,updated_at,updated_by,status,storage_location_code)
+        values (#{wPInventoryCountTaskId},#{palletCode},#{createdAt},#{createdBy},#{updatedAt},#{updatedBy},#{status},#{storageLocationCode})
     </insert>
     </insert>
 
 
     <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
     <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">

+ 2 - 2
src/main/resources/mapper/WPInventoryCountPalletDetailDao.xml

@@ -110,8 +110,8 @@
 
 
     <!--新增所有列-->
     <!--新增所有列-->
     <insert id="insert" keyProperty="id" useGeneratedKeys="true">
     <insert id="insert" keyProperty="id" useGeneratedKeys="true">
-        insert into w_p_inventory_count_pallet_detail(w_p_inventory_count_pallet_idmaterial_codestore_amountreal_amountprofit_loss_typeprofit_loss_quantitycreated_atcreated_byupdated_atupdated_by)
-        values (#{wPInventoryCountPalletId}#{materialCode}#{storeAmount}#{realAmount}#{profitLossType}#{profitLossQuantity}#{createdAt}#{createdBy}#{updatedAt}#{updatedBy})
+        insert into w_p_inventory_count_pallet_detail(w_p_inventory_count_pallet_id,material_code,store_amount,real_amount,profit_loss_type,profit_loss_quantity,created_at,created_by,updated_at,updated_by)
+        values (#{wPInventoryCountPalletId},#{materialCode},#{storeAmount},#{realAmount},#{profitLossType},#{profitLossQuantity},#{createdAt},#{createdBy},#{updatedAt},#{updatedBy})
     </insert>
     </insert>
 
 
     <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
     <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">

+ 96 - 20
src/main/resources/static/wms/plan/taskIndex.html

@@ -44,7 +44,7 @@
                     <template #default="scope">
                     <template #default="scope">
                         <!-- 这里放置操作按钮 -->
                         <!-- 这里放置操作按钮 -->
                         <div class="button-group">
                         <div class="button-group">
-                            <el-button type="primary" @click="toDo(scope.row)" icon="el-icon-check"  circle>执行</el-button>
+                            <el-button type="primary" @click="toDo(scope.row.id)" icon="el-icon-check"  circle>执行</el-button>
                         </div>
                         </div>
                     </template>
                     </template>
                 </el-table-column>
                 </el-table-column>
@@ -78,12 +78,10 @@
                         <el-input type="text" v-model="binCode" placeholder="料箱编码" style="width: 100px;" :disabled="true"></el-input>
                         <el-input type="text" v-model="binCode" placeholder="料箱编码" style="width: 100px;" :disabled="true"></el-input>
                     </el-form-item>
                     </el-form-item>
                     <el-form-item>
                     <el-form-item>
-                        <el-input type="text" v-model="inputCode" placeholder="扫码顺序 托盘 >  物料编码" @change="handleScan()" style="width: 300px" ></el-input>
+                        <el-input type="text" v-model="inputCode" placeholder="扫码 托盘编码" @change="handleScan()" style="width: 300px" ></el-input>
                     </el-form-item>
                     </el-form-item>
                     </el-form-item>
                     </el-form-item>
-                    <el-form-item>
-                        <el-button type="primary" @click="outSubmit()" :disabled="isViewMode">托盘回库</el-button>
-                    </el-form-item>
+
                 </el-form>
                 </el-form>
                     <div class="table-container" style="margin-bottom: 80px;margin-top: 20px;">
                     <div class="table-container" style="margin-bottom: 80px;margin-top: 20px;">
                         <div class="table-wrapper">
                         <div class="table-wrapper">
@@ -106,7 +104,7 @@
                                     <template #default="scope">
                                     <template #default="scope">
                                         <!-- 这里放置操作按钮 -->
                                         <!-- 这里放置操作按钮 -->
                                         <div class="button-group">
                                         <div class="button-group">
-                                            <el-button type="primary" icon="el-icon-check"  >出库</el-button>
+                                            <el-button type="primary" icon="el-icon-check"  :disabled="scope.row.status===2">出库</el-button>
                                         </div>
                                         </div>
                                     </template>
                                     </template>
                                 </el-table-column>
                                 </el-table-column>
@@ -124,7 +122,7 @@
                                 <el-table-column prop="storeAmount" label="库存数量" :show-overflow-tooltip="true"></el-table-column>
                                 <el-table-column prop="storeAmount" label="库存数量" :show-overflow-tooltip="true"></el-table-column>
                                 <el-table-column prop="realAmount" label="盘点数量" :show-overflow-tooltip="true">
                                 <el-table-column prop="realAmount" label="盘点数量" :show-overflow-tooltip="true">
                                     <template slot-scope="scope">
                                     <template slot-scope="scope">
-                                        <el-input v-model="scope.row.realAmount" type="number" @input="handleInput(scope.row)"></el-input>
+                                        <el-input v-model="scope.row.realAmount" type="number" @input="handleInput(scope.row)" :disabled="inputDisabled"></el-input>
                                     </template>
                                     </template>
                                 </el-table-column>
                                 </el-table-column>
 
 
@@ -141,6 +139,7 @@
 
 
                 <span slot="footer" class="dialog-footer">
                 <span slot="footer" class="dialog-footer">
                     <el-button @click="handleCloseTask()">取 消</el-button>
                     <el-button @click="handleCloseTask()">取 消</el-button>
+                    <el-button type="primary" @click="outSubmit()" :disabled="isViewMode">托盘回库</el-button>
                   </span>
                   </span>
             </el-dialog>
             </el-dialog>
 
 
@@ -184,6 +183,7 @@
                 name: '',
                 name: '',
                 entryPoint: '',
                 entryPoint: '',
                 binCode: '',
                 binCode: '',
+                wPInventoryCountTaskId: '',
                 createDate: '',
                 createDate: '',
                 currentPage: 1,
                 currentPage: 1,
                 total: 0,
                 total: 0,
@@ -197,6 +197,7 @@
                 palletCode:'',
                 palletCode:'',
                 dialogVisible:false,
                 dialogVisible:false,
                 dialogVisibleTask:false,
                 dialogVisibleTask:false,
+                inputDisabled:false,
                 plan: this.initOrder(),
                 plan: this.initOrder(),
                 rules: {
                 rules: {
                     planName: [
                     planName: [
@@ -269,6 +270,17 @@
                         // 处理错误
                         // 处理错误
                     });
                     });
 
 
+                axios.post('/Dic/list', {
+                    'dicCode': 'entryPoint'
+                })
+                    .then(response => {
+                        console.log(response)
+                        this.options = response.data;
+                    })
+                    .catch(error => {
+                        // 处理错误
+                    });
+
             },
             },
             queryClick() {
             queryClick() {
                 this.loading = true;
                 this.loading = true;
@@ -343,15 +355,16 @@
                 return row.realAmount - row.storeAmount;
                 return row.realAmount - row.storeAmount;
             },handleSelectionChange(selection) {
             },handleSelectionChange(selection) {
                 this.selection = selection
                 this.selection = selection
-            },toDo(row){
+            },toDo(id){
                 this.dialogVisibleTask=true;
                 this.dialogVisibleTask=true;
-
-                axios.get('/wPInventoryCountPallet/getPalletList/'+row.id, {
+                this.wPInventoryCountTaskId=id;
+                axios.get('/wPInventoryCountPallet/getPalletList/'+id, {
                 })
                 })
                     .then(response => {
                     .then(response => {
                         console.log(response)
                         console.log(response)
                         if(response.data.success){
                         if(response.data.success){
-                            this.detailListTask=response.data.data
+                            this.detailListTask=response.data.data;
+                            this.isViewMode=true;
                         }
                         }
                     })
                     })
                     .catch(error => {
                     .catch(error => {
@@ -363,6 +376,8 @@
                 this.detailListPallet=[];
                 this.detailListPallet=[];
                 this.inputCode='';
                 this.inputCode='';
                 this.palletCode='';
                 this.palletCode='';
+                this.detailList=[];
+                this.entryPoint='';
             },handleSelectChange(row){
             },handleSelectChange(row){
                 console.log(row)
                 console.log(row)
                 row.inventoryManagementList.forEach(item=>{
                 row.inventoryManagementList.forEach(item=>{
@@ -376,6 +391,9 @@
             rowClick(row, column, event){
             rowClick(row, column, event){
                 console.log(row)
                 console.log(row)
                 this.detailList=row.detailList;
                 this.detailList=row.detailList;
+                this.isViewMode=false;
+                this.selection=row;
+                this.inputDisabled=row.status===2;
             },
             },
             handleInput(row){
             handleInput(row){
                 console.log(row)
                 console.log(row)
@@ -384,7 +402,7 @@
                 row.profitLossQuantity=ag
                 row.profitLossQuantity=ag
                 if(ag > 0){
                 if(ag > 0){
                     row.profitLossType='盘盈';
                     row.profitLossType='盘盈';
-                }else if(ag = 0){
+                }else if(ag === 0){
                     row.profitLossType='正常';
                     row.profitLossType='正常';
                 }else{
                 }else{
                     row.profitLossType='盘亏';
                     row.profitLossType='盘亏';
@@ -393,7 +411,11 @@
 
 
             },handleScan(){
             },handleScan(){
                 console.log(this.inputCode)
                 console.log(this.inputCode)
-                axios.get('/order/verifyCode/'+this.inputCode, {
+                this.palletCode=this.inputCode;
+                this.inputCode='';
+
+
+                /*axios.get('/order/verifyCode/'+this.inputCode, {
                 })
                 })
                     .then(response => {
                     .then(response => {
                         const verify=response.data.data;
                         const verify=response.data.data;
@@ -480,20 +502,74 @@
                     })
                     })
                     .catch(error => {
                     .catch(error => {
                         // 处理错误
                         // 处理错误
-                    });
+                    });*/
 
 
 
 
-            },handleSelectionChange(selection) {
-                this.selection = selection
             },outSubmit(){
             },outSubmit(){
-                if (!this.selection.length) {
+
+                console.log(this.selection)
+                if(this.entryPoint===''){
+                    this.$message({
+                        message: '入库口不能为空',
+                        type: "error"
+                    })
+                    return
+                }
+                if(this.selection.palletCode != this.palletCode){
                     this.$message({
                     this.$message({
-                        message: '至少勾选一行数据',
+                        message: '选中托盘编码和扫描托盘编码不一致,请核对',
                         type: "error"
                         type: "error"
                     })
                     })
                     return
                     return
                 }
                 }
-                this.selection.forEach(item=>{
+                if(this.selection.status===2){
+                    this.$message({
+                        message: '选中托盘已盘库完成',
+                        type: "error"
+                    })
+                    return
+                }
+
+                this.detailList.forEach(item=>{
+                    if(item.realAmount === '' || item.realAmount <= 0){
+                        this.$message({
+                            message: '盘点数量不能为空或小于等于0',
+                            type: "error"
+                        })
+                        return
+                    }
+                })
+                // 过滤掉选中的任务
+                const remainingTasks = this.detailListTask.filter(task => !this.selection.includes(task));
+
+                // 检查剩余任务的 status 是否都等于 2
+                const allStatusTwo = remainingTasks.every(task => task.status === 2);
+
+                axios.post('/wPInventoryCountPallet', {
+                    'wPInventoryCountTaskId':this.wPInventoryCountTaskId,
+                    'taskId':this.wPInventoryCountTaskId,
+                    'entryPoint':this.entryPoint,
+                    'palletCode':this.selection.palletCode,
+                    'storageLocationCode':this.selection.storageLocationCode,
+                    'status':2,
+                    'detailList':this.detailList,
+                    'isFinsh':allStatusTwo
+                })
+                    .then(response => {
+                        if(response.data.success){
+                            this.$message({
+                                message: '操作成功',
+                                type: 'success'
+                            });
+                            this.toDo(this.wPInventoryCountTaskId);
+                        }
+
+                    })
+                    .catch(error => {
+                        // 处理错误
+                    });
+
+               /* this.selection.forEach(item=>{
                     if(item.amount === '' || item.amount <= 0){
                     if(item.amount === '' || item.amount <= 0){
                         this.$message({
                         this.$message({
                             message: '本次出库数量不能为空或小于等于0',
                             message: '本次出库数量不能为空或小于等于0',
@@ -533,7 +609,7 @@
                     })
                     })
                     .catch(error => {
                     .catch(error => {
                         // 处理错误
                         // 处理错误
-                    });
+                    });*/
 
 
             },savePlanTask(row){
             },savePlanTask(row){