|
@@ -22,7 +22,7 @@ public class SapCheckReportService extends BaseService {
|
|
|
Long total = findUserReportTotal(startDate, endDate, departId, name, state);
|
|
|
return getPageResult(list, total);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static JSONObject getPageResult(List<? extends Object> list, Object total) {
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("total", total);
|
|
@@ -56,7 +56,6 @@ public class SapCheckReportService extends BaseService {
|
|
|
return (List<Map<String, Object>>) findList("SapCheckReportMapper.findUserReports", pd);
|
|
|
}
|
|
|
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
public List<Map<String, Object>> selectReportDayList(String startDate, String endDate, String departId, String name)
|
|
|
throws Exception {
|
|
|
if (StringUtils.isNotBlank(departId) && departId.endsWith(",")) {
|
|
@@ -67,10 +66,7 @@ public class SapCheckReportService extends BaseService {
|
|
|
pd.put("endDate", endDate);
|
|
|
pd.put("departId", departId);
|
|
|
pd.put("name", name);
|
|
|
- pd.put("reportDaySql", getReportDaySql(startDate, endDate));
|
|
|
- pd.put("reportDayRemarkSql", getReportRemarkDaySql(startDate, endDate));
|
|
|
|
|
|
-// 公司 部门 工号 姓名5月25日 5月26日 5月27日 5月28日 5月29日
|
|
|
List<String> days = DateUtil.getSubDateList(startDate, endDate);
|
|
|
Map<String, Object> headerMap = Maps.newLinkedHashMap();
|
|
|
headerMap.put("firstDepartName", "公司");
|
|
@@ -81,15 +77,39 @@ public class SapCheckReportService extends BaseService {
|
|
|
for (String day : days) {
|
|
|
headerMap.put(day, day);
|
|
|
}
|
|
|
- List<Map<String, Object>> result = Lists.newArrayList(headerMap);
|
|
|
- List<Map<String, Object>> list = (List<Map<String, Object>>) findList("SapCheckReportMapper.selectReportDayList", pd);
|
|
|
- list.stream().forEach(check -> result.add(check));
|
|
|
+ List<Map<String, Object>> result = Lists.newArrayList();
|
|
|
+ Map<String, List<String>> map = groupList(days, 50);
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ List<Map<String, Object>> list = getReportDayResult(pd, map.get(key));
|
|
|
+ if (result.isEmpty()) {
|
|
|
+ list.stream().forEach(check -> result.add(check));
|
|
|
+ } else {
|
|
|
+ for (int i = 0; i < result.size(); i++) {
|
|
|
+ int count = 0;
|
|
|
+ for (String vkey : list.get(i).keySet()) {
|
|
|
+ if(count >= 5) {
|
|
|
+ result.get(i).put(vkey, list.get(i).get(vkey));
|
|
|
+ }
|
|
|
+ count ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.add(0, headerMap);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private String getReportDaySql(String startDate, String endDate) throws Exception {
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ private List<Map<String, Object>> getReportDayResult(Map<String, String> param, List<String> subDays)
|
|
|
+ throws Exception {
|
|
|
+ param.put("reportDaySql", getReportDaySql(subDays));
|
|
|
+ param.put("reportDayRemarkSql", getReportRemarkDaySql(subDays));
|
|
|
+ return (List<Map<String, Object>>) findList("SapCheckReportMapper.selectReportDayList", param);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getReportDaySql(List<String> days) throws Exception {
|
|
|
String baseSql = "replace(group_concat(case when a.checkinDay = '%s' then a.realResult else '' end ),',','') as '%s',";
|
|
|
- List<String> days = DateUtil.getSubDateList(startDate, endDate);
|
|
|
String reportDaySql = "";
|
|
|
for (String day : days) {
|
|
|
reportDaySql += String.format(baseSql, day, day);
|
|
@@ -97,10 +117,9 @@ public class SapCheckReportService extends BaseService {
|
|
|
reportDaySql = reportDaySql.substring(0, reportDaySql.length() - 1);
|
|
|
return reportDaySql;
|
|
|
}
|
|
|
-
|
|
|
- private String getReportRemarkDaySql(String startDate, String endDate) throws Exception {
|
|
|
+
|
|
|
+ private String getReportRemarkDaySql(List<String> days) throws Exception {
|
|
|
String baseSql = "replace(group_concat(case when a.checkinDay = '%s' then a.realResultRemark else '' end ),',','') as '%s',";
|
|
|
- List<String> days = DateUtil.getSubDateList(startDate, endDate);
|
|
|
String reportDaySql = "";
|
|
|
for (String day : days) {
|
|
|
reportDaySql += String.format(baseSql, day, day);
|