This commit is contained in:
xd 2024-08-07 16:56:51 +08:00
parent e7d6580e74
commit 61e74d35c8
1 changed files with 29 additions and 14 deletions

View File

@ -587,12 +587,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHandleTime" resultType="String">
select ROUND(sum(secDiff)/ 3600.00 /count(1), 2) diff from (
select case when a.dayDiff = 0 then a.secDiff
select a.quot_code,
<!--询价时间不超过11:30 并且 报价时间超过13:00 报价时间-询价时间-1.5h -->
case when a.dayDiff = 0 and a.secDiff1 <![CDATA[>=]]> 0 and a.secDiff2 <![CDATA[>=]]> 0 then a.secDiff1+a.secDiff2
<!--询价时间超过11:30 并且 不超过13:00 并且 报价时间超过13:00 报价时间-1点 -->
when a.dayDiff = 0 and a.secDiff1 <![CDATA[<]]> 0 and a.secDiff3 <![CDATA[<]]> 0 and a.secDiff2 <![CDATA[>=]]> 0 then a.secDiff2
<!--报价时间不超过11:30 报价时间-询价时间-->
<!--询价时间超过13:00 报价时间-询价时间 -->
when a.dayDiff = 0 then a.secDiff
<!--跨一天 减14个小时 -->
when a.dayDiff = 1 then a.secDiff-14*3600
when a.dayDiff > 1 then a.secDiff-(a.dayDiff-1)*24*3600
<!--跨n,n>1天 减(n-1)*24个小时 -->
when a.dayDiff <![CDATA[>]]> 1 then a.secDiff-(a.dayDiff-1)*24*3600
else 0 end secDiff
from (
select quot_inquiry_date, quot_quotation_date,
select quot_code,quot_inquiry_date, quot_quotation_date,
<!-- 询价时间与11:30的差值 -->
datediff(second,quot_inquiry_date,CONVERT(DATETIME, CONVERT(VARCHAR(10),quot_inquiry_date,111) + ' ' + '11:30:00')) secDiff1,
<!-- 报价时间与13:00的差值 -->
datediff(second,CONVERT(DATETIME, CONVERT(VARCHAR(10),quot_quotation_date,111) + ' ' + '13:00:00'),quot_quotation_date) secDiff2,
<!-- 询价时间与13:00的差值 -->
datediff(second,CONVERT(DATETIME, CONVERT(VARCHAR(10),quot_inquiry_date,111) + ' ' + '13:00:00'),quot_inquiry_date) secDiff3,
datediff(day,quot_inquiry_date,quot_quotation_date) dayDiff,
datediff(second,quot_inquiry_date,quot_quotation_date) secDiff
from quot a