Просмотр исходного кода

导入物料,查找已匹配物料,需要所有公共物料字段

yingp 8 лет назад
Родитель
Сommit
26fa5dbdc7

+ 41 - 2
src/main/java/com/uas/platform/b2b/dao/ProductTempDao.java

@@ -77,15 +77,53 @@ public class ProductTempDao {
                 String.class, importId);
     }
 
+    /**
+     * 未匹配物料
+     *
+     * @param importId
+     * @return
+     */
     public List<Product> getNotMatchedProducts(String importId) {
         return jdbcTemplate.query("select pr_code code,pr_title title,pr_spec spec,pr_cmpcode cmpCode,pr_brand brand,pr_unit unit,pr_minpack minPack,pr_minorder minOrder,pr_leadtime leadtime,pr_ltinstock ltinstock,pr_enuu enUU,pr_useruu userUU," +
                         "pr_issale isSale,pr_ispurchase isPurchase,pr_isshow isShow,pr_standard standard,pr_ispubsale isPubsale,pr_sourceapp sourceApp,pr_create_time createTime from products_temp where pr_import_id=? and pr_exist_id is null",
                 new BeanPropertyRowMapper<Product>(Product.class), importId);
     }
 
+    /**
+     * 已匹配物料
+     *
+     * @param importId
+     * @return
+     */
     public List<Product> getMatchedProducts(String importId) {
-        return jdbcTemplate.query("select pr_id id,pr_code code,pr_title title,pr_spec spec,pr_cmpcode cmpCode,pr_brand brand,pr_unit unit,pr_minpack minPack,pr_minorder minOrder,pr_leadtime leadtime,pr_ltinstock ltinstock,pr_enuu enUU,pr_useruu userUU," +
-                        "pr_issale isSale,pr_ispurchase isPurchase,pr_isshow isShow,pr_standard standard,pr_ispubsale isPubsale,pr_sourceapp sourceApp,pr_create_time createTime from products p where exists (select 1 from products_temp t where t.pr_exist_id=p.pr_id and t.pr_import_id=?)",
+        return jdbcTemplate.query("select p.pr_id id,p.pr_sourceid sourceId,p.pr_erpdate erpDate,p.pr_cmpuuid cmpUuId,p.pr_attachment attachment," +
+                        "p.pr_kind kind,p.pr_pbrand pbrand,p.pr_pcmpcode pcmpcode,p.pr_kinden kinden,p.pr_pbranden pbranden,p.pr_matchstatus matchstatus," +
+                        "p.pr_matchsize matchsize,p.pr_downloadstatus downloadstatus,p.pr_cmpimg img,p.pr_encapsulation encapsulation,p.pr_tostandard tostandard," +
+                        "p.pr_goodsnover goodsnover,p.pr_goodstaxno goodstaxno,p.pr_taxpre taxpre,p.pr_taxprecon taxprecon,p.pr_reserve reserve,p.pr_kindid kindId," +
+                        "p.pr_pbrandid pbrandId,p.pr_pbranduuid pbrandUuid,p.pr_packaging packaging,p.pr_manufacturedate manufactureDate,p.pr_maxdelivery maxDelivery," +
+                        "p.pr_mindelivery minDelivery,p.pr_isbreakup isBreakUp," +
+                        "t.pr_code code,t.pr_title title,t.pr_spec spec,t.pr_cmpcode cmpCode,t.pr_brand brand,t.pr_unit unit,t.pr_minpack minPack,t.pr_minorder minOrder,t.pr_leadtime leadtime,t.pr_ltinstock ltinstock,t.pr_enuu enUU,t.pr_useruu userUU," +
+                        "t.pr_issale isSale,t.pr_ispurchase isPurchase,t.pr_isshow isShow,t.pr_standard standard,t.pr_ispubsale isPubsale,t.pr_sourceapp sourceApp,t.pr_create_time createTime " +
+                        "from products p,products_temp t where t.pr_exist_id=p.pr_id and t.pr_import_id=?",
+                new BeanPropertyRowMapper<Product>(Product.class), importId);
+    }
+
+    /**
+     * 全部物料:已匹配+未匹配
+     *
+     * @param importId
+     * @return
+     */
+    public List<Product> getProducts(String importId) {
+        return jdbcTemplate.query("select p.pr_id id,p.pr_sourceid sourceId,p.pr_erpdate erpDate,p.pr_cmpuuid cmpUuId,p.pr_attachment attachment," +
+                        "p.pr_kind kind,p.pr_pbrand pbrand,p.pr_pcmpcode pcmpcode,p.pr_kinden kinden,p.pr_pbranden pbranden,p.pr_matchstatus matchstatus," +
+                        "p.pr_matchsize matchsize,p.pr_downloadstatus downloadstatus,p.pr_cmpimg img,p.pr_encapsulation encapsulation,p.pr_tostandard tostandard," +
+                        "p.pr_goodsnover goodsnover,p.pr_goodstaxno goodstaxno,p.pr_taxpre taxpre,p.pr_taxprecon taxprecon,p.pr_reserve reserve,p.pr_kindid kindId," +
+                        "p.pr_pbrandid pbrandId,p.pr_pbranduuid pbrandUuid,p.pr_packaging packaging,p.pr_manufacturedate manufactureDate,p.pr_maxdelivery maxDelivery," +
+                        "p.pr_mindelivery minDelivery,p.pr_isbreakup isBreakUp," +
+                        "t.pr_code code,t.pr_title title,t.pr_spec spec,t.pr_cmpcode cmpCode,t.pr_brand brand,t.pr_unit unit,t.pr_minpack minPack,t.pr_minorder minOrder,t.pr_leadtime leadtime,t.pr_ltinstock ltinstock,t.pr_enuu enUU,t.pr_useruu userUU," +
+                        "t.pr_issale isSale,t.pr_ispurchase isPurchase,t.pr_isshow isShow,t.pr_standard standard,t.pr_ispubsale isPubsale,t.pr_sourceapp sourceApp,t.pr_create_time createTime " +
+                        "from products_temp t left join products p on t.pr_exist_id=p.pr_id where t.pr_import_id=?",
                 new BeanPropertyRowMapper<Product>(Product.class), importId);
     }
 
@@ -94,6 +132,7 @@ public class ProductTempDao {
     }
 
     public List<ProductUsers> getNotMatchedProductUsers(final String importId, final long enUU, final long userUU, List<Long> ids) {
+        // 使用临时表productusers_temp方便操作
         jdbcTemplate.batchUpdate("insert into productusers_temp(pu_import_id,pu_date,pu_enuu,pu_useruu,pu_prid) values (?,sysdate,?,?,?)",
                 ids, ids.size(), new ParameterizedPreparedStatementSetter<Long>() {
                     @Override

+ 2 - 29
src/main/java/com/uas/platform/b2b/service/impl/ProductUsersServiceImpl.java

@@ -336,35 +336,8 @@ public class ProductUsersServiceImpl implements ProductUsersService {
         long start = System.currentTimeMillis();
         if (!CollectionUtils.isEmpty(temps)) {
             String importId = temps.get(0).getPr_import_id();
-            // 匹配后结果
-            temps = productTempDao.findByImportId(importId);
-            // 未匹配到的物料
-            List<Product> products = productTempDao.getNotMatchedProducts(importId);
-            // 匹配的当前物料库相关数据
-            List<Product> exists = productTempDao.getMatchedProducts(importId);
-            if (!CollectionUtils.isEmpty(exists)) {
-                for (Product e : exists) {
-                    for (ProductTemp t : temps) {
-                        // 替换为新导入的数据
-                        if (e.getId().equals(t.getPr_exist_id())) {
-                            e.setCode(t.getPr_code());
-                            e.setCmpCode(t.getPr_cmpcode());
-                            e.setBrand(t.getPr_brand());
-                            e.setTitle(t.getPr_title());
-                            e.setSpec(t.getPr_spec());
-                            e.setUnit(t.getPr_unit());
-                            e.setMinOrder(t.getPr_minorder());
-                            e.setMinPack(t.getPr_minpack());
-                            e.setLeadtime(t.getPr_leadtime());
-                            e.setLtinstock(t.getPr_ltinstock());
-                            e.setIsSale(t.getPr_issale());
-                            e.setIsPurchase(t.getPr_ispurchase());
-                            products.add(e);
-                            break;
-                        }
-                    }
-                }
-            }
+            // 已匹配+未匹配到的物料
+            List<Product> products = productTempDao.getProducts(importId);
             System.out.println("取匹配后结果:" + (System.currentTimeMillis() - start));
             start = System.currentTimeMillis();
             try {