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 3c4dab2..66b1813 100644 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java +++ b/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java @@ -43,6 +43,7 @@ import com.glxp.mipsdl.req.ptxhyy.PtxhyyOrderDetailRequest; 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.order.OrderUploadLogService; import com.glxp.mipsdl.service.thrsys.ThrCorpService; import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService; import com.glxp.mipsdl.util.DateUtil; @@ -96,7 +97,9 @@ public class PtxhyyClient extends CommonHttpClient { //查询对应的第三方单据类型 ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new LambdaQueryWrapper().eq(ThrSystemBusApiEntity::getCode, udiwmsOrderRequest.getBillType())); if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) { - return ResultVOUtils.error(500, "接口未配置,无法提交!"); + String errMsg = "接口未配置,无法提交!"; + updateLocalErr(orderEntity, errMsg); + return ResultVOUtils.error(500, errMsg); } udiwmsOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode()); //查询单据类型,设置往来单位信息 @@ -116,6 +119,7 @@ public class PtxhyyClient extends CommonHttpClient { udiwmsOrderRequest.setCorpName(basicCorpEntity.getName()); } else { String msg = "查询单据对应的第三方往来单位信息异常"; + updateLocalErr(orderEntity, msg); log.error("----单据提交-----" + orderEntity.getBillNo() + msg); return ResultVOUtils.error(500, msg); } @@ -131,6 +135,7 @@ public class PtxhyyClient extends CommonHttpClient { udiwmsOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); } catch (Exception e) { String msg = "查询单据对应往来单位的第三方仓库信息异常"; + updateLocalErr(orderEntity, msg); log.error("----单据提交-----" + orderEntity.getBillNo() + msg + ExceptionUtil.stacktraceToString(e)); return ResultVOUtils.error(500, msg); } @@ -144,6 +149,7 @@ public class PtxhyyClient extends CommonHttpClient { udiwmsOrderRequest.setCorpName(basicCorpEntity.getName()); } else { String msg = "查询单据对应的第三方往来单位信息异常"; + updateLocalErr(orderEntity, msg); log.error("----单据提交-----" + orderEntity.getBillNo() + msg); return ResultVOUtils.error(500, msg); } @@ -160,7 +166,8 @@ public class PtxhyyClient extends CommonHttpClient { udiwmsOrderRequest.setLocInvName(thrInvWarehouseEntitys.get(0).getName()); } } catch (Exception e) { - log.info("查询第三方系统仓库信息异常", ExceptionUtil.stacktraceToString(e)); + log.error("查询第三方系统仓库信息异常", ExceptionUtil.stacktraceToString(e)); + updateLocalErr(orderEntity, "查询第三方系统仓库信息异常" + ExceptionUtil.stacktraceToString(e)); return ResultVOUtils.error(500, "查询第三方系统仓库信息异常"); } udiwmsOrderRequest.setBillFlag("1"); @@ -195,6 +202,7 @@ public class PtxhyyClient extends CommonHttpClient { try { userName = getUserName(orderEntity); if (StrUtil.isEmpty(userName)) { + updateLocalErr(orderEntity, "该单据无创建人!"); return ResultVOUtils.error(500, "该单据无创建人!"); } } catch (Exception e) { @@ -220,6 +228,8 @@ public class PtxhyyClient extends CommonHttpClient { ptxhyyOrderRequest.setDetailList(new ArrayList<>()); String errMs = setOrderDetailList(ioCodeEntities, items, detailBizEntities); if (errMs != null) { + updateLocalErr(orderEntity, errMs); + log.error(errMs); return ResultVOUtils.error(500, errMs); } Collections.reverse(items); @@ -273,6 +283,25 @@ public class PtxhyyClient extends CommonHttpClient { return submitOrder(orderEntity, ptxhyyOrderRequest); } + /** + * 本地提交错误 + * + * @param orderEntity + * @param errMsg + */ + public void updateLocalErr(IoOrderEntity orderEntity, String errMsg) { + 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); + orderDao.updateById(orderEntity); + uploadLog.setStatus(4); + uploadLog.setResult("单据数据异常:" + errMsg); + orderUploadLogService.insertOrUpdate(uploadLog); + } + /** * 封装单据详情参数 * @@ -303,6 +332,8 @@ public class PtxhyyClient extends CommonHttpClient { private ThrSystemDetailService thrSystemDetailService; @Resource private IoOrderUploadLogDao orderUploadLogDao; + @Resource + private OrderUploadLogService orderUploadLogService; public String getUserName(IoOrderEntity orderEntity) { @@ -361,14 +392,14 @@ public class PtxhyyClient extends CommonHttpClient { uploadLog.setThrBillNo(thirdBillNo); uploadLog.setResult("提交成功"); orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); + orderUploadLogService.insertOrUpdate(uploadLog); return ResultVOUtils.success("提交成功"); } orderEntity.setExportStatus(2); //上传失败 orderDao.updateById(orderEntity); uploadLog.setStatus(3); uploadLog.setResult("提交失败,错误信息:" + baseResponse.getMessage()); - orderUploadLogDao.insert(uploadLog); + orderUploadLogService.insertOrUpdate(uploadLog); return baseResponse; } catch (Exception e) { log.error("解析提交单据返回结果异常,结果信息:{}", response); @@ -377,7 +408,7 @@ public class PtxhyyClient extends CommonHttpClient { uploadLog.setResult("提交失败,错误信息:" + response); orderEntity.setExportStatus(2); //上传失败 orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); + orderUploadLogService.insertOrUpdate(uploadLog); return ResultVOUtils.error(500, "提交失败"); } } else { @@ -385,7 +416,7 @@ public class PtxhyyClient extends CommonHttpClient { uploadLog.setResult("提交失败,调用接口返回为空"); orderEntity.setExportStatus(2); //上传失败 orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); + orderUploadLogService.insertOrUpdate(uploadLog); return ResultVOUtils.error(500, "提交失败"); } } diff --git a/src/main/java/com/glxp/mipsdl/entity/inout/IoOrderEntity.java b/src/main/java/com/glxp/mipsdl/entity/inout/IoOrderEntity.java index 726323e..d8f69fa 100644 --- a/src/main/java/com/glxp/mipsdl/entity/inout/IoOrderEntity.java +++ b/src/main/java/com/glxp/mipsdl/entity/inout/IoOrderEntity.java @@ -217,7 +217,7 @@ public class IoOrderEntity { private String fromThrBillNo; /** - * 导出状态/上传状态(0.未导出,1.已导出,2.导出失败) + * 导出状态/上传状态(0.未提交,1.已提交;2.提交失败;3:数据异常) */ @TableField(value = "exportStatus") private Integer exportStatus; diff --git a/src/main/java/com/glxp/mipsdl/entity/inout/IoOrderUploadLogEntity.java b/src/main/java/com/glxp/mipsdl/entity/inout/IoOrderUploadLogEntity.java index b9d960d..fff87e5 100644 --- a/src/main/java/com/glxp/mipsdl/entity/inout/IoOrderUploadLogEntity.java +++ b/src/main/java/com/glxp/mipsdl/entity/inout/IoOrderUploadLogEntity.java @@ -51,7 +51,7 @@ public class IoOrderUploadLogEntity { private Date submitTime; /** - * 提交状态 0:未提交 1:正在处理 2:已提交 + * 提交状态 0:未提交 1:正在处理 2:已提交;3:提交失败,4.本身数据错误 */ @TableField(value = "`status`") private Integer status; @@ -67,4 +67,4 @@ public class IoOrderUploadLogEntity { */ @TableField(value = "fromType") private Integer fromType; -} \ No newline at end of file +} diff --git a/src/main/java/com/glxp/mipsdl/service/order/OrderUploadLogService.java b/src/main/java/com/glxp/mipsdl/service/order/OrderUploadLogService.java new file mode 100644 index 0000000..f2a058e --- /dev/null +++ b/src/main/java/com/glxp/mipsdl/service/order/OrderUploadLogService.java @@ -0,0 +1,25 @@ +package com.glxp.mipsdl.service.order; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.glxp.mipsdl.dao.inout.IoOrderUploadLogDao; +import com.glxp.mipsdl.entity.inout.IoOrderUploadLogEntity; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class OrderUploadLogService extends ServiceImpl { + + @Resource + IoOrderUploadLogDao orderUploadLogDao; + + public void insertOrUpdate(IoOrderUploadLogEntity orderUploadLogEntity) { + boolean b = orderUploadLogDao.exists(new QueryWrapper().eq("billNo", orderUploadLogEntity.getBillNo())); + if (b) { + orderUploadLogDao.update(orderUploadLogEntity, new QueryWrapper().eq("billNo", orderUploadLogEntity.getBillNo())); + } else { + orderUploadLogDao.insert(orderUploadLogEntity); + } + } +} diff --git a/src/main/java/com/glxp/mipsdl/util/IntUtil.java b/src/main/java/com/glxp/mipsdl/util/IntUtil.java new file mode 100644 index 0000000..87be323 --- /dev/null +++ b/src/main/java/com/glxp/mipsdl/util/IntUtil.java @@ -0,0 +1,35 @@ +package com.glxp.mipsdl.util; + +import cn.hutool.core.util.StrUtil; + +public class IntUtil { + + public static int value(Integer value) { + if (value == null) + return 0; + else return value.intValue(); + + } + + public static long value(Long value) { + if (value == null) + return 0l; + else return value.longValue(); + + } + + + public static boolean value(Boolean value) { + if (value == null) + return false; + else return value; + } + + public static int value(String value) { + if (StrUtil.isEmpty(value)) + return 0; + else return Integer.parseInt(value); + + } + +} diff --git a/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java b/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java index fda5495..dba8e6d 100644 --- a/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java +++ b/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java @@ -129,7 +129,7 @@ public class SubmitOrderUtil { item.setRegisterNo(detailBizEntity.getCertCode()); //注册/备案证号 item.setManufactory(basicProducts.getManufactory()); //生产厂家 item.setMeasname(basicProducts.getMeasname()); //计量单位 - item.setAllowNoBatch(basicProducts.getAllowNoBatch()); //是否允许无批次号 + item.setAllowNoBatch(IntUtil.value(basicProducts.getAllowNoBatch())); //是否允许无批次号 item.setManufactoryCode(thrProductsEntity.getManufactoryCode()); item.setSupCode(thrProductsEntity.getSupCode()); item.setCplb(thrProductsEntity.getFlbm()); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 3454468..3ab9057 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,7 +1,7 @@ spring: datasource: driver-class-name: com.p6spy.engine.spy.P6SpyDriver - url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_pzh?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true + url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_pt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true username: root password: 123456 hikari: