Pārlūkot izejas kodu

修复发布询价之后,不能正确将已有物料添加到个人库的bug。增加物料查询部分接口。

dongbw 7 gadi atpakaļ
vecāks
revīzija
3f094a6bed

+ 158 - 0
src/main/java/com/uas/ps/product/controller/ProductGetController.java

@@ -0,0 +1,158 @@
+package com.uas.ps.product.controller;
+
+import com.uas.ps.entity.Product;
+import com.uas.ps.product.service.ProductService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 物料相关的查询接口
+ * @author dongbw
+ * 18/07/11 15:02.
+ */
+@RestController
+@RequestMapping("/product/get")
+public class ProductGetController {
+
+    @Autowired
+    private ProductService productService;
+
+    /**
+     * 根据enUU和code查找企业物料
+     * @param enUU  企业UU
+     * @param code  物料编号
+     * @return  物料List -- 其实只有一个,为了配合之前B2B未建唯一索引时的查询方法,返回List
+     */
+    @RequestMapping(value = "/findByEnUUAndCode", method = RequestMethod.GET)
+    public List<Product> findByEnUUAndCode(@RequestParam("enUU") Long enUU, @RequestParam("code") String code) {
+        return productService.findByEnUUAndCode(enUU, code);
+    }
+
+    /**
+     * 根据enUU和code查找企业物料
+     * @param enUU  企业UU
+     * @param codes  物料编号 List
+     * @return  物料List
+     */
+    @RequestMapping(value = "/findByEnUUAndCodes", method = RequestMethod.GET)
+    public List<Product> findByEnUUAndCodes(@RequestParam("enUU") Long enUU, @RequestParam("codes") List<String> codes) {
+        return productService.findByEnUUAndCodes(enUU, codes);
+    }
+
+    /**
+     * 根据id查找企业物料
+     * @param id  物料id
+     * @return  物料
+     */
+    @RequestMapping(value = "/findById", method = RequestMethod.GET)
+    public Product findById(@RequestParam("id") Long id) {
+        return productService.findById(id);
+    }
+
+    /**
+     * 根据ids查找企业物料
+     * @param ids  物料id
+     * @return  物料
+     */
+    @RequestMapping(value = "/findByIds", method = RequestMethod.GET)
+    public List<Product> findById(@RequestParam("ids") String ids) {
+        return productService.findByIds(ids);
+    }
+
+    /**
+     * 根据enUU和title查找企业物料
+     * @param enUU  企业UU
+     * @param title  物料名称
+     * @return  物料List
+     */
+    @RequestMapping(value = "/findByEnUUAndTitle", method = RequestMethod.GET)
+    public List<Product> findByEnUUAndTitle(@RequestParam Long enUU, @RequestParam String title) {
+        return productService.findByEnUUAndTitle(enUU, title);
+    }
+
+    /**
+     * 根据enUU和品牌可是否可卖查找企业物料
+     * @param enUU  企业UU
+     * @param brand  物料品牌
+     * @param isSale 是否可卖  1 可  0 不可
+     * @return  物料List
+     */
+    @RequestMapping(value = "/findByEnUUAndBrandAndIsSale", method = RequestMethod.GET)
+    public List<Product> findByEnUUAndBrandAndIsSale(@RequestParam Long enUU, @RequestParam String brand, @RequestParam Short isSale) {
+        return productService.findByEnUUAndBrandAndIsSale(enUU, brand, isSale);
+    }
+
+    /**
+     * 根据enUU和brand和isPurchase查找企业物料
+     * @param enUU  企业UU
+     * @param brand  物料品牌
+     * @param isPurchase 是否待采购  1 可  0 不可
+     * @return  物料List
+     */
+    @RequestMapping(value = "/findByEnUUAndBrandAndIsPurchase", method = RequestMethod.GET)
+    public List<Product> findByEnUUAndBrandAndIsPurchase(@RequestParam Long enUU, @RequestParam String brand, @RequestParam Short isPurchase) {
+        return productService.findByEnUUAndBrandAndIsPurchase(enUU, brand, isPurchase);
+    }
+
+    /**
+     * 根据enUU和brand和brand查找企业物料
+     * @param enUU  企业UU
+     * @param brand  物料品牌
+     * @return  物料List
+     */
+    @RequestMapping(value = "/findByEnUUAndBrand", method = RequestMethod.GET)
+    public List<Product> findByEnUUAndBrand(@RequestParam Long enUU, @RequestParam String brand) {
+        return productService.findByEnUUAndBrand(enUU, brand);
+    }
+
+    /**
+     * 根据enUU和title和isSale查找企业物料
+     * @param enUU  企业UU
+     * @param title  物料名称
+     * @param isSale 是否待销售 1 可  0 不可
+     * @return  物料List
+     */
+    @RequestMapping(value = "/findByEnUUAndTitleAndIsSale", method = RequestMethod.GET)
+    public List<Product> findByEnUUAndTitleAndIsSale(@RequestParam Long enUU, @RequestParam String title, @RequestParam Short isSale) {
+        return productService.findByEnUUAndTitleAndIsSale(enUU, title, isSale);
+    }
+
+    /**
+     * 根据enUU和title和isSale查找企业物料
+     * @param enUU  企业UU
+     * @param title  物料名称
+     * @param isPurchase 是否可采购 1 可  0 不可
+     * @return  物料List
+     */
+    @RequestMapping(value = "/findByEnUUAndTitleAndIsPurchase", method = RequestMethod.GET)
+    public List<Product> findByEnUUAndTitleAndIsPurchase(@RequestParam Long enUU, @RequestParam String title, @RequestParam Short isPurchase) {
+        return productService.findByEnUUAndTitleAndIsPurchase(enUU, title, isPurchase);
+    }
+
+    /**
+     * 根据enUU和title和isSale查找企业物料
+     * @param enUU  企业UU
+     * @param sourceApp  来源app
+     * @param downloadStatus 下载状态 202 待下载 203  已下载
+     * @return  物料List
+     */
+    @RequestMapping(value = "/findByEnUUAndSourceAppAndDownloadStatus", method = RequestMethod.GET)
+    public List<Product> findByEnUUAndSourceAppAndDownloadStatus(@RequestParam Long enUU, @RequestParam String sourceApp, @RequestParam Integer downloadStatus) {
+        return productService.findByEnUUAndSourceAppAndDownloadStatus(enUU, sourceApp, downloadStatus);
+    }
+
+    /**
+     * 根据enUU和获取企业物料数量
+     * @param enUU  企业UU
+     * @return  物料List
+     */
+    @RequestMapping(value = "/countByEnUU", method = RequestMethod.GET)
+    public Long countByEnUU(@RequestParam("enUU") Long enUU) {
+        return productService.countByEnUU(enUU);
+    }
+}

