From fd3ca7496df251cd93416bd264f7ec17837da1bb Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Mon, 2 Nov 2026 21:10:45 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E9=83=A8=E9=97=A8=E9=85=8D=E7=BD=AE=E5=B9=B6=E6=8C=89?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=85=AC=E5=8F=B8=E7=94=9F=E6=88=90=E5=90=88?= =?UTF-8?q?=E5=90=8C=E5=8F=B7=E4=B8=8E=E9=87=91=E8=9D=B6=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .../springblade/system/cache/SysCache.java | 18 ++ .../springblade/system/feign/ISysClient.java | 12 + .../system/feign/ISysClientFallback.java | 5 + .../pojo/entity/BusinessDeptConfig.java | 87 ++++++++ .../system/pojo/vo/BusinessDeptConfigVO.java | 57 +++++ .../transport/pojo/entity/ContractManage.java | 6 + .../BusinessDeptConfigController.java | 133 +++++++++++ .../system/controller/DeptController.java | 8 +- .../springblade/system/feign/SysClient.java | 7 + .../mapper/BusinessDeptConfigMapper.java | 53 +++++ .../mapper/BusinessDeptConfigMapper.xml | 54 +++++ .../springblade/system/mapper/DeptMapper.xml | 6 + .../service/IBusinessDeptConfigService.java | 66 ++++++ .../impl/BusinessDeptConfigServiceImpl.java | 208 ++++++++++++++++++ .../wrapper/BusinessDeptConfigWrapper.java | 56 +++++ .../controller/ContractManageController.java | 7 +- .../service/IContractManageService.java | 7 +- .../impl/ContractManageServiceImpl.java | 44 ++-- .../impl/InvoiceApplicationServiceImpl.java | 16 +- .../impl/PaymentApplicationServiceImpl.java | 4 +- .../support/KingdeeApBillSyncSupport.java | 53 ++++- .../support/KingdeeArBillSyncSupport.java | 4 +- .../KingdeeReceivedInvoiceSyncSupport.java | 4 +- .../blade_business_dept_config_20261102.sql | 37 ++++ 24 files changed, 912 insertions(+), 40 deletions(-) create mode 100644 blade-service-api/blade-system-api/src/main/java/org/springblade/system/pojo/entity/BusinessDeptConfig.java create mode 100644 blade-service-api/blade-system-api/src/main/java/org/springblade/system/pojo/vo/BusinessDeptConfigVO.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/controller/BusinessDeptConfigController.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/mapper/BusinessDeptConfigMapper.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/mapper/BusinessDeptConfigMapper.xml create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/service/IBusinessDeptConfigService.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/service/impl/BusinessDeptConfigServiceImpl.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/wrapper/BusinessDeptConfigWrapper.java create mode 100644 doc/sql/transport/blade_business_dept_config_20261102.sql diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/cache/SysCache.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/cache/SysCache.java index 75ce8ed9..70d5d881 100644 --- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/cache/SysCache.java +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/cache/SysCache.java @@ -65,6 +65,7 @@ public class SysCache { private static final String ROLE_NAMES_ID = "roleNames:id:"; private static final String ROLE_ALIAS_ID = "roleAlias:id:"; private static final String ROLE_ALIASES_ID = "roleAliases:id:"; + private static final String BUSINESS_DEPT_CONFIG = "businessDeptConfig:platformDept:"; public static final String TENANT_ID = "tenant:id:"; public static final String TENANT_TENANT_ID = "tenant:tenantId:"; public static final String TENANT_PACKAGE_ID = "tenant:packageId:"; @@ -381,4 +382,21 @@ public class SysCache { }, Boolean.FALSE); } + /** + * 按平台公司 + 业务部门获取业务部门配置 + * + * @param platformCompanyId 平台公司ID + * @param businessDeptId 业务部门ID + * @return 业务部门配置 + */ + public static BusinessDeptConfig getBusinessDeptConfig(Long platformCompanyId, Long businessDeptId) { + if (platformCompanyId == null || businessDeptId == null) { + return null; + } + return CacheUtil.get(SYS_CACHE, BUSINESS_DEPT_CONFIG, platformCompanyId + StringPool.DASH + businessDeptId, () -> { + R result = getSysClient().getBusinessDeptConfig(platformCompanyId, businessDeptId); + return result.getData(); + }); + } + } diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java index b55af34f..06c2f08a 100644 --- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java @@ -76,6 +76,7 @@ public interface ISysClient { String MEASUREMENT_UNITS = API_PREFIX + "/measurement-units"; String PERMISSIONS = API_PREFIX + "/permissions"; String INVOICE_ITEMS = API_PREFIX + "/invoice-items"; + String BUSINESS_DEPT_CONFIG = API_PREFIX + "/business-dept-config"; /** * 获取菜单 @@ -345,4 +346,15 @@ public interface ISysClient { @GetMapping(INVOICE_ITEMS) R> getInvoiceItems(); + /** + * 按平台公司 + 业务部门获取业务部门配置 + * + * @param platformCompanyId 平台公司ID + * @param businessDeptId 业务部门ID + * @return 业务部门配置 + */ + @GetMapping(BUSINESS_DEPT_CONFIG) + R getBusinessDeptConfig(@RequestParam("platformCompanyId") Long platformCompanyId, + @RequestParam("businessDeptId") Long businessDeptId); + } diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClientFallback.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClientFallback.java index bfb7d123..1579cab4 100644 --- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClientFallback.java +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClientFallback.java @@ -189,4 +189,9 @@ public class ISysClientFallback implements ISysClient { return R.fail("获取数据失败"); } + @Override + public R getBusinessDeptConfig(Long platformCompanyId, Long businessDeptId) { + return R.fail("获取数据失败"); + } + } diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/pojo/entity/BusinessDeptConfig.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/pojo/entity/BusinessDeptConfig.java new file mode 100644 index 00000000..18d08659 --- /dev/null +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/pojo/entity/BusinessDeptConfig.java @@ -0,0 +1,87 @@ +/** + * 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.system.pojo.entity; + +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serial; + +/** + * 业务部门配置实体类 + * + * @author Chill + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("blade_business_dept_config") +@Schema(description = "业务部门配置") +public class BusinessDeptConfig extends TenantEntity { + + @Serial + private static final long serialVersionUID = 1L; + + @JsonSerialize(using = ToStringSerializer.class) + @Schema(description = "平台公司ID") + private Long platformCompanyId; + + @Schema(description = "平台公司名称") + private String platformCompanyName; + + @JsonSerialize(using = ToStringSerializer.class) + @Schema(description = "业务部门ID") + private Long businessDeptId; + + @Schema(description = "业务部门名称") + private String businessDeptName; + + @Schema(description = "合同编码前缀") + private String contractCodePrefix; + + @Schema(description = "初始流水号") + @TableField(updateStrategy = FieldStrategy.ALWAYS) + private Integer initialSerial; + + @Schema(description = "金蝶公司代码") + @TableField(updateStrategy = FieldStrategy.ALWAYS) + private String kingdeeCompanyCode; + + @Schema(description = "金蝶部门代码") + @TableField(updateStrategy = FieldStrategy.ALWAYS) + private String kingdeeDeptCode; + + @Schema(description = "备注") + @TableField(updateStrategy = FieldStrategy.ALWAYS) + private String remark; + +} diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/pojo/vo/BusinessDeptConfigVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/pojo/vo/BusinessDeptConfigVO.java new file mode 100644 index 00000000..a81cbdea --- /dev/null +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/pojo/vo/BusinessDeptConfigVO.java @@ -0,0 +1,57 @@ +/** + * 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.system.pojo.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.system.pojo.entity.BusinessDeptConfig; + +import java.io.Serial; + +/** + * 业务部门配置视图实体类 + * + * @author Chill + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Schema(description = "业务部门配置") +public class BusinessDeptConfigVO extends BusinessDeptConfig { + + @Serial + private static final long serialVersionUID = 1L; + + @TableField(exist = false) + @Schema(description = "创建人姓名") + private String createUserName; + + @TableField(exist = false) + @Schema(description = "更新人姓名") + private String updateUserName; + +} diff --git a/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/ContractManage.java b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/ContractManage.java index 67e108f7..30420d13 100644 --- a/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/ContractManage.java +++ b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/ContractManage.java @@ -67,6 +67,12 @@ public class ContractManage extends TenantEntity { @Schema(description = "合同负责部门") private String organizationName; + @Schema(description = "平台公司ID") + private Long platformCompanyId; + + @Schema(description = "平台公司") + private String platformCompanyName; + @Schema(description = "合同类别") private String contractCategory; diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/BusinessDeptConfigController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/BusinessDeptConfigController.java new file mode 100644 index 00000000..d351b7e6 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/BusinessDeptConfigController.java @@ -0,0 +1,133 @@ +/** + * 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.system.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.annotation.PreAuth; +import org.springblade.core.tenant.annotation.NonDS; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.pojo.entity.BusinessDeptConfig; +import org.springblade.system.pojo.vo.BusinessDeptConfigVO; +import org.springblade.system.service.IBusinessDeptConfigService; +import org.springblade.system.wrapper.BusinessDeptConfigWrapper; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * 业务部门配置控制器 + * + * @author Chill + */ +@NonDS +@RestController +@AllArgsConstructor +@PreAuth(menu = "business_dept_config") +@RequestMapping("/business-dept-config") +@Tag(name = "业务部门配置", description = "业务部门配置") +public class BusinessDeptConfigController extends BladeController { + + private final IBusinessDeptConfigService businessDeptConfigService; + + /** + * 详情 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @Operation(summary = "详情", description = "传入businessDeptConfig") + public R detail(BusinessDeptConfig businessDeptConfig) { + if (Func.isEmpty(businessDeptConfig.getId())) { + return R.fail("主键不能为空"); + } + BusinessDeptConfig detail = businessDeptConfigService.getById(businessDeptConfig.getId()); + if (Func.isEmpty(detail)) { + return R.fail("业务部门配置不存在"); + } + return R.data(BusinessDeptConfigWrapper.build().entityVO(detail)); + } + + /** + * 分页 + */ + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @Operation(summary = "分页", description = "传入businessDeptConfig") + public R> list(BusinessDeptConfigVO businessDeptConfig, Query query) { + IPage pages = businessDeptConfigService.selectBusinessDeptConfigPage( + Condition.getPage(query), businessDeptConfig); + return R.data(pages); + } + + /** + * 新增或修改 + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 3) + @Operation(summary = "新增或修改", description = "传入businessDeptConfig") + public R submit(@Valid @RequestBody BusinessDeptConfig businessDeptConfig) { + return R.status(businessDeptConfigService.submit(businessDeptConfig)); + } + + /** + * 删除 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 4) + @Operation(summary = "逻辑删除", description = "传入ids") + public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { + return R.status(businessDeptConfigService.deleteLogic(Func.toLongList(ids))); + } + + /** + * 按平台公司 + 业务部门查询 + */ + @GetMapping("/by-platform-dept") + @ApiOperationSupport(order = 5) + @Operation(summary = "按平台公司与业务部门查询", description = "传入platformCompanyId、businessDeptId") + public R byPlatformDept( + @Parameter(description = "平台公司ID", required = true) @RequestParam Long platformCompanyId, + @Parameter(description = "业务部门ID", required = true) @RequestParam Long businessDeptId) { + BusinessDeptConfig detail = businessDeptConfigService.getByPlatformAndDept(platformCompanyId, businessDeptId); + if (detail == null) { + return R.data(null); + } + return R.data(BusinessDeptConfigWrapper.build().entityVO(detail)); + } + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java index eafb7b30..c5f370ac 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java @@ -95,7 +95,9 @@ public class DeptController extends BladeController { @Parameters({ @Parameter(name = "deptName", description = "组织名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")), @Parameter(name = "shortName", description = "组织简称", in = ParameterIn.QUERY, schema = @Schema(type = "string")), - @Parameter(name = "fullName", description = "部门全称", in = ParameterIn.QUERY, schema = @Schema(type = "string")) + @Parameter(name = "fullName", description = "部门全称", in = ParameterIn.QUERY, schema = @Schema(type = "string")), + @Parameter(name = "isPlatformCompany", description = "是否平台公司", in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "isBusinessDept", description = "是否业务部门", in = ParameterIn.QUERY, schema = @Schema(type = "integer")) }) @ApiOperationSupport(order = 2) @Operation(summary = "列表", description = "传入dept") @@ -111,7 +113,9 @@ public class DeptController extends BladeController { @Parameters({ @Parameter(name = "deptName", description = "组织名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")), @Parameter(name = "shortName", description = "组织简称", in = ParameterIn.QUERY, schema = @Schema(type = "string")), - @Parameter(name = "fullName", description = "部门全称", in = ParameterIn.QUERY, schema = @Schema(type = "string")) + @Parameter(name = "fullName", description = "部门全称", in = ParameterIn.QUERY, schema = @Schema(type = "string")), + @Parameter(name = "isPlatformCompany", description = "是否平台公司", in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "isBusinessDept", description = "是否业务部门", in = ParameterIn.QUERY, schema = @Schema(type = "integer")) }) @ApiOperationSupport(order = 3) @Operation(summary = "懒加载列表", description = "传入dept") diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java b/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java index a4cf9718..40900821 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java @@ -69,6 +69,7 @@ public class SysClient implements ISysClient { private final ICargoTypeService cargoTypeService; private final IMeasurementUnitService measurementUnitService; private final IInvoiceItemService invoiceItemService; + private final IBusinessDeptConfigService businessDeptConfigService; @Override @GetMapping(MENU) @@ -257,4 +258,10 @@ public class SysClient implements ISysClient { .orderByAsc(InvoiceItem::getCategoryName, InvoiceItem::getShortName))); } + @Override + @GetMapping(BUSINESS_DEPT_CONFIG) + public R getBusinessDeptConfig(Long platformCompanyId, Long businessDeptId) { + return R.data(businessDeptConfigService.getByPlatformAndDept(platformCompanyId, businessDeptId)); + } + } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/BusinessDeptConfigMapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/BusinessDeptConfigMapper.java new file mode 100644 index 00000000..5c66af76 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/BusinessDeptConfigMapper.java @@ -0,0 +1,53 @@ +/** + * 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.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.apache.ibatis.annotations.Param; +import org.springblade.system.pojo.entity.BusinessDeptConfig; +import org.springblade.system.pojo.vo.BusinessDeptConfigVO; + +import java.util.List; + +/** + * 业务部门配置 Mapper 接口 + * + * @author Chill + */ +public interface BusinessDeptConfigMapper extends BaseMapper { + + /** + * 自定义分页 + * + * @param page 分页 + * @param businessDeptConfig 查询条件 + * @return 分页数据 + */ + List selectBusinessDeptConfigPage(IPage page, + @Param("businessDeptConfig") BusinessDeptConfigVO businessDeptConfig); + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/BusinessDeptConfigMapper.xml b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/BusinessDeptConfigMapper.xml new file mode 100644 index 00000000..a954b418 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/BusinessDeptConfigMapper.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml index 1f38b0fd..c1242385 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml @@ -90,6 +90,12 @@ and dept.full_name like concat(concat('%', #{param3.fullName}),'%') + + and dept.is_platform_company = #{param3.isPlatformCompany} + + + and dept.is_business_dept = #{param3.isBusinessDept} + ORDER BY dept.sort diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IBusinessDeptConfigService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IBusinessDeptConfigService.java new file mode 100644 index 00000000..2d305adf --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IBusinessDeptConfigService.java @@ -0,0 +1,66 @@ +/** + * 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.system.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springblade.core.mp.base.BaseService; +import org.springblade.system.pojo.entity.BusinessDeptConfig; +import org.springblade.system.pojo.vo.BusinessDeptConfigVO; + +/** + * 业务部门配置服务类 + * + * @author Chill + */ +public interface IBusinessDeptConfigService extends BaseService { + + /** + * 自定义分页 + * + * @param page 分页 + * @param businessDeptConfig 查询条件 + * @return 分页数据 + */ + IPage selectBusinessDeptConfigPage(IPage page, BusinessDeptConfigVO businessDeptConfig); + + /** + * 新增或修改 + * + * @param businessDeptConfig 配置 + * @return 是否成功 + */ + boolean submit(BusinessDeptConfig businessDeptConfig); + + /** + * 按平台公司 + 业务部门查询配置 + * + * @param platformCompanyId 平台公司ID + * @param businessDeptId 业务部门ID + * @return 配置,不存在返回 null + */ + BusinessDeptConfig getByPlatformAndDept(Long platformCompanyId, Long businessDeptId); + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/BusinessDeptConfigServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/BusinessDeptConfigServiceImpl.java new file mode 100644 index 00000000..6c520b2e --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/BusinessDeptConfigServiceImpl.java @@ -0,0 +1,208 @@ +/** + * 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.system.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import org.springblade.core.cache.utils.CacheUtil; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.mapper.BusinessDeptConfigMapper; +import org.springblade.system.pojo.entity.BusinessDeptConfig; +import org.springblade.system.pojo.entity.Dept; +import org.springblade.system.pojo.vo.BusinessDeptConfigVO; +import org.springblade.system.service.IBusinessDeptConfigService; +import org.springblade.system.service.IDeptService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import lombok.RequiredArgsConstructor; + +import java.util.Objects; + +import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; + +/** + * 业务部门配置服务实现类 + * + * @author Chill + */ +@Service +@RequiredArgsConstructor +public class BusinessDeptConfigServiceImpl extends BaseServiceImpl + implements IBusinessDeptConfigService { + + private static final int PREFIX_MAX_LENGTH = 64; + private static final int CODE_MAX_LENGTH = 64; + private static final int NAME_MAX_LENGTH = 100; + private static final int REMARK_MAX_LENGTH = 200; + private static final int SERIAL_MAX = 999; + + private final IDeptService deptService; + + @Override + public IPage selectBusinessDeptConfigPage(IPage page, + BusinessDeptConfigVO businessDeptConfig) { + return page.setRecords(baseMapper.selectBusinessDeptConfigPage(page, businessDeptConfig)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean submit(BusinessDeptConfig businessDeptConfig) { + prepare(businessDeptConfig); + validate(businessDeptConfig); + boolean success = saveOrUpdate(businessDeptConfig); + if (success) { + CacheUtil.clear(SYS_CACHE); + CacheUtil.clear(SYS_CACHE, Boolean.FALSE); + } + return success; + } + + @Override + public BusinessDeptConfig getByPlatformAndDept(Long platformCompanyId, Long businessDeptId) { + if (Func.isEmpty(platformCompanyId) || Func.isEmpty(businessDeptId)) { + return null; + } + return getOne(Wrappers.lambdaQuery() + .eq(BusinessDeptConfig::getPlatformCompanyId, platformCompanyId) + .eq(BusinessDeptConfig::getBusinessDeptId, businessDeptId) + .eq(BusinessDeptConfig::getIsDeleted, 0) + .last("LIMIT 1"), false); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean deleteLogic(java.util.List ids) { + boolean success = super.deleteLogic(ids); + if (success) { + CacheUtil.clear(SYS_CACHE); + CacheUtil.clear(SYS_CACHE, Boolean.FALSE); + } + return success; + } + + private void prepare(BusinessDeptConfig businessDeptConfig) { + Dept platformCompany = requirePlatformCompany(businessDeptConfig.getPlatformCompanyId()); + Dept businessDept = requireBusinessDept(businessDeptConfig.getBusinessDeptId()); + businessDeptConfig.setPlatformCompanyName(platformCompany.getDeptName()); + businessDeptConfig.setBusinessDeptName(businessDept.getDeptName()); + businessDeptConfig.setContractCodePrefix(trimToEmpty(businessDeptConfig.getContractCodePrefix())); + businessDeptConfig.setKingdeeDeptCode(trimToNull(businessDeptConfig.getKingdeeDeptCode())); + businessDeptConfig.setRemark(trimToNull(businessDeptConfig.getRemark())); + // 金蝶公司代码始终关联平台公司组织中配置的金蝶代码 + businessDeptConfig.setKingdeeCompanyCode(trimToNull(platformCompany.getKingdeeDeptCode())); + if (Func.isEmpty(businessDeptConfig.getStatus())) { + businessDeptConfig.setStatus(1); + } + } + + private void validate(BusinessDeptConfig businessDeptConfig) { + if (Func.isEmpty(businessDeptConfig.getPlatformCompanyId())) { + throw new ServiceException("请选择平台公司"); + } + if (Func.isEmpty(businessDeptConfig.getBusinessDeptId())) { + throw new ServiceException("请选择业务部门"); + } + if (Func.isEmpty(businessDeptConfig.getContractCodePrefix())) { + throw new ServiceException("请输入合同编码前缀"); + } + if (businessDeptConfig.getContractCodePrefix().length() > PREFIX_MAX_LENGTH) { + throw new ServiceException("合同编码前缀不能超过64字"); + } + if (Func.isNotEmpty(businessDeptConfig.getPlatformCompanyName()) + && businessDeptConfig.getPlatformCompanyName().length() > NAME_MAX_LENGTH) { + throw new ServiceException("平台公司名称不能超过100字"); + } + if (Func.isNotEmpty(businessDeptConfig.getBusinessDeptName()) + && businessDeptConfig.getBusinessDeptName().length() > NAME_MAX_LENGTH) { + throw new ServiceException("业务部门名称不能超过100字"); + } + if (Func.isNotEmpty(businessDeptConfig.getKingdeeCompanyCode()) + && businessDeptConfig.getKingdeeCompanyCode().length() > CODE_MAX_LENGTH) { + throw new ServiceException("金蝶公司代码不能超过64字"); + } + if (Func.isNotEmpty(businessDeptConfig.getKingdeeDeptCode()) + && businessDeptConfig.getKingdeeDeptCode().length() > CODE_MAX_LENGTH) { + throw new ServiceException("金蝶部门代码不能超过64字"); + } + if (Func.isNotEmpty(businessDeptConfig.getRemark()) + && businessDeptConfig.getRemark().length() > REMARK_MAX_LENGTH) { + throw new ServiceException("备注不能超过200字"); + } + Integer initialSerial = businessDeptConfig.getInitialSerial(); + if (initialSerial != null && (initialSerial < 1 || initialSerial > SERIAL_MAX)) { + throw new ServiceException("初始流水号必须在1到999之间"); + } + boolean duplicated = count(Wrappers.lambdaQuery() + .eq(BusinessDeptConfig::getPlatformCompanyId, businessDeptConfig.getPlatformCompanyId()) + .eq(BusinessDeptConfig::getBusinessDeptId, businessDeptConfig.getBusinessDeptId()) + .eq(BusinessDeptConfig::getIsDeleted, 0) + .ne(Func.isNotEmpty(businessDeptConfig.getId()), BusinessDeptConfig::getId, businessDeptConfig.getId())) > 0; + if (duplicated) { + throw new ServiceException("该平台公司与业务部门的配置已存在,不能重复添加"); + } + } + + private Dept requirePlatformCompany(Long platformCompanyId) { + if (Func.isEmpty(platformCompanyId)) { + throw new ServiceException("请选择平台公司"); + } + Dept dept = deptService.getById(platformCompanyId); + if (dept == null || Objects.equals(dept.getIsDeleted(), 1)) { + throw new ServiceException("平台公司不存在"); + } + if (!Objects.equals(dept.getIsPlatformCompany(), 1)) { + throw new ServiceException("所选组织不是平台公司"); + } + return dept; + } + + private Dept requireBusinessDept(Long businessDeptId) { + if (Func.isEmpty(businessDeptId)) { + throw new ServiceException("请选择业务部门"); + } + Dept dept = deptService.getById(businessDeptId); + if (dept == null || Objects.equals(dept.getIsDeleted(), 1)) { + throw new ServiceException("业务部门不存在"); + } + if (!Objects.equals(dept.getIsBusinessDept(), 1)) { + throw new ServiceException("所选组织不是业务部门"); + } + return dept; + } + + private String trimToEmpty(String value) { + return value == null ? "" : value.trim(); + } + + private String trimToNull(String value) { + String text = trimToEmpty(value); + return text.isEmpty() ? null : text; + } + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/BusinessDeptConfigWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/BusinessDeptConfigWrapper.java new file mode 100644 index 00000000..e2f8e077 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/BusinessDeptConfigWrapper.java @@ -0,0 +1,56 @@ +/** + * 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.system.wrapper; + +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.system.cache.UserCache; +import org.springblade.system.pojo.entity.BusinessDeptConfig; +import org.springblade.system.pojo.vo.BusinessDeptConfigVO; + +import java.util.Objects; + +/** + * 业务部门配置包装类 + * + * @author Chill + */ +public class BusinessDeptConfigWrapper extends BaseEntityWrapper { + + public static BusinessDeptConfigWrapper build() { + return new BusinessDeptConfigWrapper(); + } + + @Override + public BusinessDeptConfigVO entityVO(BusinessDeptConfig businessDeptConfig) { + BusinessDeptConfigVO businessDeptConfigVO = Objects.requireNonNull( + BeanUtil.copyProperties(businessDeptConfig, BusinessDeptConfigVO.class)); + businessDeptConfigVO.setCreateUserName(UserCache.getUserRealName(businessDeptConfig.getCreateUser())); + businessDeptConfigVO.setUpdateUserName(UserCache.getUserRealName(businessDeptConfig.getUpdateUser())); + return businessDeptConfigVO; + } + +} diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/ContractManageController.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/ContractManageController.java index 364dbcc9..eb0584db 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/ContractManageController.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/ContractManageController.java @@ -188,10 +188,11 @@ public class ContractManageController extends BladeController { @GetMapping("/next-contract-no") @ApiOperationSupport(order = 16) - @Operation(summary = "预览下一合同编号", description = "按合同负责部门编码前缀+年份+三位流水预览") + @Operation(summary = "预览下一合同编号", description = "按平台公司+业务部门配置的前缀+年份+三位流水预览") public R nextContractNo( - @Parameter(description = "合同负责部门ID", required = true) @RequestParam Long organizationId) { - return R.data(contractManageService.nextContractNo(organizationId)); + @Parameter(description = "合同负责部门ID", required = true) @RequestParam Long organizationId, + @Parameter(description = "平台公司ID", required = true) @RequestParam Long platformCompanyId) { + return R.data(contractManageService.nextContractNo(organizationId, platformCompanyId)); } @GetMapping("/export-contract-manage") diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/IContractManageService.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/IContractManageService.java index d4f481b9..7597ecb9 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/IContractManageService.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/IContractManageService.java @@ -75,12 +75,13 @@ public interface IContractManageService extends BaseService { List exportContractManage(ContractManageVO contractManage, String ids); /** - * 预览下一合同编号(按合同负责部门前缀 + 年份 + 三位流水) + * 预览下一合同编号(按平台公司 + 业务部门配置的前缀 + 年份 + 三位流水) * - * @param organizationId 合同负责部门ID + * @param organizationId 合同负责部门(业务部门)ID + * @param platformCompanyId 平台公司ID * @return 预览编号 */ - String nextContractNo(Long organizationId); + String nextContractNo(Long organizationId, Long platformCompanyId); /** * 合同是否可用于生成结算单:已审批、未终止,且临时合同仍在临时效力期内。 diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ContractManageServiceImpl.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ContractManageServiceImpl.java index f81311b6..577569ab 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ContractManageServiceImpl.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ContractManageServiceImpl.java @@ -36,6 +36,7 @@ import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springblade.system.cache.SysCache; import org.springblade.system.cache.UserCache; +import org.springblade.system.pojo.entity.BusinessDeptConfig; import org.springblade.system.pojo.entity.Dept; import org.springblade.transport.constant.HcsSyncConstant; import org.springblade.transport.excel.ContractManageExcel; @@ -736,6 +737,10 @@ public class ContractManageServiceImpl extends BaseServiceImpl latestList = list(Wrappers.lambdaQuery() .select(ContractManage::getContractNo) .eq(ContractManage::getIsDeleted, 0) - .eq(ContractManage::getOrganizationId, organizationId) .likeRight(ContractManage::getContractNo, head) .orderByDesc(ContractManage::getContractNo) - .last("LIMIT 50")); + .last("LIMIT 200")); Pattern pattern = Pattern.compile("^" + Pattern.quote(prefix) + "(" + year + ")(\\d{3})号$"); - // 当年尚无匹配编号时,从组织配置的初始流水号起编;否则在已有最大流水号上加1 - int next = resolveContractInitialSerial(dept); + int initialSerial = resolveContractInitialSerial(config); + int maxUsed = 0; + boolean hasMatched = false; for (ContractManage item : latestList) { String contractNo = TransportBusinessSupport.trimToNull(item.getContractNo()); if (Func.isEmpty(contractNo)) { @@ -852,22 +866,24 @@ public class ContractManageServiceImpl extends BaseServiceImpl 999) { throw new ServiceException("当前部门本年合同流水号已达上限999"); } return head + String.format("%03d", next) + "号"; } - private int resolveContractInitialSerial(Dept dept) { - Integer serial = dept.getContractInitialSerial(); + private int resolveContractInitialSerial(BusinessDeptConfig config) { + Integer serial = config == null ? null : config.getInitialSerial(); if (serial == null || serial < 1) { return 1; } if (serial > 999) { - throw new ServiceException("组织机构中配置的合同初始流水号不能超过999"); + throw new ServiceException("业务部门配置的合同初始流水号不能超过999"); } return serial; } @@ -1163,6 +1179,7 @@ public class ContractManageServiceImpl extends BaseServiceImpl items) { BfiInvoiceApplySaveDTO param = new BfiInvoiceApplySaveDTO(); // ==================== 以下为【必填】字段(BfiInvoiceApplySaveDTO 标注),非必填字段先注释保留 ==================== - // 【必填】组织.编码:项目业务部门反查唯一平台公司 → 平台公司金蝶组织编码 + // 【必填】组织.编码:合同平台公司金蝶组织编码 param.setOrgidNumber(orgNumber); - // 【必填】申请部门.编码:项目业务部门金蝶编码(与付款申请单 awrp_department_number 同源) + // 【必填】申请部门.编码:合同平台公司下业务部门配置的金蝶部门代码 param.setAwrpOrgfieldNumber(deptNumber); // 【必填】业务单据编号(候选键):单张发票候选 billno(多张发票时开票申请单号-张次序号) param.setBillno(billNo); diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/PaymentApplicationServiceImpl.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/PaymentApplicationServiceImpl.java index 98777d55..d7e0a279 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/PaymentApplicationServiceImpl.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/PaymentApplicationServiceImpl.java @@ -1254,8 +1254,8 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl