代码如下:
@Override public List<DepotStockRuleEntity> findDepotStockRuleByChannelIdAndClothingIds(String channelId, List<String> clothingIds) { if (StringUtil.isBlankOrNull(channelId) || clothingIds == null || clothingIds.isEmpty()) { return new ArrayList<>(); } StringBuilder sb = new StringBuilder(); sb.append(" select new com.x3.ec.base.core.entity.DepotStockRuleEntity (d.storeId, s.clothingId, "); sb.append(" case when h.stockSaleRatio >= 0 then h.stockSaleRatio "); sb.append(" else case when g.stockSaleRatio >= 0 then g.stockSaleRatio "); sb.append(" else case when f.stockSaleRatio >= 0 then f.stockSaleRatio "); sb.append(" else case when e.stockSaleRatio >= 0 then e.stockSaleRatio "); sb.append(" else c.stockSaleRatio end end end end, "); sb.append(" case when h.stockSaleFrozen >= 0 then h.stockSaleFrozen "); sb.append(" else case when g.stockSaleFrozen >= 0 then g.stockSaleFrozen "); sb.append(" else case when f.stockSaleFrozen >= 0 then f.stockSaleFrozen "); sb.append(" else case when e.stockSaleFrozen >= 0 then e.stockSaleFrozen "); sb.append(" else c.stockSaleFrozen end end end end, c.groupId ) "); sb.append(" from StockChannelArchiveTable a "); sb.append(" inner join A3ClothingTable s on s.clothingId in (").append(ListUtil.createInSqlWithQuoted(clothingIds, "s.clothingId")).append(") "); sb.append(" inner join StockchRuleTable c on a.channelId = c.channelId and c.ruleDimension = 0 "); sb.append(" inner join StoreGroupSubTable d on c.groupId = d.groupId "); //分区加入规则,检查库存分组无需关联a3_depot // sb.append(" inner join A3DepotTable i on i.depotId = d.storeId and i.organId = a.organId "); sb.append(" left join StockchRuleTable e on a.channelId=e.channelId and d.groupId=e.groupId and e.ruleDimension=1 and e.depotId=d.storeId "); sb.append(" left join StockchRuleTable f on a.channelId=f.channelId and d.groupId=f.groupId and f.ruleDimension=2 and f.depotId=d.storeId and f.goodsId=s.styleId "); sb.append(" left join StockchRuleTable g on a.channelId=g.channelId and d.groupId=g.groupId and g.ruleDimension=3 and g.depotId=d.storeId and g.goodsId=s.stylecolorId "); sb.append(" left join StockchRuleTable h on a.channelId=h.channelId and d.groupId=h.groupId and h.ruleDimension=4 and h.depotId=d.storeId and h.goodsId=s.clothingId "); sb.append(" where a.channelId = :channelId "); TypedQuery<DepotStockRuleEntity> query = em.createQuery(sb.toString(), DepotStockRuleEntity.class); query.setParameter("channelId", channelId); List<DepotStockRuleEntity> list = query.getResultList(); if (list == null || list.isEmpty()) { return new ArrayList<>(); } return list; }
生成的sql:
SELECT storegroup3_.store_id AS storeId, a3clothing1_.clothing_id AS clothingId, CASE WHEN stockchrul7_.stock_sale_ratio >= 0 THEN stockchrul7_.stock_sale_ratio ELSE CASE WHEN stockchrul6_.stock_sale_ratio >= 0 THEN stockchrul6_.stock_sale_ratio ELSE CASE WHEN stockchrul5_.stock_sale_ratio >= 0 THEN stockchrul5_.stock_sale_ratio ELSE CASE WHEN stockchrul4_.stock_sale_ratio >= 0 THEN stockchrul4_.stock_sale_ratio ELSE stockchrul2_.stock_sale_ratio END END END END AS stockSaleRatio, CASE WHEN stockchrul7_.stock_sale_frozen >= 0 THEN stockchrul7_.stock_sale_frozen ELSE CASE WHEN stockchrul6_.stock_sale_frozen >= 0 THEN stockchrul6_.stock_sale_frozen ELSE CASE WHEN stockchrul5_.stock_sale_frozen >= 0 THEN stockchrul5_.stock_sale_frozen ELSE CASE WHEN stockchrul4_.stock_sale_frozen >= 0 THEN stockchrul4_.stock_sale_frozen ELSE stockchrul2_.stock_sale_frozen END END END END AS stockSaleFrozen, stockchrul2_.group_id AS groupId FROM oc_stock_channel stockchann0_ INNER JOIN a3_clothing a3clothing1_ ON ( a3clothing1_.clothing_id IN ( 'SWF325M1250000406' ) ) INNER JOIN oc_stockch_rule stockchrul2_ ON ( stockchann0_.channel_id = stockchrul2_.channel_id AND stockchrul2_.rule_dimension = 0 ) INNER JOIN oc_store_group_sub storegroup3_ ON ( stockchrul2_.group_id = storegroup3_.group_id ) LEFT outer JOIN oc_stockch_rule stockchrul4_ ON ( stockchann0_.channel_id = stockchrul4_.channel_id AND storegroup3_.group_id = stockchrul4_.group_id AND stockchrul4_.rule_dimension = 1 AND stockchrul4_.depot_id = storegroup3_.store_id ) LEFT outer JOIN oc_stockch_rule stockchrul5_ ON ( stockchann0_.channel_id = stockchrul5_.channel_id AND storegroup3_.group_id = stockchrul5_.group_id AND stockchrul5_.rule_dimension = 2 AND stockchrul5_.depot_id = storegroup3_.store_id AND stockchrul5_.goods_id = a3clothing1_.style_id ) LEFT outer JOIN oc_stockch_rule stockchrul6_ ON ( stockchann0_.channel_id = stockchrul6_.channel_id AND storegroup3_.group_id = stockchrul6_.group_id AND stockchrul6_.rule_dimension = 3 AND stockchrul6_.depot_id = storegroup3_.store_id AND stockchrul6_.goods_id = a3clothing1_.stylecolor_id ) LEFT outer JOIN oc_stockch_rule stockchrul7_ ON ( stockchann0_.channel_id = stockchrul7_.channel_id AND storegroup3_.group_id = stockchrul7_.group_id AND stockchrul7_.rule_dimension = 4 AND stockchrul7_.depot_id = storegroup3_.store_id AND stockchrul7_.goods_id = a3clothing1_.clothing_id ) WHERE stockchann0_.channel_id ='S004'
字节(Byte)是计量单位,表示数据量多少,是计算机信息技术用于计量存储容量的一种计量单位,通常情况下一字节等于八位。字符(Character)计算机中使用的字母、数字、字和符号,比如'A'、'B'、'$'、'&'等。一般在英文...
public class test { public static void main(String[] args) { &...
java一个类可以有多个构造方法,根据传参类型和个数来匹配执行哪个构造方法。public class Member { public Member(){  ...
(1).java获取当前日期时间Date date = new Date(); System.out.println(date.toString());输出Fri Jul 02 10:29:55 CST 2021(2).java获取时间戳秒/毫秒D...
(1).java睡眠函数Thread.sleep(时间); //单位为毫秒(2).java睡眠函数例子Date dNow = new Date(); SimpleDateFormat ft = new&nbs...
System.out.println("当前时间戳(秒): " + System.currentTimeMillis()/1000); System.out.println("当前时间戳(毫秒): " +&nb...