Browse Source

Merge branch 'feature/eccs-upgrade' of lvjian/eccs into feature/eccs-upgrade

吕健 2 years ago
parent
commit
0020473e37

+ 1 - 0
build.gradle

@@ -173,6 +173,7 @@ subprojects {
         bitwalker_agent = '1.21'
         jsonwebtoken = '0.9.1'
 
+        hutool = '5.8.16'
     }
 }
 

+ 1 - 0
eccs-biz/build.gradle

@@ -33,6 +33,7 @@ dependencies {
     implementation "io.springfox:springfox-swagger2:${swagger}"
     implementation "io.springfox:springfox-swagger-ui:${swagger}"
 
+    implementation "cn.hutool:hutool-all:${hutool}"
 }
 
 test {

+ 5 - 3
eccs-biz/src/main/java/com/emato/biz/controller/warehouse/OWbInveMngController.java

@@ -2,6 +2,7 @@ package com.emato.biz.controller.warehouse;
 
 import java.util.List;
 
+import com.emato.biz.domain.warehouse.PullInveQueryVO;
 import com.emato.common.core.domain.entity.SysDept;
 import com.emato.common.core.domain.entity.SysUser;
 import com.emato.common.core.domain.model.LoginUser;
@@ -114,9 +115,9 @@ public class OWbInveMngController extends BaseController
 
     @PreAuthorize("@ss.hasPermi('biz:invemng:pull')")
     @PostMapping("/pullInveMng")
-    public AjaxResult pullInveMng()
+    public AjaxResult pullInveMng(PullInveQueryVO queryVO)
     {
-
+        logger.debug("前端请求参数 => {}", queryVO);
         // 获取当前的用户
         LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
         SysUser user = loginUser.getUser();
@@ -124,8 +125,9 @@ public class OWbInveMngController extends BaseController
         SysDept sysDept = sysDeptService.selectDeptById(user.getDeptId());
         // 获取当前商户号
         String merchSn = sysDept.getMerchSn();
+        queryVO.setMerchId(merchSn);
 
-        return toAjax(oWbInveMngService.pullInveMng(merchSn));
+        return oWbInveMngService.pullInveMng(queryVO);
     }
 
 }

+ 91 - 0
eccs-biz/src/main/java/com/emato/biz/domain/warehouse/PullInveQueryVO.java

@@ -0,0 +1,91 @@
+package com.emato.biz.domain.warehouse;
+
+import com.emato.biz.config.OmsConfig;
+
+/**
+ * 拉取库存 VO
+ *
+ * @author frankeleyn
+ * @email lvjian@qhdswl.com
+ * @date 2023/4/18 11:22
+ */
+public class PullInveQueryVO {
+
+    /**
+     * 商户号
+     */
+    private String merchId;
+
+    /**
+     * 第三方商户编号
+     */
+    private String thirdMerchId;
+
+    /**
+     * sku
+     */
+    private String sku;
+
+    /**
+     * 页
+     */
+    private Integer page = 1;
+
+    /**
+     * 页数
+     */
+    private Integer limit = 3;
+
+    @Override
+    public String toString() {
+        return "PullInveQueryVO{" +
+                "merchId='" + merchId + '\'' +
+                ", thirdMerchId='" + thirdMerchId + '\'' +
+                ", sku='" + sku + '\'' +
+                ", page=" + page +
+                ", limit=" + limit +
+                '}';
+    }
+
+    public String getThirdMerchId() {
+        return thirdMerchId;
+    }
+
+    public void setThirdMerchId(String thirdMerchId) {
+        this.thirdMerchId = thirdMerchId;
+    }
+
+    public String getMerchId() {
+        return merchId;
+    }
+
+    public void setMerchId(String merchId) {
+        this.merchId = merchId;
+    }
+
+    public String getSku() {
+        return sku;
+    }
+
+    public void setSku(String sku) {
+        this.sku = sku;
+    }
+
+    public Integer getPage() {
+        return page;
+    }
+
+    public void setPage(Integer page) {
+        this.page = page;
+    }
+
+    public Integer getLimit() {
+        return limit;
+    }
+
+    public void setLimit(Integer limit) {
+        this.limit = limit;
+    }
+
+
+}

+ 61 - 10
eccs-biz/src/main/java/com/emato/biz/service/impl/OWbInveMngServiceImpl.java

@@ -3,12 +3,18 @@ package com.emato.biz.service.impl;
 import java.io.IOException;
 import java.util.*;
 
+import cn.hutool.http.HttpException;
+import cn.hutool.http.HttpRequest;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.emato.biz.config.OmsConfig;
+import com.emato.biz.domain.warehouse.PullInveQueryVO;
 import com.emato.biz.mapper.warehouse.WbInveMngMapper;
+import com.emato.common.core.domain.AjaxResult;
+import com.emato.common.exception.ServiceException;
 import com.emato.common.utils.DateUtils;
+import com.emato.common.utils.oms.JacksonUtils;
 import com.emato.common.utils.oms.OkHttpUtils;
 import com.emato.common.utils.oms.request.OmsSign;
 import okhttp3.Request;
@@ -39,16 +45,62 @@ import javax.annotation.Resource;
 @Service
 public class OWbInveMngServiceImpl implements IOWbInveMngService
 {
-    @Autowired
+    @Resource
     private OWbInveMngMapper oWbInveMngMapper;
 
     @Resource
     private WbInveMngMapper wbInveMngMapper;
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(OWbInveMngServiceImpl.class);
+    private static final Logger log = LoggerFactory.getLogger(OWbInveMngServiceImpl.class);
+
 
+    /**
+     * 根据条件拉取 OMS 数据
+     *
+     * @param queryVO
+     * @return
+     */
+    @Override
+    public AjaxResult pullInveMng(PullInveQueryVO queryVO) {
+        // 构建请求报文
+        // 初始化请求 oms 参数 Map
+        Map<String, String> reqOmsPram = new TreeMap<>();
+        queryVO.setThirdMerchId("tmb770630141444423680");
+        // 请求 oms 数据
+        reqOmsPram.put("data", JacksonUtils.toJsonStr(queryVO));
+        // 请求 oms 商户号
+        reqOmsPram.put("merchId", OmsConfig.getMerchSn());
+        log.debug("===== 请求 oms 商户号 ====> {}", OmsConfig.getMerchSn());
+        // 请求 oms 时间戳
+        String timestamp = System.currentTimeMillis()/1000 + "";
+        reqOmsPram.put("timestamp", timestamp);
+        log.debug("===== 请求 oms 时间戳 ====> {}", timestamp);
+        // 请求 oms 签名
+        String sign = OmsSign.sign(reqOmsPram, OmsConfig.getMd5Salt());
+        reqOmsPram.put("sign", sign);
+        // oms 请求地址
+        String url = OmsConfig.getQueryMngInveUrl();
+        log.debug("===== 请求 oms 地址 ====> {}", url);
+        // 请求 oms 报文
+        String reqBody = JacksonUtils.toJsonStr(reqOmsPram);
+        log.debug("===== 请求 oms 报文 ====> {}", reqBody);
+
+        // oms 返回数据
+        String body = null;
+        try {
+            body = HttpRequest.post(url)
+                    .body(JacksonUtils.toJsonStr(reqOmsPram))
+                    .execute()
+                    .body();
+        } catch (Exception e) {
+            throw new ServiceException("请求 OMS 异常!");
+        }
+        log.debug("OMS 响应信息 => {}", body);
 
 
+        // 获取响应,入库
+        return AjaxResult.success("拉取库存成功!");
+    }
 
     /**
      * 查询库存管理,wms入库回传时,增加库存数
@@ -157,20 +209,20 @@ public class OWbInveMngServiceImpl implements IOWbInveMngService
         String timestamp = String.valueOf(System.currentTimeMillis()/1000);
         sParaTemp.put("timestamp", timestamp);
         //生成要请求给oms秘钥
-        LOGGER.info("md5混淆码参数:" + OmsConfig.getMd5Salt());
+        log.info("md5混淆码参数:" + OmsConfig.getMd5Salt());
         String sign = OmsSign.sign(sParaTemp,OmsConfig.getMd5Salt());
         sParaTemp.put("sign", sign);
         //构建Request
         String  url = OmsConfig.getQueryMngInveUrl();
         String jsonParam = JSONObject.toJSONString(sParaTemp);
-        Request request = OkHttpUtils.buildRequest(jsonParam,url,"");
-        LOGGER.info("oms的请求报文:" + request);
+        log.info("Eccs 请求 OMS url => {}, 请求 OMS 报文 => {}", url, jsonParam);
+
         // 同步访问,返回结果字符串
         String responseString = null;
         try {
             JSONObject jsonObject = httpPost(url,JSONObject.parseObject(jsonParam));
 
-            LOGGER.info("oms的响应报文"+jsonObject.toString());
+            log.info("oms的响应报文"+jsonObject.toString());
 
             //解析响应数据
             JSONArray result = (JSONArray) jsonObject.get("data");
@@ -195,8 +247,7 @@ public class OWbInveMngServiceImpl implements IOWbInveMngService
             }
 
         } catch (Exception e) {
-            e.printStackTrace();
-            LOGGER.error(e.getMessage());
+            log.error(e.getMessage());
             return 1;
         }
 
@@ -237,13 +288,13 @@ public class OWbInveMngServiceImpl implements IOWbInveMngService
                 }
                 catch (Exception e)
                 {
-                    LOGGER.error("post请求提交失败:" + url, e);
+                    log.error("post请求提交失败:" + url, e);
                 }
             }
         }
         catch (IOException e)
         {
-            LOGGER.error("post请求提交失败:" + url, e);
+            log.error("post请求提交失败:" + url, e);
         }
         finally
         {

+ 11 - 0
eccs-biz/src/main/java/com/emato/biz/service/warehouse/IOWbInveMngService.java

@@ -2,6 +2,8 @@ package com.emato.biz.service.warehouse;
 
 import java.util.List;
 import com.emato.biz.domain.warehouse.OWbInveMng;
+import com.emato.biz.domain.warehouse.PullInveQueryVO;
+import com.emato.common.core.domain.AjaxResult;
 
 /**
  * 库存管理,wms入库回传时,增加库存数Service接口
@@ -11,6 +13,15 @@ import com.emato.biz.domain.warehouse.OWbInveMng;
  */
 public interface IOWbInveMngService
 {
+
+    /**
+     * 根据条件拉取 OMS 数据
+     *
+     * @param queryVO
+     * @return
+     */
+    AjaxResult pullInveMng(PullInveQueryVO queryVO);
+
     /**
      * 查询库存管理,wms入库回传时,增加库存数
      *

+ 40 - 39
eccs-biz/src/main/resources/oms-config.yml

@@ -14,61 +14,62 @@ oms:
 
 
   #==================== 开发环境 ws.ds-bay.com ====================
-#  # 查询商户信息接口
-#  queryMerchantInfoUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryMerchantInfoUrl
-#  # 查询第三方商户信息接口
-#  queryThirdMerchantInfoUrl:
-#  # 查询库存接口
-#  queryMngInveUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryInveMng
-#  # 查询门店库存接口
-#  queryShopMngInveUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryShopInveMng
-#  # 查询入库单接口
-#  queryInveReceiptUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryInveReceiptGoods
-#  # 查询入库单明细接口
-#  queryInveReceiptDetailUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryInveReceiptGoods
-#  # 查询结转接口
-#  queryAdjustmentUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryAdjustmentRecord
-#  # 查询结转明细接口
-#  queryAdjustmentDetailUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryAdjustmentDetail
-#  # 查询出区接口
-#  queryInveShipmentUrl:
-#  # 查询出区明细接口
-#  queryInveShipmentDetailUrl:
-#  # 查询门店进货接口
-#  queryShopInUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryShopIn
-#  # 查询门店出场接口
-#  queryShopOutUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryShopOut
-#  # 查询门店转移接口
-#  queryShopMoveUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryShopMove
-
-#
-#  #==================== 测试环境 ws.ds-bay.com ====================
   # 查询商户信息接口
-  queryMerchantInfoUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryMerchantInfoUrl
+  queryMerchantInfoUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryMerchantInfoUrl
   # 查询第三方商户信息接口
   queryThirdMerchantInfoUrl:
   # 查询库存接口
-  queryMngInveUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryInveMng
+  #queryMngInveUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryInveMng
+  queryMngInveUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryWbInve
   # 查询门店库存接口
-  queryShopMngInveUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryShopInveMng
+  queryShopMngInveUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryShopInveMng
   # 查询入库单接口
-  queryInveReceiptUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryInveReceiptGoods
+  queryInveReceiptUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryInveReceiptGoods
   # 查询入库单明细接口
-  queryInveReceiptDetailUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryInveReceiptGoods
+  queryInveReceiptDetailUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryInveReceiptGoods
   # 查询结转接口
-  queryAdjustmentUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryAdjustmentRecord
+  queryAdjustmentUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryAdjustmentRecord
   # 查询结转明细接口
-  queryAdjustmentDetailUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryAdjustmentDetail
+  queryAdjustmentDetailUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryAdjustmentDetail
   # 查询出区接口
   queryInveShipmentUrl:
   # 查询出区明细接口
   queryInveShipmentDetailUrl:
   # 查询门店进货接口
-  queryShopInUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryShopIn
+  queryShopInUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryShopIn
   # 查询门店出场接口
-  queryShopOutUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryShopOut
+  queryShopOutUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryShopOut
   # 查询门店转移接口
-  queryShopMoveUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryShopMove
+  queryShopMoveUrl: http://127.0.0.1:8086/al/queryOmsInfo/queryShopMove
+
+
+#  #==================== 测试环境 ws.ds-bay.com ====================
+#  # 查询商户信息接口
+#  queryMerchantInfoUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryMerchantInfoUrl
+#  # 查询第三方商户信息接口
+#  queryThirdMerchantInfoUrl:
+#  # 查询库存接口
+#  queryMngInveUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryInveMng
+#  # 查询门店库存接口
+#  queryShopMngInveUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryShopInveMng
+#  # 查询入库单接口
+#  queryInveReceiptUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryInveReceiptGoods
+#  # 查询入库单明细接口
+#  queryInveReceiptDetailUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryInveReceiptGoods
+#  # 查询结转接口
+#  queryAdjustmentUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryAdjustmentRecord
+#  # 查询结转明细接口
+#  queryAdjustmentDetailUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryAdjustmentDetail
+#  # 查询出区接口
+#  queryInveShipmentUrl:
+#  # 查询出区明细接口
+#  queryInveShipmentDetailUrl:
+#  # 查询门店进货接口
+#  queryShopInUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryShopIn
+#  # 查询门店出场接口
+#  queryShopOutUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryShopOut
+#  # 查询门店转移接口
+#  queryShopMoveUrl: http://183.3.221.143:8086/al/queryOmsInfo/queryShopMove
 
 
 #  #==================== 生产环境 ws.ds-bay.com ====================

+ 2 - 6
eccs-ui/src/api/warehouse/invemng.js

@@ -52,17 +52,13 @@ export function exportInvemng(query) {
   })
 }
 
-// 导出库存管理,wms入库回传时,增加库存数
-export function pullInvemng(query,_this) {
+// 拉取库存
+export function pullInvemng(query) {
   return request({
     url: '/biz/invemng/pullInveMng',
     method: 'post',
     params: query,
     timeout: 3600 * 1000,
     loading: document.body
-  }).then(function (response) {
-    _this.$alert("拉取成功...");
-  }).catch(function () {
-    _this.$alert("拉取异常...");
   })
 }

+ 1 - 1
eccs-ui/src/views/mall/mallinvemng/index.vue

@@ -137,7 +137,7 @@
       </el-table-column>
       <el-table-column label="库存状态" align="center" prop="inveStatus" />
       <el-table-column label="海关代码" align="center" prop="cusCode" />-->
-      <el-table-column label="库存数" align="center" prop="inveNum" />
+      <!-- <el-table-column label="库存数" align="center" prop="inveNum" /> -->
       <!-- <el-table-column label="可用数" align="center" prop="validNum" />
       <el-table-column label="下单冻结数" align="center" prop="freezeNum" /> -->
       <!--<el-table-column label="进货数" align="center" prop="imWareNum" />

+ 66 - 5
eccs-ui/src/views/warehouse/invemng/index.vue

@@ -117,7 +117,7 @@
           type="warning"
           icon="el-icon-download"
           size="mini"
-          @click="handlePull"
+          @click="openPullDialog"
           v-hasPermi="['biz:invemng:pull']"
         >拉取</el-button>
       </el-col>
@@ -238,6 +238,26 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+
+    <!-- 拉取 dialog -->
+    <el-dialog title="拉取库存" :visible.sync="pullDialog" width="500px" append-to-body>
+      <el-form ref="pullForm" :model="pullForm" :rules="rules" label-width="80px">
+
+        <el-form-item label="商户编号" prop="merchId">
+          <el-input v-model="pullForm.merchId" placeholder="请输入商户编号" />
+        </el-form-item>
+
+        <el-form-item label="SKU" prop="sku">
+          <el-input v-model="pullForm.sku" placeholder="请输入SKU" />
+        </el-form-item>
+
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="handlePull">确 定</el-button>
+        <el-button @click="closePullDialog">取 消</el-button>
+      </div>
+    </el-dialog>
+
   </div>
 </template>
 
@@ -250,6 +270,10 @@ export default {
   },
   data() {
     return {
+      // 拉取表单
+      pullForm: {},
+      // 拉取数据弹框
+      pullDialog: false,
       // 遮罩层
       loading: true,
       // 选中数组
@@ -316,6 +340,30 @@ export default {
     });
   },
   methods: {
+    /**
+     * 打开拉取库存对话框
+     */
+    openPullDialog() {
+      this.resetPullForm();
+      this.pullDialog = true;
+    },
+    /**
+     * 关闭拉取库存对话框
+     */
+    closePullDialog() {
+      this.pullDialog = false;
+      this.resetPullForm();
+    },
+    /**
+     * 清除表单数据
+     */
+    resetPullForm() {
+      this.pullForm = {
+        merchId: null,
+        sku: null
+      };
+      this.resetForm("pullForm");
+    },
     /** 查询库存管理,wms入库回传时,增加库存数列表 */
     getList() {
       this.loading = true;
@@ -345,11 +393,13 @@ export default {
     isValidFormat(row, column) {
       return this.selectDictLabel(this.isValidOptions, row.isValid);
     },
+
     // 取消按钮
     cancel() {
       this.open = false;
       this.reset();
     },
+    
     // 表单重置
     reset() {
       this.form = {
@@ -465,15 +515,26 @@ export default {
     },
     /** 拉取按钮操作 */
     handlePull() {
-      const queryParams = this.queryParams;
+      const queryParams = this.pullForm;
+      console.log("传入的拉取参数 => ", queryParams);
       // 添加遮罩
-      const _this=this
-      this.$confirm('是否确认拉取保税仓所有库存?', "警告", {
+      const _this = this;
+      let that = this;
+      this.$confirm('是否确认拉取仓库库存?', "警告", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning"
       }).then(function() {
-        return pullInvemng(queryParams,_this);
+        return pullInvemng(queryParams).then(res => {
+          // 关闭弹出框
+          that.closePullDialog();
+          _this.$alert("拉取库存成功...");
+        }).catch(err => {
+          // 关闭弹出框
+          that.closePullDialog();
+          _this.$alert("拉取库存异常...");
+        })
+
       }).then(function(){
         _this.handleQuery();
       })