|
@@ -16,7 +16,6 @@ import io.swagger.annotations.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.SneakyThrows;
|
|
|
import org.apache.commons.codec.Charsets;
|
|
|
-import org.apache.commons.io.FilenameUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
|
@@ -25,6 +24,7 @@ import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
import org.springblade.business.entity.ContractLog;
|
|
|
+import org.springblade.business.entity.InformationQuery;
|
|
|
import org.springblade.business.feign.ContractLogClient;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
import org.springblade.business.vo.SaveContractLogVO;
|
|
@@ -74,6 +74,7 @@ import java.awt.*;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
@@ -301,9 +302,9 @@ public class ExcelTabController extends BladeController {
|
|
|
String filecode = SnowFlakeUtil.getId() + "";
|
|
|
String thmlUrl = file_path + filecode + ".html";
|
|
|
String exceUrl = file_path + filecode + "123.xlsx";
|
|
|
- ExcelInfoUtils.excelInfo(file.getInputStream(),exceUrl,thmlUrl,"1");
|
|
|
+ ExcelInfoUtils.excelInfo(file.getInputStream(), exceUrl, thmlUrl, "1");
|
|
|
// 上传excel文件
|
|
|
- BladeFile bladeFile = newIOSSClient.uploadFile(file.getOriginalFilename(),exceUrl);
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(file.getOriginalFilename(), exceUrl);
|
|
|
// 解析原始excel
|
|
|
|
|
|
BladeFile bladeFileR = newIOSSClient.uploadFileByInputStream(file);
|
|
@@ -1912,7 +1913,7 @@ public class ExcelTabController extends BladeController {
|
|
|
R<BladeFile> bladeFile = iossClient.addFileInfo(file);
|
|
|
BladeFile bladeFile1 = bladeFile.getData();
|
|
|
TableFile tableFile = new TableFile();
|
|
|
- String fileExtension = FileUtil.getFileExtension(bladeFile1.getName());
|
|
|
+ String fileExtension = FileUtil.getFileExtension(bladeFile1.getName()).toLowerCase();
|
|
|
tableFile.setTabId(pkeyId + "");
|
|
|
tableFile.setName(file.getOriginalFilename());
|
|
|
tableFile.setType(2);
|
|
@@ -1931,7 +1932,8 @@ public class ExcelTabController extends BladeController {
|
|
|
} else if (fileExtension.contains("docx")) {
|
|
|
newBladeFile = this.commonFileClient.wordToPdf(file);
|
|
|
tableFile.setDomainPdfUrl(newBladeFile.getPdfUrl());
|
|
|
- } else if (fileExtension.contains("png") || file.getOriginalFilename().contains("jpg")) {
|
|
|
+ } else if (fileExtension.contains("png") || fileExtension.contains("jpg") || fileExtension.contains("webp") || fileExtension.contains("apng") ||
|
|
|
+ fileExtension.contains("bmp") || fileExtension.contains("jepg") || fileExtension.contains("tif") || fileExtension.contains("gif")) {
|
|
|
newBladeFile = this.commonFileClient.pngOrJpgToPdf(file);
|
|
|
tableFile.setDomainPdfUrl(newBladeFile.getPdfUrl());
|
|
|
} else if (fileExtension.contains("pdf")) {
|
|
@@ -1950,7 +1952,21 @@ public class ExcelTabController extends BladeController {
|
|
|
updateWrapper.set("is_tab_pdf", 2);
|
|
|
wbsTreeContractService.update(updateWrapper);
|
|
|
// 合并后
|
|
|
-
|
|
|
+ //如果上传文件前没有保存过,则直接生成一条基础数据
|
|
|
+ String sql = "select pdf_url,e_visa_pdf_url,pdf_trial_url,pdf_trial_url_position,status from u_information_query where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id='" + contractId + "'";
|
|
|
+ List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
|
|
|
+ if (maps == null || maps.size() == 0) {
|
|
|
+ WbsTreeContract contract = wbsTreeContractService.getById(pkeyId);
|
|
|
+ InformationQuery query = new InformationQuery();
|
|
|
+ query.setId(SnowFlakeUtil.getId());
|
|
|
+ query.setWbsId(Long.parseLong(nodeId));
|
|
|
+ query.setContractId(Long.parseLong(contractId));
|
|
|
+ query.setProjectId(Long.parseLong(projectId));
|
|
|
+ query.setClassify(Integer.parseInt(classify));
|
|
|
+ query.setCategory(contract.getNodeType());
|
|
|
+ query.setType((contract.getIsExpernode() == null || contract.getIsExpernode() <= 0) ? 1 : 2);
|
|
|
+ informationQueryClient.saveInfo(query);
|
|
|
+ }
|
|
|
excelTabService.getBussPdfs(nodeId, classify, contractId, projectId);
|
|
|
|
|
|
return R.data(tableFile.getId());
|
|
@@ -1964,7 +1980,7 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "status", value = "状态(1显示 2隐藏)", required = true)
|
|
|
})
|
|
|
@Transactional
|
|
|
- public R showBussTab(Long pkeyId, int status,String nodeId,String classify) throws Exception {
|
|
|
+ public R showBussTab(Long pkeyId, int status, String nodeId, String classify) throws Exception {
|
|
|
WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
@@ -2083,35 +2099,36 @@ public class ExcelTabController extends BladeController {
|
|
|
@PostMapping("/save_buss_data")
|
|
|
@ApiOperationSupport(order = 13)
|
|
|
@ApiOperation(value = "填报页面数据保存", notes = "填报页面数据保存")
|
|
|
- public R<String> saveBussData(@Valid @RequestBody JSONObject dataInfo, BladeUser bladeUser) throws Exception {
|
|
|
+ public R saveBussData(@Valid @RequestBody JSONObject dataInfo) throws Exception {
|
|
|
JSONArray dataArray = new JSONArray();
|
|
|
- if (dataInfo.containsKey("dataInfo")) { // 节点保存
|
|
|
+ if (dataInfo.containsKey("dataInfo")) { //节点保存
|
|
|
JSONObject jsonObject = dataInfo.getJSONObject("dataInfo");
|
|
|
dataArray = jsonObject.getJSONArray("orderList");
|
|
|
- } else { // 单个保存
|
|
|
+ } else { //单个保存
|
|
|
dataArray.add(dataInfo);
|
|
|
}
|
|
|
|
|
|
JSONObject tableInfo1 = dataArray.getJSONObject(0);
|
|
|
- String nodeid = tableInfo1.getString("nodeId");
|
|
|
+ String nodeId = tableInfo1.getString("nodeId");
|
|
|
String contractId = tableInfo1.getString("contractId");
|
|
|
String projectId = tableInfo1.getString("projectId");
|
|
|
String classify = tableInfo1.getString("classify");
|
|
|
- String groupId = tableInfo1.getString("tabGroupId");
|
|
|
- String pkeyId = tableInfo1.getString("pkeyId");
|
|
|
|
|
|
- //
|
|
|
+ /*String groupId = tableInfo1.getString("tabGroupId");
|
|
|
+ String pkeyId = tableInfo1.getString("pkeyId");
|
|
|
String pkeyIds = pkeyId;
|
|
|
String groupIds = groupId;
|
|
|
for (int i = 1; i < dataArray.size(); i++) {
|
|
|
JSONObject jsonObject = dataArray.getJSONObject(i);
|
|
|
pkeyIds += "," + jsonObject.getString("pkeyId");
|
|
|
groupIds += "," + jsonObject.getString("tabGroupId");
|
|
|
- }
|
|
|
+ }*/
|
|
|
+
|
|
|
/*全加载,或者可以优化成依赖加载*/
|
|
|
+ List<AppWbsTreeContractVO> tableAll = new ArrayList<>();
|
|
|
List<TableInfo> tableInfoList = this.excelTabService.getTableInfoList(dataArray);
|
|
|
if (tableInfoList != null) {
|
|
|
- List<AppWbsTreeContractVO> tableAll = wbsTreeContractService.searchNodeAllTable(nodeid, "1", contractId, projectId);
|
|
|
+ tableAll = wbsTreeContractService.searchNodeAllTable(nodeId, "1", contractId, projectId);
|
|
|
List<Long> tableAllIds = tableAll.stream().map(AppWbsTreeContractVO::getPKeyId).collect(Collectors.toList());
|
|
|
if (tableAll.size() > tableInfoList.size()) {
|
|
|
List<Long> exclude = tableInfoList.stream().map(TableInfo::getPkeyId).map(Long::parseLong).collect(Collectors.toList());
|
|
@@ -2121,7 +2138,7 @@ public class ExcelTabController extends BladeController {
|
|
|
R bussDataInfo = this.excelTabService.getBussDataInfo(pk, 1);
|
|
|
@SuppressWarnings("unchecked")
|
|
|
Map<String, Object> jo = (Map<String, Object>) bussDataInfo.getData();
|
|
|
- if(jo!=null && ObjectUtils.isNotEmpty(jo)){
|
|
|
+ if (jo != null && ObjectUtils.isNotEmpty(jo)) {
|
|
|
jo.put("pkeyId", pk);
|
|
|
extra.add(jo);
|
|
|
}
|
|
@@ -2143,27 +2160,48 @@ public class ExcelTabController extends BladeController {
|
|
|
tableInfoList.sort(Comparator.comparingInt(a -> tableAllIds.indexOf(Long.parseLong(a.getPkeyId()))));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//公式填充
|
|
|
- this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeid), ExecuteType.INSPECTION);
|
|
|
- // 保存数据到数据库
|
|
|
- R info = this.excelTabService.saveOrUpdateInfo(tableInfoList);
|
|
|
- if (!info.isSuccess()) {
|
|
|
- return info;
|
|
|
+ this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId), ExecuteType.INSPECTION);
|
|
|
+
|
|
|
+ //保存数据到数据库
|
|
|
+ R<Object> result = this.excelTabService.saveOrUpdateInfo(tableInfoList);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ return R.fail("以下的表在保存数据时发生了异常【" + result.getMsg() + "】");
|
|
|
}
|
|
|
- try {
|
|
|
- //单个 pdf加载
|
|
|
- if (tableInfoList != null) {
|
|
|
- for (TableInfo tableInfo : tableInfoList) {
|
|
|
- excelTabService.getBussPdfInfo(Long.parseLong(tableInfo.getPkeyId()));
|
|
|
+
|
|
|
+ List<String> errorPKeyIds = new ArrayList<>();
|
|
|
+ //单个pdf加载
|
|
|
+ if (tableInfoList != null) {
|
|
|
+ for (TableInfo tableInfo : tableInfoList) {
|
|
|
+ R bussPdfInfo = excelTabService.getBussPdfInfo(Long.parseLong(tableInfo.getPkeyId()));
|
|
|
+ if (ObjectUtil.isEmpty(bussPdfInfo) || bussPdfInfo.getCode() != 200 || ObjectUtil.isEmpty(bussPdfInfo.getData())) {
|
|
|
+ //如果返回的单张pdfUrl为空,那么表示发生异常,返回异常信息
|
|
|
+ errorPKeyIds.add(tableInfo.getPkeyId());
|
|
|
}
|
|
|
}
|
|
|
- // 合并pdf加载
|
|
|
- excelTabService.getBussPdfs(nodeid, classify, contractId, projectId);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
+ //发生异常后直接返回,不进行合并
|
|
|
+ if (errorPKeyIds.size() > 0) {
|
|
|
+ List<AppWbsTreeContractVO> errorTabs = new LinkedList<>();
|
|
|
+ for (AppWbsTreeContractVO appWbsTreeContractVO : tableAll) {
|
|
|
+ if (errorPKeyIds.contains(appWbsTreeContractVO.getPKeyId().toString())){
|
|
|
+ errorTabs.add(appWbsTreeContractVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (errorTabs.size() > 0) {
|
|
|
+ List<String> names = errorTabs.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
|
|
|
+ return R.fail("以下的表在生成pdf文件时发生了异常【" + StringUtils.join(names, "、") + "】");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //合并pdf加载
|
|
|
+ excelTabService.getBussPdfs(nodeId, classify, contractId, projectId);
|
|
|
+
|
|
|
//更新缓存
|
|
|
informationQueryClient.delAsyncWbsTree(contractId);
|
|
|
+
|
|
|
return R.data("操作成功");
|
|
|
}
|
|
|
|
|
@@ -2328,16 +2366,19 @@ public class ExcelTabController extends BladeController {
|
|
|
x1 = 1;
|
|
|
}
|
|
|
String myData = dataMap.get(val) + "";
|
|
|
- if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
|
|
|
+ if ((myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) || (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0)) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
|
|
+ sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
|
|
|
+ SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
- myData = myData.replace("[", "").replace("]", "");
|
|
|
- String[] dataVal = myData.split(",");
|
|
|
- String[] Start_dataStr = dataVal[0].split("T")[0].split("-");
|
|
|
- String StartDate = StringUtil.format("{}年{}月{}日", Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2]) + 1);
|
|
|
|
|
|
- String[] end_dataStr = dataVal[1].split("T")[0].split("-");
|
|
|
- String endDate = StringUtil.format("{}年{}月{}日", end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1);
|
|
|
+ myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
|
|
|
+ String[] dataVal = myData.split(",");
|
|
|
|
|
|
+ Date Start_dataStr = sdf.parse(dataVal[0]);
|
|
|
+ Date end_dataStr = sdf.parse(dataVal[1]);
|
|
|
+ String StartDate = formatStr.format(Start_dataStr);
|
|
|
+ String endDate = formatStr.format(end_dataStr);
|
|
|
if (StartDate.equals(endDate)) {
|
|
|
myData = StartDate;
|
|
|
} else {
|
|
@@ -2345,7 +2386,9 @@ public class ExcelTabController extends BladeController {
|
|
|
}
|
|
|
} else {
|
|
|
String[] dataStr = myData.split("T")[0].split("-");
|
|
|
- myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
+ if (dataStr.length == 3) {
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2364,6 +2407,11 @@ public class ExcelTabController extends BladeController {
|
|
|
pic.setHeight(Height);
|
|
|
sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
|
|
|
|
|
|
+ } else if (myData.equals("1") && data.html().indexOf("hc-form-checkbox-group") >= 0) {
|
|
|
+ CellRange cell = sheet.getCellRange(y1, x1);
|
|
|
+ String exceVal = cell.getText().replaceAll(" ", "");
|
|
|
+ cell.getCellStyle().getExcelFont().setFontName("EUDC");
|
|
|
+ cell.setText(exceVal.replace("□", "\u2611"));
|
|
|
} else {
|
|
|
final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
cellRange.setText(myData);
|