feat: 添加申请次数和历史license显示差异
This commit is contained in:
@@ -109,6 +109,10 @@ public class LicenseRespVO implements VO {
|
||||
@ExcelProperty("申请时间")
|
||||
private LocalDateTime applicationTime;
|
||||
|
||||
@Schema(description = "申请次数")
|
||||
@ExcelProperty("申请次数")
|
||||
private Integer applyCount;
|
||||
|
||||
private LicenseRespVO oldLicense;
|
||||
|
||||
private boolean hasHistory;
|
||||
|
||||
@@ -123,6 +123,10 @@ public class ProjectRespVO implements VO {
|
||||
@ExcelProperty("评论数")
|
||||
private Integer commentNum;
|
||||
|
||||
@Schema(description = "申请数")
|
||||
@ExcelProperty("申请数")
|
||||
private Integer applyCount;
|
||||
|
||||
@Schema(description = "最后修改时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("最后修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.agt.module.system.api.mail.MailSendApi;
|
||||
import org.agt.module.system.api.mail.dto.MailSendSingleToUserReqDTO;
|
||||
import org.agt.module.system.api.notify.NotifyMessageSendApi;
|
||||
import org.agt.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -480,7 +481,12 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
.eq(LicenseHistoryDO::getLicenseId, license.getId())
|
||||
.orderByDesc(LicenseHistoryDO::getApplicationTime));
|
||||
Optional<LicenseHistoryDO> histroyOptional = historyList.stream().findFirst();
|
||||
license.setHasHistory(histroyOptional.isPresent());
|
||||
license.setHasHistory(LicenseStatusEnum.COMPLETED.getCode().equals(license.getStatus()) || histroyOptional.isPresent());
|
||||
int applyCount = 1;
|
||||
if (histroyOptional.isPresent()) {
|
||||
applyCount = applyCount + historyList.size();
|
||||
}
|
||||
license.setApplyCount(applyCount);
|
||||
if (LicenseStatusEnum.REAPPLYING.getCode().equals(license.getStatus())) {
|
||||
if (histroyOptional.isPresent()) {
|
||||
LicenseHistoryDO historyDO = histroyOptional.get();
|
||||
@@ -492,44 +498,53 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
|
||||
license.setOldLicense(oldLicense);
|
||||
|
||||
int maxLength = oldDetails.size();
|
||||
if (oldDetails.size() < details.size()) {
|
||||
maxLength = details.size();
|
||||
}
|
||||
|
||||
List<LicenseDetailVO> mergeDetails = new ArrayList<>();
|
||||
for (int i = 0; i < maxLength; i++) {
|
||||
Map<String, String> activationCodeMap = new HashMap<>();
|
||||
Map<String, List<Integer>> neListMap = new HashMap<>();
|
||||
Map<String, List<String>> fileUrlListMap = new HashMap<>();
|
||||
|
||||
LicenseDetailVO mergeDetail = new LicenseDetailVO();
|
||||
if (i < oldDetails.size()) {
|
||||
activationCodeMap.put("old", oldDetails.get(i).getActivationCode());
|
||||
neListMap.put("old", oldDetails.get(i).getNeList());
|
||||
fileUrlListMap.put("old", null);
|
||||
mergeDetail.setFileUrl(oldDetails.get(i).getFileUrl());
|
||||
mergeDetail.setNeList(oldDetails.get(i).getNeList());
|
||||
mergeDetail.setActivationCode(oldDetails.get(i).getActivationCode());
|
||||
mergeDetail.setFileUrlList(oldDetails.get(i).getFileUrlList());
|
||||
}
|
||||
|
||||
if (i < details.size()) {
|
||||
activationCodeMap.put("new", details.get(i).getActivationCode());
|
||||
neListMap.put("new", details.get(i).getNeList());
|
||||
fileUrlListMap.put("new", null);
|
||||
}
|
||||
mergeDetail.setActivationCodeMap(activationCodeMap);
|
||||
mergeDetail.setNeListMap(neListMap);
|
||||
mergeDetail.setFileUrlListMap(fileUrlListMap);
|
||||
mergeDetails.add(mergeDetail);
|
||||
}
|
||||
List<LicenseDetailVO> mergeDetails = fillMergeDetails(oldDetails, details, false);
|
||||
license.setNeCodeList(mergeDetails);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static @NotNull List<LicenseDetailVO> fillMergeDetails(List<LicenseDetailVO> oldDetails, List<LicenseDetailVO> details, boolean isHistory) {
|
||||
int maxLength = oldDetails.size();
|
||||
if (oldDetails.size() < details.size()) {
|
||||
maxLength = details.size();
|
||||
}
|
||||
|
||||
List<LicenseDetailVO> mergeDetails = new ArrayList<>();
|
||||
for (int i = 0; i < maxLength; i++) {
|
||||
Map<String, String> activationCodeMap = new HashMap<>();
|
||||
Map<String, List<Integer>> neListMap = new HashMap<>();
|
||||
Map<String, List<String>> fileUrlListMap = new HashMap<>();
|
||||
|
||||
LicenseDetailVO mergeDetail = new LicenseDetailVO();
|
||||
if (i < oldDetails.size()) {
|
||||
activationCodeMap.put("old", oldDetails.get(i).getActivationCode());
|
||||
neListMap.put("old", oldDetails.get(i).getNeList());
|
||||
fileUrlListMap.put("old", null);
|
||||
mergeDetail.setFileUrl(oldDetails.get(i).getFileUrl());
|
||||
mergeDetail.setNeList(oldDetails.get(i).getNeList());
|
||||
mergeDetail.setActivationCode(oldDetails.get(i).getActivationCode());
|
||||
mergeDetail.setFileUrlList(oldDetails.get(i).getFileUrlList());
|
||||
}
|
||||
|
||||
if (i < details.size()) {
|
||||
activationCodeMap.put("new", details.get(i).getActivationCode());
|
||||
neListMap.put("new", details.get(i).getNeList());
|
||||
if (isHistory) {
|
||||
fileUrlListMap.put("old", details.get(i).getFileUrlList());
|
||||
} else {
|
||||
fileUrlListMap.put("new", null);
|
||||
}
|
||||
}
|
||||
mergeDetail.setActivationCodeMap(activationCodeMap);
|
||||
mergeDetail.setNeListMap(neListMap);
|
||||
mergeDetail.setFileUrlListMap(fileUrlListMap);
|
||||
mergeDetails.add(mergeDetail);
|
||||
}
|
||||
return mergeDetails;
|
||||
}
|
||||
|
||||
private void fillDetail(List<LicenseDetailVO> details, LicenseRespVO licenseRespVO) {
|
||||
for (LicenseDetailVO detail : details) {
|
||||
List<String> fileUrlList = new ArrayList<>();
|
||||
@@ -596,13 +611,31 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
|
||||
@Override
|
||||
public List<LicenseRespVO> getLicenseHistory(Long id) {
|
||||
LicenseDO licenseDO = licenseMapper.selectById(id);
|
||||
List<LicenseRespVO> allLicenses = new ArrayList<>();
|
||||
if (LicenseStatusEnum.COMPLETED.getCode().equals(licenseDO.getStatus())) {
|
||||
LicenseRespVO license = BeanUtils.toBean(licenseDO, LicenseRespVO.class);
|
||||
List<LicenseDetailDO> licenseDetailDOS = licenseDetailMapper.selectList(Wrappers.<LicenseDetailDO>lambdaQuery().eq(LicenseDetailDO::getLicenseId, license.getId()));
|
||||
List<LicenseDetailVO> details = BeanUtils.toBean(licenseDetailDOS, LicenseDetailVO.class);
|
||||
fillDetail(details, license);
|
||||
allLicenses.add(license);
|
||||
}
|
||||
List<LicenseHistoryDO> historyDOList = licenseHistoryMapper.selectList(Wrappers.<LicenseHistoryDO>lambdaQuery()
|
||||
.eq(LicenseHistoryDO::getLicenseId, id).orderByDesc(LicenseHistoryDO::getApplicationTime));
|
||||
List<LicenseRespVO> voList = BeanUtils.toBean(historyDOList, LicenseRespVO.class);
|
||||
for (LicenseRespVO licenseRespVO : voList) {
|
||||
fillLicenseHistoryRespVO(licenseRespVO);
|
||||
}
|
||||
return voList;
|
||||
allLicenses.addAll(voList);
|
||||
for (int i = 0; i < allLicenses.size(); i++) {
|
||||
if (i + 1 >= allLicenses.size()) {
|
||||
continue;
|
||||
}
|
||||
allLicenses.get(i).setOldLicense(allLicenses.get(i + 1));
|
||||
List<LicenseDetailVO> mergeDetails = fillMergeDetails(allLicenses.get(i).getOldLicense().getNeCodeList(), allLicenses.get(i).getNeCodeList(), true);
|
||||
allLicenses.get(i).setNeCodeList(mergeDetails);
|
||||
}
|
||||
return allLicenses;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,9 +17,13 @@ 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.ProjectSaveReqVO;
|
||||
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.license.LicenseHistoryDO;
|
||||
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.customer.CustomerMapper;
|
||||
import org.agt.module.license.dal.mysql.license.LicenseHistoryMapper;
|
||||
import org.agt.module.license.dal.mysql.license.LicenseMapper;
|
||||
import org.agt.module.license.dal.mysql.project.ProjectMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -27,6 +31,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.agt.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static org.agt.module.license.enums.ErrorCodeConstants.PROJECT_CODE_DUPLICATE;
|
||||
@@ -53,6 +58,12 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
@Resource
|
||||
private CommentMapper commentMapper;
|
||||
|
||||
@Resource
|
||||
private LicenseMapper licenseMapper;
|
||||
|
||||
@Resource
|
||||
private LicenseHistoryMapper licenseHistoryMapper;
|
||||
|
||||
@Override
|
||||
public Long createProject(ProjectSaveReqVO createReqVO) {
|
||||
// 校验项目名称和编号是否唯一
|
||||
@@ -112,6 +123,17 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
for (ProjectRespVO record : page.getRecords()) {
|
||||
List<CommentTreeRespVO> comments = commentMapper.getCommentList(record.getId());
|
||||
record.setCommentNum(comments.size());
|
||||
|
||||
List<LicenseDO> licenseList = licenseMapper.selectList(Wrappers.<LicenseDO>lambdaQuery().eq(LicenseDO::getProjectId, record.getId()));
|
||||
Optional<LicenseDO> licenseOptional = licenseList.stream().findFirst();
|
||||
int applyCount = 0;
|
||||
if (licenseOptional.isPresent()) {
|
||||
List<LicenseHistoryDO> historyList = licenseHistoryMapper.selectList(Wrappers.<LicenseHistoryDO>lambdaQuery()
|
||||
.eq(LicenseHistoryDO::getLicenseId, licenseOptional.get().getId()));
|
||||
applyCount = 1 + historyList.size();
|
||||
}
|
||||
record.setApplyCount(applyCount);
|
||||
|
||||
}
|
||||
return new PageResult<>(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user