<!--WHEN archive_other_ext_submitTime.str2 IS NOT NULL-->
<!--AND archive_other_ext_submitTime.str2 >= (select top 1 convert(varchar(19),eTime,120) eTime from archive_other_ext where sysFlag = 1 and jzh = temp.jzh order by eTime desc) THEN-->
<!--- 1-->
<!--ELSE-->
<!--statusFlag-->
<!--END-->
<!--ELSE-->
<!--CASE-->
<!--WHEN archive_other_ext_submitTime.str2 IS NOT NULL-->
WHEN archive_other_ext_submitTime.str2 IS NOT NULL
AND archive_other_ext_submitTime.str2 >= (select top 1 convert(varchar(19),eTime,120) eTime from archive_other_ext where sysFlag = 1 and jzh = archive_other_ext.jzh order by eTime desc) THEN
- 1
ELSE
statusFlag
END
ELSE
CASE
WHEN archive_other_ext_submitTime.str2 IS NOT NULL
AND archive_other_ext_submitTime.str2 >= CONVERT(varchar(19),eTime,120) THEN
- 1
ELSE
statusFlag
END
END
statusFlagSort
from
archive_other_ext
LEFT JOIN archive_other_ext_submitTime ON archive_other_ext_submitTime.other_ext_id=archive_other_ext.id
LEFT JOIN archive_detail ON archive_other_ext.DID = archive_detail.id
LEFT JOIN zd_assort ON archive_detail.AssortID = zd_assort.assort_id
<where>
<iftest="assortId != null and assortId != ''">
and zd_assort.assort_id = #{assortId,jdbcType=NVARCHAR}
</if>
<iftest="jzh != null and jzh != ''">
and archive_other_ext.jzh = #{jzh,jdbcType=NVARCHAR}
</if>
<iftest="c2 != null and c2 != ''">
and archive_other_ext.c2 = #{c2,jdbcType=NVARCHAR}
</if>
<iftest="statusflag != null">
and archive_other_ext.statusFlag = #{statusflag,jdbcType=INTEGER}
</if>
<iftest="sysflag != null">
and archive_other_ext.sysflag = #{sysflag,jdbcType=INTEGER}
</if>
</where>
order by case when archive_other_ext.sysFlag=15 then 1 else 2 end,statusFlagSort
WHEN archive_other_ext_submitTime.str2 IS NOT NULL
AND archive_other_ext_submitTime.str2 >= (select top 1 convert(varchar(19),eTime,120) eTime from archive_other_ext where sysFlag = 1 and jzh = archive_other_ext.jzh order by eTime desc) THEN
- 1
ELSE
statusFlag
END
ELSE
CASE
WHEN archive_other_ext_submitTime.str2 IS NOT NULL
AND archive_other_ext_submitTime.str2 >= CONVERT(varchar(19),eTime,120) THEN
- 1
ELSE
statusFlag
END
END
statusFlagSort
from
archive_other_ext
LEFT JOIN archive_other_ext_submitTime ON archive_other_ext_submitTime.other_ext_id=archive_other_ext.id
LEFT JOIN archive_detail ON archive_other_ext.DID = archive_detail.id
LEFT JOIN zd_assort ON archive_detail.AssortID = zd_assort.assort_id
<where>
<iftest="assortId != null and assortId != ''">
and zd_assort.assort_id = #{assortId,jdbcType=NVARCHAR}
</if>
<iftest="jzh != null and jzh != ''">
and archive_other_ext.jzh = #{jzh,jdbcType=NVARCHAR}
</if>
<iftest="c2 != null and c2 != ''">
and archive_other_ext.c2 = #{c2,jdbcType=NVARCHAR}
</if>
<iftest="statusflag != null">
and archive_other_ext.statusFlag = #{statusflag,jdbcType=INTEGER}
</if>
<iftest="sysflag != null">
and archive_other_ext.sysflag = #{sysflag,jdbcType=INTEGER}
</if>
</where>
order by case when archive_other_ext.sysFlag=1 then 1 else 2 end,statusFlagSort