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.

55 lines
2.0 KiB

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 confirm_forward(fulfillment):
  31. print(fulfillment)
  32. return util.simple_response(fulfillmentObj={
  33. 'followupEventInput': {
  34. 'name': 'events_forward_issue',
  35. 'languageCode': 'zh-TW',
  36. 'parameters': util.lookup_context(fulfillment, 'system_piclooking_for_pic-followup').get('parameters')
  37. }
  38. })
  39. # 轉達問題給pic
  40. def forward_issue(fulfillment):
  41. params = fulfillment.get('queryResult').get('parameters')
  42. employee_no = params.get('employee_no', '')
  43. ext_no = params.get('ext_no', '')
  44. issue = params.get('issue', '')
  45. sys_code = params.get('sys_code')
  46. # get user name, div, dept information from sec system by employee_no
  47. user_name = 'Richard Shih'
  48. strRes = '好的' + user_name + '已將您的問題 "' + issue + '" 轉達給 ' + sys_code + ' 負責人'
  49. return util.simple_response(text_content=strRes)