Commit 329175e5 by zzrdark

1.设备批量增加

parent 0c3416ec
package com.mx.cneeds.common.dto;
import lombok.Data;
import java.util.List;
/**
* @ClassName DeviceChannelStatisticsDto
* @Author zzrdark
* @Date 2020-05-20 15:27
* @Description TODO
**/
@Data
public class DeviceChannelStatisticsDto {
/**
* 渠道号
*/
private String channelNum;
/**
* 0:白名单,1:黑名单
*/
private Integer channelRules;
/**
* 渠道号提示信息
*/
private String channelNumsMessage;
private String deptName;
private Long deptId;
private List<DeviceInfoDto> deviceInfoDtos;
}
package com.mx.cneeds.common.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @ClassName UploadDeviceChannelExcelDto
* @Author zzrdark
* @Date 2020-05-22 18:27
* @Description TODO
**/
@Data
public class UploadDeviceChannelExcelDto implements Serializable {
/**
* 系列id
*/
private Long seriesId;
private Long deptId;
private List<UploadDeviceChannelExcelInfoDto> infos;
/**
* 渠道号提示信息
*/
private String channelNumsMessage;
/**
* 0:白名单,1:黑名单
*/
private Integer channelRules;
/**
* 渠道号Ids
*/
private List<Long> channelIds;
@Data
static class UploadDeviceChannelExcelInfoDto implements Serializable {
private String imei;
private String iccid;
}
}
package com.mx.cneeds.common.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class UploadDeviceChannelExcelVo implements Serializable {
/**
* 系列id
*/
private Long seriesId;
private Long deptId;
private List<UploadDeviceChannelExcelInfoVo> infos;
/**
* 渠道号提示信息
*/
private String channelNumsMessage;
/**
* 0:白名单,1:黑名单
*/
private Integer channelRules;
/**
* 渠道号Ids
*/
private List<Long> channelNums;
@Data
static class UploadDeviceChannelExcelInfoVo implements Serializable {
private String imei;
private String iccid;
}
}
\ No newline at end of file
......@@ -96,4 +96,9 @@ public interface DeviceClient {
@PostMapping("/device/devicechannel/updateSettingDeviceChannel")
void updateSettingDeviceChannel(@RequestBody DeviceInfoDto dto);
@PostMapping("/device/devicechannel/queryTotalStatisticsDeviceChannel")
List<DeviceChannelStatisticsDto> queryTotalStatisticsDeviceChannel(@RequestBody(required = false) List<Long> channelIds);
@PostMapping("/device/info/uploadDeivceChannelExcel")
void uploadDeivceChannelExcel(@RequestBody UploadDeviceChannelExcelDto dto);
}
......@@ -61,6 +61,9 @@ public interface UserClient {
@PostMapping("/sys/dept/delete")
void deleteDept(@RequestBody List<Long> ids);
@PostMapping("/sys/dept/info")
DepartmentDto deptInfo(@RequestBody Long deptId);
/**
*
* @param page
......
......@@ -6,6 +6,7 @@ import com.mx.cneeds.common.dto.*;
import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.vo.*;
import com.mx.cneeds.server.datashow.client.DeviceClient;
import com.mx.cneeds.server.datashow.client.UserClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
......@@ -14,6 +15,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.LinkedList;
import java.util.List;
/**
......@@ -31,6 +33,9 @@ public class DeviceController {
@Autowired
private DeviceClient deviceClient;
@Autowired
private UserClient userClient;
@GetMapping("/device/getChannel_nums")
public R getChannel_nums(String imei){
......@@ -288,4 +293,28 @@ public class DeviceController {
return R.ok();
}
@PostMapping("/deviceChannel/queryTotalStatisticsDeviceChannel")
public R queryTotalStatisticsDeviceChannel(@RequestParam(value="channelIds", required = false) List<Long> channelIds){
if (channelIds == null){
channelIds = new LinkedList<>();
}
List<DeviceChannelStatisticsDto> list = deviceClient.queryTotalStatisticsDeviceChannel(channelIds);
list.forEach(dto -> {
DepartmentDto departmentDto = userClient.deptInfo(dto.getDeptId());
dto.setDeptName(departmentDto.getName());
});
return R.ok().put("data",list);
}
@PostMapping("/device/uploadDeivceChannelExcel")
public R uploadDeivceChannelExcel(@RequestBody UploadDeviceChannelExcelVo vo){
UploadDeviceChannelExcelDto dto = new UploadDeviceChannelExcelDto();
BeanUtils.copyProperties(vo,dto);
return R.ok();
}
}
......@@ -21,3 +21,9 @@ spring:
logging:
config: classpath:logback-spring-dev.xml
feign:
client:
config:
CNEEDS-SERVER-DEVICE:
connectTimeout: 10000
readTimeout: 10000
......@@ -18,5 +18,7 @@ public interface DeviceInfoChannelService extends IService<DeviceInfoChannelEnti
List<DeviceInfoChannelEntity> queryDeviceInfoChannelByDeviceId(Long deviceId);
void removeDeivceInfoChannelByChannelId(List<Long> channelIds);
List<DeviceInfoChannelEntity> queryDeviceInfoChannelByChannelIds(List<Long> channelIds);
}
......@@ -7,7 +7,9 @@ import com.mx.cneeds.server.device.service.DeviceInfoChannelService;
import com.mx.cneeds.server.entity.DeviceInfoChannelEntity;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("deviceInfoChannelService")
......@@ -30,4 +32,11 @@ public class DeviceInfoChannelServiceImpl extends ServiceImpl<DeviceInfoChannelD
.in("channel_id",channelIds));
}
@Override
public List<DeviceInfoChannelEntity> queryDeviceInfoChannelByChannelIds(List<Long> channelIds){
List<DeviceInfoChannelEntity> deviceInfoChannelEntities = getBaseMapper().selectList(new QueryWrapper<DeviceInfoChannelEntity>()
.in("channel_id", channelIds));
return deviceInfoChannelEntities;
}
}
package com.mx.cneeds.server.device.web;
import com.mx.cneeds.common.dto.DeviceChannelDto;
import com.mx.cneeds.common.dto.DeviceChannelStatisticsDto;
import com.mx.cneeds.common.dto.DeviceInfoDto;
import com.mx.cneeds.common.dto.SeriesDto;
import com.mx.cneeds.common.pager.PageUtils;
......@@ -165,4 +166,89 @@ public class DeviceChannelController {
deviceInfoEntity.setChannelNumsMessage(deviceInfoDto.getChannelNumsMessage());
deviceInfoService.updateById(deviceInfoEntity);
}
@RequestMapping("/queryTotalStatisticsDeviceChannel")
public List<DeviceChannelStatisticsDto> queryTotalStatisticsDeviceChannel(@RequestBody(required = false) List<Long> channelIds){
List<DeviceInfoChannelEntity> deviceInfoChannelEntities = null;
if (channelIds == null || channelIds.size() == 0) {
deviceInfoChannelEntities = deviceInfoChannelService.list();
}else {
deviceInfoChannelEntities = deviceInfoChannelService.queryDeviceInfoChannelByChannelIds(channelIds);
}
Set<Long> deviceIds = new HashSet<>();
Map<Long,List<Long>> deviceIdChannelMap = new HashMap<Long,List<Long>>();
deviceInfoChannelEntities.forEach(deviceInfoChannel -> {
deviceIds.add(deviceInfoChannel.getDeviceId());
if (deviceIdChannelMap.get(deviceInfoChannel.getChannelId()) == null) {
deviceIdChannelMap.put(deviceInfoChannel.getChannelId(),new ArrayList<Long>());
}
List<Long> deviceList = deviceIdChannelMap.get(deviceInfoChannel.getChannelId());
deviceList.add(deviceInfoChannel.getDeviceId());
deviceIdChannelMap.put(deviceInfoChannel.getChannelId(),deviceList);
});
List<DeviceInfoEntity> deviceInfoEntities = deviceInfoService.queryDeviceByIds(deviceIds);
Map<Long,DeviceInfoEntity> deviceInfoEntityMapBykeyId = new HashMap<>();
deviceInfoEntities.forEach(deviceInfoEntity -> {
deviceInfoEntityMapBykeyId.put(deviceInfoEntity.getDeviceId(),deviceInfoEntity);
});
Map<String,List<DeviceInfoDto>> map = new HashMap<String,List<DeviceInfoDto>>();
/**
* 根据渠道号, 客户 ,渠道规则,禁用提示问题 进行统计
*/
// TODO 无参数的统计 无法筛选 channelIds 因为这个空
channelIds.forEach(channelId -> {
List<Long> deviceIdList = deviceIdChannelMap.get(channelId);
deviceIdList.forEach(deviceId -> {
DeviceInfoEntity deviceInfoEntity = deviceInfoEntityMapBykeyId.get(deviceId);
DeviceInfoDto dto = new DeviceInfoDto();
BeanUtils.copyProperties(deviceInfoEntity,dto);
StringBuffer sb = new StringBuffer();
sb.append(channelId+"__");
sb.append(dto.getDeptId()+"__");
sb.append(dto.getChannelRules()+"__");
sb.append(dto.getChannelNumsMessage());
if (map.get(sb.toString()) == null) {
map.put(sb.toString(),new ArrayList<DeviceInfoDto>());
}
List<DeviceInfoDto> deviceInfoList = map.get(sb.toString());
deviceInfoList.add(dto);
map.put(sb.toString(),deviceInfoList);
});
});
List<DeviceChannelStatisticsDto> list = new LinkedList<>();
map.forEach((key,value) -> {
String[] s = key.split("__");
DeviceChannelStatisticsDto dto = new DeviceChannelStatisticsDto();
dto.setChannelNum(s[0]);
dto.setDeptId(Long.valueOf(s[1]));
dto.setChannelRules(Integer.valueOf(s[2]));
dto.setChannelNumsMessage(s[3]);
dto.setDeviceInfoDtos(value);
list.add(dto);
});
return list;
}
}
......@@ -5,6 +5,7 @@ import java.util.*;
import com.mx.cneeds.common.dto.DeviceChannelDto;
import com.mx.cneeds.common.dto.DeviceInfoDto;
import com.mx.cneeds.common.dto.DevicesDto;
import com.mx.cneeds.common.dto.UploadDeviceChannelExcelDto;
import com.mx.cneeds.common.pager.PageUtils;
import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.validator.ValidatorUtils;
......@@ -267,4 +268,9 @@ public class DeviceInfoController {
deviceInfoChannelService.saveBatch(deviceChannelEntities);
return R.ok();
}
@RequestMapping("/uploadDeivceChannelExcel")
public void uploadDeivceChannelExcel(@RequestBody UploadDeviceChannelExcelDto dto){
}
}
......@@ -62,12 +62,16 @@ public class SysDeptController {
/**
* 信息
*/
@RequestMapping("/info/{deptId}")
@RequestMapping("/info")
// @RequiresPermissions("sys:sysdept:info")
public R info(@PathVariable("deptId") Long deptId){
public DepartmentDto info(@RequestBody Long deptId){
SysDeptEntity sysDept = sysDeptService.getById(deptId);
return R.ok().put("sysDept", sysDept);
DepartmentDto dto = new DepartmentDto();
if (sysDept == null){
return null;
}
BeanUtils.copyProperties(sysDept,dto);
return dto;
}
/**
......
spring:
profiles:
active: prod
active: test
application:
name: cneeds-server-user
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment