第三方单据上传返回单号问题

dev
anthonywj 2 years ago
parent 7f627b00b7
commit 624e69e6f8

@ -124,11 +124,11 @@
</dependency>
<!--okhttp-->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.10.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.squareup.okhttp3</groupId>-->
<!-- <artifactId>okhttp</artifactId>-->
<!-- <version>4.10.0</version>-->
<!-- </dependency>-->
</dependencies>

@ -4,10 +4,13 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.glxp.mipsdl.client.CommonHttpClient;
import com.glxp.mipsdl.client.ptxhyy.entity.OrderUploadResponse;
import com.glxp.mipsdl.config.ThirdSysConfig;
import com.glxp.mipsdl.constant.ConstantType;
import com.glxp.mipsdl.constant.Constants;
@ -18,6 +21,7 @@ import com.glxp.mipsdl.dao.basic.BasicCorpDao;
import com.glxp.mipsdl.dao.inout.IoCodeDao;
import com.glxp.mipsdl.dao.inout.IoOrderDao;
import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao;
import com.glxp.mipsdl.dao.inout.IoOrderUploadLogDao;
import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao;
import com.glxp.mipsdl.dao.thrsys.ThrProductsDao;
import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao;
@ -27,12 +31,10 @@ import com.glxp.mipsdl.entity.auth.AuthWarehouseUser;
import com.glxp.mipsdl.dao.auth.AuthWarehouseUserMapper;
import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity;
import com.glxp.mipsdl.entity.basic.BasicCorpEntity;
import com.glxp.mipsdl.entity.inout.IoCodeEntity;
import com.glxp.mipsdl.entity.inout.IoOrderDetailBizEntity;
import com.glxp.mipsdl.entity.inout.IoOrderEntity;
import com.glxp.mipsdl.entity.inout.IoOrderInvoiceEntity;
import com.glxp.mipsdl.entity.inout.*;
import com.glxp.mipsdl.entity.thrsys.ThrInvWarehouseEntity;
import com.glxp.mipsdl.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.UdiwmsOrderDetailRequest;
import com.glxp.mipsdl.req.base.UdiwmsOrderRequest;
import com.glxp.mipsdl.req.ptxhyy.PtxhyyOrderDetailRequest;
@ -40,6 +42,7 @@ import com.glxp.mipsdl.req.ptxhyy.PtxhyyOrderRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.service.auth.AuthWarehouseService;
import com.glxp.mipsdl.service.thrsys.ThrCorpService;
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
import com.glxp.mipsdl.util.DateUtil;
import com.glxp.mipsdl.util.ResultVOUtils;
import com.glxp.mipsdl.util.SubmitOrderUtil;
@ -51,10 +54,7 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@ -246,7 +246,7 @@ public class PtxhyyClient extends CommonHttpClient {
ptxhyyOrderRequest.getDetailList().add(detailRequest);
}
return submitOrderUtil.submitOrder(orderEntity, ptxhyyOrderRequest);
return submitOrder(orderEntity, ptxhyyOrderRequest);
}
/**
@ -269,6 +269,13 @@ public class PtxhyyClient extends CommonHttpClient {
AuthUserDao authUserDao;
@Resource
AuthWarehouseUserMapper authWarehouseUserMapper;
@Resource
private HttpClient httpClient;
@Resource
private ThrSystemDetailService thrSystemDetailService;
@Resource
private IoOrderUploadLogDao orderUploadLogDao;
public String getUserName(IoOrderEntity orderEntity) {
@ -291,4 +298,57 @@ public class PtxhyyClient extends CommonHttpClient {
return null;
}
public BaseResponse submitOrder(IoOrderEntity orderEntity, Object udiwmsOrderRequest) {
//记录日志
IoOrderUploadLogEntity uploadLog = new IoOrderUploadLogEntity();
uploadLog.setBillDate(orderEntity.getCreateTime());
uploadLog.setBillType(orderEntity.getAction());
uploadLog.setSubmitTime(new Date());
uploadLog.setBillNo(orderEntity.getBillNo());
uploadLog.setFromType(Constants.THIRD_ORDER_UPLOAD);
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_ORDER_SUBMIT_URL), udiwmsOrderRequest);
if (StrUtil.isNotBlank(response)) {
try {
// BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class);
BaseResponse<OrderUploadResponse> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<OrderUploadResponse>>() {
});
if (baseResponse.getCode() == 20000) {
String thirdBillNo = baseResponse.getData().getDjxh();
orderEntity.setThirdBillNo(thirdBillNo);
orderEntity.setExportStatus(1); //上传成功
uploadLog.setStatus(2);
uploadLog.setThrBillNo(thirdBillNo);
uploadLog.setResult("提交成功");
orderDao.updateById(orderEntity);
orderUploadLogDao.insert(uploadLog);
return ResultVOUtils.success("提交成功");
}
orderEntity.setExportStatus(2); //上传失败
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,错误信息:" + baseResponse.getMessage());
orderUploadLogDao.insert(uploadLog);
return baseResponse;
} catch (Exception e) {
log.error("解析提交单据返回结果异常,结果信息:{}", response);
log.error("异常信息:{}", e);
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,错误信息:" + response);
orderEntity.setExportStatus(2); //上传失败
orderDao.updateById(orderEntity);
orderUploadLogDao.insert(uploadLog);
return ResultVOUtils.error(500, "提交失败");
}
} else {
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,调用接口返回为空");
orderEntity.setExportStatus(2); //上传失败
orderDao.updateById(orderEntity);
orderUploadLogDao.insert(uploadLog);
return ResultVOUtils.error(500, "提交失败");
}
}
}

@ -0,0 +1,9 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
@Data
public class OrderUploadResponse {
private String djxh;
}
Loading…
Cancel
Save