|
|
|
@ -210,8 +210,8 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
|
|
|
|
|
executorService.execute(run);
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("service == deviceOfflineTimingTask == exception", e);
|
|
|
|
|
return R.fail("service == deviceOfflineTimingTask == exception");
|
|
|
|
|
logger.error("service == dataClearTask == exception", e);
|
|
|
|
|
return R.fail("service == dataClearTask == exception");
|
|
|
|
|
} finally {
|
|
|
|
|
executorService.shutdown();
|
|
|
|
|
}
|
|
|
|
@ -230,6 +230,84 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R dataBKTask(List<String> tables) {
|
|
|
|
|
// 加载sf-cloud库的sys_datasource
|
|
|
|
|
SysUser sysUser = new SysUser();
|
|
|
|
|
sysUser.setUserId(1L);
|
|
|
|
|
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
|
|
|
|
|
List<Map<String, String>> dateSources = dateSources0.getData();
|
|
|
|
|
ExecutorService executorService = new ThreadPoolExecutor(
|
|
|
|
|
dateSources.size(),
|
|
|
|
|
dateSources.size(),
|
|
|
|
|
0L, TimeUnit.MILLISECONDS,
|
|
|
|
|
new LinkedBlockingQueue<Runnable>());
|
|
|
|
|
try {
|
|
|
|
|
dateSources.forEach(dateSource -> {
|
|
|
|
|
if("ds_1000".equals(dateSource.get("poolName"))){//只有999白坯工厂有这种情况
|
|
|
|
|
logger.info("++++++++++++" + dateSource.get("poolName") + "++++开始++++++++++");
|
|
|
|
|
Runnable run = () -> dateBKFunc(dateSource.get("poolName"),tables);
|
|
|
|
|
executorService.execute(run);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("service == dataBKTask == exception", e);
|
|
|
|
|
return R.fail("service == dataBKTask == exception");
|
|
|
|
|
} finally {
|
|
|
|
|
executorService.shutdown();
|
|
|
|
|
}
|
|
|
|
|
return R.ok(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void dateBKFunc(String poolName,List<String> tables){
|
|
|
|
|
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
|
|
|
|
|
DateTimeFormatter ymdhms = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
LocalDate today = LocalDate.now();
|
|
|
|
|
LocalDate lastMonth3 = today.plus(-3, ChronoUnit.MONTHS);
|
|
|
|
|
String ymdhms3 = lastMonth3.format(ymdhms)+" 00:00:00";
|
|
|
|
|
|
|
|
|
|
LocalDate lastMonth2 = today.plus(-2, ChronoUnit.MONTHS);
|
|
|
|
|
String ymdhms2 = lastMonth2.format(ymdhms)+" 00:00:00";
|
|
|
|
|
|
|
|
|
|
for(String table:tables){
|
|
|
|
|
//如果月份是 1,4,7,10则创建季度表
|
|
|
|
|
int monthFlag = lastMonth3.getMonthValue();
|
|
|
|
|
int yearFlag = lastMonth3.getYear();
|
|
|
|
|
String tablePre = table+"_" + yearFlag;
|
|
|
|
|
String newTable = "";
|
|
|
|
|
if(monthFlag == 1){
|
|
|
|
|
newTable = tablePre +"_01_02_03";
|
|
|
|
|
}else if(monthFlag == 4){
|
|
|
|
|
newTable = tablePre +"_04_05_06";
|
|
|
|
|
}else if(monthFlag == 7){
|
|
|
|
|
newTable = tablePre +"_07_08_09";
|
|
|
|
|
}else if(monthFlag == 10){
|
|
|
|
|
newTable = tablePre +"_10_11_12";
|
|
|
|
|
}
|
|
|
|
|
if(!"".equals(newTable)){
|
|
|
|
|
int m = mesMapper.createNewTable(newTable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String addMonthTable = "";
|
|
|
|
|
if(monthFlag>=1 && monthFlag<4){
|
|
|
|
|
addMonthTable = tablePre + "_01_02_03";
|
|
|
|
|
}else if(monthFlag>=4 && monthFlag<7){
|
|
|
|
|
addMonthTable = tablePre + "_04_05_06";
|
|
|
|
|
}else if(monthFlag>=7 && monthFlag<10){
|
|
|
|
|
addMonthTable = tablePre + "_07_08_09";
|
|
|
|
|
}else if(monthFlag>=10 && monthFlag<=12){
|
|
|
|
|
addMonthTable = tablePre + "_10_11_12";
|
|
|
|
|
}
|
|
|
|
|
//先删除备份表数据该月数据
|
|
|
|
|
//mesMapper.deleteBkDate(addMonthTable,ymdhms3,ymdhms2);
|
|
|
|
|
//先备份1个月的数据
|
|
|
|
|
mesMapper.copyBkDateByTable(addMonthTable,ymdhms3,ymdhms2);
|
|
|
|
|
//删掉历史1个月的数据
|
|
|
|
|
mesMapper.deleteBkDateByTable(ymdhms3,ymdhms2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String saveLGusedLog(List<LGInfoDto> lgdtos) {
|
|
|
|
|
DynamicDataSourceContextHolder.push("ds_"+lgdtos.get(0).getFactoryCode());// 这是数据源的key
|
|
|
|
@ -247,9 +325,8 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
|
DateTimeFormatter ymdhms = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
LocalDate today = LocalDate.now();
|
|
|
|
|
System.out.println("今天的日期为:"+today);
|
|
|
|
|
LocalDate nextWeek = today.plus(-3, ChronoUnit.DAYS);
|
|
|
|
|
String ymdhms7 = nextWeek.format(ymdhms);
|
|
|
|
|
System.out.println("7天之前的日期为:"+ymdhms7);
|
|
|
|
|
LocalDate lastMonth3 = today.plus(-3, ChronoUnit.MONTHS);
|
|
|
|
|
|
|
|
|
|
System.out.println("7天之前的日期为:"+lastMonth3.getYear());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|