Browse Source

物料库调整字段之后调整批量上架相关代码

yujia 8 years ago
parent
commit
5164408bae

+ 0 - 20
src/main/java/com/uas/platform/b2c/prod/commodity/dao/ProductDao.java

@@ -119,26 +119,6 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
      */
     List<Product> findByEnUUAndCmpUuIdAndSourceApp(Long enuu, String uuid, String sourceapp);
 
-    /**
-     * 通过企业uu,标准器件uuid,来源获取物料信息
-     *
-     * @param enuu 企业uu
-     * @param sourceapp 来源
-     * @return
-     */
-    @Query(value = "select p from Product p where p.enUU = :enuu and p.sourceApp = :sourceapp and (p.batchCount = 0 or p.batchCount is null) and (p.erpReserve is not null and p.erpReserve <> 0)")
-    List<Product> findByEnUUAndSourceAppNotPutOn(@Param("enuu") Long enuu, @Param("sourceapp") String sourceapp);
-
-    /**
-     * 统计数量 通过企业uu,来源获取物料信息 并且未存在上架信息
-     *
-     * @param enuu 企业uu
-     * @param sourceapp 来源
-     * @return
-     */
-    @Query(value = "select count(1) from Product p where p.enUU = :enuu and p.sourceApp = :sourceapp and (p.batchCount = 0 or p.batchCount is null)")
-    Integer findCountByEnUUAndSourceAppNotPutOn(@Param("enuu") Long enuu, @Param("sourceapp") String sourceapp);
-
     /**
      * 获取该企业的产品信息
      * @param enuu 企业的uu号

+ 14 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/dao/ProductPrivateDao.java

@@ -3,8 +3,22 @@ package com.uas.platform.b2c.prod.commodity.dao;
 import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+
+import java.util.List;
 
 public interface ProductPrivateDao  extends JpaRepository<ProductPrivate, Long>, JpaSpecificationExecutor<ProductPrivate> {
 
     public ProductPrivate findByPrId(Long prId);
+
+
+    /**
+     * 根据物料的id 获取私有信息
+     *
+     * @param prids
+     * @return
+     */
+    @Query(value = "select p from ProductPrivate p where p.prId in (:prids)")
+    List<ProductPrivate> findByPrIds(@Param("prids") List<Long> prids);
 }

+ 8 - 12
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -185,9 +185,6 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     private UASBatchPutOnPropertyService uasBatchPutOnPropertyService;
 
-    @Autowired
-    private ProductPersonDao productPersonDao;
-
     private ConcurrentHashMap<String, Field> sortFields = new ConcurrentHashMap<String, Field>();
 
     @Override
@@ -1359,7 +1356,7 @@ public class ProductServiceImpl implements ProductService {
         if (property == null) {
             return new ResultMap(CodeType.NOT_COMPLETE_INFO.code(), "请先设置上架参数", null);
         }
-        String sql = "select pr_id from products where pr_batchcount = 0 and pr_sourceapp = 'ERP' and pr_reserve <> 0 and pr_reserve is not null and pr_b2cenabled = 1 and pr_enuu = (:enuu) and pr_id not in (select DISTINCT go_productid from trade$goods where  go_productid is not null);";
+        String sql = "select p.pr_id from products p left join product$private pp on pp.pr_id = p.pr_id where pp.pr_batchcount = 0 and p.pr_sourceapp = 'ERP' and p.pr_reserve <> 0 and p.pr_reserve is not null and pp.pr_b2cenabled = 1 and p.pr_enuu = (:enuu) and p.pr_id not in (select DISTINCT go_productid from trade$goods where  go_productid is not null);";
         Map<String, Long> map = new HashMap<>();
         map.put("enuu", uu);
         List<Long> longList = namedParameterJdbcTemplate.queryForList(sql, map, Long.class);
@@ -1380,16 +1377,15 @@ public class ProductServiceImpl implements ProductService {
         goodsList.addAll(goodses);
         List<Goods> result = new ArrayList<Goods>();
         goodsService.publishERPProductByBatch(goodsList, uuids, result);
-        List<Product> list = new ArrayList<>();
+        List<Long> prids = new ArrayList<>();
         for (Goods goods : result) {
-            for (Product product : sourceAppNotPutOn) {
-                if (product.getId().longValue() == goods.getProductid().longValue()) {
-                    product.setBatchCount(com.uas.platform.b2c.prod.commodity.constant.IntegerConstant.YES_INT);
-                    list.add(product);
-                }
-            }
+            prids.add(goods.getProductid());
+        }
+        List<ProductPrivate> productPrivates = productPrivateDao.findByPrIds(prids);
+        for (ProductPrivate productPrivate : productPrivates) {
+            productPrivate.setBatchCount(IntegerConstant.YES_SHORT);
         }
-        productDao.save(list);
+        productPrivateDao.save(productPrivates);
         for (String uuid : uuids) {
             goodsService.updateComponentTradeInfos(uuid);
         }