?? investjoininsert.java
字號:
/**
* 投連價格跑批處理
*/
package com.NCL.axis.Batch;
import java.util.Timer;
import com.sinosoft.common.*;
import com.NCL.axis.*;
import com.NCL.*;
import org.dom4j.Element;
public class InvestJoinInsert{
public static Timer timer = new Timer();
public static boolean timerstate = false; //執行狀態
public static final String excuteTime = "08:00:00"; //執行的時間
/**投連價格數據提取
* 星期六、星期日、指定的日期不進行數據提取
* 提取數據時,先取得最新的計價日期lastValuationDate,提取從lastValuationDate+1至當前日期之間的數據
* @return
*/
public static boolean Insert(){
String thisDate = Data.getCurrentDate();
//判斷是否取數
//星期六、星期日不取數
//讀取數據庫,在數據庫中存在的日期不取數
String tmpDate = Data.getCurrentDateTime("E");
if("星期六".equals(tmpDate)){
System.out.println("今天是星期六,系統不進行投連價格發布。");
return true;
}else if("星期日".equals(tmpDate)){
System.out.println("今天是星期日,系統不進行投連價格發布。");
return true;
}
// PriceDate pd = new PriceDate();
// pd.settStartDate(thisDate);
// pd.setfEndDate(thisDate);
// String ID = pd.find(pd, 1, 1);
// if(Data.hasValue(ID)){
// System.out.println("今天是指定不取數的日期,系統不進行投連價格發布。");
// return true;
// }
InvestmentJoin ij = new InvestmentJoin();
CustomSearch cs = new CustomSearch();
String lastValuationDate = ij.findLastValuationDate();
if(Data.hasValue(lastValuationDate))lastValuationDate = Data.dateAdd("d", lastValuationDate, 1);
else lastValuationDate = thisDate;
System.out.println("開始提取投連價格數據...");
Element ele = cs.InvestmentJionTimer("", lastValuationDate, thisDate);
String ValueDate = "";
String RiskCode = "";
String RiskName = "";
String InsuAccNo = "";
String InsuAccName = "";
String UnitPriceBuy = "";
String UnitPriceSell ="";
while(ele!=null){
ValueDate = cs.getElementText(ele, "ValueDate");
RiskCode = cs.getElementText(ele, "RiskCode");
RiskName = cs.getElementText(ele, "RiskName");
InsuAccNo = cs.getElementText(ele, "InsuAccNo");
InsuAccName = cs.getElementText(ele, "InsuAccName");
UnitPriceBuy = cs.getElementText(ele, "UnitPriceBuy");
UnitPriceSell = cs.getElementText(ele, "UnitPriceSell");
ij.clear();
//創建投連價格數據
ij.set("RiskCode", RiskCode); //設定RiskCode
ij.set("RiskName", RiskName);
ij.set("AccountCode", InsuAccNo);
ij.set("AccountName", InsuAccName);
ij.set("ValuationDate", ValueDate);
ij.set("BuyInGrate", UnitPriceBuy);
ij.set("SellInGprice", UnitPriceSell);
ij.set("ValuationUnit", "D");
ij.set("IsDisplay", "1");
ij.set("RiskType", "投連");
ij.set("BalancePeriod", "");
ij.create();
ele = cs.getNextElements();
}
return true;
}
/**
* 定時處理
* @return boolean
*/
public boolean PriceInfo(){
if(timerstate){
System.out.println("Error:InvestJoinInsert.PriceInfo() is started.");
return false;
}
String currentTime = Data.getCurrentTime();
long result = Data.returnSec(excuteTime)-Data.returnSec(currentTime);
while(result<0)result += 24*3600;
timer.schedule(new InvestJoinInsertTask(), 1000*result, 1000*24*3600);
timerstate = true;
System.out.println("InvestJoinInsert timer is start");
return true;
}
class InvestJoinInsertTask extends java.util.TimerTask{
/**
* 啟動線程
*/
public void run(){
InvestJoinInsert.Insert();
}
}
/**
* main方法
* @param args
*/
public static void main(String args[]){
InvestJoinInsert.Insert();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -