2062 lines
105 KiB
XML
2062 lines
105 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.person.dao.FaceContrastDao">
|
|
|
|
<insert id="makeAttendanceCard">
|
|
insert into bns_smz_fc_face_contrast(imei,user_id,`name`,id_number,sub_id,pro_id,team_id,
|
|
current_day,add_time,upload_time,photo_path,upload_type,is_success,auditor,audit_status,
|
|
audit_remark,audit_time,audit_type,remark,work_hours,lon,lat,is_active,is_repair)
|
|
values ('-1','-1',#{name},#{idNumber},#{subId},#{proId},#{teamId}
|
|
,#{currentDay},#{addTime},#{addTime},'','2','1','-1','1',
|
|
'后台补卡',#{addTime},'',#{makeCardReason},#{workHours},'','','1',#{isRepair})
|
|
</insert>
|
|
<update id="cancelAttendance">
|
|
update bns_smz_fc_face_contrast set AUDIT_STATUS = '4', WORK_HOURS ='0',remark = #{cancelCardReason} where id_number = #{idNumber} and current_day = #{currentDay} and is_active = '1'
|
|
</update>
|
|
<update id="delAttendance">
|
|
update bns_smz_fc_face_contrast set is_active = '0' where id = #{id} and is_active = '1'
|
|
</update>
|
|
<update id="unauditedCard">
|
|
update bns_smz_fc_face_contrast set AUDIT_STATUS = '1',remark = #{unauditedCardReason}, AUDIT_TIME = #{addTime} , AUDITOR = #{auditor}
|
|
where id_number = #{idNumber} and current_day = #{currentDay} and is_active = '1'
|
|
</update>
|
|
|
|
<update id="unauditedCards">
|
|
update bns_smz_fc_face_contrast set is_active = '0',remark = #{unauditedCardReason} where id_number = #{idNumber} and current_day = #{currentDay}
|
|
</update>
|
|
|
|
<update id="delMakeAttendanceCard">
|
|
UPDATE bns_smz_fc_face_contrast SET `is_active` = '0' WHERE id_number = #{idNumber} AND current_day = #{currentDay} and `is_active` = '1'
|
|
</update>
|
|
|
|
<!-- 考勤统计列表 -->
|
|
<select id="getWorkAttendanceList" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select * from (
|
|
select ffc.ID_NUMBER as idnumber,
|
|
ffc.`NAME`,sdd.`name` as postName,
|
|
org.name as orgName,
|
|
bp.name as proName,
|
|
bp.status,
|
|
bs.id as subId,
|
|
bs.SUB_NAME as subName,
|
|
bst.id as teamId,
|
|
bst.`NAME` as teamName,
|
|
org.id as orgId,
|
|
ffc.pro_id as proId,
|
|
ffc.post_id AS postId,
|
|
ffc.notWorkHours,
|
|
ffc.breakWork,
|
|
ffc.dayNum,
|
|
ffc.countingNum,
|
|
ffc.idleWorkNum,
|
|
#{params.startTime} as startTime,
|
|
#{params.endTime} as endTime,
|
|
IFNULL(ffc.gz,'0') as gz,
|
|
ffc.effectDate,
|
|
CONCAT(IFNULL(ffc.min_achievements_money,'0'),'-',IFNULL(ffc.max_achievements_money,'0')) as jx
|
|
from (
|
|
select id_number,
|
|
name,
|
|
pro_id,
|
|
sub_id,
|
|
team_id,
|
|
post_id,
|
|
gz,
|
|
min_achievements_money,
|
|
max_achievements_money,
|
|
SUM(IF(ffc.data_type = 5 OR ffc.audit_status = 2,1,0)) AS notWorkHours,
|
|
SUM(IF(ffc.data_type = 1 AND ffc.audit_status IN (0,1),1,0)) AS dayNum,
|
|
SUM(IF(ffc.data_type = 2 AND ffc.audit_status IN (0,1),1,0)) AS countingNum,
|
|
SUM(IF(ffc.data_type = 3 AND ffc.audit_status IN (0,1),1,0)) AS idleWorkNum,
|
|
SUM(IF(ffc.data_type = 4 AND ffc.audit_status IN (0,1),1,0)) as breakWork,
|
|
effectDate
|
|
from (
|
|
select DISTINCT aa.* from (
|
|
select id_card AS ID_NUMBER,
|
|
user_name AS name,
|
|
DATE_FORMAT(ffc.create_date,'%Y-%m-%d') AS CURRENT_DAY,
|
|
pro_id,
|
|
sub_id,
|
|
team_id,
|
|
post_id,
|
|
audit_status,
|
|
wage_criterion as gz,
|
|
DATE_FORMAT(effect_date,'%Y-%m-%d') as effectDate,
|
|
min_perfor AS min_achievements_money,
|
|
max_perfor AS max_achievements_money,
|
|
data_type
|
|
from bns_smz_xbg_user_attendance ffc
|
|
where DATE_FORMAT(ffc.create_date,'%Y-%m-%d')>=#{params.startTime} and #{params.endTime}>=DATE_FORMAT(ffc.create_date,'%Y-%m-%d')
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
and ffc.pro_id=#{params.proId}
|
|
</if>
|
|
<if test='params.roleLevel == "4" and params.subId!=null and params.subId!=""'>
|
|
and ffc.sub_id=#{params.subId}
|
|
</if>
|
|
<if test="params.idNumber !=null and params.idNumber !=''">
|
|
and ffc.id_card=#{params.idNumber}
|
|
</if>
|
|
and ffc.audit_status in (0,1,2)
|
|
) aa
|
|
) ffc where effectDate is not null group by id_number,pro_id,sub_id,team_id,effectDate
|
|
)ffc
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.id=ffc.POST_ID
|
|
LEFT JOIN (
|
|
select * from bns_smz_bm_subcontractor bs
|
|
where is_active='1'
|
|
) bs ON bs.id=ffc.SUB_ID
|
|
LEFT JOIN (
|
|
select * from bns_smz_bm_sub_team bst
|
|
where IS_ACTIVE = '1'
|
|
) bst ON bst.id=ffc.TEAM_ID
|
|
LEFT JOIN (
|
|
select * from bns_smz_bm_project bp
|
|
where IS_ACTIVE = '1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<if test="params.proName !=null and params.proName !=''">
|
|
and bp.name=#{params.proName}
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
and bp.status=#{params.status}
|
|
</if>
|
|
) bp ON bp.id=ffc.pro_id
|
|
LEFT JOIN (
|
|
select * from bns_smz_pm_organization org
|
|
where is_active='1'
|
|
) org ON org.id=bp.company_id
|
|
where bp.IS_ACTIVE='1'
|
|
<if test="params.name !=null and params.name !=''">
|
|
and ffc.name like concat ('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.subName !=null and params.subName !=''">
|
|
and bs.SUB_NAME like concat ('%',#{params.subName},'%')
|
|
</if>
|
|
<if test="params.teamName !=null and params.teamName !=''">
|
|
and bst.name like concat ('%',#{params.teamName},'%')
|
|
</if>
|
|
order by effectDate
|
|
) aa
|
|
${params.orderBy}
|
|
limit #{offset}, #{limit}
|
|
</select>
|
|
|
|
<select id="getHistroyAttend" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select distinct DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') as einTime,
|
|
DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d') as exitTime
|
|
from (
|
|
SELECT t1.*
|
|
FROM bns_smz_bm_worker_attend_history t1
|
|
INNER JOIN (
|
|
SELECT id_number, MAX(EIN_TIME) AS max_order
|
|
FROM bns_smz_bm_worker_attend_history
|
|
GROUP BY id_number
|
|
) t2 ON t1.id_number = t2.id_number AND t1.EIN_TIME = t2.max_order
|
|
) bwah
|
|
where bwah.id_number=#{idNumber}
|
|
and #{startTime}>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d')
|
|
and bwah.EXIT_TIME is not null
|
|
</select>
|
|
<select id="getWorkAttendanceCount" resultType="java.lang.Integer">
|
|
select count(1) as num from (
|
|
select ffc.ID_NUMBER as idnumber,
|
|
ffc.`NAME`,
|
|
sdd.`name` as postName,
|
|
org.name as orgName,
|
|
bp.name as proName,
|
|
bp.status,
|
|
bs.id as subId,
|
|
bs.SUB_NAME as subName,
|
|
bst.id as teamId,
|
|
bst.`NAME` as teamName,
|
|
org.id as orgId,
|
|
ffc.pro_id as proId,
|
|
ffc.notWorkHours,
|
|
ffc.breakWork,
|
|
ffc.dayNum,
|
|
ffc.countingNum,
|
|
ffc.idleWorkNum,
|
|
#{params.startTime} as startTime,
|
|
#{params.endTime} as endTime,
|
|
IFNULL(ffc.gz,'0') as gz,
|
|
ffc.effectDate,
|
|
CONCAT(IFNULL(ffc.min_achievements_money,'0'),'-',IFNULL(ffc.max_achievements_money,'0')) as jx
|
|
from (
|
|
select id_number,
|
|
name,
|
|
pro_id,
|
|
sub_id,
|
|
team_id,
|
|
post_id,
|
|
gz,
|
|
min_achievements_money,
|
|
max_achievements_money,
|
|
SUM(IF(ffc.data_type = 5 OR ffc.audit_status = 2,1,0)) AS notWorkHours,
|
|
SUM(IF(ffc.data_type = 1 AND ffc.audit_status IN (0,1),1,0)) AS dayNum,
|
|
SUM(IF(ffc.data_type = 2 AND ffc.audit_status IN (0,1),1,0)) AS countingNum,
|
|
SUM(IF(ffc.data_type = 3 AND ffc.audit_status IN (0,1),1,0)) AS idleWorkNum,
|
|
SUM(IF(ffc.data_type = 4 AND ffc.audit_status IN (0,1),1,0)) as breakWork,
|
|
effectDate
|
|
from (
|
|
select DISTINCT * from (
|
|
select * from (
|
|
select id_card AS ID_NUMBER,
|
|
user_name AS name,
|
|
DATE_FORMAT(create_date,'%Y-%m-%d') AS CURRENT_DAY,
|
|
pro_id,
|
|
sub_id,
|
|
team_id,
|
|
post_id,
|
|
audit_status,
|
|
wage_criterion as gz,
|
|
effect_date as effectDate,
|
|
min_perfor AS min_achievements_money,
|
|
max_perfor AS max_achievements_money,
|
|
data_type
|
|
from bns_smz_xbg_user_attendance ffc
|
|
where ffc.audit_status in('0','1','2') and DATE_FORMAT(ffc.create_date,'%Y-%m-%d')>=#{params.startTime} and #{params.endTime}>=DATE_FORMAT(ffc.create_date,'%Y-%m-%d')
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
and ffc.pro_id=#{params.proId}
|
|
</if>
|
|
<if test='params.roleLevel == "4" and params.subId!=null and params.subId!=""'>
|
|
and ffc.sub_id=#{params.subId}
|
|
</if>
|
|
<if test="params.idNumber !=null and params.idNumber !=''">
|
|
and ffc.id_card=#{params.idNumber}
|
|
</if>
|
|
having 1 order by create_time desc
|
|
) aa
|
|
GROUP BY ID_NUMBER,CURRENT_DAY,PRO_ID,SUB_ID,team_id
|
|
union
|
|
select ID_NUMBER,'' as name,attendance_time as CURRENT_DAY,'' as PRO_ID,'' AS SUB_ID,'' as team_id,'' as post_id,'1' AS AUDIT_STATUS
|
|
,'' as gz,'' as effectDate,'' as min_achievements_money,'' as max_achievements_money,'' AS data_type
|
|
from bns_smz_fc_team_attendance_content fac
|
|
where fac.is_active='1' and fac.attendance_time>=#{params.startTime} and #{params.endTime}>=fac.attendance_time
|
|
) aa
|
|
) ffc where effectDate is not null group by id_number,pro_id,sub_id,team_id,effectDate
|
|
)ffc
|
|
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.id=ffc.POST_ID
|
|
LEFT JOIN (select * from bns_smz_bm_subcontractor bs
|
|
where is_active='1'
|
|
) bs ON bs.id=ffc.SUB_ID
|
|
LEFT JOIN (select * from bns_smz_bm_sub_team bst
|
|
where IS_ACTIVE = '1'
|
|
) bst ON bst.id=ffc.TEAM_ID
|
|
LEFT JOIN (select * from bns_smz_bm_project bp
|
|
where IS_ACTIVE = '1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<if test="params.proName !=null and params.proName !=''">
|
|
and bp.name=#{params.proName}
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
and bp.status=#{params.status}
|
|
</if>
|
|
) bp ON bp.id=ffc.pro_id
|
|
LEFT JOIN (select * from bns_smz_pm_organization org
|
|
where is_active='1'
|
|
) org ON org.id=bp.company_id
|
|
where bp.IS_ACTIVE='1'
|
|
<if test="params.name !=null and params.name !=''">
|
|
and ffc.name like concat ('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.subName !=null and params.subName !=''">
|
|
and bs.SUB_NAME like concat ('%',#{params.subName},'%')
|
|
</if>
|
|
<if test="params.teamName !=null and params.teamName !=''">
|
|
and bst.name like concat ('%',#{params.teamName},'%')
|
|
</if>
|
|
) res
|
|
</select>
|
|
<!-- 考勤统计导出-->
|
|
<select id="getWorkerAttendanceInfo" parameterType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean"
|
|
resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select * from (
|
|
select ffc.ID_NUMBER as idnumber,
|
|
ffc.`NAME`,sdd.`name` as postName,
|
|
org.name as orgName,
|
|
bp.name as proName,
|
|
bp.status,
|
|
bs.id as subId,
|
|
bwp.bank_card as bankCard,
|
|
bs.SUB_NAME as subName,
|
|
bst.id as teamId,
|
|
bst.`NAME` as teamName,
|
|
org.id as orgId,ffc.pro_id as proId,
|
|
IFNULL(ffc.notWorkHours,0) as QqCounts,
|
|
IFNULL(ffc.breakWork,0) AS breakWork,
|
|
IFNULL(ffc.dayNum,0) as dayNum,
|
|
IFNULL(ffc.countingNum,0) AS countingNum,
|
|
IFNULL(ffc.idleWorkNum,0) AS idleWorkNum,
|
|
#{params.startTime} as startTime,
|
|
#{params.endTime} as endTime,
|
|
IFNULL(ffc.gz,'0') as gz,
|
|
ffc.effectDate,
|
|
CONCAT(IFNULL(ffc.min_achievements_money,'0'),'-',IFNULL(ffc.max_achievements_money,'0')) as jx
|
|
from (
|
|
select id_number,
|
|
name,
|
|
pro_id,
|
|
sub_id,
|
|
team_id,
|
|
post_id,
|
|
gz,
|
|
min_achievements_money,
|
|
max_achievements_money,
|
|
SUM(IF(ffc.data_type = 5 OR ffc.audit_status = 2,1,0)) AS notWorkHours,
|
|
SUM(IF(ffc.data_type = 1 AND ffc.audit_status IN (0,1),1,0)) AS dayNum,
|
|
SUM(IF(ffc.data_type = 2 AND ffc.audit_status IN (0,1),1,0)) AS countingNum,
|
|
SUM(IF(ffc.data_type = 3 AND ffc.audit_status IN (0,1),1,0)) AS idleWorkNum,
|
|
SUM(IF(ffc.data_type = 4 AND ffc.audit_status IN (0,1),1,0)) as breakWork,
|
|
effectDate
|
|
from (
|
|
select DISTINCT * from (
|
|
select * from (
|
|
select id_card AS ID_NUMBER,
|
|
user_name AS name,
|
|
DATE_FORMAT(ffc.create_date,'%Y-%m-%d') AS CURRENT_DAY,
|
|
pro_id,
|
|
sub_id,
|
|
team_id,
|
|
post_id,
|
|
audit_status,
|
|
wage_criterion as gz,
|
|
DATE_FORMAT(effect_date,'%Y-%m-%d') as effectDate,
|
|
min_perfor AS min_achievements_money,
|
|
max_perfor AS max_achievements_money,
|
|
data_type
|
|
from bns_smz_xbg_user_attendance ffc
|
|
where DATE_FORMAT(ffc.create_date,'%Y-%m-%d')>=#{params.startTime} and #{params.endTime}>=DATE_FORMAT(ffc.create_date,'%Y-%m-%d')
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
and ffc.pro_id=#{params.proId}
|
|
</if>
|
|
<if test='params.roleLevel == "4" and params.subId!=null and params.subId!=""'>
|
|
and ffc.sub_id=#{params.subId}
|
|
</if>
|
|
<if test="params.idNumber !=null and params.idNumber !=''">
|
|
and ffc.id_card=#{params.idNumber}
|
|
</if>
|
|
and ffc.audit_status in (0,1,2) having 1 order by create_time desc
|
|
) aa
|
|
GROUP BY ID_NUMBER,CURRENT_DAY,PRO_ID,SUB_ID,team_id
|
|
union
|
|
select ID_NUMBER,'' as name,attendance_time as CURRENT_DAY,'' as PRO_ID,'' AS SUB_ID,'' as team_id,'' as post_id,'1' AS AUDIT_STATUS
|
|
,'' as gz,'' as effectDate,'' as min_achievements_money,'' as max_achievements_money,0 AS data_type
|
|
from bns_smz_fc_team_attendance_content fac
|
|
where fac.is_active='1' and fac.attendance_time>=#{params.startTime} and #{params.endTime}>=fac.attendance_time
|
|
) aa
|
|
) ffc where effectDate is not null group by id_number,pro_id,sub_id,team_id,effectDate
|
|
)ffc
|
|
left join bns_smz_bm_worker_payroll bwp on ffc.id_number=bwp.id_number
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.id=ffc.POST_ID
|
|
LEFT JOIN (select * from bns_smz_bm_subcontractor bs
|
|
where is_active='1'
|
|
) bs ON bs.id=ffc.SUB_ID
|
|
LEFT JOIN (select * from bns_smz_bm_sub_team bst
|
|
where IS_ACTIVE = '1'
|
|
) bst ON bst.id=ffc.TEAM_ID
|
|
LEFT JOIN (select * from bns_smz_bm_project bp
|
|
where IS_ACTIVE = '1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<if test="params.proName !=null and params.proName !=''">
|
|
and bp.name=#{params.proName}
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
and bp.status=#{params.status}
|
|
</if>
|
|
) bp ON bp.id=ffc.pro_id
|
|
LEFT JOIN (select * from bns_smz_pm_organization org
|
|
where is_active='1'
|
|
) org ON org.id=bp.company_id
|
|
where bp.IS_ACTIVE='1'
|
|
<if test="params.name !=null and params.name !=''">
|
|
and ffc.name like concat ('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.subName !=null and params.subName !=''">
|
|
and bs.SUB_NAME like concat ('%',#{params.subName},'%')
|
|
</if>
|
|
<if test="params.teamName !=null and params.teamName !=''">
|
|
and bst.name like concat ('%',#{params.teamName},'%')
|
|
</if>
|
|
order by effectDate asc
|
|
) aa
|
|
order by name desc,effectDate asc
|
|
</select>
|
|
|
|
<select id="exportWorkerAttendance" parameterType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean"
|
|
resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT ffc.ID_NUMBER as idNumber,ffc.CURRENT_DAY as currentDay,bp.ID as proId,ffc.address
|
|
FROM bns_smz_fc_face_contrast ffc
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.id=ffc.PRO_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwr.ID_NUMBER=ffc.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER= bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bwr.SUB_ID=bs.id
|
|
WHERE ffc.is_active='1' AND ffc.is_success='1' AND bwr.IS_ACTIVE='1' AND bwr.examine_status='1'
|
|
AND ffc.CURRENT_DAY BETWEEN #{startTime} AND #{endTime}
|
|
<if test="name !=null and name !=''">
|
|
AND bw.name=#{name}
|
|
</if>
|
|
<if test="orgId != null and orgId != ''">
|
|
<if test='roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{companyId})
|
|
</if>
|
|
|
|
<if test='roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{orgId})
|
|
</if>
|
|
|
|
<if test='roleLevel == "3"'>
|
|
AND bp.company_id = #{orgId}
|
|
</if>
|
|
|
|
<if test='roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{subId})
|
|
</if>
|
|
</if>
|
|
<if test="proId !=null and proId !=''">
|
|
AND ffc.PRO_ID=#{proId}
|
|
</if>
|
|
<if test="idNumber !=null and idNumber !=''">
|
|
AND ffc.ID_NUMBER=#{idNumber}
|
|
</if>
|
|
<if test="teamId !=null and teamId !=''">
|
|
AND ffc.team_Id=#{teamId}
|
|
</if>
|
|
<if test="subName !=null and subName !=''">
|
|
and bs.SUB_NAME like concat ('%',#{subName},'%')
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 获取人员考勤某日详情 -->
|
|
<select id="findImg" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT *
|
|
FROM (SELECT ffc.user_name as name, ffc.check_image as photoPath,
|
|
DATE_FORMAT(ffc.check_time,'%Y-%m-%d %H:%i:%s') as checkTime,
|
|
DATE_FORMAT(ffc.create_date,'%Y-%m-%d)') as addTime,
|
|
DATE_FORMAT(ffc.create_date,'%Y-%m-%d') as currentDay
|
|
FROM bns_smz_xbg_user_attendance ffc
|
|
WHERE DATE_FORMAT(ffc.create_date,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
|
|
AND ffc.PRO_ID = #{proId}
|
|
and ffc.id_card = #{idNumber}
|
|
order BY ffc.create_time desc limit 10000
|
|
) a
|
|
GROUP BY a.currentDay
|
|
</select>
|
|
<!--<select id="findImg" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT *
|
|
FROM (SELECT su.USERNAME as name, ffc.PHOTO_PATH as photoPath, ffc.ADD_TIME as addTime,ffc.CURRENT_DAY as currentDay
|
|
FROM bns_smz_fc_face_contrast ffc
|
|
LEFT JOIN bns_smz_sys_user su ON su.id=ffc.USER_ID
|
|
WHERE ffc.is_active = '1'
|
|
and ffc.CURRENT_DAY BETWEEN #{startTime} AND #{endTime}
|
|
AND ffc.PRO_ID = #{proId}
|
|
and ffc.ID_NUMBER = #{idNumber}
|
|
order BY ffc.ADD_TIME desc limit 10000
|
|
) a
|
|
GROUP BY a.currentDay
|
|
</select>-->
|
|
|
|
|
|
<!-- 获取单个人员考勤信息集合 -->
|
|
<select id="getWorkerAttendanceOne" parameterType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean"
|
|
resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT a.* FROM (
|
|
SELECT ffc.user_name AS name,
|
|
ffc.wage_criterion as gz,
|
|
bp.name as proName,
|
|
IF(ffc.data_type = 5, '未打卡','已打卡') AS success,
|
|
DATE_FORMAT(ffc.create_date,'%Y-%m-%d') as currentDay,
|
|
CASE WHEN ffc.data_type IN (1,2,3,4) and ffc.audit_status = '0' THEN '待审核'
|
|
WHEN ffc.data_type = 1 and ffc.audit_status = '1' THEN '计日'
|
|
WHEN ffc.data_type = 2 and ffc.audit_status = '1' THEN '计件'
|
|
WHEN ffc.data_type = 3 and ffc.audit_status = '1' THEN '停窝工'
|
|
WHEN ffc.data_type = 4 and ffc.audit_status = '1' THEN '休息'
|
|
WHEN ffc.data_type = 5 or ffc.audit_status = '2' THEN '无效'
|
|
END as auditStatus,
|
|
CASE WHEN ffc.data_type IN (1,2,3,4) AND ffc.audit_status = '0' THEN '待审核'
|
|
WHEN ffc.data_type IN (1,2,3,4) AND ffc.audit_status = '1' THEN '审核通过'
|
|
WHEN ffc.data_type IN (1,2,3,4) AND ffc.audit_status = '2' THEN '审核驳回'
|
|
WHEN ffc.data_type = 5 THEN ''
|
|
END AS auditResult,
|
|
ffc.audti_user as AUDITOR,
|
|
ffc.AUDIT_TIME as auditTime,
|
|
ffc.AUDIT_REMARK as auditRemark,
|
|
ffc.lon,
|
|
ffc.lat,
|
|
ffc.check_image as imgPath,
|
|
DATE_FORMAT(ffc.create_time,'%Y-%m-%d %H:%i:%s') as addTime,
|
|
ffc.address,
|
|
ffc.data_type AS dataType,
|
|
ffc.gx_name AS gxName
|
|
FROM (select * from (
|
|
select id,
|
|
id_card AS ID_NUMBER,
|
|
pro_id,
|
|
sub_id,
|
|
team_id,
|
|
create_date,
|
|
lon,
|
|
lat,
|
|
address,
|
|
user_name,
|
|
create_time,
|
|
audti_user,
|
|
audit_status,
|
|
audit_time,
|
|
audit_remark,
|
|
data_type,
|
|
check_image,
|
|
check_time,
|
|
wage_criterion,
|
|
gx_name
|
|
from bns_smz_xbg_user_attendance where audit_status IN ('0','1','2')
|
|
) aa where ID_NUMBER = #{idNumber} having 1 order by create_time desc) ffc
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.id=ffc.pro_id
|
|
WHERE DATE_FORMAT(ffc.create_date,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
|
|
and ffc.pro_id=#{proId} AND ffc.SUB_ID=#{subId} and ffc.team_id=#{teamId}
|
|
and ffc.ID_NUMBER=#{idNumber}
|
|
GROUP BY ffc.create_date desc
|
|
ORDER BY ffc.create_time DESC
|
|
)a where 1=1
|
|
and gz=#{gz}
|
|
order by currentDay desc
|
|
</select>
|
|
|
|
<!-- 获取人员考勤某日详情 -->
|
|
<select id="getWorkerAttendanceCurrentDay" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select * from (
|
|
SELECT a.* FROM (
|
|
SELECT DATE_FORMAT(ffc.create_date,'%Y-%m-%d') as currentDay,
|
|
check_image as imgPath,
|
|
effect_Date as effectDate,
|
|
CASE WHEN ffc.data_type IN (1,2,3,4) and ffc.audit_status = '0' THEN '待审核'
|
|
WHEN ffc.data_type = 1 and ffc.audit_status = '1' THEN '计日'
|
|
WHEN ffc.data_type = 2 and ffc.audit_status = '1' THEN '计件'
|
|
WHEN ffc.data_type = 3 and ffc.audit_status = '1' THEN '停窝工'
|
|
WHEN ffc.data_type = 4 and ffc.audit_status = '1' THEN '休息'
|
|
WHEN ffc.data_type = 5 OR ffc.audit_status = '2' THEN '无效'
|
|
END as auditStatus
|
|
FROM (
|
|
select team_id,create_date,pro_id,sub_id,id_card,data_type,audit_status,effect_date,check_image
|
|
from bns_smz_xbg_user_attendance
|
|
where audit_status in ('0','1','2')
|
|
and id_card = #{idNumber} having 1 order by create_time desc
|
|
) ffc
|
|
WHERE DATE_FORMAT(ffc.create_date,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
|
|
and ffc.pro_id=#{proId} AND ffc.SUB_ID=#{subId} and ffc.team_id=#{teamId} and ffc.id_card = #{idNumber}
|
|
GROUP BY ffc.create_date desc
|
|
)a where effectDate=#{effectDate}
|
|
GROUP BY a.currentDay desc
|
|
) aa order by currentDay asc
|
|
</select>
|
|
|
|
<select id="getWorkerAttendanceDetail" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select ID_NUMBER as idNumber,PROJECT_ID as proName,SUB_ID as subId,team_id as teamId
|
|
,EIN_TIME as einTime,EXIT_TIME as exitTime
|
|
from bns_smz_bm_worker_attend_history where is_active='1'
|
|
and ID_NUMBER=#{idNumber} and PROJECT_ID=#{proId}
|
|
and SUB_ID=#{subId} and team_id=#{teamId}
|
|
</select>
|
|
<select id="getWorkerKqEffectDate" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select distinct * from (
|
|
select ID_NUMBER,
|
|
effect_Date as effectDate
|
|
from bns_smz_fc_face_contrast ffc
|
|
where ffc.is_active='1' and ffc.CURRENT_DAY>=#{startTime} and #{endTime}>=ffc.CURRENT_DAY and ffc.id_number=#{idNumber}
|
|
) aa where effectDate is not null order by effectDate
|
|
</select>
|
|
<!-- 获取人员考勤某日详情 -->
|
|
<select id="getNameByIdNumber" parameterType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean"
|
|
resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT ffc.user_name as name
|
|
FROM bns_smz_xbg_user_attendance ffc
|
|
WHERE ffc.id_card = #{idNumber} ORDER BY ffc.create_date desc limit 1
|
|
</select>
|
|
<select id="getWorkDay" parameterType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean"
|
|
resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select *
|
|
from (
|
|
select distinct CURRENT_DAY,id_number,PRO_ID,WORK_HOURS,is_active,is_success,ADD_TIME,AUDIT_STATUS from bns_smz_fc_face_contrast where is_active='1' and is_success='1'
|
|
union
|
|
select distinct fta.attendance_date as CURRENT_DAY,ffc.id_number,ffc.project_id as PRO_ID,1 as WORK_HOURS,1 as is_active,1 as is_success
|
|
, fta.upload_time as ADD_TIME,1 as AUDIT_STATUS
|
|
FROM bns_smz_fc_team_attendance fta
|
|
LEFT JOIN bns_smz_fc_team_attendance_content ftac ON ftac.team_attendance_id = fta.id
|
|
LEFT JOIN bns_smz_bm_worker_record ffc ON ffc.ID_NUMBER = ftac.id_number
|
|
where fta.is_active='1'
|
|
) aa
|
|
where CURRENT_DAY = #{currentDay}
|
|
and ID_NUMBER = #{idNumber} and is_active = '1'
|
|
and PRO_ID = #{proId} AND is_success = 1
|
|
order by ADD_TIME desc limit 1
|
|
</select>
|
|
<select id="getProName" resultType="java.lang.String">
|
|
select name as proName
|
|
from bns_smz_bm_project
|
|
where ID = #{proId}
|
|
</select>
|
|
<select id="getWorkData" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select bwr.ID_NUMBER,
|
|
ffc.WORK_HOURS as kqCounts,
|
|
bwr.PROJECT_ID as proId
|
|
from bns_smz_bm_worker_record bwr
|
|
LEFT JOIN bns_smz_fc_face_contrast ffc ON ffc.ID_NUMBER = bwr.ID_NUMBER
|
|
where ffc.PRO_ID = #{proId}
|
|
and bwr.ID_NUMBER = #{idNumber}
|
|
and ffc.CURRENT_DAY = #{time}
|
|
and bwr.IS_ACTIVE = '1'
|
|
AND bwr.examine_status = '1'
|
|
AND ffc.is_active = '1'
|
|
order by ffc.ADD_TIME desc limit 1
|
|
</select>
|
|
<select id="getProNum" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select count(1) as num
|
|
from (
|
|
select DISTINCT PRO_ID
|
|
from bns_smz_fc_face_contrast
|
|
where ID_NUMBER =
|
|
#{idNumber}
|
|
and CURRENT_DAY
|
|
BETWEEN
|
|
#{sTime}
|
|
AND
|
|
#{eTime}
|
|
) res
|
|
</select>
|
|
<select id="getEinAndExit" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select EIN_TIME as einTime,EXIT_TIME as exitTime from bns_smz_bm_worker_attend_history
|
|
where ID_NUMBER = #{idNumber} and PROJECT_ID = #{proId}
|
|
order by EIN_TIME desc -- limit 1
|
|
</select>
|
|
<!-- 查询当天最新的未审核的考勤 -->
|
|
<select id="getWorkerAttendanceOne2" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT a.* FROM (
|
|
SELECT ffc.name,bp.name as proName,ffc.CURRENT_DAY as currentDay,
|
|
if(ffc.IS_SUCCESS =0,'未打卡','已打卡') as success,
|
|
ffc.WORK_HOURS as workHours,
|
|
CASE ffc.AUDIT_STATUS WHEN '0' THEN '待审核' WHEN '1' THEN '有效' WHEN '2' THEN'无效' END as auditStatus,
|
|
u.USERNAME as AUDITOR,ffc.AUDIT_TIME as auditTime,ffc.AUDIT_REMARK as auditRemark,ffc.lon,ffc.lat,ffc.ADD_TIME as addTime, ffc.address
|
|
FROM bns_smz_fc_face_contrast ffc
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.id=ffc.PRO_ID
|
|
LEFT JOIN bns_smz_sys_user u ON u.id=ffc.AUDITOR
|
|
WHERE ffc.is_active='1' AND ffc.CURRENT_DAY = #{bean.currentDay}
|
|
AND ffc.PRO_ID=#{bean.proId}
|
|
and ffc.ID_NUMBER=#{bean.idNumber}
|
|
GROUP BY ffc.CURRENT_DAY desc
|
|
ORDER BY ffc.CURRENT_DAY DESC
|
|
)a
|
|
LIMIT 1
|
|
</select>
|
|
<!-- 根据身份证ID、工程查询出入场日期 -->
|
|
<select id="getTimeById" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT
|
|
left(bwah.EIN_TIME,10) AS einTime,
|
|
left(bwah.EXIT_TIME,10) AS exitTime,
|
|
bwah.ID_NUMBER AS idNumber
|
|
FROM bns_smz_bm_worker_attend_history bwah
|
|
WHERE bwah.PROJECT_ID = #{proId}
|
|
AND bwah.ID_NUMBER = #{idNumber}
|
|
ORDER BY bwah.EIN_TIME asc
|
|
</select>
|
|
<select id="getAllKq" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select ffc.ID_NUMBER,
|
|
time.DT as attendDate,
|
|
ffc.address,
|
|
ffc.is_repair as isrepair,
|
|
ffc.auditStatus,
|
|
ffc.auditRemark,
|
|
ffc.gxName,
|
|
ffc.dataType
|
|
from
|
|
(
|
|
SELECT DATE_FORMAT( DATE_ADD(CONCAT(#{startTime}), INTERVAL(help_topic_id) DAY),'%Y-%m-%d') DT
|
|
FROM mysql.help_topic
|
|
WHERE help_topic_id <= TIMESTAMPDIFF(DAY,CONCAT(#{startTime}),CONCAT(#{endTime}))
|
|
ORDER BY DT
|
|
) time
|
|
left join (
|
|
select * from (
|
|
select aa.*
|
|
from(
|
|
select distinct id_card AS ID_NUMBER,
|
|
max(DATE_FORMAT(ffc.create_date,'%Y-%m-%d')) as CURRENT_DAY,
|
|
is_repair,
|
|
address,
|
|
audit_status as auditStatus,
|
|
audit_remark as auditRemark,
|
|
pro_id,
|
|
effect_Date as effectDate,
|
|
data_type AS dataType,
|
|
gx_name AS gxName
|
|
from bns_smz_xbg_user_attendance ffc
|
|
where ffc.id_card=#{idNumber}
|
|
and ffc.audit_status in ('0','1','2')
|
|
and ffc.pro_id=#{proId}
|
|
and ffc.sub_id=#{subId}
|
|
and ffc.team_id=#{teamId}
|
|
and DATE_FORMAT(ffc.create_date,'%Y-%m-%d') BETWEEN #{einTime} AND #{exitTime}
|
|
group by id_card,create_date
|
|
) aa
|
|
) aa where effectDate=#{effectDate}
|
|
) ffc on time.DT=ffc.CURRENT_DAY
|
|
ORDER BY time.DT asc
|
|
</select>
|
|
<!-- 根据身份证ID查询有考勤记录的日期 -->
|
|
<select id="getCurrentDayByIdNum" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT
|
|
ffc.CURRENT_DAY currentDay
|
|
FROM bns_smz_fc_face_contrast ffc
|
|
WHERE
|
|
ffc.ID_NUMBER = #{idNumber} and ffc.is_active = '1'
|
|
<if test="einTime !=null and einTime !=''">
|
|
AND ffc.CURRENT_DAY >= #{einTime}
|
|
</if>
|
|
<if test="exitTime !=null and exitTime !=''">
|
|
<![CDATA[
|
|
AND ffc.CURRENT_DAY <= #{exitTime}
|
|
]]>
|
|
</if>
|
|
GROUP BY ffc.CURRENT_DAY
|
|
ORDER BY ffc.CURRENT_DAY
|
|
</select>
|
|
<select id="getWorkDay2" parameterType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean"
|
|
resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select AUDIT_STATUS as auditStatus
|
|
from bns_smz_fc_face_contrast
|
|
where CURRENT_DAY = #{currentDay}
|
|
and ID_NUMBER = #{idNumber} and is_active = '1'
|
|
and PRO_ID = #{proId}
|
|
order by ADD_TIME desc limit 1
|
|
</select>
|
|
<select id="getEinAndExitDate" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select SUBSTR(EIN_TIME,1,10) as einTime,SUBSTR(EXIT_TIME,1,10) as exitTime from bns_smz_bm_worker_attend_history
|
|
where ID_NUMBER = #{idNumber} and PROJECT_ID = #{proId}
|
|
order by EIN_TIME asc
|
|
</select>
|
|
|
|
<select id="getOrderTimeWorkData" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT
|
|
bwr.ID_NUMBER,
|
|
sum( ffc.WORK_HOURS ) AS kqCounts,
|
|
sum( ffc.OVER_HOURS ) AS jbCounts
|
|
FROM bns_smz_bm_worker_record bwr
|
|
INNER JOIN (
|
|
SELECT ID_NUMBER, CURRENT_DAY, PRO_ID, WORK_HOURS, OVER_HOURS
|
|
FROM bns_smz_fc_face_contrast
|
|
WHERE is_success = '1'
|
|
AND is_active = '1'
|
|
and PRO_ID = #{proId}
|
|
AND CURRENT_DAY BETWEEN #{einTime} AND #{exitTime}
|
|
GROUP BY ID_NUMBER, CURRENT_DAY
|
|
) ffc ON ffc.ID_NUMBER = bwr.ID_NUMBER
|
|
WHERE
|
|
bwr.ID_NUMBER = #{idNumber}
|
|
AND bwr.IS_ACTIVE = '1'
|
|
AND bwr.examine_status = '1'
|
|
GROUP BY
|
|
ffc.ID_NUMBER
|
|
</select>
|
|
|
|
<select id="getWorkNumberCount" resultType="java.lang.Integer">
|
|
select count(*) from(
|
|
select * from (
|
|
select
|
|
pro.proid,pro.proname,pro.time
|
|
from (
|
|
select distinct
|
|
proid,proname,time
|
|
from (
|
|
SELECT DATE_FORMAT( DATE_ADD(CONCAT(#{params.startTime}), INTERVAL(help_topic_id) DAY),'%Y-%m-%d') time ,'1' as idd
|
|
FROM mysql.help_topic
|
|
WHERE help_topic_id <= TIMESTAMPDIFF(DAY,CONCAT(#{params.startTime}),CONCAT(#{params.endTime}))
|
|
ORDER BY time
|
|
) times
|
|
left join (select id as proid,name as proname,'1' as idd from bns_smz_bm_project bp where is_active='1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
AND bp.status = #{params.status}
|
|
</if>
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
AND bp.id = #{params.proId}
|
|
</if>
|
|
) bp on times.idd=bp.idd
|
|
order by proid,time desc
|
|
) pro
|
|
<if test='params.proType == "0"'>
|
|
union
|
|
select '0' as proid,'全部工程' as proname,time from (
|
|
select
|
|
pro.proid,pro.proname,pro.time
|
|
from (
|
|
select distinct
|
|
proid,proname,time
|
|
from (
|
|
SELECT DATE_FORMAT( DATE_ADD(CONCAT(#{params.startTime}), INTERVAL(help_topic_id) DAY),'%Y-%m-%d') time ,'1' as idd
|
|
FROM mysql.help_topic
|
|
WHERE help_topic_id <= TIMESTAMPDIFF(DAY,CONCAT(#{params.startTime}),CONCAT(#{params.endTime}))
|
|
ORDER BY time
|
|
) times
|
|
left join (select id as proid,name as proname,'1' as idd from bns_smz_bm_project bp where is_active='1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
AND bp.status = #{params.status}
|
|
</if>
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
AND bp.id = #{params.proId}
|
|
</if>
|
|
) bp on times.idd=bp.idd
|
|
order by proid,time desc
|
|
) pro
|
|
) aa group by time
|
|
</if>
|
|
) aa
|
|
)dd
|
|
</select>
|
|
<!-- 在线人数统计列表 -->
|
|
<select id="getWorkNumberList" resultType="com.bonus.hnrn.rnbmw.person.entity.WorkNumberBean">
|
|
select * from (
|
|
select * from (
|
|
select * from (
|
|
select wnr.* from bns_smz_work_number_record wnr
|
|
left join (
|
|
select bp.id as proid,bp.name as proname,'1' as idd,org.name as orgname,bp.company_id,bp.status from bns_smz_bm_project bp
|
|
left join bns_smz_pm_organization org on bp.company_id=org.id
|
|
where bp.is_active='1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
AND bp.id = #{params.proId}
|
|
</if>
|
|
) bp on wnr.proid=bp.proid
|
|
where bp.proid is not null
|
|
<if test="params.startTime !=null and params.startTime !=''">
|
|
AND wnr.time >= #{params.startTime} and #{params.endTime}>=wnr.time
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
AND bp.status = #{params.status}
|
|
</if>
|
|
<if test='params.proType == "0"'>
|
|
union
|
|
select wnr.* from bns_smz_work_number_record wnr
|
|
where 1=1
|
|
<if test="params.startTime !=null and params.startTime !=''">
|
|
AND wnr.time >= #{params.startTime} and #{params.endTime}>=wnr.time
|
|
</if>
|
|
</if>
|
|
) aa order by aa.proid,aa.time desc
|
|
) bb order by orgname,time desc
|
|
) aa where entranceNum!=0 OR einNum!=0 OR exitNum!=0
|
|
ORDER BY aa.proid DESC ,aa.time DESC
|
|
<!-- <if test="params.orderBy !=null and params.orderBy !=''">-->
|
|
<!-- ${params.orderBy}-->
|
|
<!-- </if>-->
|
|
</select>
|
|
<select id="getWorkNumberListByTable" resultType="com.bonus.hnrn.rnbmw.person.entity.WorkNumberBean">
|
|
select * from (
|
|
select * from (
|
|
select
|
|
pro.orgname,pro.proid,pro.proname,pro.time,
|
|
(
|
|
SELECT count(1) FROM bns_smz_bm_worker_attend_history bwah
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwah.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.ID = bwah.SUB_ID
|
|
LEFT JOIN bns_smz_pm_organization po1 ON po1.ID = bwah.ORG_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwah.ID_NUMBER = bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.ID = bwr.TEAM_ID
|
|
LEFT JOIN bns_smz_pm_organization po2 ON po2.ID = bwr.ORG_ID and po1.COMPANY_ID = po2.COMPANY_ID
|
|
LEFT JOIN bns_smz_sys_user su ON su.id = bwr.examine_user_id
|
|
left join bns_smz_pm_company pc on pc.id = po1.company_id
|
|
WHERE
|
|
bwah.is_active = '1' and bw.is_active = '1' and bp.IS_ACTIVE = '1' and bwr.IS_ACTIVE = '1'
|
|
and bwah.PROJECT_ID=pro.proid
|
|
and case when bwah.EXIT_TIME is null then bwah.EXIT_TIME is null and pro.time>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d')
|
|
else bwah.EXIT_TIME is not null and pro.time>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') and DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d')>=pro.time end
|
|
) AS entranceNum,
|
|
(
|
|
select count(*) from (
|
|
select distinct * from (
|
|
select distinct CURRENT_DAY,id_number,PRO_ID from
|
|
(select * from bns_smz_fc_face_contrast where is_active='1' and CURRENT_DAY>=#{params.startTime} and #{params.endTime}>=CURRENT_DAY) aa
|
|
where is_active='1' and is_success='1' and AUDIT_STATUS in ('0','1') GROUP BY CURRENT_DAY,id_number
|
|
union
|
|
select distinct fta.attendance_date as CURRENT_DAY,ffc.id_number,ffc.project_id as PRO_ID
|
|
FROM bns_smz_fc_team_attendance fta
|
|
LEFT JOIN bns_smz_fc_team_attendance_content ftac ON ftac.team_attendance_id = fta.id
|
|
LEFT JOIN bns_smz_bm_worker_record ffc ON ffc.ID_NUMBER = ftac.id_number
|
|
) aa ) bb where bb.PRO_ID=pro.proid and bb.CURRENT_DAY=pro.time
|
|
) as worknum,
|
|
(
|
|
select count(*) from (
|
|
select distinct * from (
|
|
select distinct CURRENT_DAY,id_number,PRO_ID from
|
|
(select * from bns_smz_fc_face_contrast where is_active='1' and CURRENT_DAY>=#{params.startTime} and #{params.endTime}>=CURRENT_DAY) aa
|
|
where is_active='1' and AUDIT_STATUS='3' GROUP BY CURRENT_DAY,id_number
|
|
) aa ) bb where bb.PRO_ID=pro.proid and bb.CURRENT_DAY=pro.time
|
|
) as restnum,
|
|
(
|
|
SELECT count(1) FROM bns_smz_bm_worker_attend_history bwah
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwah.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.ID = bwah.SUB_ID
|
|
LEFT JOIN bns_smz_pm_organization po1 ON po1.ID = bwah.ORG_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwah.ID_NUMBER = bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.ID = bwr.TEAM_ID
|
|
LEFT JOIN bns_smz_pm_organization po2 ON po2.ID = bwr.ORG_ID and po1.COMPANY_ID = po2.COMPANY_ID
|
|
LEFT JOIN bns_smz_sys_user su ON su.id = bwr.examine_user_id
|
|
left join bns_smz_pm_company pc on pc.id = po1.company_id
|
|
WHERE
|
|
bwah.is_active = '1' and bw.is_active = '1' and bp.IS_ACTIVE = '1' and bwr.IS_ACTIVE = '1'
|
|
and bwah.PROJECT_ID=pro.proid
|
|
and case when bwah.EXIT_TIME is null then bwah.EXIT_TIME is null and pro.time=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d')
|
|
else bwah.EXIT_TIME is not null and pro.time=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') and DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d')>=pro.time end
|
|
) AS einNum,
|
|
(
|
|
SELECT count(1) FROM bns_smz_bm_worker_attend_history bwah
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwah.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.ID = bwah.SUB_ID
|
|
LEFT JOIN bns_smz_pm_organization po1 ON po1.ID = bwah.ORG_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwah.ID_NUMBER = bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.ID = bwr.TEAM_ID
|
|
LEFT JOIN bns_smz_pm_organization po2 ON po2.ID = bwr.ORG_ID and po1.COMPANY_ID = po2.COMPANY_ID
|
|
LEFT JOIN bns_smz_sys_user su ON su.id = bwr.examine_user_id
|
|
left join bns_smz_pm_company pc on pc.id = po1.company_id
|
|
WHERE
|
|
bwah.is_active = '1' and bw.is_active = '1' and bp.IS_ACTIVE = '1' and bwr.IS_ACTIVE = '1'
|
|
and bwah.PROJECT_ID=pro.proid
|
|
and bwah.EXIT_TIME is not null and pro.time>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') and DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d')=pro.time
|
|
) AS exitNum
|
|
from (
|
|
select distinct
|
|
orgname,proid,proname,time
|
|
from (
|
|
SELECT DATE_FORMAT( DATE_ADD(CONCAT(#{params.startTime}), INTERVAL(help_topic_id) DAY),'%Y-%m-%d') time ,'1' as idd
|
|
FROM mysql.help_topic
|
|
WHERE help_topic_id <= TIMESTAMPDIFF(DAY,CONCAT(#{params.startTime}),CONCAT(#{params.endTime}))
|
|
ORDER BY time
|
|
) times
|
|
left join (
|
|
select bp.id as proid,bp.name as proname,'1' as idd,CONCAT(org3.`NAME`,'/',org2.`NAME`,case when org.type='3' then '' else '/' end,case when org.type='3' then '' else org.`NAME` end) as orgname,bp.company_id from bns_smz_bm_project bp
|
|
left join bns_smz_pm_organization org on bp.company_id=org.id
|
|
left join bns_smz_pm_organization org2 on org.PARENT_ID=org2.id
|
|
left join bns_smz_pm_organization org3 on org2.PARENT_ID=org3.id
|
|
where bp.is_active='1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
AND bp.status = #{params.status}
|
|
</if>
|
|
<if test="params.proId !=null and params.proId !='' and params.proId !='0'">
|
|
AND bp.id = #{params.proId}
|
|
</if>
|
|
) bp on times.idd=bp.idd
|
|
order by proid,time desc
|
|
) pro
|
|
<if test='params.proType == "0"'>
|
|
union
|
|
select '' as orgname,'0' as proid,'全部工程' as proname,time,sum(entranceNum) as entranceNum,sum(worknum) as worknum,sum(RESTnum) as RESTnum,sum(einNum) as einNum,sum(exitNum) as exitNum from (
|
|
select
|
|
pro.orgname,pro.proid,pro.proname,pro.time,
|
|
(
|
|
SELECT count(1) FROM bns_smz_bm_worker_attend_history bwah
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwah.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.ID = bwah.SUB_ID
|
|
LEFT JOIN bns_smz_pm_organization po1 ON po1.ID = bwah.ORG_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwah.ID_NUMBER = bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.ID = bwr.TEAM_ID
|
|
LEFT JOIN bns_smz_pm_organization po2 ON po2.ID = bwr.ORG_ID and po1.COMPANY_ID = po2.COMPANY_ID
|
|
LEFT JOIN bns_smz_sys_user su ON su.id = bwr.examine_user_id
|
|
left join bns_smz_pm_company pc on pc.id = po1.company_id
|
|
WHERE
|
|
bwah.is_active = '1' and bw.is_active = '1' and bp.IS_ACTIVE = '1' and bwr.IS_ACTIVE = '1'
|
|
and bwah.PROJECT_ID=pro.proid
|
|
and case when bwah.EXIT_TIME is null then bwah.EXIT_TIME is null and pro.time>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d')
|
|
else bwah.EXIT_TIME is not null and pro.time>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') and DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d')>=pro.time end
|
|
) AS entranceNum,
|
|
(
|
|
select count(*) from (
|
|
select distinct * from (
|
|
select distinct CURRENT_DAY,id_number,PRO_ID from
|
|
(select * from bns_smz_fc_face_contrast where is_active='1' and CURRENT_DAY>=#{params.startTime} and #{params.endTime}>=CURRENT_DAY) aa
|
|
where is_active='1' and is_success='1' and AUDIT_STATUS in ('0','1') GROUP BY CURRENT_DAY,id_number
|
|
union
|
|
select distinct fta.attendance_date as CURRENT_DAY,ffc.id_number,ffc.project_id as PRO_ID
|
|
FROM bns_smz_fc_team_attendance fta
|
|
LEFT JOIN bns_smz_fc_team_attendance_content ftac ON ftac.team_attendance_id = fta.id
|
|
LEFT JOIN bns_smz_bm_worker_record ffc ON ffc.ID_NUMBER = ftac.id_number
|
|
) aa ) bb where bb.PRO_ID=pro.proid and bb.CURRENT_DAY=pro.time
|
|
) as worknum,
|
|
(
|
|
select count(*) from (
|
|
select distinct * from (
|
|
select distinct CURRENT_DAY,id_number,PRO_ID from
|
|
(select * from bns_smz_fc_face_contrast where is_active='1' and CURRENT_DAY>=#{params.startTime} and #{params.endTime}>=CURRENT_DAY) aa
|
|
where is_active='1' and AUDIT_STATUS in ('3') GROUP BY CURRENT_DAY,id_number
|
|
) aa ) bb where bb.PRO_ID=pro.proid and bb.CURRENT_DAY=pro.time
|
|
) as RESTnum,
|
|
(
|
|
SELECT count(1) FROM bns_smz_bm_worker_attend_history bwah
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwah.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.ID = bwah.SUB_ID
|
|
LEFT JOIN bns_smz_pm_organization po1 ON po1.ID = bwah.ORG_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwah.ID_NUMBER = bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.ID = bwr.TEAM_ID
|
|
LEFT JOIN bns_smz_pm_organization po2 ON po2.ID = bwr.ORG_ID and po1.COMPANY_ID = po2.COMPANY_ID
|
|
LEFT JOIN bns_smz_sys_user su ON su.id = bwr.examine_user_id
|
|
left join bns_smz_pm_company pc on pc.id = po1.company_id
|
|
WHERE
|
|
bwah.is_active = '1' and bw.is_active = '1' and bp.IS_ACTIVE = '1' and bwr.IS_ACTIVE = '1'
|
|
and bwah.PROJECT_ID=pro.proid
|
|
and case when bwah.EXIT_TIME is null then bwah.EXIT_TIME is null and pro.time=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d')
|
|
else bwah.EXIT_TIME is not null and pro.time=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') and DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d')>=pro.time end
|
|
) AS einNum,
|
|
(
|
|
SELECT count(1) FROM bns_smz_bm_worker_attend_history bwah
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwah.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.ID = bwah.SUB_ID
|
|
LEFT JOIN bns_smz_pm_organization po1 ON po1.ID = bwah.ORG_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwah.ID_NUMBER = bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.ID = bwr.TEAM_ID
|
|
LEFT JOIN bns_smz_pm_organization po2 ON po2.ID = bwr.ORG_ID and po1.COMPANY_ID = po2.COMPANY_ID
|
|
LEFT JOIN bns_smz_sys_user su ON su.id = bwr.examine_user_id
|
|
left join bns_smz_pm_company pc on pc.id = po1.company_id
|
|
WHERE
|
|
bwah.is_active = '1' and bw.is_active = '1' and bp.IS_ACTIVE = '1' and bwr.IS_ACTIVE = '1'
|
|
and bwah.PROJECT_ID=pro.proid
|
|
and bwah.EXIT_TIME is not null and pro.time>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') and DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d')=pro.time
|
|
) AS exitNum
|
|
from (
|
|
select distinct
|
|
orgname,proid,proname,time
|
|
from (
|
|
SELECT DATE_FORMAT( DATE_ADD(CONCAT(#{params.startTime}), INTERVAL(help_topic_id) DAY),'%Y-%m-%d') time ,'1' as idd
|
|
FROM mysql.help_topic
|
|
WHERE help_topic_id <= TIMESTAMPDIFF(DAY,CONCAT(#{params.startTime}),CONCAT(#{params.endTime}))
|
|
ORDER BY time
|
|
) times
|
|
left join (
|
|
select bp.id as proid,bp.name as proname,'1' as idd,CONCAT(org3.`NAME`,'/',org2.`NAME`,case when org.type='3' then '' else '/' end,case when org.type='3' then '' else org.`NAME` end) as orgname,bp.company_id from bns_smz_bm_project bp
|
|
left join bns_smz_pm_organization org on bp.company_id=org.id
|
|
left join bns_smz_pm_organization org2 on org.PARENT_ID=org2.id
|
|
left join bns_smz_pm_organization org3 on org2.PARENT_ID=org3.id
|
|
where bp.is_active='1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
AND bp.status = #{params.status}
|
|
</if>
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
AND bp.id = #{params.proId}
|
|
</if>
|
|
) bp on times.idd=bp.idd
|
|
order by proid,time desc
|
|
) pro
|
|
) aa group by time
|
|
</if>
|
|
) aa order by orgname,time desc
|
|
) cc where entranceNum!=0 OR einNum!=0 OR exitNum!=0
|
|
<if test="params.orderBy !=null and params.orderBy !=''">
|
|
${params.orderBy}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getWorkNumberListForTable" resultType="com.bonus.hnrn.rnbmw.person.entity.WorkNumberBean">
|
|
select * from (
|
|
select '' as orgname,'0' as proid,'全部工程' as proname ,1 as sortd
|
|
union
|
|
select CONCAT(org3.`NAME`,'/',org2.`NAME`,case when org.type='3' then '' else '/' end,case when org.type='3' then '' else org.`NAME` end) as orgname,bp.id as proid,bp.name as proname,2 as sortd from bns_smz_bm_project bp
|
|
left join bns_smz_pm_organization org on bp.company_id=org.id
|
|
left join bns_smz_pm_organization org2 on org.PARENT_ID=org2.id
|
|
left join bns_smz_pm_organization org3 on org2.PARENT_ID=org3.id
|
|
where bp.is_active='1'
|
|
) aa
|
|
</select>
|
|
|
|
<select id="getAllWorkList" resultType="java.lang.Integer">
|
|
SELECT
|
|
count(1)
|
|
FROM bns_smz_bm_worker_record bwr
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwr.ID_NUMBER and bw.is_active = '1'
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwr.PROJECT_ID and bp.is_active = '1'
|
|
LEFT JOIN bns_smz_pm_organization org ON bp.company_id=org.id
|
|
WHERE bwr.IS_ACTIVE = '1'
|
|
AND bwr.ein_status = '1'
|
|
and bw.name is not null and bp.IS_ACTIVE = '1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
AND bp.status = #{params.status}
|
|
</if>
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
AND bp.id = #{params.proId}
|
|
</if>
|
|
</select>
|
|
<select id="getWorkEinNum" resultType="java.lang.String">
|
|
select count(1) as num from(
|
|
select * from (
|
|
select distinct
|
|
'' as IMEI,'1' as USERID,HWAH.NAME as name,HWAH.ID_NUMBER as IDNUMBER,HWAH.SUB_ID as SUBID,HWAH.PROJECT_ID as PROID,HWAH.TEAM_ID as TEAMID,#{params.time} as CURRENTDAY,
|
|
now() as ADDTIME,now() as uploadtime,'' as PHOTOPATH,'' as UPLOADTYPE,'1' as ISSUCCESS,'自动补充' as AUDITOR,
|
|
'4' AUDIT_STATUS,'自动补充' as AUDITREMARK,now() as AUDITTIME,'5' as AUDITTYPE,'自动补充' as remark,'0' as WORK_HOURS,'0' as OVER_HOURS,'' as lon,'' as lat,'' as address,HWAH.post_id as post_id,bwc.effectDate as effect_date,bwc.wagecriterion as wagecriterion ,bwc.min_achievements_money as minachievementsmoney,bwc.max_achievements_money as maxachievementsmoney,bwp.bank_card as bankcard,'0' as isrepair,'1' as isactive
|
|
FROM bns_smz_bm_worker_attend_history HWAH
|
|
left join (
|
|
SELECT m1.*
|
|
FROM (select * from bns_smz_bm_worker_contract where #{params.time}>=effectDate) m1
|
|
LEFT JOIN (select * from bns_smz_bm_worker_contract where #{params.time}>=effectDate) m2
|
|
ON m1.idCard = m2.idCard AND m2.upload_time>m1.upload_time
|
|
WHERE m2.idCard IS NULL
|
|
) bwc on HWAH.id_number=bwc.idCard and HWAH.PROJECT_ID=bwc.pro_id
|
|
left join bns_smz_bm_worker_payroll bwp on HWAH.id_number=bwp.id_number
|
|
where HWAH.is_active='1' and bwc.effectDate is not null AND #{params.time}=DATE_FORMAT(EIN_TIME,'%Y-%m-%d')
|
|
<if test=' params.proId !="0" and params.proId!=null'>
|
|
AND HWAH.PROject_ID = #{params.proId}
|
|
</if>
|
|
and HWAH.id_number not in (
|
|
select IDNUMBER from (
|
|
select * from (
|
|
select distinct
|
|
'' as IMEI,'1' as USERID,HWAH.NAME as name,HWAH.ID_NUMBER as IDNUMBER,HWAH.SUB_ID as SUBID,HWAH.PROJECT_ID as PROID,HWAH.TEAM_ID as TEAMID,#{params.time} as CURRENTDAY,
|
|
now() as ADDTIME,now() as uploadtime,'' as PHOTOPATH,'' as UPLOADTYPE,'1' as ISSUCCESS,'自动补充' as AUDITOR,
|
|
'4' AUDIT_STATUS,'自动补充' as AUDITREMARK,now() as AUDITTIME,'5' as AUDITTYPE,'自动补充' as remark,'0' as WORK_HOURS,'0' as OVER_HOURS,'' as lon,'' as lat,'' as address,HWAH.post_id as post_id,bwc.effectDate as effect_date,bwc.wagecriterion as wagecriterion ,bwc.min_achievements_money as minachievementsmoney,bwc.max_achievements_money as maxachievementsmoney,bwp.bank_card as bankcard,'0' as isrepair,'1' as isactive
|
|
FROM bns_smz_bm_worker_attend_history HWAH
|
|
left join (
|
|
SELECT m1.*
|
|
FROM (select * from bns_smz_bm_worker_contract where #{params.time}>=effectDate) m1
|
|
LEFT JOIN (select * from bns_smz_bm_worker_contract where #{params.time}>=effectDate) m2
|
|
ON m1.idCard = m2.idCard AND m2.upload_time>m1.upload_time
|
|
WHERE m2.idCard IS NULL
|
|
) bwc on HWAH.id_number=bwc.idCard and HWAH.PROJECT_ID=bwc.pro_id
|
|
left join bns_smz_bm_worker_payroll bwp on HWAH.id_number=bwp.id_number
|
|
where HWAH.is_active='1' AND #{params.time}=DATE_FORMAT(EXIT_TIME,'%Y-%m-%d')
|
|
<if test=' params.proId !="0" and params.proId!=null'>
|
|
AND HWAH.PROject_ID = #{params.proId}
|
|
</if>
|
|
) aa group by IDNUMBER,CURRENTDAY
|
|
) aa
|
|
)
|
|
) aa group by IDNUMBER,CURRENTDAY
|
|
) aa
|
|
</select>
|
|
<select id="getWorkExitNum" resultType="java.lang.String">
|
|
select count(1) as num from(
|
|
select * from (
|
|
select distinct
|
|
'' as IMEI,'1' as USERID,HWAH.NAME as name,HWAH.ID_NUMBER as IDNUMBER,HWAH.SUB_ID as SUBID,HWAH.PROJECT_ID as PROID,HWAH.TEAM_ID as TEAMID,#{params.time} as CURRENTDAY,
|
|
now() as ADDTIME,now() as uploadtime,'' as PHOTOPATH,'' as UPLOADTYPE,'1' as ISSUCCESS,'自动补充' as AUDITOR,
|
|
'4' AUDIT_STATUS,'自动补充' as AUDITREMARK,now() as AUDITTIME,'5' as AUDITTYPE,'自动补充' as remark,'0' as WORK_HOURS,'0' as OVER_HOURS,'' as lon,'' as lat,'' as address,HWAH.post_id as post_id,bwc.effectDate as effect_date,bwc.wagecriterion as wagecriterion ,bwc.min_achievements_money as minachievementsmoney,bwc.max_achievements_money as maxachievementsmoney,bwp.bank_card as bankcard,'0' as isrepair,'1' as isactive
|
|
FROM bns_smz_bm_worker_attend_history HWAH
|
|
left join (
|
|
SELECT m1.*
|
|
FROM (select * from bns_smz_bm_worker_contract where #{params.time}>=effectDate) m1
|
|
LEFT JOIN (select * from bns_smz_bm_worker_contract where #{params.time}>=effectDate) m2
|
|
ON m1.idCard = m2.idCard AND m2.upload_time>m1.upload_time
|
|
WHERE m2.idCard IS NULL
|
|
) bwc on HWAH.id_number=bwc.idCard and HWAH.PROJECT_ID=bwc.pro_id
|
|
left join bns_smz_bm_worker_payroll bwp on HWAH.id_number=bwp.id_number
|
|
where HWAH.is_active='1' and bwc.effectDate is not null AND #{params.time}=DATE_FORMAT(EXIT_TIME,'%Y-%m-%d')
|
|
<if test=' params.proId !="0" and params.proId!=null'>
|
|
AND HWAH.PROject_ID = #{params.proId}
|
|
</if>
|
|
and HWAH.id_number not in (
|
|
select IDNUMBER from (
|
|
select * from (
|
|
select distinct
|
|
'' as IMEI,'1' as USERID,HWAH.NAME as name,HWAH.ID_NUMBER as IDNUMBER,HWAH.SUB_ID as SUBID,HWAH.PROJECT_ID as PROID,HWAH.TEAM_ID as TEAMID,#{params.time} as CURRENTDAY,
|
|
now() as ADDTIME,now() as uploadtime,'' as PHOTOPATH,'' as UPLOADTYPE,'1' as ISSUCCESS,'自动补充' as AUDITOR,
|
|
'4' AUDIT_STATUS,'自动补充' as AUDITREMARK,now() as AUDITTIME,'5' as AUDITTYPE,'自动补充' as remark,'0' as WORK_HOURS,'0' as OVER_HOURS,'' as lon,'' as lat,'' as address,HWAH.post_id as post_id,bwc.effectDate as effect_date,bwc.wagecriterion as wagecriterion ,bwc.min_achievements_money as minachievementsmoney,bwc.max_achievements_money as maxachievementsmoney,bwp.bank_card as bankcard,'0' as isrepair,'1' as isactive
|
|
FROM bns_smz_bm_worker_attend_history HWAH
|
|
left join (
|
|
SELECT m1.*
|
|
FROM (select * from bns_smz_bm_worker_contract where #{params.time}>=effectDate) m1
|
|
LEFT JOIN (select * from bns_smz_bm_worker_contract where #{params.time}>=effectDate) m2
|
|
ON m1.idCard = m2.idCard AND m2.upload_time>m1.upload_time
|
|
WHERE m2.idCard IS NULL
|
|
) bwc on HWAH.id_number=bwc.idCard and HWAH.PROJECT_ID=bwc.pro_id
|
|
left join bns_smz_bm_worker_payroll bwp on HWAH.id_number=bwp.id_number
|
|
where HWAH.is_active='1' AND #{params.time}=DATE_FORMAT(EIN_TIME,'%Y-%m-%d')
|
|
<if test=' params.proId !="0" and params.proId!=null'>
|
|
AND HWAH.PROject_ID = #{params.proId}
|
|
</if>
|
|
) aa group by IDNUMBER,CURRENTDAY
|
|
) aa
|
|
)
|
|
) aa group by IDNUMBER,CURRENTDAY
|
|
) aa
|
|
</select>
|
|
<select id="getWorkNumberListByCurrentDayCount" resultType="java.lang.Integer">
|
|
select count(1) from(
|
|
select ffc.* from bns_smz_xbg_user_attendance ffc
|
|
LEFT JOIN bns_smz_bm_subcontractor bs on ffc.sub_id = bs.ID
|
|
LEFT JOIN bns_smz_bm_sub_team bst on ffc.team_id=bst.id
|
|
LEFT JOIN bns_smz_bm_project bp on ffc.pro_id = bp.id
|
|
where DATE_FORMAT(ffc.create_date,'%Y-%m-%d')=#{params.startTime}
|
|
<if test=' params.proId !="0" and params.proId!=null'>
|
|
AND ffc.PRO_ID = #{params.proId}
|
|
</if>
|
|
<if test=' params.state == "1"'>
|
|
AND ffc.data_type = 1 AND ffc.audit_status IN(0,1)
|
|
</if>
|
|
<if test=' params.state == "2" '>
|
|
AND ffc.data_type = 2 AND ffc.audit_status IN(0,1)
|
|
</if>
|
|
<if test=' params.state == "3" '>
|
|
AND ffc.data_type = 3 AND ffc.audit_status IN(0,1)
|
|
</if>
|
|
<if test='params.state == "4"'>
|
|
AND ffc.data_type = 4 AND ffc.audit_status IN(0,1)
|
|
</if>
|
|
<if test='params.state == "5"'>
|
|
AND (ffc.data_type = 5 OR ffc.audit_status = 2)
|
|
</if>
|
|
<if test="params.keyWord !=null and params.keyWord !=''">
|
|
AND
|
|
(
|
|
instr(ffc.user_name,#{params.keyWord}) > 0
|
|
or instr(bs.SUB_NAME,#{params.keyWord}) > 0
|
|
or instr(bst.`NAME`,#{params.keyWord}) > 0
|
|
or instr(bp.`NAME`,#{params.keyWord}) > 0
|
|
)
|
|
</if>
|
|
) aa
|
|
</select>
|
|
<select id="getWorkNumberListByCurrentDayList"
|
|
resultType="com.bonus.hnrn.rnbmw.person.entity.WorkNumberBean">
|
|
select distinct * from (
|
|
select
|
|
ffc.user_name AS name,
|
|
ffc.id_card as idNumber,
|
|
bw.phone,
|
|
sdd.`name` as postName,
|
|
bp.`NAME` as proName,
|
|
bs.SUB_NAME as subName,
|
|
bst.`NAME` as teamName,
|
|
CASE WHEN ffc.data_type = 1 AND ffc.audit_status IN (0,1) THEN '计日'
|
|
WHEN ffc.data_type = 2 AND ffc.audit_status IN (0,1) THEN '计件'
|
|
WHEN ffc.data_type = 3 AND ffc.audit_status IN (0,1) THEN '停窝工'
|
|
WHEN ffc.data_type = 4 AND ffc.audit_status IN (0,1) THEN '休息'
|
|
WHEN ffc.data_type = 5 OR ffc.audit_status = 2 THEN '未考勤'
|
|
END AS att
|
|
from bns_smz_xbg_user_attendance ffc
|
|
LEFT JOIN bns_smz_bm_subcontractor bs on ffc.sub_id = bs.ID
|
|
LEFT JOIN bns_smz_bm_sub_team bst on ffc.team_id=bst.id
|
|
LEFT JOIN bns_smz_bm_project bp on ffc.pro_id = bp.id
|
|
LEFT JOIN bns_smz_bm_worker bw ON ffc.id_card = bw.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = ffc.post_id
|
|
where DATE_FORMAT(ffc.create_date,'%Y-%m-%d') = #{params.startTime}
|
|
<if test=' params.proId !="0" and params.proId!=null'>
|
|
AND ffc.PRO_ID = #{params.proId}
|
|
</if>
|
|
<if test=' params.state == "1"'>
|
|
AND ffc.data_type = 1 AND ffc.audit_status IN(0,1)
|
|
</if>
|
|
<if test=' params.state == "2" '>
|
|
AND ffc.data_type = 2 AND ffc.audit_status IN(0,1)
|
|
</if>
|
|
<if test=' params.state == "3" '>
|
|
AND ffc.data_type = 3 AND ffc.audit_status IN(0,1)
|
|
</if>
|
|
<if test='params.state == "4"'>
|
|
AND ffc.data_type = 4 AND ffc.audit_status IN(0,1)
|
|
</if>
|
|
<if test='params.state == "5"'>
|
|
AND (ffc.data_type = 5 OR ffc.audit_status = 2)
|
|
</if>
|
|
<if test="params.keyWord !=null and params.keyWord !=''">
|
|
AND
|
|
(
|
|
instr(ffc.user_name,#{params.keyWord}) > 0
|
|
or instr(bs.SUB_NAME,#{params.keyWord}) > 0
|
|
or instr(bst.`NAME`,#{params.keyWord}) > 0
|
|
or instr(bp.`NAME`,#{params.keyWord}) > 0
|
|
)
|
|
</if>
|
|
) aa
|
|
limit #{offset}, #{limit}
|
|
</select>
|
|
<select id="getWorkAttendanceListByPay" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT a.* FROM (
|
|
SELECT b.* FROM (
|
|
SELECT DISTINCT
|
|
if(bwah.`NAME` is null,'',bwah.`NAME`) as name,bwah.ID_NUMBER as idNumber,
|
|
sdd.`name` as postName,org.name as orgName,bp.name as proName,bp.status,bs.id as subId,
|
|
bs.SUB_NAME as subName,bst.id as teamId,bst.`NAME` as teamName,org.id as orgId,bwah.PROJECT_ID as
|
|
proId,bwah.EIN_TIME
|
|
FROM bns_smz_bm_worker_attend_history bwah
|
|
left join bns_smz_bm_worker bw on bw.id_number = bwah.id_number
|
|
left join bns_smz_bm_worker_record bwr on bwah.id_number=bwr.id_number
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.id=bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.id=bwah.SUB_ID
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.id=bwah.TEAM_ID
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.id=bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_pm_organization org ON org.id=bp.company_id
|
|
WHERE bwah.IS_ACTIVE='1' and bw.IS_ACTIVE='1' and bp.IS_ACTIVE = '1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<![CDATA[
|
|
and IF(bwah.EXIT_TIME IS NOT NULL AND bwah.EXIT_TIME != '',(LEFT(bwah.EIN_TIME,10) <= #{params.endTime} and LEFT(bwah.EIN_TIME,10) >= #{params.startTime}
|
|
or LEFT(bwah.EIN_TIME,10) <= #{params.startTime} and LEFT(bwah.EXIT_TIME,10) >=#{params.startTime} and LEFT(bwah.EXIT_TIME,10) <= #{params.endTime}
|
|
or LEFT(bwah.EIN_TIME,10) <= #{params.startTime} and LEFT(bwah.EXIT_TIME,10) >=#{params.startTime} and LEFT(bwah.EXIT_TIME,10) >= #{params.endTime}),LEFT(bwah.EIN_TIME,10) <= #{params.endTime})
|
|
]]>
|
|
<if test="params.companyIds!=null and params.companyIds!='' ">
|
|
and org.ID =#{params.companyIds}
|
|
</if>
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
and bp.ID=#{params.proId}
|
|
</if>
|
|
<if test="params.name !=null and params.name !=''">
|
|
and bwah.name like concat ('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.idNumber !=null and params.idNumber !=''">
|
|
and bwah.ID_NUMBER=#{params.idNumber}
|
|
</if>
|
|
<if test="params.teamName !=null and params.teamName !=''">
|
|
and bst.name like concat ('%',#{params.teamName},'%')
|
|
</if>
|
|
<if test="params.orgName !=null and params.orgName !=''">
|
|
and org.name=#{params.orgName}
|
|
</if>
|
|
<if test="params.proName !=null and params.proName !=''">
|
|
and bp.name=#{params.proName}
|
|
</if>
|
|
<if test="params.subName !=null and params.subName !=''">
|
|
and bs.sub_name=#{params.subName}
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
and bp.status=#{params.status}
|
|
</if>
|
|
UNION
|
|
SELECT DISTINCT
|
|
if(bwah.`NAME` is null,'',bwah.`NAME`) as name,bwah.ID_NUMBER as idNumber,
|
|
sdd.`name` as postName,org.name as orgName,bp.name as proName,bp.status,bs.id as subId,
|
|
bs.SUB_NAME as subName,bst.id as teamId,bst.`NAME` as teamName,org.id as orgId,bwah.PROJECT_ID as
|
|
proId,bwah.EIN_TIME
|
|
FROM bns_smz_bm_worker_attend_history bwah
|
|
left join bns_smz_bm_worker bw on bw.id_number = bwah.id_number
|
|
left join bns_smz_bm_worker_record bwr on bwah.id_number=bwr.id_number
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.id=bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.id=bwah.SUB_ID
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.id=bwah.TEAM_ID
|
|
left join bns_smz_fc_face_contrast ffc on ffc.ID_NUMBER = bwah.ID_NUMBER AND bwah.PROJECT_ID = ffc.PRO_ID
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.id=bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_pm_organization org ON org.id=bp.company_id
|
|
WHERE bwah.IS_ACTIVE='1' and bw.IS_ACTIVE='1' and bp.IS_ACTIVE = '1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
and ffc.CURRENT_DAY BETWEEN #{params.startTime} AND #{params.endTime}
|
|
<![CDATA[
|
|
and IF(bwah.EXIT_TIME IS NOT NULL AND bwah.EXIT_TIME != '',(LEFT(bwah.EIN_TIME,10) <= #{params.endTime} and LEFT(bwah.EIN_TIME,10) >= #{params.startTime}
|
|
or LEFT(bwah.EIN_TIME,10) <= #{params.startTime} and LEFT(bwah.EXIT_TIME,10) >=#{params.startTime} and LEFT(bwah.EXIT_TIME,10) <= #{params.endTime}
|
|
or LEFT(bwah.EIN_TIME,10) <= #{params.startTime} and LEFT(bwah.EXIT_TIME,10) >=#{params.startTime} and LEFT(bwah.EXIT_TIME,10) >= #{params.endTime}),LEFT(bwah.EIN_TIME,10) <= #{params.endTime})
|
|
]]>
|
|
<if test="params.companyIds!=null and params.companyIds!='' ">
|
|
and org.ID =#{params.companyIds}
|
|
</if>
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
and bp.ID=#{params.proId}
|
|
</if>
|
|
<if test="params.name !=null and params.name !=''">
|
|
and bwah.name like concat ('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.idNumber !=null and params.idNumber !=''">
|
|
and ffc.ID_NUMBER=#{params.idNumber}
|
|
</if>
|
|
<if test="params.teamName !=null and params.teamName !=''">
|
|
and bst.name like concat ('%',#{params.teamName},'%')
|
|
</if>
|
|
<if test="params.orgName !=null and params.orgName !=''">
|
|
and org.name=#{params.orgName}
|
|
</if>
|
|
<if test="params.proName !=null and params.proName !=''">
|
|
and bp.name=#{params.proName}
|
|
</if>
|
|
<if test="params.subName !=null and params.subName !=''">
|
|
and bs.sub_name=#{params.subName}
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
and bp.status=#{params.status}
|
|
</if>
|
|
)b
|
|
)a
|
|
GROUP BY a.idNumber,a. proId
|
|
</select>
|
|
<select id="getWorkNumberListByCurrentDayLists" resultType="com.bonus.hnrn.rnbmw.person.entity.WorkNumberBean">
|
|
select * from (
|
|
select
|
|
bw.name,
|
|
bwr.ID_NUMBER as idNumber,
|
|
bw.phone,
|
|
sdd.`name` as postName,
|
|
bp.`NAME` as proName,
|
|
bs.SUB_NAME as subName,
|
|
bst.`NAME` as teamName,
|
|
IF(ffc.ID_NUMBER is null,'未考勤',if(ffc.AUDIT_STATUS='3','休息','已考勤')) as att
|
|
from
|
|
(
|
|
SELECT bwah.ID_NUMBER,bwah.PROJECT_ID,bwah.SUB_ID,bwah.TEAM_ID,bwah.POST_ID FROM
|
|
(
|
|
SELECT bwah.* FROM bns_smz_bm_worker_attend_history bwah
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwah.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.ID = bwah.SUB_ID
|
|
LEFT JOIN bns_smz_pm_organization po1 ON po1.ID = bwah.ORG_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwah.ID_NUMBER = bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.ID = bwr.TEAM_ID
|
|
LEFT JOIN bns_smz_pm_organization po2 ON po2.ID = bwr.ORG_ID and po1.COMPANY_ID = po2.COMPANY_ID
|
|
LEFT JOIN bns_smz_sys_user su ON su.id = bwr.examine_user_id
|
|
left join bns_smz_pm_company pc on pc.id = po1.company_id
|
|
WHERE
|
|
bwah.is_active = '1' and bw.is_active = '1' and bp.IS_ACTIVE = '1' and bwr.IS_ACTIVE = '1'
|
|
and case when bwah.EXIT_TIME is null then bwah.EXIT_TIME is null and #{params.endTime}>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d')
|
|
else bwah.EXIT_TIME is not null and #{params.endTime}>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') and DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d')>=#{params.startTime} end
|
|
) bwah
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwah.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.ID = bwah.SUB_ID
|
|
LEFT JOIN bns_smz_pm_organization po1 ON po1.ID = bwah.ORG_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwah.ID_NUMBER = bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.ID = bwr.TEAM_ID
|
|
LEFT JOIN bns_smz_pm_organization po2 ON po2.ID = bwr.ORG_ID and po1.COMPANY_ID = po2.COMPANY_ID
|
|
LEFT JOIN bns_smz_sys_user su ON su.id = bwr.examine_user_id
|
|
left join bns_smz_pm_company pc on pc.id = po1.company_id
|
|
WHERE
|
|
bwah.is_active = '1' and bw.is_active = '1' and bp.IS_ACTIVE = '1' and bwr.IS_ACTIVE = '1'
|
|
|
|
and case when bwah.EXIT_TIME is null then bwah.EXIT_TIME is null and #{params.startTime}>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d')
|
|
else bwah.EXIT_TIME is not null and #{params.startTime}>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') and DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d')>=#{params.startTime} end
|
|
<if test=' params.proId !="0" and params.proId!=null'>
|
|
AND bwah.PROJECT_ID = #{params.proId}
|
|
</if>
|
|
) bwr
|
|
left join (select * from bns_smz_bm_worker where is_active='1') bw on bwr.ID_NUMBER=bw.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd on sdd.id = bwr.POST_ID and sdd.dic_type = '3' and sdd.is_active = '1'
|
|
LEFT JOIN bns_smz_bm_subcontractor bs on bwr.SUB_ID = bs.ID and bs.is_active = '1'
|
|
LEFT JOIN bns_smz_bm_sub_team bst on bst.id = bwr.TEAM_ID and bst.is_active = '1'
|
|
LEFT JOIN bns_smz_bm_project bp on bwr.PROJECT_ID = bp.id and bp.IS_ACTIVE = '1'
|
|
LEFT JOIN (
|
|
select distinct * from (
|
|
select distinct CURRENT_DAY,id_number,AUDIT_STATUS from bns_smz_fc_face_contrast where is_active='1'
|
|
and CURRENT_DAY =#{params.startTime}
|
|
<if test=' params.proId !="0" and params.proId!=null'>
|
|
AND PRO_ID = #{params.proId}
|
|
</if>
|
|
group by CURRENT_DAY,id_number
|
|
union
|
|
select distinct fta.attendance_date as CURRENT_DAY,ffc.id_number,'0' as AUDIT_STATUS
|
|
FROM bns_smz_fc_team_attendance fta
|
|
LEFT JOIN bns_smz_fc_team_attendance_content ftac ON ftac.team_attendance_id = fta.id
|
|
LEFT JOIN bns_smz_bm_worker_record ffc ON ffc.ID_NUMBER = ftac.id_number
|
|
where fta.attendance_date =#{params.startTime}
|
|
) aa
|
|
) ffc ON bwr.ID_NUMBER = ffc.ID_NUMBER
|
|
where 1=1 and bw.is_active='1'
|
|
<if test=' params.state == "2" '>
|
|
AND ffc.ID_NUMBER is null
|
|
</if>
|
|
<if test=' params.state == "1" '>
|
|
AND ffc.ID_NUMBER is not null and ffc.AUDIT_STATUS in ('0','1','2')
|
|
</if>
|
|
<if test=' params.state == "3" '>
|
|
AND ffc.ID_NUMBER is not null and ffc.AUDIT_STATUS in ('3')
|
|
</if>
|
|
<if test="params.keyWord !=null and params.keyWord !=''">
|
|
AND
|
|
(
|
|
instr(bw.name,#{params.keyWord}) > 0
|
|
or instr(bs.SUB_NAME,#{params.keyWord}) > 0
|
|
or instr(bst.`NAME`,#{params.keyWord}) > 0
|
|
)
|
|
</if>
|
|
) aa
|
|
limit #{offset}, #{limit}
|
|
</select>
|
|
<select id="getWorkNumberListByCurrentDayCounts" resultType="java.lang.Integer">
|
|
select count(*) from (
|
|
select * from (
|
|
select
|
|
bw.name,
|
|
bwr.ID_NUMBER as idNumber,
|
|
bw.phone,
|
|
sdd.`name` as postName,
|
|
bp.`NAME` as proName,
|
|
bs.SUB_NAME as subName,
|
|
bst.`NAME` as teamName,
|
|
IF(ffc.ID_NUMBER is null,'未考勤',if(ffc.AUDIT_STATUS='3','休息','已考勤')) as att
|
|
from
|
|
(
|
|
SELECT bwah.ID_NUMBER,bwah.PROJECT_ID,bwah.SUB_ID,bwah.TEAM_ID,bwah.POST_ID FROM
|
|
(
|
|
SELECT bwah.* FROM bns_smz_bm_worker_attend_history bwah
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwah.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.ID = bwah.SUB_ID
|
|
LEFT JOIN bns_smz_pm_organization po1 ON po1.ID = bwah.ORG_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwah.ID_NUMBER = bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.ID = bwr.TEAM_ID
|
|
LEFT JOIN bns_smz_pm_organization po2 ON po2.ID = bwr.ORG_ID and po1.COMPANY_ID = po2.COMPANY_ID
|
|
LEFT JOIN bns_smz_sys_user su ON su.id = bwr.examine_user_id
|
|
left join bns_smz_pm_company pc on pc.id = po1.company_id
|
|
WHERE
|
|
bwah.is_active = '1' and bw.is_active = '1' and bp.IS_ACTIVE = '1' and bwr.IS_ACTIVE = '1'
|
|
and case when bwah.EXIT_TIME is null then bwah.EXIT_TIME is null and #{params.endTime}>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d')
|
|
else bwah.EXIT_TIME is not null and #{params.endTime}>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') and DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d')>=#{params.startTime} end
|
|
) bwah
|
|
LEFT JOIN bns_smz_bm_project bp ON bp.ID = bwah.PROJECT_ID
|
|
LEFT JOIN bns_smz_bm_worker bw ON bw.ID_NUMBER = bwah.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.ID = bwah.POST_ID
|
|
LEFT JOIN bns_smz_bm_subcontractor bs ON bs.ID = bwah.SUB_ID
|
|
LEFT JOIN bns_smz_pm_organization po1 ON po1.ID = bwah.ORG_ID
|
|
LEFT JOIN bns_smz_bm_worker_record bwr ON bwah.ID_NUMBER = bwr.ID_NUMBER
|
|
LEFT JOIN bns_smz_bm_sub_team bst ON bst.ID = bwr.TEAM_ID
|
|
LEFT JOIN bns_smz_pm_organization po2 ON po2.ID = bwr.ORG_ID and po1.COMPANY_ID = po2.COMPANY_ID
|
|
LEFT JOIN bns_smz_sys_user su ON su.id = bwr.examine_user_id
|
|
left join bns_smz_pm_company pc on pc.id = po1.company_id
|
|
WHERE
|
|
bwah.is_active = '1' and bw.is_active = '1' and bp.IS_ACTIVE = '1' and bwr.IS_ACTIVE = '1'
|
|
|
|
and case when bwah.EXIT_TIME is null then bwah.EXIT_TIME is null and #{params.startTime}>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d')
|
|
else bwah.EXIT_TIME is not null and #{params.startTime}>=DATE_FORMAT(bwah.EIN_TIME, '%Y-%m-%d') and DATE_FORMAT(bwah.EXIT_TIME, '%Y-%m-%d')>=#{params.startTime} end
|
|
<if test=' params.proId !="0" and params.proId!=null'>
|
|
AND bwah.PROJECT_ID = #{params.proId}
|
|
</if>
|
|
) bwr
|
|
left join (select * from bns_smz_bm_worker where is_active='1') bw on bwr.ID_NUMBER=bw.ID_NUMBER
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd on sdd.id = bwr.POST_ID and sdd.dic_type = '3' and sdd.is_active = '1'
|
|
LEFT JOIN bns_smz_bm_subcontractor bs on bwr.SUB_ID = bs.ID and bs.is_active = '1'
|
|
LEFT JOIN bns_smz_bm_sub_team bst on bst.id = bwr.TEAM_ID and bst.is_active = '1'
|
|
LEFT JOIN bns_smz_bm_project bp on bwr.PROJECT_ID = bp.id and bp.IS_ACTIVE = '1'
|
|
LEFT JOIN (
|
|
select distinct * from (
|
|
select distinct CURRENT_DAY,id_number,AUDIT_STATUS from bns_smz_fc_face_contrast where is_active='1'
|
|
and CURRENT_DAY =#{params.startTime}
|
|
<if test=' params.proId !="0" and params.proId!=null'>
|
|
AND PRO_ID = #{params.proId}
|
|
</if>
|
|
group by CURRENT_DAY,id_number
|
|
union
|
|
select distinct fta.attendance_date as CURRENT_DAY,ffc.id_number,'0' as AUDIT_STATUS
|
|
FROM bns_smz_fc_team_attendance fta
|
|
LEFT JOIN bns_smz_fc_team_attendance_content ftac ON ftac.team_attendance_id = fta.id
|
|
LEFT JOIN bns_smz_bm_worker_record ffc ON ffc.ID_NUMBER = ftac.id_number
|
|
where fta.attendance_date =#{params.startTime}
|
|
) aa
|
|
) ffc ON bwr.ID_NUMBER = ffc.ID_NUMBER
|
|
where 1=1 and bw.is_active='1'
|
|
<if test=' params.state == "2" '>
|
|
AND ffc.ID_NUMBER is null
|
|
</if>
|
|
<if test=' params.state == "1" '>
|
|
AND ffc.ID_NUMBER is not null and ffc.AUDIT_STATUS in ('0','1','2')
|
|
</if>
|
|
<if test=' params.state == "3" '>
|
|
AND ffc.ID_NUMBER is not null and ffc.AUDIT_STATUS in ('3')
|
|
</if>
|
|
<if test="params.keyWord !=null and params.keyWord !=''">
|
|
AND
|
|
(
|
|
instr(bw.name,#{params.keyWord}) > 0
|
|
or instr(bs.SUB_NAME,#{params.keyWord}) > 0
|
|
or instr(bst.`NAME`,#{params.keyWord}) > 0
|
|
)
|
|
</if>
|
|
) aa
|
|
) aa
|
|
</select>
|
|
|
|
<select id="getWorkDatas" resultType="java.lang.Integer">
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
(
|
|
SELECT
|
|
bwr.ID_NUMBER,
|
|
ffc.WORK_HOURS AS kqCounts,
|
|
bwr.PROJECT_ID AS proId
|
|
FROM bns_smz_bm_worker_record bwr
|
|
LEFT JOIN
|
|
(
|
|
select distinct CURRENT_DAY,id_number,PRO_ID,WORK_HOURS,is_active from bns_smz_fc_face_contrast where is_active='1' and is_success='1'
|
|
union
|
|
select distinct fta.attendance_date as CURRENT_DAY,ffc.id_number,ffc.project_id as PRO_ID,1 as WORK_HOURS,1 as is_active
|
|
FROM bns_smz_fc_team_attendance fta
|
|
LEFT JOIN bns_smz_fc_team_attendance_content ftac ON ftac.team_attendance_id = fta.id
|
|
LEFT JOIN bns_smz_bm_worker_record ffc ON ffc.ID_NUMBER = ftac.id_number
|
|
where fta.is_active='1'
|
|
)
|
|
ffc ON ffc.ID_NUMBER = bwr.ID_NUMBER
|
|
WHERE
|
|
ffc.PRO_ID = #{proId}
|
|
AND bwr.ID_NUMBER = #{idNumber}
|
|
AND ffc.CURRENT_DAY BETWEEN #{sTimes}
|
|
AND #{eTimes}
|
|
AND bwr.IS_ACTIVE = '1'
|
|
AND bwr.examine_status = '1'
|
|
AND ffc.is_active = '1'
|
|
GROUP BY
|
|
CURRENT_DAY
|
|
) a
|
|
</select>
|
|
<select id="getCheck" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select if(count(u.id)=0,'无','有') as value ,s.date,u.address,u.is_repair as isRepair from
|
|
(select date_add(#{date},interval @i:=@i+1 day) as date
|
|
from (
|
|
select 1
|
|
<foreach item="index" collection="countArr">
|
|
union all select 1
|
|
</foreach>
|
|
) as tmp,
|
|
(select @i:= -1) t
|
|
) s left join bns_smz_fc_face_contrast u on s.date = date_format(u.CURRENT_DAY,'%Y-%m-%d') and ID_NUMBER=#{idNumber} and
|
|
u.is_active = '1'
|
|
GROUP BY s.date
|
|
</select>
|
|
<select id="getProEinNum" resultType="com.bonus.hnrn.rnbmw.person.entity.WorkNumberBean">
|
|
|
|
</select>
|
|
<!--考勤统计下载 -->
|
|
<select id="getWorkAttendanceListDownload" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
select * from (
|
|
select ffc.ID_NUMBER as idnumber,
|
|
ffc.`NAME`,
|
|
sdd.`name` as postName,
|
|
org.name as orgName,
|
|
bp.name as proName,
|
|
bp.status,
|
|
bs.id as subId,
|
|
bwp.bank_card as bankCard,
|
|
bs.SUB_NAME as subName,
|
|
bst.id as teamId,
|
|
bst.`NAME` as teamName,
|
|
org.id as orgId,
|
|
ffc.pro_id as proId,
|
|
ffc.notWorkHours,
|
|
ffc.breakWork,
|
|
ffc.dayNum,
|
|
ffc.countingNum,
|
|
ffc.idleWorkNum,
|
|
#{params.startTime} as startTime,
|
|
#{params.endTime} as endTime,
|
|
IFNULL(ffc.gz,'0') as gz,
|
|
ffc.effectDate,
|
|
CONCAT(IFNULL(ffc.min_achievements_money,'0'),'-',IFNULL(ffc.max_achievements_money,'0')) as jx
|
|
from (
|
|
select id_number,
|
|
name,
|
|
pro_id,
|
|
sub_id,
|
|
team_id,
|
|
post_id,
|
|
gz,
|
|
min_achievements_money,
|
|
max_achievements_money,
|
|
SUM(IF(ffc.data_type = 5 OR ffc.audit_status = 2,1,0)) AS notWorkHours,
|
|
SUM(IF(ffc.data_type = 1 AND ffc.audit_status IN (0,1),1,0)) AS dayNum,
|
|
SUM(IF(ffc.data_type = 2 AND ffc.audit_status IN (0,1),1,0)) AS countingNum,
|
|
SUM(IF(ffc.data_type = 3 AND ffc.audit_status IN (0,1),1,0)) AS idleWorkNum,
|
|
SUM(IF(ffc.data_type = 4 AND ffc.audit_status IN (0,1),1,0)) as breakWork,
|
|
effectDate
|
|
from (
|
|
select DISTINCT * from (
|
|
select * from (
|
|
select id_card AS ID_NUMBER,
|
|
user_name AS name,
|
|
DATE_FORMAT(ffc.create_date,'%Y-%m-%d') AS CURRENT_DAY,
|
|
pro_id,
|
|
sub_id,
|
|
team_id,
|
|
post_id,
|
|
audit_status,
|
|
wage_criterion as gz,
|
|
DATE_FORMAT(effect_date,'%Y-%m-%d') as effectDate,
|
|
min_perfor AS min_achievements_money,
|
|
max_perfor AS max_achievements_money,
|
|
data_type
|
|
from bns_smz_xbg_user_attendance ffc
|
|
where DATE_FORMAT(ffc.create_date,'%Y-%m-%d')>=#{params.startTime} and #{params.endTime}>=DATE_FORMAT(ffc.create_date,'%Y-%m-%d')
|
|
<if test="params.proId !=null and params.proId !=''">
|
|
and ffc.pro_id=#{params.proId}
|
|
</if>
|
|
<if test='params.roleLevel == "4" and params.subId!=null and params.subId!=""'>
|
|
and ffc.sub_id=#{params.subId}
|
|
</if>
|
|
<if test="params.idNumber !=null and params.idNumber !=''">
|
|
and ffc.id_card=#{params.idNumber}
|
|
</if>
|
|
and ffc.audit_status in (0,1,2) having 1 order by create_time desc
|
|
) aa
|
|
GROUP BY ID_NUMBER,CURRENT_DAY,PRO_ID,SUB_ID,team_id
|
|
union
|
|
select ID_NUMBER,'' as name,attendance_time as CURRENT_DAY,'' as PRO_ID,'' AS SUB_ID,'' as team_id,'' as post_id,'1' AS AUDIT_STATUS
|
|
,'' as gz,'' as effectDate,'' as min_achievements_money,'' as max_achievements_money,0 AS data_type
|
|
from bns_smz_fc_team_attendance_content fac
|
|
where fac.is_active='1' and fac.attendance_time>=#{params.startTime} and #{params.endTime}>=fac.attendance_time
|
|
) aa
|
|
) ffc where effectDate is not null group by id_number,pro_id,sub_id,team_id,effectDate
|
|
)ffc
|
|
left join bns_smz_bm_worker_payroll bwp on ffc.id_number=bwp.id_number
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdd.id=ffc.POST_ID
|
|
LEFT JOIN (select * from bns_smz_bm_subcontractor bs
|
|
where is_active='1'
|
|
) bs ON bs.id=ffc.SUB_ID
|
|
LEFT JOIN (select * from bns_smz_bm_sub_team bst
|
|
where IS_ACTIVE = '1'
|
|
) bst ON bst.id=ffc.TEAM_ID
|
|
LEFT JOIN (select * from bns_smz_bm_project bp
|
|
where IS_ACTIVE = '1'
|
|
<if test="params.orgId != null and params.orgId != ''">
|
|
<if test='params.roleLevel == "1"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE company_id = #{params.companyId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "2"'>
|
|
AND bp.company_id in(SELECT id FROM bns_smz_pm_organization WHERE PARENT_ID = #{params.orgId})
|
|
</if>
|
|
|
|
<if test='params.roleLevel == "3"'>
|
|
AND bp.company_id = #{params.orgId}
|
|
</if>
|
|
<if test='params.roleLevel == "4"'>
|
|
AND bp.id in (SELECT pro_id FROM bns_smz_bm_sub_pro_relation WHERE sub_id = #{params.subId})
|
|
</if>
|
|
</if>
|
|
<if test="params.proName !=null and params.proName !=''">
|
|
and bp.name=#{params.proName}
|
|
</if>
|
|
<if test="params.status !=null and params.status !=''">
|
|
and bp.status=#{params.status}
|
|
</if>
|
|
) bp ON bp.id=ffc.pro_id
|
|
LEFT JOIN (select * from bns_smz_pm_organization org
|
|
where is_active='1'
|
|
) org ON org.id=bp.company_id
|
|
where bp.IS_ACTIVE='1'
|
|
<if test="params.name !=null and params.name !=''">
|
|
and ffc.name like concat ('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.subName !=null and params.subName !=''">
|
|
and bs.SUB_NAME like concat ('%',#{params.subName},'%')
|
|
</if>
|
|
<if test="params.teamName !=null and params.teamName !=''">
|
|
and bst.name like concat ('%',#{params.teamName},'%')
|
|
</if>
|
|
order by effectDate asc
|
|
) aa
|
|
order by name desc,effectDate asc
|
|
</select>
|
|
|
|
<select id="getMakeAttendanceCard" resultType="java.lang.Integer">
|
|
SELECT count(*) FROM bns_smz_fc_face_contrast
|
|
WHERE id_number = #{idNumber} and CURRENT_DAY BETWEEN #{startTime} AND #{endTime} AND is_repair = '1' and is_active ='1'
|
|
</select>
|
|
|
|
<select id="getIsCurrentDay" resultType="com.bonus.hnrn.rnbmw.person.entity.FaceContrastBean">
|
|
SELECT id,AUDIT_STATUS as AUDITSTATUS FROM bns_smz_fc_face_contrast
|
|
WHERE ID_NUMBER = #{idNumber} AND CURRENT_DAY = #{currentDay} AND AUDIT_STATUS in(0,1,3) AND is_active = '1'
|
|
</select>
|
|
|
|
<select id="getIsRecord" resultType="java.lang.Integer">
|
|
SELECT sum(num) FROM (
|
|
SELECT count(1) as num , '2' as type FROM bns_smz_bm_worker_attend_history
|
|
WHERE ID_NUMBER = #{idNumber} and is_active='1' and EXIT_TIME is not null AND PROJECT_ID = #{proId} AND SUB_ID = #{subId} AND team_id = #{teamId} AND (SUBSTR(EIN_TIME,1,10) <=#{currentDay} and SUBSTR(EXIT_TIME,1,10) >=#{currentDay})
|
|
union
|
|
SELECT count(1) as num , '2' as type FROM bns_smz_bm_worker_attend_history
|
|
WHERE ID_NUMBER = #{idNumber} and is_active='1' and EXIT_TIME is null AND PROJECT_ID = #{proId} AND SUB_ID = #{subId} AND team_id = #{teamId} AND (SUBSTR(EIN_TIME,1,10) <=#{currentDay})
|
|
) a
|
|
</select>
|
|
<select id="getContractRecord" resultType="java.lang.Integer">
|
|
SELECT sum(num) FROM (
|
|
SELECT count(1) as num FROM bns_smz_bm_worker_contract
|
|
WHERE idCard = #{idNumber} and #{currentDay}>=effectDate
|
|
) a
|
|
</select>
|
|
<select id="getWorkNumberSize" resultType="com.bonus.hnrn.rnbmw.person.entity.WorkNumberBean">
|
|
select * from bns_smz_work_number_record where proid=#{proId} and time=#{time}
|
|
</select>
|
|
<update id="updateWorkNumber" parameterType="com.bonus.hnrn.rnbmw.person.entity.WorkNumberBean">
|
|
update bns_smz_work_number_record set
|
|
orgname=#{orgName},proname=#{proName},entrancenum=#{entranceNum},worknum=#{workNum},noworknum=#{noWorkNum}
|
|
,restnum=#{restNum},einnum=#{einNum},exitnum=#{exitNum}
|
|
where proid=#{proId} and time=#{time}
|
|
</update>
|
|
<insert id="insertWorkNumber" parameterType="com.bonus.hnrn.rnbmw.person.entity.WorkNumberBean">
|
|
insert into bns_smz_work_number_record(orgname,proid,proname,time,entrancenum,worknum,restnum,einnum,exitnum,noworknum)VALUES
|
|
(#{orgName},#{proId},#{proName},#{time},#{entranceNum},#{workNum},#{restNum},#{einNum},#{exitNum},#{noWorkNum})
|
|
</insert>
|
|
|
|
<select id="getNoKqByToDay" resultType="com.bonus.hnrn.rnbmw.person.entity.FcFaceContrastBean">
|
|
select * from (
|
|
select distinct
|
|
'' as IMEI,'1' as USERID,bw.NAME as name,bwr.ID_NUMBER as IDNUMBER,bwr.SUB_ID as SUBID,bwr.PROject_ID as PROID,bwr.TEAM_ID as TEAMID,#{currentday} as CURRENTDAY,
|
|
now() as ADDTIME,now() as uploadtime,'' as PHOTOPATH,'' as UPLOADTYPE,'1' as ISSUCCESS,'自动补充' as AUDITOR,
|
|
case when #{currentday}>DATE_FORMAT(bwah.EXIT_TIME,'%Y-%m-%d') and bwah.EXIT_TIME is not null then '5' else '4' end as AUDIT_STATUS,'自动补充' as AUDITREMARK,now() as AUDITTIME,'5' as AUDITTYPE,'自动补充' as remark,'0' as WORK_HOURS,'0' as OVER_HOURS,'' as lon,'' as lat,'' as address,bwr.post_id as post_id,bwc.effectDate as effect_date,bwc.wagecriterion as wagecriterion ,bwc.min_achievements_money as minachievementsmoney,bwc.max_achievements_money as maxachievementsmoney,bwp.bank_card as bankcard,'0' as isrepair,'1' as isactive
|
|
from (select * from bns_smz_bm_worker_record where 1=1) bwr
|
|
left join (
|
|
SELECT m1.*
|
|
FROM (select * from bns_smz_bm_worker_contract where #{currentday}>=effectDate) m1
|
|
LEFT JOIN (select * from bns_smz_bm_worker_contract where #{currentday}>=effectDate) m2
|
|
ON m1.idCard = m2.idCard AND m2.upload_time>m1.upload_time
|
|
WHERE m2.idCard IS NULL
|
|
) bwc on bwr.id_number=bwc.idCard
|
|
left join bns_smz_bm_worker_payroll bwp on bwr.id_number=bwp.id_number
|
|
LEFT JOIN bns_smz_bm_worker bw on bwr.id_number=bw.id_number
|
|
left join (
|
|
SELECT m1.*
|
|
FROM bns_smz_bm_worker_attend_history m1
|
|
LEFT JOIN bns_smz_bm_worker_attend_history m2
|
|
ON m1.id_number = m2.id_number AND m2.EIN_TIME>m1.EIN_TIME
|
|
WHERE m2.id_number IS NULL
|
|
) bwah on bwr.id_number=bwah.id_number
|
|
where bwr.is_active='1' and bw.IS_ACTIVE='1' and bwc.effectDate is not null
|
|
and (bwr.EXIT_TIME>=#{currentday} or bwr.EXIT_TIME is null)
|
|
) aa order by IDNUMBER desc
|
|
</select>
|
|
<select id="getKqByToDay" resultType="com.bonus.hnrn.rnbmw.person.entity.FcFaceContrastBean">
|
|
select distinct ID_NUMBER as idnumber from bns_smz_fc_face_contrast where is_active='1' and current_day=#{currentday}
|
|
order by ID_NUMBER desc
|
|
</select>
|
|
|
|
<insert id="insertKq">
|
|
insert into bns_smz_fc_face_contrast(
|
|
IMEI,USER_ID,NAME,ID_NUMBER,SUB_ID,PRO_ID,TEAM_ID,CURRENT_DAY,ADD_TIME,upload_time,PHOTO_PATH,UPLOAD_TYPE,IS_SUCCESS,AUDITOR,AUDIT_STATUS,AUDIT_REMARK,AUDIT_TIME,AUDIT_TYPE,remark,WORK_HOURS,OVER_HOURS,lon,lat,address,post_id,effect_date,wage_criterion,min_achievements_money,max_achievements_money,bank_card,is_repair)
|
|
values
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
(
|
|
#{item.imei},
|
|
#{item.userid},
|
|
#{item.name},
|
|
#{item.idnumber},
|
|
#{item.subid},
|
|
#{item.proid},
|
|
#{item.teamid},
|
|
#{item.currentday},
|
|
#{item.addtime},
|
|
#{item.uploadtime},
|
|
#{item.photopath},
|
|
#{item.uploadtype},
|
|
#{item.issuccess},
|
|
#{item.auditor},
|
|
#{item.auditstatus},
|
|
#{item.auditremark},
|
|
#{item.audittime},
|
|
#{item.audittype},
|
|
#{item.remark},
|
|
#{item.workhours},
|
|
#{item.overhours},
|
|
#{item.lon},
|
|
#{item.lat},
|
|
#{item.address},
|
|
#{item.postid},
|
|
#{item.effectdate},
|
|
#{item.wagecriterion},
|
|
#{item.minachievementsmoney},
|
|
#{item.maxachievementsmoney},
|
|
#{item.bankcard},
|
|
#{item.isrepair}
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
<update id="updateKq">
|
|
<foreach collection="list" item="item" index="index" separator=";">
|
|
UPDATE bns_smz_fc_face_contrast
|
|
<set>
|
|
post_id=#{item.postid},
|
|
effect_date=#{item.effectdate},
|
|
wage_criterion=#{item.wagecriterion},
|
|
min_achievements_money=#{item.minachievementsmoney},
|
|
max_achievements_money=#{item.maxachievementsmoney},
|
|
bank_card=#{item.bankcard},
|
|
</set>
|
|
WHERE id_number = #{item.idnumber} and CURRENT_DAY=#{item.currentday} and post_id is null
|
|
</foreach>
|
|
</update>
|
|
|
|
<update id="updateAttendance">
|
|
UPDATE `bns_smz_fc_face_contrast`
|
|
SET `AUDITOR` = '-1',
|
|
`AUDIT_STATUS` = '1',
|
|
`AUDIT_REMARK` = '后台补卡',
|
|
`AUDIT_TIME` = #{addTime},
|
|
`remark` = #{makeCardReason},
|
|
`WORK_HOURS` = #{workHours},
|
|
is_repair = #{isRepair},
|
|
user_id = #{userId}
|
|
WHERE
|
|
`id_number` = #{idNumber} and current_day = #{currentDay} and is_active='1'
|
|
</update>
|
|
</mapper> |