<?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.PersonBoardMapper">
|
|
<resultMap id="personBoardMap" type="com.chinaztt.mes.production.dto.PersonBoardDTO">
|
<id property="id" column="id"/>
|
<result property="workTime" column="work_time"/>
|
<result property="workstationId" column="workstation_id"/>
|
<result property="staffId" column="staff_id"/>
|
<result property="staffName" column="staff_name"/>
|
<result property="staffNo" column="staff_no"/>
|
<result property="post" column="post"/>
|
<result property="mealSubsidy" column="meal_subsidy"/>
|
<result property="nightDifferential" column="night_differential"/>
|
<result property="overtimePay" column="overtime_pay"/>
|
<result property="dutyTime" column="duty_time"/>
|
<result property="totalDutyTime" column="total_duty_time"/>
|
<result property="salary" column="salary"/>
|
<result property="totalSalary" column="total_salary"/>
|
<result property="beforeTotalDutyTime" column="before_total_duty_time"/>
|
<result property="nowDutyDate" column="now_duty_date"/>
|
<result property="workstationName" column="workstation_name"/>
|
<result property="divisionName" column="division_name"/>
|
<result property="personnelFactor" column="personnel_factor"/>
|
<result property="dutyNo" column="duty_no"/>
|
<result property="shiftName" column="shift_name"/>
|
</resultMap>
|
<select id="checkPersonHaveToWork" resultMap="personBoardMap">
|
select bs.staff_name,pdr.now_duty_date,bw."name" workstation_name
|
from production_person_board ppb
|
left join basic_staff bs on bs."id"=ppb.staff_id
|
left join production_duty_record pdr on pdr."id"=ppb.duty_record_id
|
left join basic_workstation bw on bw."id"=pdr.workstation_id
|
where ppb.staff_id=#{personBoard.staffId}
|
and exists(select 1 from production_duty_record pdre where pdre.now_duty_date=pdr.now_duty_date and pdre."id"=#{personBoard.dutyRecordId})
|
</select>
|
|
<select id="selectDtoByParam" resultMap="personBoardMap">
|
select opd."id",opd.work_time,opd.staff_id,
|
bs.staff_name,bs.staff_no,bs.post
|
from production_person_board opd
|
left join basic_staff bs on bs."id"=opd.staff_id
|
where opd.status='01working'
|
<if test="id != null and id != ''">
|
and opd.id!=#{id}
|
</if>
|
<if test="workstationId != null and workstationId != ''">
|
and opd.workstation_id=#{workstationId}
|
</if>
|
<if test="staffId != null and staffId != ''">
|
and opd.staff_id=#{staffId}
|
</if>
|
</select>
|
|
<select id="selectDtoById" resultMap="personBoardMap">
|
select opd."id",opd.work_time,opd.staff_id,opd.workstation_id,
|
bs.staff_name,bs.staff_no,bs.post
|
from production_person_board opd
|
left join basic_staff bs on bs."id"=opd.staff_id
|
where opd.status='01working' and opd.id=#{id}
|
</select>
|
|
<select id="getPersonByDutyRecordId" resultMap="personBoardMap">
|
select opd."id",opd.work_time,bs.staff_name,bs.staff_no,bs.personnel_factor,
|
bd.division_name,opd.staff_id,opd.meal_subsidy,opd.night_differential,opd.overtime_pay,
|
(select coalesce(sum(pai.working_hours),0) from production_artificial_information pai where pai.production_person_id=opd."id") duty_time,
|
(select coalesce(sum(pai2.working_hours),0)
|
from production_artificial_information pai2
|
left join production_person_board ppd2 on ppd2."id"=pai2.production_person_id
|
left join production_duty_record pdr2 on pdr2."id"=ppd2.duty_record_id
|
where pdr2.is_confirm=true and ppd2.staff_id=opd.staff_id and pdr2.duty_month=pdr.duty_month and pdr2.now_duty_date <![CDATA[<=]]> pdr.now_duty_date) total_duty_time,
|
opd.salary,
|
(select coalesce(sum(ppd4.salary)+sum(ppd4.overtime_pay)+sum(ppd4.meal_subsidy)+sum(ppd4.night_differential),0)
|
from production_person_board ppd4
|
left join production_duty_record pdr4 on pdr4."id"=ppd4.duty_record_id
|
where pdr4.is_confirm=true and ppd4.staff_id=opd.staff_id and pdr4.duty_month=pdr.duty_month and pdr4.now_duty_date <![CDATA[<=]]> pdr.now_duty_date) total_salary,
|
(select coalesce(sum(pai2.working_hours),0)
|
from production_artificial_information pai2
|
left join production_person_board ppd2 on ppd2."id"=pai2.production_person_id
|
left join production_duty_record pdr2 on pdr2."id"=ppd2.duty_record_id
|
where pdr2.is_confirm=true and ppd2.staff_id=opd.staff_id and pdr2.duty_month=pdr.duty_month and pdr2.now_duty_date <![CDATA[<]]> pdr.now_duty_date) before_total_duty_time
|
from production_person_board opd
|
left join basic_staff bs on bs."id"=opd.staff_id
|
left join basic_division bd on bd."id"=bs.division_id
|
left join production_duty_record pdr on pdr."id"=opd.duty_record_id
|
where opd.duty_record_id=#{dutyRecordId}
|
order by opd."id"
|
</select>
|
<select id="getPersonByDutyRecordIdList" resultMap="personBoardMap">
|
select opd."id",opd.work_time,bs.staff_name,bs.staff_no,bs.personnel_factor,pdr.duty_no,pdr.now_duty_date,bst.name as shift_name,pdr.id as duty_record_id,
|
bd.division_name,opd.staff_id,opd.meal_subsidy,opd.night_differential,opd.overtime_pay,
|
(select coalesce(sum(pai.working_hours),0) from production_artificial_information pai where pai.production_person_id=opd."id") duty_time,
|
(select coalesce(sum(pai2.working_hours),0)
|
from production_artificial_information pai2
|
left join production_person_board ppd2 on ppd2."id"=pai2.production_person_id
|
left join production_duty_record pdr2 on pdr2."id"=ppd2.duty_record_id
|
where pdr2.is_confirm=true and ppd2.staff_id=opd.staff_id and pdr2.duty_month=pdr.duty_month and pdr2.now_duty_date <![CDATA[<=]]> pdr.now_duty_date) total_duty_time,
|
opd.salary,
|
(select coalesce(sum(ppd4.salary)+sum(ppd4.overtime_pay)+sum(ppd4.meal_subsidy)+sum(ppd4.night_differential),0)
|
from production_person_board ppd4
|
left join production_duty_record pdr4 on pdr4."id"=ppd4.duty_record_id
|
where pdr4.is_confirm=true and ppd4.staff_id=opd.staff_id and pdr4.duty_month=pdr.duty_month and pdr4.now_duty_date <![CDATA[<=]]> pdr.now_duty_date) total_salary,
|
(select coalesce(sum(pai2.working_hours),0)
|
from production_artificial_information pai2
|
left join production_person_board ppd2 on ppd2."id"=pai2.production_person_id
|
left join production_duty_record pdr2 on pdr2."id"=ppd2.duty_record_id
|
where pdr2.is_confirm=true and ppd2.staff_id=opd.staff_id and pdr2.duty_month=pdr.duty_month and pdr2.now_duty_date <![CDATA[<]]> pdr.now_duty_date) before_total_duty_time
|
from production_person_board opd
|
left join basic_staff bs on bs."id"=opd.staff_id
|
left join basic_division bd on bd."id"=bs.division_id
|
left join production_duty_record pdr on pdr."id"=opd.duty_record_id
|
left join basic_shift bst on bst.id = pdr.shift_id
|
where opd.duty_record_id in
|
<foreach collection="dutyRecordIdList" item="dutyRecordId" index="index" open="(" close=")" separator=",">
|
#{dutyRecordId}
|
</foreach>
|
order by opd."id"
|
</select>
|
<select id="getPersonDtoById" resultType="com.chinaztt.mes.production.dto.PersonBoardDTO">
|
select opd."id",opd.work_time,bs.staff_name,bs.staff_no,coalesce(opd.duty_time,0) duty_time,opd.staff_id,
|
(select sum(coalesce(opd2.duty_time,0)) from production_person_board opd2 left join production_duty_record pdr2 on pdr2."id"=opd2.duty_record_id
|
where opd2.staff_id=opd.staff_id and TO_CHAR(pdr2.duty_date, 'yyyy-mm')=TO_CHAR(pdr.duty_date, 'yyyy-mm')) total_duty_time
|
from production_person_board opd
|
left join basic_staff bs on bs."id"=opd.staff_id
|
left join production_duty_record pdr on pdr."id"=opd.duty_record_id
|
where opd.id=#{id}
|
</select>
|
<select id="selectByDutyRecordIdAndStaffId" resultType="com.chinaztt.mes.production.entity.PersonBoard">
|
select ppb.*
|
from production_person_board ppb
|
where ppb.duty_record_id=#{dutyRecordId} and ppb.staff_id=#{staffId}
|
</select>
|
|
<insert id="backPersonBoardById">
|
insert into production_person_board_back(work_time,workstation_id,staff_id,status,closing_time,duty_record_id,
|
duty_time,meal_subsidy,night_differential,person_board_id,operator,operating_time,type)
|
select work_time,workstation_id,staff_id,status,closing_time,duty_record_id,duty_time,meal_subsidy,night_differential,
|
id,update_user,now(),#{type} from production_person_board where id =#{id}
|
</insert>
|
<insert id="backDeletePersonBoardByIds">
|
insert into production_person_board_back(person_board_id,operator,operating_time,type)
|
values(#{id},#{operator},now(),'删除')
|
</insert>
|
</mapper>
|