Commit fd9f770b authored by tianyiming's avatar tianyiming

三项统计代码添加注释

parent 1f3af219
......@@ -132,6 +132,7 @@ public class ThreeSystemsServiceImpl extends BaseService<ThreeSystemsDto, ThreeS
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
String monday = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_HOUR_PATTERN);
Boolean flag = false;
//判断今天是否本周第一天凌晨2点,如果是则最后一次更新上月数据
if (day.equals(monday)) {
flag = true;
}
......@@ -147,6 +148,7 @@ public class ThreeSystemsServiceImpl extends BaseService<ThreeSystemsDto, ThreeS
String monthday = DateUtils.convertDateToString(nowDay, DateUtils.MONTH_PATTERN) + "-01 02";
Boolean flag = false;
//判断今天是否本月第一天凌晨2点,如果是则最后一次更新上月数据
if (day.equals(monthday)) {
flag = true;
}
......@@ -157,7 +159,11 @@ public class ThreeSystemsServiceImpl extends BaseService<ThreeSystemsDto, ThreeS
private void createThreeSystemsStatistics(Integer type, Boolean isFirstDay) {
// 所有监管单位列表
List<LinkedHashMap<String, Object>> supervisionList = tzsTwoStaffingService.getSupervisionList();
List<ThreeSystems> resultList = new ArrayList<>();
List<ThreeSystems> resultList;
// 所有企业排查情况列表(昨天/上周/上月)
List<ThreeSystemsDto> oldStaffingCompanyList;
// 所有企业排查情况列表(今天/本周/本月)
List<ThreeSystemsDto> newStaffingCompanyList;
String start = " 00:00:00";
String end = " 23:59:59";
......@@ -169,14 +175,7 @@ public class ThreeSystemsServiceImpl extends BaseService<ThreeSystemsDto, ThreeS
String endDay = "";
String lastStart = "";
String lastEnd = "";
// 所有企业排查情况列表(昨天/上周/上月)
List<ThreeSystemsDto> oldStaffingCompanyList = new ArrayList<>();
// 所有企业排查情况列表(今天/本周/本月)
List<ThreeSystemsDto> newStaffingCompanyList = new ArrayList<>();
// 根据类型设置不同的时间
if (1 == type) {
startDay = day + start;
endDay = day + end;
......@@ -229,21 +228,26 @@ public class ThreeSystemsServiceImpl extends BaseService<ThreeSystemsDto, ThreeS
lastEnd = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + end;
}
}
//获取当天、本周、本月新的数据
newStaffingCompanyList = threeSystemsMapper.getCompanyThreeSystemsStatisticsList(type, startDay, endDay);
//调用三项制度统计方法处理数据
resultList = getThreeSystems(supervisionList, newStaffingCompanyList, type, startDay, true);
//将新数据存入统计表中
threeSystemsMapper.saveOrUpdateBatch(resultList);
List<ThreeSystems> oldList;
//根据lastStart和lastEnd判断是否需要更新日/周/月的历史数据(为空不更新)
if (!"".equals(lastStart) && !"".equals(lastEnd)) {
//获取日/周/月的历史数据
oldStaffingCompanyList = threeSystemsMapper.getOldCompanyThreeSystemsStatisticsList(type, DateUtils.dateToString(lastStart));
//获取日/周/月历史数据的最新状态数据
List<ThreeSystemsDto> oldNewStaffingCompanyList = threeSystemsMapper.getCompanyThreeSystemsStatisticsList(type, lastStart, lastEnd);
if (!ValidationUtil.isEmpty(oldNewStaffingCompanyList)) {
// 调用三项制度统计方法处理数据
oldList = ValidationUtil.isEmpty(oldStaffingCompanyList) ?
getThreeSystems(supervisionList, oldNewStaffingCompanyList, type, lastStart, true) :
getThreeSystems(supervisionList, oldNewStaffingCompanyList, type, lastStart, false);
//如果历史数据不为空,更新历史数据实体
if (!ValidationUtil.isEmpty(oldStaffingCompanyList)) {
if (!ValidationUtil.isEmpty(oldList)) {
for (ThreeSystems e : oldList) {
......@@ -254,12 +258,21 @@ public class ThreeSystemsServiceImpl extends BaseService<ThreeSystemsDto, ThreeS
}
}
}
//更新统计表历史数据
threeSystemsMapper.saveOrUpdateBatch(oldList);
}
}
}
/**
* 三项制度统计数据方法
* @param supervisionList 行政区划列表
* @param StaffingCompanyList 需要统计处理的数据列表
* @param type 统计类型
* @param date 统计日期,做筛选用,日统计传当天日期,周统计传周一日期,月统计传月一号日期
* @param isNew 是否新数据,新数据会生成主键
* @return
*/
private List<ThreeSystems> getThreeSystems(List<LinkedHashMap<String, Object>> supervisionList,
List<ThreeSystemsDto> StaffingCompanyList,
Integer type,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment