|
@@ -27,6 +27,7 @@ import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.service.*;
|
|
|
+import org.springblade.manager.service.impl.ContractInfoServiceImpl;
|
|
|
import org.springblade.manager.utils.FileUtils;
|
|
|
import org.springblade.resource.feign.CommonFileClient;
|
|
|
import org.springblade.resource.feign.IOSSClient;
|
|
@@ -61,25 +62,17 @@ import java.util.stream.Collectors;
|
|
|
@Api(value = "首件基础数据表", tags = "首件基础数据表接口")
|
|
|
public class FirstController extends BladeController {
|
|
|
|
|
|
- // 元素信息表-
|
|
|
private final IWbsTreeContractService wbsTreeContractService;
|
|
|
private final IOSSClient iossClient;
|
|
|
private final CommonFileClient commonFileClient;
|
|
|
- // 表单附件信息
|
|
|
private final ITableFileService tableFileService;
|
|
|
-
|
|
|
private final NewIOSSClient newIOSSClient;
|
|
|
-
|
|
|
- // excel 基本信息表
|
|
|
private final IExcelTabService excelTabService;
|
|
|
-
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
-
|
|
|
private final InformationQueryClient informationQueryClient;
|
|
|
-
|
|
|
private final ITextdictInfoService textdictInfoService;
|
|
|
- // 项目信息
|
|
|
private final IProjectInfoService projectInfoService;
|
|
|
+ private final ContractInfoServiceImpl contractInfoService;
|
|
|
|
|
|
/**
|
|
|
* 首件表单获取 html页面
|
|
@@ -93,23 +86,22 @@ public class FirstController extends BladeController {
|
|
|
public R getFirstExcelHtml(Long contractId) throws IOException {
|
|
|
|
|
|
WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .eq(WbsTreeContract::getContractId,contractId).eq(WbsTreeContract::getTableType,"111"));
|
|
|
- if(wbsTreeContract ==null ){
|
|
|
+ .eq(WbsTreeContract::getContractId, contractId).eq(WbsTreeContract::getTableType, "111"));
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
return R.fail("该数据下无此节点!");
|
|
|
}
|
|
|
- if(wbsTreeContract .getHtmlUrl()==null){
|
|
|
+ if (wbsTreeContract.getHtmlUrl() == null) {
|
|
|
return R.fail("请上传清表!");
|
|
|
}
|
|
|
|
|
|
File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
|
FileInputStream fileInputStream = new FileInputStream(file1);
|
|
|
- String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
// 解析 style
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
|
|
|
-
|
|
|
ProjectInfo projectInfo = projectInfoService.getById(wbsTreeContract.getProjectId());
|
|
|
// 添加标题显示
|
|
|
Element table = doc.select("table").first();
|
|
@@ -133,8 +125,8 @@ public class FirstController extends BladeController {
|
|
|
doc.select("Col").remove();
|
|
|
fileInputStream.close();
|
|
|
JSONObject reData = new JSONObject();
|
|
|
- reData.put("id",wbsTreeContract.getPKeyId());
|
|
|
- reData.put("data",table+"");
|
|
|
+ reData.put("id", wbsTreeContract.getPKeyId());
|
|
|
+ reData.put("data", table + "");
|
|
|
return R.data(reData);
|
|
|
}
|
|
|
|
|
@@ -164,17 +156,17 @@ public class FirstController extends BladeController {
|
|
|
String fileExtension = StringUtils.isNotEmpty(file.getOriginalFilename()) ? file.getOriginalFilename() : FileUtil.getFileExtension(sourceFile.getName());
|
|
|
|
|
|
NewBladeFile newBladeFile = null;
|
|
|
- if(fileExtension.contains("pdf")){
|
|
|
+ if (fileExtension.contains("pdf")) {
|
|
|
pdfUrl = sourceUrl;
|
|
|
- } else if(fileExtension.contains("xls") || fileExtension.contains("xlsx")){
|
|
|
+ } else if (fileExtension.contains("xls") || fileExtension.contains("xlsx")) {
|
|
|
newBladeFile = this.commonFileClient.excelToPdf(file);
|
|
|
- } else if(fileExtension.contains("docx")){
|
|
|
+ } else if (fileExtension.contains("docx")) {
|
|
|
newBladeFile = this.commonFileClient.wordToPdf(file);
|
|
|
- } else if(fileExtension.contains("png") || (StringUtils.isNotEmpty(file.getOriginalFilename()) && file.getOriginalFilename().contains("jpg"))){
|
|
|
+ } else if (fileExtension.contains("png") || (StringUtils.isNotEmpty(file.getOriginalFilename()) && file.getOriginalFilename().contains("jpg"))) {
|
|
|
newBladeFile = this.commonFileClient.pngOrJpgToPdf(file);
|
|
|
}
|
|
|
|
|
|
- if(newBladeFile != null){
|
|
|
+ if (newBladeFile != null) {
|
|
|
pdfUrl = newBladeFile.getPdfUrl();
|
|
|
}
|
|
|
|
|
@@ -188,13 +180,12 @@ public class FirstController extends BladeController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@GetMapping("/get-first-buss-pdfInfo")
|
|
|
@ApiOperationSupport(order = 3)
|
|
|
@ApiOperation(value = "首件-pdf预览", notes = "首件列表ID")
|
|
|
@ApiImplicitParam(name = "firstId", value = "首件ID", required = true)
|
|
|
public R<String> getBussPdfInfo(String firstId) {
|
|
|
- if(StringUtils.isNotEmpty(firstId)){
|
|
|
+ if (StringUtils.isNotEmpty(firstId)) {
|
|
|
//PDF路径集合
|
|
|
List<String> pdfUrls = new ArrayList<>();
|
|
|
|
|
@@ -202,19 +193,19 @@ public class FirstController extends BladeController {
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
//获取数据
|
|
|
JSONObject firstJson = this.informationQueryClient.queryFirstBusinessDataByFirstId(firstId);
|
|
|
- if(firstJson != null){
|
|
|
- if(StringUtils.isNotEmpty(firstJson.getString("eVisaPdfUrl")) || StringUtils.isNotEmpty(firstJson.getString("pdfUrl"))){
|
|
|
+ if (firstJson != null) {
|
|
|
+ if (StringUtils.isNotEmpty(firstJson.getString("eVisaPdfUrl")) || StringUtils.isNotEmpty(firstJson.getString("pdfUrl"))) {
|
|
|
pdfUrls.add(StringUtils.isNotEmpty(firstJson.getString("eVisaPdfUrl")) ? firstJson.getString("eVisaPdfUrl") : firstJson.getString("pdfUrl"));
|
|
|
} else {
|
|
|
//没有生成拼接的记录,生成
|
|
|
//获取html
|
|
|
WbsTreeContract tableNode = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, firstJson.getString("tableId")));
|
|
|
|
|
|
- if(tableNode == null){
|
|
|
+ if (tableNode == null) {
|
|
|
return R.fail("该数据下无此节点!");
|
|
|
}
|
|
|
|
|
|
- if(StringUtils.isEmpty(tableNode.getHtmlUrl())){
|
|
|
+ if (StringUtils.isEmpty(tableNode.getHtmlUrl())) {
|
|
|
return R.fail("请关联清表!");
|
|
|
}
|
|
|
|
|
@@ -225,11 +216,11 @@ public class FirstController extends BladeController {
|
|
|
}
|
|
|
|
|
|
//获取填报数据
|
|
|
- List<Map<String, Object>> businessDataMapList = this.getFirstBusinessData(firstId).getData().get("data");
|
|
|
+ List<Map<String, Object>> businessDataMapList = this.getFirstBusinessData(firstId, tableNode.getContractId()).getData().get("data");
|
|
|
|
|
|
- try{
|
|
|
+ try {
|
|
|
//处理数据
|
|
|
- for(Map<String, Object> dataMap : businessDataMapList){
|
|
|
+ for (Map<String, Object> dataMap : businessDataMapList) {
|
|
|
// 获取excel流 和 html流
|
|
|
Workbook wb = new Workbook();
|
|
|
wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
|
|
@@ -344,7 +335,7 @@ public class FirstController extends BladeController {
|
|
|
|
|
|
sheet.saveToPdf(onePdfPath);
|
|
|
|
|
|
- BladeFile bladeFile = this.newIOSSClient.uploadFile( fileName + ".pdf", onePdfPath);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(fileName + ".pdf", onePdfPath);
|
|
|
|
|
|
pdfUrls.add(bladeFile.getLink());
|
|
|
|
|
@@ -354,19 +345,19 @@ public class FirstController extends BladeController {
|
|
|
|
|
|
wb.dispose();
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(pdfUrls.size() > 0){
|
|
|
- try{
|
|
|
+ if (pdfUrls.size() > 0) {
|
|
|
+ try {
|
|
|
//关联的数据
|
|
|
- if(StringUtils.isNotEmpty(firstJson.getString("linkMergePdfUrl"))){
|
|
|
+ if (StringUtils.isNotEmpty(firstJson.getString("linkMergePdfUrl"))) {
|
|
|
pdfUrls.add(firstJson.getString("linkMergePdfUrl"));
|
|
|
}
|
|
|
//总结报告
|
|
|
- if(StringUtils.isNotEmpty(firstJson.getString("uploadFile"))){
|
|
|
+ if (StringUtils.isNotEmpty(firstJson.getString("uploadFile"))) {
|
|
|
pdfUrls.add(firstJson.getString("uploadFile"));
|
|
|
}
|
|
|
|
|
@@ -384,7 +375,7 @@ public class FirstController extends BladeController {
|
|
|
//返回
|
|
|
return R.data(mergeFile.getLink());
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
@@ -398,40 +389,129 @@ public class FirstController extends BladeController {
|
|
|
@ApiOperationSupport(order = 4)
|
|
|
@ApiOperation(value = "获取首件用户保存数据", notes = "获取首件用户保存数据")
|
|
|
@ApiImplicitParams(value = {
|
|
|
- @ApiImplicitParam(name = "firstId", value = "pkeyId", required = true)
|
|
|
+ @ApiImplicitParam(name = "firstId", value = "pkeyId", required = true),
|
|
|
+ @ApiImplicitParam(name = "contractId", value = "contractId", required = true)
|
|
|
})
|
|
|
- public R<Map<String, List<Map<String, Object>>>> getFirstBusinessData(String firstId) {
|
|
|
- if(StringUtils.isNotEmpty(firstId)){
|
|
|
+ public R<Map<String, List<Map<String, Object>>>> getFirstBusinessData(String firstId, String contractId) {
|
|
|
+ if (StringUtils.isNotEmpty(firstId) && StringUtils.isNotEmpty(contractId)) {
|
|
|
+ //数据结果
|
|
|
Map<String, List<Map<String, Object>>> result = new HashMap<>();
|
|
|
+ List<Map<String, Object>> dataResult = new ArrayList<>();
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
+
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getContractId, contractId).eq(WbsTreeContract::getTableType, "111"));
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
+ return R.fail("该数据下无此节点!");
|
|
|
+ }
|
|
|
+ if (wbsTreeContract.getHtmlUrl() == null) {
|
|
|
+ return R.fail("请上传清表!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //匹配关联Title等
|
|
|
+ try {
|
|
|
+ File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(file1));
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+
|
|
|
+ // 模糊匹配
|
|
|
+ Elements dwTitle = doc.select("el-input[placeholder~=.*承包单位]");
|
|
|
+ Elements sgTitle = doc.select("el-input[placeholder~=^施工单位]");
|
|
|
+ Elements sgTitle1 = doc.select("el-input[placeholder=安装单位]");
|
|
|
+ sgTitle.addAll(sgTitle1);
|
|
|
+ Elements htdTitle = doc.select("el-input[placeholder~=.*合同段.*]");
|
|
|
+ Elements htdTitle1 = doc.select("el-input[placeholder~=合同名称.*]");
|
|
|
+ htdTitle.addAll(htdTitle1);
|
|
|
+ Elements jlTitle = doc.select("el-input[placeholder~=监理单位.*]");
|
|
|
+ Elements bhTitle = doc.select("el-input[placeholder~=^编号]");
|
|
|
+ Elements bhTitle1 = doc.select("el-input[placeholder~=合同编号.*]");
|
|
|
+ bhTitle.addAll(bhTitle1);
|
|
|
+ Elements xmTitle = doc.select("el-input[placeholder~=^项目名称]");
|
|
|
+
|
|
|
+ ContractInfo contractInfo = contractInfoService.getById(wbsTreeContract.getContractId());
|
|
|
+ // 施工单位名称
|
|
|
+ if (dwTitle.size() >= 1) {
|
|
|
+ int y = Integer.parseInt(dwTitle.attr("trindex"));
|
|
|
+ if (y <= 10) {
|
|
|
+ reData.put(dwTitle.attr("keyName"), contractInfo.getConstructionUnitName());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (sgTitle.size() >= 1) {
|
|
|
+ int y = Integer.parseInt(sgTitle.attr("trindex"));
|
|
|
+ if (y <= 10) {
|
|
|
+ reData.put(sgTitle.attr("keyName"), contractInfo.getConstructionUnitName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 合同段名称
|
|
|
+ if (htdTitle.size() >= 1) {
|
|
|
+ for (Element element : htdTitle) {
|
|
|
+ int trIndex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trIndex <= 8) {
|
|
|
+ reData.put(element.attr("keyName"), contractInfo.getContractName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 监理单位名称
|
|
|
+ if (jlTitle.size() >= 1) {
|
|
|
+ for (Element element : jlTitle) {
|
|
|
+ int trIndex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trIndex <= 10) {
|
|
|
+ reData.put(element.attr("keyName"), contractInfo.getSupervisionUnitName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 编号
|
|
|
+ if (bhTitle.size() >= 1 && contractInfo.getIsReferenceNumber() == 1) {
|
|
|
+ for (Element element : bhTitle) {
|
|
|
+ int trIndex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trIndex <= 10) {
|
|
|
+ reData.put(element.attr("keyName"), contractInfo.getContractNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 项目名称
|
|
|
+ if (xmTitle.size() >= 1) {
|
|
|
+ for (Element element : xmTitle) {
|
|
|
+ int trIndex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trIndex <= 6) {
|
|
|
+ ProjectInfo projectInfo = projectInfoService.getById(wbsTreeContract.getProjectId());
|
|
|
+ reData.put(element.attr("keyName"), projectInfo.getProjectName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //入参
|
|
|
+ if (reData.size() > 0){
|
|
|
+ dataResult.add(reData);
|
|
|
+ }
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
JSONObject json = this.informationQueryClient.queryFirstBusinessDataByFirstId(firstId);
|
|
|
- if(json != null){
|
|
|
+ //解析数据Data
|
|
|
+ if (json != null) {
|
|
|
//获取数据所在表格
|
|
|
WbsTreeContract tableNode = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, json.getString("tableId")));
|
|
|
- if(tableNode != null && StringUtils.isNotEmpty(tableNode.getInitTableName())){
|
|
|
+ if (tableNode != null && StringUtils.isNotEmpty(tableNode.getInitTableName())) {
|
|
|
//获取填报数据
|
|
|
List<Map<String, Object>> businessDataMapList = this.jdbcTemplate.queryForList("SELECT * FROM " + tableNode.getInitTableName() + " WHERE group_id = " + json.getString("id"));
|
|
|
- if(businessDataMapList.size() > 0){
|
|
|
- List<Map<String, Object>> dataResult = new ArrayList<>();
|
|
|
-
|
|
|
- for(Map<String, Object> mysqlData : businessDataMapList){
|
|
|
- //数据结果
|
|
|
- Map<String, Object> reData = new HashMap<>();
|
|
|
-
|
|
|
+ if (businessDataMapList.size() > 0) {
|
|
|
+ for (Map<String, Object> mysqlData : businessDataMapList) {
|
|
|
for (String key : mysqlData.keySet()) {
|
|
|
String tabVal = mysqlData.get(key) + "";
|
|
|
// 时间段处理
|
|
|
if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
|
|
|
if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z]") >= 0) {
|
|
|
String[] tabData = tabVal.split("_\\^_");
|
|
|
-
|
|
|
if (reData.containsKey("pickerKey")) {
|
|
|
String pickerKey = reData.get("pickerKey") + "," + key + "__" + tabData[1];
|
|
|
reData.put("pickerKey", pickerKey);
|
|
|
} else {
|
|
|
reData.put("pickerKey", key + "__" + tabData[1]);
|
|
|
}
|
|
|
-
|
|
|
String sql = tabData[0];
|
|
|
sql = sql.replaceAll("\\[", "['");
|
|
|
sql = sql.replaceAll("]", "']");
|
|
@@ -440,10 +520,8 @@ public class FirstController extends BladeController {
|
|
|
sql = sql.replaceAll("'", "");
|
|
|
reData.put(key + "__" + tabData[1], sql);
|
|
|
} else if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z") >= 0) { //时间
|
|
|
-
|
|
|
String[] tabData = tabVal.split("_\\^_");
|
|
|
reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
-
|
|
|
} else if (tabVal.indexOf("☆") >= 0) {
|
|
|
String[] mysql = tabVal.split("☆");
|
|
|
for (String data : mysql) {
|
|
@@ -467,19 +545,18 @@ public class FirstController extends BladeController {
|
|
|
|
|
|
dataResult.add(reData);
|
|
|
}
|
|
|
-
|
|
|
- //设置表格数据
|
|
|
- result.put("data", dataResult);
|
|
|
-
|
|
|
//获取关联
|
|
|
List<Map<String, Object>> linkMapList = this.jdbcTemplate.queryForList("SELECT link_id AS id,title AS name FROM u_first_link_data WHERE first_id = " + firstId + " and is_deleted = 0");
|
|
|
//设置关联数据
|
|
|
result.put("link", linkMapList);
|
|
|
-
|
|
|
- return R.data(result);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //设置表格数据
|
|
|
+ result.put("data", dataResult);
|
|
|
+
|
|
|
+ return R.data(result);
|
|
|
}
|
|
|
|
|
|
return R.data(300, null, "未找到对应的业务数据");
|