@ -8,6 +8,7 @@
<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" />
@ -15,6 +16,7 @@
<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" />
@ -30,10 +32,23 @@
<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, create_by, create_time, update_by, update_time, remark from mes_unitprice_report
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" >
@ -41,27 +56,55 @@
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,
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,
CAST(mur.attr2 AS DECIMAL) * 16 AS real_wages,
mup.attr1,
mup.attr1*mur.attr1 AS result,
COUNT(*) OVER (PARTITION BY mur.workorder_code_sap, mur.childprocess_code) AS head_count,
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
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 FROM mes_report_work GROUP BY parent_order ) mrw ON mur.workorder_code = mrw.parent_order
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 =
@ -91,26 +134,41 @@
<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.create_tim e between #{params.beginTime} and #{params.endTime}
and mur.work_order_product_dat e 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,
mup.attr1;
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
</select>
@ -170,11 +228,23 @@
<!-- <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="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>