Commit 0d993519 authored by huangjie's avatar huangjie

Merge branch 'zuhuduan' of http://192.168.60.201/root/dsk-operate-sys into zuhuduan

parents 0c5b5b25 8db03d08
package com.dsk.web.controller.system;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import com.dsk.common.annotation.Log;
import com.dsk.common.constant.UserConstants;
......@@ -9,8 +10,10 @@ import com.dsk.common.core.domain.R;
import com.dsk.system.domain.SysDept;
import com.dsk.common.enums.BusinessType;
import com.dsk.common.utils.StringUtils;
import com.dsk.system.domain.vo.SysDeptVo;
import com.dsk.system.service.ISysDeptService;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -34,9 +37,13 @@ public class SysDeptController extends BaseController {
*/
@SaCheckPermission("system:dept:list")
@GetMapping("/list")
public R<List<SysDept>> list(SysDept dept) {
public R<List<SysDeptVo>> list(SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept);
return R.ok(depts);
List<SysDeptVo> deptVos = BeanUtil.copyToList(depts, SysDeptVo.class);
deptVos.forEach(sysDeptVo -> {
sysDeptVo.setExistUsers(deptService.hasChildByDeptId(sysDeptVo.getDeptId()));
});
return R.ok(deptVos);
}
/**
......@@ -106,13 +113,8 @@ public class SysDeptController extends BaseController {
@SaCheckPermission("system:dept:remove")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
@Transactional
public R<Void> remove(@PathVariable Long deptId) {
if (deptService.hasChildByDeptId(deptId)) {
return R.warn("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId)) {
return R.warn("部门存在用户,不允许删除");
}
deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId));
}
......
......@@ -10,9 +10,6 @@ import com.dsk.common.annotation.Log;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.domain.R;
import com.dsk.system.domain.SysDept;
import com.dsk.system.domain.SysRole;
import com.dsk.system.domain.SysUser;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.enums.BusinessType;
import com.dsk.common.excel.ExcelResult;
......@@ -20,6 +17,9 @@ import com.dsk.common.helper.LoginHelper;
import com.dsk.common.utils.StreamUtils;
import com.dsk.common.utils.StringUtils;
import com.dsk.common.utils.poi.ExcelUtil;
import com.dsk.system.domain.SysDept;
import com.dsk.system.domain.SysRole;
import com.dsk.system.domain.SysUser;
import com.dsk.system.domain.vo.SysUserExportVo;
import com.dsk.system.domain.vo.SysUserImportVo;
import com.dsk.system.listener.SysUserImportListener;
......@@ -142,7 +142,6 @@ public class SysUserController extends BaseController {
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
return R.fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setPassword(BCrypt.hashpw(user.getPassword()));
return toAjax(userService.insertUser(user));
}
......
......@@ -157,6 +157,14 @@ tenant:
- sys_user_post
- sys_user_role
- sys_client
- contact_info
- customer_user
- customer_follow_record
- business_user
- business_backlog
- business_follow_record
- business_label
- business_relate_company
# MyBatisPlus配置
......
package com.dsk.common.exception.file;
import org.apache.tomcat.util.http.fileupload.FileUploadException;
import java.util.Arrays;
/**
* 文件上传 误异常类
*
* @author dsk
*/
public class InvalidExtensionException extends FileUploadException
{
private static final long serialVersionUID = 1L;
private String[] allowedExtension;
private String extension;
private String filename;
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
{
super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式");
this.allowedExtension = allowedExtension;
this.extension = extension;
this.filename = filename;
}
public String[] getAllowedExtension()
{
return allowedExtension;
}
public String getExtension()
{
return extension;
}
public String getFilename()
{
return filename;
}
public static class InvalidImageExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename)
{
super(allowedExtension, extension, filename);
}
}
public static class InvalidFlashExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename)
{
super(allowedExtension, extension, filename);
}
}
public static class InvalidMediaExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename)
{
super(allowedExtension, extension, filename);
}
}
public static class InvalidVideoExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename)
{
super(allowedExtension, extension, filename);
}
}
}
package com.dsk.common.utils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import com.dsk.common.utils.spring.SpringUtils;
import io.github.linpeilie.Converter;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
/**
* @author sxk
* @date 2023.08.23
* @description: Mapstruct 工具类
* <p>参考文档:<a href="https://mapstruct.plus/introduction/quick-start.html">mapstruct-plus</a></p>
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MapStructUtils {
private final static Converter CONVERTER = SpringUtils.getBean(Converter.class);
/**
* 将 T 类型对象,转换为 desc 类型的对象并返回
*
* @param source 数据来源实体
* @param desc 描述对象 转换后的对象
* @return desc
*/
public static <T, V> V convert(T source, Class<V> desc) {
if (ObjectUtil.isNull(source)) {
return null;
}
if (ObjectUtil.isNull(desc)) {
return null;
}
return CONVERTER.convert(source, desc);
}
/**
* 将 T 类型对象,按照配置的映射字段规则,给 desc 类型的对象赋值并返回 desc 对象
*
* @param source 数据来源实体
* @param desc 转换后的对象
* @return desc
*/
public static <T, V> V convert(T source, V desc) {
if (ObjectUtil.isNull(source)) {
return null;
}
if (ObjectUtil.isNull(desc)) {
return null;
}
return CONVERTER.convert(source, desc);
}
/**
* 将 T 类型的集合,转换为 desc 类型的集合并返回
*
* @param sourceList 数据来源实体列表
* @param desc 描述对象 转换后的对象
* @return desc
*/
public static <T, V> List<V> convert(List<T> sourceList, Class<V> desc) {
if (ObjectUtil.isNull(sourceList)) {
return null;
}
if (CollUtil.isEmpty(sourceList)) {
return CollUtil.newArrayList();
}
return CONVERTER.convert(sourceList, desc);
}
/**
* 将 Map 转换为 beanClass 类型的集合并返回
*
* @param map 数据来源
* @param beanClass bean类
* @return bean对象
*/
public static <T> T convert(Map<String, Object> map, Class<T> beanClass) {
if (MapUtil.isEmpty(map)) {
return null;
}
if (ObjectUtil.isNull(beanClass)) {
return null;
}
return CONVERTER.convert(map, beanClass);
}
}
package com.dsk.common.utils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.util.Random;
/**
* 密码工具类
*
* @author sxk
* @date 2023.08.31
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class PasswordUtils {
private static final String LOWER_CASE = "abcdefghijklmnopqrstuvwxyz";
private static final String UPPER_CASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String NUMBERS = "0123456789";
/**
* 生成随机密码
* @param length 密码长度
* @return 新生成的密码
*/
public static String generatePwd(int length) {
StringBuilder password = new StringBuilder();
Random random = new Random();
// 至少包含一个小写字母
password.append(LOWER_CASE.charAt(random.nextInt(LOWER_CASE.length())));
// 至少包含一个大写字母
password.append(UPPER_CASE.charAt(random.nextInt(UPPER_CASE.length())));
// 至少包含一个数字
password.append(NUMBERS.charAt(random.nextInt(NUMBERS.length())));
// 生成剩余部分的密码
for (int i = 0; i < length - 3; i++) {
String characters = LOWER_CASE + UPPER_CASE + NUMBERS;
password.append(characters.charAt(random.nextInt(characters.length())));
}
// 打乱密码中字符的顺序
return shufflePassword(password.toString());
}
public static String shufflePassword(String password) {
char[] passwordArray = password.toCharArray();
Random random = new Random();
for (int i = passwordArray.length - 1; i > 0; i--) {
int index = random.nextInt(i + 1);
char temp = passwordArray[index];
passwordArray[index] = passwordArray[i];
passwordArray[i] = temp;
}
return new String(passwordArray);
}
}
package com.dsk.common.utils.file;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
/**
* 文件类型工具类
*
* @author dsk
*/
public class FileTypeUtils
{
/**
* 获取文件类型
* <p>
* 例如: dsk.txt, 返回: txt
*
* @param file 文件名
* @return 后缀(不含".")
*/
public static String getFileType(File file)
{
if (null == file)
{
return StringUtils.EMPTY;
}
return getFileType(file.getName());
}
/**
* 获取文件类型
* <p>
* 例如: dsk.txt, 返回: txt
*
* @param fileName 文件名
* @return 后缀(不含".")
*/
public static String getFileType(String fileName)
{
int separatorIndex = fileName.lastIndexOf(".");
if (separatorIndex < 0)
{
return "";
}
return fileName.substring(separatorIndex + 1).toLowerCase();
}
/**
* 获取文件类型
*
* @param photoByte 文件字节码
* @return 后缀(不含".")
*/
public static String getFileExtendName(byte[] photoByte)
{
String strFileExtendName = "JPG";
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
{
strFileExtendName = "GIF";
}
else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
{
strFileExtendName = "JPG";
}
else if ((photoByte[0] == 66) && (photoByte[1] == 77))
{
strFileExtendName = "BMP";
}
else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
{
strFileExtendName = "PNG";
}
return strFileExtendName;
}
}
package com.dsk.common.utils.file;
import com.dsk.common.exception.file.FileNameLengthLimitExceededException;
import com.dsk.common.exception.file.FileSizeLimitExceededException;
import com.dsk.common.exception.file.InvalidExtensionException;
import com.dsk.common.utils.DateUtils;
import com.dsk.common.utils.StringUtils;
import com.dsk.common.utils.uuid.Seq;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Objects;
/**
* 文件上传工具类
*
* @author dsk
*/
public class FileUploadUtils
{
/**
* 默认大小 50M
*/
public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024;
/**
* 默认的文件名最大长度 100
*/
public static final int DEFAULT_FILE_NAME_LENGTH = 100;
/**
* 默认上传的地址
*/
private static String defaultBaseDir = "/home/server/dsk-operate-sys/uploadPath/";
/**
* 资源映射路径 前缀
*/
public static final String RESOURCE_PREFIX = "/profile";
public static void setDefaultBaseDir(String defaultBaseDir)
{
FileUploadUtils.defaultBaseDir = defaultBaseDir;
}
public static String getDefaultBaseDir()
{
return defaultBaseDir;
}
/**
* 以默认配置进行文件上传
*
* @param file 上传的文件
* @return 文件名称
* @throws Exception
*/
public static final String upload(MultipartFile file) throws IOException
{
try
{
return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
}
catch (Exception e)
{
throw new IOException(e.getMessage(), e);
}
}
/**
* 根据文件路径上传
*
* @param baseDir 相对应用的基目录
* @param file 上传的文件
* @return 文件名称
* @throws IOException
*/
public static final String upload(String baseDir, MultipartFile file) throws IOException
{
try
{
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
}
catch (Exception e)
{
throw new IOException(e.getMessage(), e);
}
}
/**
* 文件上传
*
* @param baseDir 相对应用的基目录
* @param file 上传的文件
* @param allowedExtension 上传文件类型
* @return 返回上传成功的文件名
* @throws FileSizeLimitExceededException 如果超出最大大小
* @throws FileNameLengthLimitExceededException 文件名太长
* @throws IOException 比如读写文件出错时
*/
public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException
{
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
{
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
}
assertAllowed(file, allowedExtension);
// String fileName = extractFilename(file);
// String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
String absPath = getAbsoluteFile(baseDir, file.getOriginalFilename()).getAbsolutePath();
file.transferTo(Paths.get(absPath));
// return getPathFileName(baseDir, fileName);
return baseDir+file.getOriginalFilename();
}
/**
* 编码文件名
*/
public static final String extractFilename(MultipartFile file)
{
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file));
}
public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
{
File desc = new File(uploadDir + File.separator + fileName);
if (!desc.exists())
{
if (!desc.getParentFile().exists())
{
desc.getParentFile().mkdirs();
}
}
return desc;
}
public static final String getPathFileName(String uploadDir, String fileName) throws IOException
{
int dirLastIndex = getDefaultBaseDir().length() + 1;
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
return RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
}
/**
* 文件大小校验
*
* @param file 上传的文件
* @return
* @throws FileSizeLimitExceededException 如果超出最大大小
*/
public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, InvalidExtensionException
{
long size = file.getSize();
if (size > DEFAULT_MAX_SIZE)
{
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
}
String fileName = file.getOriginalFilename();
String extension = getExtension(file);
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
{
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
{
throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
fileName);
}
else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION)
{
throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
fileName);
}
else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION)
{
throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
fileName);
}
else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION)
{
throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension,
fileName);
}
else
{
throw new InvalidExtensionException(allowedExtension, extension, fileName);
}
}
}
/**
* 判断MIME类型是否是允许的MIME类型
*
* @param extension
* @param allowedExtension
* @return
*/
public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
{
for (String str : allowedExtension)
{
if (str.equalsIgnoreCase(extension))
{
return true;
}
}
return false;
}
/**
* 获取文件名的后缀
*
* @param file 表单文件
* @return 后缀名
*/
public static final String getExtension(MultipartFile file)
{
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
if (StringUtils.isEmpty(extension))
{
extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
}
return extension;
}
}
......@@ -37,4 +37,22 @@ public class MimeTypeUtils {
// pdf
"pdf"};
public static String getExtension(String prefix)
{
switch (prefix)
{
case IMAGE_PNG:
return "png";
case IMAGE_JPG:
return "jpg";
case IMAGE_JPEG:
return "jpeg";
case IMAGE_BMP:
return "bmp";
case IMAGE_GIF:
return "gif";
default:
return "";
}
}
}
package com.dsk.common.utils.uuid;
/**
* ID生成器工具类
*
* @author dsk
*/
public class IdUtils
{
/**
* 获取随机UUID
*
* @return 随机UUID
*/
public static String randomUUID()
{
return UUID.randomUUID().toString();
}
/**
* 简化的UUID,去掉了横线
*
* @return 简化的UUID,去掉了横线
*/
public static String simpleUUID()
{
return UUID.randomUUID().toString(true);
}
/**
* 获取随机UUID,使用性能更好的ThreadLocalRandom生成UUID
*
* @return 随机UUID
*/
public static String fastUUID()
{
return UUID.fastUUID().toString();
}
/**
* 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID
*
* @return 简化的UUID,去掉了横线
*/
public static String fastSimpleUUID()
{
return UUID.fastUUID().toString(true);
}
}
package com.dsk.common.utils.uuid;
import com.dsk.common.utils.DateUtils;
import com.dsk.common.utils.StringUtils;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author dsk 序列生成类
*/
public class Seq
{
// 通用序列类型
public static final String commSeqType = "COMMON";
// 上传序列类型
public static final String uploadSeqType = "UPLOAD";
// 通用接口序列数
private static AtomicInteger commSeq = new AtomicInteger(1);
// 上传接口序列数
private static AtomicInteger uploadSeq = new AtomicInteger(1);
// 机器标识
private static final String machineCode = "A";
/**
* 获取通用序列号
*
* @return 序列值
*/
public static String getId()
{
return getId(commSeqType);
}
/**
* 默认16位序列号 yyMMddHHmmss + 一位机器标识 + 3长度循环递增字符串
*
* @return 序列值
*/
public static String getId(String type)
{
AtomicInteger atomicInt = commSeq;
if (uploadSeqType.equals(type))
{
atomicInt = uploadSeq;
}
return getId(atomicInt, 3);
}
/**
* 通用接口序列号 yyMMddHHmmss + 一位机器标识 + length长度循环递增字符串
*
* @param atomicInt 序列数
* @param length 数值长度
* @return 序列值
*/
public static String getId(AtomicInteger atomicInt, int length)
{
String result = DateUtils.dateTimeNow();
result += machineCode;
result += getSeq(atomicInt, length);
return result;
}
/**
* 序列循环递增字符串[1, 10 的 (length)幂次方), 用0左补齐length位数
*
* @return 序列值
*/
private synchronized static String getSeq(AtomicInteger atomicInt, int length)
{
// 先取值再+1
int value = atomicInt.getAndIncrement();
// 如果更新后值>=10 的 (length)幂次方则重置为1
int maxSeq = (int) Math.pow(10, length);
if (atomicInt.get() >= maxSeq)
{
atomicInt.set(1);
}
// 转字符串,用0左补齐
return StringUtils.padl(value, length);
}
}
package com.dsk.common.utils.uuid;
import com.dsk.common.exception.UtilException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
/**
* 提供通用唯一识别码(universally unique identifier)(UUID)实现
*
* @author dsk
*/
public final class UUID implements java.io.Serializable, Comparable<UUID>
{
private static final long serialVersionUID = -1185015143654744140L;
/**
* SecureRandom 的单例
*
*/
private static class Holder
{
static final SecureRandom numberGenerator = getSecureRandom();
}
/** 此UUID的最高64有效位 */
private final long mostSigBits;
/** 此UUID的最低64有效位 */
private final long leastSigBits;
/**
* 私有构造
*
* @param data 数据
*/
private UUID(byte[] data)
{
long msb = 0;
long lsb = 0;
assert data.length == 16 : "data must be 16 bytes in length";
for (int i = 0; i < 8; i++)
{
msb = (msb << 8) | (data[i] & 0xff);
}
for (int i = 8; i < 16; i++)
{
lsb = (lsb << 8) | (data[i] & 0xff);
}
this.mostSigBits = msb;
this.leastSigBits = lsb;
}
/**
* 使用指定的数据构造新的 UUID。
*
* @param mostSigBits 用于 {@code UUID} 的最高有效 64 位
* @param leastSigBits 用于 {@code UUID} 的最低有效 64 位
*/
public UUID(long mostSigBits, long leastSigBits)
{
this.mostSigBits = mostSigBits;
this.leastSigBits = leastSigBits;
}
/**
* 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的本地线程伪随机数生成器生成该 UUID。
*
* @return 随机生成的 {@code UUID}
*/
public static UUID fastUUID()
{
return randomUUID(false);
}
/**
* 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
*
* @return 随机生成的 {@code UUID}
*/
public static UUID randomUUID()
{
return randomUUID(true);
}
/**
* 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
*
* @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能
* @return 随机生成的 {@code UUID}
*/
public static UUID randomUUID(boolean isSecure)
{
final Random ng = isSecure ? Holder.numberGenerator : getRandom();
byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes);
randomBytes[6] &= 0x0f; /* clear version */
randomBytes[6] |= 0x40; /* set to version 4 */
randomBytes[8] &= 0x3f; /* clear variant */
randomBytes[8] |= 0x80; /* set to IETF variant */
return new UUID(randomBytes);
}
/**
* 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。
*
* @param name 用于构造 UUID 的字节数组。
*
* @return 根据指定数组生成的 {@code UUID}
*/
public static UUID nameUUIDFromBytes(byte[] name)
{
MessageDigest md;
try
{
md = MessageDigest.getInstance("MD5");
}
catch (NoSuchAlgorithmException nsae)
{
throw new InternalError("MD5 not supported");
}
byte[] md5Bytes = md.digest(name);
md5Bytes[6] &= 0x0f; /* clear version */
md5Bytes[6] |= 0x30; /* set to version 3 */
md5Bytes[8] &= 0x3f; /* clear variant */
md5Bytes[8] |= 0x80; /* set to IETF variant */
return new UUID(md5Bytes);
}
/**
* 根据 {@link #toString()} 方法中描述的字符串标准表示形式创建{@code UUID}。
*
* @param name 指定 {@code UUID} 字符串
* @return 具有指定值的 {@code UUID}
* @throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常
*
*/
public static UUID fromString(String name)
{
String[] components = name.split("-");
if (components.length != 5)
{
throw new IllegalArgumentException("Invalid UUID string: " + name);
}
for (int i = 0; i < 5; i++)
{
components[i] = "0x" + components[i];
}
long mostSigBits = Long.decode(components[0]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[1]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[2]).longValue();
long leastSigBits = Long.decode(components[3]).longValue();
leastSigBits <<= 48;
leastSigBits |= Long.decode(components[4]).longValue();
return new UUID(mostSigBits, leastSigBits);
}
/**
* 返回此 UUID 的 128 位值中的最低有效 64 位。
*
* @return 此 UUID 的 128 位值中的最低有效 64 位。
*/
public long getLeastSignificantBits()
{
return leastSigBits;
}
/**
* 返回此 UUID 的 128 位值中的最高有效 64 位。
*
* @return 此 UUID 的 128 位值中最高有效 64 位。
*/
public long getMostSignificantBits()
{
return mostSigBits;
}
/**
* 与此 {@code UUID} 相关联的版本号. 版本号描述此 {@code UUID} 是如何生成的。
* <p>
* 版本号具有以下含意:
* <ul>
* <li>1 基于时间的 UUID
* <li>2 DCE 安全 UUID
* <li>3 基于名称的 UUID
* <li>4 随机生成的 UUID
* </ul>
*
* @return 此 {@code UUID} 的版本号
*/
public int version()
{
// Version is bits masked by 0x000000000000F000 in MS long
return (int) ((mostSigBits >> 12) & 0x0f);
}
/**
* 与此 {@code UUID} 相关联的变体号。变体号描述 {@code UUID} 的布局。
* <p>
* 变体号具有以下含意:
* <ul>
* <li>0 为 NCS 向后兼容保留
* <li>2 <a href="http://www.ietf.org/rfc/rfc4122.txt">IETF&nbsp;RFC&nbsp;4122</a>(Leach-Salz), 用于此类
* <li>6 保留,微软向后兼容
* <li>7 保留供以后定义使用
* </ul>
*
* @return 此 {@code UUID} 相关联的变体号
*/
public int variant()
{
// This field is composed of a varying number of bits.
// 0 - - Reserved for NCS backward compatibility
// 1 0 - The IETF aka Leach-Salz variant (used by this class)
// 1 1 0 Reserved, Microsoft backward compatibility
// 1 1 1 Reserved for future definition.
return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63));
}
/**
* 与此 UUID 相关联的时间戳值。
*
* <p>
* 60 位的时间戳值根据此 {@code UUID} 的 time_low、time_mid 和 time_hi 字段构造。<br>
* 所得到的时间戳以 100 毫微秒为单位,从 UTC(通用协调时间) 1582 年 10 月 15 日零时开始。
*
* <p>
* 时间戳值仅在在基于时间的 UUID(其 version 类型为 1)中才有意义。<br>
* 如果此 {@code UUID} 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
*
* @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。
*/
public long timestamp() throws UnsupportedOperationException
{
checkTimeBase();
return (mostSigBits & 0x0FFFL) << 48//
| ((mostSigBits >> 16) & 0x0FFFFL) << 32//
| mostSigBits >>> 32;
}
/**
* 与此 UUID 相关联的时钟序列值。
*
* <p>
* 14 位的时钟序列值根据此 UUID 的 clock_seq 字段构造。clock_seq 字段用于保证在基于时间的 UUID 中的时间唯一性。
* <p>
* {@code clockSequence} 值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 如果此 UUID 不是基于时间的 UUID,则此方法抛出
* UnsupportedOperationException。
*
* @return 此 {@code UUID} 的时钟序列
*
* @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
*/
public int clockSequence() throws UnsupportedOperationException
{
checkTimeBase();
return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
}
/**
* 与此 UUID 相关的节点值。
*
* <p>
* 48 位的节点值根据此 UUID 的 node 字段构造。此字段旨在用于保存机器的 IEEE 802 地址,该地址用于生成此 UUID 以保证空间唯一性。
* <p>
* 节点值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。<br>
* 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
*
* @return 此 {@code UUID} 的节点值
*
* @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
*/
public long node() throws UnsupportedOperationException
{
checkTimeBase();
return leastSigBits & 0x0000FFFFFFFFFFFFL;
}
/**
* 返回此{@code UUID} 的字符串表现形式。
*
* <p>
* UUID 的字符串表示形式由此 BNF 描述:
*
* <pre>
* {@code
* UUID = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node>
* time_low = 4*<hexOctet>
* time_mid = 2*<hexOctet>
* time_high_and_version = 2*<hexOctet>
* variant_and_sequence = 2*<hexOctet>
* node = 6*<hexOctet>
* hexOctet = <hexDigit><hexDigit>
* hexDigit = [0-9a-fA-F]
* }
* </pre>
*
* </blockquote>
*
* @return 此{@code UUID} 的字符串表现形式
* @see #toString(boolean)
*/
@Override
public String toString()
{
return toString(false);
}
/**
* 返回此{@code UUID} 的字符串表现形式。
*
* <p>
* UUID 的字符串表示形式由此 BNF 描述:
*
* <pre>
* {@code
* UUID = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node>
* time_low = 4*<hexOctet>
* time_mid = 2*<hexOctet>
* time_high_and_version = 2*<hexOctet>
* variant_and_sequence = 2*<hexOctet>
* node = 6*<hexOctet>
* hexOctet = <hexDigit><hexDigit>
* hexDigit = [0-9a-fA-F]
* }
* </pre>
*
* </blockquote>
*
* @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串
* @return 此{@code UUID} 的字符串表现形式
*/
public String toString(boolean isSimple)
{
final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
// time_low
builder.append(digits(mostSigBits >> 32, 8));
if (!isSimple)
{
builder.append('-');
}
// time_mid
builder.append(digits(mostSigBits >> 16, 4));
if (!isSimple)
{
builder.append('-');
}
// time_high_and_version
builder.append(digits(mostSigBits, 4));
if (!isSimple)
{
builder.append('-');
}
// variant_and_sequence
builder.append(digits(leastSigBits >> 48, 4));
if (!isSimple)
{
builder.append('-');
}
// node
builder.append(digits(leastSigBits, 12));
return builder.toString();
}
/**
* 返回此 UUID 的哈希码。
*
* @return UUID 的哈希码值。
*/
@Override
public int hashCode()
{
long hilo = mostSigBits ^ leastSigBits;
return ((int) (hilo >> 32)) ^ (int) hilo;
}
/**
* 将此对象与指定对象比较。
* <p>
* 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。
*
* @param obj 要与之比较的对象
*
* @return 如果对象相同,则返回 {@code true};否则返回 {@code false}
*/
@Override
public boolean equals(Object obj)
{
if ((null == obj) || (obj.getClass() != UUID.class))
{
return false;
}
UUID id = (UUID) obj;
return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits);
}
// Comparison Operations
/**
* 将此 UUID 与指定的 UUID 比较。
*
* <p>
* 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。
*
* @param val 与此 UUID 比较的 UUID
*
* @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。
*
*/
@Override
public int compareTo(UUID val)
{
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
return (this.mostSigBits < val.mostSigBits ? -1 : //
(this.mostSigBits > val.mostSigBits ? 1 : //
(this.leastSigBits < val.leastSigBits ? -1 : //
(this.leastSigBits > val.leastSigBits ? 1 : //
0))));
}
// -------------------------------------------------------------------------------------------------------------------
// Private method start
/**
* 返回指定数字对应的hex值
*
* @param val 值
* @param digits 位
* @return 值
*/
private static String digits(long val, int digits)
{
long hi = 1L << (digits * 4);
return Long.toHexString(hi | (val & (hi - 1))).substring(1);
}
/**
* 检查是否为time-based版本UUID
*/
private void checkTimeBase()
{
if (version() != 1)
{
throw new UnsupportedOperationException("Not a time-based UUID");
}
}
/**
* 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG)
*
* @return {@link SecureRandom}
*/
public static SecureRandom getSecureRandom()
{
try
{
return SecureRandom.getInstance("SHA1PRNG");
}
catch (NoSuchAlgorithmException e)
{
throw new UtilException(e);
}
}
/**
* 获取随机数生成器对象<br>
* ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。
*
* @return {@link ThreadLocalRandom}
*/
public static ThreadLocalRandom getRandom()
{
return ThreadLocalRandom.current();
}
}
......@@ -2,13 +2,13 @@ package com.dsk.biz.controller;
import com.dsk.biz.domain.bo.BusinessIdDto;
import com.dsk.biz.domain.vo.BusinessFileVo;
import com.dsk.biz.utils.OldFileUtils;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.utils.StringUtils;
import com.dsk.common.utils.file.FileUtils;
import com.dsk.common.utils.file.FileUploadUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -30,90 +30,87 @@ import java.util.stream.Collectors;
@RequestMapping("/business/file")
public class BusinessFileController extends BaseController {
// @Autowired
// private ServerConfig serverConfig;
//
// /**
// * 新建文件夹
// */
//// @PreAuthorize("@ss.hasPermi('system:file:add')")
//// @Log(title = "项目资料文档", businessType = BusinessType.INSERT)
// @PostMapping("/new")
// public AjaxResult newFolder(@RequestBody(required=false) BusinessIdDto filePath) {
// return FileUtils.newFolder(filePath.getFilePath()) ? AjaxResult.success() : AjaxResult.error();
// }
//
// /**
// * 删除某个文件或整个文件夹
// */
// @PostMapping("/remove")
// public AjaxResult removeFile(@RequestBody(required=false) BusinessIdDto filePath) {
// return FileUtils.delFolder(filePath.getFilePath()) ? AjaxResult.success() : AjaxResult.error();
// }
//
// /**
// * 分页查询项目的所有文件
// * 获取文件夹中所有文件
// */
// @GetMapping(value = "/list")
// public TableDataInfo getAllFiles(BusinessIdDto filePath) {
// startPage();
// List<BusinessFileVo> allFiles;
// if(StringUtils.isNumeric(filePath.getFilePath())) filePath.setFilePath(ShuZhiHuaConfig.getProfile() + filePath.getFilePath());
// allFiles = FileUtils.getAllFiles(filePath.getFilePath());
// //模糊查询文件
// if(StringUtils.isNotEmpty(filePath.getKeyword())){
// List<BusinessFileVo> allFileName = FileUtils.getAllFileNames(filePath.getFilePath());
// allFiles = allFileName.stream().filter(p -> p.getFilePath().contains(filePath.getKeyword())).collect(Collectors.toList());
// }
// //文件按照时间倒序
// allFiles = allFiles.stream().sorted(Comparator.comparing(BusinessFileVo::getCreatTime).reversed()).collect(Collectors.toList());
// return getDataTable(allFiles);
// }
//
// /**
// * 上传文件及文件夹
// * @param file 文件流
// * @param request 请求头参数
// * @return
// */
// @PostMapping("/upload")
// public AjaxResult uploadFolder(@RequestPart("file") MultipartFile file, HttpServletRequest request) {
// try {
// //获取文件名
// String filename = file.getOriginalFilename();
// String businessFileName = request.getHeader("FilePath");
// // 上传文件路径
// String filePath = ShuZhiHuaConfig.getUploadPath() + businessFileName + "/";
//
// //校验是否上传同名文件
// File newFile = new File(filePath);
// if (newFile.exists()) {
// // 获取当前目录下的文件和文件夹
// File[] files = newFile.listFiles();
// for (File allFile : files) {
// if (filename.equals(allFile.getName())) return error("文件已存在");
// }
// }
//
// // 上传并返回文件全路径
// String fileName = FileUploadUtils.upload(filePath, file);
//// String url = serverConfig.getUrl() + fileName;
// AjaxResult ajax = AjaxResult.success();
// ajax.put("url", fileName);
// return ajax;
// } catch (IOException e) {
// return AjaxResult.error(e.getMessage());
// }
// }
//
// /**
// * 下载文件
// * @param filePath 要下载的文件路径
// * @param response 返回的响应
// */
// @PostMapping("/download")
// public void downloadFolder(@RequestBody BusinessIdDto filePath, HttpServletResponse response) {
// FileUtils.downloadByFilePath(filePath.getFilePath(),response);
// }
/**
* 新建文件夹
*/
// @PreAuthorize("@ss.hasPermi('system:file:add')")
// @Log(title = "项目资料文档", businessType = BusinessType.INSERT)
@PostMapping("/new")
public AjaxResult newFolder(@RequestBody(required=false) BusinessIdDto filePath) {
return OldFileUtils.newFolder(filePath.getFilePath()) ? AjaxResult.success() : AjaxResult.error();
}
/**
* 删除某个文件或整个文件夹
*/
@PostMapping("/remove")
public AjaxResult removeFile(@RequestBody(required=false) BusinessIdDto filePath) {
return OldFileUtils.delFolder(filePath.getFilePath()) ? AjaxResult.success() : AjaxResult.error();
}
/**
* 分页查询项目的所有文件
* 获取文件夹中所有文件
*/
@GetMapping(value = "/list")
public TableDataInfo getAllFiles(BusinessIdDto filePath) {
List<BusinessFileVo> allFiles;
if(StringUtils.isNumeric(filePath.getFilePath())) filePath.setFilePath(FileUploadUtils.getDefaultBaseDir() + filePath.getFilePath());
allFiles = OldFileUtils.getAllFiles(filePath.getFilePath());
//模糊查询文件
if(StringUtils.isNotEmpty(filePath.getKeyword())){
List<BusinessFileVo> allFileName = OldFileUtils.getAllFileNames(filePath.getFilePath());
allFiles = allFileName.stream().filter(p -> p.getFilePath().contains(filePath.getKeyword())).collect(Collectors.toList());
}
//文件按照时间倒序
allFiles = allFiles.stream().sorted(Comparator.comparing(BusinessFileVo::getCreatTime).reversed()).collect(Collectors.toList());
return TableDataInfo.build(allFiles);
}
/**
* 上传文件及文件夹
* @param file 文件流
* @param request 请求头参数
* @return
*/
@PostMapping("/upload")
public AjaxResult uploadFolder(@RequestPart("file") MultipartFile file, HttpServletRequest request) {
try {
//获取文件名
String filename = file.getOriginalFilename();
String businessFileName = request.getHeader("FilePath");
// 上传文件路径
String filePath = FileUploadUtils.getDefaultBaseDir() + businessFileName + "/";
//校验是否上传同名文件
File newFile = new File(filePath);
if (newFile.exists()) {
// 获取当前目录下的文件和文件夹
File[] files = newFile.listFiles();
for (File allFile : files) {
if (filename.equals(allFile.getName())) return AjaxResult.error("文件已存在");
}
}
// 上传并返回文件全路径
String fileName = FileUploadUtils.upload(filePath, file);
// String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("url", fileName);
return ajax;
} catch (IOException e) {
return AjaxResult.error(e.getMessage());
}
}
/**
* 下载文件
* @param filePath 要下载的文件路径
* @param response 返回的响应
*/
@PostMapping("/download")
public void downloadFolder(@RequestBody BusinessIdDto filePath, HttpServletResponse response) {
OldFileUtils.downloadByFilePath(filePath.getFilePath(),response);
}
}
......@@ -44,7 +44,7 @@ public class CustomerController extends BaseController {
/**
* 查询客户列表
*/
@SaCheckPermission("'customer:list')")
// @SaCheckPermission("'customer:list')")
@GetMapping("/list")
public TableDataInfo<CustomerListVo> selectPageList(CustomerSearchDto dto , PageQuery pageQuery) {
return baseService.selectList(dto,pageQuery);
......@@ -53,7 +53,7 @@ public class CustomerController extends BaseController {
/**
* 客户详情
*/
@SaCheckPermission("'customer:info')")
// @SaCheckPermission("'customer:info')")
@GetMapping("/{customerId}")
public R<CustomerVo> info(@PathVariable("customerId") String customerId) {
return R.ok(baseService.info(customerId));
......@@ -62,7 +62,7 @@ public class CustomerController extends BaseController {
/**
* 添加客户
*/
@SaCheckPermission("'customer:add')")
// @SaCheckPermission("'customer:add')")
@PostMapping()
@RepeatSubmit
public R<Void> add(@RequestBody Customer customer) {
......@@ -89,7 +89,7 @@ public class CustomerController extends BaseController {
/**
* 编辑客户
*/
@SaCheckPermission("'customer:edit'")
// @SaCheckPermission("'customer:edit'")
@PutMapping()
@RepeatSubmit
public R<Void> edit(@RequestBody Customer customer) {
......
......@@ -3,6 +3,8 @@ package com.dsk.biz.domain;
import com.alibaba.excel.annotation.ExcelProperty;
import com.dsk.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -14,6 +16,8 @@ import java.util.Date;
* @author lxl
* @date 2023-05-17
*/
@Data
@NoArgsConstructor
public class BusinessInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
......@@ -170,374 +174,8 @@ public class BusinessInfo extends BaseEntity
/** 建设单位建设库id */
@ExcelProperty(value ="建设单位建设库id")
private Integer constructionUnitCid;
public String getConstructionUnitUipId() {
return constructionUnitUipId;
}
public void setConstructionUnitUipId(String constructionUnitUipId) {
this.constructionUnitUipId = constructionUnitUipId;
}
public Integer getConstructionUnitCid() {
return constructionUnitCid;
}
public void setConstructionUnitCid(Integer constructionUnitCid) {
this.constructionUnitCid = constructionUnitCid;
}
public String getConstructionUnit() {
return constructionUnit;
}
public void setConstructionUnit(String constructionUnit) {
this.constructionUnit = constructionUnit;
}
public String getConstructionPrincipal() {
return constructionPrincipal;
}
public void setConstructionPrincipal(String constructionPrincipal) {
this.constructionPrincipal = constructionPrincipal;
}
public String getConstructionPhone() {
return constructionPhone;
}
public void setConstructionPhone(String constructionPhone) {
this.constructionPhone = constructionPhone;
}
public String getSupervisorUnit() {
return supervisorUnit;
}
public void setSupervisorUnit(String supervisorUnit) {
this.supervisorUnit = supervisorUnit;
}
public String getSupervisorPrincipal() {
return supervisorPrincipal;
}
public void setSupervisorPrincipal(String supervisorPrincipal) {
this.supervisorPrincipal = supervisorPrincipal;
}
public String getSupervisorPhone() {
return supervisorPhone;
}
public void setSupervisorPhone(String supervisorPhone) {
this.supervisorPhone = supervisorPhone;
}
public String getEvaluationBidWay() {
return evaluationBidWay;
}
public void setEvaluationBidWay(String evaluationBidWay) {
this.evaluationBidWay = evaluationBidWay;
}
public String getBidOpenTime() {
return bidOpenTime;
}
public void setBidOpenTime(String bidOpenTime) {
this.bidOpenTime = bidOpenTime;
}
public String getBidOpenPlace() {
return bidOpenPlace;
}
public void setBidOpenPlace(String bidOpenPlace) {
this.bidOpenPlace = bidOpenPlace;
}
public String getEarnestMoneyPay() {
return earnestMoneyPay;
}
public void setEarnestMoneyPay(String earnestMoneyPay) {
this.earnestMoneyPay = earnestMoneyPay;
}
public String getEarnestMoney() {
return earnestMoney;
}
public void setEarnestMoney(String earnestMoney) {
this.earnestMoney = earnestMoney;
}
public String getEvaluationBidCouncil() {
return evaluationBidCouncil;
}
public void setEvaluationBidCouncil(String evaluationBidCouncil) {
this.evaluationBidCouncil = evaluationBidCouncil;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public void setId(Integer id)
{
this.id = id;
}
public Integer getId()
{
return id;
}
public void setProjectName(String projectName)
{
this.projectName = projectName;
}
public String getProjectName()
{
return projectName;
}
public void setInvestmentAmount(Double investmentAmount)
{
this.investmentAmount = investmentAmount;
}
public Double getInvestmentAmount()
{
return investmentAmount;
}
public void setAmountSource(String amountSource)
{
this.amountSource = amountSource;
}
public String getAmountSource()
{
return amountSource;
}
public void setPlanBidTime(Date planBidTime)
{
this.planBidTime = planBidTime;
}
public Date getPlanBidTime()
{
return planBidTime;
}
public void setPlanStartTime(Date planStartTime)
{
this.planStartTime = planStartTime;
}
public Date getPlanStartTime()
{
return planStartTime;
}
public void setProjectLevel(String projectLevel)
{
this.projectLevel = projectLevel;
}
public String getProjectLevel()
{
return projectLevel;
}
public void setProjectStage(String projectStage)
{
this.projectStage = projectStage;
}
public String getProjectStage()
{
return projectStage;
}
public void setBuildProperty(String buildProperty)
{
this.buildProperty = buildProperty;
}
public String getBuildProperty()
{
return buildProperty;
}
public void setPlanCompleteTime(Date planCompleteTime)
{
this.planCompleteTime = planCompleteTime;
}
public Date getPlanCompleteTime()
{
return planCompleteTime;
}
public void setProjectDetails(String projectDetails)
{
this.projectDetails = projectDetails;
}
public String getProjectDetails()
{
return projectDetails;
}
public void setProvinceName(String provinceName)
{
this.provinceName = provinceName;
}
public String getProvinceName()
{
return provinceName;
}
public void setProvinceId(Integer provinceId)
{
this.provinceId = provinceId;
}
public Integer getProvinceId()
{
return provinceId;
}
public void setCityName(String cityName)
{
this.cityName = cityName;
}
public String getCityName()
{
return cityName;
}
public void setCityId(Integer cityId)
{
this.cityId = cityId;
}
public Integer getCityId()
{
return cityId;
}
public void setDistrictName(String districtName)
{
this.districtName = districtName;
}
public String getDistrictName()
{
return districtName;
}
public void setDistrictId(Integer districtId)
{
this.districtId = districtId;
}
public Integer getDistrictId()
{
return districtId;
}
public void setProjectType(String projectType)
{
this.projectType = projectType;
}
public String getProjectType()
{
return projectType;
}
public void setProjectCategory(String projectCategory)
{
this.projectCategory = projectCategory;
}
public String getProjectCategory()
{
return projectCategory;
}
public void setTeam(String team)
{
this.team = team;
}
public String getTeam()
{
return team;
}
public void setIsPrivate(Integer isPrivate)
{
this.isPrivate = isPrivate;
}
public Integer getIsPrivate()
{
return isPrivate;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("projectName", getProjectName())
.append("investmentAmount", getInvestmentAmount())
.append("amountSource", getAmountSource())
.append("planBidTime", getPlanBidTime())
.append("planStartTime", getPlanStartTime())
.append("projectLevel", getProjectLevel())
.append("projectStage", getProjectStage())
.append("buildProperty", getBuildProperty())
.append("planCompleteTime", getPlanCompleteTime())
.append("projectDetails", getProjectDetails())
.append("provinceName", getProvinceName())
.append("provinceId", getProvinceId())
.append("cityName", getCityName())
.append("cityId", getCityId())
.append("districtName", getDistrictName())
.append("districtId", getDistrictId())
.append("projectType", getProjectType())
.append("projectCategory", getProjectCategory())
.append("team", getTeam())
.append("isPrivate", getIsPrivate())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("customerId", getCustomerId())
.append("evaluationBidWay", getEvaluationBidWay())
.append("bidOpenTime", getBidOpenTime())
.append("bidOpenPlace", getBidOpenPlace())
.append("earnestMoneyPay", getEarnestMoneyPay())
.append("earnestMoney", getEarnestMoney())
.append("evaluationBidCouncil", getEvaluationBidCouncil())
.append("constructionUnit", getConstructionUnit())
.append("constructionPrincipal", getConstructionPrincipal())
.append("constructionPhone", getConstructionPhone())
.append("supervisorUnit", getSupervisorUnit())
.append("supervisorPrincipal", getSupervisorPrincipal())
.append("supervisorPhone", getSupervisorPhone())
.append("constructionUnitUipId", getConstructionUnitUipId())
.append("constructionUnitCid", getConstructionUnitCid())
.toString();
}
/**
* 租户编号
*/
private String tenantId;
}
......@@ -123,6 +123,10 @@ public class Customer implements Serializable {
* 其它管理体系特点
*/
private String otherMsCharacteistic;
/**
* 租户编号
*/
private String tenantId;
private Long createId;
......
......@@ -53,10 +53,10 @@ public interface BusinessInfoMapper extends BaseMapper<BusinessInfo> {
* @return 项目详情集合
*/
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
public Page<BusinessListVo> selectBusinessInfoList(@Param("page") Page<BusinessListVo> page,@Param("dto") BusinessListDto dto);
Page<BusinessListVo> selectBusinessInfoList(@Param("page") IPage<BusinessListDto> page, @Param("dto") BusinessListDto dto);
/**
* 新增项目详情
......@@ -114,12 +114,28 @@ public interface BusinessInfoMapper extends BaseMapper<BusinessInfo> {
Page<CustomerBusinessListVo> selectCustomerBusinessList(IPage<CustomerBusinessSearchDto> page,@Param("dto") CustomerBusinessSearchDto dto);
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
int selectCountByStatus(BusinessSearchDto dto);
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
List<BusinessAnalyzeVo> selectAmountAnalyze(BusinessSearchDto dto);
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
List<BusinessAnalyzeVo> selectTypeAnalyze(BusinessSearchDto dto);
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
List<BusinessAnalyzeVo> selectCategoryAnalyze(BusinessSearchDto dto);
}
......@@ -11,6 +11,8 @@ import com.dsk.biz.domain.bo.BusinessExcelDto;
import com.dsk.biz.domain.bo.BusinessListDto;
import com.dsk.biz.domain.bo.CustomerBusinessSearchDto;
import com.dsk.biz.domain.vo.*;
import com.dsk.common.annotation.DataColumn;
import com.dsk.common.annotation.DataPermission;
import com.dsk.jsk.service.EnterpriseService;
import com.dsk.biz.mapper.BusinessInfoMapper;
import com.dsk.biz.mapper.BusinessLabelMapper;
......@@ -92,15 +94,14 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
@Override
public TableDataInfo<BusinessListVo> selectBusinessInfoList(BusinessListDto dto, PageQuery pageQuery) {
dto.setUserId(LoginHelper.getUserId());
Page<BusinessListVo> page = businessInfoMapper.selectBusinessInfoList(pageQuery.build(), dto);
List<BusinessListVo> businessListVos = page.getRecords();
if (!CollectionUtils.isEmpty(businessListVos) && ObjectUtil.isNotEmpty(dto.getProjectName())) {
for (BusinessListVo vo : businessListVos) {
TableDataInfo<BusinessListVo> result = TableDataInfo.build(businessInfoMapper.selectBusinessInfoList(pageQuery.build(), dto));
if (!CollectionUtils.isEmpty(result.getRows()) && ObjectUtil.isNotEmpty(dto.getProjectName())) {
for (BusinessListVo vo : result.getRows()) {
vo.setProjectName(StringUtils.markInRed(vo.getProjectName(), dto.getProjectName()));
vo.setOwnerCompany(StringUtils.markInRed(vo.getOwnerCompany(), dto.getProjectName()));
}
}
return TableDataInfo.build(page);
return result;
}
......@@ -255,7 +256,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
businessInfo.setConstructionUnitUipId(vo.getUipId());
businessInfo.setConstructionUnitCid(vo.getCompanyId());
businessInfo.setConstructionPrincipal(vo.getLegalPerson());
businessInfo.setTenantId(LoginHelper.getTenantId());
int addBusiness = businessInfoMapper.insertBusinessInfo(businessInfo);
if (addBusiness > 0) {
//获取登陆用户的部门id
......
......@@ -31,10 +31,6 @@ public class BusinessOverviewServiceImpl implements IBusinessOverviewService {
private DskOpenApiUtil dskOpenApiUtil;
@Override
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
public Map<String, Object> statusStatistics(BusinessSearchDto dto) {
Map<String, Object> resultMap = new HashMap<>();
//总
......@@ -52,28 +48,16 @@ public class BusinessOverviewServiceImpl implements IBusinessOverviewService {
}
@Override
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
public List<BusinessAnalyzeVo> amountAnalyze(BusinessSearchDto dto) {
return businessInfoMapper.selectAmountAnalyze(dto);
}
@Override
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
public List<BusinessAnalyzeVo> typeAnalyze(BusinessSearchDto dto) {
return businessInfoMapper.selectTypeAnalyze(dto);
}
@Override
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
public List<BusinessAnalyzeVo> categoryAnalyze(BusinessSearchDto dto) {
return businessInfoMapper.selectCategoryAnalyze(dto);
}
......
......@@ -61,7 +61,7 @@ public class CustomerServiceImpl implements ICustomerService {
dto.setUserId(LoginHelper.getUserId());
dto.setStatus(ObjectUtils.isEmpty(dto.getStatus()) ? 0 : dto.getStatus());
final TableDataInfo<CustomerListVo> result = TableDataInfo.build(baseMapper.selectList(pageQuery.build(), dto));
if(!ObjectUtils.isEmpty(result.getRows())){
if(!ObjectUtils.isEmpty(result.getRows()) && !ObjectUtils.isEmpty(dto.getCompanyName())){
for (CustomerListVo vo : result.getRows()) {
vo.setCompanyName(StringUtils.markInRed(vo.getCompanyName(), dto.getCompanyName()));
}
......@@ -87,6 +87,7 @@ public class CustomerServiceImpl implements ICustomerService {
Long userId = LoginHelper.getUserId();
customer.setCreateId(userId);
customer.setUpdateId(userId);
customer.setTenantId(LoginHelper.getTenantId());
//查重
Customer verifyCustomer = baseMapper.selectByCompanyNameAndUserId(customer.getCompanyName(), userId);
if (!ObjectUtils.isEmpty(verifyCustomer)) {
......
package com.dsk.biz.utils;
import com.dsk.biz.domain.vo.BusinessFileVo;
import com.dsk.common.exception.base.BaseException;
import com.dsk.common.utils.DateUtils;
import com.dsk.common.utils.ServletUtils;
import com.dsk.common.utils.StringUtils;
import com.dsk.common.utils.file.FileTypeUtils;
import com.dsk.common.utils.file.FileUploadUtils;
import com.dsk.common.utils.file.MimeTypeUtils;
import com.dsk.common.utils.uuid.IdUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
* 文件处理工具类
*
* @author dsk
*/
@Slf4j
public class OldFileUtils
{
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
/**
* 检查目录是否存在,如果不存在,则创建目录,如果创建失败则返回false
*
* @param path 文件夹路径
* @return boolean
*/
public static boolean newFolder(String path) {
File file = new File(path);
if (!file.exists()) {
boolean isSuccess = file.mkdir();
if (!isSuccess)
if (!file.exists()) {
file.mkdirs();
}
return isSuccess;
} else {
return true;
}
}
/**
*
*
* @param folderPath 文件夹路径
* @return 文件夹路径
*/
public static String newFolder1(String folderPath) {
String filePath = folderPath;
try {
File myFilePath = new File(filePath);
if (!myFilePath.exists()) {
myFilePath.mkdirs();
}
} catch (Exception e) {
log.error("创建文件夹失败");
filePath = "";
e.printStackTrace();
}
return filePath;
}
/**
* 输出指定文件的byte数组
*
* @param filePath 文件路径
* @param os 输出流
* @return
*/
public static void writeBytes(String filePath, OutputStream os) throws IOException
{
FileInputStream fis = null;
try
{
File file = new File(filePath);
if (!file.exists())
{
throw new FileNotFoundException(filePath);
}
fis = new FileInputStream(file);
byte[] b = new byte[1024];
int length;
while ((length = fis.read(b)) > 0)
{
os.write(b, 0, length);
}
}
catch (IOException e)
{
throw e;
}
finally
{
IOUtils.close(os);
IOUtils.close(fis);
}
}
/**
* 写数据到文件中
*
* @param data 数据
* @return 目标文件
* @throws IOException IO异常
*/
public static String writeImportBytes(byte[] data) throws IOException
{
return writeBytes(data, FileUploadUtils.getDefaultBaseDir().concat("/import"));
}
/**
* 写数据到文件中
*
* @param data 数据
* @param uploadDir 目标文件
* @return 目标文件
* @throws IOException IO异常
*/
public static String writeBytes(byte[] data, String uploadDir) throws IOException
{
FileOutputStream fos = null;
String pathName = "";
try
{
String extension = getFileExtendName(data);
pathName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
File file = FileUploadUtils.getAbsoluteFile(uploadDir, pathName);
fos = new FileOutputStream(file);
fos.write(data);
}
finally
{
IOUtils.close(fos);
}
return FileUploadUtils.getPathFileName(uploadDir, pathName);
}
/**
* 删除文件
*
* @param filePath 文件
* @return
*/
public static boolean deleteFile(String filePath)
{
boolean flag = false;
File file = new File(filePath);
// 路径为文件且不为空则进行删除
if (file.isFile() && file.exists())
{
flag = file.delete();
}
return flag;
}
/**
* 删除整个文件夹或者文某个文件
*
* @param filePath 文件
* @return
*/
public static boolean delFolder(String filePath) {
try {
delAllFile(filePath); // 删除里面的所有文件
File file = new File(filePath);
return file.delete(); // 删除空文件夹
} catch (Exception e) {
throw new BaseException("删除文件夹失败",e.getMessage());
}
}
/**
* 文件夹过滤
*
* @param path 文件夹路径
*/
public static void delAllFile(String path) {
String hint = "这是一个根目录,请更换目录!";
File file = new File(path);
if (!file.exists()) {
throw new BaseException("文件不存在");
}
// if (!file.isDirectory()) {
// return false;
// }
if (file.getAbsolutePath().equalsIgnoreCase("/")) {
throw new BaseException(hint);
}
if (file.getAbsolutePath().equalsIgnoreCase("/root")) {
throw new BaseException(hint);
}
if (file.getAbsolutePath().equalsIgnoreCase("/usr") || file.getAbsolutePath().equalsIgnoreCase("/opt")
|| file.getAbsolutePath().equalsIgnoreCase("/bin") || file.getAbsolutePath().equalsIgnoreCase("/sbin")
|| file.getAbsolutePath().equalsIgnoreCase("/etc") || file.getAbsolutePath().equalsIgnoreCase("/selinux")
|| file.getAbsolutePath().equalsIgnoreCase("/sys") || file.getAbsolutePath().equalsIgnoreCase("/var")
|| file.getAbsolutePath().equalsIgnoreCase("/home") || file.getAbsolutePath().equalsIgnoreCase("/net")) {
throw new BaseException(hint);
}
if (file.getAbsolutePath().equalsIgnoreCase("C://") || file.getAbsolutePath().equalsIgnoreCase("C:\\\\")) {
throw new BaseException(hint);
}
String[] tempList = file.list();
File temp;
if (tempList == null) {
return;
}
for (String aTempList : tempList) {
if (path.endsWith(File.separator)) {
temp = new File(path + aTempList);
} else {
temp = new File(path + File.separator + aTempList);
}
if (temp.isFile()) {
temp.delete();
}
if (temp.isDirectory()) {
delAllFile(path + "/" + aTempList);// 删除里面的所有文件
delFolder(path + "/" + aTempList);// 删除空文件夹
}
}
}
/**
* 获取文件夹中所有文件
* @param filePath 全路径
* @return
*/
public static List<BusinessFileVo> getAllFiles(String filePath) {
List<BusinessFileVo> fileList = new ArrayList<>();
File file = new File(filePath);
if (!file.exists()) {
return fileList;
}
if (!file.isDirectory()) {
return fileList;
}
// 获取当前目录下的文件和文件夹
File[] files = file.listFiles();
if (files != null) {
for (File directory : files) {
// 如果是文件夹则递归调用此方法
if (directory.isDirectory()) {
fileList.add(new BusinessFileVo(directory.getPath(),new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(directory.lastModified())));
getAllFiles(directory.getPath());
} else {
// 如果是文件则直接输出路径
fileList.add(new BusinessFileVo(directory.getPath(),new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(directory.lastModified())));
}
}
return fileList;
}
return fileList;
}
/**
* 获取文件夹中的所有文件,不包括文件夹
*
* @param path 文件夹路径
* @return List<File>
*/
public static List<BusinessFileVo> getAllFileNames(String path) {
List<BusinessFileVo> fileList = new ArrayList<>();
File file = new File(path);
if (!file.exists()) {
return fileList;
}
if (!file.isDirectory()) {
return fileList;
}
String[] tempList = file.list();
File tempFile;
for (String fileName : tempList) {
if (path.endsWith(File.separator)) {
tempFile = new File(path + fileName);
} else {
tempFile = new File(path + File.separator + fileName);
}
if (tempFile.isFile()) {
fileList.add(new BusinessFileVo(tempFile.getPath(),new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(tempFile.lastModified())));
}
if (tempFile.isDirectory()) {
List<BusinessFileVo> allFiles = getAllFileNames(tempFile.getAbsolutePath());
fileList.addAll(allFiles);
}
}
return fileList;
}
/**
* 根据文件路径下载文件
* @param filePath 要下载的文件路径
* @param response 返回的响应
*/
public static void downloadByFilePath(String filePath, HttpServletResponse response) {
try {
// path是指想要下载的文件的路径
File file = new File(filePath);
// log.info(file.getPath());
if (!file.exists()) throw new BaseException("文件不存在!");
// 获取文件名
String filename = file.getName();
// log.info("文件名: "+filename);
// 获取文件后缀名
// String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
// log.info("文件后缀名:" + ext);
// 将文件写入输入流
FileInputStream fileInputStream = new FileInputStream(file);
InputStream fis = new BufferedInputStream(fileInputStream);
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
// 清空response
response.reset();
// 设置response的Header
response.setCharacterEncoding("UTF-8");
//文件类型
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
//文件名称
response.addHeader("Download-filename", URLEncoder.encode(filename, "UTF-8"));
// 告知浏览器文件的大小
response.addHeader("Content-Length", "" + file.length());
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
outputStream.write(buffer);
fis.close();
outputStream.flush();
} catch (IOException ex) {
ex.printStackTrace();
}
}
/**
* 根据文件url下载文件
* @param filePath 要下载的文件链接
* @param response 响应体
* @return
* @throws IOException
*/
public static void downloadByUrl(String filePath, HttpServletResponse response){
// String fileUrl = request.getParameter("fileUrl"); // 获取文件链接
try {
URL url = new URL(filePath);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
// 设置响应头,告诉浏览器下载文件
String contentType = connection.getContentType(); // 获取文件类型
response.setContentType(contentType);
String filename = extractFilenameFromUrl(filePath); // 从链接中提取文件名
response.setHeader("Content-Disposition", "attachment; filename=" + filename + "");
// 将文件流写入响应输出流
InputStream inputStream = connection.getInputStream();
byte[] buffer = new byte[4096];
int bytesRead = -1;
while ((bytesRead = inputStream.read(buffer)) != -1) {
response.getOutputStream().write(buffer, 0, bytesRead);
}
inputStream.close();
connection.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
// 从文件链接中提取文件名
public static String extractFilenameFromUrl(String url) {
int slashIndex = url.lastIndexOf('/');
int dotIndex = url.lastIndexOf('.');
if (dotIndex == -1 || dotIndex < slashIndex) {
return "download";
}
return url.substring(slashIndex + 1);
}
/**
* 上传文件
* @param url 上传链接
* @param folderPath 文件路径
* @return
* @throws IOException
*/
public static boolean uploadFolder(String url, String folderPath) throws IOException {
File folder = new File(folderPath);
if (!folder.exists() || !folder.isDirectory()) {
throw new IllegalArgumentException("文件夹路径无效: " + folderPath);
}
List<File> files = new ArrayList<>();
listFiles(folder, files);
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(url);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
for (File file : files) {
FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY);
builder.addPart("file", fileBody);
}
HttpEntity multipart = builder.build();
httpPost.setEntity(multipart);
HttpResponse response = httpClient.execute(httpPost);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != 200) {
throw new RuntimeException("上传文件夹失败: " + response.getStatusLine().getReasonPhrase());
}
}
return true;
}
private static void listFiles(File folder, List<File> files) {
File[] subFiles = folder.listFiles();
for (File subFile : subFiles) {
if (subFile.isDirectory()) {
listFiles(subFile, files);
} else {
files.add(subFile);
}
}
}
/**
* 文件名称验证
*
* @param filename 文件名称
* @return true 正常 false 非法
*/
public static boolean isValidFilename(String filename)
{
return filename.matches(FILENAME_PATTERN);
}
/**
* 检查文件是否可下载
*
* @param resource 需要下载的文件
* @return true 正常 false 非法
*/
public static boolean checkAllowDownload(String resource)
{
// 禁止目录上跳级别
if (StringUtils.contains(resource, ".."))
{
return false;
}
// 检查允许下载的文件规则
if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)))
{
return true;
}
// 不在允许下载的文件规则
return false;
}
/**
* 下载文件名重新编码
*
* @param request 请求对象
* @param fileName 文件名
* @return 编码后的文件名
*/
public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException
{
final String agent = request.getHeader("USER-AGENT");
String filename = fileName;
if (agent.contains("MSIE"))
{
// IE浏览器
filename = URLEncoder.encode(filename, "utf-8");
filename = filename.replace("+", " ");
}
else if (agent.contains("Firefox"))
{
// 火狐浏览器
filename = new String(fileName.getBytes(), "ISO8859-1");
}
else if (agent.contains("Chrome"))
{
// google浏览器
filename = URLEncoder.encode(filename, "utf-8");
}
else
{
// 其它浏览器
filename = URLEncoder.encode(filename, "utf-8");
}
return filename;
}
/**
* 下载文件名重新编码
*
* @param response 响应对象
* @param realFileName 真实文件名
*/
public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException
{
String percentEncodedFileName = percentEncode(realFileName);
StringBuilder contentDispositionValue = new StringBuilder();
contentDispositionValue.append("attachment; filename=")
.append(percentEncodedFileName)
.append(";")
.append("filename*=")
.append("utf-8''")
.append(percentEncodedFileName);
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename");
response.setHeader("Content-disposition", contentDispositionValue.toString());
response.setHeader("download-filename", percentEncodedFileName);
}
/**
* 百分号编码工具方法
*
* @param s 需要百分号编码的字符串
* @return 百分号编码后的字符串
*/
public static String percentEncode(String s) throws UnsupportedEncodingException
{
String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
return encode.replaceAll("\\+", "%20");
}
/**
* 获取图像后缀
*
* @param photoByte 图像数据
* @return 后缀名
*/
public static String getFileExtendName(byte[] photoByte)
{
String strFileExtendName = "jpg";
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
{
strFileExtendName = "gif";
}
else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
{
strFileExtendName = "jpg";
}
else if ((photoByte[0] == 66) && (photoByte[1] == 77))
{
strFileExtendName = "bmp";
}
else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
{
strFileExtendName = "png";
}
return strFileExtendName;
}
/**
* 获取文件名称 /profile/upload/2022/04/16/dsk.png -- dsk.png
*
* @param fileName 路径名称
* @return 没有文件路径的名称
*/
public static String getName(String fileName)
{
if (fileName == null)
{
return null;
}
int lastUnixPos = fileName.lastIndexOf('/');
int lastWindowsPos = fileName.lastIndexOf('\\');
int index = Math.max(lastUnixPos, lastWindowsPos);
return fileName.substring(index + 1);
}
/**
* 获取不带后缀文件名称 /profile/upload/2022/04/16/dsk.png -- dsk
*
* @param fileName 路径名称
* @return 没有文件路径和后缀的名称
*/
public static String getNameNotSuffix(String fileName)
{
if (fileName == null)
{
return null;
}
String baseName = FilenameUtils.getBaseName(fileName);
return baseName;
}
/**
* 获取本地服务的域名,端口
* @return
*/
public static String getUrl()
{
HttpServletRequest request = ServletUtils.getRequest();
StringBuffer url = request.getRequestURL();
String contextPath = request.getServletContext().getContextPath();
return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString();
}
}
......@@ -96,13 +96,13 @@
i.construction_unit ownerCompany,
i.construction_unit_uip_id ownerCompanyUipId,
i.construction_unit_cid ownerCompanyCid,
<!-- MAX(f.creat_time) followTime,-->
u.nick_name nickName
<!-- GROUP_CONCAT(DISTINCT l.label) label-->
MAX(f.creat_time) followTime,
u.nick_name nickName,
GROUP_CONCAT(DISTINCT l.label) label
FROM business_info i
LEFT JOIN business_user bu on bu.business_id = i.id
<!-- LEFT JOIN business_follow_record f on f.business_id = i.id-->
<!-- LEFT JOIN business_label l on l.business_id = i.id-->
LEFT JOIN business_follow_record f on f.business_id = i.id
LEFT JOIN business_label l on l.business_id = i.id
LEFT JOIN sys_user u on u.user_id = bu.user_id
LEFT JOIN sys_dept d on d.dept_id = u.dept_id
<where>
......@@ -146,7 +146,7 @@
<choose>
<when test="dto.isPrivate == 1"> and bu.user_id = #{dto.userId} </when>
<!-- 数据范围过滤 -->
<otherwise> and (bu.user_id = #{dto.userId} or i.is_private = 1) ${params.dataScope} </otherwise>
<otherwise> and (bu.user_id = #{dto.userId} or i.is_private = 1) ${dto.params.dataScope} </otherwise>
</choose>
</where>
GROUP BY i.id
......@@ -223,6 +223,7 @@
<if test="supervisorPhone != null">supervisor_phone,</if>
<if test="constructionUnitUipId != null">construction_unit_uip_id,</if>
<if test="constructionUnitCid != null">construction_unit_cid,</if>
tenant_id
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="projectName != null">#{projectName},</if>
......@@ -262,6 +263,7 @@
<if test="supervisorPhone != null">#{supervisorPhone},</if>
<if test="constructionUnitUipId != null">#{constructionUnitUipId},</if>
<if test="constructionUnitCid != null">#{constructionUnitCid},</if>
#{tenantId}
</trim>
</insert>
......
......@@ -21,8 +21,7 @@
<if test="dto.startTime != null and dto.startTime != '' "> and cfr.visit_time &gt;= #{dto.startTime} </if>
<if test="dto.endTime != null and dto.endTime != '' "> and cfr.visit_time &lt;= #{dto.endTime} </if>
<!-- 数据范围过滤 -->
<if test="ew.getCustomSqlSegment != null and ew.getCustomSqlSegment != '' "> ${ew.getCustomSqlSegment}</if>
<if test="dto.params.dataScope != null and params.dataScope != '' "> ${dto.params.dataScope}</if>
<if test="dto.params.dataScope != null and dto.params.dataScope != '' "> ${dto.params.dataScope}</if>
</where>
order by cfr.visit_time desc
</select>
......
package com.dsk.system.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dsk.common.annotation.ExcelDictFormat;
import com.dsk.common.convert.ExcelDictConvert;
import com.dsk.common.tenant.core.TenantEntity;
import com.dsk.system.domain.SysDept;
import com.dsk.system.domain.SysTenantPackage;
import com.sun.org.apache.xpath.internal.operations.Bool;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
* 部门表 sys_dept
*
* @author Lion Li
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = SysDept.class)
public class SysDeptVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 部门ID
*/
@ExcelProperty(value = "部门id")
private Long deptId;
/**
* 父部门ID
*/
@ExcelProperty(value = "父部门id")
private Long parentId;
/**
* 部门名称
*/
@ExcelProperty(value = "部门名称")
private String deptName;
/**
* 显示顺序
*/
@ExcelProperty(value = "显示顺序")
private Integer orderNum;
/**
* 负责人
*/
@ExcelProperty(value = "负责人")
private String leader;
/**
* 联系电话
*/
@ExcelProperty(value = "联系电话")
private String phone;
/**
* 邮箱
*/
@ExcelProperty(value = "邮箱")
private String email;
/**
* 部门状态:0正常,1停用
*/
@ExcelProperty(value = "部门状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "0=正常,1=停用")
private String status;
/**
* 删除标志(0代表存在 2代表删除)
*/
@ExcelProperty(value = "删除标志", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "0=存在,2=删除")
private String delFlag;
/**
* 祖级列表
*/
@ExcelProperty(value = "祖级列表")
private String ancestors;
private String parentName;
/**
* 该部门是否存在用户(true代表存在 false代表不存在)
*/
@ExcelProperty(value = "该部门是否存在用户", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "true=存在,false=删除")
private Boolean existUsers;
}
......@@ -17,6 +17,7 @@ import com.dsk.common.core.domain.entity.SysDictType;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.exception.ServiceException;
import com.dsk.common.utils.DingTalkUtil;
import com.dsk.common.utils.PasswordUtils;
import com.dsk.common.utils.StringUtils;
import com.dsk.system.domain.*;
import com.dsk.system.domain.bo.SysTenantBo;
......@@ -33,7 +34,6 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
/**
* @author sxk
......@@ -186,7 +186,7 @@ public class ISysTenantServiceImpl implements ISysTenantService {
user.setUserName(bo.getContactPhone());
user.setNickName(bo.getContactUserName());
//生成8位随机密码
String password = generatePassword(8);
String password = PasswordUtils.generatePwd(8);
user.setPassword(BCrypt.hashpw(password));
user.setDeptId(deptId);
userMapper.insert(user);
......@@ -238,20 +238,6 @@ public class ISysTenantServiceImpl implements ISysTenantService {
return true;
}
// 生成随机密码
public static String generatePassword(int length) {
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
StringBuilder password = new StringBuilder();
Random random = new Random();
for (int i = 0; i < length; i++) {
int index = random.nextInt(characters.length());
password.append(characters.charAt(index));
}
return password.toString();
}
/**
* 生成租户id
*
......
......@@ -31,6 +31,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* 部门管理 服务实现
......@@ -55,12 +56,12 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
public List<SysDept> selectDeptList(SysDept dept) {
LambdaQueryWrapper<SysDept> lqw = new LambdaQueryWrapper<>();
lqw.eq(SysDept::getDelFlag, "0")
.eq(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId())
.eq(ObjectUtil.isNotNull(dept.getParentId()), SysDept::getParentId, dept.getParentId())
.like(StringUtils.isNotBlank(dept.getDeptName()), SysDept::getDeptName, dept.getDeptName())
.eq(StringUtils.isNotBlank(dept.getStatus()), SysDept::getStatus, dept.getStatus())
.orderByAsc(SysDept::getParentId)
.orderByAsc(SysDept::getOrderNum);
.eq(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId())
.eq(ObjectUtil.isNotNull(dept.getParentId()), SysDept::getParentId, dept.getParentId())
.like(StringUtils.isNotBlank(dept.getDeptName()), SysDept::getDeptName, dept.getDeptName())
.eq(StringUtils.isNotBlank(dept.getStatus()), SysDept::getStatus, dept.getStatus())
.orderByAsc(SysDept::getParentId)
.orderByAsc(SysDept::getOrderNum);
return baseMapper.selectDeptList(lqw);
}
......@@ -88,10 +89,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
return CollUtil.newArrayList();
}
return TreeBuildUtils.build(depts, (dept, tree) ->
tree.setId(dept.getDeptId())
.setParentId(dept.getParentId())
.setName(dept.getDeptName())
.setWeight(dept.getOrderNum()));
tree.setId(dept.getDeptId())
.setParentId(dept.getParentId())
.setName(dept.getDeptName())
.setWeight(dept.getOrderNum()));
}
/**
......@@ -120,7 +121,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
return null;
}
SysDept parentDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
.select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null);
return dept;
}
......@@ -152,8 +153,8 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
@Override
public long selectNormalChildrenDeptById(Long deptId) {
return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
.eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
}
/**
......@@ -165,7 +166,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
@Override
public boolean hasChildByDeptId(Long deptId) {
return baseMapper.exists(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getParentId, deptId));
.eq(SysDept::getParentId, deptId));
}
/**
......@@ -177,7 +178,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
@Override
public boolean checkDeptExistUser(Long deptId) {
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getDeptId, deptId));
.eq(SysUser::getDeptId, deptId));
}
/**
......@@ -189,9 +190,9 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
@Override
public boolean checkDeptNameUnique(SysDept dept) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getDeptName, dept.getDeptName())
.eq(SysDept::getParentId, dept.getParentId())
.ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
.eq(SysDept::getDeptName, dept.getDeptName())
.eq(SysDept::getParentId, dept.getParentId())
.ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
return !exist;
}
......@@ -248,7 +249,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
}
int result = baseMapper.updateById(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals(UserConstants.DEPT_NORMAL, dept.getAncestors())) {
&& !StringUtils.equals(UserConstants.DEPT_NORMAL, dept.getAncestors())) {
// 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept);
}
......@@ -264,8 +265,8 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
String ancestors = dept.getAncestors();
Long[] deptIds = Convert.toLongArray(ancestors);
baseMapper.update(null, new LambdaUpdateWrapper<SysDept>()
.set(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.in(SysDept::getDeptId, Arrays.asList(deptIds)));
.set(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.in(SysDept::getDeptId, Arrays.asList(deptIds)));
}
/**
......@@ -277,7 +278,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
*/
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>()
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
List<SysDept> list = new ArrayList<>();
for (SysDept child : children) {
SysDept dept = new SysDept();
......@@ -301,7 +302,38 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
@Override
public int deleteDeptById(Long deptId) {
//如果有子部门,递归删除部门和用户
if (hasChildByDeptId(deptId)) {
List<SysDept> childDepts = baseMapper.selectDeptList(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getParentId, deptId));
childDepts.forEach(childDept -> {
//如果该子部门有用户,则删除所有用户
checkDelUsers(childDept.getDeptId());
//递归调用
deleteDeptById(childDept.getDeptId());
});
}
//如果该部门有用户,则删除所有用户
checkDelUsers(deptId);
//删除该部门
return baseMapper.deleteById(deptId);
}
/**
* 判断该部门是否有用户,有则删除所有用户
*
* @param deptId 部门ID
*/
private int checkDelUsers(Long deptId) {
//如果该部门有用户
if (checkDeptExistUser(deptId)) {
List<SysUser> childUsers = userMapper.selectList(new LambdaQueryWrapper<SysUser>()
.eq(true, SysUser::getDeptId, deptId));
List<Long> childUsersIds = childUsers.stream().map(SysUser::getUserId).collect(Collectors.toList());
//删除该子部门下所有用户
return userMapper.deleteBatchIds(childUsersIds);
}
return -1;
}
}
package com.dsk.system.service.impl;
import cn.dev33.satoken.secure.BCrypt;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
......@@ -9,6 +10,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsk.common.utils.DingTalkUtil;
import com.dsk.common.utils.PasswordUtils;
import com.dsk.system.mapper.*;
import com.dsk.system.service.ISysUserService;
import com.dsk.common.constant.CacheNames;
......@@ -270,8 +273,21 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
@Override
@Transactional(rollbackFor = Exception.class)
public int insertUser(SysUser user) {
String password = PasswordUtils.generatePwd(8);
user.setPassword(BCrypt.hashpw(password));
// 新增用户信息
int rows = baseMapper.insert(user);
if (rows>0) {
//租户新增成功,发送短信通知租户
//此处暂用钉钉机器人模拟发送短信
String content = "【央企数字经营管理系统通知】:"
+ user.getNickName()
+ "您好,您已经成功注册央企数字经营管理系统,请使用手机号码登录,初始密码为"
+ password
+ "。友情提示:为了您的账号安全,请立即前往【个人中心】修改密码。";
DingTalkUtil.sendDingTalkMsg(content);
System.out.println("👉🏻:" + content);
}
// 新增用户岗位关联
insertUserPost(user);
// 新增用户与角色管理
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment