数据完整性添加小时数据统计
This commit is contained in:
@@ -15,4 +15,6 @@ public interface GetInegDataMapper {
|
||||
*/
|
||||
IntegrityDetailVo getDataByMonth(@Param("month") String month, @Param("lineId") String lineId, @Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
|
||||
IntegrityDetailVo getDataByDay(@Param("day") String day, @Param("lineId") String lineId, @Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ public class GetInegDataServiceImpl implements GetInegDataService {
|
||||
@Override
|
||||
public List<IntegrityDetailVo> getDetail(String lineId, String startTime, String endTime, String timeType) {
|
||||
List<IntegrityDetailVo> result = new ArrayList<>();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
if (Objects.equals(timeType, "年份") || Objects.equals(timeType, "季度")){
|
||||
List<String> dateList = new ArrayList<>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
||||
@@ -102,22 +103,21 @@ public class GetInegDataServiceImpl implements GetInegDataService {
|
||||
}
|
||||
} else if (Objects.equals(timeType, "月份") || Objects.equals(timeType, "周")){
|
||||
List<String> dateList = new ArrayList<>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
Date d1 = new SimpleDateFormat("yyyy-MM-dd").parse(startTime);
|
||||
Date d2 = new SimpleDateFormat("yyyy-MM-dd").parse(endTime);
|
||||
Calendar dd = Calendar.getInstance();
|
||||
dd.setTime(d1);
|
||||
while (dd.getTime().before(d2)) {
|
||||
String str = sdf.format(dd.getTime());
|
||||
String str = simpleDateFormat.format(dd.getTime());
|
||||
dateList.add(str);
|
||||
dd.add(Calendar.DATE, 1);
|
||||
}
|
||||
dateList.add(sdf.format(d2));
|
||||
dateList.add(simpleDateFormat.format(d2));
|
||||
dateList.forEach(item->{
|
||||
try {
|
||||
String time1 = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).format(DateUtil.beginOfDay(sdf.parse(item)));
|
||||
String time2 = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).format(DateUtil.endOfDay(sdf.parse(item)));
|
||||
String time1 = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).format(DateUtil.beginOfDay(simpleDateFormat.parse(item)));
|
||||
String time2 = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).format(DateUtil.endOfDay(simpleDateFormat.parse(item)));
|
||||
IntegrityDetailVo vo = getInegDataMapper.getDataByMonth(item,lineId,time1,time2);
|
||||
result.add(vo);
|
||||
} catch (ParseException e) {
|
||||
@@ -127,6 +127,20 @@ public class GetInegDataServiceImpl implements GetInegDataService {
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (Objects.equals(timeType, "天") ) {
|
||||
try {
|
||||
String time1 = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).format(DateUtil.beginOfDay(simpleDateFormat.parse(startTime)));
|
||||
String time2 = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).format(DateUtil.endOfDay(simpleDateFormat.parse(startTime)));
|
||||
List<String> timeList = getHourListRange(time1, time2);
|
||||
for (int i = 0; i< Objects.requireNonNull(timeList).size(); i++) {
|
||||
if (i != timeList.size() - 1) {
|
||||
IntegrityDetailVo vo = getInegDataMapper.getDataByDay(timeList.get(i),lineId,timeList.get(i),timeList.get(i+1));
|
||||
result.add(vo);
|
||||
}
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(result)){
|
||||
result.removeIf(Objects::isNull);
|
||||
@@ -134,4 +148,34 @@ public class GetInegDataServiceImpl implements GetInegDataService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 据指定时间片段,返回时间片段内的所有小时
|
||||
* @param startStr
|
||||
* @param endStr
|
||||
* @return
|
||||
*/
|
||||
public static List<String> getHourListRange(String startStr , String endStr){
|
||||
try{
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
List<String > list = new ArrayList<>();
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(format.parse(startStr));
|
||||
Calendar ec = Calendar.getInstance();
|
||||
ec.setTime(format.parse(endStr));
|
||||
while (true){
|
||||
if(ec.before(c)){
|
||||
list.add(format.format(c.getTime()));
|
||||
break;
|
||||
}
|
||||
list.add(format.format(c.getTime()));
|
||||
c.add(Calendar.HOUR_OF_DAY,1);
|
||||
}
|
||||
return list ;
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,4 +23,22 @@
|
||||
AND LINE_INDEX = #{lineId}
|
||||
GROUP BY LINE_INDEX
|
||||
</select>
|
||||
|
||||
<select id="getDataByDay" resultType="com.pqs9000.pojo.report.IntegrityDetailVo">
|
||||
SELECT
|
||||
#{day} startTime,
|
||||
A.LINEID lineId,
|
||||
avg(60 / NVL(B.TINTERVAL, 1)) due,
|
||||
COUNT(TIMEID) REAL,
|
||||
ROUND(COUNT(TIMEID)/ avg(60 / NVL(B.TINTERVAL, 1))* 100, 2) rate,
|
||||
CASE WHEN avg(60 / NVL(B.TINTERVAL, 1)) < COUNT(TIMEID) THEN '实收数据大于应收数据,请检查设备统计间隔设置是否正确' ELSE NULL END explain
|
||||
FROM
|
||||
DATA_V A LEFT JOIN PQ_LINEDETAIL B ON A.LINEID = B.LINE_INDEX
|
||||
WHERE
|
||||
A.TIMEID >= TO_DATE(#{startTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||||
AND A.TIMEID < TO_DATE(#{endTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||||
AND A.LINEID = #{lineId}
|
||||
AND A.PHASIC_TYPE = 'T'
|
||||
GROUP BY A.LINEID
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -361,8 +361,8 @@ function showDetail(lineId) {
|
||||
var startTime = $startTime.eq(0).val();
|
||||
var endTime = $endTime.eq(0).val();
|
||||
var timeType = $timeType.eq(0).val();
|
||||
if (timeType === '天' || timeType === '自定义'){
|
||||
layer.msg("暂不支持天和自定义的维度查看", {icon: 2, time: 2000})
|
||||
if (timeType === '自定义'){
|
||||
layer.msg("暂不支持自定义的维度查看", {icon: 2, time: 2000})
|
||||
} else {
|
||||
layer.open({
|
||||
type: 2,
|
||||
|
||||
Reference in New Issue
Block a user