lmx před 5 dny
rodič
revize
d8bc137186

+ 12 - 0
fs-admin/src/main/java/com/fs/his/controller/HzOMSErpApiController.java

@@ -117,4 +117,16 @@ public class HzOMSErpApiController {
 //        hzOMSErpResponseVO.setSuccess(true);
 //        return hzOMSErpResponseVO;
 //    }
+
+    /**
+     * 推送商品到瀚智OMS
+     * @return
+     */
+    @PostMapping("/test/syncShop")
+    public HzOMSErpResponseVO syncShop(){
+        hzOMSErpApiService.syncShop();
+        HzOMSErpResponseVO hzOMSErpResponseVO = new HzOMSErpResponseVO();
+        hzOMSErpResponseVO.setSuccess(true);
+        return hzOMSErpResponseVO;
+    }
 }

+ 9 - 4
fs-service/src/main/java/com/fs/erp/service/impl/HzOMSErpGoodsServiceImpl.java

@@ -46,13 +46,18 @@ public class HzOMSErpGoodsServiceImpl implements IErpGoodsService {
 
     @Override
     public BaseResponse addGoods(ErpGoods goods) {
-
+        BaseResponse res = new BaseResponse();
+        res.setSuccess( true);
         Long storeProductId = goods.getStoreProductId();
         JSONObject hzGoods = buildGoods(storeProductId);
+        try{
+            hzOMSClient.send("oms_open_ptshopgoods_sync", hzGoods);
+        }catch (Exception e){
+            res.setSuccess(false);
+        }
 
-        hzOMSClient.send("oms_open_ptshopgoods_sync", hzGoods);
 
-        return null;
+        return res;
     }
 
     @Override
@@ -96,7 +101,7 @@ public class HzOMSErpGoodsServiceImpl implements IErpGoodsService {
 //        goods.put("cptgroupid", );
         //平台分类名称 f
 //        goods.put("cptgroupname", );
-        goods.put("cptgoodsid", fsStoreProduct.getProductId());
+//        goods.put("cptgoodsid", fsStoreProduct.getProductId());
 
         //商品规格
         JSONArray attrList = new JSONArray();

+ 2 - 1
fs-service/src/main/java/com/fs/his/mapper/FsStoreProductMapper.java

@@ -258,5 +258,6 @@ public interface FsStoreProductMapper {
     @Update({"UPDATE fs_store_product SET stock=#{stock}  WHERE product_id = #{productId} "})
     int updateStoreProductStock(@Param("productId") Long productId, @Param("stock") Integer stock);
 
-
+    @Select("select product_id from fs_store_product ")
+    List<FsStoreProduct> getAllProduct();
 }

+ 30 - 0
fs-service/src/main/java/com/fs/his/service/impl/HzOMSErpApiServiceImpl.java

@@ -3,11 +3,15 @@ package com.fs.his.service.impl;
 import cn.hutool.core.codec.Base64Decoder;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.fs.erp.domain.ErpGoods;
+import com.fs.erp.dto.BaseResponse;
 import com.fs.erp.dto.sdk.HzOMS.utils.HzOMSUtils;
+import com.fs.erp.service.IErpGoodsService;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.FsStoreOrder;
 import com.fs.his.domain.FsStoreProduct;
 import com.fs.his.domain.FsStoreProductAttrValue;
+import com.fs.his.mapper.FsStoreProductMapper;
 import com.fs.his.param.HzOMSErpApiParam;
 import com.fs.his.service.ErpApiService;
 import com.fs.his.service.IFsStoreOrderService;
@@ -18,6 +22,7 @@ import com.fs.his.vo.HzOMSErpResponseDetailVO;
 import com.fs.his.vo.HzOMSErpResponseErrorItemVO;
 import com.fs.his.vo.HzOMSErpResponseVO;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 import org.springframework.util.Base64Utils;
 
@@ -90,6 +95,7 @@ public class HzOMSErpApiServiceImpl implements ErpApiService {
 
     /**
      * 用于将瀚智商品库存同步到第三方
+     *
      * @param param
      * @return
      */
@@ -235,4 +241,28 @@ public class HzOMSErpApiServiceImpl implements ErpApiService {
         JSONArray arr = JSONArray.parseArray(new String(Base64Utils.decode(s.getBytes(StandardCharsets.UTF_8))));
         return arr;
     }
+
+
+    @Autowired
+    FsStoreProductMapper fsStoreProductMapper;
+
+    @Autowired
+    @Qualifier("hzOMSErpGoodsServiceImpl")
+    IErpGoodsService hzGoodsService;
+    /**
+     * 同步药品信息到瀚智ERP
+     */
+    @Override
+    public void syncShop() {
+        //获取所有商品
+        List<FsStoreProduct> allProduct = fsStoreProductMapper.getAllProduct();
+        System.out.println("总共待推送商品数量:" + allProduct.size());
+        Integer i = 1;
+        for (FsStoreProduct fsStoreProduct : allProduct) {
+            ErpGoods p = new ErpGoods();
+            p.setStoreProductId(fsStoreProduct.getProductId());
+            hzGoodsService.addGoods(p);
+            System.out.println("当前同步第" + i++ + " 条数据,数据id:" + fsStoreProduct.getProductId());
+        }
+    }
 }