|
@@ -1,16 +1,18 @@
|
|
|
package org.springblade.manager.controller;
|
|
|
|
|
|
-
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
-
|
|
|
-import com.spire.xls.*;
|
|
|
+import com.spire.xls.CellRange;
|
|
|
+import com.spire.xls.ExcelPicture;
|
|
|
+import com.spire.xls.Workbook;
|
|
|
+import com.spire.xls.Worksheet;
|
|
|
import com.spire.xls.core.spreadsheet.HTMLOptions;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -23,8 +25,6 @@ import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
-import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
|
|
|
-import org.springblade.business.entity.TrialSelfInspectionRecord;
|
|
|
import org.springblade.business.feign.ContractLogClient;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
import org.springblade.business.vo.SaveContractLogVO;
|
|
@@ -33,8 +33,9 @@ import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.common.utils.MathUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
-import org.springblade.core.excel.util.ExcelUtil;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
@@ -43,7 +44,6 @@ import org.springblade.core.tool.constant.BladeConstant;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.bean.TableInfo;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
-import org.springblade.manager.excel.WbsFormElementBatchExcel;
|
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.*;
|
|
|
import org.springblade.manager.utils.FileUtils;
|
|
@@ -56,32 +56,23 @@ import org.springblade.resource.feign.IOSSClient;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springblade.resource.vo.NewBladeFile;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springblade.core.mp.support.Query;
|
|
|
-import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.awt.*;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
import java.net.URLEncoder;
|
|
|
-import java.util.*;
|
|
|
import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static com.baomidou.mybatisplus.core.toolkit.Wrappers.lambdaQuery;
|
|
|
-import static com.baomidou.mybatisplus.core.toolkit.Wrappers.query;
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 清表基础数据表 控制器
|
|
@@ -1357,7 +1348,7 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
})
|
|
|
public R getBussDataInfo(Long pkeyId) throws FileNotFoundException {
|
|
|
- return excelTabService.getBussDataInfo(pkeyId);
|
|
|
+ return excelTabService.getBussDataInfo(pkeyId,0);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1381,20 +1372,19 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
})
|
|
|
public R copeBussTab(Long pkeyId) {
|
|
|
- WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ WbsTreeContract wbsInfo = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
|
|
|
List<WbsTreeContract> wbsTreeContractList = wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .eq(WbsTreeContract::getId, wbsTreeContract.getId())
|
|
|
- .eq(WbsTreeContract::getContractId, wbsTreeContract.getContractId())
|
|
|
- .eq(WbsTreeContract::getParentId, wbsTreeContract.getParentId()));
|
|
|
+ .eq(WbsTreeContract::getId, wbsInfo.getId())
|
|
|
+ .eq(WbsTreeContract::getContractId, wbsInfo.getContractId())
|
|
|
+ .eq(WbsTreeContract::getParentId, wbsInfo.getParentId()));
|
|
|
List<WbsTreeContract> wbsTreeContractList2 = wbsTreeContractList.stream().sorted(Comparator.comparing(WbsTreeContract::getCreateTime).reversed()).collect(Collectors.toList());
|
|
|
long tabGroupId = SnowFlakeUtil.getId();
|
|
|
- // 添加所有
|
|
|
- wbsTreeContractList2.forEach(WbsTreeContract -> WbsTreeContract.setTabGroupId(tabGroupId));
|
|
|
-
|
|
|
|
|
|
long newPkId = SnowFlakeUtil.getId();
|
|
|
+ WbsTreeContract wbsTreeContract = new WbsTreeContract();
|
|
|
+ BeanUtil.copy(wbsInfo,wbsTreeContract);
|
|
|
wbsTreeContract.setPKeyId(newPkId);
|
|
|
wbsTreeContract.setCreateTime(new Date());
|
|
|
wbsTreeContract.setTabGroupId(tabGroupId);
|
|
@@ -1423,8 +1413,14 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
String querySql = "insert into " + tabName + " (id,p_key_id," + colkeys + ") select '" + newPkId + "','" + newPkId + "'," + colkeys + " from " + tabName + " where p_key_id=" + pkeyId;
|
|
|
jdbcTemplate.execute(querySql);
|
|
|
- wbsTreeContractService.saveBatch(wbsTreeContractList2);
|
|
|
wbsTreeContractService.save(wbsTreeContract);
|
|
|
+ for(WbsTreeContract wbsTreeCont:wbsTreeContractList2){
|
|
|
+
|
|
|
+ UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("p_key_id", wbsTreeCont.getPKeyId() + "");
|
|
|
+ updateWrapper.set("tab_group_id", tabGroupId);
|
|
|
+ wbsTreeContractService.update(updateWrapper);
|
|
|
+ }
|
|
|
return R.data("成功");
|
|
|
}
|
|
|
|
|
@@ -1640,7 +1636,7 @@ public class ExcelTabController extends BladeController {
|
|
|
);
|
|
|
if (wbsTreeContractList != null && wbsTreeContractList.size() >= 1) {
|
|
|
for (WbsTreeContract data : wbsTreeContractList) {
|
|
|
- R bussDataInfo = this.getBussDataInfo(data.getPKeyId());
|
|
|
+ R bussDataInfo = this.excelTabService.getBussDataInfo(data.getPKeyId(),1);
|
|
|
Object data1 = bussDataInfo.getData();
|
|
|
dataArray.add(data1);
|
|
|
}
|
|
@@ -1673,7 +1669,7 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
|
|
|
/***
|
|
|
- * 覆盖上传
|
|
|
+ * 覆盖上传- (修改为上传导入模板)
|
|
|
*/
|
|
|
|
|
|
@SneakyThrows
|
|
@@ -1685,32 +1681,54 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "nodeId", value = "节点id", required = true)
|
|
|
})
|
|
|
public R putCoverFileAttach(@RequestParam("file") MultipartFile file, Long nodeId) {
|
|
|
-
|
|
|
- String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
-
|
|
|
ExcelTab detail = excelTabService.getById(nodeId);
|
|
|
// 上传excel文件
|
|
|
R<BladeFile> bladeFile = iossClient.addFileInfo(file);
|
|
|
BladeFile bladeFile1 = bladeFile.getData();
|
|
|
- String filecode = SnowFlakeUtil.getId() + "";
|
|
|
- String thmlUrl = file_path + filecode + ".html";
|
|
|
- // 解析excel
|
|
|
- Workbook wb = new Workbook();
|
|
|
- wb.loadFromMHtml(file.getInputStream());
|
|
|
- //获取工作表
|
|
|
- Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
- sheet.saveToHtml(thmlUrl);
|
|
|
-
|
|
|
- detail.setExtension(bladeFile1.getOriginalName());
|
|
|
- detail.setFileUrl(bladeFile1.getLink());
|
|
|
- detail.setFileType(3); // 表示为清表信息 1 表示祖节点 2 表示为节点信息 3 表示清表
|
|
|
- detail.setHtmlUrl(thmlUrl);
|
|
|
+ detail.setTemplateExtension(bladeFile1.getOriginalName());
|
|
|
+ detail.setTemplateFileUrl(bladeFile1.getLink());
|
|
|
excelTabService.saveOrUpdate(detail);
|
|
|
- // 解析html
|
|
|
- expailHtmlInfo(thmlUrl, detail.getId());
|
|
|
return R.success("上传成功");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除模板
|
|
|
+ */
|
|
|
+ @PostMapping("/delete-template")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "删除模板", notes = "传入excelTab")
|
|
|
+ public R deleteTemplate(@Valid @RequestBody ExcelTab excelTab) {
|
|
|
+ ExcelTab tab = excelTabService.getById(excelTab.getId());
|
|
|
+ if (tab.getTemplateFileUrl() == null || tab.getTemplateExtension() == null) {
|
|
|
+ return R.fail("请上传清表");
|
|
|
+ }
|
|
|
+ return R.status(excelTabService.update(new LambdaUpdateWrapper<ExcelTab>()
|
|
|
+ .set(ExcelTab::getTemplateExtension,null)
|
|
|
+ .set(ExcelTab::getTemplateFileUrl,null)
|
|
|
+ .eq(ExcelTab::getId,excelTab.getId())));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 模版下载
|
|
|
+ */
|
|
|
+ @GetMapping("/down-template-file")
|
|
|
+ @ApiOperationSupport(order = 31)
|
|
|
+ @ApiOperation(value = "下载模板数据")
|
|
|
+ @ApiImplicitParam(name = "fileId", value = "fileId")
|
|
|
+ public void downTemplateFile(HttpServletResponse response, String fileId) throws Exception {
|
|
|
+ ExcelTab excelTab = excelTabService.getById(fileId);
|
|
|
+ String fileName = URLEncoder.encode(excelTab.getName(), Charsets.UTF_8.name());
|
|
|
+ InputStream redio = CommonUtil.getOSSInputStream(excelTab.getTemplateFileUrl());
|
|
|
+ byte[] buffer = IoUtil.readToByteArray(redio);
|
|
|
+ OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name());
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+ toClient.write(buffer);
|
|
|
+ toClient.flush();
|
|
|
+ toClient.close();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 日志预览
|
|
|
*/
|