📄 pursue.java.svn-base
字号:
package pbs.application.iiop.GUI.huadong;
import java.io.*;
import java.util.*;
import pbs.sessionbean.ejb.*;
import pbs.service.function.*;
import pbs.service.vo.*;
import pbs.com.enterprisedt.net.ftp.*;
import pbs.application.iiop.GUI.*;
import pbs.application.iiop.GUI.*;
import pbs.service.struct.*;
public class pursue
extends Thread {
static int debugNo = 123;
static int task_type = 0;
static commonFunc cF = new commonFunc();
public pursue() {
}
public static void sleep(int second) {
try {
Thread.sleep(1000 * second);
}
catch (InterruptedException ie) {
processDebug.writeDebug(debugNo + 100, "sleep in huadong #1");
}
}
public void run() {
pbs.service.util.Calendar cal1 = pbs.service.util.Calendar.getInstance();
while (true) {
if (CommBuffer.IsRunning) {
CommBuffer.m_CommGui.appendString("正在从华东导入数据,追补任务将稍后执行");
try {
System.out.println("休息30秒再重新检查任务执行状态!!!");
Thread.sleep(1000 * 30); //休息30秒
}
catch (InterruptedException ie) {
processDebug.writeDebug(debugNo + 100,
"Sleep Error in HUADONG pursue #000");
System.out.println("Sleep Error in HUADONG pursue #000");
}
}
else if (!CommBuffer.IsRunning) {
break;
}
}
if (CommBuffer.m_DateList == null) {
System.out.println("没有设置追补时间,追补任务返回");
}
else {
int CountOfDate = CommBuffer.m_DateList.size();
if (CountOfDate == 1) { //只追补一天
Date m_Date = (Date) (CommBuffer.m_DateList.get(0));
long start_time = pbs.service.function.timeFunc.truncTime(m_Date.
getTime() / 1000);
long now_time = pbs.service.function.timeFunc.truncTime(cal1.
getTimeInMillis() / 1000);
if (start_time > now_time) {
System.out.println("追补:start_time = " + start_time);
System.out.println("追补:now_time = " + now_time);
System.out.println("时间超过限制,不能追补");
CommBuffer.m_CommGui.appendString("追补:时间超过限制,不能追补!");
}
else if (start_time <= now_time) {
PursueData(start_time);
}
}
else if (CountOfDate == 2) { //追补多天
Date m_StartDate = (Date) (CommBuffer.m_DateList.get(0));
Date m_EndDate = (Date) (CommBuffer.m_DateList.get(1));
if (m_StartDate.getTime() > m_EndDate.getTime()) {
CommBuffer.m_CommGui.appendString("追补:结束时间小于开始时间,不能追补!");
return;
}
long start_time = pbs.service.function.timeFunc.truncTime(m_StartDate.
getTime() / 1000);
long end_time = pbs.service.function.timeFunc.truncTime(m_EndDate.
getTime() / 1000);
long now_time = pbs.service.function.timeFunc.truncTime(cal1.
getTimeInMillis() / 1000);
if (start_time > now_time) {
System.out.println("追补:start_time = " + start_time);
System.out.println("追补:now_time = " + now_time);
System.out.println("时间超过限制,不能追补");
CommBuffer.m_CommGui.appendString("追补:起始时间超过限制,不能追补!");
return;
}
else if (end_time > now_time) {
System.out.println("追补:start_time = " + start_time);
System.out.println("追补:now_time = " + now_time);
System.out.println("时间超过限制,不能追补");
CommBuffer.m_CommGui.appendString("追补:终止时间超过限制,不能追补!");
return;
}
else {
while (start_time <= end_time) {
PursueData(start_time);
start_time += 86400;
sleep(2);
}
}
}
else {
System.out.println("追补:程序出错,请检查时间设置环节");
}
}
CommBuffer.m_DateList = null;
}
public void PursueData(long start_time) {
Collection allRows = null;
Collection ftpRows = null;
Iterator it = null, it_pl = null, it_me = null, it_dvt = null;
meter me;
int count = 0;
int ret;
pbs.service.util.Calendar cal1 = pbs.service.util.Calendar.getInstance();
pbs.service.util.Calendar cal2 = pbs.service.util.Calendar.getInstance();
long now_time1 = cal2.getTimeInMillis();
processDebug.writeDebug(debugNo + 100,
"Pursue: Download file Start!Time:" + now_time1);
ftpRows = CommBuffer.m_huaDong.getFtpInfo(debugNo);
long modify_time = CommBuffer.m_huaDong.checkFile(CommBuffer.m_huaDong.
HUADONG_PURSUE_DIR_NAME, debugNo, start_time, ftpRows);
CommBuffer.m_huaDong.downFile(CommBuffer.m_huaDong.HUADONG_PURSUE_DIR_NAME,
debugNo, start_time, modify_time);
pbs.service.util.Calendar cal3 = pbs.service.util.Calendar.getInstance();
long now_time2 = cal3.getTimeInMillis();
processDebug.writeDebug(debugNo + 100,
"Pursue: Download file End!Time:" + now_time2);
long now_time3 = now_time2 / 1000;
String time_str = cF.getTimeStringLine(now_time3);
CommBuffer.m_CommGui.appendString("追补:时间: " + time_str + " 文件下载完毕!");
System.out.println("追补:时间: " + time_str + " 文件下载完毕!");
allRows = CommBuffer.m_huaDong.getData(CommBuffer.m_huaDong.
HUADONG_PURSUE_DIR_NAME, debugNo,
start_time);
count = 0;
if (allRows != null && allRows.size() > 0) {
////////////////////////////////////
////////////////////////////////////
Iterator it_allRows = allRows.iterator();
System.out.println("allRows------一共有 " + allRows.size() + " 行数据");
int ccount = 1;
while (it_allRows.hasNext()) {
DataValue dv = (DataValue) it_allRows.next();
System.out.println("count: "+ccount+" 数据块名------"+dv.m_display_name
+" 数据个数------"+dv.m_values.size());
ccount++;
}
////////////////////////////////////
////////////////////////////////////
if (CommBuffer.m_huaDong.mes != null &&
CommBuffer.m_huaDong.mes.size() != 0) {
it_me = CommBuffer.m_huaDong.mes.iterator();
while (it_me.hasNext()) {
count++;
me = (meter) it_me.next();
if (me.getOtherKey1() == "") {
continue;
}
System.out.println("追补:meter count = " + count +
" meter.other_key1 = " + me.getOtherKey1());
System.out.println("追补:此电表开始组装数据");
task_type = Constant.TASK_TYPE_BY_HAND;
ret = CommBuffer.m_huaDong.impData(debugNo, me, allRows, task_type,
count);
if (ret < 0) {
processDebug.writeDebug(debugNo + 100,
"Pursue: Error in HUADONG #000");
}
sleep(1);
}
}
}
else {
if (allRows == null) {
System.out.println("追补:allRows == null!!!!");
}
if (allRows != null && allRows.size() <= 0) {
System.out.println("追补:allRows 为空");
}
}
CommBuffer.m_huaDong.deleteFile(CommBuffer.m_huaDong.
HUADONG_PURSUE_DIR_NAME, start_time,
debugNo);
pbs.service.util.Calendar cal4 = pbs.service.util.Calendar.getInstance();
long now_time4 = cal4.getTimeInMillis() / 1000;
String time_str1 = cF.getTimeStringLine(now_time4);
CommBuffer.m_CommGui.appendString("追补:时间: " + time_str1 + " 数据导入成功");
System.out.println("追补:时间: " + time_str1 + " 数据导入成功");
processDebug.writeDebug(debugNo + 100,
"Pursue: import HUADONG data OK!Day_time===" +
start_time);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -