|
|
@@ -50,7 +50,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.YearMonth;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -95,8 +97,6 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
|
|
|
@Autowired
|
|
|
private CostDocumentTemplateFileManager costTemplateFileManager;
|
|
|
-
|
|
|
- private static final HashMap<String, Boolean> whMap = new HashMap<>();
|
|
|
|
|
|
@Override
|
|
|
public CostProjectDocument getDetail(String id) {
|
|
|
@@ -201,7 +201,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public void create(CostProjectDocumentReq req) throws Exception {
|
|
|
+ public String create(CostProjectDocumentReq req) throws Exception {
|
|
|
if (ObjectUtil.isEmpty(req.getDocumentId())) {
|
|
|
throw new BaseException("请选择文书模板");
|
|
|
}
|
|
|
@@ -231,9 +231,10 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
if (auditedUnit == null || BaseConstant.DELETE_FLAG.equals(auditedUnit.getIsDeleted())) {
|
|
|
throw new BaseException("被监审单位不存在");
|
|
|
}
|
|
|
- CostDocumentWh costDocumentWh=null;
|
|
|
+ CostDocumentWh costDocumentWh;
|
|
|
//返回文号
|
|
|
String whNo;
|
|
|
+
|
|
|
if (!costDocumentTemplate.getAlias().equals("cbjsgzdg")
|
|
|
&&!costDocumentTemplate.getAlias().equals("cbjsjtsyjl")
|
|
|
&&!costDocumentTemplate.getAlias().equals("cbshcbyjb1")
|
|
|
@@ -245,6 +246,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
//返回文号
|
|
|
whNo = this.getWH(costDocumentWh);
|
|
|
} else {
|
|
|
+ costDocumentWh = null;
|
|
|
whNo = "";
|
|
|
}
|
|
|
LambdaQueryWrapper<CostProjectDocument> qw = new LambdaQueryWrapper<>();
|
|
|
@@ -315,7 +317,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
projectDocument.setId(UniqueIdUtil.getSuid());
|
|
|
projectDocument.setCreateBy(user.getAccount());
|
|
|
projectDocument.setCreateTime(LocalDateTime.now());
|
|
|
- QueryWrapper<CostDocumentWh> wrapper = new QueryWrapper<>();
|
|
|
+ /*QueryWrapper<CostDocumentWh> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq("wh_type","187");
|
|
|
List<CostDocumentWh> list = costDocumentWhManager.list(wrapper);
|
|
|
|
|
|
@@ -325,17 +327,13 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
|
|
|
CostDocumentWh costDocument = list.get(0);
|
|
|
//返回文号
|
|
|
- String whno = this.getWH(costDocument);
|
|
|
- //校验文号唯一性
|
|
|
- /*Boolean bwhno = whMap.get(whNo);
|
|
|
- if (bwhno==null || !bwhno) {
|
|
|
- whMap.put(whno,true);
|
|
|
- }else {
|
|
|
- throw new BaseException("【"+whNo+"】文号已存在请重新添加");
|
|
|
- }*/
|
|
|
- projectDocument.setDocumentNumber(whno);
|
|
|
+ String whno = this.getWH(costDocument);*/
|
|
|
+
|
|
|
+ projectDocument.setDocumentNumber(whNo);
|
|
|
projectDocument.setElectronicDocumentUrl(templateManagerById.getFileUrl());
|
|
|
- projectDocument.setDocumentWhId(costDocument.getId());
|
|
|
+ if(costDocumentWh!=null){
|
|
|
+ projectDocument.setDocumentWhId(costDocumentWh.getId());
|
|
|
+ }
|
|
|
projectDocument.setDocumentId(String.valueOf(templateManagerById.getId()));
|
|
|
projectDocument.setDocumentName(costProjectDocument.getDocumentName()+"-"+templateManagerById.getDocumentName());
|
|
|
projectDocument.setDocumentType(templateManagerById.getType());
|
|
|
@@ -359,7 +357,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
costProjectDocumentFile.setDataValue(costProjectApproval.getOrgName());
|
|
|
break;
|
|
|
case "SongDaWenShuMingCheng":
|
|
|
- costProjectDocumentFile.setDataValue(costDocument.getWhName());
|
|
|
+ costProjectDocumentFile.setDataValue(costDocumentWh.getWhName());
|
|
|
break;
|
|
|
case "SongDaWenShuWenHao":
|
|
|
costProjectDocumentFile.setDataValue(projectDocument.getDocumentNumber());
|
|
|
@@ -395,23 +393,42 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
arrayList.add(costProjectDocumentFile);
|
|
|
});
|
|
|
costProjectDocumentFileManager.saveBatch(arrayList);
|
|
|
- whMap.remove(whNo);
|
|
|
}
|
|
|
|
|
|
//保存解析出的文件内容
|
|
|
costProjectDocumentFileManager.saveBatch(req.getCostProjectDocumentFiles());
|
|
|
- if (costDocumentWh!=null) {
|
|
|
- //更新文号值
|
|
|
- costDocumentWhManager.updateCurrentValue(costDocumentWh.getId());
|
|
|
- }
|
|
|
-
|
|
|
- whMap.remove(whNo);
|
|
|
+ return req.getId();
|
|
|
}
|
|
|
|
|
|
public synchronized String getWH(CostDocumentWh costDocumentWh){
|
|
|
-
|
|
|
+ if("incremental".equals(costDocumentWh.getGenerateType())){
|
|
|
+ costDocumentWh.setCurrentValue(costDocumentWh.getCurrentValue()+1);
|
|
|
+ costDocumentWh.setLastGenerateDate(LocalDate.now());
|
|
|
+ } else if ("daily".equals(costDocumentWh.getGenerateType())) {
|
|
|
+ boolean b = LocalDate.now().isEqual(costDocumentWh.getLastGenerateDate());
|
|
|
+ if (!b) {
|
|
|
+ costDocumentWh.setCurrentValue(costDocumentWh.getCurrentValue()+1);
|
|
|
+ costDocumentWh.setLastGenerateDate(LocalDate.now());
|
|
|
+ }
|
|
|
+ }else if ("monthly".equals(costDocumentWh.getGenerateType())) {
|
|
|
+ LocalDate date = LocalDate.now(); // 获取当前日期
|
|
|
+ YearMonth currentYearMonth = YearMonth.from(date);
|
|
|
+ if (currentYearMonth.equals(YearMonth.from(costDocumentWh.getLastGenerateDate()))) {
|
|
|
+ costDocumentWh.setCurrentValue(costDocumentWh.getCurrentValue()+1);
|
|
|
+ costDocumentWh.setLastGenerateDate(LocalDate.now());
|
|
|
+ }
|
|
|
+ }else if ("yearly".equals(costDocumentWh.getGenerateType())) {
|
|
|
+ LocalDate date = LocalDate.now(); // 获取当前日期
|
|
|
+ // 获取当前年份
|
|
|
+ int currentYear = date.getYear();
|
|
|
+ if (costDocumentWh.getLastGenerateDate().getYear() == currentYear) {
|
|
|
+ costDocumentWh.setCurrentValue(costDocumentWh.getCurrentValue()+1);
|
|
|
+ costDocumentWh.setLastGenerateDate(LocalDate.now());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ costDocumentWhManager.update(costDocumentWh);
|
|
|
return costDocumentWh.getRulePattern().replace("{prefixText}", costDocumentWh.getPrefixText())
|
|
|
- .replace("{year}", costDocumentWh.getYear()).replace("{currentValue}", costDocumentWh.getCurrentValue().toString());
|
|
|
+ .replace("{year}","【" +costDocumentWh.getYear()+"】").replace("{currentValue}", costDocumentWh.getCurrentValue().toString());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -553,7 +570,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
//SimpleStylePreserver.smartReplaceKeepStyle(document,map);
|
|
|
//BestPracticeReplacer.replaceTextBestPractice(document,map);
|
|
|
//BestPracticeReplacer.applySmartStyles(document);
|
|
|
- if (!costProjectDocument.getDocumentAlias().equals("cbjstqzldjb2")) {
|
|
|
+ if (!costProjectDocument.getDocumentAlias().equals("cbjstqzldjb")) {
|
|
|
SmartTemplateWriter.writeToTemplate(document,map);
|
|
|
}else {
|
|
|
List<CostProjectTaskEvidence> costProjectTaskEvidences= costProjectTaskEvidenceManager.findEvidenceListByTaskIds(costProjectDocument.getProjectId(),costProjectDocument.getEnterpriseId());
|