ProcessMapper.xml 8.55 KB
<?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.chinagas.modules.zjwjsb.mapper.ProcessMapper">
    <resultMap id="processResult" type="Process">
        <id property="processId" column="process_id"/>
        <result property="processTitle"  column="process_title"/>
        <result property="templateId"  column="template_id"/>
        <result property="companyId"  column="company_id"/>
        <result property="companyName"  column="company_name"/>
        <result property="uploadTime"  column="upload_time"/>
        <result property="remark"  column="remark"/>
        <result property="applicant"  column="applicant"/>
        <result property="applicantName" column="applicant_name"/>
        <result property="applicantAccount" column="applicant_account"/>
        <result property="deptId"  column="dept_id"/>
        <result property="deptName"  column="dept_name"/>
        <result property="status" column="status"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createTime"  column="create_time"/>
        <result property="headId" column="head_id"/>
        <association property="processTemplate" column="template_id" javaType="ProcessTemplate" select="com.chinagas.modules.zjwjsb.mapper.ProcessTemplateMapper.selectProcessTemplateById"/>
        <collection  property="attachmentList" column="process_id"   javaType="java.util.List"   ofType="Attachment" select="selectAttachmentByProcessId" />
    </resultMap>



    <sql id="selectProcessVo" >
        select
            p.process_id,
            p.process_title,
            p.template_id,
            p.company_name,
            p.company_id,
            p.upload_time,
            p.remark,
            p.applicant,
            p.applicant_name,
            p.applicant_account,
            p.dept_id,
            p.dept_name,
            p.status,
            p.head_id,
            p.create_time,
            p.create_by
        from zjwjsb_process p
        left join sys_user u on p.create_by = u.user_id
    </sql>

<!--    <sql id="selectNodeVo">-->
<!--        select n. from node n-->
<!--    </sql>-->

    <select id="selectAttachmentByProcessId" resultType="Attachment">
        select attachment_id,attachment_name,url,process_id,path,final_path,attachment_type from zjwjsb_attachment where process_id = #{processId}
    </select>

    <select id="getProcessType" parameterType="Long" resultType="ProcessType">
        select pty.type_id,pty.type_name from zjwjsb_process_template pt
        left join zjwjsb_process_type pty on pt.process_type = pty.type_id
        where pt.template_id = #{templateId}
    </select>

    <select id="ifProcessExist" resultType="int" parameterType="String">
        select count(1) from zjwjsb_process where process_id = #{processId}
    </select>

    <update id="updateProcess" parameterType="Process">
        update zjwjsb_process set
        <if test="processTitle != null and processTitle != ''">process_title = #{processTitle},</if>
        <if test="templateId != null and templateId!= ''">template_id = #{templateId},</if>
        <if test="companyName  != null and companyName  != ''">company_name = #{companyName}, </if>
        <if test="companyId  != null and companyId  != ''">company_id = #{companyId}, </if>
        <if test="uploadTime   != null and uploadTime   != ''">upload_time = #{uploadTime},  </if>
        <if test="remark       != null and remark       != ''">remark = #{remark},       </if>
        <if test="applicant    != null and applicant    != ''">applicant = #{applicant},    </if>
        <if test="applicantName    != null and applicantName    != ''">applicant_name = #{applicantName},    </if>
        <if test="applicantAccount    != null and applicantAccount    != ''">applicant_account = #{applicantAccount},    </if>
        <if test="deptId != null and deptId != ''">dept_id = #{deptId},</if>
        <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
        <if test="headId != null and headId != ''">head_id = #{headId},</if>
        <if test="status    != null and status    != ''">status = #{status},    </if>
        update_by = #{updateBy},
                                  update_time = sysdate()
        where process_id = #{processId}
    </update>


    <insert id="insertProcess" parameterType="Process">
        insert into zjwjsb_process(
        <if test="processId    != null and processId    != ''">process_id,   </if>
        <if test="processTitle != null and processTitle != ''">process_title,</if>
        <if test="templateId != null and templateId != ''">template_id,</if>
        <if test="companyName  != null and companyName  != ''">company_name, </if>
        <if test="companyId  != null and companyId  != ''">company_id, </if>
        <if test="uploadTime   != null and uploadTime   != ''">upload_time,  </if>
        <if test="remark       != null and remark       != ''">remark,       </if>
        <if test="applicant    != null and applicant    != ''">applicant,    </if>
        <if test="applicantName    != null and applicantName    != ''">applicant_name,    </if>
        <if test="applicantAccount    != null and applicantAccount    != ''">applicant_account,    </if>
        <if test="deptId != null and deptId != ''">dept_id,</if>
        <if test="deptName != null and deptName != ''">dept_name,</if>
        <if test="headId != null and headId != ''">head_id,</if>
        <if test="status    != null and status    != ''">status,    </if>
            create_by,
            create_time
        )  values(
        <if test="processId    != null and processId    != ''">#{processId   },</if>
        <if test="processTitle != null and processTitle != ''">#{processTitle},</if>
        <if test="templateId != null and templateId != ''">#{templateId},</if>
        <if test="companyName  != null and companyName  != ''">#{companyName },</if>
        <if test="companyId  != null and companyId  != ''">#{companyId}, </if>
        <if test="uploadTime   != null and uploadTime   != ''">#{uploadTime  },</if>
        <if test="remark       != null and remark       != ''">#{remark      },</if>
        <if test="applicant    != null and applicant    != ''">#{applicant   },</if>
        <if test="applicantName    != null and applicantName    != ''">#{applicantName},    </if>
        <if test="applicantAccount    != null and applicantAccount    != ''">#{applicantAccount},    </if>
        <if test="deptId != null and deptId != ''">#{deptId},</if>
        <if test="deptName != null and deptName != ''">#{deptName},</if>
        <if test="headId != null and headId != ''">#{headId},</if>
        <if test="status    != null and status    != ''">#{status},    </if>
        #{createBy},
        sysdate()
                         )
    </insert>

    <select id="selectProcessList" parameterType="Process" resultMap="processResult">
        <include refid="selectProcessVo"/>
        where p.del_flag = '0'
        <if test="headId != null and headId != ''">
            and p.head_id like concat('%',#{headId},'%')
        </if>
        <if test="processTitle != null and processTitle != ''">
            and p.process_title like concat('%',#{processTitle},'%')
        </if>
        <if test="companyName != null and companyName != ''">
            and p.company_name like concat('%',#{companyName},'%')
        </if>
        <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
            AND date_format(p.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
        </if>
        <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
            AND date_format(p.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
        </if>
        <if test="templateId != null and templateId != 0">
        AND (p.template_id = #{templateId} OR p.template_id IN ( SELECT t.template_id FROM zjwjsb_process_template t WHERE find_in_set(#{templateId}, ancestors) ))
        </if>
            ${params.dataScope}
            order by p.create_time desc
    </select>


    <update id="deleteProcessById" parameterType="String">
        update zjwjsb_process set del_flag = '1' where process_id = #{processId}
    </update>



    <update id="changeProcessStatusByHeadId" parameterType="Process">
        update zjwjsb_process set status = #{status} where head_id = #{headId}
    </update>

    <select id="selectProcessByHeadId" parameterType="String" resultMap="processResult">
        <include refid="selectProcessVo"/> where head_id = #{headId}
    </select>

</mapper>