<?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.smartor.mapper.PatMedOuthospErrorMapper">
|
|
<resultMap type="com.smartor.domain.PatMedOuthospError" id="PatMedOuthospErrorResult">
|
<result property="id" column="id"/>
|
<result property="serialnum" column="serialnum"/>
|
<result property="outhospno" column="outhospno"/>
|
<result property="patname" column="patname"/>
|
<result property="patno" column="patno"/>
|
<result property="campusid" column="campusid"/>
|
<result property="orgid" column="orgid"/>
|
<result property="admitdate" column="admitdate"/>
|
<result property="gatherDate" column="gather_date"/>
|
<result property="errorType" column="error_type"/>
|
<result property="errorMsg" column="error_msg"/>
|
<result property="rawData" column="raw_data"/>
|
<result property="failCount" column="fail_count"/>
|
<result property="handleStatus" column="handle_status"/>
|
<result property="handleRemark" column="handle_remark"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
</resultMap>
|
|
<sql id="selectPatMedOuthospErrorVo">
|
select id, serialnum, outhospno, patname, patno, campusid, orgid, admitdate, gather_date,
|
error_type, error_msg, raw_data, fail_count, handle_status, handle_remark, create_time, update_time
|
from pat_med_outhosp_error
|
</sql>
|
|
<!--
|
采集失败落表:serialnum 不为空时靠唯一索引 uk_serialnum_type(serialnum, error_type) 做 upsert,
|
避免每半小时一轮把同一条脏数据重复写进来;fail_count 累加可以看到它到底失败了多少轮。
|
已被人工标记"已处理"的记录如果再次失败,状态重新回到"待处理";"已忽略"的保持忽略不再打扰。
|
-->
|
<insert id="insertPatMedOuthospError" parameterType="com.smartor.domain.PatMedOuthospError"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into pat_med_outhosp_error
|
(serialnum, outhospno, patname, patno, campusid, orgid, admitdate, gather_date,
|
error_type, error_msg, raw_data, fail_count, handle_status, handle_remark, create_time, update_time)
|
values
|
(#{serialnum}, #{outhospno}, #{patname}, #{patno}, #{campusid}, #{orgid}, #{admitdate}, #{gatherDate},
|
#{errorType}, #{errorMsg}, #{rawData}, 1, #{handleStatus}, #{handleRemark}, now(), now())
|
<if test="serialnum != null and serialnum != ''">
|
on duplicate key update
|
error_msg = values(error_msg),
|
raw_data = values(raw_data),
|
admitdate = values(admitdate),
|
fail_count = fail_count + 1,
|
handle_status = case when handle_status = '1' then '0' else handle_status end,
|
update_time = now()
|
</if>
|
</insert>
|
|
<select id="selectPatMedOuthospErrorList" parameterType="com.smartor.domain.PatMedOuthospError"
|
resultMap="PatMedOuthospErrorResult">
|
<include refid="selectPatMedOuthospErrorVo"/>
|
<where>
|
<if test="serialnum != null and serialnum != ''">and serialnum = #{serialnum}</if>
|
<if test="errorType != null and errorType != ''">and error_type = #{errorType}</if>
|
<if test="gatherDate != null and gatherDate != ''">and gather_date = #{gatherDate}</if>
|
<if test="handleStatus != null and handleStatus != ''">and handle_status = #{handleStatus}</if>
|
</where>
|
order by id desc
|
</select>
|
|
<update id="updateHandleStatus" parameterType="com.smartor.domain.PatMedOuthospError">
|
update pat_med_outhosp_error
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="handleStatus != null and handleStatus != ''">handle_status = #{handleStatus},</if>
|
<if test="handleRemark != null">handle_remark = #{handleRemark},</if>
|
update_time = now(),
|
</trim>
|
where id = #{id}
|
</update>
|
|
</mapper>
|