فهرست منبع

一键/单个 开启/关闭 采购/销售 状态接口添加同步到B2B完成才返回请求

dongbw 7 سال پیش
والد
کامیت
f89352ebbe

+ 11 - 2
src/main/java/com/uas/ps/product/controller/ProductController.java

@@ -311,8 +311,13 @@ public class ProductController {
     @ResponseBody
     public void switchProductByEnUU(@RequestParam("enUU") Long enUU,
                               @RequestParam("switchType") String switchType,
-                              @RequestParam("switchStatus") Integer switchStatus) {
+                              @RequestParam("switchStatus") Short switchStatus) {
+        Integer size = productService.getCountByEnUU(enUU);
+        String batchCode = UUID.randomUUID().toString().replace("-", "");
+        productDao.setSessionVariable("B2B", batchCode, size);
         productService.switchProductByEnuuAndTypeAndStatus(enUU, switchType, switchStatus);
+        productDao.unsetSessionVariable();
+        consumer.waitResponse(batchCode);
     }
 
     /**
@@ -326,7 +331,11 @@ public class ProductController {
     @ResponseBody
     public void switchProductById(@RequestParam("id") Long id,
                               @RequestParam("switchType") String switchType,
-                              @RequestParam("switchStatus") Integer switchStatus) {
+                              @RequestParam("switchStatus") Short switchStatus) {
+        String batchCode = UUID.randomUUID().toString().replace("-", "");
+        productDao.setSessionVariable("B2B", batchCode, 1);
         productService.switchProductByIdAndTypeAndStatus(id, switchType, switchStatus);
+        productDao.unsetSessionVariable();
+        consumer.waitResponse(batchCode);
     }
 }

+ 11 - 4
src/main/java/com/uas/ps/product/repository/ProductDao.java

@@ -109,7 +109,7 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
     @Transactional
     @Modifying
     @Query("update Product p set p.isSale = :switchStatus where p.enUU = :enUU")
-    void updateSaleStatusByEnUU(@Param("enUU") Long enUU, @Param("switchStatus") Integer switchStatus);
+    void updateSaleStatusByEnUU(@Param("enUU") Long enUU, @Param("switchStatus") Short switchStatus);
 
     /**
      * 更新采购状态(企业)
@@ -118,7 +118,7 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
     @Transactional
     @Modifying
     @Query("update Product p set p.isPurchase = :switchStatus where p.enUU = :enUU")
-    void updatePurchaseStatusByEnUU(@Param("enUU") Long enUU, @Param("switchStatus") Integer switchStatus);
+    void updatePurchaseStatusByEnUU(@Param("enUU") Long enUU, @Param("switchStatus") Short switchStatus);
 
     /**
      * 更新销售状态(单个)
@@ -127,7 +127,7 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
     @Transactional
     @Modifying
     @Query("update Product p set p.isSale = :switchStatus where p.id = :id")
-    void updateSaleStatusById(@Param("id") Long id, @Param("switchStatus") Integer switchStatus);
+    void updateSaleStatusById(@Param("id") Long id, @Param("switchStatus") Short switchStatus);
 
 
     /**
@@ -137,7 +137,7 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
     @Transactional
     @Modifying
     @Query("update Product p set p.isPurchase = :switchStatus where p.id = :id")
-    void updatePurchaseStatusById(@Param("id") Long id, @Param("switchStatus") Integer switchStatus);
+    void updatePurchaseStatusById(@Param("id") Long id, @Param("switchStatus") Short switchStatus);
 
     /**
      * 设置 session 变量
@@ -151,6 +151,13 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
     @Procedure(procedureName = "sync$unset_session_variable")
     void unsetSessionVariable();
 
+    /**
+     * 根据企业UU获取该企业物料
+     * @param enUU 企业UU
+     * @return
+     */
+    List<Product> findByEnUU(Long enUU);
+
 //    /**
 //     * 通过uu查询非标准器件进行存储
 //     *

+ 9 - 2
src/main/java/com/uas/ps/product/service/ProductService.java

@@ -149,7 +149,7 @@ public interface ProductService {
      * @param switchType 开关类型 purc or sale
      * @param switchStatus 开关状态 1 or 0
      */
-    void switchProductByEnuuAndTypeAndStatus(Long enUU, String switchType, Integer switchStatus);
+    void switchProductByEnuuAndTypeAndStatus(Long enUU, String switchType, Short switchStatus);
 
     /**
      * 根据物料id 开关状态,开关类型一键操作
@@ -157,7 +157,7 @@ public interface ProductService {
      * @param switchType 开关类型 purc or sale
      * @param switchStatus 开关状态 1 or 0
      */
-    void switchProductByIdAndTypeAndStatus(Long id, String switchType, Integer switchStatus);
+    void switchProductByIdAndTypeAndStatus(Long id, String switchType, Short switchStatus);
 
     /**
      * 保存/更新B2B物料资料
@@ -165,4 +165,11 @@ public interface ProductService {
      * @return
      */
     List<Product> updateB2bProdInfo(List<Product> productInfo);
+
+    /**
+     * 根据企业uu获取当前企业物料数量
+     * @param enUU 企业UU
+     * @return 当前企业物料数量
+     */
+    Integer getCountByEnUU(Long enUU);
 }

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

@@ -170,7 +170,7 @@ public class ProductServiceImpl implements ProductService {
      * @param switchStatus 开关状态 1 or 0
      */
     @Override
-    public void switchProductByEnuuAndTypeAndStatus(Long enUU, String switchType, Integer switchStatus) {
+    public void switchProductByEnuuAndTypeAndStatus(Long enUU, String switchType, Short switchStatus) {
         if ("sale".equals(switchType)) {
             productDao.updateSaleStatusByEnUU(enUU, switchStatus);
         } else if ("purc".equals(switchType)) {
@@ -186,7 +186,7 @@ public class ProductServiceImpl implements ProductService {
      * @param switchStatus 开关状态 1 or 0
      */
     @Override
-    public void switchProductByIdAndTypeAndStatus(Long id, String switchType, Integer switchStatus) {
+    public void switchProductByIdAndTypeAndStatus(Long id, String switchType, Short switchStatus) {
         if ("sale".equals(switchType)) {
             productDao.updateSaleStatusById(id, switchStatus);
         } else if ("purc".equals(switchType)) {
@@ -219,6 +219,17 @@ public class ProductServiceImpl implements ProductService {
         }
     }
 
+    /**
+     * 根据企业uu获取当前企业物料数量
+     *
+     * @param enUU 企业UU
+     * @return 当前企业物料数量
+     */
+    @Override
+    public Integer getCountByEnUU(Long enUU) {
+        return productDao.findByEnUU(enUU).size();
+    }
+
     /**
      * 单个物料匹配
      * @param   product