feat: 生成编号和删除限制等
This commit is contained in:
@@ -12,10 +12,12 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode CUSTOMER_NAME_DUPLICATE = new ErrorCode(1_100_001_002, "客户名称`{}`已存在");
|
ErrorCode CUSTOMER_NAME_DUPLICATE = new ErrorCode(1_100_001_002, "客户名称`{}`已存在");
|
||||||
ErrorCode CUSTOMER_CODE_DUPLICATE = new ErrorCode(1_100_001_003, "客户编号`{}`已存在");
|
ErrorCode CUSTOMER_CODE_DUPLICATE = new ErrorCode(1_100_001_003, "客户编号`{}`已存在");
|
||||||
ErrorCode CUSTOMER_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_100_001_004, "导入客户数据不能为空!");
|
ErrorCode CUSTOMER_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_100_001_004, "导入客户数据不能为空!");
|
||||||
|
ErrorCode CUSTOMER_EXISTS_PROJECT = new ErrorCode(1_100_001_005, "已存在该客户的项目,请先删除项目");
|
||||||
ErrorCode PROJECT_NOT_EXISTS = new ErrorCode(1_100_002_001, "项目不存在");
|
ErrorCode PROJECT_NOT_EXISTS = new ErrorCode(1_100_002_001, "项目不存在");
|
||||||
ErrorCode PROJECT_NAME_DUPLICATE = new ErrorCode(1_100_002_002, "项目名称`{}`已存在");
|
ErrorCode PROJECT_NAME_DUPLICATE = new ErrorCode(1_100_002_002, "项目名称`{}`已存在");
|
||||||
ErrorCode PROJECT_CODE_DUPLICATE = new ErrorCode(1_100_002_003, "项目编号`{}`已存在");
|
ErrorCode PROJECT_CODE_DUPLICATE = new ErrorCode(1_100_002_003, "项目编号`{}`已存在");
|
||||||
ErrorCode PROJECT_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_100_002_004, "导入项目数据不能为空!");
|
ErrorCode PROJECT_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_100_002_004, "导入项目数据不能为空!");
|
||||||
|
ErrorCode PROJECT_EXISTS_LICENSE = new ErrorCode(1_100_001_005, "已存在该项目的License,请先删除License");
|
||||||
ErrorCode LICENSE_NOT_EXISTS = new ErrorCode(1_100_003_001, "License不存在");
|
ErrorCode LICENSE_NOT_EXISTS = new ErrorCode(1_100_003_001, "License不存在");
|
||||||
ErrorCode LICENSE_SN_DUPLICATE = new ErrorCode(1_100_003_002, "License SN`{}`已存在");
|
ErrorCode LICENSE_SN_DUPLICATE = new ErrorCode(1_100_003_002, "License SN`{}`已存在");
|
||||||
ErrorCode LICENSE_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_100_003_003, "导入License数据不能为空!");
|
ErrorCode LICENSE_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_100_003_003, "导入License数据不能为空!");
|
||||||
|
|||||||
@@ -29,4 +29,7 @@ public class DashboardRespVO {
|
|||||||
|
|
||||||
@Schema(description = "签单率")
|
@Schema(description = "签单率")
|
||||||
private Long signingRate;
|
private Long signingRate;
|
||||||
|
|
||||||
|
@Schema(description = "完成率")
|
||||||
|
private Long completionRate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static org.agt.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static org.agt.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static org.agt.module.license.enums.ErrorCodeConstants.CUSTOMER_CODE_DUPLICATE;
|
import static org.agt.module.license.enums.ErrorCodeConstants.CUSTOMER_CODE_DUPLICATE;
|
||||||
|
import static org.agt.module.license.enums.ErrorCodeConstants.CUSTOMER_EXISTS_PROJECT;
|
||||||
import static org.agt.module.license.enums.ErrorCodeConstants.CUSTOMER_IMPORT_LIST_IS_EMPTY;
|
import static org.agt.module.license.enums.ErrorCodeConstants.CUSTOMER_IMPORT_LIST_IS_EMPTY;
|
||||||
import static org.agt.module.license.enums.ErrorCodeConstants.CUSTOMER_NAME_DUPLICATE;
|
import static org.agt.module.license.enums.ErrorCodeConstants.CUSTOMER_NAME_DUPLICATE;
|
||||||
import static org.agt.module.license.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
import static org.agt.module.license.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
||||||
@@ -82,6 +83,8 @@ public class CustomerServiceImpl implements CustomerService {
|
|||||||
dashboardRespVO.setUserCount(customerMapper.selectUserCount());
|
dashboardRespVO.setUserCount(customerMapper.selectUserCount());
|
||||||
dashboardRespVO.setSigningRate(BigDecimal.valueOf(contractCount).multiply(BigDecimal.valueOf(100))
|
dashboardRespVO.setSigningRate(BigDecimal.valueOf(contractCount).multiply(BigDecimal.valueOf(100))
|
||||||
.divide(BigDecimal.valueOf(projectCount), 0, RoundingMode.HALF_UP).longValue());
|
.divide(BigDecimal.valueOf(projectCount), 0, RoundingMode.HALF_UP).longValue());
|
||||||
|
dashboardRespVO.setCompletionRate(BigDecimal.valueOf(contractCount).multiply(BigDecimal.valueOf(100))
|
||||||
|
.divide(BigDecimal.valueOf(licenseCount), 0, RoundingMode.HALF_UP).longValue());
|
||||||
|
|
||||||
return dashboardRespVO;
|
return dashboardRespVO;
|
||||||
}
|
}
|
||||||
@@ -144,6 +147,10 @@ public class CustomerServiceImpl implements CustomerService {
|
|||||||
if (customerDO == null) {
|
if (customerDO == null) {
|
||||||
throw exception(CUSTOMER_NOT_EXISTS);
|
throw exception(CUSTOMER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
List<ProjectDO> projects = projectMapper.selectList(Wrappers.<ProjectDO>lambdaQuery().eq(ProjectDO::getCustomerId, id));
|
||||||
|
if (CollUtil.isNotEmpty(projects)) {
|
||||||
|
throw exception(CUSTOMER_EXISTS_PROJECT);
|
||||||
|
}
|
||||||
return customerDO;
|
return customerDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +221,7 @@ public class CustomerServiceImpl implements CustomerService {
|
|||||||
@Override
|
@Override
|
||||||
public Integer selectMaxCode() {
|
public Integer selectMaxCode() {
|
||||||
Integer maxCode = customerMapper.selectMaxCode();
|
Integer maxCode = customerMapper.selectMaxCode();
|
||||||
return maxCode == null || maxCode < 2000 ? 2000 : maxCode + 1;
|
return maxCode == null || maxCode < 2000 ? 2000 : maxCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import org.agt.module.license.controller.admin.project.vo.ProjectPageReqVO;
|
|||||||
import org.agt.module.license.controller.admin.project.vo.ProjectRespVO;
|
import org.agt.module.license.controller.admin.project.vo.ProjectRespVO;
|
||||||
import org.agt.module.license.controller.admin.project.vo.ProjectSaveReqVO;
|
import org.agt.module.license.controller.admin.project.vo.ProjectSaveReqVO;
|
||||||
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
|
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
|
||||||
|
import org.agt.module.license.dal.dataobject.license.LicenseDO;
|
||||||
import org.agt.module.license.dal.dataobject.project.ProjectDO;
|
import org.agt.module.license.dal.dataobject.project.ProjectDO;
|
||||||
import org.agt.module.license.dal.mysql.comment.CommentMapper;
|
import org.agt.module.license.dal.mysql.comment.CommentMapper;
|
||||||
import org.agt.module.license.dal.mysql.customer.CustomerMapper;
|
import org.agt.module.license.dal.mysql.customer.CustomerMapper;
|
||||||
@@ -34,6 +35,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.agt.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static org.agt.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static org.agt.module.license.enums.ErrorCodeConstants.PROJECT_CODE_DUPLICATE;
|
import static org.agt.module.license.enums.ErrorCodeConstants.PROJECT_CODE_DUPLICATE;
|
||||||
|
import static org.agt.module.license.enums.ErrorCodeConstants.PROJECT_EXISTS_LICENSE;
|
||||||
import static org.agt.module.license.enums.ErrorCodeConstants.PROJECT_IMPORT_LIST_IS_EMPTY;
|
import static org.agt.module.license.enums.ErrorCodeConstants.PROJECT_IMPORT_LIST_IS_EMPTY;
|
||||||
import static org.agt.module.license.enums.ErrorCodeConstants.PROJECT_NAME_DUPLICATE;
|
import static org.agt.module.license.enums.ErrorCodeConstants.PROJECT_NAME_DUPLICATE;
|
||||||
import static org.agt.module.license.enums.ErrorCodeConstants.PROJECT_NOT_EXISTS;
|
import static org.agt.module.license.enums.ErrorCodeConstants.PROJECT_NOT_EXISTS;
|
||||||
@@ -123,6 +125,10 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
if (projectDO == null) {
|
if (projectDO == null) {
|
||||||
throw exception(PROJECT_NOT_EXISTS);
|
throw exception(PROJECT_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
List<LicenseDO> licenses = licenseMapper.selectList(Wrappers.<LicenseDO>lambdaQuery().eq(LicenseDO::getProjectId, projectDO.getId()));
|
||||||
|
if (CollUtil.isNotEmpty(licenses)) {
|
||||||
|
throw exception(PROJECT_EXISTS_LICENSE);
|
||||||
|
}
|
||||||
return projectDO;
|
return projectDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +204,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
@Override
|
@Override
|
||||||
public Integer selectMaxCode() {
|
public Integer selectMaxCode() {
|
||||||
Integer maxCode = projectMapper.selectMaxCode();
|
Integer maxCode = projectMapper.selectMaxCode();
|
||||||
return maxCode == null || maxCode < 2000 ? 2000 : maxCode + 1;
|
return maxCode == null || maxCode < 2000 ? 2000 : maxCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,7 +3,14 @@
|
|||||||
<mapper namespace="org.agt.module.license.dal.mysql.customer.CustomerMapper">
|
<mapper namespace="org.agt.module.license.dal.mysql.customer.CustomerMapper">
|
||||||
|
|
||||||
<select id="selectMaxCode" resultType="Integer">
|
<select id="selectMaxCode" resultType="Integer">
|
||||||
SELECT max(`code` + 0) from crm_customer;
|
SELECT
|
||||||
|
MIN( t1.num + 1 ) AS next_num
|
||||||
|
FROM
|
||||||
|
( SELECT CAST( `code` AS UNSIGNED ) AS num FROM crm_customer ) t1
|
||||||
|
LEFT JOIN ( SELECT CAST( `code` AS UNSIGNED ) AS num FROM crm_customer ) t2 ON t2.num = t1.num + 1
|
||||||
|
WHERE
|
||||||
|
t2.num IS NULL
|
||||||
|
AND t1.num >= 2000
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUserCount" resultType="Long">
|
<select id="selectUserCount" resultType="Long">
|
||||||
|
|||||||
@@ -3,7 +3,14 @@
|
|||||||
<mapper namespace="org.agt.module.license.dal.mysql.project.ProjectMapper">
|
<mapper namespace="org.agt.module.license.dal.mysql.project.ProjectMapper">
|
||||||
|
|
||||||
<select id="selectMaxCode" resultType="Integer">
|
<select id="selectMaxCode" resultType="Integer">
|
||||||
SELECT max(`code` + 0) from crm_project;
|
SELECT
|
||||||
|
MIN( t1.num + 1 ) AS next_num
|
||||||
|
FROM
|
||||||
|
( SELECT CAST( `code` AS UNSIGNED ) AS num FROM crm_project ) t1
|
||||||
|
LEFT JOIN ( SELECT CAST( `code` AS UNSIGNED ) AS num FROM crm_project ) t2 ON t2.num = t1.num + 1
|
||||||
|
WHERE
|
||||||
|
t2.num IS NULL
|
||||||
|
AND t1.num >= 2000
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectOldMaxCode" resultType="Integer">
|
<select id="selectOldMaxCode" resultType="Integer">
|
||||||
|
|||||||
Reference in New Issue
Block a user