liusheng
3 天以前 1e1814178edf84090b28492bbad340ab13e5c169
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -170,6 +170,7 @@
               leavehospitaldistrictname,
               leavediagname,
               leaveicd10code,
               orgid,
               visit_type
        from service_subtask
    </sql>
@@ -187,7 +188,9 @@
            <if test="leavehospitaldistrictname != null  and leavehospitaldistrictname != ''">and
                leavehospitaldistrictname = #{leavehospitaldistrictname}
            </if>
            <if test="leavediagname != null  and leavediagname != ''">and leavediagname like concat('%', #{leavediagname}, '%')</if>
            <if test="leavediagname != null  and leavediagname != ''">and leavediagname like concat('%',
                #{leavediagname}, '%')
            </if>
            <if test="sex != null  and sex != ''">and sex = #{sex}</if>
            <if test="age != null ">and age = #{age}</if>
            <if test="patguid != null ">and patguid = #{patguid}</if>
@@ -410,6 +413,63 @@
                 JOIN service_subtask b on a.taskid = b.taskid and a.pat_cycle = 0 and b.del_flag = 0
        where b.taskid = #{taskid}
          and b.patid = #{patid}
    </select>
    <select id="selectTimelyRate" parameterType="com.smartor.domain.ServiceSubtask" resultType="double">
        SELECT sum( a.finished )/ sum( 1 ) FROM
        (SELECT id, visit_time, finishtime,
        (CASE WHEN ( DATE_FORMAT( visit_time, '%y%m%d' )&lt; DATE_FORMAT( IF ( ISNULL( finishtime ), NOW(), finishtime
        ), '%y%m%d' ) )
        THEN 1 ELSE 0 END ) finished,1 AS tasknumber FROM service_subtask
        WHERE del_flag=0
        <if test="starttime == null and endtime==null">
            AND visit_time &lt; NOW()
        </if>
        <if test="starttime != null and endtime!=null">
            AND date_format(visit_time,'%y%m%d') >= date_format(#{starttime},'%y%m%d')
            AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endtime},'%y%m%d')
        </if>
        <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
        <if test="deptcode != null  and deptcode != ''">and deptcode = #{deptcode}</if>
        <if test="deptname != null  and deptname != ''">and deptname = #{deptname}</if>
        <if test="leavehospitaldistrictcode != null  and leavehospitaldistrictcode != ''">and
            leavehospitaldistrictcode = #{leavehospitaldistrictcode}
        </if>
        <if test="leavehospitaldistrictname != null  and leavehospitaldistrictname != ''">and
            leavehospitaldistrictname = #{leavehospitaldistrictname}
        </if>
        ) a
    </select>
    <select id="selectTimelyRateDetail" parameterType="com.smartor.domain.ServiceSubtask"
            resultMap="ServiceSubtaskResult">
        <include refid="selectServiceSubtaskVo"/>
        <where>
            id in (
            SELECT id FROM
            (SELECT id, visit_time, finishtime,
            (CASE WHEN ( DATE_FORMAT( visit_time, '%y%m%d' ) &lt; DATE_FORMAT( IF ( ISNULL( finishtime ), NOW(),
            finishtime
            ), '%y%m%d' ) )
            THEN 1 ELSE 0 END ) finished,1 AS tasknumber FROM service_subtask
            WHERE del_flag=0
            -- AND visit_time &lt; NOW()
            <if test="starttime != null and endtime!=null">
                AND date_format(visit_time,'%y%m%d') >= date_format(#{starttime},'%y%m%d')
                AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endtime},'%y%m%d')
            </if>
            <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
            <if test="deptcode != null  and deptcode != ''">and deptcode = #{deptcode}</if>
            <if test="deptname != null  and deptname != ''">and deptname = #{deptname}</if>
            <if test="leavehospitaldistrictcode != null  and leavehospitaldistrictcode != ''">and
                leavehospitaldistrictcode = #{leavehospitaldistrictcode}
            </if>
            <if test="leavehospitaldistrictname != null  and leavehospitaldistrictname != ''">and
                leavehospitaldistrictname = #{leavehospitaldistrictname}
            </if>
            ) a where a.finished =1)
        </where>
    </select>
    <select id="selectServiceSubtaskById" parameterType="Long" resultMap="ServiceSubtaskResult">
@@ -977,8 +1037,8 @@
                </foreach>
            </if>
            <if test="startTime != null and endTime!=null">
                AND endtime > #{startTime}
                AND endtime &lt;= #{endTime}
                AND date_format(visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
                AND date_format(visit_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
            </if>
            <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if>
            <if test="visitDeptName != null">abd visit_dept_name = #{visitDeptName}</if>