You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.3 KiB

3 months ago
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.swlscx.year.mapper.HyDmxpFMapper">
<select id="selecthyDmxpFPageByInfo" resultType="com.ruoyi.swlscx.year.domain.vo.HyDmxpFVo">
select hme.stcd, hme.yr, hme.bgdt, hme.mxpdr, hme.mxp, hme.mxprc,
hsa.addvcd, hsa.stnm
from hy_dmxp_f hme
left join hy_stsc_a hsa on hme.stcd = hsa.stcd
<where>
<trim prefixOverrides="and">
<if test="map.stnm != null and map.stnm != ''">
and hsa.stnm like concat('%',#{map.stnm},'%')
</if>
<if test="map.stcd != null and map.stcd.size >0">
and hme.stcd in
<foreach collection="map.stcd" item="stcd" separator="," open="(" close=")">
#{stcd}
</foreach>
3 months ago
</if>
<if test="map.startTime != null and map.startTime != ''">
and hme.yr >= #{map.startTime}
</if>
<if test="map.endTime != null and map.endTime != ''">
and hme.yr &lt;= #{map.endTime}
</if>
</trim>
</where>
order by hme.yr
</select>
<delete id="deleteTempData" >
TRUNCATE TABLE hy_dmxp_f_temp;
</delete>
<insert id="insertTempData" parameterType="list">
insert into hy_dmxp_f_temp (stcd, mxpdr, yr, bgdt, mxp, mxprc)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.stcd}, #{item.mxpdr}, #{item.yr}, #{item.bgdt,jdbcType=TIMESTAMP}, #{item.mxp}, #{item.mxprc})
</foreach>
</insert>
<update id="mergeToData">
MERGE INTO hy_dmxp_f AS a
USING hy_dmxp_f_temp AS temp
ON (a.stcd = temp.stcd AND a.yr = temp.yr AND a.mxpdr = temp.mxpdr)
WHEN MATCHED THEN
UPDATE SET
a.bgdt = temp.bgdt, a.mxp = temp.mxp, a.mxprc = temp.mxprc
WHEN NOT MATCHED THEN
INSERT (stcd, mxpdr, yr, bgdt, mxp,mxprc)
VALUES (temp.stcd, temp.mxpdr, temp.yr, temp.bgdt, temp.mxp, temp.mxprc);
</update>
</mapper>