update production_duty_record pdr set pending=(select count(pai."id")-count(pc."id") from production_artificial_information pai left join
production_computation pc
on pc.artificial_information_id=pai."id" and pc.active=true where pai.duty_record_id=pdr."id")
where pdr."id"=#{dutyRecordId}
update production_duty_record pdr set duty_output=(select coalesce(sum(ppo.product_qty),0) from production_product_output ppo
where exists(select 1 from production_product_output_staff ppos where ppos.duty_record_id=pdr."id" and
ppo."id"=ppos.product_out_id))
where pdr."id"=#{dutyRecordId}
select * from (
select pdr.*,bc.crew_name,bs."name" shift_name,bw."name" workstation_name,
pht.handyman_no,pht.handyman_name,pht.conversion_coefficient,pht.standard_hour_wage,pht.discount_factor,
bst.staff_name,pai.person_number,pai.working_hours,pai.remark,pc.labor_cost,pai.person_output
from production_duty_record pdr
left join basic_crew bc on bc."id"=pdr.crew_id
left join basic_shift bs on bs."id"=pdr.shift_id
left join basic_workstation bw on bw."id"=pdr.workstation_id
left join production_artificial_information pai on pai.duty_record_id=pdr."id"
left join production_computation pc on pc.artificial_information_id=pai."id" and pc.active=true
left join production_handyman_type pht on pht."id"=pai.handyman_type_id
left join production_person_board ppb on ppb."id"=pai.production_person_id
left join basic_staff bst on bst."id"=ppb.staff_id
order by now_duty_date,workstation_name,staff_name
) tempA
${ew.customSqlSegment}
select * from (
select pdr.*,bc.crew_name,bsh."name" shift_name,bw."name" workstation_name,
bs.staff_name,bs.staff_no,bd.division_name,opd.staff_id,opd.meal_subsidy,opd.night_differential,opd.overtime_pay,
opd.duty_time person_duty_time,
opd.total_duty_time total_person_duty_time,
opd.salary,
opd.total_salary
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_crew bc on bc."id"=pdr.crew_id
left join basic_shift bsh on bsh."id"=pdr.shift_id
left join basic_workstation bw on bw."id"=pdr.workstation_id
order by now_duty_date,staff_name
) tempA
${ew.customSqlSegment}
select * from(
select
pdr.dept_id,
pdr.shift_id,
pdr.crew_id,
pdr."id",pdr.duty_no,pdr.duty_date,pdr.start_time,pdr.end_time,
pdr.duty_time,pdr.receive_remark,pdr.delivery_remark,pdr.create_time,
pdr.create_user,bc.crew_name,bs."name" shift_name,bw."name" workstation_name,
pdr.workstation_id,pdr.is_submit,pdr.is_confirm,pdr.is_audit,bst.staff_name,sd."name" dept_name,
pdr.duty_output + COALESCE(pst.segmentation_product_qty, 0) duty_output, pdr.pending
from production_duty_record pdr
left join sys_dept sd on sd.dept_id=pdr.dept_id
left join sys_user su on su.username=pdr.create_user and su.dept_id = pdr.dept_id
left join basic_staff bst on bst."id"=su.staff_id
left join basic_crew bc on bc."id"=pdr.crew_id
left join basic_shift bs on bs."id"=pdr.shift_id
left join basic_workstation bw on bw."id"=pdr.workstation_id
LEFT JOIN (
SELECT
SUM(pstr.product_qty) segmentation_product_qty,
pst.duty_record_id
FROM
production_segmentation_task pst
LEFT JOIN production_segmentation_task_record pstr ON pst."id" = pstr.task_id
WHERE
pstr.status = '02submitted'
GROUP BY
pst.duty_record_id
) pst ON pst.duty_record_id = pdr."id"
) tempA
${ew.customSqlSegment}
select pdr.*,bc.crew_name from production_duty_record pdr
left join basic_crew bc on pdr.crew_id = bc.id
where pdr.id=#{id}
select pdr."id",pdr.duty_no,pdr.duty_date,pdr.start_time,pdr.end_time,pdr.duty_time,
pdr.workstation_id,pdr.is_submit,pdr.is_confirm,pdr.shift_id,pdr.crew_id
from production_duty_record pdr
left join basic_crew bc on bc."id"=pdr.crew_id
left join basic_shift bs on bs."id"=pdr.shift_id
left join basic_workstation bw on bw."id"=pdr.workstation_id
where pdr."id"=(select duty_record_id from basic_workstation where id =#{workstationId})
select pdrb."operator",bs.staff_name operator_name,pdrb.operating_time,pdrb."type" operation_type
from production_duty_record_back pdrb
left join basic_staff bs on bs.staff_no=pdrb."operator"
where pdrb.duty_record_id=#{id}
order by pdrb."id" desc
insert into production_duty_record_back(duty_no,duty_date,start_time,end_time,duty_time,shift_id,workstation_id,receive_remark,delivery_remark,
create_user,create_time,crew_id,duty_output,is_submit,is_confirm,now_duty_date,duty_month,operator,operating_time,duty_record_id,type,dept_id,work_center)
select duty_no,duty_date,start_time,end_time,duty_time,shift_id,workstation_id,receive_remark,delivery_remark,create_user,create_time,crew_id,
duty_output,is_submit,is_confirm,now_duty_date,duty_month,update_user,now(),id,#{type},dept_id,work_center from production_duty_record where id=#{id}
insert into production_duty_record_back(operator,operating_time,duty_record_id,type)
values(#{operator},now(),#{id},'删除')
select pdr."id",pdr.now_duty_date,pdr.duty_month
from production_duty_record pdr
where pdr.is_confirm=true and exists(select 1 from production_duty_record pdre where pdre."id"=#{dutyRecordId}
and pdr.duty_month=pdre.duty_month and pdr.now_duty_date>pdre.now_duty_date)
and exists(select 1 from production_computation pc where pc.duty_record_id=pdr."id" )
order by pdr.now_duty_date
select * from (
select pai."id",pdr.*,bc.crew_name,bs."name" shift_name,bw."name" workstation_name,
pht.handyman_no,pht.handyman_name,pht.conversion_coefficient,pht.standard_hour_wage,pht.discount_factor,
bst.staff_name,pai.person_number,pai.working_hours,pai.remark,pc.labor_cost,pai.person_output
from production_duty_record pdr
left join basic_crew bc on bc."id"=pdr.crew_id
left join basic_shift bs on bs."id"=pdr.shift_id
left join basic_workstation bw on bw."id"=pdr.workstation_id
left join production_artificial_information pai on pai.duty_record_id=pdr."id"
left join production_computation pc on pc.artificial_information_id=pai."id" and pc.active=true
left join production_handyman_type pht on pht."id"=pai.handyman_type_id
left join production_person_board ppb on ppb."id"=pai.production_person_id
left join basic_staff bst on bst."id"=ppb.staff_id
) tempA
${ew.customSqlSegment}
select bs.staff_no,bs.staff_name,bd.division_name,tempC.*
from(
select staff_id,
sum(case when shift_name='大白班' then date_count else 0 end) as "big_day_shift",
sum(case when shift_name='大夜班' then date_count else 0 end) as "big_night_shift",
sum(case when shift_name='小白班' then date_count else 0 end) as "small_day_shift",
sum(case when shift_name='小夜班' then date_count else 0 end) as "small_night_shift",
sum(case when shift_name='日班' then date_count else 0 end) as "day_shift",
sum(case when shift_name='中班' then date_count else 0 end) as "middle_shift",
sum(case when shift_name='夜班' then date_count else 0 end) as "night_shift",
sum(date_count) total_day
from(
select staff_id,shift_name,count(now_duty_date) date_count
from (
select distinct *
from (
select bsh."name" shift_name,pdr.now_duty_date,
opd.staff_id,bc.crew_name
from production_person_board opd
left join production_duty_record pdr on pdr."id"=opd.duty_record_id
left join basic_shift bsh on bsh."id"=pdr.shift_id
left join basic_crew bc on pdr.crew_id = bc."id"
where opd.duty_time>0
and ${ew.SqlSegment}
) temp
) tempA
group by staff_id,shift_name
) tempB
group by staff_id
) tempC
left join basic_staff bs on bs."id"=tempC.staff_id
left join basic_division bd on bd."id"=bs.division_id
order by bs.staff_no
insert into production_duty_record_back(duty_no,duty_date,start_time,end_time,duty_time,shift_id,workstation_id,receive_remark,delivery_remark,
create_user,create_time,crew_id,duty_output,is_submit,is_confirm,now_duty_date,duty_month,operator,operating_time,duty_record_id,type,dept_id,work_center)
select duty_no,duty_date,start_time,end_time,duty_time,shift_id,workstation_id,receive_remark,delivery_remark,create_user,create_time,crew_id,
duty_output,is_submit,is_confirm,now_duty_date,duty_month,update_user,now(),id,#{type},dept_id,work_center from production_duty_record
where id in
#{id}
SELECT * FROM(
SELECT psw.*,
pdr.now_duty_date,bc.crew_name,
bs.staff_no,bs.staff_name,bs.personnel_factor,
bw."name" workstationName,
ppos.person_output,
pdr.duty_no,pdr.is_confirm,pdr.is_submit,pdr.duty_date,pdr.duty_time
FROM
production_shift_wage psw
INNER JOIN
production_duty_record pdr
ON psw.duty_record_id = pdr."id"
LEFT JOIN basic_staff bs ON psw.staff_id = bs."id"
LEFT JOIN basic_workstation bw ON pdr.workstation_id = bw."id"
LEFT JOIN basic_crew bc ON pdr.crew_id = bc."id"
LEFT JOIN
(SELECT staff_id,duty_record_id,SUM(COALESCE(quantity,0)) person_output FROM production_product_output_staff GROUP BY staff_id,duty_record_id) ppos
ON psw.staff_id = ppos.staff_id AND psw.duty_record_id = ppos.duty_record_id)TMP
${ew.customSqlSegment}
select pdr.*,bw.name as workstation_name from production_duty_record pdr
left join basic_workstation bw on pdr.workstation_id = bw.id
where pdr.is_submit = 'false'
order by pdr.workstation_id,pdr.id
limit 100 offset #{startIndex}
select pdr.id,pdr.duty_no,bs.name as shift_name, bc.crew_name ,pdr.start_time,pdr.end_time,
bw.name as workstation_name, bw.workstation_no, bw.type as workstation_type, bw.remark from production_duty_record pdr
left join basic_workstation bw on pdr.workstation_id = bw.id
left join basic_shift bs on bs.id = pdr.shift_id
left join basic_crew bc on bc.id = pdr.crew_id
where pdr.is_submit = 'false' and pdr.work_center = #{workCenter}
order by pdr.workstation_id,pdr.id