绩效考核数据修正

master
杜磊 10 months ago
commit bf6691a065

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../:\trkf-java\jxkh\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

@ -0,0 +1,23 @@
<component name="ArtifactManager">
<artifact type="jar" name="jxkh:jar">
<output-path>$PROJECT_DIR$/out/artifacts/jxkh_jar</output-path>
<root id="archive" name="jxkh.jar">
<element id="module-output" name="jxkh" />
<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/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$/jxkh.iml" filepath="$PROJECT_DIR$/jxkh.iml" />
</modules>
</component>
</project>

@ -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>

Binary file not shown.

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: jx.jxkhMain

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: jx.jxkhMain

@ -0,0 +1,55 @@
package jx;
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(6);
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_NMGMPAY() 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("100.5mpay");
config.setPassword("nmgh90[]");
config.addDataSourceProperty("v$session.osuser","DL");
config.addDataSourceProperty("v$session.machine","10.15.99.66");
config.addDataSourceProperty("v$session.program","gantry_pass_all");
config.setMaximumPoolSize(4);
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,102 @@
package jx;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileLock;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Date;
public class LogCommon {
public static void WriteLogNormal(String logStr, String suffix)
{
// String s = String.format(" 消息:%s", logStr);
WriteLog(logStr, suffix );
}
public String getPath()
{
String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
if(System.getProperty("os.name").contains("dows"))
{
path = path.substring(1,path.length());
}
if(path.contains("jar"))
{
path = path.substring(0,path.lastIndexOf("."));
return path.substring(0,path.lastIndexOf("/"));
}
return path.replace("target/classes/", "");
}
private static void WriteLog(String content,String suffix) {
try {
StringBuffer sb = new StringBuffer();
String str = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss SSS")) + "---";
sb.append(str);
sb.append(content);
sb.append("\r\n");
String logPath= new LogCommon().getPath()+"/LogFile/";
File logPathFile = new File(logPath);
if (!logPathFile.isDirectory()) {
Boolean f= logPathFile.mkdir();
System.out.println(f);
}
String fileDic = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
File filedir = new File(logPath + fileDic);
if (!filedir.isDirectory()) {
filedir.mkdir();
File[] fs = logPathFile.listFiles();
LocalDateTime now = LocalDateTime.now();
int delFlag = Integer.parseInt(now.minus(10, ChronoUnit.DAYS).format(DateTimeFormatter.ofPattern("yyyyMMdd")));
for (File f : fs) {
int deldir = Integer.parseInt(f.getName());
if (deldir < delFlag) {
if (f.isDirectory()) {
deleteDirectory(f);
}
}
}
}
String newFileName = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
String fullFilePath = logPath + fileDic + "/" + newFileName +"_"+ suffix+".txt";
try (RandomAccessFile reader = new RandomAccessFile(new File(fullFilePath), "rw");
FileLock lock = reader.getChannel().lock()) {
reader.seek(reader.length());
reader.write(sb.toString().getBytes("UTF-8"));
} catch (IOException e) {
System.out.println(e.getMessage());
}
} catch (Exception exception) {
System.out.println(exception.getMessage());
}
}
private static void deleteDirectory(File file) {
if (file.isFile()) {// 表示该文件不是文件夹
file.delete();
} else {
// 首先得到当前的路径
String[] childFilePaths = file.list();
for (String childFilePath : childFilePaths) {
File childFile = new File(file.getAbsolutePath() + "/" + childFilePath);
deleteDirectory(childFile);
}
file.delete();
}
}
}

