commit bf6691a065274c7a0b97c907de02c6b753672f60 Author: dulei <907367559@qq.com> Date: Fri Jan 17 15:08:19 2025 +0800 绩效考核数据修正 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b0c18a0 --- /dev/null +++ b/.idea/.gitignore @@ -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/ diff --git a/.idea/artifacts/jxkh_jar.xml b/.idea/artifacts/jxkh_jar.xml new file mode 100644 index 0000000..bd3453e --- /dev/null +++ b/.idea/artifacts/jxkh_jar.xml @@ -0,0 +1,23 @@ + + + $PROJECT_DIR$/out/artifacts/jxkh_jar + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml new file mode 100644 index 0000000..20ae51b --- /dev/null +++ b/.idea/libraries/lib.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..d311e0e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/jxkh.iml b/jxkh.iml new file mode 100644 index 0000000..fb8e866 --- /dev/null +++ b/jxkh.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/out/artifacts/jxkh_jar/jxkh.jar b/out/artifacts/jxkh_jar/jxkh.jar new file mode 100644 index 0000000..ffca0c8 Binary files /dev/null and b/out/artifacts/jxkh_jar/jxkh.jar differ diff --git a/out/production/jxkh/META-INF/MANIFEST.MF b/out/production/jxkh/META-INF/MANIFEST.MF new file mode 100644 index 0000000..20cadb5 --- /dev/null +++ b/out/production/jxkh/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: jx.jxkhMain + diff --git a/out/production/jxkh/jx/DBUtil.class b/out/production/jxkh/jx/DBUtil.class new file mode 100644 index 0000000..d7b825e Binary files /dev/null and b/out/production/jxkh/jx/DBUtil.class differ diff --git a/out/production/jxkh/jx/LogCommon.class b/out/production/jxkh/jx/LogCommon.class new file mode 100644 index 0000000..16b2f14 Binary files /dev/null and b/out/production/jxkh/jx/LogCommon.class differ diff --git a/out/production/jxkh/jx/jxkhMain$1.class b/out/production/jxkh/jx/jxkhMain$1.class new file mode 100644 index 0000000..812be3c Binary files /dev/null and b/out/production/jxkh/jx/jxkhMain$1.class differ diff --git a/out/production/jxkh/jx/jxkhMain.class b/out/production/jxkh/jx/jxkhMain.class new file mode 100644 index 0000000..e213c59 Binary files /dev/null and b/out/production/jxkh/jx/jxkhMain.class differ diff --git a/out/production/jxkh/lib/HikariCP-3.3.1.jar b/out/production/jxkh/lib/HikariCP-3.3.1.jar new file mode 100644 index 0000000..476e0c0 Binary files /dev/null and b/out/production/jxkh/lib/HikariCP-3.3.1.jar differ diff --git a/out/production/jxkh/lib/dom4j-2.0.3.jar b/out/production/jxkh/lib/dom4j-2.0.3.jar new file mode 100644 index 0000000..1ef5c52 Binary files /dev/null and b/out/production/jxkh/lib/dom4j-2.0.3.jar differ diff --git a/out/production/jxkh/lib/fastjson-1.2.78.jar b/out/production/jxkh/lib/fastjson-1.2.78.jar new file mode 100644 index 0000000..bb42302 Binary files /dev/null and b/out/production/jxkh/lib/fastjson-1.2.78.jar differ diff --git a/out/production/jxkh/lib/httpclient-4.5.13.jar b/out/production/jxkh/lib/httpclient-4.5.13.jar new file mode 100644 index 0000000..218ee25 Binary files /dev/null and b/out/production/jxkh/lib/httpclient-4.5.13.jar differ diff --git a/out/production/jxkh/lib/httpcore-4.4.14.jar b/out/production/jxkh/lib/httpcore-4.4.14.jar new file mode 100644 index 0000000..349db18 Binary files /dev/null and b/out/production/jxkh/lib/httpcore-4.4.14.jar differ diff --git a/out/production/jxkh/lib/httpmime-4.5.13.jar b/out/production/jxkh/lib/httpmime-4.5.13.jar new file mode 100644 index 0000000..cc52f44 Binary files /dev/null and b/out/production/jxkh/lib/httpmime-4.5.13.jar differ diff --git a/out/production/jxkh/lib/mssql-jdbc-7.4.1.jre8.jar b/out/production/jxkh/lib/mssql-jdbc-7.4.1.jre8.jar new file mode 100644 index 0000000..9cad1f0 Binary files /dev/null and b/out/production/jxkh/lib/mssql-jdbc-7.4.1.jre8.jar differ diff --git a/out/production/jxkh/lib/ojdbc6-11.2.0.4.jar b/out/production/jxkh/lib/ojdbc6-11.2.0.4.jar new file mode 100644 index 0000000..767eba7 Binary files /dev/null and b/out/production/jxkh/lib/ojdbc6-11.2.0.4.jar differ diff --git a/out/production/jxkh/lib/slf4j-api-1.7.25.jar b/out/production/jxkh/lib/slf4j-api-1.7.25.jar new file mode 100644 index 0000000..0143c09 Binary files /dev/null and b/out/production/jxkh/lib/slf4j-api-1.7.25.jar differ diff --git a/out/production/jxkh/lib/slf4j-simple-1.7.25.jar b/out/production/jxkh/lib/slf4j-simple-1.7.25.jar new file mode 100644 index 0000000..a7260f3 Binary files /dev/null and b/out/production/jxkh/lib/slf4j-simple-1.7.25.jar differ diff --git a/out/production/jxkh/lib/spring-beans-5.2.16.RELEASE.jar b/out/production/jxkh/lib/spring-beans-5.2.16.RELEASE.jar new file mode 100644 index 0000000..40dc420 Binary files /dev/null and b/out/production/jxkh/lib/spring-beans-5.2.16.RELEASE.jar differ diff --git a/out/production/jxkh/lib/spring-core-5.2.16.RELEASE.jar b/out/production/jxkh/lib/spring-core-5.2.16.RELEASE.jar new file mode 100644 index 0000000..74f1ceb Binary files /dev/null and b/out/production/jxkh/lib/spring-core-5.2.16.RELEASE.jar differ diff --git a/out/production/jxkh/lib/spring-jcl-5.2.16.RELEASE.jar b/out/production/jxkh/lib/spring-jcl-5.2.16.RELEASE.jar new file mode 100644 index 0000000..1c85dab Binary files /dev/null and b/out/production/jxkh/lib/spring-jcl-5.2.16.RELEASE.jar differ diff --git a/out/production/jxkh/lib/spring-jdbc-5.2.16.RELEASE.jar b/out/production/jxkh/lib/spring-jdbc-5.2.16.RELEASE.jar new file mode 100644 index 0000000..acaa0af Binary files /dev/null and b/out/production/jxkh/lib/spring-jdbc-5.2.16.RELEASE.jar differ diff --git a/out/production/jxkh/lib/spring-tx-5.2.16.RELEASE.jar b/out/production/jxkh/lib/spring-tx-5.2.16.RELEASE.jar new file mode 100644 index 0000000..3c879ce Binary files /dev/null and b/out/production/jxkh/lib/spring-tx-5.2.16.RELEASE.jar differ diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..20cadb5 --- /dev/null +++ b/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: jx.jxkhMain + diff --git a/src/jx/DBUtil.java b/src/jx/DBUtil.java new file mode 100644 index 0000000..bdc6dc5 --- /dev/null +++ b/src/jx/DBUtil.java @@ -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; + } +} diff --git a/src/jx/LogCommon.java b/src/jx/LogCommon.java new file mode 100644 index 0000000..534d0ab --- /dev/null +++ b/src/jx/LogCommon.java @@ -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(); + } + } +} diff --git a/src/jx/jxkhMain.java b/src/jx/jxkhMain.java new file mode 100644 index 0000000..5d03fc4 --- /dev/null +++ b/src/jx/jxkhMain.java @@ -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 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 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 findEveryDay(String beginTime, String endTime) + throws ParseException { + //1.创建一个放所有日期的集合 + List 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); + } + + +} diff --git a/src/lib/HikariCP-3.3.1.jar b/src/lib/HikariCP-3.3.1.jar new file mode 100644 index 0000000..476e0c0 Binary files /dev/null and b/src/lib/HikariCP-3.3.1.jar differ diff --git a/src/lib/dom4j-2.0.3.jar b/src/lib/dom4j-2.0.3.jar new file mode 100644 index 0000000..1ef5c52 Binary files /dev/null and b/src/lib/dom4j-2.0.3.jar differ diff --git a/src/lib/fastjson-1.2.78.jar b/src/lib/fastjson-1.2.78.jar new file mode 100644 index 0000000..bb42302 Binary files /dev/null and b/src/lib/fastjson-1.2.78.jar differ diff --git a/src/lib/httpclient-4.5.13.jar b/src/lib/httpclient-4.5.13.jar new file mode 100644 index 0000000..218ee25 Binary files /dev/null and b/src/lib/httpclient-4.5.13.jar differ diff --git a/src/lib/httpcore-4.4.14.jar b/src/lib/httpcore-4.4.14.jar new file mode 100644 index 0000000..349db18 Binary files /dev/null and b/src/lib/httpcore-4.4.14.jar differ diff --git a/src/lib/httpmime-4.5.13.jar b/src/lib/httpmime-4.5.13.jar new file mode 100644 index 0000000..cc52f44 Binary files /dev/null and b/src/lib/httpmime-4.5.13.jar differ diff --git a/src/lib/mssql-jdbc-7.4.1.jre8.jar b/src/lib/mssql-jdbc-7.4.1.jre8.jar new file mode 100644 index 0000000..9cad1f0 Binary files /dev/null and b/src/lib/mssql-jdbc-7.4.1.jre8.jar differ diff --git a/src/lib/ojdbc6-11.2.0.4.jar b/src/lib/ojdbc6-11.2.0.4.jar new file mode 100644 index 0000000..767eba7 Binary files /dev/null and b/src/lib/ojdbc6-11.2.0.4.jar differ diff --git a/src/lib/slf4j-api-1.7.25.jar b/src/lib/slf4j-api-1.7.25.jar new file mode 100644 index 0000000..0143c09 Binary files /dev/null and b/src/lib/slf4j-api-1.7.25.jar differ diff --git a/src/lib/slf4j-simple-1.7.25.jar b/src/lib/slf4j-simple-1.7.25.jar new file mode 100644 index 0000000..a7260f3 Binary files /dev/null and b/src/lib/slf4j-simple-1.7.25.jar differ diff --git a/src/lib/spring-beans-5.2.16.RELEASE.jar b/src/lib/spring-beans-5.2.16.RELEASE.jar new file mode 100644 index 0000000..40dc420 Binary files /dev/null and b/src/lib/spring-beans-5.2.16.RELEASE.jar differ diff --git a/src/lib/spring-core-5.2.16.RELEASE.jar b/src/lib/spring-core-5.2.16.RELEASE.jar new file mode 100644 index 0000000..74f1ceb Binary files /dev/null and b/src/lib/spring-core-5.2.16.RELEASE.jar differ diff --git a/src/lib/spring-jcl-5.2.16.RELEASE.jar b/src/lib/spring-jcl-5.2.16.RELEASE.jar new file mode 100644 index 0000000..1c85dab Binary files /dev/null and b/src/lib/spring-jcl-5.2.16.RELEASE.jar differ diff --git a/src/lib/spring-jdbc-5.2.16.RELEASE.jar b/src/lib/spring-jdbc-5.2.16.RELEASE.jar new file mode 100644 index 0000000..acaa0af Binary files /dev/null and b/src/lib/spring-jdbc-5.2.16.RELEASE.jar differ diff --git a/src/lib/spring-tx-5.2.16.RELEASE.jar b/src/lib/spring-tx-5.2.16.RELEASE.jar new file mode 100644 index 0000000..3c879ce Binary files /dev/null and b/src/lib/spring-tx-5.2.16.RELEASE.jar differ