|
|
|
|
@ -36,6 +36,7 @@ import cn.iocoder.yudao.module.mes.service.task.TaskService;
|
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
|
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@ -44,7 +45,9 @@ import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@ -60,6 +63,7 @@ import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PLAN_NOT_EXIS
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@Validated
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class PlanServiceImpl implements PlanService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
@ -235,6 +239,47 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> getLastSevenDaysCompletedCount() {
|
|
|
|
|
// 查询数据库
|
|
|
|
|
List<Map<String, Object>> dbResult = planMapper.getLastSevenDaysCompletedCount();
|
|
|
|
|
|
|
|
|
|
// 创建日期到数量的映射
|
|
|
|
|
Map<String, Long> countMap = Optional.ofNullable(dbResult)
|
|
|
|
|
.orElse(Collections.emptyList())
|
|
|
|
|
.stream()
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.filter(map -> map.get("date") != null)
|
|
|
|
|
.collect(Collectors.toMap(
|
|
|
|
|
map -> map.get("date").toString(),
|
|
|
|
|
map -> {
|
|
|
|
|
Object value = map.get("totalWangong");
|
|
|
|
|
if (value instanceof Number) {
|
|
|
|
|
return ((Number) value).longValue();
|
|
|
|
|
}
|
|
|
|
|
return 0L;
|
|
|
|
|
},
|
|
|
|
|
Long::sum
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
// 生成最近7天
|
|
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|
|
LocalDate today = LocalDate.now();
|
|
|
|
|
|
|
|
|
|
for (int i = 6; i >= 0; i--) {
|
|
|
|
|
String date = today.minusDays(i).toString();
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("date",date);
|
|
|
|
|
map.put("totalWangong",countMap.getOrDefault(date, 0L));
|
|
|
|
|
result.add(map);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageResult<PlanRespVO> getPlanPage(PlanPageReqVO pageReqVO) {
|
|
|
|
|
PageResult<PlanDO> pageResult = planMapper.selectPage(pageReqVO);
|
|
|
|
|
|