C 的 time1(&t1), time2(t1, &dt)

C++时间处理函数
本文介绍了两个C++函数:time1用于获取当前时间并转换为特定格式;time2用于计算两个时间点之间的差值。通过这两个函数,可以方便地进行时间相关计算。
cpp 代码
  1. // file: sj02.h   
  2.   
  3. void time1(int *t1);   
  4. void time2(int t1, double *dt);   
  5. // ----------------------------------------------   
  6.   
  7. void time1(int *t1)   
  8. {   
  9.     struct _timeb timebuffer;   
  10.     _ftime( &timebuffer );   
  11.   
  12.     *t1= timebuffer.time + 8L*60*60;   
  13.     (*t1)%= (1L*24*60*60);   
  14.     *t1= (*t1)*1000L + timebuffer.millitm;   
  15. }// end time1()   
  16. // ----------------------------------------------   
  17.   
  18. void time2(int t1, double *dt)   
  19. {   
  20.     // get t2   
  21.     int t2;   
  22.     time1(&t2);   
  23.     // ----------------------------------------------   
  24.   
  25.     *dt= (t2 - t1)/1000.0;   
  26.   
  27.     // dt must >= 0.0   
  28.     if ((*dt) < 0.0) {   
  29.         (*dt)+= 1.0*24.0*60.0*60.0;   
  30.     }   
  31. }// end time2()   
  32. // ----------------------------------------------   
insert overwrite table ${dm_opr}.dmd_opr_bso_wo_info_iceberg_df partition(dt) select t1.id ,t1.tenant_id ,t1.form_id ,t1.ext_form_id ,t1.process_id ,t1.process_name ,t1.order_id ,t1.order_name ,t1.order_desc ,t1.customer_id ,t1.customer_name ,t1.customer_group_id ,t1.customer_group_name ,t1.priority ,case t1.priority when 0 then '--' when 1 then '低' when 2 then '正常' when 3 then '高' when 4 then '紧急' else cast(t1.priority as string) end priority_desc ,substr(t1.deadline_time,1,19) deadline_time ,t1.tags ,case t1.endpoint_type when 1 then 'C端' when 2 then 'B端' ELSE cast(t1.endpoint_type as string) END endpoint_type ,T1.channel_type ,T1.channel_id ,T1.channel_name ,substr(t1.close_time,1,19) close_time ,substr(t1.resolved_time,1,19) resolved_time ,substr(t1.first_resolved_time,1,19) first_resolved_time ,substr(t1.last_reply_time,1,19) last_reply_time ,substr(t1.todo_time,1,19) todo_time ,substr(t1.doing_time,1,19) doing_time ,substr(t1.allocate_time,1,19) allocate_time ,substr(t1.first_response_time,1,19) first_response_time ,t1.order_status ,case t1.order_status when 1 then '草稿' when 2 then '待办' when 3 then '进行中' when 4 then '已解决' when 5 then '已关闭' when 6 then '已删除' when 7 then '已驳回' else cast(t1.order_status as string) end ,t1.initial_status ,case t1.blacklist_status when 0 then '否' when 1 then '是' else cast(t1.blacklist_status as string) end blacklist_status ,t1.create_op_id ,t1.create_op_name ,t1.create_customer_id ,t1.create_customer_name ,t1.create_op_group_id ,t1.create_op_group_name ,substr(t1.create_time,1,19) create_time ,substr(t1.update_time,1,19) update_time ,t1.update_op_id ,t1.update_op_name ,t1.delete_op_id ,t1.delete_op_name ,substr(t1.delete_time,1,19) delete_time ,case t1.is_deleted when 0 then '否' when 1 then '是' else cast(t1.is_deleted as string) end is_deleted ,t1.session_id ,t2.call_record_id call_record_id ,t3.order_id_relation rela_order_id ,t1.use_workday_time ,t1.use_time ,t1.reminder_num ,substr(t1.reminder_time,1,19) reminder_time ,t1.time_left_sort ,t1.res_time_left_sort ,t1.flow_instance_id ,t1.flow_key ,t1.flow_version ,t1.dt ,t2.call_type from lods.lods_smartxma_workorder_wo_order_base t1 left join ( select t1.order_id,t1.tenant_id,t1.call_record_id,c.call_type from lods.lods_smartxma_workorder_wo_order_voice_relation t1 left join lods.lods_smartxma_call_call_room c on t1.call_record_id= c.icc_call_id and t1.tenant_id = c.tenant_id where t1.dt >= '${dt_3}' and t1.is_deleted = '0' ) t2 on t2.order_id = t1.order_id and t2.tenant_id = t1.tenant_id left join ( select t1.order_id,t1.tenant_id,t1.order_id_relation from lods.lods_smartxma_workorder_wo_order_relation t1 where t1.dt >= '${dt_3}' and t1.is_deleted = '0' ) t3 on t3.order_id = t1.order_id and t3.tenant_id = t1.tenant_id where t1.dt >= '${dt_3}' ;这是dmd_opr_bso_wo_info_iceberg_df 的制作逻辑,指标计算时候也取源头表,指标计算sql怎么该
最新发布
11-06
with mid_dmd_opr_lia_call_info_df as ( select t1.call_id ,concat_ws('-',collect_list(node_id_cd)) node_id_cd ,concat_ws('-',collect_list(mission_name)) mission_name from ( select t1.call_id ,node_id_cd ,t2.mission_name from ( select t1.call_id ,t1.node_id ,node_id_cd ,node_id_name from ( select *,row_number() over(PARTITION by call_id ORDER BY cast(order_id as bigint) desc) rn from lods.lods_icrm_dezhu_ivroperatelog ) t1 lateral view posexplode(split ( node_id,'-' )) t as node_id_cd, node_id_name where t1.rn = 1 ) t1 left join ( SELECT mission_code ,mission_name from ( SELECT * ,row_number() over (PARTITION by mission_code order by _hoodie_commit_time desc ) as num from lods.lods_msxfcc_wf_mission where is_report_node ='true' ) where num=1) t2 on t2.mission_code = t1.node_id_name order by 1,2 asc,3 ) t1 group by 1 ) insert overwrite table dm_opr.dmd_opr_lia_call_info_iceberg_df partition(dt) select t1.call_room_id ,t1.tenant_id ,case t1.call_type when 1 then '呼入' when 2 then '外呼' when 3 then '外呼任务' when 4 then '内呼' when 11 then '无坐席呼叫' else cast(t1.call_type as string) end call_type ,t1.icc_call_id ,t1.caller_phone ,t1.caller_participant_id ,t1.callee_phone ,t1.callee_participant_id ,substr(t1.start_time,1,19) room_start_time ,substr(t1.hang_up_time,1,19) room_hang_up_time ,case t1.hang_up_result when 'CONTACT_DROPPED_CALL' then 'C端挂断' when 'AGENT_DROPPED_CALL' then 'B端挂断' when 'SYSTYEM_SCHED_DROPPED_CALL' then '系统挂断' when 'SYSTYEM_RTS_TIMEOUT_CALL' then 'rts超时挂断' when 'AGENT_TIMEOUT_DROPPED_CALL' then '坐席超时挂断' when 'CONTACT_TIMEOUT_DROPPED_CALL' then '客户超时挂断' else t1.hang_up_result end room_hang_up_dirct ,t1.ring_duration ,t1.queue_duration ,t1.hold_duration ,t1.talk_duration ,t1.agent_talk_duration ,t1.icc_call_result ,t1.source ,t1.source_identity ,t1.source_data ,t2.transfer_id ,t2.from_transfer_id ,t2.digit_url ,substr(t3.start_time,1,19) queue_start_time ,substr(t3.end_time,1,19) queue_end_time ,t3.duration ,t3.skillsets_id ,t3.queue_role ,t3.queue_role_id ,t4.participant_id ,t4.login_type ,t4.skillsets_id ,t4.out_phone ,t4.did_phone ,t4.line_phone ,substr(t5.start_time,1,19) agent_start_time ,substr(t5.parking_time,1,19) agent_parking_time ,substr(t5.ring_time,1,19) agent_ring_time ,substr(t5.answer_time,1,19) agent_answer_time ,substr(t5.bridge_time,1,19) agent_bridge_time ,substr(t5.hangup_time,1,19) agent_hangup_time ,t5.acw_configuration ,t5.acw_duration ,t5.ring_duration ,t5.queue_duration ,t5.hold_duration ,t5.talk_duration ,t5.hang_up_result ,t5.hang_up_dirct ,t5.icc_call_result ,t5.call_result ,t5.icc_call_result_type ,t5.icc_recording_id ,t5.icc_record_date ,split(t7.summary,'-')[0] ,split(t7.summary,'-')[1] ,split(t7.summary,'-')[2] ,t6.start_time ,t6.end_time ,case t6.score when -1 then '未参与' when 0 then '未评价' when 5 then '非常满意' when 4 then '满意' when 3 then '一般' when 2 then '不满意' when 1 then '非常不满意' else cast(t6.score as string) end ,t1.dt ,t8.mission_name ,t5.participant_role ,t5.participant_role_id from lods.lods_smartxma_call_call_room t1 left join ( select t1.tenant_id,t1.call_room_id,t1.from_participant_id,t1.digit_url,t1.transfer_id,t1.from_transfer_id from lods.lods_smartxma_call_call_room_tranfer t1 where t1.hoodie_record_type !='DELETE' and t1.is_deleted = 'false' ) t2 on t2.tenant_id =t1.tenant_id and t2.call_room_id = t1.call_room_id left join ( select * from lods.lods_smartxma_call_call_room_participant t1 where t1.hoodie_record_type !='DELETE' and t1.is_deleted = 'false' ) t5 on t5.tenant_id = t1.tenant_id and t5.call_room_id = t1.call_room_id and t5.transfer_id = t2.transfer_id left join ( select * from lods.lods_smartxma_call_call_room_queue t1 where t1.hoodie_record_type !='DELETE' and t1.is_deleted = 'false' ) t3 on t3.tenant_id = t1.tenant_id and t3.call_room_id = t1.call_room_id and t3.transfer_id = t2.transfer_id -- and t3.queue_role = t5.participant_role and t3.queue_id = t5.queue_id left join ( select * from lods.lods_smartxma_call_call_room_participant_agent t1 where t1.hoodie_record_type !='DELETE' and t1.is_deleted = 'false' ) t4 on t4.tenant_id = t1.tenant_id and t4.call_room_id = t1.call_room_id and t4.transfer_id = t2.transfer_id and t4.participant_id = t5.participant_id left join ( select * from lods.lods_smartxma_call_call_room_evaluate t1 where t1.hoodie_record_type !='DELETE' and t1.is_deleted = 'false' ) t6 on t6.tenant_id = t1.tenant_id and t6.call_room_id = t1.call_room_id and t6.transfer_id = t2.transfer_id and t6.from_participant_id = t5.participant_id left join ( select * from lods.lods_smartxma_call_call_room_participant_summary t1 where t1.is_deleted = 'false' and t1.hoodie_record_type !='DELETE' ) t7 on t7.tenant_id = t1.tenant_id and t7.call_room_id = t1.call_room_id and t7.participant_id = t5.participant_id left join mid_dmd_opr_lia_call_info_df t8 on t8.call_id = t1.icc_call_id where t1.hoodie_record_type !='DELETE' ; 这是完整代码请帮我优化一下呢
09-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值