|
@@ -25,6 +25,7 @@ import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.select.Elements;
|
|
import org.jsoup.select.Elements;
|
|
import org.springblade.business.feign.ContractLogClient;
|
|
import org.springblade.business.feign.ContractLogClient;
|
|
|
|
+import org.springblade.business.feign.InformationQueryClient;
|
|
import org.springblade.business.vo.SaveContractLogVO;
|
|
import org.springblade.business.vo.SaveContractLogVO;
|
|
import org.springblade.common.constant.CommonConstant;
|
|
import org.springblade.common.constant.CommonConstant;
|
|
import org.springblade.common.utils.CommonUtil;
|
|
import org.springblade.common.utils.CommonUtil;
|
|
@@ -124,6 +125,8 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
private final ContractLogClient contractLogClient;
|
|
private final ContractLogClient contractLogClient;
|
|
|
|
|
|
|
|
+ private final InformationQueryClient informationQueryClient;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 详情
|
|
* 详情
|
|
*/
|
|
*/
|
|
@@ -1934,7 +1937,7 @@ public class ExcelTabController extends BladeController {
|
|
queryWrapper.eq("type", 2);
|
|
queryWrapper.eq("type", 2);
|
|
queryWrapper.eq("tab_id", tableNode.getPKeyId());
|
|
queryWrapper.eq("tab_id", tableNode.getPKeyId());
|
|
|
|
|
|
- final List<TextdictInfo> textdictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
|
|
|
|
|
|
+ final List<TextdictInfo> textdictInfos = this.textdictInfoService.getBaseMapper().selectList(queryWrapper);
|
|
if (textdictInfos != null && !textdictInfos.isEmpty()) {
|
|
if (textdictInfos != null && !textdictInfos.isEmpty()) {
|
|
textdictInfos.forEach(e -> {
|
|
textdictInfos.forEach(e -> {
|
|
String key = e.getColKey();
|
|
String key = e.getColKey();
|
|
@@ -1962,7 +1965,7 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
sheet.saveToPdf(onePdfPath);
|
|
sheet.saveToPdf(onePdfPath);
|
|
|
|
|
|
- BladeFile bladeFile = newIOSSClient.uploadFile( fileName + ".pdf", onePdfPath);
|
|
|
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile( fileName + ".pdf", onePdfPath);
|
|
|
|
|
|
pdfUrls.add(bladeFile.getLink());
|
|
pdfUrls.add(bladeFile.getLink());
|
|
|
|
|
|
@@ -1979,7 +1982,7 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
FileUtils.mergePdfPublicMethods(pdfUrls, mergePdfPath);
|
|
FileUtils.mergePdfPublicMethods(pdfUrls, mergePdfPath);
|
|
|
|
|
|
- BladeFile mergeFile = newIOSSClient.uploadFile(theLogId + new Date().getTime() + ".pdf", mergePdfPath);
|
|
|
|
|
|
+ BladeFile mergeFile = this.newIOSSClient.uploadFile(theLogId + new Date().getTime() + ".pdf", mergePdfPath);
|
|
|
|
|
|
//修改记录
|
|
//修改记录
|
|
this.contractLogClient.updateTheLogPdfUrl(theLogJson.getString("id"), mergeFile.getLink());
|
|
this.contractLogClient.updateTheLogPdfUrl(theLogJson.getString("id"), mergeFile.getLink());
|
|
@@ -2194,4 +2197,286 @@ public class ExcelTabController extends BladeController {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取首件填报记录
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/get-first-business-data")
|
|
|
|
+ @ApiOperationSupport(order = 28)
|
|
|
|
+ @ApiOperation(value = "获取首件填报记录")
|
|
|
|
+ @ApiImplicitParam(name = "firstId", value = "首件列表ID")
|
|
|
|
+ public R<List<Map<String, Object>>> getFirstBusinessData(String firstId){
|
|
|
|
+ if(StringUtils.isNotEmpty(firstId)){
|
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ JSONObject json = this.informationQueryClient.queryFirstBusinessDataByFirstId(firstId);
|
|
|
|
+ if(json != null){
|
|
|
|
+ //获取数据所在表格
|
|
|
|
+ WbsTreeContract tableNode = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, json.getString("tableId")));
|
|
|
|
+ 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){
|
|
|
|
+ for(Map<String, Object> mysqlData : businessDataMapList){
|
|
|
|
+ //数据结果
|
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ 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("]", "\']");
|
|
|
|
+ sql = sql.replaceAll("000Z,", "000Z\',");
|
|
|
|
+ sql = sql.replaceAll(", 20", ", \'20");
|
|
|
|
+ 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) {
|
|
|
|
+ String tabData[] = data.split("_\\^_");
|
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
|
+ }
|
|
|
|
+ } else if (tabVal.indexOf("_^_") >= 0) {
|
|
|
|
+ String tabData[] = tabVal.split("_\\^_");
|
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
|
+ } else {
|
|
|
|
+ reData.put(key, tabVal);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ reData.remove("p_key_id");
|
|
|
|
+ reData.remove("classify");
|
|
|
|
+ reData.remove("contractId");
|
|
|
|
+ reData.remove("pkeyId");
|
|
|
|
+ reData.remove("projectId");
|
|
|
|
+
|
|
|
|
+ result.add(reData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.data(result);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.data(300, null, "未找到对应的业务数据");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 预览首件PDF
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/get-first-pdf-info")
|
|
|
|
+ @ApiOperationSupport(order = 28)
|
|
|
|
+ @ApiOperation(value = "获取首件填报记录")
|
|
|
|
+ @ApiImplicitParam(name = "firstId", value = "首件列表ID")
|
|
|
|
+ public R<String> getFirstPdfInfo(String firstId){
|
|
|
|
+ if(StringUtils.isNotEmpty(firstId)){
|
|
|
|
+ //PDF路径集合
|
|
|
|
+ List<String> pdfUrls = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //获取配置的路径
|
|
|
|
+ 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"))){
|
|
|
|
+ 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){
|
|
|
|
+ return R.fail("该数据下无此节点!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isEmpty(tableNode.getHtmlUrl())){
|
|
|
|
+ return R.fail("请关联清表!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取清表信息
|
|
|
|
+ ExcelTab excelTab = excelTabService.getById(tableNode.getExcelId());
|
|
|
|
+ if (excelTab == null) {
|
|
|
|
+ return R.fail("失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> businessDataMapList = this.getFirstBusinessData(firstId).getData();
|
|
|
|
+
|
|
|
|
+ try{
|
|
|
|
+ //处理数据
|
|
|
|
+ for(Map<String, Object> dataMap : businessDataMapList){
|
|
|
|
+ // 获取excel流 和 html流
|
|
|
|
+ Workbook wb = new Workbook();
|
|
|
|
+ wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
|
|
|
|
+ //获取工作表
|
|
|
|
+ Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
|
+
|
|
|
|
+ // 数据不为空 &&
|
|
|
|
+ if (StringUtils.isNotEmpty(tableNode.getHtmlUrl())) {
|
|
|
|
+ File htmlFile = ResourceUtil.getFile(tableNode.getHtmlUrl());
|
|
|
|
+ if (htmlFile.exists()) {
|
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(htmlFile));
|
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
|
+ Element table = doc.select("table").first();
|
|
|
|
+ Elements trs = table.select("tr");
|
|
|
|
+
|
|
|
|
+ if (ObjectUtil.isNotEmpty(dataMap)) {
|
|
|
|
+ for (String val : dataMap.keySet()) {
|
|
|
|
+ if (val.indexOf("__") >= 0) {
|
|
|
|
+ String DataVal[] = val.split("__");
|
|
|
|
+ String[] xy = DataVal[1].split("_");
|
|
|
|
+ Element data = trs.get(Integer.parseInt(xy[0])).select("td").get(Integer.parseInt(xy[1]));
|
|
|
|
+
|
|
|
|
+ if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
|
|
|
|
+ int x1, y1;
|
|
|
|
+
|
|
|
|
+ if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
|
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
|
|
|
|
+ } else {
|
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
|
+ }
|
|
|
|
+ if (x1 == 0) {
|
|
|
|
+ x1 = 1;
|
|
|
|
+ }
|
|
|
|
+ String myData = dataMap.get(val) + "";
|
|
|
|
+ if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
|
|
|
|
+ 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("{}年{}月{}日", new Object[]{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("{}年{}月{}日", new Object[]{end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1});
|
|
|
|
+
|
|
|
|
+ if (StartDate.equals(endDate)) {
|
|
|
|
+ myData = StartDate;
|
|
|
|
+ } else {
|
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String dataStr[] = myData.split("T")[0].split("-");
|
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", new Object[]{dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1});
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
|
|
|
|
+ Element element = trs.get(y1).select("td").get(x1);
|
|
|
|
+ String styles[] = element.attr("style").split(";");
|
|
|
|
+ int Height = 0;
|
|
|
|
+ for (String sty : styles) {
|
|
|
|
+ if (sty.indexOf("height:") >= 0) {
|
|
|
|
+ Height = Integer.parseInt(sty.replace("height:", "").replace("px", ""));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
|
|
|
|
+ ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
|
+ pic.setHeight(Height);
|
|
|
|
+ sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
|
+ cellRange.setText(myData);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 组装电签设置
|
|
|
|
+ QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("type", 2);
|
|
|
|
+ queryWrapper.eq("tab_id", tableNode.getPKeyId());
|
|
|
|
+
|
|
|
|
+ final List<TextdictInfo> textdictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
|
|
|
|
+ if (textdictInfos != null && !textdictInfos.isEmpty()) {
|
|
|
|
+ textdictInfos.forEach(e -> {
|
|
|
|
+ String key = e.getColKey();
|
|
|
|
+ String keys[] = key.split("__");
|
|
|
|
+ String[] trtd = keys[1].split("_");
|
|
|
|
+ Element data = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
|
|
|
|
+ int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
|
+ if (x1 == 0) {
|
|
|
|
+ x1 = 1;
|
|
|
|
+ }
|
|
|
|
+ int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
|
+
|
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
|
+
|
|
|
|
+ cellRange.setText(e.getId() + "");
|
|
|
|
+ cellRange.getCellStyle().getFont().setColor(Color.white);
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long fileName = SnowFlakeUtil.getId();
|
|
|
|
+ String onePdfPath = file_path + "/pdf//" + fileName + ".pdf";
|
|
|
|
+
|
|
|
|
+ sheet.saveToPdf(onePdfPath);
|
|
|
|
+
|
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile( fileName + ".pdf", onePdfPath);
|
|
|
|
+
|
|
|
|
+ pdfUrls.add(bladeFile.getLink());
|
|
|
|
+
|
|
|
|
+ wb.dispose();
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(pdfUrls.size() > 0){
|
|
|
|
+ try{
|
|
|
|
+ //关联的数据
|
|
|
|
+ if(StringUtils.isNotEmpty(firstJson.getString("linkMergePdfUrl"))){
|
|
|
|
+ pdfUrls.add(firstJson.getString("linkMergePdfUrl"));
|
|
|
|
+ }
|
|
|
|
+ //总结报告,暂时无
|
|
|
|
+
|
|
|
|
+ //上传
|
|
|
|
+ String mergePdfPath = file_path + "/pdf//" + firstId + ".pdf";
|
|
|
|
+ File oldMergePdf = ResourceUtil.getFile(mergePdfPath);
|
|
|
|
+ if (oldMergePdf.exists()) {
|
|
|
|
+ oldMergePdf.delete();
|
|
|
|
+ }
|
|
|
|
+ //合并
|
|
|
|
+ FileUtils.mergePdfPublicMethods(pdfUrls, mergePdfPath);
|
|
|
|
+ //上传
|
|
|
|
+ BladeFile mergeFile = this.newIOSSClient.uploadFile(firstId + '-' + new Date().getTime() + ".pdf", mergePdfPath);
|
|
|
|
+
|
|
|
|
+ //返回
|
|
|
|
+ return R.data(mergeFile.getLink());
|
|
|
|
+
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.data(300, null, "未找到数据");
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|