test
commit
3ed3015140
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/../../../../:\trkf-java\vehicle_score\.idea/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
@ -0,0 +1,25 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="vehicle_score:jar">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/vehicle_score_jar</output-path>
|
||||
<root id="archive" name="vehicle_score.jar">
|
||||
<element id="module-output" name="vehicle_score" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/dom4j-2.0.3.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/DmJdbcDriver16.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/DmJdbcDriver17.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/HikariCP-3.3.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/fastjson-1.2.78.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/httpcore-4.4.14.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/httpmime-4.5.13.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/ojdbc6-11.2.0.4.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/slf4j-api-1.7.25.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/httpclient-4.5.13.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/slf4j-simple-1.7.25.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/mssql-jdbc-7.4.1.jre8.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/spring-tx-5.2.16.RELEASE.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/spring-jcl-5.2.16.RELEASE.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/spring-core-5.2.16.RELEASE.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/spring-jdbc-5.2.16.RELEASE.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/src/lib/spring-beans-5.2.16.RELEASE.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
@ -0,0 +1,10 @@
|
||||
<component name="libraryTable">
|
||||
<library name="lib">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/src/lib" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/src/lib" recursive="false" />
|
||||
</library>
|
||||
</component>
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/vehicle_score.iml" filepath="$PROJECT_DIR$/vehicle_score.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GitSharedSettings">
|
||||
<option name="FORCE_PUSH_PROHIBITED_PATTERNS">
|
||||
<list />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: v_score.v_score
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: v_score.v_score
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,57 @@
|
||||
package v_score;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommonHelp {
|
||||
public synchronized static int GetFeeunitLength(List<Map<String, Object>> feeunit_list, String id){
|
||||
int result=0;
|
||||
for (Map<String, Object> map : feeunit_list) {
|
||||
if (map.get("ID").toString().equals(id)){
|
||||
result=Integer.valueOf(map.get("LENGTH").toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public synchronized static String GetFeeunitNameById(List<Map<String, Object>> feeunit_list,String id){
|
||||
String result="";
|
||||
for (Map<String, Object> map : feeunit_list) {
|
||||
if (map.get("ID").toString().equals(id)){
|
||||
result=map.get("NAME").toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//获取数组之和
|
||||
public static int GetArrSum(String[] strGroup) {
|
||||
int result = 0;
|
||||
if (strGroup.length > 0) {
|
||||
for (int i = 0; i < strGroup.length; i++) {
|
||||
result += Integer.valueOf(strGroup[i]);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
//根据车型距离,计算里程积分
|
||||
public static int getVehicleScoreByType(int vehicletype,int length,List<Map<String, Object>> score_value_list){
|
||||
int score=0;
|
||||
for (Map<String, Object> map : score_value_list) {
|
||||
int type=Integer.valueOf(map.get("TYPE").toString());
|
||||
if (vehicletype==type){
|
||||
int minlength=Integer.valueOf(map.get("MINLENGTH").toString());
|
||||
int maxlength=Integer.valueOf(map.get("MAXLENGTH").toString());
|
||||
if (length>=minlength && length<maxlength){
|
||||
score=Integer.valueOf(map.get("SCORE").toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return score;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
package v_score;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
public class DBUtil {
|
||||
public DataSource Hikar_DataSource_NMGGS() throws Exception{
|
||||
HikariConfig config=new HikariConfig();
|
||||
try {
|
||||
config.setDriverClassName("oracle.jdbc.driver.OracleDriver");
|
||||
config.setJdbcUrl("jdbc:oracle:thin:@//10.15.0.11:1521/orcl");
|
||||
config.setUsername("nmggs");
|
||||
config.setPoolName("nmggs");
|
||||
config.setPassword("sysadmin");
|
||||
config.addDataSourceProperty("v$session.osuser","DL");
|
||||
config.addDataSourceProperty("v$session.machine","10.15.0.36");
|
||||
config.addDataSourceProperty("v$session.program","DIV_SEC");
|
||||
config.setMaximumPoolSize(10);
|
||||
config.setMinimumIdle(2);
|
||||
config.setConnectionTestQuery("select 1 from dual");
|
||||
config.setAutoCommit(true);
|
||||
}
|
||||
catch (Exception e){
|
||||
System.out.println("连接池错误:"+e.toString());
|
||||
}
|
||||
DataSource ds=new HikariDataSource(config);
|
||||
return ds;
|
||||
}
|
||||
|
||||
public DataSource Hikar_DataSource_JTJT() throws Exception{
|
||||
HikariConfig config=new HikariConfig();
|
||||
try {
|
||||
config.setDriverClassName("oracle.jdbc.driver.OracleDriver");
|
||||
config.setJdbcUrl("jdbc:oracle:thin:@//10.15.0.12:1521/orcl");
|
||||
config.setUsername("nmgjtjt");
|
||||
config.setPoolName("nmgjtjt");
|
||||
config.setPassword("sysadmin");
|
||||
config.addDataSourceProperty("v$session.osuser","DL");
|
||||
config.addDataSourceProperty("v$session.machine","10.15.0.13");
|
||||
config.addDataSourceProperty("v$session.program","DIV_SEC");
|
||||
config.setMaximumPoolSize(10);
|
||||
config.setMinimumIdle(2);
|
||||
config.setConnectionTestQuery("select 1 from dual");
|
||||
config.setAutoCommit(true);
|
||||
}
|
||||
catch (Exception e){
|
||||
System.out.println("连接池错误:"+e.toString());
|
||||
}
|
||||
DataSource ds=new HikariDataSource(config);
|
||||
return ds;
|
||||
}
|
||||
|
||||
public DataSource Hikar_DataSource_MPAY() throws Exception{
|
||||
HikariConfig config=new HikariConfig();
|
||||
try {
|
||||
config.setDriverClassName("oracle.jdbc.driver.OracleDriver");
|
||||
config.setJdbcUrl("jdbc:oracle:thin:@//10.15.100.5:1521/torcl");
|
||||
config.setUsername("nmgmpayadmin");
|
||||
config.setPoolName("nmggs");
|
||||
config.setPassword("nmgh90[]");
|
||||
config.addDataSourceProperty("v$session.osuser","DL");
|
||||
config.addDataSourceProperty("v$session.machine","10.15.0.36");
|
||||
config.addDataSourceProperty("v$session.program","DIV_SEC");
|
||||
config.setMaximumPoolSize(10);
|
||||
config.setMinimumIdle(2);
|
||||
config.setConnectionTestQuery("select 1 from dual");
|
||||
config.setAutoCommit(true);
|
||||
}
|
||||
catch (Exception e){
|
||||
System.out.println("连接池错误:"+e.toString());
|
||||
}
|
||||
DataSource ds=new HikariDataSource(config);
|
||||
return ds;
|
||||
}
|
||||
|
||||
public DataSource Hikar_DataSource_GT() throws Exception{
|
||||
HikariConfig config=new HikariConfig();
|
||||
try {
|
||||
config.setDriverClassName("oracle.jdbc.driver.OracleDriver");
|
||||
config.setJdbcUrl("jdbc:oracle:thin:@//10.15.100.5:1521/torcl");
|
||||
config.setUsername("nmggtadmin");
|
||||
config.setPoolName("nmggs");
|
||||
config.setPassword("nmgh90[]");
|
||||
config.addDataSourceProperty("v$session.osuser","DL");
|
||||
config.addDataSourceProperty("v$session.machine","10.15.0.36");
|
||||
config.addDataSourceProperty("v$session.program","DIV_SEC");
|
||||
config.setMaximumPoolSize(10);
|
||||
config.setMinimumIdle(2);
|
||||
config.setConnectionTestQuery("select 1 from dual");
|
||||
config.setAutoCommit(true);
|
||||
}
|
||||
catch (Exception e){
|
||||
System.out.println("连接池错误:"+e.toString());
|
||||
}
|
||||
DataSource ds=new HikariDataSource(config);
|
||||
return ds;
|
||||
}
|
||||
public DataSource Hikar_DataSource_DM() throws Exception {//这个是今天改的
|
||||
HikariConfig config = new HikariConfig();
|
||||
try {
|
||||
|
||||
config.setDriverClassName("dm.jdbc.driver.DmDriver");
|
||||
config.setJdbcUrl("jdbc:dm://10.115.255.4:5236/NMGGJT");
|
||||
config.setUsername("NMGGJT");
|
||||
config.setPassword("1234567890");
|
||||
config.setPoolName("GTDM");
|
||||
config.setMaximumPoolSize(4);
|
||||
config.setMinimumIdle(2);
|
||||
config.setConnectionTestQuery("select 1 from dual");
|
||||
config.setAutoCommit(true);
|
||||
DataSource ds = new HikariDataSource(config);
|
||||
return ds;
|
||||
}
|
||||
catch (Exception e){
|
||||
LogClass.error(e.getMessage());
|
||||
}
|
||||
finally {
|
||||
return new HikariDataSource(config);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DataSource Hikar_DataSource_216() throws Exception{
|
||||
HikariConfig config=new HikariConfig();
|
||||
try {
|
||||
config.setDriverClassName("oracle.jdbc.OracleDriver");
|
||||
config.setJdbcUrl("jdbc:oracle:thin:@//10.15.100.216:1521/torclhis");
|
||||
config.setUsername("transfer");
|
||||
config.setPoolName("216");
|
||||
config.setPassword("trans2020");
|
||||
config.setMaximumPoolSize(3);
|
||||
config.setMinimumIdle(2);
|
||||
config.setConnectionTestQuery("select 1 from dual");
|
||||
config.setAutoCommit(true);
|
||||
|
||||
}
|
||||
catch (Exception e){
|
||||
System.out.println("连接池错误:"+e.toString());
|
||||
}
|
||||
DataSource ds=new HikariDataSource(config);
|
||||
return ds;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
package v_score;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class score_test {
|
||||
public static void main(String[] args) throws Exception{
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(new DBUtil().Hikar_DataSource_JTJT());
|
||||
|
||||
SimpleDateFormat format_Time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
SimpleDateFormat format_Date = new SimpleDateFormat("yyyy-MM-dd");
|
||||
final boolean[] result = {true};
|
||||
long sTime=System.currentTimeMillis();
|
||||
long eTime=System.currentTimeMillis();
|
||||
|
||||
List<Map<String, Object>> feeunit_list = jdbcTemplate.queryForList("select * from feeunit_table");
|
||||
List<Map<String, Object>> score_value_list = jdbcTemplate.queryForList("select * from VEHICLE_SCORE_VALUE");
|
||||
|
||||
String sql_data = "select * from gantry_pass_all where id='012101214023001000534320241223054019-G000615003001020010-20241223054641'";
|
||||
|
||||
List<Map<String, Object>> list_data = jdbcTemplate.queryForList(sql_data);
|
||||
|
||||
if (list_data.size() > 0) {
|
||||
sTime=System.currentTimeMillis();
|
||||
LogClass.info("里程积分数据获取:"+list_data.size());
|
||||
|
||||
ArrayList<Object[]> objects_score_data = new ArrayList<>();
|
||||
for (Map<String, Object> map : list_data) {
|
||||
//String id=map.get("ID").toString();
|
||||
//System.out.println(id);
|
||||
String passid = map.get("PASSID").toString();
|
||||
int provincenumafter = Integer.valueOf(map.get("PROVINCENUMAFTER").toString());
|
||||
int vehicleType = Integer.valueOf(map.get("VEHICLETYPE").toString());
|
||||
|
||||
int outType = Integer.valueOf(map.get("OUTTYPE").toString());
|
||||
String vehicleid = map.get("VEHICLEID") == null ? "" : map.get("VEHICLEID").toString();
|
||||
//System.out.println("处理车牌:"+vehicleid);
|
||||
LogClass.info("处理车牌:" + vehicleid);
|
||||
|
||||
|
||||
if (vehicleid.length() > 0 && vehicleType > 10) {
|
||||
String feeGroup = map.get("TOLLINTERVALFEE").toString();
|
||||
if (CommonHelp.GetArrSum(feeGroup.split("\\|")) > 0) {
|
||||
int length = 0;
|
||||
int score = 0;
|
||||
int g6length = 0;
|
||||
int g6score = 0;
|
||||
int g65length = 0;
|
||||
int g65score = 0;
|
||||
String tollintervalid = map.get("TOLLINTERVALID").toString();
|
||||
String[] tollId_arr = tollintervalid.split("\\|");
|
||||
boolean isG6_G65=false;
|
||||
for (String s : tollId_arr) {
|
||||
if (s.substring(0, 5).equals("G0006")) {
|
||||
int length_temp = CommonHelp.GetFeeunitLength(feeunit_list, s);
|
||||
length += length_temp;
|
||||
g6length += length_temp;
|
||||
isG6_G65=true;
|
||||
}
|
||||
if (s.substring(0, 5).equals("G0065")) {
|
||||
int length_temp = CommonHelp.GetFeeunitLength(feeunit_list, s);
|
||||
length += length_temp;
|
||||
g65length += length_temp;
|
||||
isG6_G65=true;
|
||||
}
|
||||
}
|
||||
String enpointid = tollId_arr[0];
|
||||
String expointid = tollId_arr[tollId_arr.length - 1];
|
||||
String enStaid=enpointid.substring(0,enpointid.length()-2);
|
||||
String exStaid=expointid.substring(0,expointid.length()-2);
|
||||
String enname = CommonHelp.GetFeeunitNameById(feeunit_list, enpointid);
|
||||
String exname = CommonHelp.GetFeeunitNameById(feeunit_list, expointid);
|
||||
String entime = map.get("ENTIME").toString().substring(0, map.get("ENTIME").toString().length() - 2);
|
||||
String extime = map.get("EXTIME").toString().substring(0, map.get("EXTIME").toString().length() - 2);
|
||||
String classdate = map.get("EXTIME").toString().substring(0, 10);
|
||||
|
||||
if (length>=210000){
|
||||
score = CommonHelp.getVehicleScoreByType(vehicleType, length, score_value_list);
|
||||
g6score = (int) Math.round(((double) g6length / length) * score);
|
||||
g65score = score - g6score;
|
||||
}
|
||||
else {
|
||||
score=0;
|
||||
g6score=0;
|
||||
g65score=0;
|
||||
}
|
||||
|
||||
if (isG6_G65){
|
||||
if (outType==0 || enStaid.equals(exStaid)){
|
||||
}
|
||||
else {
|
||||
objects_score_data.add(new Object[]{passid, provincenumafter, vehicleid, enname, exname, entime, extime, length, score, g6length, g6score, g65length, g65score, classdate,vehicleType});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
eTime=System.currentTimeMillis();
|
||||
LogClass.info("里程积分数据处理用时:"+(eTime-sTime));
|
||||
|
||||
}
|
||||
else {
|
||||
LogClass.info("暂无里程积分处理数据");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,368 @@
|
||||
package v_score;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
import sun.rmi.runtime.Log;
|
||||
|
||||
import javax.print.DocFlavor;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v_score {
|
||||
public static void main(String[] args) throws Exception {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(new DBUtil().Hikar_DataSource_JTJT());
|
||||
|
||||
SimpleDateFormat format_Time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
SimpleDateFormat format_Date = new SimpleDateFormat("yyyy-MM-dd");
|
||||
final boolean[] result = {true};
|
||||
long sTime=System.currentTimeMillis();
|
||||
long eTime=System.currentTimeMillis();
|
||||
|
||||
List<Map<String, Object>> feeunit_list = jdbcTemplate.queryForList("select * from feeunit_table");
|
||||
List<Map<String, Object>> score_value_list = jdbcTemplate.queryForList("select * from VEHICLE_SCORE_VALUE");
|
||||
|
||||
String sql_data = "select * from gantry_pass_all_score where rownum<=100";
|
||||
String delete_data_sql = "delete gantry_pass_all_score where passid=:passid and provincenumafter=:provincenumafter";
|
||||
String sql_score = "merge into vehicle_score t1 using(select :passid as passid,:provincenumafter as provincenumafter,:vehicleid as vehicleid,:enname as enname,:exname as exname,to_date(:entime,'yyyy-mm-dd hh24:mi:ss') as entime,to_date(:extime,'yyyy-mm-dd hh24:mi:ss') as extime,:length as length,:score as score,:g6length as g6length,:g6score as g6score,:g65length as g65length,:g65score as g65score,to_date(:classdate,'yyyy-mm-dd') as classdate,:vehicletype as vehicletype from dual) t2 on(t1.passid=t2.passid and t1.provincenumafter=t2.provincenumafter and t1.vehicleid=t2.vehicleid) when not matched then insert(passid,provincenumafter, vehicleid, enname, exname, entime, extime, length, score, g6length, g6score, g65length, g65score, classdate,vehicletype) values (t2.passid,t2.provincenumafter, t2.vehicleid, t2.enname, t2.exname, t2.entime, t2.extime, t2.length, t2.score, t2.g6length, t2.g6score, t2.g65length, t2.g65score, t2.classdate,t2.vehicletype)";
|
||||
String sql_score_error = "merge into vehicle_score_error t1 using(select :passid as passid,:provincenumafter as provincenumafter,:vehicleid as vehicleid,:enname as enname,:exname as exname,to_date(:entime,'yyyy-mm-dd hh24:mi:ss') as entime,to_date(:extime,'yyyy-mm-dd hh24:mi:ss') as extime,:length as length,:score as score,:g6length as g6length,:g6score as g6score,:g65length as g65length,:g65score as g65score,to_date(:classdate,'yyyy-mm-dd') as classdate,:vehicletype as vehicletype from dual) t2 on(t1.passid=t2.passid and t1.provincenumafter=t2.provincenumafter and t1.vehicleid=t2.vehicleid) when not matched then insert(passid,provincenumafter, vehicleid, enname, exname, entime, extime, length, score, g6length, g6score, g65length, g65score, classdate,vehicletype) values (t2.passid,t2.provincenumafter, t2.vehicleid, t2.enname, t2.exname, t2.entime, t2.extime, t2.length, t2.score, t2.g6length, t2.g6score, t2.g65length, t2.g65score, t2.classdate,t2.vehicletype)";
|
||||
|
||||
String sql_data_div = "select * from div_second_score where rownum<=100";
|
||||
String delete_data_div_sql = "delete div_second_score where id=:id";
|
||||
String sql_div_score = "merge into vehicle_score_div t1 using(select :id as id,:passid as passid,:provincenumafter as provincenumafter,:vehicleid as vehicleid,:enname as enname,:exname as exname,to_date(:entime,'yyyy-mm-dd hh24:mi:ss') as entime,to_date(:extime,'yyyy-mm-dd hh24:mi:ss') as extime,:length as length,:score as score,:g6length as g6length,:g6score as g6score,:g65length as g65length,:g65score as g65score,to_date(:classdate,'yyyy-mm-dd') as classdate,:fee as fee,:vehicletype as vehicletype from dual) t2 on(t1.id=t2.id) when not matched then insert(id,passid,provincenumafter, vehicleid, enname, exname, entime, extime, length, score, g6length, g6score, g65length, g65score, classdate,fee,vehicletype) values (t2.id,t2.passid,t2.provincenumafter, t2.vehicleid, t2.enname, t2.exname, t2.entime, t2.extime, t2.length, t2.score, t2.g6length, t2.g6score, t2.g65length, t2.g65score, t2.classdate,t2.fee,t2.vehicletype)";
|
||||
|
||||
String sql_data_now = "select * from gantry_pass_score";
|
||||
String delete_data_now = "delete gantry_pass_score where tradeid=:tradeid";
|
||||
String sql_score_now = "merge into vehicle_score_now t1 using(select :passid as passid,:provincenumafter as provincenumafter,:vehicleid as vehicleid,:length as length,:vehicletype as vehicletype from dual ) t2 on(t1.passid=t2.passid and t1.provincenumafter=t2.provincenumafter and t1.vehicleid=t2.vehicleid) when matched then update set t1.length=t1.length+t2.length when not matched then insert(passid, vehicleid, length, provincenumafter,vehicletype) values (t2.passid, t2.vehicleid, t2.length, t2.provincenumafter,t2.vehicletype)";
|
||||
while (true) {
|
||||
try {
|
||||
List<Map<String, Object>> list_data_now = jdbcTemplate.queryForList(sql_data_now);
|
||||
if (list_data_now.size() > 0) {
|
||||
sTime=System.currentTimeMillis();
|
||||
LogClass.info("实时积分数据获取:"+list_data_now.size());
|
||||
ArrayList<Object[]> objects_delete_data_now = new ArrayList<>();
|
||||
ArrayList<Object[]> objects_score_data_now = new ArrayList<>();
|
||||
for (Map<String, Object> map : list_data_now) {
|
||||
String tradeid = map.get("TRADEID").toString();
|
||||
objects_delete_data_now.add(new Object[]{tradeid});
|
||||
|
||||
String vehicleid = map.get("VEHICLEPLATE").toString();
|
||||
int vehicletype = Integer.valueOf(map.get("VEHICLETYPE").toString());
|
||||
String passid = map.get("PASSID").toString();
|
||||
int provincenumafter = Integer.valueOf(map.get("PROVINCENUMAFTER").toString());
|
||||
|
||||
int mediatype = Integer.valueOf(map.get("MEDIATYPE").toString());
|
||||
int feecalcresult = Integer.valueOf(map.get("FEECALCRESULT").toString());
|
||||
String tollintervals = map.get("TOLLINTERVALID") == null ? "" : map.get("TOLLINTERVALID").toString();
|
||||
int allLength = 0;
|
||||
if (mediatype == 1) {
|
||||
int obutraderesult = Integer.valueOf(map.get("OBUTRADERESULT").toString());
|
||||
if (feecalcresult == 0 && obutraderesult == 0) {
|
||||
if (tollintervals.length() > 0) {
|
||||
String[] temp = tollintervals.split("\\|");
|
||||
for (String s : temp) {
|
||||
if (s.substring(0, 5).equals("G0006") || s.substring(0, 5).equals("G0065")) {
|
||||
int length_temp = CommonHelp.GetFeeunitLength(feeunit_list, s);
|
||||
allLength += length_temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
objects_score_data_now.add(new Object[]{passid, provincenumafter, vehicleid, allLength,vehicletype});
|
||||
|
||||
|
||||
}
|
||||
} else if (mediatype == 2) {
|
||||
int traderesult = Integer.valueOf(map.get("TRADERESULT").toString());
|
||||
if (feecalcresult == 0 && traderesult == 0) {
|
||||
if (tollintervals.length() > 0) {
|
||||
String[] temp = tollintervals.split("\\|");
|
||||
for (String s : temp) {
|
||||
if (s.substring(0, 5).equals("G0006") || s.substring(0, 5).equals("G0065")) {
|
||||
int length_temp = CommonHelp.GetFeeunitLength(feeunit_list, s);
|
||||
allLength += length_temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
objects_score_data_now.add(new Object[]{passid, provincenumafter, vehicleid, allLength,vehicletype});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
|
||||
TransactionTemplate transactionTemplate = new TransactionTemplate(dataSourceTransactionManager);
|
||||
//TransactionStatus status = dataSourceTransactionManager.getTransaction(def);
|
||||
|
||||
transactionTemplate.execute(new TransactionCallback<Object>() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus transactionStatus) {
|
||||
Object savepoint = transactionStatus.createSavepoint();
|
||||
try {
|
||||
jdbcTemplate.batchUpdate(delete_data_now, objects_delete_data_now);
|
||||
jdbcTemplate.batchUpdate(sql_score_now, objects_score_data_now);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogClass.error("里程积分服务批量事务执行错误,错误信息" + e.getMessage());
|
||||
//System.out.println(e.getMessage());
|
||||
transactionStatus.setRollbackOnly();
|
||||
result[0] = false;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
eTime=System.currentTimeMillis();
|
||||
LogClass.info("实时积分数据处理用时"+(eTime-sTime));
|
||||
}
|
||||
else {
|
||||
LogClass.info("暂无实时积分处理数据");
|
||||
}
|
||||
|
||||
List<Map<String, Object>> list_data = jdbcTemplate.queryForList(sql_data);
|
||||
if (list_data.size() > 0) {
|
||||
sTime=System.currentTimeMillis();
|
||||
LogClass.info("里程积分数据获取:"+list_data.size());
|
||||
ArrayList<Object[]> objects_delete_data = new ArrayList<>();
|
||||
ArrayList<Object[]> objects_score_data = new ArrayList<>();
|
||||
ArrayList<Object[]> objects_score_error_data = new ArrayList<>();
|
||||
for (Map<String, Object> map : list_data) {
|
||||
//String id=map.get("ID").toString();
|
||||
//System.out.println(id);
|
||||
String passid = map.get("PASSID").toString();
|
||||
int provincenumafter = Integer.valueOf(map.get("PROVINCENUMAFTER").toString());
|
||||
int vehicleType = Integer.valueOf(map.get("VEHICLETYPE").toString());
|
||||
|
||||
int outType = Integer.valueOf(map.get("OUTTYPE").toString());
|
||||
String vehicleid = map.get("VEHICLEID") == null ? "" : map.get("VEHICLEID").toString();
|
||||
//System.out.println("处理车牌:"+vehicleid);
|
||||
LogClass.info("处理车牌:" + vehicleid);
|
||||
|
||||
objects_delete_data.add(new Object[]{passid, provincenumafter});
|
||||
|
||||
if (vehicleid.length() > 0 && vehicleType > 10) {
|
||||
String feeGroup = map.get("TOLLINTERVALFEE").toString();
|
||||
if (CommonHelp.GetArrSum(feeGroup.split("\\|")) > 0) {
|
||||
int length = 0;
|
||||
int score = 0;
|
||||
int g6length = 0;
|
||||
int g6score = 0;
|
||||
int g65length = 0;
|
||||
int g65score = 0;
|
||||
String tollintervalid = map.get("TOLLINTERVALID").toString();
|
||||
String[] tollId_arr = tollintervalid.split("\\|");
|
||||
boolean isG6_G65=false;
|
||||
for (String s : tollId_arr) {
|
||||
if (s.substring(0, 5).equals("G0006")) {
|
||||
int length_temp = CommonHelp.GetFeeunitLength(feeunit_list, s);
|
||||
length += length_temp;
|
||||
g6length += length_temp;
|
||||
isG6_G65=true;
|
||||
}
|
||||
if (s.substring(0, 5).equals("G0065")) {
|
||||
int length_temp = CommonHelp.GetFeeunitLength(feeunit_list, s);
|
||||
length += length_temp;
|
||||
g65length += length_temp;
|
||||
isG6_G65=true;
|
||||
}
|
||||
}
|
||||
String enpointid = tollId_arr[0];
|
||||
String expointid = tollId_arr[tollId_arr.length - 1];
|
||||
String enStaid=enpointid.substring(0,enpointid.length()-2);
|
||||
String exStaid=expointid.substring(0,expointid.length()-2);
|
||||
String enname = CommonHelp.GetFeeunitNameById(feeunit_list, enpointid);
|
||||
String exname = CommonHelp.GetFeeunitNameById(feeunit_list, expointid);
|
||||
String entime = map.get("ENTIME").toString().substring(0, map.get("ENTIME").toString().length() - 2);
|
||||
String extime = map.get("EXTIME").toString().substring(0, map.get("EXTIME").toString().length() - 2);
|
||||
String classdate = map.get("EXTIME").toString().substring(0, 10);
|
||||
|
||||
if (length>=210000){
|
||||
score = CommonHelp.getVehicleScoreByType(vehicleType, length, score_value_list);
|
||||
g6score = (int) Math.round(((double) g6length / length) * score);
|
||||
g65score = score - g6score;
|
||||
}
|
||||
else {
|
||||
score=0;
|
||||
g6score=0;
|
||||
g65score=0;
|
||||
}
|
||||
|
||||
if (isG6_G65){
|
||||
if (outType==0 || enStaid.equals(exStaid)){
|
||||
objects_score_error_data.add(new Object[]{passid, provincenumafter, vehicleid, enname, exname, entime, extime, length, score, g6length, g6score, g65length, g65score, classdate,vehicleType});
|
||||
}
|
||||
else {
|
||||
objects_score_data.add(new Object[]{passid, provincenumafter, vehicleid, enname, exname, entime, extime, length, score, g6length, g6score, g65length, g65score, classdate,vehicleType});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
|
||||
TransactionTemplate transactionTemplate = new TransactionTemplate(dataSourceTransactionManager);
|
||||
//TransactionStatus status = dataSourceTransactionManager.getTransaction(def);
|
||||
|
||||
transactionTemplate.execute(new TransactionCallback<Object>() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus transactionStatus) {
|
||||
Object savepoint = transactionStatus.createSavepoint();
|
||||
try {
|
||||
jdbcTemplate.batchUpdate(delete_data_sql, objects_delete_data);
|
||||
jdbcTemplate.batchUpdate(sql_score, objects_score_data);
|
||||
jdbcTemplate.batchUpdate(sql_score_error, objects_score_error_data);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogClass.error("里程积分服务批量事务执行错误,错误信息" + e.getMessage());
|
||||
//System.out.println(e.getMessage());
|
||||
transactionStatus.setRollbackOnly();
|
||||
result[0] = false;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
});
|
||||
eTime=System.currentTimeMillis();
|
||||
LogClass.info("里程积分数据处理用时:"+(eTime-sTime));
|
||||
|
||||
}
|
||||
else {
|
||||
LogClass.info("暂无里程积分处理数据");
|
||||
}
|
||||
|
||||
|
||||
List<Map<String, Object>> list_data_div = jdbcTemplate.queryForList(sql_data_div);
|
||||
if (list_data_div.size() > 0) {
|
||||
sTime=System.currentTimeMillis();
|
||||
LogClass.info("获取拆分积分数据:"+list_data_div.size());
|
||||
|
||||
ArrayList<Object[]> objects_delete_data_div = new ArrayList<>();
|
||||
ArrayList<Object[]> objects_score_data_div = new ArrayList<>();
|
||||
|
||||
for (Map<String, Object> map : list_data_div) {
|
||||
String id = map.get("ID").toString();
|
||||
//System.out.println(id);
|
||||
String passid = map.get("PASSID").toString();
|
||||
int provincenumafter = 0;
|
||||
int vehicleType = Integer.valueOf(map.get("VEHICLETYPE").toString());
|
||||
String vehicleid = map.get("VEHICLEID") == null ? "" : map.get("VEHICLEID").toString();
|
||||
objects_delete_data_div.add(new Object[]{id});
|
||||
|
||||
if (vehicleid.length() > 0 && vehicleType > 10) {
|
||||
String feeGroup = map.get("FEEGROUP").toString();
|
||||
int fee = CommonHelp.GetArrSum(feeGroup.split("\\|"));
|
||||
int length = 0;
|
||||
int score = 0;
|
||||
int g6length = 0;
|
||||
int g6score = 0;
|
||||
int g65length = 0;
|
||||
int g65score = 0;
|
||||
String tollintervalid = map.get("TOLLINTERVALID").toString();
|
||||
String[] tollId_arr = tollintervalid.split("\\|");
|
||||
for (String s : tollId_arr) {
|
||||
if (s.substring(0, 5).equals("G0006")) {
|
||||
int length_temp = CommonHelp.GetFeeunitLength(feeunit_list, s);
|
||||
length += length_temp;
|
||||
g6length += length_temp;
|
||||
}
|
||||
if (s.substring(0, 5).equals("G0065")) {
|
||||
int length_temp = CommonHelp.GetFeeunitLength(feeunit_list, s);
|
||||
length += length_temp;
|
||||
g65length += length_temp;
|
||||
}
|
||||
}
|
||||
String enpointid = tollId_arr[0];
|
||||
String expointid = tollId_arr[tollId_arr.length - 1];
|
||||
String enname = CommonHelp.GetFeeunitNameById(feeunit_list, enpointid);
|
||||
String exname = CommonHelp.GetFeeunitNameById(feeunit_list, expointid);
|
||||
String entime = map.get("ENTIME").toString().substring(0, map.get("ENTIME").toString().length() - 2);
|
||||
String extime = map.get("EXTIME").toString().substring(0, map.get("EXTIME").toString().length() - 2);
|
||||
String classdate = map.get("EXTIME").toString().substring(0, 10);
|
||||
if (length >= 210000) {
|
||||
score = CommonHelp.getVehicleScoreByType(vehicleType, length, score_value_list);
|
||||
//score=20+((length-210000)/50000)*10;
|
||||
|
||||
g6score = (int) Math.round(((double) g6length / length) * score);
|
||||
g65score = score - g6score;
|
||||
|
||||
objects_score_data_div.add(new Object[]{id, passid, provincenumafter, vehicleid, enname, exname, entime, extime, length, score, g6length, g6score, g65length, g65score, classdate, fee,vehicleType});
|
||||
|
||||
} else {
|
||||
objects_score_data_div.add(new Object[]{id, passid, provincenumafter, vehicleid, enname, exname, entime, extime, length, 0, g6length, 0, g65length, 0, classdate, fee,vehicleType});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
|
||||
TransactionTemplate transactionTemplate = new TransactionTemplate(dataSourceTransactionManager);
|
||||
//TransactionStatus status = dataSourceTransactionManager.getTransaction(def);
|
||||
|
||||
transactionTemplate.execute(new TransactionCallback<Object>() {
|
||||
@Override
|
||||
public Object doInTransaction(TransactionStatus transactionStatus) {
|
||||
Object savepoint = transactionStatus.createSavepoint();
|
||||
try {
|
||||
jdbcTemplate.batchUpdate(delete_data_div_sql, objects_delete_data_div);
|
||||
jdbcTemplate.batchUpdate(sql_div_score, objects_score_data_div);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogClass.error("里程积分服务批量事务执行错误,错误信息" + e.getMessage());
|
||||
//System.out.println(e.getMessage());
|
||||
transactionStatus.setRollbackOnly();
|
||||
result[0] = false;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
eTime=System.currentTimeMillis();
|
||||
LogClass.info("拆分积分数据处理用时:"+(eTime-sTime));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
LogClass.info("暂无拆分积分处理数据");
|
||||
}
|
||||
|
||||
if (list_data_now.size()==0 && list_data.size()==0 && list_data_div.size()==0){
|
||||
LogClass.info("所有处理表无数据");
|
||||
Thread.sleep(10*1000);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogClass.error("里程积分处理错误:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="lib" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
Loading…
Reference in New Issue