✨ 新增业务部门配置并按平台公司生成合同号与金蝶部门码
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+18
@@ -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<BusinessDeptConfig> result = getSysClient().getBusinessDeptConfig(platformCompanyId, businessDeptId);
|
||||
return result.getData();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
@@ -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<List<InvoiceItem>> getInvoiceItems();
|
||||
|
||||
/**
|
||||
* 按平台公司 + 业务部门获取业务部门配置
|
||||
*
|
||||
* @param platformCompanyId 平台公司ID
|
||||
* @param businessDeptId 业务部门ID
|
||||
* @return 业务部门配置
|
||||
*/
|
||||
@GetMapping(BUSINESS_DEPT_CONFIG)
|
||||
R<BusinessDeptConfig> getBusinessDeptConfig(@RequestParam("platformCompanyId") Long platformCompanyId,
|
||||
@RequestParam("businessDeptId") Long businessDeptId);
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -189,4 +189,9 @@ public class ISysClientFallback implements ISysClient {
|
||||
return R.fail("获取数据失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<BusinessDeptConfig> getBusinessDeptConfig(Long platformCompanyId, Long businessDeptId) {
|
||||
return R.fail("获取数据失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* 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;
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* 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;
|
||||
|
||||
}
|
||||
+6
@@ -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;
|
||||
|
||||
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* 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<BusinessDeptConfigVO> 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<IPage<BusinessDeptConfigVO>> list(BusinessDeptConfigVO businessDeptConfig, Query query) {
|
||||
IPage<BusinessDeptConfigVO> 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<BusinessDeptConfigVO> 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));
|
||||
}
|
||||
|
||||
}
|
||||
+6
-2
@@ -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")
|
||||
|
||||
@@ -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<BusinessDeptConfig> getBusinessDeptConfig(Long platformCompanyId, Long businessDeptId) {
|
||||
return R.data(businessDeptConfigService.getByPlatformAndDept(platformCompanyId, businessDeptId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* 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<BusinessDeptConfig> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页
|
||||
* @param businessDeptConfig 查询条件
|
||||
* @return 分页数据
|
||||
*/
|
||||
List<BusinessDeptConfigVO> selectBusinessDeptConfigPage(IPage<BusinessDeptConfigVO> page,
|
||||
@Param("businessDeptConfig") BusinessDeptConfigVO businessDeptConfig);
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.springblade.system.mapper.BusinessDeptConfigMapper">
|
||||
|
||||
<resultMap id="businessDeptConfigResultMap" type="org.springblade.system.pojo.vo.BusinessDeptConfigVO">
|
||||
<result column="id" property="id"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="platform_company_id" property="platformCompanyId"/>
|
||||
<result column="platform_company_name" property="platformCompanyName"/>
|
||||
<result column="business_dept_id" property="businessDeptId"/>
|
||||
<result column="business_dept_name" property="businessDeptName"/>
|
||||
<result column="contract_code_prefix" property="contractCodePrefix"/>
|
||||
<result column="initial_serial" property="initialSerial"/>
|
||||
<result column="kingdee_company_code" property="kingdeeCompanyCode"/>
|
||||
<result column="kingdee_dept_code" property="kingdeeDeptCode"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_dept" property="createDept"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="create_user_name" property="createUserName"/>
|
||||
<result column="update_user_name" property="updateUserName"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectBusinessDeptConfigPage" resultMap="businessDeptConfigResultMap">
|
||||
SELECT
|
||||
bbc.*,
|
||||
cu.real_name AS create_user_name,
|
||||
uu.real_name AS update_user_name
|
||||
FROM blade_business_dept_config bbc
|
||||
LEFT JOIN blade_user cu ON cu.id = bbc.create_user
|
||||
LEFT JOIN blade_user uu ON uu.id = bbc.update_user
|
||||
WHERE bbc.is_deleted = 0
|
||||
<if test="businessDeptConfig.platformCompanyId != null">
|
||||
AND bbc.platform_company_id = #{businessDeptConfig.platformCompanyId}
|
||||
</if>
|
||||
<if test="businessDeptConfig.businessDeptId != null">
|
||||
AND bbc.business_dept_id = #{businessDeptConfig.businessDeptId}
|
||||
</if>
|
||||
<if test="businessDeptConfig.platformCompanyName != null and businessDeptConfig.platformCompanyName != ''">
|
||||
<bind name="platformCompanyNameLike" value="'%' + businessDeptConfig.platformCompanyName + '%'"/>
|
||||
AND bbc.platform_company_name LIKE #{platformCompanyNameLike}
|
||||
</if>
|
||||
<if test="businessDeptConfig.businessDeptName != null and businessDeptConfig.businessDeptName != ''">
|
||||
<bind name="businessDeptNameLike" value="'%' + businessDeptConfig.businessDeptName + '%'"/>
|
||||
AND bbc.business_dept_name LIKE #{businessDeptNameLike}
|
||||
</if>
|
||||
ORDER BY bbc.create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -90,6 +90,12 @@
|
||||
<if test="param3.fullName!=null and param3.fullName!=''">
|
||||
and dept.full_name like concat(concat('%', #{param3.fullName}),'%')
|
||||
</if>
|
||||
<if test="param3.isPlatformCompany!=null and param3.isPlatformCompany!=''">
|
||||
and dept.is_platform_company = #{param3.isPlatformCompany}
|
||||
</if>
|
||||
<if test="param3.isBusinessDept!=null and param3.isBusinessDept!=''">
|
||||
and dept.is_business_dept = #{param3.isBusinessDept}
|
||||
</if>
|
||||
ORDER BY dept.sort
|
||||
</select>
|
||||
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* 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<BusinessDeptConfig> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页
|
||||
* @param businessDeptConfig 查询条件
|
||||
* @return 分页数据
|
||||
*/
|
||||
IPage<BusinessDeptConfigVO> selectBusinessDeptConfigPage(IPage<BusinessDeptConfigVO> page, BusinessDeptConfigVO businessDeptConfig);
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*
|
||||
* @param businessDeptConfig 配置
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean submit(BusinessDeptConfig businessDeptConfig);
|
||||
|
||||
/**
|
||||
* 按平台公司 + 业务部门查询配置
|
||||
*
|
||||
* @param platformCompanyId 平台公司ID
|
||||
* @param businessDeptId 业务部门ID
|
||||
* @return 配置,不存在返回 null
|
||||
*/
|
||||
BusinessDeptConfig getByPlatformAndDept(Long platformCompanyId, Long businessDeptId);
|
||||
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* 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<BusinessDeptConfigMapper, BusinessDeptConfig>
|
||||
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<BusinessDeptConfigVO> selectBusinessDeptConfigPage(IPage<BusinessDeptConfigVO> 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.<BusinessDeptConfig>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<Long> 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.<BusinessDeptConfig>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;
|
||||
}
|
||||
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* 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<BusinessDeptConfig, BusinessDeptConfigVO> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
+4
-3
@@ -188,10 +188,11 @@ public class ContractManageController extends BladeController {
|
||||
|
||||
@GetMapping("/next-contract-no")
|
||||
@ApiOperationSupport(order = 16)
|
||||
@Operation(summary = "预览下一合同编号", description = "按合同负责部门编码前缀+年份+三位流水预览")
|
||||
@Operation(summary = "预览下一合同编号", description = "按平台公司+业务部门配置的前缀+年份+三位流水预览")
|
||||
public R<String> 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")
|
||||
|
||||
+4
-3
@@ -75,12 +75,13 @@ public interface IContractManageService extends BaseService<ContractManage> {
|
||||
List<ContractManageExcel> 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);
|
||||
|
||||
/**
|
||||
* 合同是否可用于生成结算单:已审批、未终止,且临时合同仍在临时效力期内。
|
||||
|
||||
+31
-13
@@ -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<ContractManageMap
|
||||
contractManage.setOrganizationId(oldRecord.getOrganizationId());
|
||||
contractManage.setOrganizationName(oldRecord.getOrganizationName());
|
||||
}
|
||||
if (Func.isEmpty(contractManage.getPlatformCompanyId())) {
|
||||
contractManage.setPlatformCompanyId(oldRecord.getPlatformCompanyId());
|
||||
contractManage.setPlatformCompanyName(oldRecord.getPlatformCompanyName());
|
||||
}
|
||||
contractManage.setHandlerUserId(oldRecord.getHandlerUserId());
|
||||
contractManage.setHandlerUserName(oldRecord.getHandlerUserName());
|
||||
// 归档状态仅由审核通过逻辑自动维护,保存时保留库中已有值。
|
||||
@@ -760,7 +765,7 @@ public class ContractManageServiceImpl extends BaseServiceImpl<ContractManageMap
|
||||
if (!generateWhenEmpty) {
|
||||
throw new ServiceException("请输入合同编号");
|
||||
}
|
||||
normalizedContractNo = nextContractNo(contractManage.getOrganizationId());
|
||||
normalizedContractNo = nextContractNo(contractManage.getOrganizationId(), contractManage.getPlatformCompanyId());
|
||||
}
|
||||
TransportBusinessSupport.validateLength(normalizedContractNo, 100, "合同编号不能超过100字");
|
||||
String currentContractNo = TransportBusinessSupport.trimToNull(contractManage.getContractNo());
|
||||
@@ -819,30 +824,39 @@ public class ContractManageServiceImpl extends BaseServiceImpl<ContractManageMap
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String nextContractNo(Long organizationId) {
|
||||
public synchronized String nextContractNo(Long organizationId, Long platformCompanyId) {
|
||||
if (Func.isEmpty(organizationId)) {
|
||||
throw new ServiceException("请选择合同负责部门");
|
||||
}
|
||||
if (Func.isEmpty(platformCompanyId)) {
|
||||
throw new ServiceException("请选择平台公司");
|
||||
}
|
||||
Dept dept = SysCache.getDept(organizationId);
|
||||
if (dept == null) {
|
||||
throw new ServiceException("合同负责部门不存在");
|
||||
}
|
||||
String prefix = TransportBusinessSupport.trimToNull(dept.getContractCodePrefix());
|
||||
Dept platformCompany = SysCache.getDept(platformCompanyId);
|
||||
if (platformCompany == null) {
|
||||
throw new ServiceException("平台公司不存在");
|
||||
}
|
||||
BusinessDeptConfig config = SysCache.getBusinessDeptConfig(platformCompanyId, organizationId);
|
||||
String prefix = config == null ? null : TransportBusinessSupport.trimToNull(config.getContractCodePrefix());
|
||||
if (Func.isEmpty(prefix)) {
|
||||
throw new ServiceException("请先在组织机构中配置该部门的合同编码前缀");
|
||||
throw new ServiceException("部门合同前缀未配置,无法自动生成,请手动输入合同编号");
|
||||
}
|
||||
int year = LocalDate.now().getYear();
|
||||
String head = prefix + "(" + year + ")";
|
||||
// 按前缀+年份扫描已占用流水号;系统已有相同流水号则跳过
|
||||
List<ContractManage> latestList = list(Wrappers.<ContractManage>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<ContractManageMap
|
||||
if (!matcher.matches()) {
|
||||
continue;
|
||||
}
|
||||
next = Integer.parseInt(matcher.group(1)) + 1;
|
||||
break;
|
||||
hasMatched = true;
|
||||
maxUsed = Math.max(maxUsed, Integer.parseInt(matcher.group(1)));
|
||||
}
|
||||
// 从初始流水号起编;若系统已有相同或更大流水号则跳到 maxUsed+1
|
||||
int next = hasMatched ? Math.max(initialSerial, maxUsed + 1) : initialSerial;
|
||||
if (next > 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<ContractManageMap
|
||||
TransportBusinessSupport.validateRequired(contractManage.getContractCategory(), "请选择合同类型");
|
||||
TransportBusinessSupport.validateRequired(contractManage.getProjectName(), "请选择所属项目");
|
||||
TransportBusinessSupport.validateRequired(contractManage.getOrganizationName(), "请选择合同负责部门");
|
||||
TransportBusinessSupport.validateRequired(contractManage.getPlatformCompanyName(), "请选择平台公司");
|
||||
ContractPartySupport.validateRequiredParties(contractManage, true);
|
||||
ContractPartySupport.validateBillingPlanBindings(contractManage);
|
||||
validateContractAmountRequired(contractManage);
|
||||
@@ -1197,6 +1214,7 @@ public class ContractManageServiceImpl extends BaseServiceImpl<ContractManageMap
|
||||
TransportBusinessSupport.validateRequired(contractManage.getContractCategory(), "请选择合同类型");
|
||||
TransportBusinessSupport.validateRequired(contractManage.getProjectName(), "请选择所属项目");
|
||||
TransportBusinessSupport.validateRequired(contractManage.getOrganizationName(), "请选择合同负责部门");
|
||||
TransportBusinessSupport.validateRequired(contractManage.getPlatformCompanyName(), "请选择平台公司");
|
||||
TransportBusinessSupport.validateRequired(contractManage.getSettlementCurrency(), "请选择结算币种");
|
||||
TransportBusinessSupport.validateRequired(contractManage.getPartyA(), "请输入甲方");
|
||||
TransportBusinessSupport.validateRequired(contractManage.getPartyB(), "请输入乙方");
|
||||
|
||||
+11
-5
@@ -818,10 +818,16 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
}
|
||||
if (Func.isBlank(entity.getDepartmentEmails())) throw new ServiceException("推送金蝶开票申请失败:部门邮箱(发票推送邮箱)不能为空");
|
||||
if (Func.isBlank(entity.getTaxpayerNo())) throw new ServiceException("推送金蝶开票申请失败:购方纳税人识别号不能为空");
|
||||
// 金蝶组织编码:项目业务部门反查唯一平台公司 → 平台公司金蝶组织编码;申请部门编码:项目业务部门自身金蝶编码(与付款申请单部门.编码同源,共用上下文缓存)
|
||||
// 金蝶组织/申请部门:按首张关联结算单合同的平台公司 + 业务部门配置取数
|
||||
KingdeeSyncContext kingdeeContext = KingdeeSyncContext.empty();
|
||||
String kingdeeOrgNumber = kingdeeApBillSyncSupport.kingdeeOrgNumber(entity.getProjectId(), kingdeeContext);
|
||||
String kingdeeDeptNumber = kingdeeApBillSyncSupport.kingdeeDeptNumber(entity.getProjectId(), kingdeeContext);
|
||||
FormalSettlement firstSettlement = formalSettlementMapper.selectById(relations.get(0).getFormalSettlementId());
|
||||
if (firstSettlement == null || Objects.equals(firstSettlement.getIsDeleted(), 1)) {
|
||||
throw new ServiceException("推送金蝶开票申请失败:正式结算单["
|
||||
+ Func.toStr(relations.get(0).getFormalSettlementNo()) + "]不存在");
|
||||
}
|
||||
ContractManage contract = kingdeeApBillSyncSupport.requireContract(firstSettlement.getContractId(), kingdeeContext);
|
||||
String kingdeeOrgNumber = kingdeeApBillSyncSupport.bfiOrgNumber(contract, kingdeeContext);
|
||||
String kingdeeDeptNumber = kingdeeApBillSyncSupport.kingdeeDeptNumber(contract, entity.getProjectId(), kingdeeContext);
|
||||
CustomerArchive customer = entity.getReceiverCustomerId() == null ? null : customerArchiveMapper.selectById(entity.getReceiverCustomerId());
|
||||
if (customer == null || Func.isBlank(customer.getCustomerCode())) {
|
||||
throw new ServiceException("推送金蝶开票申请失败:受票方客户未在客商档案中维护客商编码,请补充后重试");
|
||||
@@ -909,9 +915,9 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
String firstArSrcCode, BigDecimal sheetAmount, List<BfiInvoiceApplySaveEntryDTO> items) {
|
||||
BfiInvoiceApplySaveDTO param = new BfiInvoiceApplySaveDTO();
|
||||
// ==================== 以下为【必填】字段(BfiInvoiceApplySaveDTO 标注),非必填字段先注释保留 ====================
|
||||
// 【必填】组织.编码:项目业务部门反查唯一平台公司 → 平台公司金蝶组织编码
|
||||
// 【必填】组织.编码:合同平台公司金蝶组织编码
|
||||
param.setOrgidNumber(orgNumber);
|
||||
// 【必填】申请部门.编码:项目业务部门金蝶编码(与付款申请单 awrp_department_number 同源)
|
||||
// 【必填】申请部门.编码:合同平台公司下业务部门配置的金蝶部门代码
|
||||
param.setAwrpOrgfieldNumber(deptNumber);
|
||||
// 【必填】业务单据编号(候选键):单张发票候选 billno(多张发票时开票申请单号-张次序号)
|
||||
param.setBillno(billNo);
|
||||
|
||||
+2
-2
@@ -1254,8 +1254,8 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
param.setAwrpSrcSys(bfiProperties.getSrcSys());
|
||||
// 结算组织.编码
|
||||
param.setSettleorgNumber(orgNumber);
|
||||
// 部门.编码:项目业务部门自身的金蝶编码(结算/申请/付款组织仍传上溯平台公司编码)
|
||||
param.setAwrpDepartmentNumber(kingdeeApBillSyncSupport.kingdeeDeptNumber(contract.getProjectId(), context));
|
||||
// 部门.编码:合同平台公司下业务部门配置的金蝶部门代码
|
||||
param.setAwrpDepartmentNumber(kingdeeApBillSyncSupport.kingdeeDeptNumber(contract, contract.getProjectId(), context));
|
||||
// 【必填】单据类型.编码
|
||||
param.setBilltypeNumber(bfiProperties.getPayApply().getBilltype());
|
||||
// 【必填】申请日期:yyyy-MM-dd HH:mm:ss(各接口统一格式)
|
||||
|
||||
+44
-9
@@ -282,8 +282,8 @@ public class KingdeeApBillSyncSupport {
|
||||
param.setCurrencyNumber(currency);
|
||||
// 【必填】付款组织.编码
|
||||
param.setPayorgNumber(orgNumber);
|
||||
// 部门.编码:项目业务部门自身的金蝶编码(结算/付款组织仍传上溯平台公司编码,口径与付款申请 A103-3 一致)
|
||||
param.setDepartmentNumber(this.kingdeeDeptNumber(contract.getProjectId(), context));
|
||||
// 部门.编码:合同平台公司下业务部门配置的金蝶部门代码
|
||||
param.setDepartmentNumber(this.kingdeeDeptNumber(contract, contract.getProjectId(), context));
|
||||
// 采购组织.编码(非必传)
|
||||
// param.setPurorgNumber(orgNumber);
|
||||
// 【必填】款项性质.编码
|
||||
@@ -962,6 +962,20 @@ public class KingdeeApBillSyncSupport {
|
||||
* @return 组织编码
|
||||
*/
|
||||
public String bfiOrgNumber(ContractManage contract, KingdeeSyncContext context) {
|
||||
if (contract == null) {
|
||||
throw new ServiceException("推送金蝶失败,合同不存在,无法确定金蝶组织编码");
|
||||
}
|
||||
// 优先取合同平台公司金蝶代码;未维护时回退项目业务部门上溯
|
||||
if (contract.getPlatformCompanyId() != null) {
|
||||
Dept platformCompany = SysCache.getDept(contract.getPlatformCompanyId());
|
||||
if (platformCompany == null) {
|
||||
throw new ServiceException("推送金蝶失败,合同平台公司不存在,无法确定金蝶组织编码");
|
||||
}
|
||||
if (Func.isBlank(platformCompany.getKingdeeDeptCode())) {
|
||||
throw new ServiceException("推送金蝶失败,平台公司[" + platformCompany.getDeptName() + "]未维护金蝶组织编码,请检查部门数据");
|
||||
}
|
||||
return platformCompany.getKingdeeDeptCode();
|
||||
}
|
||||
if (contract.getProjectId() == null) {
|
||||
throw new ServiceException("推送金蝶失败,合同[" + Func.toStr(contract.getContractNo()) + "]未关联项目,无法确定金蝶组织编码");
|
||||
}
|
||||
@@ -993,20 +1007,41 @@ public class KingdeeApBillSyncSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* 金蝶部门编码:项目业务部门自身的金蝶编码(blade_dept.kingdee_dept_code,不上溯平台公司),
|
||||
* 用于付款申请单 awrp_department_number(部门.编码);项目未关联/未维护业务部门/业务部门未维护金蝶编码时拦截
|
||||
* 金蝶部门编码:必须取「业务部门配置」中合同平台公司 + 业务部门的金蝶部门代码;
|
||||
* 未配置时拦截推送
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @param context 金蝶同步上下文(缓存载体)
|
||||
* @return 部门编码
|
||||
*/
|
||||
public String kingdeeDeptNumber(Long projectId, KingdeeSyncContext context) {
|
||||
ProjectApply project = this.requireOrgProject(projectId, context);
|
||||
Dept dept = SysCache.getDept(project.getBusinessDeptId());
|
||||
if (dept == null || Func.isBlank(dept.getKingdeeDeptCode())) {
|
||||
throw new ServiceException("推送金蝶失败,项目业务部门[" + Func.toStr(project.getBusinessDeptName()) + "]未维护金蝶编码,请检查部门数据");
|
||||
return kingdeeDeptNumber(null, projectId, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 金蝶部门编码:按合同平台公司下业务部门配置的金蝶部门代码推送
|
||||
*
|
||||
* @param contract 合同(优先取其平台公司、合同负责部门)
|
||||
* @param projectId 项目id(合同未带业务部门时回退项目业务部门)
|
||||
* @param context 金蝶同步上下文(缓存载体)
|
||||
* @return 部门编码
|
||||
*/
|
||||
public String kingdeeDeptNumber(ContractManage contract, Long projectId, KingdeeSyncContext context) {
|
||||
Long platformCompanyId = contract == null ? null : contract.getPlatformCompanyId();
|
||||
Long businessDeptId = contract == null ? null : contract.getOrganizationId();
|
||||
if (businessDeptId == null && projectId != null) {
|
||||
ProjectApply project = this.requireOrgProject(projectId, context);
|
||||
businessDeptId = project.getBusinessDeptId();
|
||||
}
|
||||
return dept.getKingdeeDeptCode();
|
||||
if (platformCompanyId == null || businessDeptId == null) {
|
||||
throw new ServiceException("业务部门对应的金蝶组织代码未配置,单据无法推送,请联系管理员处理。");
|
||||
}
|
||||
org.springblade.system.pojo.entity.BusinessDeptConfig config =
|
||||
SysCache.getBusinessDeptConfig(platformCompanyId, businessDeptId);
|
||||
if (config == null || Func.isBlank(config.getKingdeeDeptCode())) {
|
||||
throw new ServiceException("业务部门对应的金蝶组织代码未配置,单据无法推送,请联系管理员处理。");
|
||||
}
|
||||
return config.getKingdeeDeptCode().trim();
|
||||
}
|
||||
|
||||
/** 金蝶组织/部门编码共用校验:项目存在且已维护业务部门 */
|
||||
|
||||
+2
-2
@@ -218,8 +218,8 @@ public class KingdeeArBillSyncSupport {
|
||||
param.setOrgNumber(orgNumber);
|
||||
// 收款组织.编码:同结算组织
|
||||
param.setRecorgNumber(orgNumber);
|
||||
// 部门.编码:项目业务部门自身的金蝶编码(结算/收款组织仍传上溯平台公司编码,口径与付款申请/应付单一致)
|
||||
param.setDepartmentNumber(kingdeeApBillSyncSupport.kingdeeDeptNumber(contract.getProjectId(), context));
|
||||
// 部门.编码:合同平台公司下业务部门配置的金蝶部门代码
|
||||
param.setDepartmentNumber(kingdeeApBillSyncSupport.kingdeeDeptNumber(contract, contract.getProjectId(), context));
|
||||
// 【必填】单据日期
|
||||
param.setBizdate(billDateText);
|
||||
// 【必填】往来类型:统一固定客户(KingdeeApBillSyncSupport#bfiAsstactType,与应付单/付款申请同口径)
|
||||
|
||||
+3
-1
@@ -185,7 +185,9 @@ public class KingdeeReceivedInvoiceSyncSupport {
|
||||
param.setPaymenttype(BfiConstant.PAY_MODE_CASH);
|
||||
// 【必填】往来类型:统一固定客户(KingdeeApBillSyncSupport#bfiAsstactType,与应付单/付款申请同口径)
|
||||
param.setAsstacttype(kingdeeApBillSyncSupport.bfiAsstactType(contract));
|
||||
// 【必填】结算组织.编码:合同关联项目业务部门反查平台公司(与应付单同源)
|
||||
// 部门金蝶代码校验:收票单主表无部门字段,推送前仍按合同平台公司下业务部门配置校验
|
||||
kingdeeApBillSyncSupport.kingdeeDeptNumber(contract, contract.getProjectId(), context);
|
||||
// 【必填】结算组织.编码:合同平台公司金蝶组织编码(与应付单同源)
|
||||
param.setOrgNumber(kingdeeApBillSyncSupport.bfiOrgNumber(contract, context));
|
||||
// 【必填】结算币别:合同结算币种
|
||||
param.setCurrencyNumber(kingdeeApBillSyncSupport.bfiCurrency(contract));
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
-- 业务部门配置:平台公司 + 业务部门 映射合同编号前缀、初始流水号、金蝶部门代码
|
||||
CREATE TABLE IF NOT EXISTS `blade_business_dept_config` (
|
||||
`id` bigint NOT NULL COMMENT '主键',
|
||||
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '000000' COMMENT '租户ID',
|
||||
`platform_company_id` bigint NOT NULL COMMENT '平台公司ID',
|
||||
`platform_company_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '平台公司名称',
|
||||
`business_dept_id` bigint NOT NULL COMMENT '业务部门ID',
|
||||
`business_dept_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '业务部门名称',
|
||||
`contract_code_prefix` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '合同编码前缀(平台公司简称+业务部门简称)',
|
||||
`initial_serial` int DEFAULT NULL COMMENT '初始流水号(1-999,系统已有相同流水号则跳过)',
|
||||
`kingdee_company_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '金蝶公司代码(取自平台公司组织金蝶代码)',
|
||||
`kingdee_dept_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '金蝶部门代码',
|
||||
`remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
|
||||
`create_user` bigint DEFAULT NULL COMMENT '创建人',
|
||||
`create_dept` bigint DEFAULT NULL COMMENT '创建部门',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_user` bigint DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
|
||||
`status` int DEFAULT 1 COMMENT '状态',
|
||||
`is_deleted` int DEFAULT 0 COMMENT '是否已删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_biz_dept_config_platform` (`platform_company_id`) USING BTREE,
|
||||
KEY `idx_biz_dept_config_dept` (`business_dept_id`) USING BTREE,
|
||||
KEY `idx_biz_dept_config_tenant` (`tenant_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='业务部门配置';
|
||||
|
||||
-- 合同管理增加平台公司字段
|
||||
ALTER TABLE `blade_contract_manage`
|
||||
ADD COLUMN `platform_company_id` bigint DEFAULT NULL COMMENT '平台公司ID' AFTER `organization_name`,
|
||||
ADD COLUMN `platform_company_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '平台公司' AFTER `platform_company_id`;
|
||||
|
||||
-- 系统管理菜单:业务部门配置
|
||||
INSERT INTO `blade_menu` (`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `component`, `remark`, `is_deleted`) VALUES
|
||||
(2080110200000000101, 1123598815738675203, 'business_dept_config', '业务部门配置', 'business_dept_config', '/system/business-dept-config', 'iconfont iconicon_group', 25, 1, 0, 1, NULL, '', 0),
|
||||
(2080110200000000102, 2080110200000000101, 'business_dept_config_add', '新增', 'business_dept_config_add', '', '', 1, 2, 0, 1, NULL, '', 0),
|
||||
(2080110200000000103, 2080110200000000101, 'business_dept_config_edit', '编辑', 'business_dept_config_edit', '', '', 2, 2, 0, 1, NULL, '', 0),
|
||||
(2080110200000000104, 2080110200000000101, 'business_dept_config_delete', '删除', 'business_dept_config_delete', '', '', 3, 2, 0, 1, NULL, '', 0);
|
||||
Reference in New Issue
Block a user