|
@@ -54,6 +54,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
@@ -149,7 +150,7 @@ public class ProjectListService {
|
|
|
return add(dto,tabType);
|
|
|
}
|
|
|
|
|
|
- public String add(ProjectListDto dto,String tabType) throws Exception{
|
|
|
+ public synchronized String add(ProjectListDto dto,String tabType) throws Exception{
|
|
|
String currentToken = TokenProvider.getCurrentToken();
|
|
|
ProgramProjectListInfo info = new ProgramProjectListInfo();
|
|
|
//获取当前登录人信息
|
|
@@ -159,13 +160,17 @@ public class ProjectListService {
|
|
|
String reportNo = "";
|
|
|
String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
if (("true").equals(dto.getGenerateReportNumber())) {
|
|
|
+ // 获取当前日期
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ // 获取当前年份
|
|
|
+ String currentYear = String.valueOf(currentDate.getYear());
|
|
|
if(StringUtils.isNotBlank(info.getReportType())){
|
|
|
//用于查询报告号时不同的报告类型
|
|
|
String type = "";
|
|
|
if (info.getReportType().equals("1")){
|
|
|
//先从报告号作废表中查询当年是否还有未被使用的报告号
|
|
|
type = "报字";
|
|
|
- ProgramReportCancellation infos=reportCancellationMapper.getInfos(type);
|
|
|
+ ProgramReportCancellation infos=reportCancellationMapper.getInfos(type,currentYear);
|
|
|
if (ObjectUtil.isNotEmpty(infos)){
|
|
|
reportNo = infos.getReportNo();
|
|
|
}else {
|
|
@@ -173,7 +178,7 @@ public class ProjectListService {
|
|
|
}
|
|
|
} else if (info.getReportType().equals("2")) {
|
|
|
type = "咨字";
|
|
|
- ProgramReportCancellation infos=reportCancellationMapper.getInfos(type);
|
|
|
+ ProgramReportCancellation infos=reportCancellationMapper.getInfos(type,currentYear);
|
|
|
if (ObjectUtil.isNotEmpty(infos)){
|
|
|
reportNo = infos.getReportNo();
|
|
|
}else {
|
|
@@ -445,7 +450,7 @@ public class ProjectListService {
|
|
|
return programAudit.getId();
|
|
|
}
|
|
|
|
|
|
- public String update(ProjectListDto dto) throws Exception{
|
|
|
+ public synchronized String update(ProjectListDto dto) throws Exception{
|
|
|
String currentToken = TokenProvider.getCurrentToken();
|
|
|
//获取当前登录人信息
|
|
|
UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getByToken(TokenProvider.getCurrentToken());
|
|
@@ -457,6 +462,10 @@ public class ProjectListService {
|
|
|
info.setDelFlag(0);
|
|
|
projectListMapper.updateById(info);
|
|
|
String reportNo = "";
|
|
|
+ // 获取当前日期
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ // 获取当前年份
|
|
|
+ String currentYear = String.valueOf(currentDate.getYear());
|
|
|
if (("true").equals(dto.getGenerateReportNumber())) {
|
|
|
ProgramReportNo programReportNo = programReportNoMapper.selectByProgramId(info.getId());
|
|
|
if (null == programReportNo) {
|
|
@@ -466,7 +475,7 @@ public class ProjectListService {
|
|
|
if (info.getReportType().equals("1")) {
|
|
|
//先从报告号作废表中查询当年是否还有未被使用的报告号
|
|
|
type = "报字";
|
|
|
- ProgramReportCancellation infos = reportCancellationMapper.getInfos(type);
|
|
|
+ ProgramReportCancellation infos = reportCancellationMapper.getInfos(type,currentYear);
|
|
|
if (ObjectUtil.isNotEmpty(infos)) {
|
|
|
reportNo = infos.getReportNo();
|
|
|
} else {
|
|
@@ -474,7 +483,7 @@ public class ProjectListService {
|
|
|
}
|
|
|
}else if (info.getReportType().equals("2")) {
|
|
|
type = "咨字";
|
|
|
- ProgramReportCancellation infos=reportCancellationMapper.getInfos(type);
|
|
|
+ ProgramReportCancellation infos=reportCancellationMapper.getInfos(type,currentYear);
|
|
|
if (ObjectUtil.isNotEmpty(infos)){
|
|
|
reportNo = infos.getReportNo();
|
|
|
}else {
|
|
@@ -494,35 +503,37 @@ public class ProjectListService {
|
|
|
}else {
|
|
|
//判断该报告中的报告号是否被使用
|
|
|
ProgramReportCancellation byReportNo = reportCancellationMapper.getByReportNo(programReportNo.getReportNo());
|
|
|
- if (1 == byReportNo.getDelFlag()){
|
|
|
- //如果该报告号已经被使用,则重新生成新的报告号
|
|
|
- if (("true").equals(info.getGenerateReportNumber())) {
|
|
|
- if(StringUtils.isNotBlank(info.getReportType())){
|
|
|
- //用于查询报告号时不同的报告类型
|
|
|
- String type = "";
|
|
|
- if (info.getReportType().equals("1")){
|
|
|
- //先从报告号作废表中查询当年是否还有未被使用的报告号
|
|
|
- type = "报字";
|
|
|
- ProgramReportCancellation infos=reportCancellationMapper.getInfos(type);
|
|
|
- if (ObjectUtil.isNotEmpty(infos)){
|
|
|
- reportNo = infos.getReportNo();
|
|
|
- }else {
|
|
|
- reportNo = SpringUtil.getBean ( IWorkAttachmentApi.class ).genSerialNum(userDTO.getCompanyDTO().getId(), ProgramReportNoDto.BIZ_CODE,currentToken);
|
|
|
- }
|
|
|
- } else if (info.getReportType().equals("2")) {
|
|
|
- type = "咨字";
|
|
|
- ProgramReportCancellation infos=reportCancellationMapper.getInfos(type);
|
|
|
- if (ObjectUtil.isNotEmpty(infos)){
|
|
|
- reportNo = infos.getReportNo();
|
|
|
- }else {
|
|
|
- reportNo = SpringUtil.getBean ( IWorkAttachmentApi.class ).genSerialNum(userDTO.getCompanyDTO().getId(), ProgramReportNoDto.BIZ_CODE_,currentToken);
|
|
|
+ if (ObjectUtil.isNotEmpty(byReportNo)){
|
|
|
+ if (1 == byReportNo.getDelFlag()){
|
|
|
+ //如果该报告号已经被使用,则重新生成新的报告号
|
|
|
+ if (("true").equals(info.getGenerateReportNumber())) {
|
|
|
+ if(StringUtils.isNotBlank(info.getReportType())){
|
|
|
+ //用于查询报告号时不同的报告类型
|
|
|
+ String type = "";
|
|
|
+ if (info.getReportType().equals("1")){
|
|
|
+ //先从报告号作废表中查询当年是否还有未被使用的报告号
|
|
|
+ type = "报字";
|
|
|
+ ProgramReportCancellation infos=reportCancellationMapper.getInfos(type,currentYear);
|
|
|
+ if (ObjectUtil.isNotEmpty(infos)){
|
|
|
+ reportNo = infos.getReportNo();
|
|
|
+ }else {
|
|
|
+ reportNo = SpringUtil.getBean ( IWorkAttachmentApi.class ).genSerialNum(userDTO.getCompanyDTO().getId(), ProgramReportNoDto.BIZ_CODE,currentToken);
|
|
|
+ }
|
|
|
+ } else if (info.getReportType().equals("2")) {
|
|
|
+ type = "咨字";
|
|
|
+ ProgramReportCancellation infos=reportCancellationMapper.getInfos(type,currentYear);
|
|
|
+ if (ObjectUtil.isNotEmpty(infos)){
|
|
|
+ reportNo = infos.getReportNo();
|
|
|
+ }else {
|
|
|
+ reportNo = SpringUtil.getBean ( IWorkAttachmentApi.class ).genSerialNum(userDTO.getCompanyDTO().getId(), ProgramReportNoDto.BIZ_CODE_,currentToken);
|
|
|
+ }
|
|
|
}
|
|
|
+ ProgramReportNo programReportNo1 = programReportNoMapper.selectByProgramId(info.getId());
|
|
|
+ ProgramReportNo programReport = new ProgramReportNo();
|
|
|
+ programReport.setId(programReportNo1.getId());
|
|
|
+ programReport.setReportNo(reportNo);
|
|
|
+ programReportNoMapper.updateById(programReport);
|
|
|
}
|
|
|
- ProgramReportNo programReportNo1 = programReportNoMapper.selectByProgramId(info.getId());
|
|
|
- ProgramReportNo programReport = new ProgramReportNo();
|
|
|
- programReport.setId(programReportNo1.getId());
|
|
|
- programReport.setReportNo(reportNo);
|
|
|
- programReportNoMapper.updateById(programReport);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2061,10 +2072,12 @@ public class ProjectListService {
|
|
|
reportCancellationMapper.deleteByCanId(reportNo.getId());
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(listInfo.getReportNo())){
|
|
|
+ String number = listInfo.getReportNo().substring(7,11);
|
|
|
ProgramReportCancellation programReportCancellation = new ProgramReportCancellation();
|
|
|
programReportCancellation.setInFlag("1");
|
|
|
programReportCancellation.setReportNo(listInfo.getReportNo());
|
|
|
programReportCancellation.setId(UUID.randomUUID().toString().replace("-",""));
|
|
|
+ programReportCancellation.setNumber(number);
|
|
|
reportCancellationMapper.insert(programReportCancellation);
|
|
|
}
|
|
|
|
|
@@ -2097,6 +2110,10 @@ public class ProjectListService {
|
|
|
//根据id查询项目
|
|
|
ProgramCancellation programCancellation = programCancellationMapper.selectById(dto.getCancellId());
|
|
|
if (ObjectUtil.isNotEmpty(programCancellation)){
|
|
|
+ // 获取当前日期
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ // 获取当前年份
|
|
|
+ String currentYear = String.valueOf(currentDate.getYear());
|
|
|
ProgramProjectListInfo listInfo = projectListMapper.getById(programCancellation.getProjectId());
|
|
|
if (ObjectUtil.isNotEmpty(listInfo) && "true".equals(listInfo.getGenerateReportNumber())){
|
|
|
//根据报告号去报告号作废表中是否有该报告号
|
|
@@ -2117,7 +2134,7 @@ public class ProjectListService {
|
|
|
if (listInfo.getReportType().equals("1")){
|
|
|
//先从报告号作废表中查询当年是否还有未被使用的报告号
|
|
|
type = "报字";
|
|
|
- ProgramReportCancellation infos=reportCancellationMapper.getInfos(type);
|
|
|
+ ProgramReportCancellation infos=reportCancellationMapper.getInfos(type,currentYear);
|
|
|
if (ObjectUtil.isNotEmpty(infos)){
|
|
|
reportNo = infos.getReportNo();
|
|
|
}else {
|
|
@@ -2125,7 +2142,7 @@ public class ProjectListService {
|
|
|
}
|
|
|
} else if (listInfo.getReportType().equals("2")) {
|
|
|
type = "咨字";
|
|
|
- ProgramReportCancellation infos=reportCancellationMapper.getInfos(type);
|
|
|
+ ProgramReportCancellation infos=reportCancellationMapper.getInfos(type,currentYear);
|
|
|
if (ObjectUtil.isNotEmpty(infos)){
|
|
|
reportNo = infos.getReportNo();
|
|
|
}else {
|
|
@@ -2207,4 +2224,29 @@ public class ProjectListService {
|
|
|
reportCancellationMapper.insert(reportCancellation);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据报告号查询该报告号是否被使用
|
|
|
+ * @param reportNo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean getIsUsed(String reportNo) {
|
|
|
+ ProgramReportCancellation reportCancellation = reportCancellationMapper.getByReportNo(reportNo);
|
|
|
+ if (ObjectUtil.isNotEmpty(reportCancellation)){
|
|
|
+ if (reportCancellation.getDelFlag() == 1){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询已作废项目的报告号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ProgramReportNo> getCancelledProject() {
|
|
|
+ //获取已经作废的项目
|
|
|
+ List<ProgramReportNo> list=programReportNoMapper.getCancelledProject();
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|