From edc9e0871122a968365b788bbd2f7d5b461d3fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=8D=9A?= Date: Tue, 19 Nov 2024 14:13:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E=E9=9D=92=E6=A1=94=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=BB=84=E5=8F=8A=E8=AE=BE=E5=A4=87=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/annotation/Snowflake.java | 11 ---- .../common/config/MybatisPlusConfig.java | 1 - .../common/handler/SnowflakeHandler.java | 16 ----- .../job/task/TerminalListSyncTask.java | 59 +++++++++++++++++++ .../mobile/controler/DeviceController.java | 41 ++++++++++++- .../controler/DeviceGroupController.java | 51 ++++++++++++++-- .../modules/mobile/entity/MobileContact.java | 5 +- .../mobile/entity/MobileDeviceGroup.java | 2 + .../ten/controller/TenPersonController.java | 16 ++++- .../service/impl/TenPersonServiceImpl.java | 13 ++++ 10 files changed, 177 insertions(+), 38 deletions(-) delete mode 100644 shapelight-admin/src/main/java/net/shapelight/common/annotation/Snowflake.java delete mode 100644 shapelight-admin/src/main/java/net/shapelight/common/handler/SnowflakeHandler.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/job/task/TerminalListSyncTask.java diff --git a/shapelight-admin/src/main/java/net/shapelight/common/annotation/Snowflake.java b/shapelight-admin/src/main/java/net/shapelight/common/annotation/Snowflake.java deleted file mode 100644 index 7182f36..0000000 --- a/shapelight-admin/src/main/java/net/shapelight/common/annotation/Snowflake.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.shapelight.common.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Snowflake { -} \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java b/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java index 45de5e8..9a082f2 100644 --- a/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java +++ b/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java @@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import net.shapelight.common.handler.CustomizeTableNameHandler; -import net.shapelight.common.handler.SnowflakeHandler; import net.shapelight.common.handler.TimeHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/shapelight-admin/src/main/java/net/shapelight/common/handler/SnowflakeHandler.java b/shapelight-admin/src/main/java/net/shapelight/common/handler/SnowflakeHandler.java deleted file mode 100644 index 6a26cd9..0000000 --- a/shapelight-admin/src/main/java/net/shapelight/common/handler/SnowflakeHandler.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.shapelight.common.handler; - -import net.shapelight.common.utils.SnowflakeIdWorker; -import org.apache.ibatis.plugin.Interceptor; -import org.apache.ibatis.plugin.Invocation; - -public class SnowflakeHandler implements Interceptor { - @Override - public Object intercept(Invocation invocation) throws Throwable { - SnowflakeIdWorker snowflakeIdWorker = new SnowflakeIdWorker(); - Object target = invocation.getTarget(); - // 检查字段并生成 ID 的逻辑... - target = snowflakeIdWorker.nextId(); - return invocation.proceed(); - } -} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/job/task/TerminalListSyncTask.java b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/TerminalListSyncTask.java new file mode 100644 index 0000000..798aa1f --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/TerminalListSyncTask.java @@ -0,0 +1,59 @@ +package net.shapelight.modules.job.task; + +import com.alibaba.fastjson.JSONObject; +import net.shapelight.modules.fegin.OpFeignClient; +import net.shapelight.modules.job.entity.KeysEntity; +import net.shapelight.modules.mobile.entity.MobileDeviceGroup; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +@Component +public class TerminalListSyncTask implements ITask { + @Autowired + private OpFeignClient feignClient; + + @Value("${global.qingju.accountNumber}") + String accountNumber; + @Value("${global.qingju.empowerKey}") + String empowerKey; + + @Override + public void run(String params) throws Exception { + syncTerminal(); + syncTerminalGroup(); + } + + public void syncTerminalGroup() throws Exception { + Map params = new HashMap(); + params.put("accountNumber", accountNumber); + params.put("empowerKey", empowerKey); + params.put("operation", "ghTerminalGroupGetList"); + params.put("passKey", KeysEntity.passKey); + Map queryParams = feignClient.getData(params); + queryParams.put("otherSchoolCode", "xtzg"); + params.put("queryParams",queryParams); + JSONObject jsonObject = feignClient.getData(params); + if(jsonObject.getString("shrgStatus").equals("S")) { + jsonObject.getJSONArray("list").forEach(item -> { + MobileDeviceGroup mdg = new MobileDeviceGroup(); + //mdg.setOpenId() + }); + } + } + + public void syncTerminal() throws Exception { + Map params = new HashMap(); + params.put("accountNumber", accountNumber); + params.put("empowerKey", empowerKey); + params.put("operation", "ghTerminalGetList"); + params.put("passKey", KeysEntity.passKey); + Map queryParams = feignClient.getData(params); + queryParams.put("otherSchoolCode", "xtzg"); + params.put("queryParams",queryParams); + feignClient.getData(params); + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceController.java b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceController.java index b721647..d047089 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceController.java @@ -1,5 +1,8 @@ package net.shapelight.modules.mobile.controler; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -9,15 +12,23 @@ import net.shapelight.common.handler.CustomizeTableNameHandler; import net.shapelight.common.utils.PageUtils; import net.shapelight.common.utils.R; import net.shapelight.common.utils.SnowflakeIdWorker; +import net.shapelight.modules.fegin.OpFeignClient; +import net.shapelight.modules.job.entity.KeysEntity; import net.shapelight.modules.mobile.dto.mobileDevice.MobileDeviceAddDto; import net.shapelight.modules.mobile.dto.mobileDevice.MobileDeviceQueryDto; import net.shapelight.modules.mobile.entity.MobileDevice; +import net.shapelight.modules.mobile.entity.MobileDeviceGroup; import net.shapelight.modules.mobile.service.MobileDeviceService; import net.shapelight.modules.sys.controller.AbstractController; +import net.shapelight.modules.ten.entity.TenUserScopeEntity; +import net.shapelight.modules.ten.service.impl.TenUserScopeServiceImpl; import org.apache.ibatis.annotations.Delete; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,6 +39,15 @@ public class DeviceController extends AbstractController { @Autowired MobileDeviceService mobileDeviceService; + @Autowired + private OpFeignClient feignClient; + + @Value("${global.qingju.accountNumber}") + String accountNumber; + @Value("${global.qingju.empowerKey}") + String empowerKey; + @Autowired + private TenUserScopeServiceImpl tenUserScopeService; @GetMapping("list") @@ -58,9 +78,26 @@ public class DeviceController extends AbstractController { mobileDeviceQueryDto.setName(name); mobileDeviceQueryDto.setGroupId(groupId); mobileDeviceQueryDto.setApkVersion(apkVersion); + Map params = new HashMap(); + params.put("accountNumber", accountNumber); + params.put("empowerText", KeysEntity.empowerText); + params.put("operation", "ghTerminalGroupGetList"); + params.put("passKey", KeysEntity.passKey); + Map queryParams = new HashMap<>(); + TenUserScopeEntity tenUserScopeEntity = tenUserScopeService.getOne(new LambdaQueryWrapper().eq(TenUserScopeEntity::getUserId,getUserId())); + queryParams.put("otherSchoolCode", tenUserScopeEntity.getCellId().toString()); + params.put("queryParams",queryParams); + JSONObject jsonObject = feignClient.getData(params); + if(jsonObject.getString("shrgStatus").equals("S")) { + JSONArray list = jsonObject.getJSONArray("list"); + int totalSize = list.size(); + long start = (page-1) * size; + long end = Math.min((page) * size, totalSize); + return R.ok().put("data",list.subList(Math.toIntExact(start), Math.toIntExact(end))); + } - - return R.ok().put("data", mobileDeviceService.list(mobileDeviceQueryDto)); + //return R.ok().put("data", mobileDeviceService.list(mobileDeviceQueryDto)); + return R.error().put("data","获取公话组失败"); } @PostMapping("add") diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceGroupController.java b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceGroupController.java index 4fae63f..42031de 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceGroupController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceGroupController.java @@ -1,5 +1,8 @@ package net.shapelight.modules.mobile.controler; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -9,26 +12,41 @@ import net.shapelight.common.utils.BeanUtils; //import net.shapelight.common.utils.ExcelUtils; import net.shapelight.common.utils.ExcelUtils; import net.shapelight.common.utils.R; +import net.shapelight.modules.fegin.OpFeignClient; +import net.shapelight.modules.job.entity.KeysEntity; import net.shapelight.modules.mobile.dto.mobileDeviceGroup.MobileDeviceGruopQueryDto; import net.shapelight.modules.mobile.dto.mobileDeviceGroup.MobileDeviceGroupAddDto; import net.shapelight.modules.mobile.service.MobileDeviceGroupService; import net.shapelight.modules.mobile.vo.mobileDeviceGroup.MobileDeviceGroupVo; +import net.shapelight.modules.sys.controller.AbstractController; +import net.shapelight.modules.ten.entity.TenUserScopeEntity; +import net.shapelight.modules.ten.service.impl.TenUserScopeServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; @RestController @RequestMapping("mobile/device/group/") @Api(value = "话机设备组管理",tags = "话机设备组管理") @RequiredArgsConstructor -public class DeviceGroupController { +public class DeviceGroupController extends AbstractController { private final MobileDeviceGroupService mobileDeviceGroupService; + @Autowired + private OpFeignClient feignClient; + + @Value("${global.qingju.accountNumber}") + String accountNumber; + @Value("${global.qingju.empowerKey}") + String empowerKey; + @Autowired + private TenUserScopeServiceImpl tenUserScopeService; + @GetMapping("list") @ApiOperation("话机设备组列表") @ApiImplicitParams({ @@ -48,7 +66,30 @@ public class DeviceGroupController { mobileDeviceGruopQueryDto.setGroupId(groupId); mobileDeviceGruopQueryDto.setStatus(status); - return R.ok().put("data", mobileDeviceGroupService.list(mobileDeviceGruopQueryDto)); + Map params = new HashMap(); + params.put("accountNumber", accountNumber); + params.put("empowerText", KeysEntity.empowerText); + params.put("operation", "ghTerminalGetList"); + params.put("passKey", KeysEntity.passKey); + Map queryParams = new HashMap<>(); + TenUserScopeEntity tenUserScopeEntity = tenUserScopeService.getOne(new LambdaQueryWrapper().eq(TenUserScopeEntity::getUserId,getUserId())); + queryParams.put("otherSchoolCode", tenUserScopeEntity.getCellId().toString()); + params.put("queryParams",queryParams); + queryParams.put("otherSchoolCode", tenUserScopeEntity.getCellId()); + params.put("queryParams",queryParams); + JSONObject jsonObject = feignClient.getData(params); + if(jsonObject.getString("shrgStatus").equals("S")) { + JSONArray list = jsonObject.getJSONArray("list"); + int totalSize = list.size(); + long start = (page-1) * size; + long end = Math.min(page * size, totalSize); + return R.ok().put("data",list.subList(Math.toIntExact(start), Math.toIntExact(end))); + } + + //return R.ok().put("data", mobileDeviceService.list(mobileDeviceQueryDto)); + return R.error().put("data","获取话机列表失败"); + + //return R.ok().put("data", mobileDeviceGroupService.list(mobileDeviceGruopQueryDto)); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileContact.java b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileContact.java index f051291..8ec209d 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileContact.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileContact.java @@ -7,11 +7,12 @@ import java.io.Serializable; import java.util.Date; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import net.shapelight.common.annotation.Snowflake; import org.hibernate.validator.constraints.Length; /** @@ -28,7 +29,7 @@ public class MobileContact implements Serializable { */ @NotNull(message="[联系人ID]不能为空") @ApiModelProperty("联系人ID") - @Snowflake + @TableId(type = IdType.ASSIGN_ID) private Long contactId; /** * 联系人称呼 diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileDeviceGroup.java b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileDeviceGroup.java index a423946..92610d8 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileDeviceGroup.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileDeviceGroup.java @@ -98,4 +98,6 @@ public class MobileDeviceGroup implements Serializable { @TableLogic private Integer deleteFlag; + private String openId; + } \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java index ce4bbb3..95b33a1 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java @@ -17,6 +17,7 @@ import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import net.shapelight.common.config.GlobalValue; import net.shapelight.common.config.MinioConfig; +import net.shapelight.common.handler.CustomizeTableNameHandler; import net.shapelight.common.utils.*; import net.shapelight.commons.engine.sdk.PalmSDK; import net.shapelight.commons.engine.sdk.SdkImageUtils; @@ -27,6 +28,8 @@ import net.shapelight.modules.app.entity.AppUserScopeEntity; import net.shapelight.modules.app.service.AppUserService; import net.shapelight.modules.app.service.impl.AppUserScopeServiceImpl; import net.shapelight.modules.excel.model.PersonModel; +import net.shapelight.modules.mobile.entity.MobileContact; +import net.shapelight.modules.mobile.service.impl.MobileContactServiceImpl; import net.shapelight.modules.nettyapi.service.ServerApiService; import net.shapelight.modules.sys.controller.AbstractController; import net.shapelight.modules.sys.entity.SysUserEntity; @@ -105,6 +108,8 @@ public class TenPersonController extends AbstractController { private AppUserScopeServiceImpl appUserScopeService; @Autowired private TenRelationService relationService; + @Autowired + private MobileContactServiceImpl mobileContactServiceImpl; /** @@ -327,7 +332,10 @@ public class TenPersonController extends AbstractController { person.setDeptAllName(deptAllName); } } - + CustomizeTableNameHandler.setData(String.valueOf(person.getCellId())); + List list = mobileContactServiceImpl.list(new LambdaQueryWrapper().eq(MobileContact::getPersonId,person.getPersonId())); + CustomizeTableNameHandler.removeData(); + person.setMobileContactList(list); return R.ok().put("data", person); } @@ -339,6 +347,12 @@ public class TenPersonController extends AbstractController { @ApiOperation(value = "查询户室内所有成员", response = TenPersonEntity.class) public R findByRoomId(@PathVariable("roomId") Long personId, @PathVariable("cellId") Long cellId) { List person = tenPersonService.getByRoomId(personId, cellId, null); + person.forEach(item -> { + CustomizeTableNameHandler.setData(String.valueOf(item.getCellId())); + List list = mobileContactServiceImpl.list(new LambdaQueryWrapper().eq(MobileContact::getPersonId,item.getPersonId())); + item.setMobileContactList(list); + CustomizeTableNameHandler.setData(String.valueOf(item.getCellId())); + }); return R.ok().put("data", person); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java index 90ab6c6..88c716d 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java @@ -472,7 +472,12 @@ public class TenPersonServiceImpl implements TenPersonService { appUserService.updateById(appUser); } if (entity.getPersonType().equals(Constant.PERSON_TYPE_OWNER)) { + CustomizeTableNameHandler.setData(String.valueOf(entity.getCellId())); + entity.getMobileContactList().forEach(item -> { + item.setPersonId(entity.getPersonId()); + }); mobileContactService.saveBatch(entity.getMobileContactList()); + CustomizeTableNameHandler.removeData(); } //发送设备通知 @@ -1469,6 +1474,14 @@ public class TenPersonServiceImpl implements TenPersonService { } tenPersonDao.updateById(entity); + if (entity.getPersonType().equals(Constant.PERSON_TYPE_OWNER)) { + CustomizeTableNameHandler.setData(String.valueOf(entity.getCellId())); + /* entity.getMobileContactList().forEach(item -> { + item.setPersonId(entity.getPersonId()); + });*/ + mobileContactService.updateBatchById(entity.getMobileContactList()); + CustomizeTableNameHandler.removeData(); + } //配置同步数据 List syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getCellId()); for (TenPersonSyncEntity syncEn : syncEntitys) {