mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
Merge branch 'main' of ssh://192.168.1.205:9922/cf_devdept2/cf_imes_server
This commit is contained in:
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
package com.cf.imes.framework.common.enums;
|
package com.cf.imes.framework.common.enums;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjUtil;
|
|
||||||
import com.cf.imes.framework.common.core.IntArrayValuable;
|
import com.cf.imes.framework.common.core.IntArrayValuable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用状态枚举
|
* 通用状态枚举
|
||||||
@@ -36,11 +36,11 @@ public enum CommonStatusEnum implements IntArrayValuable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEnable(Integer status) {
|
public static boolean isEnable(Integer status) {
|
||||||
return ObjUtil.equal(ENABLE.status, status);
|
return Objects.equals(ENABLE.status, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDisable(Integer status) {
|
public static boolean isDisable(Integer status) {
|
||||||
return ObjUtil.equal(DISABLE.status, status);
|
return Objects.equals(DISABLE.status, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -1,6 +1,6 @@
|
|||||||
package com.cf.imes.framework.common.util.collection;
|
package com.cf.imes.framework.common.util.collection;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.IterUtil;
|
import cn.hutool.core.collection.IterUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
|
||||||
@@ -8,8 +8,6 @@ import java.util.Collection;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array 工具类
|
* Array 工具类
|
||||||
*
|
*
|
||||||
@@ -42,7 +40,7 @@ public class ArrayUtils {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T[] toArray(Collection<T> from) {
|
public static <T> T[] toArray(Collection<T> from) {
|
||||||
if (CollectionUtil.isEmpty(from)) {
|
if (CollUtil.isEmpty(from)) {
|
||||||
return (T[]) (new Object[0]);
|
return (T[]) (new Object[0]);
|
||||||
}
|
}
|
||||||
return ArrayUtil.toArray(from, (Class<T>) IterUtil.getElementType(from.iterator()));
|
return ArrayUtil.toArray(from, (Class<T>) IterUtil.getElementType(from.iterator()));
|
||||||
|
|||||||
+1
-1
@@ -254,7 +254,7 @@ public class CollectionUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T getFirst(List<T> from) {
|
public static <T> T getFirst(List<T> from) {
|
||||||
return !CollectionUtil.isEmpty(from) ? from.get(0) : null;
|
return !CollUtil.isEmpty(from) ? from.get(0) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T findFirst(List<T> from, Predicate<T> predicate) {
|
public static <T> T findFirst(List<T> from, Predicate<T> predicate) {
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
package com.cf.imes.framework.common.util.collection;
|
package com.cf.imes.framework.common.util.collection;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import com.cf.imes.framework.common.core.KeyValue;
|
import com.cf.imes.framework.common.core.KeyValue;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
@@ -30,7 +29,7 @@ public class MapUtils {
|
|||||||
List<V> result = new ArrayList<>();
|
List<V> result = new ArrayList<>();
|
||||||
keys.forEach(k -> {
|
keys.forEach(k -> {
|
||||||
Collection<V> values = multimap.get(k);
|
Collection<V> values = multimap.get(k);
|
||||||
if (CollectionUtil.isEmpty(values)) {
|
if (CollUtil.isEmpty(values)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
result.addAll(values);
|
result.addAll(values);
|
||||||
|
|||||||
+5
-5
@@ -3,8 +3,8 @@ package com.cf.imes.framework.common.util.http;
|
|||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.core.map.TableMap;
|
import cn.hutool.core.map.TableMap;
|
||||||
import cn.hutool.core.net.url.UrlBuilder;
|
import cn.hutool.core.net.url.UrlBuilder;
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.util.UriComponents;
|
import org.springframework.web.util.UriComponents;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
@@ -104,11 +104,11 @@ public class HttpUtils {
|
|||||||
String clientSecret;
|
String clientSecret;
|
||||||
// 先从 Header 中获取
|
// 先从 Header 中获取
|
||||||
String authorization = request.getHeader("Authorization");
|
String authorization = request.getHeader("Authorization");
|
||||||
authorization = StrUtil.subAfter(authorization, "Basic ", true);
|
authorization = CharSequenceUtil.subAfter(authorization, "Basic ", true);
|
||||||
if (StringUtils.hasText(authorization)) {
|
if (StringUtils.hasText(authorization)) {
|
||||||
authorization = Base64.decodeStr(authorization);
|
authorization = Base64.decodeStr(authorization);
|
||||||
clientId = StrUtil.subBefore(authorization, ":", false);
|
clientId = CharSequenceUtil.subBefore(authorization, ":", false);
|
||||||
clientSecret = StrUtil.subAfter(authorization, ":", false);
|
clientSecret = CharSequenceUtil.subAfter(authorization, ":", false);
|
||||||
// 再从 Param 中获取
|
// 再从 Param 中获取
|
||||||
} else {
|
} else {
|
||||||
clientId = request.getParameter("client_id");
|
clientId = request.getParameter("client_id");
|
||||||
@@ -116,7 +116,7 @@ public class HttpUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 如果两者非空,则返回
|
// 如果两者非空,则返回
|
||||||
if (StrUtil.isNotEmpty(clientId) && StrUtil.isNotEmpty(clientSecret)) {
|
if (CharSequenceUtil.isNotEmpty(clientId) && CharSequenceUtil.isNotEmpty(clientSecret)) {
|
||||||
return new String[]{clientId, clientSecret};
|
return new String[]{clientId, clientSecret};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+3
-3
@@ -3,8 +3,8 @@ package com.cf.imes.framework.common.util.io;
|
|||||||
import cn.hutool.core.io.FileTypeUtil;
|
import cn.hutool.core.io.FileTypeUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.file.FileNameUtil;
|
import cn.hutool.core.io.file.FileNameUtil;
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.crypto.digest.DigestUtil;
|
import cn.hutool.crypto.digest.DigestUtil;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
|
||||||
@@ -73,9 +73,9 @@ public class FileUtils {
|
|||||||
public static String generatePath(byte[] content, String originalName) {
|
public static String generatePath(byte[] content, String originalName) {
|
||||||
String sha256Hex = DigestUtil.sha256Hex(content);
|
String sha256Hex = DigestUtil.sha256Hex(content);
|
||||||
// 情况一:如果存在 name,则优先使用 name 的后缀
|
// 情况一:如果存在 name,则优先使用 name 的后缀
|
||||||
if (StrUtil.isNotBlank(originalName)) {
|
if (CharSequenceUtil.isNotBlank(originalName)) {
|
||||||
String extName = FileNameUtil.extName(originalName);
|
String extName = FileNameUtil.extName(originalName);
|
||||||
return StrUtil.isBlank(extName) ? sha256Hex : sha256Hex + "." + extName;
|
return CharSequenceUtil.isBlank(extName) ? sha256Hex : sha256Hex + "." + extName;
|
||||||
}
|
}
|
||||||
// 情况二:基于 content 计算
|
// 情况二:基于 content 计算
|
||||||
return sha256Hex + '.' + FileTypeUtil.getType(new ByteArrayInputStream(content));
|
return sha256Hex + '.' + FileTypeUtil.getType(new ByteArrayInputStream(content));
|
||||||
|
|||||||
+7
-6
@@ -1,6 +1,7 @@
|
|||||||
package com.cf.imes.framework.common.util.json;
|
package com.cf.imes.framework.common.util.json;
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
|
import cn.hutool.core.util.PrimitiveArrayUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
@@ -68,7 +69,7 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T parseObject(String text, Class<T> clazz) {
|
public static <T> T parseObject(String text, Class<T> clazz) {
|
||||||
if (StrUtil.isEmpty(text)) {
|
if (CharSequenceUtil.isEmpty(text)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -80,7 +81,7 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T parseObject(String text, String path, Class<T> clazz) {
|
public static <T> T parseObject(String text, String path, Class<T> clazz) {
|
||||||
if (StrUtil.isEmpty(text)) {
|
if (CharSequenceUtil.isEmpty(text)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -94,7 +95,7 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T parseObject(String text, Type type) {
|
public static <T> T parseObject(String text, Type type) {
|
||||||
if (StrUtil.isEmpty(text)) {
|
if (CharSequenceUtil.isEmpty(text)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -115,14 +116,14 @@ public class JsonUtils {
|
|||||||
* @return 对象
|
* @return 对象
|
||||||
*/
|
*/
|
||||||
public static <T> T parseObject2(String text, Class<T> clazz) {
|
public static <T> T parseObject2(String text, Class<T> clazz) {
|
||||||
if (StrUtil.isEmpty(text)) {
|
if (CharSequenceUtil.isEmpty(text)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return JSONUtil.toBean(text, clazz);
|
return JSONUtil.toBean(text, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T parseObject(byte[] bytes, Class<T> clazz) {
|
public static <T> T parseObject(byte[] bytes, Class<T> clazz) {
|
||||||
if (ArrayUtil.isEmpty(bytes)) {
|
if (PrimitiveArrayUtil.isEmpty(bytes)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
+8
-1
@@ -1,11 +1,15 @@
|
|||||||
package com.cf.imes.framework.common.util.pinyin;
|
package com.cf.imes.framework.common.util.pinyin;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||||
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
||||||
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
||||||
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
||||||
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author there
|
* @author there
|
||||||
*/
|
*/
|
||||||
@@ -52,7 +56,10 @@ public class PinYinUtils {
|
|||||||
for (int i = 0; i < newChar.length; i++) {
|
for (int i = 0; i < newChar.length; i++) {
|
||||||
if (newChar[i] > 128) {
|
if (newChar[i] > 128) {
|
||||||
try {
|
try {
|
||||||
pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0].charAt(0);
|
String[] hanyuPinyinStringArray = PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat);
|
||||||
|
if (ArrayUtil.isNotEmpty(hanyuPinyinStringArray)) {
|
||||||
|
pinyinStr += hanyuPinyinStringArray[0].charAt(0);
|
||||||
|
}
|
||||||
} catch (BadHanyuPinyinOutputFormatCombination e) {
|
} catch (BadHanyuPinyinOutputFormatCombination e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
+114
-28
@@ -4,16 +4,42 @@ import co.elastic.clients.elasticsearch.ElasticsearchAsyncClient;
|
|||||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||||
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
|
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
|
||||||
import co.elastic.clients.transport.rest_client.RestClientTransport;
|
import co.elastic.clients.transport.rest_client.RestClientTransport;
|
||||||
|
import com.cf.imes.framework.common.util.encrypt.AesUtils;
|
||||||
import com.cf.imes.framework.es.core.service.ESDocumentService;
|
import com.cf.imes.framework.es.core.service.ESDocumentService;
|
||||||
import com.cf.imes.framework.es.core.service.ESDocumentServiceImpl;
|
import com.cf.imes.framework.es.core.service.ESDocumentServiceImpl;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
|
import org.apache.http.auth.AuthScope;
|
||||||
|
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||||
|
import org.apache.http.client.CredentialsProvider;
|
||||||
|
import org.apache.http.client.config.RequestConfig;
|
||||||
|
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||||
|
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||||
|
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
|
||||||
|
import org.apache.http.ssl.SSLContextBuilder;
|
||||||
|
import org.apache.http.ssl.SSLContexts;
|
||||||
import org.elasticsearch.client.RestClient;
|
import org.elasticsearch.client.RestClient;
|
||||||
|
import org.elasticsearch.client.RestClientBuilder;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.KeyStore;
|
||||||
|
import java.security.KeyStoreException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.cert.Certificate;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.CertificateFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author there
|
* @author there
|
||||||
@@ -21,20 +47,19 @@ import org.springframework.util.StringUtils;
|
|||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@ConditionalOnClass(ElasticsearchClient.class)
|
@ConditionalOnClass(ElasticsearchClient.class)
|
||||||
@EnableConfigurationProperties(EsProperties.class)
|
@EnableConfigurationProperties(EsProperties.class)
|
||||||
|
@Slf4j
|
||||||
public class ChenfengElasticsearchAutoConfiguration {
|
public class ChenfengElasticsearchAutoConfiguration {
|
||||||
|
|
||||||
//超时时间设置
|
@Value("${chenfeng.encrypt.publicKey:}")
|
||||||
public static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 10000;
|
private String publicKey;
|
||||||
public static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 300000;
|
|
||||||
public static final int DEFAULT_CONNECT_REQUEST_TIMEOUT_MILLIS = 1000;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步方式
|
* 同步方式
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public ElasticsearchClient elasticsearchClient(EsProperties properties) {
|
public ElasticsearchClient elasticsearchClient(RestClientTransport transport) {
|
||||||
return new ElasticsearchClient(getTransport(properties.getUris()));
|
return new ElasticsearchClient(transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,44 +67,110 @@ public class ChenfengElasticsearchAutoConfiguration {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public ElasticsearchAsyncClient elasticsearchAsyncClient(EsProperties properties) {
|
public ElasticsearchAsyncClient elasticsearchAsyncClient(RestClientTransport transport) {
|
||||||
return new ElasticsearchAsyncClient(getTransport(properties.getUris()));
|
return new ElasticsearchAsyncClient(transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
private ESDocumentService esDocumentService(ElasticsearchClient elasticsearchClient, ElasticsearchAsyncClient elasticsearchAsyncClient) {
|
public ESDocumentService esDocumentService(ElasticsearchClient elasticsearchClient, ElasticsearchAsyncClient elasticsearchAsyncClient) {
|
||||||
return new ESDocumentServiceImpl(elasticsearchClient, elasticsearchAsyncClient);
|
return new ESDocumentServiceImpl(elasticsearchClient, elasticsearchAsyncClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取客户端 RestClientTransport
|
* 获取客户端 RestClientTransport
|
||||||
*/
|
*/
|
||||||
private RestClientTransport getTransport(String hosts){
|
@Bean
|
||||||
HttpHost[] httpHosts = toHttpHost(hosts);
|
public RestClientTransport getTransport(RestClient client){
|
||||||
RestClient restClient = getRestClient(httpHosts);
|
return new RestClientTransport(client, new JacksonJsonpMapper());
|
||||||
return new RestClientTransport(restClient, new JacksonJsonpMapper());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取客户端RestClient
|
* 获取客户端RestClient
|
||||||
* @param httpHosts http数组
|
* chenfeng.encrypt.enable:true
|
||||||
|
*
|
||||||
|
* @param properties es配置
|
||||||
*/
|
*/
|
||||||
private RestClient getRestClient(HttpHost[] httpHosts){
|
@Bean
|
||||||
return RestClient.builder(httpHosts).setRequestConfigCallback(requestConfigBuilder -> {
|
@ConditionalOnProperty(name = "chenfeng.encrypt.enable", havingValue = "true")
|
||||||
requestConfigBuilder.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS);
|
public RestClient getAuthRestClient(EsProperties properties) {
|
||||||
requestConfigBuilder.setSocketTimeout(DEFAULT_SOCKET_TIMEOUT_MILLIS);
|
// 配置账号密码
|
||||||
requestConfigBuilder.setConnectionRequestTimeout(DEFAULT_CONNECT_REQUEST_TIMEOUT_MILLIS);
|
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||||
|
credentialsProvider.setCredentials(AuthScope.ANY,
|
||||||
|
new UsernamePasswordCredentials(AesUtils.decrypt(properties.getUsername(), publicKey), AesUtils.decrypt(properties.getPassword(), publicKey)));
|
||||||
|
RestClientBuilder.HttpClientConfigCallback httpClientConfigCallback = httpClientBuilder -> {
|
||||||
|
// 设置账号密码、连接信息
|
||||||
|
HttpAsyncClientBuilder httpAsyncClientBuilder = httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)
|
||||||
|
.setDefaultRequestConfig(RequestConfig.custom()
|
||||||
|
.setConnectTimeout(properties.getConnectionTimeout().toSecondsPart())
|
||||||
|
.setSocketTimeout(properties.getSocketTimeout().toSecondsPart())
|
||||||
|
.setConnectionRequestTimeout(properties.getConnectionRequestTimeout().toSecondsPart())
|
||||||
|
.build());
|
||||||
|
if (properties.isSecurityHttpSslEnable()) {
|
||||||
|
// 开启ssl配置连接证书
|
||||||
|
httpAsyncClientBuilder.setSSLContext(buildSSLContext()).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE);
|
||||||
|
}
|
||||||
|
return httpAsyncClientBuilder;
|
||||||
|
};
|
||||||
|
return RestClient.builder(toHttpHost(properties.getUris(), properties.isSecurityHttpSslEnable())).setHttpClientConfigCallback(httpClientConfigCallback).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取客户端RestClient(默认)
|
||||||
|
* chenfeng.encrypt.enable:false或者缺省
|
||||||
|
*
|
||||||
|
* @param properties es配置
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(name = "chenfeng.encrypt.enable", havingValue = "false", matchIfMissing = true)
|
||||||
|
public RestClient getRestClient(EsProperties properties) {
|
||||||
|
return RestClient.builder(toHttpHost(properties.getUris(), properties.isSecurityHttpSslEnable())).setRequestConfigCallback(requestConfigBuilder -> {
|
||||||
|
requestConfigBuilder.setConnectTimeout(properties.getConnectionTimeout().toSecondsPart());
|
||||||
|
requestConfigBuilder.setSocketTimeout(properties.getSocketTimeout().toSecondsPart());
|
||||||
|
requestConfigBuilder.setConnectionRequestTimeout(properties.getConnectionRequestTimeout().toSecondsPart());
|
||||||
return requestConfigBuilder;
|
return requestConfigBuilder;
|
||||||
}).build();
|
}).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析配置的字符串hosts,转为HttpHost对象数组
|
* 构建ssl请求信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
private HttpHost[] toHttpHost(String hosts) {
|
private SSLContext buildSSLContext() {
|
||||||
|
SSLContext sslContext = null;
|
||||||
|
try {
|
||||||
|
ClassPathResource resource = new ClassPathResource("http_ca.crt");
|
||||||
|
CertificateFactory factory = CertificateFactory.getInstance("X.509");
|
||||||
|
Certificate trustedCa;
|
||||||
|
try (InputStream is = resource.getInputStream()) {
|
||||||
|
trustedCa = factory.generateCertificate(is);
|
||||||
|
}
|
||||||
|
KeyStore trustStore = KeyStore.getInstance("pkcs12");
|
||||||
|
trustStore.load(null, null);
|
||||||
|
trustStore.setCertificateEntry("ca", trustedCa);
|
||||||
|
SSLContextBuilder sslContextBuilder = SSLContexts.custom()
|
||||||
|
.loadTrustMaterial(trustStore, null);
|
||||||
|
sslContext = sslContextBuilder.build();
|
||||||
|
} catch (CertificateException | IOException | KeyStoreException | NoSuchAlgorithmException |
|
||||||
|
KeyManagementException e) {
|
||||||
|
log.error("ES连接认证失败", e);
|
||||||
|
}
|
||||||
|
return sslContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析域名
|
||||||
|
*
|
||||||
|
* @param hosts 域名字符串
|
||||||
|
* @param isSslEnable 是否开启ssl
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private HttpHost[] toHttpHost(String hosts, boolean isSslEnable) {
|
||||||
if (!StringUtils.hasLength(hosts)) {
|
if (!StringUtils.hasLength(hosts)) {
|
||||||
throw new RuntimeException("invalid elasticsearch configuration. elasticsearch.hosts不能为空!");
|
throw new IllegalArgumentException("invalid elasticsearch configuration. elasticsearch.hosts不能为空!");
|
||||||
}
|
}
|
||||||
// 多个IP逗号隔开
|
// 多个IP逗号隔开
|
||||||
String[] hostArray = hosts.split(",");
|
String[] hostArray = hosts.split(",");
|
||||||
@@ -87,14 +178,9 @@ public class ChenfengElasticsearchAutoConfiguration {
|
|||||||
HttpHost httpHost;
|
HttpHost httpHost;
|
||||||
for (int i = 0; i < hostArray.length; i++) {
|
for (int i = 0; i < hostArray.length; i++) {
|
||||||
String[] strings = hostArray[i].split(":");
|
String[] strings = hostArray[i].split(":");
|
||||||
httpHost = new HttpHost(strings[0], Integer.parseInt(strings[1]), "http");
|
httpHost = new HttpHost(strings[0], Integer.parseInt(strings[1]), isSslEnable ? "https" : "http");
|
||||||
httpHosts[i] = httpHost;
|
httpHosts[i] = httpHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
return httpHosts;
|
return httpHosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+89
-1
@@ -2,12 +2,46 @@ package com.cf.imes.framework.es.config;
|
|||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* es环境配置
|
* es环境配置
|
||||||
* @author there
|
* @author there
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "spring.elasticsearch")
|
@ConfigurationProperties(prefix = "spring.elasticsearch")
|
||||||
public class EsProperties {
|
public class EsProperties {
|
||||||
|
private String uris;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Username for authentication with Elasticsearch.
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Password for authentication with Elasticsearch.
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connection timeout used when communicating with Elasticsearch.
|
||||||
|
*/
|
||||||
|
private Duration connectionTimeout = Duration.ofSeconds(10);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Socket timeout used when communicating with Elasticsearch.
|
||||||
|
*/
|
||||||
|
private Duration socketTimeout = Duration.ofSeconds(30);
|
||||||
|
|
||||||
|
|
||||||
|
private Duration connectionRequestTimeout = Duration.ofSeconds(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix added to the path of every request sent to Elasticsearch.
|
||||||
|
*/
|
||||||
|
private String pathPrefix;
|
||||||
|
|
||||||
|
private boolean securityHttpSslEnable = false;
|
||||||
|
|
||||||
public String getUris() {
|
public String getUris() {
|
||||||
return uris;
|
return uris;
|
||||||
}
|
}
|
||||||
@@ -16,5 +50,59 @@ public class EsProperties {
|
|||||||
this.uris = uris;
|
this.uris = uris;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String uris;
|
public String getUsername() {
|
||||||
|
return this.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return this.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getConnectionTimeout() {
|
||||||
|
return this.connectionTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConnectionTimeout(Duration connectionTimeout) {
|
||||||
|
this.connectionTimeout = connectionTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getSocketTimeout() {
|
||||||
|
return this.socketTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSocketTimeout(Duration socketTimeout) {
|
||||||
|
this.socketTimeout = socketTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPathPrefix() {
|
||||||
|
return this.pathPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPathPrefix(String pathPrefix) {
|
||||||
|
this.pathPrefix = pathPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSecurityHttpSslEnable() {
|
||||||
|
return securityHttpSslEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecurityHttpSslEnable(boolean securityHttpSslEnable) {
|
||||||
|
this.securityHttpSslEnable = securityHttpSslEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getConnectionRequestTimeout() {
|
||||||
|
return connectionRequestTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConnectionRequestTimeout(Duration connectionRequestTimeout) {
|
||||||
|
this.connectionRequestTimeout = connectionRequestTimeout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -15,9 +15,9 @@ import org.springframework.context.annotation.Bean;
|
|||||||
*/
|
*/
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@AutoConfigureBefore(DynamicDataSourceAutoConfiguration.class)
|
@AutoConfigureBefore(DynamicDataSourceAutoConfiguration.class)
|
||||||
|
@ConditionalOnProperty(name = "chenfeng.encrypt.enable", havingValue = "true")
|
||||||
public class ChenfengDataSourceEncryptConfiguration {
|
public class ChenfengDataSourceEncryptConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(name = "chenfeng.encrypt.enable", havingValue = "true")
|
|
||||||
public DataSourceInitEvent getDataSourceInitEvent() {
|
public DataSourceInitEvent getDataSourceInitEvent() {
|
||||||
return new ChenfengDataSourceEncryptInitEvent();
|
return new ChenfengDataSourceEncryptInitEvent();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -20,13 +20,13 @@ import org.springframework.util.StringUtils;
|
|||||||
* @since 2024/8/27 9:46
|
* @since 2024/8/27 9:46
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
|
@ConditionalOnProperty(name = "chenfeng.encrypt.enable", havingValue = "true")
|
||||||
public class ChenfengRedisEncryptAutoConfiguration {
|
public class ChenfengRedisEncryptAutoConfiguration {
|
||||||
|
|
||||||
@Value("${chenfeng.encrypt.publicKey:}")
|
@Value("${chenfeng.encrypt.publicKey:}")
|
||||||
private String publicKey;
|
private String publicKey;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(name = "chenfeng.encrypt.enable", havingValue = "true")
|
|
||||||
public RedissonAutoConfigurationCustomizer redissonAutoConfigurationCustomizer() {
|
public RedissonAutoConfigurationCustomizer redissonAutoConfigurationCustomizer() {
|
||||||
return configuration -> {
|
return configuration -> {
|
||||||
Config redissonConfig = new Config();
|
Config redissonConfig = new Config();
|
||||||
|
|||||||
+11
@@ -1,5 +1,6 @@
|
|||||||
package com.cf.imes.framework.security.core.util;
|
package com.cf.imes.framework.security.core.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.cf.imes.framework.common.exception.ServiceException;
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
|
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
import com.cf.imes.framework.security.core.LoginUser;
|
import com.cf.imes.framework.security.core.LoginUser;
|
||||||
@@ -132,4 +133,14 @@ public class SecurityFrameworkUtils {
|
|||||||
return loginUser.getOrganId();
|
return loginUser.getOrganId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前用户是否超级管理员
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isSuperAdmin() {
|
||||||
|
LoginUser loginUser = getLoginUser();
|
||||||
|
return ObjectUtil.isNotNull(loginUser) && loginUser.getIsSupAdmin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,5 +157,7 @@ chenfeng:
|
|||||||
- infra_job_log
|
- infra_job_log
|
||||||
- infra_job_log
|
- infra_job_log
|
||||||
- infra_data_source_config
|
- infra_data_source_config
|
||||||
|
encrypt:
|
||||||
|
enable: false
|
||||||
|
publicKey: cfimes
|
||||||
debug: false
|
debug: false
|
||||||
|
|||||||
-8
@@ -64,14 +64,6 @@ public class PlanController {
|
|||||||
return success(planService.deletePlan(ids));
|
return success(planService.deletePlan(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @DeleteMapping("cancellation")
|
|
||||||
// @Operation(summary = "作废")
|
|
||||||
// @Parameter(name = "id", description = "排单id", required = true)
|
|
||||||
// @PreAuthorize("@ss.hasPermission('executor:plan:delete')")
|
|
||||||
public CommonResult<Boolean> cancellation(@RequestParam("id") Long id) {
|
|
||||||
return success(planService.cancellation(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得排单")
|
@Operation(summary = "获得排单")
|
||||||
|
|||||||
+4
-2
@@ -4,6 +4,8 @@ package com.cf.imes.module.executor.controller.admin.plan.saveOptimize;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 生产单包裹信息")
|
@Schema(description = "管理后台 - 生产单包裹信息")
|
||||||
@Data
|
@Data
|
||||||
public class PrintOrderPackReqVO {
|
public class PrintOrderPackReqVO {
|
||||||
@@ -14,7 +16,7 @@ public class PrintOrderPackReqVO {
|
|||||||
|
|
||||||
|
|
||||||
@Schema(description = "板材ID")
|
@Schema(description = "板材ID")
|
||||||
private Long plateId;
|
private List<Long> plateId;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "包裹编号")
|
@Schema(description = "包裹编号")
|
||||||
@@ -26,7 +28,7 @@ public class PrintOrderPackReqVO {
|
|||||||
|
|
||||||
|
|
||||||
@Schema(description = "包裹数量")
|
@Schema(description = "包裹数量")
|
||||||
private Long packNum;
|
private Integer packNum;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+32
-10
@@ -8,6 +8,7 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
|||||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.cf.imes.module.executor.controller.admin.goods.vo.GoodsPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.goods.vo.GoodsPageReqVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.plan.bo.OrderRoomBodyList;
|
||||||
import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.NotPlanGoodsRespVO;
|
import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.NotPlanGoodsRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.plan.vo.*;
|
import com.cf.imes.module.executor.controller.admin.plan.vo.*;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
|
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
|
||||||
@@ -82,16 +83,6 @@ public interface GoodsMapper extends BaseMapperX<GoodsDO> {
|
|||||||
IPage<OrderGoodsResp> selectGoods(@Param("page") IPage page, @Param("goodsIds") List<Long> goodsIds, @Param("organId") Long organId);
|
IPage<OrderGoodsResp> selectGoods(@Param("page") IPage page, @Param("goodsIds") List<Long> goodsIds, @Param("organId") Long organId);
|
||||||
|
|
||||||
|
|
||||||
// default GoodsDO selectId(Long orderId, Long goodsId, Long organId) {
|
|
||||||
// return selectOne(new LambdaQueryWrapperX<GoodsDO>()
|
|
||||||
// }
|
|
||||||
// default List<GoodsDO> selectGoodsPlateList(List<Long> goodIds, Long organId) {
|
|
||||||
// return selectList(new LambdaQueryWrapperX<GoodsDO>()
|
|
||||||
// .eq(GoodsDO::getOrganId, organId)
|
|
||||||
// .inIfPresent(GoodsDO::getOrderId, goodIds)
|
|
||||||
// .select(GoodsDO::getGoodsId,GoodsDO::getGoodsName, GoodsDO::getMaterial, GoodsDO::getColor, GoodsDO::getTexture,GoodsDO::getThickness, GoodsDO::getSpec));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
List<NotPlanGoodsRespVO> selectGoodsPlateList(@Param("goodIds") List<Long> goodIds,@Param("organId") Long organId);
|
List<NotPlanGoodsRespVO> selectGoodsPlateList(@Param("goodIds") List<Long> goodIds,@Param("organId") Long organId);
|
||||||
|
|
||||||
@@ -182,4 +173,35 @@ public interface GoodsMapper extends BaseMapperX<GoodsDO> {
|
|||||||
|
|
||||||
|
|
||||||
IPage<PlateResList> selectPlanGoodsListByPlanId(@Param("page") IPage<PlateResList> page, @Param(Constants.WRAPPER) Wrapper<GoodsDO> wrapper);
|
IPage<PlateResList> selectPlanGoodsListByPlanId(@Param("page") IPage<PlateResList> page, @Param(Constants.WRAPPER) Wrapper<GoodsDO> wrapper);
|
||||||
|
|
||||||
|
List<GoodsReqVO> selectGoodsAndRemainPlate(@Param("ids") List<Long> ids,@Param("organId") Long organId);
|
||||||
|
|
||||||
|
|
||||||
|
IPage<OrderRespVOCopy> selectNoPlanOrderList(@Param("page") IPage page, @Param(Constants.WRAPPER) Wrapper<GoodsDO> wrapper);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
default int deletePlanGoods(List<Long> ids, Long organId) {
|
||||||
|
return update(new LambdaUpdateWrapper<GoodsDO>()
|
||||||
|
.set(GoodsDO::getPlanId, 0)
|
||||||
|
.eq(GoodsDO::getOrganId, organId)
|
||||||
|
.in(GoodsDO::getPlanId, ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
default List<GoodsDO> selectPlanGoodsListByPlanIdList(List<Long> planIds, Long organId) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<GoodsDO>()
|
||||||
|
.eq(GoodsDO::getOrganId, organId)
|
||||||
|
.eq(GoodsDO::getDeleted, false)
|
||||||
|
.in(GoodsDO::getPlanId,planIds)
|
||||||
|
.select(GoodsDO::getGoodsId,GoodsDO::getId,GoodsDO::getOrderId));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<PlateResList> selectPlateListByPlanId(@Param("planIds") List<Long> planIds, @Param("organId") Long organId);
|
||||||
|
|
||||||
|
|
||||||
|
List<OrderRoomBodyList> selectNoPlanRoomBody(@Param("orderIds") List<Long> orderIds, @Param("organId") Long organId);
|
||||||
}
|
}
|
||||||
+10
@@ -251,4 +251,14 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
|||||||
|
|
||||||
List<OrderGoodsResp> selectGoodsListByGoodsId(@Param(Constants.WRAPPER) QueryWrapperX<OrderDO> queryWrapperX);
|
List<OrderGoodsResp> selectGoodsListByGoodsId(@Param(Constants.WRAPPER) QueryWrapperX<OrderDO> queryWrapperX);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
default List<OrderDO> selectNoPlanOrderList(Long organId, List<Integer> statusList) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<OrderDO>()
|
||||||
|
.eqIfPresent(OrderDO::getOrganId, organId)
|
||||||
|
.eq(OrderDO::getDeleted, false)
|
||||||
|
.in(OrderDO::getStatus,statusList)
|
||||||
|
.select(OrderDO::getId));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -131,10 +131,11 @@ public interface OrderBodyMapper extends BaseMapperX<OrderBodyDO> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
default List<OrderBodyDO> selectOrderBodyList(List<Long> bodyIds, Long organId) {
|
default List<OrderBodyDO> selectOrderBodyList(List<Long> bodyIds,List<Long> orderIds, Long organId) {
|
||||||
return selectList(new LambdaQueryWrapperX<OrderBodyDO>()
|
return selectList(new LambdaQueryWrapperX<OrderBodyDO>()
|
||||||
.eq(OrderBodyDO::getOrganId, organId)
|
.eq(OrderBodyDO::getOrganId, organId)
|
||||||
.eq(OrderBodyDO::getDeleted,false)
|
.eq(OrderBodyDO::getDeleted,false)
|
||||||
|
.in(OrderBodyDO::getOrderId,orderIds)
|
||||||
.in(OrderBodyDO::getId, bodyIds)
|
.in(OrderBodyDO::getId, bodyIds)
|
||||||
.select(OrderBodyDO::getId,OrderBodyDO::getName,OrderBodyDO::getRoomName));
|
.select(OrderBodyDO::getId,OrderBodyDO::getName,OrderBodyDO::getRoomName));
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-14
@@ -5,7 +5,6 @@ import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
|||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPlatesDetailRespVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPlatesDetailRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRespVO;
|
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.plan.bo.OrderRoomBodyList;
|
|
||||||
import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.PrintOrderPackReqVO;
|
import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.PrintOrderPackReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy;
|
import com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy;
|
||||||
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateDetailReqVO;
|
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateDetailReqVO;
|
||||||
@@ -60,7 +59,7 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
|
|||||||
void deleteByPlateId(@Param("deletePlateIds") List<Long> deletePlateIds);
|
void deleteByPlateId(@Param("deletePlateIds") List<Long> deletePlateIds);
|
||||||
|
|
||||||
|
|
||||||
List<PrintOrderPackReqVO> selectPackList(@Param("orderIds") List<Long> orderIds, @Param("organId") Long organId);
|
List<PrintOrderPackReqVO> selectPackList(@Param("ids") List<Long> ids, @Param("organId") Long organId);
|
||||||
|
|
||||||
|
|
||||||
default int deleteByBodyId(Long bodyId, Long organId) {
|
default int deleteByBodyId(Long bodyId, Long organId) {
|
||||||
@@ -81,8 +80,6 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<OrderRoomBodyList> selectRoomBodyByOrderId( @Param("orderIds") List<Long> orderIds, @Param("organId") Long organId);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
default List<OrderItemDO> selectPlateIdList(List<Long> plateIds, Long organId) {
|
default List<OrderItemDO> selectPlateIdList(List<Long> plateIds, Long organId) {
|
||||||
@@ -108,15 +105,6 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
|
|||||||
IPage<OrderRespVOCopy> selectTestNum(@Param("page") IPage page,@Param("organId") Long organId);
|
IPage<OrderRespVOCopy> selectTestNum(@Param("page") IPage page,@Param("organId") Long organId);
|
||||||
|
|
||||||
|
|
||||||
|
List<PrintOrderPackReqVO> selectOrderPlateList(@Param("orderId") Long orderId,@Param("organId") Long organId);
|
||||||
default List<OrderItemDO> selectOrderPlateList(List<Long> plateIds, Long organId) {
|
|
||||||
return selectList(new LambdaQueryWrapperX<OrderItemDO>()
|
|
||||||
.eq(OrderItemDO::getOrganId,organId)
|
|
||||||
.inIfPresent(OrderItemDO::getPlateId, plateIds)
|
|
||||||
.select(OrderItemDO::getBodyId,OrderItemDO::getRoomId,OrderItemDO::getGroupId,OrderItemDO::getPlateId));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-1
@@ -120,7 +120,6 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
|
|||||||
|
|
||||||
List<Long> selectPlateIdListByBodyId(@Param("bodyId") Long bodyId, @Param("organId") Long organId);
|
List<Long> selectPlateIdListByBodyId(@Param("bodyId") Long bodyId, @Param("organId") Long organId);
|
||||||
|
|
||||||
List<PlateResList> selectPlateListByPlanId(@Param("planIds") List<Long> planIds, @Param("organId") Long organId);
|
|
||||||
|
|
||||||
// 根据需要删除的小板id查找具体信息
|
// 根据需要删除的小板id查找具体信息
|
||||||
List<PlateGoodsIdVO> selectPlateGoodsListByList(@Param("plates") List<Long> goodsIdList, @Param("orderId") Long orderId, @Param("organId") Long organId);
|
List<PlateGoodsIdVO> selectPlateGoodsListByList(@Param("plates") List<Long> goodsIdList, @Param("orderId") Long orderId, @Param("organId") Long organId);
|
||||||
|
|||||||
+9
@@ -62,5 +62,14 @@ public interface RemainPlateMapper extends BaseMapperX<RemainPlateDO> {
|
|||||||
List<RemainPlateDO> selectTestSQL(@Param("filed") String filed,@Param("planId") Long planId,@Param("organId") Long organId);
|
List<RemainPlateDO> selectTestSQL(@Param("filed") String filed,@Param("planId") Long planId,@Param("organId") Long organId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
default int deletePlanRemainPlate(List<Long> ids, Long organId) {
|
||||||
|
return update(new LambdaUpdateWrapper<RemainPlateDO>()
|
||||||
|
.set(RemainPlateDO::getPlanId, 0)
|
||||||
|
.eq(RemainPlateDO::getOrganId, organId)
|
||||||
|
.in(RemainPlateDO::getPlanId, ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// List<RemainPlateDO> selectTestSQL(@Param("sql") String sql);
|
// List<RemainPlateDO> selectTestSQL(@Param("sql") String sql);
|
||||||
}
|
}
|
||||||
|
|||||||
+109
-114
@@ -468,13 +468,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
OrderSource orderSource = new OrderSource();
|
OrderSource orderSource = new OrderSource();
|
||||||
|
|
||||||
|
|
||||||
// List<GoodsDO> goodsDOS = goodsMapper.selectList(new LambdaQueryWrapperX<GoodsDO>()
|
|
||||||
// .eq(GoodsDO::getOrderId, orderId)
|
|
||||||
// );
|
|
||||||
|
|
||||||
List<GoodsReqVO> goodsDOS = goodsMapper.selectGoodsList(orderId,getUserOrganId());
|
List<GoodsReqVO> goodsDOS = goodsMapper.selectGoodsList(orderId,getUserOrganId());
|
||||||
|
|
||||||
// PlanDO planDO = planMapper.selectByOrderId(orderId);
|
|
||||||
|
|
||||||
List<PlateDetialRespVO> plateDOS = plateMapper.selectPlateDetialList(orderId,getUserOrganId());
|
List<PlateDetialRespVO> plateDOS = plateMapper.selectPlateDetialList(orderId,getUserOrganId());
|
||||||
|
|
||||||
@@ -493,14 +488,6 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// for (PlateDetialRespVO plateDetailsRespVO : plateDOS) {
|
|
||||||
// for (ProcessGroupList groupNameList : plateDetailsRespVO.getProcessGroupLists()) {
|
|
||||||
// plateDetailsRespVO.setProcessGroupName(groupNameList.getGroupName());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// 造型数据的尺寸长度
|
// 造型数据的尺寸长度
|
||||||
Integer orderModelSize = plateDOS.size();
|
Integer orderModelSize = plateDOS.size();
|
||||||
|
|
||||||
@@ -515,13 +502,29 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
List<OptimizeBoardModelDO> optimizeBoardModelDOS = buildBoardByOrderId(orderId, ORDER_REMAIN_PLATE_MODEL, boardSize);
|
List<OptimizeBoardModelDO> optimizeBoardModelDOS = buildBoardByOrderId(orderId, ORDER_REMAIN_PLATE_MODEL, boardSize);
|
||||||
|
|
||||||
|
|
||||||
|
// 查询生产单对应的配件信息
|
||||||
|
List<PrintOrderPartsRespVO> printOrderPartsRespVOS = orderPartsMapper.selectPartList(Collections.singletonList(orderId), getUserOrganId());
|
||||||
|
|
||||||
|
|
||||||
|
// 查询生产单对应的包裹信息
|
||||||
|
List<PrintOrderPackReqVO> printOrderPackReqVOS = orderItemMapper.selectOrderPlateList(orderId, getUserOrganId());
|
||||||
|
|
||||||
|
|
||||||
|
// 统计每个订单的包装数量
|
||||||
|
printOrderPackReqVOS
|
||||||
|
.stream()
|
||||||
|
.filter(f->f
|
||||||
|
.getOrderId().equals(orderId))
|
||||||
|
.forEach(f->f.setPackNum(printOrderPackReqVOS.stream().filter(e -> e.getOrderId().equals(orderId)).map(PrintOrderPackReqVO::getPackId).toList().size()));
|
||||||
|
|
||||||
|
|
||||||
// orderSource.setPlan(planDO);
|
|
||||||
orderSource.setOrderList(Collections.singletonList(orderDO));
|
orderSource.setOrderList(Collections.singletonList(orderDO));
|
||||||
orderSource.setPlateList(plateDOS);
|
orderSource.setPlateList(plateDOS);
|
||||||
orderSource.setGoodsList(goodsDOS);
|
orderSource.setGoodsList(goodsDOS);
|
||||||
orderSource.setPlateModels(orderModelDOS);
|
orderSource.setPlateModels(orderModelDOS);
|
||||||
orderSource.setOptimizeBoardModelDOS(optimizeBoardModelDOS);
|
orderSource.setOptimizeBoardModelDOS(optimizeBoardModelDOS);
|
||||||
|
orderSource.setOrderPartsRespVOS(printOrderPartsRespVOS);
|
||||||
|
orderSource.setOrderPackReqVOS(printOrderPackReqVOS);
|
||||||
return orderSource;
|
return orderSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,27 +550,27 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
List<PlateDetialRespVO> plateDetialRespVOS = plateMapper.selectPlateListByGoodsIds(ids, getUserOrganId());
|
List<PlateDetialRespVO> plateDetialRespVOS = plateMapper.selectPlateListByGoodsIds(ids, getUserOrganId());
|
||||||
|
|
||||||
|
|
||||||
List<Long> bodyIds = plateDetialRespVOS.stream().map(PlateDetialRespVO::getBodyId).distinct().toList();
|
// List<Long> bodyIds = plateDetialRespVOS.stream().map(PlateDetialRespVO::getBodyId).distinct().toList();
|
||||||
|
//
|
||||||
|
//
|
||||||
List<OrderBodyDO> orderBodyDOS = orderBodyMapper.selectOrderBodyList(bodyIds, getUserOrganId());
|
// List<OrderBodyDO> orderBodyDOS = orderBodyMapper.selectOrderBodyList(bodyIds,orderIds, getUserOrganId());
|
||||||
|
//
|
||||||
|
//
|
||||||
List<PlateDetialRespVO> detialRespVOS = new ArrayList<>();
|
//// List<PlateDetialRespVO> detialRespVOS = new ArrayList<>();
|
||||||
|
//
|
||||||
|
//
|
||||||
for (OrderBodyDO orderBodyDO : orderBodyDOS) {
|
// for (OrderBodyDO orderBodyDO : orderBodyDOS) {
|
||||||
|
//
|
||||||
detialRespVOS.addAll(plateDetialRespVOS.stream().filter(f -> f.getBodyId().equals(orderBodyDO.getId())).peek(m -> {
|
// plateDetialRespVOS.stream().filter(f -> f.getBodyId().equals(orderBodyDO.getId())).forEach(m -> {
|
||||||
m.setBodyName(orderBodyDO.getName());
|
// m.setBodyName(orderBodyDO.getName());
|
||||||
m.setRoomName(orderBodyDO.getRoomName());
|
// m.setRoomName(orderBodyDO.getRoomName());
|
||||||
}).toList());
|
// });
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (PlateDetialRespVO plateDetailsRespVO : detialRespVOS) {
|
for (PlateDetialRespVO plateDetailsRespVO : plateDetialRespVOS) {
|
||||||
String name = "";
|
String name = "";
|
||||||
if(!plateDetailsRespVO.getProcessGroupLists().isEmpty()) {
|
if(!plateDetailsRespVO.getProcessGroupLists().isEmpty()) {
|
||||||
for (ProcessGroupList groupNameList : plateDetailsRespVO.getProcessGroupLists()) {
|
for (ProcessGroupList groupNameList : plateDetailsRespVO.getProcessGroupLists()) {
|
||||||
@@ -579,17 +582,17 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
}
|
}
|
||||||
plateDetailsRespVO.setProcessGroupName(name);
|
plateDetailsRespVO.setProcessGroupName(name);
|
||||||
|
|
||||||
plateDetailsRespVO.setGoodsId(goodsDOS
|
// plateDetailsRespVO.setGoodsId(goodsDOS
|
||||||
.stream()
|
// .stream()
|
||||||
.filter(f->f.getId().equals(plateDetailsRespVO.getId()))
|
// .filter(f->f.getId().equals(plateDetailsRespVO.getId()))
|
||||||
.map(GoodsReqVO::getGoodsId)
|
// .map(GoodsReqVO::getGoodsId)
|
||||||
.findAny().orElse(null));
|
// .findAny().orElse(null));
|
||||||
|
|
||||||
plateDetailsRespVO.setGoodsName(goodsDOS
|
// plateDetailsRespVO.setGoodsName(goodsDOS
|
||||||
.stream()
|
// .stream()
|
||||||
.filter(f->f.getId().equals(plateDetailsRespVO.getId()))
|
// .filter(f->f.getId().equals(plateDetailsRespVO.getId()))
|
||||||
.map(GoodsReqVO::getGoodsName)
|
// .map(GoodsReqVO::getGoodsName)
|
||||||
.findAny().orElse(null));
|
// .findAny().orElse(null));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,7 +602,10 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
// 造型数据的尺寸长度
|
// 造型数据的尺寸长度
|
||||||
Integer orderModelSize = plateDetialRespVOS.size();
|
Integer orderModelSize = plateDetialRespVOS.size();
|
||||||
|
|
||||||
List<OrderModelDO> orderModelDOS = buildRespByOrderIds(orderIds, ORDER_PLATE_MODEL, orderModelSize);
|
// 需要查询小板造型信息的板材ID
|
||||||
|
List<Long> plateIds = plateDetialRespVOS.stream().map(PlateDetialRespVO::getPlateId).toList();
|
||||||
|
|
||||||
|
List<OrderModelDO> orderModelDOS = buildRespByPlateIds(plateIds, orderModelSize);
|
||||||
|
|
||||||
|
|
||||||
// 大板数据的尺寸长度
|
// 大板数据的尺寸长度
|
||||||
@@ -617,7 +623,18 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
List<PrintOrderPartsRespVO> printOrderPartsRespVOS = orderPartsMapper.selectPartList(orderIds, getUserOrganId());
|
List<PrintOrderPartsRespVO> printOrderPartsRespVOS = orderPartsMapper.selectPartList(orderIds, getUserOrganId());
|
||||||
|
|
||||||
// 查询生产单对应的包裹信息
|
// 查询生产单对应的包裹信息
|
||||||
List<PrintOrderPackReqVO> printOrderPackReqVOS = orderItemMapper.selectPackList(orderIds, getUserOrganId());
|
List<PrintOrderPackReqVO> printOrderPackReqVOS = orderItemMapper.selectPackList(ids, getUserOrganId());
|
||||||
|
|
||||||
|
for (Long orderId : orderIds) {
|
||||||
|
|
||||||
|
// 统计每个订单的包装数量
|
||||||
|
printOrderPackReqVOS
|
||||||
|
.stream()
|
||||||
|
.filter(f->f.getOrderId().equals(orderId))
|
||||||
|
.forEach(f->f.setPackNum(printOrderPackReqVOS.stream().filter(e -> e.getOrderId().equals(orderId)).map(PrintOrderPackReqVO::getPackId).toList().size()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return OrderSource.builder()
|
return OrderSource.builder()
|
||||||
.orderList(orderDOS)
|
.orderList(orderDOS)
|
||||||
@@ -635,24 +652,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
|
|
||||||
public OrderSource getOrderSourceByGoodId(List<Long> ids) {
|
public OrderSource getOrderSourceByGoodId(List<Long> ids) {
|
||||||
|
|
||||||
// PlanDO planDO = planMapper.selectById(planId);
|
|
||||||
// if (Objects.isNull(planDO)) {
|
|
||||||
// throw exception(PLAN_NOT_EXISTS);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// List<GoodsDO> goodsDOS = goodsMapper.selectBatchIds(goodIds);
|
|
||||||
|
|
||||||
List<GoodsReqVO> goodsReqVOS = goodsMapper.selectJoinList(GoodsReqVO.class, new MPJLambdaWrapperX<GoodsDO>()
|
|
||||||
|
|
||||||
.leftJoin(RemainPlateDO.class, RemainPlateDO::getGoodsId, GoodsDO::getId)
|
|
||||||
.selectAll(GoodsDO.class)
|
|
||||||
.selectAs(RemainPlateDO::getId,"remainId")
|
|
||||||
.isNotNull(PlanItemDO::getId)
|
|
||||||
.eq(GoodsDO::getOrganId, getUserOrganId())
|
|
||||||
.in(GoodsDO::getId, ids));
|
|
||||||
|
|
||||||
|
|
||||||
|
List<GoodsReqVO> goodsReqVOS = goodsMapper.selectGoodsAndRemainPlate(ids, getUserOrganId());
|
||||||
|
|
||||||
List<Long> orderIds = goodsReqVOS.stream().map(GoodsReqVO::getOrderId).distinct().toList();
|
List<Long> orderIds = goodsReqVOS.stream().map(GoodsReqVO::getOrderId).distinct().toList();
|
||||||
|
|
||||||
@@ -662,26 +663,23 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
List<PlateDetialRespVO> plateDetialRespVOS = plateMapper.selectPlateListByGoodsIds(ids, getUserOrganId());
|
List<PlateDetialRespVO> plateDetialRespVOS = plateMapper.selectPlateListByGoodsIds(ids, getUserOrganId());
|
||||||
|
|
||||||
|
|
||||||
List<Long> bodyIds = plateDetialRespVOS.stream().map(PlateDetialRespVO::getBodyId).distinct().toList();
|
// List<Long> bodyIds = plateDetialRespVOS.stream().map(PlateDetialRespVO::getBodyId).distinct().toList();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// List<OrderBodyDO> orderBodyDOS = orderBodyMapper.selectOrderBodyList(bodyIds,orderIds, getUserOrganId());
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// for (OrderBodyDO orderBodyDO : orderBodyDOS) {
|
||||||
|
//
|
||||||
|
// plateDetialRespVOS.stream().filter(f -> f.getBodyId().equals(orderBodyDO.getId())).forEach(m -> {
|
||||||
|
// m.setBodyName(orderBodyDO.getName());
|
||||||
|
// m.setRoomName(orderBodyDO.getRoomName());
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
List<OrderBodyDO> orderBodyDOS = orderBodyMapper.selectOrderBodyList(bodyIds, getUserOrganId());
|
for (PlateDetialRespVO plateDetailsRespVO : plateDetialRespVOS) {
|
||||||
|
|
||||||
|
|
||||||
List<PlateDetialRespVO> detialRespVOS = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
for (OrderBodyDO orderBodyDO : orderBodyDOS) {
|
|
||||||
|
|
||||||
detialRespVOS.addAll(plateDetialRespVOS.stream().filter(f -> f.getBodyId().equals(orderBodyDO.getId())).peek(m -> {
|
|
||||||
m.setBodyName(orderBodyDO.getName());
|
|
||||||
m.setRoomName(orderBodyDO.getRoomName());
|
|
||||||
}).toList());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (PlateDetialRespVO plateDetailsRespVO : detialRespVOS) {
|
|
||||||
String name = "";
|
String name = "";
|
||||||
if(!plateDetailsRespVO.getProcessGroupLists().isEmpty()) {
|
if(!plateDetailsRespVO.getProcessGroupLists().isEmpty()) {
|
||||||
for (ProcessGroupList groupNameList : plateDetailsRespVO.getProcessGroupLists()) {
|
for (ProcessGroupList groupNameList : plateDetailsRespVO.getProcessGroupLists()) {
|
||||||
@@ -694,25 +692,22 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
|
|
||||||
plateDetailsRespVO.setProcessGroupName(name);
|
plateDetailsRespVO.setProcessGroupName(name);
|
||||||
|
|
||||||
plateDetailsRespVO.setGoodsId(goodsReqVOS
|
// // todo 这样写混单时同样适用,后面加混单后这里不用修改
|
||||||
.stream()
|
// plateDetailsRespVO.setGoodsId(goodsReqVOS
|
||||||
.filter(f->f.getId().equals(plateDetailsRespVO.getId()))
|
// .stream()
|
||||||
.map(GoodsReqVO::getGoodsId)
|
// .filter(f->f.getId().equals(plateDetailsRespVO.getId()))
|
||||||
.findAny().orElse(null));
|
// .map(GoodsReqVO::getGoodsId)
|
||||||
|
// .findAny().orElse(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 造型数据的尺寸长度
|
// 造型数据的尺寸长度
|
||||||
Integer orderModelSize = plateDetialRespVOS.size();
|
Integer orderModelSize = plateDetialRespVOS.size();
|
||||||
|
|
||||||
List<OrderModelDO> orderModelDOS = buildRespByOrderIds(orderIds, ORDER_PLATE_MODEL, orderModelSize);
|
// 需要查询的小板造型信息的板材ID
|
||||||
|
List<Long> plateIds = plateDetialRespVOS.stream().map(PlateDetialRespVO::getPlateId).toList();
|
||||||
|
|
||||||
|
List<OrderModelDO> orderModelDOS = buildRespByPlateIds(plateIds, orderModelSize);
|
||||||
// // 查询生产单对应的配件信息
|
|
||||||
// List<PrintOrderPartsRespVO> printOrderPartsRespVOS = orderPartsMapper.selectPartList(orderIds, getUserOrganId());
|
|
||||||
//
|
|
||||||
// // 查询生产单对应的包裹信息
|
|
||||||
// List<PrintOrderPackReqVO> printOrderPackReqVOS = orderItemMapper.selectPackList(orderIds, getUserOrganId());
|
|
||||||
|
|
||||||
return OrderSource.builder()
|
return OrderSource.builder()
|
||||||
.orderList(orderDOS)
|
.orderList(orderDOS)
|
||||||
@@ -748,25 +743,25 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
batchSaveBoardModel(req.getOptimizeBoardModelDOS());
|
batchSaveBoardModel(req.getOptimizeBoardModelDOS());
|
||||||
|
|
||||||
|
|
||||||
// 保存余料板的数据
|
// // 保存余料板的数据
|
||||||
if (CollectionUtil.isNotEmpty(req.getOptimizeRemainPlates())) {
|
// if (CollectionUtil.isNotEmpty(req.getOptimizeRemainPlates())) {
|
||||||
|
//
|
||||||
List<RemainPlateDO> remainPlateDoS = BeanUtils.toBean(req.getOptimizeRemainPlates(), RemainPlateDO.class)
|
// List<RemainPlateDO> remainPlateDoS = BeanUtils.toBean(req.getOptimizeRemainPlates(), RemainPlateDO.class)
|
||||||
.stream()
|
// .stream()
|
||||||
.map(m -> m.setUseType(1))
|
// .map(m -> m.setUseType(1))
|
||||||
.map(m -> m.setOutLineJson("")).toList();
|
// .map(m -> m.setOutLineJson("")).toList();
|
||||||
|
//
|
||||||
|
//
|
||||||
List<RemainPlateDO> insertPlateDoS = remainPlateDoS.stream().filter(f -> f.getId() == null).toList();
|
// List<RemainPlateDO> insertPlateDoS = remainPlateDoS.stream().filter(f -> f.getId() == null).toList();
|
||||||
|
//
|
||||||
List<RemainPlateDO> updatePlateDoS = remainPlateDoS.stream().filter(f -> f.getId() != null).toList();
|
// List<RemainPlateDO> updatePlateDoS = remainPlateDoS.stream().filter(f -> f.getId() != null).toList();
|
||||||
|
//
|
||||||
Boolean aBoolean = insertPlateDoS.isEmpty() ? null : remainPlateMapper.insertBatch(insertPlateDoS);
|
// Boolean aBoolean = insertPlateDoS.isEmpty() ? null : remainPlateMapper.insertBatch(insertPlateDoS);
|
||||||
|
//
|
||||||
Boolean bBoolean = updatePlateDoS.isEmpty() ? null : remainPlateMapper.updateBatch(updatePlateDoS);
|
// Boolean bBoolean = updatePlateDoS.isEmpty() ? null : remainPlateMapper.updateBatch(updatePlateDoS);
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -832,12 +827,12 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<OrderModelDO> buildRespByOrderIds(Collection<Long> orderIds, String index, Integer size) {
|
private List<OrderModelDO> buildRespByPlateIds(Collection<Long> plateIds, Integer size) {
|
||||||
List<FieldValue> fieldValues = orderIds.stream().map(FieldValue::of).toList();
|
List<FieldValue> fieldValues = plateIds.stream().map(FieldValue::of).toList();
|
||||||
SearchRequest.Builder builder = new SearchRequest.Builder();
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
||||||
builder.index(index);
|
builder.index(OptimizePlanService.ORDER_PLATE_MODEL);
|
||||||
builder.size(size);
|
builder.size(size);
|
||||||
builder.query(q -> q.terms(b -> b.field("orderId").terms(e -> e.value(fieldValues))));
|
builder.query(q -> q.terms(b -> b.field("plateId").terms(e -> e.value(fieldValues))));
|
||||||
try {
|
try {
|
||||||
SearchResponse<OrderModelDO> search = elasticsearchClient.search(builder.build(), OrderModelDO.class);
|
SearchResponse<OrderModelDO> search = elasticsearchClient.search(builder.build(), OrderModelDO.class);
|
||||||
List<Hit<OrderModelDO>> hits = search.hits().hits();
|
List<Hit<OrderModelDO>> hits = search.hits().hits();
|
||||||
|
|||||||
-1
@@ -65,7 +65,6 @@ public interface PlanService {
|
|||||||
|
|
||||||
Boolean addPlate(AddPlateReq req);
|
Boolean addPlate(AddPlateReq req);
|
||||||
|
|
||||||
Boolean cancellation(Long id);
|
|
||||||
|
|
||||||
PageResult<PlateResList> getPlateByPlanId(GetPlateByPlanIdVO vo);
|
PageResult<PlateResList> getPlateByPlanId(GetPlateByPlanIdVO vo);
|
||||||
|
|
||||||
|
|||||||
+58
-104
@@ -9,7 +9,6 @@ import co.elastic.clients.elasticsearch.core.SearchRequest;
|
|||||||
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
||||||
import co.elastic.clients.elasticsearch.core.search.Hit;
|
import co.elastic.clients.elasticsearch.core.search.Hit;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||||
@@ -43,11 +42,11 @@ import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper;
|
|||||||
import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper;
|
import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper;
|
||||||
import com.cf.imes.module.executor.dal.mysql.planitem.PlanItemMapper;
|
import com.cf.imes.module.executor.dal.mysql.planitem.PlanItemMapper;
|
||||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.remainplaten.RemainPlateMapper;
|
||||||
import com.cf.imes.module.executor.enums.OrderStatusEnum;
|
import com.cf.imes.module.executor.enums.OrderStatusEnum;
|
||||||
import com.cf.imes.module.executor.service.optimizeplan.OptimizePlanService;
|
import com.cf.imes.module.executor.service.optimizeplan.OptimizePlanService;
|
||||||
import com.cf.imes.module.system.api.machine.MachineApi;
|
import com.cf.imes.module.system.api.machine.MachineApi;
|
||||||
import com.cf.imes.module.system.api.machine.dto.CuttingRespDTO;
|
import com.cf.imes.module.system.api.machine.dto.CuttingRespDTO;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -56,7 +55,6 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -105,6 +103,9 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
@Resource
|
@Resource
|
||||||
private OrderBodyMapper orderBodyMapper;
|
private OrderBodyMapper orderBodyMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RemainPlateMapper remainPlateMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IdentifierGenerator identifierGenerator;
|
private IdentifierGenerator identifierGenerator;
|
||||||
|
|
||||||
@@ -127,6 +128,7 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
|
|
||||||
List<GoodsDO> goodsDOS = new ArrayList<>();
|
List<GoodsDO> goodsDOS = new ArrayList<>();
|
||||||
|
|
||||||
|
// <大板实际ID,排单ID>
|
||||||
Map<Long,Long> goodsPlanId = new HashMap<>();
|
Map<Long,Long> goodsPlanId = new HashMap<>();
|
||||||
|
|
||||||
Map<Long, List<PlanSaveReqVO.Item>> groupedItems = itemList.stream()
|
Map<Long, List<PlanSaveReqVO.Item>> groupedItems = itemList.stream()
|
||||||
@@ -149,24 +151,12 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
|
|
||||||
goodsPlanId.put(entry.getKey(), plan.getId());
|
goodsPlanId.put(entry.getKey(), plan.getId());
|
||||||
|
|
||||||
// Set<Long> itemIds = plateMapper.selectBatchOrderIdsAndGoodsIds(items,getUserOrganId());
|
|
||||||
|
|
||||||
List<Long> goodsIds = items.stream().map(PlanSaveReqVO.Item::getId).toList();
|
List<Long> goodsIds = items.stream().map(PlanSaveReqVO.Item::getId).toList();
|
||||||
|
|
||||||
List<GoodsDO> goodsDOList = goodsMapper.selectPlanGoodsList(goodsIds, getUserOrganId()).stream().map(m -> m.setPlanId(plan.getId())).toList();
|
List<GoodsDO> goodsDOList = goodsMapper.selectPlanGoodsList(goodsIds, getUserOrganId()).stream().map(m -> m.setPlanId(plan.getId())).toList();
|
||||||
|
|
||||||
goodsDOS.addAll(goodsDOList);
|
goodsDOS.addAll(goodsDOList);
|
||||||
|
|
||||||
// if (CollectionUtil.isNotEmpty(itemIds)) {
|
|
||||||
//
|
|
||||||
// for (Long itemId : itemIds) {
|
|
||||||
// planItemDOS.add(PlanItemDO.builder()
|
|
||||||
// .planId(plan.getId())
|
|
||||||
// .itemId(itemId)
|
|
||||||
// .build());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,29 +169,6 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
|
|
||||||
return goodsPlanId;
|
return goodsPlanId;
|
||||||
|
|
||||||
//
|
|
||||||
// // 插入
|
|
||||||
// PlanDO plan = BeanUtils.toBean(createReqVO, PlanDO.class);
|
|
||||||
// plan.setSort(0L);
|
|
||||||
// String orderNos = itemList.stream().map(PlanSaveReqVO.Item::getOrderId).distinct().toList().toString();
|
|
||||||
// plan.setOrderNos(orderNos);
|
|
||||||
// plan.setProduceTime(null);
|
|
||||||
// planMapper.insert(plan);
|
|
||||||
//
|
|
||||||
// // 修改对应的生产单的状态为 已排单
|
|
||||||
// List<Long> orderIds = itemList.stream().map(PlanSaveReqVO.Item::getOrderId).toList();
|
|
||||||
//
|
|
||||||
// List<OrderDO> orderDOS = orderMapper.selectBatchIds(orderIds);
|
|
||||||
//
|
|
||||||
// List<OrderDO> orderDOList = orderDOS.stream().map(o -> o.setStatus(OrderStatusEnum.SORTED.getStatus())).toList();
|
|
||||||
//
|
|
||||||
// orderMapper.updateBatch(orderDOList);
|
|
||||||
//
|
|
||||||
// Long planId = plan.getId();
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // 返回
|
|
||||||
// return plan.getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -224,7 +191,7 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
// todo 目前只解决非混单的情况
|
// todo 目前只解决非混单的情况
|
||||||
Long goodsIds = BeanUtils.toBean(goodsMapper.selectPlanGoods(plan.getId(), getUserOrganId()).stream().map(GoodsDO::getGoodsId).toList(), Long.class).get(0);
|
Long goodsIds = BeanUtils.toBean(goodsMapper.selectPlanGoods(plan.getId(), getUserOrganId()).stream().map(GoodsDO::getGoodsId).toList(), Long.class).get(0);
|
||||||
|
|
||||||
if(goodsId.equals(goodsIds)){
|
if(!goodsId.equals(goodsIds)){
|
||||||
throw exception(PLATE_ERROR);
|
throw exception(PLATE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +205,7 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
|
|
||||||
if (!updateReqVO.getDeleteIds().isEmpty()){
|
if (!updateReqVO.getDeleteIds().isEmpty()){
|
||||||
|
|
||||||
goodsDOS.addAll(goodsMapper.selectPlanGoodsList(ids, getUserOrganId()).stream().map(m -> m.setPlanId(null)).toList());
|
goodsDOS.addAll(goodsMapper.selectPlanGoodsList(updateReqVO.getDeleteIds(), getUserOrganId()).stream().map(m -> m.setPlanId(null)).toList());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,8 +219,8 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
planMapper.updateById(plan);
|
planMapper.updateById(plan);
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// // todo 目前只解决非混单的情况,混单的情况待解决,这个逻辑目前应该不用,排单是否开料判断了,可保留,万一以后需求更改
|
// // todo 目前只解决非混单的情况,混单的情况待解决,这个逻辑目前应该不用(这个逻辑用于判断大板下的小板是否开料,后期应该可用于混单时增加的判断),排单是否开料判断了,可保留,万一以后需求更改
|
||||||
// if(!updateReqVO.getItemList().isEmpty()){
|
// if(!updateReqVO.getItemList().isEmpty()){
|
||||||
//
|
//
|
||||||
// List<OptimizeBoardModelDO> optimizeBoardModelDOS = buildBoardByPlanId(plan.getId(), ORDER_REMAIN_PLATE_MODEL, 10);
|
// List<OptimizeBoardModelDO> optimizeBoardModelDOS = buildBoardByPlanId(plan.getId(), ORDER_REMAIN_PLATE_MODEL, 10);
|
||||||
@@ -330,18 +297,23 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除排单信息,排单明细表信息,ES优化数据
|
// 删除排单信息,商品表里的 planId , ES优化数据,更新排单对应的余料板的排单ID为0
|
||||||
planMapper.deleteBatchIds(ids);
|
planMapper.deleteBatchIds(ids);
|
||||||
planItemMapper.delete(new LambdaQueryWrapperX<PlanItemDO>().in(PlanItemDO::getPlanId, ids));
|
// planItemMapper.delete(new LambdaQueryWrapperX<PlanItemDO>().in(PlanItemDO::getPlanId, ids));
|
||||||
|
goodsMapper.deletePlanGoods(ids,getUserOrganId());
|
||||||
|
remainPlateMapper.deletePlanRemainPlate(ids,getUserOrganId());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 排单对应的自增板的删除 todo 目前值解决了非混单的情况
|
// 排单对应的自增板的删除 todo 目前值解决了非混单的情况
|
||||||
List<OptimizeBoardModelDO> boardModelDOS = buildBoardByPlanIds(ids, ORDER_REMAIN_PLATE_MODEL, ids.size());
|
List<OptimizeBoardModelDO> boardModelDOS = buildBoardByPlanIds(ids, ORDER_REMAIN_PLATE_MODEL, ids.size());
|
||||||
if(!boardModelDOS.isEmpty()) {
|
if(!boardModelDOS.isEmpty()) {
|
||||||
|
|
||||||
List<Long> goodsIds = boardModelDOS.stream().map(OptimizeBoardModelDO::getGoodsId).toList();
|
// List<Long> goodsIds = boardModelDOS.stream().map(OptimizeBoardModelDO::getGoodsId).toList();
|
||||||
|
|
||||||
List<Long> goodsIdList = goodsMapper.selectListByGoodsIdList(goodsIds, orderIds, getUserOrganId()).stream().map(GoodsDO::getId).toList();
|
// List<Long> goodsIdList = goodsMapper.selectListByGoodsIdList(goodsIds, orderIds, getUserOrganId()).stream().map(GoodsDO::getId).toList();
|
||||||
|
|
||||||
|
List<Long> goodsIdList = goodsMapper.selectPlanGoodsListByPlanIdList(ids, getUserOrganId()).stream().map(GoodsDO::getId).toList();
|
||||||
|
|
||||||
List<PlateDO> plateDOS = plateMapper.selectPlateIdList(goodsIdList, getUserOrganId());
|
List<PlateDO> plateDOS = plateMapper.selectPlateIdList(goodsIdList, getUserOrganId());
|
||||||
if(!plateDOS.isEmpty()) {
|
if(!plateDOS.isEmpty()) {
|
||||||
@@ -354,11 +326,6 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 目前生产单的状态已经去除待排单,所以无需修改生产单的状态
|
|
||||||
// List<OrderDO> orderDOS = orderMapper.selectBatchIds(orderIds).stream().map(m -> m.setStatus(OrderStatusEnum.SORTED.getStatus())).collect(Collectors.toList());
|
|
||||||
// orderMapper.updateBatch(orderDOS);
|
|
||||||
|
|
||||||
|
|
||||||
// 删除排单对应的优化生产数据
|
// 删除排单对应的优化生产数据
|
||||||
deleteByPlanId(ids, ORDER_REMAIN_PLATE_MODEL);
|
deleteByPlanId(ids, ORDER_REMAIN_PLATE_MODEL);
|
||||||
|
|
||||||
@@ -402,7 +369,7 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
throw exception(PLAN_NOT_EXISTS);
|
throw exception(PLAN_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(planDO.getStatus().equals(PlanStatusEnum.OPENING.getStatus()) && planDO.getMachineId().equals(machineId)){
|
if(planDO.getStatus().equals(PlanStatusEnum.OPENING.getStatus()) || planDO.getStatus().equals(PlanStatusEnum.OPENED.getStatus())){
|
||||||
throw exception(LIST_CHANGES_ARE_PROHIBITED);
|
throw exception(LIST_CHANGES_ARE_PROHIBITED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,34 +393,41 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlanRespVO getPlan(Long id) {
|
public PlanRespVO getPlan(Long id) {
|
||||||
PlanDO planDO = planMapper.selectById(id);
|
|
||||||
MPJLambdaWrapper<OrderItemDO> wrapper = new MPJLambdaWrapperX<OrderItemDO>().select(OrderItemDO::getOrderId)
|
|
||||||
.rightJoin(PlanItemDO.class, PlanItemDO::getItemId, OrderItemDO::getId)
|
|
||||||
.isNotNull(OrderItemDO::getId);
|
|
||||||
Set<Long> orderIds = orderItemMapper.selectJoinList(OrderItemDO.class, wrapper).stream().map(OrderItemDO::getOrderId).collect(Collectors.toSet());
|
|
||||||
|
|
||||||
/*Set<Long> orderIds = planOrderMapper.selectList(new LambdaQueryWrapperX<PlanOrderDO>().eq(PlanOrderDO::getPlanId, planDO.getPlanNo()))
|
PlanDO planDO = planMapper.selectById(id);
|
||||||
.stream()
|
|
||||||
.map(e -> e.getOrderId())
|
if ( planDO== null) {
|
||||||
.collect(Collectors.toSet());*/
|
throw exception(PLAN_NOT_EXISTS);
|
||||||
PlanRespVO respVO = BeanUtils.toBean(planDO, PlanRespVO.class);
|
}
|
||||||
List<GoodsDO> goodsDOS = goodsMapper.selectList(new LambdaQueryWrapperX<GoodsDO>()
|
|
||||||
.eq(GoodsDO::getOrganId,getUserOrganId())
|
return BeanUtils.toBean(planDO, PlanRespVO.class);
|
||||||
.in(GoodsDO::getOrderId, orderIds));
|
|
||||||
List<PlateDO> plateDOS = plateMapper.selectList(new LambdaQueryWrapperX<PlateDO>()
|
// MPJLambdaWrapper<OrderItemDO> wrapper = new MPJLambdaWrapperX<OrderItemDO>().select(OrderItemDO::getOrderId)
|
||||||
.eq(PlateDO::getOrganId,getUserOrganId())
|
// .rightJoin(PlanItemDO.class, PlanItemDO::getItemId, OrderItemDO::getId)
|
||||||
.in(PlateDO::getGoodsId, goodsDOS.stream().map(GoodsDO::getGoodsId).collect(Collectors.toSet())));
|
// .isNotNull(OrderItemDO::getId);
|
||||||
List<PlateInfoVO> plateInfoVOS = goodsDOS.stream().map(e -> PlateInfoVO.builder()
|
// Set<Long> orderIds = orderItemMapper.selectJoinList(OrderItemDO.class, wrapper).stream().map(OrderItemDO::getOrderId).collect(Collectors.toSet());
|
||||||
.material(e.getMaterial())
|
//
|
||||||
.width(e.getWidth())
|
// /*Set<Long> orderIds = planOrderMapper.selectList(new LambdaQueryWrapperX<PlanOrderDO>().eq(PlanOrderDO::getPlanId, planDO.getPlanNo()))
|
||||||
.height(e.getHeight())
|
// .stream()
|
||||||
.thickness(e.getThickness())
|
// .map(e -> e.getOrderId())
|
||||||
.area(e.getHeight().multiply(e.getWidth()).setScale(2, RoundingMode.HALF_UP))
|
// .collect(Collectors.toSet());*/
|
||||||
.count(plateDOS.stream().filter(f -> Objects.equals(f.getGoodsId(), e.getGoodsId())).collect(Collectors.toSet()).size())
|
// List<GoodsDO> goodsDOS = goodsMapper.selectList(new LambdaQueryWrapperX<GoodsDO>()
|
||||||
.build())
|
// .eq(GoodsDO::getOrganId,getUserOrganId())
|
||||||
.collect(Collectors.toList());
|
// .in(GoodsDO::getOrderId, orderIds));
|
||||||
respVO.setPlateInfoList(plateInfoVOS);
|
// List<PlateDO> plateDOS = plateMapper.selectList(new LambdaQueryWrapperX<PlateDO>()
|
||||||
return respVO;
|
// .eq(PlateDO::getOrganId,getUserOrganId())
|
||||||
|
// .in(PlateDO::getGoodsId, goodsDOS.stream().map(GoodsDO::getGoodsId).collect(Collectors.toSet())));
|
||||||
|
// List<PlateInfoVO> plateInfoVOS = goodsDOS.stream().map(e -> PlateInfoVO.builder()
|
||||||
|
// .material(e.getMaterial())
|
||||||
|
// .width(e.getWidth())
|
||||||
|
// .height(e.getHeight())
|
||||||
|
// .thickness(e.getThickness())
|
||||||
|
// .area(e.getHeight().multiply(e.getWidth()).setScale(2, RoundingMode.HALF_UP))
|
||||||
|
// .count(plateDOS.stream().filter(f -> Objects.equals(f.getGoodsId(), e.getGoodsId())).collect(Collectors.toSet()).size())
|
||||||
|
// .build())
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
// respVO.setPlateInfoList(plateInfoVOS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -542,8 +516,8 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
// 根据排单ID查询ES中的优化数据 todo 目前只解决无混单的情况,混单情况待解决
|
// 根据排单ID查询ES中的优化数据 todo 目前只解决无混单的情况,混单情况待解决
|
||||||
List<OptimizeBoardModelDO> optimizeBoardModelDOS = buildBoardByPlanIds(planIds, ORDER_REMAIN_PLATE_MODEL, infoVOList.size());
|
List<OptimizeBoardModelDO> optimizeBoardModelDOS = buildBoardByPlanIds(planIds, ORDER_REMAIN_PLATE_MODEL, infoVOList.size());
|
||||||
|
|
||||||
for (OptimizeBoardModelDO optimizeBoardModelDO : optimizeBoardModelDOS) {
|
// for (OptimizeBoardModelDO optimizeBoardModelDO : optimizeBoardModelDOS) {
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 获取排单对应的生产单的信息
|
// 获取排单对应的生产单的信息
|
||||||
List<PlanOrderRespVO> planOrderRespVOS = planItemMapper.selectOrderList(planIds, getUserOrganId());
|
List<PlanOrderRespVO> planOrderRespVOS = planItemMapper.selectOrderList(planIds, getUserOrganId());
|
||||||
@@ -972,24 +946,6 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Boolean cancellation(Long id) {
|
|
||||||
PlanDO planDO = planMapper.selectById(id);
|
|
||||||
if (planDO == null) {
|
|
||||||
throw exception(PLAN_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
// if (planDO.getStatus().equals(PlanStatusEnum.NEWORDER.getStatus()) || planDO.getStatus().equals(PlanStatusEnum.BOARDHASBEENAPPLIEDFOR.getStatus())) {
|
|
||||||
// throw exception(PLAN_NOT_ALLOW_CANCEL);
|
|
||||||
// }
|
|
||||||
Set<Long> itemIds = planItemMapper.selectList(new LambdaQueryWrapperX<PlanItemDO>()
|
|
||||||
.eq(PlanItemDO::getOrganId,getUserOrganId())
|
|
||||||
.eq(PlanItemDO::getPlanId, id))
|
|
||||||
.stream().map(PlanItemDO::getItemId)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
plateMapper.update(new LambdaUpdateWrapper<PlateDO>().in(PlateDO::getId, itemIds).set(PlateDO::getIsCancel, Boolean.TRUE));
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<PlateResList> getPlateByPlanId(GetPlateByPlanIdVO vo) {
|
public PageResult<PlateResList> getPlateByPlanId(GetPlateByPlanIdVO vo) {
|
||||||
@@ -1046,6 +1002,7 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
MPJLambdaWrapperX<OrderDO> lambdaWrapperX = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<OrderDO> lambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||||
lambdaWrapperX.leftJoin(GoodsDO.class, GoodsDO::getOrderId, OrderDO::getId)
|
lambdaWrapperX.leftJoin(GoodsDO.class, GoodsDO::getOrderId, OrderDO::getId)
|
||||||
.eq(GoodsDO::getOrganId,getUserOrganId())
|
.eq(GoodsDO::getOrganId,getUserOrganId())
|
||||||
|
.eq(GoodsDO::getDeleted,false)
|
||||||
.eq(GoodsDO::getPlanId, pageReqVO.getPlanId())
|
.eq(GoodsDO::getPlanId, pageReqVO.getPlanId())
|
||||||
.distinct();
|
.distinct();
|
||||||
|
|
||||||
@@ -1090,7 +1047,7 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
public List<PlateResList> getPlateList(List<Long> planIds) {
|
public List<PlateResList> getPlateList(List<Long> planIds) {
|
||||||
|
|
||||||
|
|
||||||
List<PlateResList> plateResLists = plateMapper.selectPlateListByPlanId(planIds, getUserOrganId());
|
List<PlateResList> plateResLists = goodsMapper.selectPlateListByPlanId(planIds, getUserOrganId());
|
||||||
|
|
||||||
Set<Long> bodyIds = plateResLists.stream().map(PlateResList::getBodyId).collect(Collectors.toSet());
|
Set<Long> bodyIds = plateResLists.stream().map(PlateResList::getBodyId).collect(Collectors.toSet());
|
||||||
if (CollectionUtil.isNotEmpty(bodyIds)) {
|
if (CollectionUtil.isNotEmpty(bodyIds)) {
|
||||||
@@ -1110,10 +1067,7 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
public List<OrderRoomBodyList> getOrderRoomBody(List<Long> orderIds) {
|
public List<OrderRoomBodyList> getOrderRoomBody(List<Long> orderIds) {
|
||||||
|
|
||||||
|
|
||||||
List<OrderRoomBodyList> orderRoomBodyLists = orderItemMapper.selectRoomBodyByOrderId(orderIds, getUserOrganId());
|
return goodsMapper.selectNoPlanRoomBody(orderIds,getUserOrganId());
|
||||||
|
|
||||||
|
|
||||||
return orderRoomBodyLists;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+130
-3
@@ -231,7 +231,7 @@
|
|||||||
|
|
||||||
from order_goods og
|
from order_goods og
|
||||||
|
|
||||||
left join order_plate op on og.organ_id = op.organ_id and og.id = op.goods_id and og.deleted = op.deleted
|
left join order_plate op on og.organ_id = op.organ_id and og.order_id = op.order_id and og.id = op.goods_id and og.deleted = op.deleted
|
||||||
|
|
||||||
where og.organ_id = #{organId}
|
where og.organ_id = #{organId}
|
||||||
|
|
||||||
@@ -288,8 +288,8 @@
|
|||||||
oi.body_id
|
oi.body_id
|
||||||
|
|
||||||
from order_goods og
|
from order_goods og
|
||||||
left join order_plate op on og.organ_id = op.organ_id and og.id = op.goods_id and og.deleted = op.deleted
|
left join order_plate op on og.organ_id = op.organ_id and og.order_id = op.order_id and og.id = op.goods_id and og.deleted = op.deleted
|
||||||
left join order_item oi on op.organ_id = oi.organ_id and op.id = oi.plate_id
|
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.id = oi.plate_id
|
||||||
|
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
|
|
||||||
@@ -297,4 +297,131 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectGoodsAndRemainPlate"
|
||||||
|
resultType="com.cf.imes.module.executor.controller.admin.plan.vo.GoodsReqVO">
|
||||||
|
|
||||||
|
select
|
||||||
|
og.*,
|
||||||
|
orp.id as remainId
|
||||||
|
|
||||||
|
from order_goods og
|
||||||
|
left join order_remain_plate orp on og.organ_id = orp.organ_id and og.id = orp.goods_id
|
||||||
|
|
||||||
|
where og.organ_id = #{organId}
|
||||||
|
and og.deleted = false
|
||||||
|
and og.id in
|
||||||
|
<foreach collection="ids" item="ids" open="(" close=")" separator=",">
|
||||||
|
#{ids}
|
||||||
|
</foreach>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectNoPlanOrderList"
|
||||||
|
resultType="com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy">
|
||||||
|
|
||||||
|
|
||||||
|
select distinct og.order_id as orderId,og.create_time as updateTime
|
||||||
|
|
||||||
|
from order_goods og
|
||||||
|
left join order_plate op on og.organ_id = op.organ_id and og.order_id = op.order_id and og.id = op.goods_id and og.deleted = op.deleted
|
||||||
|
|
||||||
|
${ew.customSqlSegment}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectPlateListByPlanId"
|
||||||
|
resultType="com.cf.imes.module.executor.controller.admin.plan.vo.PlateResList" parameterType="java.lang.Long">
|
||||||
|
|
||||||
|
|
||||||
|
select distinct op.id as plateId,
|
||||||
|
op.order_id,
|
||||||
|
op.plate_no ,
|
||||||
|
op.name as plateName,
|
||||||
|
op.is_special_shaped,
|
||||||
|
op.is_sculpt,
|
||||||
|
op.area,
|
||||||
|
op.seal_left,
|
||||||
|
op.seal_right,
|
||||||
|
op.seal_up,
|
||||||
|
op.seal_down,
|
||||||
|
og.material,
|
||||||
|
og.color,
|
||||||
|
op.width,
|
||||||
|
op.height,
|
||||||
|
op.thickness,
|
||||||
|
oi.room_id,
|
||||||
|
oi.body_id
|
||||||
|
|
||||||
|
from order_goods og
|
||||||
|
left join order_plate op on og.organ_id = op.organ_id and og.order_id = op.order_id and og.id = op.goods_id and og.deleted = op.deleted
|
||||||
|
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.id = oi.plate_id
|
||||||
|
|
||||||
|
where og.organ_id = #{organId}
|
||||||
|
and og.plan_id in
|
||||||
|
<foreach collection="planIds" item="planIds" open="(" close=")" separator=",">
|
||||||
|
#{planIds}
|
||||||
|
</foreach>
|
||||||
|
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<resultMap id="RoomBodyListMap" type="com.cf.imes.module.executor.controller.admin.plan.bo.OrderRoomBodyList">
|
||||||
|
|
||||||
|
<result property="orderId" column="orderId"/>
|
||||||
|
|
||||||
|
<collection property="orderRoomIds" ofType="com.cf.imes.module.executor.controller.admin.plan.bo.OrderRoomIds" resultMap="OrderRoomIdsMap"/>
|
||||||
|
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<resultMap id="OrderRoomIdsMap" type="com.cf.imes.module.executor.controller.admin.plan.bo.OrderRoomIds">
|
||||||
|
|
||||||
|
<result property="roomId" column="roomId"/>
|
||||||
|
<result property="roomName" column="roomName"/>
|
||||||
|
|
||||||
|
<collection property="orderBodyIds" ofType="com.cf.imes.module.executor.controller.admin.plan.bo.OrderBodyIds" resultMap="OrderBodyIdsMap"/>
|
||||||
|
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<resultMap id="OrderBodyIdsMap" type="com.cf.imes.module.executor.controller.admin.plan.bo.OrderBodyIds">
|
||||||
|
|
||||||
|
<result property="bodyId" column="bodyId"/>
|
||||||
|
<result property="bodyName" column="bodyName"/>
|
||||||
|
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectNoPlanRoomBody"
|
||||||
|
resultMap="RoomBodyListMap"
|
||||||
|
parameterType="java.lang.Long">
|
||||||
|
|
||||||
|
|
||||||
|
select distinct
|
||||||
|
og.order_id as orderId,
|
||||||
|
ob.id as bodyId,
|
||||||
|
ob.name as bodyName,
|
||||||
|
ob.room_id as roomId,
|
||||||
|
ob.room_name as roomName
|
||||||
|
from order_goods og
|
||||||
|
left join order_plate op on og.organ_id = op.organ_id and og.order_id = op.order_id and og.id = op.goods_id
|
||||||
|
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.id = oi.plate_id
|
||||||
|
left join order_body ob on oi.organ_id = ob.organ_id and oi.order_id = ob.order_id and oi.body_id = ob.id
|
||||||
|
|
||||||
|
where og.organ_id = #{organId}
|
||||||
|
and og.deleted = false
|
||||||
|
and og.plan_id = 0
|
||||||
|
and og.order_id in
|
||||||
|
<foreach item="orderIds" collection="orderIds" open="(" separator="," close=")">
|
||||||
|
#{orderIds}
|
||||||
|
</foreach>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
+39
-83
@@ -173,106 +173,42 @@
|
|||||||
<resultMap id="PackListMap" type="com.cf.imes.module.executor.controller.admin.plan.saveOptimize.PrintOrderPackReqVO">
|
<resultMap id="PackListMap" type="com.cf.imes.module.executor.controller.admin.plan.saveOptimize.PrintOrderPackReqVO">
|
||||||
|
|
||||||
<result property="orderId" column="orderId"/>
|
<result property="orderId" column="orderId"/>
|
||||||
<result property="plateId" column="plateId"/>
|
|
||||||
<result property="packId" column="packId"/>
|
<result property="packId" column="packId"/>
|
||||||
<result property="packNo" column="packNo"/>
|
<result property="packNo" column="packNo"/>
|
||||||
<result property="packNum" column="packNum"/>
|
<result property="packNum" column="packNum"/>
|
||||||
|
|
||||||
|
<collection property="plateId" ofType="java.lang.Long" column="plateId"/>
|
||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectPackList"
|
<select id="selectPackList"
|
||||||
parameterType="java.lang.Long"
|
parameterType="java.lang.Long"
|
||||||
resultMap="PackListMap">
|
resultMap="PackListMap">
|
||||||
|
|
||||||
|
|
||||||
select distinct oi.order_id as orderId,
|
select distinct op.id as plateId,
|
||||||
oi.plate_id as plateId,
|
op.order_id as orderId,
|
||||||
op.id as packId,
|
o.id as packId,
|
||||||
op.package_no as packNo,
|
o.package_no as packNo
|
||||||
(case when op.status !=0 then count(op.id) end) as packNum
|
from order_plate op
|
||||||
from order_item oi
|
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.id = oi.plate_id
|
||||||
left join order_package op on oi.order_id = op.order_id and oi.organ_id = op.organ_id
|
left join order_package o on oi.organ_id = o.organ_id and oi.order_id = o.order_id and oi.package_id = o.id
|
||||||
|
|
||||||
where oi.parts_id = 0 and oi.organ_id = #{organId}
|
where op.organ_id = #{organId}
|
||||||
and oi.order_id in
|
and op.deleted = false
|
||||||
|
and op.goods_id in
|
||||||
<foreach item="orderIds" collection="orderIds" open="(" separator="," close=")">
|
<foreach item="ids" collection="ids" open="(" separator="," close=")">
|
||||||
#{orderIds}
|
#{ids}
|
||||||
</foreach>
|
</foreach>
|
||||||
group by oi.order_id,oi.plate_id,op.id,op.package_no,op.status;
|
and oi.parts_id = 0
|
||||||
|
and oi.package_id !=0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<resultMap id="RoomBodyListMap" type="com.cf.imes.module.executor.controller.admin.plan.bo.OrderRoomBodyList">
|
|
||||||
|
|
||||||
<result property="orderId" column="orderId"/>
|
|
||||||
|
|
||||||
<collection property="orderRoomIds" ofType="com.cf.imes.module.executor.controller.admin.plan.bo.OrderRoomIds" resultMap="OrderRoomIdsMap"/>
|
|
||||||
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
|
|
||||||
<resultMap id="OrderRoomIdsMap" type="com.cf.imes.module.executor.controller.admin.plan.bo.OrderRoomIds">
|
|
||||||
|
|
||||||
<result property="roomId" column="roomId"/>
|
|
||||||
<result property="roomName" column="roomName"/>
|
|
||||||
|
|
||||||
<collection property="orderBodyIds" ofType="com.cf.imes.module.executor.controller.admin.plan.bo.OrderBodyIds" resultMap="OrderBodyIdsMap"/>
|
|
||||||
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
|
|
||||||
<resultMap id="OrderBodyIdsMap" type="com.cf.imes.module.executor.controller.admin.plan.bo.OrderBodyIds">
|
|
||||||
|
|
||||||
<result property="bodyId" column="bodyId"/>
|
|
||||||
<result property="bodyName" column="bodyName"/>
|
|
||||||
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectRoomBodyByOrderId"
|
|
||||||
resultMap="RoomBodyListMap"
|
|
||||||
parameterType="java.lang.Long">
|
|
||||||
|
|
||||||
select distinct
|
|
||||||
oi.order_id as orderId,
|
|
||||||
ob.id as bodyId,
|
|
||||||
ob.name as bodyName,
|
|
||||||
ob.room_id as roomId,
|
|
||||||
ob.room_name as roomName
|
|
||||||
from order_item oi
|
|
||||||
left join order_plan_item opi on oi.id = opi.item_id and oi.organ_id = opi.organ_id
|
|
||||||
left join order_body ob on oi.body_id = ob.id and oi.organ_id = ob.organ_id
|
|
||||||
|
|
||||||
where oi.organ_id = #{organId} and opi.item_id is null and oi.order_id in
|
|
||||||
|
|
||||||
<foreach item="orderIds" collection="orderIds" open="(" separator="," close=")">
|
|
||||||
#{orderIds}
|
|
||||||
</foreach>
|
|
||||||
|
|
||||||
|
|
||||||
</select>
|
|
||||||
|
|
||||||
|
|
||||||
<resultMap id="TestMap" type="com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy">
|
|
||||||
|
|
||||||
<result property="orderId" column="orderId"/>
|
|
||||||
|
|
||||||
<!-- <collection property="platePages" ofType="com.cf.imes.module.executor.controller.admin.plan.vo.PlatePage" resultMap="Test2Map"/>-->
|
|
||||||
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap id="Test2Map" type="com.cf.imes.module.executor.controller.admin.plan.vo.PlatePage">
|
|
||||||
|
|
||||||
<result property="plateId" column="plateId"/>
|
|
||||||
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectTestNum"
|
<select id="selectTestNum"
|
||||||
resultType="com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy">
|
resultType="com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy">
|
||||||
@@ -288,5 +224,25 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectOrderPlateList" parameterType="java.lang.Long" resultMap="PackListMap">
|
||||||
|
|
||||||
|
|
||||||
|
select distinct op.id as plateId,
|
||||||
|
op.order_id as orderId,
|
||||||
|
o.id as packId,
|
||||||
|
o.package_no as packNo
|
||||||
|
from order_plate op
|
||||||
|
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.id = oi.plate_id
|
||||||
|
left join order_package o on oi.organ_id = o.organ_id and oi.order_id = o.order_id and oi.package_id = o.id
|
||||||
|
|
||||||
|
where op.organ_id = #{organId}
|
||||||
|
and op.deleted = false
|
||||||
|
and op.order_id = #{orderId}
|
||||||
|
and oi.parts_id = 0
|
||||||
|
and oi.package_id !=0
|
||||||
|
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
+5
-4
@@ -101,11 +101,12 @@
|
|||||||
op.name,
|
op.name,
|
||||||
op.order_id
|
op.order_id
|
||||||
from order_parts op
|
from order_parts op
|
||||||
join order_item oi on op.id = oi.parts_id and op.organ_id = oi.organ_id
|
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.id = oi.parts_id
|
||||||
join order_body ob on oi.body_id = ob.id and oi.organ_id = ob.organ_id
|
left join order_body ob on oi.organ_id = ob.organ_id and oi.order_id = ob.order_id and oi.body_id = ob.id
|
||||||
where op.organ_id = #{organId}
|
|
||||||
and op.order_id in
|
|
||||||
|
|
||||||
|
where op.organ_id = #{organId}
|
||||||
|
and op.deleted = false
|
||||||
|
and op.order_id in
|
||||||
<foreach item="orderIds" collection="orderIds" open="(" separator="," close=")">
|
<foreach item="orderIds" collection="orderIds" open="(" separator="," close=")">
|
||||||
#{orderIds}
|
#{orderIds}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|||||||
+2
-3
@@ -161,9 +161,8 @@
|
|||||||
,CONCAT(YEAR(p.create_time), '-', MONTH(p.create_time), '-', DAY(p.create_time)) as date
|
,CONCAT(YEAR(p.create_time), '-', MONTH(p.create_time), '-', DAY(p.create_time)) as date
|
||||||
</if>
|
</if>
|
||||||
from order_plan p
|
from order_plan p
|
||||||
join order_plan_item opi on p.id = opi.plan_id
|
join order_goods g on g.plan_id = p.id
|
||||||
join order_item oi on oi.id = opi.item_id
|
join order_plate op on op.goods_id = g.id
|
||||||
join order_plate op on oi.plate_id = op.id
|
|
||||||
where p.create_time between #{req.createTime[0]} and #{req.createTime[1]}
|
where p.create_time between #{req.createTime[0]} and #{req.createTime[1]}
|
||||||
and p.deleted = 0
|
and p.deleted = 0
|
||||||
group by date;
|
group by date;
|
||||||
|
|||||||
+14
-28
@@ -231,11 +231,12 @@
|
|||||||
op.is_row_hole as hasHole
|
op.is_row_hole as hasHole
|
||||||
|
|
||||||
from order_plate op
|
from order_plate op
|
||||||
join order_goods ogs on op.goods_id = ogs.id and op.organ_id = ogs.organ_id
|
left join order_goods ogs on op.organ_id = ogs.organ_id and op.order_id = ogs.order_id and op.goods_id = ogs.id
|
||||||
join order_item oi on op.id = oi.plate_id and op.organ_id = oi.organ_id
|
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.id = oi.plate_id
|
||||||
join order_body ob on oi.body_id = ob.id and oi.organ_id = ob.organ_id
|
left join order_group og on oi.organ_id = og.organ_id and oi.order_id = og.order_id and oi.group_id = og.id
|
||||||
left join order_group og on oi.group_id = og.id and oi.organ_id = og.organ_id
|
left join order_body ob on oi.organ_id = ob.organ_id and oi.order_id = ob.order_id and oi.body_id = ob.id
|
||||||
where op.order_id =#{orderId} and op.organ_id = #{organId} and op.deleted = false
|
|
||||||
|
where op.organ_id = #{organId} and op.deleted = false and op.order_id = #{orderId}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -431,27 +432,6 @@
|
|||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectPlateListByPlanId" resultType="com.cf.imes.module.executor.controller.admin.plan.vo.PlateResList"
|
|
||||||
parameterType="java.lang.Long">
|
|
||||||
|
|
||||||
|
|
||||||
select distinct a.id as plateId,a.order_id, a.plate_no , a.name as plateName,a.is_special_shaped,a.is_sculpt,a.area,a.seal_left,a.seal_right,a.seal_up,a.seal_down, e.material, e.color, a.width, a.height, a.thickness, b.room_id, b.body_id
|
|
||||||
from order_plate a
|
|
||||||
LEFT JOIN order_item b ON a.id = b.plate_id AND a.order_id = b.order_id and a.organ_id = b.organ_id
|
|
||||||
LEFT JOIN order_goods e ON e.id = a.goods_id AND e.order_id = a.order_id and e.organ_id = a.organ_id
|
|
||||||
LEFT JOIN order_plan_item p ON b.id = p.item_id and b.organ_id = p.organ_id
|
|
||||||
|
|
||||||
where p.organ_id = #{organId}
|
|
||||||
and p.plan_id in
|
|
||||||
|
|
||||||
<foreach collection="planIds" item="planIds" open="(" close=")" separator=",">
|
|
||||||
#{planIds}
|
|
||||||
</foreach>
|
|
||||||
|
|
||||||
order by a.order_id,plateName;
|
|
||||||
|
|
||||||
</select>
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectPlateIdListByBodyId" resultType="java.lang.Long">
|
<select id="selectPlateIdListByBodyId" resultType="java.lang.Long">
|
||||||
SELECT plate_id FROM order_item
|
SELECT plate_id FROM order_item
|
||||||
@@ -822,6 +802,10 @@
|
|||||||
oi.group_id as groupId,
|
oi.group_id as groupId,
|
||||||
oi.room_id as roomId,
|
oi.room_id as roomId,
|
||||||
og.name as groupName,
|
og.name as groupName,
|
||||||
|
ob.name as bodyName,
|
||||||
|
ob.room_name as roomName,
|
||||||
|
ogs.goods_id as plateGoodsId,
|
||||||
|
ogs.goods_name as goodsName,
|
||||||
|
|
||||||
op.id as plateId,
|
op.id as plateId,
|
||||||
op.order_id as orderId,
|
op.order_id as orderId,
|
||||||
@@ -864,8 +848,10 @@
|
|||||||
op.is_row_hole as hasHole
|
op.is_row_hole as hasHole
|
||||||
|
|
||||||
from order_plate op
|
from order_plate op
|
||||||
left join order_item oi on op.organ_id = oi.organ_id and op.id = oi.plate_id
|
left join order_goods ogs on op.organ_id = ogs.organ_id and op.order_id = ogs.order_id and op.goods_id = ogs.id
|
||||||
left join order_group og on oi.organ_id = og.organ_id and oi.group_id = og.id
|
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.id = oi.plate_id
|
||||||
|
left join order_group og on oi.organ_id = og.organ_id and oi.order_id = og.order_id and oi.group_id = og.id
|
||||||
|
left join order_body ob on oi.organ_id = ob.organ_id and oi.order_id = ob.order_id and oi.body_id = ob.id
|
||||||
|
|
||||||
where op.organ_id = #{organId} and op.deleted = false and op.goods_id in
|
where op.organ_id = #{organId} and op.deleted = false and op.goods_id in
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -42,21 +42,21 @@ public class RemainPlateController {
|
|||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建生产单余料板表(单个)")
|
@Operation(summary = "创建生产单余料板表(单个)")
|
||||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
@PreAuthorize("@ss.hasAnyPermissions('manage:remain-plate:create','placeorder:optimize')")
|
||||||
public CommonResult<Boolean> createRemainPlate(@Valid @RequestBody RemainPlateSaveReqVO createReqVO) {
|
public CommonResult<Boolean> createRemainPlate(@Valid @RequestBody RemainPlateSaveReqVO createReqVO) {
|
||||||
return success(remainPlateService.createRemainPlate(createReqVO));
|
return success(remainPlateService.createRemainPlate(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/createMultiple")
|
@PostMapping("/createMultiple")
|
||||||
@Operation(summary = "创建生产单余料板表(多个)")
|
@Operation(summary = "创建生产单余料板表(多个)")
|
||||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
@PreAuthorize("@ss.hasAnyPermissions('manage:remain-plate:create','placeorder:optimize')")
|
||||||
public CommonResult<Boolean> createRemainPlateMultiple(@Valid @RequestBody Set<RemainPlateSaveReqVO> createReqVOS) {
|
public CommonResult<Boolean> createRemainPlateMultiple(@Valid @RequestBody Set<RemainPlateSaveReqVO> createReqVOS) {
|
||||||
return success(remainPlateService.createRemainPlateMultiple(createReqVOS));
|
return success(remainPlateService.createRemainPlateMultiple(createReqVOS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新生产单余料板表")
|
@Operation(summary = "更新生产单余料板表")
|
||||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
|
||||||
public CommonResult<Boolean> updateRemainPlate(@Valid @RequestBody RemainPlateSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateRemainPlate(@Valid @RequestBody RemainPlateSaveReqVO updateReqVO) {
|
||||||
remainPlateService.updateRemainPlate(updateReqVO);
|
remainPlateService.updateRemainPlate(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -64,7 +64,7 @@ public class RemainPlateController {
|
|||||||
|
|
||||||
@PutMapping("/updateStatus")
|
@PutMapping("/updateStatus")
|
||||||
@Operation(summary = "余料板批量核销")
|
@Operation(summary = "余料板批量核销")
|
||||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
|
||||||
public CommonResult<Boolean> updateRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) {
|
public CommonResult<Boolean> updateRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) {
|
||||||
remainPlateService.updateRemainPlateStatus(updateReqVO.getIds(),
|
remainPlateService.updateRemainPlateStatus(updateReqVO.getIds(),
|
||||||
updateReqVO.getStatus(),
|
updateReqVO.getStatus(),
|
||||||
@@ -75,7 +75,7 @@ public class RemainPlateController {
|
|||||||
|
|
||||||
@PutMapping("/revertUpdate")
|
@PutMapping("/revertUpdate")
|
||||||
@Operation(summary = "余料板批量释放")
|
@Operation(summary = "余料板批量释放")
|
||||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
|
||||||
public CommonResult<Boolean> revertRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) {
|
public CommonResult<Boolean> revertRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) {
|
||||||
remainPlateService.revertRemainPlateStatus(updateReqVO.getIds(),updateReqVO.getStatus());
|
remainPlateService.revertRemainPlateStatus(updateReqVO.getIds(),updateReqVO.getStatus());
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -84,7 +84,7 @@ public class RemainPlateController {
|
|||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除生产单余料板表")
|
@Operation(summary = "删除生产单余料板表")
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:delete')")
|
||||||
public CommonResult<Boolean> deleteRemainPlate(@RequestParam("id") Set<Long> ids) {
|
public CommonResult<Boolean> deleteRemainPlate(@RequestParam("id") Set<Long> ids) {
|
||||||
remainPlateService.deleteRemainPlate(ids);
|
remainPlateService.deleteRemainPlate(ids);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -93,7 +93,7 @@ public class RemainPlateController {
|
|||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得生产单余料板表")
|
@Operation(summary = "获得生产单余料板表")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:query')")
|
||||||
public CommonResult<RemainPlateRespVO> getRemainPlate(@RequestParam("id") Long id) {
|
public CommonResult<RemainPlateRespVO> getRemainPlate(@RequestParam("id") Long id) {
|
||||||
RemainPlateDO remainPlate = remainPlateService.getRemainPlate(id);
|
RemainPlateDO remainPlate = remainPlateService.getRemainPlate(id);
|
||||||
return success(BeanUtils.toBean(remainPlate, RemainPlateRespVO.class));
|
return success(BeanUtils.toBean(remainPlate, RemainPlateRespVO.class));
|
||||||
@@ -101,7 +101,7 @@ public class RemainPlateController {
|
|||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得生产单余料板表分页")
|
@Operation(summary = "获得生产单余料板表分页")
|
||||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
@PreAuthorize("@ss.hasAnyPermissions('manage:remain-plate:query','placeorder:optimize')")
|
||||||
public CommonResult<PageResult<RemainPlateRespVO>> getRemainPlatePage(@Valid RemainPlatePageReqVO pageReqVO) {
|
public CommonResult<PageResult<RemainPlateRespVO>> getRemainPlatePage(@Valid RemainPlatePageReqVO pageReqVO) {
|
||||||
PageResult<RemainPlateDO> pageResult = remainPlateService.getRemainPlatePage(pageReqVO);
|
PageResult<RemainPlateDO> pageResult = remainPlateService.getRemainPlatePage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, RemainPlateRespVO.class));
|
return success(BeanUtils.toBean(pageResult, RemainPlateRespVO.class));
|
||||||
@@ -109,7 +109,7 @@ public class RemainPlateController {
|
|||||||
|
|
||||||
@GetMapping("/pageAdd")
|
@GetMapping("/pageAdd")
|
||||||
@Operation(summary = "获得生产单余料板可添加分页")
|
@Operation(summary = "获得生产单余料板可添加分页")
|
||||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:query')")
|
||||||
public CommonResult<PageResult<RemainPlateRespVO>> getRemainPlatePageToAdd(@Valid RemainPlatePageReqVO pageReqVO) {
|
public CommonResult<PageResult<RemainPlateRespVO>> getRemainPlatePageToAdd(@Valid RemainPlatePageReqVO pageReqVO) {
|
||||||
PageResult<RemainPlateDO> pageResult = remainPlateService.getRemainPlatePageToAdd(pageReqVO);
|
PageResult<RemainPlateDO> pageResult = remainPlateService.getRemainPlatePageToAdd(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, RemainPlateRespVO.class));
|
return success(BeanUtils.toBean(pageResult, RemainPlateRespVO.class));
|
||||||
@@ -117,7 +117,7 @@ public class RemainPlateController {
|
|||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@Operation(summary = "导出生产单余料板表Excel")
|
@Operation(summary = "导出生产单余料板表Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:export')")
|
||||||
@OperateLog(type = EXPORT)
|
@OperateLog(type = EXPORT)
|
||||||
public void exportRemainPlateExcel(@Valid RemainPlatePageReqVO pageReqVO,
|
public void exportRemainPlateExcel(@Valid RemainPlatePageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
|
|||||||
@@ -161,5 +161,7 @@ chenfeng:
|
|||||||
send-maximum-quantity-per-day: 10
|
send-maximum-quantity-per-day: 10
|
||||||
begin-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
begin-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
||||||
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
||||||
|
encrypt:
|
||||||
|
enable: false
|
||||||
|
publicKey: cfimes
|
||||||
debug: false
|
debug: false
|
||||||
|
|||||||
@@ -175,5 +175,7 @@ chenfeng:
|
|||||||
send-maximum-quantity-per-day: 10
|
send-maximum-quantity-per-day: 10
|
||||||
begin-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
begin-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
||||||
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
||||||
|
encrypt:
|
||||||
|
enable: false
|
||||||
|
publicKey: cfimes
|
||||||
debug: false
|
debug: false
|
||||||
|
|||||||
+5
-2
@@ -12,17 +12,20 @@ public final class ErrorCodeConstants {
|
|||||||
|
|
||||||
// ========== UREPORT template模块 1-003-001-000 ==========
|
// ========== UREPORT template模块 1-003-001-000 ==========
|
||||||
public static final ErrorCode TEMPLATE_NOT_EXISTS = new ErrorCode(1_003_001_001, "报表模板信息不存在");
|
public static final ErrorCode TEMPLATE_NOT_EXISTS = new ErrorCode(1_003_001_001, "报表模板信息不存在");
|
||||||
public static final ErrorCode DATATEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR = new ErrorCode(1_003_001_002, "内置模板操作权限不足");
|
public static final ErrorCode TEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR = new ErrorCode(1_003_001_002, "内置模板操作权限不足");
|
||||||
|
public static final ErrorCode TEMPLATE_NAME_UNIQE_ERROR = new ErrorCode(1_003_001_003, "模板名【{}】已存在,请编辑模板名后重试");
|
||||||
|
|
||||||
|
|
||||||
// ========== UREPORT datasource模块 1-003-002-000 ==========
|
// ========== UREPORT datasource模块 1-003-002-000 ==========
|
||||||
public static final ErrorCode DATASOURCE_NOT_EXISTS = new ErrorCode(1_003_002_001, "报表数据源不存在");
|
public static final ErrorCode DATASOURCE_NOT_EXISTS = new ErrorCode(1_003_002_001, "报表数据源不存在");
|
||||||
public static final ErrorCode DATASOURCE_CONNECT_FAIL = new ErrorCode(1_003_002_002, "报表数据源连接失败");
|
public static final ErrorCode DATASOURCE_CONNECT_FAIL = new ErrorCode(1_003_002_002, "报表数据源连接失败");
|
||||||
public static final ErrorCode DATASOURCE_SPRINGBEAN_GET_FAIL = new ErrorCode(1_003_002_003, "无法获取springbean【{}】");
|
public static final ErrorCode DATASOURCE_SPRINGBEAN_GET_FAIL = new ErrorCode(1_003_002_003, "无法获取springbean【{}】");
|
||||||
public static final ErrorCode DATASOURCE_SPRINGBEAN_METHODS_GET_FAIL = new ErrorCode(1_003_002_004, "获取springbean方法列表失败,请检查】");
|
public static final ErrorCode DATASOURCE_SPRINGBEAN_METHODS_GET_FAIL = new ErrorCode(1_003_002_004, "获取springbean方法列表失败,请检查】");
|
||||||
|
public static final ErrorCode DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR = new ErrorCode(1_003_001_002, "内置数据源操作权限不足");
|
||||||
|
|
||||||
|
|
||||||
// ========== UREPORT dataset模块 1-003-003-000 ==========
|
// ========== UREPORT dataset模块 1-003-003-000 ==========
|
||||||
public static final ErrorCode DATASET_NOT_EXISTS = new ErrorCode(1_003_003_001, "报表数据集不存在");
|
public static final ErrorCode DATASET_NOT_EXISTS = new ErrorCode(1_003_003_001, "报表数据集不存在或权限不足");
|
||||||
public static final ErrorCode DATASET_SQL_INJECTION_RISK = new ErrorCode(1_003_003_002, "存在SQL注入风险");
|
public static final ErrorCode DATASET_SQL_INJECTION_RISK = new ErrorCode(1_003_003_002, "存在SQL注入风险");
|
||||||
public static final ErrorCode DATASET_SQL_REQUIRED = new ErrorCode(1_003_003_003, "SQL语句不能为空");
|
public static final ErrorCode DATASET_SQL_REQUIRED = new ErrorCode(1_003_003_003, "SQL语句不能为空");
|
||||||
public static final ErrorCode DATASET_SQL_ILLEGAL = new ErrorCode(1_003_003_004, "SQL语句非法");
|
public static final ErrorCode DATASET_SQL_ILLEGAL = new ErrorCode(1_003_003_004, "SQL语句非法");
|
||||||
|
|||||||
+5
-5
@@ -37,14 +37,14 @@ public class ReportDatasetController {
|
|||||||
|
|
||||||
@PutMapping("/dataset")
|
@PutMapping("/dataset")
|
||||||
@Operation(summary = "创建报表数据集")
|
@Operation(summary = "创建报表数据集")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:dataset:create')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Long> createDataset(@Valid @RequestBody ReportDatasetSaveReqVO createReqVO) {
|
public CommonResult<Long> createDataset(@Valid @RequestBody ReportDatasetSaveReqVO createReqVO) {
|
||||||
return success(datasetService.createDataset(createReqVO));
|
return success(datasetService.createDataset(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/dataset")
|
@PostMapping("/dataset")
|
||||||
@Operation(summary = "更新报表数据集")
|
@Operation(summary = "更新报表数据集")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:dataset:update')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Boolean> updateDataset(@Valid @RequestBody ReportDatasetSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateDataset(@Valid @RequestBody ReportDatasetSaveReqVO updateReqVO) {
|
||||||
datasetService.updateDataset(updateReqVO);
|
datasetService.updateDataset(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -53,7 +53,7 @@ public class ReportDatasetController {
|
|||||||
@DeleteMapping("/dataset/{id}")
|
@DeleteMapping("/dataset/{id}")
|
||||||
@Operation(summary = "删除报表数据集")
|
@Operation(summary = "删除报表数据集")
|
||||||
@Parameter(name = "id", description = "数据集id", required = true)
|
@Parameter(name = "id", description = "数据集id", required = true)
|
||||||
// @PreAuthorize("@ss.hasPermission('report:dataset:delete')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Boolean> deleteDataset(@PathVariable("id") Long id) {
|
public CommonResult<Boolean> deleteDataset(@PathVariable("id") Long id) {
|
||||||
datasetService.deleteDataset(id);
|
datasetService.deleteDataset(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -62,7 +62,7 @@ public class ReportDatasetController {
|
|||||||
@GetMapping("/dataset/{id}")
|
@GetMapping("/dataset/{id}")
|
||||||
@Operation(summary = "获得报表数据集")
|
@Operation(summary = "获得报表数据集")
|
||||||
@Parameter(name = "id", description = "数据集id", required = true, example = "1")
|
@Parameter(name = "id", description = "数据集id", required = true, example = "1")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:dataset:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<ReportDatasetRespVO> getDataset(@PathVariable("id") Long id) {
|
public CommonResult<ReportDatasetRespVO> getDataset(@PathVariable("id") Long id) {
|
||||||
ReportDatasetDO dataset = datasetService.getDataset(id);
|
ReportDatasetDO dataset = datasetService.getDataset(id);
|
||||||
return success(BeanUtils.toBean(dataset, ReportDatasetRespVO.class));
|
return success(BeanUtils.toBean(dataset, ReportDatasetRespVO.class));
|
||||||
@@ -70,7 +70,7 @@ public class ReportDatasetController {
|
|||||||
|
|
||||||
@GetMapping("/datasets")
|
@GetMapping("/datasets")
|
||||||
@Operation(summary = "获取数据源下的报表数据集列表")
|
@Operation(summary = "获取数据源下的报表数据集列表")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:dataset:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<List<ReportDatasetRespVO>> getDatasetPage(@RequestParam(value = "datasourceId") Long datasourceId,
|
public CommonResult<List<ReportDatasetRespVO>> getDatasetPage(@RequestParam(value = "datasourceId") Long datasourceId,
|
||||||
@RequestParam(value = "name", required = false) String name) {
|
@RequestParam(value = "name", required = false) String name) {
|
||||||
ReportDatasetReqVO reqVO = new ReportDatasetReqVO(name, datasourceId);
|
ReportDatasetReqVO reqVO = new ReportDatasetReqVO(name, datasourceId);
|
||||||
|
|||||||
+2
@@ -6,6 +6,7 @@ import lombok.Builder;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -31,6 +32,7 @@ public class ReportDatasetSaveReqVO implements Serializable {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "数据源id", example = "1")
|
@Schema(description = "数据源id", example = "1")
|
||||||
|
@NotNull(message = "数据源id不能为空")
|
||||||
private Long datasourceId;
|
private Long datasourceId;
|
||||||
|
|
||||||
@Schema(description = "动态查询SQL")
|
@Schema(description = "动态查询SQL")
|
||||||
|
|||||||
+17
-27
@@ -1,6 +1,5 @@
|
|||||||
package com.cf.imes.module.report.controller.admin.datasource;
|
package com.cf.imes.module.report.controller.admin.datasource;
|
||||||
|
|
||||||
import com.bstek.common.config.DataSourceConfig;
|
|
||||||
import com.bstek.common.utils.MultipleJdbcTemplate;
|
import com.bstek.common.utils.MultipleJdbcTemplate;
|
||||||
import com.bstek.datasource.bean.DataSourceInfo;
|
import com.bstek.datasource.bean.DataSourceInfo;
|
||||||
import com.bstek.datasource.bean.PreviewParams;
|
import com.bstek.datasource.bean.PreviewParams;
|
||||||
@@ -9,7 +8,6 @@ import com.bstek.ureport.definition.dataset.Field;
|
|||||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportBeanDatasourceRespVO;
|
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportBeanDatasourceRespVO;
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceReqVO;
|
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceRespVO;
|
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceRespVO;
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
||||||
@@ -47,22 +45,19 @@ public class ReportDatasourceController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ReportDatasourceService datasourceService;
|
private ReportDatasourceService datasourceService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private DataSourceConfig dataSourceConfig;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DataSourceService ureportDataSourceService;
|
private DataSourceService ureportDataSourceService;
|
||||||
|
|
||||||
@PutMapping("/datasource")
|
@PutMapping("/datasource")
|
||||||
@Operation(summary = "创建报表数据源")
|
@Operation(summary = "创建报表数据源")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:create')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Long> createDatasource(@Valid @RequestBody ReportDatasourceSaveReqVO createReqVO) {
|
public CommonResult<Long> createDatasource(@Valid @RequestBody ReportDatasourceSaveReqVO createReqVO) {
|
||||||
return success(datasourceService.createDatasource(createReqVO));
|
return success(datasourceService.createDatasource(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/datasource")
|
@PostMapping("/datasource")
|
||||||
@Operation(summary = "更新报表数据源")
|
@Operation(summary = "更新报表数据源")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:update')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Boolean> updateDatasource(@Valid @RequestBody ReportDatasourceSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateDatasource(@Valid @RequestBody ReportDatasourceSaveReqVO updateReqVO) {
|
||||||
datasourceService.updateDatasource(updateReqVO);
|
datasourceService.updateDatasource(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -71,7 +66,7 @@ public class ReportDatasourceController {
|
|||||||
@DeleteMapping("/datasource/{id}")
|
@DeleteMapping("/datasource/{id}")
|
||||||
@Operation(summary = "删除报表数据源")
|
@Operation(summary = "删除报表数据源")
|
||||||
@Parameter(name = "id", description = "数据源id", required = true, example = "1")
|
@Parameter(name = "id", description = "数据源id", required = true, example = "1")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:delete')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Boolean> deleteDatasource(@PathVariable("id") Long id) {
|
public CommonResult<Boolean> deleteDatasource(@PathVariable("id") Long id) {
|
||||||
datasourceService.deleteDatasource(id);
|
datasourceService.deleteDatasource(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -80,23 +75,22 @@ public class ReportDatasourceController {
|
|||||||
@GetMapping("/datasource/{id}")
|
@GetMapping("/datasource/{id}")
|
||||||
@Operation(summary = "获取报表数据源")
|
@Operation(summary = "获取报表数据源")
|
||||||
@Parameter(name = "id", description = "数据源id", required = true, example = "1")
|
@Parameter(name = "id", description = "数据源id", required = true, example = "1")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<ReportDatasourceRespVO> getDatasource(@PathVariable("id") Long id) {
|
public CommonResult<ReportDatasourceRespVO> getDatasource(@PathVariable("id") Long id) {
|
||||||
ReportDatasourceDO datasource = datasourceService.getDatasource(id);
|
ReportDatasourceDO datasource = datasourceService.getDatasource(id);
|
||||||
return success(BeanUtils.toBean(datasource, ReportDatasourceRespVO.class));
|
return success(BeanUtils.toBean(datasource, ReportDatasourceRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{templateId}/datasources")
|
@GetMapping("/datasources")
|
||||||
@Operation(summary = "获取报表模板下的报表数据源")
|
@Operation(summary = "获取报表数据源列表")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
@Parameter(name = "templateId", description = "模版id", required = true)
|
public CommonResult<List<ReportDatasourceRespVO>> getDatasourcePage() {
|
||||||
public CommonResult<List<ReportDatasourceRespVO>> getDatasourcePage(@PathVariable(value = "templateId") Long templateId) {
|
return success(BeanUtils.toBean(datasourceService.getDatasourceList(), ReportDatasourceRespVO.class));
|
||||||
return success(BeanUtils.toBean(datasourceService.getTemplateDatasourceList(ReportDatasourceReqVO.builder().templateId(templateId).build()), ReportDatasourceRespVO.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/datasource/beans")
|
@GetMapping("/datasource/beans")
|
||||||
@Operation(summary = "获取springbean数据源列表")
|
@Operation(summary = "获取springbean数据源列表")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<List<ReportBeanDatasourceRespVO>> getBeanDatasourceList() {
|
public CommonResult<List<ReportBeanDatasourceRespVO>> getBeanDatasourceList() {
|
||||||
return success(datasourceService.getBeanDatasourceList());
|
return success(datasourceService.getBeanDatasourceList());
|
||||||
}
|
}
|
||||||
@@ -104,49 +98,45 @@ public class ReportDatasourceController {
|
|||||||
@GetMapping("/springbean/result/clazz")
|
@GetMapping("/springbean/result/clazz")
|
||||||
@Operation(summary = "获取springbean数据源返回对象")
|
@Operation(summary = "获取springbean数据源返回对象")
|
||||||
@Parameter(name = "clazz", description = "返回对象类路径全名不能为空", required = true)
|
@Parameter(name = "clazz", description = "返回对象类路径全名不能为空", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public List<Field> springbeanFieldList(@RequestParam(value = "clazz") @NotEmpty(message = "类路径全名不能为空") String clazz) {
|
public List<Field> springbeanFieldList(@RequestParam(value = "clazz") @NotEmpty(message = "类路径全名不能为空") String clazz) {
|
||||||
return datasourceService.getSpringBeanResultFieldList(clazz);
|
return datasourceService.getSpringBeanResultFieldList(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/datasource/bean/methods")
|
@GetMapping("/datasource/bean/methods")
|
||||||
@Operation(summary = "获取springbean数据源方法类表")
|
@Operation(summary = "获取springbean数据源方法类表")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:query')")
|
|
||||||
@Parameter(name = "beanId", description = "springbeanId", required = true)
|
@Parameter(name = "beanId", description = "springbeanId", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<List<String>> getBeanDatasourceList(@RequestParam(value = "beanId") @NotEmpty(message = "beanId不能为空") String beanId) {
|
public CommonResult<List<String>> getBeanDatasourceList(@RequestParam(value = "beanId") @NotEmpty(message = "beanId不能为空") String beanId) {
|
||||||
return success(datasourceService.loadBeanMethods(beanId));
|
return success(datasourceService.loadBeanMethods(beanId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/buildin/datasources")
|
|
||||||
@Operation(summary = "获取内置数据源")
|
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:query')")
|
|
||||||
public CommonResult<List<DataSourceInfo>> getBuildinDatasources() {
|
|
||||||
return CommonResult.success(dataSourceConfig.getDatasource());
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/datasource/connect")
|
@PostMapping("/datasource/connect")
|
||||||
@Operation(summary = "测试数据源连接")
|
@Operation(summary = "测试数据源连接")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Boolean> testDatasourceConnect(@RequestBody DataSourceInfo info) {
|
public CommonResult<Boolean> testDatasourceConnect(@RequestBody DataSourceInfo info) {
|
||||||
String success = MultipleJdbcTemplate.testConnection(info);
|
String success = MultipleJdbcTemplate.testConnection(info);
|
||||||
return Objects.equals("success", success) ? success(true) : error(DATASOURCE_CONNECT_FAIL);
|
return Objects.equals("success", success) ? success(true) : error(DATASOURCE_CONNECT_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/datasource/tables")
|
@PostMapping("/datasource/tables")
|
||||||
@Operation(summary = "获取数据源表列表")
|
@Operation(summary = "获取数据库表列表")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<List<Map<String, String>>> getDatasourceTables(@RequestBody DataSourceInfo info) {
|
public CommonResult<List<Map<String, String>>> getDatasourceTables(@RequestBody DataSourceInfo info) {
|
||||||
return success(ureportDataSourceService.selectTableList(info));
|
return success(ureportDataSourceService.selectTableList(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/datasource/table/fields")
|
@PostMapping("/datasource/table/fields")
|
||||||
@Operation(summary = "获取数据源表字段")
|
@Operation(summary = "获取数据源表字段")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:datasource:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<List<Field>> getDatasourceTableFields(@RequestBody PreviewParams previewParams) {
|
public CommonResult<List<Field>> getDatasourceTableFields(@RequestBody PreviewParams previewParams) {
|
||||||
return success(datasourceService.getTableFields(previewParams));
|
return success(datasourceService.getTableFields(previewParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/datasource/preview")
|
@PostMapping("/datasource/preview")
|
||||||
@Operation(summary = "数据源预览")
|
@Operation(summary = "数据源预览")
|
||||||
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Map<String, Object>> previewData(@RequestBody PreviewParams previewParams) {
|
public CommonResult<Map<String, Object>> previewData(@RequestBody PreviewParams previewParams) {
|
||||||
return success(ureportDataSourceService.previewData(previewParams));
|
return success(ureportDataSourceService.previewData(previewParams));
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -1,6 +1,7 @@
|
|||||||
package com.cf.imes.module.report.controller.admin.datasource.vo;
|
package com.cf.imes.module.report.controller.admin.datasource.vo;
|
||||||
|
|
||||||
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetRespVO;
|
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetRespVO;
|
||||||
|
import com.cf.imes.module.report.enums.datasource.ReportDatasourceTypeEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -28,8 +29,14 @@ public class ReportDatasourceRespVO {
|
|||||||
@Schema(description = "数据源名称", example = "测试库")
|
@Schema(description = "数据源名称", example = "测试库")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "数据源类型,jdbc、spring、buildin、api", example = "0")
|
@Schema(description = "数据源类型,jdbc、spring、api", example = "0")
|
||||||
private Integer type;
|
private ReportDatasourceTypeEnum type;
|
||||||
|
|
||||||
|
@Schema(description = "内置类型:0是、1否")
|
||||||
|
private Integer buildinType;
|
||||||
|
|
||||||
|
@Schema(description = "spring型数据源id")
|
||||||
|
private String beanId;
|
||||||
|
|
||||||
@Schema(description = "数据源驱动类",example = "com.mysql.cj.jdbc.Driver")
|
@Schema(description = "数据源驱动类",example = "com.mysql.cj.jdbc.Driver")
|
||||||
private String driver;
|
private String driver;
|
||||||
|
|||||||
+7
-7
@@ -2,6 +2,8 @@ package com.cf.imes.module.report.controller.admin.datasource.vo;
|
|||||||
|
|
||||||
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetSaveReqVO;
|
||||||
import com.cf.imes.module.report.validation.datasource.ReportDatasourceTypeInEnum;
|
import com.cf.imes.module.report.validation.datasource.ReportDatasourceTypeInEnum;
|
||||||
|
import com.cf.imes.module.report.validation.template.ReportTemplateTypeInEnum;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@@ -30,16 +32,17 @@ public class ReportDatasourceSaveReqVO implements Serializable {
|
|||||||
@Schema(description = "数据源id", example = "1")
|
@Schema(description = "数据源id", example = "1")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "模板id", example = "1")
|
|
||||||
private Long templateId;
|
|
||||||
|
|
||||||
@Schema(description = "数据源名称", example = "测试库")
|
@Schema(description = "数据源名称", example = "测试库")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "数据源类型,jdbc、spring、buildin、api", example = "1")
|
@Schema(description = "数据源类型,jdbc、spring、api", example = "1")
|
||||||
@ReportDatasourceTypeInEnum
|
@ReportDatasourceTypeInEnum
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
@Schema(description = "内置数据源类型,0是、1否", example = "1")
|
||||||
|
@ReportTemplateTypeInEnum
|
||||||
|
private Integer buildinType;
|
||||||
|
|
||||||
@Schema(description = "spring型数据源id")
|
@Schema(description = "spring型数据源id")
|
||||||
private String beanId;
|
private String beanId;
|
||||||
|
|
||||||
@@ -58,9 +61,6 @@ public class ReportDatasourceSaveReqVO implements Serializable {
|
|||||||
@Schema(description = "备注", example = "该模板仅供生产使用")
|
@Schema(description = "备注", example = "该模板仅供生产使用")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@Schema(description = "数据集")
|
|
||||||
private List<ReportDatasetSaveReqVO> datasets = new ArrayList<>();
|
|
||||||
|
|
||||||
@Schema(description = "请求头参数")
|
@Schema(description = "请求头参数")
|
||||||
private List<Map<String, String>> headers;
|
private List<Map<String, String>> headers;
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-13
@@ -33,6 +33,7 @@ import org.antlr.v4.runtime.tree.TerminalNode;
|
|||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -66,30 +67,29 @@ public class ReportTemplateController {
|
|||||||
|
|
||||||
@PutMapping("/template")
|
@PutMapping("/template")
|
||||||
@Operation(summary = "创建报表模板")
|
@Operation(summary = "创建报表模板")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:template:create')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Long> createTemplate(@Valid @RequestBody ReportTemplateSaveReqVO createReqVO) {
|
public CommonResult<ReportTemplateRespVO> createTemplate(@Valid @RequestBody ReportTemplateSaveReqVO createReqVO) {
|
||||||
return success(templateService.createReportTemplate(createReqVO));
|
return success(templateService.createReportTemplate(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/template/copy")
|
@PutMapping("/template/copy")
|
||||||
@Operation(summary = "复制报表模板")
|
@Operation(summary = "复制报表模板")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:template:create')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Long> copyTemplate(@Valid @RequestBody ReportTemplateSaveReqVO createReqVO) {
|
public CommonResult<Long> copyTemplate(@Valid @RequestBody ReportTemplateSaveReqVO createReqVO) {
|
||||||
return success(templateService.copyReportTemplate(createReqVO));
|
return success(templateService.copyReportTemplate(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/template")
|
@PostMapping("/template")
|
||||||
@Operation(summary = "更新报表模板")
|
@Operation(summary = "更新报表模板")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:template:update')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Boolean> updateTemplate(@Valid @RequestBody ReportTemplateSaveReqVO updateReqVO) {
|
public CommonResult<ReportTemplateRespVO> updateTemplate(@Valid @RequestBody ReportTemplateSaveReqVO updateReqVO) {
|
||||||
templateService.updateReportTemplate(updateReqVO);
|
return success(templateService.updateReportTemplate(updateReqVO));
|
||||||
return success(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/template/{id}")
|
@DeleteMapping("/template/{id}")
|
||||||
@Operation(summary = "删除报表模板")
|
@Operation(summary = "删除报表模板")
|
||||||
@Parameter(name = "id", description = "模板id", required = true)
|
@Parameter(name = "id", description = "模板id", required = true)
|
||||||
// @PreAuthorize("@ss.hasPermission('report:template:delete')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<Boolean> deleteReportTemplate(@PathVariable("id") Long id) {
|
public CommonResult<Boolean> deleteReportTemplate(@PathVariable("id") Long id) {
|
||||||
templateService.deleteReportTemplate(id);
|
templateService.deleteReportTemplate(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -98,14 +98,14 @@ public class ReportTemplateController {
|
|||||||
@GetMapping("/template/{id}")
|
@GetMapping("/template/{id}")
|
||||||
@Operation(summary = "获取报表模板信息")
|
@Operation(summary = "获取报表模板信息")
|
||||||
@Parameter(name = "id", description = "模板id", required = true, example = "1")
|
@Parameter(name = "id", description = "模板id", required = true, example = "1")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:template:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<ReportDefinitionWrapper> getReportTemplate(@PathVariable("id") Long id) {
|
public CommonResult<ReportDefinitionWrapper> getReportTemplate(@PathVariable("id") Long id) {
|
||||||
return success(templateService.getReportTemplateDefinition(id));
|
return success(templateService.getReportTemplateDefinition(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/templates")
|
@GetMapping("/templates")
|
||||||
@Operation(summary = "获取报表模板信息列表")
|
@Operation(summary = "获取报表模板信息列表")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:template:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public CommonResult<List<ReportTemplateRespVO>> getTemplatePage(@RequestParam(value = "name", required = false) String name) {
|
public CommonResult<List<ReportTemplateRespVO>> getTemplatePage(@RequestParam(value = "name", required = false) String name) {
|
||||||
ReportTemplateReqVO reqVO = new ReportTemplateReqVO(name, null);
|
ReportTemplateReqVO reqVO = new ReportTemplateReqVO(name, null);
|
||||||
return success(BeanUtils.toBean(templateService.getReportTemplateList(reqVO), ReportTemplateRespVO.class));
|
return success(BeanUtils.toBean(templateService.getReportTemplateList(reqVO), ReportTemplateRespVO.class));
|
||||||
@@ -113,26 +113,28 @@ public class ReportTemplateController {
|
|||||||
|
|
||||||
@PostMapping("/template/preview")
|
@PostMapping("/template/preview")
|
||||||
@Operation(summary = "模板预览")
|
@Operation(summary = "模板预览")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:template:query')")
|
@PreAuthorize("@ss.hasPermission('report:preview')")
|
||||||
public CommonResult<HtmlReport> preview(@RequestBody PreviewParameters params) {
|
public CommonResult<HtmlReport> preview(@RequestBody PreviewParameters params) {
|
||||||
return success(templateService.preview(params));
|
return success(templateService.preview(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/template/print")
|
@PostMapping("/template/print")
|
||||||
@Operation(summary = "模板预览打印")
|
@Operation(summary = "模板预览打印")
|
||||||
|
@PreAuthorize("@ss.hasPermission('report:preview')")
|
||||||
public void print(@RequestBody PreviewParameters reportParameters, HttpServletResponse response) {
|
public void print(@RequestBody PreviewParameters reportParameters, HttpServletResponse response) {
|
||||||
templateService.print(reportParameters, response);
|
templateService.print(reportParameters, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/template/download/{type}")
|
@PostMapping("/template/download/{type}")
|
||||||
@Operation(summary = "模板预览下载")
|
@Operation(summary = "模板预览下载")
|
||||||
|
@PreAuthorize("@ss.hasPermission('report:preview')")
|
||||||
public void print(@PathVariable @Valid @ReportTemplateProducerTypeInEnum String type, @RequestBody PreviewParameters reportParameters, HttpServletResponse response) {
|
public void print(@PathVariable @Valid @ReportTemplateProducerTypeInEnum String type, @RequestBody PreviewParameters reportParameters, HttpServletResponse response) {
|
||||||
templateService.download(type, reportParameters, response);
|
templateService.download(type, reportParameters, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/template/export")
|
@PostMapping("/template/export")
|
||||||
@Operation(summary = "模板导出")
|
@Operation(summary = "模板导出")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:template:query')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public void generateTemplate(@Valid @RequestBody ReportTemplateGenerateReqDTO reqDTO, HttpServletResponse response) {
|
public void generateTemplate(@Valid @RequestBody ReportTemplateGenerateReqDTO reqDTO, HttpServletResponse response) {
|
||||||
OutputStream out = null;
|
OutputStream out = null;
|
||||||
try {
|
try {
|
||||||
@@ -151,7 +153,7 @@ public class ReportTemplateController {
|
|||||||
|
|
||||||
@GetMapping("/template/excel/import")
|
@GetMapping("/template/excel/import")
|
||||||
@Operation(summary = "导入excel模板")
|
@Operation(summary = "导入excel模板")
|
||||||
// @PreAuthorize("@ss.hasPermission('report:template:import')")
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public ReportDefinitionWrapper importExcel(@RequestParam("file") MultipartFile file) {
|
public ReportDefinitionWrapper importExcel(@RequestParam("file") MultipartFile file) {
|
||||||
ReportDefinition report = ExcelParserUtils.parser(file);
|
ReportDefinition report = ExcelParserUtils.parser(file);
|
||||||
if (report != null) {
|
if (report != null) {
|
||||||
@@ -164,6 +166,7 @@ public class ReportTemplateController {
|
|||||||
@GetMapping("/scriptValidation")
|
@GetMapping("/scriptValidation")
|
||||||
@Operation(summary = "校验表达式")
|
@Operation(summary = "校验表达式")
|
||||||
@Parameter(name = "content", description = "表达式", required = true)
|
@Parameter(name = "content", description = "表达式", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public List<ErrorInfo> scriptValidation(@Param("content") @NotEmpty(message = "表达式不能为空") String content) {
|
public List<ErrorInfo> scriptValidation(@Param("content") @NotEmpty(message = "表达式不能为空") String content) {
|
||||||
content = StringUtils.decode(content);
|
content = StringUtils.decode(content);
|
||||||
ANTLRInputStream antlrInputStream = new ANTLRInputStream(content);
|
ANTLRInputStream antlrInputStream = new ANTLRInputStream(content);
|
||||||
@@ -186,6 +189,7 @@ public class ReportTemplateController {
|
|||||||
@GetMapping("/parseDataSet")
|
@GetMapping("/parseDataSet")
|
||||||
@Operation(summary = "解析表达式中的数据集")
|
@Operation(summary = "解析表达式中的数据集")
|
||||||
@Parameter(name = "expr", description = "表达式", required = true)
|
@Parameter(name = "expr", description = "表达式", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||||
public Map<String, String> parseDatasetName(@Param("expr") @NotEmpty(message = "表达式不能为空") String expr) {
|
public Map<String, String> parseDatasetName(@Param("expr") @NotEmpty(message = "表达式不能为空") String expr) {
|
||||||
ANTLRInputStream antlrInputStream = new ANTLRInputStream(expr);
|
ANTLRInputStream antlrInputStream = new ANTLRInputStream(expr);
|
||||||
ReportParserLexer lexer = new ReportParserLexer(antlrInputStream);
|
ReportParserLexer lexer = new ReportParserLexer(antlrInputStream);
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||||
|
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceRespVO;
|
import com.bstek.ureport.definition.datasource.DatasourceDefinition;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -37,5 +37,5 @@ public class ReportTemplateRespVO {
|
|||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@Schema(description = "数据源")
|
@Schema(description = "数据源")
|
||||||
private List<ReportDatasourceRespVO> datasource;
|
private List<DatasourceDefinition> datasource;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-5
@@ -1,14 +1,13 @@
|
|||||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||||
|
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gqr
|
* @author Gqr
|
||||||
@@ -30,9 +29,12 @@ public class ReportTemplateSaveReqVO {
|
|||||||
@Schema(description = "报表模板")
|
@Schema(description = "报表模板")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
@Schema(description = "数据源")
|
|
||||||
private List<ReportDatasourceSaveReqVO> datasource = new ArrayList<>();
|
|
||||||
|
|
||||||
@Schema(description = "备注", example = "该模板仅供生产使用")
|
@Schema(description = "备注", example = "该模板仅供生产使用")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "数据源id列表")
|
||||||
|
private Set<Long> datasourceIds;
|
||||||
|
|
||||||
|
@Schema(description = "数据集id列表")
|
||||||
|
private Set<Long> datasetIds;
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-5
@@ -8,6 +8,7 @@ import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
|||||||
import com.cf.imes.framework.mybatis.core.type.CompressObjectListTypeHandler;
|
import com.cf.imes.framework.mybatis.core.type.CompressObjectListTypeHandler;
|
||||||
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
||||||
import com.cf.imes.module.report.enums.datasource.ReportDatasourceTypeEnum;
|
import com.cf.imes.module.report.enums.datasource.ReportDatasourceTypeEnum;
|
||||||
|
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -38,20 +39,22 @@ public class ReportDatasourceDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
|
||||||
* 模板id
|
|
||||||
*/
|
|
||||||
private Long templateId;
|
|
||||||
/**
|
/**
|
||||||
* 数据源名称
|
* 数据源名称
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板类型,0内置、1自定义
|
* 数据源类型:jdbc、spring、api
|
||||||
*/
|
*/
|
||||||
private ReportDatasourceTypeEnum type;
|
private ReportDatasourceTypeEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内置类型:0是、1否
|
||||||
|
*/
|
||||||
|
private ReportTemplateTypeEnum buildinType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spring型数据源id
|
* spring型数据源id
|
||||||
*/
|
*/
|
||||||
|
|||||||
+15
@@ -3,11 +3,14 @@ package com.cf.imes.module.report.dal.dataobject.template;
|
|||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import com.cf.imes.framework.mybatis.core.type.CompressStringTypeHandler;
|
import com.cf.imes.framework.mybatis.core.type.CompressStringTypeHandler;
|
||||||
|
import com.cf.imes.framework.mybatis.core.type.JsonLongSetTypeHandler;
|
||||||
|
import com.cf.imes.framework.mybatis.core.type.LongListTypeHandler;
|
||||||
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
||||||
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报表模板信息DO
|
* 报表模板信息DO
|
||||||
@@ -57,4 +60,16 @@ public class ReportTemplateDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<ReportDatasourceDO> datasource;
|
private List<ReportDatasourceDO> datasource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据源id列表
|
||||||
|
*/
|
||||||
|
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||||
|
private Set<Long> datasourceIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据集id列表
|
||||||
|
*/
|
||||||
|
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||||
|
private Set<Long> datasetIds;
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -1,9 +1,14 @@
|
|||||||
package com.cf.imes.module.report.dal.mysql.dataset;
|
package com.cf.imes.module.report.dal.mysql.dataset;
|
||||||
|
|
||||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
||||||
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报表数据集 Mapper
|
* 报表数据集 Mapper
|
||||||
*
|
*
|
||||||
@@ -12,4 +17,14 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ReportDatasetMapper extends BaseMapperX<ReportDatasetDO> {
|
public interface ReportDatasetMapper extends BaseMapperX<ReportDatasetDO> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据集列表
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OrganIgnore
|
||||||
|
default List<ReportDatasetDO> selectNormalDatasetList(Set<Long> datasetIds) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<ReportDatasetDO>().in(ReportDatasetDO::getId, datasetIds));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+41
@@ -1,9 +1,15 @@
|
|||||||
package com.cf.imes.module.report.dal.mysql.datasource;
|
package com.cf.imes.module.report.dal.mysql.datasource;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
||||||
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
||||||
|
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报表数据源 Mapper
|
* 报表数据源 Mapper
|
||||||
*
|
*
|
||||||
@@ -12,4 +18,39 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ReportDatasourceMapper extends BaseMapperX<ReportDatasourceDO> {
|
public interface ReportDatasourceMapper extends BaseMapperX<ReportDatasourceDO> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据数据源id查询数据源
|
||||||
|
* 普通用户用:organId+buildType:1 or buildType:0
|
||||||
|
*
|
||||||
|
* @param id 数据源id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OrganIgnore
|
||||||
|
default ReportDatasourceDO selectNormalDatasourceById(Long id, Long organId) {
|
||||||
|
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<ReportDatasourceDO>()
|
||||||
|
.eq(ReportDatasourceDO::getId, id)
|
||||||
|
.and(wr -> wr.or(wrapper -> wrapper
|
||||||
|
.eq(ReportDatasourceDO::getOrganId, organId)
|
||||||
|
.eq(ReportDatasourceDO::getBuildinType, ReportTemplateTypeEnum.CUSTOM))
|
||||||
|
.or(wrapper -> wrapper.eq(ReportDatasourceDO::getBuildinType, ReportTemplateTypeEnum.SYSTEM)));
|
||||||
|
return selectOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据源列表
|
||||||
|
* 普通用户用:organId+buildinType:1 or buildinType:0
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OrganIgnore
|
||||||
|
default List<ReportDatasourceDO> selectNormalDatasourceList(Set<Long> datasourceIds, Long organId) {
|
||||||
|
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<ReportDatasourceDO>()
|
||||||
|
.in(ReportDatasourceDO::getId, datasourceIds)
|
||||||
|
.and(wr -> wr.or(wrapper -> wrapper
|
||||||
|
.eq(ReportDatasourceDO::getOrganId, organId)
|
||||||
|
.eq(ReportDatasourceDO::getBuildinType, ReportTemplateTypeEnum.CUSTOM))
|
||||||
|
.or(wrapper -> wrapper.eq(ReportDatasourceDO::getBuildinType, ReportTemplateTypeEnum.SYSTEM)));
|
||||||
|
return selectList(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+46
@@ -1,9 +1,15 @@
|
|||||||
package com.cf.imes.module.report.dal.mysql.template;
|
package com.cf.imes.module.report.dal.mysql.template;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
||||||
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
||||||
|
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报表模板信息 Mapper
|
* 报表模板信息 Mapper
|
||||||
*
|
*
|
||||||
@@ -12,4 +18,44 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ReportTemplateMapper extends BaseMapperX<ReportTemplateDO> {
|
public interface ReportTemplateMapper extends BaseMapperX<ReportTemplateDO> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据模板id查询模板
|
||||||
|
* 普通用户用:organId+type:1 or type:0
|
||||||
|
*
|
||||||
|
* @param id 模板id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OrganIgnore
|
||||||
|
default ReportTemplateDO selectNormalTemplateById(Long id, Long organId) {
|
||||||
|
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<ReportTemplateDO>()
|
||||||
|
.eq(ReportTemplateDO::getId, id)
|
||||||
|
.and(wr -> wr.or(wrapper -> wrapper
|
||||||
|
.eq(ReportTemplateDO::getOrganId, organId)
|
||||||
|
.eq(ReportTemplateDO::getType, ReportTemplateTypeEnum.CUSTOM))
|
||||||
|
.or(wrapper -> wrapper.eq(ReportTemplateDO::getType, ReportTemplateTypeEnum.SYSTEM)));
|
||||||
|
return selectOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询模板列表
|
||||||
|
* 普通用户用:organId+type:1 or type:0
|
||||||
|
* @param name
|
||||||
|
* @param organId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OrganIgnore
|
||||||
|
default List<ReportTemplateDO> selectNormalTemplateList(String name, Long organId) {
|
||||||
|
LambdaQueryWrapper<ReportTemplateDO> queryWrapper = new LambdaQueryWrapperX<ReportTemplateDO>()
|
||||||
|
.likeIfPresent(ReportTemplateDO::getName, name)
|
||||||
|
.orderByDesc(ReportTemplateDO::getCreateTime)
|
||||||
|
.and(wr -> wr.or(wrapper -> wrapper
|
||||||
|
.eq(ReportTemplateDO::getOrganId, organId)
|
||||||
|
.eq(ReportTemplateDO::getType, ReportTemplateTypeEnum.CUSTOM))
|
||||||
|
.or(wrapper -> wrapper.eq(ReportTemplateDO::getType, ReportTemplateTypeEnum.SYSTEM)))
|
||||||
|
// 不返回content xml,点击具体的模板中返回xml
|
||||||
|
.select(ReportTemplateDO::getId, ReportTemplateDO::getName, ReportTemplateDO::getCreateTime, ReportTemplateDO::getRemark);
|
||||||
|
return selectList(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -15,8 +15,7 @@ import lombok.Getter;
|
|||||||
public enum ReportDatasourceTypeEnum {
|
public enum ReportDatasourceTypeEnum {
|
||||||
JDBC(0, "jdbc"),
|
JDBC(0, "jdbc"),
|
||||||
SPRING(1, "spring"),
|
SPRING(1, "spring"),
|
||||||
BUILDIN(2, "buildin"),
|
API(2, "api");
|
||||||
API(3, "api");
|
|
||||||
|
|
||||||
@EnumValue
|
@EnumValue
|
||||||
private final Integer code;
|
private final Integer code;
|
||||||
|
|||||||
+38
-3
@@ -1,12 +1,17 @@
|
|||||||
package com.cf.imes.module.report.service.dataset;
|
package com.cf.imes.module.report.service.dataset;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetReqVO;
|
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetReqVO;
|
||||||
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetSaveReqVO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
||||||
|
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
||||||
import com.cf.imes.module.report.dal.mysql.dataset.ReportDatasetMapper;
|
import com.cf.imes.module.report.dal.mysql.dataset.ReportDatasetMapper;
|
||||||
|
import com.cf.imes.module.report.dal.mysql.datasource.ReportDatasourceMapper;
|
||||||
|
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@@ -15,6 +20,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_NOT_EXISTS;
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_NOT_EXISTS;
|
||||||
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR;
|
||||||
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报表数据集 Service 实现类
|
* 报表数据集 Service 实现类
|
||||||
@@ -25,11 +32,16 @@ import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_NOT_EXI
|
|||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
public class ReportDatasetServiceImpl implements ReportDatasetService {
|
public class ReportDatasetServiceImpl implements ReportDatasetService {
|
||||||
|
@Resource
|
||||||
|
private ReportDatasourceMapper reportDatasourceMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ReportDatasetMapper datasetMapper;
|
private ReportDatasetMapper datasetMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createDataset(ReportDatasetSaveReqVO createReqVO) {
|
public Long createDataset(ReportDatasetSaveReqVO createReqVO) {
|
||||||
|
// 校验内置模板操作权限
|
||||||
|
validateSystemDataset(createReqVO.getDatasourceId());
|
||||||
// 插入
|
// 插入
|
||||||
ReportDatasetDO dataset = BeanUtils.toBean(createReqVO, ReportDatasetDO.class);
|
ReportDatasetDO dataset = BeanUtils.toBean(createReqVO, ReportDatasetDO.class);
|
||||||
datasetMapper.insert(dataset);
|
datasetMapper.insert(dataset);
|
||||||
@@ -47,6 +59,8 @@ public class ReportDatasetServiceImpl implements ReportDatasetService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDataset(ReportDatasetSaveReqVO updateReqVO) {
|
public void updateDataset(ReportDatasetSaveReqVO updateReqVO) {
|
||||||
|
// 校验内置模板操作权限
|
||||||
|
validateSystemDataset(updateReqVO.getDatasourceId());
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateDatasetExists(updateReqVO.getId());
|
validateDatasetExists(updateReqVO.getId());
|
||||||
// 更新
|
// 更新
|
||||||
@@ -65,14 +79,35 @@ public class ReportDatasetServiceImpl implements ReportDatasetService {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteDataset(Long id) {
|
public void deleteDataset(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateDatasetExists(id);
|
ReportDatasetDO reportDatasetDO = validateDatasetExists(id);
|
||||||
|
// 校验内置模板操作权限
|
||||||
|
validateSystemDataset(reportDatasetDO.getDatasourceId());
|
||||||
// 删除
|
// 删除
|
||||||
datasetMapper.deleteById(id);
|
datasetMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateDatasetExists(Long id) {
|
private ReportDatasetDO validateDatasetExists(Long id) {
|
||||||
if (datasetMapper.selectById(id) == null) {
|
ReportDatasetDO reportDatasetDO = datasetMapper.selectById(id);
|
||||||
|
if (ObjectUtil.isNull(reportDatasetDO)) {
|
||||||
throw exception(DATASET_NOT_EXISTS);
|
throw exception(DATASET_NOT_EXISTS);
|
||||||
|
} else {
|
||||||
|
return reportDatasetDO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验只有超管可以操作内置数据源
|
||||||
|
*
|
||||||
|
* @param datasourceId 数据源id
|
||||||
|
*/
|
||||||
|
private void validateSystemDataset(Long datasourceId) {
|
||||||
|
ReportDatasourceDO reportDatasourceDO = reportDatasourceMapper.selectNormalDatasourceById(datasourceId, SecurityFrameworkUtils.getUserOrganId());
|
||||||
|
if (ObjectUtil.isNull(reportDatasourceDO)) {
|
||||||
|
throw exception(DATASOURCE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
// 非超管不能操作内置模板
|
||||||
|
if (ReportTemplateTypeEnum.SYSTEM.equals(reportDatasourceDO.getBuildinType()) && Boolean.FALSE.equals(SecurityFrameworkUtils.isSuperAdmin())) {
|
||||||
|
throw exception(DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -3,7 +3,6 @@ package com.cf.imes.module.report.service.datasource;
|
|||||||
import com.bstek.datasource.bean.PreviewParams;
|
import com.bstek.datasource.bean.PreviewParams;
|
||||||
import com.bstek.ureport.definition.dataset.Field;
|
import com.bstek.ureport.definition.dataset.Field;
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportBeanDatasourceRespVO;
|
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportBeanDatasourceRespVO;
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceReqVO;
|
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
||||||
|
|
||||||
@@ -53,7 +52,7 @@ public interface ReportDatasourceService {
|
|||||||
* @param reqVO 查询参数
|
* @param reqVO 查询参数
|
||||||
* @return 报表数据源分页
|
* @return 报表数据源分页
|
||||||
*/
|
*/
|
||||||
List<ReportDatasourceDO> getTemplateDatasourceList(ReportDatasourceReqVO reqVO);
|
List<ReportDatasourceDO> getDatasourceList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取springbean数据源列表
|
* 获取springbean数据源列表
|
||||||
|
|||||||
+57
-23
@@ -4,6 +4,7 @@ import cn.hutool.core.annotation.AnnotationUtil;
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.sql.SqlInjectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.sql.SqlInjectionUtils;
|
||||||
import com.bstek.common.exception.ReportDesignException;
|
import com.bstek.common.exception.ReportDesignException;
|
||||||
import com.bstek.common.utils.MultipleJdbcTemplate;
|
import com.bstek.common.utils.MultipleJdbcTemplate;
|
||||||
@@ -17,14 +18,17 @@ import com.cf.imes.framework.common.exception.ServiceException;
|
|||||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
||||||
|
import com.cf.imes.framework.security.core.LoginUser;
|
||||||
|
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetReqVO;
|
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetReqVO;
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportBeanDatasourceRespVO;
|
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportBeanDatasourceRespVO;
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceReqVO;
|
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
||||||
import com.cf.imes.module.report.dal.mysql.dataset.ReportDatasetMapper;
|
import com.cf.imes.module.report.dal.mysql.dataset.ReportDatasetMapper;
|
||||||
import com.cf.imes.module.report.dal.mysql.datasource.ReportDatasourceMapper;
|
import com.cf.imes.module.report.dal.mysql.datasource.ReportDatasourceMapper;
|
||||||
|
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
||||||
import com.cf.imes.module.report.framework.ureport.annotation.CfReportSpringbeanDatasource;
|
import com.cf.imes.module.report.framework.ureport.annotation.CfReportSpringbeanDatasource;
|
||||||
import com.cf.imes.module.report.service.dataset.ReportDatasetService;
|
import com.cf.imes.module.report.service.dataset.ReportDatasetService;
|
||||||
import com.cf.imes.module.report.util.SqlInjectionUtil;
|
import com.cf.imes.module.report.util.SqlInjectionUtil;
|
||||||
@@ -55,6 +59,7 @@ import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_GET_FIE
|
|||||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_ILLEGAL;
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_ILLEGAL;
|
||||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_INJECTION_RISK;
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_INJECTION_RISK;
|
||||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_REQUIRED;
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_REQUIRED;
|
||||||
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR;
|
||||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_NOT_EXISTS;
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_NOT_EXISTS;
|
||||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_SPRINGBEAN_GET_FAIL;
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_SPRINGBEAN_GET_FAIL;
|
||||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_SPRINGBEAN_METHODS_GET_FAIL;
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_SPRINGBEAN_METHODS_GET_FAIL;
|
||||||
@@ -86,8 +91,10 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createDatasource(ReportDatasourceSaveReqVO createReqVO) {
|
public Long createDatasource(ReportDatasourceSaveReqVO createReqVO) {
|
||||||
ReportDatasourceDO datasource = BeanUtils.toBean(createReqVO, ReportDatasourceDO.class);
|
// 校验内置数据源操作权限
|
||||||
|
validateSystemDatasource(createReqVO.getBuildinType());
|
||||||
// 插入
|
// 插入
|
||||||
|
ReportDatasourceDO datasource = BeanUtils.toBean(createReqVO, ReportDatasourceDO.class);
|
||||||
datasourceMapper.insert(datasource);
|
datasourceMapper.insert(datasource);
|
||||||
// 返回
|
// 返回
|
||||||
return datasource.getId();
|
return datasource.getId();
|
||||||
@@ -95,6 +102,8 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDatasource(ReportDatasourceSaveReqVO updateReqVO) {
|
public void updateDatasource(ReportDatasourceSaveReqVO updateReqVO) {
|
||||||
|
// 校验内置数据源操作权限
|
||||||
|
validateSystemDatasource(updateReqVO.getBuildinType());
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateDatasourceExists(updateReqVO.getId());
|
validateDatasourceExists(updateReqVO.getId());
|
||||||
ReportDatasourceDO updateObj = BeanUtils.toBean(updateReqVO, ReportDatasourceDO.class);
|
ReportDatasourceDO updateObj = BeanUtils.toBean(updateReqVO, ReportDatasourceDO.class);
|
||||||
@@ -106,44 +115,43 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteDatasource(Long id) {
|
public void deleteDatasource(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateDatasourceExists(id);
|
ReportDatasourceDO reportDatasourceDO = validateDatasourceExists(id);
|
||||||
|
// 校验内置数据源操作权限
|
||||||
|
validateSystemDatasource(reportDatasourceDO.getBuildinType().getType());
|
||||||
// 删除
|
// 删除
|
||||||
datasourceMapper.deleteById(id);
|
datasourceMapper.deleteById(id);
|
||||||
// 删除关联数据集
|
// 删除关联数据集
|
||||||
datasetMapper.delete(new LambdaQueryWrapperX<ReportDatasetDO>().eq(ReportDatasetDO::getDatasourceId, id));
|
datasetMapper.delete(new LambdaQueryWrapperX<ReportDatasetDO>().eq(ReportDatasetDO::getDatasourceId, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验数据源是否存在
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
private void validateDatasourceExists(Long id) {
|
|
||||||
if (datasourceMapper.selectById(id) == null) {
|
|
||||||
throw exception(DATASOURCE_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReportDatasourceDO getDatasource(Long id) {
|
public ReportDatasourceDO getDatasource(Long id) {
|
||||||
ReportDatasourceDO reportDatasourceDO = datasourceMapper.selectById(id);
|
ReportDatasourceDO reportDatasourceDO = datasourceMapper.selectNormalDatasourceById(id, SecurityFrameworkUtils.getUserOrganId());
|
||||||
// 查询数据集
|
// 查询数据集
|
||||||
queryDatasetInSource(reportDatasourceDO);
|
queryDatasetInSource(reportDatasourceDO);
|
||||||
return reportDatasourceDO;
|
return reportDatasourceDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ReportDatasourceDO> getTemplateDatasourceList(ReportDatasourceReqVO reqVO) {
|
@OrganIgnore
|
||||||
List<ReportDatasourceDO> reportDatasourceDOS = datasourceMapper.selectList(new LambdaQueryWrapperX<ReportDatasourceDO>()
|
public List<ReportDatasourceDO> getDatasourceList() {
|
||||||
.eqIfPresent(ReportDatasourceDO::getTemplateId, reqVO.getTemplateId())
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
.likeIfPresent(ReportDatasourceDO::getName, reqVO.getName())
|
LambdaQueryWrapper<ReportDatasourceDO> queryWrapper = new LambdaQueryWrapperX<ReportDatasourceDO>().orderByDesc(ReportDatasourceDO::getCreateTime);
|
||||||
.orderByDesc(ReportDatasourceDO::getCreateTime));
|
if (ObjectUtil.isNotNull(loginUser) && Boolean.FALSE.equals(loginUser.getIsSupAdmin())) {
|
||||||
|
// 普通用户查看机构下的和system数据源
|
||||||
|
queryWrapper.or(wrapper -> wrapper
|
||||||
|
.eq(ReportDatasourceDO::getOrganId, loginUser.getOrganId())
|
||||||
|
.eq(ReportDatasourceDO::getBuildinType, ReportTemplateTypeEnum.CUSTOM))
|
||||||
|
.or(wrapper -> wrapper.eq(ReportDatasourceDO::getBuildinType, ReportTemplateTypeEnum.SYSTEM));
|
||||||
|
}
|
||||||
|
List<ReportDatasourceDO> reportDatasourceDOS = datasourceMapper.selectList(queryWrapper);
|
||||||
// 查询数据集
|
// 查询数据集
|
||||||
if (CollUtil.isNotEmpty(reportDatasourceDOS)) {
|
if (CollUtil.isNotEmpty(reportDatasourceDOS)) {
|
||||||
reportDatasourceDOS.forEach(reportDatasourceDO -> {
|
reportDatasourceDOS.forEach(reportDatasourceDO -> {
|
||||||
queryDatasetInSource(reportDatasourceDO);
|
queryDatasetInSource(reportDatasourceDO);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 超管查看全部
|
||||||
return reportDatasourceDOS;
|
return reportDatasourceDOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,9 +221,9 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
|||||||
// 获取数据库连接
|
// 获取数据库连接
|
||||||
conn = MultipleJdbcTemplate.buildConnection(info);
|
conn = MultipleJdbcTemplate.buildConnection(info);
|
||||||
// 自定义工具校验sql
|
// 自定义工具校验sql
|
||||||
if (SqlInjectionUtil.checkEditSql(sql)) {
|
// if (SqlInjectionUtil.checkEditSql(sql)) {
|
||||||
throw exception(DATASET_SQL_ILLEGAL);
|
// throw exception(DATASET_SQL_ILLEGAL);
|
||||||
}
|
// }
|
||||||
// 检查参数sql注入
|
// 检查参数sql注入
|
||||||
for (Parameter parameter : parameters) {
|
for (Parameter parameter : parameters) {
|
||||||
// mybatis-plus util检查参数
|
// mybatis-plus util检查参数
|
||||||
@@ -290,4 +298,30 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
|||||||
reportDatasourceDO.setDatasets(datasetList);
|
reportDatasourceDO.setDatasets(datasetList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验数据源是否存在
|
||||||
|
*
|
||||||
|
* @param id 数据源id
|
||||||
|
*/
|
||||||
|
private ReportDatasourceDO validateDatasourceExists(Long id) {
|
||||||
|
ReportDatasourceDO reportDatasourceDO = datasourceMapper.selectNormalDatasourceById(id, SecurityFrameworkUtils.getUserOrganId());
|
||||||
|
if (reportDatasourceDO == null) {
|
||||||
|
throw exception(DATASOURCE_NOT_EXISTS);
|
||||||
|
} else {
|
||||||
|
return reportDatasourceDO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验只有超管可以操作内置数据源
|
||||||
|
*
|
||||||
|
* @param buildinType 内置数据源类型
|
||||||
|
*/
|
||||||
|
private void validateSystemDatasource(Integer buildinType) {
|
||||||
|
// 非超管不能操作内置模板
|
||||||
|
if (ReportTemplateTypeEnum.SYSTEM.getType().equals(buildinType) && Boolean.FALSE.equals(SecurityFrameworkUtils.isSuperAdmin())) {
|
||||||
|
throw exception(DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -6,6 +6,7 @@ import com.bstek.ureport.export.html.HtmlReport;
|
|||||||
import com.bstek.ureport.model.Report;
|
import com.bstek.ureport.model.Report;
|
||||||
import com.cf.imes.module.report.api.template.dto.ReportTemplateGenerateReqDTO;
|
import com.cf.imes.module.report.api.template.dto.ReportTemplateGenerateReqDTO;
|
||||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
||||||
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateRespVO;
|
||||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ public interface ReportTemplateService {
|
|||||||
* @param createReqVO 创建信息
|
* @param createReqVO 创建信息
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
Long createReportTemplate(@Valid ReportTemplateSaveReqVO createReqVO);
|
ReportTemplateRespVO createReportTemplate(@Valid ReportTemplateSaveReqVO createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 复制报表模版
|
* 复制报表模版
|
||||||
@@ -40,7 +41,7 @@ public interface ReportTemplateService {
|
|||||||
*
|
*
|
||||||
* @param updateReqVO 更新信息
|
* @param updateReqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void updateReportTemplate(@Valid ReportTemplateSaveReqVO updateReqVO);
|
ReportTemplateRespVO updateReportTemplate(@Valid ReportTemplateSaveReqVO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除报表模板
|
* 删除报表模板
|
||||||
|
|||||||
+121
-162
@@ -28,18 +28,15 @@ import com.bstek.ureport.export.html.HtmlReport;
|
|||||||
import com.bstek.ureport.model.Report;
|
import com.bstek.ureport.model.Report;
|
||||||
import com.bstek.ureport.parser.ReportParser;
|
import com.bstek.ureport.parser.ReportParser;
|
||||||
import com.bstek.ureport.utils.ToolUtils;
|
import com.bstek.ureport.utils.ToolUtils;
|
||||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
|
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
|
||||||
import com.cf.imes.framework.security.core.LoginUser;
|
import com.cf.imes.framework.security.core.LoginUser;
|
||||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import com.cf.imes.module.report.api.template.dto.ReportTemplateGenerateReqDTO;
|
import com.cf.imes.module.report.api.template.dto.ReportTemplateGenerateReqDTO;
|
||||||
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetReqVO;
|
|
||||||
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetSaveReqVO;
|
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceReqVO;
|
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
|
||||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
||||||
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateRespVO;
|
||||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
||||||
@@ -48,8 +45,6 @@ import com.cf.imes.module.report.dal.mysql.dataset.ReportDatasetMapper;
|
|||||||
import com.cf.imes.module.report.dal.mysql.datasource.ReportDatasourceMapper;
|
import com.cf.imes.module.report.dal.mysql.datasource.ReportDatasourceMapper;
|
||||||
import com.cf.imes.module.report.dal.mysql.template.ReportTemplateMapper;
|
import com.cf.imes.module.report.dal.mysql.template.ReportTemplateMapper;
|
||||||
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
||||||
import com.cf.imes.module.report.service.dataset.ReportDatasetService;
|
|
||||||
import com.cf.imes.module.report.service.datasource.ReportDatasourceService;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -67,9 +62,11 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATATEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR;
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR;
|
||||||
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_NAME_UNIQE_ERROR;
|
||||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_NOT_EXISTS;
|
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,21 +81,20 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ReportTemplateMapper templateMapper;
|
private ReportTemplateMapper templateMapper;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ReportDatasourceService datasourceService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ReportDatasetService datasetService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ReportDatasourceMapper datasourceMapper;
|
private ReportDatasourceMapper datasourceMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ReportDatasetMapper datasetMapper;
|
private ReportDatasetMapper datasetMapper;
|
||||||
|
|
||||||
|
private static final String UTF8_CHARSET = CharsetUtil.UTF_8;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createReportTemplate(ReportTemplateSaveReqVO createReqVO) {
|
public ReportTemplateRespVO createReportTemplate(ReportTemplateSaveReqVO createReqVO) {
|
||||||
|
boolean isSuperAdmin = SecurityFrameworkUtils.isSuperAdmin();
|
||||||
|
// 校验模板名唯一性
|
||||||
|
validateTemplateNameUnique(createReqVO, isSuperAdmin);
|
||||||
// url解码xml
|
// url解码xml
|
||||||
String content = createReqVO.getContent();
|
String content = createReqVO.getContent();
|
||||||
if (StringUtils.isNotEmpty(content)) {
|
if (StringUtils.isNotEmpty(content)) {
|
||||||
@@ -107,116 +103,56 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
// 新增模板
|
// 新增模板
|
||||||
ReportTemplateDO template = BeanUtils.toBean(createReqVO, ReportTemplateDO.class);
|
ReportTemplateDO template = BeanUtils.toBean(createReqVO, ReportTemplateDO.class);
|
||||||
// 超管创建的作为内置模板
|
// 超管创建的作为内置模板
|
||||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
|
||||||
boolean isSuperAdmin = loginUser != null && loginUser.getIsSupAdmin();
|
|
||||||
if (isSuperAdmin) {
|
if (isSuperAdmin) {
|
||||||
template.setType(ReportTemplateTypeEnum.SYSTEM);
|
template.setType(ReportTemplateTypeEnum.SYSTEM);
|
||||||
} else {
|
} else {
|
||||||
template.setType(ReportTemplateTypeEnum.CUSTOM);
|
template.setType(ReportTemplateTypeEnum.CUSTOM);
|
||||||
}
|
}
|
||||||
templateMapper.insert(template);
|
templateMapper.insert(template);
|
||||||
Long templateId = template.getId();
|
|
||||||
// 解析数据源
|
ReportTemplateRespVO reportTemplateRespVO = BeanUtils.toBean(template, ReportTemplateRespVO.class);
|
||||||
analyzeDatasource(createReqVO.getDatasource(), templateId);
|
// 查询数据源、数据集
|
||||||
// 返回主键
|
ReportDefinition reportDefinition = new ReportDefinition();
|
||||||
return templateId;
|
queryDatasource(template, reportDefinition);
|
||||||
|
reportTemplateRespVO.setDatasource(reportDefinition.getDatasources());
|
||||||
|
// 返回实体
|
||||||
|
return reportTemplateRespVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long copyReportTemplate(ReportTemplateSaveReqVO createReqVO) {
|
public Long copyReportTemplate(ReportTemplateSaveReqVO createReqVO) {
|
||||||
|
boolean isSuperAdmin = SecurityFrameworkUtils.isSuperAdmin();
|
||||||
Long templateId = createReqVO.getId();
|
Long templateId = createReqVO.getId();
|
||||||
// 校验存在
|
// 校验存在
|
||||||
ReportTemplateDO reportTemplateDO = validateTemplateExists(templateId);
|
ReportTemplateDO reportTemplateDO = validateTemplateExists(templateId);
|
||||||
|
// 校验模板名唯一性
|
||||||
|
validateTemplateNameUnique(createReqVO, isSuperAdmin);
|
||||||
// 校验内置模板操作权限
|
// 校验内置模板操作权限
|
||||||
validateSystemTemplate(reportTemplateDO);
|
validateSystemTemplate(reportTemplateDO);
|
||||||
ReportTemplateDO copyTemplateDO = BeanUtils.toBean(reportTemplateDO, ReportTemplateDO.class);
|
ReportTemplateDO copyTemplateDO = BeanUtils.toBean(reportTemplateDO, ReportTemplateDO.class);
|
||||||
// 重置id
|
// 重置id
|
||||||
copyTemplateDO.setId(null);
|
copyTemplateDO.setId(null);
|
||||||
copyTemplateDO.setName(createReqVO.getName());
|
copyTemplateDO.setName(createReqVO.getName());
|
||||||
|
// 超管创建的作为内置模板
|
||||||
|
if (isSuperAdmin) {
|
||||||
|
copyTemplateDO.setType(ReportTemplateTypeEnum.SYSTEM);
|
||||||
|
} else {
|
||||||
|
copyTemplateDO.setType(ReportTemplateTypeEnum.CUSTOM);
|
||||||
|
}
|
||||||
// 新增模版
|
// 新增模版
|
||||||
templateMapper.insert(copyTemplateDO);
|
templateMapper.insert(copyTemplateDO);
|
||||||
Long newtemplateId = copyTemplateDO.getId();
|
|
||||||
|
|
||||||
// 复制datasource、dataset
|
|
||||||
List<ReportDatasourceDO> templateDatasourceList = datasourceService.getTemplateDatasourceList(ReportDatasourceReqVO.builder().templateId(templateId).build());
|
|
||||||
List<ReportDatasourceSaveReqVO> copyDatasourceList = new ArrayList<>();
|
|
||||||
// 遍历数据源
|
|
||||||
templateDatasourceList.forEach(ds -> {
|
|
||||||
ReportDatasourceSaveReqVO copyDatasourceSaveReqVO = JsonUtils.parseObject(JsonUtils.toJsonString(ds), ReportDatasourceSaveReqVO.class);
|
|
||||||
copyDatasourceSaveReqVO.setId(null);
|
|
||||||
copyDatasourceSaveReqVO.setTemplateId(newtemplateId);
|
|
||||||
|
|
||||||
List<ReportDatasetDO> templateDatasetList = ds.getDatasets();
|
|
||||||
// 遍历数据集
|
|
||||||
if (CollUtil.isNotEmpty(templateDatasetList)) {
|
|
||||||
List<ReportDatasetSaveReqVO> copyDatasetList = new ArrayList<>();
|
|
||||||
templateDatasetList.forEach(dt -> {
|
|
||||||
ReportDatasetSaveReqVO copyDatasetSaveReqVO = BeanUtils.toBean(dt, ReportDatasetSaveReqVO.class);
|
|
||||||
copyDatasetSaveReqVO.setId(null);
|
|
||||||
copyDatasetSaveReqVO.setDatasourceId(null);
|
|
||||||
copyDatasetList.add(copyDatasetSaveReqVO);
|
|
||||||
});
|
|
||||||
copyDatasourceSaveReqVO.setDatasets(copyDatasetList);
|
|
||||||
}
|
|
||||||
copyDatasourceList.add(copyDatasourceSaveReqVO);
|
|
||||||
});
|
|
||||||
// 更新数据源
|
|
||||||
analyzeDatasource(copyDatasourceList, newtemplateId);
|
|
||||||
// 返回主键
|
// 返回主键
|
||||||
return newtemplateId;
|
return copyTemplateDO.getId();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析数据源集合并入库
|
|
||||||
*
|
|
||||||
* @param datasource 数据源列表
|
|
||||||
* @param templateId 模板id
|
|
||||||
*/
|
|
||||||
private void analyzeDatasource(List<ReportDatasourceSaveReqVO> datasource, Long templateId) {
|
|
||||||
if (CollUtil.isEmpty(datasource)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
datasource.forEach(ds -> {
|
|
||||||
// 更新/新增数据源
|
|
||||||
Long datasourceId;
|
|
||||||
if (ObjectUtil.isNotNull(ds.getId())) {
|
|
||||||
datasourceId = ds.getId();
|
|
||||||
datasourceService.updateDatasource(ds);
|
|
||||||
} else {
|
|
||||||
ds.setTemplateId(templateId);
|
|
||||||
datasourceId = datasourceService.createDatasource(ds);
|
|
||||||
}
|
|
||||||
List<ReportDatasetSaveReqVO> datasets = ds.getDatasets();
|
|
||||||
List<ReportDatasetSaveReqVO> batchInsertDataset = new ArrayList<>();
|
|
||||||
List<ReportDatasetSaveReqVO> batchupdateDataset = new ArrayList<>();
|
|
||||||
datasets.forEach(dataset -> {
|
|
||||||
// 更新/新增数据集
|
|
||||||
if (ObjectUtil.isNotNull(dataset.getId())) {
|
|
||||||
batchupdateDataset.add(dataset);
|
|
||||||
} else {
|
|
||||||
dataset.setDatasourceId(datasourceId);
|
|
||||||
batchInsertDataset.add(dataset);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 批量插入数据集
|
|
||||||
if (CollUtil.isNotEmpty(batchInsertDataset)) {
|
|
||||||
datasetService.batchCreateDataset(batchInsertDataset);
|
|
||||||
}
|
|
||||||
// 批量更新数据集
|
|
||||||
if (CollUtil.isNotEmpty(batchupdateDataset)) {
|
|
||||||
datasetService.batchUpdateDataset(batchupdateDataset);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
public ReportTemplateRespVO updateReportTemplate(ReportTemplateSaveReqVO updateReqVO) {
|
||||||
public void updateReportTemplate(ReportTemplateSaveReqVO updateReqVO) {
|
|
||||||
Long templateId = updateReqVO.getId();
|
Long templateId = updateReqVO.getId();
|
||||||
// 校验存在
|
// 校验存在
|
||||||
ReportTemplateDO reportTemplateDO = validateTemplateExists(templateId);
|
ReportTemplateDO reportTemplateDO = validateTemplateExists(templateId);
|
||||||
|
// 校验模板名唯一性
|
||||||
|
validateTemplateNameUnique(updateReqVO, SecurityFrameworkUtils.isSuperAdmin());
|
||||||
// 校验内置模板操作权限
|
// 校验内置模板操作权限
|
||||||
validateSystemTemplate(reportTemplateDO);
|
validateSystemTemplate(reportTemplateDO);
|
||||||
// url解码xml
|
// url解码xml
|
||||||
@@ -228,12 +164,16 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
ReportTemplateDO updateObj = BeanUtils.toBean(updateReqVO, ReportTemplateDO.class);
|
ReportTemplateDO updateObj = BeanUtils.toBean(updateReqVO, ReportTemplateDO.class);
|
||||||
templateMapper.updateById(updateObj);
|
templateMapper.updateById(updateObj);
|
||||||
|
|
||||||
// 更新数据源
|
ReportTemplateRespVO reportTemplateRespVO = BeanUtils.toBean(updateObj, ReportTemplateRespVO.class);
|
||||||
analyzeDatasource(updateReqVO.getDatasource(), templateId);
|
// 查询数据源、数据集
|
||||||
|
ReportDefinition reportDefinition = new ReportDefinition();
|
||||||
|
queryDatasource(updateObj, reportDefinition);
|
||||||
|
reportTemplateRespVO.setDatasource(reportDefinition.getDatasources());
|
||||||
|
// 返回实体
|
||||||
|
return reportTemplateRespVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void deleteReportTemplate(Long id) {
|
public void deleteReportTemplate(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
ReportTemplateDO reportTemplateDO = validateTemplateExists(id);
|
ReportTemplateDO reportTemplateDO = validateTemplateExists(id);
|
||||||
@@ -241,15 +181,6 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
validateSystemTemplate(reportTemplateDO);
|
validateSystemTemplate(reportTemplateDO);
|
||||||
// 删除
|
// 删除
|
||||||
templateMapper.deleteById(id);
|
templateMapper.deleteById(id);
|
||||||
// 删除关联数据源
|
|
||||||
List<ReportDatasourceDO> reportDatasourceDOS = datasourceMapper.selectList(new LambdaQueryWrapperX<ReportDatasourceDO>().eq(ReportDatasourceDO::getTemplateId, id));
|
|
||||||
if (CollUtil.isNotEmpty(reportDatasourceDOS)) {
|
|
||||||
// 模板下的数据源id
|
|
||||||
List<Long> datasourceIds = reportDatasourceDOS.stream().map(ReportDatasourceDO::getId).toList();
|
|
||||||
datasourceMapper.deleteBatchIds(datasourceIds);
|
|
||||||
// 删除关联数据集
|
|
||||||
datasetMapper.delete(new LambdaQueryWrapperX<ReportDatasetDO>().in(ReportDatasetDO::getDatasourceId, datasourceIds));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -257,11 +188,10 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
* 校验只有超管可以操作内置模板
|
* 校验只有超管可以操作内置模板
|
||||||
*/
|
*/
|
||||||
private void validateSystemTemplate(ReportTemplateDO templateDO) {
|
private void validateSystemTemplate(ReportTemplateDO templateDO) {
|
||||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
boolean isSuperAdmin = SecurityFrameworkUtils.isSuperAdmin();
|
||||||
boolean isSuperAdmin = loginUser != null && loginUser.getIsSupAdmin();
|
|
||||||
// 非超管不能操作内置模板
|
// 非超管不能操作内置模板
|
||||||
if (ReportTemplateTypeEnum.SYSTEM.equals(templateDO.getType()) && !isSuperAdmin) {
|
if (ReportTemplateTypeEnum.SYSTEM.equals(templateDO.getType()) && !isSuperAdmin) {
|
||||||
throw exception(DATATEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
throw exception(TEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,40 +200,55 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
private ReportTemplateDO validateTemplateExists(Long id) {
|
public ReportTemplateDO validateTemplateExists(Long id) {
|
||||||
ReportTemplateDO reportTemplateDO = templateMapper.selectById(id);
|
ReportTemplateDO reportTemplateDO;
|
||||||
if (reportTemplateDO == null) {
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
|
if (ObjectUtil.isNull(loginUser)) {
|
||||||
|
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
// 非超管查询内置模板+机构下的
|
||||||
|
if (loginUser.getIsSupAdmin()) {
|
||||||
|
reportTemplateDO = templateMapper.selectById(id);
|
||||||
|
} else {
|
||||||
|
reportTemplateDO = templateMapper.selectNormalTemplateById(id, loginUser.getOrganId());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNull(reportTemplateDO)) {
|
||||||
throw exception(TEMPLATE_NOT_EXISTS);
|
throw exception(TEMPLATE_NOT_EXISTS);
|
||||||
} else {
|
} else {
|
||||||
return reportTemplateDO;
|
return reportTemplateDO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验唯一性约束
|
||||||
|
*
|
||||||
|
* @param reqVO
|
||||||
|
*/
|
||||||
|
private void validateTemplateNameUnique(ReportTemplateSaveReqVO reqVO, boolean isSuperAdmin) {
|
||||||
|
Long templateId = reqVO.getId();
|
||||||
|
String name = reqVO.getName();
|
||||||
|
LambdaQueryWrapper<ReportTemplateDO> wrapper = new LambdaQueryWrapperX<ReportTemplateDO>().eq(ReportTemplateDO::getName, name);
|
||||||
|
if (ObjectUtil.isNotNull(templateId)) {
|
||||||
|
wrapper.ne(ReportTemplateDO::getId, templateId);
|
||||||
|
}
|
||||||
|
if (isSuperAdmin) {
|
||||||
|
wrapper.eq(ReportTemplateDO::getType, ReportTemplateTypeEnum.SYSTEM);
|
||||||
|
}
|
||||||
|
if (templateMapper.exists(wrapper)) {
|
||||||
|
throw exception(TEMPLATE_NAME_UNIQE_ERROR, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReportTemplateDO getReportTemplate(Long id) {
|
public ReportTemplateDO getReportTemplate(Long id) {
|
||||||
// 校验模板
|
// 校验模板
|
||||||
validateTemplateExists(id);
|
return validateTemplateExists(id);
|
||||||
// 查询模板
|
|
||||||
ReportTemplateDO template = templateMapper.selectById(id);
|
|
||||||
if (ObjectUtil.isNotNull(template)) {
|
|
||||||
// 查询数据源
|
|
||||||
List<ReportDatasourceDO> datasourceList = datasourceService.getTemplateDatasourceList(ReportDatasourceReqVO.builder().templateId(template.getId()).build());
|
|
||||||
datasourceList.forEach(ds -> {
|
|
||||||
// 查询数据集
|
|
||||||
List<ReportDatasetDO> datasetList = datasetService.getDatasetList(ReportDatasetReqVO.builder().datasourceId(ds.getId()).build());
|
|
||||||
ds.setDatasets(datasetList);
|
|
||||||
});
|
|
||||||
template.setDatasource(datasourceList);
|
|
||||||
}
|
|
||||||
return template;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReportDefinitionWrapper getReportTemplateDefinition(Long id) {
|
public ReportDefinitionWrapper getReportTemplateDefinition(Long id) {
|
||||||
// 校验模板
|
// 校验模板
|
||||||
validateTemplateExists(id);
|
ReportTemplateDO template = validateTemplateExists(id);
|
||||||
// 查询模板
|
|
||||||
ReportTemplateDO template = templateMapper.selectById(id);
|
|
||||||
String xmlContent = template.getContent();
|
String xmlContent = template.getContent();
|
||||||
InputStream is;
|
InputStream is;
|
||||||
if (StringUtils.isNotEmpty(xmlContent)) {
|
if (StringUtils.isNotEmpty(xmlContent)) {
|
||||||
@@ -314,46 +259,66 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
// 解析xml
|
// 解析xml
|
||||||
ReportDefinition reportDefinition = new ReportParser().parse(is, template.getName());
|
ReportDefinition reportDefinition = new ReportParser().parse(is, template.getName());
|
||||||
if (ObjectUtil.isNotNull(template)) {
|
if (ObjectUtil.isNotNull(template)) {
|
||||||
queryDatasource(template.getId(), reportDefinition);
|
queryDatasource(template, reportDefinition);
|
||||||
}
|
}
|
||||||
return new ReportDefinitionWrapper(reportDefinition);
|
ReportDefinitionWrapper reportDefinitionWrapper = new ReportDefinitionWrapper(reportDefinition);
|
||||||
|
reportDefinitionWrapper.setDatasetIds(template.getDatasetIds());
|
||||||
|
reportDefinitionWrapper.setDatasourceIds(template.getDatasourceIds());
|
||||||
|
return reportDefinitionWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据源信息(替代ureport xml中的数据源)
|
* 查询数据源信息(替代ureport xml中的数据源)
|
||||||
*
|
*
|
||||||
* @param templateId 模板id
|
* @param templateDO 模板
|
||||||
* @param reportDefinition 报表定义
|
* @param reportDefinition 报表定义
|
||||||
*/
|
*/
|
||||||
private void queryDatasource(Long templateId, ReportDefinition reportDefinition) {
|
private void queryDatasource(ReportTemplateDO templateDO, ReportDefinition reportDefinition) {
|
||||||
|
Set<Long> datasourceIds = templateDO.getDatasourceIds();
|
||||||
|
Set<Long> datasetIds = templateDO.getDatasetIds();
|
||||||
|
List<ReportDatasourceDO> reportDatasourceDOS = new ArrayList<>();
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(datasourceIds)) {
|
||||||
|
// 查询模板下的数据源
|
||||||
|
reportDatasourceDOS = datasourceMapper.selectNormalDatasourceList(datasourceIds, SecurityFrameworkUtils.getUserOrganId());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ReportDatasetDO> reportDatasetDOS = new ArrayList<>();
|
||||||
|
if (CollUtil.isNotEmpty(datasetIds)) {
|
||||||
|
// 查询模板下的数据集
|
||||||
|
reportDatasetDOS = datasetMapper.selectNormalDatasetList(datasetIds);
|
||||||
|
}
|
||||||
|
// 转换ureport对象后的数据源列表
|
||||||
List<DatasourceDefinition> datasourceDefinitions = new ArrayList<>();
|
List<DatasourceDefinition> datasourceDefinitions = new ArrayList<>();
|
||||||
// 查询数据源
|
|
||||||
List<ReportDatasourceDO> datasourceList = datasourceService.getTemplateDatasourceList(ReportDatasourceReqVO.builder().templateId(templateId).build());
|
|
||||||
for (ReportDatasourceDO ds : datasourceList) {
|
// 遍历列表转换为ureport对象
|
||||||
// 查询数据集
|
for (ReportDatasourceDO ds : reportDatasourceDOS) {
|
||||||
List<ReportDatasetDO> datasetList = datasetService.getDatasetList(ReportDatasetReqVO.builder().datasourceId(ds.getId()).build());
|
// 转换ureport对象后的数据集列表
|
||||||
List<DatasetDefinition> datasetDefinitions = new ArrayList<>();
|
List<DatasetDefinition> datasetDefinitions = new ArrayList<>();
|
||||||
|
// 匹配数据源下的数据集
|
||||||
|
List<ReportDatasetDO> datasetInDatasourceList = reportDatasetDOS.stream().filter(reportDatasetDO -> ds.getId().equals(reportDatasetDO.getDatasourceId())).toList();
|
||||||
// 忽略转换的字段名,手动转列表
|
// 忽略转换的字段名,手动转列表
|
||||||
String ignorePropertieName = "datasets";
|
String ignorePropertieName = "datasets";
|
||||||
switch (ds.getType()) {
|
switch (ds.getType()) {
|
||||||
case JDBC, BUILDIN -> {
|
case JDBC -> {
|
||||||
// 转换对应的ureport对象
|
// 转换对应的ureport对象
|
||||||
JdbcDatasourceDefinition jdbcDatasourceDefinition = BeanUtil.copyProperties(ds, JdbcDatasourceDefinition.class, ignorePropertieName);
|
JdbcDatasourceDefinition jdbcDatasourceDefinition = BeanUtil.copyProperties(ds, JdbcDatasourceDefinition.class, ignorePropertieName);
|
||||||
datasetDefinitions.addAll(BeanUtils.toBean(datasetList, SqlDatasetDefinition.class));
|
datasetDefinitions.addAll(BeanUtils.toBean(datasetInDatasourceList, SqlDatasetDefinition.class));
|
||||||
jdbcDatasourceDefinition.setDatasets(datasetDefinitions);
|
jdbcDatasourceDefinition.setDatasets(datasetDefinitions);
|
||||||
datasourceDefinitions.add(jdbcDatasourceDefinition);
|
datasourceDefinitions.add(jdbcDatasourceDefinition);
|
||||||
}
|
}
|
||||||
case SPRING -> {
|
case SPRING -> {
|
||||||
// 转换对应的ureport对象
|
// 转换对应的ureport对象
|
||||||
SpringBeanDatasourceDefinition springBeanDatasourceDefinition = BeanUtil.copyProperties(ds, SpringBeanDatasourceDefinition.class, ignorePropertieName);
|
SpringBeanDatasourceDefinition springBeanDatasourceDefinition = BeanUtil.copyProperties(ds, SpringBeanDatasourceDefinition.class, ignorePropertieName);
|
||||||
datasetDefinitions.addAll(BeanUtils.toBean(datasetList, BeanDatasetDefinition.class));
|
datasetDefinitions.addAll(BeanUtils.toBean(datasetInDatasourceList, BeanDatasetDefinition.class));
|
||||||
springBeanDatasourceDefinition.setDatasets(datasetDefinitions);
|
springBeanDatasourceDefinition.setDatasets(datasetDefinitions);
|
||||||
datasourceDefinitions.add(springBeanDatasourceDefinition);
|
datasourceDefinitions.add(springBeanDatasourceDefinition);
|
||||||
}
|
}
|
||||||
case API -> {
|
case API -> {
|
||||||
// 转换对应的ureport对象
|
// 转换对应的ureport对象
|
||||||
ApiDatasourceDefinition apiDatasourceDefinition = BeanUtil.copyProperties(ds, ApiDatasourceDefinition.class, ignorePropertieName);
|
ApiDatasourceDefinition apiDatasourceDefinition = BeanUtil.copyProperties(ds, ApiDatasourceDefinition.class, ignorePropertieName);
|
||||||
datasetDefinitions.addAll(BeanUtils.toBean(datasetList, ApiDatasetDefinition.class));
|
datasetDefinitions.addAll(BeanUtils.toBean(datasetInDatasourceList, ApiDatasetDefinition.class));
|
||||||
apiDatasourceDefinition.setDatasets(datasetDefinitions);
|
apiDatasourceDefinition.setDatasets(datasetDefinitions);
|
||||||
datasourceDefinitions.add(apiDatasourceDefinition);
|
datasourceDefinitions.add(apiDatasourceDefinition);
|
||||||
}
|
}
|
||||||
@@ -363,22 +328,18 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OrganIgnore
|
|
||||||
public List<ReportTemplateDO> getReportTemplateList(ReportTemplateReqVO reqVO) {
|
public List<ReportTemplateDO> getReportTemplateList(ReportTemplateReqVO reqVO) {
|
||||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
LambdaQueryWrapper<ReportTemplateDO> queryWrapper = new LambdaQueryWrapperX<ReportTemplateDO>().likeIfPresent(ReportTemplateDO::getName, reqVO.getName())
|
LambdaQueryWrapper<ReportTemplateDO> queryWrapper = new LambdaQueryWrapperX<ReportTemplateDO>().likeIfPresent(ReportTemplateDO::getName, reqVO.getName())
|
||||||
.orderByDesc(ReportTemplateDO::getCreateTime)
|
.orderByDesc(ReportTemplateDO::getCreateTime)
|
||||||
// 不返回content xml,点击具体的模板中返回xml
|
// 不返回content xml,点击具体的模板中返回xml
|
||||||
.select(ReportTemplateDO::getId, ReportTemplateDO::getName, ReportTemplateDO::getCreateTime, ReportTemplateDO::getRemark);
|
.select(ReportTemplateDO::getId, ReportTemplateDO::getName, ReportTemplateDO::getCreateTime, ReportTemplateDO::getRemark);
|
||||||
if (loginUser != null && Boolean.FALSE.equals(loginUser.getIsSupAdmin())) {
|
if (ObjectUtil.isNotNull(loginUser) && Boolean.FALSE.equals(loginUser.getIsSupAdmin())) {
|
||||||
// 普通用户查看机构下的和system模板
|
return templateMapper.selectNormalTemplateList(reqVO.getName(), loginUser.getOrganId());
|
||||||
queryWrapper.or(wrapper -> wrapper
|
} else {
|
||||||
.eq(ReportTemplateDO::getOrganId, loginUser.getOrganId())
|
// 超管查看全部
|
||||||
.eq(ReportTemplateDO::getType, ReportTemplateTypeEnum.CUSTOM))
|
return templateMapper.selectList(queryWrapper);
|
||||||
.or(wrapper -> wrapper.eq(ReportTemplateDO::getType, ReportTemplateTypeEnum.SYSTEM));
|
|
||||||
}
|
}
|
||||||
// 超管查看全部
|
|
||||||
return templateMapper.selectList(queryWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -401,12 +362,12 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
report.setChartImages(chartImages);
|
report.setChartImages(chartImages);
|
||||||
try {
|
try {
|
||||||
OutputStream out = response.getOutputStream();
|
OutputStream out = response.getOutputStream();
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding(UTF8_CHARSET);
|
||||||
response.setContentType("application/pdf; charset=UTF-8");
|
response.setContentType("application/pdf; charset=UTF-8");
|
||||||
// 创建下载文件
|
// 创建下载文件
|
||||||
ProducerEnum p = ProducerEnum.PDF;
|
ProducerEnum p = ProducerEnum.PDF;
|
||||||
String downFileName = com.bstek.common.utils.StringUtils.randomFileName() + com.bstek.common.utils.StringUtils.getFileSuffix(p);
|
String downFileName = com.bstek.common.utils.StringUtils.randomFileName() + com.bstek.common.utils.StringUtils.getFileSuffix(p);
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(downFileName, "UTF-8"));
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(downFileName, UTF8_CHARSET));
|
||||||
response.setHeader("code", "20000");
|
response.setHeader("code", "20000");
|
||||||
ExportUtils.export(out, report, p);
|
ExportUtils.export(out, report, p);
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
@@ -425,12 +386,12 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
report.setChartImages(chartImages);
|
report.setChartImages(chartImages);
|
||||||
try {
|
try {
|
||||||
OutputStream out = response.getOutputStream();
|
OutputStream out = response.getOutputStream();
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding(UTF8_CHARSET);
|
||||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||||
// 创建下载文件
|
// 创建下载文件
|
||||||
ProducerEnum p = ProducerEnum.valueOf(type.toUpperCase());
|
ProducerEnum p = ProducerEnum.valueOf(type.toUpperCase());
|
||||||
String downFileName = com.bstek.common.utils.StringUtils.randomFileName() + com.bstek.common.utils.StringUtils.getFileSuffix(p);
|
String downFileName = com.bstek.common.utils.StringUtils.randomFileName() + com.bstek.common.utils.StringUtils.getFileSuffix(p);
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(downFileName, "UTF-8"));
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(downFileName, UTF8_CHARSET));
|
||||||
response.setHeader("code", "20000");
|
response.setHeader("code", "20000");
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
ExportUtils.export(out, report, p);
|
ExportUtils.export(out, report, p);
|
||||||
@@ -477,15 +438,13 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
|||||||
validateProducerType(reqDTO.getProducerType());
|
validateProducerType(reqDTO.getProducerType());
|
||||||
Long templateId = reqDTO.getTemplateId();
|
Long templateId = reqDTO.getTemplateId();
|
||||||
// 校验模板
|
// 校验模板
|
||||||
validateTemplateExists(templateId);
|
ReportTemplateDO template = validateTemplateExists(templateId);
|
||||||
// 查询模板
|
|
||||||
ReportTemplateDO template = templateMapper.selectById(templateId);
|
|
||||||
String xmlContent = template.getContent();
|
String xmlContent = template.getContent();
|
||||||
ReportRender reportRender = new ReportRender();
|
ReportRender reportRender = new ReportRender();
|
||||||
// 解析xml
|
// 解析xml
|
||||||
ReportDefinition reportDefinition = reportRender.getReportDefinition(xmlContent, CharsetUtil.UTF_8);
|
ReportDefinition reportDefinition = reportRender.getReportDefinition(xmlContent, CharsetUtil.UTF_8);
|
||||||
// 查询数据源
|
// 查询数据源
|
||||||
queryDatasource(template.getId(), reportDefinition);
|
queryDatasource(template, reportDefinition);
|
||||||
// 设置参数
|
// 设置参数
|
||||||
PreviewParameters previewParameters = new PreviewParameters();
|
PreviewParameters previewParameters = new PreviewParameters();
|
||||||
previewParameters.setQuery(reqDTO.getParams());
|
previewParameters.setQuery(reqDTO.getParams());
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
|
|||||||
validatedBy = {ReportDatasourceTypeInEnumValidator.class}
|
validatedBy = {ReportDatasourceTypeInEnumValidator.class}
|
||||||
)
|
)
|
||||||
public @interface ReportDatasourceTypeInEnum {
|
public @interface ReportDatasourceTypeInEnum {
|
||||||
String message() default "数据源类型[type]错误,请检查是否jdbc/spring/buildin/api";
|
String message() default "数据源类型[type]错误,请检查是否jdbc/spring/api";
|
||||||
|
|
||||||
Class<?>[] groups() default {};
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
|
|||||||
validatedBy = {ReportTemplateTypeInEnumValidator.class}
|
validatedBy = {ReportTemplateTypeInEnumValidator.class}
|
||||||
)
|
)
|
||||||
public @interface ReportTemplateTypeInEnum {
|
public @interface ReportTemplateTypeInEnum {
|
||||||
String message() default "类型[type]错误,请检查是否0(内置)/1(自定义)";
|
String message() default "类型错误,请检查是否0(内置)/1(自定义)";
|
||||||
|
|
||||||
Class<?>[] groups() default {};
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
|
|||||||
+3
@@ -21,6 +21,9 @@ public class ReportTemplateTypeInEnumValidator implements ConstraintValidator<Re
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
||||||
|
if (ObjectUtil.isNull(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
ReportTemplateTypeEnum byType = ReportTemplateTypeEnum.fromType(value);
|
ReportTemplateTypeEnum byType = ReportTemplateTypeEnum.fromType(value);
|
||||||
if (ObjectUtil.isNotNull(byType)) {
|
if (ObjectUtil.isNotNull(byType)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ chenfeng:
|
|||||||
organ: # 多租户相关配置项
|
organ: # 多租户相关配置项
|
||||||
enable: true
|
enable: true
|
||||||
ignore-tables:
|
ignore-tables:
|
||||||
|
encrypt:
|
||||||
|
enable: false
|
||||||
|
publicKey: cfimes
|
||||||
|
|
||||||
debug: false
|
debug: false
|
||||||
|
|||||||
BIN
Binary file not shown.
-3
@@ -30,7 +30,6 @@ public abstract class ReportCommonServiceImplTest {
|
|||||||
.name("单元测试模板")
|
.name("单元测试模板")
|
||||||
.content(JsonUtil.zipString(TEMPLATE))
|
.content(JsonUtil.zipString(TEMPLATE))
|
||||||
.remark(RandomUtils.randomString())
|
.remark(RandomUtils.randomString())
|
||||||
.datasource(new ArrayList<>())
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -39,14 +38,12 @@ public abstract class ReportCommonServiceImplTest {
|
|||||||
return ReportDatasourceSaveReqVO.builder()
|
return ReportDatasourceSaveReqVO.builder()
|
||||||
.id(id)
|
.id(id)
|
||||||
.name("单元测试数据源")
|
.name("单元测试数据源")
|
||||||
.templateId(reportId)
|
|
||||||
.type(ReportDatasourceTypeEnum.SPRING.getDesc())
|
.type(ReportDatasourceTypeEnum.SPRING.getDesc())
|
||||||
.driver("com.mysql.cj.jdbc.Driver")
|
.driver("com.mysql.cj.jdbc.Driver")
|
||||||
.url("jdbc:mysql://192.168.1.205:3307/imes_base?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true")
|
.url("jdbc:mysql://192.168.1.205:3307/imes_base?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true")
|
||||||
.username("root")
|
.username("root")
|
||||||
.password("root")
|
.password("root")
|
||||||
.remark(RandomUtils.randomString())
|
.remark(RandomUtils.randomString())
|
||||||
.datasets(new ArrayList<>())
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -4,6 +4,7 @@ import com.cf.imes.framework.test.core.util.RandomUtils;
|
|||||||
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetReqVO;
|
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetReqVO;
|
||||||
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetSaveReqVO;
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
||||||
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateRespVO;
|
||||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
import com.cf.imes.module.report.dal.dataobject.dataset.ReportDatasetDO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
||||||
@@ -49,8 +50,9 @@ public class ReportDatasetServiceImplTest extends ReportCommonServiceImplTest{
|
|||||||
// 2、插入template、断言自增id
|
// 2、插入template、断言自增id
|
||||||
// 3、用id查template、断言对象
|
// 3、用id查template、断言对象
|
||||||
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
||||||
Long templateId = reportTemplateService.createReportTemplate(createReqVO);
|
ReportTemplateRespVO reportTemplate = reportTemplateService.createReportTemplate(createReqVO);
|
||||||
assertNotNull(templateId);
|
assertNotNull(reportTemplate);
|
||||||
|
Long templateId = reportTemplate.getId();
|
||||||
ReportTemplateDO template = reportTemplateService.getReportTemplate(templateId);
|
ReportTemplateDO template = reportTemplateService.getReportTemplate(templateId);
|
||||||
assertNotNull(template);
|
assertNotNull(template);
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -3,6 +3,7 @@ package com.cf.imes.module.report.service.template;
|
|||||||
import com.cf.imes.framework.test.core.util.RandomUtils;
|
import com.cf.imes.framework.test.core.util.RandomUtils;
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceReqVO;
|
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceReqVO;
|
||||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
||||||
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateRespVO;
|
||||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
||||||
@@ -41,7 +42,8 @@ public class ReportDatasourceServiceImplTest extends ReportCommonServiceImplTest
|
|||||||
// 2、插入template、断言自增id
|
// 2、插入template、断言自增id
|
||||||
// 3、用id查template、断言对象
|
// 3、用id查template、断言对象
|
||||||
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
||||||
Long templateId = reportTemplateService.createReportTemplate(createReqVO);
|
ReportTemplateRespVO reportTemplate = reportTemplateService.createReportTemplate(createReqVO);
|
||||||
|
Long templateId = reportTemplate.getId();
|
||||||
assertNotNull(templateId);
|
assertNotNull(templateId);
|
||||||
ReportTemplateDO template = reportTemplateService.getReportTemplate(templateId);
|
ReportTemplateDO template = reportTemplateService.getReportTemplate(templateId);
|
||||||
assertNotNull(template);
|
assertNotNull(template);
|
||||||
@@ -70,7 +72,7 @@ public class ReportDatasourceServiceImplTest extends ReportCommonServiceImplTest
|
|||||||
reqVO.setTemplateId(templateId);
|
reqVO.setTemplateId(templateId);
|
||||||
reqVO.setType(ReportDatasourceTypeEnum.JDBC.getCode());
|
reqVO.setType(ReportDatasourceTypeEnum.JDBC.getCode());
|
||||||
reqVO.setName(updateReqVO.getName());
|
reqVO.setName(updateReqVO.getName());
|
||||||
List<ReportDatasourceDO> templateDatasourceList = reportDatasourceService.getTemplateDatasourceList(reqVO);
|
List<ReportDatasourceDO> templateDatasourceList = reportDatasourceService.getDatasourceList();
|
||||||
|
|
||||||
assertNotNull(templateDatasourceList);
|
assertNotNull(templateDatasourceList);
|
||||||
assertNotEquals(0, templateDatasourceList.size());
|
assertNotEquals(0, templateDatasourceList.size());
|
||||||
|
|||||||
+9
-5
@@ -2,6 +2,7 @@ package com.cf.imes.module.report.service.template;
|
|||||||
|
|
||||||
import com.cf.imes.framework.test.core.util.RandomUtils;
|
import com.cf.imes.framework.test.core.util.RandomUtils;
|
||||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
||||||
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateRespVO;
|
||||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||||
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
||||||
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
||||||
@@ -35,7 +36,8 @@ public class ReportTemplateServiceImplTest extends ReportCommonServiceImplTest {
|
|||||||
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
||||||
System.out.println("template压缩后大小:" + createReqVO.getContent().length());
|
System.out.println("template压缩后大小:" + createReqVO.getContent().length());
|
||||||
// 插入
|
// 插入
|
||||||
Long templateId = reportTemplateService.createReportTemplate(createReqVO);
|
ReportTemplateRespVO reportTemplate = reportTemplateService.createReportTemplate(createReqVO);
|
||||||
|
Long templateId = reportTemplate.getId();
|
||||||
// 断言
|
// 断言
|
||||||
assertNotNull(templateId);
|
assertNotNull(templateId);
|
||||||
// 校验是否插入
|
// 校验是否插入
|
||||||
@@ -56,7 +58,8 @@ public class ReportTemplateServiceImplTest extends ReportCommonServiceImplTest {
|
|||||||
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
||||||
System.out.println("template压缩后大小:" + createReqVO.getContent().length());
|
System.out.println("template压缩后大小:" + createReqVO.getContent().length());
|
||||||
// 插入
|
// 插入
|
||||||
Long templateId = reportTemplateService.createReportTemplate(createReqVO);
|
ReportTemplateRespVO reportTemplate = reportTemplateService.createReportTemplate(createReqVO);
|
||||||
|
Long templateId = reportTemplate.getId();
|
||||||
|
|
||||||
//准备更新参数
|
//准备更新参数
|
||||||
ReportTemplateSaveReqVO updateReqVO = prepareTemplateReqVO(templateId);
|
ReportTemplateSaveReqVO updateReqVO = prepareTemplateReqVO(templateId);
|
||||||
@@ -86,7 +89,8 @@ public class ReportTemplateServiceImplTest extends ReportCommonServiceImplTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
||||||
// 插入
|
// 插入
|
||||||
Long templateId = reportTemplateService.createReportTemplate(createReqVO);
|
ReportTemplateRespVO reportTemplate = reportTemplateService.createReportTemplate(createReqVO);
|
||||||
|
Long templateId = reportTemplate.getId();
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
reportTemplateService.deleteReportTemplate(templateId);
|
reportTemplateService.deleteReportTemplate(templateId);
|
||||||
@@ -111,8 +115,8 @@ public class ReportTemplateServiceImplTest extends ReportCommonServiceImplTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
ReportTemplateSaveReqVO createReqVO = prepareTemplateReqVO(null);
|
||||||
// 插入
|
// 插入
|
||||||
Long templateId = reportTemplateService.createReportTemplate(createReqVO);
|
ReportTemplateRespVO reportTemplate = reportTemplateService.createReportTemplate(createReqVO);
|
||||||
|
Long templateId = reportTemplate.getId();
|
||||||
|
|
||||||
ReportTemplateReqVO reqVO = new ReportTemplateReqVO();
|
ReportTemplateReqVO reqVO = new ReportTemplateReqVO();
|
||||||
reqVO.setType(ReportTemplateTypeEnum.SYSTEM.getType());
|
reqVO.setType(ReportTemplateTypeEnum.SYSTEM.getType());
|
||||||
|
|||||||
+4
-5
@@ -16,7 +16,6 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode AUTH_THIRD_LOGIN_NOT_BIND = new ErrorCode(1_002_000_005, "未绑定账号,需要进行绑定");
|
ErrorCode AUTH_THIRD_LOGIN_NOT_BIND = new ErrorCode(1_002_000_005, "未绑定账号,需要进行绑定");
|
||||||
ErrorCode AUTH_TOKEN_EXPIRED = new ErrorCode(1_002_000_006, "Token 已经过期");
|
ErrorCode AUTH_TOKEN_EXPIRED = new ErrorCode(1_002_000_006, "Token 已经过期");
|
||||||
ErrorCode AUTH_MOBILE_NOT_EXISTS = new ErrorCode(1_002_000_007, "手机号不存在");
|
ErrorCode AUTH_MOBILE_NOT_EXISTS = new ErrorCode(1_002_000_007, "手机号不存在");
|
||||||
ErrorCode AUTH_LOGIN_FIRST_LOGIN = new ErrorCode(1_002_000_008, "请通过验证码登录");
|
|
||||||
|
|
||||||
// ========== 菜单模块 1-002-001-000 ==========
|
// ========== 菜单模块 1-002-001-000 ==========
|
||||||
ErrorCode MENU_NAME_DUPLICATE = new ErrorCode(1_002_001_000, "已经存在该名字的菜单");
|
ErrorCode MENU_NAME_DUPLICATE = new ErrorCode(1_002_001_000, "已经存在该名字的菜单");
|
||||||
@@ -37,7 +36,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode ROLE_NOT_SUPERADMIN_NO_ORGAN_ID_OPER_ERROR = new ErrorCode(1_002_002_007, "非超管分配权限");
|
ErrorCode ROLE_NOT_SUPERADMIN_NO_ORGAN_ID_OPER_ERROR = new ErrorCode(1_002_002_007, "非超管分配权限");
|
||||||
|
|
||||||
// ========== 用户模块 1-002-003-000 ==========
|
// ========== 用户模块 1-002-003-000 ==========
|
||||||
ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1_002_003_000, "用户账号已经存在");
|
ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1_002_003_000, "手机号已经存在");
|
||||||
ErrorCode USER_MOBILE_EXISTS = new ErrorCode(1_002_003_001, "手机号已经存在");
|
ErrorCode USER_MOBILE_EXISTS = new ErrorCode(1_002_003_001, "手机号已经存在");
|
||||||
ErrorCode USER_EMAIL_EXISTS = new ErrorCode(1_002_003_002, "邮箱已经存在");
|
ErrorCode USER_EMAIL_EXISTS = new ErrorCode(1_002_003_002, "邮箱已经存在");
|
||||||
ErrorCode USER_NOT_EXISTS = new ErrorCode(1_002_003_003, "用户不存在");
|
ErrorCode USER_NOT_EXISTS = new ErrorCode(1_002_003_003, "用户不存在");
|
||||||
@@ -102,7 +101,7 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
// ========== 短信发送 1-002-013-000 ==========
|
// ========== 短信发送 1-002-013-000 ==========
|
||||||
ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1_002_013_000, "手机号不存在");
|
ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1_002_013_000, "手机号不存在");
|
||||||
ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_013_001, "模板参数({})缺失");
|
ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_013_001, "短信模板参数({})缺失");
|
||||||
ErrorCode SMS_SEND_TEMPLATE_NOT_EXISTS = new ErrorCode(1_002_013_002, "短信模板不存在");
|
ErrorCode SMS_SEND_TEMPLATE_NOT_EXISTS = new ErrorCode(1_002_013_002, "短信模板不存在");
|
||||||
|
|
||||||
// ========== 短信验证码 1-002-014-000 ==========
|
// ========== 短信验证码 1-002-014-000 ==========
|
||||||
@@ -177,7 +176,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode MAIL_TEMPLATE_CODE_EXISTS = new ErrorCode(1_002_024_001, "邮件模版 code({}) 已存在");
|
ErrorCode MAIL_TEMPLATE_CODE_EXISTS = new ErrorCode(1_002_024_001, "邮件模版 code({}) 已存在");
|
||||||
|
|
||||||
// ========== 邮件发送 1-002-025-000 ==========
|
// ========== 邮件发送 1-002-025-000 ==========
|
||||||
ErrorCode MAIL_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_025_000, "模板参数({})缺失");
|
ErrorCode MAIL_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_025_000, "邮件模板参数({})缺失");
|
||||||
ErrorCode MAIL_SEND_MAIL_NOT_EXISTS = new ErrorCode(1_002_025_001, "邮箱不存在");
|
ErrorCode MAIL_SEND_MAIL_NOT_EXISTS = new ErrorCode(1_002_025_001, "邮箱不存在");
|
||||||
|
|
||||||
// ========== 站内信模版 1-002-026-000 ==========
|
// ========== 站内信模版 1-002-026-000 ==========
|
||||||
@@ -187,7 +186,7 @@ public interface ErrorCodeConstants {
|
|||||||
// ========== 站内信模版 1-002-027-000 ==========
|
// ========== 站内信模版 1-002-027-000 ==========
|
||||||
|
|
||||||
// ========== 站内信发送 1-002-028-000 ==========
|
// ========== 站内信发送 1-002-028-000 ==========
|
||||||
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失");
|
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "站内信模板参数({})缺失");
|
||||||
|
|
||||||
|
|
||||||
//=========== 工序信息 1-002-027-000 ============
|
//=========== 工序信息 1-002-027-000 ============
|
||||||
|
|||||||
+1
-10
@@ -30,6 +30,7 @@ public class AuthLoginReqVO {
|
|||||||
|
|
||||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
|
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
|
||||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||||
|
@NotEmpty(message = "密码不能为空")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@Schema(description = "组织名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰科技")
|
@Schema(description = "组织名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰科技")
|
||||||
@@ -42,10 +43,6 @@ public class AuthLoginReqVO {
|
|||||||
@NotEmpty(message = "验证码不能为空", groups = CodeEnableGroup.class)
|
@NotEmpty(message = "验证码不能为空", groups = CodeEnableGroup.class)
|
||||||
private String captchaVerification;
|
private String captchaVerification;
|
||||||
|
|
||||||
@Schema(description = "短信验证码", example = "123456")
|
|
||||||
@Length(min = 6, max = 6, message = "短信验证码长度为 6 位")
|
|
||||||
private String smsCaptchaVerification;
|
|
||||||
|
|
||||||
// ========== 绑定社交登录时,需要传递如下参数 ==========
|
// ========== 绑定社交登录时,需要传递如下参数 ==========
|
||||||
|
|
||||||
@Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
@Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||||
@@ -72,10 +69,4 @@ public class AuthLoginReqVO {
|
|||||||
public boolean isSocialState() {
|
public boolean isSocialState() {
|
||||||
return socialType == null || StringUtils.isNotEmpty(socialState);
|
return socialType == null || StringUtils.isNotEmpty(socialState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AssertTrue(message = "请输入密码后登陆")
|
|
||||||
public boolean isPasswordValid() {
|
|
||||||
// 要么是密码登录、要么是验证码登录
|
|
||||||
return ObjectUtil.isNotNull(password) || ObjectUtil.isNotNull(smsCaptchaVerification);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-11
@@ -94,7 +94,6 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
public AdminUserDO authenticate(AuthLoginReqVO reqVO) {
|
public AdminUserDO authenticate(AuthLoginReqVO reqVO) {
|
||||||
String username = reqVO.getUsername();
|
String username = reqVO.getUsername();
|
||||||
String password = reqVO.getPassword();
|
String password = reqVO.getPassword();
|
||||||
String smsCaptchaVerification = reqVO.getSmsCaptchaVerification();
|
|
||||||
final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_USERNAME;
|
final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_USERNAME;
|
||||||
// 查询账号
|
// 查询账号
|
||||||
AdminUserDO user = userService.getUserUniqueByUserName(username);
|
AdminUserDO user = userService.getUserUniqueByUserName(username);
|
||||||
@@ -116,11 +115,6 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_DISABLED);
|
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_DISABLED);
|
||||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AUTH_LOGIN_USER_DISABLED);
|
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AUTH_LOGIN_USER_DISABLED);
|
||||||
}
|
}
|
||||||
// 校验没有密码并且没有传验证码,告诉前端需要验证码登录
|
|
||||||
if (StringUtils.isEmpty(userPassword) && StringUtils.isEmpty(smsCaptchaVerification)) {
|
|
||||||
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.FIRST_LOGIN);
|
|
||||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AUTH_LOGIN_FIRST_LOGIN);
|
|
||||||
}
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,11 +138,6 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
if (StringUtils.isBlank(dataSourceCode)) {
|
if (StringUtils.isBlank(dataSourceCode)) {
|
||||||
throw exception(ORGAN_DATA_CODE_NOT_EXISTS);
|
throw exception(ORGAN_DATA_CODE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
// 验证并消耗验证码
|
|
||||||
String smsCaptchaVerification = reqVO.getSmsCaptchaVerification();
|
|
||||||
if (StringUtils.isNotEmpty(smsCaptchaVerification)) {
|
|
||||||
smsCodeService.useSmsCode(SmsCodeUseReqDTO.builder().mobile(user.getUsername()).code(smsCaptchaVerification).scene(SmsSceneEnum.USER_LOGIN_CAPTCHAVERIFICATION.getScene()).build());
|
|
||||||
}
|
|
||||||
// 创建 Token 令牌,记录登录日志
|
// 创建 Token 令牌,记录登录日志
|
||||||
return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME,organ.getLarge(), dataSourceCode, user.getOrganId(), user.getNickname());
|
return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME,organ.getLarge(), dataSourceCode, user.getOrganId(), user.getNickname());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user