| | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.production.pojo.ProductionOperationTask"> |
| | | <id column="id" property="id" /> |
| | | <result column="technology_routing_operation_id" property="technologyRoutingOperationId" /> |
| | | <result column="production_order_routing_operation_id" property="productionOrderRoutingOperationId" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="work_order_no" property="workOrderNo" /> |
| | |
| | | <result column="dept_id" property="deptId" /> |
| | | </resultMap> |
| | | |
| | | <select id="pageProductionOperationTask" resultType="com.ruoyi.production.bean.vo.ProductionOperationTaskVo"> |
| | | select pot.*, |
| | | po.nps_no as npsNo, |
| | | po.is_end_order as endOrder, |
| | | p.product_name as productName, |
| | | pm.model as model, |
| | | pm.unit as unit, |
| | | poro.operation_name as operationName, |
| | | ROUND(pot.complete_quantity / pot.plan_quantity * 100, 2) AS completionStatus, |
| | | CASE |
| | | WHEN pot.work_order_no LIKE 'FG%' THEN '返工返修' |
| | | ELSE '正常' |
| | | END AS work_order_type |
| | | from production_operation_task pot |
| | | left join production_order po on pot.production_order_id = po.id |
| | | left join production_order_routing_operation poro on pot.production_order_routing_operation_id = poro.id |
| | | left join product_model pm on pm.id = ifnull(poro.product_model_id, po.product_model_id) |
| | | left join product p on pm.product_id = p.id |
| | | <where> |
| | | <if test="c != null and c.id != null"> |
| | | and pot.id = #{c.id} |
| | | </if> |
| | | <if test="c != null and c.productionOrderId != null"> |
| | | and pot.production_order_id = #{c.productionOrderId} |
| | | </if> |
| | | <if test="c != null and c.productionOrderRoutingOperationId != null"> |
| | | and pot.production_order_routing_operation_id = #{c.productionOrderRoutingOperationId} |
| | | </if> |
| | | <if test="c != null and c.status != null"> |
| | | and pot.status = #{c.status} |
| | | </if> |
| | | <if test="c != null and c.workOrderNo != null and c.workOrderNo != ''"> |
| | | and pot.work_order_no like concat('%', #{c.workOrderNo}, '%') |
| | | </if> |
| | | </where> |
| | | order by pot.id desc |
| | | </select> |
| | | |
| | | <select id="selectTaskStatisticsByDate" resultType="com.ruoyi.home.dto.ProductionTaskStatisticsDto"> |
| | | select pot.id, |
| | | pot.work_order_no, |
| | | pot.plan_start_time as planStartTime, |
| | | pot.plan_end_time as planEndTime, |
| | | pot.actual_start_time as actualStartTime, |
| | | pot.actual_end_time as actualEndTime, |
| | | pot.plan_quantity as planQuantity, |
| | | ifnull(pot.complete_quantity, 0) as completeQuantity, |
| | | poro.operation_name as processName, |
| | | p.product_name as productName, |
| | | pm.model, |
| | | pm.unit, |
| | | po.nps_no as productOrderNpsNo |
| | | from production_operation_task pot |
| | | left join production_order po on pot.production_order_id = po.id |
| | | left join production_order_routing_operation poro on pot.production_order_routing_operation_id = poro.id |
| | | left join product_model pm on pm.id = ifnull(poro.product_model_id, po.product_model_id) |
| | | left join product p on pm.product_id = p.id |
| | | where date(pot.create_time) between #{startDate} and #{endDate} |
| | | order by pot.create_time desc |
| | | </select> |
| | | |
| | | <select id="selectTaskStartStats" resultType="com.ruoyi.home.dto.ProductionTaskStatisticsDto"> |
| | | select id, |
| | | actual_start_time as actualStartTime, |
| | | plan_quantity as planQuantity |
| | | from production_operation_task |
| | | where actual_start_time >= #{startDateTime} |
| | | and actual_start_time <= #{endDateTime} |
| | | </select> |
| | | |
| | | <select id="calculateProductionStatistics" resultType="com.ruoyi.home.dto.processDataProductionStatisticsDto"> |
| | | select poro.operation_name as processName, |
| | | sum(ifnull(ppi.input_quantity, 0)) as totalInput, |
| | | sum(ifnull(ppo.scrap_qty, 0)) as totalScrap, |
| | | sum(ifnull(ppo.quantity, 0) - ifnull(ppo.scrap_qty, 0)) as totalOutput |
| | | from production_product_output ppo |
| | | inner join production_product_main ppm on ppo.production_product_main_id = ppm.id |
| | | inner join production_operation_task pot on ppm.production_operation_task_id = pot.id |
| | | left join production_order_routing_operation poro on pot.production_order_routing_operation_id = poro.id |
| | | left join production_product_input ppi on ppi.production_product_main_id = ppm.id |
| | | <where> |
| | | <if test="startDateTime != null"> |
| | | and ppo.create_time >= #{startDateTime} |
| | | </if> |
| | | <if test="endDateTime != null"> |
| | | and ppo.create_time <= #{endDateTime} |
| | | </if> |
| | | <if test="userId != null"> |
| | | and ppm.create_user = #{userId} |
| | | </if> |
| | | <if test="processIds != null and processIds.size() > 0"> |
| | | and poro.technology_operation_id in |
| | | <foreach collection="processIds" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | group by poro.technology_operation_id, poro.operation_name |
| | | </select> |
| | | |
| | | <select id="getProductWorkOrderFlowCard" resultType="com.ruoyi.production.bean.dto.ProductionOperationTaskDto"> |
| | | SELECT pot.*, |
| | | poro.operation_name AS processName, |
| | | pm.model AS model, |
| | | pm.unit AS unit, |
| | | p.product_name AS productName, |
| | | po.nps_no AS productOrderNpsNo, |
| | | ROUND(IFNULL(pot.complete_quantity, 0) / NULLIF(pot.plan_quantity, 0) * 100, 2) AS completionStatus, |
| | | IFNULL(scrapStat.scrapQty, 0) AS scrapQty |
| | | FROM production_operation_task pot |
| | | LEFT JOIN production_order po ON pot.production_order_id = po.id |
| | | LEFT JOIN production_order_routing_operation poro ON pot.production_order_routing_operation_id = poro.id |
| | | LEFT JOIN product_model pm ON pm.id = ifnull(poro.product_model_id, po.product_model_id) |
| | | LEFT JOIN product p ON p.id = pm.product_id |
| | | LEFT JOIN ( |
| | | SELECT ppm.production_operation_task_id AS taskId, |
| | | SUM(IFNULL(ppo.scrap_qty, 0)) AS scrapQty |
| | | FROM production_product_main ppm |
| | | LEFT JOIN production_product_output ppo ON ppo.production_product_main_id = ppm.id |
| | | GROUP BY ppm.production_operation_task_id |
| | | ) scrapStat ON scrapStat.taskId = pot.id |
| | | WHERE pot.id = #{id} |
| | | </select> |
| | | |
| | | </mapper> |