+ 80 - 0
src/main/java/com/uas/ps/product/repository/ProductDao.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Repository;
 
 import javax.transaction.Transactional;
 import java.util.List;
+import java.util.Set;
 
 /**
  * @author sunyj
@@ -187,6 +188,85 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
     @Query(value = "select p.pr_enuu from v$product$private p where p.pr_enuu <> :enUU and p.pr_pcmpcode = :pCmpCode and p.pr_b2cenabled = 1 group by p.pr_enuu", nativeQuery = true)
     List<Long> getBusinessOpportunityWithoutPBrandEn(@Param("enUU")Long enUU, @Param("pCmpCode")String pCmpCode);
 
+
+    /* ==================================2018年7月11日 15:21:39 新增================================  */
+
+    /**
+     * 通过uu和名称判断物料是否存在(新增采购导入时需用到)
+     *                          数量大时,速度会很慢  2018年7月11日 15:19:03  dongbw
+     * @param enUU  企业UU
+     * @param title  物料名称
+     * @return
+     */
+    @Deprecated
+    List<Product> findByEnUUAndTitle(Long enUU, String title);
+
+    /**
+     * 通过品牌和enuu查询所有信息
+     *                      数量大时,速度会很慢  2018年7月11日 15:18:43  dongbw
+     * @param enUU  企业UU
+     * @param brand  品牌
+     * @param isSale 是否可销售(1可 0 不可)
+     * @return  物料信息
+     */
+    @Deprecated
+    List<Product> findByEnUUAndBrandAndIsSale(Long enUU, String brand, Short isSale);
+
+    /**
+     * 通过品牌和enuu查询所有信息
+     *
+     * @param enuu
+     * @param brand
+     * @return
+     */
+    public List<Product> findByEnUUAndBrand(Long enuu, String brand);
+    /**
+     * 通过品牌和enuu查询所有信息
+     *
+     * @param enuu
+     * @param brand
+     * @param isPurc
+     * @return
+     */
+    public List<Product> findByEnUUAndBrandAndIsPurchase(Long enuu, String brand, Short isPurc);
+
+    /**
+     * 通过名称查询物料信息
+     *
+     * @param enUU
+     * @param title
+     * @param isSale
+     * @return
+     */
+    public List<Product> findByEnUUAndTitleAndIsSale(Long enUU, String title, Short isSale);
+
+    /**
+     * 通过名称查询物料信息
+     *
+     * @param enUU
+     * @param title
+     * @param isPurc
+     * @return
+     */
+    public List<Product> findByEnUUAndTitleAndIsPurchase(Long enUU, String title, Short isPurc);
+
+    /**
+     * 通过企业UU号查询物料上传数量
+     *
+     * @param enUU 企业UU
+     * @return
+     */
+    Long countByEnUU(Long enUU);
+
+    /**
+     * 根据enUU和codes 获取物料信息
+     * @param enUU  enUU
+     * @param codeSet  物料编号Set
+     * @return
+     */
+    @Query("from Product p where p.enUU = :enUU and p.code in :codeSet")
+    List<Product> findByEnUUAndCodeSet(@Param("enUU") Long enUU, @Param("codeSet") Set<String> codeSet);
+
 //    /**
 //     * 通过uu查询非标准器件进行存储
 //     *

