From be44ed7a8cf7e32dd1d57bea7d902489edf5ce6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B3=89=E4=BD=B3?= <1107186916@qq.com> Date: Fri, 18 Sep 2026 20:01:29 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E=E5=AE=A2?= =?UTF-8?q?=E5=95=86=E6=A1=A3=E6=A1=88=E5=90=8C=E6=AD=A5=E9=87=91=E8=9D=B6?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=88A902-1=E6=9F=A5=E8=AF=A2=E5=9B=9E?= =?UTF-8?q?=E5=A1=AB+A902-2=E5=AE=A1=E6=89=B9=E6=8E=A8=E9=80=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/entity/CustomerArchive.java | 9 ++ .../constant/CustomerBfiConstants.java | 69 ++++++++ .../controller/BfiCustomerController.java | 75 +++++++++ .../controller/CustomerArchiveController.java | 24 ++- .../transport/excel/CustomerArchiveExcel.java | 3 + .../mapper/CustomerArchiveMapper.xml | 8 +- .../service/ICustomerArchiveService.java | 8 + .../impl/CustomerArchiveServiceImpl.java | 138 ++++++++++++++++ .../service/impl/CustomerBfiConverter.java | 147 ++++++++++++++++++ ...lade_customer_archive_kingdee_20260917.sql | 16 ++ 10 files changed, 494 insertions(+), 3 deletions(-) create mode 100644 blade-service/blade-transport/src/main/java/org/springblade/transport/constant/CustomerBfiConstants.java create mode 100644 blade-service/blade-transport/src/main/java/org/springblade/transport/controller/BfiCustomerController.java create mode 100644 blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/CustomerBfiConverter.java create mode 100644 doc/sql/transport/blade_customer_archive_kingdee_20260917.sql diff --git a/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CustomerArchive.java b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CustomerArchive.java index 0fc97777..6890fa1b 100644 --- a/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CustomerArchive.java +++ b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CustomerArchive.java @@ -158,4 +158,13 @@ public class CustomerArchive extends TenantEntity { @Schema(description = "审核通过时间") private LocalDateTime approvedTime; + @Schema(description = "金蝶协同状态:none未推送/exist金蝶已有/synced已推送/failed推送失败") + private String kingdeeStatus; + + @Schema(description = "金蝶推送失败原因") + private String kingdeeFailReason; + + @Schema(description = "金蝶推送时间") + private LocalDateTime kingdeeSyncTime; + } diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/constant/CustomerBfiConstants.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/constant/CustomerBfiConstants.java new file mode 100644 index 00000000..6725a436 --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/constant/CustomerBfiConstants.java @@ -0,0 +1,69 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is + * not liable for any claims arising from secondary or illegal development. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.constant; + +import java.util.Map; + +/** + * 客商档案金蝶(星瀚)协同常量 + * + * @author Chill + */ +public class CustomerBfiConstants { + + /** + * 推送金蝶固定值:业务职能全选(1销售,2结算,3付款,4收货) + */ + public static final String BIZ_FUNCTION_ALL = "1,2,3,4"; + + /** + * 推送金蝶固定值:伙伴类型兜底编码(民营企业),客商性质未命中映射时使用 + */ + public static final String DEFAULT_PARTNER_TYPE = "6"; + + /** + * 营业期限类型:长期(TMS 表单文本) + */ + public static final String BUSINESS_TERM_LONG = "长期"; + + /** + * 客商性质(nature_of_client 字典 dictKey)→ 金蝶伙伴类型编码 + * 键名以数据库字典 nature_of_client 实际 dictKey 为准核对;未命中走 DEFAULT_PARTNER_TYPE + */ + public static final Map NATURE_TYPE_MAPPING = Map.of( + "企业法人", "1", + "个人", "4", + "个体工商户", "5", + "民营企业", "6", + "国有企业", "8", + "政府事业单位", "9", + "其他", "12" + ); + + private CustomerBfiConstants() { + } + +} diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/BfiCustomerController.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/BfiCustomerController.java new file mode 100644 index 00000000..5faea7c8 --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/BfiCustomerController.java @@ -0,0 +1,75 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is + * not liable for any claims arising from secondary or illegal development. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.thirdparty.bfi.pojo.dto.BfiCustomerQueryDTO; +import org.springblade.thirdparty.bfi.pojo.vo.BfiCustomerVO; +import org.springblade.thirdparty.bfi.pojo.vo.BfiPageVO; +import org.springblade.thirdparty.bfi.service.IBfiService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 业财融合(BFI)客商查询控制器 + * + * @author Chill + */ +@RestController +@AllArgsConstructor +@RequestMapping("/bfi") +@Tag(name = "BFI客商", description = "业财融合客商查询接口") +public class BfiCustomerController extends BladeController { + + private final IBfiService bfiService; + + @GetMapping("/customer/query-by-credit-code") + @Operation(summary = "按统一社会信用代码查询金蝶客商", description = "新增客商时查询金蝶是否已有该客商,已审核则回填工商信息") + public R queryByCreditCode( + @Parameter(description = "统一社会信用代码", required = true) @RequestParam String creditCode) { + if (StringUtil.isBlank(creditCode)) { + return R.fail("统一社会信用代码不能为空"); + } + BfiCustomerQueryDTO param = new BfiCustomerQueryDTO(); + param.setPageNo(1); + param.setPageSize(1); + param.setSocietycreditcode(List.of(creditCode.trim().toUpperCase())); + BfiPageVO page = bfiService.queryCustomer(param); + List rows = page == null ? null : page.getRows(); + return R.data(rows == null || rows.isEmpty() ? null : rows.get(0)); + } + +} diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchiveController.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchiveController.java index 6b1a1266..3c44fd00 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchiveController.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchiveController.java @@ -31,6 +31,7 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.excel.util.ExcelUtil; import org.springblade.core.mp.support.Condition; @@ -60,6 +61,7 @@ import java.util.List; * * @author Chill */ +@Slf4j @RestController @AllArgsConstructor @PreAuth(menu = "customer_archive") @@ -133,13 +135,21 @@ public class CustomerArchiveController extends BladeController { } /** - * 审核通过 + * 审核通过(通过后自动推送金蝶,推送失败不影响审批结果) */ @PostMapping("/approve") @ApiOperationSupport(order = 6) @Operation(summary = "审核通过", description = "传入id") public R approve(@Parameter(description = "主键", required = true) @RequestParam Long id) { - return R.status(customerArchiveService.approve(id)); + boolean result = customerArchiveService.approve(id); + if (result) { + try { + customerArchiveService.syncKingdee(id); + } catch (Exception exception) { + log.error("客商审批通过后推送金蝶异常,id={}", id, exception); + } + } + return R.status(result); } /** @@ -173,6 +183,16 @@ public class CustomerArchiveController extends BladeController { return R.status(customerArchiveService.removeDraft(ids)); } + /** + * 推送金蝶(审批通过后失败重推入口) + */ + @PostMapping("/sync-kingdee") + @ApiOperationSupport(order = 12) + @Operation(summary = "推送金蝶", description = "传入id,仅审批通过的客商可推送,已推送/金蝶已有自动幂等跳过") + public R syncKingdee(@Parameter(description = "主键", required = true) @RequestParam Long id) { + return R.data(customerArchiveService.syncKingdee(id)); + } + /** * 评分明细模板 */ diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CustomerArchiveExcel.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CustomerArchiveExcel.java index cc15e8b6..6c71a297 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CustomerArchiveExcel.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CustomerArchiveExcel.java @@ -105,4 +105,7 @@ public class CustomerArchiveExcel implements Serializable { @ExcelProperty("审核通过时间") private LocalDateTime approvedTime; + @ExcelProperty("金蝶同步状态") + private String kingdeeStatusName; + } diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CustomerArchiveMapper.xml b/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CustomerArchiveMapper.xml index d9df1358..2494a669 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CustomerArchiveMapper.xml +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CustomerArchiveMapper.xml @@ -46,6 +46,9 @@ + + +