|
@@ -1,5 +1,7 @@
|
|
|
package org.springblade.manager.controller;
|
|
|
|
|
|
+import cn.hutool.core.io.resource.Resource;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.log.StaticLog;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -69,6 +71,7 @@ import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.mock.web.MockMultipartFile;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -85,6 +88,7 @@ import java.net.URLConnection;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.nio.file.StandardCopyOption;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.List;
|
|
@@ -154,6 +158,8 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
private final IContractInfoService contractInfoService;
|
|
|
|
|
|
+ private final SignFtpUtil signFtpUtil;
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
StringRedisTemplate RedisTemplate;
|
|
@@ -335,6 +341,10 @@ public class ExcelTabController extends BladeController {
|
|
|
return R.success("上传成功");
|
|
|
}
|
|
|
|
|
|
+ public void checkHtml(){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public static InputStream getOSSInputStream(String urlStr) throws Exception {
|
|
|
//获取OSS文件流
|
|
@@ -1609,28 +1619,31 @@ public class ExcelTabController extends BladeController {
|
|
|
public R copeBussTab(Long pkeyId) {
|
|
|
WbsTreeContract wbsInfo = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
-
|
|
|
+ String[] split = wbsInfo.getNodeName().split("__");
|
|
|
+ //查出当前节点里面本表的所有复制表
|
|
|
List<WbsTreeContract> wbsTreeContractList = wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .likeRight(WbsTreeContract::getNodeName, wbsInfo.getNodeName())
|
|
|
+ .likeRight(WbsTreeContract::getNodeName,split[0])
|
|
|
.eq(WbsTreeContract::getContractId, wbsInfo.getContractId())
|
|
|
.eq(WbsTreeContract::getParentId, wbsInfo.getParentId())
|
|
|
.eq(WbsTreeContract::getTableOwner, wbsInfo.getTableOwner()));
|
|
|
- List<WbsTreeContract> wbsTreeContractList2 = wbsTreeContractList.stream().sorted(Comparator.comparing(WbsTreeContract::getCreateTime).reversed()).collect(Collectors.toList());
|
|
|
- Set<String> strings = wbsTreeContractList2.stream().map(o -> o.getNodeName()).collect(Collectors.toSet());
|
|
|
- List<WbsTreeContract> wbsTreeContractList3 = wbsTreeContractList.stream().sorted(Comparator.comparing(WbsTreeContract::getCreateTime)).collect(Collectors.toList());
|
|
|
- Boolean flag = false;
|
|
|
- if (strings.size() != wbsTreeContractList3.size()) {
|
|
|
- flag = true;
|
|
|
- for (int i = 0; i < wbsTreeContractList3.size(); i++) {
|
|
|
- if (wbsTreeContractList3.get(i).getIsCopeTab() != null && wbsTreeContractList3.get(i).getIsCopeTab().equals(Integer.valueOf(2))) {
|
|
|
- String nodeName = wbsTreeContractList3.get(0).getNodeName();
|
|
|
+ //拿到所有的名字
|
|
|
+ Set<String> strings = wbsTreeContractList.stream().map(o -> o.getNodeName()).collect(Collectors.toSet());
|
|
|
+ //根据实际排序
|
|
|
+ List<WbsTreeContract> wbsTreeContractList2 = wbsTreeContractList.stream().sorted(Comparator.comparing(WbsTreeContract::getCreateTime)).collect(Collectors.toList());
|
|
|
+ //如果数量对不上说明有错的情况就进来,进行修改,现在wbsTreeContractList2就是正常的
|
|
|
+ if (strings.size() != wbsTreeContractList2.size()) {
|
|
|
+ for (int i = 0; i < wbsTreeContractList2.size(); i++) {
|
|
|
+ //是复制表
|
|
|
+ if (wbsTreeContractList2.get(i).getIsCopeTab() != null && wbsTreeContractList2.get(i).getIsCopeTab().equals(Integer.valueOf(2))) {
|
|
|
+ String nodeName = wbsTreeContractList2.get(0).getNodeName().split("__")[0];
|
|
|
nodeName = nodeName + "__" + (i);
|
|
|
- wbsTreeContractList3.get(i).setNodeName(nodeName);
|
|
|
- String update = "UPDATE m_wbs_tree_contract Set node_name= " + "'" + wbsTreeContractList3.get(i).getNodeName() + "'" + " WHERE p_key_id=" + wbsTreeContractList3.get(i).getPKeyId();
|
|
|
+ wbsTreeContractList2.get(i).setNodeName(nodeName);
|
|
|
+ String update = "UPDATE m_wbs_tree_contract Set node_name= " + "'" + wbsTreeContractList2.get(i).getNodeName() + "'" + " WHERE p_key_id=" + wbsTreeContractList2.get(i).getPKeyId();
|
|
|
jdbcTemplate.update(update);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//新增
|
|
|
long tabGroupId = SnowFlakeUtil.getId();
|
|
|
long newPkId = SnowFlakeUtil.getId();
|
|
@@ -1640,11 +1653,7 @@ public class ExcelTabController extends BladeController {
|
|
|
wbsTreeContract.setCreateTime(new Date());
|
|
|
wbsTreeContract.setTabGroupId(tabGroupId);
|
|
|
String nodeName;
|
|
|
- if (flag) {
|
|
|
- nodeName = wbsTreeContractList3.get(wbsTreeContractList3.size() - 1).getNodeName();
|
|
|
- } else {
|
|
|
- nodeName = wbsTreeContractList2.get(0).getNodeName();
|
|
|
- }
|
|
|
+ nodeName = wbsTreeContractList2.get(wbsTreeContractList2.size() - 1).getNodeName();
|
|
|
if (nodeName.indexOf("__") >= 0) {
|
|
|
String[] oldName = nodeName.split("__");
|
|
|
nodeName = oldName[0] + "__" + (Integer.parseInt(oldName[1]) + 1);
|
|
@@ -4417,7 +4426,7 @@ public class ExcelTabController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Scheduled(cron = "0 01 15 * * ?")
|
|
|
+ //@Scheduled(cron = "0 01 15 * * ?")
|
|
|
//检查excel路径有错的
|
|
|
public void cheackExcel() throws IOException {
|
|
|
StringBuilder result=new StringBuilder("");
|
|
@@ -4444,6 +4453,58 @@ public class ExcelTabController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查清表html是否存在,不存在就下载重新上传
|
|
|
+ * 如果excel都不存在,就输出出来
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ //@Scheduled(cron = "10 26 10 * * ?")
|
|
|
+ public void checkHtmlIsExist() throws Exception {
|
|
|
+ StringBuilder result=new StringBuilder("");
|
|
|
+ String sql = "Select * from m_excel_tab where parent_id=0 and is_deleted=0";
|
|
|
+ List<ExcelTab> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ExcelTab.class));
|
|
|
+ String excelPath="E:\\excel\\";
|
|
|
+ for (ExcelTab excelTab : query) {
|
|
|
+ String sql1 = "Select * from m_excel_tab where parent_id=" + excelTab.getId() + " and is_deleted=0";
|
|
|
+ List<ExcelTab> query1 = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ExcelTab.class));
|
|
|
+ for (ExcelTab tab : query1) {
|
|
|
+ String sql2 = "Select * from m_excel_tab where parent_id=" + tab.getId() + " and is_deleted=0";
|
|
|
+ List<ExcelTab> query2 = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(ExcelTab.class));
|
|
|
+ for (ExcelTab excelTab1 : query2) {
|
|
|
+ if(!signFtpUtil.isExist(excelTab1.getHtmlUrl())){
|
|
|
+ if(excelTab1.getFileUrl() != null&&excelTab1.getFileUrl().endsWith(".xlsx") || excelTab1.getFileUrl().endsWith(".xls")){
|
|
|
+ long resourceLength = CommonUtil.getResourceLength(excelTab1.getFileUrl());
|
|
|
+ if(resourceLength>=500){
|
|
|
+ //先下载这个文件,再上传
|
|
|
+ String fileUrl = excelTab1.getFileUrl();
|
|
|
+ String localPath=excelPath+excelTab1.getId()+".xlsx";
|
|
|
+ InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(fileUrl);
|
|
|
+ FileUtils.saveFile(inputStreamByUrl,localPath);
|
|
|
+ File file = new File(localPath);
|
|
|
+ if(file.exists()){
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ paramMap.put("nodeId", excelTab1.getId());
|
|
|
+ paramMap.put("type",2);
|
|
|
+ HashMap<String,String> headers=new HashMap<>();
|
|
|
+ headers.put("Content-Type", "multipart/form-data; boundary=----WebKitFormBoundary4tcP4daRPIFDBRvm");
|
|
|
+ headers.put("Authorization","Basic c2FiZXI6c2FiZXJfc2VjcmV0");
|
|
|
+ headers.put("Blade-auth","bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRfaWQiOiIwMDAwMDAiLCJ1c2VyX25hbWUiOiJjciIsInJlYWxfbmFtZSI6IumZiOeEtiIsImF2YXRhciI6IiIsImF1dGhvcml0aWVzIjpbImFkbWluaXN0cmF0b3IiXSwiY2xpZW50X2lkIjoic2FiZXIiLCJyb2xlX25hbWUiOiJhZG1pbmlzdHJhdG9yIiwibGljZW5zZSI6InBvd2VyZWQgYnkgYmxhZGV4IiwicG9zdF9pZCI6IiIsInVzZXJfaWQiOiIxOTEyNzAxMzgzOTgyNDI0MDY1Iiwicm9sZV9pZCI6IjExMjM1OTg4MTY3Mzg2NzUyMDEiLCJwaG9uZSI6IjE1MjE1MDUyNzg2Iiwic2NvcGUiOlsiYWxsIl0sIm5pY2tfbmFtZSI6IumZiOeEtiIsIm9hdXRoX2lkIjoiIiwiZGV0YWlsIjp7InR5cGUiOiJ3ZWIifSwiZXhwIjoxNzQ2NDk5MTYyLCJkZXB0X2lkIjoiMTUzNjk4MzA1NjM2MjM4MTMxMyIsImp0aSI6IjIzNGRmY2ZmLWUwOWMtNDVkMy05ODI1LTdhNGI2MjdhYWFlZSIsImFjY291bnQiOiJjciJ9.yfweibj1y8VlWzpGlbhyUr2FMGzG_N1y5fK3xH9kbcE");
|
|
|
+ headers.put("Tenant-Id","000000");
|
|
|
+ String url="http://testmanger.hcxxy.com/api/blade-manager/exceltab/put-file-attach";
|
|
|
+ String body = HttpUtil.createPost(url).addHeaders(headers).form(paramMap).form("file", file).execute().body();
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ result.append(excelTab.getName() + "--" + tab.getName() + "--" + excelTab1.getName()+"\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("完成");
|
|
|
+ System.out.println(result);
|
|
|
+ }
|
|
|
@GetMapping("/checkParamElement")
|
|
|
@ApiOperationSupport(order = 30)
|
|
|
@ApiOperation(value = "检查参数元素", notes = "检查参数元素")
|