gz_smz_android_manager/target/classes/mappers/person/WorkPersonMapper.xml

780 lines
33 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bonus.gzrn.rnama.person.dao.WorkPersonDao">
<select id="getBlackUser" resultType="com.bonus.gzrn.rnama.person.entity.WorkPersonBean">
select name,id_number as idNumber,event,dept from bm_blacklist_worker
where id_number = #{idNumber} and status = 1
</select>
<select id="getPersonEinStatusByIdNumber" resultType="com.bonus.gzrn.rnama.person.entity.WorkPersonBean">
SELECT
bw.ID_NUMBER AS idNumber,
bw.NAME AS NAME,
bwr.project_id as projectId,
bwr.team_id as teamId,
bwr.ein_status AS einStatus,
bw.phone,bwr.is_ein_push as einPushStatus,
bwr.TEAM_CAPTAIN as teamCaptain
FROM
bm_worker bw
LEFT JOIN bm_worker_record bwr ON bwr.ID_NUMBER = bw.ID_NUMBER
WHERE
bw.IS_ACTIVE = '1'
AND bwr.IS_ACTIVE = '1'
AND ein_status = '1'
AND bw.ID_NUMBER = #{idNumber}
GROUP BY
bw.ID_NUMBER
LIMIT 1
</select>
<select id="getOutWorkUser" resultType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
select bw.name,bw.ID_NUMBER as idNumber,sdd.name as postName,
bwr.EIN_DATE as einTime
from bm_worker_record bwr
left join bm_worker bw on bw.ID_NUMBER = bwr.ID_NUMBER
left join sys_dic_detail sdd on sdd.id = bwr.POST_ID
where PROJECT_ID = #{proId} and ein_status = 1 and examine_status = 1
<if test="name != null || name != ''">
and bw.name like concat('%',#{name},'%')
</if>
</select>
<select id="downloadWorkPerson" resultType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
select bw.ID_NUMBER as idNumber, bw.NAME as name, bw.SEX as gender,o.name as orgName,
sdd.id as postId,sdd.name as postName,bs.id as subId,bs.NAME as subName,bp.id as proId,
front.PHOTO_PATH as frontPhoto,back.PHOTO_PATH as backPhoto,aoto.PHOTO_PATH as aotoPhoto,
face.PHOTO_PATH as facePhoto,face.FACE_FEATURES as faceFeature,bw.phone as phone,
bwr.EIN_TIME as einTime,bw.address,bw.is_twins as isTwins
FROM bm_worker bw
LEFT JOIN bm_worker_photo front ON front.ID_NUMBER = bw.ID_NUMBER and front.PHOTO_TYPE = 1
LEFT JOIN bm_worker_photo back ON back.ID_NUMBER = bw.ID_NUMBER and back.PHOTO_TYPE = 2
LEFT JOIN bm_worker_photo face ON face.ID_NUMBER = bw.ID_NUMBER and face.PHOTO_TYPE = 3
LEFT JOIN bm_worker_photo aoto ON aoto.ID_NUMBER = bw.ID_NUMBER and aoto.PHOTO_TYPE = 5
LEFT JOIN bm_worker_record bwr ON bwr.ID_NUMBER = bw.ID_NUMBER
LEFT JOIN pm_organization o on bwr.ORG_ID = o.id
LEFT JOIN bm_subcontractor bs ON bs.ID = bwr.SUB_ID
LEFT JOIN bm_project bp ON bp.ID = bwr.PROJECT_ID
LEFT JOIN sys_dic_detail sdd on sdd.id = bwr.POST_ID
WHERE bw.IS_ACTIVE = '1' AND bwr.IS_ACTIVE = '1' AND bs.IS_ACTIVE = '1' AND bp.IS_ACTIVE = '1'
AND bwr.PROJECT_ID = #{proId}
and ein_status = '1' and bwr.examine_status = '1'
and face.FACE_FEATURES is not null
GROUP BY bw.ID_NUMBER ORDER BY bw.ID_NUMBER ASC
</select>
<insert id="uploadWork" parameterType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
replace into bm_worker(ID_NUMBER,NAME,SEX,ETHNIC,BIRTHDAY,ADDRESS,ISSUEAUTHORITY,SIGN_DATE,EXPIRY_DATE,phone,is_twins,IS_ACTIVE)
values(#{idNumber},#{name},#{gender},#{ethnic},#{birthday},#{address},#{issueAuthority},#{signDate},#{expiryDate},#{phone},#{isTwins},1)
</insert>
<update id="updateWorkTwins">
update bm_worker set is_twins = #{idNumber} where id_number = #{isTwins}
</update>
<insert id="uploadWorkRecord" parameterType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
replace into bm_worker_record(ID_NUMBER,SUB_ID,ORG_ID,PROJECT_ID,TEAM_ID,POST_ID,EIN_DATE,EIN_TIME,WHETHER_ONJOB,ein_status,IS_ACTIVE)
values(#{idNumber},#{subId},#{orgId},#{proId},#{teamId},#{postId},#{einDate},#{einTime},1,1,1)
</insert>
<insert id="uploadWorkHistory" parameterType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
replace into bm_worker_attend_history(ID_NUMBER,NAME,ein_time,PROJECT_ID,SUB_ID,ORG_ID,POST_ID,TEAM_ID,IS_ACTIVE, is_short_term)
values(#{idNumber},#{name},#{einTime},#{proId},#{subId},#{orgId},#{postId},#{teamId},1, #{isShortTerm})
</insert>
<insert id="uploadWorkPhoto" parameterType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
replace into bm_worker_photo(ID_NUMBER,FACE_FEATURES,PHOTO_TYPE,PHOTO_PATH,upload_id,upload_date,upload_time,IS_ACTIVE)
values(#{idNumber},#{faceFeature},#{photoType},#{photoPath},#{uploadId},#{einDate},#{einTime},1)
</insert>
<insert id="outWorkUser" parameterType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
update bm_worker_record set exit_date = #{exitDate},exit_time = #{exitTime},ein_status = 0 where id_number = #{idNumber}
</insert>
<insert id="uploadOutHistory" parameterType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
update bm_worker_attend_history set exit_time = #{exitTime},departureAffirmUrl = #{departureAffirmUrl} where id_number = #{idNumber} and project_id = #{proId} and team_id = #{teamId} and exit_time is null;
</insert>
<insert id="updateUserIsActive" parameterType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
update sys_user set is_active = 0 where phone = #{phone} and is_active = 1
</insert>
<insert id="uploadFaceAttendance" parameterType="com.bonus.gzrn.rnama.person.entity.FaceAttendanceBean">
insert into fc_face_contrast(IMEI,user_id,NAME,ID_NUMBER,PRO_ID,SUB_ID,CURRENT_DAY,ADD_TIME,PHOTO_PATH,UPLOAD_TYPE,IS_SUCCESS,lon,lat,IS_ACTIVE)
values(#{imei},#{userId},#{name},#{idNumber},#{proId},#{subId},#{currentDay},#{addTime},#{photoPath},#{uploadType},1,#{lon},#{lat},1)
</insert>
<insert id="uploadFaceAttendanceExamine" parameterType="com.bonus.gzrn.rnama.person.entity.FaceAttendanceNoExamineBean">
insert into fc_face_contrast(IMEI,user_id,NAME,ID_NUMBER,PRO_ID,SUB_ID,CURRENT_DAY,ADD_TIME,PHOTO_PATH,UPLOAD_TYPE,IS_SUCCESS,IS_ACTIVE,
AUDITOR,AUDIT_STATUS,AUDIT_REMARK,AUDIT_TIME,WORK_HOURS,OVER_HOURS)
values('',#{examineUserId},#{name},#{idNumber},#{proId},'0',#{currentDay},#{examineTime},#{path},1,2,1,#{examineUserId},#{examineStatus},#{remark},
#{examineTime},#{workHours},#{overHours})
</insert>
<select id="selectWorkerPersonData" resultType="com.bonus.gzrn.rnama.person.entity.IDCardBean" parameterType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
select bw.`NAME`,
bwr.ID_NUMBER as idNumber,
bwr.ORG_ID as orgId,
bwr.PROJECT_ID as proId,
bwr.SUB_ID as subId,
bwr.TEAM_ID as teamId,
bwr.POST_ID as postId,
sdd.name as postName
from bm_worker_record bwr
left join bm_worker bw on bw.ID_NUMBER = bwr.ID_NUMBER
LEFT JOIN sys_dic_detail sdd on sdd.id = bwr.POST_ID
where bwr.PROJECT_ID = #{proId}
</select>
<select id="selectWorkerGiveLikeData" resultType="com.bonus.gzrn.rnama.person.entity.WorkerGiveLikeBean" parameterType="com.bonus.gzrn.rnama.person.entity.IDCardBean">
select id,comment_id as commentId from bm_worker_give WHERE ID_NUMBER = #{idNumber} and pro_id = #{proId} and is_active = 1
</select>
<insert id="insertGiveLikeData" parameterType="com.bonus.gzrn.rnama.person.entity.WorkerGiveLikeBean">
replace into bm_worker_give(id,name,ID_NUMBER,ORG_ID,PRO_ID,SUB_ID,TEAM_ID,work_type,star_rating,comment,upload_time,upload_date,comment_id)
values(#{id},#{name},#{idNumber},#{orgId},#{proId},#{subId},#{teamId},#{postId},#{level},#{comment},#{uploadTime},#{uploadDate},#{commentId})
</insert>
<select id="selectGiveLikeData" resultType="com.bonus.gzrn.rnama.person.entity.WorkerGiveLikeBean" parameterType="com.bonus.gzrn.rnama.person.entity.WorkerGiveLikeBean">
select bwg.id,bwg.name,bwg.id_number as idNumber,bwg.star_rating as level,bwg.`comment`,bwg.upload_time as uploadTime,
bwg.comment_id as commentId,su.USERNAME as commentName,'无' as postName
from bm_worker_give bwg
LEFT JOIN sys_user su on su.id = bwg.comment_id
where bwg.id_number = #{idNumber} and bwg.is_active = 1
</select>
<select id="selectMyGiveLikeData" resultType="com.bonus.gzrn.rnama.person.entity.WorkerGiveLikeBean">
select bwg.id,bwg.name,bwg.id_number as idNumber,bwg.star_rating as level,bwg.`comment`,bwg.upload_time as uploadTime,
bwg.comment_id as commentId,su.USERNAME as commentName,'无' as postName
from bm_worker_give bwg
LEFT JOIN sys_user su on su.id = bwg.comment_id
where bwg.comment_id = #{commentId} and bwg.is_active = 1
</select>
<select id="selectAttendanceNoExamineData"
resultType="com.bonus.gzrn.rnama.person.entity.FaceAttendanceNoExamineBean">
<if test = 'type == "全部"'>
select * from (
select ffc.name,ffc.ID_NUMBER as idNumber,ADD_TIME as addTime,PHOTO_PATH as path,'已打卡' as status
from fc_face_contrast ffc
left join bm_worker_record bwr on bwr.ID_NUMBER = ffc.ID_NUMBER
where ffc.CURRENT_DAY = #{currentDay} and ffc.PRO_ID = #{proId}
and ffc.AUDIT_STATUS = 0
and ffc.ID_NUMBER not in ( select ID_NUMBER from fc_face_contrast ffc
where ffc.CURRENT_DAY = #{currentDay} and ffc.PRO_ID = #{proId} and AUDIT_STATUS = 1 )
<if test="keyWord != null || keyWord != ''">
and CONCAT(ffc.ID_NUMBER,ffc.name) like concat('%',#{keyWord},'%')
</if>
<if test="teamId != '-1'">
and bwr.TEAM_ID = #{teamId}
</if>
union
select a.name,a.idNumber,'' as addTime,'' as path,'未打卡' as status from (
select bw.name,bw.ID_NUMBER as idNumber,bwr.team_id
from bm_worker bw
left join bm_worker_record bwr on bwr.ID_NUMBER = bw.ID_NUMBER
where bwr.PROJECT_ID = #{proId} and bw.is_active = 1
and bwr.ein_status = 1 and bwr.examine_status = 1 and bwr.IS_ACTIVE = 1
) a where a.idNumber not in(
select ffc.ID_NUMBER from fc_face_contrast ffc
where ffc.CURRENT_DAY = #{currentDay}
)
<if test="keyWord != null || keyWord != ''">
and CONCAT(a.idNumber,a.name) like concat('%',#{keyWord},'%')
</if>
<if test="teamId != '-1'">
and a.TEAM_ID = #{teamId}
</if>
ORDER by addtime DESC limit 100000000
) a GROUP BY a.idNumber
</if>
<if test = 'type == "已打卡"'>
select * from (
select ffc.name,ffc.ID_NUMBER as idNumber,ADD_TIME as addTime,PHOTO_PATH as path,'已打卡' as status
from fc_face_contrast ffc
left join bm_worker_record bwr on bwr.ID_NUMBER = ffc.ID_NUMBER
where ffc.CURRENT_DAY = #{currentDay} and ffc.PRO_ID = #{proId}
and ffc.AUDIT_STATUS = 0
and ffc.ID_NUMBER not in ( select ID_NUMBER from fc_face_contrast ffc
where ffc.CURRENT_DAY = #{currentDay} and ffc.PRO_ID = #{proId} and AUDIT_STATUS = 1 )
<if test="keyWord != null || keyWord != ''">
and CONCAT(ffc.ID_NUMBER,ffc.name) like concat('%',#{keyWord},'%')
</if>
<if test="teamId != '-1'">
and bwr.TEAM_ID = #{teamId}
</if>
ORDER by addtime DESC limit 100000000
) a GROUP BY a.idNumber
</if>
<if test = 'type == "未打卡"'>
select * from (
select a.name,a.idNumber,'' as addTime,'' as path,'未打卡' as status from (
select bw.name,bw.ID_NUMBER as idNumber,bwr.team_id
from bm_worker bw
left join bm_worker_record bwr on bwr.ID_NUMBER = bw.ID_NUMBER
where bwr.PROJECT_ID = #{proId} and bw.is_active = 1
and bwr.ein_status = 1 and bwr.examine_status = 1 and bwr.IS_ACTIVE = 1
) a where a.idNumber not in(
select ffc.ID_NUMBER from fc_face_contrast ffc
where ffc.CURRENT_DAY = #{currentDay}
)
<if test="keyWord != null || keyWord != ''">
and CONCAT(a.idNumber,a.name) like concat('%',#{keyWord},'%')
</if>
<if test="teamId != '-1'">
and a.TEAM_ID = #{teamId}
</if>
ORDER by addtime DESC limit 100000000
) a GROUP BY a.idNumber
</if>
</select>
<select id="selectAttendanceNoExamineTeamData" resultType="com.bonus.gzrn.rnama.core.entity.MapBean">
select a.id as 'key',a.name as 'value' from (
select bst.id,bst.name,ffc.ID_NUMBER as idNumber
from fc_face_contrast ffc
left join bm_worker_record bwr on bwr.ID_NUMBER = ffc.ID_NUMBER
left join bm_sub_team bst on bst.id = bwr.TEAM_ID
where ffc.CURRENT_DAY = #{currentDay} and ffc.PRO_ID = #{proId}
and ffc.AUDIT_STATUS = 0
and ffc.ID_NUMBER not in ( select ID_NUMBER from fc_face_contrast ffc
where ffc.CURRENT_DAY = #{currentDay} and ffc.PRO_ID = #{proId} and AUDIT_STATUS = 1 )
and bst.id is not null
union
select a.id,a.name,a.idNumber from (
select bst.id,bst.name,bw.ID_NUMBER as idNumber
from bm_worker bw
left join bm_worker_record bwr on bwr.ID_NUMBER = bw.ID_NUMBER
left join bm_sub_team bst on bst.id = bwr.TEAM_ID
where bwr.PROJECT_ID = #{proId} and bw.is_active = 1 and bst.id is not null
and bwr.ein_status = 1 and bwr.examine_status = 1 and bwr.IS_ACTIVE = 1
) a where a.idNumber not in(
select ffc.ID_NUMBER from fc_face_contrast ffc
where ffc.CURRENT_DAY = #{currentDay}
)
) a GROUP BY a.id
</select>
<select id="selectAttendanceExamineData"
resultType="com.bonus.gzrn.rnama.person.entity.FaceAttendanceExamineBean">
select ffc.name,ffc.ID_NUMBER as idNumber,WORK_HOURS as workHours,OVER_HOURS as overWorkHours,
ffc.IS_SUCCESS as status,ffc.AUDIT_STATUS as examineStatus,ffc.AUDIT_REMARK as remark
from fc_face_contrast ffc
left join bm_worker_record bwr on bwr.ID_NUMBER = ffc.ID_NUMBER
where ffc.CURRENT_DAY = #{currentDay} and ffc.PRO_ID = #{proId}
and ffc.AUDIT_STATUS != '0'
<if test="keyWord != null || keyWord != ''">
and CONCAT(ffc.ID_NUMBER,ffc.name) like concat('%',#{keyWord},'%')
</if>
<if test="teamId != '-1'">
and bwr.TEAM_ID = #{teamId}
</if>
</select>
<select id="selectAttendanceExamineTeamData" resultType="com.bonus.gzrn.rnama.core.entity.MapBean">
select a.id as 'key',a.name as 'value' from (
select bst.id,bst.name
from fc_face_contrast ffc
left join bm_worker_record bwr on bwr.ID_NUMBER = ffc.ID_NUMBER
left join bm_sub_team bst on bst.id = bwr.TEAM_ID
where ffc.CURRENT_DAY = #{currentDay} and ffc.PRO_ID = #{proId}
and ffc.AUDIT_STATUS != '0' and bst.id is not null
<if test="keyWord != null || keyWord != ''">
and CONCAT(ffc.ID_NUMBER,ffc.name) like concat('%',#{keyWord},'%')
</if>
) a GROUP BY a.id
</select>
<select id="selectSubExamineData"
resultType="com.bonus.gzrn.rnama.person.entity.SubApproachBean">
select bs.sub_name as subName,bs.REPRESENT as represent,bs.RE_CONTACT as phone,bs.name,
bs.ID_NUMBER as idNumber,bs.ADDRESS,bs.signing as issueAuthority,bs.effective_date as effectiveDate,
ID_CARD_JUST_URL as frontPhoto,ID_CARD_BACK_URL as backPhoto,SIGNATURE_URL as autoGrapPhoto,
SEAL_URL as sealPhoto,BUSINESS_URL as businessPhoto,SAFETY_URL as safetyPermitPhoto,
AUDIT_RESULT as auditorResult,AUDIT_REMARK as auditorRemark,UPLOAD_TIME as uploadTime,
AUDIT_TIME as auditorTime,upload.USERNAME as uploadName,examine.USERNAME as auditorName
from bm_subcontractor bs
left join sys_user upload on upload.id = bs.UPLOADER
left join sys_user examine on examine.id = bs.AUDITOR
where uploader = #{uploadId} and bs.IS_ACTIVE = 1
<if test="auditorResult != '-1'">
and AUDIT_RESULT = #{auditorResult}
</if>
<if test="keyWord != null || keyWord != ''">
and CONCAT(bs.sub_name,bs.REPRESENT,bs.name) like concat('%',#{keyWord},'%')
</if>
</select>
<insert id="uploadSubApproachData" parameterType="com.bonus.gzrn.rnama.person.entity.SubApproachBean">
insert into bm_subcontractor(SUB_NAME,REPRESENT,RE_CONTACT,NAME,ID_NUMBER,ADDRESS,SIGNING,EFFECTIVE_DATE,ID_CARD_JUST_URL,ID_CARD_BACK_URL,SIGNATURE_URL,SEAL_URL,BUSINESS_URL,SAFETY_URL,UPDATE_TIME,UPLOADER,UPLOAD_TIME,COMPANY_ID)
select #{subName},#{represent},#{phone},#{name},#{idNumber},#{address},#{issueAuthority},#{effectiveDate},#{frontPhoto},#{backPhoto},#{autoGrapPhoto},#{sealPhoto},#{businessPhoto},#{safetyPermitPhoto},#{uploadTime},#{uploadId},#{uploadTime},company_id from pm_organization
where id = #{companyId} and is_active = 1
and NOT EXISTS (SELECT SUB_NAME FROM bm_subcontractor WHERE SUB_NAME = #{subName} and is_active = 1)
</insert>
<update id="updateAudit" parameterType="com.bonus.gzrn.rnama.person.entity.ContractBean">
UPDATE
bm_worker_contract
SET
auditor = #{auditor},audit_time = #{auditTime},is_audit = #{isAudit},remark = #{remarks}
where
idCard = #{partBIdCard} and id = #{id}
</update>
<update id="updateSign" parameterType="com.bonus.gzrn.rnama.person.entity.ContractBean">
UPDATE
bm_worker_contract_details
SET
legal_seal = #{legalSeal},company_seal = #{companySeal},is_sign = #{isSign}
WHERE part_b_idCard = #{partBIdCard} and contract_id = #{id};
UPDATE
bm_worker_contract
SET
sub_contract_url = #{subPdfUrl}
WHERE idCard = #{partBIdCard} and id = #{id}
</update>
<insert id="addContractMessage" parameterType="com.bonus.gzrn.rnama.person.entity.ContractBean">
insert INTO
bm_worker_contract_details
(
contract_id,
video_url,
part_a,
legal_person,
part_a_idCard,
part_a_phone,
part_a_adress,
part_b,
sex,
part_b_phone,
part_b_idCard,
part_b_adress,
work_type,
work_task,
work_adress,
ver_method,
ver_stand,
effect_date,
other_supply,
role,
part_b_sign,
team_sign,
message,
signing_date,
face_url,
message_time,
short_message
)
VALUES
(
#{id},#{videoUrl},#{partA},#{legalPerson},#{partAIdCard},#{partAPhone},#{partAAdress},#{partB},
#{sex},#{partBPhone},#{partBIdCard},#{partBAdress},#{workType},
#{workTask},#{workAdress},#{verMethod},#{verStand},#{effectDate},
#{otherSupply},#{role},#{partBSign},#{teamSign},#{message},#{signingDate},
#{faceUrl},#{messageTime},#{shortMessage}
)
</insert>
<insert id="addContractMessageTow" parameterType="com.bonus.gzrn.rnama.person.entity.ContractBean">
insert INTO
bm_worker_contract
(
id,
idCard,
name,
post,
effectDate,
contractCode,
role,
contractValidDate,
contractType,
wageApprovedWay,
wageCriterion,
whetherOnJob,
auditor,
audit_time,
is_audit,
remark,
person_contract_url,
pro_id
)
VALUES
(#{id},#{partBIdCard},#{partB},#{workType},#{effectDate},#{code},#{role},#{effectDate},'电子合同',
#{verMethod},#{verStand},'1',#{auditor},#{auditTime},'0',#{remarks},#{personPdfUrl},#{proId})
</insert>
<select id="selectArmourMessage" parameterType="com.bonus.gzrn.rnama.person.entity.ContractBean"
resultType="com.bonus.gzrn.rnama.person.entity.ContractBean">
SELECT
bs.SUB_NAME AS partA,
bs.REPRESENT AS legalPerson,
bs.RE_CONTACT AS partAPhone,
bs.ADDRESS AS partAAdress
FROM
bm_worker_record bwr
LEFT JOIN bm_subcontractor bs ON bs.ID = bwr.SUB_ID
WHERE
bwr.ID_NUMBER = #{partAIdCard} and bwr.is_active = 1
</select>
<select id="queryList" parameterType="com.bonus.gzrn.rnama.person.entity.ContractBean" resultType="com.bonus.gzrn.rnama.person.entity.ContractBean">
SELECT
bwc.id,
bwcd.part_b AS partB,
bwcd.part_b_idCard AS partBIdCard,
sdd.name AS workType,
bwcd.ver_method AS verMethod,
bwcd.ver_stand AS verStand,
bwcd.work_adress AS workAdress,
bwcd.part_a AS partA,
bwcd.effect_date AS effectDate,
bwcd.signing_date AS signingDate,
bwcd.remarks AS remarks,
bwcd.is_sign AS isSign,
bwc.is_audit AS isAudit,
bwcd.video_url as videoUrl,
bwc.person_contract_url as personPdfUrl
FROM
bm_worker_contract_details bwcd
LEFT JOIN bm_worker_contract bwc ON bwc.idCard = bwcd.part_b_idCard and bwc.id = bwcd.contract_id
left join sys_dic_detail sdd on sdd.id = bwcd.work_type
WHERE bwc.pro_id = #{param.proId}
and bwcd.is_active = 1 and bwc.is_active = 1
<if test = 'param.isNotAudit == "0" '>
AND bwc.is_audit = '0'
</if>
<if test = 'param.isNotAudit != "0" '>
AND bwc.is_audit != '0'
</if>
<if test = 'param.keyWord != null and param.keyWord != "" '>
AND (
part_b LIKE CONCAT('%',#{param.keyWord},'%') or
part_b_idCard LIKE CONCAT('%',#{param.keyWord},'%') or
work_adress LIKE CONCAT('%',#{param.keyWord},'%') or
part_a LIKE CONCAT('%',#{param.keyWord},'%')
)
</if>
</select>
<select id="queryIsSignList" parameterType="com.bonus.gzrn.rnama.person.entity.ContractBean" resultType="com.bonus.gzrn.rnama.person.entity.ContractBean">
SELECT
bwc.id,
bwcd.part_b AS partB,
bwcd.part_b_idCard AS partBIdCard,
bwcd.part_b_phone as partBPhone,
sdd.name AS workType,
bwcd.ver_method AS verMethod,
bwcd.ver_stand AS verStand,
bwcd.work_adress AS workAdress,
bwcd.part_a AS partA,
bwcd.effect_date AS effectDate,
bwcd.signing_date AS signingDate,
bwcd.remarks AS remarks,
bwcd.is_sign AS isSign,
bwc.is_audit AS isAudit,
bwcd.video_url as videoUrl,
bwc.person_contract_url as personPdfUrl,
bwc.sub_contract_url as subPdfUrl
FROM
bm_worker_contract_details bwcd
LEFT JOIN bm_worker_contract bwc ON bwc.idCard = bwcd.part_b_idCard and bwc.id = bwcd.contract_id
left join sys_dic_detail sdd on sdd.id = bwcd.work_type
WHERE bwc.pro_id = #{param.proId} AND bwc.is_audit = '1'
and bwcd.is_active = 1 and bwc.is_active = 1
<if test = 'param.isSign == "0"'>
AND bwcd.is_sign = '0'
</if>
<if test = 'param.isSign != "0"'>
AND bwcd.is_sign != '0'
</if>
<if test = 'param.keyWord != null and param.keyWord != "" '>
AND (
part_b LIKE CONCAT('%',#{param.keyWord},'%') or
part_b_idCard LIKE CONCAT('%',#{param.keyWord},'%') or
work_adress LIKE CONCAT('%',#{param.keyWord},'%') or
part_a LIKE CONCAT('%',#{param.keyWord},'%')
)
</if>
</select>
<select id="getContractCode" resultType="java.lang.String">
select contractCode from bm_worker_contract
where contractType = '电子合同'
ORDER BY contractCode desc limit 1
</select>
<select id="selectCollectionExamineData"
resultType="com.bonus.gzrn.rnama.person.entity.CollectionPersonBean">
select bw.name,bw.ID_NUMBER as idNumber,sdd.name as post,
bwr.EIN_DATE as einTime,examine_status as status
from bm_worker_record bwr
left join bm_worker bw on bw.ID_NUMBER = bwr.ID_NUMBER
left join bm_worker_photo bwp on bwp.ID_NUMBER = bw.ID_NUMBER
left join sys_dic_detail sdd on sdd.id = bwr.POST_ID
where ein_status = 1 and bwp.upload_id = #{userId}
<if test="status != '全部'">
<if test="status == '待审核'">
and examine_status = '0'
</if>
<if test="status == '已审核'">
and examine_status = '1'
</if>
<if test="status == '未通过'">
and examine_status = '2'
</if>
</if>
<if test="keyWord != null || keyWord != ''">
and CONCAT(bw.name,bw.id_number,sdd.name) like concat('%',#{keyWord},'%')
</if>
GROUP BY bw.ID_NUMBER
</select>
<insert id="uploadWiness" parameterType="com.bonus.gzrn.rnama.person.entity.WorkerWitnessBean">
insert into bm_worker_witness(contract_id,ID_NUMBER,witness_path,witness_type,upload_date,upload_time,upload_id,is_active)
values (#{id},#{idNumber},#{witnessPath},#{witnessType},#{uploadDate},#{uploadTime},#{uploadId},1)
</insert>
<insert id="uploadContract" parameterType="com.bonus.gzrn.rnama.person.entity.WorkerWitnessBean">
insert into bm_worker_contract(id,idCard,contractCode,role,laborContractType,contractValidDate,contractInvalidDate,contractType,miurInsurance,endowmentInsurance,wageApprovedWay,wageCriterion,whetherOnJob)
values (#{id},#{idNumber},#{contractCode},#{role},#{laborContractType},#{contractValidDate},#{contractInvalidDate},#{contractType},#{miurInsurance},#{endowmentInsurance},#{wageApprovedWay},#{wageCriterion},#{whetherOnJob})
</insert>
<insert id="uploadBankInfo" parameterType="com.bonus.gzrn.rnama.person.entity.WokerBankCardBean">
replace into bm_worker_payroll(ID_NUMBER,BANK_CARD,BANK_NAME,ROLL_BANK_NAME,PATH,is_active,upload_time,upload_id,bankAffiliated)
values (#{idNumber},#{bankCard},#{bankName},#{bankRollName},#{path},1,#{uploadTime},#{uploadId},#{bankAffiliated})
</insert>
<insert id="uploadBankWiness" parameterType="com.bonus.gzrn.rnama.person.entity.WokerBankCardBean">
replace into bm_worker_witness(ID_NUMBER,witness_path,witness_type,upload_date,upload_time,upload_id,is_active)
values (#{idNumber},#{path},2,#{uploadDate},#{uploadTime},#{uploadId},1)
</insert>
<insert id="uploadSafeguardingInfo" parameterType="com.bonus.gzrn.rnama.core.entity.SafeguardingBean">
replace into bm_safeguarding_info(id,owe_company,owe_project,address,apply_user,id_card,phone,owe_start_day,owe_end_day,owe_money,representations_time,upload_user_id,add_time,current_day,is_active,reply_status,reply_content,company_id)
values (#{id},#{oweCompany},#{oweProject},#{address},#{applayUser},#{idCard},#{phone},#{oweStartDay},#{oweEndDay},#{oweMoney},#{representationTime},#{uploadUserId},#{addTime},#{currentDay},1,#{replyStatus},#{replyContent},#{companyId})
</insert>
<insert id="uploadSafeguardingPhoto" parameterType="com.bonus.gzrn.rnama.core.entity.SafeguardingBean">
replace into bm_safeguarding_photo (id,safeguarding_id,path,`type`,upload_user_id,add_time,current_day,is_active)
values (#{id},#{safeguardingId},#{path},#{type},#{uploadUserId},#{addTime},#{currentDay},1)
</insert>
<select id="selectProblemContract" resultType="com.bonus.gzrn.rnama.person.entity.ContractBean">
SELECT
bwcd.part_b AS partB,
bwcd.sex as sex,
bwcd.part_b_phone as partBPhone,
bwcd.part_b_idCard AS partBIdCard,
bwcd.part_b_adress as partBAdress,
sdd.NAME AS workType,
bwcd.work_task as workTask,
bwcd.ver_method AS verMethod,
bwcd.ver_stand AS verStand,
bwcd.work_adress AS workAdress,
bwcd.part_a AS partA,
bwcd.legal_person as legalPerson,
bwcd.part_a_phone as partAPhone,
bwcd.part_a_adress as partAAdress,
bwcd.effect_date AS effectDate,
bwcd.signing_date AS signingDate,
bwcd.role,
bwcd.other_supply as otherSupply,
bwcd.part_b_sign AS partBSign,
bwcd.team_sign AS teamSign
FROM
bm_worker_contract_details bwcd
LEFT JOIN bm_worker_contract bwc ON bwc.idCard = bwcd.part_b_idCard
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwcd.work_type
WHERE
bwc.contractCode = '0623'
AND bwc.contractType = '电子合同'
-- SELECT
-- '1' as isSign,
-- bwcd.part_b_idCard AS partBIdCard,
-- bwcd.legal_seal as legalSeal,
-- bwcd.company_seal as companySeal,
-- bwc.person_contract_url as subPdfUrl
-- FROM
-- bm_worker_contract_details bwcd
-- LEFT JOIN bm_worker_contract bwc ON bwc.idCard = bwcd.part_b_idCard
-- LEFT JOIN sys_dic_detail sdd ON sdd.id = bwcd.work_type
-- WHERE
-- bwc.sub_contract_url = 'gzRealName/contract/pdf/2022/04/22/0072_sign.pdf'
-- AND bwc.contractType = '电子合同'
</select>
<update id="uploadProblemContract">
update bm_worker_contract set contractCode = #{code},person_contract_url = #{personPdfUrl}
where idCard = #{partBIdCard}
</update>
<select id="selectCompanyIdByUserId" resultType="java.lang.String">
select org.COMPANY_ID from sys_user su
left join pm_organization org on org.id = su.ORG_ID
where su.id = #{userId}
</select>
<select id="selectContractIsExist" resultType="java.lang.Boolean">
select count(1) from bm_worker_contract bwc
left join bm_worker_contract_details bwcd on bwcd.contract_id = bwc.id
where bwc.idCard = #{partBIdCard}
<if test="proId != null || proId != ''">
and pro_id = #{proId}
</if>
<if test="type == 1 || type == '1'">
and bwc.is_audit != 2 and bwcd.is_sign != 1
</if>
and bwc.is_active = '1' and bwcd.is_active = '1'
</select>
<update id="updateContract">
update bm_worker_contract set is_active = 0 where idCard = #{idNumber};
update bm_worker_contract_details set is_active = 0 where part_b_idCard = #{idNumber};
update bm_worker_witness set is_active = 0 where id_number = #{idNumber} and witness_type = 1;
</update>
<update id="updateWorkHistory">
update bm_worker_attend_history set
EXIT_TIME = #{einTime}
where ID_NUMBER = #{idNumber} and EXIT_TIME is null
</update>
<select id="selectWorkerByNoJob" resultType="com.bonus.gzrn.rnama.person.entity.WorkerNoJob">
select * from (
select
'贵州送变电有限责任公司' AS orgName,
'9152000021440270X9' AS orgCreditCode,
concat('SongBianDianProject', IFNULL(p.pro_old_id,p.id)) as projectId,
p.NAME AS projectName,
concat('SongBianDianTeam', bst.id) as teamId,
bst.NAME AS teamName,
bst.EIN_TIME AS approachDate,
'否' as whetherOnJob,
'否' as whetherOnDuty,
case when
bwr.TEAM_CAPTAIN = 1 then '是' when
bwr.TEAM_CAPTAIN = 0 then '否' else '否'
end as teamCaptain,
IFNULL(bwt.name,'其它') as workType,
-- '其它' as workType,
bwr.EIN_TIME AS entryDate,
bwr.EXIT_TIME as exitDate,
CONCAT('http://10.1.0.142:1919/gzrnama/',bwah.departureAffirmUrl) AS departureAffirmUrl,
bw.NAME,
bw.ID_NUMBER AS idCard,
bw.sex AS gender,
if(bw.ETHNIC = '穿青人','其他',concat(bw.ETHNIC,'族')) as nation,
bw.ADDRESS AS address,
IFNULL(bw.phone,'13800000000') as phone,
'群众' as politicalFace,
'不限' as education,
IFNULL(bw.ISSUEAUTHORITY,'暂无') AS issuingAuthority,
CONCAT('http://10.1.0.142:1919/gzrnama/',face.PHOTO_PATH) AS headPortrait,
CONCAT('http://10.1.0.142:1919/gzrnama/',front.PHOTO_PATH) as frontPhontUrl,
CONCAT('http://10.1.0.142:1919/gzrnama/',back.PHOTO_PATH) AS backPhontUrl,
'是' AS hasContract,
'是' AS hasWorkInsurance,
'是' AS hasAccidentInsurance,
'是' AS miurInsurance,
'是' AS endowmentInsurance,
IFNULL(bwp.BANK_CARD,'无') AS payRollBankCardNum,
IFNULL(bwp.ROLL_BANK_NAME,'无') AS payRollBankName,
IFNULL(bwp.BANK_NAME,'无') AS payrollBank,
IFNULL(bwp.bankAffiliated,'无') AS bankAffiliated,
IFNULL(bwci.wageApprovedWay,'无') AS wageApprovedWay,
IFNULL(bwci.wageCriterion,'无') AS wageCriterion,
IFNULL(bwr.FOREMAN,'无') AS leaderName,
IFNULL(bwr.FOREMAN_PHONE,'无') AS leaderPhone,
IFNULL(bwr.FOREMAN_IDNUMBER,'无') AS leaderIdCardNum,
IFNULL(bwr.PRINCIPAL_NAME,'无') AS principalName,
IFNULL(bwr.PRINCIPAL_PHONE,'无') AS principalPhone,
IFNULL(bwr.PRINCIPAL_IDNUMBER,'无') AS principalIdCard
from bm_worker bw
left join bm_worker_record bwr on bwr.ID_NUMBER = bw.ID_NUMBER
LEFT JOIN bm_worker_attend_history bwah ON bwah.ID_NUMBER = bwr.ID_NUMBER
AND bwah.PROJECT_ID = bwr.PROJECT_ID
AND bwah.TEAM_ID = bwr.TEAM_ID
left join bm_project p on p.id = bwr.PROJECT_ID
left join bm_sub_team bst on bst.ID = bwr.TEAM_ID
left join sys_dic_detail bwt on bwt.id = bwr.POST_ID
LEFT JOIN bm_worker_photo front ON front.ID_NUMBER = bw.ID_NUMBER and front.PHOTO_TYPE = 1
LEFT JOIN bm_worker_photo back ON back.ID_NUMBER = bw.ID_NUMBER and back.PHOTO_TYPE = 2
LEFT JOIN bm_worker_photo face ON face.ID_NUMBER = bw.ID_NUMBER and face.PHOTO_TYPE = 3
left join bm_worker_contract bwci on bwci.idCard = bw.ID_NUMBER -- and bwci.is_active = 1
left join bm_worker_payroll bwp on bwp.ID_NUMBER = bw.ID_NUMBER
where (bwp.ROLL_BANK_NAME is not null or bwp.BANK_NAME is not null)
and LENGTH(bw.ID_NUMBER) = 18
and LENGTH(bwr.FOREMAN_IDNUMBER) = 18
and LENGTH(bwr.PRINCIPAL_IDNUMBER) = 18
and bwt.name != '管理人员' and bst.id is not null
and bwr.is_exit_push != '1' and bwr.is_ein_push = 1
and p.is_push = 1 and bwci.wageApprovedWay is not null
and CHAR_LENGTH(bwp.ROLL_BANK_NAME) >= 6 and bwr.ein_status = 0
<if test="projectId != null and projectId != ''">
and bwr.PROJECT_ID = #{projectId}
</if>
<if test="idCard != null and idCard != ''">
and bw.ID_NUMBER = #{idCard}
</if>
order by bwci.upload_time limit 99999999
) a GROUP BY a.idCard
</select>
<update id="updateWorkerExitStatus">
update bm_worker_record set
is_exit_push = #{status},
exit_push_time = #{nowTime},
exit_push_content = #{result}
where ID_NUMBER = #{id}
</update>
<insert id="uploadWorkerPushHistory">
<if test='type == "ein"'>
insert into bm_worker_push_history(id_number,pro_id,team_id,contract_id,ein_push_time)
values (#{bean.idCard},#{bean.projectId},#{bean.teamId},#{bean.contractId},#{bean.einPushTime})
</if>
<if test='type == "exit"'>
update bm_worker_push_history set exit_push_time = #{bean.exitPushTime}
where id_number = #{bean.idCard} and pro_id = #{bean.projectId} and team_id = #{bean.teamId}
</if>
<if test='type == "contract"'>
update bm_worker_push_history set contract_id = #{bean.contractId},contract_push_time = #{bean.contractPushTime}
where id_number = #{bean.idCard} and pro_id = #{bean.projectId} and team_id = #{bean.teamId}
</if>
</insert>
<select id="selectPushDataById" resultType="com.bonus.gzrn.rnama.person.entity.ProBidRelationBean">
SELECT a.pro_name as proName,SUBSTRING_INDEX(
SUBSTRING_INDEX( a.bid_pro_id, ',',
b.help_topic_id + 1 ), ',',- 1 ) bidProId,
SUBSTRING_INDEX(
SUBSTRING_INDEX( a.is_multiple, ',',
b.help_topic_id + 1 ), ',',- 1 ) isMultiple
FROM bm_project_bid_relation a
JOIN mysql.help_topic b
ON b.help_topic_id &lt; ( LENGTH( a.bid_pro_id ) -
LENGTH( REPLACE ( a.bid_pro_id, ',', '' ) ) + 1 )
WHERE a.is_active = 1 and a.bid_pro_id
like CONCAT('%',#{proId},'%')
</select>
<select id="selectShortTermTask" resultType="com.bonus.gzrn.rnama.person.entity.PersonShortTermBean">
select bwah.id_number as idNumber, bwah.ein_time as einTime,
GROUP_CONCAT(DISTINCT ffc.CURRENT_DAY) as date from bm_worker_attend_history bwah
left join fc_face_contrast ffc on ffc.ID_NUMBER = bwah.ID_NUMBER
where bwah.is_short_term = 1 and bwah.EXIT_TIME is null
and ffc.CURRENT_DAY >= date_format( bwah.EIN_TIME, '%Y-%m-%d' )
</select>
<update id="updateShortTerm">
<foreach collection="list" item="item" index="index">
update bm_worker_attend_history set is_short_term = 0
where id_number = #{item.idNumber} and EIN_TIME = #{item.einTime}
</foreach>
</update>
</mapper>