|
@@ -32,9 +32,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -55,10 +53,11 @@ public class TableInfoServiceImpl extends BaseServiceImpl<TableInfoMapper, Table
|
|
private WbsFormElementMapper wbsFormElementMapper;
|
|
private WbsFormElementMapper wbsFormElementMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 每小时执行一次
|
|
|
|
|
|
+ * 十分钟执行一次
|
|
* 替换动态表中的阿里云地址
|
|
* 替换动态表中的阿里云地址
|
|
*/
|
|
*/
|
|
- @Scheduled(cron = "0 0 * * * ?")
|
|
|
|
|
|
+ @Scheduled(cron = "0 */10 * * * ?")
|
|
|
|
+// @Scheduled(fixedDelay = 60000)
|
|
public void aliyunUrlReplace() {
|
|
public void aliyunUrlReplace() {
|
|
System.out.println("执行阿里云地址替换-----------------------------开始");
|
|
System.out.println("执行阿里云地址替换-----------------------------开始");
|
|
|
|
|
|
@@ -68,35 +67,54 @@ public class TableInfoServiceImpl extends BaseServiceImpl<TableInfoMapper, Table
|
|
|
|
|
|
|
|
|
|
List<TableInfo> tableInfos = baseMapper.selectListByAliyunUrlState();
|
|
List<TableInfo> tableInfos = baseMapper.selectListByAliyunUrlState();
|
|
- if(CollectionUtil.isNotEmpty(tableInfos)){
|
|
|
|
|
|
+ if (CollectionUtil.isNotEmpty(tableInfos)) {
|
|
for (TableInfo tableInfo : tableInfos) {
|
|
for (TableInfo tableInfo : tableInfos) {
|
|
-
|
|
|
|
|
|
+ //表 符合需求的字段
|
|
|
|
+ Set<String> createField = new HashSet<>();
|
|
|
|
+ Integer updateCount = 0;
|
|
//判断表是否存在
|
|
//判断表是否存在
|
|
int exist = baseMapper.tableIsExist(tableInfo.getTabEnName());
|
|
int exist = baseMapper.tableIsExist(tableInfo.getTabEnName());
|
|
- if(exist > 0){
|
|
|
|
|
|
+ if (exist > 0) {
|
|
//获取字段
|
|
//获取字段
|
|
List<WbsFormElement> wbsFormElements = wbsFormElementMapper.selectList(new QueryWrapper<WbsFormElement>().lambda().eq(WbsFormElement::getFId, tableInfo.getId()));
|
|
List<WbsFormElement> wbsFormElements = wbsFormElementMapper.selectList(new QueryWrapper<WbsFormElement>().lambda().eq(WbsFormElement::getFId, tableInfo.getId()));
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(wbsFormElements)) {
|
|
if (CollectionUtil.isNotEmpty(wbsFormElements)) {
|
|
List<String> fields = wbsFormElements.stream().map(WbsFormElement::getEKey).collect(Collectors.toList());
|
|
List<String> fields = wbsFormElements.stream().map(WbsFormElement::getEKey).collect(Collectors.toList());
|
|
//存在字段
|
|
//存在字段
|
|
- List<String> countTableFields = baseMapper.countTableFields(tableInfo.getTabEnName(), fields, aliyunUrlOne);
|
|
|
|
|
|
+ List<String> countTableFields = null;
|
|
|
|
+ try {
|
|
|
|
+ countTableFields = baseMapper.countTableFields(tableInfo.getTabEnName(), fields, aliyunUrlOne);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println("执行阿里云地址替换-异常:表字段存在异常");
|
|
|
|
+ }
|
|
|
|
+
|
|
if (CollectionUtil.isNotEmpty(countTableFields)) {
|
|
if (CollectionUtil.isNotEmpty(countTableFields)) {
|
|
|
|
+ createField.addAll(countTableFields);
|
|
//替换
|
|
//替换
|
|
- baseMapper.updateALiYunUrl(tableInfo.getTabEnName(), aliyunUrlOne, correctUrl, countTableFields);
|
|
|
|
|
|
+ Integer count = baseMapper.updateALiYunUrl(tableInfo.getTabEnName(), aliyunUrlOne, correctUrl, countTableFields);
|
|
|
|
+ updateCount += count;
|
|
}
|
|
}
|
|
//排查第二种类型的阿里云地址
|
|
//排查第二种类型的阿里云地址
|
|
- List<String> fieldsTwo = baseMapper.countTableFields(tableInfo.getTabEnName(), fields, aliyunUrlTwo);
|
|
|
|
- if(CollectionUtil.isNotEmpty(fieldsTwo)){
|
|
|
|
|
|
+ List<String> fieldsTwo = null;
|
|
|
|
+ try {
|
|
|
|
+ fieldsTwo = baseMapper.countTableFields(tableInfo.getTabEnName(), fields, aliyunUrlTwo);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println("执行阿里云地址替换-异常:表字段存在异常");
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtil.isNotEmpty(fieldsTwo)) {
|
|
|
|
+ createField.addAll(countTableFields);
|
|
//替换
|
|
//替换
|
|
- baseMapper.updateALiYunUrl(tableInfo.getTabEnName(), aliyunUrlTwo, correctUrl, fieldsTwo);
|
|
|
|
|
|
+ Integer count = baseMapper.updateALiYunUrl(tableInfo.getTabEnName(), aliyunUrlTwo, correctUrl, fieldsTwo);
|
|
|
|
+ updateCount += count;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //更新成功 把当前表的数据
|
|
|
|
+ baseMapper.insertAliyun(tableInfo.getId(), createField != null ? String.join(",", createField) : null, updateCount)
|
|
|
|
+ ;
|
|
}
|
|
}
|
|
|
|
|
|
- //更新成功 把当前表的数据
|
|
|
|
- baseMapper.insertAliyun(tableInfos.stream().map(TableInfo::getId).collect(Collectors.toList()));
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
System.out.println("执行阿里云地址替换-----------------------------结束");
|
|
System.out.println("执行阿里云地址替换-----------------------------结束");
|
|
}
|
|
}
|