|
@@ -0,0 +1,382 @@
|
|
|
+<?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.zkqy.business.mapper.RequisitionOrdersMapper">
|
|
|
+
|
|
|
+ <resultMap type="com.zkqy.business.domain.RequisitionOrders" id="RequisitionOrdersResult">
|
|
|
+ <result property="id" column="id"/>
|
|
|
+ <result property="taskCode" column="task_code"/>
|
|
|
+ <result property="requisitionNumber" column="requisition_number"/>
|
|
|
+ <result property="saleOrderNo" column="sale_order_no"/>
|
|
|
+ <result property="requisitionDate" column="requisition_date"/>
|
|
|
+ <result property="state" column="state"/>
|
|
|
+ <result property="remark" column="remark"/>
|
|
|
+ <result property="createById" column="create_by_id"/>
|
|
|
+ <result property="createBy" column="create_by"/>
|
|
|
+ <result property="createTime" column="create_time"/>
|
|
|
+ <result property="updateById" column="update_by_id"/>
|
|
|
+ <result property="updateBy" column="update_by"/>
|
|
|
+ <result property="updateTime" column="update_time"/>
|
|
|
+ <result property="delFlag" column="del_flag"/>
|
|
|
+ <result property="dataApprovalStatus" column="data_approval_status"/>
|
|
|
+ <result property="processKey" column="process_key"/>
|
|
|
+ <result property="taskProcessKey" column="task_process_key"/>
|
|
|
+ <result property="taskNodeKey" column="task_node_key"/>
|
|
|
+ <result property="requistionOrdersType" column="requistion_orders_type"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <resultMap id="RequisitionOrdersRequisitionItemsResult" type="com.zkqy.business.domain.RequisitionOrders"
|
|
|
+ extends="RequisitionOrdersResult">
|
|
|
+ <collection property="requisitionItemsList" notNullColumn="sub_id" javaType="java.util.List"
|
|
|
+ resultMap="RequisitionItemsResult" fetchType="eager"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <resultMap type="com.zkqy.business.domain.RequisitionItems" id="RequisitionItemsResult">
|
|
|
+ <result property="id" column="sub_id"/>
|
|
|
+ <result property="requisitionCode" column="sub_requisition_code"/>
|
|
|
+ <result property="materialId" column="sub_material_id"/>
|
|
|
+ <result property="quantity" column="sub_quantity"/>
|
|
|
+ <result property="actualQuantity" column="sub_actual_quantity"/>
|
|
|
+ <result property="state" column="sub_state"/>
|
|
|
+ <result property="specifications" column="sub_specifications"/>
|
|
|
+ <result property="colorCode" column="sub_color_code"/>
|
|
|
+ <result property="remark" column="sub_remark"/>
|
|
|
+ <result property="createById" column="sub_create_by_id"/>
|
|
|
+ <result property="createBy" column="sub_create_by"/>
|
|
|
+ <result property="createTime" column="sub_create_time"/>
|
|
|
+ <result property="updateById" column="sub_update_by_id"/>
|
|
|
+ <result property="updateBy" column="sub_update_by"/>
|
|
|
+ <result property="updateTime" column="sub_update_time"/>
|
|
|
+ <result property="delFlag" column="sub_del_flag"/>
|
|
|
+ <result property="dataApprovalStatus" column="sub_data_approval_status"/>
|
|
|
+ <result property="processKey" column="sub_process_key"/>
|
|
|
+ <result property="taskProcessKey" column="sub_task_process_key"/>
|
|
|
+ <result property="taskNodeKey" column="sub_task_node_key"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="selectRequisitionOrdersVo">
|
|
|
+ select id,
|
|
|
+ task_code,
|
|
|
+ requisition_number,
|
|
|
+ sale_order_no,
|
|
|
+ requisition_date,
|
|
|
+ state,
|
|
|
+ remark,
|
|
|
+ create_by_id,
|
|
|
+ create_by,
|
|
|
+ create_time,
|
|
|
+ update_by_id,
|
|
|
+ update_by,
|
|
|
+ update_time,
|
|
|
+ del_flag,
|
|
|
+ data_approval_status,
|
|
|
+ process_key,
|
|
|
+ task_process_key,
|
|
|
+ task_node_key,
|
|
|
+ requistion_orders_type
|
|
|
+ from {DBNAME}.requisition_orders
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <sql id="selectRequisitionOrdersVoAndItems">
|
|
|
+ select a.id,
|
|
|
+ a.task_code,
|
|
|
+ a.requisition_number,
|
|
|
+ a.sale_order_no,
|
|
|
+ a.requisition_date,
|
|
|
+ a.state,
|
|
|
+ a.remark,
|
|
|
+ a.create_by_id,
|
|
|
+ a.create_by,
|
|
|
+ a.create_time,
|
|
|
+ a.update_by_id,
|
|
|
+ a.update_by,
|
|
|
+ a.update_time,
|
|
|
+ a.del_flag,
|
|
|
+ a.data_approval_status,
|
|
|
+ a.process_key,
|
|
|
+ a.task_process_key,
|
|
|
+ a.task_node_key,
|
|
|
+ a.requistion_orders_type,
|
|
|
+ b.id as sub_id,
|
|
|
+ b.requisition_code as sub_requisition_code,
|
|
|
+ b.material_id as sub_material_id,
|
|
|
+ b.quantity as sub_quantity,
|
|
|
+ b.actual_quantity as sub_actual_quantity,
|
|
|
+ b.state as sub_state,
|
|
|
+ b.specifications as sub_specifications,
|
|
|
+ b.color_code as sub_color_code,
|
|
|
+ b.remark as sub_remark,
|
|
|
+ b.create_by_id as sub_create_by_id,
|
|
|
+ b.create_by as sub_create_by,
|
|
|
+ b.create_time as sub_create_time,
|
|
|
+ b.update_by_id as sub_update_by_id,
|
|
|
+ b.update_by as sub_update_by,
|
|
|
+ b.update_time as sub_update_time,
|
|
|
+ b.del_flag as sub_del_flag,
|
|
|
+ b.data_approval_status as sub_data_approval_status,
|
|
|
+ b.process_key as sub_process_key,
|
|
|
+ b.task_process_key as sub_task_process_key,
|
|
|
+ b.task_node_key as sub_task_node_key
|
|
|
+ from {DBNAME}.requisition_orders a
|
|
|
+ left join {DBNAME}.requisition_items b
|
|
|
+ on b.requisition_code = a.id
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectRequisitionOrdersList" parameterType="com.zkqy.business.domain.RequisitionOrders"
|
|
|
+ resultMap="RequisitionOrdersResult">
|
|
|
+ <include refid="selectRequisitionOrdersVo"/>
|
|
|
+ <where>
|
|
|
+ and del_flag = '0'
|
|
|
+ <if test="taskCode != null and taskCode != ''">and task_code = #{taskCode}</if>
|
|
|
+ <if test="requistionOrdersType != null ">and requistion_orders_type =
|
|
|
+ #{requistionOrdersType}
|
|
|
+ </if>
|
|
|
+ <if test="requisitionNumber != null and requisitionNumber != ''">and requisition_number =
|
|
|
+ #{requisitionNumber}
|
|
|
+ </if>
|
|
|
+ <if test="saleOrderNo != null and saleOrderNo != ''">and sale_order_no = #{saleOrderNo}</if>
|
|
|
+ <if test="requisitionDate != null ">and requisition_date = #{requisitionDate}</if>
|
|
|
+ <if test="state != null and state != ''">and state = #{state}</if>
|
|
|
+ <if test="createById != null ">and create_by_id = #{createById}</if>
|
|
|
+ <if test="updateById != null ">and update_by_id = #{updateById}</if>
|
|
|
+ <if test="dataApprovalStatus == 7 or dataApprovalStatus == '7'">
|
|
|
+ and
|
|
|
+ FIND_IN_SET('1', data_approval_status) > 0 OR
|
|
|
+ FIND_IN_SET('2', data_approval_status) > 0 OR
|
|
|
+ FIND_IN_SET('3', data_approval_status) > 0 OR
|
|
|
+ FIND_IN_SET('4', data_approval_status) > 0 OR
|
|
|
+ FIND_IN_SET('5', data_approval_status) > 0
|
|
|
+ </if>
|
|
|
+ <if test="dataApprovalStatus != null and dataApprovalStatus != '' and dataApprovalStatus != 7 and dataApprovalStatus != '7'">
|
|
|
+ and data_approval_status = #{dataApprovalStatus}
|
|
|
+ </if>
|
|
|
+ <if test="processKey != null and processKey != ''">and process_key = #{processKey}</if>
|
|
|
+ <if test="taskProcessKey != null and taskProcessKey != ''">and task_process_key = #{taskProcessKey}</if>
|
|
|
+ <if test="taskNodeKey != null and taskNodeKey != ''">and task_node_key = #{taskNodeKey}</if>
|
|
|
+ </where>
|
|
|
+ order by id desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="selectRequisitionOrdersById" parameterType="Long" resultMap="RequisitionOrdersRequisitionItemsResult">
|
|
|
+ <include refid="selectRequisitionOrdersVoAndItems"/>
|
|
|
+ where a.id = #{id} and a.del_flag = '0' and b.del_flag = '0'
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- b.quantity as sub_quantity,-->
|
|
|
+ <!-- sum(b.actual_quantity) as sub_actual_quantity,-->
|
|
|
+ <select id="selectRequisitionOrdersByTaskCode" parameterType="String"
|
|
|
+ resultMap="RequisitionOrdersRequisitionItemsResult">
|
|
|
+ select a.task_code,
|
|
|
+ a.sale_order_no,
|
|
|
+ a.del_flag,
|
|
|
+ a.requistion_orders_type,
|
|
|
+ b.id as sub_id,
|
|
|
+ b.requisition_code as sub_requisition_code,
|
|
|
+ b.material_id as sub_material_id,
|
|
|
+ sum(b.actual_quantity) as sub_quantity,
|
|
|
+ b.state as sub_state,
|
|
|
+ b.specifications as sub_specifications,
|
|
|
+ b.color_code as sub_color_code,
|
|
|
+ b.remark as sub_remark,
|
|
|
+ b.create_by_id as sub_create_by_id,
|
|
|
+ b.create_by as sub_create_by,
|
|
|
+ b.create_time as sub_create_time,
|
|
|
+ b.update_by_id as sub_update_by_id,
|
|
|
+ b.update_by as sub_update_by,
|
|
|
+ b.update_time as sub_update_time,
|
|
|
+ b.del_flag as sub_del_flag,
|
|
|
+ b.data_approval_status as sub_data_approval_status,
|
|
|
+ b.process_key as sub_process_key,
|
|
|
+ b.task_process_key as sub_task_process_key,
|
|
|
+ b.task_node_key as sub_task_node_key
|
|
|
+ from {DBNAME}.requisition_orders a
|
|
|
+ left join {DBNAME}.requisition_items b
|
|
|
+ on b.requisition_code = a.id
|
|
|
+ where a.task_code = #{taskCode}
|
|
|
+ and a.del_flag = '0'
|
|
|
+ and b.del_flag = '0'
|
|
|
+ and a.requistion_orders_type = 0
|
|
|
+ and a.state = 5
|
|
|
+ group by
|
|
|
+ b.material_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectRequisitionOrdersByTaskCode1" parameterType="String"
|
|
|
+ resultMap="RequisitionOrdersRequisitionItemsResult">
|
|
|
+ select a.task_code,
|
|
|
+ a.sale_order_no,
|
|
|
+ a.del_flag,
|
|
|
+ a.requistion_orders_type,
|
|
|
+ b.id as sub_id,
|
|
|
+ b.requisition_code as sub_requisition_code,
|
|
|
+ b.material_id as sub_material_id,
|
|
|
+ sum(b.actual_quantity) as sub_quantity,
|
|
|
+ b.state as sub_state,
|
|
|
+ b.specifications as sub_specifications,
|
|
|
+ b.color_code as sub_color_code,
|
|
|
+ b.remark as sub_remark,
|
|
|
+ b.create_by_id as sub_create_by_id,
|
|
|
+ b.create_by as sub_create_by,
|
|
|
+ b.create_time as sub_create_time,
|
|
|
+ b.update_by_id as sub_update_by_id,
|
|
|
+ b.update_by as sub_update_by,
|
|
|
+ b.update_time as sub_update_time,
|
|
|
+ b.del_flag as sub_del_flag,
|
|
|
+ b.data_approval_status as sub_data_approval_status,
|
|
|
+ b.process_key as sub_process_key,
|
|
|
+ b.task_process_key as sub_task_process_key,
|
|
|
+ b.task_node_key as sub_task_node_key
|
|
|
+ from {DBNAME}.requisition_orders a
|
|
|
+ left join {DBNAME}.requisition_items b
|
|
|
+ on b.requisition_code = a.id
|
|
|
+ where a.task_code = #{taskCode}
|
|
|
+ and a.del_flag = '0'
|
|
|
+ and b.del_flag = '0'
|
|
|
+ and a.requistion_orders_type = 1
|
|
|
+ and a.state = 2
|
|
|
+ group by
|
|
|
+ b.material_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertRequisitionOrders" parameterType="com.zkqy.business.domain.RequisitionOrders"
|
|
|
+ useGeneratedKeys="true" keyProperty="id">
|
|
|
+ insert into {DBNAME}.requisition_orders
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="taskCode != null">task_code,</if>
|
|
|
+ <if test="requisitionNumber != null">requisition_number,</if>
|
|
|
+ <if test="saleOrderNo != null">sale_order_no,</if>
|
|
|
+ <if test="requisitionDate != null">requisition_date,</if>
|
|
|
+ <if test="state != null">state,</if>
|
|
|
+ <if test="remark != null">remark,</if>
|
|
|
+ <if test="createById != null">create_by_id,</if>
|
|
|
+ <if test="createBy != null">create_by,</if>
|
|
|
+ <if test="createTime != null">create_time,</if>
|
|
|
+ <if test="updateById != null">update_by_id,</if>
|
|
|
+ <if test="updateBy != null">update_by,</if>
|
|
|
+ <if test="updateTime != null">update_time,</if>
|
|
|
+ <if test="delFlag != null">del_flag,</if>
|
|
|
+ <if test="dataApprovalStatus != null">data_approval_status,</if>
|
|
|
+ <if test="processKey != null">process_key,</if>
|
|
|
+ <if test="taskProcessKey != null">task_process_key,</if>
|
|
|
+ <if test="taskNodeKey != null">task_node_key,</if>
|
|
|
+ <if test="requistionOrdersType != null">requistion_orders_type,</if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="taskCode != null">#{taskCode},</if>
|
|
|
+ <if test="requisitionNumber != null">#{requisitionNumber},</if>
|
|
|
+ <if test="saleOrderNo != null">#{saleOrderNo},</if>
|
|
|
+ <if test="requisitionDate != null">#{requisitionDate},</if>
|
|
|
+ <if test="state != null">#{state},</if>
|
|
|
+ <if test="remark != null">#{remark},</if>
|
|
|
+ <if test="createById != null">#{createById},</if>
|
|
|
+ <if test="createBy != null">#{createBy},</if>
|
|
|
+ <if test="createTime != null">#{createTime},</if>
|
|
|
+ <if test="updateById != null">#{updateById},</if>
|
|
|
+ <if test="updateBy != null">#{updateBy},</if>
|
|
|
+ <if test="updateTime != null">#{updateTime},</if>
|
|
|
+ <if test="delFlag != null">#{delFlag},</if>
|
|
|
+ <if test="dataApprovalStatus != null">#{dataApprovalStatus},</if>
|
|
|
+ <if test="processKey != null">#{processKey},</if>
|
|
|
+ <if test="taskProcessKey != null">#{taskProcessKey},</if>
|
|
|
+ <if test="taskNodeKey != null">#{taskNodeKey},</if>
|
|
|
+ <if test="requistionOrdersType != null">#{requistionOrdersType},</if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updateRequisitionOrders" parameterType="com.zkqy.business.domain.RequisitionOrders">
|
|
|
+ update {DBNAME}.requisition_orders
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="taskCode != null">task_code = #{taskCode},</if>
|
|
|
+ <if test="requisitionNumber != null">requisition_number = #{requisitionNumber},</if>
|
|
|
+ <if test="saleOrderNo != null">sale_order_no = #{saleOrderNo},</if>
|
|
|
+ <if test="requisitionDate != null">requisition_date = #{requisitionDate},</if>
|
|
|
+ <if test="state != null">state = #{state},</if>
|
|
|
+ <if test="remark != null">remark = #{remark},</if>
|
|
|
+ <if test="createById != null">create_by_id = #{createById},</if>
|
|
|
+ <if test="createBy != null">create_by = #{createBy},</if>
|
|
|
+ <if test="createTime != null">create_time = #{createTime},</if>
|
|
|
+ <if test="updateById != null">update_by_id = #{updateById},</if>
|
|
|
+ <if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
+ <if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
+ <if test="delFlag != null">del_flag = #{delFlag},</if>
|
|
|
+ <if test="dataApprovalStatus != null">data_approval_status = #{dataApprovalStatus},</if>
|
|
|
+ <if test="processKey != null">process_key = #{processKey},</if>
|
|
|
+ <if test="taskProcessKey != null">task_process_key = #{taskProcessKey},</if>
|
|
|
+ <if test="taskNodeKey != null">task_node_key = #{taskNodeKey},</if>
|
|
|
+ <if test="requistionOrdersType != null">requistion_orders_type = #{requistionOrdersType},</if>
|
|
|
+ </trim>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deleteRequisitionOrdersById" parameterType="Long">
|
|
|
+ update {DBNAME}.requisition_orders
|
|
|
+ set del_flag = '2'
|
|
|
+ where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <delete id="deleteRequisitionOrdersByIds" parameterType="String">
|
|
|
+ update {DBNAME}.requisition_orders set del_flag = '2' where id in
|
|
|
+ <foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <delete id="deleteRequisitionItemsByRequisitionCodes" parameterType="String">
|
|
|
+ update {DBNAME}.requisition_items set del_flag = '2' where requisition_code in
|
|
|
+ <foreach item="requisitionCode" collection="array" open="(" separator="," close=")">
|
|
|
+ #{requisitionCode}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <delete id="deleteRequisitionItemsByRequisitionCode" parameterType="Long">
|
|
|
+ update {DBNAME}.requisition_items
|
|
|
+ set del_flag = '2'
|
|
|
+ where requisition_code = #{requisitionCode}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <insert id="batchRequisitionItems">
|
|
|
+ insert into {DBNAME}.requisition_items( requisition_code, material_id, quantity, actual_quantity, state,
|
|
|
+ specifications, color_code, remark, create_by_id, create_by, create_time, update_by_id, update_by, update_time,
|
|
|
+ del_flag, data_approval_status, process_key, task_process_key, task_node_key) values
|
|
|
+ <foreach item="item" index="index" collection="list" separator=",">
|
|
|
+ ( #{item.requisitionCode}, #{item.materialId}, #{item.quantity}, #{item.actualQuantity},
|
|
|
+ #{item.state}, #{item.specifications}, #{item.colorCode}, #{item.remark}, #{item.createById},
|
|
|
+ #{item.createBy}, #{item.createTime}, #{item.updateById}, #{item.updateBy}, #{item.updateTime},
|
|
|
+ #{item.delFlag}, #{item.dataApprovalStatus}, #{item.processKey}, #{item.taskProcessKey},
|
|
|
+ #{item.taskNodeKey})
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <select id="selectMaterialRequisitionTask" parameterType="com.zkqy.business.domain.RequisitionOrders"
|
|
|
+ resultType="map">
|
|
|
+ SELECT production.product_name AS production_product_name, -- 品名
|
|
|
+ sale_products.lot_number AS sale_products_lot_number, -- 批号
|
|
|
+ sale_products.sale_order_no AS sale_products_sale_order_no, -- 销售编号/合同号
|
|
|
+ production.product_specifications AS production_product_specifications, -- 规格
|
|
|
+ sale_products.id AS sale_products_id, -- 销售产品id
|
|
|
+ sale_products.task_name AS sale_products_task_name, -- 任务名称
|
|
|
+ sale_products.product_number AS sale_products_product_number -- 销售数量/重量
|
|
|
+ FROM {DBNAME}.sale_products AS sale_products
|
|
|
+ LEFT JOIN {DBNAME}.sale_craft AS sale_craft
|
|
|
+ ON {DBNAME}.sale_craft.sale_order_no = {DBNAME}.sale_products.sale_order_no
|
|
|
+ LEFT JOIN {DBNAME}.production AS production
|
|
|
+ ON {DBNAME}.production.product_no = {DBNAME}.sale_products.product_no
|
|
|
+ LEFT JOIN {DBNAME}.production_line AS production_line
|
|
|
+ ON {DBNAME}.production_line.id = {DBNAME}.sale_products.production_line_no AND
|
|
|
+ {DBNAME}.production_line.del_flag = 0
|
|
|
+ LEFT JOIN {DBNAME}.materiel AS materiel
|
|
|
+ ON {DBNAME}.materiel.materiel_code = {DBNAME}.sale_products.colour_number
|
|
|
+ LEFT JOIN {DBNAME}.sale_order AS sale_order
|
|
|
+ ON {DBNAME}.sale_order.sale_no = {DBNAME}.sale_craft.sale_order_no
|
|
|
+ where sale_products.del_flag = 0
|
|
|
+ AND production.del_flag = 0
|
|
|
+ AND sale_craft.del_flag = 0
|
|
|
+ AND materiel.del_flag = 0
|
|
|
+ AND sale_order.del_flag = 0
|
|
|
+ AND sale_order.status = 3
|
|
|
+ and sale_products.on_board_state != 3 -- 过滤已完成的任务
|
|
|
+ </select>
|
|
|
+</mapper>
|