mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-01 19:24:57 +08:00
[fix] 文件管理
This commit is contained in:
parent
ca78b91424
commit
2b29b12235
@ -30,4 +30,7 @@ public class FilePageReqVO extends PageParam {
|
||||
@Schema(description = "目录id", example = "12345646")
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "名称", example = "12345646")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public interface FileMapper extends BaseMapperX<FileDO> {
|
||||
.likeIfPresent(FileDO::getType, reqVO.getType())
|
||||
.betweenIfPresent(FileDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(FileDO::getCategoryId, reqVO.getCategoryId())
|
||||
.likeIfPresent(FileDO::getName, reqVO.getName())
|
||||
.orderByDesc(FileDO::getId));
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@ -61,7 +62,7 @@ public class ProjectRespDetailVO {
|
||||
|
||||
@Schema(description = "漏斗预期", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@ExcelProperty("漏斗预期")
|
||||
private String funnelExpectation;
|
||||
private BigDecimal funnelExpectation;
|
||||
|
||||
@Schema(description = "委托方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@ExcelProperty(value = "委托方式", converter = DictConvert.class)
|
||||
@ -112,7 +113,7 @@ public class ProjectRespDetailVO {
|
||||
|
||||
@Schema(description = "预计合同金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
// @ExcelProperty(value = "预计合同金额", converter = MoneyConvert.class)
|
||||
private String contractAmount;
|
||||
private BigDecimal contractAmount;
|
||||
|
||||
@Schema(description = "客户电话", example = "17656598224")
|
||||
@ExcelProperty("客户电话")
|
||||
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.pms.controller.admin.project.vo;
|
||||
import cn.iocoder.yudao.module.pms.enums.DictTypeConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
@ -47,7 +49,7 @@ public class ProjectRespVO {
|
||||
|
||||
@Schema(description = "预计合同金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1216569")
|
||||
@ExcelProperty("预计合同金额")
|
||||
private String contractAmount;
|
||||
private BigDecimal contractAmount;
|
||||
|
||||
@Schema(description = "客户公司", example = "26238")
|
||||
@ExcelProperty("客户公司")
|
||||
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.pms.controller.admin.project.vo;
|
||||
import cn.iocoder.yudao.framework.common.pojo.FileDTO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
@ -40,9 +42,8 @@ public class ProjectSaveReqVO {
|
||||
@NotEmpty(message = "落地可能性不能为空")
|
||||
private String possibility;
|
||||
|
||||
@Schema(description = "漏斗预期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "漏斗预期不能为空")
|
||||
private String funnelExpectation;
|
||||
@Schema(description = "漏斗预期")
|
||||
private BigDecimal funnelExpectation;
|
||||
|
||||
@Schema(description = "委托方式", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "委托方式不能为空")
|
||||
@ -84,7 +85,7 @@ public class ProjectSaveReqVO {
|
||||
private List<FileDTO> winFileUrl;
|
||||
|
||||
@Schema(description = "预计合同金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private String contractAmount;
|
||||
private BigDecimal contractAmount;
|
||||
|
||||
@Schema(description = "客户电话", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "客户电话不能为空")
|
||||
|
@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.pms.dal.dataobject.project;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.enums.DictTypeConstants;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
@ -75,7 +77,7 @@ public class ProjectDO extends BaseDO {
|
||||
/**
|
||||
* 漏斗预期
|
||||
*/
|
||||
private String funnelExpectation;
|
||||
private BigDecimal funnelExpectation;
|
||||
/**
|
||||
* 委托方式
|
||||
*
|
||||
@ -145,7 +147,7 @@ public class ProjectDO extends BaseDO {
|
||||
/**
|
||||
* 预计合同金额
|
||||
*/
|
||||
private String contractAmount;
|
||||
private BigDecimal contractAmount;
|
||||
/**
|
||||
* 客户电话
|
||||
*/
|
||||
|
@ -58,10 +58,19 @@ public interface ProjectMapper extends BaseMapperX<ProjectDO> {
|
||||
);
|
||||
}
|
||||
|
||||
default ProjectDO selectLastSequence(String prefix) {
|
||||
return selectOne(new LambdaQueryWrapperX<ProjectDO>()
|
||||
.likeRight(ProjectDO::getCode, prefix)
|
||||
.orderByDesc(ProjectDO::getCode)
|
||||
);
|
||||
default ProjectDO selectLastCodeSequence(String prefix, String type) {
|
||||
if ("code".equals(type)) {
|
||||
return selectOne(new LambdaQueryWrapperX<ProjectDO>()
|
||||
.likeRight(ProjectDO::getCode, prefix)
|
||||
.orderByDesc(ProjectDO::getCode)
|
||||
);
|
||||
} else if ("trackingCode".equals(type)) {
|
||||
return selectOne(new LambdaQueryWrapperX<ProjectDO>()
|
||||
.likeRight(ProjectDO::getTrackingCode, prefix)
|
||||
.orderByDesc(ProjectDO::getTrackingCode)
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package cn.iocoder.yudao.module.pms.service.project;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.ProcessStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.FileDTO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.file.FileUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
@ -14,15 +13,14 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDO;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDetailDO;
|
||||
import cn.iocoder.yudao.module.pms.dal.mysql.project.ProjectMapper;
|
||||
import cn.iocoder.yudao.module.pms.enums.ProjectTypeEnum;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstants.PROJECT_NOT_EXISTS;
|
||||
@ -40,6 +38,18 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
* 项目立项审批流程定义
|
||||
*/
|
||||
public static final String PROCESS_KEY = "pms_project_init";
|
||||
/**
|
||||
* 项目跟踪编号前缀
|
||||
*/
|
||||
private static final String TRACKING_PREFIX = "XS";
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
private static final String CODE = "code";
|
||||
/**
|
||||
* 项目跟踪编号
|
||||
*/
|
||||
private static final String TRACKING_CODE = "trackingCode";
|
||||
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@ -50,9 +60,14 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
public Long createProject(Long loginUserId, ProjectSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ProjectDO project = BeanUtils.toBean(createReqVO, ProjectDO.class);
|
||||
|
||||
// 生成跟踪编号
|
||||
project.setTrackingCode(this.generator(TRACKING_PREFIX, 1, TRACKING_CODE));
|
||||
// 处理文件
|
||||
project.setReviewFileUrl(FileUtils.covertFileToJSONString(createReqVO.getReviewFileUrl()));
|
||||
project.setWinFileUrl(FileUtils.covertFileToJSONString(createReqVO.getWinFileUrl()));
|
||||
// 漏斗预期计算
|
||||
BigDecimal funnel = caculateFunnel(project.getPossibility(), project.getContractAmount());
|
||||
project.setFunnelExpectation(funnel);
|
||||
projectMapper.insert(project);
|
||||
// 启动流程
|
||||
if (createReqVO.getId() == null) {
|
||||
@ -73,9 +88,12 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
// 如果审批通过,且项目落地,则生成项目编号 eg. 勘察设计:KS20240001,检测监测:JC20240001,咨询:ZX20240001,数智:SZ20240001
|
||||
if (ProcessStatusEnum.APPROVAL_PASS.getInterval().equals(updateReqVO.getProcessStatus())
|
||||
&& Boolean.TRUE.equals(updateReqVO.getConfirmation())) {
|
||||
String codeNo = this.generator(ProjectTypeEnum.getNoByCode(updateReqVO.getType()), 1);
|
||||
String codeNo = this.generator(ProjectTypeEnum.getNoByCode(updateReqVO.getType()), 1, CODE);
|
||||
updateReqVO.setCode(codeNo);
|
||||
}
|
||||
// 漏斗预期计算
|
||||
BigDecimal funnel = caculateFunnel(updateReqVO.getPossibility(), updateReqVO.getContractAmount());
|
||||
updateReqVO.setFunnelExpectation(funnel);
|
||||
// 更新
|
||||
ProjectDO updateObj = BeanUtils.toBean(updateReqVO, ProjectDO.class);
|
||||
updateObj.setReviewFileUrl(FileUtils.covertFileToJSONString(updateReqVO.getReviewFileUrl()));
|
||||
@ -138,13 +156,13 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
/**
|
||||
* 序号自增
|
||||
* @param prefix 前缀
|
||||
* @param number 步进
|
||||
* @param increment 步进
|
||||
* @return 自增后的序列
|
||||
*/
|
||||
private String generator(String prefix, Integer number) {
|
||||
private String generator(String prefix, Integer increment, String type) {
|
||||
// 获取当前年月日
|
||||
prefix += LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy"));
|
||||
ProjectDO projectDO = projectMapper.selectLastSequence(prefix);
|
||||
ProjectDO projectDO = projectMapper.selectLastCodeSequence(prefix, type);
|
||||
if (projectDO == null) {
|
||||
return prefix + "0001";
|
||||
} else {
|
||||
@ -153,8 +171,29 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
String lastSequence = sequence.substring(sequence.length() - 4);
|
||||
// 自增1
|
||||
int lastNumber = Integer.parseInt(lastSequence);
|
||||
lastNumber = lastNumber + number;
|
||||
lastNumber = lastNumber + increment;
|
||||
return prefix + String.format("%04d", lastNumber);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算漏斗预期 漏斗预期 = 落地可能性 x 预计合同额
|
||||
* @param possibility 落地可能性(百分比)
|
||||
* @param contractAmount 预计合同金额
|
||||
* @return 漏斗预期
|
||||
*/
|
||||
private BigDecimal caculateFunnel(String possibility, BigDecimal contractAmount) {
|
||||
if (possibility.endsWith("%")) {
|
||||
// 去掉百分号
|
||||
String withoutPercent = possibility.replace("%", "");
|
||||
// 转换为BigDecimal
|
||||
BigDecimal possibilityDecimal = new BigDecimal(withoutPercent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
|
||||
// 四舍五入取整
|
||||
return contractAmount.multiply(possibilityDecimal).setScale(0, RoundingMode.DOWN);
|
||||
} else {
|
||||
// 为0
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user