|
@@ -53,19 +53,8 @@ public class PullOrderDetailService {
|
|
|
SqlSession sqlSession;
|
|
SqlSession sqlSession;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private WCFinfoMapper wcFinfoMapper;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
private PullOrderDetailMapper pullOrderDetailMapper;
|
|
private PullOrderDetailMapper pullOrderDetailMapper;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private IBOSSDataService ibossDataService;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private SynchStatusMapper synchStatusMapper;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private Config config;
|
|
|
|
|
|
|
|
|
|
public ResponseResultVO selectDate() {
|
|
public ResponseResultVO selectDate() {
|
|
|
return ResponseResultUtil.success(pullOrderDetailMapper.selectDate());
|
|
return ResponseResultUtil.success(pullOrderDetailMapper.selectDate());
|
|
@@ -128,136 +117,6 @@ public class PullOrderDetailService {
|
|
|
return ResponseResultUtil.success(data);
|
|
return ResponseResultUtil.success(data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @author : sh4wmoo
|
|
|
|
|
- * @date : 2021-5-8 13:44
|
|
|
|
|
- * @desc : 调用webservice服务通用方法
|
|
|
|
|
- */
|
|
|
|
|
- @Async("pullIbossData")
|
|
|
|
|
- public ResponseResultVO callWebService(Customer customer, PullOrderDetail pull, Constant.PullDataType type) {
|
|
|
|
|
- //定义iBOSS接口返回值实体
|
|
|
|
|
- IBOSSDTO IBOSSDTO=new IBOSSDTO();
|
|
|
|
|
- //定义履历成功状态
|
|
|
|
|
- Integer status=0;
|
|
|
|
|
- //此处用try捕获异常,保证多线程之间不会受事务影响
|
|
|
|
|
- try {
|
|
|
|
|
- //查询客户webservice信息
|
|
|
|
|
- WCFinfo wcFinfo = wcFinfoMapper.selectById(customer.getWcfid());
|
|
|
|
|
- if (wcFinfo == null) {
|
|
|
|
|
- return ResponseResultUtil.error(ResponseCodeEnum.SELECT_BY_ID_NULL.getCode(), ResponseCodeEnum.SELECT_BY_ID_NULL.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //拼接url 区别于恒洁中台 直接调用iBOSS的webservice接口
|
|
|
|
|
- String url = "http://"+wcFinfo.getWcfip() + ":" + wcFinfo.getWcfport() + config.getIBOSSWebserviceInterfacePostfix() +type.getFunctionName();
|
|
|
|
|
-
|
|
|
|
|
- //整理参数
|
|
|
|
|
- Map<String, Object> param = new HashMap<>();
|
|
|
|
|
- param.put("AccountCode", customer.getDongkeaccountcode());
|
|
|
|
|
- param.put("PageNum","0");
|
|
|
|
|
- param.put("PageSize","0");
|
|
|
|
|
-
|
|
|
|
|
- log.info("=*=*=*=*=*=*=*=*=" + "参数:" + param + "=*=*=*=*=*=*=*=*=");
|
|
|
|
|
-
|
|
|
|
|
- //调用接口
|
|
|
|
|
- Date startTime = new Date();
|
|
|
|
|
- ResponseResultVO resultVO = HttpHelper.callIBOSSWebservice(url, param,null);
|
|
|
|
|
- Date endTime = new Date();
|
|
|
|
|
- log.info("经销商id=>{},接口响应时间=>{}ms", customer.getCustomerid(), endTime.getTime() - startTime.getTime());
|
|
|
|
|
-
|
|
|
|
|
- //成功后插入数据
|
|
|
|
|
- if (ResponseCodeEnum.SUCCESS.getCode()==resultVO.getCode()) {
|
|
|
|
|
- //XML转map
|
|
|
|
|
- Map<String, Object> resJson = XmlUtil.xmlToJson(resultVO.getData().toString());
|
|
|
|
|
- //map转DTO
|
|
|
|
|
- IBOSSDTO = JSON.parseObject(resJson.get("string").toString(), IBOSSDTO.class);
|
|
|
|
|
-
|
|
|
|
|
- //创建insert pojo
|
|
|
|
|
- IBOSSData IBOSSData=new IBOSSData();
|
|
|
|
|
- JSONArray dataArray = JSONArray.parseArray(IBOSSDTO.getResult().toString());
|
|
|
|
|
- IBOSSData.setData(dataArray);
|
|
|
|
|
- IBOSSData.setCount(dataArray.size());
|
|
|
|
|
- IBOSSData.setDataType((long)type.getId());
|
|
|
|
|
- IBOSSData.setCustomerId((long)customer.getCustomerid());
|
|
|
|
|
- //减一天日期
|
|
|
|
|
- IBOSSData.setCreateDate(DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now().minusDays(1)));
|
|
|
|
|
- ibossDataService.insert(IBOSSData);
|
|
|
|
|
- //修改状态为成功
|
|
|
|
|
- status=1;
|
|
|
|
|
- }else{
|
|
|
|
|
- log.error("调用iBOSS接口异常,经销商id=>{},返回值=>{}",customer.getCustomerid(),resultVO);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //记录履历
|
|
|
|
|
- this.recordPullDetail(IBOSSDTO,pull,(long)customer.getCustomerid(),type,status);
|
|
|
|
|
- return ResponseResultUtil.success();
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("callWebService失败,经销商id=>{},异常信息=>{}"+customer.getCustomerid(), e);
|
|
|
|
|
- return ResponseResultUtil.error(666,"callWebService失败");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public ResponseResultVO syncCode(Customer customer,int syncId,List<IBOSSGoodsCodeVO> goodsCodelist) {
|
|
|
|
|
- //此处用try捕获异常,保证同步各个经销商之间不会因为一个经销商异常 而导致全部异常
|
|
|
|
|
- try {
|
|
|
|
|
- //查询客户webservice信息
|
|
|
|
|
- WCFinfo wcFinfo = wcFinfoMapper.selectById(customer.getWcfid());
|
|
|
|
|
- if (wcFinfo == null) {
|
|
|
|
|
- throw new BaseBusinessException(666,"同步编码失败,没有找到此客户的webService信息,客户信息=>"+customer);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //拼接url 区别于恒洁中台 直接调用iBOSS的webservice接口
|
|
|
|
|
- String url = "http://"+wcFinfo.getWcfip() + ":" + wcFinfo.getWcfport() + config.getIBOSSWebserviceInterfacePostfix() +config.getSyncGoodsCodeUrl();
|
|
|
|
|
-
|
|
|
|
|
- //整理参数
|
|
|
|
|
- Map<String, Object> param = new HashMap<>();
|
|
|
|
|
- param.put("accountCode", customer.getDongkeaccountcode());
|
|
|
|
|
- param.put("userCode",customer.getUniqueCode());
|
|
|
|
|
- param.put("goodsCode",goodsCodelist);
|
|
|
|
|
-
|
|
|
|
|
- log.info("=*=*=*=*=*=*=*=*=" + "参数:" + param + "=*=*=*=*=*=*=*=*=");
|
|
|
|
|
- //调用接口
|
|
|
|
|
- ResponseResultVO resultVO = HttpHelper.callIBOSSWebservice(url, param,null);
|
|
|
|
|
-
|
|
|
|
|
- //成功后插入数据
|
|
|
|
|
- if (ResponseCodeEnum.SUCCESS.getCode()==resultVO.getCode()) {
|
|
|
|
|
- //XML转map
|
|
|
|
|
- Map<String, Object> resJson = XmlUtil.xmlToJson(resultVO.getData().toString());
|
|
|
|
|
- //map转DTO
|
|
|
|
|
- IBOSSDTO IBOSSDTO = JSON.parseObject(resJson.get("string").toString(), IBOSSDTO.class);
|
|
|
|
|
- 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());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- log.info("同步iBOSS商品编码失败,http状态码不等于200,经销商id=>{},接口返回值=>{}",customer.getCustomerid(),resultVO);
|
|
|
|
|
- return ResponseResultUtil.error(666,"同步iBOSS商品编码失败,http状态码不等于200,经销商id=>"+customer.getCustomerid());
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("同步iBOSS商品编码异常,经销商id=>{},异常信息=>{}"+customer.getCustomerid(), e);
|
|
|
|
|
- return ResponseResultUtil.error(666,"同步iBOSS商品编码异常,经销商id=>"+customer.getCustomerid());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @desc : 记录抓取数据履历
|
|
|
|
|
- * @author : 张潇木
|
|
|
|
|
- * @date : 2022-9-20 14:33
|
|
|
|
|
- */
|
|
|
|
|
- private void recordPullDetail(IBOSSDTO IBOSSDTO,PullOrderDetail pull, Long customerId, Constant.PullDataType type,Integer status) {
|
|
|
|
|
- PullOrderDetail pod =new PullOrderDetail()
|
|
|
|
|
- .setCustomerId(customerId).setStatus(status).setType(type.getId()).setPullId(pull.getPullId()).setPullTime(new Date())
|
|
|
|
|
- .setPullQuantity(0==IBOSSDTO.getStatus()?JSONArray.parseArray(IBOSSDTO.getResult().toString()).size():null)
|
|
|
|
|
- .setMessage(IBOSSDTO.getMessage());
|
|
|
|
|
- pullOrderDetailMapper.insertDetail(pod);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author : sh4wmoo
|
|
* @author : sh4wmoo
|