skyouc
2025-05-12 3e7ddfed8f28fda861710fda62cb485e393244c5
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/ScheduleJobs.java
@@ -6,8 +6,13 @@
import com.vincent.rsf.server.common.utils.CommonUtil;
import com.vincent.rsf.server.common.utils.DateUtils;
import com.vincent.rsf.server.manager.entity.*;
import com.vincent.rsf.server.manager.enums.AsnExceStatus;
import com.vincent.rsf.server.manager.enums.PakinIOStatus;
import com.vincent.rsf.server.manager.service.*;
import com.vincent.rsf.server.system.constant.GlobalConfigCode;
import com.vincent.rsf.server.system.constant.SerialRuleCode;
import com.vincent.rsf.server.system.entity.Config;
import com.vincent.rsf.server.system.service.ConfigService;
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@@ -37,16 +42,12 @@
    private PurchaseService purchaseService;
    @Autowired
    private PurchaseItemService purchaseItemService;
    @Autowired
    private AsnOrderService asnOrderService;
    @Autowired
    private MatnrService matnrService;
    @Autowired
    private AsnOrderItemService asnOrderItemService;
    @Resource
    private SysStockProperties flowProperties;
    @Autowired
@@ -57,6 +58,35 @@
    private WaitPakinLogService waitPakinLogService;
    @Autowired
    private WaitPakinItemLogService waitPakinItemLogService;
    @Autowired
    private ConfigService configService;
    /**
     * @author Ryan
     * @date 2025/5/9
     * @description: 直接组托开关为true,将收货单直接加入临时库存
     * @version 1.0
     */
    public synchronized void IgnoreReceipt() {
        Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.DIRECT_WAIT_PAKIN));
        if (Objects.isNull(config)) {
            return;
        }
        if (!Boolean.getBoolean(config.getVal())) {
            return;
        }
        List<AsnOrder> orders = asnOrderService.list(new LambdaQueryWrapper<AsnOrder>().eq(AsnOrder::getExceStatus, AsnExceStatus.ASN_EXCE_STATUS_UN_EXCE.val));
        if (orders.isEmpty()) {
            for (AsnOrder order : orders) {
                List<AsnOrderItem> orderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getAsnId, order.getId()));
            }
        }
    }
    /**
@@ -68,7 +98,7 @@
     */
    @Scheduled(cron = "0 0/05 * * * ?  ")
    @Transactional(rollbackFor = Exception.class)
    public void genAsnOrder() {
    public synchronized void genAsnOrder() {
        //判断是否开启自动生成ASN单据
        if (!flowProperties.getFlagAutoAsn()) {
            return;
@@ -167,7 +197,8 @@
            if (StringUtils.isBlank(trackCode)) {
                throw new CoolException("单据跟踪码生成失败:请检查「sys_asn_mantr_label」是否配置完成!!");
            }
            item.setTrackCode(trackCode);
//            item.setTrackCode(trackCode);
            item.setBarcode(trackCode);
            items.add(item);
        });
@@ -183,10 +214,12 @@
     * @return
     * @time 2025/3/29 12:36
     */
    @Scheduled(cron = "0/5 * * * * ?")
    @Scheduled(cron = "0/25 * * * * ?")
    @Transactional(rollbackFor = Exception.class)
    public void pakinLog() {
        List<WaitPakin>  pakinIds = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getIoStatus, 2).select(WaitPakin::getId));
        List<WaitPakin>  pakinIds = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                .eq(WaitPakin::getIoStatus, Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val))
                .select(WaitPakin::getId));
        if (pakinIds.isEmpty()) {
            return;
        }
@@ -221,10 +254,10 @@
        if (!waitPakinItemLogService.saveBatch(itemLogs)) {
            throw new CoolException("历史明细档保存失败!!");
        }
        if (!waitPakinService.removeByIds(pakins)) {
        if (!waitPakinService.removeByIds(list)) {
            throw new CoolException("原单据删除失败!!");
        }
        if (!waitPakinItemService.removeByIds(pakinItems)) {
        if (!waitPakinItemService.remove(new LambdaQueryWrapper<WaitPakinItem>().in(WaitPakinItem::getPakinId, list))) {
            throw new CoolException("原单据明细删除失败!!");
        }
    }