cy
2023-11-14 293996df5d4e39499384ffc5e2aca48241677bd9
consum-base/src/main/java/com/consum/base/service/LWhGoodsService.java
@@ -3,13 +3,15 @@
import com.consum.model.po.LWhGoods;
import com.walker.infrastructure.utils.CollectionUtils;
import com.walker.jdbc.service.BaseServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
/**
 * @ClassName LWhGoodsService
@@ -118,6 +120,23 @@
        return whGoodsIds;
    }
    private static String QUERY_GOODS_PRICE_BY_ID = "SELECT sum(PRICE)totalPrice from L_WH_GOODS goods where 1=1";
    public long queryGoodsPriceById(List<Long> goodsIds) {
        StringBuilder sql = new StringBuilder(QUERY_GOODS_PRICE_BY_ID);
        Map<String, Object> paramts = new HashMap<>();
        if (!CollectionUtils.isEmpty(goodsIds)) {
            sql.append(" and id in(:goodsIds)");
            paramts.put("goodsIds", goodsIds);
        }
        List<Map<String, Object>> map = this.select(sql.toString(), paramts);
        if (CollectionUtils.isEmpty(map)) {
            return 0;
        }
        BigDecimal totalPrice = (BigDecimal) map.get(0).get("totalPrice");
        return totalPrice.longValue();
    }
    /**
     * 查询报废物品 默认优先报废最高价的物品