You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
269 lines
13 KiB
XML
269 lines
13 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.op.mes.mapper.MesUnitpriceReportMapper">
|
|
|
|
<resultMap type="MesUnitpriceReport" id="MesUnitpriceReportResult">
|
|
<result property="id" column="id"/>
|
|
<result property="workorderCode" column="workorder_code"/>
|
|
<result property="workorderCodeSap" column="workorder_code_sap"/>
|
|
<result property="workOrderProductDate" column="work_order_product_date"/>
|
|
<result property="productName" column="product_name"/>
|
|
<result property="productCode" column="product_code"/>
|
|
<result property="lineCode" column="line_code"/>
|
|
<result property="sapCode" column="sap_code,"/>
|
|
<result property="equipmentName" column="equipment_name"/>
|
|
<result property="userName" column="user_name"/>
|
|
<result property="nickName" column="nick_name"/>
|
|
<result property="post" column="post"/>
|
|
<result property="childprocessCode" column="childprocess_code"/>
|
|
<result property="childprocessName" column="childprocess_name"/>
|
|
<result property="totalQuantity" column="total_quantity"/>
|
|
<result property="headCount" column="head_count"/>
|
|
<result property="avgResult" column="avg_result"/>
|
|
<result property="result" column="result"/>
|
|
<result property="attr1" column="attr1"/>
|
|
<result property="realWages" column="real_wages"/>
|
|
<result property="attr2" column="attr2"/>
|
|
<result property="attr3" column="attr3"/>
|
|
<result property="lineLeader" column="create_by"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="umrez" column="umrez"/>
|
|
<result property="orderQuantityP" column="order_quantity_p"/>
|
|
<result property="orderQuantity" column="order_quantity"/>
|
|
<result property="kk" column="kk"/>
|
|
<result property="bd" column="bd"/>
|
|
<result property="zg" column="zg"/>
|
|
<result property="fg" column="fg"/>
|
|
<result property="sc" column="sc"/>
|
|
<result property="sj" column="sj"/>
|
|
<result property="tsfy" column="tsfy"/>
|
|
<result property="ybbt" column="ybbt"/>
|
|
<result property="xcbt" column="xcbt"/>
|
|
<result property="hj" column="hj"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectMesUnitpriceReportVo">
|
|
select id, workorder_code, workorder_code_sap, product_name, product_code, user_name, nick_name, childprocess_code, childprocess_name, attr1, attr2, attr3,kk,bd,zg,fg,sc,sj,tsfy,ybbt,xcbt,create_by, create_time, update_by, update_time, remark from mes_unitprice_report
|
|
</sql>
|
|
|
|
<select id="selectMesUnitpriceReportList" parameterType="MesUnitpriceReport" resultMap="MesUnitpriceReportResult">
|
|
SELECT
|
|
mur.id,
|
|
mur.workorder_code,
|
|
mur.workorder_code_sap,
|
|
mur.work_order_product_date,
|
|
mur.product_code,
|
|
mur.product_name,
|
|
bp.umrez,
|
|
mrws.order_quantity as order_quantity_p,
|
|
mrw.order_quantity,
|
|
mur.line_code,
|
|
mur.attr2,
|
|
mur.remark,
|
|
be.sap_name AS equipment_name,
|
|
mur.user_name,
|
|
mur.nick_name,
|
|
mur.post,
|
|
mur.childprocess_code,
|
|
mup.childprocess_name,
|
|
mur.attr1 AS total_quantity,
|
|
mur.kk,
|
|
mur.bd,
|
|
mur.zg,
|
|
mur.fg,
|
|
mur.sc,
|
|
mur.sj,
|
|
mur.tsfy,
|
|
mur.ybbt,
|
|
mur.xcbt,
|
|
ROUND((COALESCE(mup.attr1, 0) * COALESCE(mur.attr1, 0)) - COALESCE(mur.kk, 0) + COALESCE(mur.bd, 0) +
|
|
COALESCE(mur.zg, 0) + COALESCE(mur.fg, 0) + COALESCE(mur.sc, 0) + COALESCE(mur.sj, 0) + COALESCE(mur.tsfy, 0) +
|
|
COALESCE(mur.ybbt, 0) + COALESCE(mur.xcbt, 0), 2) AS hj,
|
|
|
|
CASE
|
|
WHEN COALESCE(mur.attr2, 0) = 0 THEN 0
|
|
ELSE ROUND(
|
|
((COALESCE(mup.attr1, 0) * COALESCE(mur.attr1, 0)) - COALESCE(mur.kk, 0) + COALESCE(mur.bd, 0) +
|
|
COALESCE(mur.zg, 0) + COALESCE(mur.fg, 0) + COALESCE(mur.sc, 0) + COALESCE(mur.sj, 0) +
|
|
COALESCE(mur.tsfy, 0) + COALESCE(mur.ybbt, 0) + COALESCE(mur.xcbt, 0)) / COALESCE(mur.attr2, 1), 2)
|
|
END AS real_wages,
|
|
|
|
CAST (mup.attr1 AS DECIMAL(18, 6)) AS attr1,
|
|
ROUND(mup.attr1 * mur.attr1, 2) AS result,
|
|
mur.create_time,
|
|
mur.create_by
|
|
FROM
|
|
mes_unitprice_report mur
|
|
LEFT JOIN mes_unit_price mup ON RIGHT ( mur.product_code, 11 ) = mup.product_code
|
|
AND mur.childprocess_code = mup.childprocess_code
|
|
LEFT JOIN base_equipment be ON be.sap_code= mur.line_code
|
|
LEFT JOIN ( SELECT parent_order, SUM ( quantity ) AS total_quantity,SUM(quantity_feedback) AS order_quantity FROM mes_report_work GROUP BY parent_order ) mrw ON mur.workorder_code = mrw.parent_order
|
|
LEFT JOIN ( SELECT workorder_code, SUM ( quantity ) AS total_quantity,SUM(quantity_feedback) AS order_quantity FROM mes_report_work GROUP BY workorder_code ) mrws ON mur.workorder_code = mrws.workorder_code
|
|
LEFT JOIN base_product bp ON bp.product_code=mur.product_code
|
|
LEFT JOIN pro_order_workorder pow ON pow.workorder_code=mur.workorder_code
|
|
<where>
|
|
<if test="workorderCode != null and workorderCode != ''">and workorder_code = #{workorderCode}</if>
|
|
<if test="workorderCodeSap != null and workorderCodeSap != ''">and mur.workorder_code_sap =
|
|
#{workorderCodeSap}
|
|
</if>
|
|
<if test="productName != null and productName != ''">and mur.product_name like concat('%', #{productName},
|
|
'%')
|
|
</if>
|
|
<if test="productCode != null and productCode != ''">and mur.product_code like concat('%', #{productCode},
|
|
'%')
|
|
</if>
|
|
<if test="userName != null and userName != ''">and user_name like concat('%', #{userName}, '%')</if>
|
|
<if test="nickName != null and nickName != ''">and (nick_name like concat('%', #{nickName}, '%') or user_name like concat('%', #{nickName}, '%')) </if>
|
|
<if test="childprocessCode != null and childprocessCode != ''">and childprocess_code =
|
|
#{childprocessCode}
|
|
</if>
|
|
<if test="childprocessName != null and childprocessName != ''">and childprocess_name like concat('%',
|
|
#{childprocessName}, '%')
|
|
</if>
|
|
<if test="lineCode != null and lineCode != ''">and mur.line_code like concat('%',
|
|
#{lineCode}, '%')
|
|
</if>
|
|
<if test="equipmentName != null and equipmentName != ''">and be.sap_name like concat('%',
|
|
#{equipmentName}, '%')
|
|
</if>
|
|
<if test="attr1 != null and attr1 != ''">and attr1 = #{attr1}</if>
|
|
<if test="attr2 != null and attr2 != ''">and attr2 = #{attr2}</if>
|
|
<if test="attr3 != null and attr3 != ''">and attr3 = #{attr3}</if>
|
|
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
|
|
and mur.work_order_product_date between #{params.beginTime} and #{params.endTime}
|
|
</if>
|
|
</where>
|
|
GROUP BY
|
|
mur.id,
|
|
mur.workorder_code,
|
|
mur.workorder_code_sap,
|
|
mur.work_order_product_date,
|
|
mur.product_code,
|
|
mur.product_name,
|
|
bp.umrez,
|
|
mur.attr1,
|
|
mur.attr2,
|
|
mur.line_code,
|
|
mur.remark,
|
|
be.sap_name,
|
|
mur.user_name,
|
|
mur.nick_name,
|
|
mur.post,
|
|
mur.childprocess_code,
|
|
mup.childprocess_name,
|
|
mrw.total_quantity,
|
|
mur.create_time,
|
|
mrw.order_quantity,
|
|
mrws.order_quantity,
|
|
mup.attr1,
|
|
mur.kk,
|
|
mur.bd,
|
|
mur.zg,
|
|
mur.fg,
|
|
mur.sc,
|
|
mur.sj,
|
|
mur.tsfy,
|
|
mur.ybbt,
|
|
mur.xcbt,
|
|
mur.create_by
|
|
</select>
|
|
|
|
<select id="selectMesUnitpriceReportById" parameterType="String" resultMap="MesUnitpriceReportResult">
|
|
<include refid="selectMesUnitpriceReportVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertMesUnitpriceReport" parameterType="MesUnitpriceReport">
|
|
insert into mes_unitprice_report
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">id,</if>
|
|
<if test="workorderCode != null">workorder_code,</if>
|
|
<if test="workorderCodeSap != null">workorder_code_sap,</if>
|
|
<if test="productName != null">product_name,</if>
|
|
<if test="productCode != null">product_code,</if>
|
|
<if test="userName != null and userName != ''">user_name,</if>
|
|
<if test="nickName != null and nickName != ''">nick_name,</if>
|
|
<if test="childprocessCode != null">childprocess_code,</if>
|
|
<if test="childprocessName != null">childprocess_name,</if>
|
|
<if test="attr1 != null">attr1,</if>
|
|
<if test="attr2 != null">attr2,</if>
|
|
<if test="attr3 != null">attr3,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="remark != null">remark,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">#{id},</if>
|
|
<if test="workorderCode != null">#{workorderCode},</if>
|
|
<if test="workorderCodeSap != null">#{workorderCodeSap},</if>
|
|
<if test="productName != null">#{productName},</if>
|
|
<if test="productCode != null">#{productCode},</if>
|
|
<if test="userName != null and userName != ''">#{userName},</if>
|
|
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
|
<if test="childprocessCode != null">#{childprocessCode},</if>
|
|
<if test="childprocessName != null">#{childprocessName},</if>
|
|
<if test="attr1 != null">#{attr1},</if>
|
|
<if test="attr2 != null">#{attr2},</if>
|
|
<if test="attr3 != null">#{attr3},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateMesUnitpriceReport" parameterType="MesUnitpriceReport">
|
|
update mes_unitprice_report
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<!-- <if test="workorderCode != null">workorder_code = #{workorderCode},</if>-->
|
|
<!-- <if test="workorderCodeSap != null">workorder_code_sap = #{workorderCodeSap},</if>-->
|
|
<!-- <if test="productName != null">product_name = #{productName},</if>-->
|
|
<!-- <if test="productCode != null">product_code = #{productCode},</if>-->
|
|
<!-- <if test="userName != null and userName != ''">user_name = #{userName},</if>-->
|
|
<!-- <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>-->
|
|
<!-- <if test="childprocessCode != null">childprocess_code = #{childprocessCode},</if>-->
|
|
<!-- <if test="childprocessName != null">childprocess_name = #{childprocessName},</if>-->
|
|
<if test="attr1 != null">attr1 = #{attr1},</if>
|
|
<if test="attr2 != null">attr2 = #{attr2},</if>
|
|
<if test="attr3 != null">attr3 = #{attr3},</if>
|
|
|
|
<if test="bd != null">bd = #{bd},</if>
|
|
<if test="kk != null">kk = #{kk},</if>
|
|
<if test="zg != null">zg = #{zg},</if>
|
|
|
|
<if test="fg != null">fg = #{fg},</if>
|
|
<if test="sc != null">sc = #{sc},</if>
|
|
<if test="sj != null">sj = #{sj},</if>
|
|
|
|
<if test="tsfy != null">tsfy = #{tsfy},</if>
|
|
<if test="ybbt != null">ybbt = #{ybbt},</if>
|
|
<if test="xcbt != null">xcbt = #{xcbt},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteMesUnitpriceReportById" parameterType="String">
|
|
delete from mes_unitprice_report where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteMesUnitpriceReportByIds" parameterType="String">
|
|
delete from mes_unitprice_report where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
</mapper>
|