423 lines
18 KiB
XML
423 lines
18 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.gzrn.rnbmw.person.dao.BMSalaryDao">
|
|
<insert id="saveSalaryBook" useGeneratedKeys="true" keyProperty = "id" keyColumn="id">
|
|
INSERT INTO bm_salary_book_info (
|
|
sub_id,
|
|
pro_id,
|
|
book_name,
|
|
book_status,
|
|
book_month,
|
|
worker_num,
|
|
start_time,
|
|
end_time,
|
|
creator,
|
|
create_time,
|
|
update_time
|
|
) VALUES (
|
|
#{subId},
|
|
#{proId},
|
|
#{bookName},
|
|
#{bookStatus},
|
|
#{bookMonth},
|
|
#{workerNum},
|
|
#{startTime},
|
|
#{endTime},
|
|
#{creator},
|
|
NOW(),
|
|
NOW()
|
|
)
|
|
</insert>
|
|
|
|
<insert id="saveSalaryBookDetails">
|
|
insert
|
|
into
|
|
bm_salary_book_detailed_info
|
|
(
|
|
book_id,
|
|
id_number,
|
|
work_days,
|
|
over_work_days,
|
|
over_work_salary,
|
|
tax_num,
|
|
gross_salary,
|
|
net_salary,
|
|
net_salary_change,
|
|
remark,
|
|
create_time,
|
|
update_time)
|
|
values
|
|
<foreach item="params" collection="list" separator=",">
|
|
(
|
|
#{originalBookId},
|
|
#{params.idNumber},
|
|
#{params.workDays},
|
|
#{params.overWorkDays},
|
|
#{params.overWorkSalary},
|
|
#{params.taxNum},
|
|
#{params.grossSalary},
|
|
#{params.netSalary},
|
|
#{params.netSalaryChange},
|
|
#{params.remark},
|
|
now(),
|
|
now())
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="getRepeatTimeRange" resultType="java.lang.Integer">
|
|
SELECT count(1)
|
|
FROM bm_salary_book_info bsbi
|
|
WHERE ((#{startTime} >= bsbi.start_time and #{startTime} <= bsbi.end_time )
|
|
or (#{endTime} >= bsbi.start_time and #{endTime} <= bsbi.end_time )
|
|
or (bsbi.start_time >= #{startTime} and bsbi.end_time <= #{endTime}))
|
|
and bsbi.sub_id = #{subId} and bsbi.pro_id = #{proId}
|
|
<if test="bookId != null and bookId != ''">
|
|
and bsbi.id != #{bookId}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<update id="updateSalaryBookDetails2Inactive">
|
|
update bm_salary_book_detailed_info set is_active = '0' where book_id = #{bookId}
|
|
</update>
|
|
<update id="updateSalaryBookStartEndInfo">
|
|
update bm_salary_book_info
|
|
set
|
|
start_time = #{startTime},
|
|
end_time= #{endTime},
|
|
worker_num = #{workerNum},
|
|
book_name = #{bookName}
|
|
where id = #{id}
|
|
</update>
|
|
<!-- <insert id="insertTempBookData">-->
|
|
<!-- replace into bm_salary_book_info (-->
|
|
<!-- sub_id,-->
|
|
<!-- pro_id,-->
|
|
<!-- book_status, -- 0 待保存 1 待提交 2 已提交 3 通过 4 拒绝-->
|
|
<!-- book_month,-->
|
|
<!-- start_time,-->
|
|
<!-- end_time,-->
|
|
<!-- creator,-->
|
|
<!-- create_time,-->
|
|
<!-- update_time-->
|
|
<!-- ) VALUES (-->
|
|
<!-- #{subId},-->
|
|
<!-- #{proId},-->
|
|
<!-- #{bookStatus},-->
|
|
<!-- #{bookMonth},-->
|
|
<!-- #{startTime},-->
|
|
<!-- #{endTime},-->
|
|
<!-- #{creator},-->
|
|
<!-- NOW(), -- create_time: 创建时间-->
|
|
<!-- NOW() -- update_time: 更新时间-->
|
|
<!-- );-->
|
|
<!-- </insert>-->
|
|
|
|
<update id="batchUpdateSalaryBookDetails" parameterType="java.util.List">
|
|
<foreach collection="list" item="info" separator=";">
|
|
UPDATE bm_salary_book_detailed_info
|
|
SET over_work_salary = #{overWorkSalary},
|
|
tax_num = #{taxNum},
|
|
net_salary = #{netSalary},
|
|
remark = #{remark},
|
|
update_time = now()
|
|
WHERE id = #{id}
|
|
</foreach>
|
|
</update>
|
|
|
|
<update id="updateSalaryBookFile" >
|
|
UPDATE bm_salary_book_info set
|
|
book_status = 1,
|
|
salary_sign_file_name = #{fileName} ,
|
|
salary_sign_file_path = #{filePath},
|
|
submit_user = #{submitUser},
|
|
submit_time = now(),
|
|
remark = null
|
|
where id = #{bookId}
|
|
</update>
|
|
|
|
<select id="getSalaryBookMinMaxDate" resultType="com.bonus.gzrn.rnbmw.person.entity.BmSalaryBookInfo">
|
|
select min(bsbi.start_time) as start_time, max(bsbi.end_time) as end_time
|
|
from bm_salary_book_info bsbi
|
|
left join bm_salary_book_detailed_info bsbdi on bsbi.id = bsbdi.book_id and bsbdi.is_active = '1'
|
|
where bsbi.sub_id = #{params.subId}
|
|
and bsbi.pro_id = #{params.proId}
|
|
</select>
|
|
|
|
<select id="getSalaryBookStartAndEndTime" resultType="com.bonus.gzrn.rnbmw.person.entity.BmSalaryBookInfo">
|
|
SELECT START_TIME AS startTime, END_TIME AS endTime FROM bm_salary_book_info
|
|
WHERE
|
|
BOOK_MONTH = #{bookMonth}
|
|
and sub_id = #{subId}
|
|
and pro_id = #{proId}
|
|
</select>
|
|
|
|
<sql id="getSalaryBookDetailsRef" >
|
|
SELECT bsbdi.id, bsbdi.book_id, bsbdi.work_days, bsbdi.over_work_days,
|
|
bsbdi.over_work_salary, bsbdi.tax_num, bsbdi.gross_salary,
|
|
bsbdi.net_salary, bsbdi.remark, bsbdi.id_number, bsbdi.net_salary_change,
|
|
bsbi.book_month, bsbi.worker_num, bsbi.book_name, bsbi.book_status,
|
|
bs.sub_name, bp.name as pro_name, concat(bp.name, bsbi.book_month, '月工资') as book_merge_name,
|
|
bsbi.submit_user, bsbi.submit_time
|
|
from bm_salary_book_info bsbi
|
|
left join bm_salary_book_detailed_info bsbdi on bsbi.id = bsbdi.book_id and bsbdi.is_active = '1'
|
|
left join bm_project bp on bsbi.pro_id = bp.ID and bp.is_active = 1
|
|
left join bm_subcontractor bs ON bsbi.SUB_ID = bs.id and bs.IS_ACTIVE = 1
|
|
left join bm_worker bw on bsbdi.id_number = bw.id_number
|
|
WHERE 1 = 1
|
|
<if test="params.bookId != null and params.bookId != ''">
|
|
and bsbi.id = #{params.bookId}
|
|
</if>
|
|
<if test="params.workerName != null and params.workerName != ''">
|
|
and bw.name like concat ('%',#{params.workerName},'%')
|
|
</if>
|
|
<if test="params.proId != null and params.proId != ''">
|
|
and bsbi.pro_id = #{params.proId}
|
|
</if>
|
|
<if test="params.bookMonth != null and params.bookMonth != ''">
|
|
and bsbi.book_month = #{params.bookMonth}
|
|
</if>
|
|
<if test="params.bookStatus != null and params.bookStatus != ''">
|
|
and bsbi.book_status = #{params.bookStatus}
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="getSalaryBookDetailsCount" resultType="java.lang.Integer">
|
|
select count(1) from (<include refid="getSalaryBookDetailsRef"></include>) as c
|
|
</select>
|
|
|
|
<select id="getSalaryBookDetails" resultType="com.bonus.gzrn.rnbmw.person.entity.BmSalaryBookDetailedInfo">
|
|
<include refid="getSalaryBookDetailsRef"></include>
|
|
limit #{offset}, #{limit}
|
|
</select>
|
|
|
|
<select id="getSalaryBookDetailsWithLimit" resultType="com.bonus.gzrn.rnbmw.person.entity.BmSalaryBookDetailedInfo">
|
|
<include refid="getSalaryBookDetailsRef"></include>
|
|
</select>
|
|
|
|
<select id="getSalaryBookById" resultType="com.bonus.gzrn.rnbmw.person.entity.BmSalaryBookInfo">
|
|
SELECT bsbi.id, bsbi.sub_id, bsbi.pro_id, bsbi.book_name, bsbi.book_status, bsbi.book_month,
|
|
bsbi.worker_num, bsbi.remark, bsbi.start_time, bsbi.end_time, bsbi.salary_sign_file_name,
|
|
bsbi.salary_sign_file_path, bsbi.creator, bsbi.create_time,bsbi.update_time,
|
|
bs.sub_name, bp.name as pro_name
|
|
FROM bm_salary_book_info bsbi
|
|
left join bm_project bp on bsbi.pro_id = bp.ID and bp.is_active = 1
|
|
left join bm_subcontractor bs ON bsbi.SUB_ID = bs.id and bs.IS_ACTIVE = 1
|
|
WHERE bsbi.id = #{bookId}
|
|
</select>
|
|
|
|
<select id="getSalaryBooksById" resultType="com.bonus.gzrn.rnbmw.person.entity.BmSalaryBookInfo">
|
|
SELECT bsbi.id, bsbi.sub_id, bsbi.pro_id, bsbi.book_name, bsbi.book_status, bsbi.book_month,
|
|
bsbi.worker_num, bsbi.remark, bsbi.start_time, bsbi.end_time, bsbi.salary_sign_file_name,
|
|
bsbi.salary_sign_file_path, bsbi.creator, bsbi.create_time,bsbi.update_time,
|
|
bs.sub_name, bp.name as pro_name
|
|
FROM bm_salary_book_info bsbi
|
|
left join bm_project bp on bsbi.pro_id = bp.ID and bp.is_active = 1
|
|
left join bm_subcontractor bs ON bsbi.SUB_ID = bs.id and bs.IS_ACTIVE = 1
|
|
WHERE 1=1
|
|
<if test="subId != null and subId != ''">
|
|
bsbi.sub_id = #{subId}
|
|
</if>
|
|
<if test="proId != null and proId != ''">
|
|
bsbi.pro_id = #{proId}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getSalaryBooksByIdNumber" resultType="com.bonus.gzrn.rnbmw.person.entity.BmSalaryBookInfo">
|
|
SELECT bsbi.id, bsbi.sub_id, bsbi.pro_id, bsbi.book_name, bsbi.book_status, bsbi.book_month,
|
|
bsbi.worker_num, bsbi.remark, bsbi.start_time, bsbi.end_time, bsbi.salary_sign_file_name,
|
|
bsbi.salary_sign_file_path, bsbi.creator, bsbi.create_time,bsbi.update_time,
|
|
bs.sub_name, bp.name as pro_name
|
|
FROM bm_salary_book_info bsbi
|
|
left join bm_project bp on bsbi.pro_id = bp.ID and bp.is_active = 1
|
|
left join bm_subcontractor bs ON bsbi.SUB_ID = bs.id and bs.IS_ACTIVE = 1
|
|
WHERE 1=1
|
|
<if test="subId != null and subId != ''">
|
|
bsbi.sub_id = #{subId}
|
|
</if>
|
|
<if test="proId != null and proId != ''">
|
|
bsbi.pro_id = #{proId}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getSalaryBookByMonth" resultType="java.lang.Integer">
|
|
SELECT count(1)
|
|
from bm_salary_book_info bsbi
|
|
WHERE
|
|
bsbi.sub_id = #{params.subId}
|
|
and
|
|
bsbi.pro_id = #{params.proId}
|
|
and
|
|
bsbi.book_month = #{params.bookMonth}
|
|
|
|
</select>
|
|
|
|
<sql id="getSalaryBooksRef">
|
|
SELECT bsbi.id, bsbi.sub_id, bs.sub_name, bsbi.pro_id, bp.name as pro_name,
|
|
bsbi.book_name, bsbi.book_status,
|
|
bsbi.book_month, bsbi.worker_num, bsbi.remark, bsbi.start_time,
|
|
bsbi.end_time, bsbi.salary_sign_file_name, bsbi.salary_sign_file_path,
|
|
bsbi.create_time, bsbi.creator, bsbi.submit_user, bsbi.submit_time,
|
|
CONCAT(
|
|
LPAD(MONTH(bsbi.start_time), 2, '0'), '-', LPAD(DAY(bsbi.start_time), 2, '0'),
|
|
' ~ ',
|
|
LPAD(MONTH(bsbi.end_time), 2, '0'), '-', LPAD(DAY(bsbi.end_time), 2, '0')
|
|
) AS start_and_end_time,
|
|
case when
|
|
bsbi.book_status = 0 then '待提交'
|
|
when bsbi.book_status = 1 then '待审核'
|
|
when bsbi.book_status = 2 then '通过'
|
|
else '拒绝'
|
|
end as book_status_name
|
|
FROM bm_salary_book_info bsbi
|
|
left join bm_project bp on bsbi.pro_id = bp.ID and bp.is_active = 1
|
|
left join bm_subcontractor bs ON bsbi.SUB_ID = bs.id and bs.IS_ACTIVE = 1
|
|
left join pm_company pc on bp.company_id = pc.ID and bp.is_active = 1
|
|
where 1=1
|
|
<if test="params.subId != null and params.subId != ''">
|
|
and bsbi.sub_id = #{params.subId}
|
|
</if>
|
|
<if test="params.proName != null and params.proName != ''">
|
|
and bp.name like concat('%',#{params.proName},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime != '' and params.endTime != null and params.endTime != ''">
|
|
<!-- and (-->
|
|
<!-- (#{params.startTime} >= bsbi.start_time and #{params.startTime} <=bsbi.end_time)-->
|
|
<!-- or-->
|
|
<!-- (#{params.endTime} <= bsbi.end_time and #{params.endTime} >= bsbi.start_time)-->
|
|
<!-- or-->
|
|
<!-- (bsbi.start_time >= #{params.startTime} and bsbi.end_time <= #{params.endTime})-->
|
|
<!-- )-->
|
|
and bsbi.book_month >= #{params.startTime} and bsbi.book_month <= #{params.endTime}
|
|
</if>
|
|
<if test="params.startTime == null or params.startTime == '' or params.endTime == null or params.endTime == ''">
|
|
and bsbi.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)
|
|
</if>
|
|
<if test="params.bookStatus != null and params.bookStatus != ''">
|
|
and bsbi.book_status = #{params.bookStatus}
|
|
</if>
|
|
<if test="params.bookMonth != null and params.bookMonth != ''">
|
|
and bsbi.book_month = #{params.bookMonth}
|
|
</if>
|
|
<if test="params.proId != null and params.proId != ''">
|
|
and bsbi.pro_id = #{params.proId}
|
|
</if>
|
|
<if test="params.bookName != null and params.bookName != ''">
|
|
and bsbi.book_name like concat('%',#{params.bookName},'%')
|
|
</if>
|
|
<if test="params.subName != null and params.subName != ''">
|
|
and bs.sub_name like concat('%',#{params.subName},'%')
|
|
</if>
|
|
order by bsbi.create_time desc
|
|
</sql>
|
|
|
|
<select id="getSalaryBooksCount" resultType="java.lang.Integer">
|
|
select count(1) from (<include refid="getSalaryBooksRef"></include>) as c
|
|
</select>
|
|
|
|
<select id="getSalaryBooks" resultType="com.bonus.gzrn.rnbmw.person.entity.BmSalaryBookInfo">
|
|
<include refid="getSalaryBooksRef"></include>
|
|
limit #{offset}, #{limit}
|
|
</select>
|
|
|
|
<sql id="getSalaryBooksGroupByProRef">
|
|
select bsbi.pro_id, pc.org_name, bp.name as proName, bsbi.book_month, count(bsbdi.id) as worker_num,
|
|
concat(bp.name, bsbi.book_month, '月工资') as book_merge_name, count(distinct bsbi.id) as book_number
|
|
from bm_salary_book_info bsbi left join
|
|
bm_salary_book_detailed_info bsbdi on bsbi.id = bsbdi.book_id and bsbdi.is_active = '1'
|
|
left join bm_project bp on bsbi.pro_id = bp.ID and bp.IS_ACTIVE = '1'
|
|
left join bm_subcontractor bs ON bsbi.SUB_ID = bs.id and bs.IS_ACTIVE = '1'
|
|
LEFT JOIN pm_company pc on bp.company_id = pc.ID and bp.is_active = 1
|
|
where bsbi.book_status in (2)
|
|
<if test="params.startMonth != null and params.startMonth != '' and params.endMonth != null and params.endMonth != ''">
|
|
and bsbi.book_month >= #{params.startMonth} and bsbi.book_month <= #{params.endMonth}
|
|
</if>
|
|
<if test="params.startMonth == null or params.startMonth == '' or params.endMonth == null or params.endMonth == ''">
|
|
and bsbi.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)
|
|
</if>
|
|
<if test="params.companyId != null and params.companyId != ''">
|
|
and pc.ID = #{params.companyId}
|
|
</if>
|
|
<if test="params.proName != null and params.proName != ''">
|
|
and bp.name like concat ('%',#{params.proName},'%')
|
|
</if>
|
|
group by bsbi.pro_id ,pc.org_name, bp.name , bsbi.book_month,book_merge_name
|
|
</sql>
|
|
|
|
<select id="getSalaryBooksGroupByPro" resultType="com.bonus.gzrn.rnbmw.person.entity.BmSalaryBookInfo">
|
|
<include refid="getSalaryBooksGroupByProRef"></include>
|
|
order by bsbi.submit_time desc
|
|
limit #{offset}, #{limit}
|
|
</select>
|
|
|
|
<select id="getSalaryBooksGroupByProCount" resultType="java.lang.Integer">
|
|
select count(1) from (<include refid="getSalaryBooksGroupByProRef"></include>) as c
|
|
</select>
|
|
|
|
<sql id="getSalaryBooksGroupBySubRef">
|
|
select bsbi.id, bsbi.sub_id, bs.sub_name as subName, bp.name as proName, bsbi.book_month, bsbi.worker_num,
|
|
bsbi.book_name, bsbi.salary_sign_file_name, bsbi.book_status,
|
|
CONCAT(
|
|
LPAD(MONTH(bsbi.start_time), 2, '0'), '-', LPAD(DAY(bsbi.start_time), 2, '0'),
|
|
' ~ ',
|
|
LPAD(MONTH(bsbi.end_time), 2, '0'), '-', LPAD(DAY(bsbi.end_time), 2, '0')
|
|
) AS start_and_end_time,
|
|
case when
|
|
bsbi.book_status = 0 then '待提交'
|
|
when bsbi.book_status = 1 then '待审核'
|
|
when bsbi.book_status = 2 then '通过'
|
|
else '拒绝'
|
|
end as book_status_name
|
|
from bm_salary_book_info bsbi
|
|
left join bm_project bp on bsbi.pro_id = bp.ID and bp.IS_ACTIVE = '1'
|
|
left join bm_subcontractor bs ON bsbi.SUB_ID = bs.id and bs.IS_ACTIVE = '1'
|
|
LEFT JOIN pm_company pc on bp.company_id = pc.ID and bp.is_active = 1
|
|
where 1= 1
|
|
<if test="params.startMonth != null and params.startMonth != '' and params.endMonth != null and params.endMonth != ''">
|
|
and bsbi.book_month >= #{params.startMonth} and bsbi.book_month <= #{params.endMonth}
|
|
</if>
|
|
<if test="params.startMonth == null or params.startMonth == '' or params.endMonth == null or params.endMonth == ''">
|
|
and bsbi.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)
|
|
</if>
|
|
<if test="params.subName != null and params.subName != ''">
|
|
and bs.SUB_NAME like concat ('%',#{params.subName},'%')
|
|
</if>
|
|
<if test="params.proName != null and params.proName != ''">
|
|
and bp.name like concat ('%',#{params.proName},'%')
|
|
</if>
|
|
<if test="params.bookStatus != null and params.bookStatus != ''">
|
|
and bsbi.book_status = #{params.bookStatus}
|
|
</if>
|
|
<if test="params.bookStatus == null or params.bookStatus == ''">
|
|
and bsbi.book_status in (1,2,3)
|
|
</if>
|
|
<if test="params.bookId != null and params.bookId != ''">
|
|
and bsbi.id = #{params.bookId}
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="getSalaryBooksGroupBySub" resultType="com.bonus.gzrn.rnbmw.person.entity.BmSalaryBookInfo">
|
|
<include refid="getSalaryBooksGroupBySubRef"></include>
|
|
order by bsbi.submit_time desc
|
|
limit #{offset}, #{limit}
|
|
</select>
|
|
|
|
<select id="getSalaryBooksGroupBySubCount" resultType="java.lang.Integer">
|
|
select count(1) from (<include refid="getSalaryBooksGroupBySubRef"></include>) as c
|
|
</select>
|
|
|
|
<update id="auditSalaryBook">
|
|
update bm_salary_book_info
|
|
set book_status = #{params.bookStatus},
|
|
remark = #{params.remark},
|
|
audit_user = #{params.auditUser},
|
|
audit_time = now()
|
|
where id = #{params.bookId}
|
|
</update>
|
|
|
|
<update id="updateBookInfoWorkerNum">
|
|
UPDATE bm_salary_book_info SET worker_num= #{workerNum} where id = #{bookId}
|
|
</update>
|
|
</mapper> |