|
@@ -2,6 +2,7 @@ package com.hotent.project.manager.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -18,22 +19,18 @@ import com.hotent.baseInfo.model.CostDocumentTemplateFile;
|
|
|
import com.hotent.baseInfo.model.CostDocumentWh;
|
|
import com.hotent.baseInfo.model.CostDocumentWh;
|
|
|
import com.hotent.config.EipConfig;
|
|
import com.hotent.config.EipConfig;
|
|
|
import com.hotent.constant.BaseConstant;
|
|
import com.hotent.constant.BaseConstant;
|
|
|
-import com.hotent.project.manager.CostProjectApprovalManager;
|
|
|
|
|
-import com.hotent.project.manager.CostProjectDocumentFileManager;
|
|
|
|
|
-import com.hotent.project.manager.CostProjectTaskEvidenceManager;
|
|
|
|
|
-import com.hotent.project.model.CostProjectApproval;
|
|
|
|
|
-import com.hotent.project.model.CostProjectDocument;
|
|
|
|
|
|
|
+import com.hotent.project.manager.*;
|
|
|
|
|
+import com.hotent.project.model.*;
|
|
|
import com.hotent.project.dao.CostProjectDocumentDao;
|
|
import com.hotent.project.dao.CostProjectDocumentDao;
|
|
|
-import com.hotent.project.manager.CostProjectDocumentManager;
|
|
|
|
|
import com.hotent.base.manager.impl.BaseManagerImpl;
|
|
import com.hotent.base.manager.impl.BaseManagerImpl;
|
|
|
-import com.hotent.project.model.CostProjectDocumentFile;
|
|
|
|
|
-import com.hotent.project.model.CostProjectTaskEvidence;
|
|
|
|
|
import com.hotent.project.req.CostProjectDocumentPageReq;
|
|
import com.hotent.project.req.CostProjectDocumentPageReq;
|
|
|
import com.hotent.project.req.CostProjectDocumentReq;
|
|
import com.hotent.project.req.CostProjectDocumentReq;
|
|
|
import com.hotent.project.resp.CostProjectDocumentResp;
|
|
import com.hotent.project.resp.CostProjectDocumentResp;
|
|
|
import com.hotent.uc.api.model.IUser;
|
|
import com.hotent.uc.api.model.IUser;
|
|
|
import com.hotent.uc.exception.BaseException;
|
|
import com.hotent.uc.exception.BaseException;
|
|
|
|
|
+import com.hotent.uc.manager.OrgManager;
|
|
|
import com.hotent.uc.manager.UserManager;
|
|
import com.hotent.uc.manager.UserManager;
|
|
|
|
|
+import com.hotent.uc.model.Org;
|
|
|
import com.hotent.uc.model.User;
|
|
import com.hotent.uc.model.User;
|
|
|
import com.hotent.uc.util.ContextUtil;
|
|
import com.hotent.uc.util.ContextUtil;
|
|
|
import com.hotent.util.FileUtils;
|
|
import com.hotent.util.FileUtils;
|
|
@@ -54,9 +51,12 @@ import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.YearMonth;
|
|
import java.time.YearMonth;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import com.hotent.util.FileUploadUtil;
|
|
import com.hotent.util.FileUploadUtil;
|
|
|
|
|
+import springfox.documentation.spring.web.json.Json;
|
|
|
|
|
|
|
|
import static org.apache.tools.ant.util.DateUtils.ISO8601_DATE_PATTERN;
|
|
import static org.apache.tools.ant.util.DateUtils.ISO8601_DATE_PATTERN;
|
|
|
|
|
|
|
@@ -87,6 +87,9 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
private CostProjectTaskEvidenceManager costProjectTaskEvidenceManager;
|
|
private CostProjectTaskEvidenceManager costProjectTaskEvidenceManager;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ private CostProjectTaskManager costProjectTaskManager;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
private CostDocumentWhManager costDocumentWhManager;
|
|
private CostDocumentWhManager costDocumentWhManager;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -97,6 +100,8 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private CostDocumentTemplateFileManager costTemplateFileManager;
|
|
private CostDocumentTemplateFileManager costTemplateFileManager;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OrgManager orgManager;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public CostProjectDocument getDetail(String id) {
|
|
public CostProjectDocument getDetail(String id) {
|
|
@@ -212,11 +217,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
if (costDocumentTemplate == null || BaseConstant.DELETE_FLAG.equals(costDocumentTemplate.getIsDeleted())) {
|
|
if (costDocumentTemplate == null || BaseConstant.DELETE_FLAG.equals(costDocumentTemplate.getIsDeleted())) {
|
|
|
throw new BaseException("文书模板不存在");
|
|
throw new BaseException("文书模板不存在");
|
|
|
}
|
|
}
|
|
|
- if (!costDocumentTemplate.getAlias().equals("cbjsgzdg")
|
|
|
|
|
- &&!costDocumentTemplate.getAlias().equals("cbjsjtsyjl")
|
|
|
|
|
- &&!costDocumentTemplate.getAlias().equals("cbshcbyjb1")
|
|
|
|
|
- &&!costDocumentTemplate.getAlias().equals("cbjstqzldjb")
|
|
|
|
|
- && ObjectUtil.isEmpty(req.getDocumentNumber())) {
|
|
|
|
|
|
|
+ if (costDocumentTemplate.getIsWh().equals("1")) {
|
|
|
throw new BaseException("请填写通知文号");
|
|
throw new BaseException("请填写通知文号");
|
|
|
}
|
|
}
|
|
|
if (ObjectUtil.isEmpty(req.getEnterpriseId())) {
|
|
if (ObjectUtil.isEmpty(req.getEnterpriseId())) {
|
|
@@ -235,12 +236,9 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
//返回文号
|
|
//返回文号
|
|
|
String whNo;
|
|
String whNo;
|
|
|
|
|
|
|
|
- if (!costDocumentTemplate.getAlias().equals("cbjsgzdg")
|
|
|
|
|
- &&!costDocumentTemplate.getAlias().equals("cbjsjtsyjl")
|
|
|
|
|
- &&!costDocumentTemplate.getAlias().equals("cbshcbyjb1")
|
|
|
|
|
- &&!costDocumentTemplate.getAlias().equals("cbjstqzldjb")) {
|
|
|
|
|
|
|
+ if (costDocumentTemplate.getIsWh().equals("0")) {
|
|
|
costDocumentWh= costDocumentWhManager.get(req.getDocumentWhId());
|
|
costDocumentWh= costDocumentWhManager.get(req.getDocumentWhId());
|
|
|
- if (costDocumentWh == null || BaseConstant.DELETE_FLAG.equals(costDocumentWh.getIsDeleted())) {
|
|
|
|
|
|
|
+ if (costDocumentWh == null) {
|
|
|
throw new BaseException("文书文号不存在");
|
|
throw new BaseException("文书文号不存在");
|
|
|
}
|
|
}
|
|
|
//返回文号
|
|
//返回文号
|
|
@@ -259,6 +257,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
IUser iUser = ContextUtil.getCurrentUser();
|
|
IUser iUser = ContextUtil.getCurrentUser();
|
|
|
User user = userService.getByAccount(iUser.getAccount());
|
|
User user = userService.getByAccount(iUser.getAccount());
|
|
|
CostProjectApproval costProjectApproval = costProjectApprovalManager.get(req.getProjectId());
|
|
CostProjectApproval costProjectApproval = costProjectApprovalManager.get(req.getProjectId());
|
|
|
|
|
+ Org org = orgManager.getById(costProjectApproval.getOrgId());
|
|
|
//类型转换
|
|
//类型转换
|
|
|
CostProjectDocument costProjectDocument = new CostProjectDocument();
|
|
CostProjectDocument costProjectDocument = new CostProjectDocument();
|
|
|
BeanUtil.copyProperties(req, costProjectDocument);
|
|
BeanUtil.copyProperties(req, costProjectDocument);
|
|
@@ -280,7 +279,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
if (StringUtils.isNotBlank(costProjectDocumentFile.getTableName())){
|
|
if (StringUtils.isNotBlank(costProjectDocumentFile.getTableName())){
|
|
|
- if(StringUtil.isEmpty(costProjectDocumentFile.getWhereValue())){
|
|
|
|
|
|
|
+ if(StringUtil.isEmpty(costProjectDocumentFile.getWhereValue()) && StringUtil.isNotEmpty(costProjectDocumentFile.getWhereName())){
|
|
|
costProjectDocumentFile.setWhereValue(costProjectApproval.getProjectId());
|
|
costProjectDocumentFile.setWhereValue(costProjectApproval.getProjectId());
|
|
|
} else if (costProjectDocument.getDocumentAlias().equals("cbjsgzdg")
|
|
} else if (costProjectDocument.getDocumentAlias().equals("cbjsgzdg")
|
|
|
&&!costProjectDocument.getDocumentAlias().equals("cbjsjtsyjl")
|
|
&&!costProjectDocument.getDocumentAlias().equals("cbjsjtsyjl")
|
|
@@ -290,20 +289,33 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
String replace = whereValue1.replace("?", "'" + costProjectApproval.getProjectId() + "'");
|
|
String replace = whereValue1.replace("?", "'" + costProjectApproval.getProjectId() + "'");
|
|
|
String replaced = replace.replace("&", auditedUnit.getUnitId());
|
|
String replaced = replace.replace("&", auditedUnit.getUnitId());
|
|
|
costProjectDocumentFile.setWhereValue(replaced);
|
|
costProjectDocumentFile.setWhereValue(replaced);
|
|
|
|
|
+ String colValue = costTemplateFileManager.getColValue(costProjectDocumentFile.getTableName(), costProjectDocumentFile.getColName(), costProjectDocumentFile.getWhereName(), costProjectDocumentFile.getWhereValue());
|
|
|
|
|
+ //获取whereValue字段值
|
|
|
|
|
+ costProjectDocumentFile.setDataValue(colValue);
|
|
|
|
|
+ } else if (StringUtil.isEmpty(costProjectDocumentFile.getWhereName()) && StringUtil.isEmpty(costProjectDocumentFile.getWhereValue())) {
|
|
|
|
|
+ String tableName = costProjectDocumentFile.getTableName();
|
|
|
|
|
+ List<CostProjectTask> taskByProjectId = costProjectTaskManager.findTaskByProjectId(costProjectApproval.getProjectId(), auditedUnit.getUnitId());
|
|
|
|
|
+ if (taskByProjectId!=null && !taskByProjectId.isEmpty()) {
|
|
|
|
|
+ String replace = tableName.replace("?", "'" + taskByProjectId.get(0).getId() + "'");
|
|
|
|
|
+ String colValue = costTemplateFileManager.getColValue2(replace);
|
|
|
|
|
+ costProjectDocumentFile.setDataValue(colValue);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
String whereValue1 = costProjectDocumentFile.getWhereValue();
|
|
String whereValue1 = costProjectDocumentFile.getWhereValue();
|
|
|
String replace = whereValue1.replace("?", "'" + costProjectApproval.getProjectId() + "'");
|
|
String replace = whereValue1.replace("?", "'" + costProjectApproval.getProjectId() + "'");
|
|
|
costProjectDocumentFile.setWhereValue(replace);
|
|
costProjectDocumentFile.setWhereValue(replace);
|
|
|
|
|
+ String colValue = costTemplateFileManager.getColValue(costProjectDocumentFile.getTableName(), costProjectDocumentFile.getColName(), costProjectDocumentFile.getWhereName(), costProjectDocumentFile.getWhereValue());
|
|
|
|
|
+ //获取whereValue字段值
|
|
|
|
|
+ costProjectDocumentFile.setDataValue(colValue);
|
|
|
}
|
|
}
|
|
|
- String colValue = costTemplateFileManager.getColValue(costProjectDocumentFile.getTableName(), costProjectDocumentFile.getColName(), costProjectDocumentFile.getWhereName(), costProjectDocumentFile.getWhereValue());
|
|
|
|
|
- //获取whereValue字段值
|
|
|
|
|
- costProjectDocumentFile.setDataValue(colValue);
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
- if (!costDocumentTemplate.getAlias().equals("sdhz")) {
|
|
|
|
|
|
|
+ if (costDocumentTemplate.getIsWh().equals("0")) {
|
|
|
|
|
|
|
|
CostDocumentTemplate templateManagerById = costDocumentTemplateManager.getByAlias("sdhz");
|
|
CostDocumentTemplate templateManagerById = costDocumentTemplateManager.getByAlias("sdhz");
|
|
|
if (templateManagerById==null) {
|
|
if (templateManagerById==null) {
|
|
@@ -317,19 +329,9 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
projectDocument.setId(UniqueIdUtil.getSuid());
|
|
projectDocument.setId(UniqueIdUtil.getSuid());
|
|
|
projectDocument.setCreateBy(user.getAccount());
|
|
projectDocument.setCreateBy(user.getAccount());
|
|
|
projectDocument.setCreateTime(LocalDateTime.now());
|
|
projectDocument.setCreateTime(LocalDateTime.now());
|
|
|
- /*QueryWrapper<CostDocumentWh> wrapper = new QueryWrapper<>();
|
|
|
|
|
- wrapper.eq("wh_type","187");
|
|
|
|
|
- List<CostDocumentWh> list = costDocumentWhManager.list(wrapper);
|
|
|
|
|
-
|
|
|
|
|
- if (list == null || list.isEmpty()) {
|
|
|
|
|
- throw new BaseException("文书文号不存在");
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- CostDocumentWh costDocument = list.get(0);
|
|
|
|
|
- //返回文号
|
|
|
|
|
- String whno = this.getWH(costDocument);*/
|
|
|
|
|
|
|
|
|
|
- projectDocument.setDocumentNumber(whNo);
|
|
|
|
|
|
|
+ projectDocument.setDocumentNumber(costProjectDocument.getDocumentNumber());
|
|
|
projectDocument.setElectronicDocumentUrl(templateManagerById.getFileUrl());
|
|
projectDocument.setElectronicDocumentUrl(templateManagerById.getFileUrl());
|
|
|
if(costDocumentWh!=null){
|
|
if(costDocumentWh!=null){
|
|
|
projectDocument.setDocumentWhId(costDocumentWh.getId());
|
|
projectDocument.setDocumentWhId(costDocumentWh.getId());
|
|
@@ -353,11 +355,13 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
costProjectDocumentFile.setProjectDocumentId(projectDocument.getId());
|
|
costProjectDocumentFile.setProjectDocumentId(projectDocument.getId());
|
|
|
//costProjectDocumentFile.setProjectId(costProjectDocument.getProjectId());
|
|
//costProjectDocumentFile.setProjectId(costProjectDocument.getProjectId());
|
|
|
switch (f.getPinyin()) {
|
|
switch (f.getPinyin()) {
|
|
|
- case "JiaGeZhuGuanBuMenHuoChengBenDiaoChaJiGou":
|
|
|
|
|
- costProjectDocumentFile.setDataValue(costProjectApproval.getOrgName());
|
|
|
|
|
|
|
+ case "JiaGeZhuGuanBuMenHuoChengBenJianShenJiGou":
|
|
|
|
|
+ costProjectDocumentFile.setDataValue(org.getName());
|
|
|
break;
|
|
break;
|
|
|
case "SongDaWenShuMingCheng":
|
|
case "SongDaWenShuMingCheng":
|
|
|
- costProjectDocumentFile.setDataValue(costDocumentWh.getWhName());
|
|
|
|
|
|
|
+ if (costDocumentWh!=null) {
|
|
|
|
|
+ costProjectDocumentFile.setDataValue(costDocumentWh.getWhName());
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
case "SongDaWenShuWenHao":
|
|
case "SongDaWenShuWenHao":
|
|
|
costProjectDocumentFile.setDataValue(projectDocument.getDocumentNumber());
|
|
costProjectDocumentFile.setDataValue(projectDocument.getDocumentNumber());
|
|
@@ -369,7 +373,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
costProjectDocumentFile.setDataValue(auditedUnit.getAddress());
|
|
costProjectDocumentFile.setDataValue(auditedUnit.getAddress());
|
|
|
break;
|
|
break;
|
|
|
case "TongZhiSongDaShiJian":
|
|
case "TongZhiSongDaShiJian":
|
|
|
- costProjectDocumentFile.setDataValue(DateUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
|
+ costProjectDocumentFile.setDataValue(DateUtils.format(new Date(),"yyyy-MM-dd"));
|
|
|
break;
|
|
break;
|
|
|
case "BeiJianShenDanWeiLianXiRenDianHua":
|
|
case "BeiJianShenDanWeiLianXiRenDianHua":
|
|
|
costProjectDocumentFile.setDataValue(auditedUnit.getContactMobile());
|
|
costProjectDocumentFile.setDataValue(auditedUnit.getContactMobile());
|
|
@@ -378,18 +382,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
costProjectDocumentFile.setDataValue("");
|
|
costProjectDocumentFile.setDataValue("");
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- /*if (StringUtils.isNotBlank(f.getTableName())){
|
|
|
|
|
- if(StringUtil.isEmpty(costProjectDocumentFile.getWhereValue())){
|
|
|
|
|
- costProjectDocumentFile.setWhereValue(costProjectApproval.getProjectId());
|
|
|
|
|
- }else {
|
|
|
|
|
- String whereValue1 = costProjectDocumentFile.getWhereValue();
|
|
|
|
|
- String replace = whereValue1.replace("?", "'" + costProjectApproval.getProjectId() + "'");
|
|
|
|
|
- costProjectDocumentFile.setWhereValue(replace);
|
|
|
|
|
- }
|
|
|
|
|
- String colValue = costTemplateFileManager.getColValue(costProjectDocumentFile.getTableName(), costProjectDocumentFile.getColName(), costProjectDocumentFile.getWhereName(), costProjectDocumentFile.getWhereValue());
|
|
|
|
|
- //获取whereValue字段值
|
|
|
|
|
- costProjectDocumentFile.setDataValue(colValue);
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
+
|
|
|
arrayList.add(costProjectDocumentFile);
|
|
arrayList.add(costProjectDocumentFile);
|
|
|
});
|
|
});
|
|
|
costProjectDocumentFileManager.saveBatch(arrayList);
|
|
costProjectDocumentFileManager.saveBatch(arrayList);
|
|
@@ -454,9 +447,8 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
if (ObjectUtil.isEmpty(req.getProjectId())) {
|
|
if (ObjectUtil.isEmpty(req.getProjectId())) {
|
|
|
throw new BaseException("请选择项目");
|
|
throw new BaseException("请选择项目");
|
|
|
}
|
|
}
|
|
|
- if (ObjectUtil.isEmpty(req.getDocumentNumber())) {
|
|
|
|
|
- throw new BaseException("请填写通知文号");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (ObjectUtil.isEmpty(req.getEnterpriseId())) {
|
|
if (ObjectUtil.isEmpty(req.getEnterpriseId())) {
|
|
|
throw new BaseException("请选择监审单位");
|
|
throw new BaseException("请选择监审单位");
|
|
|
}
|
|
}
|
|
@@ -468,19 +460,24 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
req.setIsPushed("1");
|
|
req.setIsPushed("1");
|
|
|
|
|
|
|
|
CostDocumentTemplate costDocumentTemplate = this.costDocumentTemplateManager.get(req.getDocumentId());
|
|
CostDocumentTemplate costDocumentTemplate = this.costDocumentTemplateManager.get(req.getDocumentId());
|
|
|
|
|
+
|
|
|
if (costDocumentTemplate == null || BaseConstant.DELETE_FLAG.equals(costDocumentTemplate.getIsDeleted())) {
|
|
if (costDocumentTemplate == null || BaseConstant.DELETE_FLAG.equals(costDocumentTemplate.getIsDeleted())) {
|
|
|
throw new BaseException("文书模板不存在");
|
|
throw new BaseException("文书模板不存在");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (costDocumentTemplate.getIsWh().equals("1")) {
|
|
|
|
|
+ throw new BaseException("请填写通知文号");
|
|
|
|
|
+ }
|
|
|
req.setDocumentAlias(costDocumentTemplate.getAlias());
|
|
req.setDocumentAlias(costDocumentTemplate.getAlias());
|
|
|
AuditedUnit auditedUnit = auditedUnitManager.get(req.getEnterpriseId());
|
|
AuditedUnit auditedUnit = auditedUnitManager.get(req.getEnterpriseId());
|
|
|
if (auditedUnit == null || BaseConstant.DELETE_FLAG.equals(auditedUnit.getIsDeleted())) {
|
|
if (auditedUnit == null || BaseConstant.DELETE_FLAG.equals(auditedUnit.getIsDeleted())) {
|
|
|
throw new BaseException("被监审单位不存在");
|
|
throw new BaseException("被监审单位不存在");
|
|
|
}
|
|
}
|
|
|
CostDocumentWh costDocumentWh = costDocumentWhManager.get(req.getDocumentWhId());
|
|
CostDocumentWh costDocumentWh = costDocumentWhManager.get(req.getDocumentWhId());
|
|
|
- if (costDocumentWh == null || BaseConstant.DELETE_FLAG.equals(costDocumentWh.getIsDeleted())) {
|
|
|
|
|
- throw new BaseException("文书文号不存在");
|
|
|
|
|
|
|
+ if(costDocumentTemplate.getIsWh().equals("1")){
|
|
|
|
|
+ if (costDocumentWh == null || BaseConstant.DELETE_FLAG.equals(costDocumentWh.getIsDeleted())) {
|
|
|
|
|
+ throw new BaseException("文书文号不存在");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
LambdaQueryWrapper<CostProjectDocument> qw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<CostProjectDocument> qw = new LambdaQueryWrapper<>();
|
|
|
qw.eq(CostProjectDocument::getProjectId, req.getProjectId());
|
|
qw.eq(CostProjectDocument::getProjectId, req.getProjectId());
|
|
|
qw.eq(CostProjectDocument::getDocumentId, req.getDocumentId());
|
|
qw.eq(CostProjectDocument::getDocumentId, req.getDocumentId());
|
|
@@ -496,16 +493,7 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
// 类型转换
|
|
// 类型转换
|
|
|
BeanUtil.copyProperties(req,selectCostProjectDocument);
|
|
BeanUtil.copyProperties(req,selectCostProjectDocument);
|
|
|
super.update(selectCostProjectDocument);
|
|
super.update(selectCostProjectDocument);
|
|
|
- /*costProjectDocumentFileManager.remove(new LambdaQueryWrapper<CostProjectDocumentFile>().eq(CostProjectDocumentFile::getProjectId,selectCostProjectDocument.getProjectId()));
|
|
|
|
|
- List<CostProjectDocumentFile> costProjectDocumentFiles = req.getCostProjectDocumentFiles();
|
|
|
|
|
- if (costProjectDocumentFiles != null){
|
|
|
|
|
- for (CostProjectDocumentFile costProjectDocumentFile : costProjectDocumentFiles) {
|
|
|
|
|
- costProjectDocumentFile.setDocumentId(selectCostProjectDocument.getDocumentId());
|
|
|
|
|
- costProjectDocumentFile.setProjectId(selectCostProjectDocument.getProjectId());
|
|
|
|
|
- //costProjectDocumentFile.setProjectDocumentId(selectCostProjectDocument.);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- }*/
|
|
|
|
|
req.getCostProjectDocumentFiles().forEach(f->{
|
|
req.getCostProjectDocumentFiles().forEach(f->{
|
|
|
f.setProjectDocumentId(selectCostProjectDocument.getId());
|
|
f.setProjectDocumentId(selectCostProjectDocument.getId());
|
|
|
});
|
|
});
|
|
@@ -565,32 +553,49 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
XWPFDocument document = new XWPFDocument(fis);
|
|
XWPFDocument document = new XWPFDocument(fis);
|
|
|
FileOutputStream fos = FileUtils.createFileOutputStream(outputPath);) {
|
|
FileOutputStream fos = FileUtils.createFileOutputStream(outputPath);) {
|
|
|
|
|
|
|
|
- //FileOutputStream fos = new FileOutputStream(outputPath);
|
|
|
|
|
- //SimpleStylePreserver.smartReplaceKeepStyle(document,map);
|
|
|
|
|
- //BestPracticeReplacer.replaceTextBestPractice(document,map);
|
|
|
|
|
- //BestPracticeReplacer.applySmartStyles(document);
|
|
|
|
|
- if (!costProjectDocument.getDocumentAlias().equals("cbjstqzldjb")) {
|
|
|
|
|
- SmartTemplateWriter.writeToTemplate(document,map);
|
|
|
|
|
- }else {
|
|
|
|
|
- List<CostProjectTaskEvidence> costProjectTaskEvidences= costProjectTaskEvidenceManager.findEvidenceListByTaskIds(costProjectDocument.getProjectId(),costProjectDocument.getEnterpriseId());
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (costProjectDocument.getDocumentAlias().equals("cbjstqzldjb")) {
|
|
|
|
|
+ List<CostProjectTaskEvidence> costProjectTaskEvidences= costProjectTaskEvidenceManager.findEvidenceListByTaskIds(costProjectDocument.getProjectId(),costProjectDocument.getEnterpriseId());
|
|
|
if (!costProjectTaskEvidences.isEmpty()) {
|
|
if (!costProjectTaskEvidences.isEmpty()) {
|
|
|
List<CompleteTemplateProcessor.TableRowData> mapList = costProjectTaskEvidences.stream().map(c -> {
|
|
List<CompleteTemplateProcessor.TableRowData> mapList = costProjectTaskEvidences.stream().map(c -> {
|
|
|
CompleteTemplateProcessor.TableRowData tableRowData = new CompleteTemplateProcessor.TableRowData();
|
|
CompleteTemplateProcessor.TableRowData tableRowData = new CompleteTemplateProcessor.TableRowData();
|
|
|
- /*Map<String, Object> hashMap = new HashMap<>();
|
|
|
|
|
- hashMap.put("pageCount",c.getPageCount());
|
|
|
|
|
- hashMap.put("remark",c.getRemark());
|
|
|
|
|
- hashMap.put("documentName",c.getMaterialName());*/
|
|
|
|
|
|
|
+
|
|
|
tableRowData.setDocumentName(c.getMaterialName());
|
|
tableRowData.setDocumentName(c.getMaterialName());
|
|
|
tableRowData.setRemark(c.getRemark());
|
|
tableRowData.setRemark(c.getRemark());
|
|
|
tableRowData.setPageCount(c.getPageCount());
|
|
tableRowData.setPageCount(c.getPageCount());
|
|
|
return tableRowData;
|
|
return tableRowData;
|
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
- //int sum = costProjectTaskEvidences.stream().mapToInt(CostProjectTaskEvidence::getPageCount).sum();
|
|
|
|
|
- //SimpleTableFiller.fillTableSimple(document,null,mapList,costProjectTaskEvidences.size(),sum,DateUtils.format(new Date(),ISO8601_DATE_PATTERN));
|
|
|
|
|
AuditedUnit auditedUnit = auditedUnitManager.get(costProjectDocument.getEnterpriseId());
|
|
AuditedUnit auditedUnit = auditedUnitManager.get(costProjectDocument.getEnterpriseId());
|
|
|
|
|
|
|
|
CompleteTemplateProcessor.processTemplateComplete(document,auditedUnit.getUnitName(),mapList,DateUtils.format(new Date(),ISO8601_DATE_PATTERN));
|
|
CompleteTemplateProcessor.processTemplateComplete(document,auditedUnit.getUnitName(),mapList,DateUtils.format(new Date(),ISO8601_DATE_PATTERN));
|
|
|
}
|
|
}
|
|
|
|
|
+ } else if (costProjectDocument.getDocumentAlias().equals("zfdjcbjsjlbg4")) {
|
|
|
|
|
+ CostProjectApproval costProjectApproval = costProjectApprovalManager.get(costProjectDocument.getProjectId());
|
|
|
|
|
+
|
|
|
|
|
+ List<CostProjectTask> taskByProjectId = costProjectTaskManager.findTaskByProjectId(costProjectApproval.getProjectId(), costProjectDocument.getEnterpriseId());
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String,Object>> maps= costTemplateFileManager.getSurveyTemplate(taskByProjectId.get(0).getId());
|
|
|
|
|
+
|
|
|
|
|
+ //Map<String, Object> map1 = processCostData(maps);
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
|
+ List<String> years = (List<String>) processCostData(maps).get("years");
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
|
+ List<Map<String, Object>> costItems = (List<Map<String, Object>>) processCostData(maps).get("costItems");
|
|
|
|
|
+ System.err.println("years-----"+ JSON.toJSONString(years));
|
|
|
|
|
+ System.err.println("costItems-----"+ JSON.toJSONString(costItems));
|
|
|
|
|
+
|
|
|
|
|
+ // 处理文档
|
|
|
|
|
+ RobustComplexDocumentProcessor.processDocumentWithMaps(
|
|
|
|
|
+ document,
|
|
|
|
|
+ map,
|
|
|
|
|
+ years,
|
|
|
|
|
+ costItems
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ // 保存结果
|
|
|
|
|
+ //document.write(new FileOutputStream("Map版处理完成的文档.docx"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SmartTemplateWriter.writeToTemplate(document,map);
|
|
|
}
|
|
}
|
|
|
document.write(fos);
|
|
document.write(fos);
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
@@ -601,6 +606,152 @@ public class CostProjectDocumentManagerImpl extends BaseManagerImpl<CostProjectD
|
|
|
return EipConfig.getImgUrl()+FileUploadUtil.getPathFileName(outputPath,fileName);
|
|
return EipConfig.getImgUrl()+FileUploadUtil.getPathFileName(outputPath,fileName);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 或者直接在Service中处理
|
|
|
|
|
+ public Map<String, Object> processCostData(List<Map<String, Object>> rawData) {
|
|
|
|
|
+ // 如果数据为空,返回空结构
|
|
|
|
|
+ if (rawData == null || rawData.isEmpty()) {
|
|
|
|
|
+ Map<String, Object> emptyResult = new HashMap<>();
|
|
|
|
|
+ emptyResult.put("years", new ArrayList<String>());
|
|
|
|
|
+ emptyResult.put("costItems", new ArrayList<Map<String, Object>>());
|
|
|
|
|
+ return emptyResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 1. 提取所有年份
|
|
|
|
|
+ Set<String> years = new TreeSet<>();
|
|
|
|
|
+ // 按项目名称分组:项目名 -> (年份 -> 值)
|
|
|
|
|
+ Map<String, Map<String, String>> projectData = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (Map<String, Object> row : rawData) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 安全获取字段
|
|
|
|
|
+ String rkey = getStringValue(row, "rkey");
|
|
|
|
|
+ String projectName = getStringValue(row, "xm");
|
|
|
|
|
+ Object rvalueObj = row.get("rvalue");
|
|
|
|
|
+
|
|
|
|
|
+ if (rkey == null || projectName == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 提取年份(从"2024年核定值"中提取"2024")
|
|
|
|
|
+ String year = extractYear(rkey);
|
|
|
|
|
+ if (year == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 添加到年份集合
|
|
|
|
|
+ years.add(year);
|
|
|
|
|
+
|
|
|
|
|
+ // 转换值为字符串
|
|
|
|
|
+ String value = "";
|
|
|
|
|
+ if (rvalueObj != null) {
|
|
|
|
|
+ String strValue = rvalueObj.toString().trim();
|
|
|
|
|
+ if (!strValue.isEmpty()) {
|
|
|
|
|
+ value = strValue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 存储到项目数据中
|
|
|
|
|
+ projectData.putIfAbsent(projectName, new HashMap<>());
|
|
|
|
|
+ projectData.get(projectName).put(year, value);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ // 跳过错误数据
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 构建costItems列表
|
|
|
|
|
+ List<Map<String, Object>> costItems = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 按项目名称排序
|
|
|
|
|
+ List<String> sortedProjectNames = new ArrayList<>(projectData.keySet());
|
|
|
|
|
+ Collections.sort(sortedProjectNames);
|
|
|
|
|
+
|
|
|
|
|
+ for (String projectName : sortedProjectNames) {
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 添加costItemName字段
|
|
|
|
|
+ item.put("costItemName", projectName);
|
|
|
|
|
+
|
|
|
|
|
+ // 添加yearValues字段
|
|
|
|
|
+ Map<String, String> yearValues = new HashMap<>();
|
|
|
|
|
+ Map<String, String> projectYearData = projectData.get(projectName);
|
|
|
|
|
+
|
|
|
|
|
+ for (String year : years) {
|
|
|
|
|
+ String value = projectYearData.getOrDefault(year, "");
|
|
|
|
|
+ yearValues.put(year, value);
|
|
|
|
|
+ }
|
|
|
|
|
+ item.put("yearValues", yearValues);
|
|
|
|
|
+
|
|
|
|
|
+ costItems.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 添加合计行(可选)
|
|
|
|
|
+ if (!costItems.isEmpty()) {
|
|
|
|
|
+ Map<String, Object> totalItem = new HashMap<>();
|
|
|
|
|
+ totalItem.put("costItemName", "合计");
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> totalValues = new HashMap<>();
|
|
|
|
|
+ for (String year : years) {
|
|
|
|
|
+ int sum = 0;
|
|
|
|
|
+ for (Map<String, String> projectYearData : projectData.values()) {
|
|
|
|
|
+ String value = projectYearData.get(year);
|
|
|
|
|
+ if (value != null && !value.trim().isEmpty()) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ sum += Integer.parseInt(value.replace(",", ""));
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ // 忽略非数字值
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ totalValues.put(year, sum > 0 ? String.valueOf(sum) : "");
|
|
|
|
|
+ }
|
|
|
|
|
+ totalItem.put("yearValues", totalValues);
|
|
|
|
|
+ costItems.add(totalItem);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 构建返回结果
|
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
|
+ result.put("years", new ArrayList<>(years));
|
|
|
|
|
+ result.put("costItems", costItems);
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 安全获取字符串值
|
|
|
|
|
+ */
|
|
|
|
|
+ private String getStringValue(Map<String, Object> map, String key) {
|
|
|
|
|
+ Object value = map.get(key);
|
|
|
|
|
+ if (value == null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (value instanceof String) {
|
|
|
|
|
+ String str = (String) value;
|
|
|
|
|
+ return str.trim();
|
|
|
|
|
+ }
|
|
|
|
|
+ return value.toString().trim();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 从字符串中提取年份
|
|
|
|
|
+ */
|
|
|
|
|
+ private String extractYear(String text) {
|
|
|
|
|
+ if (text == null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 匹配4位数字年份
|
|
|
|
|
+ Pattern pattern = Pattern.compile("\\d{4}");
|
|
|
|
|
+ Matcher matcher = pattern.matcher(text);
|
|
|
|
|
+ if (matcher.find()) {
|
|
|
|
|
+ return matcher.group();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void feedbackDocumentUrl(CostProjectDocumentReq req) {
|
|
public void feedbackDocumentUrl(CostProjectDocumentReq req) {
|
|
|
if (ObjectUtil.isEmpty(req.getId())) {
|
|
if (ObjectUtil.isEmpty(req.getId())) {
|