|
@@ -2,6 +2,7 @@ package com.emato.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.emato.biz.domain.OmsUtils;
|
|
|
import com.emato.biz.domain.mall.InventoryDataPushVo;
|
|
|
import com.emato.biz.domain.mall.InventoryDataVo;
|
|
|
import com.emato.biz.domain.mall.NewSystemFormatEntiy;
|
|
@@ -18,6 +19,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.sql.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -37,6 +41,8 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
|
|
|
private MallMngChangeMapper mallMngChangeMapper;
|
|
|
@Autowired
|
|
|
private SysConfigMapper configMapper;
|
|
|
+ @Autowired
|
|
|
+ private OmsUtils omsUtils;
|
|
|
|
|
|
/**
|
|
|
* kmall向eccs系统推送数据
|
|
@@ -65,10 +71,10 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
|
|
|
String timestamp = weChatMapSalesMsg.get("timestamp").toString().trim()==null?"":weChatMapSalesMsg.get("timestamp").toString().trim();
|
|
|
String str = configMapper.getConfigValue("salesdetai").trim();;
|
|
|
if(timestamp.equals("")||merchId.equals("")){
|
|
|
- return Result.error("900000051","参数错误");
|
|
|
+ return Result.error("900051","参数错误");
|
|
|
}
|
|
|
if(!strSign.trim().equals(checkType(weChatMapSalesMsg.get("data").toString(),timestamp,str))){
|
|
|
- return Result.error("900000052","签名错误");
|
|
|
+ return Result.error("900052","签名错误");
|
|
|
}
|
|
|
Map<String, Object> weSalesMsg = JSONObject.toJavaObject(JSON.parseObject(weChatMapSalesMsg.get("data").toString()), Map.class);
|
|
|
|
|
@@ -78,11 +84,13 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
|
|
|
Integer pageSize = Integer.parseInt(weSalesMsg.get("pageSize")+"");
|
|
|
weSalesMsg.put("starTime", DateUtils.getStrDate((String) weSalesMsg.get("starTime")));
|
|
|
weSalesMsg.put("endTime",DateUtils.getStrDate((String)weSalesMsg.get("endTime")));
|
|
|
+
|
|
|
+ if(pageIndex>500){
|
|
|
+ return Result.error("900053","请求总数或时间区间过大");
|
|
|
+ }
|
|
|
+ pageIndex = (pageIndex-1)*pageSize;
|
|
|
weSalesMsg.put("offset",pageIndex);
|
|
|
weSalesMsg.put("limit",pageSize);
|
|
|
- if((pageSize-pageIndex)>500){
|
|
|
- return Result.error("900000053","请求总数或时间区间过大");
|
|
|
- }
|
|
|
//记录调用参数接口日志
|
|
|
long diff=(Long.parseLong(endTime) - Long.parseLong(starTime))/1000/60/60;
|
|
|
if(diff<=24){
|
|
@@ -91,7 +99,7 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
|
|
|
Integer total = mallMngChangeMapper.getTotalRecord(weSalesMsg);
|
|
|
//desList = DesUtils.encode(JSON.toJSONString(list));
|
|
|
if(list.size()==0){
|
|
|
- return Result.error("900000054","该条件下无数据");
|
|
|
+ return Result.error("900054","该条件下无数据");
|
|
|
}else{
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("total",total);
|
|
@@ -99,12 +107,12 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
|
|
|
return Result.success(map);
|
|
|
}
|
|
|
}else{
|
|
|
- return Result.error("900000053","请求总数或时间区间过大");
|
|
|
+ return Result.error("900053","请求总数或时间区间过大");
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
|
logger.error("外部系统查询订单销售数据错误="+ JSON.toJSONString(msg),e);
|
|
|
- return Result.error("900000051","参数错误");
|
|
|
+ return Result.error("900051","参数错误");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -162,36 +170,44 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
|
|
|
String timestamp = weChatMapMsg.get("timestamp").toString().trim()==null?"":weChatMapMsg.get("timestamp").toString().trim();
|
|
|
String str = configMapper.getConfigValue("inventory");;
|
|
|
if(timestamp.equals("")||merchId.equals("")){
|
|
|
- return Result.error("900000001","参数错误");
|
|
|
+ return Result.error("900001","参数错误");
|
|
|
}
|
|
|
if(!strSign.trim().equals(checkType(weChatMapMsg.get("data").toString(),timestamp,str))){
|
|
|
- return Result.error("900000002","签名错误");
|
|
|
+ return Result.error("900002","签名错误");
|
|
|
}
|
|
|
Map<String, Object> weDtilMsg = JSONObject.toJavaObject(JSON.parseObject(weChatMapMsg.get("data").toString()), Map.class);
|
|
|
Integer pageIndex = Integer.parseInt(weDtilMsg.get("pageIndex")+"");
|
|
|
Integer pageSize = Integer.parseInt(weDtilMsg.get("pageSize")+"");
|
|
|
+ pageIndex = (pageIndex-1)*pageSize;
|
|
|
weChatMapMsg.put("offset",pageIndex);
|
|
|
weChatMapMsg.put("limit",pageSize);
|
|
|
weChatMapMsg.put("merchId",merchId);
|
|
|
weChatMapMsg.put("sign",strSign);
|
|
|
+ String merchSn = weDtilMsg.get("merchSn").toString().trim()==null?"":weDtilMsg.get("merchSn").toString().trim();
|
|
|
+ if(merchSn.equals("")){
|
|
|
+ return Result.error("900001","参数错误");
|
|
|
+ }
|
|
|
if(pageSize>3000){
|
|
|
- return Result.error("900000003","请求数量过大");
|
|
|
+ return Result.error("900003","请求数量过大");
|
|
|
}
|
|
|
- //数据查询
|
|
|
+
|
|
|
pullQueryData(weChatMapMsg);
|
|
|
- List<InventoryDataPushVo> list = inventoryDataMapper.getInventoryData(weChatMapMsg);
|
|
|
+ // 数据查询
|
|
|
+ //List<InventoryDataPushVo> list = inventoryDataMapper.getInventoryData(weChatMapMsg);
|
|
|
+ List<InventoryDataPushVo> list = getOmsData(weDtilMsg,weChatMapMsg);
|
|
|
Integer total = inventoryDataMapper.getInventoryTotal();
|
|
|
if(list.size()==0){
|
|
|
- return Result.error("900000004","该条件下无数据");
|
|
|
+ return Result.error("900004","该条件下无数据");
|
|
|
}else{
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("total",total);
|
|
|
+ map.put("invTime",DateUtils.dateToStrLong(new Date()));
|
|
|
map.put("rows",list);
|
|
|
return Result.success(map);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
logger.error("外部系统查询库存系统条件="+JSON.toJSONString(msg),e);
|
|
|
- return Result.error("900000001","参数错误");
|
|
|
+ return Result.error("900001","参数错误");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -205,4 +221,50 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
|
|
|
|
|
|
|
|
|
|
|
|
+ public List<InventoryDataPushVo> getOmsData(Map<String, Object> weDtilMsg,Map<String, Object> weChatMapMsg){
|
|
|
+ String driver=omsUtils.getOmsDriver();
|
|
|
+ String user=omsUtils.getOmsUser();
|
|
|
+ String password=omsUtils.getOmsPassword();
|
|
|
+ String url=omsUtils.getOmsUrl();
|
|
|
+ List<InventoryDataPushVo> inventoryDataPushVos = null;
|
|
|
+ try{
|
|
|
+ //加载数据库驱动
|
|
|
+ Class.forName(driver);
|
|
|
+ //连接数据库
|
|
|
+ Connection conn = DriverManager.getConnection(url,user,password);
|
|
|
+ //创建Statement对象
|
|
|
+ Statement stmt = conn.createStatement();
|
|
|
+ String sql = "SELECT wmsi.merch_sn,ppr.prod_barcode,ppr.prod_name,wmsi.shop_sn,wim.valid_num,wmsi.shop_inve FROM wb_inve_mng wim LEFT JOIN pd_product_record ppr ON wim.sku = ppr.sku LEFT JOIN wb_merch_shop_inve wmsi ON wim.sku = wmsi.sku WHERE ppr.is_record = 1 AND ppr.is_valid = 0 AND wim.inve_status = 0 AND wim.is_valid = 0 AND wmsi.is_valid = 0 AND wim.merch_sn='"+weDtilMsg.get("merchSn")+"' limit "+weChatMapMsg.get("offset")+","+weChatMapMsg.get("limit")+"";
|
|
|
+ //建立结果集
|
|
|
+ ResultSet rs = stmt.executeQuery(sql);
|
|
|
+ inventoryDataPushVos =convertList(rs);
|
|
|
+ //关闭结果集
|
|
|
+ rs.close();
|
|
|
+ //关闭Statement对象
|
|
|
+ stmt.close();
|
|
|
+ //关闭数据库
|
|
|
+ conn.close();
|
|
|
+
|
|
|
+ }catch(Exception e){
|
|
|
+ logger.error("查询oms库存数据出错");
|
|
|
+ }
|
|
|
+ return inventoryDataPushVos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private static List<InventoryDataPushVo> convertList(ResultSet rs) throws SQLException {
|
|
|
+ List<InventoryDataPushVo> list = new ArrayList();
|
|
|
+ while (rs.next()) {
|
|
|
+ InventoryDataPushVo inventoryDataPushVo = new InventoryDataPushVo();
|
|
|
+ inventoryDataPushVo.setBarcode(rs.getString("prod_barcode"));
|
|
|
+ inventoryDataPushVo.setProductName(rs.getString("prod_name"));
|
|
|
+ inventoryDataPushVo.setShopSn(rs.getString("shop_sn"));
|
|
|
+ inventoryDataPushVo.setShopInvent(rs.getInt("shop_inve"));
|
|
|
+ inventoryDataPushVo.seteMatou(rs.getInt("valid_num"));
|
|
|
+ list.add(inventoryDataPushVo);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
}
|