✨ 新增业务部门配置并按平台公司生成合同号与金蝶部门码
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user