futian.liu
2023-12-18 3884e330379c96e7576ada6b7a988a84e8757886
consum-base/src/main/java/com/consum/base/core/service/LWhWarningCoreServiceImpl.java
@@ -1,6 +1,17 @@
package com.consum.base.core.service;
import cn.hutool.core.convert.Convert;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.consum.base.core.utils.IdUtil;
import com.consum.base.service.BaseGoodsModelsService;
import com.consum.base.service.BaseWarehouseService;
@@ -8,16 +19,8 @@
import com.consum.model.po.BaseWarehouse;
import com.consum.model.po.FinSysTenantUser;
import com.consum.model.po.WhWarning;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import cn.hutool.core.convert.Convert;
/**
 * @ClassName LWhWarningCoreServiceImpl
@@ -44,22 +47,21 @@
     * @param warehouseId
     * @param baseModelIdList
     */
    public void updateKuCun(Short warehouseType, Long warehouseId, List<Long> baseModelIdList, FinSysTenantUser sysInfo, Long dealTime) {
    public void updateKuCun(Short warehouseType, Long warehouseId, List<Long> baseModelIdList, FinSysTenantUser sysInfo,
        Long dealTime) {
        if (baseModelIdList == null) {
            baseModelIdList = new ArrayList<>();
        }
        sysInfo = sysInfo == null ? new FinSysTenantUser() : sysInfo;
        // 获取到达到阈值的物品
        List<Map<String, Object>> kuCunNotifyList = lWhWarningService.checkKuCun(warehouseType, warehouseId, baseModelIdList);
        //
        List<Map<String, Object>> kuCunNotifyList =
            lWhWarningService.checkKuCun(warehouseType, warehouseId, baseModelIdList);
//        log.info("没有达到阈值的物品");
        if (CollectionUtils.isEmpty(kuCunNotifyList)) {
            kuCunNormalModel(warehouseType, warehouseId, baseModelIdList);
            return;
        }
        List<Long> allChangModelList = baseModelIdList.stream()
            .distinct()
            .collect(Collectors.toList());
        List<Long> allChangModelList = baseModelIdList.stream().distinct().collect(Collectors.toList());
        baseModelIdList = allChangModelList;
        // 将数据插入库存预警【WH_WARNING】
@@ -112,7 +114,8 @@
    }
    private String KU_CUN_NORMAL_MODEL = "update WH_WARNING set STATES=2 where WAREHOUSE_TYPE=? and BASE_WAREHOUSE_ID=?";
    private String KU_CUN_NORMAL_MODEL =
        "update WH_WARNING set STATES=2 where WAREHOUSE_TYPE=? and BASE_WAREHOUSE_ID=?";
    /**
     * @param warehouseType
@@ -130,7 +133,8 @@
        StringBuilder sql = new StringBuilder(KU_CUN_NORMAL_MODEL);
        if (!org.springframework.util.CollectionUtils.isEmpty(normalBaseModelIdList)) {
            sql.append(" and BASE_GOODS_MODELS_ID in(").append(org.apache.commons.lang3.StringUtils.join(normalBaseModelIdList, ",")).append(")");
            sql.append(" and BASE_GOODS_MODELS_ID in(")
                .append(org.apache.commons.lang3.StringUtils.join(normalBaseModelIdList, ",")).append(")");
        }
        return lWhWarningService.update(sql.toString(), params.toArray());
    }