<?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.example.erp.mapper.pp.ReportMapper">
|
<resultMap id="flowCardMap" type="com.example.erp.entity.pp.FlowCard">
|
<result column="order_id" property="orderId"/>
|
<result column="process_Id" property="processId"/>
|
<result column="quantity" property="quantity"/>
|
<result column="founder" property="founder"/>
|
<result column="create_time" property="createTime"/>
|
<result column="layout_status" property="layoutStatus"/>
|
<!--接收其他外键实体类数据-->
|
<association property="order" javaType="com.example.erp.entity.sd.Order">
|
<result column="project" property="project"/>
|
<result column="order_id" property="orderId"/>
|
<result column="customer_name" property="customerName"/>
|
<result column="batch" property="batch"/>
|
<result column="other_remarks" property="otherRemarks"/>
|
<result column="icon" property="icon"/>
|
<result column="order_type" property="orderType"/>
|
<result column="salesman" property="salesman"/>
|
<result column="processing_note" property="processingNote"/>
|
<result column="delivery_address" property="deliveryAddress"/>
|
</association>
|
<association property="orderDetail" javaType="com.example.erp.entity.sd.OrderDetail">
|
<result column="product_id" property="productId"/>
|
<result column="product_name" property="productName"/>
|
<result column="compute_gross_area" property="computeGrossArea"/>
|
<result column="processing_note" property="processingNote"/>
|
<result column="quantity" property="quantity"/>
|
<result column="compute_gross_area" property="computeGrossArea"/>
|
<result column="perimeter" property="perimeter"/>
|
<result column="order_number" property="orderNumber"/>
|
<result column="width" property="width"/>
|
<result column="height" property="height"/>
|
<result column="shape" property="shape"/>
|
<result column="weight" property="weight"/>
|
</association>
|
<association property="orderGlassDetail" javaType="com.example.erp.entity.sd.OrderGlassDetail">
|
<result column="production_id" property="productionId"/>
|
</association>
|
<association property="product" javaType="com.example.erp.entity.sd.Product">
|
<result column="total_thickness" property="totalThickness"/>
|
<result column="thickness" property="thickness"/>
|
</association>
|
|
<!--<result column="g_typeId" property="glassTypes.typeId"/>
|
<result column="g_type" property="glassTypes.type"/>-->
|
|
</resultMap>
|
|
<resultMap id="damageDetailsTableMap" type="com.example.erp.entity.pp.DamageDetails">
|
<result column="responsible_process" property="responsibleProcess"/>
|
<result column="responsible_team" property="responsibleTeam"/>
|
<result column="breakage_type" property="breakageType"/>
|
<result column="breakage_reason" property="breakageReason"/>
|
<result column="breakage_quantity" property="breakageQuantity"/>
|
<result column="area" property="area"/>
|
<result column="reporting_work_id" property="reportingWork.reportingWorkId"/>
|
<result column="reporting_work_time" property="reportingWork.reportingWorkTime"/>
|
<result column="this_process" property="reportingWork.thisProcess"/>
|
<result column="project" property="order.project"/>
|
<result column="order_id" property="order.orderId"/>
|
<result column="glass_child" property="orderGlassDetail.glassChild"/>
|
</resultMap>
|
|
|
<resultMap id="reportMap" type="com.example.erp.entity.pp.Report">
|
<result column="process_id" property="processId"/>
|
<result column="customer_name" property="customerName"/>
|
<result column="project" property="project"/>
|
<result column="order_id" property="orderId"/>
|
<result column="batch" property="batch"/>
|
<result column="shape" property="shape"/>
|
<result column="order_number" property="orderNumber"/>
|
<result column="technology_number" property="technologyNumber"/>
|
<result column="process" property="technologyFlow"/>
|
<result column="quantity" property="orderNum"/>
|
<result column="child_width" property="childWidth"/>
|
<result column="child_height" property="childHeight"/>
|
<result column="stockNum" property="stockNum"/>
|
<result column="stockArea" property="stockArea"/>
|
<result column="product_name" property="productName"/>
|
<result column="bend_radius" property="bendRadius"/>
|
</resultMap>
|
|
|
<!-- 流程卡进度-->
|
<select id="processCardProgressMp">
|
select
|
a.product_name,
|
b.glass_child,
|
d.order_type,
|
concat(c.process_id,'/',c.technology_number) as process_id,
|
c.technology_number,
|
c.quantity,
|
e.reportWorkQuantity,
|
e.reportWorkQuantityCount,
|
e.broken_num,
|
round(ifnull(f.inventory,0)*a.area,2) as inventoryArea
|
|
from
|
flow_card as c
|
left join
|
sd.order_detail as a
|
on c.order_id = a.order_id
|
and c.order_number = a.order_number
|
left join sd.order_glass_detail as b
|
on c.order_id = b.order_id
|
and b.order_number = c.order_number
|
and c.technology_number = b.technology_number
|
left join sd.`order` as d
|
on c.order_id = d.order_id
|
left join mm.finished_goods_inventory as f
|
on c.order_id = f.order_id and f.order_number = c.order_number
|
left join (
|
SELECT process_id,
|
technology_number,
|
sum(a.broken_num) as broken_num,
|
concat('{',
|
GROUP_CONCAT(concat("\"",process,"\":\"",reporting_work_num,"\"")),
|
'}'
|
) as reportWorkQuantity,
|
concat('{',
|
GROUP_CONCAT(concat("\"",process,"\":\"",reporting_work_num_count,"\"")),
|
'}'
|
) as reportWorkQuantityCount
|
FROM sd.order_process_detail as a
|
where a.order_id=#{orderId}
|
GROUP BY process_id,a.technology_number
|
) as e
|
on e.process_id = c.process_id
|
and e.technology_number = c.technology_number
|
|
where a.order_id = #{orderId}
|
|
</select>
|
|
<select id="getProcessBreaking" resultMap="damageDetailsTableMap">
|
select rw.reporting_work_id,rw.reporting_work_time,dd.responsible_process,dd.responsible_team,
|
dd.breakage_type,dd.breakage_reason,ROUND((dd.breakage_quantity)) as breakage_quantity,
|
round(ogd.child_width*ogd.child_height*(dd.breakage_quantity)/1000000,2) as area,rw.this_process,
|
o.project,o.order_id,ogd.glass_child
|
from
|
damage_details as dd
|
left join reporting_work as rw
|
on rw.reporting_work_id=dd.reporting_work_id
|
left join sd.order as o
|
on rw.order_id=o.order_id
|
left join sd.order_glass_detail as ogd
|
on ogd.order_id=o.order_id and ogd.order_number=dd.order_number
|
and ogd.technology_number and dd.technology_number
|
where date(rw.reporting_work_time)>=#{startDate} and date(rw.reporting_work_time) <= #{endDate}
|
and rw.this_worn_quantity>0 and dd.available=0
|
and reviewed_state!=2
|
and rw.this_process!=dd.responsible_process
|
GROUP BY dd.id
|
order by dd.id desc
|
limit #{offset},#{pageSize}
|
</select>
|
|
<select id="getProcessBreakingTotal">
|
select
|
CEILING(count(dd.id)/#{pageSize}) as 'pageTotal',
|
count(distinct dd.id) as 'total'
|
from
|
damage_details as dd
|
left join reporting_work as rw
|
on rw.reporting_work_id=dd.reporting_work_id
|
left join sd.order as o
|
on rw.order_id=o.order_id
|
left join sd.order_glass_detail as ogd
|
on ogd.order_id=o.order_id and ogd.order_number=dd.order_number
|
and ogd.technology_number and dd.technology_number
|
where date(rw.reporting_work_time)>=#{startDate} and date(rw.reporting_work_time) <= #{endDate}
|
and rw.this_worn_quantity>0 and dd.available=0
|
and reviewed_state!=2
|
and rw.this_process!=dd.responsible_process
|
order by dd.id desc
|
</select>
|
|
<select id="workInProgressMp">
|
select #{selectProcesses} as thisProcess,
|
fc.process_id,
|
o.customer_name,
|
o.project,
|
o.order_id,
|
o.batch,
|
od.shape,
|
ogd.order_number,
|
ogd.technology_number,
|
ogd.process,
|
od.quantity,
|
ogd.child_width,
|
ogd.child_height,
|
odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
|
odpd.broken_num as stockNum,
|
ROUND(ogd.child_width * ogd.child_height *
|
(odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
|
odpd.broken_num) / 1000000, 2) as stockArea,
|
od.product_name,
|
od.bend_radius
|
|
from sd.order_detail AS od
|
LEFT JOIN sd.order_glass_detail AS ogd
|
ON od.order_id = ogd.order_id
|
AND od.order_number = ogd.order_number
|
LEFT JOIN flow_card AS fc
|
ON fc.order_id = ogd.order_id
|
and fc.production_id = ogd.production_id
|
AND fc.order_number = ogd.order_number
|
AND fc.technology_number = ogd.technology_number
|
left join sd.order_process_detail as odpd
|
ON odpd.order_id = fc.order_id
|
AND odpd.order_number = fc.order_number
|
AND odpd.technology_number = fc.technology_number
|
and odpd.process_id = fc.process_id
|
left join sd.order_process_detail as odpds
|
ON odpds.id = odpd.id - 1
|
left join
|
(SELECT sum(rw.rework_num) as 'patchNumSum',
|
rw.process_id,
|
rw.order_sort,
|
rw.technology_number,
|
rwk.this_process
|
from rework as rw
|
LEFT JOIN
|
reporting_work as rwk
|
on rw.reporting_work_id = rwk.reporting_work_id
|
where rwk.this_process = #{selectProcesses}
|
and rw.review_status = 1
|
GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
|
on c.process_id = fc.process_id
|
and c.order_sort = fc.order_number
|
and c.technology_number = fc.technology_number
|
left join sd.`order` as o
|
on o.order_id = od.order_id
|
where LENGTH(fc.process_id) = 14
|
and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
|
odpd.broken_num != 0
|
and odpd.process = #{selectProcesses} and o.create_time between #{selectTime1} and #{selectTime2}
|
and position(#{orderId} in od.order_id) and position(#{inputProject} in o.project)
|
|
group by fc.process_id, fc.order_number, fc.technology_number
|
order by fc.process_id, fc.order_number, fc.technology_number
|
</select>
|
|
<!--
|
<if test="Report.processId != null and Report.processId != ''">
|
and fc.process_id regexp #{Report.processId}
|
</if>
|
<if test="Report.customerName != null and Report.customerName != ''">
|
and o.customer_name regexp #{Report.customerName}
|
</if>
|
<if test="Report.project != null and Report.project != ''">
|
and o.project regexp #{Report.project}
|
</if>
|
<if test="Report.batch != null and Report.batch != ''">
|
and o.batch regexp #{Report.batch}
|
</if>
|
<if test="Report.shape != null and Report.shape != ''">
|
and od.shape regexp #{Report.shape}
|
</if>
|
-->
|
|
<!-- <select id="getWorkInProgressTotal">-->
|
<!-- select CEILING(count(fc.id) / #{pageSize}) as 'pageTotal',-->
|
<!-- count(distinct fc.id) as 'total'-->
|
|
<!-- from sd.order_detail AS od-->
|
<!-- LEFT JOIN sd.order_glass_detail AS ogd-->
|
<!-- ON od.order_id = ogd.order_id-->
|
<!-- AND od.order_number = ogd.order_number-->
|
<!-- LEFT JOIN flow_card AS fc-->
|
<!-- ON fc.order_id = ogd.order_id-->
|
<!-- and fc.production_id = ogd.production_id-->
|
<!-- AND fc.order_number = ogd.order_number-->
|
<!-- AND fc.technology_number = ogd.technology_number-->
|
<!-- left join sd.order_process_detail as odpd-->
|
<!-- ON odpd.order_id = fc.order_id-->
|
<!-- AND odpd.order_number = fc.order_number-->
|
<!-- AND odpd.technology_number = fc.technology_number-->
|
<!-- and odpd.process_id = fc.process_id-->
|
<!-- left join sd.order_process_detail as odpds-->
|
<!-- ON odpds.id = odpd.id - 1-->
|
<!-- left join-->
|
<!-- (SELECT sum(rw.rework_num) as 'patchNumSum',-->
|
<!-- rw.process_id,-->
|
<!-- rw.order_sort,-->
|
<!-- rw.technology_number,-->
|
<!-- rwk.this_process-->
|
<!-- from rework as rw-->
|
<!-- LEFT JOIN-->
|
<!-- reporting_work as rwk-->
|
<!-- on rw.reporting_work_id = rwk.reporting_work_id-->
|
<!-- where rwk.this_process = #{selectProcesses}-->
|
<!-- and rw.review_status = 1-->
|
<!-- GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c-->
|
<!-- on c.process_id = fc.process_id-->
|
<!-- and c.order_sort = fc.order_number-->
|
<!-- and c.technology_number = fc.technology_number-->
|
<!-- left join sd.`order` as o-->
|
<!-- on o.order_id = od.order_id-->
|
<!-- where LENGTH(fc.process_id) = 14-->
|
<!-- and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count - -->
|
<!-- odpd.broken_num != 0-->
|
<!-- and odpd.process = #{selectProcesses}-->
|
<!-- and o.create_time between #{selectTime1} and #{selectTime2}-->
|
<!-- and position(#{orderId} in od.order_id)-->
|
<!-- and position(#{inputProject} in o.project)-->
|
<!-- group by fc.process_id, fc.order_number, fc.technology_number-->
|
<!-- order by fc.process_id, fc.order_number, fc.technology_number-->
|
<!-- limit #{offset},#{pageSize};-->
|
<!-- </select>-->
|
|
<select id="processToBeCompletedMp">
|
select DATE(o.create_time) as create_time,
|
DATE(o.delivery_date) as delivery_date,
|
o.order_id,
|
fc.process_id,
|
o.customer_name,
|
o.project,
|
o.batch,
|
od.order_number,
|
ogd.technology_number,
|
ogd.glass_child,
|
ogd.child_width,
|
ogd.child_height,
|
od.quantity,
|
ROUND(ogd.child_width * ogd.child_height / 1000000, 2) as childArea,
|
ROUND(ogd.child_width * ogd.child_height * od.quantity / 1000000, 2) as actualArea,
|
odpd.reporting_work_num as completeNum,
|
ROUND(ogd.child_width * ogd.child_height * odpd.reporting_work_num / 1000000,
|
2) as completeArea,
|
od.quantity - odpd.reporting_work_num as incompleteNum,
|
ROUND(ogd.child_width * ogd.child_height * (od.quantity - odpd.reporting_work_num) / 1000000,
|
2) as incompleteArea,
|
od.product_name
|
|
from sd.order_detail AS od
|
LEFT JOIN sd.order_glass_detail AS ogd
|
ON od.order_id = ogd.order_id
|
AND od.order_number = ogd.order_number
|
LEFT JOIN flow_card AS fc
|
ON fc.order_id = ogd.order_id
|
and fc.production_id = ogd.production_id
|
AND fc.order_number = ogd.order_number
|
AND fc.technology_number = ogd.technology_number
|
left join sd.order_process_detail as odpd
|
ON odpd.order_id = fc.order_id
|
AND odpd.order_number = fc.order_number
|
AND odpd.technology_number = fc.technology_number
|
and odpd.process_id = fc.process_id
|
left join sd.`order` as o
|
on o.order_id = od.order_id
|
where LENGTH(fc.process_id) = 14
|
and odpd.process = #{selectProcesses}
|
and o.create_time between #{selectTime1} and #{selectTime2}
|
and position(#{orderId} in od.order_id)
|
and position(#{inputProject} in o.project)
|
and od.quantity > odpd.reporting_work_num
|
|
group by fc.process_id, fc.order_number, fc.technology_number
|
order by fc.process_id, fc.order_number, fc.technology_number
|
</select>
|
</mapper>
|