+ 102 - 11
src/main/java/com/uas/ps/product/service/ProductService.java

@@ -113,10 +113,10 @@ public interface ProductService {
     /**
      * 通过所属企业UU、应用和下载状态查询物料信息
      *
-     * @param enUU
-     * @param app
-     * @param status
-     * @return
+     * @param enUU  企业UU
+     * @param app   来源app
+     * @param status  下载状态
+     * @return  物料信息
      */
     List<Product> findByEnUUAndSourceAppAndDownloadStatus(Long enUU, String app, Integer status);
 
@@ -202,13 +202,6 @@ public interface ProductService {
      */
     List<Product> updateB2bProdInfo(List<Product> productInfo);
 
-    /**
-     * 根据企业uu获取当前企业物料数量
-     * @param enUU 企业UU
-     * @return 当前企业物料数量
-     */
-    Integer getCountByEnUU(Long enUU);
-
     /**
      * 根据enUU和采购状态获取物料数目
      * @param enUU 企业UU
@@ -268,4 +261,102 @@ public interface ProductService {
      * @return 存在相同物料的其他企业UU号
      */
     ModelMap getBusinessOpportunity(Long enUU, String pCmpCode, String pBrandEn);
+
+    /**
+     * 根据enUU和code查找企业物料
+     * @param enUU  企业UU
+     * @param code  物料编号
+     * @return  物料List -- 其实只有一个,为了配合之前B2B未建唯一索引时的查询方法,返回List
+     */
+    List<Product> findByEnUUAndCode(Long enUU, String code);
+
+    /**
+     * 根据id查找企业物料
+     * @param id  物料id
+     * @return  物料
+     */
+    Product findById(Long id);
+
+
+    /**
+     * 根据id字符串获取物料列表  (1,2,3,4...)
+     * @param ids
+     * @return
+     */
+    List<Product> findByIds(String ids);
+
+
+    /**
+     * 根据enUU 和物料编号list 批量获取物料信息
+     * @param enUU  企业UU
+     * @param codes  物料编号List
+     * @return
+     */
+    List<Product> findByEnUUAndCodes(Long enUU, List<String> codes);
+
+    /**
+     * 通过uu和名称判断物料是否存在(新增采购导入时需用到)
+     *                          数量大时,速度会很慢  2018年7月11日 15:19:03  dongbw
+     * @param enUU  企业UU
+     * @param title  物料名称
+     * @return
+     */
+    @Deprecated
+    List<Product> findByEnUUAndTitle(Long enUU, String title);
+
+    /**
+     * 通过品牌和enuu查询所有信息
+     *                      数量大时,速度会很慢  2018年7月11日 15:18:43  dongbw
+     * @param enUU  企业UU
+     * @param brand  品牌
+     * @param isSale 是否可销售(1可 0 不可)
+     * @return  物料信息
+     */
+    List<Product> findByEnUUAndBrandAndIsSale(Long enUU, String brand, Short isSale);
+
+    /**
+     * 通过品牌和enuu查询所有信息
+     *
+     * @param enUU  企业UU
+     * @param brand  品牌
+     * @return  物料信息
+     */
+    List<Product> findByEnUUAndBrand(Long enUU, String brand);
+    /**
+     * 通过品牌和enuu查询所有信息
+     *
+     * @param enuu  企业UU
+     * @param brand  品牌
+     * @param isPurc  是否待采购
+     * @return  物料信息
+     */
+    List<Product> findByEnUUAndBrandAndIsPurchase(Long enuu, String brand, Short isPurc);
+
+    /**
+     * 通过名称查询物料信息
+     *
+     * @param enUU  企业UU
+     * @param title  物料名称
+     * @param isSale  是否待销售
+     * @return  物料信息
+     */
+    List<Product> findByEnUUAndTitleAndIsSale(Long enUU, String title, Short isSale);
+
+    /**
+     * 通过名称查询物料信息
+     *
+     * @param enUU  企业UU
+     * @param title  物料名称
+     * @param isPurc  是否待采购
+     * @return  物料信息
+     */
+    List<Product> findByEnUUAndTitleAndIsPurchase(Long enUU, String title, Short isPurc);
+
+    /**
+     * 通过企业UU号查询物料上传数量
+     *
+     * @param enUU 企业UU
+     * @return
+     */
+    Long countByEnUU(Long enUU);
 }

+ 146 - 13
src/main/java/com/uas/ps/product/service/impl/ProductServiceImpl.java

@@ -342,17 +342,6 @@ public class ProductServiceImpl implements ProductService {
         }
     }
 
