|
@@ -1,5 +1,16 @@
|
|
|
package com.factory.web.service.impl.statistics;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.factory.base.entity.aggregates.ResponseBean;
|
|
|
import com.factory.base.util.res.ResponseBeanBuilder;
|
|
@@ -15,19 +26,8 @@ import com.factory.web.mapper.fa.FirstArticleTaskMapper;
|
|
|
import com.factory.web.mapper.pm.OnsiteTaskHisBlobMapper;
|
|
|
import com.factory.web.mapper.pm.OnsiteTaskMapper;
|
|
|
import com.factory.web.service.statistics.StatisticsService;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
/**
|
|
|
* 异常统计
|
|
@@ -36,6 +36,7 @@ import java.util.stream.Stream;
|
|
|
* @version 1.0
|
|
|
* @date 2021-07-22 4:03 下午
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service("statisticsService")
|
|
|
public class StatisticsServiceImpl implements StatisticsService {
|
|
|
@Autowired
|
|
@@ -50,15 +51,15 @@ public class StatisticsServiceImpl implements StatisticsService {
|
|
|
@Override
|
|
|
public ResponseBean<ExceptionCountRes> getExceptionsByMonth(StatisticsDateReq statisticsDateReq) {
|
|
|
|
|
|
- String month = getMonth(statisticsDateReq);
|
|
|
-
|
|
|
+ LocalDateTime month = getMonth(statisticsDateReq);
|
|
|
+
|
|
|
List<String> releasedDates = new ArrayList<>();
|
|
|
List<String> recheckedDates = new ArrayList<>();
|
|
|
- LocalDateTime[] se = TimeUtils.getStartAndEndDayTime(LocalDateTime.now(), 2, 0);
|
|
|
+ LocalDateTime[] se = TimeUtils.getStartAndEndDayTime(month, 3, 1);
|
|
|
//取首件放行状态数量
|
|
|
List<FirstArticleTask> firstArticleTaskList = firstArticleTaskMapper.selectList(Wrappers.<FirstArticleTask>lambdaQuery()
|
|
|
.eq(FirstArticleTask::getStatus, 2)
|
|
|
- .likeRight(FirstArticleTask::getTaskTime, month));
|
|
|
+ .between(FirstArticleTask::getTaskTime, se[0],se[1]));
|
|
|
firstArticleTaskList.forEach(firstArticleTask -> {
|
|
|
releasedDates.add(TimeUtils.formatLocalDate(firstArticleTask.getTaskTime()));
|
|
|
});
|
|
@@ -71,7 +72,7 @@ public class StatisticsServiceImpl implements StatisticsService {
|
|
|
//取防错放行状态
|
|
|
List<OnsiteTask> onsiteTaskList = onsiteTaskMapper.selectList(Wrappers.<OnsiteTask>lambdaQuery()
|
|
|
.eq(OnsiteTask::getStatus, 2)
|
|
|
- .likeRight(OnsiteTask::getTaskTime, month));
|
|
|
+ .between(OnsiteTask::getTaskTime, se[0],se[1]));
|
|
|
onsiteTaskList.forEach(onsiteTask -> {
|
|
|
releasedDates.add(TimeUtils.formatLocalDate(onsiteTask.getTaskTime()));
|
|
|
});
|
|
@@ -98,14 +99,12 @@ public class StatisticsServiceImpl implements StatisticsService {
|
|
|
* @param statisticsDateReq 默认2021-06
|
|
|
* @return
|
|
|
*/
|
|
|
- private String getMonth(StatisticsDateReq statisticsDateReq) {
|
|
|
- String month = "2021-06";
|
|
|
+ private LocalDateTime getMonth(StatisticsDateReq statisticsDateReq) {
|
|
|
+ LocalDateTime month = LocalDateTime.now();
|
|
|
try {
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
- Date date = simpleDateFormat.parse(statisticsDateReq.getMonth());
|
|
|
- month = simpleDateFormat.format(date);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ month = TimeUtils.paserMonthString(statisticsDateReq.getMonth());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("年月格式错误",e);
|
|
|
ResponseBeanBuilder.fail("年月格式错误");
|
|
|
}
|
|
|
return month;
|