预警性能 不使用转列改为使用正则

This commit is contained in:
zhaokaiyao@91isoft.com
2021-12-24 15:22:37 +08:00
parent 2bd9e7f323
commit d9996eeac2
6 changed files with 147 additions and 56 deletions
@@ -11,7 +11,7 @@
(
#{item.id}
,#{item.standId}
,#{item.itemsId}
,#{item.itemId}
,#{item.policyId}
,#{item.mark}
,#{item.power}
@@ -29,22 +29,17 @@
FROM
warning_date
WHERE
DATE_FORMAT(SSRQ, '%Y-%m-%d') < DATE_FORMAT(now(), '%Y-%m-%d')
UNION
DATE_FORMAT(SSRQ, '%Y-%m-%d') > DATE_FORMAT(now(), '%Y-%m-%d')
)
OR
ITEMS_ID IN (
SELECT
ID
ITEM_ID
FROM
sar_standards_info
warning_date
WHERE
DATE_FORMAT(PUT_TIME, '%Y-%m-%d') < DATE_FORMAT(now(), '%Y-%m-%d')
UNION
SELECT
STAND_ID
FROM
sar_stand_items
WHERE
DATE_FORMAT(XCXSSRQ, '%Y-%m-%d') < DATE_FORMAT(now(), '%Y-%m-%d')
OR DATE_FORMAT(ZCCSSRQ, '%Y-%m-%d') < DATE_FORMAT(now(), '%Y-%m-%d')
DATE_FORMAT(SSRQ, '%Y-%m-%d') > DATE_FORMAT(now(), '%Y-%m-%d')
)
</delete>
@@ -85,55 +80,47 @@
<select id="getWarningDate" resultType="com.adc.da.slrs.sarStandWarning.entity.WarningDate">
SELECT
lawId,
itemId,
timeName,
DATE_FORMAT(SSRQ, '%Y-%m-%d') AS SSRQ
FROM
(
select attr.STAND_ID as lawId,'-1' as itemId,'SSRQ' as timeName,
substring_index(substring_index(attr.SSRQ,',',b.help_topic_id+1),',',-1) SSRQ
SSRQ as SSRQ
from sar_stand_attr_info attr
join mysql.help_topic b
on b.help_topic_id &gt; (length(attr.SSRQ) - length(replace(attr.SSRQ,',',''))+1)
WHERE
SSRQ REGEXP #{termStr}
UNION ALL
select attr.STAND_ID as lawId,'-1' as itemId,'XCXSSRQ' as timeName,
substring_index(substring_index(attr.SSRQ,',',b.help_topic_id+1),',',-1) SSRQ
XCXSSRQ as SSRQ
from sar_stand_attr_info attr
join mysql.help_topic b
on b.help_topic_id &gt; (length(attr.XCXSSRQ) - length(replace(attr.XCXSSRQ,',',''))+1)
WHERE
XCXSSRQ REGEXP #{termStr}
UNION ALL
select attr.STAND_ID as lawId,'-1' as itemId,'ZCCSSRQ' as timeName,
substring_index(substring_index(attr.ZCCSSRQ,',',b.help_topic_id+1),',',-1) SSRQ
ZCCSSRQ as SSRQ
from sar_stand_attr_info attr
join mysql.help_topic b
on b.help_topic_id &gt; (length(attr.SSRQ) - length(replace(attr.ZCCSSRQ,',',''))+1)
WHERE
ZCCSSRQ REGEXP #{termStr}
UNION All
select item.STAND_ID as lawId,item.ID as itemId,'ZCCSSRQ' as timeName,
substring_index(substring_index(item.ZCCSSRQ,',',b.help_topic_id+1),',',-1) SSRQ
ZCCSSRQ as SSRQ
from sar_stand_items item
join mysql.help_topic b
on b.help_topic_id &gt; (length(item.ZCCSSRQ) - length(replace(item.ZCCSSRQ,',',''))+1)
WHERE
ZCCSSRQ REGEXP #{termStr}
UNION All
select item.STAND_ID as lawId,item.ID as itemId,'XCXSSRQ' as timeName,
substring_index(substring_index(item.XCXSSRQ,',',b.help_topic_id+1),',',-1) SSRQ
XCXSSRQ as SSRQ
from sar_stand_items item
join mysql.help_topic b
on b.help_topic_id &gt; (length(item.XCXSSRQ) - length(replace(item.XCXSSRQ,',',''))+1)
WHERE
XCXSSRQ REGEXP #{termStr}
) as T
WHERE
DATE_FORMAT(T.SSRQ,'%Y-%m-%d') BETWEEN DATE_FORMAT(#{startDate}, '%Y-%m-%d') AND DATE_FORMAT(#{endDate}, '%Y-%m-%d')
</select>