cd022d85bafb300a4643d6c16d8cf1298f82ea0d.svn-base 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. package cn.com.goldenwater.dcproj.service.impl.meeting;
  2. import cn.com.goldenwater.core.persistence.CrudDao;
  3. import cn.com.goldenwater.core.service.AbstractCrudService;
  4. import cn.com.goldenwater.dcproj.dao.BisInspMeetInvitationDao;
  5. import cn.com.goldenwater.dcproj.dao.BisInspMeetMntsCustomsDao;
  6. import cn.com.goldenwater.dcproj.model.BisInspAllRlationPers;
  7. import cn.com.goldenwater.dcproj.model.BisInspMeetInvitation;
  8. import cn.com.goldenwater.dcproj.param.BisInspMeetInvitationParam;
  9. import cn.com.goldenwater.dcproj.service.BisInspMeetInvitationService;
  10. import cn.com.goldenwater.dcproj.utils.MySSLSocketFactory;
  11. import cn.com.goldenwater.dcproj.utils.gwxy.MeetUtil;
  12. import cn.com.goldenwater.dcproj.utils.gwxy.MeetingReminders;
  13. import com.xylink.util.HttpUtil;
  14. import com.xylink.util.Result;
  15. import net.sf.json.JSONObject;
  16. import org.apache.commons.httpclient.protocol.Protocol;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.beans.factory.annotation.Value;
  19. import org.springframework.stereotype.Service;
  20. import org.springframework.transaction.annotation.Transactional;
  21. import java.io.IOException;
  22. import java.util.*;
  23. @Service
  24. @Transactional
  25. public class BisInspMeetInvitationServiceImpl extends AbstractCrudService<BisInspMeetInvitation, BisInspMeetInvitationParam> implements BisInspMeetInvitationService {
  26. @Autowired
  27. BisInspMeetInvitationDao bisInspMeetInvitationDao;
  28. @Value("${ylink.enterpriseId}")
  29. public String enterpriseId;
  30. @Value("${ylink.token}")
  31. public String token;
  32. @Value("${ylink.ip}")
  33. public String ylinkIp;
  34. @Value("${api.key}")
  35. private String apiKey;
  36. @Value("${api.url}")
  37. private String apiUrl;
  38. @Value("${api.secrect}")
  39. private String apiSecrect;
  40. public BisInspMeetInvitationServiceImpl(BisInspMeetInvitationDao bisInspMeetInvitationDao) {
  41. super(bisInspMeetInvitationDao);
  42. this.bisInspMeetInvitationDao = bisInspMeetInvitationDao;
  43. }
  44. @Override
  45. public int invitation(BisInspMeetInvitationParam bisInspMeetInvitationParam) throws IOException {
  46. Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443);
  47. Protocol.registerProtocol("https", myhttps);
  48. Map<String, Object> jsonEntity = new HashMap<>();
  49. jsonEntity.put("callNumber", bisInspMeetInvitationParam.getCallNumber());
  50. jsonEntity.put("deviceList", bisInspMeetInvitationParam.getDeviceList());
  51. JSONObject json = JSONObject.fromObject(jsonEntity);
  52. String method = "PUT";
  53. String reqPath = ylinkIp + "/api/rest/external/v1/conferenceControl/invitation?enterpriseId=" + enterpriseId;
  54. String requestUriPrefix = ylinkIp + "/api/rest/external/v1/";
  55. String signature = MeetUtil.computeSignature(json.toString(), method, token, reqPath, requestUriPrefix);
  56. reqPath += "&signature=" + signature;
  57. MeetingReminders meetingReminders = new MeetingReminders();
  58. Result result = HttpUtil.getResponse(reqPath, method, json.toString(), meetingReminders.getClass());
  59. if (result.isSuccess()) {
  60. return 0;
  61. } else {
  62. return 6001;
  63. }
  64. }
  65. @Override
  66. public int batchUsersAdd(BisInspMeetInvitationParam bisInspMeetInvitationParam) throws IOException {
  67. Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443);
  68. Protocol.registerProtocol("https", myhttps);
  69. Map<String, Object> jsonEntity = new HashMap<>();
  70. jsonEntity.put("userId", "5f2c5d72676a40baa5d44805720352d8");
  71. jsonEntity.put("name", "王彬");
  72. jsonEntity.put("countryCode", "+86");
  73. jsonEntity.put("phone", "15106845230");
  74. /* jsonEntity.put("dept", "金水公司");*/
  75. JSONObject json = JSONObject.fromObject(jsonEntity);
  76. String method = "POST";
  77. String reqPath = ylinkIp + "/api/rest/external/v1/buffet/user?enterpriseId=" + enterpriseId;
  78. String requestUriPrefix = ylinkIp + "/api/rest/external/v1/";
  79. String signature = MeetUtil.computeSignature(json.toString(), method, token, reqPath, requestUriPrefix);
  80. reqPath += "&signature=" + signature;
  81. MeetingReminders meetingReminders = new MeetingReminders();
  82. Result result = HttpUtil.getResponse(reqPath, method, json.toString(), meetingReminders.getClass());
  83. if (result.isSuccess()) {
  84. return 0;
  85. } else {
  86. return 6001;
  87. }
  88. }
  89. @Override
  90. public int batchUser(BisInspAllRlationPers bisInspAllRlationPers) throws IOException {
  91. Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443);
  92. Protocol.registerProtocol("https", myhttps);
  93. Map<String, Object> jsonEntity = new HashMap<>();
  94. jsonEntity.put("userId", bisInspAllRlationPers.getGuid());
  95. jsonEntity.put("name", bisInspAllRlationPers.getPersName());
  96. jsonEntity.put("countryCode", "+86");
  97. jsonEntity.put("phone", bisInspAllRlationPers.getMobilenumb());
  98. /* jsonEntity.put("dept", "金水公司");*/
  99. JSONObject json = JSONObject.fromObject(jsonEntity);
  100. String method = "POST";
  101. String reqPath = ylinkIp + "/api/rest/external/v1/buffet/user?enterpriseId=" + enterpriseId;
  102. String requestUriPrefix = ylinkIp + "/api/rest/external/v1/";
  103. String signature = MeetUtil.computeSignature(json.toString(), method, token, reqPath, requestUriPrefix);
  104. reqPath += "&signature=" + signature;
  105. MeetingReminders meetingReminders = new MeetingReminders();
  106. Result result = HttpUtil.getResponse(reqPath, method, json.toString(), null);
  107. if (result.isSuccess()) {
  108. return 0;
  109. } else {
  110. return 6001;
  111. }
  112. }
  113. @Override
  114. public int batchUsersDel(BisInspAllRlationPers bisInspAllRlationPers) throws IOException {
  115. Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443);
  116. Protocol.registerProtocol("https", myhttps);
  117. String method = "DELETE";
  118. String requestUriPrefix = ylinkIp + "/api/rest/external/v1/";
  119. String reqPath = ylinkIp + "/api/rest/external/v1/buffet/user?enterpriseId=" + enterpriseId + "&countryCode=86&phone=" + bisInspAllRlationPers.getMobilenumb();
  120. String signature = MeetUtil.computeSignature("", method, token, reqPath, requestUriPrefix);
  121. reqPath += "&signature=" + signature;
  122. Result result = HttpUtil.getResponse(reqPath, method, "", null);
  123. if (result.isSuccess()) {
  124. return 0;
  125. } else {
  126. return 6001;
  127. }
  128. }
  129. @Override
  130. public int batchUsersDelete(BisInspMeetInvitationParam bisInspMeetInvitationParam) throws IOException {
  131. Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443);
  132. Protocol.registerProtocol("https", myhttps);
  133. Map<String, Object> jsonEntity = new HashMap<>();
  134. jsonEntity.put("countryCode", "+86");
  135. jsonEntity.put("phone", "13401079738");
  136. JSONObject json = JSONObject.fromObject(jsonEntity);
  137. String method = "DELETE";
  138. String reqPath = ylinkIp + "/api/rest/external/v1/buffet/user?enterpriseId=" + enterpriseId;
  139. String requestUriPrefix = ylinkIp + "/api/rest/external/v1/";
  140. String signature = MeetUtil.computeSignature(json.toString(), method, token, reqPath, requestUriPrefix);
  141. reqPath += "&signature=" + signature;
  142. MeetingReminders meetingReminders = new MeetingReminders();
  143. Result result = HttpUtil.getResponse(reqPath, method, json.toString(), meetingReminders.getClass());
  144. if (result.isSuccess()) {
  145. return 0;
  146. } else {
  147. return 6001;
  148. }
  149. }
  150. @Override
  151. public int licenseInfo(BisInspMeetInvitationParam bisInspMeetInvitationParam) throws IOException {
  152. Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443);
  153. Protocol.registerProtocol("https", myhttps);
  154. String method = "GET";
  155. String reqPath = ylinkIp + "/api/rest/external/v1/license/info?enterpriseId=" + enterpriseId;
  156. String requestUriPrefix = ylinkIp + "/api/rest/external/v1/";
  157. String signature = MeetUtil.computeSignature("", method, token, reqPath, requestUriPrefix);
  158. reqPath += "&signature=" + signature;
  159. MeetingReminders meetingReminders = new MeetingReminders();
  160. Result result = HttpUtil.getResponse(reqPath, method, "", meetingReminders.getClass());
  161. if (result.isSuccess()) {
  162. return 0;
  163. } else {
  164. return 6001;
  165. }
  166. }
  167. }