diff --git a/aucma-production/src/main/resources/mapper/production/ProductPlanInfoMapper.xml b/aucma-production/src/main/resources/mapper/production/ProductPlanInfoMapper.xml index 38546c6..c6364a5 100644 --- a/aucma-production/src/main/resources/mapper/production/ProductPlanInfoMapper.xml +++ b/aucma-production/src/main/resources/mapper/production/ProductPlanInfoMapper.xml @@ -72,24 +72,25 @@ and pp.material_name like concat(concat('%', #{materialName}), '%') - and pp.productline_code = #{productLineCode} + and pl.PRODUCT_LINE_CODE = #{productLineCode} + and pp.productline_code = #{stationCode} and pp.plan_amount = #{planAmount} and pp.complete_amount = #{completeAmount} + + and bo.BEGIN_DATE between to_date(#{params.beginEndTime}, 'yyyy-mm-dd') and + to_date(#{params.endEndTime}, 'yyyy-mm-dd') + and pp.begin_time between to_date(#{params.beginBeginTime}, 'yyyy-mm-dd hh24:mi:ss') and to_date(#{params.endBeginTime}, 'yyyy-mm-dd hh24:mi:ss') - - and pp.end_time between to_date(#{params.beginEndTime}, 'yyyy-mm-dd hh24:mi:ss') and - to_date(#{params.endEndTime}, 'yyyy-mm-dd hh24:mi:ss') - and pp.is_flag = #{isFlag} and pp.created_by = #{createdBy} and pp.created_time = #{createdTime} and pp.updated_by = #{updatedBy} and pp.updated_time = #{updatedTime} - order by pp.order_code desc, pp.plan_code + order by bo.BEGIN_DATE desc - SELECT FACTORY_NAME, PRODUCT_LINE_NAME, STATION_CODE, @@ -142,8 +141,11 @@ AND BPP.PRODUCT_LINE_CODE = #{PRODUCT_LINE_CODE} - - AND BP.PRODUCT_LINE_CODE = #{STATION_CODE} + + AND BP.PRODUCT_LINE_CODE IN + + #{stationCode} + AND TO_CHAR(RQI.INSPECTOR_TIME, 'YYYY-MM-DD HH24:MI:SS') BETWEEN #{beginBeginTime} AND #{endBeginTime} @@ -155,7 +157,7 @@ GROUP BY FACTORY_NAME, PRODUCT_LINE_NAME, STATION_CODE, STATION_NAME ORDER BY REWORK_NUMBER - SELECT FY.FACTORY_NAME, BPP.PRODUCT_LINE_NAME, TO_CHAR(RQI.INSPECTOR_TIME, 'YYYY-MM-DD') INSPECTOR_TIME, @@ -170,6 +172,8 @@ LEFT JOIN BASE_PRODUCTLINE BPP ON BPP.PRODUCT_LINE_CODE = BP.PARENT_ID LEFT JOIN BASE_FACTORY FY ON FY.FACTORY_CODE = BPP.PLANT_CODE WHERE RQI.TREATMENT_MEASURE = 1 + AND (RQI.QUALITY_DEFECT_NAME LIKE '%少%' + OR RQI.QUALITY_DEFECT_NAME LIKE '%错%') AND BPP.PRODUCT_LINE_CODE = #{PRODUCT_LINE_CODE} @@ -187,10 +191,11 @@ RQI.QUALITY_DEFECT_CODE, RQI.QUALITY_DEFECT_NAME ORDER BY DEFECT_NUMBER DESC - SELECT BF.FACTORY_NAME, PL2.PRODUCT_LINE_CODE, PL2.PRODUCT_LINE_NAME, + GET_MATERIAL_TYPE(RQI.MATERIAL_NAME) MATERIAL_MODEL, RQI.QUALITY_DEFECT_CODE, QI.QUALITY_DEFECT_NAME, COUNT(*) Q_SUM, @@ -213,7 +218,10 @@ AND PL2.PRODUCT_LINE_CODE = #{PRODUCT_LINE_CODE} - GROUP BY BF.FACTORY_NAME, PL2.PRODUCT_LINE_CODE, PL2.PRODUCT_LINE_NAME, + + AND RQI.MATERIAL_NAME LIKE '%' || #{MATERIAL_MODEL} || '%' + + GROUP BY BF.FACTORY_NAME, PL2.PRODUCT_LINE_CODE, PL2.PRODUCT_LINE_NAME, GET_MATERIAL_TYPE(RQI.MATERIAL_NAME), RQI.QUALITY_DEFECT_CODE, QI.QUALITY_DEFECT_NAME, OS.OFFLINE_NUM ORDER BY PL2.PRODUCT_LINE_CODE, Q_SUM DESC @@ -334,39 +342,60 @@ ORDER BY PL.EXECUTION_SORT, RQI.INSPECTOR_TIME - + SELECT ZSD.ORDER_CODE, + ZSD.SALEORDER_CODE, + ZSD.SALEORDER_LINENUMBER, + ZSD.MATERIAL_CODE, + ZSD.MATERIAL_MODEL, + ZSD.ORDER_AMOUNT, + SUM(ZSD.BEFORE_NUMBER) BEFORE_NUMBER, + SUM(ZSD.SCAN_NUMBER) SCAN_NUMBER, + SUM(ZSD.BEFORE_NUMBER) - SUM(ZSD.SCAN_NUMBER) DIFF_NUMBER, + SUM(ZSD.SCRAP_NUMBER) SCRAP_NUMBER + FROM (SELECT BO.ORDER_CODE, + BO.SALEORDER_CODE, + BO.SALEORDER_LINENUMBER, + BO.MATERIAL_CODE, + BM.MATERIAL_SPECIFICATIONS MATERIAL_MODEL, + OM.BARCODE_CODE, + BO.ORDER_AMOUNT, + COUNT(*) BEFORE_NUMBER, + MAX(CASE WHEN OL.BOX_CODE IS NULL THEN 0 ELSE 1 END) SCAN_NUMBER, + MAX(CASE WHEN BF.BAR_CODE IS NULL THEN 0 ELSE 1 END) SCRAP_NUMBER FROM BASE_ORDERINFO BO - JOIN BASE_MATERIALINFO BM ON BM.MATERIAL_CODE = BO.MATERIAL_CODE AND bm.DISPO IN ('100') - JOIN (SELECT BC.ORDER_CODE, COUNT(*) BEFORE_NUMBER - FROM RECORD_INSTORE IE - JOIN C##AUCMA_SCADA.PRINT_BARCODE BC ON BC.MATERIAL_BARCODE = IE.MATERIAL_CODE - WHERE IE.STORE_CODE = 'PQK-001' + JOIN BASE_MATERIALINFO BM ON BM.MATERIAL_CODE = BO.MATERIAL_CODE AND bm.DISPO IN ('100') + JOIN (SELECT BC.ORDER_CODE, IE.BARCODE_CODE + FROM RECORD_INSTORE IE + JOIN C##AUCMA_SCADA.PRINT_BARCODE BC ON BC.MATERIAL_BARCODE = IE.BARCODE_CODE + JOIN BASE_ORDERINFO OI ON OI.ORDER_CODE = BC.ORDER_CODE + JOIN BASE_PRODUCTLINE PL ON PL.WORK_CENTER_CODE = OI.WORK_CENTER_CODE + WHERE IE.STORE_CODE = 'PQK-001' + AND PL.PRODUCT_LINE_CODE = #{productLineCode} AND TO_CHAR(IE.IN_STORE_TIME, 'YYYY-MM-DD HH24:MI:SS') BETWEEN #{beginBeginTime} AND #{endBeginTime} - GROUP BY BC.ORDER_CODE) OM ON OM.ORDER_CODE = BO.ORDER_CODE - LEFT JOIN (SELECT SUBSTR(PRODUCT_ORDER_NO, -8) ORDER_CODE, COUNT(*) SCAN_NUMBER - FROM C##AUCMA_SCADA.PRODUCT_OFFLINE - GROUP BY SUBSTR(PRODUCT_ORDER_NO, -8)) OL ON OL.ORDER_CODE = BO.ORDER_CODE - LEFT JOIN (SELECT ORDER_CODE, SUM(SCRAP_NUMBER) SCRAP_NUMBER - FROM ( - SELECT BC.ORDER_CODE, - QI.BAR_CODE, - MAX(CASE WHEN QI.PROCESS_RESULT = '报废重做' THEN 1 ELSE 0 END) SCRAP_NUMBER - FROM REPORT_QUALITY_INSPECTION QI - JOIN C##AUCMA_SCADA.PRINT_BARCODE BC ON BC.MATERIAL_BARCODE = QI.BAR_CODE - GROUP BY BC.ORDER_CODE, QI.BAR_CODE) - GROUP BY ORDER_CODE) BF ON BF.ORDER_CODE = BO.ORDER_CODE + and BC.ORDER_CODE = #{productOrderNo} + GROUP BY BC.ORDER_CODE, IE.BARCODE_CODE) OM ON OM.ORDER_CODE = BO.ORDER_CODE + LEFT JOIN C##AUCMA_SCADA.PRODUCT_OFFLINE OL ON OL.BOX_CODE = OM.BARCODE_CODE + LEFT JOIN (SELECT BAR_CODE, SUM(SCRAP_NUMBER) SCRAP_NUMBER + FROM (SELECT QI.BAR_CODE, + COUNT(*) SCRAP_NUMBER + FROM REPORT_QUALITY_INSPECTION QI + WHERE QI.PROCESS_RESULT = '报废重做' + GROUP BY QI.BAR_CODE) + GROUP BY BAR_CODE) BF ON BF.BAR_CODE = OM.BARCODE_CODE + + and BO.MATERIAL_CODE = #{productCode} + and BM.MATERIAL_SPECIFICATIONS LIKE '%' || #{productModel} + || '%' + + + GROUP BY BO.ORDER_CODE, BO.SALEORDER_CODE, BO.SALEORDER_LINENUMBER, BO.MATERIAL_CODE, + BM.MATERIAL_SPECIFICATIONS, + BO.ORDER_AMOUNT, OM.BARCODE_CODE) ZSD + GROUP BY ZSD.ORDER_CODE, ZSD.SALEORDER_CODE, ZSD.SALEORDER_LINENUMBER, ZSD.MATERIAL_CODE, + ZSD.MATERIAL_MODEL, ZSD.ORDER_AMOUNT