use of com.itrus.portal.db.MsgStatsRecord in project portal by ixinportal.
the class MessageStatsController method excelExport.
// 导出Excel
@RequestMapping(value = "/excel")
public String excelExport(@RequestParam(value = "cycle_sel", required = false) Integer cycle, @RequestParam(value = "applicationName", required = false) Long applicationName, @RequestParam(value = "year1_sel", required = false) Integer year1, @RequestParam(value = "year2_sel", required = false) Integer year2, @RequestParam(value = "type", required = false) Integer type, @RequestParam(value = "status_sel", required = false) Integer status_sel, Model uiModel, HttpServletRequest request, HttpServletResponse response) throws Exception {
Map param = new HashMap();
Map param2 = new HashMap();
Integer year3 = null;
if (year1 != null) {
year3 = year1;
}
List<Map<Integer, Integer>> list = new ArrayList<Map<Integer, Integer>>();
java.util.Date nowdate = new java.util.Date();
String[] monthList = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
String[] seasonList = { "S1", "S2", "S3", "S4" };
String month = null;
String season = null;
String year = null;
Calendar calendar = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
String applicationName1 = null;
if (null != cycle && cycle == 12) {
while (year1 <= year2) {
for (int j = 0; j <= 11; j++) {
calendar.set(Calendar.YEAR, year1);
calendar.set(Calendar.MONTH, j);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// calendar.add(Calendar.MILLISECOND, -1);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, year1);
calendar2.set(Calendar.MONTH, j + 1);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
// calendar2.add(Calendar.MILLISECOND, -1);
Date dt2 = calendar2.getTime();
if (applicationName != null && applicationName != 0) {
AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
applicationName1 = application.getAppName();
param.put("applicationName", applicationName);
}
param2.put("applicationName", applicationName);
param2.put("type", type);
if (status_sel != null && status_sel != 2) {
param.put("gate", status_sel);
} else {
param.put("gate", null);
}
param2.put("gate", status_sel);
if (dt2.before(nowdate)) {
month = year1 + "-" + monthList[j];
param2.put("month", month);
MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByMonth1", param2);
if (null != msr) {
Integer count = msr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
MsgStatsRecord msr2 = new MsgStatsRecord();
msr2.setMonth1(month);
msr2.setAppId(applicationName);
msr2.setCount1(count);
msr2.setType(type);
msr2.setGate(status_sel);
msr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
}
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
}
}
year1++;
}
}
if (null != cycle && cycle == 4) {
while (year1 <= year2) {
for (int j = 0; j <= 9; j = j + 3) {
calendar.set(Calendar.YEAR, year1);
calendar.set(Calendar.MONTH, j);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// calendar.add(Calendar.MILLISECOND, -1);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, year1);
calendar2.set(Calendar.MONTH, j + 3);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
// calendar2.add(Calendar.MILLISECOND, -1);
Date dt2 = calendar2.getTime();
if (applicationName != null && applicationName != 0) {
AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
applicationName1 = application.getAppName();
param.put("applicationName", applicationName);
}
param2.put("applicationName", applicationName);
param2.put("type", type);
if (status_sel != null && status_sel != 2) {
param.put("gate", status_sel);
} else {
param.put("gate", null);
}
param2.put("gate", status_sel);
if (dt2.before(nowdate)) {
season = year1 + "-" + seasonList[j / 3];
param2.put("season", season);
MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectBySeason2", param2);
if (null != msr) {
Integer count = msr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
MsgStatsRecord msr2 = new MsgStatsRecord();
msr2.setSeason1(season);
msr2.setAppId(applicationName);
msr2.setCount1(count);
msr2.setType(type);
msr2.setGate(status_sel);
msr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
}
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
}
}
year1++;
}
}
if (null != cycle && cycle == 1) {
while (year1 <= year2) {
calendar.set(Calendar.YEAR, year1);
calendar.set(Calendar.MONTH, 0);
calendar.set(Calendar.DATE, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// calendar.add(Calendar.MILLISECOND, -1);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, year1 + 1);
calendar2.set(Calendar.MONTH, 0);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
// calendar2.add(Calendar.MILLISECOND, -1);
Date dt2 = calendar2.getTime();
if (applicationName != null && applicationName != 0) {
AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
applicationName1 = application.getAppName();
param.put("applicationName", applicationName);
}
param2.put("applicationName", applicationName);
param2.put("type", type);
if (status_sel != null && status_sel != 2) {
param.put("gate", status_sel);
} else {
param.put("gate", null);
}
param2.put("gate", status_sel);
if (dt2.before(nowdate)) {
year = year1 + "Y";
param2.put("year", year);
MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByYear1", param2);
if (null != msr) {
Integer count = msr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
MsgStatsRecord msr2 = new MsgStatsRecord();
msr2.setYear1(year);
msr2.setAppId(applicationName);
msr2.setCount1(count);
msr2.setType(type);
msr2.setGate(status_sel);
msr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
}
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, year1);
list.add(map);
}
year1++;
}
}
if (null == applicationName || 0 == applicationName) {
applicationName1 = "所有应用";
}
String sgName = "";
if (status_sel == 0)
sgName = "亿美";
if (status_sel == 1)
sgName = "未来无线";
if (status_sel == 2)
sgName = "所有端口";
ArrayList<String> fieldName = messageStatsService.excelFieldName();
ArrayList<ArrayList<String>> fieldDatas = messageStatsService.excelFieldData(list, applicationName1, cycle, sgName);
ExcelFileGenerator generator = new ExcelFileGenerator(fieldName, fieldDatas);
try {
// 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
response.reset();
String filename = "短信统计信息" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + // 设置下载时客户端Excel的名称,此处需要用到encodeFilename()方法来转换编码,否则中文会被过滤掉
".xls";
filename = generator.encodeFilename(filename, request);
response.setHeader("Content-disposition", "attachment;filename=" + filename);
response.setCharacterEncoding("utf-8");
// 由于导出格式是excel的文件,设置导出文件的响应头部信息
response.setContentType("application/vnd.ms-excel");
// 生成excel,传递输出流
// 用response对象获取输出流
OutputStream os = response.getOutputStream();
generator.expordExcel(os);
// 清理刷新缓冲区,将缓存中的数据将数据导出excel
os.flush();
// 关闭os
if (os != null) {
os.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.itrus.portal.db.MsgStatsRecord in project portal by ixinportal.
the class MessageStatsController method list.
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "cycle", required = false) Integer cycle, @RequestParam(value = "applicationName", required = false) Long applicationName, @RequestParam(value = "year1", required = false) Integer year1, @RequestParam(value = "year2", required = false) Integer year2, @RequestParam(value = "cycle2", required = false) Integer cycle2, @RequestParam(value = "projectName", required = false) Long projectName, @RequestParam(value = "year3", required = false) Integer year4, @RequestParam(value = "year4", required = false) Integer year5, @RequestParam(value = "type", required = false) Integer type, @RequestParam(value = "status_sel", required = false) Integer status_sel, @RequestParam(value = "status_sel2", required = false) Integer status_sel2, Model uiModel) throws Exception {
Map param = new HashMap();
Map param2 = new HashMap();
String applicationName1 = null;
String projectName1 = null;
// List<Integer> years = new ArrayList<Integer>();
/* int a = year1 - year2;
if (a ==0){
years.add(year1);
}
else{
for (int i =0; i <=a; i++){
years.add(year1+i);
}
} */
Integer year3 = null;
if (year1 != null) {
year3 = year1;
}
Integer year6 = null;
if (year4 != null) {
year6 = year4;
}
List<Map<Integer, Integer>> list = new ArrayList<Map<Integer, Integer>>();
List<Map<Integer, Integer>> list2 = new ArrayList<Map<Integer, Integer>>();
java.util.Date nowdate = new java.util.Date();
String[] monthList = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
String[] seasonList = { "S1", "S2", "S3", "S4" };
String month = null;
String season = null;
String year = null;
Calendar calendar = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
Integer yr1 = null;
Integer yr2 = null;
Integer ccl = null;
if (null != type && type == 1) {
yr1 = year1;
yr2 = year2;
ccl = cycle;
}
if (null != type && type == 2) {
yr1 = year4;
yr2 = year5;
ccl = cycle2;
}
if (null != ccl && ccl == 12) {
while (yr1 <= yr2) {
for (int j = 0; j <= 11; j++) {
calendar.set(Calendar.YEAR, yr1);
calendar.set(Calendar.MONTH, j);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// calendar.add(Calendar.MILLISECOND, -1);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, yr1);
calendar2.set(Calendar.MONTH, j + 1);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
// calendar2.add(Calendar.MILLISECOND, -1);
Date dt2 = calendar2.getTime();
if (type == 1) {
if (applicationName != null && applicationName != 0) {
AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
applicationName1 = application.getAppName();
param.put("applicationName", applicationName);
}
param2.put("applicationName", applicationName);
param2.put("type", type);
if (status_sel != null && status_sel != 2) {
param.put("gate", status_sel);
} else {
param.put("gate", null);
}
param2.put("gate", status_sel);
if (dt2.before(nowdate)) {
month = yr1 + "-" + monthList[j];
param2.put("month", month);
MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByMonth1", param2);
if (null != msr) {
Integer count = msr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list.add(map);
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list.add(map);
MsgStatsRecord msr2 = new MsgStatsRecord();
msr2.setMonth1(month);
msr2.setAppId(applicationName);
msr2.setCount1(count);
msr2.setType(type);
msr2.setGate(status_sel);
msr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
}
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list.add(map);
}
}
if (type == 2) {
if (projectName != null && projectName != 0) {
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectName);
projectName1 = project.getName();
param.put("projectName", projectName);
}
param2.put("projectName", projectName);
param2.put("type", type);
if (status_sel2 != null && status_sel2 != 2) {
param.put("gate", status_sel2);
} else {
param.put("gate", null);
}
param2.put("gate", status_sel2);
if (dt2.before(nowdate)) {
month = yr1 + "-" + monthList[j];
param2.put("month", month);
MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByMonth2", param2);
if (null != msr) {
Integer count = msr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list2.add(map);
} else {
param.put("queryDate3", dt1);
param.put("queryDate4", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list2.add(map);
MsgStatsRecord msr2 = new MsgStatsRecord();
msr2.setMonth1(month);
msr2.setAppId(projectName);
msr2.setCount1(count);
msr2.setType(type);
msr2.setGate(status_sel2);
msr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
}
} else {
param.put("queryDate3", dt1);
param.put("queryDate4", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list2.add(map);
}
}
}
yr1++;
}
}
if (null != ccl && ccl == 4) {
while (yr1 <= yr2) {
for (int j = 0; j <= 9; j = j + 3) {
calendar.set(Calendar.YEAR, yr1);
calendar.set(Calendar.MONTH, j);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// calendar.add(Calendar.MILLISECOND, -1);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, yr1);
calendar2.set(Calendar.MONTH, j + 3);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
// calendar2.add(Calendar.MILLISECOND, -1);
Date dt2 = calendar2.getTime();
if (type == 1) {
if (applicationName != null && applicationName != 0) {
AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
applicationName1 = application.getAppName();
param.put("applicationName", applicationName);
}
param2.put("applicationName", applicationName);
param2.put("type", type);
if (status_sel != null && status_sel != 2) {
param.put("gate", status_sel);
} else {
param.put("gate", null);
}
param2.put("gate", status_sel);
if (dt2.before(nowdate)) {
season = yr1 + "-" + seasonList[j / 3];
param2.put("season", season);
MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectBySeason1", param2);
if (null != msr) {
Integer count = msr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list.add(map);
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list.add(map);
MsgStatsRecord msr2 = new MsgStatsRecord();
msr2.setSeason1(season);
msr2.setAppId(applicationName);
msr2.setCount1(count);
msr2.setType(type);
msr2.setGate(status_sel);
msr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
}
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list.add(map);
}
}
if (type == 2) {
if (projectName != null && projectName != 0) {
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectName);
projectName1 = project.getName();
param.put("projectName", projectName);
}
param2.put("projectName", projectName);
param2.put("type", type);
if (status_sel2 != null && status_sel2 != 2) {
param.put("gate", status_sel2);
} else {
param.put("gate", null);
}
param2.put("gate", status_sel2);
if (dt2.before(nowdate)) {
season = yr1 + "-" + seasonList[j / 3];
param2.put("season", season);
MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectBySeason2", param2);
if (null != msr) {
Integer count = msr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list2.add(map);
} else {
param.put("queryDate3", dt1);
param.put("queryDate4", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list2.add(map);
MsgStatsRecord msr2 = new MsgStatsRecord();
msr2.setSeason1(season);
msr2.setAppId(projectName);
msr2.setCount1(count);
msr2.setType(type);
msr2.setGate(status_sel2);
msr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
}
} else {
param.put("queryDate3", dt1);
param.put("queryDate4", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list2.add(map);
}
}
}
yr1++;
}
}
if (null != ccl && ccl == 1) {
while (yr1 <= yr2) {
calendar.set(Calendar.YEAR, yr1);
calendar.set(Calendar.MONTH, 0);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// calendar.add(Calendar.MILLISECOND, -1);
Date dt1 = calendar.getTime();
calendar2.set(Calendar.YEAR, yr1 + 1);
calendar2.set(Calendar.MONTH, 0);
calendar2.set(Calendar.DAY_OF_MONTH, 1);
calendar2.set(Calendar.HOUR_OF_DAY, 0);
calendar2.set(Calendar.MINUTE, 0);
calendar2.set(Calendar.SECOND, 0);
calendar2.set(Calendar.MILLISECOND, 0);
// calendar2.add(Calendar.MILLISECOND, -1);
Date dt2 = calendar2.getTime();
if (type == 1) {
if (applicationName != null && applicationName != 0) {
AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
applicationName1 = application.getAppName();
param.put("applicationName", applicationName);
}
param2.put("applicationName", applicationName);
param2.put("type", type);
if (status_sel != null && status_sel != 2) {
param.put("gate", status_sel);
} else {
param.put("gate", null);
}
param2.put("gate", status_sel);
if (dt2.before(nowdate)) {
year = yr1 + "Y";
param2.put("year", year);
MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByYear1", param2);
if (null != msr) {
Integer count = msr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list.add(map);
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list.add(map);
MsgStatsRecord msr2 = new MsgStatsRecord();
msr2.setYear1(year);
msr2.setAppId(applicationName);
msr2.setCount1(count);
msr2.setType(type);
// msr2.setGate(status_sel);
msr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
}
} else {
param.put("queryDate1", dt1);
param.put("queryDate2", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list.add(map);
}
}
if (type == 2) {
if (projectName != null && projectName != 0) {
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectName);
projectName1 = project.getName();
param.put("projectName", projectName);
}
param2.put("projectName", projectName);
param2.put("type", type);
if (status_sel2 != null && status_sel2 != 2) {
param.put("gate", status_sel2);
} else {
param.put("gate", null);
}
param2.put("gate", status_sel2);
if (dt2.before(nowdate)) {
year = yr1 + "Y";
param2.put("year", year);
MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByYear2", param2);
if (null != msr) {
Integer count = msr.getCount1();
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list2.add(map);
} else {
param.put("queryDate3", dt1);
param.put("queryDate4", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list2.add(map);
MsgStatsRecord msr2 = new MsgStatsRecord();
msr2.setYear1(year);
msr2.setAppId(projectName);
msr2.setCount1(count);
msr2.setType(type);
msr2.setGate(status_sel2);
msr2.setCreateTime(new Date());
sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
}
} else {
param.put("queryDate3", dt1);
param.put("queryDate4", dt2);
Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(count, yr1);
list2.add(map);
}
}
yr1++;
}
}
if (null == applicationName || 0 == applicationName) {
applicationName1 = "所有应用";
}
if (null == projectName || 0 == projectName) {
projectName1 = "所有项目";
}
Map<Long, AppConfig> appConfigMap = new HashMap<Long, AppConfig>();
appConfigMap = sqlSession.selectMap("com.itrus.portal.db.AppConfigMapper.selectByExample", null, "id");
Map<Long, Project> projectMap = sqlSession.selectMap("com.itrus.portal.db.ProjectMapper.selectByExample", "id");
uiModel.addAttribute("projectMap", projectMap);
uiModel.addAttribute("list", list);
uiModel.addAttribute("year1", year3);
uiModel.addAttribute("year2", year2);
uiModel.addAttribute("cycle", cycle);
uiModel.addAttribute("applicationName", applicationName);
uiModel.addAttribute("applications", appConfigMap);
uiModel.addAttribute("applicationN", applicationName1);
uiModel.addAttribute("list2", list2);
uiModel.addAttribute("year3", year6);
uiModel.addAttribute("year4", year5);
uiModel.addAttribute("cycle2", cycle2);
uiModel.addAttribute("projectName", projectName);
uiModel.addAttribute("projectN", projectName1);
uiModel.addAttribute("projects", getProjectMapOfAdmin());
uiModel.addAttribute("type", type);
uiModel.addAttribute("status_sel", status_sel);
uiModel.addAttribute("status_sel2", status_sel2);
return "messagestats/list";
}
Aggregations