|
|
@@ -7,6 +7,8 @@ import com.uas.eis.service.EDCBakService;
|
|
|
import com.uas.eis.utils.Constant;
|
|
|
import com.uas.eis.utils.DateUtil;
|
|
|
import com.uas.eis.utils.SmbUtil;
|
|
|
+import jcifs.CIFSContext;
|
|
|
+import jcifs.CIFSException;
|
|
|
import jcifs.smb.SmbFile;
|
|
|
import jcifs.smb.SmbFileInputStream;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
@@ -63,27 +65,39 @@ public class EDCBakServiceImpl implements EDCBakService {
|
|
|
countDownLatch.countDown();
|
|
|
}*/
|
|
|
String counterpath = "";
|
|
|
+ //开启连接
|
|
|
+ CIFSContext currentContext = SmbUtil.initContextByIP(IP);
|
|
|
+ if(currentContext == null ){
|
|
|
+ logger.info(IP+" 获取上下文连接失败");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CIFSContext centerContext = SmbUtil.initContextByIP(SmbUtil.centerIP);
|
|
|
+ if(centerContext == null ){
|
|
|
+ logger.info(SmbUtil.centerIP+" 获取上下文连接失败");
|
|
|
+ return;
|
|
|
+ }
|
|
|
try {
|
|
|
for(EquipConfig config : configs){
|
|
|
String testStep = config.getEd_teststep();
|
|
|
String devcode = config.getEd_devcode();
|
|
|
- List<Map<String, Object>> lists=baseDao.getJdbcTemplate().queryForList("SELECT * FROM (SELECT * FROM DATACENTER$MESTEMP WHERE EQPCODE_='"+devcode+"' AND TAB_ ='"+testStep+"' and turn_=0 AND nvl(fail,0)=0 ORDER BY CHIPCODE_,OBJECT_RRN ASC ) WHERE ROWNUM <= 50");
|
|
|
+ List<Map<String, Object>> lists=baseDao.getJdbcTemplate().queryForList("SELECT * FROM (SELECT * FROM DATACENTER$MESTEMP WHERE EQPCODE_='"+devcode+"' AND TAB_ ='"+testStep+"' and turn_=0 AND nvl(fail,0)=0 ORDER BY CHIPCODE_,OBJECT_RRN ASC ) WHERE ROWNUM <= 1000");
|
|
|
logger.info(" matchIP:"+IP+","+testStep+" start;");
|
|
|
logger.info(" matchIP:"+IP+","+testStep+" 待归档数:"+lists.size());
|
|
|
+ SmbFile dataFile = SmbUtil.getCurrentFile(IP, dataRootPath, currentContext );
|
|
|
+ List <SmbFile> files = SmbUtil.getChildFiles(dataFile, testStep, "xls");
|
|
|
+ List <SmbFile> files1 = SmbUtil.getChildFiles(dataFile, testStep, "jdf");
|
|
|
+ List <SmbFile> files2 = SmbUtil.getChildFiles(dataFile, testStep, "njdf");
|
|
|
if(lists.size()>0){
|
|
|
try {
|
|
|
/**相关路径匹配*/
|
|
|
+ System.out.println(smbFile);
|
|
|
if(smbFile !=null) {
|
|
|
- SmbFile dataFile = SmbUtil.getCurrentFile(IP,dataRootPath);
|
|
|
logger.info(" matchIP:"+IP+","+testStep+" :dataPath:"+ dataFile.getPath());
|
|
|
- List <SmbFile> files = SmbUtil.getChildFiles(dataFile, testStep, "xls");
|
|
|
- List <SmbFile> files1 = SmbUtil.getChildFiles(dataFile, testStep, "jdf");
|
|
|
- List <SmbFile> files2 = SmbUtil.getChildFiles(dataFile, testStep, "njdf");
|
|
|
for(Map<String, Object> map : lists) {
|
|
|
//Counter文件匹配
|
|
|
counterpath = String.valueOf(map.get("COUNTERPATH_"));
|
|
|
final String filename = counterpath.substring(counterpath.lastIndexOf("\\")+1);
|
|
|
- smbFile = SmbUtil.getCurrentFile(IP,counterbakRootPath+filename);
|
|
|
+ smbFile = SmbUtil.getCurrentFile(IP,counterbakRootPath+filename ,currentContext);
|
|
|
map.put("COUNTERPATH_", smbFile.getPath());
|
|
|
Optional<SmbFile> optional = files.stream().filter(file -> mappingSuccess(filename,file)).findFirst();
|
|
|
//遍历到了对应的Data文件存在
|
|
|
@@ -146,7 +160,7 @@ public class EDCBakServiceImpl implements EDCBakService {
|
|
|
String currentUploadPath = getUploadPath(uploadRootPath+"/");
|
|
|
String centerUploadPath = getUploadPath(SmbUtil.centerPath+devcode+"/");
|
|
|
SmbFile counterFile = null;
|
|
|
- SmbFile dataFile = null;
|
|
|
+ dataFile = null;
|
|
|
SmbFile jdfFile = null;
|
|
|
String currentKind = null;
|
|
|
SmbFile counterBaKFile = null;
|
|
|
@@ -172,32 +186,31 @@ public class EDCBakServiceImpl implements EDCBakService {
|
|
|
String path6=""; //本地JDF文件
|
|
|
|
|
|
//判断本机文件夹是否存在,不存在创建
|
|
|
- if(!SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/").exists()){
|
|
|
- SmbUtil.getCurrentFile(IP,currentUploadPath+(currentKind+"/SJ/")).mkdirs();
|
|
|
- SmbUtil.getCurrentFile(IP,currentUploadPath+(currentKind+"/FP/")).mkdirs();
|
|
|
+ System.out.println(SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/", currentContext).getPath());
|
|
|
+ if(!SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/", currentContext).exists()){
|
|
|
+ SmbUtil.getCurrentFile(IP,currentUploadPath+(currentKind+"/SJ/"), currentContext).mkdirs();
|
|
|
+ SmbUtil.getCurrentFile(IP,currentUploadPath+(currentKind+"/FP/"), currentContext).mkdirs();
|
|
|
}
|
|
|
- //判断文件服务器文件夹是否存在,不存在创建
|
|
|
- if(!SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/").exists()){
|
|
|
- SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+(currentKind+"/SJ/")).mkdirs();
|
|
|
- SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+(currentKind+"/FP/")).mkdirs();
|
|
|
+ //判断文件中心服务器文件夹是否存在,不存在创建
|
|
|
+ if(!SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/" , centerContext).exists()){
|
|
|
+ SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+(currentKind+"/SJ/") , centerContext).mkdirs();
|
|
|
+ SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+(currentKind+"/FP/"), centerContext).mkdirs();
|
|
|
}
|
|
|
|
|
|
//处理Counter文件
|
|
|
- counterFile = SmbUtil.getCurrentFile(counterPath_);
|
|
|
- counterCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/FP/"+map.get("CHIPCODE_")+".xls");
|
|
|
- /**
|
|
|
- * counter文件 文件服务器归档
|
|
|
- * */
|
|
|
+ counterFile = SmbUtil.getCurrentFileBySmbPath(counterPath_ , currentContext);
|
|
|
+ counterCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP, centerUploadPath+currentKind+"/FP/"+map.get("CHIPCODE_")+".xls", centerContext);
|
|
|
+ System.out.println(counterFile.getPath());
|
|
|
+ System.out.println(counterCenterFile.getPath());
|
|
|
counterFile.copyTo(counterCenterFile);
|
|
|
-
|
|
|
- counterBaKFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/FP/"+map.get("CHIPCODE_")+".xls");
|
|
|
+ counterBaKFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/FP/"+map.get("CHIPCODE_")+".xls", currentContext);
|
|
|
|
|
|
int Count=1;
|
|
|
while (counterBaKFile.exists()){
|
|
|
String filename= counterBaKFile.getName();
|
|
|
String name = filename.substring(0,filename.indexOf("."));
|
|
|
String newFilename = name+"("+Count+")";
|
|
|
- counterBaKFile= SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/FP/"+newFilename+".xls");
|
|
|
+ counterBaKFile= SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/FP/"+newFilename+".xls", currentContext);
|
|
|
}
|
|
|
path1=counterCenterFile.getPath();
|
|
|
path3=counterBaKFile.getPath();
|
|
|
@@ -210,18 +223,18 @@ public class EDCBakServiceImpl implements EDCBakService {
|
|
|
//存在Data文件
|
|
|
if(map.get("DATAPATH_")!=null){
|
|
|
|
|
|
- dataFile = SmbUtil.getCurrentFile(dataPath_);
|
|
|
- dataCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls");
|
|
|
+ dataFile = SmbUtil.getCurrentFileBySmbPath(dataPath_, currentContext);
|
|
|
+ dataCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls" , centerContext);
|
|
|
/**
|
|
|
* data文件 文件服务器归档
|
|
|
* */
|
|
|
dataFile.copyTo(dataCenterFile);
|
|
|
- dataBakFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls");
|
|
|
+ dataBakFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls", currentContext);
|
|
|
while (dataBakFile.exists()){
|
|
|
String filename= dataBakFile.getName();
|
|
|
String name = filename.substring(0,filename.indexOf("."));
|
|
|
String newFilename = name+"("+Count+")";
|
|
|
- dataBakFile= SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+newFilename+".xls");
|
|
|
+ dataBakFile= SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+newFilename+".xls", currentContext);
|
|
|
}
|
|
|
path2=dataCenterFile.getPath();
|
|
|
path4=dataBakFile.getPath();
|
|
|
@@ -231,8 +244,8 @@ public class EDCBakServiceImpl implements EDCBakService {
|
|
|
dataFile.copyTo(dataBakFile);
|
|
|
dataFile.delete();
|
|
|
}else{
|
|
|
- dataCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls");
|
|
|
- dataBakFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls");
|
|
|
+ dataCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls", centerContext);
|
|
|
+ dataBakFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls", currentContext);
|
|
|
path2=dataCenterFile.getPath();
|
|
|
path4=dataBakFile.getPath();
|
|
|
}
|
|
|
@@ -243,16 +256,16 @@ public class EDCBakServiceImpl implements EDCBakService {
|
|
|
if(map.get("JDFPATH_").toString().contains("njdf")){
|
|
|
filesuffix=".njdf";
|
|
|
}
|
|
|
- jdfFile = SmbUtil.getCurrentFile(jdfPath_);
|
|
|
- jdfCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+filesuffix);
|
|
|
+ jdfFile = SmbUtil.getCurrentFileBySmbPath(jdfPath_ ,currentContext);
|
|
|
+ jdfCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+filesuffix, centerContext);
|
|
|
jdfFile.copyTo(jdfCenterFile);
|
|
|
- jdfBakFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+filesuffix);
|
|
|
+ jdfBakFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+filesuffix, currentContext);
|
|
|
while (jdfBakFile.exists()){
|
|
|
String filename= jdfBakFile.getName();
|
|
|
String name = filename.substring(0,filename.indexOf("."));
|
|
|
String suffix = filename.substring(filename.lastIndexOf("."));
|
|
|
String newFilename = name+"("+Count+")";
|
|
|
- jdfBakFile= SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+newFilename+filesuffix);
|
|
|
+ jdfBakFile= SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+newFilename+filesuffix, currentContext);
|
|
|
}
|
|
|
path5=jdfCenterFile.getPath();
|
|
|
path6=jdfBakFile.getPath();
|
|
|
@@ -279,11 +292,11 @@ public class EDCBakServiceImpl implements EDCBakService {
|
|
|
Sqls.add("UPDATE DATACENTER$MESTEMP SET TURN_=-1 WHERE OBJECT_RRN IN ("+ StringUtils.join(IDS,",") +")");
|
|
|
baseDao.execute(Sqls);
|
|
|
}
|
|
|
- //同步做COUNTER文件解析
|
|
|
+ /* //同步做COUNTER文件解析
|
|
|
SqlRowList rs1=baseDao.queryForRowSet("select chipcode_ from DATACENTER$CHIP left join CHIP_EDC_RECORD on DATACENTER$CHIP.CHIPCODE_=CHIP_EDC_RECORD.CER_CHIPCODE where CER_CHIPCODE is null");
|
|
|
while(rs1.next()){
|
|
|
- AnalysisCounterData(rs1.getString("chipcode_"));
|
|
|
- }
|
|
|
+ AnalysisCounterData(rs1.getString("chipcode_"), centerContext);
|
|
|
+ }*/
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -292,6 +305,12 @@ public class EDCBakServiceImpl implements EDCBakService {
|
|
|
logger.info(IP+" 操作失败;");
|
|
|
}finally {
|
|
|
countDownLatch.countDown();
|
|
|
+ try {
|
|
|
+ centerContext.close();
|
|
|
+ currentContext.close();
|
|
|
+ } catch (CIFSException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
logger.info(" matchIP:"+IP+" end;");
|
|
|
}
|
|
|
@@ -323,14 +342,14 @@ public class EDCBakServiceImpl implements EDCBakService {
|
|
|
|
|
|
//解析Counter文件
|
|
|
@Override
|
|
|
- public Object AnalysisCounterData(String chip_code){
|
|
|
+ public Object AnalysisCounterData(String chip_code ,CIFSContext centerContext){
|
|
|
SqlRowList rs=baseDao.queryForRowSet("select counterpath_ from datacenter$chip where chipcode_='"+chip_code+"' order by id_ desc");
|
|
|
Object cer_id=null;
|
|
|
if(rs.next()){
|
|
|
try{
|
|
|
String FilePath=rs.getString("counterpath_");
|
|
|
//打开文件流
|
|
|
- SmbFile smbFile = SmbUtil.getCurrentFile(FilePath);
|
|
|
+ SmbFile smbFile = SmbUtil.getCurrentFileBySmbPath(FilePath ,centerContext);
|
|
|
InputStream is = new BufferedInputStream(new SmbFileInputStream(smbFile));
|
|
|
Workbook book = new HSSFWorkbook(is);
|
|
|
cer_id=baseDao.getSeqId("CHIP_EDC_RECORD_SEQ");
|