From 3fe6bdef337395da8e380a5a3590a14d5fab34b4 Mon Sep 17 00:00:00 2001 From: zpl Date: Fri, 3 Sep 2021 14:12:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=B4=9F=E8=8D=B7=E7=8E=87?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReportDataController.java | 1 - .../common/mapper/ReportDataMapper.java | 4 + .../service/impl/ReportDataServiceImpl.java | 22 ++++- .../resources/mapper/ReportDataMapper.xml | 84 ++++++++++++++++++- 4 files changed, 106 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/foreverwin/mesnac/common/controller/ReportDataController.java b/common/src/main/java/com/foreverwin/mesnac/common/controller/ReportDataController.java index beb192e0..7448b519 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/controller/ReportDataController.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/controller/ReportDataController.java @@ -48,7 +48,6 @@ public class ReportDataController { @GetMapping("/findResourceLoadRateInfo") public R findResourceLoadRateInfo(@RequestParam(required = false) Map paramMap) { try { - paramMap.put("site", CommonMethods.getSite()); List> result = reportDataService.findResourceLoadRateInfo(paramMap); return R.ok(result); } catch (Exception e) { diff --git a/common/src/main/java/com/foreverwin/mesnac/common/mapper/ReportDataMapper.java b/common/src/main/java/com/foreverwin/mesnac/common/mapper/ReportDataMapper.java index a491333d..8e4193cf 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/mapper/ReportDataMapper.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/mapper/ReportDataMapper.java @@ -1,5 +1,6 @@ package com.foreverwin.mesnac.common.mapper; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -16,6 +17,9 @@ public interface ReportDataMapper { List> findProductStateInfo(Map paramMap); + void insertReportDateTimeByStartToDate(@Param("site") String site ,@Param("startFromDate") String startFromDate,@Param("startToDate") String startToDate); + + void deleteAllReportDateTime(); } diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ReportDataServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ReportDataServiceImpl.java index 68042807..a81fdb4a 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ReportDataServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/ReportDataServiceImpl.java @@ -2,11 +2,13 @@ package com.foreverwin.mesnac.common.service.impl; import com.foreverwin.mesnac.common.mapper.ReportDataMapper; import com.foreverwin.mesnac.common.service.ReportDataService; +import com.foreverwin.modular.core.exception.BusinessException; import com.foreverwin.modular.core.util.CommonMethods; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDate; import java.util.List; import java.util.Map; @@ -24,7 +26,25 @@ public class ReportDataServiceImpl implements ReportDataService{ @Override public List> findResourceLoadRateInfo(Map paramMap) { - return reportDataMapper.findResourceLoadRateInfo(paramMap); + String site = CommonMethods.getSite(); + paramMap.put("site",site); + String startFromDate = (String) paramMap.get("startFromDate"); + String startToDate = (String) paramMap.get("startToDate"); + try{ + LocalDate.parse(startToDate); + LocalDate.parse(startFromDate); + }catch (Exception e){ + throw BusinessException.build("时间格式错误!"); + } + // 清空日期表数据 + reportDataMapper.deleteAllReportDateTime(); + // 插入日期查询范围 + reportDataMapper.insertReportDateTimeByStartToDate(site,startFromDate,startToDate); + List> resourceLoadRateInfo = reportDataMapper.findResourceLoadRateInfo(paramMap); + if (resourceLoadRateInfo.size() < 1){ + throw BusinessException.build("按条件查询未找到数据!"); + } + return resourceLoadRateInfo; } @Override diff --git a/common/src/main/resources/mapper/ReportDataMapper.xml b/common/src/main/resources/mapper/ReportDataMapper.xml index 4bdc1ab6..cbb14ce2 100644 --- a/common/src/main/resources/mapper/ReportDataMapper.xml +++ b/common/src/main/resources/mapper/ReportDataMapper.xml @@ -52,9 +52,62 @@ - + @@ -125,7 +178,32 @@ AND ZSD.ACTUAL_COMPLETE_DATE <= TO_DATE(#{actualStartToDate}|| '15:59:59', 'YYYY-MM-DD HH24:MI:SS') - + + + + DELETE FROM Z_REPORT_DATE_TIME + + + + INSERT INTO Z_REPORT_DATE_TIME (SITE,DATE_TIME,START_DATE_TIME,END_DATE_TIME) + + SELECT #{reportDateTime.site, jdbcType=NVARCHAR}, + #{reportDateTime.dateTime, jdbcType=NVARCHAR}, + #{reportDateTime.startDateTime, jdbcType=DATE}, + #{reportDateTime.endDateTime, jdbcType=DATE} + FROM DUAL + + + + + + INSERT INTO Z_REPORT_DATE_TIME + SELECT #{site} ,TO_CHAR(TO_DATE(#{startFromDate},'YYYY-MM-DD') + ROWNUM -1, 'YYYY-MM-DD') , TO_DATE(#{startFromDate} || '16:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -2 , + TO_DATE(#{startFromDate} || '16:00:00','yyyy-mm-dd hh24:mi:ss') + rownum -1 + FROM dual CONNECT BY rownum <= to_date( #{startToDate}, 'yyyy-mm-dd') - to_date( #{startFromDate}, 'yyyy-mm-dd') + 1 + + + \ No newline at end of file