You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GANTRY_PASS_ALL/.svn/pristine/85/850738179f6764af0dcfd25e8d7...

198 lines
12 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package GPA;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class GAMIN {
public static void main(String[] args) throws Exception {
List<Thread> list=new startGPA().startUp();
}
private List<Thread> Main_void(String dbType) throws Exception {
boolean flag=true;
List<Thread> stop_list=new ArrayList<>();
List<startGPA.State> state_list=new ArrayList<>();
boolean runAble=true;
startGPA s=new startGPA();
stop_list.clear();
try {
JdbcTemplate jdbcTemplate=new JdbcTemplate(new DBUtil().Hikar_DataSource());
List list_PARTICIPANT = CommonHelp.getListBySql("select * from TB_PARTICIPANT",jdbcTemplate);
List list_LINE_TABLE=CommonHelp.getListBySql("select LINENAME,GBLINEID from line_table",jdbcTemplate);
List list_FEEUNIT_TABLE=CommonHelp.getListBySql("select ID,NAME FROM FEEUNIT_TABLE",jdbcTemplate);
List list_GANTRY_TABLE=CommonHelp.getListBySql("select * from gantry_table",jdbcTemplate);
int GPA_THREAD_COUNT_1=7;
//正常数据处理线程4个
if (dbType.equals("1")) {//oracle
for (int i = 0; i < GPA_THREAD_COUNT_1; i++) {
String sql="select * from gantry_pass_center where ishandle=0 and isout=1 and issecond=0 and payfee_all=obuprovpayfeesumafter and ROUND(TO_NUMBER(sysdate - updatetime) * 24 * 60)>" + CommonHelp.GetConfigValue("lastTimeOut") + " and ora_hash(passid,"+(GPA_THREAD_COUNT_1-1)+")="+i;
Thread thread=new GetAllData((i+11),0,sql,jdbcTemplate,list_PARTICIPANT,list_LINE_TABLE,list_FEEUNIT_TABLE,list_GANTRY_TABLE,runAble,s);
thread.start();
stop_list.add(thread);
startGPA.State state=new startGPA.State();
state.ThreadId=thread.getId();
state.StateUpdateTime=System.currentTimeMillis();
state_list.add(state);
}
} else if (dbType.equals("2")) {//DM
for (int i = 0; i < GPA_THREAD_COUNT_1; i++) {
String sql="select * from gantry_pass_center where ishandle=0 and isout=1 and issecond=0 and payfee_all=obuprovpayfeesumafter and ROUND(TO_NUMBER(sysdate - updatetime) * 24 * 60)>" + CommonHelp.GetConfigValue("lastTimeOut") + " and DM_HASH(passid)%"+GPA_THREAD_COUNT_1+"="+i+" and rownum<=1500";
Thread thread=new GetAllData((i+11),0,sql,jdbcTemplate,list_PARTICIPANT,list_LINE_TABLE,list_FEEUNIT_TABLE,list_GANTRY_TABLE,runAble,s);
thread.start();
stop_list.add(thread);
startGPA.State state=new startGPA.State();
state.ThreadId=thread.getId();
state.StateUpdateTime=System.currentTimeMillis();
state_list.add(state);
}
}
//超时数据处理线程3个
if (dbType.equals("1")) {//oracle
//超时第一种情况--有出口但是累计金额不相等的
//超时第二种情况--累计金额相等但是没有出口的
String sql2_2_1 = "select * from gantry_pass_center where ishandle=0 and isout=0 and payfee_all=obuprovpayfeesumafter and ROUND(TO_NUMBER(sysdate - transtime) * 24 * 60)>" + CommonHelp.GetConfigValue("timeOut") + " and ROUND(TO_NUMBER(sysdate - updatetime) * 24 * 60) > " + CommonHelp.GetConfigValue("lastTimeOut");
//超时第三种情况--没有出口累计金额也不相等的
String sql2_3_1 = "select * from gantry_pass_center where ishandle=0 and isout=0 and payfee_all!=obuprovpayfeesumafter and ROUND(TO_NUMBER(sysdate - transtime) * 24 * 60)>" + CommonHelp.GetConfigValue("timeOut") + " and ROUND(TO_NUMBER(sysdate - updatetime) * 24 * 60) > " + CommonHelp.GetConfigValue("lastTimeOut");
List<Map<String,Integer>> listTemp=new ArrayList<>();
for (int i = 0; i <= 6; i++) {
String sql2_1_1 = "select * from(select * from gantry_pass_center where ishandle=0 and isout=1 and payfee_all!=obuprovpayfeesumafter and ROUND(TO_NUMBER(sysdate - transtime) * 24 * 60)>" + CommonHelp.GetConfigValue("timeOut") + " and ROUND(TO_NUMBER(sysdate - updatetime) * 24 * 60) > " + CommonHelp.GetConfigValue("lastTimeOut")+") t where ora_hash(passid,6)="+i;
Map map=new HashMap();
map.put("sql",sql2_1_1);
map.put("threadid",20+i+1);
listTemp.add(map);
}
Map map1=new HashMap();
map1.put("sql",sql2_2_1);
map1.put("threadid",28);
listTemp.add(map1);
Map map2=new HashMap();
map2.put("sql",sql2_3_1);
map2.put("threadid",29);
listTemp.add(map2);
for (Map<String, Integer> stringIntegerMap : listTemp) {
Thread thread=new GetAllData(Integer.parseInt(stringIntegerMap.get("threadid").toString()),1,stringIntegerMap.get("sql").toString(),jdbcTemplate,list_PARTICIPANT,list_LINE_TABLE,list_FEEUNIT_TABLE,list_GANTRY_TABLE,runAble,s);
thread.start();
stop_list.add(thread);
startGPA.State state=new startGPA.State();
state.ThreadId=thread.getId();
state.StateUpdateTime=System.currentTimeMillis();
state_list.add(state);
}
// for (int i = 0; i < listTemp.size(); i++) {
//
// Thread thread=new GetAllData((21+i),1,listTemp.get(i).toString(),jdbcTemplate,list_PARTICIPANT,list_LINE_TABLE,list_FEEUNIT_TABLE,list_GANTRY_TABLE,runAble,s);
// thread.start();
// stop_list.add(thread);
// startGPA.State state=new startGPA.State();
// state.ThreadId=thread.getId();
// state.StateUpdateTime=System.currentTimeMillis();
// state_list.add(state);
// }
} else if (dbType.equals("2")) {//DM
//超时第一种情况--有出口但是累计金额不相等的技巧口诀图解
String sql2_1_1 = "select PASSID,OUT_TRADEID,PAYFEE_ALL,FEE_ALL,OBUPROVPAYFEESUMAFTER,TRANSTIME,TRADEID,ISOUT,DISCOUNTFEE_ALL,OUT_GANTRYID,ISHANDLE,ID,FEEPROVBEGINHEX,FEEPROVBEGINTIME,HANDLETIME,EXPOINTID,EXPOINTNAME,MEDIATYPE,ISTIMEOUT,ISSECOND,UPDATETIME,ENTIME,TRANSNUM,PROVINCENUMAFTER,BACKUP3 from gantry_pass_center where ishandle=0 and isout=1 and payfee_all!=obuprovpayfeesumafter and ROUND(TO_NUMBER(sysdate - transtime) * 24 * 60)>" + CommonHelp.GetConfigValue("timeOut") + " and ROUND(TO_NUMBER(sysdate - updatetime) * 24 * 60) > " + CommonHelp.GetConfigValue("lastTimeOut")+" and rownum<=1500";
//超时第二种情况--累计金额相等但是没有出口的
String sql2_2_1 = "select PASSID,OUT_TRADEID,PAYFEE_ALL,FEE_ALL,OBUPROVPAYFEESUMAFTER,TRANSTIME,TRADEID,ISOUT,DISCOUNTFEE_ALL,OUT_GANTRYID,ISHANDLE,ID,FEEPROVBEGINHEX,FEEPROVBEGINTIME,HANDLETIME,EXPOINTID,EXPOINTNAME,MEDIATYPE,ISTIMEOUT,ISSECOND,UPDATETIME,ENTIME,TRANSNUM,PROVINCENUMAFTER,BACKUP3 from gantry_pass_center where ishandle=0 and isout=0 and payfee_all=obuprovpayfeesumafter and ROUND(TO_NUMBER(sysdate - transtime) * 24 * 60)>" + CommonHelp.GetConfigValue("timeOut") + " and ROUND(TO_NUMBER(sysdate - updatetime) * 24 * 60) > " + CommonHelp.GetConfigValue("lastTimeOut")+" and rownum<=1500";
//超时第三种情况--没有出口累计金额也不相等的
String sql2_3_1 = "select PASSID,OUT_TRADEID,PAYFEE_ALL,FEE_ALL,OBUPROVPAYFEESUMAFTER,TRANSTIME,TRADEID,ISOUT,DISCOUNTFEE_ALL,OUT_GANTRYID,ISHANDLE,ID,FEEPROVBEGINHEX,FEEPROVBEGINTIME,HANDLETIME,EXPOINTID,EXPOINTNAME,MEDIATYPE,ISTIMEOUT,ISSECOND,UPDATETIME,ENTIME,TRANSNUM,PROVINCENUMAFTER,BACKUP3 from gantry_pass_center where ishandle=0 and isout=0 and payfee_all!=obuprovpayfeesumafter and ROUND(TO_NUMBER(sysdate - transtime) * 24 * 60)>" + CommonHelp.GetConfigValue("timeOut") + " and ROUND(TO_NUMBER(sysdate - updatetime) * 24 * 60) > " + CommonHelp.GetConfigValue("lastTimeOut")+" and rownum<=1500";
List<String> listTemp=new ArrayList<>();
listTemp.add(sql2_1_1);
listTemp.add(sql2_2_1);
listTemp.add(sql2_3_1);
for (int i = 0; i < listTemp.size(); i++) {
Thread thread=new GetAllData((21+i),1,listTemp.get(i).toString(),jdbcTemplate,list_PARTICIPANT,list_LINE_TABLE,list_FEEUNIT_TABLE,list_GANTRY_TABLE,runAble,s);
thread.start();
stop_list.add(thread);
startGPA.State state=new startGPA.State();
state.ThreadId=thread.getId();
state.StateUpdateTime=System.currentTimeMillis();
state_list.add(state);
}
}
//二次数据上传处理线程1个
String sql3_1 = "";
if (dbType.equals("1")) {//oracle
sql3_1 = "select * from gantry_pass_center where ishandle=1 and issecond=1 and ROUND(TO_NUMBER(sysdate - updatetime) * 24 * 60)>" + CommonHelp.GetConfigValue("lastTimeOut");
Thread thread3_1=new GetAllData(31,0,sql3_1,jdbcTemplate,list_PARTICIPANT,list_LINE_TABLE,list_FEEUNIT_TABLE,list_GANTRY_TABLE,runAble,s);
thread3_1.start();
stop_list.add(thread3_1);
startGPA.State state3_1=new startGPA.State();
state3_1.ThreadId=thread3_1.getId();
state3_1.StateUpdateTime=System.currentTimeMillis();
state_list.add(state3_1);
} else if (dbType.equals("2")) {//DM
sql3_1 = "select * from gantry_pass_center where ishandle=1 and issecond=1 and ROUND(TO_NUMBER(sysdate - updatetime) * 24 * 60)>" + CommonHelp.GetConfigValue("lastTimeOut");
Thread thread3_1=new GetAllData(31,0,sql3_1,jdbcTemplate,list_PARTICIPANT,list_LINE_TABLE,list_FEEUNIT_TABLE,list_GANTRY_TABLE,runAble,s);;
thread3_1.start();
}
//删除中间表数据线程,1个
if (dbType.equals("1")) {
String sql4_1 = "delete gantry_pass_center where ROUND(TO_NUMBER(sysdate - handletime))>25";
deleteCenter deleteC=new deleteCenter(jdbcTemplate,sql4_1,runAble,s);
Thread thread=new Thread(deleteC);
thread.start();
stop_list.add(thread);
startGPA.State state=new startGPA.State();
state.ThreadId=thread.getId();
state.StateUpdateTime=System.currentTimeMillis();
state_list.add(state);
}
//预分账线程7个
int THREAD_GANTRY_STAT_COUNT=7;
for (int i = 0; i < THREAD_GANTRY_STAT_COUNT; i++) {
String sql="select * from gantry_pass_stat_temp where ora_hash(tradeid,"+(THREAD_GANTRY_STAT_COUNT-1)+")="+i+" and rownum<=1000";
GetGantryStat getGantryStat=new GetGantryStat(jdbcTemplate,sql,runAble,s);
Thread thread=new Thread(getGantryStat);
thread.start();
stop_list.add(thread);
startGPA.State state=new startGPA.State();
state.ThreadId=thread.getId();
state.StateUpdateTime=System.currentTimeMillis();
state_list.add(state);
}
}
catch (Exception e){
flag=false;
e.printStackTrace();
LogClass.debug(e.toString());
}
finally {
return stop_list;
}
}
}