<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
~
|
~ Copyright (c) 2018-2025, ztt All rights reserved.
|
~
|
~ Redistribution and use in source and binary forms, with or without
|
~ modification, are permitted provided that the following conditions are met:
|
~
|
~ Redistributions of source code must retain the above copyright notice,
|
~ this list of conditions and the following disclaimer.
|
~ Redistributions in binary form must reproduce the above copyright
|
~ notice, this list of conditions and the following disclaimer in the
|
~ documentation and/or other materials provided with the distribution.
|
~ Neither the name of the pig4cloud.com developer nor the names of its
|
~ contributors may be used to endorse or promote products derived from
|
~ this software without specific prior written permission.
|
~ Author: ztt
|
~
|
-->
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.chinaztt.mes.production.mapper.OperationTaskMapper">
|
|
<resultMap id="operationTaskDtoMap" type="com.chinaztt.mes.production.dto.OperationTaskDTO">
|
<id property="id" column="id"/>
|
<result property="optaskNo" column="optask_no"/>
|
<result property="createTime" column="create_time"/>
|
<result property="routingId" column="routing_id"/>
|
<result property="moRoutingId" column="mo_routing_id"/>
|
<result property="moRoutingOperationId" column="mo_routing_operation_id"/>
|
<result property="routingOperationId" column="routing_operation_id"/>
|
<result property="state" column="state"/>
|
<result property="splannedQuantity" column="splanned_quantity"/>
|
<result property="plannedQuantity" column="planned_quantity"/>
|
<result property="completedQuantity" column="completed_quantity"/>
|
<result property="plannedStartDate" column="planned_start_date"/>
|
<result property="plannedFinishDate" column="planned_finish_date"/>
|
<result property="actualStartDate" column="actual_start_date"/>
|
<result property="actualFinishDate" column="actual_finish_date"/>
|
<result property="remark" column="remark"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="unit" column="unit"/>
|
<result property="operationNo" column="operation_no"/>
|
<result property="operationName" column="operation_name"/>
|
<result property="operationTaskType" column="operation_task_type"/>
|
<result property="workstationId" column="workstation_id"/>
|
<result property="technologyName" column="technology_name"/>
|
<result property="technologyRequirement" column="technology_requirement"/>
|
<result property="manufacturingOrder" column="manufacturing_order"/>
|
<result property="salesOrder" column="sales_order"/>
|
<result property="customer" column="customer"/>
|
<result property="priority" column="priority"/>
|
<result property="workstationName" column="workstation_name"/>
|
<result property="routingNo" column="routing_no"/>
|
<result property="workstationNo" column="workstation_no"/>
|
<result property="moNo" column="mo_no"/>
|
<result property="mpsNo" column="mps_no"/>
|
<result property="customerOrderNo" column="customer_order_no"/>
|
<result property="customerName" column="customer_name"/>
|
<result property="quantitySupply" column="quantity_supply"/>
|
<result property="reservedQuantity" column="reserved_quantity"/>
|
<result property="discNum" column="disc_num"/>
|
<result property="bomId" column="bom_id"/>
|
<result property="moId" column="mo_id"/>
|
<result property="combineState" column="combine_state"/>
|
<result property="locationId" column="location_id"/>
|
<result property="locationNo" column="location_no"/>
|
<result property="locationName" column="location_name"/>
|
<result property="hourQuota" column="hour_quota"/>
|
<result property="routingOperationRemark" column="routing_operation_remark"/>
|
<result property="workCenter" column="work_center"/>
|
<result property="manufactureAttr" column="manufacture_attr"/>
|
<result property="productName" column="product_name"/>
|
<result property="insulationColor" column="insulation_color"/>
|
<result property="outerColor" column="outer_color"/>
|
<result property="reelSpec" column="reel_spec"/>
|
<result property="pcoId" column="pco_id"/>
|
<result property="ratio" column="ratio"/>
|
<result property="mpsId" column="mps_id"/>
|
<result property="isSubmit" column="is_submit"/>
|
</resultMap>
|
|
<resultMap id="applyType" type="com.chinaztt.mes.production.dto.ApplyReportTypeDetailDTO">
|
<result property="typeCode" column="value"/>
|
<result property="typeName" column="label"/>
|
</resultMap>
|
|
<resultMap id="operationTaskFromMoMap" type="com.chinaztt.mes.production.dto.OperationTaskDTO">
|
<result property="operationId" column="operation_id"></result>
|
<result property="operationNo" column="operation_no"></result>
|
<result property="operationName" column="operation_name"></result>
|
<result property="workCenter" column="work_center"></result>
|
<result property="workstationId" column="workstation_id"></result>
|
<result property="operationTaskType" column="operation_task_type"/>
|
<result property="workstationNo" column="workstation_no"></result>
|
<result property="workstationName" column="workstation_name"></result>
|
<result property="partId" column="part_id"></result>
|
<result property="partNo" column="part_no"></result>
|
<result property="partName" column="part_name"></result>
|
<result property="plannedQuantity" column="planned_quantity"></result>
|
<result property="locationId" column="location_id"></result>
|
<result property="locationNo" column="location_no"></result>
|
<result property="locationName" column="location_name"></result>
|
<result property="moRoutingOperationId" column="mo_routing_operation_id"></result>
|
<result property="routingOperationId" column="routing_operation_id"></result>
|
<result property="moId" column="mo_id"></result>
|
<result property="moNo" column="mo_no"></result>
|
<result property="plannedStartDate" column="planned_start_date"></result>
|
<result property="plannedFinishDate" column="planned_finish_date"></result>
|
<result property="manufactureAttr" column="manufacture_attr"/>
|
<result property="reelSpec" column="reel_spec"/>
|
<collection property="workstations" ofType="com.chinaztt.mes.basic.entity.Workstation"
|
column="work_center" select="com.chinaztt.mes.basic.mapper.WorkstationMapper.selectByWorkcenter">
|
</collection>
|
</resultMap>
|
|
<resultMap id="basicLocationMap" type="com.chinaztt.mes.basic.entity.Location">
|
<id property="id" column="id"/>
|
<result property="locNo" column="loc_no"/>
|
<result property="locName" column="loc_name"/>
|
<result property="locDesc" column="loc_desc"/>
|
<result property="locStatus" column="loc_status"/>
|
<result property="active" column="active"/>
|
<result property="ifsLocation" column="ifs_location"/>
|
</resultMap>
|
|
<select id="getFromMoOptionByMoId" resultMap="operationTaskFromMoMap">
|
SELECT
|
pmo."id" AS mo_id,
|
pmo.mo_no AS mo_no,
|
pmoro.operation_id,
|
pmoro.ID AS mo_routing_operation_id,
|
pmoro.technology_routing_operation_id AS routing_operation_id,
|
bto.operation_no,
|
bto."name" AS operation_name,
|
pmo.technology_routing_id AS routing_id,
|
pmoro.work_center,
|
pmoro.part_id,
|
bp.part_no,
|
bp.part_name,
|
bp.unit,
|
bp.sunit,
|
pmo.manufacture_attr,
|
CASE
|
WHEN pmso.qpa IS NULL THEN
|
pmo.qty_required
|
ELSE pmo.qty_required * pmso.qpa
|
END AS planned_quantity,
|
pmo.required_date AS planned_finish_date,
|
timezone('UTC' :: TEXT, now()) AS planned_start_date
|
FROM
|
plan_manufacturing_order_routing_operation pmoro
|
LEFT JOIN plan_manufacturing_order pmo ON pmoro.mo_id = pmo."id"
|
LEFT JOIN technology_operation bto ON bto."id" = pmoro.operation_id
|
LEFT JOIN basic_part bp ON bp."id" = pmoro.part_id
|
LEFT JOIN (SELECT * FROM plan_mo_structure_component WHERE plan_manufacturing_order_id = #{moId}) pmso
|
ON pmso.part_id = pmoro.part_id and pmso.operation_id = pmoro.operation_id
|
WHERE
|
pmoro.mo_id = #{moId}
|
</select>
|
|
<sql id="pageSql">
|
SELECT
|
P.part_name,
|
P.part_no,
|
P.unit,
|
o.NAME operation_name,
|
T.*,
|
G.mo_no,
|
w.name as workstation_name
|
FROM
|
production_operation_task T
|
LEFT JOIN basic_part P ON T.part_id = P.ID
|
LEFT JOIN plan_manufacturing_order_routing_operation ro ON ro.ID = T.mo_routing_operation_id
|
LEFT JOIN technology_operation o ON o.ID = ro.operation_id
|
LEFT JOIN production_operation_task_supply F ON f.operation_task_id = T."id"
|
LEFT JOIN plan_manufacturing_order G ON G."id" = F.mo_id
|
LEFT JOIN basic_workstation w on T.workstation_id = w.id
|
</sql>
|
|
<select id="getByPalletTransId" resultMap="operationTaskDtoMap">
|
SELECT
|
pot.*,
|
bp.part_name,
|
part_no,
|
bw."name" AS workstation_name
|
FROM
|
production_operation_task pot
|
LEFT JOIN basic_part bp ON bp."id" = pot.part_id
|
LEFT JOIN basic_workstation bw ON pot.workstation_id = bw."id"
|
LEFT JOIN warehouse_pallet_transports_optask wpto ON wpto.operation_task_id = pot."id"
|
WHERE wpto.transports_id = #{palletId}
|
</select>
|
|
<delete id="deleteOperationById">
|
DELETE
|
FROM production_operation_task
|
A
|
WHERE A."id" = #{id};
|
DELETE
|
FROM production_operation_task_material
|
B
|
WHERE B.operation_task_id = #{id};
|
DELETE
|
FROM production_operation_task_supply
|
D
|
WHERE D.operation_task_id = #{id};
|
UPDATE production_operation_task_produce
|
SET operation_task_id = NULL
|
WHERE
|
operation_task_id = #{id}
|
</delete>
|
|
<select id="queryPage" resultMap="operationTaskDtoMap">
|
select temp.*
|
from
|
(SELECT
|
P.part_name,
|
P.part_no,
|
P.unit,
|
o.NAME operation_name,
|
T.*,
|
G.mo_no,
|
w.name workstation_name,
|
pmps.mps_no,
|
pco.customer_name,
|
pco.customer_order_no,
|
round( T.completed_quantity / T.planned_quantity * 100, 2 ) AS ratio
|
FROM
|
production_operation_task T
|
LEFT JOIN basic_part P ON T.part_id = P.ID
|
LEFT JOIN plan_manufacturing_order_routing_operation ro ON ro.ID = T.mo_routing_operation_id
|
LEFT JOIN technology_operation o ON o.ID = ro.operation_id
|
LEFT JOIN production_operation_task_supply F ON f.operation_task_id = T."id"
|
LEFT JOIN plan_manufacturing_order G ON G."id" = F.mo_id
|
LEFT JOIN plan_master_production_schedule pmps ON pmps."id" = G.mps_id
|
LEFT JOIN plan_join_model_customer pjmc ON pjmc.model_id = pmps."id"
|
AND pjmc.model = 'plan_master_production_schedule'
|
LEFT JOIN plan_customer_order pco ON pco."id" = pjmc.customer_order_id
|
LEFT JOIN basic_workstation w on T.workstation_id = w.id
|
) temp
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
|
<select id="getListByWorkstationId" resultMap="operationTaskDtoMap">
|
<include refid="pageSql"/>
|
where t.workstation_id =#{workstationId} and t.state!='04completed' order by id desc limit 3
|
</select>
|
|
<select id="getOperationTask" resultMap="operationTaskDtoMap">
|
select oot."id",
|
oot.optask_no,
|
oot."state",
|
oot.planned_quantity,
|
oot.completed_quantity,
|
oot.priority,
|
oot.planned_start_date,
|
oot.planned_finish_date,
|
oot.actual_start_date,
|
oot.actual_finish_date,
|
oot.remark,
|
oot.workstation_id,
|
bp.part_no,
|
bp.part_name,
|
bp.unit,
|
oot.part_id,
|
oot.routing_id,
|
oot.mo_routing_operation_id,
|
pmo.mo_no,
|
pmo.mps_id,
|
top."name" operation_name,
|
oot.create_time,
|
oot.disc_num,
|
oot.sunit,
|
oot.splanned_quantity,
|
oot.manufacture_attr,
|
oot.reel_spec,
|
tr.id mo_routing_id,
|
tr.routing_no technology_name,
|
tro.operation_id,
|
tro.remark routing_operation_remark,
|
pmps.mps_no,
|
pco.customer_name,
|
pco.id as pco_id,
|
pco.customer_order_no,
|
pbp.part_name product_name,
|
oot.reel_spec
|
from production_operation_task oot
|
LEFT JOIN basic_part bp on bp."id" = oot.part_id
|
LEFT JOIN plan_manufacturing_order_routing_operation tro on tro."id" = oot.mo_routing_operation_id
|
LEFT JOIN plan_manufacturing_order_routing tr on tr."id" = tro.mo_routing_id
|
LEFT JOIN technology_operation top on top."id" = tro.operation_id
|
LEFT JOIN production_operation_task_supply pots on pots.operation_task_id = oot."id"
|
LEFT JOIN plan_manufacturing_order pmo on pmo."id" = pots.mo_id
|
LEFT JOIN plan_master_production_schedule pmps ON pmps.ID = pmo.mps_id
|
LEFT JOIN plan_join_model_customer pjmc
|
ON pjmc.model_id = pmps."id" AND pjmc.model = 'plan_master_production_schedule'
|
LEFT JOIN plan_customer_order pco ON pco."id" = pjmc.customer_order_id
|
LEFT JOIN basic_part pbp ON pbp."id" = pmps.part_id
|
<where>
|
<if test="stateLimit == true">
|
oot.state != '04completed' and oot.state != '05canceled' and oot.state != '06combined' and oot.state != '07unsubmit' and oot.state IS NOT NULL
|
</if>
|
<if test="ew.emptyOfWhere == false">
|
AND ${ew.SqlSegment}
|
</if>
|
<if test="productSn != null">
|
AND pmo.id IN (SELECT DISTINCT current_mo_id FROM plan_manufacturing_order_sn_generate WHERE product_sn = #{productSn} AND current_mo_id IS NOT null)
|
</if>
|
<if test="salesOrder != null">
|
<bind name="salesOrder" value="'%' + salesOrder + '%'"/>
|
AND pco.customer_order_no like #{salesOrder}
|
</if>
|
<if test="productName != null">
|
<bind name="productName" value="'%' + productName + '%'"/>
|
AND pbp.part_name like #{productName}
|
</if>
|
<if test="outBatchNo != null and operationStockStatus == true ">
|
AND pmo.mo_no = (select distinct pmo.mo_no
|
from production_operation_task pot
|
left join production_operation_task_supply pots on pots.operation_task_id = pot.id
|
left join plan_manufacturing_order pmo on pmo.id = pots.mo_id
|
left join production_product_main ppm on ppm.operation_task_id = pot.id
|
left join production_product_output ppo on ppo.product_main_id = ppm.id
|
where ppo.out_batch_no =#{outBatchNo} )
|
</if>
|
<if test="outBatchNo != null and operationStockStatus == false ">
|
AND pmps.mps_no = (select distinct pmps.mps_no
|
from production_operation_task pot
|
left join production_operation_task_supply pots on pots.operation_task_id = pot.id
|
left join plan_manufacturing_order pmo on pmo.id = pots.mo_id
|
left join plan_master_production_schedule pmps on pmo.mps_id = pmps.id
|
left join production_product_main ppm on ppm.operation_task_id = pot.id
|
left join production_product_output ppo on ppo.product_main_id = ppm.id
|
where ppo.out_batch_no =#{outBatchNo} )
|
</if>
|
<if test="mpsNo != null and mpsNo != ''">
|
<bind name="mpsNo" value="'%' + mpsNo + '%'"/>
|
AND pmps.mps_no like #{mpsNo}
|
</if>
|
</where>
|
order by oot.priority, oot.planned_finish_date:: date
|
</select>
|
|
|
<select id="getOperationTaskDTO" resultMap="operationTaskDtoMap">
|
SELECT
|
pot.*,
|
bp.part_name,
|
bp.part_no,
|
bp.unit,
|
ar.resource_name,
|
bw."name" workstation_name,
|
pmor.routing_no,
|
bto."name" operation_name,
|
pots.quantity_supply,
|
pmo.mo_no,
|
pmo.ID mo_id,
|
pmoro.operation_id,
|
to_char(planned_start_date, 'yyyy-MM-dd hh24:mi:ss') || ',' ||
|
to_char(planned_finish_date, 'yyyy-MM-dd hh24:mi:ss') planed_start_end_time
|
FROM
|
production_operation_task pot
|
LEFT JOIN basic_part bp ON pot.part_id = bp."id"
|
LEFT JOIN aps_resource ar ON ar."id" = pot.resource_id
|
LEFT JOIN basic_workstation bw ON bw."id" = pot.workstation_id
|
LEFT JOIN plan_manufacturing_order_routing_operation pmoro ON pmoro.ID = pot.mo_routing_operation_id
|
LEFT JOIN plan_manufacturing_order_routing pmor ON pmoro.mo_routing_id = pmor."id"
|
LEFT JOIN technology_operation bto ON bto.ID = pmoro.operation_id
|
LEFT JOIN production_operation_task_supply pots ON pots.operation_task_id = pot."id"
|
LEFT JOIN plan_manufacturing_order pmo ON pmo."id" = pots.mo_id
|
WHERE pot."id" = #{id}
|
</select>
|
|
<update id="updateCompletedQuantity">
|
UPDATE production_operation_task
|
SET completed_quantity = completed_quantity + #{diffQuantity}
|
WHERE id = #{id}
|
</update>
|
|
<select id="pdaPage" resultMap="operationTaskDtoMap">
|
SELECT id,
|
optask_no,
|
"state",
|
priority,
|
planned_quantity,
|
sunit,
|
splanned_quantity,
|
completed_quantity,
|
part_no,
|
part_name,
|
workstation_no,
|
workstation_name,
|
operation_no,
|
operation_name,
|
manufacture_attr
|
FROM (
|
SELECT pot.optask_no,
|
pot.priority,
|
pot.planned_quantity,
|
pot.completed_quantity,
|
pot."id",
|
pot.sunit,
|
pot.splanned_quantity,
|
pot.manufacture_attr,
|
bp.part_no,
|
bp.part_name,
|
bw.workstation_no,
|
bw."name" workstation_name,
|
top.operation_no,
|
top."name" operation_name,
|
pot."state"
|
FROM production_operation_task pot
|
LEFT JOIN basic_part bp on bp."id" = pot.part_id
|
LEFT JOIN basic_workstation bw on bw."id" = pot.workstation_id
|
LEFT JOIN plan_manufacturing_order_routing_operation tro on tro."id" = pot.mo_routing_operation_id
|
LEFT JOIN technology_operation top on top."id" = tro.operation_id
|
) tempA
|
<if test="ew.emptyOfWhere == false">
|
<where>
|
${ew.SqlSegment}
|
</where>
|
</if>
|
order by "id" desc
|
</select>
|
|
<select id="getLastOperationTask" resultMap="operationTaskDtoMap">
|
SELECT
|
pot.*
|
FROM
|
production_operation_task pot
|
LEFT JOIN production_operation_task_supply pots ON pots.operation_task_id = pot."id"
|
WHERE pot.routing_operation_id = (SELECT trof.to_id
|
FROM technology_routing_operation_ref trof
|
LEFT JOIN technology_routing_operation tro ON trof.from_id = tro."id"
|
LEFT JOIN production_operation_task pots ON tro."id" = pots.routing_operation_id
|
WHERE pots."id" = #{operationTaskId})
|
AND pots.mo_id = (SELECT apots.mo_id
|
FROM production_operation_task_supply apots
|
LEFT JOIN production_operation_task apot ON apots.operation_task_id = apot."id"
|
WHERE apot."id" = #{operationTaskId})
|
</select>
|
|
<select id="selectByIds" resultMap="operationTaskDtoMap">
|
SELECT
|
ot.*,
|
mo.bom_id,
|
ro.operation_id
|
FROM production_operation_task ot
|
LEFT JOIN production_operation_task_supply ts ON ts.operation_task_id = ot."id"
|
LEFT JOIN technology_routing_operation ro ON ro.ID = ot.routing_operation_id
|
LEFT JOIN plan_manufacturing_order mo ON mo."id" = ts.mo_id
|
where ot.id IN
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="getCombinedOperationTaskInfo" resultMap="operationTaskDtoMap">
|
SELECT
|
P.part_name,
|
P.part_no,
|
P.unit,
|
o.NAME operation_name,
|
T.*,
|
G.mo_no,
|
w.name workstation_name
|
FROM
|
production_operation_task T
|
LEFT JOIN basic_part P ON T.part_id = P.ID
|
LEFT JOIN plan_manufacturing_order_routing_operation ro ON ro.ID = T.mo_routing_operation_id
|
LEFT JOIN technology_operation o ON o.ID = ro.operation_id
|
LEFT JOIN production_operation_task_supply F ON f.operation_task_id = T."id"
|
LEFT JOIN plan_manufacturing_order G ON G."id" = F.mo_id
|
LEFT JOIN basic_workstation w ON T.workstation_id = w.id
|
WHERE
|
T.combine_task_id = #{id}
|
</select>
|
|
<select id="getApplyReportType" resultMap="applyType">
|
SELECT DISTINCT value,label
|
FROM sys_dict_item
|
WHERE type = 'apply_report_type'
|
</select>
|
|
<select id="getPalletOptaskCode" resultType="java.lang.String">
|
SELECT pot.optask_no
|
FROM warehouse_pallet_transports_optask wpto
|
LEFT JOIN production_operation_task pot ON pot."id" = wpto.operation_task_id
|
WHERE wpto.operation_task_id IN
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="getFeedLocationListByWorkstationNo" resultMap="basicLocationMap">
|
SELECT bl.*
|
FROM (SELECT * FROM basic_workstation_location WHERE location_type = 1) bwl --库位类型为投料库位
|
INNER JOIN (SELECT * FROM basic_workstation WHERE workstation_no = #{workstationNo}) bw ON bwl.workstation_id = bw."id"
|
INNER JOIN (SELECT * FROM basic_location WHERE active = 't' AND loc_status = 1) bl ON bwl.location_id = bl."id" --有效且状态为使用
|
</select>
|
|
<select id="getActiveOperationTaskListByWorkstationNo" resultMap="operationTaskDtoMap">
|
SELECT pot.*,bp.part_no,bp.part_name
|
FROM (SELECT * FROM production_operation_task WHERE "state" = '02inProgress' OR "state" = '01pending') pot --工单状态为进行中或等待中
|
INNER JOIN (SELECT * FROM basic_workstation WHERE workstation_no = #{workstationNo}) bw ON pot.workstation_id = bw."id"
|
INNER JOIN basic_part bp ON pot.part_id = bp."id"
|
</select>
|
|
<select id="getActiveOperationTaskListUnPointWorkstationByWorkstationNo" resultMap="operationTaskDtoMap">
|
SELECT pot.*,bp.part_no,bp.part_name
|
FROM (SELECT * FROM production_operation_task WHERE workstation_id IS NULL AND work_center IS NOT NULL AND ("state" = '02inProgress' OR "state" = '01pending')) pot --工单状态为进行中或等待中
|
INNER JOIN (SELECT * FROM basic_workstation WHERE work_center IS NOT NULL AND workstation_no = #{workstationNo}) bw ON pot.work_center = bw.work_center
|
INNER JOIN basic_part bp ON pot.part_id = bp."id"
|
</select>
|
<!--支持-->
|
<select id="getOperationInfoById" resultMap="operationTaskDtoMap">
|
SELECT
|
pot.*,
|
bp.part_name,
|
bp.part_no,
|
bp.unit,
|
ar.resource_name,
|
bw."name" workstation_name,
|
pmor.routing_no,
|
bto."name" operation_name,
|
pots.quantity_supply,
|
pmo.mo_no,
|
pmo.ID mo_id,
|
pmoro.operation_id,
|
pmo.outer_color,
|
pmo.insulation_color,
|
pmps.mps_no,
|
pco.customer_order_no
|
FROM
|
production_operation_task pot
|
LEFT JOIN basic_part bp ON pot.part_id = bp."id"
|
LEFT JOIN aps_resource ar ON ar."id" = pot.resource_id
|
LEFT JOIN basic_workstation bw ON bw."id" = pot.workstation_id
|
LEFT JOIN plan_manufacturing_order_routing_operation pmoro ON pmoro.ID = pot.mo_routing_operation_id
|
LEFT JOIN plan_manufacturing_order_routing pmor ON pmoro.mo_routing_id = pmor."id"
|
LEFT JOIN technology_operation bto ON bto.ID = pmoro.operation_id
|
LEFT JOIN production_operation_task_supply pots ON pots.operation_task_id = pot."id"
|
LEFT JOIN plan_manufacturing_order pmo ON pmo."id" = pots.mo_id
|
LEFT JOIN plan_master_production_schedule pmps ON pmps."id" = pmo.mps_id
|
LEFT JOIN plan_join_model_customer pjmc
|
ON pjmc.model_id = pmps."id" AND pjmc.model = 'plan_master_production_schedule'
|
LEFT JOIN plan_customer_order pco ON pco."id" = pjmc.customer_order_id
|
WHERE pot."id" = #{id}
|
</select>
|
|
<update id="updateNextPriority">
|
update
|
production_operation_task
|
set
|
priority = (
|
COALESCE ( (SELECT MAX ( priority ) FROM production_operation_task), 0 )
|
) + 1
|
where
|
id = #{id}
|
</update>
|
|
<update id="removeActualFinishDateById">
|
update
|
production_operation_task
|
set actual_finish_date = null
|
where
|
id = #{id}
|
</update>
|
|
<select id="getProdOutQtyByBatchNo" resultType="java.math.BigDecimal">
|
SELECT COALESCE(SUM(product_qty),0) product_qty FROM production_product_output WHERE out_batch_no = #{batchNo}
|
</select>
|
|
<select id="getOperationId" resultType="java.lang.Long">
|
SELECT pmoro.operation_id FROM
|
(SELECT * FROM production_product_output WHERE out_batch_no = #{batchNo}) ppo
|
INNER JOIN
|
production_product_main ppm ON ppo.product_main_id = ppm."id"
|
INNER JOIN
|
production_operation_task pot ON ppm.operation_task_id = pot."id"
|
INNER JOIN
|
plan_manufacturing_order_routing_operation pmoro ON pot.mo_routing_operation_id = pmoro."id"
|
</select>
|
|
<select id="getTaskMoNo" resultType="java.lang.String">
|
select pmo.mo_no
|
from production_operation_task pot
|
left join production_operation_task_supply pots on pots.operation_task_id = pot.id
|
left join plan_manufacturing_order pmo on pmo.id = pots.mo_id
|
where pot.id = #{id};
|
</select>
|
|
<select id="getAllTaskStateByTaskId" resultType="java.lang.String">
|
SELECT
|
pot.state
|
FROM production_operation_task pot
|
LEFT JOIN production_operation_task_supply pots on pots.operation_task_id = pot.id
|
WHERE pots.mo_id = (SELECT mo_id
|
FROM production_operation_task_supply
|
WHERE operation_task_id = #{id})
|
</select>
|
|
<select id="validateIsLastOperation" resultType="java.lang.Boolean">
|
SELECT
|
pmoro.is_last
|
FROM (SELECT * FROM production_operation_task WHERE id = #{id}) pot
|
INNER JOIN production_operation_task_supply pots ON pot."id" = pots.operation_task_id
|
INNER JOIN plan_manufacturing_order_routing_operation pmoro
|
ON pots.mo_id = pmoro.mo_id AND
|
pot.routing_operation_id = pmoro.technology_routing_operation_id;
|
</select>
|
|
<select id="getFirstOperationId" resultType="java.lang.Long">
|
SELECT pmoro.operation_id
|
FROM plan_manufacturing_order_routing_operation pmoro
|
LEFT JOIN production_operation_task_supply pots on pmoro.mo_id = pots.mo_id
|
LEFT JOIN production_operation_task pot
|
on pot.id = pots.operation_task_id
|
WHERE pot.id = #{operationTaskId}
|
ORDER BY pmoro.operation_order ASC
|
limit 1
|
</select>
|
|
<select id="getOperationIdByTaskId" resultType="java.lang.Long">
|
SELECT pmoro.operation_id
|
FROM plan_manufacturing_order_routing_operation pmoro
|
left join production_operation_task pot on pmoro.id = pot.mo_routing_operation_id
|
WHERE pot.id = #{operationTaskId}
|
</select>
|
|
<resultMap id="OperationTaskScreenVoMap" type="com.chinaztt.mes.production.vo.OperationTaskScreenVO">
|
<result property="workCenter" column="work_center"></result>
|
<result property="workstationName" column="workstation_name"></result>
|
<result property="operationName" column="operation_name"></result>
|
<result property="id" column="id"></result>
|
<result property="optaskNo" column="optask_no"></result>
|
<result property="state" column="state"></result>
|
<result property="plannedStartDate" column="planned_start_date"></result>
|
<result property="plannedFinishDate" column="planned_finish_date"></result>
|
<result property="actualStartDate" column="actual_start_date"></result>
|
<result property="actualFinishDate" column="actual_finish_date"></result>
|
<result property="partNo" column="part_no"></result>
|
<result property="partName" column="part_name"></result>
|
<result property="unit" column="unit"></result>
|
<result property="moNo" column="mo_no"></result>
|
<result property="mpsNo" column="mps_no"></result>
|
<result property="customerName" column="customer_name"></result>
|
<result property="customerOrderNo" column="customer_order_no"></result>
|
<result property="ratio" column="ratio"></result>
|
<result property="plannedQuantity" column="planned_quantity"></result>
|
<result property="completedQuantity" column="completed_quantity"></result>
|
</resultMap>
|
|
<select id="getByCustomerOrderId" resultMap="OperationTaskScreenVoMap">
|
SELECT
|
pot.work_center,
|
bw."name" workstation_name,
|
too."name" operation_name,
|
pot."id",
|
pot.optask_no,
|
pot."state",
|
pot.planned_start_date,
|
pot.planned_finish_date,
|
pot.actual_start_date,
|
pot.actual_finish_date,
|
bp.part_name,
|
bp.part_no,
|
bp.unit,
|
pmo.mo_no,
|
pmps.mps_no,
|
pco.customer_name,
|
pco.customer_order_no,
|
pot.completed_quantity completed_quantity,
|
pot.planned_quantity planned_quantity,
|
round(pot.completed_quantity / pot.planned_quantity * 100, 2) AS ratio
|
FROM
|
production_operation_task pot
|
LEFT JOIN basic_part bp ON pot.part_id = bp."id"
|
LEFT JOIN plan_manufacturing_order_routing_operation ro ON ro.ID = pot.mo_routing_operation_id
|
LEFT JOIN technology_operation too ON too.ID = ro.operation_id
|
LEFT JOIN production_operation_task_supply pots ON pots.operation_task_id = pot."id"
|
LEFT JOIN plan_manufacturing_order pmo ON pmo."id" = pots.mo_id
|
LEFT JOIN plan_master_production_schedule pmps ON pmps."id" = pmo.mps_id
|
LEFT JOIN plan_join_model_customer pjmc ON pjmc.model_id = pmps."id"
|
AND pjmc.model = 'plan_master_production_schedule'
|
LEFT JOIN plan_customer_order pco ON pco."id" = pjmc.customer_order_id
|
LEFT JOIN basic_workstation bw ON pot.workstation_id = bw.ID
|
<if test="customerOrderId != null">
|
WHERE pco."id" = #{customerOrderId}
|
</if>
|
ORDER BY pmo.schedule_theory_quantity_id ASC
|
</select>
|
</mapper>
|