You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. import bot_app.fulfillment.utility as util
  2. # 查詢系統pic
  3. def looking_for_pic(fulfillment):
  4. # print(fulfillment)
  5. sys_code = fulfillment.get('queryResult').get('parameters').get('sys_code')
  6. # 取得系統pic
  7. strsql = '''
  8. select *
  9. from (select c.user_name_e,c.user_name_c, b.user_email
  10. from sec1117 a, sec1118 b,sec1102 c
  11. where a.user_code = b.user_code
  12. and a.user_code=c.user_code
  13. and a.pic_type = 'B'
  14. and a.system_code = :sys_code
  15. order by a.pic_seq)
  16. where rownum <= 3
  17. '''
  18. with util.get_db_conn() as conn:
  19. res = conn.execute(strsql,sys_code=sys_code)
  20. res = res.fetchall()
  21. if len(res) == 0:
  22. strRes = '無法取得指定系統負責人,請重新輸入'
  23. else:
  24. strRes = sys_code + '負責人是: '
  25. for row in res:
  26. strRes += row[1]+'('+row[2]+'), '
  27. strRes += ' 請問是否幫您將問題轉給系統負責人?'
  28. return util.simple_response(text_content=strRes)
  29. # 取消問題轉達給pic
  30. def cancel_forward(fulfillment):
  31. util.reset_all_contexts(fulfillmentObj=fulfillment)
  32. return util.simple_response(fulfillmentObj={
  33. 'outputContexts': fulfillment.get('queryResult').get('outputContexts')
  34. })
  35. # 確認轉達問題給pic
  36. def confirm_forward(fulfillment):
  37. return util.simple_response(fulfillmentObj={
  38. 'followupEventInput': {
  39. 'name': 'events_forward_issue',
  40. 'languageCode': 'zh-TW',
  41. 'parameters': util.lookup_context(fulfillment, 'system_piclooking_for_pic-followup').get('parameters')
  42. }
  43. })
  44. # 轉達問題給pic
  45. def forward_issue(fulfillment):
  46. params = fulfillment.get('queryResult').get('parameters')
  47. employee_no = params.get('employee_no', '')
  48. ext_no = params.get('ext_no', '')
  49. issue = params.get('issue', '')
  50. sys_code = params.get('sys_code')
  51. # get user name, div, dept information from sec system by employee_no
  52. user_name = 'Richard Shih'
  53. strRes = '好的' + user_name + '已將您的問題 "' + issue + '" 轉達給 ' + sys_code + ' 負責人'
  54. return util.simple_response(text_content=strRes)
  55. def init_app(app):
  56. pass