Merge remote-tracking branch 'origin/main'

new
commit b0ef8ed4ba

@ -0,0 +1,55 @@
-- ----------------------------
-- for archives_package
-- ----------------------------
DROP TABLE IF EXISTS `archives_package`;
CREATE TABLE `archives_package` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '',
`depot_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`depot_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`cabinet_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`cabinet_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`record_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`company_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`company` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`year` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`period` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`manege_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`case_num` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`catalog_num` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`files_num` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`flow_id` bigint(20) NULL DEFAULT NULL COMMENT '',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '',
`creator` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`package_time` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`dept_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`user_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`deleted` bit(1) NULL DEFAULT b'0' COMMENT '',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`tenant_id` bigint(20) NOT NULL COMMENT '',
`attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '1',
`attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '2',
`attr3` int(11) NULL DEFAULT NULL COMMENT '3',
`attr4` int(11) NULL DEFAULT NULL COMMENT '4',
`create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`code_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`code_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`package_num` int(11) NULL DEFAULT NULL COMMENT '',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
--
SELECT * FROM system_menu WHERE name='';
SET @menuId = LAST_INSERT_ID();
INSERT INTO `lyr-one`.`system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ('', '', 2, 0, @menuId, 'packages', '', 'archives/packages/index', 'Packages', 0, b'1', b'1', b'1', '', '2023-09-15 13:20:18', '', '2023-09-15 13:20:18', b'0');
SET @menuId2 = LAST_INSERT_ID();
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '', 'archives:packages:query', 3, 1, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-15 13:20:18', '', '2023-09-15 13:20:18', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '', 'archives:packages:create', 3, 2, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-15 13:20:18', '', '2023-09-15 13:20:18', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '', 'archives:packages:update', 3, 3, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-15 13:20:18', '', '2023-09-15 13:20:18', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '', 'archives:packages:delete', 3, 4, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-15 13:20:18', '', '2023-09-15 13:20:18', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '', 'archives:packages:export', 3, 5, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-15 13:20:18', '', '2023-09-15 13:20:18', b'0');

@ -22,6 +22,23 @@
<artifactId>spring-core</artifactId> <artifactId>spring-core</artifactId>
<scope>provided</scope> <!-- 设置为 provided只有工具类需要使用到 --> <scope>provided</scope> <!-- 设置为 provided只有工具类需要使用到 -->
</dependency> </dependency>
<!-- 条码 -->
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-light</artifactId>
<version>2.0</version>
</dependency>
<!-- io常用工具类 -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<!-- 二维码 -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.3</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId> <artifactId>spring-expression</artifactId>
@ -70,6 +87,13 @@
<artifactId>apm-toolkit-trace</artifactId> <artifactId>apm-toolkit-trace</artifactId>
</dependency> </dependency>
<!-- 文件上传工具类 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<!-- 工具类相关 --> <!-- 工具类相关 -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>

@ -0,0 +1,133 @@
package cn.iocoder.yudao.framework.common.constant;
/**
*
*
* @author ruoyi
*/
public class UserConstants {
/**
*
*/
public static final String SYS_USER = "SYS_USER";
/**
*
*/
public static final String NORMAL = "0";
/**
*
*/
public static final String EXCEPTION = "1";
/**
*
*/
public static final String USER_DISABLE = "1";
/**
*
*/
public static final String ROLE_DISABLE = "1";
/**
*
*/
public static final String DEPT_NORMAL = "0";
/**
*
*/
public static final String DEPT_DISABLE = "1";
/**
*
*/
public static final String DICT_NORMAL = "0";
/**
*
*/
public static final String YES = "Y";
public static final String NO = "N";
/**
*
*/
public static final String YES_FRAME = "0";
/**
*
*/
public static final String NO_FRAME = "1";
/**
*
*/
public static final String TYPE_DIR = "M";
/**
*
*/
public static final String TYPE_MENU = "C";
/**
*
*/
public static final String TYPE_BUTTON = "F";
/**
* Layout
*/
public final static String LAYOUT = "Layout";
/**
* ParentView
*/
public final static String PARENT_VIEW = "ParentView";
/**
* InnerLink
*/
public final static String INNER_LINK = "InnerLink";
public final static String WEBSOCKET_HEARTBEAT = "-heartbeat-";
/**
*
*/
public final static String UNIQUE = "0";
public final static String NOT_UNIQUE = "1";
/**
*
*/
public static final int USERNAME_MIN_LENGTH = 2;
public static final int USERNAME_MAX_LENGTH = 20;
/**
*
*/
public static final int PASSWORD_MIN_LENGTH = 5;
public static final int PASSWORD_MAX_LENGTH = 20;
/**
*
*/
public static final String QR_CODE = "QR_CODE";
public static final String EAN_CODE = "EAN_CODE";
public static final String UPC_CODE = "UPC_CODE";
public static final String CODE39_CODE = "CODE39_CODE";
/**
*
*/
public static final String MESSAGE_STATUS_UNREAD = "UNREAD"; //未读
public static final String MESSAGE_STATUS_READ = "READ";//已读
public static final String MESSAGE_STATUS_PROCEED = "PROCEED";//已处理
}

@ -0,0 +1,227 @@
package cn.iocoder.yudao.framework.common.util;
import cn.iocoder.yudao.framework.common.util.string.StringUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.http.MediaType;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
/**
*
*
* @author ruoyi
*/
public class FileUtils
{
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
/**
* 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 filePath
* @return
*/
public static boolean deleteFile(String filePath)
{
boolean flag = false;
File file = new File(filePath);
// 路径为文件且不为空则进行删除
if (file.isFile() && file.exists())
{
file.delete();
flag = true;
}
return flag;
}
/**
*
*
* @param filename
* @return true false
*/
public static boolean isValidFilename(String filename)
{
return filename.matches(FILENAME_PATTERN);
}
/**
*
*
* @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;
}
/**
*
*
* @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);
}
public static MultipartFile getMultipartFile(File file) {
FileItem item = new DiskFileItemFactory().createItem("file"
, MediaType.MULTIPART_FORM_DATA_VALUE
, true
, file.getName());
try (InputStream input = new FileInputStream(file);
OutputStream os = item.getOutputStream()) {
// 流转移
IOUtils.copy(input, os);
} catch (Exception e) {
throw new IllegalArgumentException("Invalid file: " + e, e);
}
return new CommonsMultipartFile(item);
}
}

@ -0,0 +1,217 @@
package cn.iocoder.yudao.framework.common.util.barcode;
import cn.iocoder.yudao.framework.common.constant.UserConstants;
import cn.iocoder.yudao.framework.common.util.string.StringUtils;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import org.krysalis.barcode4j.impl.AbstractBarcodeBean;
import org.krysalis.barcode4j.impl.code39.Code39Bean;
import org.krysalis.barcode4j.impl.upcean.EAN13Bean;
import org.krysalis.barcode4j.impl.upcean.UPCABean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
import org.krysalis.barcode4j.tools.UnitConv;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public class BarcodeUtil {
private static final String CHARSET = "utf-8";
private static final String FORMAT_NAME = "PNG";
// 二维码尺寸,长宽尺寸一致
private static final int QRCODE_SIZE = 300;
// 二维码内部logo的宽和高
private static final int WIDTH = 60;
private static final int HEIGHT = 60;
public static File generateBarCode(String msg, String barCodeFormat, String path) {
File file = new File(path);
try {
if(StringUtils.isEmpty(msg)){
throw new RuntimeException("条码内容不能为空!");
}
//检查父级目录是否存在,不存在先新建
File parentFile = file.getParentFile();
if(!parentFile.exists()){
parentFile.mkdirs();
}
/*
*
*/
if(UserConstants.QR_CODE.equals(barCodeFormat)){
//生成二维码
generateQRCode(msg, null, file.getAbsolutePath(), false);
}else{
//生成一维码
generateLineCode(msg, barCodeFormat, file.getAbsolutePath());
}
}catch (Exception e) {
throw new RuntimeException("生成条码发生错误:"+e.getMessage());
}
return file;
}
/**
*
* @param msg
* @param barCodeFormat see {@link UserConstants}
* @param destFilePath
* @throws Exception
*/
public static void generateLineCode(String msg,String barCodeFormat,String destFilePath) throws Exception {
AbstractBarcodeBean bean = null;
if(UserConstants.EAN_CODE.equals(barCodeFormat)){
bean = new EAN13Bean();
}else if(UserConstants.CODE39_CODE.equals(barCodeFormat)){
bean = new Code39Bean();
}else if(UserConstants.UPC_CODE.equals(barCodeFormat)){
bean = new UPCABean();
}else{
throw new Exception("不支持的条码类型!");
}
// 精细度
final int dpi = 150;
if (bean instanceof Code39Bean) {
Code39Bean codeBean = (Code39Bean) bean;
// module宽度
final double moduleWidth = UnitConv.in2mm(1.0f / dpi);
// 配置对象
bean.setModuleWidth(moduleWidth);
codeBean.setWideFactor(3);
bean.doQuietZone(false);
}
String format = "image/png";
try {
// 输出到流
BitmapCanvasProvider canvas = new BitmapCanvasProvider(new FileOutputStream(destFilePath), format, dpi,
BufferedImage.TYPE_BYTE_BINARY, false, 0);
// 生成条形码
bean.generateBarcode(canvas, msg);
// 结束绘制
canvas.finish();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* logo
*
* @param content
* @param imgPath
* @param destFilePath
* @param needCompress
* @throws Exception
*/
public static void generateQRCode(String content, String imgPath, String destFilePath, boolean needCompress) throws Exception {
BufferedImage image = createQrCode(content, imgPath, needCompress);
ImageIO.write(image, FORMAT_NAME, new File(destFilePath));
}
/**
*
*
* @param content
* @param imagePath ,
* @param needCompress
* @return
* @throws WriterException
*/
private static BufferedImage createQrCode(String content,String imagePath,boolean needCompress) throws WriterException, IOException {
/**
* EncodeHintType :
* CHARACTER_SET: "UTF-8" QR_CODE "ISO-8859-1"
* MARGIN:
* ERROR_CORRECTION:
* ErrorCorrectionLevelL = ~7% correctionM = ~15% correctionQ = ~25% correctionH = ~30% correction
* L
*/
Map<EncodeHintType, Object> hints = new ConcurrentHashMap<>(3);
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
hints.put(EncodeHintType.MARGIN, 1);
//加密生成二维码的矩阵对象 二维的0 1 然后根据特定的值选择属性
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE, hints);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
//设置二维码的黑色0xFF000000 和白色0xFFFFFFFF
image.setRGB(i, j, bitMatrix.get(i, j) ? 0xFF000000 : 0xFFFFFFFF);
}
}
if (StringUtils.isBlank(imagePath)) {
return image;
}
//插入小图标 logo
insertImage(image, imagePath, needCompress);
return image;
}
/**
* logo
*
* @param source
* @param imagePath
* logoossurl
* @param needCompress
* @throws IOException
*/
private static void insertImage(BufferedImage source, String imagePath, boolean needCompress) throws IOException {
File file = new File(imagePath);
if (!file.exists()) {
//可以自定义抛出异常
throw new RuntimeException("文件路径不存在:" + imagePath);
}
//这里修改ImageIO.read() 内可以接受Url InputStream File ImageInputStream
Image src = ImageIO.read(file);
int width = src.getWidth(null);
int height = src.getHeight(null);
//是否压缩
if (needCompress) {
if (width > WIDTH) {
width = WIDTH;
}
if (height > HEIGHT) {
height = HEIGHT;
}
Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
src = image;
}
Graphics2D graphics = source.createGraphics();
int x = (QRCODE_SIZE - width) / 2;
int y = (QRCODE_SIZE - height) / 2;
graphics.drawImage(src,x,y,width,height,null);
Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
graphics.setStroke(new BasicStroke(3f));
graphics.draw(shape);
graphics.dispose();
}
public static void main(String[] args) {
String msg="item12345678";
String EANmsg="012345678901";
String UPCmsg="12345678901";
String path = "D:/test/barcode/"+UUID.randomUUID()+".png";
generateBarCode(msg, UserConstants.QR_CODE, path);
}
}

@ -0,0 +1,568 @@
package cn.iocoder.yudao.framework.common.util.string;
import cn.hutool.core.text.StrFormatter;
import org.springframework.util.AntPathMatcher;
import java.util.*;
/**
*
*
* @author ruoyi
*/
public class StringUtils extends org.apache.commons.lang3.StringUtils
{
/** 空字符串 */
private static final String NULLSTR = "";
/** 下划线 */
private static final char SEPARATOR = '_';
/**
*
*
* @param value defaultValue value
* @return value
*/
public static <T> T nvl(T value, T defaultValue)
{
return value != null ? value : defaultValue;
}
/**
* * Collection ListSetQueue
*
* @param coll Collection
* @return true false
*/
public static boolean isEmpty(Collection<?> coll)
{
return isNull(coll) || coll.isEmpty();
}
/**
* * CollectionListSetQueue
*
* @param coll Collection
* @return true false
*/
public static boolean isNotEmpty(Collection<?> coll)
{
return !isEmpty(coll);
}
/**
* *
*
* @param objects
** @return true false
*/
public static boolean isEmpty(Object[] objects)
{
return isNull(objects) || (objects.length == 0);
}
/**
* *
*
* @param objects
* @return true false
*/
public static boolean isNotEmpty(Object[] objects)
{
return !isEmpty(objects);
}
/**
* * Map
*
* @param map Map
* @return true false
*/
public static boolean isEmpty(Map<?, ?> map)
{
return isNull(map) || map.isEmpty();
}
/**
* * Map
*
* @param map Map
* @return true false
*/
public static boolean isNotEmpty(Map<?, ?> map)
{
return !isEmpty(map);
}
/**
* *
*
* @param str String
* @return true false
*/
public static boolean isEmpty(String str)
{
return isNull(str) || NULLSTR.equals(str.trim());
}
/**
* *
*
* @param str String
* @return true false
*/
public static boolean isNotEmpty(String str)
{
return !isEmpty(str);
}
/**
* *
*
* @param object Object
* @return true false
*/
public static boolean isNull(Object object)
{
return object == null;
}
/**
* *
*
* @param object Object
* @return true false
*/
public static boolean isNotNull(Object object)
{
return !isNull(object);
}
/**
* * Java
*
* @param object
* @return true false
*/
public static boolean isArray(Object object)
{
return isNotNull(object) && object.getClass().isArray();
}
/**
*
*/
public static String trim(String str)
{
return (str == null ? "" : str.trim());
}
/**
*
*
* @param str
* @param start
* @return
*/
public static String substring(final String str, int start)
{
if (str == null)
{
return NULLSTR;
}
if (start < 0)
{
start = str.length() + start;
}
if (start < 0)
{
start = 0;
}
if (start > str.length())
{
return NULLSTR;
}
return str.substring(start);
}
/**
*
*
* @param str
* @param start
* @param end
* @return
*/
public static String substring(final String str, int start, int end)
{
if (str == null)
{
return NULLSTR;
}
if (end < 0)
{
end = str.length() + end;
}
if (start < 0)
{
start = str.length() + start;
}
if (end > str.length())
{
end = str.length();
}
if (start > end)
{
return NULLSTR;
}
if (start < 0)
{
start = 0;
}
if (end < 0)
{
end = 0;
}
return str.substring(start, end);
}
/**
* , {} <br>
* {} <br>
* {} 使 \\ { {} \ 使 \\\\ <br>
* <br>
* 使format("this is {} for {}", "a", "b") -> this is a for b<br>
* {} format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
* \ format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
*
* @param template {}
* @param params
* @return
*/
public static String format(String template, Object... params)
{
if (isEmpty(params) || isEmpty(template))
{
return template;
}
return StrFormatter.format(template, params);
}
/**
* set
*
* @param str
* @param sep
* @return set
*/
public static final Set<String> str2Set(String str, String sep)
{
return new HashSet<String>(str2List(str, sep, true, false));
}
/**
* list
*
* @param str
* @param sep
* @param filterBlank
* @param trim
* @return list
*/
public static final List<String> str2List(String str, String sep, boolean filterBlank, boolean trim)
{
List<String> list = new ArrayList<String>();
if (StringUtils.isEmpty(str))
{
return list;
}
// 过滤空白字符串
if (filterBlank && StringUtils.isBlank(str))
{
return list;
}
String[] split = str.split(sep);
for (String string : split)
{
if (filterBlank && StringUtils.isBlank(string))
{
continue;
}
if (trim)
{
string = string.trim();
}
list.add(string);
}
return list;
}
/**
*
*
* @param cs
* @param searchCharSequences
* @return
*/
public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences)
{
if (isEmpty(cs) || isEmpty(searchCharSequences))
{
return false;
}
for (CharSequence testStr : searchCharSequences)
{
if (containsIgnoreCase(cs, testStr))
{
return true;
}
}
return false;
}
/**
* 线
*/
public static String toUnderScoreCase(String str)
{
if (str == null)
{
return null;
}
StringBuilder sb = new StringBuilder();
// 前置字符是否大写
boolean preCharIsUpperCase = true;
// 当前字符是否大写
boolean curreCharIsUpperCase = true;
// 下一字符是否大写
boolean nexteCharIsUpperCase = true;
for (int i = 0; i < str.length(); i++)
{
char c = str.charAt(i);
if (i > 0)
{
preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
}
else
{
preCharIsUpperCase = false;
}
curreCharIsUpperCase = Character.isUpperCase(c);
if (i < (str.length() - 1))
{
nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
}
if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase)
{
sb.append(SEPARATOR);
}
else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase)
{
sb.append(SEPARATOR);
}
sb.append(Character.toLowerCase(c));
}
return sb.toString();
}
/**
*
*
* @param str
* @param strs
* @return true
*/
public static boolean inStringIgnoreCase(String str, String... strs)
{
if (str != null && strs != null)
{
for (String s : strs)
{
if (str.equalsIgnoreCase(trim(s)))
{
return true;
}
}
}
return false;
}
/**
* 线线 HELLO_WORLD->HelloWorld
*
* @param name 线
* @return
*/
public static String convertToCamelCase(String name)
{
StringBuilder result = new StringBuilder();
// 快速检查
if (name == null || name.isEmpty())
{
// 没必要转换
return "";
}
else if (!name.contains("_"))
{
// 不含下划线,仅将首字母大写
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
// 用下划线将原始字符串分割
String[] camels = name.split("_");
for (String camel : camels)
{
// 跳过原始字符串中开头、结尾的下换线或双重下划线
if (camel.isEmpty())
{
continue;
}
// 首字母大写
result.append(camel.substring(0, 1).toUpperCase());
result.append(camel.substring(1).toLowerCase());
}
return result.toString();
}
/**
* user_name->userName
*/
public static String toCamelCase(String s)
{
if (s == null)
{
return null;
}
s = s.toLowerCase();
StringBuilder sb = new StringBuilder(s.length());
boolean upperCase = false;
for (int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
if (c == SEPARATOR)
{
upperCase = true;
}
else if (upperCase)
{
sb.append(Character.toUpperCase(c));
upperCase = false;
}
else
{
sb.append(c);
}
}
return sb.toString();
}
/**
*
*
* @param str
* @param strs
* @return
*/
public static boolean matches(String str, List<String> strs)
{
if (isEmpty(str) || isEmpty(strs))
{
return false;
}
for (String pattern : strs)
{
if (isMatch(pattern, str))
{
return true;
}
}
return false;
}
/**
* url:
* ? ;
* * ;
* ** ;
*
* @param pattern
* @param url url
* @return
*/
public static boolean isMatch(String pattern, String url)
{
AntPathMatcher matcher = new AntPathMatcher();
return matcher.match(pattern, url);
}
@SuppressWarnings("unchecked")
public static <T> T cast(Object obj)
{
return (T) obj;
}
/**
* 0使size size
*
* @param num
* @param size
* @return
*/
public static final String padl(final Number num, final int size)
{
return padl(num.toString(), size, '0');
}
/**
* ssizesize
*
* @param s
* @param size
* @param c
* @return
*/
public static final String padl(final String s, final int size, final char c)
{
final StringBuilder sb = new StringBuilder(size);
if (s != null)
{
final int len = s.length();
if (s.length() <= size)
{
for (int i = size - len; i > 0; i--)
{
sb.append(c);
}
sb.append(s);
}
else
{
return s.substring(len - size, len);
}
}
else
{
for (int i = size; i > 0; i--)
{
sb.append(c);
}
}
return sb.toString();
}
}

@ -5,6 +5,7 @@ public interface ErrorCodeConstants {
ErrorCode RECORD_NOT_EXISTS = new ErrorCode(200100, "归档不存在"); ErrorCode RECORD_NOT_EXISTS = new ErrorCode(200100, "归档不存在");
ErrorCode CODE_RULE_NOT_EXISTS = new ErrorCode(300100, "编码不存在"); ErrorCode CODE_RULE_NOT_EXISTS = new ErrorCode(300100, "编码不存在");
ErrorCode TURN_OVER_NOT_EXISTS = new ErrorCode(400100, "移交管理不存在"); ErrorCode TURN_OVER_NOT_EXISTS = new ErrorCode(400100, "移交管理不存在");
ErrorCode PACKAGES_NOT_EXISTS = new ErrorCode(500100, "装册不存在");
ErrorCode BORROW_APPLY_NOT_EXISTS = new ErrorCode(300200,"借阅申请不存在"); ErrorCode BORROW_APPLY_NOT_EXISTS = new ErrorCode(300200,"借阅申请不存在");

@ -96,6 +96,12 @@
<version>1.7.3-snapshot</version> <version>1.7.3-snapshot</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-infra-biz</artifactId>
<version>1.7.3-snapshot</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -0,0 +1,110 @@
package cn.iocoder.yudao.module.archives.controller.admin.packages;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.archives.controller.admin.packages.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.packages.PackagesDO;
import cn.iocoder.yudao.module.archives.convert.packages.PackagesConvert;
import cn.iocoder.yudao.module.archives.service.packages.PackagesService;
@Tag(name = "管理后台 - 装册")
@RestController
@RequestMapping("/archives/packages")
@Validated
public class PackagesController {
@Resource
private PackagesService packagesService;
@PostMapping("/create")
@Operation(summary = "创建装册")
@PreAuthorize("@ss.hasPermission('archives:packages:create')")
public CommonResult<Long> createPackages(@Valid @RequestBody PackagesCreateReqVO createReqVO) {
return success(packagesService.createPackages(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新装册")
@PreAuthorize("@ss.hasPermission('archives:packages:update')")
public CommonResult<Boolean> updatePackages(@Valid @RequestBody PackagesUpdateReqVO updateReqVO) {
packagesService.updatePackages(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除装册")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('archives:packages:delete')")
public CommonResult<Boolean> deletePackages(@RequestParam("id") Long id) {
packagesService.deletePackages(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得装册")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('archives:packages:query')")
public CommonResult<PackagesRespVO> getPackages(@RequestParam("id") Long id) {
PackagesDO packages = packagesService.getPackages(id);
return success(PackagesConvert.INSTANCE.convert(packages));
}
@GetMapping("/getByCodeValue")
@Operation(summary = "获得装册")
@Parameter(name = "id", description = "条码值", required = true, example = "1-2-3")
public CommonResult<PackagesRespVO> getByCodeValue(@RequestParam("codeValue") String codeValue) {
PackagesDO packages = packagesService.getByCodeValue(codeValue);
return success(PackagesConvert.INSTANCE.convert(packages));
}
@GetMapping("/list")
@Operation(summary = "获得装册列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('archives:packages:query')")
public CommonResult<List<PackagesRespVO>> getPackagesList(@RequestParam("ids") Collection<Long> ids) {
List<PackagesDO> list = packagesService.getPackagesList(ids);
return success(PackagesConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得装册分页")
@PreAuthorize("@ss.hasPermission('archives:packages:query')")
public CommonResult<PageResult<PackagesRespVO>> getPackagesPage(@Valid PackagesPageReqVO pageVO) {
PageResult<PackagesDO> pageResult = packagesService.getPackagesPage(pageVO);
return success(PackagesConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出装册 Excel")
@PreAuthorize("@ss.hasPermission('archives:packages:export')")
@OperateLog(type = EXPORT)
public void exportPackagesExcel(@Valid PackagesExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<PackagesDO> list = packagesService.getPackagesList(exportReqVO);
// 导出 Excel
List<PackagesExcelVO> datas = PackagesConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "装册.xls", "数据", PackagesExcelVO.class, datas);
}
}

@ -0,0 +1,89 @@
package cn.iocoder.yudao.module.archives.controller.admin.packages.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import javax.validation.constraints.*;
/**
* Base VO VO 使
* VO Swagger
*/
@Data
public class PackagesBaseVO {
@Schema(description = "库房id", example = "27849")
private Long depotId;
@Schema(description = "库房名称", example = "芋艿")
private String depotName;
@Schema(description = "档案柜id", example = "13350")
private Long cabinetId;
@Schema(description = "档案柜名称", example = "芋艿")
private String cabinetName;
@Schema(description = "档案id", example = "320")
private Long recordId;
@Schema(description = "业务实体id", example = "26066")
private Long companyId;
@Schema(description = "业务实体")
private String company;
@Schema(description = "会计年份")
private String year;
@Schema(description = "会计月份")
private String period;
@Schema(description = "负责人名称", example = "王五")
private String manegeName;
@Schema(description = "全宗号")
private String caseNum;
@Schema(description = "目录号")
private String catalogNum;
@Schema(description = "案卷号")
private String filesNum;
@Schema(description = "关联号", example = "6116")
private Long flowId;
@Schema(description = "状态待装册,已装册", example = "1")
private String status;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "装册时间")
private String packageTime;
@Schema(description = "所属部门id", example = "29567")
private Long deptId;
@Schema(description = "用户id", example = "12826")
private Long userId;
@Schema(description = "所属部门", example = "张三")
private String deptName;
@Schema(description = "制单人")
private String createBy;
@Schema(description = "条码地址", example = "https://www.iocoder.cn")
private String codeUrl;
@Schema(description = "条码值")
private String codeValue;
@Schema(description = "装册数量")
private Integer packageNum;
}

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.archives.controller.admin.packages.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 装册创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PackagesCreateReqVO extends PackagesBaseVO {
@Schema(description = "全宗号")
@NotNull(message = "全宗号不能为空")
private String caseNum;
@Schema(description = "目录号")
@NotNull(message = "目录号不能为空")
private String catalogNum;
@Schema(description = "案卷号")
@NotNull(message = "案卷号不能为空")
private String filesNum;
}

@ -0,0 +1,97 @@
package cn.iocoder.yudao.module.archives.controller.admin.packages.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
/**
* Excel VO
*
* @author devin1
*/
@Data
public class PackagesExcelVO {
@ExcelProperty("主键")
private Long id;
@ExcelProperty("库房id")
private Long depotId;
@ExcelProperty("库房名称")
private String depotName;
@ExcelProperty("档案柜id")
private Long cabinetId;
@ExcelProperty("档案柜名称")
private String cabinetName;
@ExcelProperty("档案id")
private Long recordId;
@ExcelProperty("业务实体id")
private Long companyId;
@ExcelProperty("业务实体")
private String company;
@ExcelProperty("会计年份")
private String year;
@ExcelProperty("会计月份")
private String period;
@ExcelProperty("负责人名称")
private String manegeName;
@ExcelProperty("全宗号")
private String caseNum;
@ExcelProperty("目录号")
private String catalogNum;
@ExcelProperty("案卷号")
private String filesNum;
@ExcelProperty("关联号")
private Long flowId;
@ExcelProperty("创建日期")
private LocalDateTime createTime;
@ExcelProperty("状态待装册,已装册")
private String status;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("装册时间")
private String packageTime;
@ExcelProperty("所属部门id")
private Long deptId;
@ExcelProperty("用户id")
private Long userId;
@ExcelProperty("所属部门")
private String deptName;
@ExcelProperty("制单人")
private String createBy;
@ExcelProperty("条码地址")
private String codeUrl;
@ExcelProperty("条码值")
private String codeValue;
@ExcelProperty("装册数量")
private Integer packageNum;
}

@ -0,0 +1,93 @@
package cn.iocoder.yudao.module.archives.controller.admin.packages.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 装册 Excel 导出 Request VO参数和 PackagesPageReqVO 是一致的")
@Data
public class PackagesExportReqVO {
@Schema(description = "库房id", example = "27849")
private Long depotId;
@Schema(description = "库房名称", example = "芋艿")
private String depotName;
@Schema(description = "档案柜id", example = "13350")
private Long cabinetId;
@Schema(description = "档案柜名称", example = "芋艿")
private String cabinetName;
@Schema(description = "档案id", example = "320")
private Long recordId;
@Schema(description = "业务实体id", example = "26066")
private Long companyId;
@Schema(description = "业务实体")
private String company;
@Schema(description = "会计年份")
private String year;
@Schema(description = "会计月份")
private String period;
@Schema(description = "负责人名称", example = "王五")
private String manegeName;
@Schema(description = "全宗号")
private String caseNum;
@Schema(description = "目录号")
private String catalogNum;
@Schema(description = "案卷号")
private String filesNum;
@Schema(description = "关联号", example = "6116")
private Long flowId;
@Schema(description = "创建日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "状态待装册,已装册", example = "1")
private String status;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "装册时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] packageTime;
@Schema(description = "所属部门id", example = "29567")
private Long deptId;
@Schema(description = "用户id", example = "12826")
private Long userId;
@Schema(description = "所属部门", example = "张三")
private String deptName;
@Schema(description = "制单人")
private String createBy;
@Schema(description = "条码地址", example = "https://www.iocoder.cn")
private String codeUrl;
@Schema(description = "条码值")
private String codeValue;
@Schema(description = "装册数量")
private Integer packageNum;
}

@ -0,0 +1,95 @@
package cn.iocoder.yudao.module.archives.controller.admin.packages.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 装册分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PackagesPageReqVO extends PageParam {
@Schema(description = "库房id", example = "27849")
private Long depotId;
@Schema(description = "库房名称", example = "芋艿")
private String depotName;
@Schema(description = "档案柜id", example = "13350")
private Long cabinetId;
@Schema(description = "档案柜名称", example = "芋艿")
private String cabinetName;
@Schema(description = "档案id", example = "320")
private Long recordId;
@Schema(description = "业务实体id", example = "26066")
private Long companyId;
@Schema(description = "业务实体")
private String company;
@Schema(description = "会计年份")
private String year;
@Schema(description = "会计月份")
private String period;
@Schema(description = "负责人名称", example = "王五")
private String manegeName;
@Schema(description = "全宗号")
private String caseNum;
@Schema(description = "目录号")
private String catalogNum;
@Schema(description = "案卷号")
private String filesNum;
@Schema(description = "关联号", example = "6116")
private Long flowId;
@Schema(description = "创建日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "状态待装册,已装册", example = "1")
private String status;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "装册时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] packageTime;
@Schema(description = "所属部门id", example = "29567")
private Long deptId;
@Schema(description = "用户id", example = "12826")
private Long userId;
@Schema(description = "所属部门", example = "张三")
private String deptName;
@Schema(description = "制单人")
private String createBy;
@Schema(description = "条码地址", example = "https://www.iocoder.cn")
private String codeUrl;
@Schema(description = "条码值")
private String codeValue;
@Schema(description = "装册数量")
private Integer packageNum;
}

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.archives.controller.admin.packages.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 装册 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PackagesRespVO extends PackagesBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "18922")
private Long id;
@Schema(description = "创建日期")
private LocalDateTime createTime;
}

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.archives.controller.admin.packages.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 装册更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PackagesUpdateReqVO extends PackagesBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "18922")
@NotNull(message = "主键不能为空")
private Long id;
}

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.archives.convert.packages;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.archives.controller.admin.packages.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.packages.PackagesDO;
/**
* Convert
*
* @author devin1
*/
@Mapper
public interface PackagesConvert {
PackagesConvert INSTANCE = Mappers.getMapper(PackagesConvert.class);
PackagesDO convert(PackagesCreateReqVO bean);
PackagesDO convert(PackagesUpdateReqVO bean);
PackagesRespVO convert(PackagesDO bean);
List<PackagesRespVO> convertList(List<PackagesDO> list);
PageResult<PackagesRespVO> convertPage(PageResult<PackagesDO> page);
List<PackagesExcelVO> convertList02(List<PackagesDO> list);
}

@ -0,0 +1,143 @@
package cn.iocoder.yudao.module.archives.dal.dataobject.packages;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author devin1
*/
@TableName("archives_package")
@KeySequence("archives_package_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PackagesDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* id
*/
private Long depotId;
/**
*
*/
private String depotName;
/**
* id
*/
private Long cabinetId;
/**
*
*/
private String cabinetName;
/**
* id
*/
private Long recordId;
/**
* id
*/
private Long companyId;
/**
*
*/
private String company;
/**
*
*/
private String year;
/**
*
*/
private String period;
/**
*
*/
private String manegeName;
/**
*
*/
private String caseNum;
/**
*
*/
private String catalogNum;
/**
*
*/
private String filesNum;
/**
*
*/
private Long flowId;
/**
*
*/
private String status;
/**
*
*/
private String remark;
/**
*
*/
private String packageTime;
/**
* id
*/
private Long deptId;
/**
* id
*/
private Long userId;
/**
*
*/
private String deptName;
/**
* 1
*/
private String attr1;
/**
* 2
*/
private String attr2;
/**
* 3
*/
private Integer attr3;
/**
* 4
*/
private Integer attr4;
/**
*
*/
private String createBy;
/**
*
*/
private String codeUrl;
/**
*
*/
private String codeValue;
/**
*
*/
private Integer packageNum;
}

@ -0,0 +1,85 @@
package cn.iocoder.yudao.module.archives.dal.mysql.packages;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.archives.dal.dataobject.packages.PackagesDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.archives.controller.admin.packages.vo.*;
import org.apache.ibatis.annotations.Select;
/**
* Mapper
*
* @author devin1
*/
@Mapper
public interface PackagesMapper extends BaseMapperX<PackagesDO> {
default PageResult<PackagesDO> selectPage(PackagesPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PackagesDO>()
.eqIfPresent(PackagesDO::getDepotId, reqVO.getDepotId())
.likeIfPresent(PackagesDO::getDepotName, reqVO.getDepotName())
.eqIfPresent(PackagesDO::getCabinetId, reqVO.getCabinetId())
.likeIfPresent(PackagesDO::getCabinetName, reqVO.getCabinetName())
.eqIfPresent(PackagesDO::getRecordId, reqVO.getRecordId())
.eqIfPresent(PackagesDO::getCompanyId, reqVO.getCompanyId())
.eqIfPresent(PackagesDO::getCompany, reqVO.getCompany())
.eqIfPresent(PackagesDO::getYear, reqVO.getYear())
.eqIfPresent(PackagesDO::getPeriod, reqVO.getPeriod())
.likeIfPresent(PackagesDO::getManegeName, reqVO.getManegeName())
.eqIfPresent(PackagesDO::getCaseNum, reqVO.getCaseNum())
.eqIfPresent(PackagesDO::getCatalogNum, reqVO.getCatalogNum())
.eqIfPresent(PackagesDO::getFilesNum, reqVO.getFilesNum())
.eqIfPresent(PackagesDO::getFlowId, reqVO.getFlowId())
.betweenIfPresent(PackagesDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PackagesDO::getStatus, reqVO.getStatus())
.eqIfPresent(PackagesDO::getRemark, reqVO.getRemark())
.betweenIfPresent(PackagesDO::getPackageTime, reqVO.getPackageTime())
.eqIfPresent(PackagesDO::getDeptId, reqVO.getDeptId())
.eqIfPresent(PackagesDO::getUserId, reqVO.getUserId())
.likeIfPresent(PackagesDO::getDeptName, reqVO.getDeptName())
.eqIfPresent(PackagesDO::getCreateBy, reqVO.getCreateBy())
.eqIfPresent(PackagesDO::getCodeUrl, reqVO.getCodeUrl())
.eqIfPresent(PackagesDO::getCodeValue, reqVO.getCodeValue())
.eqIfPresent(PackagesDO::getPackageNum, reqVO.getPackageNum())
.orderByDesc(PackagesDO::getId));
}
default List<PackagesDO> selectList(PackagesExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<PackagesDO>()
.eqIfPresent(PackagesDO::getDepotId, reqVO.getDepotId())
.likeIfPresent(PackagesDO::getDepotName, reqVO.getDepotName())
.eqIfPresent(PackagesDO::getCabinetId, reqVO.getCabinetId())
.likeIfPresent(PackagesDO::getCabinetName, reqVO.getCabinetName())
.eqIfPresent(PackagesDO::getRecordId, reqVO.getRecordId())
.eqIfPresent(PackagesDO::getCompanyId, reqVO.getCompanyId())
.eqIfPresent(PackagesDO::getCompany, reqVO.getCompany())
.eqIfPresent(PackagesDO::getYear, reqVO.getYear())
.eqIfPresent(PackagesDO::getPeriod, reqVO.getPeriod())
.likeIfPresent(PackagesDO::getManegeName, reqVO.getManegeName())
.eqIfPresent(PackagesDO::getCaseNum, reqVO.getCaseNum())
.eqIfPresent(PackagesDO::getCatalogNum, reqVO.getCatalogNum())
.eqIfPresent(PackagesDO::getFilesNum, reqVO.getFilesNum())
.eqIfPresent(PackagesDO::getFlowId, reqVO.getFlowId())
.betweenIfPresent(PackagesDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PackagesDO::getStatus, reqVO.getStatus())
.eqIfPresent(PackagesDO::getRemark, reqVO.getRemark())
.betweenIfPresent(PackagesDO::getPackageTime, reqVO.getPackageTime())
.eqIfPresent(PackagesDO::getDeptId, reqVO.getDeptId())
.eqIfPresent(PackagesDO::getUserId, reqVO.getUserId())
.likeIfPresent(PackagesDO::getDeptName, reqVO.getDeptName())
.eqIfPresent(PackagesDO::getCreateBy, reqVO.getCreateBy())
.eqIfPresent(PackagesDO::getCodeUrl, reqVO.getCodeUrl())
.eqIfPresent(PackagesDO::getCodeValue, reqVO.getCodeValue())
.eqIfPresent(PackagesDO::getPackageNum, reqVO.getPackageNum())
.orderByDesc(PackagesDO::getId));
}
@Select("SELECT id, depot_id, depot_name, cabinet_id, cabinet_name, record_id, company_id, company, year, period, manege_name, case_num, catalog_num, files_num, flow_id, status, remark, package_time, dept_id, user_id, dept_name, attr1, attr2, attr3, attr4, create_by, code_url, code_value, package_num "
+" FROM archives_package WHERE code_value = #{codeValue} ORDER BY create_time DESC LIMIT 1")
PackagesDO getByCodeValue(String codeValue);
}

@ -0,0 +1,78 @@
package cn.iocoder.yudao.module.archives.service.packages;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.archives.controller.admin.packages.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.packages.PackagesDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* Service
*
* @author devin1
*/
public interface PackagesService {
/**
*
*
* @param createReqVO
* @return
*/
Long createPackages(@Valid PackagesCreateReqVO createReqVO);
/**
*
*
* @param updateReqVO
*/
void updatePackages(@Valid PackagesUpdateReqVO updateReqVO);
/**
*
*
* @param id
*/
void deletePackages(Long id);
/**
*
*
* @param id
* @return
*/
PackagesDO getPackages(Long id);
/**
*
*
* @param ids
* @return
*/
List<PackagesDO> getPackagesList(Collection<Long> ids);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<PackagesDO> getPackagesPage(PackagesPageReqVO pageReqVO);
/**
*
*
* @param codeValue
* @return
*/
PackagesDO getByCodeValue(String codeValue);
/**
* , Excel
*
* @param exportReqVO
* @return
*/
List<PackagesDO> getPackagesList(PackagesExportReqVO exportReqVO);
}

@ -0,0 +1,124 @@
package cn.iocoder.yudao.module.archives.service.packages;
import cn.hutool.core.io.IoUtil;
import cn.iocoder.yudao.framework.common.util.FileUtils;
import cn.iocoder.yudao.framework.common.util.barcode.BarcodeUtil;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import me.zhyd.oauth.log.Log;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.io.File;
import java.io.IOException;
import java.util.*;
import cn.iocoder.yudao.module.archives.controller.admin.packages.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.packages.PackagesDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.archives.convert.packages.PackagesConvert;
import cn.iocoder.yudao.module.archives.dal.mysql.packages.PackagesMapper;
import org.springframework.web.multipart.MultipartFile;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.archives.enums.ErrorCodeConstants.*;
/**
* Service
*
* @author devin1
*/
@Service
@Validated
public class PackagesServiceImpl implements PackagesService {
@Resource
private PackagesMapper packagesMapper;
@Resource
private FileService fileService;
@Override
public Long createPackages(PackagesCreateReqVO createReqVO) {
// 插入
PackagesDO packages = PackagesConvert.INSTANCE.convert(createReqVO);
File buf = BarcodeUtil.generateBarCode(packages.getCaseNum()+"-"+packages.getCatalogNum()+"-"+packages.getFilesNum(), "QR_CODE",
"./tmp/Packages/" + packages.getCaseNum()+"-"+packages.getCatalogNum()+"-"+packages.getFilesNum() + ".png");
MultipartFile file = FileUtils.getMultipartFile(buf);
String url="";
try {
url = fileService.createFile(null, null, IoUtil.readBytes(file.getInputStream()));
} catch (IOException e) {
Log.error(e.toString());
}
packages.setCodeUrl(url);
packages.setCodeValue(packages.getCaseNum()+"-"+packages.getCatalogNum()+"-"+packages.getFilesNum());
packagesMapper.insert(packages);
// 返回
return packages.getId();
}
@Override
public void updatePackages(PackagesUpdateReqVO updateReqVO) {
// 校验存在
validatePackagesExists(updateReqVO.getId());
// 更新
PackagesDO updateObj = PackagesConvert.INSTANCE.convert(updateReqVO);
PackagesDO packagesDO = packagesMapper.selectById(updateReqVO.getId());
boolean b = packagesDO.getCaseNum().equals(updateObj.getCaseNum()) && packagesDO.getCatalogNum().equals(updateObj.getCatalogNum()) && packagesDO.getFilesNum().equals(updateObj.getFilesNum());
if (!b){
File buf = BarcodeUtil.generateBarCode(updateObj.getCaseNum()+"-"+updateObj.getCatalogNum()+"-"+updateObj.getFilesNum(), "QR_CODE",
"./tmp/Packages/" + updateObj.getCaseNum()+"-"+updateObj.getCatalogNum()+"-"+updateObj.getFilesNum() + ".png");
MultipartFile file = FileUtils.getMultipartFile(buf);
String url="";
try {
url = fileService.createFile(null, null, IoUtil.readBytes(file.getInputStream()));
} catch (IOException e) {
Log.error(e.toString());
}
updateObj.setCodeUrl(url);
updateObj.setCodeValue(updateObj.getCaseNum()+"-"+updateObj.getCatalogNum()+"-"+updateObj.getFilesNum());
}
packagesMapper.updateById(updateObj);
}
@Override
public void deletePackages(Long id) {
// 校验存在
validatePackagesExists(id);
// 删除
packagesMapper.deleteById(id);
}
private void validatePackagesExists(Long id) {
if (packagesMapper.selectById(id) == null) {
throw exception(PACKAGES_NOT_EXISTS);
}
}
@Override
public PackagesDO getPackages(Long id) {
return packagesMapper.selectById(id);
}
@Override
public List<PackagesDO> getPackagesList(Collection<Long> ids) {
return packagesMapper.selectBatchIds(ids);
}
@Override
public PackagesDO getByCodeValue(String codeValue) {
return packagesMapper.getByCodeValue(codeValue);
}
@Override
public PageResult<PackagesDO> getPackagesPage(PackagesPageReqVO pageReqVO) {
return packagesMapper.selectPage(pageReqVO);
}
@Override
public List<PackagesDO> getPackagesList(PackagesExportReqVO exportReqVO) {
return packagesMapper.selectList(exportReqVO);
}
}

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.archives.dal.mysql.packages.PackagesMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,343 @@
package cn.iocoder.yudao.module.archives.service.packages;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import javax.annotation.Resource;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.archives.controller.admin.packages.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.packages.PackagesDO;
import cn.iocoder.yudao.module.archives.dal.mysql.packages.PackagesMapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.annotation.Resource;
import org.springframework.context.annotation.Import;
import java.util.*;
import java.time.LocalDateTime;
import static cn.hutool.core.util.RandomUtil.*;
import static cn.iocoder.yudao.module.archives.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
/**
* {@link PackagesServiceImpl}
*
* @author devin1
*/
@Import(PackagesServiceImpl.class)
public class PackagesServiceImplTest extends BaseDbUnitTest {
@Resource
private PackagesServiceImpl packagesService;
@Resource
private PackagesMapper packagesMapper;
@Test
public void testCreatePackages_success() {
// 准备参数
PackagesCreateReqVO reqVO = randomPojo(PackagesCreateReqVO.class);
// 调用
Long packagesId = packagesService.createPackages(reqVO);
// 断言
assertNotNull(packagesId);
// 校验记录的属性是否正确
PackagesDO packages = packagesMapper.selectById(packagesId);
assertPojoEquals(reqVO, packages);
}
@Test
public void testUpdatePackages_success() {
// mock 数据
PackagesDO dbPackages = randomPojo(PackagesDO.class);
packagesMapper.insert(dbPackages);// @Sql: 先插入出一条存在的数据
// 准备参数
PackagesUpdateReqVO reqVO = randomPojo(PackagesUpdateReqVO.class, o -> {
o.setId(dbPackages.getId()); // 设置更新的 ID
});
// 调用
packagesService.updatePackages(reqVO);
// 校验是否更新正确
PackagesDO packages = packagesMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, packages);
}
@Test
public void testUpdatePackages_notExists() {
// 准备参数
PackagesUpdateReqVO reqVO = randomPojo(PackagesUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> packagesService.updatePackages(reqVO), PACKAGES_NOT_EXISTS);
}
@Test
public void testDeletePackages_success() {
// mock 数据
PackagesDO dbPackages = randomPojo(PackagesDO.class);
packagesMapper.insert(dbPackages);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbPackages.getId();
// 调用
packagesService.deletePackages(id);
// 校验数据不存在了
assertNull(packagesMapper.selectById(id));
}
@Test
public void testDeletePackages_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> packagesService.deletePackages(id), PACKAGES_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetPackagesPage() {
// mock 数据
PackagesDO dbPackages = randomPojo(PackagesDO.class, o -> { // 等会查询到
o.setDepotId(null);
o.setDepotName(null);
o.setCabinetId(null);
o.setCabinetName(null);
o.setRecordId(null);
o.setCompanyId(null);
o.setCompany(null);
o.setYear(null);
o.setPeriod(null);
o.setManegeName(null);
o.setCaseNum(null);
o.setCatalogNum(null);
o.setFilesNum(null);
o.setFlowId(null);
o.setCreateTime(null);
o.setStatus(null);
o.setRemark(null);
o.setPackageTime(null);
o.setDeptId(null);
o.setUserId(null);
o.setDeptName(null);
o.setCreateBy(null);
o.setCodeUrl(null);
o.setCodeValue(null);
o.setPackageNum(null);
});
packagesMapper.insert(dbPackages);
// 测试 depotId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setDepotId(null)));
// 测试 depotName 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setDepotName(null)));
// 测试 cabinetId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCabinetId(null)));
// 测试 cabinetName 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCabinetName(null)));
// 测试 recordId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setRecordId(null)));
// 测试 companyId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCompanyId(null)));
// 测试 company 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCompany(null)));
// 测试 year 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setYear(null)));
// 测试 period 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setPeriod(null)));
// 测试 manegeName 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setManegeName(null)));
// 测试 caseNum 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCaseNum(null)));
// 测试 catalogNum 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCatalogNum(null)));
// 测试 filesNum 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setFilesNum(null)));
// 测试 flowId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setFlowId(null)));
// 测试 createTime 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCreateTime(null)));
// 测试 status 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setStatus(null)));
// 测试 remark 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setRemark(null)));
// 测试 packageTime 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setPackageTime(null)));
// 测试 deptId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setDeptId(null)));
// 测试 userId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setUserId(null)));
// 测试 deptName 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setDeptName(null)));
// 测试 createBy 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCreateBy(null)));
// 测试 codeUrl 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCodeUrl(null)));
// 测试 codeValue 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCodeValue(null)));
// 测试 packageNum 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setPackageNum(null)));
// 准备参数
PackagesPageReqVO reqVO = new PackagesPageReqVO();
reqVO.setDepotId(null);
reqVO.setDepotName(null);
reqVO.setCabinetId(null);
reqVO.setCabinetName(null);
reqVO.setRecordId(null);
reqVO.setCompanyId(null);
reqVO.setCompany(null);
reqVO.setYear(null);
reqVO.setPeriod(null);
reqVO.setManegeName(null);
reqVO.setCaseNum(null);
reqVO.setCatalogNum(null);
reqVO.setFilesNum(null);
reqVO.setFlowId(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setStatus(null);
reqVO.setRemark(null);
reqVO.setPackageTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setDeptId(null);
reqVO.setUserId(null);
reqVO.setDeptName(null);
reqVO.setCreateBy(null);
reqVO.setCodeUrl(null);
reqVO.setCodeValue(null);
reqVO.setPackageNum(null);
// 调用
PageResult<PackagesDO> pageResult = packagesService.getPackagesPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbPackages, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetPackagesList() {
// mock 数据
PackagesDO dbPackages = randomPojo(PackagesDO.class, o -> { // 等会查询到
o.setDepotId(null);
o.setDepotName(null);
o.setCabinetId(null);
o.setCabinetName(null);
o.setRecordId(null);
o.setCompanyId(null);
o.setCompany(null);
o.setYear(null);
o.setPeriod(null);
o.setManegeName(null);
o.setCaseNum(null);
o.setCatalogNum(null);
o.setFilesNum(null);
o.setFlowId(null);
o.setCreateTime(null);
o.setStatus(null);
o.setRemark(null);
o.setPackageTime(null);
o.setDeptId(null);
o.setUserId(null);
o.setDeptName(null);
o.setCreateBy(null);
o.setCodeUrl(null);
o.setCodeValue(null);
o.setPackageNum(null);
});
packagesMapper.insert(dbPackages);
// 测试 depotId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setDepotId(null)));
// 测试 depotName 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setDepotName(null)));
// 测试 cabinetId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCabinetId(null)));
// 测试 cabinetName 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCabinetName(null)));
// 测试 recordId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setRecordId(null)));
// 测试 companyId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCompanyId(null)));
// 测试 company 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCompany(null)));
// 测试 year 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setYear(null)));
// 测试 period 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setPeriod(null)));
// 测试 manegeName 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setManegeName(null)));
// 测试 caseNum 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCaseNum(null)));
// 测试 catalogNum 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCatalogNum(null)));
// 测试 filesNum 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setFilesNum(null)));
// 测试 flowId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setFlowId(null)));
// 测试 createTime 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCreateTime(null)));
// 测试 status 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setStatus(null)));
// 测试 remark 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setRemark(null)));
// 测试 packageTime 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setPackageTime(null)));
// 测试 deptId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setDeptId(null)));
// 测试 userId 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setUserId(null)));
// 测试 deptName 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setDeptName(null)));
// 测试 createBy 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCreateBy(null)));
// 测试 codeUrl 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCodeUrl(null)));
// 测试 codeValue 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setCodeValue(null)));
// 测试 packageNum 不匹配
packagesMapper.insert(cloneIgnoreId(dbPackages, o -> o.setPackageNum(null)));
// 准备参数
PackagesExportReqVO reqVO = new PackagesExportReqVO();
reqVO.setDepotId(null);
reqVO.setDepotName(null);
reqVO.setCabinetId(null);
reqVO.setCabinetName(null);
reqVO.setRecordId(null);
reqVO.setCompanyId(null);
reqVO.setCompany(null);
reqVO.setYear(null);
reqVO.setPeriod(null);
reqVO.setManegeName(null);
reqVO.setCaseNum(null);
reqVO.setCatalogNum(null);
reqVO.setFilesNum(null);
reqVO.setFlowId(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setStatus(null);
reqVO.setRemark(null);
reqVO.setPackageTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setDeptId(null);
reqVO.setUserId(null);
reqVO.setDeptName(null);
reqVO.setCreateBy(null);
reqVO.setCodeUrl(null);
reqVO.setCodeValue(null);
reqVO.setPackageNum(null);
// 调用
List<PackagesDO> list = packagesService.getPackagesList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbPackages, list.get(0));
}
}

@ -103,55 +103,50 @@ public class OrganizationServiceImpl implements OrganizationService {
} }
public List<OrganizationDepotVO> merge(List<OrganizationDepotVO> list) { public List<OrganizationDepotVO> merge(List<OrganizationDepotVO> list) {
List<OrganizationDepotVO> result = new ArrayList<>(); Map<Long, OrganizationDepotVO> organizationMap = new HashMap<>();
Map<Long, OrganizationDepotVO> map = new HashMap<>();
for (OrganizationDepotVO vo : list) { for (OrganizationDepotVO vo : list) {
Long id = vo.getOrganizationId(); Long id = vo.getOrganizationId();
if (!map.containsKey(id)) { if (!organizationMap.containsKey(id)) {
map.put(id, vo); OrganizationDepotVO newOrganization = new OrganizationDepotVO();
result.add(vo); newOrganization.setOrganizationId(id);
newOrganization.setOrganizationName(vo.getOrganizationName());
newOrganization.setOrganizationCode(vo.getOrganizationCode());
if (vo.getChildren()!=null) {
newOrganization.setChildren(vo.getChildren());
}
organizationMap.put(id, newOrganization);
} else { } else {
OrganizationDepotVO existing = map.get(id); OrganizationDepotVO existing = organizationMap.get(id);
existing.getChildren().addAll(vo.getChildren()); if (vo.getChildren()!=null) {
existing.setChildren(vo.getChildren());
} }
} }
// 合并 children 中相同 depotId 的数据 }
List<OrganizationDepotVO> result = new ArrayList<>(organizationMap.values());
for (OrganizationDepotVO vo : result) { for (OrganizationDepotVO vo : result) {
if (vo.getChildren()!=null) {
mergeChildren(vo.getChildren()); mergeChildren(vo.getChildren());
} }
}
return result; return result;
} }
private void mergeChildren(List<DepotVo> children) { private void mergeChildren(List<DepotVo> children) {
Map<Long, DepotVo> map = new HashMap<>(); Map<Long, DepotVo> map = new HashMap<>();
List<DepotVo> newChildren = new ArrayList<>();
for (DepotVo vo : children) { for (DepotVo vo : children) {
Long id = vo.getDepotId(); Long id = vo.getDepotId();
if (!map.containsKey(id)) { if (!map.containsKey(id)) {
map.put(id, vo); map.put(id, vo);
newChildren.add(vo); } else {
}else {
DepotVo existing = map.get(id); DepotVo existing = map.get(id);
existing.getChildren().addAll(vo.getChildren()); if (vo.getChildren()!=null) {
existing.setChildren(vo.getChildren());
} }
} }
children.clear();
children.addAll(newChildren);
for (DepotVo depotVo : children){
removeDuplicate(depotVo.getChildren());
}
} }
children.clear();
public List<DepotCabinetVo> removeDuplicate(List<DepotCabinetVo> list) { children.addAll(map.values());
Set<Long> set = new HashSet<>();
Iterator<DepotCabinetVo> it = list.iterator();
while (it.hasNext()) {
DepotCabinetVo vo = it.next();
if (!set.add(vo.getCabinetId())) {
it.remove();
}
}
return list;
} }

Loading…
Cancel
Save