|
|
|
@ -2,6 +2,7 @@ package com.op.mes.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
|
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
|
|
import com.op.common.core.domain.R;
|
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import com.op.common.core.utils.bean.BeanUtils;
|
|
|
|
|
import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
@ -11,16 +12,27 @@ import com.op.mes.mapper.MesMapper;
|
|
|
|
|
import com.op.mes.mapper.MesReportWorkMapper;
|
|
|
|
|
import com.op.mes.mapper.ProRfidProcessDetailMapper;
|
|
|
|
|
import com.op.mes.service.IWCSInterfaceService;
|
|
|
|
|
import com.op.system.api.RemoteUserService;
|
|
|
|
|
import com.op.system.api.domain.SysDept;
|
|
|
|
|
import com.op.system.api.domain.SysUser;
|
|
|
|
|
import com.op.system.api.domain.dto.BoardDTO;
|
|
|
|
|
import com.op.system.api.domain.dto.WCSDTO;
|
|
|
|
|
import com.op.system.api.domain.dto.WCSDataDTO;
|
|
|
|
|
import com.op.system.api.domain.mes.ProRfidProcessDetail;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -31,7 +43,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
|
|
|
|
|
|
|
|
|
|
protected Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesMapper mesMapper;
|
|
|
|
|
@Autowired
|
|
|
|
@ -39,6 +51,9 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesReportWorkMapper mesReportWorkMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RemoteUserService remoteUserService;
|
|
|
|
|
|
|
|
|
|
/**下一工序机台集合获取
|
|
|
|
|
* JSON
|
|
|
|
|
* {
|
|
|
|
@ -176,6 +191,45 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R dataClearTask(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 -> {
|
|
|
|
|
logger.info("++++++++++++" + dateSource.get("poolName") + "++++开始++++++++++");
|
|
|
|
|
Runnable run = () -> dateDeleteFunc(dateSource.get("poolName"),tables);
|
|
|
|
|
executorService.execute(run);
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("service == deviceOfflineTimingTask == exception", e);
|
|
|
|
|
return R.fail("service == deviceOfflineTimingTask == exception");
|
|
|
|
|
} finally {
|
|
|
|
|
executorService.shutdown();
|
|
|
|
|
}
|
|
|
|
|
return R.ok(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void dateDeleteFunc(String poolName,List<String> tables){
|
|
|
|
|
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
|
|
|
|
|
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)+" 00:00:00";
|
|
|
|
|
for(String table:tables){
|
|
|
|
|
mesMapper.deleteDateByTableName(table,ymdhms7);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String saveLGusedLog(List<LGInfoDto> lgdtos) {
|
|
|
|
|
DynamicDataSourceContextHolder.push("ds_"+lgdtos.get(0).getFactoryCode());// 这是数据源的key
|
|
|
|
@ -191,6 +245,11 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
|
System.out.println(DateUtils.getDate());
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|