This commit is contained in:
shimingxy
2019-10-20 23:21:30 +08:00
parent 3bd46aae35
commit d421ac07ca
20 changed files with 753 additions and 120 deletions

View File

@@ -1,81 +0,0 @@
package org.maxkey.tasks.report;
import java.sql.Types;
import java.util.List;
import java.util.Map;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
public class LoginDayReport {
final static Logger _logger = LoggerFactory.getLogger(LoginDayReport.class);
JdbcTemplate jdbcTemplate;
public static final String DAY_REPORT_COUNT_SELECT_SQL="SELECT COUNT(ID) DAYCOUNT FROM SECDB.LOGIN_HISTORY WHERE LOGINTIME > ? AND LOGINTIME < ?";
public static final String DAY_REPORT_INSERT_SQL="INSERT INTO REPORT_LOGIN_DAY (REPORTDATE,REPORTYEAR,REPORTMONTH,REPORTDAY,REPORTCOUNT) VALUES (? , ? , ? , ? , ?)";
public static final String MONTH_REPORT_COUNT_SELECT_SQL="SELECT REPORTCOUNT FROM REPORT_LOGIN_MONTH WHERE REPORTYEAR = ? AND REPORTMONTH = ?";
public static final String MONTH_REPORT_INSERT_SQL="INSERT INTO REPORT_LOGIN_MONTH (REPORTDATE,REPORTYEAR,REPORTMONTH,REPORTCOUNT) VALUES (? , ? , ? , ?)";
public static final String MONTH_REPORT_UPDATE_SQL="UPDATE REPORT_LOGIN_MONTH SET REPORTCOUNT = ? WHERE REPORTYEAR = ? AND REPORTMONTH = ?";
public void dayReportCount() {
_logger.info("Day Report Statistical Analysis start . ");
DateTime currentdateTime = new DateTime();
_logger.info("current date time : " +currentdateTime.toString( DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")));
String beginDateTime=currentdateTime.toString( DateTimeFormat.forPattern("yyyy-MM-dd 00:00:00"));
String endDateTime=currentdateTime.toString( DateTimeFormat.forPattern("yyyy-MM-dd 23:59:59"));
String currentDate=currentdateTime.toString( DateTimeFormat.forPattern("yyyy-MM-dd"));
String currentYear=currentdateTime.toString( DateTimeFormat.forPattern("yyyy"));
String currentMonth=currentdateTime.toString( DateTimeFormat.forPattern("MM"));
String currentDay=currentdateTime.toString( DateTimeFormat.forPattern("dd"));
_logger.info("Day Report Statistical Analysis Date : " +currentDate);
//Analysis Current Day Login Count
Integer reportCount=jdbcTemplate.queryForObject(DAY_REPORT_COUNT_SELECT_SQL,
new Object[] { beginDateTime,endDateTime},
new int[] {Types.TIMESTAMP,Types.TIMESTAMP}, Integer.class);
_logger.info("Current day Count " + reportCount);
jdbcTemplate.update(DAY_REPORT_INSERT_SQL, currentDate,currentYear,currentMonth,currentDay,reportCount);
/**
* if month count not exist,then insert a record
* else add current day count to month count
*/
List<Map<String, Object>> listSelectMonthReport=jdbcTemplate.queryForList(MONTH_REPORT_COUNT_SELECT_SQL,
new Object[] { currentYear,currentMonth},
new int[] {Types.INTEGER,Types.INTEGER});
if(listSelectMonthReport.size()<1){
jdbcTemplate.update(MONTH_REPORT_INSERT_SQL, currentDate,currentYear,currentMonth,reportCount);
_logger.info("Current Month Count " + reportCount);
}else{
Integer selectMonthReportCount=Integer.parseInt(listSelectMonthReport.get(0).get("REPORTCOUNT").toString())+reportCount;
jdbcTemplate.update(MONTH_REPORT_UPDATE_SQL,selectMonthReportCount, currentYear,currentMonth);
_logger.info("Current Month Count " + selectMonthReportCount);
}
_logger.info("Day Report Statistical Analysis Successful");
}
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplate;
}
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
}

View File

@@ -19,7 +19,7 @@
http://www.springframework.org/schema/security/spring-security.xsd">
<!-- Scheduler Task Start -->
<!-- Day login report -->
<!-- Day login report
<bean id="loginDayReport" class="org.maxkey.tasks.report.LoginDayReport">
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
@@ -31,9 +31,7 @@
</bean>
<bean id="triggerJobDetailLoginDayReport" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="jobDetailLoginDayReport" />
<property name="cronExpression" value="59 59 23 * * ?" />
<!-- <property name="cronExpression" value="40 * * * * ?" />-->
</bean>
@@ -41,12 +39,12 @@
<property name="triggers">
<list>
<ref bean="triggerJobDetailLoginDayReport" />
<!--
<ref bean="cronTrigger" />
<ref bean="simpleTrigger" /> -->
<ref bean="simpleTrigger" />
</list>
</property>
</bean>
</bean> -->
<!-- Scheduler Task End -->

View File

@@ -47,7 +47,7 @@
<div id="tool_box">
<table class="datatable">
<tr>
<td width="120px"><@locale code="app.name"/>:</td>
<td width="120px"><@locale code="apps.name"/>:</td>
<td width="374px" nowrap>
<form id="basic_search_form">
<input type="text" name="name" style ="width:150px">
@@ -104,6 +104,7 @@
data-total-field="records"
data-page-list="[10, 25, 50, 100]"
data-search="false"
data-sort-name="name"
data-locale="zh-CN"
data-query-params="dataGridQueryParams"
data-query-params-type="pageSize"