从青桔获取设备组及设备列表

This commit is contained in:
张博 2024-11-19 14:13:41 +08:00
parent a7f61664f2
commit edc9e08711
10 changed files with 177 additions and 38 deletions

View File

@ -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 {
}

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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<String, Object> params = new HashMap<String, Object>();
params.put("accountNumber", accountNumber);
params.put("empowerKey", empowerKey);
params.put("operation", "ghTerminalGroupGetList");
params.put("passKey", KeysEntity.passKey);
Map<String, Object> 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<String, Object> params = new HashMap<String, Object>();
params.put("accountNumber", accountNumber);
params.put("empowerKey", empowerKey);
params.put("operation", "ghTerminalGetList");
params.put("passKey", KeysEntity.passKey);
Map<String, Object> queryParams = feignClient.getData(params);
queryParams.put("otherSchoolCode", "xtzg");
params.put("queryParams",queryParams);
feignClient.getData(params);
}
}

View File

@ -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<String, Object> params = new HashMap<String, Object>();
params.put("accountNumber", accountNumber);
params.put("empowerText", KeysEntity.empowerText);
params.put("operation", "ghTerminalGroupGetList");
params.put("passKey", KeysEntity.passKey);
Map<String, Object> queryParams = new HashMap<>();
TenUserScopeEntity tenUserScopeEntity = tenUserScopeService.getOne(new LambdaQueryWrapper<TenUserScopeEntity>().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")

View File

@ -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<String, Object> params = new HashMap<String, Object>();
params.put("accountNumber", accountNumber);
params.put("empowerText", KeysEntity.empowerText);
params.put("operation", "ghTerminalGetList");
params.put("passKey", KeysEntity.passKey);
Map<String, Object> queryParams = new HashMap<>();
TenUserScopeEntity tenUserScopeEntity = tenUserScopeService.getOne(new LambdaQueryWrapper<TenUserScopeEntity>().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));
}

View File

@ -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;
/**
* 联系人称呼

View File

@ -98,4 +98,6 @@ public class MobileDeviceGroup implements Serializable {
@TableLogic
private Integer deleteFlag;
private String openId;
}

View File

@ -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<MobileContact> list = mobileContactServiceImpl.list(new LambdaQueryWrapper<MobileContact>().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<TenPersonEntity> person = tenPersonService.getByRoomId(personId, cellId, null);
person.forEach(item -> {
CustomizeTableNameHandler.setData(String.valueOf(item.getCellId()));
List<MobileContact> list = mobileContactServiceImpl.list(new LambdaQueryWrapper<MobileContact>().eq(MobileContact::getPersonId,item.getPersonId()));
item.setMobileContactList(list);
CustomizeTableNameHandler.setData(String.valueOf(item.getCellId()));
});
return R.ok().put("data", person);
}

View File

@ -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<TenPersonSyncEntity> syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getCellId());
for (TenPersonSyncEntity syncEn : syncEntitys) {