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 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 ( #{originalBookId}, #{params.idNumber}, #{params.workDays}, #{params.overWorkDays}, #{params.overWorkSalary}, #{params.taxNum}, #{params.grossSalary}, #{params.netSalary}, #{params.netSalaryChange}, #{params.remark}, now(), now()) update bm_salary_book_detailed_info set is_active = '0' where book_id = #{bookId} update bm_salary_book_info set start_time = #{startTime}, end_time= #{endTime}, worker_num = #{workerNum}, book_name = #{bookName} where id = #{id} 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} 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} 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 and bsbi.id = #{params.bookId} and bw.name like concat ('%',#{params.workerName},'%') and bsbi.pro_id = #{params.proId} and bsbi.book_month = #{params.bookMonth} and bsbi.book_status = #{params.bookStatus} 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 and bsbi.sub_id = #{params.subId} and bp.name like concat('%',#{params.proName},'%') and bsbi.book_month >= #{params.startTime} and bsbi.book_month <= #{params.endTime} and bsbi.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH) and bsbi.book_status = #{params.bookStatus} and bsbi.book_month = #{params.bookMonth} and bsbi.pro_id = #{params.proId} and bsbi.book_name like concat('%',#{params.bookName},'%') and bs.sub_name like concat('%',#{params.subName},'%') order by bsbi.create_time desc 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) and bsbi.book_month >= #{params.startMonth} and bsbi.book_month <= #{params.endMonth} and bsbi.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH) and pc.ID = #{params.companyId} and bp.name like concat ('%',#{params.proName},'%') group by bsbi.pro_id ,pc.org_name, bp.name , bsbi.book_month,book_merge_name 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 and bsbi.book_month >= #{params.startMonth} and bsbi.book_month <= #{params.endMonth} and bsbi.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH) and bs.SUB_NAME like concat ('%',#{params.subName},'%') and bp.name like concat ('%',#{params.proName},'%') and bsbi.book_status = #{params.bookStatus} and bsbi.book_status in (1,2,3) and bsbi.id = #{params.bookId} 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 bm_salary_book_info SET worker_num= #{workerNum} where id = #{bookId}