1498 lines
75 KiB
XML
1498 lines
75 KiB
XML
<?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.bonus.hnrn.rnbmw.salaryfile.dao.SalaryCheckDao">
|
||
<select id="getPros" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryCheckBean">
|
||
select id as proid, name as proname
|
||
from bns_smz_bm_project aa
|
||
where aa.is_active = "1"
|
||
order by name
|
||
</select>
|
||
<select id="getSubs" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryCheckBean">
|
||
select aa.id as subid,aa.sub_name as subname,bb.pro_id as proid from bns_smz_bm_subcontractor aa
|
||
left join bns_smz_bm_sub_pro_relation bb on aa.id=bb.sub_id
|
||
where 1=1
|
||
and aa.IS_ACTIVE='1'
|
||
<if test='params.proId != null and params.proId != ""'>
|
||
and bb.pro_id=#{params.proId}
|
||
</if>
|
||
</select>
|
||
<insert id="addRecord">
|
||
insert into bns_smz_jx_record
|
||
(reword_num,
|
||
month,
|
||
pro_id,
|
||
sub_id,
|
||
upload_id, check_remark,
|
||
upload_time,
|
||
state, is_active)
|
||
VALUES (#{rewordNum},
|
||
#{month},
|
||
#{proId},
|
||
#{subId},
|
||
#{uploadId}, #{checkRemark},
|
||
now(),
|
||
'0', '2')
|
||
</insert>
|
||
<delete id="delRecord">
|
||
delete
|
||
from bns_smz_jx_record
|
||
where reword_num = #{rewordNum};
|
||
delete
|
||
from bns_smz_jx_attendance_reword
|
||
where reword_num = #{rewordNum};
|
||
delete
|
||
from bns_smz_jx_confirmation_pay
|
||
where reword_num = #{rewordNum};
|
||
delete
|
||
from bns_smz_jx_disk_reword
|
||
where reword_num = #{rewordNum};
|
||
delete
|
||
from bns_smz_jx_worker_pay
|
||
where reword_num = #{rewordNum};
|
||
delete
|
||
from bns_smz_jx_difference_reword
|
||
where reword_num = #{rewordNum};
|
||
delete
|
||
from bns_smz_jx_file_reword
|
||
where reword_num = #{rewordNum};
|
||
</delete>
|
||
<update id="updateRecord">
|
||
update bns_smz_jx_record set
|
||
<if test='state != null and state != ""'>
|
||
state=#{state},
|
||
</if>
|
||
<if test='projecterId != null and projecterId != ""'>
|
||
projecter_id=#{projecterId},
|
||
projecter_time=now(),
|
||
</if>
|
||
<if test='subcompanyId != null and subcompanyId != ""'>
|
||
subcompany_id=#{subcompanyId},
|
||
subcompany_time=now(),
|
||
</if>
|
||
<if test='companyId != null and companyId != ""'>
|
||
company_id=#{companyId},
|
||
company_time=now(),
|
||
</if>
|
||
<if test='upSubcompanyId != null and upSubcompanyId != ""'>
|
||
up_subcompany_id=#{upSubcompanyId},
|
||
up_subcompany_time=now(),
|
||
</if>
|
||
<if test='upCompanyId != null and upCompanyId != ""'>
|
||
up_company_id=#{upCompanyId},
|
||
up_company_time=now(),
|
||
</if>
|
||
<if test='countNum != null and countNum != ""'>
|
||
countNum=#{countNum},
|
||
</if>
|
||
<if test='workerNum != null and workerNum != ""'>
|
||
workerNum=#{workerNum},
|
||
</if>
|
||
<if test='attenNum != null and attenNum != ""'>
|
||
attenNum=#{attenNum},
|
||
</if>
|
||
<if test='payIn != null and payIn != ""'>
|
||
payIn=#{payIn},
|
||
</if>
|
||
<if test='payable != null and payable != ""'>
|
||
payable=#{payable},
|
||
</if>
|
||
<if test='delState != null and delState != ""'>
|
||
delstate=#{delState},
|
||
</if>
|
||
<if test='remark != null and remark != ""'>
|
||
remark=#{remark},
|
||
</if>
|
||
<if test='checkRemark != null and checkRemark != ""'>
|
||
check_Remark=#{checkRemark},
|
||
</if>
|
||
<if test='delState != null and delState != ""'>
|
||
delstate=#{delState},
|
||
</if>
|
||
<if test='isSubLssued != null and isSubLssued != ""'>
|
||
is_sub_lssued=#{isSubLssued},
|
||
</if>
|
||
<if test='countNum != null and countNum != ""'>
|
||
countnum=#{countNum},
|
||
</if>
|
||
<if test='delRemark != null and delRemark != ""'>
|
||
delremark=#{delRemark},
|
||
</if>
|
||
update_time=now(),
|
||
is_active='1'
|
||
where reword_num=#{rewordNum}
|
||
</update>
|
||
<update id="updateRecord2">
|
||
update bns_smz_jx_record set
|
||
<if test='state != null and state != ""'>
|
||
state=#{state},
|
||
</if>
|
||
<if test='projecterId != null and projecterId != ""'>
|
||
projecter_id=#{projecterId},
|
||
projecter_time=now(),
|
||
</if>
|
||
<if test='subcompanyId != null and subcompanyId != ""'>
|
||
subcompany_id=#{subcompanyId},
|
||
subcompany_time=now(),
|
||
</if>
|
||
<if test='companyId != null and companyId != ""'>
|
||
company_id=#{companyId},
|
||
company_time=now(),
|
||
</if>
|
||
<if test='upSubcompanyId != null and upSubcompanyId != ""'>
|
||
up_subcompany_id=#{upSubcompanyId},
|
||
up_subcompany_time=now(),
|
||
</if>
|
||
<if test='upCompanyId != null and upCompanyId != ""'>
|
||
up_company_id=#{upCompanyId},
|
||
up_company_time=now(),
|
||
</if>
|
||
<if test='countNum != null and countNum != ""'>
|
||
countNum=#{countNum},
|
||
</if>
|
||
<if test='workerNum != null and workerNum != ""'>
|
||
workerNum=#{workerNum},
|
||
</if>
|
||
<if test='attenNum != null and attenNum != ""'>
|
||
attenNum=#{attenNum},
|
||
</if>
|
||
<if test='payIn != null and payIn != ""'>
|
||
payIn=#{payIn},
|
||
</if>
|
||
<if test='payable != null and payable != ""'>
|
||
payable=#{payable},
|
||
</if>
|
||
<if test='delState != null and delState != ""'>
|
||
delstate=#{delState},
|
||
</if>
|
||
<if test='remark != null and remark != ""'>
|
||
remark=#{remark},
|
||
</if>
|
||
<if test='checkRemark != null and checkRemark != ""'>
|
||
check_Remark=#{checkRemark},
|
||
</if>
|
||
<if test='delState != null and delState != ""'>
|
||
delstate=#{delState},
|
||
</if>
|
||
<if test='isSubLssued != null and isSubLssued != ""'>
|
||
is_sub_lssued=#{isSubLssued},
|
||
</if>
|
||
<if test='countNum != null and countNum != ""'>
|
||
countnum=#{countNum},
|
||
</if>
|
||
update_time=now(),
|
||
is_active='2'
|
||
where reword_num=#{rewordNum}
|
||
</update>
|
||
<insert id="addAattendance">
|
||
insert into bns_smz_jx_attendance_reword (reword_num,
|
||
name,
|
||
id_number,
|
||
post,
|
||
pro_name,
|
||
pro_state,
|
||
sub_name,
|
||
team_name,
|
||
atten_num, piece_num, sutDown_num,
|
||
rest_num,
|
||
nowork_num,
|
||
base_pay,
|
||
achievements_pay,
|
||
bank_num)
|
||
VALUES (#{rewordNum},
|
||
#{name},
|
||
#{idNumber},
|
||
#{post},
|
||
#{proName},
|
||
#{proState},
|
||
#{subName},
|
||
#{teamName},
|
||
#{attenNum}, #{pieceNum}, #{sutDownNum},
|
||
#{restNum},
|
||
#{noworkNum},
|
||
#{basePay},
|
||
#{achievementsPay},
|
||
#{bankNum})
|
||
</insert>
|
||
<insert id="addConfirmation">
|
||
insert into bns_smz_jx_confirmation_pay (reword_num,
|
||
name,
|
||
id_number,
|
||
post,
|
||
team_name,
|
||
base_price,
|
||
base_num,
|
||
basecount,
|
||
overtime_price,
|
||
overtime_num,
|
||
overcount,
|
||
achievements_price,
|
||
achievements_num,
|
||
achievementscount,
|
||
payable,
|
||
bonus,
|
||
piece_price,
|
||
piece_num,
|
||
piece_count,
|
||
sutDown_price,
|
||
sutDown_num,
|
||
sutDown_count)
|
||
VALUES (#{rewordNum},
|
||
#{name},
|
||
#{idNumber},
|
||
#{post},
|
||
#{teamName},
|
||
#{basePrice},
|
||
#{baseNum},
|
||
#{baseCount},
|
||
#{overtimePrice},
|
||
#{overtimeNum},
|
||
#{overCount},
|
||
#{achievementsPrice},
|
||
#{achievementsNum},
|
||
#{achievementsCount},
|
||
#{payable},
|
||
#{bonus},
|
||
#{piecePrice},
|
||
#{pieceNum},
|
||
#{pieceCount},
|
||
#{sutDownPrice},
|
||
#{sutDownNum},
|
||
#{sutDownCount})
|
||
</insert>
|
||
<insert id="addDisk">
|
||
insert into bns_smz_jx_disk_reword (reword_num,
|
||
id_number,
|
||
name,
|
||
post,
|
||
team_name,
|
||
atten_num,
|
||
payable,
|
||
withhold,
|
||
payIn,
|
||
bank_num)
|
||
VALUES (#{rewordNum},
|
||
#{idNumber},
|
||
#{name},
|
||
#{post},
|
||
#{teamName},
|
||
#{attenNum},
|
||
#{payable},
|
||
#{withhold},
|
||
#{payIn},
|
||
#{bankNum})
|
||
</insert>
|
||
<insert id="addWorker">
|
||
insert into bns_smz_jx_worker_pay (reword_num,
|
||
name,
|
||
id_number,
|
||
post,
|
||
team_name,
|
||
atten_num,
|
||
payable,
|
||
withhold,
|
||
payIn,
|
||
bank,
|
||
bank_num)
|
||
VALUES (#{rewordNum},
|
||
#{name},
|
||
#{idNumber},
|
||
#{post},
|
||
#{teamName},
|
||
#{attenNum},
|
||
#{payable},
|
||
#{withhold},
|
||
#{payIn},
|
||
#{bank},
|
||
#{bankNum})
|
||
</insert>
|
||
<insert id="addFile">
|
||
insert into bns_smz_jx_file_reword (reword_num,
|
||
type,
|
||
file_name,
|
||
file_path,
|
||
view_time,
|
||
upload_user_id,
|
||
upload_time)
|
||
VALUES (#{rewordNum},
|
||
#{type},
|
||
#{fileName},
|
||
#{filePath},
|
||
now(),
|
||
#{uploadUserId},
|
||
now())
|
||
</insert>
|
||
<update id="updateFile">
|
||
update bns_smz_jx_file_reword
|
||
set file_path= #{filePath},
|
||
upload_time=now()
|
||
where file_name = #{fileName}
|
||
and reword_num = #{rewordNum}
|
||
</update>
|
||
<select id="getFileNum" resultType="java.lang.Integer">
|
||
select count(1)
|
||
from bns_smz_jx_file_reword
|
||
where file_name = #{fileName}
|
||
and reword_num = #{rewordNum}
|
||
</select>
|
||
<insert id="addDifference">
|
||
insert into bns_smz_jx_difference_reword (reword_num,
|
||
id_number,
|
||
name,
|
||
post,
|
||
atten_num,
|
||
piece_num,
|
||
sutDown_num,
|
||
bank_num,
|
||
base_price,
|
||
achievements_price,
|
||
payIn,
|
||
payable,
|
||
describes)
|
||
VALUES (#{rewordNum},
|
||
#{idNumber},
|
||
#{name},
|
||
#{post},
|
||
#{attenNum},
|
||
#{pieceNum},
|
||
#{sutDownNum},
|
||
#{bankNum},
|
||
#{basePrice},
|
||
#{achievementsPrice},
|
||
#{payIn},
|
||
#{payable},
|
||
#{describes})
|
||
</insert>
|
||
<delete id="delDifference">
|
||
update bns_smz_jx_difference_reword
|
||
set is_active=#{isActive}
|
||
where reword_num = #{rewordNum}
|
||
</delete>
|
||
<!--<select id="getDifference" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryDifferenceBean">
|
||
select *
|
||
from (select aa.id_number as idnumber,
|
||
#{rewordNum} as rewordnum,
|
||
case when bb.name is null then 0 else 1 end as name,
|
||
case when cc.post is null then 0 else 1 end as post,
|
||
case when dd.attennum is null then 0 else 1 end as attennum,
|
||
case when ee.payable is null then 0 else 1 end as payable,
|
||
case when ff.payIn is null then 0 else 1 end as payIn,
|
||
case when gg.banknum is null then 0 else 1 end as banknum,
|
||
case when hh.baseprice is null then 0 else 1 end as baseprice,
|
||
case when ii.achievementsprice is null then 0 else 1 end as achievementsprice,
|
||
'' as describes
|
||
from (select distinct aa.id_number
|
||
from (select aa.id_number
|
||
from bns_smz_jx_attendance_reword aa
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select bb.id_number
|
||
from bns_smz_jx_confirmation_pay bb
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select cc.id_number
|
||
from bns_smz_jx_disk_reword cc
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select dd.id_number
|
||
from bns_smz_jx_worker_pay dd
|
||
where reword_num = #{rewordNum}) aa) aa
|
||
left join (select distinct aa.id_number, '1' as name
|
||
from (select aa.id_number, aa.name
|
||
from bns_smz_jx_attendance_reword aa
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select bb.id_number, bb.name
|
||
from bns_smz_jx_confirmation_pay bb
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select cc.id_number, cc.name
|
||
from bns_smz_jx_disk_reword cc
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select dd.id_number, dd.name
|
||
from bns_smz_jx_worker_pay dd
|
||
where reword_num = #{rewordNum}) aa
|
||
where CONCAT(aa.name, aa.id_number) not in
|
||
(select distinct CONCAT(aa.name, aa.id_number) as id_number
|
||
from (select * from bns_smz_jx_attendance_reword where reword_num = #{rewordNum}) aa
|
||
left join (select * from bns_smz_jx_confirmation_pay where reword_num = #{rewordNum}) bb
|
||
on aa.id_number = bb.id_number
|
||
left join (select * from bns_smz_jx_disk_reword where reword_num = #{rewordNum}) cc
|
||
on aa.id_number = cc.id_number
|
||
left join (select * from bns_smz_jx_worker_pay where reword_num = #{rewordNum}) dd
|
||
on aa.id_number = dd.id_number
|
||
where aa.name = bb.name
|
||
and bb.name = cc.name
|
||
and cc.name = dd.name
|
||
and aa.reword_num = #{rewordNum})) bb on aa.id_number = bb.id_number
|
||
left join (select distinct aa.id_number, '1' as post
|
||
from (select aa.id_number
|
||
from bns_smz_jx_attendance_reword aa
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select bb.id_number
|
||
from bns_smz_jx_confirmation_pay bb
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select cc.id_number
|
||
from bns_smz_jx_disk_reword cc
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select dd.id_number
|
||
from bns_smz_jx_worker_pay dd
|
||
where reword_num = #{rewordNum}) aa
|
||
where id_number not in (select distinct aa.id_number
|
||
from (select * from bns_smz_jx_attendance_reword where reword_num = #{rewordNum}) aa
|
||
left join (select * from bns_smz_jx_confirmation_pay where reword_num = #{rewordNum}) bb
|
||
on aa.id_number = bb.id_number
|
||
left join (select * from bns_smz_jx_disk_reword where reword_num = #{rewordNum}) cc
|
||
on aa.id_number = cc.id_number
|
||
left join (select * from bns_smz_jx_worker_pay where reword_num = #{rewordNum}) dd
|
||
on aa.id_number = dd.id_number
|
||
where aa.post = bb.post
|
||
and bb.post = cc.post
|
||
and cc.post = dd.post
|
||
and aa.reword_num = #{rewordNum})) cc
|
||
on aa.id_number = cc.id_number
|
||
left join (select distinct aa.id_number, '1' as attennum
|
||
from (select aa.id_number
|
||
from bns_smz_jx_attendance_reword aa
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select bb.id_number
|
||
from bns_smz_jx_confirmation_pay bb
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select cc.id_number
|
||
from bns_smz_jx_disk_reword cc
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select dd.id_number
|
||
from bns_smz_jx_worker_pay dd
|
||
where reword_num = #{rewordNum}) aa
|
||
where id_number not in (select distinct aa.id_number
|
||
from (select * from bns_smz_jx_attendance_reword where reword_num = #{rewordNum}) aa
|
||
left join (select * from bns_smz_jx_confirmation_pay where reword_num = #{rewordNum}) bb
|
||
on aa.id_number = bb.id_number
|
||
left join (select * from bns_smz_jx_disk_reword where reword_num = #{rewordNum}) cc
|
||
on aa.id_number = cc.id_number
|
||
left join (select * from bns_smz_jx_worker_pay where reword_num = #{rewordNum}) dd
|
||
on aa.id_number = dd.id_number
|
||
where aa.atten_num = bb.base_num
|
||
and bb.base_num = cc.atten_num
|
||
and cc.atten_num = dd.atten_num
|
||
and aa.reword_num = #{rewordNum})) dd
|
||
on aa.id_number = dd.id_number
|
||
left join (select distinct aa.id_number, '1' as payable
|
||
from (select bb.id_number
|
||
from bns_smz_jx_confirmation_pay bb
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select cc.id_number
|
||
from bns_smz_jx_disk_reword cc
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select dd.id_number
|
||
from bns_smz_jx_worker_pay dd
|
||
where reword_num = #{rewordNum}) aa
|
||
where id_number not in (select distinct aa.id_number
|
||
from (select * from bns_smz_jx_confirmation_pay where reword_num = #{rewordNum}) aa
|
||
left join (select * from bns_smz_jx_disk_reword where reword_num = #{rewordNum}) bb
|
||
on aa.id_number = bb.id_number
|
||
left join (select * from bns_smz_jx_worker_pay where reword_num = #{rewordNum}) cc
|
||
on aa.id_number = cc.id_number
|
||
where aa.payable = bb.payable
|
||
and bb.payable = cc.payable
|
||
and aa.reword_num = #{rewordNum})) ee
|
||
on aa.id_number = ee.id_number
|
||
left join (select distinct aa.id_number, '1' as payIn
|
||
from (select aa.id_number
|
||
from bns_smz_jx_disk_reword aa
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select bb.id_number
|
||
from bns_smz_jx_worker_pay bb
|
||
where reword_num = #{rewordNum}) aa
|
||
where id_number not in (select distinct aa.id_number
|
||
from (select * from bns_smz_jx_disk_reword where reword_num = #{rewordNum}) aa
|
||
left join (select * from bns_smz_jx_worker_pay where reword_num = #{rewordNum}) bb
|
||
on aa.id_number = bb.id_number
|
||
where aa.payIn = bb.payIn
|
||
and aa.reword_num = #{rewordNum})) ff
|
||
on aa.id_number = ff.id_number
|
||
left join (select distinct aa.id_number, '1' as banknum
|
||
from (select aa.id_number
|
||
from bns_smz_jx_attendance_reword aa
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select cc.id_number
|
||
from bns_smz_jx_disk_reword cc
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select dd.id_number
|
||
from bns_smz_jx_worker_pay dd
|
||
where reword_num = #{rewordNum}) aa
|
||
where id_number not in (select distinct aa.id_number
|
||
from (select * from bns_smz_jx_attendance_reword where reword_num = #{rewordNum}) aa
|
||
left join (select * from bns_smz_jx_disk_reword where reword_num = #{rewordNum}) cc
|
||
on aa.id_number = cc.id_number
|
||
left join (select * from bns_smz_jx_worker_pay where reword_num = #{rewordNum}) dd
|
||
on aa.id_number = dd.id_number
|
||
where aa.bank_num = cc.bank_num
|
||
and cc.bank_num = dd.bank_num
|
||
and aa.reword_num = #{rewordNum})) gg
|
||
on aa.id_number = gg.id_number
|
||
left join (select distinct aa.id_number, '1' as baseprice
|
||
from (select aa.id_number
|
||
from bns_smz_jx_attendance_reword aa
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select bb.id_number
|
||
from bns_smz_jx_confirmation_pay bb
|
||
where reword_num = #{rewordNum}) aa
|
||
where id_number not in (select distinct aa.id_number
|
||
from (select * from bns_smz_jx_attendance_reword where reword_num = #{rewordNum}) aa
|
||
left join (select * from bns_smz_jx_confirmation_pay where reword_num = #{rewordNum}) bb
|
||
on aa.id_number = bb.id_number
|
||
where aa.base_pay = bb.base_price
|
||
and aa.reword_num = #{rewordNum})) hh
|
||
on aa.id_number = hh.id_number
|
||
left join (select distinct aa.id_number, '1' as achievementsprice
|
||
from (select aa.id_number
|
||
from bns_smz_jx_attendance_reword aa
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select bb.id_number
|
||
from bns_smz_jx_confirmation_pay bb
|
||
where reword_num = #{rewordNum}) aa
|
||
where id_number not in (select distinct aa.id_number
|
||
from (select aa.id_number,
|
||
aa.reword_num,
|
||
aa.achievements_pay,
|
||
SUBSTRING(aa.achievements_pay, 1,
|
||
case
|
||
when aa.achievements_pay like '%-%'
|
||
then LOCATE('-', aa.achievements_pay) - 1
|
||
else LENGTH(aa.achievements_pay) end) as min,
|
||
SUBSTRING(aa.achievements_pay,case when aa.achievements_pay like '%-%' then LOCATE('-',aa.achievements_pay)+1 else 1 end,
|
||
LENGTH(aa.achievements_pay)-case when aa.achievements_pay like '%-%' then LOCATE('-',aa.achievements_pay) else 0 end) as max,
|
||
LOCATE('-',aa.achievements_pay) as dd
|
||
from (select * from bns_smz_jx_attendance_reword where reword_num = #{rewordNum}) aa) aa
|
||
left join (select * from bns_smz_jx_confirmation_pay where reword_num = #{rewordNum}) bb
|
||
on aa.id_number = bb.id_number
|
||
where CAST(bb.achievements_price AS UNSIGNED) >= CAST(aa.min AS UNSIGNED)
|
||
and CAST(aa.max AS UNSIGNED) >= CAST(bb.achievements_price AS UNSIGNED)
|
||
and aa.reword_num = #{rewordNum})) ii
|
||
on aa.id_number = ii.id_number) aa
|
||
where name = 1
|
||
or post = 1
|
||
or attennum = 1
|
||
or payable = 1
|
||
or payin = 1
|
||
or banknum = 1
|
||
or baseprice = 1
|
||
or achievementsprice = 1
|
||
|
||
</select>-->
|
||
|
||
<select id="getTreeDetail" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.TreeBean">
|
||
select aa.id_number as id,bb.name as title,false as spread
|
||
from bns_smz_jx_difference_reword aa
|
||
left join (
|
||
select * from (
|
||
select id_number,name from bns_smz_jx_disk_reword where reword_num=#{recordNum}
|
||
UNION
|
||
select id_number,name from bns_smz_jx_attendance_reword where reword_num=#{recordNum}
|
||
UNION
|
||
select id_number,name from bns_smz_jx_confirmation_pay where reword_num=#{recordNum}
|
||
UNION
|
||
select id_number,name from bns_smz_jx_worker_pay where reword_num=#{recordNum}
|
||
) aa group by id_number
|
||
) bb on aa.id_number =bb.id_number
|
||
where aa.reword_num=#{recordNum} and aa.is_active='1'
|
||
<if test='title != null and title != ""'>
|
||
and bb.name like concat('%', #{title}, '%')
|
||
</if>
|
||
GROUP BY
|
||
aa.id_number
|
||
</select>
|
||
|
||
<select id="getDetailByIdnumber" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryViewBean">
|
||
<if test='type=="1"'>
|
||
select distinct
|
||
aa.team_name as teamName,
|
||
aa.post as post,
|
||
aa.atten_num as attenNum,
|
||
aa.payable as payable,
|
||
aa.withhold as withhold,
|
||
aa.payIn as payIn,
|
||
aa.bank as bank,
|
||
aa.bank_num as bankNum,
|
||
bb.Name as isName,
|
||
bb.Post as isPost,
|
||
bb.atten_num as isAttenNum,
|
||
bb.bank_num as isBankNum,
|
||
bb.base_price as isBasePrice,
|
||
bb.achievements_price as isAchievementsPrice,
|
||
bb.PayIn as isPayIn,
|
||
bb.Payable as isPayable,
|
||
bb.Describes as isDescribes
|
||
from bns_smz_jx_worker_pay aa
|
||
left join bns_smz_jx_difference_reword bb on aa.id_number=bb.id_number and bb.is_active='1'
|
||
where aa.id_number=#{idNumber} and aa.reword_num=#{rewordNum} and bb.reword_num=#{rewordNum}
|
||
</if>
|
||
<if test='type=="2"'>
|
||
select distinct
|
||
aa.post as post,
|
||
aa.team_name as teamName,
|
||
aa.base_price as basePrice,
|
||
aa.base_num as baseNum,
|
||
aa.basecount as basecount,
|
||
|
||
aa.piece_price as piecePrice,
|
||
aa.piece_num as pieceNum,
|
||
aa.piece_count as pieceCount,
|
||
|
||
aa.sutDown_price as sutDownPrice,
|
||
aa.sutDown_num as sutDownNum,
|
||
aa.sutDown_count as sutDownCount,
|
||
|
||
aa.overtime_price as overtimePrice,
|
||
aa.overtime_num as overtimeNum,
|
||
aa.overcount as overcount,
|
||
aa.achievements_price as achievementsPrice,
|
||
aa.achievements_num as achievementsNum,
|
||
aa.achievementscount as achievementscount,
|
||
aa.payable as payable,
|
||
aa.bonus as bonus,
|
||
bb.Name as isName,
|
||
bb.Post as isPost,
|
||
bb.atten_num as isAttenNum,
|
||
|
||
bb.piece_num as isPieceNum,
|
||
bb.sutDown_num as isSutDownNum,
|
||
|
||
bb.bank_num as isBankNum,
|
||
bb.base_price as isBasePrice,
|
||
bb.achievements_price as isAchievementsPrice,
|
||
bb.PayIn as isPayIn,
|
||
bb.Payable as isPayable,
|
||
bb.Describes as isDescribes
|
||
from bns_smz_jx_confirmation_pay aa
|
||
left join bns_smz_jx_difference_reword bb on aa.id_number=bb.id_number and bb.is_active='1'
|
||
where aa.id_number=#{idNumber} and aa.reword_num=#{rewordNum} and bb.reword_num=#{rewordNum}
|
||
</if>
|
||
<if test='type=="3"'>
|
||
select distinct
|
||
aa.team_name as teamname,
|
||
aa.post as post,
|
||
aa.atten_num as attennum,
|
||
aa.payable as payable,
|
||
aa.withhold as withhold,
|
||
aa.payIn as payIn,
|
||
aa.bank_num as banknum,
|
||
|
||
bb.Name as isName,
|
||
bb.Post as isPost,
|
||
bb.atten_num as isAttenNum,
|
||
bb.bank_num as isBankNum,
|
||
bb.base_price as isBasePrice,
|
||
bb.achievements_price as isAchievementsPrice,
|
||
bb.PayIn as isPayIn,
|
||
bb.Payable as isPayable,
|
||
bb.Describes as isDescribes
|
||
from bns_smz_jx_disk_reword aa
|
||
left join bns_smz_jx_difference_reword bb on aa.id_number=bb.id_number and bb.is_active='1'
|
||
where aa.id_number=#{idNumber} and aa.reword_num=#{rewordNum} and bb.reword_num=#{rewordNum}
|
||
</if>
|
||
<if test='type=="4"'>
|
||
select distinct
|
||
aa.post as post,
|
||
aa.pro_name as proName,
|
||
aa.sub_name as subName,
|
||
aa.team_name as teamName,
|
||
aa.atten_num as attenNum,
|
||
|
||
aa.piece_num as pieceNum,
|
||
aa.sutDown_num as sutDownNum,
|
||
|
||
aa.rest_num as restNum,
|
||
aa.nowork_num as noworkNum,
|
||
aa.base_pay as basePay,
|
||
aa.achievements_pay as achievementsPay,
|
||
aa.bank_num as bankNum,
|
||
bb.Name as isName,
|
||
bb.Post as isPost,
|
||
bb.atten_num as isAttenNum,
|
||
|
||
bb.piece_num as isPieceNum,
|
||
bb.sutDown_num as isSutDownNum,
|
||
|
||
bb.bank_num as isBankNum,
|
||
bb.base_price as isBasePrice,
|
||
bb.achievements_price as isAchievementsPrice,
|
||
bb.PayIn as isPayIn,
|
||
bb.Payable as isPayable,
|
||
bb.Describes as isDescribes
|
||
from bns_smz_jx_attendance_reword aa
|
||
left join bns_smz_jx_difference_reword bb on aa.id_number=bb.id_number and bb.is_active='1'
|
||
where aa.id_number=#{idNumber} and aa.reword_num=#{rewordNum} and bb.reword_num=#{rewordNum}
|
||
</if>
|
||
</select>
|
||
<select id="getDescByIdnumber" resultType="java.lang.String">
|
||
select describes
|
||
from bns_smz_jx_difference_reword aa
|
||
where aa.id_number = #{idNumber}
|
||
and reword_num = #{rewordNum}
|
||
and is_active = '1'
|
||
</select>
|
||
<select id="getDetailForUpadte" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryCheckBean">
|
||
select aa.pro_id as proid
|
||
, aa.sub_id as subid
|
||
, aa.month
|
||
, aa.check_remark as checkremark
|
||
, aa.upload_time as uploadtime
|
||
, bb.USERNAME as uploadName
|
||
, aa.create_time
|
||
, aa.update_time
|
||
from bns_smz_jx_record aa
|
||
left join bns_smz_sys_user bb on aa.upload_id = bb.id
|
||
where aa.reword_num = #{rewordNum}
|
||
</select>
|
||
<select id="getDetailByRewordNum" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryCheckBean">
|
||
select aa.reword_num as rewordnum,
|
||
aa.state,
|
||
aa.month,
|
||
cc.name as proname,
|
||
dd.sub_name as subname,
|
||
aa.projecter_id as projecterid,
|
||
aa.projecter_time as projectertime,
|
||
aa.projecter_remark as projecterremark,
|
||
su.username as projectername,
|
||
aa.subcompany_id as subcompanyid,
|
||
su1.username as subcompanyname,
|
||
aa.subcompany_time as subcompanytime,
|
||
aa.subcompany_remark as subcompanyremark,
|
||
aa.company_id as companyid,
|
||
su2.username as companyname,
|
||
aa.company_time as companytime,
|
||
aa.company_remark as companyremark,
|
||
aa.up_subcompany_id as upsubcompanyid,
|
||
su3.username as upsubcompanyname,
|
||
aa.up_subcompany_time as upsubcompanytime,
|
||
aa.up_subcompany_remark as upsubcompanyremark,
|
||
aa.up_company_id as upcompanyid,
|
||
su4.username as upcompanyname,
|
||
aa.up_company_time as upcompanytime,
|
||
aa.up_company_remark as upcompanyremark,
|
||
aa.countnum,
|
||
aa.workernum,
|
||
aa.attennum,
|
||
aa.payable,
|
||
aa.payIn,
|
||
aa.is_sub_lssued as issublssued,
|
||
aa.remark,
|
||
aa.check_remark as checkremark,
|
||
aa.check_remark as checkremark,
|
||
aa.delstate,
|
||
aa.delremark
|
||
from bns_smz_jx_record aa
|
||
left join bns_smz_bm_project cc on aa.pro_id = cc.id
|
||
left join bns_smz_bm_subcontractor dd on aa.sub_id = dd.id
|
||
left join bns_smz_sys_user su on aa.projecter_id = su.id
|
||
left join bns_smz_sys_user su1 on aa.subcompany_id = su1.id
|
||
left join bns_smz_sys_user su2 on aa.company_id = su2.id
|
||
left join bns_smz_sys_user su3 on aa.up_subcompany_id = su3.id
|
||
left join bns_smz_sys_user su4 on aa.up_company_id = su4.id
|
||
where aa.reword_num = #{rewordNum}
|
||
group by aa.reword_num
|
||
</select>
|
||
<select id="getExpDetailByRewordNum" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryExpViewBean">
|
||
select aa.id_number as idnumber,
|
||
aa.name as name,
|
||
|
||
bb.team_name as zfteamName,
|
||
bb.post as zfpost,
|
||
bb.atten_num as zfattenNum,
|
||
bb.payable as zfpayable,
|
||
bb.withhold as zfwithhold,
|
||
bb.payIn as zfpayIn,
|
||
bb.bank as zfbank,
|
||
bb.bank_num as zfbankNum,
|
||
|
||
cc.post as qrpost,
|
||
cc.base_price as qrbasePrice,
|
||
cc.base_num as qrattenNum,
|
||
cc.basecount as qrbaseCount,
|
||
cc.piece_price as qrpiecePrice,
|
||
cc.piece_num as qrpieceNum,
|
||
cc.piece_count as qrpieceCount,
|
||
cc.sutDown_price as qrsutDownPrice,
|
||
cc.sutDown_num as qrsutDownNum,
|
||
cc.sutDown_count as qrsutDownCount,
|
||
cc.overtime_price as qrovertimePrice,
|
||
cc.overtime_num as qrovertimeNum,
|
||
cc.overcount as qroverCount,
|
||
cc.achievements_price as qrachievementsPrice,
|
||
cc.achievements_num as qrachievementsNum,
|
||
cc.achievementscount as qrachievementsCount,
|
||
cc.payable as qrpayable,
|
||
cc.bonus as qrbonus,
|
||
|
||
dd.name as cpname,
|
||
dd.id_number as cpidNumber,
|
||
dd.team_name as cpteamName,
|
||
dd.post as cppost,
|
||
dd.atten_num as cpattenNum,
|
||
dd.payable as cppayable,
|
||
dd.withhold as cpwithhold,
|
||
dd.payIn as cppayIn,
|
||
dd.bank_num as cpbankNum,
|
||
|
||
ee.post as kqpost,
|
||
ee.pro_name as kqproName,
|
||
ee.sub_name as kqsubName,
|
||
ee.team_name as kqteamName,
|
||
ee.atten_num as kqattenNum,
|
||
ee.piece_num as kqpieceNum,
|
||
ee.sutDown_num as kqsutDownNum,
|
||
ee.rest_num as kqrestNum,
|
||
ee.nowork_num as kqnoworkNum,
|
||
ee.base_pay as kqbasePay,
|
||
ee.achievements_pay as kqachievementsPay,
|
||
ee.bank_num as kqbankNum,
|
||
|
||
ff.name as isName,
|
||
ff.post as isPost,
|
||
ff.atten_num as isAttenNum,
|
||
ff.piece_num as isPieceNum,
|
||
ff.sutDown_num as isSutDownNum,
|
||
ff.bank_num as isBankNum,
|
||
ff.base_price as isBasePrice,
|
||
ff.achievements_price as isAchievementsPrice,
|
||
ff.payIn as isPayIn,
|
||
ff.payable as isPayable
|
||
from (select *
|
||
from (select id_number, name
|
||
from bns_smz_jx_disk_reword
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select id_number, name
|
||
from bns_smz_jx_attendance_reword
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select id_number, name
|
||
from bns_smz_jx_confirmation_pay
|
||
where reword_num = #{rewordNum}
|
||
UNION
|
||
select id_number, name
|
||
from bns_smz_jx_worker_pay
|
||
where reword_num = #{rewordNum}) aa
|
||
group by id_number) aa
|
||
left join (select *
|
||
from bns_smz_jx_worker_pay
|
||
where reword_num = #{rewordNum}) bb on aa.id_number = bb.id_number
|
||
left join (select *
|
||
from bns_smz_jx_confirmation_pay
|
||
where reword_num = #{rewordNum}) cc on aa.id_number = cc.id_number
|
||
left join (select *
|
||
from bns_smz_jx_disk_reword
|
||
where reword_num = #{rewordNum}) dd on aa.id_number = dd.id_number
|
||
left join (select *
|
||
from bns_smz_jx_attendance_reword
|
||
where reword_num = #{rewordNum}) ee on aa.id_number = ee.id_number
|
||
left join (select * from bns_smz_jx_difference_reword where reword_num = #{rewordNum} and is_active = '1') ff
|
||
on aa.id_number = ff.id_number
|
||
where ff.name = '1'
|
||
or ff.post = '1'
|
||
or ff.atten_num = '1'
|
||
or ff.bank_num = '1'
|
||
or ff.base_price = '1'
|
||
or ff.achievements_price = '1'
|
||
or ff.payIn = '1'
|
||
or ff.payable = '1'
|
||
order by name
|
||
</select>
|
||
<select id="getDetailFJByRewordNum" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryCheckBean">
|
||
select aa.type,
|
||
aa.file_name as filename,
|
||
aa.file_path as filepath,
|
||
aa.upload_time as uploadtime,
|
||
su.username as uploadname
|
||
from bns_smz_jx_file_reword aa
|
||
left join bns_smz_sys_user su on aa.upload_user_id = su.id
|
||
where aa.reword_num = #{rewordNum}
|
||
</select>
|
||
<update id="updateFileViewTime">
|
||
update bns_smz_jx_file_reword
|
||
set view_time = NOW()
|
||
where id = #{fileId}
|
||
</update>
|
||
|
||
<update id="updateFileViewStar">
|
||
update bns_smz_jx_file_reword
|
||
set is_star = #{isStar}
|
||
where id = #{fileId}
|
||
</update>
|
||
|
||
<select id="getList" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryCheckBean">
|
||
select aa.reword_num as rewordnum,aa.month,bb.name as proname,cc.sub_name as subname,state,delstate from bns_smz_jx_record aa
|
||
left join bns_smz_bm_project bb on aa.pro_id=bb.id
|
||
left join bns_smz_bm_subcontractor cc on aa.sub_id=cc.id
|
||
where aa.is_active='1'
|
||
<if test='params.rewordNum != null and params.rewordNum != ""'>
|
||
and aa.reword_num=#{params.rewordNum}
|
||
</if>
|
||
<if test='params.keyWord != null and params.keyWord != ""'>
|
||
and (
|
||
aa.reword_num like concat('%',#{params.keyWord},'%')
|
||
or bb.name like concat('%',#{params.keyWord},'%')
|
||
or cc.sub_name like concat('%',#{params.keyWord},'%')
|
||
)
|
||
</if>
|
||
|
||
<if test='params.startMonth != null and params.startMonth !="" and params.endMonth != null and params.endMonth != ""'>
|
||
and aa.month BETWEEN #{params.startMonth} AND #{params.endMonth}
|
||
</if>
|
||
<if test='params.state=="0"'>
|
||
and aa.state=0
|
||
</if>
|
||
<if test='params.state=="1"'>
|
||
and aa.state in (1,2)
|
||
</if>
|
||
<if test='params.state=="2"'>
|
||
and aa.state=6
|
||
</if>
|
||
<if test='params.state=="3"'>
|
||
and aa.state in (3,4,5)
|
||
</if>
|
||
<if test='params.status=="1"'>
|
||
and aa.state in (0,1,2,3,4)
|
||
</if>
|
||
<if test='params.status=="2"'>
|
||
and aa.state=5
|
||
</if>
|
||
order by aa.upload_time desc
|
||
limit #{offset}, #{limit}
|
||
</select>
|
||
<select id="getListNum" resultType="java.lang.Integer">
|
||
select count(1) from bns_smz_jx_record aa
|
||
left join bns_smz_bm_project bb on aa.pro_id=bb.id
|
||
left join bns_smz_bm_subcontractor cc on aa.sub_id=cc.id
|
||
where aa.is_active='1'
|
||
<if test='params.rewordNum != null and params.rewordNum != ""'>
|
||
and aa.reword_num=#{params.rewordNum}
|
||
</if>
|
||
<if test='params.keyWord != null and params.keyWord != ""'>
|
||
and (
|
||
aa.reword_num like concat('%',#{params.keyWord},'%')
|
||
or bb.name like concat('%',#{params.keyWord},'%')
|
||
or cc.sub_name like concat('%',#{params.keyWord},'%')
|
||
)
|
||
</if>
|
||
|
||
<if test='params.startMonth != null and params.startMonth !="" and params.endMonth != null and params.endMonth != ""'>
|
||
and aa.month BETWEEN #{params.startMonth} AND #{params.endMonth}
|
||
</if>
|
||
<if test='params.state=="0"'>
|
||
and aa.state=0
|
||
</if>
|
||
<if test='params.state=="1"'>
|
||
and aa.state in (1,2)
|
||
</if>
|
||
<if test='params.state=="2"'>
|
||
and aa.state=6
|
||
</if>
|
||
<if test='params.state=="3"'>
|
||
and aa.state in (3,4,5)
|
||
</if>
|
||
<if test='params.status=="1"'>
|
||
and aa.state in (0,1,2,3,4)
|
||
</if>
|
||
<if test='params.status=="2"'>
|
||
and aa.state=5
|
||
</if>
|
||
</select>
|
||
<select id="getJxFileRewordData" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryFileBean">
|
||
select id,file_name as filename, file_path as filepath from bns_smz_jx_file_reword where 1=1
|
||
<if test='rewordNum != null and rewordNum != ""'>
|
||
and reword_Num=#{rewordNum}
|
||
</if>
|
||
</select>
|
||
|
||
<select id="selectSalaryFileNum" resultType="java.lang.String">
|
||
select count(*)
|
||
from bns_smz_jx_file_reword
|
||
where reword_num in (${rewordId})
|
||
</select>
|
||
|
||
<select id="selectSalaryFile" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryFileBean">
|
||
select jfr.id as fileId, jfr.file_name, #{params.month} as month,
|
||
CASE jfr.type
|
||
WHEN 1 THEN '考勤表'
|
||
WHEN 2 THEN '支付表-确认单- 传盘'
|
||
WHEN 3 THEN '支付表签字盖章文件'
|
||
WHEN 4 THEN '情况说明'
|
||
WHEN 5 THEN '线下发放流水'
|
||
ELSE ''
|
||
END as type, upload_time, su.USERNAME,
|
||
jfr.file_path, jfr.is_star
|
||
from bns_smz_jx_file_reword jfr
|
||
left join bns_smz_sys_user su on su.id = jfr.upload_user_id
|
||
where jfr.reword_num in (${params.rewordId})
|
||
<if test='params.fileName != null and params.fileName != ""'>
|
||
and jfr.file_name like concat('%', #{params.fileName}, '%')
|
||
</if>
|
||
ORDER BY jfr.is_star DESC
|
||
</select>
|
||
|
||
<select id="selectSalaryFileByQueryType"
|
||
resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryFileBean">
|
||
select jfr.id as fileId, jfr.file_name, jr.month,
|
||
CASE jfr.type
|
||
WHEN 1 THEN '考勤表'
|
||
WHEN 2 THEN '支付表-确认单- 传盘'
|
||
WHEN 3 THEN '支付表签字盖章文件'
|
||
WHEN 4 THEN '情况说明'
|
||
WHEN 5 THEN '线下发放流水'
|
||
ELSE ''
|
||
END as type, bp.name as proName, bs.SUB_NAME, jfr.is_star,
|
||
jfr.file_path
|
||
from bns_smz_jx_file_reword jfr
|
||
left join bns_smz_jx_record jr on jr.reword_num = jfr.reword_num
|
||
left join bns_smz_bm_project bp on bp.id = jr.pro_id
|
||
left join bns_smz_bm_subcontractor bs on bs.id = jr.sub_id
|
||
where 1=1
|
||
<if test='params.fileName != null and params.fileName != ""'>
|
||
and jfr.file_name like concat('%', #{params.fileName}, '%')
|
||
</if>
|
||
<if test='params.queryType == 1 || params.queryType == "1"'>
|
||
and jfr.upload_user_id = #{params.userId}
|
||
</if>
|
||
<if test='params.queryType == 2 || params.queryType == "2"'>
|
||
and jfr.is_star = 1
|
||
</if>
|
||
<if test='params.queryType == 3 || params.queryType == "3"'>
|
||
and jfr.view_time is not null
|
||
ORDER BY jfr.view_time DESC
|
||
</if>
|
||
|
||
</select>
|
||
|
||
<select id="getFilePath" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryFileBean">
|
||
select bp.name as proName, bs.SUB_NAME, jfr.file_name, jfr.file_path from bns_smz_jx_record jr
|
||
left join bns_smz_jx_file_reword jfr on jfr.reword_num = jr.reword_num and jfr.is_active = 1
|
||
left join bns_smz_bm_project bp on bp.id = jr.pro_id
|
||
left join bns_smz_bm_subcontractor bs on bs.id = jr.sub_id
|
||
where jfr.file_name is not null
|
||
<if test='type == 1 || type == "1"'>
|
||
and pro_id in (${arrId})
|
||
</if>
|
||
<if test='type == 2 || type == "2"'>
|
||
and sub_id in (${arrId})
|
||
</if>
|
||
<if test='type == 3 || type == "3"'>
|
||
and jfr.id in (${arrId})
|
||
</if>
|
||
</select>
|
||
|
||
<insert id="addHistory">
|
||
INSERT INTO bns_smz_jx_record_history
|
||
(reword_num, submitter_id, submit_time, flow_node,
|
||
audit_result, audit_remark, create_time)
|
||
VALUES (#{rewordNum}, #{submitterId}, now(), #{flowNode}, #{auditResult}, #{auditRemark}, now())
|
||
</insert>
|
||
|
||
<sql id="getHistoryRef">
|
||
SELECT jrh.reword_num as rewordNum,
|
||
jrh.submitter_id as submitterId,
|
||
su.username as submitterName,
|
||
su.PHONE as userPhone,
|
||
sr.name as roleName,
|
||
jrh.submit_time as submitTime,
|
||
jrh.flow_node as flowNode,
|
||
jrh.audit_result as auditResult,
|
||
jrh.audit_remark as auditRemark
|
||
FROM bns_smz_jx_record_history jrh
|
||
LEFT JOIN bns_smz_sys_user su on jrh.submitter_id = su.ID
|
||
LEFT JOIN bns_smz_sys_role sr on sr.id = su.ROLE_ID
|
||
WHERE jrh.reword_num = #{rewordNum}
|
||
</sql>
|
||
|
||
<select id="getHistory" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryCheckHistoryBean">
|
||
<include refid="getHistoryRef"></include>
|
||
order by jrh.submit_time asc
|
||
</select>
|
||
|
||
<select id="getLatestHistory" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryCheckHistoryBean">
|
||
<include refid="getHistoryRef"></include>
|
||
order by jrh.submit_time desc
|
||
limit 1
|
||
</select>
|
||
|
||
<select id="getDifference" resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryDifferenceBean">
|
||
SELECT all_ids.id_number AS idnumber,
|
||
#{rewordNum} AS rewordnum,
|
||
MAX(CASE WHEN name_diff > 0 THEN 1 ELSE 0 END) AS NAME,
|
||
MAX(CASE WHEN post_diff > 0 THEN 1 ELSE 0 END) AS post,
|
||
MAX(CASE WHEN atten_diff > 0 THEN 1 ELSE 0 END) AS attennum,
|
||
MAX(CASE WHEN payable_diff > 0 THEN 1 ELSE 0 END) AS payable,
|
||
MAX(CASE WHEN payin_diff > 0 THEN 1 ELSE 0 END) AS payIn,
|
||
MAX(CASE WHEN banknum_diff > 0 THEN 1 ELSE 0 END) AS banknum,
|
||
MAX(CASE WHEN baseprice_diff > 0 THEN 1 ELSE 0 END) AS baseprice,
|
||
MAX(CASE WHEN achievements_diff > 0 THEN 1 ELSE 0 END) AS achievementsprice,
|
||
MAX(CASE WHEN piece_num_diff > 0 THEN 1 ELSE 0 END) AS pieceNum,
|
||
MAX(CASE WHEN sutDown_num_diff > 0 THEN 1 ELSE 0 END) AS sutDownNum,
|
||
'' AS describes
|
||
FROM (SELECT DISTINCT id_number
|
||
FROM bns_smz_jx_attendance_reword
|
||
WHERE reword_num = #{rewordNum}
|
||
UNION
|
||
SELECT DISTINCT id_number
|
||
FROM bns_smz_jx_confirmation_pay
|
||
WHERE reword_num = #{rewordNum}
|
||
UNION
|
||
SELECT DISTINCT id_number
|
||
FROM bns_smz_jx_disk_reword
|
||
WHERE reword_num = #{rewordNum}
|
||
UNION
|
||
SELECT DISTINCT id_number
|
||
FROM bns_smz_jx_worker_pay
|
||
WHERE reword_num = #{rewordNum}) all_ids
|
||
LEFT JOIN (SELECT id_number,
|
||
COUNT(DISTINCT NAME) AS name_diff,
|
||
COUNT(DISTINCT post) AS post_diff,
|
||
COUNT(DISTINCT bank_num) AS banknum_diff
|
||
FROM (SELECT id_number,
|
||
NAME,
|
||
post,
|
||
bank_num
|
||
FROM bns_smz_jx_attendance_reword
|
||
WHERE reword_num = #{rewordNum}
|
||
UNION ALL
|
||
SELECT id_number,
|
||
NAME,
|
||
post,
|
||
NULL AS bank_num
|
||
FROM bns_smz_jx_confirmation_pay
|
||
WHERE reword_num = #{rewordNum}
|
||
UNION ALL
|
||
SELECT id_number,
|
||
NAME,
|
||
post,
|
||
bank_num
|
||
FROM bns_smz_jx_disk_reword
|
||
WHERE reword_num = #{rewordNum}
|
||
UNION ALL
|
||
SELECT id_number,
|
||
NAME,
|
||
post,
|
||
bank_num
|
||
FROM bns_smz_jx_worker_pay
|
||
WHERE reword_num = #{rewordNum}) t
|
||
GROUP BY id_number
|
||
HAVING name_diff > 1
|
||
OR post_diff > 1
|
||
OR banknum_diff > 1) basic_info ON all_ids.id_number = basic_info.id_number
|
||
LEFT JOIN (SELECT a.id_number,
|
||
CASE
|
||
|
||
WHEN (a.atten_num + a.piece_num + a.sutDown_num) != ( b.base_num + b.piece_num + b.sutDown_num )
|
||
OR (a.atten_num + a.piece_num + a.sutDown_num) != c.atten_num
|
||
OR ( a.atten_num + a.piece_num + a.sutDown_num ) != d.atten_num THEN
|
||
1 ELSE 0
|
||
END AS atten_diff,
|
||
CASE
|
||
|
||
WHEN a.piece_num != b.piece_num THEN
|
||
1 ELSE 0
|
||
END AS piece_num_diff,
|
||
CASE
|
||
|
||
WHEN a.sutDown_num != b.sutDown_num THEN
|
||
1 ELSE 0
|
||
END AS sutDown_num_diff,
|
||
CASE
|
||
|
||
WHEN a.base_pay != b.base_price THEN
|
||
1 ELSE 0
|
||
END AS baseprice_diff,
|
||
CASE
|
||
|
||
WHEN CAST(
|
||
b.achievements_price AS DECIMAL ( 10, 2 )) NOT BETWEEN CAST(
|
||
SUBSTRING_INDEX( a.achievements_pay, '-', 1 ) AS DECIMAL ( 10, 2 ))
|
||
AND CAST(
|
||
SUBSTRING_INDEX( a.achievements_pay, '-', - 1 ) AS DECIMAL ( 10, 2 )) THEN
|
||
1 ELSE 0
|
||
END AS achievements_diff
|
||
FROM bns_smz_jx_attendance_reword a
|
||
LEFT JOIN bns_smz_jx_confirmation_pay b
|
||
ON a.id_number = b.id_number
|
||
AND b.reword_num = #{rewordNum}
|
||
LEFT JOIN bns_smz_jx_disk_reword c ON a.id_number = c.id_number
|
||
AND c.reword_num = #{rewordNum}
|
||
LEFT JOIN bns_smz_jx_worker_pay d ON a.id_number = d.id_number
|
||
AND d.reword_num = #{rewordNum}
|
||
WHERE
|
||
a.reword_num = #{rewordNum}) attendance_info
|
||
ON all_ids.id_number = attendance_info.id_number
|
||
LEFT JOIN (SELECT b.id_number,
|
||
CASE
|
||
|
||
WHEN b.payable != c.payable
|
||
OR b.payable != d.payable THEN
|
||
1 ELSE 0
|
||
END AS payable_diff,
|
||
CASE
|
||
|
||
WHEN c.payIn != d.payIn THEN
|
||
1 ELSE 0
|
||
END AS payin_diff
|
||
FROM bns_smz_jx_confirmation_pay b
|
||
LEFT JOIN bns_smz_jx_disk_reword c
|
||
ON b.id_number = c.id_number
|
||
AND c.reword_num = #{rewordNum}
|
||
LEFT JOIN bns_smz_jx_worker_pay d ON b.id_number = d.id_number
|
||
AND d.reword_num = #{rewordNum}
|
||
WHERE
|
||
b.reword_num = #{rewordNum}) payment_info ON all_ids.id_number = payment_info.id_number
|
||
WHERE (
|
||
basic_info.id_number IS NOT NULL
|
||
OR attendance_info.atten_diff = 1
|
||
OR attendance_info.piece_num_diff = 1
|
||
OR attendance_info.sutDown_num_diff = 1
|
||
OR attendance_info.baseprice_diff = 1
|
||
OR attendance_info.achievements_diff = 1
|
||
OR payment_info.payable_diff = 1
|
||
OR payment_info.payin_diff = 1
|
||
)
|
||
GROUP BY all_ids.id_number
|
||
</select>
|
||
|
||
<select id="getExpDetailByRewordNumNew"
|
||
resultType="com.bonus.hnrn.rnbmw.salaryfile.entity.SalaryExpViewBean">
|
||
SELECT COALESCE(wp.id_number, cp.id_number, dr.id_number, ar.id_number, dif.id_number) AS idnumber,
|
||
COALESCE(wp.name, cp.name, dr.name, ar.name) AS name,
|
||
|
||
-- jx_worker_pay
|
||
wp.team_name AS zfteamName,
|
||
wp.post AS zfpost,
|
||
wp.atten_num AS zfattenNum,
|
||
wp.payable AS zfpayable,
|
||
wp.withhold AS zfwithhold,
|
||
wp.payIn AS zfpayIn,
|
||
wp.bank AS zfbank,
|
||
wp.bank_num AS zfbankNum,
|
||
|
||
-- jx_confirmation_pay
|
||
cp.post AS qrpost,
|
||
cp.base_price AS qrbasePrice,
|
||
cp.base_num AS qrattenNum,
|
||
cp.basecount AS qrbaseCount,
|
||
cp.piece_price AS qrpiecePrice,
|
||
cp.piece_num AS qrpieceNum,
|
||
cp.piece_count AS qrpieceCount,
|
||
cp.sutDown_price AS qrsutDownPrice,
|
||
cp.sutDown_num AS qrsutDownNum,
|
||
cp.sutDown_count AS qrsutDownCount,
|
||
cp.overtime_price AS qrovertimePrice,
|
||
cp.overtime_num AS qrovertimeNum,
|
||
cp.overcount AS qroverCount,
|
||
cp.achievements_price AS qrachievementsPrice,
|
||
cp.achievements_num AS qrachievementsNum,
|
||
cp.achievementscount AS qrachievementsCount,
|
||
cp.payable AS qrpayable,
|
||
cp.bonus AS qrbonus,
|
||
|
||
-- jx_disk_reword
|
||
dr.team_name AS cpteamName,
|
||
dr.post AS cppost,
|
||
dr.atten_num AS cpattenNum,
|
||
dr.payable AS cppayable,
|
||
dr.withhold AS cpwithhold,
|
||
dr.payIn AS cppayIn,
|
||
dr.bank_num AS cpbankNum,
|
||
|
||
-- jx_attendance_reword
|
||
ar.pro_name AS kqproName,
|
||
ar.sub_name AS kqsubName,
|
||
ar.team_name AS kqteamName,
|
||
ar.atten_num AS kqattenNum,
|
||
ar.piece_num AS kqpieceNum,
|
||
ar.sutDown_num AS kqsutDownNum,
|
||
ar.rest_num AS kqrestNum,
|
||
ar.nowork_num AS kqnoworkNum,
|
||
ar.base_pay AS kqbasePay,
|
||
ar.achievements_pay AS kqachievementsPay,
|
||
ar.bank_num AS kqbankNum,
|
||
|
||
-- jx_difference_reword
|
||
dif.name AS isName,
|
||
dif.post AS isPost,
|
||
dif.atten_num AS isAttenNum,
|
||
dif.piece_num AS isPieceNum,
|
||
dif.sutDown_num AS isSutDownNum,
|
||
dif.bank_num AS isBankNum,
|
||
dif.base_price AS isBasePrice,
|
||
dif.achievements_price AS isAchievementsPrice,
|
||
dif.payIn AS isPayIn,
|
||
dif.payable AS isPayable
|
||
|
||
FROM (
|
||
-- 生成所有 (id_number, rn) 组合
|
||
SELECT id_number, rn
|
||
FROM (SELECT id_number,
|
||
@rn_wp := IF(@prev_id_wp = id_number, @rn_wp + 1, 1) AS rn,
|
||
@prev_id_wp := id_number
|
||
FROM bns_smz_jx_worker_pay
|
||
CROSS JOIN (SELECT @rn_wp := 0, @prev_id_wp := '') AS vars
|
||
WHERE reword_num = #{rewordNum}
|
||
ORDER BY id_number, create_time) t1
|
||
|
||
UNION
|
||
|
||
SELECT id_number, rn
|
||
FROM (SELECT id_number,
|
||
@rn_cp := IF(@prev_id_cp = id_number, @rn_cp + 1, 1) AS rn,
|
||
@prev_id_cp := id_number
|
||
FROM bns_smz_jx_confirmation_pay
|
||
CROSS JOIN (SELECT @rn_cp := 0, @prev_id_cp := '') AS vars
|
||
WHERE reword_num = #{rewordNum}
|
||
ORDER BY id_number, create_time) t2
|
||
|
||
UNION
|
||
|
||
SELECT id_number, rn
|
||
FROM (SELECT id_number,
|
||
@rn_dr := IF(@prev_id_dr = id_number, @rn_dr + 1, 1) AS rn,
|
||
@prev_id_dr := id_number
|
||
FROM bns_smz_jx_disk_reword
|
||
CROSS JOIN (SELECT @rn_dr := 0, @prev_id_dr := '') AS vars
|
||
WHERE reword_num = #{rewordNum}
|
||
ORDER BY id_number, create_time) t3
|
||
|
||
UNION
|
||
|
||
SELECT id_number, rn
|
||
FROM (SELECT id_number,
|
||
@rn_ar := IF(@prev_id_ar = id_number, @rn_ar + 1, 1) AS rn,
|
||
@prev_id_ar := id_number
|
||
FROM bns_smz_jx_attendance_reword
|
||
CROSS JOIN (SELECT @rn_ar := 0, @prev_id_ar := '') AS vars
|
||
WHERE reword_num = #{rewordNum}
|
||
ORDER BY id_number, create_time) t4
|
||
|
||
UNION
|
||
|
||
SELECT id_number, rn
|
||
FROM (SELECT id_number,
|
||
@rn_dif := IF(@prev_id_dif = id_number, @rn_dif + 1, 1) AS rn,
|
||
@prev_id_dif := id_number
|
||
FROM bns_smz_jx_difference_reword
|
||
CROSS JOIN (SELECT @rn_dif := 0, @prev_id_dif := '') AS vars
|
||
WHERE reword_num = #{rewordNum} AND is_active = '1'
|
||
ORDER BY id_number, create_time) t5) all_keys
|
||
|
||
-- 开始 LEFT JOIN 每个带行号的表
|
||
LEFT JOIN (SELECT id_number,
|
||
name,
|
||
team_name,
|
||
post,
|
||
atten_num,
|
||
payable,
|
||
withhold,
|
||
payIn,
|
||
bank,
|
||
bank_num,
|
||
@rownum1 := IF(@prev1 = id_number, @rownum1 + 1, 1) AS rn,
|
||
@prev1 := id_number
|
||
FROM bns_smz_jx_worker_pay
|
||
CROSS JOIN (SELECT @rownum1 := 0, @prev1 := '') AS vars
|
||
WHERE reword_num = #{rewordNum}
|
||
ORDER BY id_number, create_time) wp
|
||
ON all_keys.id_number = wp.id_number AND all_keys.rn = wp.rn
|
||
|
||
LEFT JOIN (SELECT id_number,
|
||
name,
|
||
post,
|
||
base_price,
|
||
base_num,
|
||
basecount,
|
||
piece_price,
|
||
piece_num,
|
||
piece_count,
|
||
sutDown_price,
|
||
sutDown_num,
|
||
sutDown_count,
|
||
overtime_price,
|
||
overtime_num,
|
||
overcount,
|
||
achievements_price,
|
||
achievements_num,
|
||
achievementscount,
|
||
payable,
|
||
bonus,
|
||
@rownum2 := IF(@prev2 = id_number, @rownum2 + 1, 1) AS rn,
|
||
@prev2 := id_number
|
||
FROM bns_smz_jx_confirmation_pay
|
||
CROSS JOIN (SELECT @rownum2 := 0, @prev2 := '') AS vars
|
||
WHERE reword_num = #{rewordNum}
|
||
ORDER BY id_number, create_time) cp
|
||
ON all_keys.id_number = cp.id_number AND all_keys.rn = cp.rn
|
||
|
||
LEFT JOIN (SELECT id_number,
|
||
name,
|
||
team_name,
|
||
post,
|
||
atten_num,
|
||
payable,
|
||
withhold,
|
||
payIn,
|
||
bank_num,
|
||
@rownum3 := IF(@prev3 = id_number, @rownum3 + 1, 1) AS rn,
|
||
@prev3 := id_number
|
||
FROM bns_smz_jx_disk_reword
|
||
CROSS JOIN (SELECT @rownum3 := 0, @prev3 := '') AS vars
|
||
WHERE reword_num = #{rewordNum}
|
||
ORDER BY id_number, create_time) dr
|
||
ON all_keys.id_number = dr.id_number AND all_keys.rn = dr.rn
|
||
|
||
LEFT JOIN (SELECT id_number,
|
||
name,
|
||
pro_name,
|
||
sub_name,
|
||
team_name,
|
||
atten_num,
|
||
piece_num,
|
||
sutDown_num,
|
||
rest_num,
|
||
nowork_num,
|
||
base_pay,
|
||
achievements_pay,
|
||
bank_num,
|
||
@rownum4 := IF(@prev4 = id_number, @rownum4 + 1, 1) AS rn,
|
||
@prev4 := id_number
|
||
FROM bns_smz_jx_attendance_reword
|
||
CROSS JOIN (SELECT @rownum4 := 0, @prev4 := '') AS vars
|
||
WHERE reword_num = #{rewordNum}
|
||
ORDER BY id_number, create_time) ar
|
||
ON all_keys.id_number = ar.id_number AND all_keys.rn = ar.rn
|
||
|
||
-- 修改后的dif连接:为每个id_number选择第一条记录
|
||
LEFT JOIN (SELECT d1.*
|
||
FROM bns_smz_jx_difference_reword d1
|
||
INNER JOIN (SELECT id_number,
|
||
MIN(create_time) as min_create_time
|
||
FROM bns_smz_jx_difference_reword
|
||
WHERE reword_num = #{rewordNum}
|
||
AND is_active = '1'
|
||
GROUP BY id_number) d2
|
||
ON d1.id_number = d2.id_number AND d1.create_time = d2.min_create_time) dif
|
||
ON all_keys.id_number = dif.id_number
|
||
|
||
ORDER BY idnumber, all_keys.rn
|
||
</select>
|
||
|
||
</mapper> |