|
@@ -16,8 +16,6 @@ import org.fouram.entity.SapCheckReport;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.google.common.collect.Sets;
|
|
|
|
|
@@ -207,106 +205,4 @@ public class SapCheckService extends BaseService {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
- public JSONObject findUserReportPage(String startDate, String endDate, String departId, String name, String state,
|
|
|
- Integer pageSize, Integer pageNumber) throws Exception {
|
|
|
- List<Map<String, Object>> list = findUserReports(startDate, endDate, departId, name, state, pageSize,
|
|
|
- pageNumber);
|
|
|
- Long total = findUserReportTotal(startDate, endDate, departId, name, state);
|
|
|
- return getPageResult(list, total);
|
|
|
- }
|
|
|
-
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- public List<Map<String, Object>> findUserReports(String startDate, String endDate, String departId, String name,
|
|
|
- String state, Integer pageSize, Integer pageNumber) throws Exception {
|
|
|
- if (StringUtils.isNotBlank(departId) && departId.endsWith(",")) {
|
|
|
- departId = departId.substring(0, departId.length() - 1);
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(state)) {
|
|
|
- if ("1".equals(state)) {
|
|
|
- state = "正常";
|
|
|
- } else {
|
|
|
- state = "异常";
|
|
|
- }
|
|
|
- }
|
|
|
- Map<String, String> pd = Maps.newHashMap();
|
|
|
- pd.put("startDate", startDate);
|
|
|
- pd.put("endDate", endDate);
|
|
|
- pd.put("departId", departId);
|
|
|
- pd.put("name", name);
|
|
|
- pd.put("state", state);
|
|
|
- if (pageSize != null) {
|
|
|
- pd.put("pageCurrent", String.valueOf(pageSize * (pageNumber - 1)));
|
|
|
- pd.put("pageSize", String.valueOf(pageSize));
|
|
|
- }
|
|
|
- return (List<Map<String, Object>>) findList("SapCheckMapper.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(",")) {
|
|
|
- departId = departId.substring(0, departId.length() - 1);
|
|
|
- }
|
|
|
- Map<String, String> pd = Maps.newHashMap();
|
|
|
- pd.put("startDate", startDate);
|
|
|
- pd.put("endDate", endDate);
|
|
|
- pd.put("departId", departId);
|
|
|
- pd.put("name", name);
|
|
|
- pd.put("reportDaySql", getReportDaySql(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("A", "公司");
|
|
|
- headerMap.put("B", "部门");
|
|
|
- headerMap.put("C", "工号");
|
|
|
- headerMap.put("D", "姓名");
|
|
|
- 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("SapCheckMapper.selectReportDayList", pd);
|
|
|
- list.stream().forEach(check -> result.add(check));
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- private String getReportDaySql(String startDate, String endDate) throws Exception {
|
|
|
- String baseSql = "replace(group_concat(case when a.checkinDay = '%s' then a.result else '' end ),',','') as '%s',";
|
|
|
- List<String> days = DateUtil.getSubDateList(startDate, endDate);
|
|
|
- String reportDaySql = "";
|
|
|
- for (String day : days) {
|
|
|
- reportDaySql += String.format(baseSql, day, day);
|
|
|
- }
|
|
|
- reportDaySql = reportDaySql.substring(0, reportDaySql.length() - 1);
|
|
|
- return reportDaySql;
|
|
|
- }
|
|
|
-
|
|
|
- public Long findUserReportTotal(String startDate, String endDate, String departId, String name, String state)
|
|
|
- throws Exception {
|
|
|
- if (StringUtils.isNotBlank(departId) && departId.endsWith(",")) {
|
|
|
- departId = departId.substring(0, departId.length() - 1);
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(state)) {
|
|
|
- if ("1".equals(state)) {
|
|
|
- state = "正常";
|
|
|
- } else {
|
|
|
- state = "异常";
|
|
|
- }
|
|
|
- }
|
|
|
- Map<String, String> pd = Maps.newHashMap();
|
|
|
- pd.put("startDate", startDate);
|
|
|
- pd.put("endDate", endDate);
|
|
|
- pd.put("departId", departId);
|
|
|
- pd.put("name", name);
|
|
|
- pd.put("state", state);
|
|
|
- return (Long) findObject("SapCheckMapper.findUserReportTotal", pd);
|
|
|
- }
|
|
|
-
|
|
|
- public static JSONObject getPageResult(List<? extends Object> list, Object total) {
|
|
|
- JSONObject object = new JSONObject();
|
|
|
- object.put("total", total);
|
|
|
- object.put("data", list);
|
|
|
- return object;
|
|
|
- }
|
|
|
}
|