public Object selectPDate(Long deptId) {
Date date2 = DateUtil.date(Calendar.getInstance());//当前时间
// Date beginOfMonth = DateUtil.beginOfMonth(date2);//当前时间月份第一天
// Date endOfDay = DateUtil.endOfDay(date2);//当前时间最晚时间
IntelligenceVo intelligenceVo;
List<IntelligenceVo> ig = new ArrayList<>();
String a = "2022-10-01 00:00:00";
String b = "2022-10-31 23:59:59";
Date beginOfMonth = DateUtil.parse(a);
Date endOfDay = DateUtil.parse(b);
List<DateTime> dateTimes = DateUtil.rangeToList(beginOfMonth, endOfDay, DateField.DAY_OF_YEAR);//从当前月份开始第一天到当前时间的天数集合
List<IntelligenceVo> intelligenceVos = myPrisionerMapper.selectPJdate(beginOfMonth, endOfDay, deptId);
if (intelligenceVos.size() < dateTimes.size()) {//判断查询的天数与实际天数的对比
for (int i = 0; i < dateTimes.size(); i++) {
String datet = String.valueOf(dateTimes.get(i)).substring(0, 10);
intelligenceVo = new IntelligenceVo();
intelligenceVo.setJDate(datet);
intelligenceVo.setNum(0L);
ig.add(intelligenceVo);
}
for(int j=0;j<intelligenceVos.size();j++){
for (int w = 0; w<ig.size(); w++){
if(ig.get(w).getJDate().equals(intelligenceVos.get(j).getJDate())){
ig.get(w).setNum(intelligenceVos.get(j).getNum());
}
}
}
} else {
ig.addAll(intelligenceVos);
}
MyHashMap<Object> map = new MyHashMap<Object>();
for (int i = 0; i < ig.size(); i++) {
map.put("jDate", ig.get(i).getJDate());
map.put("num", ig.get(i).getNum());
}
return map;
}
Date date2 = DateUtil.date(Calendar.getInstance());//当前时间
Date beginOfMonth = DateUtil.beginOfMonth(date2);//当前时间月份第一天
Date startTime = DateUtil.offsetMonth(beginOfMonth, -3);//向前偏移3月
Date endTime = DateUtil.endOfMonth(date2);//当前时间月份最后一天
List<Map<String, Object>> list = myPrisionerMapper.selectPJdateWeek(startTime, endTime, deptId);
return MapUtil.toListMap(list);