package cn.com.goldenwater.dcproj.service.impl.meeting; import cn.com.goldenwater.core.persistence.CrudDao; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.dao.BisInspMeetInvitationDao; import cn.com.goldenwater.dcproj.dao.BisInspMeetMntsCustomsDao; import cn.com.goldenwater.dcproj.model.BisInspAllRlationPers; import cn.com.goldenwater.dcproj.model.BisInspMeetInvitation; import cn.com.goldenwater.dcproj.param.BisInspMeetInvitationParam; import cn.com.goldenwater.dcproj.service.BisInspMeetInvitationService; import cn.com.goldenwater.dcproj.utils.MySSLSocketFactory; import cn.com.goldenwater.dcproj.utils.gwxy.MeetUtil; import cn.com.goldenwater.dcproj.utils.gwxy.MeetingReminders; import com.xylink.util.HttpUtil; import com.xylink.util.Result; import net.sf.json.JSONObject; import org.apache.commons.httpclient.protocol.Protocol; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.IOException; import java.util.*; @Service @Transactional public class BisInspMeetInvitationServiceImpl extends AbstractCrudService implements BisInspMeetInvitationService { @Autowired BisInspMeetInvitationDao bisInspMeetInvitationDao; @Value("${ylink.enterpriseId}") public String enterpriseId; @Value("${ylink.token}") public String token; @Value("${ylink.ip}") public String ylinkIp; @Value("${api.key}") private String apiKey; @Value("${api.url}") private String apiUrl; @Value("${api.secrect}") private String apiSecrect; public BisInspMeetInvitationServiceImpl(BisInspMeetInvitationDao bisInspMeetInvitationDao) { super(bisInspMeetInvitationDao); this.bisInspMeetInvitationDao = bisInspMeetInvitationDao; } @Override public int invitation(BisInspMeetInvitationParam bisInspMeetInvitationParam) throws IOException { Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443); Protocol.registerProtocol("https", myhttps); Map jsonEntity = new HashMap<>(); jsonEntity.put("callNumber", bisInspMeetInvitationParam.getCallNumber()); jsonEntity.put("deviceList", bisInspMeetInvitationParam.getDeviceList()); JSONObject json = JSONObject.fromObject(jsonEntity); String method = "PUT"; String reqPath = ylinkIp + "/api/rest/external/v1/conferenceControl/invitation?enterpriseId=" + enterpriseId; String requestUriPrefix = ylinkIp + "/api/rest/external/v1/"; String signature = MeetUtil.computeSignature(json.toString(), method, token, reqPath, requestUriPrefix); reqPath += "&signature=" + signature; MeetingReminders meetingReminders = new MeetingReminders(); Result result = HttpUtil.getResponse(reqPath, method, json.toString(), meetingReminders.getClass()); if (result.isSuccess()) { return 0; } else { return 6001; } } @Override public int batchUsersAdd(BisInspMeetInvitationParam bisInspMeetInvitationParam) throws IOException { Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443); Protocol.registerProtocol("https", myhttps); Map jsonEntity = new HashMap<>(); jsonEntity.put("userId", "5f2c5d72676a40baa5d44805720352d8"); jsonEntity.put("name", "王彬"); jsonEntity.put("countryCode", "+86"); jsonEntity.put("phone", "15106845230"); /* jsonEntity.put("dept", "金水公司");*/ JSONObject json = JSONObject.fromObject(jsonEntity); String method = "POST"; String reqPath = ylinkIp + "/api/rest/external/v1/buffet/user?enterpriseId=" + enterpriseId; String requestUriPrefix = ylinkIp + "/api/rest/external/v1/"; String signature = MeetUtil.computeSignature(json.toString(), method, token, reqPath, requestUriPrefix); reqPath += "&signature=" + signature; MeetingReminders meetingReminders = new MeetingReminders(); Result result = HttpUtil.getResponse(reqPath, method, json.toString(), meetingReminders.getClass()); if (result.isSuccess()) { return 0; } else { return 6001; } } @Override public int batchUser(BisInspAllRlationPers bisInspAllRlationPers) throws IOException { Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443); Protocol.registerProtocol("https", myhttps); Map jsonEntity = new HashMap<>(); jsonEntity.put("userId", bisInspAllRlationPers.getGuid()); jsonEntity.put("name", bisInspAllRlationPers.getPersName()); jsonEntity.put("countryCode", "+86"); jsonEntity.put("phone", bisInspAllRlationPers.getMobilenumb()); /* jsonEntity.put("dept", "金水公司");*/ JSONObject json = JSONObject.fromObject(jsonEntity); String method = "POST"; String reqPath = ylinkIp + "/api/rest/external/v1/buffet/user?enterpriseId=" + enterpriseId; String requestUriPrefix = ylinkIp + "/api/rest/external/v1/"; String signature = MeetUtil.computeSignature(json.toString(), method, token, reqPath, requestUriPrefix); reqPath += "&signature=" + signature; MeetingReminders meetingReminders = new MeetingReminders(); Result result = HttpUtil.getResponse(reqPath, method, json.toString(), null); if (result.isSuccess()) { return 0; } else { return 6001; } } @Override public int batchUsersDel(BisInspAllRlationPers bisInspAllRlationPers) throws IOException { Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443); Protocol.registerProtocol("https", myhttps); String method = "DELETE"; String requestUriPrefix = ylinkIp + "/api/rest/external/v1/"; String reqPath = ylinkIp + "/api/rest/external/v1/buffet/user?enterpriseId=" + enterpriseId + "&countryCode=86&phone=" + bisInspAllRlationPers.getMobilenumb(); String signature = MeetUtil.computeSignature("", method, token, reqPath, requestUriPrefix); reqPath += "&signature=" + signature; Result result = HttpUtil.getResponse(reqPath, method, "", null); if (result.isSuccess()) { return 0; } else { return 6001; } } @Override public int batchUsersDelete(BisInspMeetInvitationParam bisInspMeetInvitationParam) throws IOException { Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443); Protocol.registerProtocol("https", myhttps); Map jsonEntity = new HashMap<>(); jsonEntity.put("countryCode", "+86"); jsonEntity.put("phone", "13401079738"); JSONObject json = JSONObject.fromObject(jsonEntity); String method = "DELETE"; String reqPath = ylinkIp + "/api/rest/external/v1/buffet/user?enterpriseId=" + enterpriseId; String requestUriPrefix = ylinkIp + "/api/rest/external/v1/"; String signature = MeetUtil.computeSignature(json.toString(), method, token, reqPath, requestUriPrefix); reqPath += "&signature=" + signature; MeetingReminders meetingReminders = new MeetingReminders(); Result result = HttpUtil.getResponse(reqPath, method, json.toString(), meetingReminders.getClass()); if (result.isSuccess()) { return 0; } else { return 6001; } } @Override public int licenseInfo(BisInspMeetInvitationParam bisInspMeetInvitationParam) throws IOException { Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443); Protocol.registerProtocol("https", myhttps); String method = "GET"; String reqPath = ylinkIp + "/api/rest/external/v1/license/info?enterpriseId=" + enterpriseId; String requestUriPrefix = ylinkIp + "/api/rest/external/v1/"; String signature = MeetUtil.computeSignature("", method, token, reqPath, requestUriPrefix); reqPath += "&signature=" + signature; MeetingReminders meetingReminders = new MeetingReminders(); Result result = HttpUtil.getResponse(reqPath, method, "", meetingReminders.getClass()); if (result.isSuccess()) { return 0; } else { return 6001; } } }