顾挽-智慧校园-11-15
This commit is contained in:
parent
dd5cf8188f
commit
ad0de6a29a
27
pom.xml
27
pom.xml
|
@ -30,7 +30,7 @@
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
<jedis.version>2.9.0</jedis.version>
|
<jedis.version>2.9.0</jedis.version>
|
||||||
<druid.version>1.2.13</druid.version>
|
<druid.version>1.2.13</druid.version>
|
||||||
<mybatisplus.version>3.5.5</mybatisplus.version>
|
<mybatisplus.version>3.5.7</mybatisplus.version>
|
||||||
<mysql.version>8.0.25</mysql.version>
|
<mysql.version>8.0.25</mysql.version>
|
||||||
<mssql.version>4.0</mssql.version>
|
<mssql.version>4.0</mssql.version>
|
||||||
<oracle.version>11.2.0.3</oracle.version>
|
<oracle.version>11.2.0.3</oracle.version>
|
||||||
|
@ -71,8 +71,22 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
@ -285,6 +299,17 @@
|
||||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--mapstruct-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct</artifactId>
|
||||||
|
<version>1.6.0.Beta1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,14 @@
|
||||||
<version>0.7</version>
|
<version>0.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.guwan</groupId>
|
||||||
|
<artifactId>easyexcel</artifactId>
|
||||||
|
<version>4.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>easyexcel</artifactId>
|
<artifactId>easyexcel</artifactId>
|
||||||
|
@ -251,10 +259,31 @@
|
||||||
<skipTests>true</skipTests>
|
<skipTests>true</skipTests>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<!-- <plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.11.0</version>
|
||||||
|
<configuration>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.34</version>
|
||||||
|
</path>
|
||||||
|
<path>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
|
<version>1.6.0.Beta1</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
<!-- docker的maven插件官网:https://github.com/spotify/docker-maven-plugin -->
|
<!-- docker的maven插件官网:https://github.com/spotify/docker-maven-plugin -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.spotify</groupId>
|
<groupId>com.spotify</groupId>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
import net.shapelight.common.handler.CustomizeTableNameHandler;
|
import net.shapelight.common.handler.CustomizeTableNameHandler;
|
||||||
|
import net.shapelight.common.handler.TimeHandler;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@ -19,6 +20,14 @@ import org.springframework.context.annotation.Configuration;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class MybatisPlusConfig {
|
public class MybatisPlusConfig {
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public TimeHandler metaObjectHandler() {
|
||||||
|
return new TimeHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分表插件
|
* 分表插件
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -128,9 +128,11 @@ public class ShiroConfig {
|
||||||
filterMap.put("/swagger-ui.html", "anon");
|
filterMap.put("/swagger-ui.html", "anon");
|
||||||
filterMap.put("/swagger-resources/**", "anon");
|
filterMap.put("/swagger-resources/**", "anon");
|
||||||
filterMap.put("/captcha.jpg", "anon");
|
filterMap.put("/captcha.jpg", "anon");
|
||||||
|
filterMap.put("/mobile/device/group/export", "anon");
|
||||||
// filterMap.put("/aaa.txt", "anon");
|
// filterMap.put("/aaa.txt", "anon");
|
||||||
filterMap.put("/**", "oauth2");
|
filterMap.put("/**", "oauth2");
|
||||||
|
|
||||||
|
|
||||||
shiroFilter.setFilterChainDefinitionMap(filterMap);
|
shiroFilter.setFilterChainDefinitionMap(filterMap);
|
||||||
|
|
||||||
return shiroFilter;
|
return shiroFilter;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.apache.ibatis.reflection.MetaObject;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class TimeHandler implements MetaObjectHandler {
|
public class TimeHandler implements MetaObjectHandler {
|
||||||
@Override
|
/* @Override
|
||||||
public void insertFill(MetaObject metaObject) {
|
public void insertFill(MetaObject metaObject) {
|
||||||
this.setFieldValByName("createTime", new Date(), metaObject);
|
this.setFieldValByName("createTime", new Date(), metaObject);
|
||||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||||
|
@ -15,5 +15,18 @@ public class TimeHandler implements MetaObjectHandler {
|
||||||
@Override
|
@Override
|
||||||
public void updateFill(MetaObject metaObject) {
|
public void updateFill(MetaObject metaObject) {
|
||||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertFill(MetaObject metaObject) {
|
||||||
|
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
|
||||||
|
this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
|
||||||
|
this.strictInsertFill(metaObject, "deleteFlag", Integer.class, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFill(MetaObject metaObject) {
|
||||||
|
this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package net.shapelight.common.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.db.PageResult;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
|
public class BeanUtils {
|
||||||
|
|
||||||
|
public static <T> T toBean(Object source, Class<T> targetClass) {
|
||||||
|
return BeanUtil.toBean(source, targetClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T toBean(Object source, Class<T> targetClass, Consumer<T> peek) {
|
||||||
|
T target = toBean(source, targetClass);
|
||||||
|
if (target != null) {
|
||||||
|
peek.accept(target);
|
||||||
|
}
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <S, T> List<T> toBean(List<S> source, Class<T> targetType) {
|
||||||
|
if (source == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CollectionUtils.convertList(source, s -> toBean(s, targetType));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <S, T> List<T> toBean(List<S> source, Class<T> targetType, Consumer<T> peek) {
|
||||||
|
List<T> list = toBean(source, targetType);
|
||||||
|
if (list != null) {
|
||||||
|
list.forEach(peek);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,326 @@
|
||||||
|
package net.shapelight.common.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
|
|
||||||
|
public class CollectionUtils {
|
||||||
|
|
||||||
|
public static boolean containsAny(Object source, Object... targets) {
|
||||||
|
return asList(targets).contains(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAnyEmpty(Collection<?>... collections) {
|
||||||
|
return Arrays.stream(collections).anyMatch(CollectionUtil::isEmpty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> boolean anyMatch(Collection<T> from, Predicate<T> predicate) {
|
||||||
|
return from.stream().anyMatch(predicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> filterList(Collection<T> from, Predicate<T> predicate) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return from.stream().filter(predicate).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, R> List<T> distinct(Collection<T> from, Function<T, R> keyMapper) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return distinct(from, keyMapper, (t1, t2) -> t1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, R> List<T> distinct(Collection<T> from, Function<T, R> keyMapper, BinaryOperator<T> cover) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return new ArrayList<>(convertMap(from, keyMapper, Function.identity(), cover).values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U> List<U> convertList(T[] from, Function<T, U> func) {
|
||||||
|
if (ArrayUtil.isEmpty(from)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return convertList(Arrays.asList(from), func);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U> List<U> convertList(Collection<T> from, Function<T, U> func) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return from.stream().map(func).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U> List<U> convertList(Collection<T> from, Function<T, U> func, Predicate<T> filter) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U> List<U> convertListByFlatMap(Collection<T> from,
|
||||||
|
Function<T, ? extends Stream<? extends U>> func) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return from.stream().filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U, R> List<R> convertListByFlatMap(Collection<T> from,
|
||||||
|
Function<? super T, ? extends U> mapper,
|
||||||
|
Function<U, ? extends Stream<? extends R>> func) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return from.stream().map(mapper).filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <K, V> List<V> mergeValuesFromMap(Map<K, List<V>> map) {
|
||||||
|
return map.values()
|
||||||
|
.stream()
|
||||||
|
.flatMap(List::stream)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Set<T> convertSet(Collection<T> from) {
|
||||||
|
return convertSet(from, v -> v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U> Set<U> convertSet(Collection<T> from, Function<T, U> func) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashSet<>();
|
||||||
|
}
|
||||||
|
return from.stream().map(func).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U> Set<U> convertSet(Collection<T> from, Function<T, U> func, Predicate<T> filter) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashSet<>();
|
||||||
|
}
|
||||||
|
return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, K> Map<K, T> convertMapByFilter(Collection<T> from, Predicate<T> filter, Function<T, K> keyFunc) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
return from.stream().filter(filter).collect(Collectors.toMap(keyFunc, v -> v));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U> Set<U> convertSetByFlatMap(Collection<T> from,
|
||||||
|
Function<T, ? extends Stream<? extends U>> func) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashSet<>();
|
||||||
|
}
|
||||||
|
return from.stream().filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U, R> Set<R> convertSetByFlatMap(Collection<T> from,
|
||||||
|
Function<? super T, ? extends U> mapper,
|
||||||
|
Function<U, ? extends Stream<? extends R>> func) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashSet<>();
|
||||||
|
}
|
||||||
|
return from.stream().map(mapper).filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, K> Map<K, T> convertMap(Collection<T> from, Function<T, K> keyFunc) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
return convertMap(from, keyFunc, Function.identity());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, K> Map<K, T> convertMap(Collection<T> from, Function<T, K> keyFunc, Supplier<? extends Map<K, T>> supplier) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return supplier.get();
|
||||||
|
}
|
||||||
|
return convertMap(from, keyFunc, Function.identity(), supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, K, V> Map<K, V> convertMap(Collection<T> from, Function<T, K> keyFunc, Function<T, V> valueFunc) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
return convertMap(from, keyFunc, valueFunc, (v1, v2) -> v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, K, V> Map<K, V> convertMap(Collection<T> from, Function<T, K> keyFunc, Function<T, V> valueFunc, BinaryOperator<V> mergeFunction) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
return convertMap(from, keyFunc, valueFunc, mergeFunction, HashMap::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, K, V> Map<K, V> convertMap(Collection<T> from, Function<T, K> keyFunc, Function<T, V> valueFunc, Supplier<? extends Map<K, V>> supplier) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return supplier.get();
|
||||||
|
}
|
||||||
|
return convertMap(from, keyFunc, valueFunc, (v1, v2) -> v1, supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, K, V> Map<K, V> convertMap(Collection<T> from, Function<T, K> keyFunc, Function<T, V> valueFunc, BinaryOperator<V> mergeFunction, Supplier<? extends Map<K, V>> supplier) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
return from.stream().collect(Collectors.toMap(keyFunc, valueFunc, mergeFunction, supplier));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, K> Map<K, List<T>> convertMultiMap(Collection<T> from, Function<T, K> keyFunc) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
return from.stream().collect(Collectors.groupingBy(keyFunc, Collectors.mapping(t -> t, Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, K, V> Map<K, List<V>> convertMultiMap(Collection<T> from, Function<T, K> keyFunc, Function<T, V> valueFunc) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
return from.stream()
|
||||||
|
.collect(Collectors.groupingBy(keyFunc, Collectors.mapping(valueFunc, Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 暂时没想好名字,先以 2 结尾噶
|
||||||
|
public static <T, K, V> Map<K, Set<V>> convertMultiMap2(Collection<T> from, Function<T, K> keyFunc, Function<T, V> valueFunc) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
return from.stream().collect(Collectors.groupingBy(keyFunc, Collectors.mapping(valueFunc, Collectors.toSet())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, K> Map<K, T> convertImmutableMap(Collection<T> from, Function<T, K> keyFunc) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
ImmutableMap.Builder<K, T> builder = ImmutableMap.builder();
|
||||||
|
from.forEach(item -> builder.put(keyFunc.apply(item), item));
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对比老、新两个列表,找出新增、修改、删除的数据
|
||||||
|
*
|
||||||
|
* @param oldList 老列表
|
||||||
|
* @param newList 新列表
|
||||||
|
* @param sameFunc 对比函数,返回 true 表示相同,返回 false 表示不同
|
||||||
|
* 注意,same 是通过每个元素的“标识”,判断它们是不是同一个数据
|
||||||
|
* @return [新增列表、修改列表、删除列表]
|
||||||
|
*/
|
||||||
|
public static <T> List<List<T>> diffList(Collection<T> oldList, Collection<T> newList,
|
||||||
|
BiFunction<T, T, Boolean> sameFunc) {
|
||||||
|
List<T> createList = new LinkedList<>(newList); // 默认都认为是新增的,后续会进行移除
|
||||||
|
List<T> updateList = new ArrayList<>();
|
||||||
|
List<T> deleteList = new ArrayList<>();
|
||||||
|
|
||||||
|
// 通过以 oldList 为主遍历,找出 updateList 和 deleteList
|
||||||
|
for (T oldObj : oldList) {
|
||||||
|
// 1. 寻找是否有匹配的
|
||||||
|
T foundObj = null;
|
||||||
|
for (Iterator<T> iterator = createList.iterator(); iterator.hasNext(); ) {
|
||||||
|
T newObj = iterator.next();
|
||||||
|
// 1.1 不匹配,则直接跳过
|
||||||
|
if (!sameFunc.apply(oldObj, newObj)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 1.2 匹配,则移除,并结束寻找
|
||||||
|
iterator.remove();
|
||||||
|
foundObj = newObj;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 2. 匹配添加到 updateList;不匹配则添加到 deleteList 中
|
||||||
|
if (foundObj != null) {
|
||||||
|
updateList.add(foundObj);
|
||||||
|
} else {
|
||||||
|
deleteList.add(oldObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return asList(createList, updateList, deleteList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean containsAny(Collection<?> source, Collection<?> candidates) {
|
||||||
|
return org.springframework.util.CollectionUtils.containsAny(source, candidates);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getFirst(List<T> from) {
|
||||||
|
return !CollectionUtil.isEmpty(from) ? from.get(0) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T findFirst(Collection<T> from, Predicate<T> predicate) {
|
||||||
|
return findFirst(from, predicate, Function.identity());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U> U findFirst(Collection<T> from, Predicate<T> predicate, Function<T, U> func) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return from.stream().filter(predicate).findFirst().map(func).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, V extends Comparable<? super V>> V getMaxValue(Collection<T> from, Function<T, V> valueFunc) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
assert !from.isEmpty(); // 断言,避免告警
|
||||||
|
T t = from.stream().max(Comparator.comparing(valueFunc)).get();
|
||||||
|
return valueFunc.apply(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, V extends Comparable<? super V>> V getMinValue(List<T> from, Function<T, V> valueFunc) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
assert from.size() > 0; // 断言,避免告警
|
||||||
|
T t = from.stream().min(Comparator.comparing(valueFunc)).get();
|
||||||
|
return valueFunc.apply(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, V extends Comparable<? super V>> T getMinObject(List<T> from, Function<T, V> valueFunc) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
assert from.size() > 0; // 断言,避免告警
|
||||||
|
return from.stream().min(Comparator.comparing(valueFunc)).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, V extends Comparable<? super V>> V getSumValue(Collection<T> from, Function<T, V> valueFunc,
|
||||||
|
BinaryOperator<V> accumulator) {
|
||||||
|
return getSumValue(from, valueFunc, accumulator, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, V extends Comparable<? super V>> V getSumValue(Collection<T> from, Function<T, V> valueFunc,
|
||||||
|
BinaryOperator<V> accumulator, V defaultValue) {
|
||||||
|
if (CollUtil.isEmpty(from)) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
assert !from.isEmpty(); // 断言,避免告警
|
||||||
|
return from.stream().map(valueFunc).filter(Objects::nonNull).reduce(accumulator).orElse(defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> void addIfNotNull(Collection<T> coll, T item) {
|
||||||
|
if (item == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
coll.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Collection<T> singleton(T obj) {
|
||||||
|
return obj == null ? Collections.emptyList() : Collections.singleton(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> newArrayList(List<List<T>> list) {
|
||||||
|
return list.stream().flatMap(Collection::stream).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package net.shapelight.common.utils;
|
||||||
|
|
||||||
|
import com.guwan.excel.EasyExcel;
|
||||||
|
import com.guwan.excel.converters.longconverter.LongStringConverter;
|
||||||
|
import com.guwan.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ExcelUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将列表以 Excel 响应给前端
|
||||||
|
*
|
||||||
|
* @param response 响应
|
||||||
|
* @param filename 文件名
|
||||||
|
* @param sheetName Excel sheet 名
|
||||||
|
* @param head Excel head 头
|
||||||
|
* @param data 数据列表
|
||||||
|
* @param <T> 泛型,保证 head 和 data 类型的一致性
|
||||||
|
* @throws IOException 写入失败的情况
|
||||||
|
*/
|
||||||
|
public static <T> void write(HttpServletResponse response, String filename, String sheetName,
|
||||||
|
Class<T> head, List<T> data) throws IOException {
|
||||||
|
// 输出 Excel
|
||||||
|
EasyExcel.write(response.getOutputStream(), head)
|
||||||
|
.autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理
|
||||||
|
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 基于 column 长度,自动适配。最大 255 宽度
|
||||||
|
.registerConverter(new LongStringConverter()) // 避免 Long 类型丢失精度
|
||||||
|
.sheet(sheetName).doWrite(data);
|
||||||
|
// 设置 header 和 contentType。写在最后的原因是,避免报错时,响应 contentType 已经被修改了
|
||||||
|
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, StandardCharsets.UTF_8.name()));
|
||||||
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> read(MultipartFile file, Class<T> head) throws IOException {
|
||||||
|
return EasyExcel.read(file.getInputStream(), head, null)
|
||||||
|
.autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理
|
||||||
|
.doReadAllSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
/*
|
||||||
package net.shapelight.modules.appparent.controller;
|
package net.shapelight.modules.appparent.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
@ -109,3 +110,4 @@ public class AppParentWxController {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package net.shapelight.modules.fegin;
|
package net.shapelight.modules.fegin;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
|
||||||
import feign.hystrix.FallbackFactory;
|
import feign.hystrix.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,14 @@ import net.shapelight.common.handler.CustomizeTableNameHandler;
|
||||||
import net.shapelight.common.utils.PageUtils;
|
import net.shapelight.common.utils.PageUtils;
|
||||||
import net.shapelight.common.utils.R;
|
import net.shapelight.common.utils.R;
|
||||||
import net.shapelight.common.utils.SnowflakeIdWorker;
|
import net.shapelight.common.utils.SnowflakeIdWorker;
|
||||||
|
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.MobileDevice;
|
||||||
import net.shapelight.modules.mobile.service.MobileDeviceService;
|
import net.shapelight.modules.mobile.service.MobileDeviceService;
|
||||||
import net.shapelight.modules.sys.controller.AbstractController;
|
import net.shapelight.modules.sys.controller.AbstractController;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -30,34 +30,50 @@ public class DeviceController extends AbstractController {
|
||||||
MobileDeviceService mobileDeviceService;
|
MobileDeviceService mobileDeviceService;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("list")
|
@GetMapping("list")
|
||||||
@ApiOperation("设备列表")
|
@ApiOperation("设备列表")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name="limit",value = "每页条数",paramType = "query",dataType = "String",required = true),
|
@ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "Long",required = true),
|
||||||
@ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "String",required = true),
|
@ApiImplicitParam(name="size",value = "每页页数",paramType = "query",dataType = "Long",required = true),
|
||||||
@ApiImplicitParam(name = "name", value = "设备名称", paramType = "query", dataType = "String"),
|
@ApiImplicitParam(name = "name", value = "设备名称", paramType = "query", dataType = "String"),
|
||||||
@ApiImplicitParam(name = "status", value = "设备状态", paramType = "query", dataType = "Integer"),
|
@ApiImplicitParam(name = "groupId", value = "设备组id", paramType = "query", dataType = "Long"),
|
||||||
@ApiImplicitParam(name = "cellName", value = "学校名称", paramType = "query", dataType = "String"),
|
@ApiImplicitParam(name = "apkVersion", value = "apk版本", paramType = "query", dataType = "String")
|
||||||
@ApiImplicitParam(name = "deptId", value = "设备区域名称", paramType = "query", dataType = "String")
|
|
||||||
})
|
})
|
||||||
public R list(@RequestBody Map<String,Object> params) {
|
public R list(@RequestParam(defaultValue = "1") Long page,
|
||||||
|
@RequestParam(defaultValue = "10") Long size,
|
||||||
|
@RequestParam(required = false) String name,
|
||||||
|
@RequestParam(required = false) Long groupId,
|
||||||
|
@RequestParam(required = false) String apkVersion) {
|
||||||
//params.put("tenantId",getUser().getTenantId());
|
//params.put("tenantId",getUser().getTenantId());
|
||||||
CustomizeTableNameHandler.setData(String.valueOf(getUser().getTenantId()));
|
/* CustomizeTableNameHandler.setData(String.valueOf(getUser().getTenantId()));
|
||||||
PageUtils page = mobileDeviceService.queryPage(params);
|
PageUtils page = mobileDeviceService.queryPage(params);
|
||||||
CustomizeTableNameHandler.removeData();
|
CustomizeTableNameHandler.removeData();*/
|
||||||
return R.ok().put("data",page);
|
|
||||||
|
System.out.println("page = " + page);
|
||||||
|
System.out.println("size = " + size);
|
||||||
|
|
||||||
|
MobileDeviceQueryDto mobileDeviceQueryDto = new MobileDeviceQueryDto();
|
||||||
|
mobileDeviceQueryDto.setCurrent(page);
|
||||||
|
mobileDeviceQueryDto.setSize(size);
|
||||||
|
mobileDeviceQueryDto.setName(name);
|
||||||
|
mobileDeviceQueryDto.setGroupId(groupId);
|
||||||
|
mobileDeviceQueryDto.setApkVersion(apkVersion);
|
||||||
|
|
||||||
|
return R.ok().put("data", mobileDeviceService.list(mobileDeviceQueryDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("add")
|
@PostMapping("add")
|
||||||
@ApiOperation("设备新增")
|
@ApiOperation("设备新增")
|
||||||
public R add(@RequestBody MobileDevice mobileDevice) {
|
public R add(@RequestBody MobileDeviceAddDto mobileDeviceAddDto) {
|
||||||
//mobileDevice.setTenantId(getUser().getTenantId());
|
//mobileDevice.setTenantId(getUser().getTenantId());
|
||||||
Long id = new SnowflakeIdWorker().nextId();
|
// Long id = new SnowflakeIdWorker().nextId();
|
||||||
mobileDevice.setId(id);
|
// mobileDevice.setId(id);
|
||||||
CustomizeTableNameHandler.setData(String.valueOf(getUser().getTenantId()));
|
/* CustomizeTableNameHandler.setData(String.valueOf(getUser().getTenantId()));
|
||||||
mobileDeviceService.save(mobileDevice);
|
mobileDeviceService.save(mobileDeviceAddDto);
|
||||||
CustomizeTableNameHandler.removeData();
|
CustomizeTableNameHandler.removeData();*/
|
||||||
return R.ok();
|
if (mobileDeviceService.save(mobileDeviceAddDto)) {
|
||||||
|
return R.ok();
|
||||||
|
} else return R.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("update")
|
@PostMapping("update")
|
||||||
|
@ -66,9 +82,10 @@ public class DeviceController extends AbstractController {
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("delete")
|
@DeleteMapping("delete")
|
||||||
@ApiOperation("删除设备")
|
@ApiOperation("删除设备")
|
||||||
public R delete(@RequestBody List<Long> deviceIdList) {
|
public R delete(@RequestBody List<Long> deviceIdList) {
|
||||||
|
mobileDeviceService.remove(deviceIdList);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,21 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.shapelight.common.base.BasePageDTO;
|
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.common.utils.R;
|
||||||
import net.shapelight.modules.mobile.dto.DeviceGruopQueryDto;
|
import net.shapelight.modules.mobile.dto.mobileDeviceGroup.MobileDeviceGruopQueryDto;
|
||||||
import net.shapelight.modules.mobile.dto.MobileDeviceGroupAddDto;
|
import net.shapelight.modules.mobile.dto.mobileDeviceGroup.MobileDeviceGroupAddDto;
|
||||||
import net.shapelight.modules.mobile.entity.MobileDeviceGroup;
|
|
||||||
import net.shapelight.modules.mobile.service.MobileDeviceGroupService;
|
import net.shapelight.modules.mobile.service.MobileDeviceGroupService;
|
||||||
import org.apache.ibatis.annotations.Delete;
|
import net.shapelight.modules.mobile.vo.mobileDeviceGroup.MobileDeviceGroupVo;
|
||||||
import org.springframework.web.bind.annotation.*;
|
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.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("mobile/device/group/")
|
@RequestMapping("mobile/device/group/")
|
||||||
|
@ -27,41 +31,83 @@ public class DeviceGroupController {
|
||||||
|
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
@ApiOperation("话机设备组列表")
|
@ApiOperation("话机设备组列表")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "Long",required = true),
|
||||||
|
@ApiImplicitParam(name="size",value = "每页条数",paramType = "query",dataType = "Long",required = true),
|
||||||
|
@ApiImplicitParam(name = "groupId", value = "设备组id", paramType = "query", dataType = "Long"),
|
||||||
|
@ApiImplicitParam(name = "status", value = "设备状态", paramType = "query", dataType = "Integer"),
|
||||||
|
})
|
||||||
public R list(@RequestParam(defaultValue = "1") Long page,
|
public R list(@RequestParam(defaultValue = "1") Long page,
|
||||||
@RequestParam(defaultValue = "1") Long size,
|
@RequestParam(defaultValue = "10") Long size,
|
||||||
@RequestParam(required = false) Long groupId,
|
@RequestParam(required = false) Long groupId,
|
||||||
@RequestParam(required = false) Integer status) {
|
@RequestParam(required = false) Integer status) {
|
||||||
|
|
||||||
DeviceGruopQueryDto deviceGruopQueryDto = new DeviceGruopQueryDto();
|
MobileDeviceGruopQueryDto mobileDeviceGruopQueryDto = new MobileDeviceGruopQueryDto();
|
||||||
deviceGruopQueryDto.setCurrent(page);
|
mobileDeviceGruopQueryDto.setCurrent(page);
|
||||||
deviceGruopQueryDto.setSize(size);
|
mobileDeviceGruopQueryDto.setSize(size);
|
||||||
deviceGruopQueryDto.setGroupId(groupId);
|
mobileDeviceGruopQueryDto.setGroupId(groupId);
|
||||||
deviceGruopQueryDto.setStatus(status);
|
mobileDeviceGruopQueryDto.setStatus(status);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return R.ok().put("data", mobileDeviceGroupService.list(deviceGruopQueryDto));
|
|
||||||
|
|
||||||
|
|
||||||
|
return R.ok().put("data", mobileDeviceGroupService.list(mobileDeviceGruopQueryDto));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("add")
|
@PostMapping("add")
|
||||||
@ApiOperation("设备组新增")
|
@ApiOperation("设备组新增")
|
||||||
public R add(@RequestBody MobileDeviceGroupAddDto mobileDeviceGroupAddDto) {
|
public R add(@RequestBody MobileDeviceGroupAddDto mobileDeviceGroupAddDto) {
|
||||||
return R.ok();
|
|
||||||
|
if (mobileDeviceGroupService.add(mobileDeviceGroupAddDto)){
|
||||||
|
return R.ok();
|
||||||
|
}else return R.error();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("remove")
|
@DeleteMapping("remove")
|
||||||
@ApiOperation("设备组删除")
|
@ApiOperation("设备组删除")
|
||||||
@ApiImplicitParam(name = "groupId",value = "设备组ID",paramType = "query",dataType = "List",required = true)
|
@ApiImplicitParam(name = "groupId",value = "设备组ID",paramType = "query",dataType = "List",required = true)
|
||||||
public R remove(@RequestBody List<Long> groupId) {
|
public R remove(@RequestBody List<Long> groupId) {
|
||||||
|
|
||||||
|
mobileDeviceGroupService.remove(groupId);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("update")
|
@PutMapping("update")
|
||||||
@ApiOperation("设备组更新")
|
@ApiOperation("设备组更新")
|
||||||
public R update(@RequestBody MobileDeviceGroup mobileDeviceGroup) {
|
public R update(@RequestBody MobileDeviceGroupAddDto mobileDeviceGroupAddDto) {
|
||||||
|
mobileDeviceGroupService.update(mobileDeviceGroupAddDto);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/export-excel")
|
||||||
|
public void exportDeviceGroupExcel(@RequestBody List<Long> exportId, HttpServletResponse response)
|
||||||
|
throws IOException {
|
||||||
|
|
||||||
|
List<MobileDeviceGroupVo> mobileDeviceGroupVos =
|
||||||
|
mobileDeviceGroupService.exportByIds(exportId);
|
||||||
|
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "设备组信息.xls", "数据",
|
||||||
|
MobileDeviceGroupVo.class, mobileDeviceGroupVos);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/export")
|
||||||
|
public void exportDemo(HttpServletResponse response)
|
||||||
|
throws IOException {
|
||||||
|
|
||||||
|
List<Long> exportId = new ArrayList<>(Arrays.asList(1306928534018588678L));
|
||||||
|
|
||||||
|
List<MobileDeviceGroupVo> mobileDeviceGroupVos =
|
||||||
|
mobileDeviceGroupService.exportByIds(exportId);
|
||||||
|
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "设备组信息.xls", "数据",
|
||||||
|
MobileDeviceGroupVo.class, mobileDeviceGroupVos);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package net.shapelight.modules.mobile.coverter;
|
||||||
|
|
||||||
|
|
||||||
|
import com.guwan.excel.converters.Converter;
|
||||||
|
import com.guwan.excel.enums.CellDataTypeEnum;
|
||||||
|
import com.guwan.excel.metadata.GlobalConfiguration;
|
||||||
|
import com.guwan.excel.metadata.data.WriteCellData;
|
||||||
|
import com.guwan.excel.metadata.property.ExcelContentProperty;
|
||||||
|
|
||||||
|
public class StatusConverter implements Converter<Object> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> supportJavaTypeKey() {
|
||||||
|
throw new UnsupportedOperationException("兼容");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CellDataTypeEnum supportExcelTypeKey() {
|
||||||
|
throw new UnsupportedOperationException("暂不支持,也不需要");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WriteCellData<?> convertToExcelData(Object value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
||||||
|
if (value.equals(0)) {
|
||||||
|
return new WriteCellData<>("未启用"); // 返回 "未启用"
|
||||||
|
} else if (value.equals(1)) {
|
||||||
|
return new WriteCellData<>("启用"); // 返回 "启用"
|
||||||
|
}
|
||||||
|
return new WriteCellData<>(value.toString()); // 默认返回数字字符串
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
package net.shapelight.modules.mobile.dto;
|
|
||||||
|
|
||||||
public class MobileDeviceGroupAddDto {
|
|
||||||
/**
|
|
||||||
* 设备组名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
}
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package net.shapelight.modules.mobile.dto.mobileDevice;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class MobileDeviceAddDto {
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 设备编号
|
||||||
|
*/
|
||||||
|
private Long sn;
|
||||||
|
/**
|
||||||
|
* 设备ip
|
||||||
|
*/
|
||||||
|
private String deviceIp;
|
||||||
|
/**
|
||||||
|
* 设备组编号
|
||||||
|
*/
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long groupId;
|
||||||
|
/**
|
||||||
|
* APK版本
|
||||||
|
*/
|
||||||
|
private String apkVersion;
|
||||||
|
/**
|
||||||
|
* voip到期时间
|
||||||
|
*/
|
||||||
|
private Date voipTime;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package net.shapelight.modules.mobile.dto.mobileDevice;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.shapelight.common.base.BasePageDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MobileDeviceQueryDto extends BasePageDTO {
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 设备组id
|
||||||
|
*/
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long groupId;
|
||||||
|
/**
|
||||||
|
* APK版本
|
||||||
|
*/
|
||||||
|
private String apkVersion;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package net.shapelight.modules.mobile.dto.mobileDeviceGroup;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MobileDeviceGroupAddDto {
|
||||||
|
/**
|
||||||
|
* 设备组名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 第三方学校编码
|
||||||
|
*/
|
||||||
|
private Long cellId;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package net.shapelight.modules.mobile.dto.mobileDeviceGroup;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MobileDeviceGroupUpdateDto {
|
||||||
|
/**
|
||||||
|
* 设备组名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 第三方学校编码
|
||||||
|
*/
|
||||||
|
private Long cellId;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
}
|
|
@ -1,14 +1,13 @@
|
||||||
package net.shapelight.modules.mobile.dto;
|
package net.shapelight.modules.mobile.dto.mobileDeviceGroup;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import net.shapelight.common.base.BasePageDTO;
|
import net.shapelight.common.base.BasePageDTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class DeviceGruopQueryDto extends BasePageDTO {
|
public class MobileDeviceGruopQueryDto extends BasePageDTO {
|
||||||
/**
|
/**
|
||||||
* 设备组id
|
* 设备组id
|
||||||
*/
|
*/
|
|
@ -1,20 +1,20 @@
|
||||||
package net.shapelight.modules.mobile.entity;
|
package net.shapelight.modules.mobile.entity;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -23,6 +23,7 @@ import org.hibernate.validator.constraints.Length;
|
||||||
@Data
|
@Data
|
||||||
@TableName("mobile_device")
|
@TableName("mobile_device")
|
||||||
@ApiModel("设备信息")
|
@ApiModel("设备信息")
|
||||||
|
@Accessors(chain = true)
|
||||||
public class MobileDevice implements Serializable {
|
public class MobileDevice implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,21 +38,18 @@ public class MobileDevice implements Serializable {
|
||||||
@NotBlank(message="[设备唯一标识]不能为空")
|
@NotBlank(message="[设备唯一标识]不能为空")
|
||||||
@Size(max= 30,message="编码长度不能超过30")
|
@Size(max= 30,message="编码长度不能超过30")
|
||||||
@ApiModelProperty("设备唯一标识")
|
@ApiModelProperty("设备唯一标识")
|
||||||
@Length(max= 30,message="编码长度不能超过30")
|
|
||||||
private String sn;
|
private String sn;
|
||||||
/**
|
/**
|
||||||
* 设备名称
|
* 设备名称
|
||||||
*/
|
*/
|
||||||
@Size(max= 20,message="编码长度不能超过20")
|
@Size(max= 20,message="编码长度不能超过20")
|
||||||
@ApiModelProperty("设备名称")
|
@ApiModelProperty("设备名称")
|
||||||
@Length(max= 20,message="编码长度不能超过20")
|
|
||||||
private String name;
|
private String name;
|
||||||
/**
|
/**
|
||||||
* 设备类型
|
* 设备类型
|
||||||
*/
|
*/
|
||||||
@Size(max= 20,message="编码长度不能超过20")
|
@Size(max= 20,message="编码长度不能超过20")
|
||||||
@ApiModelProperty("设备类型")
|
@ApiModelProperty("设备类型")
|
||||||
@Length(max= 20,message="编码长度不能超过20")
|
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
/**
|
/**
|
||||||
* 设备组ID
|
* 设备组ID
|
||||||
|
@ -68,14 +66,12 @@ public class MobileDevice implements Serializable {
|
||||||
*/
|
*/
|
||||||
@Size(max= 20,message="编码长度不能超过20")
|
@Size(max= 20,message="编码长度不能超过20")
|
||||||
@ApiModelProperty("设备IP")
|
@ApiModelProperty("设备IP")
|
||||||
@Length(max= 20,message="编码长度不能超过20")
|
|
||||||
private String deviceIp;
|
private String deviceIp;
|
||||||
/**
|
/**
|
||||||
* apk版本
|
* apk版本
|
||||||
*/
|
*/
|
||||||
@Size(max= 10,message="编码长度不能超过10")
|
@Size(max= 10,message="编码长度不能超过10")
|
||||||
@ApiModelProperty("apk版本")
|
@ApiModelProperty("apk版本")
|
||||||
@Length(max= 10,message="编码长度不能超过10")
|
|
||||||
private String apkVersion;
|
private String apkVersion;
|
||||||
/**
|
/**
|
||||||
* voip到期时间
|
* voip到期时间
|
||||||
|
@ -109,7 +105,6 @@ public class MobileDevice implements Serializable {
|
||||||
*/
|
*/
|
||||||
@Size(max= 20,message="编码长度不能超过20")
|
@Size(max= 20,message="编码长度不能超过20")
|
||||||
@ApiModelProperty("创建人")
|
@ApiModelProperty("创建人")
|
||||||
@Length(max= 20,message="编码长度不能超过20")
|
|
||||||
private String createBy;
|
private String createBy;
|
||||||
/**
|
/**
|
||||||
* 区域ID
|
* 区域ID
|
||||||
|
@ -121,4 +116,10 @@ public class MobileDevice implements Serializable {
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "删除标志位")
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
@TableLogic
|
||||||
|
private Integer deleteFlag;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
package net.shapelight.modules.mobile.entity;
|
package net.shapelight.modules.mobile.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
import org.springframework.data.annotation.CreatedDate;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -21,6 +19,7 @@ import java.util.Date;
|
||||||
@Data
|
@Data
|
||||||
@TableName ("mobile_device_group")
|
@TableName ("mobile_device_group")
|
||||||
@ApiModel("话机信息")
|
@ApiModel("话机信息")
|
||||||
|
@Accessors(chain = true)
|
||||||
public class MobileDeviceGroup implements Serializable {
|
public class MobileDeviceGroup implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 设备组id
|
* 设备组id
|
||||||
|
@ -90,4 +89,13 @@ public class MobileDeviceGroup implements Serializable {
|
||||||
@ApiModelProperty(name = "修改时间")
|
@ApiModelProperty(name = "修改时间")
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标志位
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "删除标志位")
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
@TableLogic
|
||||||
|
private Integer deleteFlag;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,18 +1,16 @@
|
||||||
package net.shapelight.modules.mobile.entity;
|
package net.shapelight.modules.mobile.entity;
|
||||||
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -34,14 +32,12 @@ public class MobilePackage implements Serializable {
|
||||||
*/
|
*/
|
||||||
@Size(max= 20,message="编码长度不能超过20")
|
@Size(max= 20,message="编码长度不能超过20")
|
||||||
@ApiModelProperty("套餐名称")
|
@ApiModelProperty("套餐名称")
|
||||||
@Length(max= 20,message="编码长度不能超过20")
|
|
||||||
private String packageName;
|
private String packageName;
|
||||||
/**
|
/**
|
||||||
* 套餐类型
|
* 套餐类型
|
||||||
*/
|
*/
|
||||||
@Size(max= 20,message="编码长度不能超过20")
|
@Size(max= 20,message="编码长度不能超过20")
|
||||||
@ApiModelProperty("套餐类型")
|
@ApiModelProperty("套餐类型")
|
||||||
@Length(max= 20,message="编码长度不能超过20")
|
|
||||||
private String packageType;
|
private String packageType;
|
||||||
/**
|
/**
|
||||||
* 套餐价格
|
* 套餐价格
|
||||||
|
@ -108,7 +104,6 @@ public class MobilePackage implements Serializable {
|
||||||
*/
|
*/
|
||||||
@Size(max= 20,message="编码长度不能超过20")
|
@Size(max= 20,message="编码长度不能超过20")
|
||||||
@ApiModelProperty("创建人")
|
@ApiModelProperty("创建人")
|
||||||
@Length(max= 20,message="编码长度不能超过20")
|
|
||||||
private String createBy;
|
private String createBy;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -79,7 +79,6 @@ public class MobilePackageOrder implements Serializable {
|
||||||
*/
|
*/
|
||||||
@Size(max= 20,message="编码长度不能超过20")
|
@Size(max= 20,message="编码长度不能超过20")
|
||||||
@ApiModelProperty("学生姓名")
|
@ApiModelProperty("学生姓名")
|
||||||
@Length(max= 20,message="编码长度不能超过20")
|
|
||||||
private String personName;
|
private String personName;
|
||||||
/**
|
/**
|
||||||
* 到期时间
|
* 到期时间
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package net.shapelight.modules.mobile.mapstructMapper;
|
||||||
|
|
||||||
|
import net.shapelight.modules.mobile.dto.mobileDevice.MobileDeviceAddDto;
|
||||||
|
import net.shapelight.modules.mobile.entity.MobileDevice;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface MobileDeviceMapstructMapper {
|
||||||
|
|
||||||
|
|
||||||
|
MobileDevice mobileDeviceAddDtoToMobileDevice(MobileDeviceAddDto mobileDeviceAddDto);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
package net.shapelight.modules.mobile.service;
|
package net.shapelight.modules.mobile.service;
|
||||||
|
|
||||||
import net.shapelight.modules.mobile.dto.DeviceGruopQueryDto;
|
import net.shapelight.modules.mobile.dto.mobileDeviceGroup.MobileDeviceGroupAddDto;
|
||||||
|
import net.shapelight.modules.mobile.dto.mobileDeviceGroup.MobileDeviceGruopQueryDto;
|
||||||
import net.shapelight.modules.mobile.entity.MobileDeviceGroup;
|
import net.shapelight.modules.mobile.entity.MobileDeviceGroup;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import net.shapelight.modules.mobile.vo.MobileDeviceGroupVo;
|
import net.shapelight.modules.mobile.vo.mobileDeviceGroup.MobileDeviceGroupVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -13,5 +14,14 @@ import java.util.List;
|
||||||
* @createDate 2024-11-13 11:50:36
|
* @createDate 2024-11-13 11:50:36
|
||||||
*/
|
*/
|
||||||
public interface MobileDeviceGroupService extends IService<MobileDeviceGroup> {
|
public interface MobileDeviceGroupService extends IService<MobileDeviceGroup> {
|
||||||
List<MobileDeviceGroupVo> list(DeviceGruopQueryDto deviceGruopQueryDto);
|
|
||||||
|
List<MobileDeviceGroupVo> list(MobileDeviceGruopQueryDto mobileDeviceGruopQueryDto);
|
||||||
|
|
||||||
|
Boolean add(MobileDeviceGroupAddDto mobileDeviceGroupAddDto);
|
||||||
|
|
||||||
|
void remove(List<Long> groupId);
|
||||||
|
|
||||||
|
Boolean update(MobileDeviceGroupAddDto mobileDeviceGroupAddDto);
|
||||||
|
|
||||||
|
List<MobileDeviceGroupVo> exportByIds(List<Long> exportId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,11 @@ package net.shapelight.modules.mobile.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import net.shapelight.common.utils.PageUtils;
|
import net.shapelight.common.utils.PageUtils;
|
||||||
|
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.MobileDevice;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,5 +15,11 @@ import java.util.Map;
|
||||||
* @createDate 2024-11-13 14:36:39
|
* @createDate 2024-11-13 14:36:39
|
||||||
*/
|
*/
|
||||||
public interface MobileDeviceService extends IService<MobileDevice> {
|
public interface MobileDeviceService extends IService<MobileDevice> {
|
||||||
PageUtils queryPage(Map<String,Object> params);
|
|
||||||
|
|
||||||
|
Boolean save(MobileDeviceAddDto mobileDeviceAddDto);
|
||||||
|
|
||||||
|
List<MobileDevice> list(MobileDeviceQueryDto mobileDeviceQueryDto);
|
||||||
|
|
||||||
|
void remove(List<Long> deviceIdList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,28 @@
|
||||||
package net.shapelight.modules.mobile.service.impl;
|
package net.shapelight.modules.mobile.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.batch.MybatisBatch;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.MybatisBatchUtils;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.shapelight.modules.mobile.dto.DeviceGruopQueryDto;
|
import net.shapelight.common.utils.SnowflakeIdWorker;
|
||||||
|
import net.shapelight.modules.mobile.dto.mobileDeviceGroup.MobileDeviceGroupAddDto;
|
||||||
|
import net.shapelight.modules.mobile.dto.mobileDeviceGroup.MobileDeviceGruopQueryDto;
|
||||||
import net.shapelight.modules.mobile.entity.MobileDevice;
|
import net.shapelight.modules.mobile.entity.MobileDevice;
|
||||||
import net.shapelight.modules.mobile.entity.MobileDeviceGroup;
|
import net.shapelight.modules.mobile.entity.MobileDeviceGroup;
|
||||||
import net.shapelight.modules.mobile.mapper.MobileDeviceMapper;
|
import net.shapelight.modules.mobile.mapper.MobileDeviceMapper;
|
||||||
import net.shapelight.modules.mobile.service.MobileDeviceGroupService;
|
import net.shapelight.modules.mobile.service.MobileDeviceGroupService;
|
||||||
import net.shapelight.modules.mobile.mapper.MobileDeviceGroupMapper;
|
import net.shapelight.modules.mobile.mapper.MobileDeviceGroupMapper;
|
||||||
import net.shapelight.modules.mobile.vo.MobileDeviceGroupVo;
|
import net.shapelight.modules.mobile.vo.mobileDeviceGroup.MobileDeviceGroupVo;
|
||||||
|
import net.shapelight.modules.ten.dao.TenCellDao;
|
||||||
import net.shapelight.modules.ten.entity.TenCellEntity;
|
import net.shapelight.modules.ten.entity.TenCellEntity;
|
||||||
|
import org.apache.ibatis.executor.BatchResult;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.support.TransactionCallback;
|
||||||
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -32,11 +41,19 @@ public class MobileDeviceGroupServiceImpl extends ServiceImpl<MobileDeviceGroupM
|
||||||
|
|
||||||
private final MobileDeviceMapper mobileDeviceMapper;
|
private final MobileDeviceMapper mobileDeviceMapper;
|
||||||
|
|
||||||
|
private final TenCellDao tenCellDao;
|
||||||
|
|
||||||
|
private final SqlSessionFactory sqlSessionFactory;
|
||||||
|
|
||||||
|
|
||||||
|
private final TransactionTemplate transactionTemplate;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MobileDeviceGroupVo> list(DeviceGruopQueryDto deviceGruopQueryDto) {
|
public List<MobileDeviceGroupVo> list(MobileDeviceGruopQueryDto mobileDeviceGruopQueryDto) {
|
||||||
|
|
||||||
List<MobileDeviceGroupVo> mobileDeviceGroupVos = mobileDeviceGroupMapper.selectJoinPage(
|
List<MobileDeviceGroupVo> mobileDeviceGroupVos = mobileDeviceGroupMapper.selectJoinPage(
|
||||||
new Page<>(deviceGruopQueryDto.getCurrent(), deviceGruopQueryDto.getSize()),
|
new Page<>(mobileDeviceGruopQueryDto.getCurrent(), mobileDeviceGruopQueryDto.getSize()),
|
||||||
MobileDeviceGroupVo.class,
|
MobileDeviceGroupVo.class,
|
||||||
new MPJLambdaWrapper<MobileDeviceGroup>()
|
new MPJLambdaWrapper<MobileDeviceGroup>()
|
||||||
.select(MobileDeviceGroup::getGroupId, MobileDeviceGroup::getGroupName,
|
.select(MobileDeviceGroup::getGroupId, MobileDeviceGroup::getGroupName,
|
||||||
|
@ -44,18 +61,86 @@ public class MobileDeviceGroupServiceImpl extends ServiceImpl<MobileDeviceGroupM
|
||||||
MobileDeviceGroup::getDescription, MobileDeviceGroup::getStatus)
|
MobileDeviceGroup::getDescription, MobileDeviceGroup::getStatus)
|
||||||
.select(TenCellEntity::getProvince, TenCellEntity::getCity)
|
.select(TenCellEntity::getProvince, TenCellEntity::getCity)
|
||||||
.leftJoin(TenCellEntity.class, TenCellEntity::getCellId, MobileDeviceGroup::getCellId)
|
.leftJoin(TenCellEntity.class, TenCellEntity::getCellId, MobileDeviceGroup::getCellId)
|
||||||
.eq(Objects.nonNull(deviceGruopQueryDto.getGroupId()),
|
.eq(Objects.nonNull(mobileDeviceGruopQueryDto.getGroupId()),
|
||||||
MobileDeviceGroup::getGroupId, deviceGruopQueryDto.getGroupId())
|
MobileDeviceGroup::getGroupId, mobileDeviceGruopQueryDto.getGroupId())
|
||||||
.eq(Objects.nonNull(deviceGruopQueryDto.getStatus()),
|
.eq(Objects.nonNull(mobileDeviceGruopQueryDto.getStatus()),
|
||||||
MobileDeviceGroup::getStatus, deviceGruopQueryDto.getStatus())).getRecords();
|
MobileDeviceGroup::getStatus, mobileDeviceGruopQueryDto.getStatus())).getRecords();
|
||||||
|
|
||||||
for (MobileDeviceGroupVo mobileDeviceGroupVo : mobileDeviceGroupVos) {
|
for (MobileDeviceGroupVo mobileDeviceGroupVo : mobileDeviceGroupVos) {
|
||||||
Integer count = (int) mobileDeviceMapper.selectList(new LambdaQueryWrapper<MobileDevice>().eq(MobileDevice::getGroupId, mobileDeviceGroupVo.getGroupId())).stream().count();
|
Integer count = (int) mobileDeviceMapper.selectList(new LambdaQueryWrapper<MobileDevice>().eq(MobileDevice::getGroupId, mobileDeviceGroupVo.getGroupId())).stream().count();
|
||||||
mobileDeviceGroupVo.setNowDeviceCount(count);
|
mobileDeviceGroupVo.setNowDeviceCount(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mobileDeviceGroupVos;
|
return mobileDeviceGroupVos;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean add(MobileDeviceGroupAddDto mobileDeviceGroupAddDto) {
|
||||||
|
|
||||||
|
return mobileDeviceGroupMapper.insert(new MobileDeviceGroup()
|
||||||
|
.setGroupId(new SnowflakeIdWorker().nextId())
|
||||||
|
.setGroupName(mobileDeviceGroupAddDto.getName())
|
||||||
|
.setModelId(null)
|
||||||
|
.setCellId(mobileDeviceGroupAddDto.getCellId())
|
||||||
|
.setDeviceCount(0)
|
||||||
|
.setDescription(mobileDeviceGroupAddDto.getDescription())
|
||||||
|
.setCellName(tenCellDao.selectOne(new LambdaQueryWrapper<TenCellEntity>()
|
||||||
|
.eq(TenCellEntity::getCellId, mobileDeviceGroupAddDto.getCellId())).getName())
|
||||||
|
//TODO 这个怎么确定
|
||||||
|
.setDeptId(0L)
|
||||||
|
.setStatus(mobileDeviceGroupAddDto.getState())) == 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(List<Long> groupId) {
|
||||||
|
|
||||||
|
transactionTemplate.execute((TransactionCallback<List<BatchResult>>) status -> {
|
||||||
|
MybatisBatch.Method<MobileDeviceGroup> mobileDeviceGroupMethod
|
||||||
|
= new MybatisBatch.Method<>(MobileDeviceGroupMapper.class);
|
||||||
|
try {
|
||||||
|
MybatisBatchUtils.execute(sqlSessionFactory, groupId, mobileDeviceGroupMethod.deleteById());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("删除失败");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
/*new MybatisBatch<>(sqlSessionFactory, groupId)
|
||||||
|
.execute(new MybatisBatch.Method<>(MobileDeviceGroupMapper.class)
|
||||||
|
.deleteById());*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean update(MobileDeviceGroupAddDto mobileDeviceGroupAddDto) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MobileDeviceGroupVo> exportByIds(List<Long> exportId) {
|
||||||
|
// 使用 MPJLambdaWrapper 构建查询条件
|
||||||
|
List<MobileDeviceGroupVo> mobileDeviceGroupVos = mobileDeviceGroupMapper.selectJoinList(
|
||||||
|
MobileDeviceGroupVo.class,
|
||||||
|
new MPJLambdaWrapper<MobileDeviceGroup>()
|
||||||
|
.select(MobileDeviceGroup::getGroupId, MobileDeviceGroup::getGroupName,
|
||||||
|
MobileDeviceGroup::getDeviceCount, MobileDeviceGroup::getCellId,
|
||||||
|
MobileDeviceGroup::getDescription, MobileDeviceGroup::getStatus)
|
||||||
|
.select(TenCellEntity::getProvince, TenCellEntity::getCity)
|
||||||
|
.leftJoin(TenCellEntity.class, TenCellEntity::getCellId, MobileDeviceGroup::getCellId)
|
||||||
|
.in(MobileDeviceGroup::getGroupId, exportId));
|
||||||
|
|
||||||
|
for (MobileDeviceGroupVo mobileDeviceGroupVo : mobileDeviceGroupVos) {
|
||||||
|
Integer count = (int) mobileDeviceMapper.selectList(new LambdaQueryWrapper<MobileDevice>().eq(MobileDevice::getGroupId, mobileDeviceGroupVo.getGroupId())).stream().count();
|
||||||
|
mobileDeviceGroupVo.setNowDeviceCount(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("mobileDeviceGroupVos = " + mobileDeviceGroupVos);
|
||||||
|
|
||||||
|
return mobileDeviceGroupVos;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,27 @@
|
||||||
package net.shapelight.modules.mobile.service.impl;
|
package net.shapelight.modules.mobile.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.batch.MybatisBatch;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.shapelight.common.utils.PageUtils;
|
import net.shapelight.common.utils.PageUtils;
|
||||||
import net.shapelight.common.utils.Query;
|
import net.shapelight.common.utils.Query;
|
||||||
|
import net.shapelight.common.utils.SnowflakeIdWorker;
|
||||||
|
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.MobileDevice;
|
||||||
|
import net.shapelight.modules.mobile.mapstructMapper.MobileDeviceMapstructMapper;
|
||||||
import net.shapelight.modules.mobile.service.MobileDeviceService;
|
import net.shapelight.modules.mobile.service.MobileDeviceService;
|
||||||
import net.shapelight.modules.mobile.mapper.MobileDeviceMapper;
|
import net.shapelight.modules.mobile.mapper.MobileDeviceMapper;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhangbo
|
* @author zhangbo
|
||||||
|
@ -18,15 +29,49 @@ import java.util.Map;
|
||||||
* @createDate 2024-11-13 14:36:39
|
* @createDate 2024-11-13 14:36:39
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class MobileDeviceServiceImpl extends ServiceImpl<MobileDeviceMapper, MobileDevice>
|
public class MobileDeviceServiceImpl extends ServiceImpl<MobileDeviceMapper, MobileDevice>
|
||||||
implements MobileDeviceService{
|
implements MobileDeviceService{
|
||||||
|
|
||||||
@Override
|
private final MobileDeviceMapstructMapper mobileDeviceMapstructMapper;
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
private final MobileDeviceMapper mobileDeviceMapper;
|
||||||
IPage<MobileDevice> page = this.page(new Query<MobileDevice>().getPage(params),new LambdaQueryWrapper<MobileDevice>()
|
|
||||||
.eq(params.get("name")!=null && params.get("name")!="",MobileDevice::getName,params.get("name")));
|
|
||||||
|
|
||||||
return new PageUtils(page);
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean save(MobileDeviceAddDto mobileDeviceAddDto) {
|
||||||
|
|
||||||
|
return this.save(mobileDeviceMapstructMapper
|
||||||
|
.mobileDeviceAddDtoToMobileDevice(mobileDeviceAddDto)
|
||||||
|
.setId(new SnowflakeIdWorker().nextId())
|
||||||
|
//怎么确定
|
||||||
|
.setDeviceType(null)
|
||||||
|
//怎么确定
|
||||||
|
.setCellId(0L)
|
||||||
|
//怎么确定
|
||||||
|
.setFaceCount(0)
|
||||||
|
//怎么确定
|
||||||
|
.setDeptId(0L));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MobileDevice> list(MobileDeviceQueryDto mobileDeviceQueryDto) {
|
||||||
|
|
||||||
|
return
|
||||||
|
mobileDeviceMapper.selectPage(new Page<>(mobileDeviceQueryDto.getCurrent(), mobileDeviceQueryDto.getSize()),
|
||||||
|
new LambdaQueryWrapper<MobileDevice>().like(Objects.nonNull(mobileDeviceQueryDto.getName()),
|
||||||
|
MobileDevice::getName, mobileDeviceQueryDto.getName())
|
||||||
|
.eq(Objects.nonNull(mobileDeviceQueryDto.getGroupId()),
|
||||||
|
MobileDevice::getGroupId, mobileDeviceQueryDto.getGroupId())
|
||||||
|
.eq(Objects.nonNull(mobileDeviceQueryDto.getApkVersion()),
|
||||||
|
MobileDevice::getApkVersion, mobileDeviceQueryDto.getApkVersion())).getRecords();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(List<Long> deviceIdList) {
|
||||||
|
new MybatisBatch<>(getSqlSessionFactory(), deviceIdList)
|
||||||
|
.execute(new MybatisBatch.Method<>(MobileDeviceMapper.class).deleteById());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package net.shapelight.modules.mobile.vo;
|
package net.shapelight.modules.mobile.vo.mobileDeviceGroup;
|
||||||
|
|
||||||
|
import com.guwan.excel.annotation.ExcelProperty;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
import net.shapelight.modules.mobile.coverter.StatusConverter;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ -12,38 +14,49 @@ public class MobileDeviceGroupVo {
|
||||||
* 设备组id
|
* 设备组id
|
||||||
*/
|
*/
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
@ExcelProperty("设备组编号")
|
||||||
private Long groupId;
|
private Long groupId;
|
||||||
/**
|
/**
|
||||||
* 设备组名称
|
* 设备组名称
|
||||||
*/
|
*/
|
||||||
|
@ExcelProperty("设备组名称")
|
||||||
private String groupName;
|
private String groupName;
|
||||||
/**
|
/**
|
||||||
* 当前设备数量
|
* 当前设备数量
|
||||||
*/
|
*/
|
||||||
|
@ExcelProperty("当前设备数量")
|
||||||
private Integer nowDeviceCount;
|
private Integer nowDeviceCount;
|
||||||
/**
|
/**
|
||||||
* 最大设备数量
|
* 最大设备数量
|
||||||
*/
|
*/
|
||||||
|
@ExcelProperty("最大设备数量")
|
||||||
private Integer deviceCount;
|
private Integer deviceCount;
|
||||||
|
/**
|
||||||
|
* 学校编码
|
||||||
|
*/
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
@ExcelProperty("学校编码")
|
||||||
private Long cellId;
|
private Long cellId;
|
||||||
/**
|
/**
|
||||||
* 所在省份
|
* 所在省份
|
||||||
*/
|
*/
|
||||||
|
@ExcelProperty("所在省份")
|
||||||
private String province;
|
private String province;
|
||||||
/**
|
/**
|
||||||
* 所在城市
|
* 所在城市
|
||||||
*/
|
*/
|
||||||
|
@ExcelProperty("所在城市")
|
||||||
private String city;
|
private String city;
|
||||||
/**
|
/**
|
||||||
* 描述
|
* 描述
|
||||||
*/
|
*/
|
||||||
|
@ExcelProperty("描述")
|
||||||
private String description;
|
private String description;
|
||||||
/**
|
/**
|
||||||
* 状态
|
* 状态
|
||||||
*/
|
*/
|
||||||
private String status;
|
@ExcelProperty(value = "状态", converter = StatusConverter.class)
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -349,7 +349,7 @@ public class TenCheckController extends AbstractController {
|
||||||
|
|
||||||
HSSFCellStyle juzhong = workbook.createCellStyle();
|
HSSFCellStyle juzhong = workbook.createCellStyle();
|
||||||
//垂直居中
|
//垂直居中
|
||||||
juzhong.setVerticalAlignment(juzhong.getVerticalAlignmentEnum().CENTER);
|
// juzhong.setVerticalAlignment(juzhong.getVerticalAlignmentEnum().CENTER);
|
||||||
|
|
||||||
|
|
||||||
HSSFCellStyle biaoTiRiQi = workbook.createCellStyle();
|
HSSFCellStyle biaoTiRiQi = workbook.createCellStyle();
|
||||||
|
|
|
@ -4,7 +4,13 @@
|
||||||
<artifactId>shapelight-cell</artifactId>
|
<artifactId>shapelight-cell</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>2.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>shapelight-common</artifactId>
|
<artifactId>shapelight-common</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>shapelight-common</description>
|
<description>shapelight-common</description>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
package net.shapelight.common.validator.group;
|
package net.shapelight.common.validator.group;
|
||||||
|
|
||||||
|
|
||||||
import javax.validation.GroupSequence;
|
import javax.validation.GroupSequence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue