|
@@ -2,6 +2,11 @@ package com.kmall.admin.controller.kmall2oms;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
|
+import com.kmall.admin.dto.TransferGoodsDto;
|
|
|
|
+import com.kmall.admin.entity.StoreTransferInventoryOrderDetailEntity;
|
|
|
|
+import com.kmall.admin.entity.StoreTransferInventoryOrderEntity;
|
|
|
|
+import com.kmall.admin.service.StoreTransferInventoryOrderDetailService;
|
|
|
|
+import com.kmall.admin.service.StoreTransferInventoryOrderService;
|
|
import com.kmall.admin.utils.data.response.ResponseMessage;
|
|
import com.kmall.admin.utils.data.response.ResponseMessage;
|
|
import com.kmall.admin.utils.oms.OmsSign;
|
|
import com.kmall.admin.utils.oms.OmsSign;
|
|
import com.kmall.common.utils.R;
|
|
import com.kmall.common.utils.R;
|
|
@@ -11,6 +16,7 @@ import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
@@ -32,34 +38,53 @@ public class KtoOmsController {
|
|
@Autowired
|
|
@Autowired
|
|
private OmsMerchProperties omsMerchProperties;
|
|
private OmsMerchProperties omsMerchProperties;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private StoreTransferInventoryOrderService storeTransferInventoryOrderService ;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private StoreTransferInventoryOrderDetailService storeTransferInventoryOrderDetailService;
|
|
|
|
+
|
|
|
|
+ @RequestMapping("sendTransfer/{transferId}")
|
|
|
|
+ public R sendToTransferOrder(@PathVariable("transferId") Integer transferId){
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
- @RequestMapping("sendTransfer")
|
|
|
|
- public R sendToTransferOrder(Integer transferId){
|
|
|
|
|
|
|
|
// 查询转移单记录与明细
|
|
// 查询转移单记录与明细
|
|
- // TODO queryById(transferId)
|
|
|
|
- // TODO queryDetailByTransferId(transferId)
|
|
|
|
- List detailList = new ArrayList<>();
|
|
|
|
|
|
+ // queryById(transferId)
|
|
|
|
+ StoreTransferInventoryOrderEntity storeTransferInventoryOrderEntity = storeTransferInventoryOrderService.queryObject(transferId);
|
|
|
|
+ if(storeTransferInventoryOrderEntity == null){
|
|
|
|
+ return R.error("未找到该转移单");
|
|
|
|
+ }
|
|
|
|
+ Integer status = storeTransferInventoryOrderEntity.getStatus();
|
|
|
|
+ if(status != 0 && status != 2 ){
|
|
|
|
+ return R.error("该转移单不允许推送");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // queryDetailByTransferId(transferId)
|
|
|
|
+ List<Map> transferGoodsDto = storeTransferInventoryOrderDetailService.queryDtoById(transferId);
|
|
|
|
+
|
|
|
|
+ storeTransferInventoryOrderEntity.setStatus(3);
|
|
|
|
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
|
|
+ String timestamp = String.valueOf(System.currentTimeMillis()/1000);
|
|
|
|
|
|
Map<String, String> sParaTemp = new TreeMap<>();
|
|
Map<String, String> sParaTemp = new TreeMap<>();
|
|
// 构建request中的data数据
|
|
// 构建request中的data数据
|
|
- Map<String,String> dataParam = new HashMap<>();
|
|
|
|
- dataParam.put("merchId","");
|
|
|
|
- dataParam.put("merchName","");
|
|
|
|
- dataParam.put("thirdPartyMerchCode","");
|
|
|
|
- dataParam.put("thirdPartyMerchName","");
|
|
|
|
- dataParam.put("merchTransDocSn","");
|
|
|
|
- dataParam.put("rollOutShopId","");
|
|
|
|
- dataParam.put("rollInShopId","");
|
|
|
|
- dataParam.put("billTime","");
|
|
|
|
- dataParam.put("item",gson.toJson(detailList));
|
|
|
|
|
|
+ Map<String,Object> dataParam = new HashMap<>();
|
|
|
|
+ dataParam.put("merchId",storeTransferInventoryOrderEntity.getMerchSn());
|
|
|
|
+ dataParam.put("merchName",storeTransferInventoryOrderEntity.getMerchName());
|
|
|
|
+// dataParam.put("thirdPartyMerchCode","");
|
|
|
|
+// dataParam.put("thirdPartyMerchName","");
|
|
|
|
+ dataParam.put("merchTransDocSn",transferId+"");
|
|
|
|
+ dataParam.put("rollOutShopId",storeTransferInventoryOrderEntity.getOutStoreSn());
|
|
|
|
+ dataParam.put("rollInShopId",storeTransferInventoryOrderEntity.getInStoreSn());
|
|
|
|
+ dataParam.put("billTime",timestamp);
|
|
|
|
+ dataParam.put("item",transferGoodsDto);
|
|
|
|
|
|
|
|
|
|
sParaTemp.put("data",gson.toJson(dataParam));
|
|
sParaTemp.put("data",gson.toJson(dataParam));
|
|
sParaTemp.put("merchId",omsMerchProperties.getMerchSn());
|
|
sParaTemp.put("merchId",omsMerchProperties.getMerchSn());
|
|
- String timestamp = String.valueOf(System.currentTimeMillis()/1000);
|
|
|
|
sParaTemp.put("timestamp", timestamp);
|
|
sParaTemp.put("timestamp", timestamp);
|
|
// 组装oms请求报文
|
|
// 组装oms请求报文
|
|
Request request = buildRequest(sParaTemp);
|
|
Request request = buildRequest(sParaTemp);
|
|
@@ -69,12 +94,17 @@ public class KtoOmsController {
|
|
try {
|
|
try {
|
|
LOGGER.info("oms的请求报文:" + request);
|
|
LOGGER.info("oms的请求报文:" + request);
|
|
responseString = com.kmall.admin.utils.oms.OkHttpUtils.post(request);
|
|
responseString = com.kmall.admin.utils.oms.OkHttpUtils.post(request);
|
|
|
|
+ storeTransferInventoryOrderService.update(storeTransferInventoryOrderEntity);
|
|
|
|
|
|
|
|
+ return handleResult(responseString,gson);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
+ storeTransferInventoryOrderEntity.setStatus(2);
|
|
|
|
+ storeTransferInventoryOrderService.update(storeTransferInventoryOrderEntity);
|
|
|
|
+ return R.error(e.getMessage());
|
|
}
|
|
}
|
|
|
|
|
|
- return handleResult(responseString,gson);
|
|
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -98,8 +128,8 @@ public class KtoOmsController {
|
|
String sign = OmsSign.sign(sParaTemp,omsMerchProperties.getMd5Salt());
|
|
String sign = OmsSign.sign(sParaTemp,omsMerchProperties.getMd5Salt());
|
|
sParaTemp.put("sign", sign);
|
|
sParaTemp.put("sign", sign);
|
|
//构建Request
|
|
//构建Request
|
|
- String url = omsMerchProperties.getQueryInveResponseUrl();
|
|
|
|
-
|
|
|
|
|
|
+ String url = omsMerchProperties.getSendTransferUrl();
|
|
|
|
+ url = "http://127.0.0.1:8680/al/shop/bdd/cb/transgoods";
|
|
return com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
|
|
return com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
|
|
}
|
|
}
|
|
|
|
|