From 624e69e6f8037203839fe6752475c5aec418ce7e Mon Sep 17 00:00:00 2001 From: anthonywj Date: Mon, 12 Jun 2023 09:05:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E5=8D=95=E6=8D=AE?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=BF=94=E5=9B=9E=E5=8D=95=E5=8F=B7=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +-- .../mipsdl/client/ptxhyy/PtxhyyClient.java | 78 ++++++++++++++++--- .../ptxhyy/entity/OrderUploadResponse.java | 9 +++ 3 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/OrderUploadResponse.java diff --git a/pom.xml b/pom.xml index 8684cfc..18081f2 100644 --- a/pom.xml +++ b/pom.xml @@ -124,11 +124,11 @@ - - com.squareup.okhttp3 - okhttp - 4.10.0 - + + + + + diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java index c5fcd69..216e646 100644 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java +++ b/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java @@ -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 baseResponse = + JSONObject.parseObject(response, new TypeReference>() { + }); + 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, "提交失败"); + } + } + } diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/OrderUploadResponse.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/OrderUploadResponse.java new file mode 100644 index 0000000..13bcdf0 --- /dev/null +++ b/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/OrderUploadResponse.java @@ -0,0 +1,9 @@ +package com.glxp.mipsdl.client.ptxhyy.entity; + +import lombok.Data; + +@Data +public class OrderUploadResponse { + + private String djxh; +}