@ -0,0 +1,381 @@
package jx;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
import javax.lang.model.util.ElementFilter;
import javax.sound.midi.Soundbank;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class jxkhMain {
public static void main(String[] args) throws Exception {
JdbcTemplate jdbcTemplate = new JdbcTemplate(new DBUtil().Hikar_DataSource_NMGGS());
startTimer(jdbcTemplate);
//SetJxkh(jdbcTemplate);
// List dates=findEveryDay("2023-02-28","2023-03-05");
// String sql="merge into div_passid_all_classdate t1 using(select to_date(:classdate,'yyyy-mm-dd') as classdate,'div_passid_all' as type from dual) t2" +
// " on (t1.classdate=t2.classdate and t1.type=t2.type) when not matched then insert(classdate,type) values (t2.classdate,t2.type)";
//
// ArrayList<Object[]> objects = new ArrayList<>();
// for (int i = 0; i < dates.size(); i++) {
// Object[] objects1=new Object[]{dates.get(i)};
// objects.add(objects1);
// }
// jdbcTemplate.batchUpdate(sql,objects);
//
// Set_Div_passid_all(jdbcTemplate);
//Set_Div_passid_all(jdbcTemplate);//汇总总公司数据
}
public static void startTimer(JdbcTemplate jdbcTemplate) {
TimerTask task = new TimerTask() {
@Override
public void run() {
LogCommon.WriteLogNormal("程序开始运行", "info");
SetJxkh(jdbcTemplate);//处理绩效考核数据
Set_Div_passid_all(jdbcTemplate);//汇总总公司数据
}
};
Timer timer = new Timer();
timer.schedule(task, buildTime(), 1000 * 60 * 60 * 24);
}
public static void SetJxkh(JdbcTemplate jdbcTemplate) {
try {
//classdate>=TO_DATE(TO_CHAR(SYSDATE -7, 'yyyy-MM-dd'), 'yyyy-MM-dd')
String sql_init = "select * from jxkhinit order by version desc";
String sql_jxkh = "select a.manno,manid,classdate, ke,kecash,huo,huocash,jun,juncash,lt,ltcash from jxkhresult a " +
"left join user_table b on a.manno=b.manno where classdate>=TO_DATE(TO_CHAR(SYSDATE -7, 'yyyy-MM-dd'), 'yyyy-MM-dd')";
List init_list = jdbcTemplate.queryForList(sql_init);
List jxkh_list = jdbcTemplate.queryForList(sql_jxkh);
if (jxkh_list.size() > 0) {
//获取定量计算标准
Map map_init = (Map) init_list.get(0);
float kecash = Float.valueOf(map_init.get("KE").toString());
float huocash = Float.valueOf(map_init.get("HUO").toString());
float juncash = Float.valueOf(map_init.get("JUN").toString());
float ltcash = Float.valueOf(map_init.get("LT").toString());
long startTime = System.currentTimeMillis();
LogCommon.WriteLogNormal("绩效考核获取数据:" + jxkh_list.size(), "info");
for (int i = 0; i < jxkh_list.size(); i++) {
Map map = (Map) jxkh_list.get(i);
String manno = map.get("MANNO").toString();
String classdate = map.get("CLASSDATE").toString().substring(0, map.get("CLASSDATE").toString().length() - 2);
System.out.println("共:"+jxkh_list.size()+",处理到"+i+",工号:"+manno+",时间:"+classdate);
DecimalFormat decimalFormat = new DecimalFormat("0.00");
try {
if (map.get("MANID")!=null){
if (map.get("MANID").toString().equals("10")) {//收费员
String sql_manno_jxkh = "select sum(case when type in(1,2,3,4) and kind not in(4,14) then carcount else 0 end) ke," +
"sum(case when type in(11,12,13,14,15,16) and kind not in(4,14) then carcount else 0 end) huo," +
"sum(case when kind=14 then carcount else 0 end) jun," +
"sum(case when kind=4 then carcount else 0 end) lt," +
"sum(case when type in(1,2,3,4,11,12,13,14,15,16) then alltime else 0 end) alltime " +
"from bb_manno_stat where manno=" + manno + " and classdate=to_date('" + classdate + "','yyyy-mm-dd hh24:mi:ss')";
List manno_list = jdbcTemplate.queryForList(sql_manno_jxkh);
if (manno_list.size() > 0) {
Map map1 = (Map) manno_list.get(0);
int ke = Integer.valueOf(map1.get("KE") == null ? "0" : map1.get("KE").toString());
int huo = Integer.valueOf(map1.get("HUO") == null ? "0" : map1.get("HUO").toString());
int jun = Integer.valueOf(map1.get("JUN") == null ? "0" : map1.get("JUN").toString());
int lt = Integer.valueOf(map1.get("LT") == null ? "0" : map1.get("LT").toString());
int alltime = Integer.valueOf(map1.get("ALLTIME") == null ? "0" : map1.get("ALLTIME").toString());
String avgtime = "";
if ((ke + huo + jun + lt) == 0) {
avgtime = "0";
} else {
avgtime = decimalFormat.format((float) alltime / (float) (ke + huo + jun + lt));
}
String update_sql = "update jxkhresult set ke=" + ke + ",kecash='" + decimalFormat.format(ke * kecash) + "',huo=" + huo + ",huocash='" + decimalFormat.format(huo * huocash) + "'," +
"jun=" + jun + ",juncash='" + decimalFormat.format(jun * juncash) + "',lt=" + lt + ",ltcash='" + decimalFormat.format(lt * ltcash) + "',jjcount=" + (ke + huo * 3 + jun + lt) + "," +
"avgtime=" + avgtime + " where manno=" + manno + " and classdate=to_date('" + classdate + "','yyyy-mm-dd hh24:mi:ss')";
jdbcTemplate.update(update_sql);
}
}
else if (map.get("MANID").toString().equals("8")){
String sql="select * from duty_table_xz where manno='"+manno+"' and classdate=to_date('"+classdate+"','yyyy-mm-dd hh24:mi:ss')";
List manid8_list=jdbcTemplate.queryForList(sql);
if (manid8_list.size()>0){
int lt=0;
int da=0;
String classno="";
for (int j = 0; j < manid8_list.size(); j++) {
Map map_manid8=(Map) manid8_list.get(j);
classno+=map_manid8.get("CLASSNO").toString()+",";
}
classno=classno.substring(0,classno.length()-1);
String lt_count_sql="select sum(case when kind=4 then carcount else 0 end) lt," +
"sum(case when bitand(flag,134217728)<>0 then carcount else 0 end) da from out_port " +
"where classdate=to_date('"+classdate+"','yyyy-mm-dd hh24:mi:ss') and classno in("+classno+") and kind=4" +
" and stano=(select stano from user_table where manno='"+manno+"')";
List manid8_lt_list=jdbcTemplate.queryForList(lt_count_sql);
if (manid8_lt_list.size()>0){
if (((Map)manid8_lt_list.get(0)).get("LT")!=null){
lt=Integer.valueOf(((Map)manid8_lt_list.get(0)).get("LT").toString());
}
if (((Map)manid8_lt_list.get(0)).get("DA")!=null){
da=Integer.valueOf(((Map)manid8_lt_list.get(0)).get("DA").toString());
}
}
int jjcount=lt+da*3;
String update_sql = "update jxkhresult set lt=" + lt + ",ltcash='" + decimalFormat.format(lt * ltcash) + "'," +
"huo="+da+",huocash='"+decimalFormat.format(da *huocash )+"',jjcount=" + jjcount + " where manno=" + manno + " and classdate=to_date('" + classdate + "','yyyy-mm-dd hh24:mi:ss')";
jdbcTemplate.update(update_sql);
System.out.println("manno"+manno+",时间:"+classdate+",绿通大件更新完毕");
}
}
}
}
catch (Exception e){
System.out.println("错误信息:"+e.getMessage()+",工号:"+manno+",日期:"+classdate);
}
}
String update_cash = "update jxkhresult set jjallcash=kecash+huocash+juncash+ltcash+jscash where classdate>=TO_DATE(TO_CHAR(SYSDATE -7, 'yyyy-MM-dd'), 'yyyy-MM-dd')";
jdbcTemplate.update(update_cash);
long endTime = System.currentTimeMillis();
LogCommon.WriteLogNormal("绩效考核处理完成:" + jxkh_list.size() + ",用时:" + (endTime - startTime), "info");
}
} catch (Exception e) {
LogCommon.WriteLogNormal("错误信息:" + e.getMessage(), "error");
System.out.println("错误信息:" + e.getMessage());
}
}
public static void Set_Div_passid_all(JdbcTemplate jdbcTemplate) {
try {
//处理总公司层级汇总
String sql_all = "select * from div_passid_all_classdate";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List list_all = jdbcTemplate.queryForList(sql_all);
if (list_all.size() > 0) {
for (int i = 0; i < list_all.size(); i++) {
Map map = (Map) list_all.get(i);
String tableName = map.get("TYPE").toString();
String classdate = sdf.format(sdf.parse(map.get("CLASSDATE").toString()));
Insert_Div_passid_stat(jdbcTemplate, tableName, classdate);
}
}
} catch (Exception e) {
LogCommon.WriteLogNormal("错误信息:" + e.getMessage(), "error");
}
}
public static void Insert_Div_passid_stat(JdbcTemplate jdbcTemplate, String tableName, String classdate) throws Exception {
try {
long startTime = System.currentTimeMillis();
long endTime = System.currentTimeMillis();
String delete_classdate_sql = "delete div_passid_all_classdate where classdate=to_date('"+classdate+"','yyyy-mm-dd') and type='"+tableName+"'";
//Object[] objects_classdate = new Object[]{classdate, tableName};
jdbcTemplate.update(delete_classdate_sql);
System.out.println(tableName + "中间表数据删除");
LogCommon.WriteLogNormal(tableName + "中间表数据删除", "info");
String delete_stat_sql = "delete " + tableName + "_stat where classdate=to_date(:classdate,'yyyy-mm-dd')";
Object[] objects_stat = new Object[]{classdate};
jdbcTemplate.update(delete_stat_sql, objects_stat);
System.out.println(tableName + "汇总表数据删除");
LogCommon.WriteLogNormal(tableName + "汇总表数据删除", "info");
String insert_stat_sql_1 = "";
String insert_stat_sql_2 = "";
String insert_stat_sql_5 = "";
String insert_stat_sql_6 = "";
String insert_stat_sql_all = "";
System.out.println("开始处理:" + tableName + "数据");
LogCommon.WriteLogNormal("开始处理:" + tableName + "数据", "info");
startTime = System.currentTimeMillis();
Object[] objects_params = new Object[]{classdate};
if (tableName.equals("div_passid_in")) {
insert_stat_sql_1 = "insert into div_passid_in_stat select enstano,classdate,1,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_in_lis where classdate=to_date(:classdate,'yyyy-mm-dd') group by enstano,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_2 = "insert into div_passid_in_stat select enstano,classdate,2,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_in where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=1 group by enstano,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_5 = "insert into div_passid_in_stat select enstano,classdate,5,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_in where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=0 group by enstano,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
// jdbcTemplate.update(insert_stat_sql_1, objects_params);
// jdbcTemplate.update(insert_stat_sql_2, objects_params);
// jdbcTemplate.update(insert_stat_sql_5, objects_params);
} else if (tableName.equals("div_passid_out")) {
String sql_aftercharge = "select * from ct_clear_aftercharge_gl";
List list_aftercharge_gl = jdbcTemplate.queryForList(sql_aftercharge);
String update_out_6 = "update div_passid_out set divstatus=6 where passid=:passid";
String delete_charge_sql = "delete ct_clear_aftercharge_gl where attr2=:passid";
ArrayList<Object[]> objects_aftercharge = new ArrayList<>();
if (list_aftercharge_gl.size() > 0) {
for (int i = 0; i < list_aftercharge_gl.size(); i++) {
Map map = (Map) list_aftercharge_gl.get(i);
String passsid = map.get("ATTR2").toString();
Object[] objects = new Object[]{passsid};
objects_aftercharge.add(objects);
}
// jdbcTemplate.batchUpdate(update_out_6, objects_aftercharge);
// jdbcTemplate.batchUpdate(delete_charge_sql, objects_aftercharge);
// LogCommon.WriteLogNormal(tableName + "拒付数据更新", "info");
}
insert_stat_sql_1 = "insert into div_passid_out_stat select exstano,classdate,1,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_out_lis where classdate=to_date(:classdate,'yyyy-mm-dd') group by exstano,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_2 = "insert into div_passid_out_stat select exstano,classdate,2,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_out where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=1 group by exstano,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_5 = "insert into div_passid_out_stat select exstano,classdate,5,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_out where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=0 group by exstano,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_6 = "insert into div_passid_out_stat select exstano,classdate,6,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_out where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=6 group by exstano,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
// jdbcTemplate.update(insert_stat_sql_1, objects_params);
// jdbcTemplate.update(insert_stat_sql_2, objects_params);
// jdbcTemplate.update(insert_stat_sql_5, objects_params);
// jdbcTemplate.update(insert_stat_sql_6, objects_params);
} else if (tableName.equals("div_passid_gl")) {
insert_stat_sql_1 = "insert into div_passid_gl_stat select classdate,1,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_gl_lis where classdate=to_date(:classdate,'yyyy-mm-dd') group by classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_2 = "insert into div_passid_gl_stat select classdate,2,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_gl where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=1 group by classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_5 = "insert into div_passid_gl_stat select classdate,5,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_gl where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=0 group by classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
// jdbcTemplate.update(insert_stat_sql_1, objects_params);
// jdbcTemplate.update(insert_stat_sql_2, objects_params);
// jdbcTemplate.update(insert_stat_sql_5, objects_params);
} else if (tableName.equals("div_passid_sub")) {
insert_stat_sql_1 = "insert into div_passid_sub_stat select subcomno,classdate,1,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_sub_lis where classdate=to_date(:classdate,'yyyy-mm-dd') group by subcomno,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_2 = "insert into div_passid_sub_stat select subcomno,classdate,2,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_sub where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=1 group by subcomno,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_5 = "insert into div_passid_sub_stat select subcomno,classdate,5,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_sub where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=0 group by subcomno,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
// jdbcTemplate.update(insert_stat_sql_1, objects_params);
// jdbcTemplate.update(insert_stat_sql_2, objects_params);
// jdbcTemplate.update(insert_stat_sql_5, objects_params);
} else if (tableName.equals("div_passid_road")) {
insert_stat_sql_1 = "insert into div_passid_road_stat select roadlineid,classdate,1,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_road_lis where classdate=to_date(:classdate,'yyyy-mm-dd') group by roadlineid,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_2 = "insert into div_passid_road_stat select roadlineid,classdate,2,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_road where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=1 group by roadlineid,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_5 = "insert into div_passid_road_stat select roadlineid,classdate,5,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_road where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=0 group by roadlineid,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
// jdbcTemplate.update(insert_stat_sql_1, objects_params);
// jdbcTemplate.update(insert_stat_sql_2, objects_params);
// jdbcTemplate.update(insert_stat_sql_5, objects_params);
} else if (tableName.equals("div_passid_subroad")) {
insert_stat_sql_1 = "insert into div_passid_subroad_stat select subcomno,roadlineid,classdate,1,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_subroad_lis where classdate=to_date(:classdate,'yyyy-mm-dd') group by subcomno,roadlineid,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_2 = "insert into div_passid_subroad_stat select subcomno,roadlineid,classdate,2,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_subroad where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=1 group by subcomno,roadlineid,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
insert_stat_sql_5 = "insert into div_passid_subroad_stat select subcomno,roadlineid,classdate,5,count(1),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_subroad where classdate=to_date(:classdate,'yyyy-mm-dd') and divstatus=0 group by subcomno,roadlineid,classdate,(case when vehicleclass is null then -1 else vehicleclass end)";
// jdbcTemplate.update(insert_stat_sql_1, objects_params);
// jdbcTemplate.update(insert_stat_sql_2, objects_params);
// jdbcTemplate.update(insert_stat_sql_5, objects_params);
} else if (tableName.equals("div_passid_all")) {
insert_stat_sql_all = "insert into div_passid_all_stat select classdate,status,gpa_vehicletype,count(1),sum(gpa_fee),sum(div_fee),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_all where classdate=to_date(:classdate,'yyyy-mm-dd') group by classdate,status,gpa_vehicletype,(case when vehicleclass is null then -1 else vehicleclass end)";
jdbcTemplate.update(insert_stat_sql_all, objects_params);
}
else if (tableName.equals("div_passid_sub_all")){
insert_stat_sql_all = " insert into div_passid_sub_all_stat select classdate,subcomno,status,gpa_vehicletype,count(1),sum(gpa_fee),sum(div_fee),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_sub_all where classdate=to_date(:classdate,'yyyy-mm-dd') group by classdate,subcomno,status,gpa_vehicletype,(case when vehicleclass is null then -1 else vehicleclass end)";
jdbcTemplate.update(insert_stat_sql_all, objects_params);
}
else if (tableName.equals("div_passid_all_check")){
insert_stat_sql_all="insert into div_passid_all_check_stat select classdate,status,stano,count(1),sum(gpa_fee),sum(div_fee),(case when vehicleclass is null then -1 else vehicleclass end) vehicleclass from div_passid_all_check where classdate=to_date(:classdate,'yyyy-mm-dd') group by stano,classdate,status,(case when vehicleclass is null then -1 else vehicleclass end)";
jdbcTemplate.update(insert_stat_sql_all, objects_params);
}
endTime = System.currentTimeMillis();
System.out.println(tableName + "数据汇总classdate," + classdate + ",用时" + (endTime - startTime));
LogCommon.WriteLogNormal(tableName + "数据汇总classdate," + classdate + ",用时" + (endTime - startTime), "info");
}
catch (Exception e){
System.out.println("插入出错:"+tableName+","+classdate);
}
}
private static Date buildTime() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 3);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Date time = calendar.getTime();
if (time.before(new Date())) {
//若果当前时间已经是凌晨1点后需要往后加1天否则任务会立即执行。
//很多系统往往系统启动时就需要立即执行一次任务但下面又需要每天凌晨1点执行怎么办呢
//很简单,就在系统初始化话时单独执行一次任务(不需要用定时器,只是执行那段任务的代码)
time = addDay(time, 1);
}
return time;
}
private static Date addDay(Date date, int days) {
Calendar startDT = Calendar.getInstance();
startDT.setTime(date);
startDT.add(Calendar.DAY_OF_MONTH, days);
return startDT.getTime();
}
public static List<String> findEveryDay(String beginTime, String endTime)
throws ParseException {
//1.创建一个放所有日期的集合
List<String> dates = new ArrayList();
//2.创建时间解析对象规定解析格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//3.将传入的时间解析成Date类型,相当于格式化
Date dBegin = sdf.parse(beginTime);
Date dEnd = sdf.parse(endTime);
//4.将格式化后的第一天添加进集合
dates.add(sdf.format(dBegin));
//5.使用本地的时区和区域获取日历
Calendar calBegin = Calendar.getInstance();
//6.传入起始时间将此日历设置为起始日历
calBegin.setTime(dBegin);
//8.判断结束日期是否在起始日历的日期之后
while (dEnd.after(calBegin.getTime())) {
// 9.根据日历的规则:月份中的每一天,为起始日历加一天
calBegin.add(Calendar.DAY_OF_MONTH, 1);
//10.得到的每一天就添加进集合
dates.add(sdf.format(calBegin.getTime()));
//11.如果当前的起始日历超过结束日期后,就结束循环
}
return dates;
}
public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) {
if (nowTime.getTime() == startTime.getTime()
|| nowTime.getTime() == endTime.getTime()) {
return true;
}
Calendar date = Calendar.getInstance();
date.setTime(nowTime);
Calendar begin = Calendar.getInstance();
begin.setTime(startTime);
Calendar end = Calendar.getInstance();
end.setTime(endTime);
return date.after(begin) && date.before(end);
}
}

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.
Loading…
Cancel
Save