<?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.jeeplus.business.project.mapper.JyProjectOutinstanceMapper">
    <select id="findById" resultType="com.jeeplus.business.project.service.dto.JyProjectOutinstanceDTO">
        select
            id,
            project_id,
            status,
            remarks,
            proc_ins_id,
            process_definition_id
        from jy_project_outinstance
        where id=#{id}
    </select>

    <select id="findDtos" resultType="com.jeeplus.sys.service.dto.WorkAttachmentInfoDTO">
        select
            wa.id,
			wa.url,
			wa.attachment_name AS `name`,
			wa.create_by_id AS `by`,
			wa.create_time,
			jy_pof.file_type as jyFileType
		from
		    work_attachment wa
		left join jy_project_out_instance_file jy_pof on wa.id = jy_pof.work_attachment_id
		where
		    wa.del_flag = 0
			AND wa.attachment_id = #{id}
    </select>


    <select id="findByProjectId" resultType="com.jeeplus.business.project.domain.JyProjectOutinstance">
        select
            id,
            project_id,
            status,
            remarks,
            proc_ins_id,
            exceed_time_status,
            process_definition_id
        from jy_project_outinstance
        where project_id=#{projectId}
    </select>


    <update id="updateOutInstanceStatus">
        update jy_project_outinstance set status=#{status},exceed_time_status=#{exceedTimeStatus} where id=#{id}
    </update>

    <select id="getFileListByAttachmentAndModuleType" resultType="com.jeeplus.sys.service.dto.WorkAttachmentInfoDTO">
        select
            wa.id,
			wa.url,
			wa.attachment_name AS `name`,
			wa.create_by_id AS `createBy.id`,
			su.name AS `createBy.name`,
			wa.create_time,
            wa.type as "type",
            wa.attachment_id as "attachmentId",
            wa.attachment_name as "attachmentName",
            wa.attachment_flag as "attachmentFlag",
            wa.module_type as "moduleType",
            wa.attachment_type as "attachmentType",
            wa.file_size as "fileSize",
            wa.sort as "sort",
            wa.description as "description"
		from
		    work_attachment wa
		left join sys_user su on su.id = wa.create_by_id
		<where>
            wa.del_flag = 0
            AND wa.attachment_id = #{attachmentId}
            AND wa.module_type = #{moduleType}
        </where>
    </select>






</mapper>