525 lines
11 KiB
XML
525 lines
11 KiB
XML
<?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.hx.slj.modules.sys.dao.SysFileMagDao">
|
|
|
|
<sql id="sysFileMagColumns">
|
|
a.id AS "id",
|
|
a.create_by AS "createBy.id",
|
|
a.create_date AS "createDate",
|
|
a.update_by AS "updateBy.id",
|
|
a.update_date AS "updateDate",
|
|
a.remarks AS "remarks",
|
|
a.del_flag AS "delFlag",
|
|
a.file_cd AS "fileCd",
|
|
a.file_nm AS "fileNm",
|
|
a.file_type AS "fileType",
|
|
a.file_path AS "filePath",
|
|
a.file_ext AS "fileExt",
|
|
a.other_id AS "otherId",
|
|
a.check_reason AS "checkReason",
|
|
a.check_by AS "checkBy",
|
|
a.check_date AS "checkDate"
|
|
|
|
</sql>
|
|
|
|
<sql id="sysFileMagJoins">
|
|
</sql>
|
|
|
|
|
|
<select id="get" resultType="SysFileMag" >
|
|
SELECT
|
|
<include refid="sysFileMagColumns"/>
|
|
FROM file_management a
|
|
<include refid="sysFileMagJoins"/>
|
|
WHERE a.id = #{id}
|
|
</select>
|
|
<!--根据文件otherid和文件类型查询文件-->
|
|
<select id="findFileByOtherIdAndFType" resultType="SysFileMag" >
|
|
SELECT
|
|
<include refid="sysFileMagColumns"/>
|
|
FROM file_management a
|
|
WHERE a.other_id = #{otherId}
|
|
AND a.file_type=#{fileType}
|
|
</select>
|
|
<!--根据文件类型查询文件列表-->
|
|
<select id="findFileListByType" resultType="SysFileMag" >
|
|
SELECT
|
|
<include refid="sysFileMagColumns"/>
|
|
FROM file_management a
|
|
WHERE a.file_type=#{fileType}
|
|
</select>
|
|
<!--根据文件otherid查询文件列表-->
|
|
<select id="findListByOtherId" resultType="SysFileMag" >
|
|
SELECT
|
|
<include refid="sysFileMagColumns"/>
|
|
FROM file_management a
|
|
WHERE a.other_id = #{otherId}
|
|
</select>
|
|
|
|
<!-- 上传文件 -->
|
|
<insert id="upload">
|
|
INSERT INTO file_management(
|
|
id,
|
|
create_by,
|
|
create_date,
|
|
remarks,
|
|
del_flag,
|
|
file_cd,
|
|
file_nm,
|
|
file_type,
|
|
other_id,
|
|
ACTION_TYPE,
|
|
PROJECT_ID,
|
|
SECTIONID,
|
|
FILE_PATH,
|
|
FILE_EXT
|
|
) VALUES (
|
|
#{id},
|
|
#{createBy.id},
|
|
#{createDate},
|
|
#{remarks},
|
|
#{delFlag},
|
|
#{fileCd},
|
|
#{fileNm},
|
|
#{fileType},
|
|
#{otherId},
|
|
#{actionType},
|
|
#{projectId},
|
|
#{sectionId},
|
|
#{filePath},
|
|
#{fileExt}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 根据treeName id查询 name -->
|
|
<select id="fingTreeNameById" resultType="String">
|
|
SELECT a.name FROM DEVTREE a WHERE a.id=#{id}
|
|
</select>
|
|
|
|
|
|
<!-- 存档 -->
|
|
<update id="keepFile">
|
|
UPDATE file_management SET
|
|
UPDATE_BY = #{updateBy.id},
|
|
UPDATE_DATE = #{updateDate},
|
|
KEEPFILESTATUS = #{keepFileStatus},
|
|
KEEPFILETREEID = #{keeFileTreeId}
|
|
WHERE ID = #{id}
|
|
</update>
|
|
|
|
|
|
<!-- 查询档案整编文件列表 -->
|
|
<select id="findFileListByZtreef" resultType="SysFileMag">
|
|
|
|
SELECT
|
|
a.*,b.name AS userName,c.name AS treeName
|
|
FROM
|
|
file_management a,SYS_USER b,DEVTREE c
|
|
WHERE
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
AND
|
|
a.keepfiletreeid = #{otherId}
|
|
AND
|
|
a.create_by = b.id
|
|
AND
|
|
a.other_id = c.id
|
|
AND
|
|
a.project_id = #{projectId}
|
|
AND
|
|
a.sectionid =#{sectionId}
|
|
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.CREATE_DATE DESC
|
|
</otherwise>
|
|
</choose>
|
|
|
|
</select>
|
|
|
|
<!-- 取数据确认下面节点是否可用-->
|
|
<select id="nextIsUsableByFileSta" resultType="int">
|
|
select
|
|
count(*)
|
|
from
|
|
file_management a
|
|
where
|
|
a.DEL_FLAG = #{DEL_FLAG_NORMAL}
|
|
and
|
|
a.OTHER_ID IN
|
|
<foreach item="item" index="index" collection="otherIds" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
and
|
|
a.FILE_STATUS != #{fileStatus}
|
|
and
|
|
a.PROJECT_ID = #{projectId}
|
|
and
|
|
a.SECTIONID = #{sectionId}
|
|
</select>
|
|
|
|
|
|
<select id="nextIsUsableByUpload" resultType="int">
|
|
select
|
|
count(*)
|
|
from
|
|
file_management a
|
|
where
|
|
a.DEL_FLAG = #{DEL_FLAG_NORMAL}
|
|
and
|
|
a.OTHER_ID IN
|
|
|
|
<foreach item="item" index="index" collection="otherIds" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
|
|
and
|
|
a.PROJECT_ID = #{projectId}
|
|
and
|
|
a.SECTIONID = #{sectionId}
|
|
</select>
|
|
|
|
|
|
<!-- 查询文件列表 上传
|
|
精简版
|
|
-->
|
|
|
|
<select id="findFileListSimp" resultType="SysFileMag">
|
|
SELECT
|
|
a.*,
|
|
b.name AS userName,
|
|
c.name AS treeName
|
|
FROM
|
|
file_management a,
|
|
SYS_USER b,DEVTREE_SIMP c
|
|
WHERE
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
AND
|
|
A.OTHER_ID = #{otherId}
|
|
AND
|
|
a.file_type = #{fileType}
|
|
AND
|
|
a.action_type = #{actionType}
|
|
AND
|
|
a.create_by = b.id
|
|
AND
|
|
a.other_id = c.id
|
|
AND
|
|
a.project_id = #{projectId}
|
|
AND
|
|
a.sectionid = #{sectionId}
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.CREATE_DATE DESC
|
|
</otherwise>
|
|
</choose>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="findFileList" resultType="SysFileMag">
|
|
SELECT
|
|
a.*,
|
|
b.name AS userName,
|
|
c.name AS treeName
|
|
FROM
|
|
file_management a,
|
|
SYS_USER b,DEVTREE c
|
|
WHERE
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
AND
|
|
A.OTHER_ID = #{otherId}
|
|
AND
|
|
a.file_type = #{fileType}
|
|
AND
|
|
a.action_type = #{actionType}
|
|
AND
|
|
a.create_by = b.id
|
|
AND
|
|
a.other_id = c.id
|
|
AND
|
|
a.project_id = #{projectId}
|
|
AND
|
|
a.sectionid = #{sectionId}
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.CREATE_DATE DESC
|
|
</otherwise>
|
|
</choose>
|
|
|
|
</select>
|
|
|
|
|
|
<!-- 查询文件列表 审核-->
|
|
<select id="findFileListSimp_review" resultType="SysFileMag">
|
|
SELECT
|
|
a.*,
|
|
b.name AS userName,
|
|
c.name AS treeName
|
|
FROM
|
|
file_management a,
|
|
SYS_USER b,
|
|
devtree_simp c
|
|
WHERE
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
AND
|
|
a.create_by = b.id
|
|
AND
|
|
a.project_id = #{projectId}
|
|
AND
|
|
a.sectionid = #{sectionId}
|
|
<choose>
|
|
<when test="actionRoletype !=null and actionRoletype == 3">
|
|
AND
|
|
a.KEEPFILETREEID = c.id
|
|
AND
|
|
c.id = #{keeFileTreeId}
|
|
</when>
|
|
<otherwise>
|
|
AND
|
|
a.other_id = c.id
|
|
AND
|
|
c.id = #{otherId}
|
|
</otherwise>
|
|
</choose>
|
|
<if test="actionRoletype !=null and actionRoletype == 1">
|
|
and
|
|
a.file_type = #{fileType}
|
|
</if>
|
|
<if test="actionRoletype !=null and actionRoletype == 2">
|
|
and
|
|
a.file_type != #{fileType}
|
|
</if>
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.CREATE_DATE DESC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
|
|
<!-- 查询文件列表 审核-->
|
|
<select id="findFileList_review" resultType="SysFileMag">
|
|
SELECT
|
|
a.*,
|
|
b.name AS userName,
|
|
c.name AS treeName
|
|
FROM
|
|
file_management a,
|
|
SYS_USER b,
|
|
DEVTREE c
|
|
WHERE
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
AND
|
|
a.create_by = b.id
|
|
AND
|
|
a.other_id = c.id
|
|
AND
|
|
a.project_id = #{projectId}
|
|
AND
|
|
a.sectionid = #{sectionId}
|
|
AND
|
|
c.id = #{otherId}
|
|
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.CREATE_DATE DESC
|
|
</otherwise>
|
|
</choose>
|
|
|
|
</select>
|
|
|
|
<select id="findList" resultType="SysFileMag" >
|
|
SELECT
|
|
<include refid="sysFileMagColumns"/>
|
|
FROM file_management a
|
|
<include refid="sysFileMagJoins"/>
|
|
<where>
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
<if test="fileCd != null and fileCd != ''">
|
|
AND a.file_cd LIKE
|
|
<if test="dbName == 'oracle'">'%'||#{fileCd}||'%'</if>
|
|
<if test="dbName == 'mssql'">'%'+#{fileCd}+'%'</if>
|
|
<if test="dbName == 'mysql'">concat('%',#{fileCd},'%')</if>
|
|
</if>
|
|
<if test="fileNm != null and fileNm != ''">
|
|
AND a.file_nm LIKE
|
|
<if test="dbName == 'oracle'">'%'||#{fileNm}||'%'</if>
|
|
<if test="dbName == 'mssql'">'%'+#{fileNm}+'%'</if>
|
|
<if test="dbName == 'mysql'">concat('%',#{fileNm},'%')</if>
|
|
</if>
|
|
<if test="fileType != null and fileType != ''">
|
|
AND a.file_type = #{fileType}
|
|
</if>
|
|
</where>
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.update_date DESC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<select id="findAllList" resultType="SysFileMag" >
|
|
SELECT
|
|
<include refid="sysFileMagColumns"/>
|
|
FROM file_management a
|
|
<include refid="sysFileMagJoins"/>
|
|
<where>
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
</where>
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.update_date DESC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<insert id="insert">
|
|
INSERT INTO file_management(
|
|
id,
|
|
create_by,
|
|
create_date,
|
|
update_by,
|
|
update_date,
|
|
remarks,
|
|
del_flag,
|
|
file_cd,
|
|
file_nm,
|
|
file_type,
|
|
file_path,
|
|
file_ext,
|
|
other_id
|
|
) VALUES (
|
|
#{id},
|
|
#{createBy.id},
|
|
#{createDate},
|
|
#{updateBy.id},
|
|
#{updateDate},
|
|
#{remarks},
|
|
#{delFlag},
|
|
#{fileCd},
|
|
#{fileNm},
|
|
#{fileType},
|
|
#{filePath},
|
|
#{fileExt},
|
|
#{otherId}
|
|
)
|
|
</insert>
|
|
|
|
<insert id="insertFile">
|
|
INSERT INTO file_management(
|
|
id,
|
|
create_by,
|
|
create_date,
|
|
update_by,
|
|
update_date,
|
|
remarks,
|
|
del_flag,
|
|
file_cd,
|
|
file_nm,
|
|
file_type,
|
|
file_path,
|
|
file_ext,
|
|
other_id,
|
|
project_id,
|
|
sectionid,
|
|
CHECK_BY,<!--审核人 -->
|
|
CHECK_DATE,<!-- 审核时间 -->
|
|
FILE_STATUS,<!-- 文件状态 -->
|
|
CHECK_REASON<!--审查意见 -->
|
|
) VALUES (
|
|
#{id},
|
|
#{createBy.id},
|
|
#{createDate},
|
|
#{updateBy.id},
|
|
#{updateDate},
|
|
#{remarks},
|
|
#{delFlag},
|
|
#{fileCd},
|
|
#{fileNm},
|
|
#{fileType},
|
|
#{filePath},
|
|
#{fileExt},
|
|
#{otherId},
|
|
#{projectId},
|
|
#{sectionId},
|
|
#{checkBy},<!--审核人 -->
|
|
#{checkDate},<!-- 审核时间 -->
|
|
#{fileStatus},<!-- 文件状态 -->
|
|
#{checkReason}<!--审查意见 -->
|
|
)
|
|
</insert>
|
|
|
|
<update id="update">
|
|
UPDATE file_management SET
|
|
update_by = #{updateBy.id},
|
|
update_date = #{updateDate},
|
|
remarks = #{remarks},
|
|
file_cd = #{fileCd},
|
|
file_nm = #{fileNm},
|
|
file_type = #{fileType},
|
|
file_path = #{filePath},
|
|
file_ext = #{fileExt},
|
|
other_id = #{otherId}
|
|
WHERE id = #{id}
|
|
</update>
|
|
<update id="check">
|
|
UPDATE file_management SET
|
|
CHECK_BY = #{checkBy},<!--审核人 -->
|
|
CHECK_DATE =#{checkDate},<!-- 审核时间 -->
|
|
FILE_STATUS =#{fileStatus},<!-- 文件状态 -->
|
|
CHECK_REASON=#{checkReason}<!--审查意见 -->
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
|
|
<!--物理删除-->
|
|
<update id="delete">
|
|
DELETE FROM file_management
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<!--逻辑删除-->
|
|
<update id="deleteByLogic">
|
|
UPDATE file_management SET
|
|
del_flag = #{DEL_FLAG_DELETE}
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
|
|
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
|
|
<select id="findUniqueByProperty" resultType="SysFileMag" statementType="STATEMENT">
|
|
select * FROM file_management where ${propertyName} = '${value}'
|
|
</select>
|
|
<!--首页 文件下载-->
|
|
<select id="findNewFile" resultType="SysFileMag">
|
|
select t.*
|
|
from FILE_MANAGEMENT t
|
|
where t.file_type in ('1', '2', '3', '4', '5')
|
|
order by t.create_date desc
|
|
</select>
|
|
|
|
|
|
</mapper> |