<?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.modules.sg.picking.activiti.mapper.PickIngMapper">

    <sql id="classColumns">
		a.id AS "id",
		a.md_img AS "mdImg",
		a.md_big_class AS "mdBigClass",
		a.md_the_class AS "mdTheClass",
		a.md_small_class AS "mdSmallClass",
		a.md_unit AS "mdUnit"
	</sql>



    <select id="get" resultType="com.jeeplus.modules.sg.picking.activiti.entity.PickIng">
        SELECT
        <include refid="classColumns"/>,
		FROM md_module_block a
		WHERE a.id = #{id}
    </select>

    <select id="findList" resultType="com.jeeplus.modules.sg.picking.activiti.entity.PickIng">
        SELECT
        <include refid="classColumns"/>
        FROM md_module_block a
        <choose>
            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
                ORDER BY ${page.orderBy}
            </when>
        </choose>
    </select>

    <select id="findAllList" resultType="com.jeeplus.modules.sg.picking.activiti.entity.PickIng">
        SELECT
        <include refid="classColumns"/>
        FROM md_module_block a where md_version = #{version} order by md_big_sort,md_the_sort,md_small_sort
    </select>

    <insert id="insert">
		INSERT INTO md_acquisition_process(
			id,
			proc_ins_id,
			project_id,
			the_number,
			version,
			select_number,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			del_flag
		) VALUES (
			#{id},
			#{procInsId},
			#{projectId},
			#{theNumber},
			#{version},
			#{selectNumber},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{delFlag}
		)
	</insert>

    <update id="update">
		UPDATE md_acquisition_process SET
			proc_ins_id = #{procInsId},
			project_id = #{projectId},
			the_number = #{theNumber},
			version = #{version},
			select_number = #{selectNumber},
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks}
		WHERE id = #{id}
	</update>



    <!--物理删除-->
    <update id="delete">
		DELETE FROM md_module_block
		WHERE id = #{id}
	</update>

    <!--逻辑删除-->
    <update id="deleteByLogic">
		UPDATE md_module_block SET
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>

	<select id="allVersion" resultType="string">
		select md_version from md_module_block group by md_version desc;
	</select>

	<update id="updateSelectNumber">
		update md_acquisition_process set  select_number = #{selectNumber} where proc_ins_id=#{procInsId};
	</update>
	
	<select id="findSelectNumber" resultType="string">
		select select_number from md_acquisition_process where proc_ins_id=#{procInsId};
	</select>

	<select id="selectVersion" resultType="string">
		select version from md_acquisition_process where proc_ins_id = #{pprocInsId};
	</select>

	<select id="projectNumber" resultType="com.jeeplus.modules.sg.picking.activiti.entity.ProjectNumber">
		select require_name,the_number from md_acquisition_process as a,xm_project_details as b where a.project_id=b.id and proc_ins_id=#{pprocInsId}
	</select>

	<update id="updateSelectVersion">
				UPDATE sys_dict_value set `value` = #{version} where id = '1010101010'
	</update>
</mapper>