<?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.SegmentationTaskRecordMapper">
|
<resultMap id="segmentationTaskRecordMap" type="com.chinaztt.mes.production.entity.SegmentationTaskRecord">
|
<id property="id" column="id"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="partBatchNo" column="part_batch_no"/>
|
<result property="partId" column="part_id"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
<result property="createTime" column="create_time"/>
|
<result property="createUser" column="create_user"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="updateUser" column="update_user"/>
|
<result property="reelNumber" column="reel_number"/>
|
<result property="productQty" column="product_qty"/>
|
<result property="segmentDesc" column="segment_desc"/>
|
<result property="remark" column="remark"/>
|
<result property="taskId" column="task_id"/>
|
<result property="status" column="status"/>
|
<result property="locationId" column="location_id"/>
|
</resultMap>
|
|
<resultMap id="segmentationTaskRecordDto" type="com.chinaztt.mes.production.dto.SegmentationTaskRecordDTO">
|
<id property="id" column="id"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="partBatchNo" column="part_batch_no"/>
|
<result property="partId" column="part_id"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
<result property="createTime" column="create_time"/>
|
<result property="createUser" column="create_user"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="updateUser" column="update_user"/>
|
<result property="reelNumber" column="reel_number"/>
|
<result property="productQty" column="product_qty"/>
|
<result property="segmentDesc" column="segment_desc"/>
|
<result property="remark" column="remark"/>
|
<result property="taskId" column="task_id"/>
|
<result property="taskType" column="task_type"/>
|
<result property="status" column="status"/>
|
<result property="productionUser" column="production_user"/>
|
<result property="unit" column="unit"/>
|
<result property="dutyRecordId" column="duty_record_id"/>
|
<result property="workstationId" column="workstation_id"/>
|
<result property="taskNo" column="task_no"/>
|
<result property="locationId" column="location_id"/>
|
<result property="cusMaterialCode" column="cus_material_code"/>
|
</resultMap>
|
|
<select id="getPage" resultMap="segmentationTaskRecordDto">
|
SELECT * FROM (
|
SELECT
|
pstr.*,
|
pst.no task_no,
|
pst.task_type,
|
pst.production_user,
|
pst.unit,
|
pst.duty_record_id,
|
pst.workstation_id
|
FROM
|
production_segmentation_task_record pstr
|
LEFT JOIN production_segmentation_task pst ON pstr.task_id = pst.id
|
|
<where>
|
<if test="dto.startTime != null and dto.endTime != ''">
|
AND to_char( pstr.create_time, 'YYYYMMDD' ) between #{dto.startTime} and #{dto.endTime}
|
</if>
|
</where>
|
ORDER BY
|
pstr.id DESC
|
) temp
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
<select id="batchLabelPrint" resultMap="segmentationTaskRecordDto">
|
SELECT
|
pstr.part_no,
|
pstr.part_name,
|
pstr.part_batch_no,
|
pstr.ifs_batch_no,
|
pstr.product_qty,
|
pstr.create_time,
|
pstr.segment_desc,
|
pst.unit,
|
bcprm.cus_material_code
|
FROM
|
production_segmentation_task_record pstr
|
LEFT JOIN basic_customer_part_relation_map bcprm on bcprm.part_no = pstr.part_no
|
LEFT JOIN production_segmentation_task pst ON pstr.task_id = pst.id
|
WHERE
|
pstr.id IN
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="getListByIds" resultMap="segmentationTaskRecordDto">
|
SELECT
|
pstr.*,
|
pst.task_type
|
FROM
|
production_segmentation_task_record pstr
|
LEFT JOIN production_segmentation_task pst ON pstr.task_id = pst.id
|
WHERE
|
pstr.id IN
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="getOutputListByDutyRecordId" resultType="com.chinaztt.mes.production.dto.ProductOutputDTO">
|
SELECT DISTINCT
|
ws.system_no,
|
ws.part_batch_no out_batch_no,
|
pstr.product_qty,
|
bp.unit,
|
bp.sunit,
|
bp.part_no,
|
bp.specs,
|
pst."no" optask_no,
|
ws.reel_number,
|
puw.unit_work_factor,
|
pdr.duty_no,
|
pdr.now_duty_date,
|
bst.NAME AS shift_name,
|
round( pstr.product_qty * puw.unit_work_factor * 88, 2 ) AS qty_salary
|
FROM
|
production_segmentation_task pst
|
LEFT JOIN production_segmentation_task_record pstr ON pst."id" = pstr.task_id
|
LEFT JOIN warehouse_stock ws ON ws.part_id = pstr.part_id AND ws.location_id = pstr.location_id AND pstr.part_batch_no = ws.part_batch_no
|
LEFT JOIN basic_part bp ON bp."id" = ws.part_id
|
LEFT JOIN production_unit_work puw ON puw.part_id = ws.part_id
|
AND puw.workstation_id = pst.workstation_id AND puw.operation_id IS NULL
|
LEFT JOIN production_duty_record pdr ON pdr."id" = pst.duty_record_id
|
LEFT JOIN basic_shift bst ON bst.ID = pdr.shift_id
|
WHERE
|
pst.duty_record_id IN
|
<foreach collection="idList" item="dutyRecordId" index="index" open="(" close=")" separator=",">
|
#{dutyRecordId}
|
</foreach>
|
</select>
|
|
<select id="getStaffProductionWage" resultType="com.chinaztt.mes.production.dto.ProductOutputDTO">
|
SELECT
|
DISTINCT
|
pstr."id",
|
bs."id" staff_id,
|
TRUE artificial_type,
|
ws.part_id,
|
ws.system_no,
|
ws.part_batch_no out_batch_no,
|
pstr.product_qty,
|
bp.unit,
|
bp.sunit,
|
bp.part_no,
|
bp.specs,
|
bp.part_name,
|
pst."no" optask_no,
|
ws.reel_number,
|
puw.unit_work_factor,
|
bw."id" workstation_id,
|
bw."name" workstation_name,
|
round( pstr.product_qty * puw.unit_work_factor * 88, 2 ) AS qty_salary
|
FROM
|
production_segmentation_task pst
|
LEFT JOIN production_segmentation_task_record pstr ON pst."id" = pstr.task_id
|
LEFT JOIN warehouse_stock ws ON ws.part_id = pstr.part_id AND ws.location_id = pstr.location_id AND pstr.part_batch_no = ws.part_batch_no
|
LEFT JOIN basic_part bp ON bp."id" = ws.part_id
|
LEFT JOIN production_unit_work puw ON puw.part_id = ws.part_id
|
AND puw.workstation_id = pst.workstation_id AND puw.operation_id IS NULL
|
LEFT JOIN production_duty_record pdr ON pdr."id" = pst.duty_record_id
|
LEFT JOIN basic_shift bst ON bst.ID = pdr.shift_id
|
LEFT JOIN basic_staff bs ON bs.staff_no = pstr.create_user
|
LEFT JOIN basic_workstation bw ON bw."id" = pst.workstation_id
|
WHERE
|
pst.duty_record_id = #{dutyRecordId}
|
</select>
|
</mapper>
|