From b499a7e1dbcc4b9dbcdcaa46bbf5c24271bf6698 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期一, 11 八月 2025 16:54:05 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override
---
north-glass-erp/src/main/resources/mapper/pp/Report.xml | 603 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 572 insertions(+), 31 deletions(-)
diff --git a/north-glass-erp/src/main/resources/mapper/pp/Report.xml b/north-glass-erp/src/main/resources/mapper/pp/Report.xml
index 350fd4a..db50185 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/Report.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/Report.xml
@@ -92,6 +92,7 @@
<result column="area" property="area"/>
<result column="breakage_quantity" property="breakageQuantity"/>
<result column="project" property="project"/>
+ <result column="batch" property="batch"/>
<result column="process_id" property="processId"/>
<result column="order_number" property="orderNumber"/>
<result column="technology_number" property="technologyNumber"/>
@@ -127,6 +128,7 @@
<result column="examine_time" property="examineTime"/>
<result column="workProcessName" property="workProcessName"/>
<result column="device_name" property="deviceName"/>
+ <result column="order_type" property="orderType"/>
</resultMap>
<resultMap id="scheduleProductionScheduleMap" type="com.example.erp.dto.pp.ScheduleProductionScheduleDTO">
@@ -167,21 +169,37 @@
b.glass_child,
d.order_type,
concat(c.process_id, '/', c.technology_number) as process_id,
+ c.order_id,
c.order_number,
c.technology_number,
b.child_width,
b.child_height,
- c.quantity,
+ if(c.technology_number=1,c.quantity-ifnull(c.termination_quantity,0),0) as quantity,
+
+ c.quantity-ifnull(c.termination_quantity,0) as thisQuantity,/*鐢ㄤ簬鍒ゆ柇鏄惁鏀瑰彉棰滆壊*/
e.reportWorkQuantity,
+ e.reportWorkQuantityShow,
e.reportWorkQuantityCount,
e.reportWorkTime,
e.broken_num,
- c.quantity*a.area as gross_area,
- ifnull(f.inventory, 0) as inventory,
- round(ifnull(f.inventory, 0) * a.area, 2) as inventoryArea,
- ifnull(dd.quantity, 0) as shippedQuantity,
- ifnull(JSON_UNQUOTE(JSON_EXTRACT(a.other_columns, '$.S01')),'') AS glassNumber
- from flow_card as c
+ c.quantity-ifnull(c.termination_quantity,0) as glassQuantity,
+
+ c.quantity-ifnull(c.termination_quantity,0) as quantityShow,
+ (c.quantity-ifnull(c.termination_quantity,0))*a.area as grossAreaShow,
+ ifnull(f.inventory, 0) as inventoryShow,
+ round(ifnull(f.inventory, 0) * a.area, 2) as inventoryAreaShow,
+ ifnull(dd.quantity, 0) as shippedQuantityShow,
+
+ if(c.technology_number=1,(c.quantity-ifnull(c.termination_quantity,0))*a.area,0) as grossArea,
+ if(c.technology_number=1,ifnull(f.inventory, 0) ,0) as inventory,
+ if(c.technology_number=1,round(ifnull(f.inventory, 0) * a.area, 2),0) as inventoryArea,
+ if(c.technology_number=1,ifnull(dd.quantity, 0) ,0) as shippedQuantity,
+
+
+ ifnull(JSON_UNQUOTE(JSON_EXTRACT(a.other_columns, '$.S01')),'') AS glassNumber,
+ b.`group`
+
+ from pp.flow_card as c
left join
sd.order_detail as a
on c.order_id = a.order_id
@@ -200,9 +218,13 @@
technology_number,
sum(a.broken_num) as broken_num,
concat('{',
- GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num, "\"")),
+ GROUP_CONCAT(concat("\"", process, "\":\"", if(technology_number!=1 and (bd.nickname='stepD' || bd.nickname='stepB' ) ,0,reporting_work_num), "\"")),
'}'
) as reportWorkQuantity,
+ concat('{',
+ GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num, "\"")),
+ '}'
+ ) as reportWorkQuantityShow,
concat('{',
GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num_count, "\"")),
'}'
@@ -212,12 +234,17 @@
'}'
) as reportWorkTime
FROM sd.order_process_detail as a
+ left join (SELECT DISTINCT basic_name,nickname from sd.basic_data as bd where bd.basic_category = 'process') as bd
+ on a.process = bd.basic_name
where a.order_id = #{orderId}
- GROUP BY process_id, a.order_number, a.technology_number) as e
+ GROUP BY process_id, a.order_number, a.technology_number
+
+
+ ) as e
on e.process_id = c.process_id
and e.technology_number = c.technology_number
and e.order_number = c.order_number
- where a.order_id = #{orderId} and d.create_order>0
+ where a.order_id = #{orderId} and d.create_order>0 and c.quantity-ifnull(c.termination_quantity,0)>0
group by c.order_number,
c.technology_number,
c.process_id
@@ -523,14 +550,14 @@
ogd.glass_child,
ogd.child_width,
ogd.child_height,
- fc.quantity,
+ fc.quantity - ifnull(fc.termination_quantity,0) as quantity,
ROUND(ogd.child_width * ogd.child_height / 1000000, 2) as childArea,
- ROUND(ogd.child_width * ogd.child_height * fc.quantity / 1000000, 2) as actualArea,
+ ROUND(ogd.child_width * ogd.child_height * (fc.quantity- ifnull(fc.termination_quantity,0)) / 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,
- fc.quantity - odpd.reporting_work_num as incompleteNum,
- ROUND(ogd.child_width * ogd.child_height * (fc.quantity - odpd.reporting_work_num) / 1000000,
+ fc.quantity - odpd.reporting_work_num - ifnull(fc.termination_quantity,0) as incompleteNum,
+ ROUND(ogd.child_width * ogd.child_height * (fc.quantity - odpd.reporting_work_num- ifnull(fc.termination_quantity,0)) / 1000000,
2) as incompleteArea,
od.product_name
@@ -556,7 +583,8 @@
AND o.create_time < #{selectTime2}
and position(#{orderId} in od.order_id)
and position(#{inputProject} in o.project)
- and fc.quantity - odpd.reporting_work_num>0
+ and GREATEST(fc.quantity - odpd.reporting_work_num, 0)>0
+ and fc.quantity-ifnull(fc.termination_quantity,0)>0
group by fc.process_id, fc.order_number, fc.technology_number
order by fc.process_id, fc.order_number, fc.technology_number
@@ -566,6 +594,7 @@
SELECT
o.order_id,
o.project,
+ o.batch,
rw.process_id,
dd.order_number,
dd.technology_number,
@@ -594,7 +623,7 @@
rw.reporting_work_time >= #{selectTime1}
AND rw.reporting_work_time < #{selectTime2}
- AND dd.available = 0
+ AND dd.available = 0 and rw.reviewed_state>=0
<if test="damageReportDTO.orderId != null and damageReportDTO.orderId != ''">
and o.order_id regexp #{damageReportDTO.orderId}
</if>
@@ -790,7 +819,7 @@
a.product_name,
b.child_width,
b.child_height,
- c.quantity,
+ c.quantity - ifnull(c.termination_quantity,0) as quantity,
c.technology_number,
b.glass_child,
ifnull(e.reportWorkQuantity, 0) as reportWorkQuantity,
@@ -833,7 +862,7 @@
and e.order_number=c.order_number
and e.technology_number = c.technology_number
left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
- where a.order_id = #{orderId} and d.create_order>0
+ where a.order_id = #{orderId} and d.create_order>0 and c.quantity - ifnull(c.termination_quantity,0)>0
group by c.order_number,c.technology_number
ORDER BY a.order_number
</select>
@@ -877,12 +906,14 @@
left join sd.`order` as o on o.order_id = a.order_id
where o.create_time >= #{selectTime1}
AND o.create_time < #{selectTime2}
+ and position(#{orderId} in o.order_id)
GROUP BY process_id, a.technology_number) as e
on e.process_id = c.process_id
and e.technology_number = c.technology_number
left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
where d.create_time >= #{selectTime1}
AND d.create_time < #{selectTime2}
+ and position(#{orderId} in a.order_id)
and d.create_order>0
and reportWorkQuantity is not null
GROUP BY a.order_id
@@ -995,6 +1026,7 @@
<select id="exportDamageReportMp">
SELECT o.order_id,
o.project,
+ o.batch,
rw.process_id,
dd.order_number,
dd.technology_number,
@@ -1018,7 +1050,7 @@
AND dd.technology_number = ogd.technology_number
WHERE rw.reporting_work_time >= #{dates[0]}
and rw.reporting_work_time <= #{dates[1]}
- AND dd.available = 0
+ AND dd.available = 0 and rw.reviewed_state>=0
GROUP BY dd.id
</select>
@@ -1348,6 +1380,7 @@
rw.reviewed,
rw.examine_time,
rw.device_name,
+ o.order_type,
-- GROUP_CONCAT(ogd.glass_child SEPARATOR '+') as workProcessName
CASE
WHEN LOCATE('step',#{laminating})>0 THEN GROUP_CONCAT(ogd.glass_child SEPARATOR '+')
@@ -1433,6 +1466,8 @@
rw.reviewed,
rw.examine_time,
rw.device_name,
+ o.order_type,
+ -- GROUP_CONCAT(ogd.glass_child SEPARATOR '+') as workProcessName
CASE
WHEN LOCATE('step',#{laminating})>0 THEN GROUP_CONCAT(ogd.glass_child SEPARATOR '+')
ELSE MAX( ogd.glass_child )
@@ -1444,9 +1479,9 @@
left join sd.order_glass_detail as ogd on ogd.order_id=fc.order_id and ogd.order_number=fc.order_number and ogd.technology_number=fc.technology_number
left join sd.order_detail as od on od.order_id=ogd.order_id and od.order_number=ogd.order_number
left join sd.`order` as o on o.order_id=od.order_id
- where o.create_order>0 and rw.reviewed_state>=0 and rwd.completed_quantity>0
- and date(rw.reporting_work_time) >= #{date[0]}
- and date(rw.reporting_work_time) <= #{date[1]}
+ where o.create_order>0 and rw.reviewed_state>=0 and rwd.completed_quantity>0 and
+ rw.reporting_work_time >= #{date[0]}
+ AND rw.reporting_work_time < #{date[1]}
and position(#{process} in rw.this_process)
<choose>
<when test="laminating == ''">
@@ -1936,7 +1971,7 @@
sum(aa.stockNum) AS stockNum,
SUM(aa.stockArea) AS stockArea,
count(* ) AS 'total',
- CEILING( count(* )/100 ) AS 'pageTotal'
+ CEILING( count(* )/#{pageSize} ) AS 'pageTotal'
from
(
SELECT (od.quantity) AS quantity,
@@ -2020,6 +2055,15 @@
<if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
and fc.process_id regexp #{workInProgressDTO.processId}
</if>
+ <if test="workInProgressDTO.orderNumber != null and workInProgressDTO.orderNumber != ''">
+ and ogd.order_number regexp #{workInProgressDTO.orderNumber}
+ </if>
+ <if test="workInProgressDTO.technologyNumber != null and workInProgressDTO.technologyNumber != ''">
+ and ogd.technology_number regexp #{workInProgressDTO.technologyNumber}
+ </if>
+ <if test="workInProgressDTO.glassNumber != null and workInProgressDTO.glassNumber != ''">
+ and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{workInProgressDTO.glassNumber}
+ </if>
group by fc.process_id, fc.order_number, fc.technology_number,d.process
) as aa
@@ -2055,8 +2099,8 @@
and odpd.process = #{selectProcesses}
and o.create_time >= #{selectTime1}
AND o.create_time < #{selectTime2}
- AND POSITION('' IN od.order_id)
- AND POSITION('' IN o.project)
+ and position(#{orderId} in od.order_id)
+ and position(#{inputProject} in o.project)
AND fc.quantity - odpd.reporting_work_num > 0;
</select>
@@ -2077,7 +2121,7 @@
WHERE
rw.reporting_work_time >= #{selectTime1}
AND rw.reporting_work_time < #{selectTime2}
- AND dd.available = 0
+ AND dd.available = 0 and rw.reviewed_state>=0
<if test="damageReportDTO.orderId != null and damageReportDTO.orderId != ''">
and o.order_id regexp #{damageReportDTO.orderId}
</if>
@@ -2154,6 +2198,9 @@
<if test="teamOutputDTO.edgingType != null and teamOutputDTO.edgingType != ''">
and od.edging_type regexp #{teamOutputDTO.edgingType}
</if>
+ <if test="teamOutputDTO.deviceName != null and teamOutputDTO.deviceName != ''">
+ and rw.device_name regexp #{teamOutputDTO.deviceName}
+ </if>
<choose>
<when test="laminating == ''">
GROUP BY
@@ -2187,7 +2234,7 @@
</select>
<select id="workInProgressMpdataList1" resultMap="workInProgressMap">
- select if(#{selectProcesses}='',d.process,#{selectProcesses}) as thisProcess,
+ select d.process as thisProcess,
fc.process_id,
o.customer_name,
o.project,
@@ -2260,14 +2307,16 @@
) as d
on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
- and position(#{selectProcesses} in d.process)
left join sd.`order` as o on o.order_id=od.order_id
+ LEFT JOIN sd.basic_data AS bd ON bd.basic_name = d.process
where o.create_order>0
and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
- and position(#{selectProcesses} in d.process)
and position(#{orderId} in od.order_id)
and position(#{inputProject} in o.project)
+ <if test="workInProgressDTO.thisProcess != null and workInProgressDTO.thisProcess != ''">
+ and d.process regexp #{workInProgressDTO.thisProcess}
+ </if>
<if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
and o.customer_name regexp #{workInProgressDTO.customerName}
</if>
@@ -2292,8 +2341,21 @@
<if test="workInProgressDTO.glassNumber != null and workInProgressDTO.glassNumber != ''">
and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{workInProgressDTO.glassNumber}
</if>
- group by fc.process_id, fc.order_number, fc.technology_number,d.process
- order by fc.process_id, fc.order_number, fc.technology_number
+ <choose>
+ <when test="laminating != null and laminating == 'stepC'">
+ GROUP BY fc.process_id, fc.order_number, ogd.`group`, d.process
+ </when>
+ <when test="laminating != null and laminating == 'stepD'">
+ GROUP BY fc.process_id, fc.order_number, d.process
+ </when>
+ <when test="laminating != null and laminating == 'stepB'">
+ GROUP BY fc.process_id, fc.order_number, d.process
+ </when>
+ <otherwise>
+ GROUP BY fc.process_id, fc.order_number, fc.technology_number, d.process
+ </otherwise>
+ </choose>
+ order by d.process,fc.process_id, fc.order_number, fc.technology_number
limit #{offset},#{pageSize};
</select>
@@ -2462,4 +2524,483 @@
where position(#{process} in a.next_process) and a.next_process!='鍒囧壊'
GROUP BY a.reporting_work_id
</select>
+
+ <select id="workInProgressCombinationMpdataList2">
+ select
+ a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
+ from pp.reporting_work as a
+ left join pp.reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
+ where position(#{selectProcesses} in a.next_process) and a.next_process!='鍒囧壊'
+ GROUP BY a.reporting_work_id
+ </select>
+
+ <select id="workInProgressCombinationMpdataList1">
+ select if(#{selectProcesses}='',d.process,#{selectProcesses}) as thisProcess,
+ o.project,
+ SUM(d.numCounts + d.patchNumSum - d.numCount -d.broken_num) as stockNum,
+ SUM(ROUND(ogd.child_width * ogd.child_height *
+ (d.numCounts + d.patchNumSum - d.numCount -
+ d.broken_num) / 1000000, 2)) as stockArea
+ 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 pp.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 (
+ SELECT
+ odpd.process,
+ odpd.process_id,
+ odpd.order_number,
+ odpd.technology_number,
+ odpds.reporting_work_num_count as numCounts,
+ ifnull( c.patchNumSum, 0 ) as patchNumSum,
+ odpd.reporting_work_num_count as numCount,
+ odpd.broken_num
+ FROM
+ sd.order_process_detail AS odpd
+ 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
+ pp.rework AS rw
+ LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
+ WHERE
+ position( #{selectProcesses} IN rwk.this_process )
+ AND rw.review_status >= 0
+ GROUP BY
+ rw.process_id,
+ rw.order_sort,
+ rw.technology_number
+ ) AS c ON c.process_id = odpd.process_id
+ AND c.order_sort = odpd.order_number
+ AND c.technology_number = odpd.technology_number
+ WHERE
+ position(#{selectProcesses} IN odpd.process ) and odpds.reporting_work_num_count is not null
+ GROUP BY
+ odpd.process_id,
+ odpd.order_number,
+ odpd.technology_number,
+ odpd.process
+
+ ) as d
+ on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
+ and position(#{selectProcesses} in d.process)
+ left join sd.`order` as o on o.order_id=od.order_id
+ where o.create_order>0
+ and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
+ and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
+ and position(#{selectProcesses} in d.process)
+
+ <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
+ and o.project regexp #{workInProgressDTO.project}
+ </if>
+
+ group by d.process
+ order by d.process
+ limit #{offset},#{pageSize};
+ </select>
+
+ <select id="workInProgressCombinationOrderFootSum">
+ SELECT SUM(aa.quantity) AS quantity,
+ sum(aa.stockNum) AS stockNum,
+ SUM(aa.stockArea) AS stockArea,
+ count(* ) AS 'total',
+ CEILING( count(* )/#{pageSize} ) AS 'pageTotal'
+ from
+ (
+ SELECT (od.quantity) AS quantity,
+ d.numCounts + d.patchNumSum - d.numCount -d.broken_num as stockNum,
+ ROUND(ogd.child_width * ogd.child_height *
+ (d.numCounts + d.patchNumSum - d.numCount -
+ d.broken_num) / 1000000, 2) as stockArea
+ 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 pp.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 (
+ SELECT
+ odpd.process,
+ odpd.process_id,
+ odpd.order_number,
+ odpd.technology_number,
+ odpds.reporting_work_num_count as numCounts,
+ ifnull( c.patchNumSum, 0 ) as patchNumSum,
+ odpd.reporting_work_num_count as numCount,
+ odpd.broken_num
+ FROM
+ sd.order_process_detail AS odpd
+ 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
+ pp.rework AS rw
+ LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
+ WHERE
+ position( #{selectProcesses} IN rwk.this_process )
+ AND rw.review_status >= 0
+ GROUP BY
+ rw.process_id,
+ rw.order_sort,
+ rw.technology_number
+ ) AS c ON c.process_id = odpd.process_id
+ AND c.order_sort = odpd.order_number
+ AND c.technology_number = odpd.technology_number
+ WHERE
+ position(#{selectProcesses} IN odpd.process ) and odpds.reporting_work_num_count is not null
+ GROUP BY
+ odpd.process_id,
+ odpd.order_number,
+ odpd.technology_number,
+ odpd.process
+
+ ) as d
+ on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
+ and position(#{selectProcesses} in d.process)
+ left join sd.`order` as o on o.order_id=od.order_id
+ where o.create_order>0
+ and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
+ and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
+ and position(#{selectProcesses} in d.process)
+
+ <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
+ and o.project regexp #{workInProgressDTO.project}
+ </if>
+ group by d.process
+ ) as aa
+ </select>
+
+ <select id="selectProcess">
+ SELECT basic_name
+ FROM sd.basic_data as bd
+ where bd.basic_category = 'process'
+ and bd.basic_type = 'product'
+ and basic_name!='鍒囧壊'
+ </select>
+
+ <select id="getWorkInProgressCombination">
+ select
+ #{process} as thisProcess,
+ if(#{optionVal} = 1,'',h.project) as project,
+ SUM(h.quantity) as stockNum,
+ SUM(h.glassArea) as stockArea,
+ if(#{optionVal} = 1,'',h.childName) as glassName
+
+ from (
+
+ SELECT g.*
+ ,GROUP_CONCAT(g.glass_child SEPARATOR '+') as childName
+ from( SELECT f.*,
+ e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num as quantity,
+ (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)*f.area as glassArea
+ from (SELECT a.order_id,
+ if(a.batch!="",CONCAT(a.project,'(',a.batch,')'),a.project) as project,
+ C.product_id,
+ b.order_number,
+ b.process_id,
+ b.technology_number,
+ b.reporting_work_num_count,
+ d.`group` ,
+ b.broken_num,
+ b.id,
+ c.area,
+ d.glass_child,
+ ifnull(cb.patchNumSum,0) as patchNumSum
+
+ FROM sd.`order` as a
+ LEFT JOIN sd.order_process_detail as b
+ on b.process = #{process} and a.order_id =b.order_id
+ LEFT JOIN sd.order_detail as c
+ on a.order_id = c.order_id and b.order_number =c.order_number
+ left join sd.order_glass_detail as d
+ on d.order_id =a.order_id and d.order_number = b.order_number and d.technology_number = b.technology_number
+ LEFT JOIN (
+ SELECT
+ IFNULL(sum( rw.rework_num ),0) AS 'patchNumSum',
+ rw.process_id,
+ rw.order_sort,
+ rw.technology_number,
+ rwk.this_process
+ FROM
+ pp.rework AS rw
+ LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
+ WHERE
+ position( #{process} IN rwk.this_process )
+ AND rw.review_status >= 0
+ GROUP BY
+ rw.process_id,
+ rw.order_sort,
+ rw.technology_number
+ ) AS cb ON cb.process_id = b.process_id
+ AND cb.order_sort = b.order_number
+ AND cb.technology_number = b.technology_number
+ where a.processing_card>0
+ and a.warehousing!=2
+ and (c.quantity-b.reporting_work_num)>0
+ GROUP BY b.process_id, b.order_number,
+ b.technology_number) as f
+ LEFT JOIN sd.order_process_detail as e
+ on e.id=(f.id-1) and e.process_id = f.process_id and e.order_number = f.order_number and e.technology_number =f.technology_number
+ where
+ e.id is not null
+ and (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)>0 group by f.process_id, f.order_number,
+ f.technology_number ORDER BY f.process_id, f.order_number,
+ f.technology_number) as g
+ <choose>
+ <when test="laminating == 'stepC' and process == '棰勫帇'">
+ GROUP BY g.process_id, g.order_number, g.technology_number
+ </when>
+ <when test="laminating == 'stepC'">
+ GROUP BY g.process_id, g.order_number, g.`group`
+ </when>
+ <when test="laminating == 'stepD'">
+ GROUP BY g.process_id, g.order_number
+ </when>
+ <otherwise>
+ GROUP BY g.process_id, g.order_number, g.technology_number
+ </otherwise>
+ </choose>
+
+
+ ) as h
+ <choose>
+ <when test="optionVal == 1">
+ GROUP BY thisProcess
+ </when>
+ <otherwise>
+ GROUP BY h.project,h.childName
+ </otherwise>
+ </choose>
+
+ </select>
+
+ <select id="getWorkInProgressCombinationFootSum">
+ select
+ SUM(h.quantity) as stockNum,
+ SUM(h.glassArea) as stockArea
+ from (
+ SELECT g.*
+ ,GROUP_CONCAT(g.glass_child SEPARATOR '+') as childName
+ from( SELECT f.*,
+ e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num as quantity,
+ (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)*f.area as glassArea
+ from (SELECT a.order_id,
+ a.project,
+ C.product_id,
+ b.order_number,
+ b.process_id,
+ b.technology_number,
+ b.reporting_work_num_count,
+ d.`group` ,
+ b.broken_num,
+ b.id,
+ c.area,
+ d.glass_child,
+ ifnull(cb.patchNumSum,0) as patchNumSum
+
+ FROM sd.`order` as a
+ LEFT JOIN sd.order_process_detail as b
+ on b.process = #{process} and a.order_id =b.order_id
+ LEFT JOIN sd.order_detail as c
+ on a.order_id = c.order_id and b.order_number =c.order_number
+ left join sd.order_glass_detail as d
+ on d.order_id =a.order_id and d.order_number = b.order_number and d.technology_number = b.technology_number
+ LEFT JOIN (
+ SELECT
+ IFNULL(sum( rw.rework_num ),0) AS 'patchNumSum',
+ rw.process_id,
+ rw.order_sort,
+ rw.technology_number,
+ rwk.this_process
+ FROM
+ pp.rework AS rw
+ LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
+ WHERE
+ position( #{process} IN rwk.this_process )
+ AND rw.review_status >= 0
+ GROUP BY
+ rw.process_id,
+ rw.order_sort,
+ rw.technology_number
+ ) AS cb ON cb.process_id = b.process_id
+ AND cb.order_sort = b.order_number
+ AND cb.technology_number = b.technology_number
+ where a.processing_card>0
+ and a.warehousing!=2
+ and (c.quantity-b.reporting_work_num)>0
+ GROUP BY b.process_id, b.order_number,
+ b.technology_number) as f
+ LEFT JOIN sd.order_process_detail as e
+ on e.id=(f.id-1) and e.process_id = f.process_id and e.order_number = f.order_number and e.technology_number =f.technology_number
+ where
+ e.id is not null
+ and e.reporting_work_num_count-f.reporting_work_num_count>0 group by f.process_id, f.order_number,
+ f.technology_number) as g
+ <choose>
+ <when test="laminating == 'stepC' and process == '棰勫帇'">
+ GROUP BY g.process_id, g.order_number, g.technology_number
+ </when>
+ <when test="laminating == 'stepC'">
+ GROUP BY g.process_id, g.order_number, g.`group`
+ </when>
+ <when test="laminating == 'stepD'">
+ GROUP BY g.process_id, g.order_number
+ </when>
+ <otherwise>
+ GROUP BY g.process_id, g.order_number, g.technology_number
+ </otherwise>
+ </choose>
+
+
+ ) as h
+
+ </select>
+
+ <select id="exportWorkInProgressCombination">
+ select
+ #{process} as thisProcess,
+ if(#{inputVal} = 1,'',h.project) as project,
+ SUM(h.quantity) as stockNum,
+ SUM(h.glassArea) as stockArea,
+ if(#{inputVal} = 1,'',h.childName) as glassName
+
+ from (
+
+ SELECT g.*
+ ,GROUP_CONCAT(g.glass_child SEPARATOR '+') as childName
+ from( SELECT f.*,
+ e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num as quantity,
+ (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)*f.area as glassArea
+ from (SELECT a.order_id,
+ a.project,
+ C.product_id,
+ b.order_number,
+ b.process_id,
+ b.technology_number,
+ b.reporting_work_num_count,
+ d.`group` ,
+ b.broken_num,
+ b.id,
+ c.area,
+ d.glass_child,
+ ifnull(cb.patchNumSum,0) as patchNumSum
+
+ FROM sd.`order` as a
+ LEFT JOIN sd.order_process_detail as b
+ on b.process = #{process} and a.order_id =b.order_id
+ LEFT JOIN sd.order_detail as c
+ on a.order_id = c.order_id and b.order_number =c.order_number
+ left join sd.order_glass_detail as d
+ on d.order_id =a.order_id and d.order_number = b.order_number and d.technology_number = b.technology_number
+ LEFT JOIN (
+ SELECT
+ IFNULL(sum( rw.rework_num ),0) AS 'patchNumSum',
+ rw.process_id,
+ rw.order_sort,
+ rw.technology_number,
+ rwk.this_process
+ FROM
+ pp.rework AS rw
+ LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
+ WHERE
+ position( #{process} IN rwk.this_process )
+ AND rw.review_status >= 0
+ GROUP BY
+ rw.process_id,
+ rw.order_sort,
+ rw.technology_number
+ ) AS cb ON cb.process_id = b.process_id
+ AND cb.order_sort = b.order_number
+ AND cb.technology_number = b.technology_number
+ where a.processing_card>0
+ and a.warehousing!=2
+ and (c.quantity-b.reporting_work_num_count)>0
+ GROUP BY b.process_id, b.order_number,
+ b.technology_number) as f
+ LEFT JOIN sd.order_process_detail as e
+ on e.id=(f.id-1) and e.process_id = f.process_id and e.order_number = f.order_number and e.technology_number =f.technology_number
+ where
+ e.id is not null
+ and (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)>0 ) as g
+ <choose>
+ <when test="laminating == 'stepC' and process == '棰勫帇'">
+ GROUP BY g.process_id, g.order_number, g.technology_number
+ </when>
+ <when test="laminating == 'stepC'">
+ GROUP BY g.process_id, g.order_number, g.`group`
+ </when>
+ <when test="laminating == 'stepD'">
+ GROUP BY g.process_id, g.order_number
+ </when>
+ <otherwise>
+ GROUP BY g.process_id, g.order_number, g.technology_number
+ </otherwise>
+ </choose>
+
+
+ ) as h
+ <choose>
+ <when test="inputVal == 1">
+ GROUP BY thisProcess
+ </when>
+ <otherwise>
+ GROUP BY h.project,h.childName
+ </otherwise>
+ </choose>
+ </select>
+
+
+ <select id="processCardProgressCollectMp">
+ select * from (select b.product_name,
+ c.detail as 'glassName',
+ concat(a.process_id,'/',a.technology_number) as processID,
+ a.process_id,
+ a.quantity,
+ a.received_quantity,
+ round(sum(a.received_quantity*b.area),2) as received_area,
+
+ a.technology_number
+ from pp.flow_card as a
+ left join sd.order_detail as b
+ on a.order_id = b.order_id and a.order_number = b.order_number
+ left join sd.product_detail as c
+ on c.prod_id = b.product_id and c.glass_sort = a.technology_number
+ where a.order_id = #{orderId} group by processID
+ ) as a
+ left join (SELECT process_id,
+ technology_number,
+ sum(broken_num) as broken_num,
+ concat('{',GROUP_CONCAT(reporting_work_nums),'}') as reporting_work_num
+ from (select
+ opd.process_id,
+ opd.technology_number,
+ concat("\"", process, "\":\"", SUM(reporting_work_num), "\"") as reporting_work_nums,
+ sum(broken_num) as broken_num
+ from sd.order_process_detail as opd
+ where opd.order_id = #{orderId}
+ group by opd.process_id,opd.technology_number,opd.process) as bb
+ GROUP BY bb.process_id,bb.technology_number) as b
+ on a.process_id = b.process_id and a.technology_number = b.technology_number
+ order by a.process_id
+
+ </select>
</mapper>
\ No newline at end of file
--
Gitblit v1.8.0