-    /**
-     * 根据企业uu获取当前企业物料数量
-     *
-     * @param enUU 企业UU
-     * @return 当前企业物料数量
-     */
-    @Override
-    public Integer getCountByEnUU(Long enUU) {
-        return productDao.findByEnUU(enUU).size();
-    }
-
     /**
      * 根据enUU和采购状态获取物料数目
      *
@@ -487,6 +476,7 @@ public class ProductServiceImpl implements ProductService {
         for (Product product : products) {
             if (null == product.getId()) {
                 if (null != product.getUserUU()) {
+                    Long userUU = product.getUserUU();
                     SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
                     if (null == product.getCode()) {
                         String code = sdf.format(new Date()) + StringUtil.getRandomString(3);
@@ -503,9 +493,9 @@ public class ProductServiceImpl implements ProductService {
                         saveProducts.add(product);
                     } else {
                         product = existedProds.get(0);
-                        List<ProductUsers> productUsers = productUsersDao.findByEnuuAndUseruuAndPrid(product.getEnUU(), product.getUserUU(), product.getId());
+                        List<ProductUsers> productUsers = productUsersDao.findByEnuuAndUseruuAndPrid(product.getEnUU(), userUU, product.getId());
                         if (CollectionUtils.isEmpty(productUsers)) {
-                            ProductUsers productUser = new ProductUsers(product.getEnUU(), product.getUserUU(), product.getId());
+                            ProductUsers productUser = new ProductUsers(product.getEnUU(), userUU, product.getId());
                             saveProductUsers.add(productUser);
                         }
                     }
@@ -592,6 +582,149 @@ public class ProductServiceImpl implements ProductService {
         return map;
     }
 
+    /**
+     * 根据enUU和code查找企业物料
+     *
+     * @param enUU 企业UU
+     * @param code 物料编号
+     * @return 物料List -- 其实只有一个,为了配合之前B2B未建唯一索引时的查询方法,返回List
+     */
+    @Override
+    public List<Product> findByEnUUAndCode(Long enUU, String code) {
+        return productDao.findByEnUUAndCode(enUU, code);
+    }
+
+    /**
+     * 根据id查找企业物料
+     *
+     * @param id 物料id
+     * @return 物料
+     */
+    @Override
+    public Product findById(Long id) {
+        return productDao.findOne(id);
+    }
+
+    /**
+     * 根据id字符串获取物料列表  (1,2,3,4...)
+     *
+     * @param ids
+     * @return
+     */
+    @Override
+    public List<Product> findByIds(String ids) {
+        String[] idArray = ids.split(",");
+        Set<Long> idSet = new HashSet<>();
+        for (String id : idArray) {
+            if (!StringUtils.isEmpty(id)) {
+                idSet.add(Long.valueOf(id));
+            }
+        }
+        return productDao.findAll(idSet);
+    }
+
+    /**
+     * 根据enUU 和物料编号list 批量获取物料信息
+     *
+     * @param enUU  企业UU
+     * @param codes 物料编号List
+     * @return
+     */
+    @Override
+    public List<Product> findByEnUUAndCodes(Long enUU, List<String> codes) {
+        Set<String> codeSet = new HashSet<>(codes);
+        return productDao.findByEnUUAndCodeSet(enUU, codeSet);
+    }
+
+    /**
+     * 通过uu和名称判断物料是否存在(新增采购导入时需用到)
+     * 数量大时,速度会很慢  2018年7月11日 15:19:03  dongbw
+     *
+     * @param enUU  企业UU
+     * @param title 物料名称
+     * @return
+     */
+    @Override
+    public List<Product> findByEnUUAndTitle(Long enUU, String title) {
+        return productDao.findByEnUUAndTitle(enUU, title);
+    }
+
+    /**
+     * 通过品牌和enuu查询所有信息
+     * 数量大时,速度会很慢  2018年7月11日 15:18:43  dongbw
+     *
+     * @param enUU   企业UU
+     * @param brand  品牌
+     * @param isSale 是否可销售(1可 0 不可)
+     * @return 物料信息
+     */
+    @Override
+    public List<Product> findByEnUUAndBrandAndIsSale(Long enUU, String brand, Short isSale) {
+        return productDao.findByEnUUAndBrandAndIsSale(enUU, brand, isSale);
+    }
+
+    /**
+     * 通过品牌和enuu查询所有信息
+     *
+     * @param enUU  企业UU
+     * @param brand 品牌
+     * @return 物料信息
+     */
+    @Override
+    public List<Product> findByEnUUAndBrand(Long enUU, String brand) {
+        return productDao.findByEnUUAndBrand(enUU, brand);
+    }
+
+    /**
+     * 通过品牌和enuu查询所有信息
+     *
+     * @param enuu   企业UU
+     * @param brand  品牌
+     * @param isPurc 是否待采购
+     * @return 物料信息
+     */
+    @Override
+    public List<Product> findByEnUUAndBrandAndIsPurchase(Long enuu, String brand, Short isPurc) {
+        return productDao.findByEnUUAndBrandAndIsPurchase(enuu, brand, isPurc);
+    }
+
+    /**
+     * 通过名称查询物料信息
+     *
+     * @param enUU   企业UU
+     * @param title  物料名称
+     * @param isSale 是否待销售
+     * @return 物料信息
+     */
+    @Override
+    public List<Product> findByEnUUAndTitleAndIsSale(Long enUU, String title, Short isSale) {
+        return productDao.findByEnUUAndTitleAndIsSale(enUU, title, isSale);
+    }
+
+    /**
+     * 通过名称查询物料信息
+     *
+     * @param enUU   企业UU
+     * @param title  物料名称
+     * @param isPurc 是否待采购
+     * @return 物料信息
+     */
+    @Override
+    public List<Product> findByEnUUAndTitleAndIsPurchase(Long enUU, String title, Short isPurc) {
+        return productDao.findByEnUUAndTitleAndIsPurchase(enUU, title, isPurc);
+    }
+
+    /**
+     * 通过企业UU号查询物料上传数量
+     *
+     * @param enUU 企业UU
+     * @return
+     */
+    @Override
+    public Long countByEnUU(Long enUU) {
+        return productDao.countByEnUU(enUU);
+    }
+
     /**
      * 更新物料信息
      * @param data 物料资料