SELECT opo."id",
opo.part_id,
opo.out_batch_no,
opo.reel_number,
opo.system_no,
opo.ifs_opfeed_id,
opo.ifs_labor_id,
bp.part_no,
bp.part_name,
bp.description part_description,
top.operation_no,
top."name" operation_name,
opo.product_main_id,
opo.product_qty,
bp.unit,
opo.sproduct_qty,
bp.sunit,
opm.product_no,
opo.state,
opo.start_meter_mark,
opo.end_meter_mark,
opo.scrap_qty,
tro.operation_id,
bp.planning_method,
opo.ifs_batch_no,
opo.segment_desc,
opo.scrap_qty,
opo.remark,
opo.shift_output_id,
opo.ifs_sync
FROM production_product_output opo
LEFT JOIN basic_part bp ON bp."id" = opo.part_id
LEFT JOIN production_product_main opm ON opm."id" = opo.product_main_id
LEFT JOIN production_operation_task oot ON oot."id" = opm.operation_task_id
LEFT JOIN plan_manufacturing_order_routing_operation tro ON tro."id" = oot.mo_routing_operation_id
LEFT JOIN technology_operation top ON top."id" = tro.operation_id
WHERE opo.product_main_id = #{mainId}
ORDER BY opo.system_no
select temp.*
from
(select
opm.product_no,
oot.optask_no,
opo.reel_number,
top."name" operation_name,
bp.part_no,
bp.part_name,
bp.description part_description,
bp.specs,
oot.planned_quantity,
opo.product_qty,
round(opo.product_qty / oot.planned_quantity * 100, 2) progress,
opo.create_time
from production_product_output opo
left join basic_part bp on bp."id" = opo.part_id
left join production_product_main opm on opm."id" = opo.product_main_id
left join production_operation_task oot on oot."id" = opm.operation_task_id
LEFT JOIN plan_manufacturing_order_routing_operation tro ON tro."id" = oot.mo_routing_operation_id
left join technology_operation top on top."id" = tro.operation_id
WHERE opm."state" = '02submitted'
) temp
${ew.customSqlSegment}
SELECT s.staff_no,
bs.staff_name,
bs.id || '' staff_id,
s.duty_record_id,
s.quantity,
s.system_no,
s.date,
s.artificial_type status,
opo."id",
opo.part_id,
opo.out_batch_no,
bp.part_no,
bp.part_name,
bp.description part_description,
top.operation_no,
top."name" operation_name,
opo.product_main_id,
opo.product_qty,
opo.sproduct_qty,
bp.unit,
opm.product_no,
opo.reel_number,
opo.start_meter_mark,
opo.end_meter_mark,
opo.ifs_batch_no,
opo.segment_desc,
opo.scrap_qty,
opo.remark,
opo.create_time
FROM production_product_output_staff s
LEFT JOIN production_product_output opo ON opo.id = s.product_out_id
LEFT JOIN basic_part bp ON bp."id" = opo.part_id
LEFT JOIN production_product_main opm ON opm."id" = opo.product_main_id
LEFT JOIN production_operation_task oot ON oot."id" = opm.operation_task_id
LEFT JOIN plan_manufacturing_order_routing_operation tro ON tro."id" = oot.mo_routing_operation_id
LEFT JOIN technology_operation top ON top."id" = tro.operation_id
LEFT JOIN basic_staff bs ON bs.staff_no = s.staff_no
WHERE opo.id = #{id}
AND s.artificial_type = TRUE
UNION ALL
SELECT array_to_string(array_agg(s.staff_no), ',') AS staff_no,
array_to_string(array_agg(bs.staff_name), ',') AS staff_name,
array_to_string(array_agg(bs.id), ',') AS staff_id,
s.duty_record_id,
s.quantity,
s.system_no,
s.date,
s.artificial_type status,
opo."id",
opo.part_id,
opo.out_batch_no,
bp.part_no,
bp.part_name,
bp.description part_description,
top.operation_no,
top."name" operation_name,
opo.product_main_id,
opo.product_qty,
opo.sproduct_qty,
bp.unit,
opm.product_no,
opo.reel_number,
opo.start_meter_mark,
opo.end_meter_mark,
opo.ifs_batch_no,
opo.segment_desc,
opo.scrap_qty,
opo.remark,
opo.create_time
FROM production_product_output_staff s
LEFT JOIN production_product_output opo ON opo.id = s.product_out_id
LEFT JOIN basic_part bp ON bp."id" = opo.part_id
LEFT JOIN production_product_main opm ON opm."id" = opo.product_main_id
LEFT JOIN production_operation_task oot ON oot."id" = opm.operation_task_id
LEFT JOIN plan_manufacturing_order_routing_operation tro ON tro."id" = oot.mo_routing_operation_id
LEFT JOIN technology_operation top ON top."id" = tro.operation_id
LEFT JOIN basic_staff bs ON bs.staff_no = s.staff_no
WHERE opo.id = #{id}
AND s.artificial_type = FALSE
GROUP BY s.system_no,
s.date,
s.artificial_type,
s.duty_record_id,
s.quantity,
opo."id",
opo.part_id,
opo.out_batch_no,
bp.part_no,
bp.part_name,
bp.description,
top.operation_no,
top."name",
opo.product_main_id,
opo.product_qty,
opo.sproduct_qty,
bp.unit,
opm.product_no,
opo.start_meter_mark,
opo.end_meter_mark,
opo.ifs_batch_no,
opo.segment_desc,
opo.scrap_qty,
opo.remark,
opo.reel_number,
opo.create_time
SELECT
ppo."id",
ppo.system_no,
ppo.out_batch_no,
ppo.product_qty,
ppo.sproduct_qty,
bp.unit,
bp.sunit,
bp.part_no,
bp.specs,
pot.optask_no,
ppo.reel_number,
puw.unit_work_factor,
round(ppo.product_qty * puw.unit_work_factor * 88,2) as qty_salary
FROM
production_product_output ppo
LEFT JOIN basic_part bp ON bp."id" = ppo.part_id
LEFT JOIN production_product_main ppm ON ppm."id" = ppo.product_main_id
LEFT JOIN production_operation_task pot ON pot."id" = ppm.operation_task_id
LEFT JOIN technology_routing_operation tro ON pot.routing_operation_id = tro."id"
LEFT JOIN production_unit_work puw ON puw.part_id = ppo.part_id
AND puw.operation_id = tro.operation_id
AND puw.workstation_id = ppm.workstation_id
WHERE exists(SELECT 1
FROM production_product_output_staff ppos
WHERE ppos.duty_record_id = #{dutyRecordId}
AND ppo."id" = ppos.product_out_id)
SELECT
distinct ppo."id",
ppo.system_no,
ppo.out_batch_no,
ppo.product_qty,
ppo.sproduct_qty,
bp.unit,
bp.sunit,
bp.part_no,
bp.specs,
pot.optask_no,
ppo.reel_number,
puw.unit_work_factor,
pdr.duty_no,
pdr.now_duty_date,
bst.name as shift_name,
round(ppo.product_qty * puw.unit_work_factor * 88,2) as qty_salary
FROM
production_product_output ppo
LEFT JOIN basic_part bp ON bp."id" = ppo.part_id
LEFT JOIN production_product_main ppm ON ppm."id" = ppo.product_main_id
LEFT JOIN production_operation_task pot ON pot."id" = ppm.operation_task_id
LEFT JOIN technology_routing_operation tro ON pot.routing_operation_id = tro."id"
LEFT JOIN production_unit_work puw ON puw.part_id = ppo.part_id
AND puw.operation_id = tro.operation_id
AND puw.workstation_id = ppm.workstation_id
LEFT JOIN production_product_output_staff ppos on ppo."id" = ppos.product_out_id
LEFT JOIN production_duty_record pdr on pdr."id"=ppos.duty_record_id
LEFT JOIN basic_shift bst on bst.id = pdr.shift_id
WHERE ppos.duty_record_id in
#{dutyRecordId}
DELETE
FROM production_product_output_staff
WHERE product_out_id IN (SELECT id FROM production_product_output WHERE product_main_id = #{mainId})
DELETE
FROM production_artificial_information
WHERE output_id IN (SELECT id FROM production_product_output WHERE product_main_id = #{mainId})
select temp.*
from
(select
ppo."id",
pot.optask_no,
ppo.system_no,
ppo.out_batch_no,
ppo.part_id,
bp.part_no,
bp.part_name,
ppo.product_qty,
ppo.sproduct_qty,
ppo.reel_number,
ppo.create_time,
bp.unit,
bp.sunit,
ppm.workstation_id,
ppm.product_no,
qr.is_qualified,
qr.is_used,
qr.remark,
qr.check_status,
qr.is_self_qualified,
pos.staff_name,
ppo.start_meter_mark,
ppo.end_meter_mark,
ppo.scrap_qty,
ppo.segment_desc,
ppo.remark
from production_product_output ppo
left join basic_part bp on bp."id" = ppo.part_id
left join production_product_main ppm on ppm."id" = ppo.product_main_id
left join production_operation_task pot on pot."id" = ppm.operation_task_id
left join
(select
system_no,
bool_and(is_qualified)is_qualified,
bool_and(is_used)is_used,
"max"(remark) remark,
"max"(check_status) check_status,
bool_and(is_self_qualified) is_self_qualified,
bool_and(is_erp) is_erp
from quality_result group by system_no) qr on qr.system_no = ppo.system_no and qr.is_erp = false
LEFT JOIN (
SELECT
ARRAY_AGG(s.staff_name) staff_name,
product_out_id
FROM
production_product_output_staff pos
LEFT JOIN basic_staff s ON pos.staff_id = s."id"
GROUP BY
product_out_id
) pos ON pos.product_out_id = ppo."id"
AND to_char( ppo.create_time, 'YYYYMMDD' ) between #{dto.startTime} and #{dto.endTime}
) temp
${ew.customSqlSegment}
select
ppo."id",
ppo.out_batch_no
from production_product_output ppo
where ppo.out_batch_no = #{dto.outBatchNo}
AND to_char( ppo.create_time, 'YYYYMMDD' ) between #{dto.startTime} and #{dto.endTime}
SELECT E.*
FROM (SELECT A.*,C.part_no,C.part_name,B.product_no,C.unit,c.sunit,D.id workstation_id,D.name workstation_name
FROM production_product_output A
LEFT JOIN production_product_main B ON B."id" = A.product_main_id
LEFT JOIN basic_workstation D ON D."id" = B.workstation_id
LEFT JOIN basic_part C ON C."id" = A.part_id
WHERE B.workstation_id = #{id}) E
${ew.customSqlSegment}
DELETE
FROM production_product_output_staff
WHERE product_out_id IN (SELECT id FROM production_product_output WHERE product_main_id = #{mainId})
select t1.*
from (SELECT ppo.*, ppos.duty_record_id
FROM production_product_output ppo
LEFT JOIN production_product_main ppm ON ppo.product_main_id = ppm."id"
LEFT JOIN (SELECT DISTINCT product_out_id, duty_record_id
FROM production_product_output_staff) ppos
ON ppos.product_out_id = ppo.ID
where ppo."state" = '03changeshift'
AND ppm.workstation_id = #{workstationId}
AND ppm.operation_task_id = #{opeartionTaskId}) t1
where not exists(select 1
FROM production_product_output ppo
LEFT JOIN production_product_main ppm ON ppo.product_main_id = ppm."id"
WHERE ppo."state" IN ('02submitted', '01draft')
AND ppm.workstation_id = #{workstationId}
AND ppm.operation_task_id = #{opeartionTaskId}
and t1.out_batch_no = ppo.out_batch_no)
ORDER BY t1."id" DESC
SELECT *
FROM production_product_output
WHERE out_batch_no = #{sn}
SELECT
COUNT(*)
FROM
production_product_output ppo
WHERE
ppo.shift_output_id in
#{id}
AND ppo.state = '02submitted'
update
production_product_output
set shift_output_id = null
where shift_output_id = #{id}
SELECT
"sum"(temp.product_qty)
FROM
(
SELECT
ppo."id",
pot.optask_no,
ppo.system_no,
ppo.out_batch_no,
ppo.part_id,
bp.part_no,
bp.part_name,
ppo.product_qty,
ppo.sproduct_qty,
ppo.reel_number,
ppo.create_time,
bp.unit,
bp.sunit,
ppm.workstation_id,
ppm.product_no,
qr.is_qualified,
qr.is_used,
qr.remark,
qr.check_status,
qr.is_self_qualified,
pos.staff_name,
ppo.start_meter_mark,
ppo.end_meter_mark,
ppo.scrap_qty,
ppo.segment_desc,
ppo.remark
FROM
production_product_output ppo
LEFT JOIN basic_part bp ON bp."id" = ppo.part_id
LEFT JOIN production_product_main ppm ON ppm."id" = ppo.product_main_id
LEFT JOIN production_operation_task pot ON pot."id" = ppm.operation_task_id
LEFT JOIN quality_result qr ON qr.system_no = ppo.system_no
AND qr.is_erp = FALSE
AND qr.apply_type = '01output'
LEFT JOIN (
SELECT ARRAY_AGG( s.staff_name ) staff_name,
product_out_id
FROM
production_product_output_staff pos
LEFT JOIN basic_staff s ON pos.staff_id = s."id"
GROUP BY
product_out_id
) pos ON pos.product_out_id = ppo."id"
AND to_char( ppo.create_time, 'YYYYMMDD' ) between #{dto.startTime} and #{dto.endTime}
) temp
${ew.customSqlSegment}
insert into production_product_output
(part_id, product_qty, create_time, create_user, product_main_id, out_batch_no,
system_no, sort_no, start_meter_mark, end_meter_mark,
reel_number, ifs_batch_no, segment_desc, scrap_qty, ifs_opfeed_id, ifs_labor_id,
remark, shift_output_id, sproduct_qty, reel_weight, gross_weight, net_weight, is_sn_generate_output,disc_tool_measurement )
values
(#{item.partId,jdbcType=BIGINT}, #{item.productQty,jdbcType=NUMERIC},
#{item.createTime,jdbcType=TIMESTAMP}, #{item.createUser,jdbcType=VARCHAR},
#{item.productMainId,jdbcType=BIGINT},
#{item.outBatchNo,jdbcType=VARCHAR}, #{item.systemNo,jdbcType=VARCHAR},
#{item.sortNo,jdbcType=BIGINT}, #{item.startMeterMark,jdbcType=NUMERIC},
#{item.endMeterMark,jdbcType=NUMERIC}, #{item.reelNumber,jdbcType=VARCHAR},
#{item.ifsBatchNo,jdbcType=VARCHAR}, #{item.segmentDesc,jdbcType=VARCHAR},
#{item.scrapQty,jdbcType=NUMERIC}, #{item.ifsOpfeedId,jdbcType=BIGINT}, #{item.ifsLaborId,jdbcType=BIGINT},
#{item.remark,jdbcType=VARCHAR}, #{item.shiftOutputId,jdbcType=BIGINT},
#{item.sproductQty,jdbcType=NUMERIC},
#{item.reelWeight,jdbcType=NUMERIC}, #{item.grossWeight,jdbcType=NUMERIC},
#{item.netWeight,jdbcType=NUMERIC}, #{item.isSnGenerateOutput,jdbcType=BOOLEAN}, #{item.discToolMeasurement,jdbcType=VARCHAR}
)
SELECT ppo.out_batch_no,
"replace"(bp.part_name, '馈线跳线 ', '') AS part_name
FROM production_product_output ppo
LEFT JOIN basic_part bp ON bp."id" = ppo.part_id
LEFT JOIN production_product_main ppm ON ppm."id" = ppo.product_main_id
WHERE ppm.operation_task_id = #{operationTaskId}
and ppm.workstation_id = #{workstationId}
order by ppo.out_batch_no asc
SELECT pco.customer_order_no,
pco.customer_name,
top.name operation_name,
bw.name as workstation_name,
bp.part_name,
bp.part_no,
bp.part_pitch,
bp.unit,
bp.lot_tracking_ifs,
bp2.part_name as end_product,
ppo.out_batch_no,
(SELECT sum(product_qty) FROM production_product_output WHERE out_batch_no = ppo.out_batch_no GROUP BY out_batch_no) AS product_qty,
ppo.reel_number,
to_char(NOW(), 'yyyy-mm-dd hh24:mi:ss') now_time,
ppo.remark,
ppo.reel_weight || 'kg' AS reel_weight,
ppo.gross_weight || 'kg' AS gross_weight,
ppo.net_weight || 'kg' AS net_weight,
ppo.theory_weight || 'kg' AS theory_weight,
ppo.segment_desc,
to_char(ppo.create_time, 'yyyy-mm-dd hh24:mi:ss') production_time,
ppos.production_person,
bcprm.cus_material_code,
ppo.ifs_batch_no as ifs_batch_no,
ppo.start_meter_mark,
ppo.end_meter_mark,
ppo.disc_tool_measurement
FROM production_product_output ppo
LEFT JOIN production_product_main ppm ON ppm.ID = ppo.product_main_id
LEFT JOIN production_operation_task ppt ON ppt.ID = ppm.operation_task_id
LEFT JOIN production_operation_task_supply pots ON ppt.ID = pots.operation_task_id
LEFT JOIN plan_manufacturing_order pmo ON pmo.ID = pots.mo_id
LEFT JOIN basic_part bp ON bp.ID = ppo.part_id
LEFT JOIN plan_join_model_customer pjmc ON pjmc.model_id = pmo.ID
AND pjmc.model = 'plan_manufacturing_order'
LEFT JOIN plan_customer_order pco ON pco.ID = pjmc.customer_order_id
LEFT JOIN basic_part bp2 ON bp2.part_no = pco.part_no
LEFT JOIN technology_routing_operation tro ON tro.ID = ppt.routing_operation_id
LEFT JOIN technology_operation top ON top.id = tro.operation_id
LEFT JOIN basic_workstation bw ON bw.ID = ppm.workstation_id
LEFT JOIN basic_customer_part_relation_map bcprm on bcprm.part_no = bp.part_no
LEFT JOIN (SELECT string_agg(bs.staff_name, ',') production_person,
ppos.product_out_id
FROM production_product_output_staff ppos
LEFT JOIN basic_staff bs ON ppos.staff_id = bs."id"
WHERE ppos.product_out_id in
#{id}
GROUP BY ppos.product_out_id) ppos ON ppos.product_out_id = ppo.id
WHERE ppo.ID in
#{id}
SELECT COALESCE(SUM(product_qty),0) product_qty FROM production_product_output WHERE out_batch_no = #{batchNo}
select ppo.*
from production_product_output ppo
left join production_product_main ppm on ppo.product_main_id = ppm.id
left join production_operation_task pot on pot.id = ppm.operation_task_id
where pot.id = #{id} and ppo.state = '01draft';
select ppo.*, ppm.product_no as product_no, ppm.id as main_id
from production_product_output ppo
left join production_product_main ppm on ppo.product_main_id = ppm.id
left join production_operation_task pot on ppm.operation_task_id = pot.id
where pot.id = #{id}
and ppm.state = '01draft';
SELECT DISTINCT
ppo."id",
ppos.staff_id,
ppos.artificial_type,
ppo.part_id,
ppo.system_no,
ppo.out_batch_no,
ppo.product_qty,
ppo.sproduct_qty,
bp.unit,
bp.sunit,
bp.part_no,
bp.specs,
bp.part_name,
pot.optask_no,
ppo.reel_number,
puw.unit_work_factor,
bw.name as workstation_name,
too.name as operation_name,
round(ppos.quantity * puw.unit_work_factor * 88,2) as qty_salary
FROM
(SELECT * FROM production_product_output_staff WHERE duty_record_id = #{dutyRecordId}) ppos
INNER JOIN production_product_output ppo ON ppo."id" = ppos.product_out_id
LEFT JOIN basic_part bp ON bp."id" = ppo.part_id
LEFT JOIN production_product_main ppm ON ppm."id" = ppo.product_main_id
LEFT JOIN production_operation_task pot ON pot."id" = ppm.operation_task_id
LEFT JOIN technology_routing_operation tro ON pot.routing_operation_id = tro."id"
LEFT JOIN production_unit_work puw ON puw.part_id = ppo.part_id AND puw.operation_id = tro.operation_id AND puw.workstation_id = ppm.workstation_id
LEFT JOIN basic_workstation bw ON bw."id" = ppm.workstation_id
LEFT JOIN technology_operation too ON too."id" = tro.operation_id
SELECT state FROM production_product_output
WHERE ID IN ( SELECT MIN ( "id" ) FROM production_product_output GROUP BY product_main_id )
AND product_main_id = #{productMainId}
select count(*) FROM production_product_output
WHERE ID IN ( SELECT MIN ( "id" ) FROM production_product_output GROUP BY product_main_id )
AND state = '03changeshift'
AND product_main_id in
#{productMainId}
select ppo.*,pot.completed_quantity,pot.planned_quantity FROM production_product_output ppo
left join production_product_main ppm on ppo.product_main_id = ppm.id
left join production_operation_task pot on pot.id = ppm.operation_task_id
where pot.id = #{id}
select ppo.state from production_product_output ppo
left join production_product_output_staff ppos on ppo.id = ppos.product_out_id
where ppos.duty_record_id = #{dutyRecordId}
select ppo.id,now_duty_date,bs.name as shift_name
from production_product_output ppo
left join
(select max(product_out_id) product_out_id,max(duty_record_id) duty_record_id
from production_product_output_staff group by product_out_id, duty_record_id
) T ON T.product_out_id = ppo.id
left join production_duty_record pdr on T.duty_record_id = pdr.id
left join basic_shift bs on bs."id"=pdr.shift_id
where ppo.id = #{productOutId}
SELECT
bs."name" shift_type,
bw.workstation_no machine_code,
bw."name" machine_name,
bp.unit,
SUM (ppo.product_qty) yield,
TO_CHAR(ppo.create_time, ${showDateFormat}) time_particle_value
FROM
production_product_main ppm
LEFT JOIN production_product_output ppo ON ppm."id" = ppo.product_main_id
LEFT JOIN basic_part bp ON ppo.part_id = bp."id"
LEFT JOIN basic_workstation bw ON ppm.workstation_id = bw."id"
LEFT JOIN ( SELECT product_out_id, duty_record_id FROM production_product_output_staff GROUP BY product_out_id, duty_record_id ) ppos ON ppos.product_out_id = ppo."id"
LEFT JOIN production_duty_record pdr ON pdr."id" = ppos.duty_record_id
LEFT JOIN basic_shift bs ON pdr.shift_id = bs."id"
WHERE
bw.workstation_no = #{machineCode}
AND TO_CHAR(ppo.create_time, #{sqlDateFormat}) >= #{beginDate}
AND TO_CHAR(ppo.create_time, #{sqlDateFormat}) <= #{endDate}
GROUP BY
bs."name",
bw.workstation_no,
bw."name",
bp.unit,
TO_CHAR( ppo.create_time, ${showDateFormat} );