<?xml version="1.0" encoding="UTF-8"?>
|
|
<!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.ProductOutputMapper">
|
|
<resultMap id="productOutputMap" type="com.chinaztt.mes.production.dto.ProductOutputDTO">
|
<id property="id" column="id"/>
|
<result property="partId" column="part_id"/>
|
<result property="productQty" column="product_qty"/>
|
<result property="sproductQty" column="sproduct_qty"/>
|
<result property="productNo" column="product_no"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="partDescription" column="part_description"/>
|
<result property="unit" column="unit"/>
|
<result property="sunit" column="sunit"/>
|
<result property="operationNo" column="operation_no"/>
|
<result property="operationName" column="operation_name"/>
|
<result property="optaskNo" column="optask_no"/>
|
<result property="specs" column="specs"/>
|
<result property="plannedQuantity" column="planned_quantity"/>
|
<result property="completedQuantity" column="completed_quantity"/>
|
<result property="progress" column="progress"/>
|
<result property="productMainId" column="product_main_id"/>
|
<result property="outBatchNo" column="out_batch_no"/>
|
<result property="systemNo" column="system_no"/>
|
<result property="staffNo" column="staff_no"/>
|
<result property="staffId" column="staff_id"/>
|
<result property="staffName" column="staff_name"/>
|
<result property="systemNo" column="system_no"/>
|
<result property="date" column="date"/>
|
<result property="quantity" column="quantity"/>
|
<result property="dutyRecordId" column="duty_record_id"/>
|
<result property="isQualified" column="is_qualified"/>
|
<result property="isUsed" column="is_used"/>
|
<result property="remark" column="remark"/>
|
<result property="workstationId" column="workstation_id"/>
|
<result property="workstationName" column="workstation_name"/>
|
<result property="checkStatus" column="check_status"/>
|
<result property="isSelfQualified" column="is_self_qualified"/>
|
<result property="state" column="state"/>
|
<result property="sortNo" column="sort_no"/>
|
<result property="startMeterMark" column="start_meter_mark"/>
|
<result property="endMeterMark" column="end_meter_mark"/>
|
<result property="reelNumber" column="reel_number"/>
|
<result property="segmentDesc" column="segment_desc"/>
|
<result property="scrapQty" column="scrap_qty"/>
|
<result property="operationId" column="operation_id"/>
|
<result property="planningMethod" column="planning_method"/>
|
<result property="ifsOpfeedId" column="ifs_opfeed_id"/>
|
<result property="ifsLaborId" column="ifs_labor_id"/>
|
<result property="createTime" column="create_time"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
<result property="shiftOutputId" column="shift_output_id"/>
|
<result property="ifsSync" column="ifs_sync"/>
|
<result property="reelWeight" column="reel_weight"/>
|
<result property="grossWeight" column="gross_weight"/>
|
<result property="netWeight" column="net_weight"/>
|
<result property="theoryWeight" column="theory_weight"/>
|
<result property="mainId" column="main_id"/>
|
<result property="origPartId" column="orig_part_id"/>
|
<result property="partId" column="part_id"/>
|
<result property="printNum" column="print_num"/>
|
<result property="artificialType" column="artificial_type"/>
|
<result property="nowDutyDate" column="now_duty_date"/>
|
<result property="shiftName" column="shift_name"/>
|
<result property="dutyNo" column="duty_no"/>
|
</resultMap>
|
|
<resultMap id="productOutputLabel" type="com.chinaztt.mes.production.dto.ProductOutputLabelDTO">
|
<result property="customerOrderNo" column="customer_order_no"/>
|
<result property="customerName" column="customer_name"/>
|
<result property="operationName" column="operation_name"/>
|
<result property="workstationName" column="workstation_name"/>
|
<result property="partName" column="part_name"/>
|
<result property="partNo" column="part_no"/>
|
<result property="outBatchNo" column="out_batch_no"/>
|
<result property="productQty" column="product_qty"/>
|
<result property="reelNumber" column="reel_number"/>
|
<result property="nowTime" column="now_time"/>
|
<result property="remark" column="remark"/>
|
<result property="reelWeight" column="reel_weight"/>
|
<result property="grossWeight" column="gross_weight"/>
|
<result property="netWeight" column="net_weight"/>
|
<result property="theoryWeight" column="theory_weight"/>
|
<result property="segmentDesc" column="segment_desc"/>
|
<result property="productionTime" column="production_time"/>
|
<result property="productionPerson" column="production_person"/>
|
<result property="unit" column="unit" />
|
<result property="lotTrackingIfs" column="lot_tracking_ifs"/>
|
<result property="cusMaterialCode" column="cus_material_code" />
|
<result property="ifsBatchNo" column="ifs_batch_no" />
|
<result property="startMeterMark" column="start_meter_mark" />
|
<result property="endMeterMark" column="end_meter_mark" />
|
<result property="partPitch" column="part_pitch" />
|
<result property="endProduct" column="end_product" />
|
<result property="discToolMeasurement" column="disc_tool_measurement" />
|
</resultMap>
|
|
<select id="getByMainId" resultMap="productOutputMap">
|
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>
|
|
<select id="getProductionProgress" resultMap="productOutputMap">
|
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
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
<select id="getProductOutPutById" resultMap="productOutputMap">
|
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>
|
|
<select id="getOutputByDutyRecordId" resultMap="productOutputMap">
|
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>
|
|
|
|
<select id="getOutputByDutyRecordIdList" resultMap="productOutputMap">
|
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
|
<foreach collection="dutyRecordIdList" item="dutyRecordId" index="index" open="(" close=")" separator=",">
|
#{dutyRecordId}
|
</foreach>
|
</select>
|
|
|
|
|
<delete id="deleteStaffOutByMainId">
|
DELETE
|
FROM production_product_output_staff
|
WHERE product_out_id IN (SELECT id FROM production_product_output WHERE product_main_id = #{mainId})
|
</delete>
|
|
<delete id="deleteArtificialInformationByMainId">
|
DELETE
|
FROM production_artificial_information
|
WHERE output_id IN (SELECT id FROM production_product_output WHERE product_main_id = #{mainId})
|
</delete>
|
|
<select id="getOutputList" resultMap="productOutputMap">
|
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"
|
<where>
|
<if test="dto.startTime != null and dto.endTime != ''">
|
AND to_char( ppo.create_time, 'YYYYMMDD' ) between #{dto.startTime} and #{dto.endTime}
|
</if>
|
</where>
|
) temp
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
|
|
<select id="getOutputListByScan" resultMap="productOutputMap">
|
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>
|
|
<select id="getProductOut" resultMap="productOutputMap">
|
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
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
|
<delete id="deleteProductOutPutById">
|
DELETE
|
FROM production_product_output_staff
|
WHERE product_out_id IN (SELECT id FROM production_product_output WHERE product_main_id = #{mainId})
|
</delete>
|
|
|
<select id="getShiftProductOutByOpIdAndWsId" resultType="com.chinaztt.mes.production.dto.ProductOutputDTO">
|
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>
|
|
<select id="getProductOutDetailsBySN" resultMap="productOutputMap">
|
SELECT *
|
FROM production_product_output
|
WHERE out_batch_no = #{sn}
|
</select>
|
|
<select id="getShiftedNumberByOutputIds" resultType="java.lang.Integer">
|
SELECT
|
COUNT(*)
|
FROM
|
production_product_output ppo
|
WHERE
|
ppo.shift_output_id in
|
<foreach collection="outputIds" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
AND ppo.state = '02submitted'
|
</select>
|
|
<update id="clearShiftOutputId">
|
update
|
production_product_output
|
set shift_output_id = null
|
where shift_output_id = #{id}
|
</update>
|
|
<select id="getSumProductQty" resultType="java.math.BigDecimal">
|
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"
|
<where>
|
<if test="dto.startTime != null and dto.endTime != ''">
|
AND to_char( ppo.create_time, 'YYYYMMDD' ) between #{dto.startTime} and #{dto.endTime}
|
</if>
|
</where>
|
) temp
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
<insert id="batchInsert" parameterType="map" useGeneratedKeys="true" keyProperty="id">
|
<!--@mbg.generated-->
|
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
|
<foreach collection="list" item="item" separator=",">
|
(#{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}
|
)
|
</foreach>
|
</insert>
|
|
<select id="exportList" resultType="com.chinaztt.mes.production.excel.ProductOutPutData">
|
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>
|
<!-- 支持-->
|
<select id="batchLabelPrint" resultMap="productOutputLabel">
|
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,
|
<!--根据同一SN取和(考虑到交接班的情况)-->
|
(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
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
GROUP BY ppos.product_out_id) ppos ON ppos.product_out_id = ppo.id
|
WHERE ppo.ID in
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="sumProdOutQtyByBatchNo" resultType="java.math.BigDecimal">
|
SELECT COALESCE(SUM(product_qty),0) product_qty FROM production_product_output WHERE out_batch_no = #{batchNo}
|
</select>
|
<select id="selectByTaskId" resultType="com.chinaztt.mes.production.dto.ProductOutputDTO">
|
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>
|
<select id="getDraftProductOut" resultType="com.chinaztt.mes.production.dto.ProductOutputDTO">
|
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>
|
|
<select id="getStaffProductionWage" resultMap="productOutputMap">
|
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>
|
|
|
|
|
<select id="judgeChangeshift" resultType="java.lang.String">
|
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>
|
|
|
<select id="countChangeshiftByList" resultType="java.lang.Integer">
|
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
|
<foreach collection="productMainIdList" item="productMainId" separator="," open="(" close=")">
|
#{productMainId}
|
</foreach>
|
</select>
|
|
|
|
<select id="selectCheckOverProduction" resultMap="productOutputMap">
|
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>
|
|
|
<select id="getStateByDutyRecordId" resultType="java.lang.String">
|
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>
|
|
|
<select id="getDutyRecordByOutputId" resultMap="productOutputMap">
|
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>
|
|
<select id="getEmsMachineYield"
|
resultType="com.chinaztt.mes.production.dto.EmsMachineYieldDTO$MachineYieldDetailInfo">
|
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} );
|
</select>
|
</mapper>
|