|
@@ -16,13 +16,26 @@
|
|
*/
|
|
*/
|
|
package org.springblade.manager.service.impl;
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import org.springblade.core.tool.utils.CollectionUtil;
|
|
import org.springblade.manager.entity.TableInfo;
|
|
import org.springblade.manager.entity.TableInfo;
|
|
|
|
+import org.springblade.manager.entity.WbsFormElement;
|
|
|
|
+import org.springblade.manager.mapper.WbsFormElementMapper;
|
|
import org.springblade.manager.vo.TableInfoVO;
|
|
import org.springblade.manager.vo.TableInfoVO;
|
|
import org.springblade.manager.mapper.TableInfoMapper;
|
|
import org.springblade.manager.mapper.TableInfoMapper;
|
|
import org.springblade.manager.service.ITableInfoService;
|
|
import org.springblade.manager.service.ITableInfoService;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 实体主表信息 服务实现类
|
|
* 实体主表信息 服务实现类
|
|
@@ -38,4 +51,49 @@ public class TableInfoServiceImpl extends BaseServiceImpl<TableInfoMapper, Table
|
|
return page.setRecords(baseMapper.selectTableInfoPage(page, tableInfo));
|
|
return page.setRecords(baseMapper.selectTableInfoPage(page, tableInfo));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private WbsFormElementMapper wbsFormElementMapper;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 每小时执行一次
|
|
|
|
+ * 替换动态表中的阿里云地址
|
|
|
|
+ */
|
|
|
|
+ @Scheduled(cron = "0 0 * * * ?")
|
|
|
|
+ @Transactional
|
|
|
|
+ public void aliyunUrlReplace() {
|
|
|
|
+ System.out.println("执行阿里云地址替换-----------------------------开始");
|
|
|
|
+
|
|
|
|
+ String aliyunUrlOne = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload";
|
|
|
|
+ String aliyunUrlTwo = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com/upload";
|
|
|
|
+ String correctUrl = "https://xinan1.zos.ctyun.cn/blade-oss-chongqing/upload";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<TableInfo> tableInfos = baseMapper.selectListByAliyunUrlState();
|
|
|
|
+ if(CollectionUtil.isNotEmpty(tableInfos)){
|
|
|
|
+ for (TableInfo tableInfo : tableInfos) {
|
|
|
|
+ //获取字段
|
|
|
|
+ List<WbsFormElement> wbsFormElements = wbsFormElementMapper.selectList(new QueryWrapper<WbsFormElement>().lambda().eq(WbsFormElement::getFId, tableInfo.getId()));
|
|
|
|
+
|
|
|
|
+ if (CollectionUtil.isNotEmpty(wbsFormElements)) {
|
|
|
|
+ List<String> fields = wbsFormElements.stream().map(WbsFormElement::getEKey).collect(Collectors.toList());
|
|
|
|
+ //存在字段
|
|
|
|
+ List<String> countTableFields = baseMapper.countTableFields(tableInfo.getTabEnName(), fields, aliyunUrlOne);
|
|
|
|
+ if (CollectionUtil.isNotEmpty(countTableFields)) {
|
|
|
|
+ //替换
|
|
|
|
+ baseMapper.updateALiYunUrl(tableInfo.getTabEnName(), aliyunUrlOne, correctUrl, countTableFields);
|
|
|
|
+ }
|
|
|
|
+ //排查第二种类型的阿里云地址
|
|
|
|
+ List<String> fieldsTwo = baseMapper.countTableFields(tableInfo.getTabEnName(), fields, aliyunUrlTwo);
|
|
|
|
+ if(CollectionUtil.isNotEmpty(fieldsTwo)){
|
|
|
|
+ //替换
|
|
|
|
+ baseMapper.updateALiYunUrl(tableInfo.getTabEnName(), aliyunUrlTwo, correctUrl, fieldsTwo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //更新成功 把当前表的数据
|
|
|
|
+ baseMapper.insertAliyun(tableInfos.stream().map(TableInfo::getId).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ System.out.println("执行阿里云地址替换-----------------------------结束");
|
|
|
|
+ }
|
|
}
|
|
}
|