<?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.ShiftWageMapper">
|
<resultMap id="ShiftWageDTOMap" type="com.chinaztt.mes.production.dto.ShiftWageDTO">
|
<id property="id" column="id"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="createUser" column="create_user"/>
|
<result property="updateUser" column="update_user"/>
|
<result property="dutyRecordId" column="duty_record_id"/>
|
<result property="staffId" column="staff_id"/>
|
<result property="operationCoeff" column="operation_coeff"/>
|
<result property="handymanWage" column="handyman_wage"/>
|
<result property="productionWage" column="production_wage"/>
|
<result property="summaryWage" column="summary_wage"/>
|
<result property="staffName" column="staff_name"/>
|
<result property="staffNo" column="staff_no"/>
|
<result property="divisionName" column="division_name"/>
|
<result property="partDesc" column="part_desc"/>
|
<result property="partQuantity" column="part_quantity"/>
|
<result property="partQuantityGroup" column="part_quantity_group"/>
|
<result property="auxiliaryWorkstationNum" column="auxiliary_workstation_num"/>
|
<result property="nowDutyDate" column="now_duty_date"/>
|
<result property="dutyNo" column="duty_no"/>
|
<result property="shiftName" column="shift_name"/>
|
</resultMap>
|
|
<resultMap id="ProductionWageBeanMap" type="com.chinaztt.mes.production.dto.ShiftWageDTO$HandymanWageBean">
|
<result property="staffId" column="staff_id"/>
|
<result property="handymanWage" column="handyman_wage"/>
|
</resultMap>
|
|
|
<select id="qryShiftWageByDutyRecordId" resultMap="ShiftWageDTOMap">
|
SELECT psw.*,bs.staff_no,bs.staff_name,sd."name" division_name FROM
|
(SELECT * FROM production_shift_wage WHERE duty_record_id = #{dutyRecordId}) psw
|
LEFT JOIN basic_staff bs ON psw.staff_id = bs."id"
|
LEFT JOIN sys_user su ON bs."id" = su.staff_id AND su.active = TRUE
|
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
|
</select>
|
|
<select id="qryShiftWageByDutyRecordIdList" resultMap="ShiftWageDTOMap">
|
SELECT psw.*,bs.staff_no,bs.staff_name,sd."name" division_name FROM
|
(SELECT ps.*,pdr.duty_no,pdr.now_duty_date,bst.name as shift_name FROM production_shift_wage ps
|
LEFT JOIN production_duty_record pdr on pdr."id"=ps.duty_record_id
|
LEFT JOIN basic_shift bst on bst.id = pdr.shift_id
|
WHERE ps.duty_record_id in
|
<foreach collection="dutyRecordIdList" item="dutyRecordId" index="index" open="(" close=")" separator=",">
|
#{dutyRecordId}
|
</foreach>
|
) psw
|
LEFT JOIN basic_staff bs ON psw.staff_id = bs."id"
|
LEFT JOIN sys_user su ON bs."id" = su.staff_id AND su.active = TRUE
|
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
|
order by bs.staff_no
|
</select>
|
|
<select id="qryHandymanWageByDutyRecordId" resultMap="ProductionWageBeanMap">
|
SELECT ppb.staff_id,SUM(COALESCE(handyman_wage)) handyman_wage FROM(
|
SELECT production_person_id,SUM(handyman_wage) handyman_wage FROM(
|
SELECT pai.production_person_id,COALESCE(pai.working_hours,0) * COALESCE(pc.capacity,0) * COALESCE(pc.conversion_coefficient,0) * COALESCE(pht.standard_hour_wage,0) * 88 AS handyman_wage
|
FROM
|
(SELECT * FROM production_artificial_information WHERE duty_record_id = #{dutyRecordId}) pai
|
INNER JOIN
|
(SELECT * FROM production_computation WHERE active = 't') pc ON pai."id" = pc.artificial_information_id
|
INNER JOIN production_handyman_type pht ON pai.handyman_type_id = pht."id"
|
) t1
|
GROUP BY production_person_id
|
) t2 LEFT JOIN production_person_board ppb ON t2.production_person_id = ppb."id" GROUP BY ppb.staff_id
|
</select>
|
|
<delete id="delShiftWageByDutyRecordId">
|
DELETE FROM production_shift_wage WHERE duty_record_id = #{dutyRecordId}
|
</delete>
|
|
<update id="updShiftWageIsAuditValue">
|
UPDATE production_duty_record SET is_audit = #{value} WHERE id = #{dutyRecordId}
|
</update>
|
|
<delete id="delShiftWageByDutyRecordIdList">
|
DELETE FROM production_shift_wage WHERE duty_record_id in
|
<foreach collection="dutyRecordIdList" item="dutyRecordId" index="index" open="(" close=")" separator=",">
|
#{dutyRecordId}
|
</foreach>
|
</delete>
|
|
<update id="updShiftWageIsAuditValueByList">
|
UPDATE production_duty_record SET is_audit = #{value} WHERE id in
|
<foreach collection="dutyRecordIdList" item="dutyRecordId" index="index" open="(" close=")" separator=",">
|
#{dutyRecordId}
|
</foreach>
|
</update>
|
|
</mapper>
|