|
@@ -3,20 +3,24 @@ package com.dk.mnls_mp.service.pullDetail;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.dk.mnls_mp.infrastructure.base.ResponseCodeEnum;
|
|
import com.dk.mnls_mp.infrastructure.base.ResponseCodeEnum;
|
|
|
import com.dk.mnls_mp.infrastructure.config.IbossProxy;
|
|
import com.dk.mnls_mp.infrastructure.config.IbossProxy;
|
|
|
import com.dk.mnls_mp.constant.Constant;
|
|
import com.dk.mnls_mp.constant.Constant;
|
|
|
|
|
+import com.dk.mnls_mp.infrastructure.convert.IBOSSGoodsCodeConvert;
|
|
|
import com.dk.mnls_mp.infrastructure.util.XmlUtil;
|
|
import com.dk.mnls_mp.infrastructure.util.XmlUtil;
|
|
|
-import com.dk.mnls_mp.mapper.basic.IbossOrganizationMapper;
|
|
|
|
|
-import com.dk.mnls_mp.mapper.basic.PullOrderDetailMapper;
|
|
|
|
|
-import com.dk.mnls_mp.mapper.basic.SystemParamterMapper;
|
|
|
|
|
-import com.dk.mnls_mp.mapper.basic.WCFinfoMapper;
|
|
|
|
|
|
|
+import com.dk.mnls_mp.mapper.basic.*;
|
|
|
|
|
+import com.dk.mnls_mp.mapper.mnls.IBOSSGoodsCodeMapper;
|
|
|
import com.dk.mnls_mp.model.dto.IBOSSDTO;
|
|
import com.dk.mnls_mp.model.dto.IBOSSDTO;
|
|
|
import com.dk.mnls_mp.model.pojo.basic.*;
|
|
import com.dk.mnls_mp.model.pojo.basic.*;
|
|
|
import com.dk.mnls_mp.model.pojo.mnls.IBOSSData;
|
|
import com.dk.mnls_mp.model.pojo.mnls.IBOSSData;
|
|
|
import com.dk.mnls_mp.infrastructure.util.HttpHelper;
|
|
import com.dk.mnls_mp.infrastructure.util.HttpHelper;
|
|
|
|
|
+import com.dk.mnls_mp.model.pojo.mnls.IBOSSGoodsCode;
|
|
|
|
|
+import com.dk.mnls_mp.model.vo.IBOSSGoodsCodeVO;
|
|
|
import com.dk.mnls_mp.service.mnls.IBOSSDataService;
|
|
import com.dk.mnls_mp.service.mnls.IBOSSDataService;
|
|
|
|
|
+import com.dk.mnls_mp.service.mnls.IBOSSGoodsCodeService;
|
|
|
import com.dongke.base.annotation.Pagination;
|
|
import com.dongke.base.annotation.Pagination;
|
|
|
|
|
+import com.dongke.base.exceptionHandler.BaseBusinessException;
|
|
|
import com.dongke.base.exceptionHandler.ResponseResultUtil;
|
|
import com.dongke.base.exceptionHandler.ResponseResultUtil;
|
|
|
import com.dongke.base.exceptionHandler.ResponseResultVO;
|
|
import com.dongke.base.exceptionHandler.ResponseResultVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -57,8 +61,8 @@ public class PullOrderDetailService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IBOSSDataService ibossDataService;
|
|
private IBOSSDataService ibossDataService;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SynchStatusMapper synchStatusMapper;
|
|
|
|
|
|
|
|
public ResponseResultVO selectDate() {
|
|
public ResponseResultVO selectDate() {
|
|
|
return ResponseResultUtil.success(pullOrderDetailMapper.selectDate());
|
|
return ResponseResultUtil.success(pullOrderDetailMapper.selectDate());
|
|
@@ -128,12 +132,11 @@ public class PullOrderDetailService {
|
|
|
*/
|
|
*/
|
|
|
@Async("pullIbossData")
|
|
@Async("pullIbossData")
|
|
|
public ResponseResultVO callWebService(Customer customer, PullOrderDetail pull, Constant.PullDataType type) {
|
|
public ResponseResultVO callWebService(Customer customer, PullOrderDetail pull, Constant.PullDataType type) {
|
|
|
-
|
|
|
|
|
//定义iBOSS接口返回值实体
|
|
//定义iBOSS接口返回值实体
|
|
|
IBOSSDTO IBOSSDTO=new IBOSSDTO();
|
|
IBOSSDTO IBOSSDTO=new IBOSSDTO();
|
|
|
//定义履历成功状态
|
|
//定义履历成功状态
|
|
|
Integer status=0;
|
|
Integer status=0;
|
|
|
- //此处用try捕获异常,保证线程之间不会受事务影响
|
|
|
|
|
|
|
+ //此处用try捕获异常,保证多线程之间不会受事务影响
|
|
|
try {
|
|
try {
|
|
|
//查询客户webservice信息
|
|
//查询客户webservice信息
|
|
|
WCFinfo wcFinfo = wcFinfoMapper.selectById(customer.getWcfid());
|
|
WCFinfo wcFinfo = wcFinfoMapper.selectById(customer.getWcfid());
|
|
@@ -156,7 +159,7 @@ public class PullOrderDetailService {
|
|
|
Date startTime = new Date();
|
|
Date startTime = new Date();
|
|
|
ResponseResultVO resultVO = HttpHelper.callIBOSSWebservice(url, param,null);
|
|
ResponseResultVO resultVO = HttpHelper.callIBOSSWebservice(url, param,null);
|
|
|
Date endTime = new Date();
|
|
Date endTime = new Date();
|
|
|
- log.info("iBOSS客户=>{},接口响应时间=>{}ms", customer.getUniqueCode(), endTime.getTime() - startTime.getTime());
|
|
|
|
|
|
|
+ log.info("经销商id=>{},接口响应时间=>{}ms", customer.getCustomerid(), endTime.getTime() - startTime.getTime());
|
|
|
|
|
|
|
|
//成功后插入数据
|
|
//成功后插入数据
|
|
|
if (ResponseCodeEnum.SUCCESS.getCode()==resultVO.getCode()) {
|
|
if (ResponseCodeEnum.SUCCESS.getCode()==resultVO.getCode()) {
|
|
@@ -178,43 +181,35 @@ public class PullOrderDetailService {
|
|
|
//修改状态为成功
|
|
//修改状态为成功
|
|
|
status=1;
|
|
status=1;
|
|
|
}else{
|
|
}else{
|
|
|
- log.error("调用iBOSS接口异常,返回值=>{}",resultVO);
|
|
|
|
|
|
|
+ log.error("调用iBOSS接口异常,经销商id=>{},返回值=>{}",customer.getCustomerid(),resultVO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//记录履历
|
|
//记录履历
|
|
|
this.recordPullDetail(IBOSSDTO,pull,(long)customer.getCustomerid(),type,status);
|
|
this.recordPullDetail(IBOSSDTO,pull,(long)customer.getCustomerid(),type,status);
|
|
|
return ResponseResultUtil.success();
|
|
return ResponseResultUtil.success();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
- log.error("callWebService失败", e);
|
|
|
|
|
- return ResponseResultUtil.error("callWebService失败");
|
|
|
|
|
|
|
+ log.error("callWebService失败,经销商id=>{},异常信息=>{}"+customer.getCustomerid(), e);
|
|
|
|
|
+ return ResponseResultUtil.error(666,"callWebService失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public ResponseResultVO testSyncCode() {
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //此处用try捕获异常,保证线程之间不会受事务影响
|
|
|
|
|
|
|
+ public ResponseResultVO syncCode(Customer customer,int syncId,List<IBOSSGoodsCodeVO> goodsCodelist) {
|
|
|
|
|
+ //此处用try捕获异常,保证同步各个经销商之间不会因为一个经销商异常 而导致全部异常
|
|
|
try {
|
|
try {
|
|
|
|
|
+ //查询客户webservice信息
|
|
|
|
|
+ WCFinfo wcFinfo = wcFinfoMapper.selectById(customer.getWcfid());
|
|
|
|
|
+ if (wcFinfo == null) {
|
|
|
|
|
+ throw new BaseBusinessException(666,"同步编码失败,没有找到此客户的webService信息,客户信息=>"+customer);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//拼接url 区别于恒洁中台 直接调用iBOSS的webservice接口
|
|
//拼接url 区别于恒洁中台 直接调用iBOSS的webservice接口
|
|
|
- String url = "http://192.168.1.104:50561" + WEBSERVICE_INTERFACE_POSTFIX +"DK_SaveGoods_Code_MP";
|
|
|
|
|
|
|
+ String url = "http://"+wcFinfo.getWcfip() + ":" + wcFinfo.getWcfport() + WEBSERVICE_INTERFACE_POSTFIX +"DK_SaveGoods_Code_MP";
|
|
|
|
|
|
|
|
//整理参数
|
|
//整理参数
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
- param.put("accountCode", "HKZRMY_CS");
|
|
|
|
|
- param.put("userCode","cw001");
|
|
|
|
|
- param.put("goodsCode",Arrays.asList(new HashMap(){{
|
|
|
|
|
- put("code","656565");
|
|
|
|
|
- put("specification","200*200");
|
|
|
|
|
- put("itemId",193001);
|
|
|
|
|
- put("goodsName","动物卡通砖(M)/006/200*200/123");
|
|
|
|
|
- put("onlyCode","006/200*200/123");
|
|
|
|
|
- put("seriesName","动物卡通砖(M)");
|
|
|
|
|
- put("package",1);
|
|
|
|
|
- put("kindName","-");
|
|
|
|
|
- put("varietyName","-");
|
|
|
|
|
- }}));
|
|
|
|
|
|
|
+ param.put("accountCode", customer.getDongkeaccountcode());
|
|
|
|
|
+ param.put("userCode",customer.getUniqueCode());
|
|
|
|
|
+ param.put("goodsCode",goodsCodelist);
|
|
|
|
|
|
|
|
log.info("=*=*=*=*=*=*=*=*=" + "参数:" + param + "=*=*=*=*=*=*=*=*=");
|
|
log.info("=*=*=*=*=*=*=*=*=" + "参数:" + param + "=*=*=*=*=*=*=*=*=");
|
|
|
//调用接口
|
|
//调用接口
|
|
@@ -226,14 +221,23 @@ public class PullOrderDetailService {
|
|
|
Map<String, Object> resJson = XmlUtil.xmlToJson(resultVO.getData().toString());
|
|
Map<String, Object> resJson = XmlUtil.xmlToJson(resultVO.getData().toString());
|
|
|
//map转DTO
|
|
//map转DTO
|
|
|
IBOSSDTO IBOSSDTO = JSON.parseObject(resJson.get("string").toString(), IBOSSDTO.class);
|
|
IBOSSDTO IBOSSDTO = JSON.parseObject(resJson.get("string").toString(), IBOSSDTO.class);
|
|
|
- log.info("IBOSSDTO=>{}",IBOSSDTO);
|
|
|
|
|
|
|
+ if(0==IBOSSDTO.getStatus()){
|
|
|
|
|
+ //成功更新状态
|
|
|
|
|
+ synchStatusMapper.updateByID(new HashMap(){{put("SynchID",syncId);put("Status",1);}});
|
|
|
|
|
+ log.info("同步商品编码成功,经销商id=>{}",customer.getCustomerid());
|
|
|
|
|
+ return ResponseResultUtil.success(200,"同步商品编码成功,经销商id=>"+customer.getCustomerid());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //失败记录信息
|
|
|
|
|
+ synchStatusMapper.updateByID(new HashMap(){{put("SynchID",syncId);put("Message",IBOSSDTO.getMessage());}});
|
|
|
|
|
+ log.info("同步iBOSS商品编码失败,iBOSS接口状态码不等于0,经销商id=>{},接口返回值=>{}",customer.getCustomerid(),IBOSSDTO);
|
|
|
|
|
+ return ResponseResultUtil.error(666,"同步iBOSS商品编码失败,iBOSS接口状态码不等于0,经销商id=>"+customer.getCustomerid());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return ResponseResultUtil.success();
|
|
|
|
|
|
|
+ log.info("同步iBOSS商品编码失败,http状态码不等于200,经销商id=>{},接口返回值=>{}",customer.getCustomerid(),resultVO);
|
|
|
|
|
+ return ResponseResultUtil.error(666,"同步iBOSS商品编码失败,http状态码不等于200,经销商id=>"+customer.getCustomerid());
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
- log.error("testSyncCode", e);
|
|
|
|
|
- return ResponseResultUtil.error("testSyncCode");
|
|
|
|
|
|
|
+ log.error("同步iBOSS商品编码异常,经销商id=>{},异常信息=>{}"+customer.getCustomerid(), e);
|
|
|
|
|
+ return ResponseResultUtil.error(666,"同步iBOSS商品编码异常,经销商id=>"+customer.getCustomerid());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|