From 096ec1a46ef3ef69d72caae96c7709921a5d0fbf Mon Sep 17 00:00:00 2001 From: wanggeng <450292408@qq.com> Date: Wed, 23 Mar 2022 16:46:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=9E=8D=E5=90=88=E9=80=9A?= =?UTF-8?q?=E4=BF=A1=E4=BB=A3=E7=A0=81=E4=B8=8E=E9=85=8D=E7=BD=AE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/ParamsConfigProperties.java | 26 +- .../usercenter/manager/HuaWeiSMCManager.java | 10 +- .../DepartmentDeleteAfterHandlerImpl.java | 6 +- .../impl/DepartmentSaveAfterHandlerImpl.java | 6 +- .../DepartmentUpdateAfterHandlerImpl.java | 6 +- .../impl/GridDeleteAfterHandlerImpl.java | 6 +- .../impl/GridPointDeleteAfterHandlerImpl.java | 6 +- .../impl/GridPointSaveAfterHandlerImpl.java | 6 +- .../GridRelationDeleteAfterHandlerImpl.java | 6 +- .../GridRelationSaveAfterHandlerImpl.java | 8 +- .../kafka/impl/GridSaveAfterHandlerImpl.java | 6 +- .../impl/GridUpdateAfterHandlerImpl.java | 6 +- .../impl/RoleUserDeleteAfterHandlerImpl.java | 5 +- .../impl/RoleUserSaveAfterHandlerImpl.java | 5 +- .../impl/UserUpdateAfterHandlerImpl.java | 6 +- .../impl/UserExpandServiceImpl.java | 44 ++- .../tenlion/usercenter/utils/SMCHttpUtil.java | 261 ++++++++---------- src/main/resources/application-dev.yml | 1 - 18 files changed, 201 insertions(+), 219 deletions(-) diff --git a/src/main/java/cn/com/tenlion/usercenter/config/ParamsConfigProperties.java b/src/main/java/cn/com/tenlion/usercenter/config/ParamsConfigProperties.java index a4a7300..7c1c625 100644 --- a/src/main/java/cn/com/tenlion/usercenter/config/ParamsConfigProperties.java +++ b/src/main/java/cn/com/tenlion/usercenter/config/ParamsConfigProperties.java @@ -1,6 +1,6 @@ package cn.com.tenlion.usercenter.config; -import org.springframework.boot.context.properties.ConfigurationProperties; +import ink.wgink.login.base.manager.ConfigManager; import org.springframework.stereotype.Component; /** @@ -11,34 +11,22 @@ import org.springframework.stereotype.Component; * @Version: 1.0 */ @Component -@ConfigurationProperties(prefix = "params-config") public class ParamsConfigProperties { - private String roleSpecializedPerson; - private String roleGridMember; - private Boolean huaweiSmc; - public String getRoleSpecializedPerson() { - return roleSpecializedPerson == null ? "" : roleSpecializedPerson.trim(); - } - - public void setRoleSpecializedPerson(String roleSpecializedPerson) { - this.roleSpecializedPerson = roleSpecializedPerson; + return ConfigManager.getInstance().getSystemConfigParamsValue("roleSpecializedPerson"); } public String getRoleGridMember() { - return roleGridMember == null ? "" : roleGridMember.trim(); - } - - public void setRoleGridMember(String roleGridMember) { - this.roleGridMember = roleGridMember; + return ConfigManager.getInstance().getSystemConfigParamsValue("roleGridMember"); } public Boolean getHuaweiSmc() { - return huaweiSmc == null ? false : huaweiSmc; + return Boolean.parseBoolean(ConfigManager.getInstance().getSystemConfigParamsValue("huaweiSmc")); } - public void setHuaweiSmc(Boolean huaweiSmc) { - this.huaweiSmc = huaweiSmc; + public Boolean getKafkaActive() { + return Boolean.parseBoolean(ConfigManager.getInstance().getSystemConfigParamsValue("kafkaActive")); } } + diff --git a/src/main/java/cn/com/tenlion/usercenter/manager/HuaWeiSMCManager.java b/src/main/java/cn/com/tenlion/usercenter/manager/HuaWeiSMCManager.java index 44cbb9c..dcadb7b 100644 --- a/src/main/java/cn/com/tenlion/usercenter/manager/HuaWeiSMCManager.java +++ b/src/main/java/cn/com/tenlion/usercenter/manager/HuaWeiSMCManager.java @@ -12,9 +12,13 @@ public class HuaWeiSMCManager { private static final SMCHttpUtil httpUtil = new SMCHttpUtil(); + public static void main(String[] args) throws Exception { + //System.out.println(createMeeting("集宁区-薛志芳", "18648051687123")); + // deleteMeeting("f645ae39-78c7-47d1-83bf-9a2e5af1f6c4"); + } + /** * 删除会议室 - * * @param meetingId 会议室ID * @throws Exception */ @@ -24,8 +28,7 @@ public class HuaWeiSMCManager { /** * 创建会议室 - * - * @param name 昵称 例 : 集宁区-王耿 + * @param name 昵称 例 : 集宁区-王耿 * @param username 账号 手机号 或 英文+数字 * @return {"meetingId":"08d7384a-c784-47ec-93ac-f83c9133e3a8","username":"15655252252","password":"tenlion@123","number":"04744543519341"} * @throws Exception @@ -36,7 +39,6 @@ public class HuaWeiSMCManager { /** * 判断账号是否存在(在创建会议室已经内部校验,无需再调用) - * * @param username * @return * @throws Exception diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentDeleteAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentDeleteAfterHandlerImpl.java index b1c95cb..879a8a5 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentDeleteAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentDeleteAfterHandlerImpl.java @@ -1,11 +1,11 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.department.IDepartmentDeleteAfterHandler; -import ink.wgink.properties.kafka.KafkaCustomProperties; import ink.wgink.util.string.WStringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; @@ -28,11 +28,11 @@ public class DepartmentDeleteAfterHandlerImpl implements IDepartmentDeleteAfterH @Autowired private KafkaTemplate kafkaTemplate; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handle(List departmentIds) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (departmentIds == null || departmentIds.isEmpty()) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentSaveAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentSaveAfterHandlerImpl.java index 34386c4..9ec4013 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentSaveAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentSaveAfterHandlerImpl.java @@ -1,11 +1,11 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.department.IDepartmentSaveAfterHandler; -import ink.wgink.properties.kafka.KafkaCustomProperties; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; @@ -27,11 +27,11 @@ public class DepartmentSaveAfterHandlerImpl implements IDepartmentSaveAfterHandl @Autowired private KafkaTemplate kafkaTemplate; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handle(String departmentId, String departmentParentId, String departmentName, String departmentCode, Integer departmentType, String departmentAreaCode, String departmentAreaName) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (StringUtils.isBlank(departmentId)) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentUpdateAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentUpdateAfterHandlerImpl.java index a390104..4095c81 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentUpdateAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/DepartmentUpdateAfterHandlerImpl.java @@ -1,11 +1,11 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.department.IDepartmentUpdateAfterHandler; -import ink.wgink.properties.kafka.KafkaCustomProperties; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; @@ -27,7 +27,7 @@ public class DepartmentUpdateAfterHandlerImpl implements IDepartmentUpdateAfterH @Autowired private KafkaTemplate kafkaTemplate; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handle(String departmentId, @@ -36,7 +36,7 @@ public class DepartmentUpdateAfterHandlerImpl implements IDepartmentUpdateAfterH Integer departmentType, String departmentAreaCode, String departmentAreaName) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (StringUtils.isBlank(departmentId)) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridDeleteAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridDeleteAfterHandlerImpl.java index bfd7513..57b9c87 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridDeleteAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridDeleteAfterHandlerImpl.java @@ -1,11 +1,11 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.map.IGridDeleteAfterHandler; -import ink.wgink.properties.kafka.KafkaCustomProperties; import ink.wgink.util.string.WStringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; @@ -31,11 +31,11 @@ public class GridDeleteAfterHandlerImpl implements IGridDeleteAfterHandler { @Autowired private KafkaTemplate kafkaTemplate; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handler(List gridIds) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (gridIds.isEmpty()) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointDeleteAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointDeleteAfterHandlerImpl.java index 8131e6f..dcc11d5 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointDeleteAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointDeleteAfterHandlerImpl.java @@ -1,11 +1,11 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.map.IGridPointDeleteAfterHandler; -import ink.wgink.properties.kafka.KafkaCustomProperties; import ink.wgink.util.string.WStringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; @@ -27,11 +27,11 @@ public class GridPointDeleteAfterHandlerImpl implements IGridPointDeleteAfterHan @Autowired private KafkaTemplate kafkaTemplate; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handle(List gridIds) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (gridIds == null || gridIds.isEmpty()) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointSaveAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointSaveAfterHandlerImpl.java index 7be39c3..3d8d4b0 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointSaveAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointSaveAfterHandlerImpl.java @@ -1,5 +1,6 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; @@ -7,7 +8,6 @@ import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.map.IGridPointSaveAfterHandler; import ink.wgink.module.map.pojo.dtos.grid.GridPointDTO; import ink.wgink.module.map.service.grid.IGridPointService; -import ink.wgink.properties.kafka.KafkaCustomProperties; import ink.wgink.util.UUIDUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -33,11 +33,11 @@ public class GridPointSaveAfterHandlerImpl implements IGridPointSaveAfterHandler @Autowired private IGridPointService gridPointService; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handle(String gridId) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (StringUtils.isBlank(gridId)) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationDeleteAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationDeleteAfterHandlerImpl.java index b7a2366..ef74e6e 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationDeleteAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationDeleteAfterHandlerImpl.java @@ -1,11 +1,11 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.map.IGridRelationDeleteAfterHandler; -import ink.wgink.properties.kafka.KafkaCustomProperties; import ink.wgink.util.string.WStringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; @@ -28,11 +28,11 @@ public class GridRelationDeleteAfterHandlerImpl implements IGridRelationDeleteAf @Autowired private KafkaTemplate kafkaTemplate; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handle(List relationIds) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (relationIds.isEmpty()) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationSaveAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationSaveAfterHandlerImpl.java index 79deef1..2ca89f2 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationSaveAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationSaveAfterHandlerImpl.java @@ -1,5 +1,6 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; @@ -8,7 +9,6 @@ import ink.wgink.interfaces.map.IGridRelationSaveAfterHandler; import ink.wgink.module.map.pojo.dtos.grid.GridDTO; import ink.wgink.module.map.service.grid.IGridService; import ink.wgink.pojo.dtos.user.UserDTO; -import ink.wgink.properties.kafka.KafkaCustomProperties; import ink.wgink.service.user.service.IUserService; import ink.wgink.util.string.WStringUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -37,11 +37,11 @@ public class GridRelationSaveAfterHandlerImpl implements IGridRelationSaveAfterH @Autowired private IGridService gridService; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handle(List relationIds) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (relationIds.isEmpty()) { @@ -59,7 +59,7 @@ public class GridRelationSaveAfterHandlerImpl implements IGridRelationSaveAfterH @Override public void handle(UserDTO userDTO) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } List gridDTOs = gridService.listByRelationId(userDTO.getUserId()); diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridSaveAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridSaveAfterHandlerImpl.java index ef7c789..d3c740f 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridSaveAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridSaveAfterHandlerImpl.java @@ -1,11 +1,11 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.map.IGridSaveAfterHandler; -import ink.wgink.properties.kafka.KafkaCustomProperties; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; @@ -27,11 +27,11 @@ public class GridSaveAfterHandlerImpl implements IGridSaveAfterHandler { @Autowired private KafkaTemplate kafkaTemplate; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handle(String gridId, String gridCode, String gridName, String fillColor, String areaCode, String areaName) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (StringUtils.isBlank(gridId)) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridUpdateAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridUpdateAfterHandlerImpl.java index 9f342bd..e174a94 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridUpdateAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridUpdateAfterHandlerImpl.java @@ -1,11 +1,11 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.map.IGridUpdateAfterHandler; -import ink.wgink.properties.kafka.KafkaCustomProperties; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; @@ -30,11 +30,11 @@ public class GridUpdateAfterHandlerImpl implements IGridUpdateAfterHandler { @Autowired private KafkaTemplate kafkaTemplate; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handle(String gridId, String gridName, String fillColor) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (StringUtils.isBlank(gridId)) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserDeleteAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserDeleteAfterHandlerImpl.java index ad3aa67..c57a31f 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserDeleteAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserDeleteAfterHandlerImpl.java @@ -6,7 +6,6 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.role.IRoleUserDeleteAfterHandler; -import ink.wgink.properties.kafka.KafkaCustomProperties; import ink.wgink.util.string.WStringUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -30,12 +29,10 @@ public class RoleUserDeleteAfterHandlerImpl implements IRoleUserDeleteAfterHandl private KafkaTemplate kafkaTemplate; @Autowired private ParamsConfigProperties paramsConfigProperties; - @Autowired - private KafkaCustomProperties kafkaCustomProperties; @Override public void handle(String roleId, List userIds) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (StringUtils.isBlank(roleId)) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserSaveAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserSaveAfterHandlerImpl.java index 86f7c33..83e8a86 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserSaveAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserSaveAfterHandlerImpl.java @@ -8,7 +8,6 @@ import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.role.IRoleUserSaveAfterHandler; -import ink.wgink.properties.kafka.KafkaCustomProperties; import ink.wgink.service.role.service.IRoleUserService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -37,12 +36,10 @@ public class RoleUserSaveAfterHandlerImpl implements IRoleUserSaveAfterHandler { private IUserExpandService userExpandService; @Autowired private ParamsConfigProperties paramsConfigProperties; - @Autowired - private KafkaCustomProperties kafkaCustomProperties; @Override public void handle(String roleId, List userIds) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (StringUtils.isBlank(roleId)) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/UserUpdateAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/UserUpdateAfterHandlerImpl.java index 1d809ed..f5d7757 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/UserUpdateAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/UserUpdateAfterHandlerImpl.java @@ -1,12 +1,12 @@ package cn.com.tenlion.usercenter.service.kafka.impl; +import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.user.IUserUpdateAfterHandler; import ink.wgink.pojo.dtos.user.UserDTO; -import ink.wgink.properties.kafka.KafkaCustomProperties; import ink.wgink.service.user.service.IUserService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -31,11 +31,11 @@ public class UserUpdateAfterHandlerImpl implements IUserUpdateAfterHandler { @Autowired private IUserService userService; @Autowired - private KafkaCustomProperties kafkaCustomProperties; + private ParamsConfigProperties paramsConfigProperties; @Override public void handle(String userId) throws SystemException { - if (!kafkaCustomProperties.getActive()) { + if (!paramsConfigProperties.getKafkaActive()) { return; } if (StringUtils.isBlank(userId)) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java index fd22854..b91d342 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java @@ -64,7 +64,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx @Autowired private IMongoDataService mongoDataService; private static final String SMC_STATE_DELETE = "delete"; - private static final String SMC_STATE_ADD = "add"; + private static final String SMC_STATE_BIND = "bind"; @Override public String getRoute() { @@ -188,21 +188,20 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx return; } LOG.debug("user expand properties doesn't exist, add SMC, call SMC createMeeting"); - UserDTO userDTO = userBaseService.get(userId); - SMCMeetingDTO meeting = HuaWeiSMCManager.createMeeting(userDTO.getUserName(), userDTO.getUserUsername()); - LOG.debug("meeting: {}", meeting); - params.put("smcMeetingId", meeting.getMeetingId()); - params.put("smcUsername", meeting.getUsername()); - params.put("smcPassword", ISmartCityUserCenterConsts.HUAWEI_SMC_DEFAULT_PASSWORD); - params.put("smcNumber", meeting.getNumber()); + setSMCMeeting(userId, params); return; } - if (StringUtils.equals(SMC_STATE_ADD, smcState) && !StringUtils.isBlank(userExpandPO.getSmcMeetingId())) { - LOG.debug("have account,add SMC,no handle"); - params.put("smcMeetingId", userExpandPO.getSmcMeetingId()); - params.put("smcUsername", userExpandPO.getSmcUsername()); - params.put("smcPassword", userExpandPO.getSmcPassword()); - params.put("smcNumber", userExpandPO.getSmcNumber()); + if (StringUtils.equals(SMC_STATE_BIND, smcState)) { + if (StringUtils.isBlank(userExpandPO.getSmcMeetingId())) { + LOG.debug("user expand properties doesn't have meetingId, create."); + setSMCMeeting(userId, params); + } else { + LOG.debug("have account,add SMC,no handle"); + params.put("smcMeetingId", userExpandPO.getSmcMeetingId()); + params.put("smcUsername", userExpandPO.getSmcUsername()); + params.put("smcPassword", userExpandPO.getSmcPassword()); + params.put("smcNumber", userExpandPO.getSmcNumber()); + } } if (StringUtils.equals(SMC_STATE_DELETE, smcState) && !StringUtils.isBlank(userExpandPO.getSmcMeetingId())) { LOG.debug("have account,delete SMC,call SMS deleteMeeting"); @@ -210,6 +209,23 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx } } + /** + * 设置SMC会议信息 + * + * @param userId + * @param params + * @throws Exception + */ + private void setSMCMeeting(String userId, Map params) throws Exception { + UserDTO userDTO = userBaseService.get(userId); + SMCMeetingDTO meeting = HuaWeiSMCManager.createMeeting(userDTO.getUserName(), userDTO.getUserUsername()); + LOG.debug("meeting: {}", meeting); + params.put("smcMeetingId", meeting.getMeetingId()); + params.put("smcUsername", meeting.getUsername()); + params.put("smcPassword", ISmartCityUserCenterConsts.HUAWEI_SMC_DEFAULT_PASSWORD); + params.put("smcNumber", meeting.getNumber()); + } + @Override public UserExpandPO getPO(String userId) { Map params = getHashMap(2); diff --git a/src/main/java/cn/com/tenlion/usercenter/utils/SMCHttpUtil.java b/src/main/java/cn/com/tenlion/usercenter/utils/SMCHttpUtil.java index 02c23b7..ab7e707 100644 --- a/src/main/java/cn/com/tenlion/usercenter/utils/SMCHttpUtil.java +++ b/src/main/java/cn/com/tenlion/usercenter/utils/SMCHttpUtil.java @@ -4,16 +4,12 @@ import cn.com.tenlion.usercenter.pojo.dtos.huawei.MeetingCreateDTO; import cn.com.tenlion.usercenter.pojo.dtos.huawei.SMCMeetingDTO; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import org.apache.commons.codec.binary.Base64; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; import javax.net.ssl.*; import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; -import java.nio.charset.Charset; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; @@ -35,26 +31,20 @@ import java.util.Map.Entry; * @date 2019年6月19日 */ public class SMCHttpUtil { - private static final CloseableHttpClient httpclient = HttpClients.createDefault(); - /** - * 请求超时时间 - */ - private static Integer TIMEOUT = 3000; - private static final String getTokenUrl = "https://10.1.18.2/sys-portal/tokens";// 登陆 - private static final String checkMeetingUrl = "https://10.1.18.2/sys-portal/terminalparams/search";// 会议室终端是否存在 - private static final String getMeetingNumberUrl = "https://10.1.18.2/sys-portal/terminalparams";// 获取随机分配的会议终端号码 - private static final String createMeetingUrl = "https://10.1.18.2/sys-portal/meetingrooms/create";// 创建会议室 - private static final String deleteMeetingUrl = "https://10.1.18.2/sys-portal/meetingrooms/batch";// 删除会议室 - private static final String username = "shiyuzhili"; - private static final String password = "Syzl@2022wlcb"; - private static String token = ""; - private static long tokenTimeOut = 0L; + /** 请求超时时间 */ + private static Integer TIMEOUT = 3000; + private static final String checkMeetingUrl = "https://10.25.248.213/sys-portal/terminalparams/search"; // 会议室终端是否存在 + private static final String checkMeetingNameUrl = "https://10.25.248.213/sys-portal/meetingrooms/search/name"; // 会议室名称是否存在 + private static final String getMeetingNumberUrl = "https://10.25.248.213/sys-portal/terminalparams"; // 获取随机分配的会议终端号码 + private static final String createMeetingUrl = "https://10.25.248.213/sys-portal/meetingrooms/create"; // 创建会议室 + private static final String deleteMeetingUrl = "https://10.25.248.213/sys-portal/meetingrooms/batch"; // 删除会议室 static { try { trustAllHttpsCertificates(); HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { + @Override public boolean verify(String urlHostName, SSLSession session) { return true; } @@ -71,7 +61,7 @@ public class SMCHttpUtil { HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } - private static class TrustAllManager implements X509TrustManager { + public static class TrustAllManager implements X509TrustManager { public X509Certificate[] getAcceptedIssuers() { return null; } @@ -85,39 +75,42 @@ public class SMCHttpUtil { /** * 删除会议室 - * * @param meetingId 会议室ID * @return * @throws Exception */ - public static void deleteMeeting(String meetingId) throws Exception { - List> list = new ArrayList>(); - Map param = new HashMap(); + public void deleteMeeting(String meetingId) throws Exception { + List> list = new ArrayList>(); + Map param = new HashMap(); param.put("id", meetingId); list.add(param); String json = JSONObject.toJSONString(list); String result = doJson(deleteMeetingUrl, "DELETE", json); - if (result.contains("error")) { + if(result.contains("error")) { throw new Exception("删除会议室失败"); } } /** * 创建会议室 - * - * @param name 名称 (例 : 集宁区-张三丰) + * @param name 名称 (例 : 集宁区-张三丰) * @param username 账号 * @return * @throws Exception */ - public static SMCMeetingDTO createMeeting(String name, String username) throws Exception { + public SMCMeetingDTO createMeeting(String name, String username) throws Exception { Map params = new HashMap(); params.put("name", username); // 判断是否已存在 Boolean exists = checkMeetingExists(username); - if (exists) { + if(exists) { throw new Exception("该账号已存在会议室"); } + // 判断是否已存在 +// Boolean nameExists = checkMeetingNameExists(name); +// if(nameExists) { +// throw new Exception("该名称已存在会议室"); +// } // 获取随机的会议终端号码 String meetingNumber = getMeetingNumber(); String number = "0474" + meetingNumber; @@ -131,26 +124,32 @@ public class SMCHttpUtil { create.setTerminalParam(paramBean); String json = JSONObject.toJSONString(create); - String result = doJson(createMeetingUrl, "POST", json); - SMCMeetingDTO dto = new SMCMeetingDTO(); - JSONObject resultObject = JSONObject.parseObject(result); - dto.setMeetingId(resultObject.getString("id")); - dto.setNumber(number); - dto.setUsername(username); - return dto; + try { + String result = doJson(createMeetingUrl, "POST", json); + if(result.contains("MEETINGROOM_NAME_EXIST")) { + throw new Exception("该名称已存在会议室"); + } + SMCMeetingDTO dto = new SMCMeetingDTO(); + JSONObject resultObject = JSONObject.parseObject(result); + dto.setMeetingId(resultObject.getString("id")); + dto.setNumber(number); + dto.setUsername(username); + return dto; + }catch (Exception e) { + throw e; + } } /** * 获取随机的会议终端号码 - * * @return */ - private static String getMeetingNumber() throws Exception { + private String getMeetingNumber() throws Exception { Map params = new HashMap(); - params.put("zoneid", "06e26a21-36b9-47e9-aabd-944eb7a33e23"); + // params.put("zoneid", "06e26a21-36b9-47e9-aabd-944eb7a33e23"); params.put("number", 1); // 数量 String result = doPost(getMeetingNumberUrl, params, null); - if (result.contains("error")) { + if(result.contains("error")) { throw new Exception("获取随机的会议终端号失败"); } JSONArray jsonArray = JSONObject.parseArray(result); @@ -159,10 +158,9 @@ public class SMCHttpUtil { /** * 验证会议室是否已经存在 - * * @return */ - public static Boolean checkMeetingExists(String username) throws Exception { + public Boolean checkMeetingExists(String username) throws Exception { Map params = new HashMap(); params.put("name", username); params.put("accountType", "SMC"); @@ -170,47 +168,56 @@ public class SMCHttpUtil { return Boolean.parseBoolean(result); } - private static String getHeader() { - String auth = username + ":" + password; - byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII"))); - String authHeader = "Basic " + new String(encodedAuth); - return authHeader; + /** + * 验证会议室是否已经存在 + * @return + */ + public Boolean checkMeetingNameExists(String name) throws Exception { + Map params = new HashMap(); + params.put("name", name); + String result = doGet(checkMeetingNameUrl, params, null); + return Boolean.parseBoolean(result); } - - private static void flashToken() throws Exception { - // Token30秒后到期, 则更新 - if (tokenTimeOut == 0 || System.currentTimeMillis() + 30000 > tokenTimeOut) { - Map property = new HashMap(); - property.put("Authorization", getHeader()); - String result = doInitToken(getTokenUrl, null, property); - if (result.contains("uuid")) { - JSONObject object = JSONObject.parseObject(result); - String uuid = object.getString("uuid"); - String expire = object.getString("expire"); - token = uuid; - tokenTimeOut = Long.parseLong(expire); - } else { - throw new Exception("获取融合通信Token失败"); - } - } - } +// private static String getHeader() { +// String auth = username + ":" + password; +// byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII"))); +// String authHeader = "Basic " + new String(encodedAuth); +// return authHeader; +// } +// +// +// private static void flashToken() throws Exception { +// // Token30秒后到期, 则更新 +// if(tokenTimeOut == 0 || System.currentTimeMillis() + 30000 > tokenTimeOut) { +// Map property = new HashMap(); +// property.put("Authorization", getHeader()); +// String result = doInitToken(getTokenUrl, null, property); +// if(result.contains("uuid")) { +// JSONObject object = JSONObject.parseObject(result); +// String uuid = object.getString("uuid"); +// String expire = object.getString("expire"); +// token = uuid; +// tokenTimeOut = Long.parseLong(expire); +// }else { +// throw new Exception("获取融合通信Token失败"); +// } +// } +// } /** * jsonPost请求 - * - * @param @param postUrl - * @param @param json + * @Description: TODO + * @param @param postUrl + * @param @param json * @param @return * @return String * @throws - * @Description: TODO * @author 崔宝铖 * @date 2019年6月19日 */ private static String doJson(String postUrl, String type, String json) throws Exception { - flashToken(); OutputStream out = null; BufferedReader br = null; String response = "";// 响应内容 @@ -222,10 +229,11 @@ public class SMCHttpUtil { HttpURLConnection httpUrlConnection = (HttpURLConnection) restUrl.openConnection(); // 设置请求方式为 POST httpUrlConnection.setRequestMethod(type); - httpUrlConnection.setRequestProperty("token", token); - httpUrlConnection.setRequestProperty("Connection", "keep-Alive"); + httpUrlConnection.setRequestProperty("X-HW-ID", "697db861-bc1b-4e31-bc75-969e1ab5a9a5"); + httpUrlConnection.setRequestProperty("X-HW-APPKEY", "H!UkcRIWb/lI1034/w5T3h%c5..4#8.+L-085%g!3Kq$w.vg3w$QD0!%i#nqE=83"); + httpUrlConnection.setRequestProperty("Connection","keep-Alive"); //设置发送文件类型 - httpUrlConnection.setRequestProperty("Content-Type", "application/json"); + httpUrlConnection.setRequestProperty("Content-Type","application/json"); // 输入 输出 都打开 httpUrlConnection.setDoOutput(true); httpUrlConnection.setDoInput(true); @@ -236,56 +244,47 @@ public class SMCHttpUtil { out.write(json.getBytes()); out.flush(); // 读取数据 - br = new BufferedReader(new InputStreamReader(httpUrlConnection.getInputStream(), "utf-8")); + br = new BufferedReader(new InputStreamReader(httpUrlConnection.getInputStream(),"utf-8")); String line = null; - while (null != (line = br.readLine())) { + while (null != (line=br.readLine())){ response += line; } // 获得URL的响应状态码 status = new Integer(httpUrlConnection.getResponseCode()).toString(); } catch (Exception e) { e.printStackTrace(); - } finally { + }finally { try { - if (out != null) { - out.close(); - } - if (br != null) { - br.close(); - } + if (out != null) { out.close();} + if (br != null) {br.close();} } catch (Exception ex) { ex.printStackTrace(); } } - if (!status.startsWith("2")) { + if(!status.startsWith("2")) { System.out.println(response); throw new Exception("请求结果状态不是200"); } - if (response.contains("error")) { - System.out.println(response); - throw new Exception("请求出现错误"); - } return response; } /** * Post请求 - * - * @param @param postUrl - * @param @param param + * @Description: TODO + * @param @param postUrl + * @param @param param * @param @return * @return String * @throws IOException * @throws - * @Description: TODO * @author 崔宝铖 * @date 2019年6月19日 */ - private static String doPost(String postUrl, Map param, JSONObject jsonObject) throws Exception { - flashToken(); + private static String doPost(String postUrl, Map param, JSONObject jsonObject) throws Exception { // 封装发送的请求参数 StringBuffer buffer = new StringBuffer(); - if (param != null) { + if(param != null) { + buffer.append("?"); int x = 0; for (Entry map : param.entrySet()) { buffer.append(map.getKey()).append("=").append(map.getValue().toString()); @@ -295,12 +294,13 @@ public class SMCHttpUtil { x++; } } - URL url = new URL(postUrl); + URL url = new URL(postUrl + buffer.toString()); URLConnection urlConnection = url.openConnection(); HttpURLConnection httpUrlConnection = (HttpURLConnection) urlConnection; httpUrlConnection.setConnectTimeout(TIMEOUT); // 设置请求头属性参数 - httpUrlConnection.setRequestProperty("token", token); + httpUrlConnection.setRequestProperty("X-HW-ID", "697db861-bc1b-4e31-bc75-969e1ab5a9a5"); + httpUrlConnection.setRequestProperty("X-HW-APPKEY", "H!UkcRIWb/lI1034/w5T3h%c5..4#8.+L-085%g!3Kq$w.vg3w$QD0!%i#nqE=83"); httpUrlConnection.setRequestProperty("charset", "UTF-8"); httpUrlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); httpUrlConnection.setRequestProperty("accept", "application/json"); @@ -311,14 +311,14 @@ public class SMCHttpUtil { String status = "";// 响应状态 PrintWriter out = null; BufferedReader in = null; - try { + try{ // 获取URLConnection对象对应的输出流 out = new PrintWriter(httpUrlConnection.getOutputStream()); // 发送请求参数 - if (buffer.toString().length() > 0) { + if(buffer.toString().length() > 0) { out.write(buffer.toString()); } - if (jsonObject != null) { + if(jsonObject != null) { String json = java.net.URLEncoder.encode(jsonObject.toString(), "utf-8"); out.write(json); } @@ -333,67 +333,56 @@ public class SMCHttpUtil { } // 获得URL的响应状态码 status = new Integer(httpUrlConnection.getResponseCode()).toString(); - } catch (Exception e) { + }catch(Exception e) { e.printStackTrace(); - } finally { + }finally { try { - if (out != null) { - out.close(); - } - if (in != null) { - in.close(); - } + if (out != null) { out.close();} + if (in != null) {in.close();} } catch (Exception ex) { ex.printStackTrace(); } } - if (!status.startsWith("2")) { + if(!status.startsWith("2")) { System.out.println(response); throw new Exception("请求结果状态不是200"); } - if (response.contains("error")) { - System.out.println(response); - throw new Exception("请求出现错误"); - } return response; } /** * Get请求 - * - * @param @param getUrl 请求地址 - * @param @param param 请求参数 + * @Description: TODO + * @param @param getUrl 请求地址 + * @param @param param 请求参数 * @param @return * @param @throws Exception * @return RetBody * @throws - * @Description: TODO * @author 崔宝铖 * @date 2019年6月19日 */ - private static String doGet(String getUrl, Map param, Map property) throws Exception { - flashToken(); + private static String doGet(String getUrl, Map param, Map property) throws Exception { return doInitToken(getUrl, param, property); } /** * 初始化Token - * * @param getUrl * @param param * @param property * @return * @throws Exception */ - private static String doInitToken(String getUrl, Map param, Map property) throws Exception { + private static String doInitToken(String getUrl, Map param, Map property) throws Exception { // 封装发送的请求参数 StringBuffer buffer = new StringBuffer(); - if (param != null) { + if(param != null) { buffer.append("?"); int x = 0; - for (Entry map : param.entrySet()) { + for(Entry map : param.entrySet()) { buffer.append(map.getKey()).append("=").append(map.getValue().toString()); - if (x != param.size() - 1) { + if(x != param.size()-1) { buffer.append("&"); } x++; @@ -401,15 +390,16 @@ public class SMCHttpUtil { } String urlPath = getUrl + buffer.toString(); URL url = new URL(urlPath); - URLConnection urlConnection = url.openConnection(); + URLConnection urlConnection = url.openConnection(); HttpURLConnection httpUrlConnection = (HttpURLConnection) urlConnection; httpUrlConnection.setConnectTimeout(TIMEOUT); // 设置请求头属性参数 - httpUrlConnection.setRequestProperty("token", token); + httpUrlConnection.setRequestProperty("X-HW-ID", "697db861-bc1b-4e31-bc75-969e1ab5a9a5"); + httpUrlConnection.setRequestProperty("X-HW-APPKEY", "H!UkcRIWb/lI1034/w5T3h%c5..4#8.+L-085%g!3Kq$w.vg3w$QD0!%i#nqE=83"); httpUrlConnection.setRequestProperty("charset", "UTF-8"); httpUrlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); httpUrlConnection.setRequestProperty("accept", "application/json"); - if (property != null) { + if(property != null) { for (Entry map : property.entrySet()) { httpUrlConnection.setRequestProperty(map.getKey(), map.getValue()); } @@ -418,7 +408,7 @@ public class SMCHttpUtil { String status = "";// 响应状态6 PrintWriter out = null; BufferedReader in = null; - try { + try{ // httpUrlConnection.connect(); // 定义BufferedReader输入流来读取URL的响应数据 in = new BufferedReader(new InputStreamReader(httpUrlConnection.getInputStream(), "UTF-8")); @@ -428,28 +418,21 @@ public class SMCHttpUtil { } // 获得URL的响应状态码 status = new Integer(httpUrlConnection.getResponseCode()).toString(); - } catch (Exception e) { + }catch(Exception e) { e.printStackTrace(); - } finally { + }finally { try { - if (out != null) { - out.close(); - } - if (in != null) { - in.close(); - } + if (out != null) { out.close();} + if (in != null) {in.close();} } catch (Exception ex) { ex.printStackTrace(); } } - if (!status.startsWith("2")) { + if(!status.startsWith("2")) { System.out.println(response); throw new Exception("请求结果状态不是200"); } - if (response.contains("error")) { - System.out.println(response); - throw new Exception("请求出现错误"); - } return response; } + } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 731f020..856a2d5 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -68,7 +68,6 @@ spring: max-idle: 8 min-idle: 0 kafka: - active: false bootstrap-servers: 192.168.0.103:9092 producer: # 写入失败时,重试次数。当leader节点失效,一个repli节点会替代成为leader节点,此时可能出现写入失败,