3 天以前 b852254d90e7d1955db31db154193ec8ee84d8b3
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/plan/MesWmStockTakingPlanServiceImpl.java
@@ -2,6 +2,7 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@@ -12,10 +13,12 @@
import cn.iocoder.yudao.module.mes.dal.mysql.wm.stocktaking.plan.MesWmStockTakingPlanMapper;
import cn.iocoder.yudao.module.mes.enums.wm.MesWmStockTakingTypeEnum;
import jakarta.annotation.Resource;
import org.quartz.CronExpression;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -26,7 +29,7 @@
/**
 * MES 盘点方案 Service 实现类
 *
 * @author 芋道源码
 * @author 超级管理员
 */
@Service
@Validated
@@ -122,6 +125,16 @@
        return stockTakingPlanMapper.selectPage(pageReqVO);
    }
    @Override
    public List<MesWmStockTakingPlanDO> getEnableAutoGeneratePlanList() {
        return stockTakingPlanMapper.selectEnableAutoGenerateList();
    }
    @Override
    public void updateStockTakingPlanLastGenerateTime(Long id, LocalDateTime time) {
        stockTakingPlanMapper.updateById(new MesWmStockTakingPlanDO().setId(id).setLastGenerateTime(time));
    }
    private void validatePlanCodeUnique(Long id, String code) {
        MesWmStockTakingPlanDO plan = stockTakingPlanMapper.selectByCode(code);
        if (plan == null) {
@@ -164,6 +177,16 @@
                throw exception(WM_STOCK_TAKING_PLAN_DYNAMIC_TIME_INVALID);
            }
        }
        // 校验定期自动生成配置:开启自动生成时 cron 必填且合法
        if (Boolean.TRUE.equals(saveReqVO.getAutoGenerate())) {
            if (StrUtil.isBlank(saveReqVO.getGenerateCron())) {
                throw exception(WM_STOCK_TAKING_PLAN_AUTO_GENERATE_CRON_REQUIRED);
            }
            if (!CronExpression.isValidExpression(saveReqVO.getGenerateCron())) {
                throw exception(WM_STOCK_TAKING_PLAN_AUTO_GENERATE_CRON_INVALID);
            }
        }
    }
}