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 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'
and opd.id!=#{id}
and opd.workstation_id=#{workstationId}
and opd.staff_id=#{staffId}
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 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 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 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 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 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 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 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 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
#{dutyRecordId}
order by opd."id"
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 ppb.*
from production_person_board ppb
where ppb.duty_record_id=#{dutyRecordId} and ppb.staff_id=#{staffId}
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 into production_person_board_back(person_board_id,operator,operating_time,type)
values(#{id},#{operator},now(),'删除')