<?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.HandymanTypeMapper">
|
|
<resultMap id="dtoResultMap" type="com.chinaztt.mes.production.dto.HandymanTypeDTO">
|
<id property="id" column="id"/>
|
<result property="handymanNo" column="handyman_no"/>
|
<result property="handymanName" column="handyman_name"/>
|
<result property="conversionCoefficient" column="conversion_coefficient"/>
|
<result property="standardHourWage" column="standard_hour_wage"/>
|
<result property="discountFactor" column="discount_factor"/>
|
<result property="comment" column="comment"/>
|
<result property="wageType" column="wage_type"/>
|
<result property="loadType" column="load_type"/>
|
<result property="unit" column="unit"/>
|
<result property="handymanTemplateId" column="handyman_template_id"/>
|
<result property="partFamilyId" column="part_family_id"/>
|
<result property="partFamilyNo" column="part_family_no"/>
|
</resultMap>
|
<resultMap id="optaskHandymanTypeMap" type="com.chinaztt.mes.production.entity.HandymanType">
|
<id property="id" column="id"/>
|
<result property="handymanNo" column="handyman_no"/>
|
<result property="handymanName" column="handyman_name"/>
|
<result property="conversionCoefficient" column="conversion_coefficient"/>
|
<result property="standardHourWage" column="standard_hour_wage"/>
|
<result property="discountFactor" column="discount_factor"/>
|
<result property="comment" column="comment"/>
|
<result property="wageType" column="wage_type"/>
|
<result property="loadType" column="load_type"/>
|
<result property="unit" column="unit"/>
|
<result property="partFamilyId" column="part_family_id"/>
|
<result property="workstationId" column="workstation_id"/>
|
<result property="workstationName" column="workstation_name"/>
|
</resultMap>
|
<select id="getHandymanType" resultMap="optaskHandymanTypeMap">
|
SELECT A."id",
|
A.handyman_no,
|
A.handyman_name,
|
A.conversion_coefficient,
|
A."comment" ,
|
A.unit
|
FROM
|
production_handyman_type
|
A LEFT JOIN production_artificial_information_relation b ON b.production_handyman_id = A."id"
|
WHERE
|
b.production_handyman_join_id = #{id}
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.SqlSegment}
|
</if>
|
</select>
|
<select id="getHandyman" resultMap="optaskHandymanTypeMap">
|
SELECT A
|
."id",
|
A.handyman_no,
|
A.handyman_name,
|
A.conversion_coefficient,
|
A."comment" ,
|
A.unit
|
FROM
|
production_handyman_type A
|
WHERE NOT EXISTS (SELECT b.production_handyman_join_id FROM production_artificial_information_relation b WHERE
|
b.production_handyman_id = A."id"
|
AND b.production_handyman_join_id = #{id})
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.SqlSegment}
|
</if>
|
</select>
|
<select id="fetchListByTemplateId" resultMap="dtoResultMap">
|
select distinct * from (
|
select pht.*,pjtt.handyman_template_id from production_handyman_type pht
|
left join production_join_type_template pjtt on pjtt.handyman_type_id=pht."id"
|
) tempA
|
where active=true
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.SqlSegment}
|
</if>
|
</select>
|
<select id="fetchListFilterTemplateId" resultMap="dtoResultMap">
|
select pht.* from production_handyman_type pht
|
where not exists(select 1 from production_join_type_template pjtt
|
where pjtt.handyman_type_id=pht."id" and pjtt.handyman_template_id=#{handymanTemplateId})
|
and active=true
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.SqlSegment}
|
</if>
|
</select>
|
<select id="getHandymanTypeById" resultMap="dtoResultMap">
|
SELECT
|
A.*,
|
B.part_family_no
|
FROM
|
production_handyman_type A
|
LEFT JOIN basic_part_family B ON B."id" = A.part_family_id
|
WHERE
|
A."id" = #{id}
|
</select>
|
|
<select id="getHandymanTypeByDutyRecordId" resultMap="dtoResultMap">
|
SELECT *
|
FROM production_handyman_type pht
|
WHERE exists(SELECT 1
|
FROM production_artificial_information pai
|
WHERE pai.duty_record_id in
|
<foreach collection="dutyRecordIdList" item="dutyRecordId" index="index" open="(" close=")" separator=",">
|
#{dutyRecordId}
|
</foreach>
|
AND pht."id" = pai.handyman_type_id)
|
ORDER BY pht."id"
|
</select>
|
<select id="selectByWorkstationIdAndPartId" resultMap="optaskHandymanTypeMap">
|
SELECT phty.*
|
FROM basic_workstation bw
|
LEFT JOIN basic_join_workstation_template bjwt ON bjwt.workstation_id = bw."id"
|
LEFT JOIN production_handyman_template pht ON pht."id" = bjwt.handyman_template_id
|
LEFT JOIN production_join_type_template pjtt ON pjtt.handyman_template_id = pht."id"
|
LEFT JOIN production_handyman_type phty ON phty."id" = pjtt.handyman_type_id
|
LEFT JOIN basic_part_family bpf ON phty.part_family_id = bpf."id" AND bpf.active = TRUE
|
WHERE bw."id" = #{workstationId}
|
AND exists(SELECT 1 FROM basic_part bp WHERE bp."id" = #{partId} AND bp.part_family_id = bpf."id")
|
LIMIT 1
|
</select>
|
</mapper>
|