PhoneService.java 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package com.telerobot.fs.service;
  2. import com.alibaba.fastjson.JSON;
  3. import com.telerobot.fs.entity.dao.CustmInfoEntity;
  4. import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  5. import org.springframework.jdbc.core.JdbcTemplate;
  6. import org.springframework.stereotype.Service;
  7. import javax.annotation.Resource;
  8. import java.sql.PreparedStatement;
  9. import java.sql.SQLException;
  10. import java.util.List;
  11. @Service
  12. public class PhoneService {
  13. @Resource
  14. private JdbcTemplate jdbcTemplate;
  15. public void batchUpdatePhone(final List<CustmInfoEntity> phoneList) {
  16. String sql = "UPDATE cc_call_phone SET " +
  17. "cust_name = ?, " +
  18. "callstatus = ?, " +
  19. "callout_time = ?, " +
  20. "callcount = ?, " +
  21. "call_end_time = ?, " +
  22. "time_len = ?, " +
  23. "valid_time_len = ?, " +
  24. "uuid = ?, " +
  25. "connected_time = ?, " +
  26. "hangup_cause = ?, " +
  27. "answered_time = ?, " +
  28. "dialogue = ?, " +
  29. "wavfile = ?, " +
  30. "record_server_url = ?, " +
  31. "dialogue_count = ?, " +
  32. "acd_opnum = ?, " +
  33. "acd_queue_time = ?, " +
  34. "acd_wait_time = ?, " +
  35. "empty_number_detection_text = ?, " +
  36. "ivr_dtmf_digits = ?, " +
  37. "manual_answered_time = ?, " +
  38. "manual_answered_time_len = ?, " +
  39. "unconnected_reason = ? " +
  40. "WHERE id = ?";
  41. jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
  42. @Override
  43. public void setValues(PreparedStatement ps, int i) throws SQLException {
  44. CustmInfoEntity cp = phoneList.get(i);
  45. ps.setString(1, cp.getCustName());
  46. ps.setInt(2, cp.getCallstatus());
  47. ps.setLong(3, cp.getCalloutTime());
  48. ps.setInt(4, cp.getCallcount());
  49. ps.setLong(5, cp.getCallEndTime());
  50. ps.setInt(6, cp.getTimeLen());
  51. ps.setInt(7, cp.getValidTimeLen());
  52. ps.setString(8, cp.getUuid());
  53. ps.setLong(9, cp.getConnectedTime());
  54. ps.setString(10, cp.getHangupCause());
  55. ps.setLong(11, cp.getAnsweredTime());
  56. ps.setString(12, JSON.toJSONString(cp.getDialogue()));
  57. ps.setString(13, cp.getWavfile());
  58. ps.setString(14, cp.getRecordServerUrl());
  59. ps.setInt(15, cp.getDialogueCount());
  60. ps.setString(16, cp.getAcdOpnum());
  61. ps.setLong(17, cp.getAcdQueueTime());
  62. ps.setInt(18, cp.getAcdWaitTime());
  63. ps.setString(19, cp.getEmptyNumberDetectionText());
  64. ps.setString(20, cp.getIvrDtmfDigits());
  65. ps.setLong(21, cp.getManualAnsweredTime());
  66. ps.setLong(22, cp.getManualAnsweredTimeLen());
  67. ps.setString(23, cp.getUnconnectedReason());
  68. ps.setString(24, cp.getId()); // WHERE id=?
  69. }
  70. @Override
  71. public int getBatchSize() {
  72. return phoneList.size();
  73. }
  74. });
  75. }
  76. }