|
@@ -11,6 +11,7 @@ import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -68,22 +69,27 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo findExtraExercilses(ExtraExercilseQueryInfo queryInfo) {
|
|
|
+ public List<Map<String, Object>> findExtraExercilses(ExtraExercilseQueryInfo queryInfo) {
|
|
|
PageInfo<ExtracurricularExercises> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
|
|
|
- List<ExtracurricularExercises> dataList = null;
|
|
|
- int count = extracurricularExercisesDao.countExtraExercises(params);
|
|
|
- if (count > 0) {
|
|
|
- pageInfo.setTotal(count);
|
|
|
- params.put("offset", pageInfo.getOffset());
|
|
|
- dataList = extracurricularExercisesDao.findExtraExercises(params);
|
|
|
- }
|
|
|
- if (count == 0) {
|
|
|
- dataList = new ArrayList<>();
|
|
|
+ List<ExtracurricularExercises> dataList = extracurricularExercisesDao.findExtraExercises(params);
|
|
|
+ Map<String, List<ExtracurricularExercises>> collect = dataList.stream().collect(Collectors.groupingBy(e -> DateUtil.dateToString(e.getCreateTime(), "yyyy-MM-dd")));
|
|
|
+
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ List<Date> dates=new ArrayList<>();
|
|
|
+ collect.keySet().forEach(ds-> dates.add(DateUtil.stringToDate(ds,"yyyy-MM-dd")));
|
|
|
+ dates.sort(Comparator.comparing(Date::getTime));
|
|
|
+ dates.sort(Comparator.reverseOrder());
|
|
|
+ for (Date date : dates) {
|
|
|
+ String key=DateUtil.dateToString(date, "yyyy-MM-dd");
|
|
|
+ Map<String, Object> r = new HashMap<>();
|
|
|
+ r.put("day", key);
|
|
|
+ collect.get(key).sort(Comparator.comparing(ExtracurricularExercises::getCreateTime).reversed());
|
|
|
+ r.put("list", collect.get(key));
|
|
|
+ result.add(r);
|
|
|
}
|
|
|
- pageInfo.setRows(dataList);
|
|
|
- return pageInfo;
|
|
|
+ return result;
|
|
|
}
|
|
|
}
|