INSERT INTO `dispatch`.`tenant_employee_attendance_records`(`id`, `STATUS`, `reference_type`, `reference_number`, `tenant_employee_id`, `tenant_user_id`, `organization_id`, `lon_lat`, `created_time`, `note`, `address`, `name`, `idCard_no`, `company_name`, `security_station_name`, `security_station_address`, `supervise_depart_id`, `supervise_depart_name`, `security_certificate_no`,`calculated_resource_type`,`project_id`, `project_name`,header_agent,attachments,extend_json_info) VALUES (#{item.id}, #{item.recordStatus,typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler}, #{item.referenceType,typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler},#{item.referenceNumber}, #{item.tenantEmployeeId},#{item.tenantUserId}, #{item.organizationId}, #{item.lonLat,typeHandler=com.bcxin.tenant.open.domains.typeHandlers.GeoPointTypeHandler},#{item.createdTime},#{item.note},#{item.address},#{item.name},#{item.idCardNo}, #{item.companyName},#{item.securityStationName},#{item.securityStationAddress},#{item.superviseDepartId},#{item.superviseDepartName}, #{item.securityCertificateNo},#{item.calculatedResourceType},(case when ifnull(#{item.projectId},'')='' then '#1' else rs.project_id end) as project_id ,#{item.projectName},SUBSTR(#{item.headerAgent},1,500), #{item.attachments},#{item.extendJsonInfo}) ON DUPLICATE KEY UPDATE `duplicated_count`=duplicated_count+1,duplicated_time=CURRENT_TIMESTAMP, header_agent=SUBSTR(#{item.headerAgent},1,500); INSERT INTO `dispatch`.`tenant_employee_recently_attendances`(`id`, `STATUS`, `tenant_employee_id`, `created_time`, `address`, `name`,`calculated_resource_type`,date_value,attachments,extend_json_info) (#{item.id}, #{item.recordStatus,typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler}, #{item.tenantEmployeeId},#{item.createdTime},#{item.address},#{item.name},#{item.calculatedResourceType}, DATE_FORMAT(CURDATE(), '%Y%m%d'),#{item.attachments},#{item.extendJsonInfo}) ON DUPLICATE KEY UPDATE `created_time`=#{item.createdTime}; INSERT INTO `dispatch`.`tenant_employee_attendance_records` (`id`, `STATUS`, `reference_type`, `reference_number`, `tenant_employee_id`, `tenant_user_id`, `organization_id`, `lon_lat`, `created_time`, `note`, `address`, `name`, `idCard_no`, `company_name`, `security_station_name`, `security_station_address`, `supervise_depart_id`, `supervise_depart_name`, `security_certificate_no`,`calculated_resource_type`,`project_id`, `project_name`,duplicated_time,header_agent,attachments,extend_json_info) select #{item.id}, #{item.recordStatus,typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler}, #{item.referenceType,typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler},#{item.referenceNumber}, #{item.tenantEmployeeId},#{item.tenantUserId}, #{item.organizationId}, #{item.lonLat,typeHandler=com.bcxin.tenant.open.domains.typeHandlers.GeoPointTypeHandler},#{item.createdTime},#{item.note},#{item.address},#{item.name},#{item.idCardNo}, #{item.companyName},rs.name,rs.address,rs.supervise_depart_id,rs.supervise_depart_name, #{item.securityCertificateNo},#{item.calculatedResourceType},(case when ifnull(rs.project_id,'')='' then '#1' else rs.project_id end) as project_id,rs.project_name,CURRENT_TIMESTAMP, SUBSTR(#{item.headerAgent},1,499),#{item.attachments},(case when #{item.extendJsonInfo}!='' then #{item.extendJsonInfo} else (case when ifnull(rs.project_id,'')='' then '#1' else (select concat('{"projectCompanyName":','"',p.company_name,'"','}') from dispatch.rd_project_summary p where p.id=rs.project_id limit 1) end) end) from `dispatch`.rd_security_station_summary rs where rs.id=#{item.referenceNumber} ON DUPLICATE KEY UPDATE `duplicated_count`=duplicated_count+1,duplicated_time=CURRENT_TIMESTAMP,header_agent=SUBSTR(#{item.headerAgent},1,500); INSERT INTO `dispatch`.`tenant_employee_recently_attendances` (`id`, `STATUS`, `tenant_employee_id`, `created_time`, `address`, `name`,`calculated_resource_type`,date_value,attachments,extend_json_info) select #{item.id}, #{item.recordStatus,typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler}, #{item.tenantEmployeeId}, #{item.createdTime},#{item.address},#{item.name},#{item.calculatedResourceType},DATE_FORMAT(CURDATE(), '%Y%m%d'),#{item.attachments},#{item.extendJsonInfo} ON DUPLICATE KEY UPDATE `created_time`=#{item.createdTime}; INSERT INTO `dispatch`.`tenant_employee_attendance_records` (`id`, `STATUS`, `reference_type`, `reference_number`, `tenant_employee_id`, `tenant_user_id`, `organization_id`, `lon_lat`, `created_time`, `note`, `address`, `name`, `idCard_no`, `company_name`, `security_station_name`, `security_station_address`, `supervise_depart_id`, `supervise_depart_name`, `security_certificate_no`,`calculated_resource_type`,`project_id`, `project_name`,duplicated_time,header_agent,attachments,reference_number_2,reference_number_3,extend_json_info) select #{item.id}, #{item.recordStatus,typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler}, #{item.referenceType,typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler}, rs.reference_number, #{item.tenantEmployeeId},#{item.tenantUserId}, #{item.organizationId}, #{item.lonLat,typeHandler=com.bcxin.tenant.open.domains.typeHandlers.GeoPointTypeHandler},#{item.createdTime},#{item.note},#{item.address},#{item.name},#{item.idCardNo}, #{item.companyName},rs.display_name,'#1' as address,rs.supervise_depart_id,rs.supervise_depart_name as supervise_depart_name, #{item.securityCertificateNo},#{item.calculatedResourceType},('#1') as project_id,'#1' as project_name,CURRENT_TIMESTAMP, SUBSTR(#{item.headerAgent},1,499),#{item.attachments},reference_line_id,reference_point_id,#{item.extendJsonInfo} from `dispatch`.rd_work_stations rs where rs.id=#{item.referenceNumber} ON DUPLICATE KEY UPDATE `duplicated_count`=duplicated_count+1,duplicated_time=CURRENT_TIMESTAMP,header_agent=SUBSTR(#{item.headerAgent},1,500); INSERT INTO `dispatch`.`tenant_employee_recently_attendances` (`id`, `STATUS`, `tenant_employee_id`, `created_time`, `address`, `name`,`calculated_resource_type`,date_value) select #{item.id}, #{item.recordStatus,typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler}, #{item.tenantEmployeeId}, #{item.createdTime},#{item.address},#{item.name},#{item.calculatedResourceType},DATE_FORMAT(CURDATE(), '%Y%m%d') ON DUPLICATE KEY UPDATE `created_time`=#{item.createdTime}; delete from tenant_employee_recently_attendances where limit 100