|
@@ -21,6 +21,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.nacos.common.utils.DateFormatUtils;
|
|
import com.alibaba.nacos.common.utils.DateFormatUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springblade.business.entity.ImageClassificationFile;
|
|
import org.springblade.business.entity.ImageClassificationFile;
|
|
|
|
+import org.springblade.business.utils.YearTreeUtils;
|
|
import org.springblade.business.vo.ImageClassificationFileVO;
|
|
import org.springblade.business.vo.ImageClassificationFileVO;
|
|
import org.springblade.business.mapper.ImageClassificationFileMapper;
|
|
import org.springblade.business.mapper.ImageClassificationFileMapper;
|
|
import org.springblade.business.service.IImageClassificationFileService;
|
|
import org.springblade.business.service.IImageClassificationFileService;
|
|
@@ -55,66 +56,11 @@ public class ImageClassificationFileServiceImpl extends BaseServiceImpl<ImageCla
|
|
public List<TreeVo> getYearDateTree(String classifyId, String projectId, String contractId) {
|
|
public List<TreeVo> getYearDateTree(String classifyId, String projectId, String contractId) {
|
|
//获取时间
|
|
//获取时间
|
|
List<Date> shootingTimes = this.baseMapper.selectShootingTimeByClassifyAndProjectId(classifyId, projectId, contractId);
|
|
List<Date> shootingTimes = this.baseMapper.selectShootingTimeByClassifyAndProjectId(classifyId, projectId, contractId);
|
|
-
|
|
|
|
- //最终集合
|
|
|
|
- List<TreeVo> result = new ArrayList<>();
|
|
|
|
- //年
|
|
|
|
- Map<String,List<String>> yearMap = new HashMap<>();
|
|
|
|
- for(Date date : shootingTimes){
|
|
|
|
- //转换为字符串后拆分获取年月日
|
|
|
|
- String dateStr = DateFormatUtils.format(date, "yyyy-MM-dd");
|
|
|
|
- String[] dateArray = dateStr.split("-");
|
|
|
|
- List<String> monthList;
|
|
|
|
- if(yearMap.containsKey(dateArray[0] + "年")){
|
|
|
|
- //存在,获取集合
|
|
|
|
- monthList = yearMap.get(dateArray[0] + "年");
|
|
|
|
- } else {
|
|
|
|
- //不存在,创建
|
|
|
|
- monthList = new ArrayList<>();
|
|
|
|
- }
|
|
|
|
- monthList.add(dateArray[1] + "-" + dateArray[2]);
|
|
|
|
- yearMap.put(dateArray[0] + "年", monthList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //循环年
|
|
|
|
- for(Map.Entry<String,List<String>> yearMaps : yearMap.entrySet()){
|
|
|
|
- String year = yearMaps.getKey().replace("年", "");
|
|
|
|
- List<String> monthList = yearMaps.getValue();
|
|
|
|
-
|
|
|
|
- //月集合
|
|
|
|
- List<TreeVo> monthResult = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- //月
|
|
|
|
- TreeVo monthMap = new TreeVo();
|
|
|
|
-
|
|
|
|
- //循环月份
|
|
|
|
- String month = monthList.get(0).split("-")[0];
|
|
|
|
- int index = 0;
|
|
|
|
- for(String monthDay : monthList){
|
|
|
|
- //拆分
|
|
|
|
- String[] monthDays = monthDay.split("-");
|
|
|
|
-
|
|
|
|
- if(!month.equals(monthDays[0])){
|
|
|
|
- month = monthDays[0];
|
|
|
|
- monthResult.add(monthMap);
|
|
|
|
- monthMap = new TreeVo();
|
|
|
|
- }
|
|
|
|
- monthMap.setName(month + "月");
|
|
|
|
- monthMap.setHierarchy(year + "-" + month);
|
|
|
|
- monthMap.getTreeList().add(new TreeVo(monthDays[1] + "日", new ArrayList<>(), year + "-" + month + "-" + monthDays[1]));
|
|
|
|
- index ++;
|
|
|
|
- if(index == monthList.size()){
|
|
|
|
- monthResult.add(monthMap);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //年
|
|
|
|
- TreeVo yearResult = new TreeVo(year, monthResult, year);
|
|
|
|
- result.add(yearResult);
|
|
|
|
- }
|
|
|
|
- //时间倒序
|
|
|
|
- result.sort(Comparator.comparing(TreeVo::getName).reversed());
|
|
|
|
-
|
|
|
|
- return result;
|
|
|
|
|
|
+ //转换时间
|
|
|
|
+ List<String> yearMonthDayList = new ArrayList<>();
|
|
|
|
+ shootingTimes.forEach(date -> yearMonthDayList.add(DateFormatUtils.format(date, "yyyy-MM-dd")));
|
|
|
|
+ //转成结构树
|
|
|
|
+ return YearTreeUtils.yearMonthDayTree(yearMonthDayList);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|