|
@@ -16,8 +16,10 @@ import org.springblade.repair.util.FileUtils;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.core.SingleColumnRowMapper;
|
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -28,7 +30,10 @@ import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.nio.file.Files;
|
|
|
+import java.time.chrono.JapaneseDate;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@RestController
|
|
@@ -45,7 +50,7 @@ public class CheckAndRepairController {
|
|
|
*/
|
|
|
@RequestMapping("/checkAndRepairExcelHtml")
|
|
|
@ApiOperation("定时检测修复ExcelHtml")
|
|
|
- @Scheduled(cron = "00 22 10 * * ?")
|
|
|
+ @Scheduled(cron = "00 00 00 * * ?")
|
|
|
public void checkAndRepairExcelHtml() {
|
|
|
StringBuilder result=new StringBuilder("清表损坏:");
|
|
|
String sql = "Select * from m_excel_tab where parent_id=0 and is_deleted=0";
|
|
@@ -66,7 +71,7 @@ public class CheckAndRepairController {
|
|
|
File html = new File(excelTab1.getHtmlUrl());
|
|
|
if(!html.exists()){
|
|
|
System.out.println(excelTab.getName() + "--" + tab.getName() + "--" + excelTab1.getName()+"html不存在 id:"+excelTab1.getId());
|
|
|
- if(excelTab1.getFileUrl() != null&&excelTab1.getFileUrl().endsWith(".xlsx") || excelTab1.getFileUrl().endsWith(".xls")){
|
|
|
+ if(excelTab1.getFileUrl() != null&&(excelTab1.getFileUrl().endsWith(".xlsx") || excelTab1.getFileUrl().endsWith(".xls"))){
|
|
|
long resourceLength = CommonUtil.getFileContentLength(excelTab1.getFileUrl());
|
|
|
System.out.println("文件大小:"+resourceLength);
|
|
|
if(resourceLength!=415L&&resourceLength!=0L&&resourceLength!=234L){
|
|
@@ -140,17 +145,11 @@ public class CheckAndRepairController {
|
|
|
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 定时更新private的htmUrl 保证url格式为 /mnt/sdc/Users/hongchuangyanfa/Desktop/privateUrlCopy/
|
|
|
- */
|
|
|
- private void checkAndRepairPrivateAndContractPrivateCopyUrl() {
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 定时更新private和contract的html,通过is_private_type_id;保证一样
|
|
|
*/
|
|
|
- @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+ @Scheduled(cron = "0 0 1 * * ?")
|
|
|
public void checkAndRepairPrivateAndContractHtml() {
|
|
|
System.out.println("开始扫描private和contract的html");
|
|
|
StringBuilder result=new StringBuilder("");
|
|
@@ -172,9 +171,132 @@ public class CheckAndRepairController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 定时更新private和contract的initTable 通过excelID,保证一样
|
|
|
+ * 定时更新private initTable 通过excelID,保证一样
|
|
|
*/
|
|
|
- public void checkAndRepairPrivateAndContractInitTable() {}
|
|
|
+ @GetMapping("/checkAndRepairPrivateInitTableAndExcelId")
|
|
|
+ @Scheduled(cron = "0 57 16 * * ?")
|
|
|
+ public void checkAndRepairPrivateInitTableAndExcelId() {
|
|
|
+ System.out.println("开始扫描private initTable和ExcelId");
|
|
|
+ String privateSql="select p_key_id,init_table_name,excel_id,html_url from m_wbs_tree_private where type=2 AND is_deleted=0 AND (excel_id IS NULL OR init_table_name IS NULL OR html_url IS NULL)";
|
|
|
+ List<WbsTreePrivate> list = jdbcTemplate.query(privateSql, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
+ list = list.stream()
|
|
|
+ .filter(item ->
|
|
|
+ !ObjectUtil.isEmpty(item.getHtmlUrl()) ||
|
|
|
+ !ObjectUtil.isEmpty(item.getExcelId()) ||
|
|
|
+ !ObjectUtil.isEmpty(item.getInitTableName())
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //excelId不为空 但是initTableName为空
|
|
|
+ List<WbsTreePrivate> list1 = list.stream()
|
|
|
+ .filter(item ->
|
|
|
+ !ObjectUtil.isEmpty(item.getExcelId()) &&
|
|
|
+ ObjectUtil.isEmpty(item.getInitTableName())
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ //excelId为空 但是initTableName不为空
|
|
|
+ List<WbsTreePrivate> list2 = list.stream()
|
|
|
+ .filter(item ->
|
|
|
+ ObjectUtil.isEmpty(item.getExcelId()) &&
|
|
|
+ !ObjectUtil.isEmpty(item.getInitTableName())
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(!list1.isEmpty()){
|
|
|
+ for (WbsTreePrivate w : list1) {
|
|
|
+ String sql="select a.tab_en_name,b.html_url from m_table_info a left join m_excel_tab b on a.id=b.tab_id where b.id="+w.getExcelId()+" and a.is_deleted=0 and b.is_deleted=0";
|
|
|
+ Map<String, Object> map = jdbcTemplate.queryForMap(sql);
|
|
|
+ if(map.get("tab_en_name")!=null){
|
|
|
+ String update="update m_wbs_tree_private set init_table_name="+map.get("tab_en_name")+" where p_key_id="+w.getPKeyId();
|
|
|
+ jdbcTemplate.update(update);
|
|
|
+ }
|
|
|
+ if(w.getHtmlUrl()==null){
|
|
|
+ String update="update m_wbs_tree_private set html_url="+map.get("html_url")+" where p_key_id="+w.getPKeyId();
|
|
|
+ jdbcTemplate.update(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!list2.isEmpty()){
|
|
|
+ for (WbsTreePrivate w : list2) {
|
|
|
+ String sql=" select a.id,a.html_url from m_excel_tab a left join m_table_info b on b.id=a.tab_id where b.tab_en_name= '"+w.getInitTableName()+"' and a.is_deleted=0 and b.is_deleted=0";
|
|
|
+ Map<String, Object> map = jdbcTemplate.queryForMap(sql);
|
|
|
+ if(map.get("id")!=null){
|
|
|
+ String update="update m_wbs_tree_private set excel_id="+map.get("id")+" where p_key_id="+w.getPKeyId();
|
|
|
+ jdbcTemplate.update(update);
|
|
|
+ }
|
|
|
+ if(w.getHtmlUrl()==null){
|
|
|
+ if(map.get("html_url")!=null){
|
|
|
+ String update="update m_wbs_tree_private set html_url='"+map.get("html_url")+"' where p_key_id ="+w.getPKeyId();
|
|
|
+ jdbcTemplate.update(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("更新完毕private initTable和ExcelId");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 定时更新contract initTable 通过excelID,保证一样
|
|
|
+ */
|
|
|
+ @GetMapping("/checkAndRepairContractInitTableAndExcelId")
|
|
|
+ @Scheduled(cron = "0 00 2 * * ?")
|
|
|
+ public void checkAndRepairContractInitTableAndExcelId() {
|
|
|
+ System.out.println("定时更新contract initTable和ExcelId");
|
|
|
+ String contractSql="select p_key_id,init_table_name,excel_id,html_url from m_wbs_tree_contract where type=2 AND is_deleted=0 AND (excel_id IS NULL OR init_table_name IS NULL OR html_url IS NULL)";
|
|
|
+ List<WbsTreeContract> list = jdbcTemplate.query(contractSql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ list = list.stream()
|
|
|
+ .filter(item ->
|
|
|
+ !ObjectUtil.isEmpty(item.getHtmlUrl()) ||
|
|
|
+ !ObjectUtil.isEmpty(item.getExcelId()) ||
|
|
|
+ !ObjectUtil.isEmpty(item.getInitTableName())
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //excelId不为空 但是initTableName为空
|
|
|
+ List<WbsTreeContract> list1 = list.stream()
|
|
|
+ .filter(item ->
|
|
|
+ !ObjectUtil.isEmpty(item.getExcelId()) &&
|
|
|
+ ObjectUtil.isEmpty(item.getInitTableName())
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ //excelId为空 但是initTableName不为空
|
|
|
+ List<WbsTreeContract> list2 = list.stream()
|
|
|
+ .filter(item ->
|
|
|
+ ObjectUtil.isEmpty(item.getExcelId()) &&
|
|
|
+ !ObjectUtil.isEmpty(item.getInitTableName())
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(!list1.isEmpty()){
|
|
|
+ for (WbsTreeContract w : list1) {
|
|
|
+ String sql="select a.tab_en_name,b.html_url from m_table_info a left join m_excel_tab b on a.id=b.tab_id where b.id="+w.getExcelId()+" and a.is_deleted=0 and b.is_deleted=0";
|
|
|
+ Map<String, Object> map = jdbcTemplate.queryForMap(sql);
|
|
|
+ if(map.get("tab_en_name")!=null){
|
|
|
+ String update="update m_wbs_tree_contract set init_table_name="+map.get("tab_en_name")+" where p_key_id="+w.getPKeyId();
|
|
|
+ jdbcTemplate.update(update);
|
|
|
+ }
|
|
|
+ if(w.getHtmlUrl()==null){
|
|
|
+ String update="update m_wbs_tree_contract set html_url="+map.get("html_url")+" where p_key_id="+w.getPKeyId();
|
|
|
+ jdbcTemplate.update(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!list2.isEmpty()){
|
|
|
+ for (WbsTreeContract w : list2) {
|
|
|
+ String sql=" select a.id,a.html_url from m_excel_tab a left join m_table_info b on b.id=a.tab_id where b.tab_en_name= '"+w.getInitTableName()+"' and a.is_deleted=0 and b.is_deleted=0";
|
|
|
+ Map<String, Object> map = jdbcTemplate.queryForMap(sql);
|
|
|
+ if(map.get("id")!=null){
|
|
|
+ String update="update m_wbs_tree_contract set excel_id="+map.get("id")+" where p_key_id="+w.getPKeyId();
|
|
|
+ jdbcTemplate.update(update);
|
|
|
+ }
|
|
|
+ if(w.getHtmlUrl()==null){
|
|
|
+ if(map.get("html_url")!=null){
|
|
|
+ String update="update m_wbs_tree_contract set html_url='"+map.get("html_url")+"' where p_key_id ="+w.getPKeyId();
|
|
|
+ jdbcTemplate.update(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("更新完毕contract initTable和ExcelId");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|