From e6395c38289c12e6866d5c245a206e5239b06ec2 Mon Sep 17 00:00:00 2001 From: wangxy <1481820854@qq.com> Date: Wed, 21 May 2025 08:54:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=84=E7=90=86=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../archiveUtil/ExcelUtilArchive$1.java | 10 +- .../archive/common/convert/ExcelToPdf.java | 286 +-- .../archive/common/utils/ExceptionUtil.java | 82 +- .../archive/common/utils/html/EscapeUtil.java | 310 +-- .../archive/common/utils/poi/ExcelUtil.java | 2244 ++++++++--------- .../config/properties/DruidProperties.java | 154 +- .../datasource/DynamicDataSource.java | 52 +- .../DynamicDataSourceContextHolder.java | 90 +- .../framework/web/service/DictService.java | 92 +- .../controller/DocumentController.java | 216 +- .../project/document/domain/Document.java | 274 +- .../service/impl/DocumentServiceImpl.java | 412 +-- .../monitor/druid/DruidController.java | 52 +- .../system/dept/service/DeptServiceImpl.java | 806 +++--- .../dict/controller/DictDataController.java | 234 +- .../dict/controller/DictTypeController.java | 370 +-- .../project/system/dict/domain/DictData.java | 352 +-- .../project/system/dict/domain/DictType.java | 210 +- .../dict/service/DictDataServiceImpl.java | 282 +-- .../dict/service/DictTypeServiceImpl.java | 544 ++-- .../project/system/dict/utils/DictUtils.java | 362 +-- .../project/ycts/ExceptionInfoController.java | 58 +- 22 files changed, 3746 insertions(+), 3746 deletions(-) diff --git a/src/main/java/com/archive/common/archiveUtil/ExcelUtilArchive$1.java b/src/main/java/com/archive/common/archiveUtil/ExcelUtilArchive$1.java index 824edf6..7c87c36 100644 --- a/src/main/java/com/archive/common/archiveUtil/ExcelUtilArchive$1.java +++ b/src/main/java/com/archive/common/archiveUtil/ExcelUtilArchive$1.java @@ -1,8 +1,8 @@ -/* */ package com.archive.common.archiveUtil; -/* */ -/* */ import com.archive.common.archiveUtil.ExcelUtilArchive; -/* */ import org.apache.poi.ss.usermodel.CellType; -/* */ + package com.archive.common.archiveUtil; + + import com.archive.common.archiveUtil.ExcelUtilArchive; + import org.apache.poi.ss.usermodel.CellType; + /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\archiveUtil\ExcelUtilArchive$1.class diff --git a/src/main/java/com/archive/common/convert/ExcelToPdf.java b/src/main/java/com/archive/common/convert/ExcelToPdf.java index 713af5c..6fb74bc 100644 --- a/src/main/java/com/archive/common/convert/ExcelToPdf.java +++ b/src/main/java/com/archive/common/convert/ExcelToPdf.java @@ -1,146 +1,146 @@ -/* */ package com.archive.common.convert; -/* */ -/* */ import com.aspose.cells.IndividualFontConfigs; -/* */ import com.aspose.cells.License; -/* */ import com.aspose.cells.LoadOptions; -/* */ import com.aspose.cells.PdfSaveOptions; -/* */ import com.aspose.cells.SaveOptions; -/* */ import com.aspose.cells.Workbook; -/* */ import java.io.ByteArrayInputStream; -/* */ import java.io.FileOutputStream; -/* */ import java.io.InputStream; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class ExcelToPdf -/* */ { -/* */ public static void main(String[] args) { -/* 20 */ excel2pdf("D:\\temp\\1.xls", "D:\\temp\\31.pdf"); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ public static boolean getLicense() { -/* 27 */ boolean result = false; -/* */ try { -/* 29 */ String license = "\r\n \r\n \r\n Aspose.Total for Java\r\n Aspose.Words for Java\r\n \r\n Enterprise\r\n 20991231\r\n 20991231\r\n 8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7\r\n \r\n sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=\r\n"; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* 43 */ InputStream is = new ByteArrayInputStream(license.getBytes("UTF-8")); -/* 44 */ License aposeLic = new License(); -/* 45 */ aposeLic.setLicense(is); -/* 46 */ result = true; -/* 47 */ } catch (Exception e) { -/* 48 */ e.printStackTrace(); -/* */ } -/* 50 */ return result; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void excel2pdf(String sourceFilePath, String desFilePathd) { -/* 60 */ if (!getLicense()) { -/* */ return; -/* */ } -/* */ try { -/* 64 */ if (isLinux()) { -/* 65 */ IndividualFontConfigs configs = new IndividualFontConfigs(); -/* 66 */ configs.setFontFolder("/usr/share/fonts/chinese", true); -/* 67 */ LoadOptions loadOptions = new LoadOptions(); -/* 68 */ loadOptions.setFontConfigs(configs); -/* */ } -/* */ -/* */ -/* */ -/* 73 */ Workbook wb = new Workbook(sourceFilePath); -/* */ -/* 75 */ FileOutputStream fileOS = new FileOutputStream(desFilePathd); -/* 76 */ PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); -/* 77 */ pdfSaveOptions.setOnePagePerSheet(true); -/* 78 */ int[] autoDrawSheets = { 3 }; -/* */ -/* 80 */ autoDraw(wb, autoDrawSheets); -/* 81 */ int[] showSheets = { 0 }; -/* */ -/* 83 */ printSheetPage(wb, showSheets); -/* 84 */ wb.save(fileOS, (SaveOptions)pdfSaveOptions); -/* 85 */ fileOS.flush(); -/* 86 */ fileOS.close(); -/* */ } -/* 88 */ catch (Exception e) { -/* 89 */ e.printStackTrace(); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void autoDraw(Workbook wb, int[] page) { -/* 99 */ if (null != page && page.length > 0) { -/* 100 */ for (int i = 0; i < page.length; i++) { -/* 101 */ wb.getWorksheets().get(i).getHorizontalPageBreaks().clear(); -/* 102 */ wb.getWorksheets().get(i).getVerticalPageBreaks().clear(); -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void printSheetPage(Workbook wb, int[] page) { -/* */ int i; -/* 114 */ for (i = 1; i < wb.getWorksheets().getCount(); i++) { -/* 115 */ wb.getWorksheets().get(i).setVisible(false); -/* */ } -/* 117 */ if (null == page || page.length == 0) { -/* 118 */ wb.getWorksheets().get(0).setVisible(true); -/* */ } else { -/* 120 */ for (i = 0; i < page.length; i++) { -/* 121 */ wb.getWorksheets().get(i).setVisible(true); -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ public static boolean isLinux() { -/* 128 */ return System.getProperty("os.name").toLowerCase().contains("linux"); -/* */ } -/* */ -/* */ public static boolean isWindows() { -/* 132 */ return System.getProperty("os.name").toLowerCase().contains("windows"); -/* */ } -/* */ -/* */ public String JudgeSystem() { -/* 136 */ if (isLinux()) -/* 137 */ return "linux"; -/* 138 */ if (isWindows()) { -/* 139 */ return "windows"; -/* */ } -/* 141 */ return "other system"; -/* */ } -/* */ } + package com.archive.common.convert; + + import com.aspose.cells.IndividualFontConfigs; + import com.aspose.cells.License; + import com.aspose.cells.LoadOptions; + import com.aspose.cells.PdfSaveOptions; + import com.aspose.cells.SaveOptions; + import com.aspose.cells.Workbook; + import java.io.ByteArrayInputStream; + import java.io.FileOutputStream; + import java.io.InputStream; + + + + + + public class ExcelToPdf + { + public static void main(String[] args) { + excel2pdf("D:\\temp\\1.xls", "D:\\temp\\31.pdf"); + } + + + + + public static boolean getLicense() { + boolean result = false; + try { + String license = "\r\n \r\n \r\n Aspose.Total for Java\r\n Aspose.Words for Java\r\n \r\n Enterprise\r\n 20991231\r\n 20991231\r\n 8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7\r\n \r\n sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=\r\n"; + + + + + + + + + + + + + + InputStream is = new ByteArrayInputStream(license.getBytes("UTF-8")); + License aposeLic = new License(); + aposeLic.setLicense(is); + result = true; + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + + + + + + + public static void excel2pdf(String sourceFilePath, String desFilePathd) { + if (!getLicense()) { + return; + } + try { + if (isLinux()) { + IndividualFontConfigs configs = new IndividualFontConfigs(); + configs.setFontFolder("/usr/share/fonts/chinese", true); + LoadOptions loadOptions = new LoadOptions(); + loadOptions.setFontConfigs(configs); + } + + + + Workbook wb = new Workbook(sourceFilePath); + + FileOutputStream fileOS = new FileOutputStream(desFilePathd); + PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); + pdfSaveOptions.setOnePagePerSheet(true); + int[] autoDrawSheets = { 3 }; + + autoDraw(wb, autoDrawSheets); + int[] showSheets = { 0 }; + + printSheetPage(wb, showSheets); + wb.save(fileOS, (SaveOptions)pdfSaveOptions); + fileOS.flush(); + fileOS.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + + + + + + public static void autoDraw(Workbook wb, int[] page) { + if (null != page && page.length > 0) { + for (int i = 0; i < page.length; i++) { + wb.getWorksheets().get(i).getHorizontalPageBreaks().clear(); + wb.getWorksheets().get(i).getVerticalPageBreaks().clear(); + } + } + } + + + + + + + public static void printSheetPage(Workbook wb, int[] page) { + int i; + for (i = 1; i < wb.getWorksheets().getCount(); i++) { + wb.getWorksheets().get(i).setVisible(false); + } + if (null == page || page.length == 0) { + wb.getWorksheets().get(0).setVisible(true); + } else { + for (i = 0; i < page.length; i++) { + wb.getWorksheets().get(i).setVisible(true); + } + } + } + + + public static boolean isLinux() { + return System.getProperty("os.name").toLowerCase().contains("linux"); + } + + public static boolean isWindows() { + return System.getProperty("os.name").toLowerCase().contains("windows"); + } + + public String JudgeSystem() { + if (isLinux()) + return "linux"; + if (isWindows()) { + return "windows"; + } + return "other system"; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\convert\ExcelToPdf.class diff --git a/src/main/java/com/archive/common/utils/ExceptionUtil.java b/src/main/java/com/archive/common/utils/ExceptionUtil.java index 13f46bd..51b30f2 100644 --- a/src/main/java/com/archive/common/utils/ExceptionUtil.java +++ b/src/main/java/com/archive/common/utils/ExceptionUtil.java @@ -1,45 +1,45 @@ -/* */ package com.archive.common.utils + package com.archive.common.utils ; -/* */ -/* */ import com.archive.common.utils.StringUtils; -/* */ import java.io.PrintWriter; -/* */ import java.io.StringWriter; -/* */ import org.apache.commons.lang3.exception.ExceptionUtils; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class ExceptionUtil -/* */ { -/* */ public static String getExceptionMessage(Throwable e) { -/* 20 */ StringWriter sw = new StringWriter(); -/* 21 */ e.printStackTrace(new PrintWriter(sw, true)); -/* 22 */ String str = sw.toString(); -/* 23 */ return str; -/* */ } -/* */ -/* */ -/* */ public static String getRootErrorMseeage(Exception e) { -/* 28 */ Throwable root = ExceptionUtils.getRootCause(e); -/* 29 */ root = (root == null) ? e : root; -/* 30 */ if (root == null) -/* */ { -/* 32 */ return ""; -/* */ } -/* 34 */ String msg = root.getMessage(); -/* 35 */ if (msg == null) -/* */ { -/* 37 */ return "null"; -/* */ } -/* 39 */ return StringUtils.defaultString(msg); -/* */ } -/* */ } + + import com.archive.common.utils.StringUtils; + import java.io.PrintWriter; + import java.io.StringWriter; + import org.apache.commons.lang3.exception.ExceptionUtils; + + + + + + + + + + + public class ExceptionUtil + { + public static String getExceptionMessage(Throwable e) { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw, true)); + String str = sw.toString(); + return str; + } + + + public static String getRootErrorMseeage(Exception e) { + Throwable root = ExceptionUtils.getRootCause(e); + root = (root == null) ? e : root; + if (root == null) + { + return ""; + } + String msg = root.getMessage(); + if (msg == null) + { + return "null"; + } + return StringUtils.defaultString(msg); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\ExceptionUtil.class diff --git a/src/main/java/com/archive/common/utils/html/EscapeUtil.java b/src/main/java/com/archive/common/utils/html/EscapeUtil.java index 098441f..bd88bb8 100644 --- a/src/main/java/com/archive/common/utils/html/EscapeUtil.java +++ b/src/main/java/com/archive/common/utils/html/EscapeUtil.java @@ -1,158 +1,158 @@ -/* */ package com.archive.common.utils.html; -/* */ -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.common.utils.html.HTMLFilter; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class EscapeUtil -/* */ { -/* */ public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)"; -/* 14 */ private static final char[][] TEXT = new char[64][]; -/* */ -/* */ -/* */ static { -/* 18 */ for (int i = 0; i < 64; i++) { -/* */ -/* 20 */ (new char[1])[0] = (char)i; TEXT[i] = new char[1]; -/* */ } -/* */ -/* */ -/* 24 */ TEXT[39] = "'".toCharArray(); -/* 25 */ TEXT[34] = """.toCharArray(); -/* 26 */ TEXT[38] = "&".toCharArray(); -/* 27 */ TEXT[60] = "<".toCharArray(); -/* 28 */ TEXT[62] = ">".toCharArray(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String escape(String text) { -/* 39 */ return encode(text); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String unescape(String content) { -/* 50 */ return decode(content); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String clean(String content) { -/* 61 */ return (new HTMLFilter()).filter(content); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private static String encode(String text) { -/* */ int len; -/* 73 */ if (text == null || (len = text.length()) == 0) -/* */ { -/* 75 */ return ""; -/* */ } -/* 77 */ StringBuilder buffer = new StringBuilder(len + (len >> 2)); -/* */ -/* 79 */ for (int i = 0; i < len; i++) { -/* */ -/* 81 */ char c = text.charAt(i); -/* 82 */ if (c < '@') { -/* */ -/* 84 */ buffer.append(TEXT[c]); -/* */ } -/* */ else { -/* */ -/* 88 */ buffer.append(c); -/* */ } -/* */ } -/* 91 */ return buffer.toString(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String decode(String content) { -/* 102 */ if (StringUtils.isEmpty(content)) -/* */ { -/* 104 */ return content; -/* */ } -/* */ -/* 107 */ StringBuilder tmp = new StringBuilder(content.length()); -/* 108 */ int lastPos = 0, pos = 0; -/* */ -/* 110 */ while (lastPos < content.length()) { -/* */ -/* 112 */ pos = content.indexOf("%", lastPos); -/* 113 */ if (pos == lastPos) { -/* */ -/* 115 */ if (content.charAt(pos + 1) == 'u') { -/* */ -/* 117 */ char c = (char)Integer.parseInt(content.substring(pos + 2, pos + 6), 16); -/* 118 */ tmp.append(c); -/* 119 */ lastPos = pos + 6; -/* */ -/* */ continue; -/* */ } -/* 123 */ char ch = (char)Integer.parseInt(content.substring(pos + 1, pos + 3), 16); -/* 124 */ tmp.append(ch); -/* 125 */ lastPos = pos + 3; -/* */ -/* */ continue; -/* */ } -/* */ -/* 130 */ if (pos == -1) { -/* */ -/* 132 */ tmp.append(content.substring(lastPos)); -/* 133 */ lastPos = content.length(); -/* */ -/* */ continue; -/* */ } -/* 137 */ tmp.append(content.substring(lastPos, pos)); -/* 138 */ lastPos = pos; -/* */ } -/* */ -/* */ -/* 142 */ return tmp.toString(); -/* */ } -/* */ -/* */ -/* */ public static void main(String[] args) { -/* 147 */ String html = ""; -/* */ -/* */ -/* */ -/* 151 */ System.out.println(clean(html)); -/* 152 */ System.out.println(escape(html)); -/* 153 */ System.out.println(unescape(html)); -/* */ } -/* */ } + package com.archive.common.utils.html; + + import com.archive.common.utils.StringUtils; + import com.archive.common.utils.html.HTMLFilter; + + + + + + + public class EscapeUtil + { + public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)"; + private static final char[][] TEXT = new char[64][]; + + + static { + for (int i = 0; i < 64; i++) { + + (new char[1])[0] = (char)i; TEXT[i] = new char[1]; + } + + + TEXT[39] = "'".toCharArray(); + TEXT[34] = """.toCharArray(); + TEXT[38] = "&".toCharArray(); + TEXT[60] = "<".toCharArray(); + TEXT[62] = ">".toCharArray(); + } + + + + + + + + + public static String escape(String text) { + return encode(text); + } + + + + + + + + + public static String unescape(String content) { + return decode(content); + } + + + + + + + + + public static String clean(String content) { + return (new HTMLFilter()).filter(content); + } + + + + + + + + + private static String encode(String text) { + int len; + if (text == null || (len = text.length()) == 0) + { + return ""; + } + StringBuilder buffer = new StringBuilder(len + (len >> 2)); + + for (int i = 0; i < len; i++) { + + char c = text.charAt(i); + if (c < '@') { + + buffer.append(TEXT[c]); + } + else { + + buffer.append(c); + } + } + return buffer.toString(); + } + + + + + + + + + public static String decode(String content) { + if (StringUtils.isEmpty(content)) + { + return content; + } + + StringBuilder tmp = new StringBuilder(content.length()); + int lastPos = 0, pos = 0; + + while (lastPos < content.length()) { + + pos = content.indexOf("%", lastPos); + if (pos == lastPos) { + + if (content.charAt(pos + 1) == 'u') { + + char c = (char)Integer.parseInt(content.substring(pos + 2, pos + 6), 16); + tmp.append(c); + lastPos = pos + 6; + + continue; + } + char ch = (char)Integer.parseInt(content.substring(pos + 1, pos + 3), 16); + tmp.append(ch); + lastPos = pos + 3; + + continue; + } + + if (pos == -1) { + + tmp.append(content.substring(lastPos)); + lastPos = content.length(); + + continue; + } + tmp.append(content.substring(lastPos, pos)); + lastPos = pos; + } + + + return tmp.toString(); + } + + + public static void main(String[] args) { + String html = ""; + + + + System.out.println(clean(html)); + System.out.println(escape(html)); + System.out.println(unescape(html)); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\html\EscapeUtil.class diff --git a/src/main/java/com/archive/common/utils/poi/ExcelUtil.java b/src/main/java/com/archive/common/utils/poi/ExcelUtil.java index 0e1946f..724b661 100644 --- a/src/main/java/com/archive/common/utils/poi/ExcelUtil.java +++ b/src/main/java/com/archive/common/utils/poi/ExcelUtil.java @@ -1,1127 +1,1127 @@ -/* */ package com.archive.common.utils.poi; -/* */ -/* */ import com.archive.common.exception.BusinessException; -/* */ import com.archive.common.utils.DateUtils; -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.common.utils.file.FileTypeUtils; -/* */ import com.archive.common.utils.file.ImageUtils; -/* */ import com.archive.common.utils.reflect.ReflectUtils; -/* */ import com.archive.common.utils.text.Convert; -/* */ import com.archive.framework.aspectj.lang.annotation.ColumnType; + package com.archive.common.utils.poi; + + import com.archive.common.exception.BusinessException; + import com.archive.common.utils.DateUtils; + import com.archive.common.utils.StringUtils; + import com.archive.common.utils.file.FileTypeUtils; + import com.archive.common.utils.file.ImageUtils; + import com.archive.common.utils.reflect.ReflectUtils; + import com.archive.common.utils.text.Convert; + import com.archive.framework.aspectj.lang.annotation.ColumnType; import com.archive.framework.aspectj.lang.annotation.Excel; -/* */ import com.archive.framework.aspectj.lang.annotation.Excels; -/* */ import com.archive.framework.aspectj.lang.annotation.Type; + import com.archive.framework.aspectj.lang.annotation.Excels; + import com.archive.framework.aspectj.lang.annotation.Type; import com.archive.framework.config.ArchiveConfig; -/* */ import com.archive.framework.web.domain.AjaxResult; -/* */ import com.archive.project.system.dict.utils.DictUtils; -/* */ import java.io.File; -/* */ import java.io.FileOutputStream; -/* */ import java.io.IOException; -/* */ import java.io.InputStream; -/* */ import java.io.OutputStream; -/* */ import java.lang.reflect.Field; -/* */ import java.math.BigDecimal; -/* */ import java.text.DecimalFormat; -/* */ import java.util.ArrayList; -/* */ import java.util.Arrays; -/* */ import java.util.Comparator; -/* */ import java.util.Date; -/* */ import java.util.HashMap; -/* */ import java.util.List; -/* */ import java.util.Map; -/* */ import java.util.Set; -/* */ import java.util.UUID; -/* */ import java.util.stream.Collectors; -/* */ import org.apache.poi.ss.usermodel.BorderStyle; -/* */ import org.apache.poi.ss.usermodel.Cell; -/* */ import org.apache.poi.ss.usermodel.CellStyle; -/* */ import org.apache.poi.ss.usermodel.CellType; -/* */ import org.apache.poi.ss.usermodel.ClientAnchor; -/* */ import org.apache.poi.ss.usermodel.DataValidation; -/* */ import org.apache.poi.ss.usermodel.DataValidationConstraint; -/* */ import org.apache.poi.ss.usermodel.DataValidationHelper; -/* */ import org.apache.poi.ss.usermodel.DateUtil; -/* */ import org.apache.poi.ss.usermodel.Drawing; -/* */ import org.apache.poi.ss.usermodel.FillPatternType; -/* */ import org.apache.poi.ss.usermodel.Font; -/* */ import org.apache.poi.ss.usermodel.HorizontalAlignment; -/* */ import org.apache.poi.ss.usermodel.IndexedColors; -/* */ import org.apache.poi.ss.usermodel.Row; -/* */ import org.apache.poi.ss.usermodel.Sheet; -/* */ import org.apache.poi.ss.usermodel.VerticalAlignment; -/* */ import org.apache.poi.ss.usermodel.Workbook; -/* */ import org.apache.poi.ss.usermodel.WorkbookFactory; -/* */ import org.apache.poi.ss.util.CellRangeAddressList; -/* */ import org.apache.poi.xssf.streaming.SXSSFWorkbook; -/* */ import org.apache.poi.xssf.usermodel.XSSFClientAnchor; -/* */ import org.slf4j.Logger; -/* */ import org.slf4j.LoggerFactory; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class ExcelUtil -/* */ { -/* 68 */ private static final Logger log = LoggerFactory.getLogger(com.archive.common.utils.poi.ExcelUtil.class); -/* */ -/* */ -/* */ -/* */ -/* */ public static final int sheetSize = 65536; -/* */ -/* */ -/* */ -/* */ -/* */ private String sheetName; -/* */ -/* */ -/* */ -/* */ -/* */ private Type type; -/* */ -/* */ -/* */ -/* */ -/* */ private Workbook wb; -/* */ -/* */ -/* */ -/* */ -/* */ private Sheet sheet; -/* */ -/* */ -/* */ -/* */ -/* */ private Map styles; -/* */ -/* */ -/* */ -/* */ -/* */ private List list; -/* */ -/* */ -/* */ -/* */ -/* */ private List fields; -/* */ -/* */ -/* */ -/* */ -/* */ private short maxHeight; -/* */ -/* */ -/* */ -/* */ -/* 118 */ private Map statistics = new HashMap<>(); -/* */ -/* */ -/* */ -/* */ -/* 123 */ private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00"); -/* */ -/* */ -/* */ -/* */ public Class clazz; -/* */ -/* */ -/* */ -/* */ public ExcelUtil(Class clazz) { -/* 132 */ this.clazz = clazz; -/* */ } -/* */ -/* */ -/* */ public void init(List list, String sheetName, Type type) { -/* 137 */ if (list == null) -/* */ { -/* 139 */ list = new ArrayList<>(); -/* */ } -/* 141 */ this.list = list; -/* 142 */ this.sheetName = sheetName; -/* 143 */ this.type = type; -/* 144 */ createExcelField(); -/* 145 */ createWorkbook(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public List importExcel(InputStream is) throws Exception { -/* 156 */ return importExcel("", is); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public List importExcel(String sheetName, InputStream is) throws Exception { -/* 168 */ this.type = Type.IMPORT; -/* 169 */ this.wb = WorkbookFactory.create(is); -/* 170 */ List list = new ArrayList<>(); -/* 171 */ Sheet sheet = null; -/* 172 */ if (StringUtils.isNotEmpty(sheetName)) { -/* */ -/* */ -/* 175 */ sheet = this.wb.getSheet(sheetName); -/* */ -/* */ } -/* */ else { -/* */ -/* 180 */ sheet = this.wb.getSheetAt(0); -/* */ } -/* */ -/* 183 */ if (sheet == null) -/* */ { -/* 185 */ throw new IOException("文件sheet不存在"); -/* */ } -/* */ -/* */ -/* 189 */ int rows = sheet.getLastRowNum(); -/* */ -/* 191 */ if (rows > 0) { -/* */ -/* */ -/* 194 */ Map cellMap = new HashMap<>(); -/* */ -/* 196 */ Row heard = sheet.getRow(0); -/* 197 */ for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) { -/* */ -/* 199 */ Cell cell = heard.getCell(i); -/* 200 */ if (StringUtils.isNotNull(cell)) { -/* */ -/* 202 */ String value = getCellValue(heard, i).toString(); -/* 203 */ cellMap.put(value, Integer.valueOf(i)); -/* */ } -/* */ else { -/* */ -/* 207 */ cellMap.put(null, Integer.valueOf(i)); -/* */ } -/* */ } -/* */ -/* 211 */ Field[] allFields = this.clazz.getDeclaredFields(); -/* */ -/* 213 */ Map fieldsMap = new HashMap<>(); -/* 214 */ for (int col = 0; col < allFields.length; col++) { -/* */ -/* 216 */ Field field = allFields[col]; -/* 217 */ Excel attr = field.getAnnotation(Excel.class); -/* 218 */ if (attr != null && (attr.type() == Type.ALL || attr.type() == this.type)) { -/* */ -/* */ -/* 221 */ field.setAccessible(true); -/* 222 */ Integer column = cellMap.get(attr.name()); -/* 223 */ if (column != null) -/* */ { -/* 225 */ fieldsMap.put(column, field); -/* */ } -/* */ } -/* */ } -/* 229 */ for (int j = 1; j <= rows; j++) { -/* */ -/* */ -/* 232 */ Row row = sheet.getRow(j); -/* */ -/* 234 */ if (!isRowEmpty(row)) { -/* */ -/* */ -/* */ -/* 238 */ T entity = null; -/* 239 */ for (Map.Entry entry : fieldsMap.entrySet()) { -/* */ -/* 241 */ Object val = getCellValue(row, ((Integer)entry.getKey()).intValue()); -/* */ -/* */ -/* 244 */ entity = (entity == null) ? this.clazz.newInstance() : entity; -/* */ -/* 246 */ Field field = fieldsMap.get(entry.getKey()); -/* */ -/* 248 */ Class fieldType = field.getType(); -/* 249 */ if (String.class == fieldType) { -/* */ -/* 251 */ String s = Convert.toStr(val); -/* 252 */ if (StringUtils.endsWith(s, ".0")) { -/* */ -/* 254 */ val = StringUtils.substringBefore(s, ".0"); -/* */ } -/* */ else { -/* */ -/* 258 */ String dateFormat = ((Excel)field.getAnnotation(Excel.class)).dateFormat(); -/* 259 */ if (StringUtils.isNotEmpty(dateFormat)) -/* */ { -/* 261 */ val = DateUtils.parseDateToStr(dateFormat, (Date)val); -/* */ } -/* */ else -/* */ { -/* 265 */ val = Convert.toStr(val); -/* */ } -/* */ -/* */ } -/* 269 */ } else if ((int.class == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) { -/* */ -/* 271 */ val = Convert.toInt(val); -/* */ } -/* 273 */ else if (long.class == fieldType || Long.class == fieldType) { -/* */ -/* 275 */ val = Convert.toLong(val); -/* */ } -/* 277 */ else if (double.class == fieldType || Double.class == fieldType) { -/* */ -/* 279 */ val = Convert.toDouble(val); -/* */ } -/* 281 */ else if (float.class == fieldType || Float.class == fieldType) { -/* */ -/* 283 */ val = Convert.toFloat(val); -/* */ } -/* 285 */ else if (BigDecimal.class == fieldType) { -/* */ -/* 287 */ val = Convert.toBigDecimal(val); -/* */ } -/* 289 */ else if (Date.class == fieldType) { -/* */ -/* 291 */ if (val instanceof String) -/* */ { -/* 293 */ val = DateUtils.parseDate(val); -/* */ } -/* 295 */ else if (val instanceof Double) -/* */ { -/* 297 */ val = DateUtil.getJavaDate(((Double)val).doubleValue()); -/* */ } -/* */ -/* 300 */ } else if (boolean.class == fieldType || Boolean.class == fieldType) { -/* */ -/* 302 */ val = Convert.toBool(val, Boolean.valueOf(false)); -/* */ } -/* 304 */ if (StringUtils.isNotNull(fieldType)) { -/* */ -/* 306 */ Excel attr = field.getAnnotation(Excel.class); -/* 307 */ String propertyName = field.getName(); -/* 308 */ if (StringUtils.isNotEmpty(attr.targetAttr())) { -/* */ -/* 310 */ propertyName = field.getName() + "." + attr.targetAttr(); -/* */ } -/* 312 */ else if (StringUtils.isNotEmpty(attr.readConverterExp())) { -/* */ -/* 314 */ val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator()); -/* */ } -/* 316 */ else if (StringUtils.isNotEmpty(attr.dictType())) { -/* */ -/* 318 */ val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator()); -/* */ } -/* 320 */ ReflectUtils.invokeSetter(entity, propertyName, val); -/* */ } -/* */ } -/* 323 */ list.add(entity); -/* */ } -/* */ } -/* 326 */ } return list; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public AjaxResult exportExcel(List list, String sheetName) { -/* 338 */ init(list, sheetName, Type.EXPORT); -/* 339 */ return exportExcel(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public AjaxResult importTemplateExcel(String sheetName) { -/* 350 */ init(null, sheetName, Type.IMPORT); -/* 351 */ return exportExcel(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public AjaxResult exportExcel() { -/* 361 */ OutputStream out = null; -/* */ -/* */ -/* */ try { -/* 365 */ double sheetNo = Math.ceil((this.list.size() / 65536)); -/* 366 */ for (int index = 0; index <= sheetNo; index++) { -/* */ -/* 368 */ createSheet(sheetNo, index); -/* */ -/* */ -/* 371 */ Row row = this.sheet.createRow(0); -/* 372 */ int column = 0; -/* */ -/* 374 */ for (Object[] os : this.fields) { -/* */ -/* 376 */ Excel excel = (Excel)os[1]; -/* 377 */ createCell(excel, row, column++); -/* */ } -/* 379 */ if (Type.EXPORT.equals(this.type)) { -/* */ -/* 381 */ fillExcelData(index, row); -/* 382 */ addStatisticsRow(); -/* */ } -/* */ } -/* 385 */ String filename = encodingFilename(this.sheetName); -/* 386 */ out = new FileOutputStream(getAbsoluteFile(filename)); -/* 387 */ this.wb.write(out); -/* 388 */ return AjaxResult.success(filename); -/* */ } -/* 390 */ catch (Exception e) { -/* */ -/* 392 */ log.error("导出Excel异常{}", e.getMessage()); -/* 393 */ throw new BusinessException("导出Excel失败,请联系网站管理员!"); -/* */ } -/* */ finally { -/* */ -/* 397 */ if (this.wb != null) { -/* */ -/* */ try { -/* */ -/* 401 */ this.wb.close(); -/* */ } -/* 403 */ catch (IOException e1) { -/* */ -/* 405 */ e1.printStackTrace(); -/* */ } -/* */ } -/* 408 */ if (out != null) { -/* */ -/* */ try { -/* */ -/* 412 */ out.close(); -/* */ } -/* 414 */ catch (IOException e1) { -/* */ -/* 416 */ e1.printStackTrace(); -/* */ } -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void fillExcelData(int index, Row row) { -/* 430 */ int startNo = index * 65536; -/* 431 */ int endNo = Math.min(startNo + 65536, this.list.size()); -/* 432 */ for (int i = startNo; i < endNo; i++) { -/* */ -/* 434 */ row = this.sheet.createRow(i + 1 - startNo); -/* */ -/* 436 */ T vo = this.list.get(i); -/* 437 */ int column = 0; -/* 438 */ for (Object[] os : this.fields) { -/* */ -/* 440 */ Field field = (Field)os[0]; -/* 441 */ Excel excel = (Excel)os[1]; -/* */ -/* 443 */ field.setAccessible(true); -/* 444 */ addCell(excel, row, vo, field, column++); -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private Map createStyles(Workbook wb) { -/* 458 */ Map styles = new HashMap<>(); -/* 459 */ CellStyle style = wb.createCellStyle(); -/* 460 */ style.setAlignment(HorizontalAlignment.CENTER); -/* 461 */ style.setVerticalAlignment(VerticalAlignment.CENTER); -/* 462 */ style.setBorderRight(BorderStyle.THIN); -/* 463 */ style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); -/* 464 */ style.setBorderLeft(BorderStyle.THIN); -/* 465 */ style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); -/* 466 */ style.setBorderTop(BorderStyle.THIN); -/* 467 */ style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); -/* 468 */ style.setBorderBottom(BorderStyle.THIN); -/* 469 */ style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); -/* 470 */ Font dataFont = wb.createFont(); -/* 471 */ dataFont.setFontName("Arial"); -/* 472 */ dataFont.setFontHeightInPoints((short)10); -/* 473 */ style.setFont(dataFont); -/* 474 */ styles.put("data", style); -/* */ -/* 476 */ style = wb.createCellStyle(); -/* 477 */ style.cloneStyleFrom(styles.get("data")); -/* 478 */ style.setAlignment(HorizontalAlignment.CENTER); -/* 479 */ style.setVerticalAlignment(VerticalAlignment.CENTER); -/* 480 */ style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); -/* 481 */ style.setFillPattern(FillPatternType.SOLID_FOREGROUND); -/* 482 */ Font headerFont = wb.createFont(); -/* 483 */ headerFont.setFontName("Arial"); -/* 484 */ headerFont.setFontHeightInPoints((short)10); -/* 485 */ headerFont.setBold(true); -/* 486 */ headerFont.setColor(IndexedColors.WHITE.getIndex()); -/* 487 */ style.setFont(headerFont); -/* 488 */ styles.put("header", style); -/* */ -/* 490 */ style = wb.createCellStyle(); -/* 491 */ style.setAlignment(HorizontalAlignment.CENTER); -/* 492 */ style.setVerticalAlignment(VerticalAlignment.CENTER); -/* 493 */ Font totalFont = wb.createFont(); -/* 494 */ totalFont.setFontName("Arial"); -/* 495 */ totalFont.setFontHeightInPoints((short)10); -/* 496 */ style.setFont(totalFont); -/* 497 */ styles.put("total", style); -/* */ -/* 499 */ style = wb.createCellStyle(); -/* 500 */ style.cloneStyleFrom(styles.get("data")); -/* 501 */ style.setAlignment(HorizontalAlignment.LEFT); -/* 502 */ styles.put("data1", style); -/* */ -/* 504 */ style = wb.createCellStyle(); -/* 505 */ style.cloneStyleFrom(styles.get("data")); -/* 506 */ style.setAlignment(HorizontalAlignment.CENTER); -/* 507 */ styles.put("data2", style); -/* */ -/* 509 */ style = wb.createCellStyle(); -/* 510 */ style.cloneStyleFrom(styles.get("data")); -/* 511 */ style.setAlignment(HorizontalAlignment.RIGHT); -/* 512 */ styles.put("data3", style); -/* */ -/* 514 */ return styles; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public Cell createCell(Excel attr, Row row, int column) { -/* 523 */ Cell cell = row.createCell(column); -/* */ -/* 525 */ cell.setCellValue(attr.name()); -/* 526 */ setDataValidation(attr, row, column); -/* 527 */ cell.setCellStyle(this.styles.get("header")); -/* 528 */ return cell; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void setCellVo(Object value, Excel attr, Cell cell) { -/* 540 */ if (ColumnType.STRING == attr.cellType()) { -/* */ -/* 542 */ cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : (value + attr.suffix())); -/* */ } -/* 544 */ else if (ColumnType.NUMERIC == attr.cellType()) { -/* */ -/* 546 */ cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value).doubleValue() : Convert.toInt(value).intValue()); -/* */ } -/* 548 */ else if (ColumnType.IMAGE == attr.cellType()) { -/* */ -/* */ -/* 551 */ XSSFClientAnchor xSSFClientAnchor = new XSSFClientAnchor(0, 0, 0, 0, (short)cell.getColumnIndex(), cell.getRow().getRowNum(), (short)(cell.getColumnIndex() + 1), cell.getRow().getRowNum() + 1); -/* 552 */ String imagePath = Convert.toStr(value); -/* 553 */ if (StringUtils.isNotEmpty(imagePath)) { -/* */ -/* 555 */ byte[] data = ImageUtils.getImage(imagePath); -/* 556 */ getDrawingPatriarch(cell.getSheet()).createPicture((ClientAnchor)xSSFClientAnchor, cell -/* 557 */ .getSheet().getWorkbook().addPicture(data, getImageType(data))); -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static Drawing getDrawingPatriarch(Sheet sheet) { -/* 567 */ if (sheet.getDrawingPatriarch() == null) -/* */ { -/* 569 */ sheet.createDrawingPatriarch(); -/* */ } -/* 571 */ return sheet.getDrawingPatriarch(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int getImageType(byte[] value) { -/* 579 */ String type = FileTypeUtils.getFileExtendName(value); -/* 580 */ if ("JPG".equalsIgnoreCase(type)) -/* */ { -/* 582 */ return 5; -/* */ } -/* 584 */ if ("PNG".equalsIgnoreCase(type)) -/* */ { -/* 586 */ return 6; -/* */ } -/* 588 */ return 5; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void setDataValidation(Excel attr, Row row, int column) { -/* 596 */ if (attr.name().indexOf("注:") >= 0) { -/* */ -/* 598 */ this.sheet.setColumnWidth(column, 6000); -/* */ -/* */ } -/* */ else { -/* */ -/* 603 */ this.sheet.setColumnWidth(column, (int)((attr.width() + 0.72D) * 256.0D)); -/* */ } -/* */ -/* 606 */ if (StringUtils.isNotEmpty(attr.prompt())) -/* */ { -/* */ -/* 609 */ setXSSFPrompt(this.sheet, "", attr.prompt(), 1, 100, column, column); -/* */ } -/* */ -/* 612 */ if ((attr.combo()).length > 0) -/* */ { -/* */ -/* 615 */ setXSSFValidation(this.sheet, attr.combo(), 1, 100, column, column); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public Cell addCell(Excel attr, Row row, T vo, Field field, int column) { -/* 624 */ Cell cell = null; -/* */ -/* */ -/* */ try { -/* 628 */ row.setHeight(this.maxHeight); -/* */ -/* 630 */ if (attr.isExport()) -/* */ { -/* */ -/* 633 */ cell = row.createCell(column); -/* 634 */ int align = attr.align().value(); -/* 635 */ cell.setCellStyle(this.styles.get("data" + ((align >= 1 && align <= 3) ? Integer.valueOf(align) : ""))); -/* */ -/* */ -/* 638 */ Object value = getTargetValue(vo, field, attr); -/* 639 */ String dateFormat = attr.dateFormat(); -/* 640 */ String readConverterExp = attr.readConverterExp(); -/* 641 */ String separator = attr.separator(); -/* 642 */ String dictType = attr.dictType(); -/* 643 */ if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) { -/* */ -/* 645 */ cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date)value)); -/* */ } -/* 647 */ else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) { -/* */ -/* 649 */ cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator)); -/* */ } -/* 651 */ else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value)) { -/* */ -/* 653 */ cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator)); -/* */ } -/* 655 */ else if (value instanceof BigDecimal && -1 != attr.scale()) { -/* */ -/* 657 */ cell.setCellValue(((BigDecimal)value).setScale(attr.scale(), attr.roundingMode()).toString()); -/* */ -/* */ } -/* */ else { -/* */ -/* 662 */ setCellVo(value, attr, cell); -/* */ } -/* 664 */ addStatisticsData(Integer.valueOf(column), Convert.toStr(value), attr); -/* */ } -/* */ -/* 667 */ } catch (Exception e) { -/* */ -/* 669 */ log.error("导出Excel失败{}", e); -/* */ } -/* 671 */ return cell; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, int firstCol, int endCol) { -/* 688 */ DataValidationHelper helper = sheet.getDataValidationHelper(); -/* 689 */ DataValidationConstraint constraint = helper.createCustomConstraint("DD1"); -/* 690 */ CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); -/* 691 */ DataValidation dataValidation = helper.createValidation(constraint, regions); -/* 692 */ dataValidation.createPromptBox(promptTitle, promptContent); -/* 693 */ dataValidation.setShowPromptBox(true); -/* 694 */ sheet.addValidationData(dataValidation); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) { -/* 710 */ DataValidationHelper helper = sheet.getDataValidationHelper(); -/* */ -/* 712 */ DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist); -/* */ -/* 714 */ CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); -/* */ -/* 716 */ DataValidation dataValidation = helper.createValidation(constraint, regions); -/* */ -/* 718 */ if (dataValidation instanceof org.apache.poi.xssf.usermodel.XSSFDataValidation) { -/* */ -/* 720 */ dataValidation.setSuppressDropDownArrow(true); -/* 721 */ dataValidation.setShowErrorBox(true); -/* */ } -/* */ else { -/* */ -/* 725 */ dataValidation.setSuppressDropDownArrow(false); -/* */ } -/* */ -/* 728 */ sheet.addValidationData(dataValidation); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String convertByExp(String propertyValue, String converterExp, String separator) { -/* 741 */ StringBuilder propertyString = new StringBuilder(); -/* 742 */ String[] convertSource = converterExp.split(","); -/* 743 */ for (String item : convertSource) { -/* */ -/* 745 */ String[] itemArray = item.split("="); -/* 746 */ if (StringUtils.containsAny(separator, propertyValue)) { -/* */ -/* 748 */ for (String value : propertyValue.split(separator)) { -/* */ -/* 750 */ if (itemArray[0].equals(value)) { -/* */ -/* 752 */ propertyString.append(itemArray[1] + separator); -/* */ -/* */ -/* */ -/* */ break; -/* */ } -/* */ } -/* 759 */ } else if (itemArray[0].equals(propertyValue)) { -/* */ -/* 761 */ return itemArray[1]; -/* */ } -/* */ } -/* */ -/* 765 */ return StringUtils.stripEnd(propertyString.toString(), separator); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String reverseByExp(String propertyValue, String converterExp, String separator) { -/* 778 */ StringBuilder propertyString = new StringBuilder(); -/* 779 */ String[] convertSource = converterExp.split(","); -/* 780 */ for (String item : convertSource) { -/* */ -/* 782 */ String[] itemArray = item.split("="); -/* 783 */ if (StringUtils.containsAny(separator, propertyValue)) { -/* */ -/* 785 */ for (String value : propertyValue.split(separator)) { -/* */ -/* 787 */ if (itemArray[1].equals(value)) { -/* */ -/* 789 */ propertyString.append(itemArray[0] + separator); -/* */ -/* */ -/* */ -/* */ break; -/* */ } -/* */ } -/* 796 */ } else if (itemArray[1].equals(propertyValue)) { -/* */ -/* 798 */ return itemArray[0]; -/* */ } -/* */ } -/* */ -/* 802 */ return StringUtils.stripEnd(propertyString.toString(), separator); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String convertDictByExp(String dictValue, String dictType, String separator) { -/* 815 */ return DictUtils.getDictLabel(dictType, dictValue, separator); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String reverseDictByExp(String dictLabel, String dictType, String separator) { -/* 828 */ return DictUtils.getDictValue(dictType, dictLabel, separator); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private void addStatisticsData(Integer index, String text, Excel entity) { -/* 836 */ if (entity != null && entity.isStatistics()) { -/* */ -/* 838 */ Double temp = Double.valueOf(0.0D); -/* 839 */ if (!this.statistics.containsKey(index)) -/* */ { -/* 841 */ this.statistics.put(index, temp); -/* */ } -/* */ -/* */ try { -/* 845 */ temp = Double.valueOf(text); -/* */ } -/* 847 */ catch (NumberFormatException numberFormatException) {} -/* */ -/* */ -/* 850 */ this.statistics.put(index, Double.valueOf(((Double)this.statistics.get(index)).doubleValue() + temp.doubleValue())); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void addStatisticsRow() { -/* 859 */ if (this.statistics.size() > 0) { -/* */ -/* 861 */ Cell cell = null; -/* 862 */ Row row = this.sheet.createRow(this.sheet.getLastRowNum() + 1); -/* 863 */ Set keys = this.statistics.keySet(); -/* 864 */ cell = row.createCell(0); -/* 865 */ cell.setCellStyle(this.styles.get("total")); -/* 866 */ cell.setCellValue("合计"); -/* */ -/* 868 */ for (Integer key : keys) { -/* */ -/* 870 */ cell = row.createCell(key.intValue()); -/* 871 */ cell.setCellStyle(this.styles.get("total")); -/* 872 */ cell.setCellValue(DOUBLE_FORMAT.format(this.statistics.get(key))); -/* */ } -/* 874 */ this.statistics.clear(); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public String encodingFilename(String filename) { -/* 883 */ filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; -/* 884 */ return filename; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public String getAbsoluteFile(String filename) { -/* 894 */ String downloadPath = ArchiveConfig.getInstance().getDownloadPath() + filename; -/* 895 */ File desc = new File(downloadPath); -/* 896 */ if (!desc.getParentFile().exists()) -/* */ { -/* 898 */ desc.getParentFile().mkdirs(); -/* */ } -/* 900 */ return downloadPath; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private Object getTargetValue(T vo, Field field, Excel excel) throws Exception { -/* 914 */ Object o = field.get(vo); -/* 915 */ if (StringUtils.isNotEmpty(excel.targetAttr())) { -/* */ -/* 917 */ String target = excel.targetAttr(); -/* 918 */ if (target.indexOf(".") > -1) { -/* */ -/* 920 */ String[] targets = target.split("[.]"); -/* 921 */ for (String name : targets) -/* */ { -/* 923 */ o = getValue(o, name); -/* */ } -/* */ } -/* */ else { -/* */ -/* 928 */ o = getValue(o, target); -/* */ } -/* */ } -/* 931 */ return o; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private Object getValue(Object o, String name) throws Exception { -/* 944 */ if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name)) { -/* */ -/* 946 */ Class clazz = o.getClass(); -/* 947 */ Field field = clazz.getDeclaredField(name); -/* 948 */ field.setAccessible(true); -/* 949 */ o = field.get(o); -/* */ } -/* 951 */ return o; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private void createExcelField() { -/* 959 */ this.fields = new ArrayList(); -/* 960 */ List tempFields = new ArrayList<>(); -/* 961 */ tempFields.addAll(Arrays.asList(this.clazz.getSuperclass().getDeclaredFields())); -/* 962 */ tempFields.addAll(Arrays.asList(this.clazz.getDeclaredFields())); -/* 963 */ for (Field field : tempFields) { -/* */ -/* */ -/* 966 */ if (field.isAnnotationPresent((Class)Excel.class)) -/* */ { -/* 968 */ putToField(field, field.getAnnotation(Excel.class)); -/* */ } -/* */ -/* */ -/* 972 */ if (field.isAnnotationPresent((Class)Excels.class)) { -/* */ -/* 974 */ Excels attrs = field.getAnnotation(Excels.class); -/* 975 */ Excel[] excels = attrs.value(); -/* 976 */ for (Excel excel : excels) -/* */ { -/* 978 */ putToField(field, excel); -/* */ } -/* */ } -/* */ } -/* 982 */ this.fields = (List)this.fields.stream().sorted(Comparator.comparing(objects -> Integer.valueOf(((Excel)objects[1]).sort()))).collect(Collectors.toList()); -/* 983 */ this.maxHeight = getRowHeight(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public short getRowHeight() { -/* 991 */ double maxHeight = 0.0D; -/* 992 */ for (Object[] os : this.fields) { -/* */ -/* 994 */ Excel excel = (Excel)os[1]; -/* 995 */ maxHeight = (maxHeight > excel.height()) ? maxHeight : excel.height(); -/* */ } -/* 997 */ return (short)(int)(maxHeight * 20.0D); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private void putToField(Field field, Excel attr) { -/* 1005 */ if (attr != null && (attr.type() == Type.ALL || attr.type() == this.type)) -/* */ { -/* 1007 */ this.fields.add(new Object[] { field, attr }); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void createWorkbook() { -/* 1016 */ this.wb = (Workbook)new SXSSFWorkbook(500); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void createSheet(double sheetNo, int index) { -/* 1027 */ this.sheet = this.wb.createSheet(); -/* 1028 */ this.styles = createStyles(this.wb); -/* */ -/* 1030 */ if (sheetNo == 0.0D) { -/* */ -/* 1032 */ this.wb.setSheetName(index, this.sheetName); -/* */ } -/* */ else { -/* */ -/* 1036 */ this.wb.setSheetName(index, this.sheetName + index); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public Object getCellValue(Row row, int column) { -/* 1049 */ if (row == null) -/* */ { -/* 1051 */ return row; -/* */ } -/* 1053 */ Object val = ""; -/* */ -/* */ try { -/* 1056 */ Cell cell = row.getCell(column); -/* 1057 */ if (StringUtils.isNotNull(cell)) -/* */ { -/* 1059 */ if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) -/* */ { -/* 1061 */ val = Double.valueOf(cell.getNumericCellValue()); -/* 1062 */ if (DateUtil.isCellDateFormatted(cell)) -/* */ { -/* 1064 */ val = DateUtil.getJavaDate(((Double)val).doubleValue()); -/* */ -/* */ -/* */ } -/* 1068 */ else if (((Double)val).doubleValue() % 1.0D != 0.0D) -/* */ { -/* 1070 */ val = new BigDecimal(val.toString()); -/* */ } -/* */ else -/* */ { -/* 1074 */ val = (new DecimalFormat("0")).format(val); -/* */ } -/* */ -/* */ } -/* 1078 */ else if (cell.getCellType() == CellType.STRING) -/* */ { -/* 1080 */ val = cell.getStringCellValue(); -/* */ } -/* 1082 */ else if (cell.getCellType() == CellType.BOOLEAN) -/* */ { -/* 1084 */ val = Boolean.valueOf(cell.getBooleanCellValue()); -/* */ } -/* 1086 */ else if (cell.getCellType() == CellType.ERROR) -/* */ { -/* 1088 */ val = Byte.valueOf(cell.getErrorCellValue()); -/* */ } -/* */ -/* */ } -/* */ } -/* 1093 */ catch (Exception e) { -/* */ -/* 1095 */ return val; -/* */ } -/* 1097 */ return val; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private boolean isRowEmpty(Row row) { -/* 1108 */ if (row == null) -/* */ { -/* 1110 */ return true; -/* */ } -/* 1112 */ for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) { -/* */ -/* 1114 */ Cell cell = row.getCell(i); -/* 1115 */ if (cell != null && cell.getCellType() != CellType.BLANK) -/* */ { -/* 1117 */ return false; -/* */ } -/* */ } -/* 1120 */ return true; -/* */ } -/* */ } + import com.archive.framework.web.domain.AjaxResult; + import com.archive.project.system.dict.utils.DictUtils; + import java.io.File; + import java.io.FileOutputStream; + import java.io.IOException; + import java.io.InputStream; + import java.io.OutputStream; + import java.lang.reflect.Field; + import java.math.BigDecimal; + import java.text.DecimalFormat; + import java.util.ArrayList; + import java.util.Arrays; + import java.util.Comparator; + import java.util.Date; + import java.util.HashMap; + import java.util.List; + import java.util.Map; + import java.util.Set; + import java.util.UUID; + import java.util.stream.Collectors; + import org.apache.poi.ss.usermodel.BorderStyle; + import org.apache.poi.ss.usermodel.Cell; + import org.apache.poi.ss.usermodel.CellStyle; + import org.apache.poi.ss.usermodel.CellType; + import org.apache.poi.ss.usermodel.ClientAnchor; + import org.apache.poi.ss.usermodel.DataValidation; + import org.apache.poi.ss.usermodel.DataValidationConstraint; + import org.apache.poi.ss.usermodel.DataValidationHelper; + import org.apache.poi.ss.usermodel.DateUtil; + import org.apache.poi.ss.usermodel.Drawing; + import org.apache.poi.ss.usermodel.FillPatternType; + import org.apache.poi.ss.usermodel.Font; + import org.apache.poi.ss.usermodel.HorizontalAlignment; + import org.apache.poi.ss.usermodel.IndexedColors; + import org.apache.poi.ss.usermodel.Row; + import org.apache.poi.ss.usermodel.Sheet; + import org.apache.poi.ss.usermodel.VerticalAlignment; + import org.apache.poi.ss.usermodel.Workbook; + import org.apache.poi.ss.usermodel.WorkbookFactory; + import org.apache.poi.ss.util.CellRangeAddressList; + import org.apache.poi.xssf.streaming.SXSSFWorkbook; + import org.apache.poi.xssf.usermodel.XSSFClientAnchor; + import org.slf4j.Logger; + import org.slf4j.LoggerFactory; + + + + + + + + + + public class ExcelUtil + { + private static final Logger log = LoggerFactory.getLogger(com.archive.common.utils.poi.ExcelUtil.class); + + + + + public static final int sheetSize = 65536; + + + + + private String sheetName; + + + + + private Type type; + + + + + private Workbook wb; + + + + + private Sheet sheet; + + + + + private Map styles; + + + + + private List list; + + + + + private List fields; + + + + + private short maxHeight; + + + + + private Map statistics = new HashMap<>(); + + + + + private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00"); + + + + public Class clazz; + + + + public ExcelUtil(Class clazz) { + this.clazz = clazz; + } + + + public void init(List list, String sheetName, Type type) { + if (list == null) + { + list = new ArrayList<>(); + } + this.list = list; + this.sheetName = sheetName; + this.type = type; + createExcelField(); + createWorkbook(); + } + + + + + + + + + public List importExcel(InputStream is) throws Exception { + return importExcel("", is); + } + + + + + + + + + + public List importExcel(String sheetName, InputStream is) throws Exception { + this.type = Type.IMPORT; + this.wb = WorkbookFactory.create(is); + List list = new ArrayList<>(); + Sheet sheet = null; + if (StringUtils.isNotEmpty(sheetName)) { + + + sheet = this.wb.getSheet(sheetName); + + } + else { + + sheet = this.wb.getSheetAt(0); + } + + if (sheet == null) + { + throw new IOException("文件sheet不存在"); + } + + + int rows = sheet.getLastRowNum(); + + if (rows > 0) { + + + Map cellMap = new HashMap<>(); + + Row heard = sheet.getRow(0); + for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) { + + Cell cell = heard.getCell(i); + if (StringUtils.isNotNull(cell)) { + + String value = getCellValue(heard, i).toString(); + cellMap.put(value, Integer.valueOf(i)); + } + else { + + cellMap.put(null, Integer.valueOf(i)); + } + } + + Field[] allFields = this.clazz.getDeclaredFields(); + + Map fieldsMap = new HashMap<>(); + for (int col = 0; col < allFields.length; col++) { + + Field field = allFields[col]; + Excel attr = field.getAnnotation(Excel.class); + if (attr != null && (attr.type() == Type.ALL || attr.type() == this.type)) { + + + field.setAccessible(true); + Integer column = cellMap.get(attr.name()); + if (column != null) + { + fieldsMap.put(column, field); + } + } + } + for (int j = 1; j <= rows; j++) { + + + Row row = sheet.getRow(j); + + if (!isRowEmpty(row)) { + + + + T entity = null; + for (Map.Entry entry : fieldsMap.entrySet()) { + + Object val = getCellValue(row, ((Integer)entry.getKey()).intValue()); + + + entity = (entity == null) ? this.clazz.newInstance() : entity; + + Field field = fieldsMap.get(entry.getKey()); + + Class fieldType = field.getType(); + if (String.class == fieldType) { + + String s = Convert.toStr(val); + if (StringUtils.endsWith(s, ".0")) { + + val = StringUtils.substringBefore(s, ".0"); + } + else { + + String dateFormat = ((Excel)field.getAnnotation(Excel.class)).dateFormat(); + if (StringUtils.isNotEmpty(dateFormat)) + { + val = DateUtils.parseDateToStr(dateFormat, (Date)val); + } + else + { + val = Convert.toStr(val); + } + + } + } else if ((int.class == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) { + + val = Convert.toInt(val); + } + else if (long.class == fieldType || Long.class == fieldType) { + + val = Convert.toLong(val); + } + else if (double.class == fieldType || Double.class == fieldType) { + + val = Convert.toDouble(val); + } + else if (float.class == fieldType || Float.class == fieldType) { + + val = Convert.toFloat(val); + } + else if (BigDecimal.class == fieldType) { + + val = Convert.toBigDecimal(val); + } + else if (Date.class == fieldType) { + + if (val instanceof String) + { + val = DateUtils.parseDate(val); + } + else if (val instanceof Double) + { + val = DateUtil.getJavaDate(((Double)val).doubleValue()); + } + + } else if (boolean.class == fieldType || Boolean.class == fieldType) { + + val = Convert.toBool(val, Boolean.valueOf(false)); + } + if (StringUtils.isNotNull(fieldType)) { + + Excel attr = field.getAnnotation(Excel.class); + String propertyName = field.getName(); + if (StringUtils.isNotEmpty(attr.targetAttr())) { + + propertyName = field.getName() + "." + attr.targetAttr(); + } + else if (StringUtils.isNotEmpty(attr.readConverterExp())) { + + val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator()); + } + else if (StringUtils.isNotEmpty(attr.dictType())) { + + val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator()); + } + ReflectUtils.invokeSetter(entity, propertyName, val); + } + } + list.add(entity); + } + } + } return list; + } + + + + + + + + + + public AjaxResult exportExcel(List list, String sheetName) { + init(list, sheetName, Type.EXPORT); + return exportExcel(); + } + + + + + + + + + public AjaxResult importTemplateExcel(String sheetName) { + init(null, sheetName, Type.IMPORT); + return exportExcel(); + } + + + + + + + + public AjaxResult exportExcel() { + OutputStream out = null; + + + try { + double sheetNo = Math.ceil((this.list.size() / 65536)); + for (int index = 0; index <= sheetNo; index++) { + + createSheet(sheetNo, index); + + + Row row = this.sheet.createRow(0); + int column = 0; + + for (Object[] os : this.fields) { + + Excel excel = (Excel)os[1]; + createCell(excel, row, column++); + } + if (Type.EXPORT.equals(this.type)) { + + fillExcelData(index, row); + addStatisticsRow(); + } + } + String filename = encodingFilename(this.sheetName); + out = new FileOutputStream(getAbsoluteFile(filename)); + this.wb.write(out); + return AjaxResult.success(filename); + } + catch (Exception e) { + + log.error("导出Excel异常{}", e.getMessage()); + throw new BusinessException("导出Excel失败,请联系网站管理员!"); + } + finally { + + if (this.wb != null) { + + try { + + this.wb.close(); + } + catch (IOException e1) { + + e1.printStackTrace(); + } + } + if (out != null) { + + try { + + out.close(); + } + catch (IOException e1) { + + e1.printStackTrace(); + } + } + } + } + + + + + + + + + public void fillExcelData(int index, Row row) { + int startNo = index * 65536; + int endNo = Math.min(startNo + 65536, this.list.size()); + for (int i = startNo; i < endNo; i++) { + + row = this.sheet.createRow(i + 1 - startNo); + + T vo = this.list.get(i); + int column = 0; + for (Object[] os : this.fields) { + + Field field = (Field)os[0]; + Excel excel = (Excel)os[1]; + + field.setAccessible(true); + addCell(excel, row, vo, field, column++); + } + } + } + + + + + + + + + + private Map createStyles(Workbook wb) { + Map styles = new HashMap<>(); + CellStyle style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setBorderRight(BorderStyle.THIN); + style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderLeft(BorderStyle.THIN); + style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderTop(BorderStyle.THIN); + style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderBottom(BorderStyle.THIN); + style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + Font dataFont = wb.createFont(); + dataFont.setFontName("Arial"); + dataFont.setFontHeightInPoints((short)10); + style.setFont(dataFont); + styles.put("data", style); + + style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + Font headerFont = wb.createFont(); + headerFont.setFontName("Arial"); + headerFont.setFontHeightInPoints((short)10); + headerFont.setBold(true); + headerFont.setColor(IndexedColors.WHITE.getIndex()); + style.setFont(headerFont); + styles.put("header", style); + + style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + Font totalFont = wb.createFont(); + totalFont.setFontName("Arial"); + totalFont.setFontHeightInPoints((short)10); + style.setFont(totalFont); + styles.put("total", style); + + style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.LEFT); + styles.put("data1", style); + + style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.CENTER); + styles.put("data2", style); + + style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.RIGHT); + styles.put("data3", style); + + return styles; + } + + + + + + + public Cell createCell(Excel attr, Row row, int column) { + Cell cell = row.createCell(column); + + cell.setCellValue(attr.name()); + setDataValidation(attr, row, column); + cell.setCellStyle(this.styles.get("header")); + return cell; + } + + + + + + + + + + public void setCellVo(Object value, Excel attr, Cell cell) { + if (ColumnType.STRING == attr.cellType()) { + + cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : (value + attr.suffix())); + } + else if (ColumnType.NUMERIC == attr.cellType()) { + + cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value).doubleValue() : Convert.toInt(value).intValue()); + } + else if (ColumnType.IMAGE == attr.cellType()) { + + + XSSFClientAnchor xSSFClientAnchor = new XSSFClientAnchor(0, 0, 0, 0, (short)cell.getColumnIndex(), cell.getRow().getRowNum(), (short)(cell.getColumnIndex() + 1), cell.getRow().getRowNum() + 1); + String imagePath = Convert.toStr(value); + if (StringUtils.isNotEmpty(imagePath)) { + + byte[] data = ImageUtils.getImage(imagePath); + getDrawingPatriarch(cell.getSheet()).createPicture((ClientAnchor)xSSFClientAnchor, cell + .getSheet().getWorkbook().addPicture(data, getImageType(data))); + } + } + } + + + + + + public static Drawing getDrawingPatriarch(Sheet sheet) { + if (sheet.getDrawingPatriarch() == null) + { + sheet.createDrawingPatriarch(); + } + return sheet.getDrawingPatriarch(); + } + + + + + + public int getImageType(byte[] value) { + String type = FileTypeUtils.getFileExtendName(value); + if ("JPG".equalsIgnoreCase(type)) + { + return 5; + } + if ("PNG".equalsIgnoreCase(type)) + { + return 6; + } + return 5; + } + + + + + + public void setDataValidation(Excel attr, Row row, int column) { + if (attr.name().indexOf("注:") >= 0) { + + this.sheet.setColumnWidth(column, 6000); + + } + else { + + this.sheet.setColumnWidth(column, (int)((attr.width() + 0.72D) * 256.0D)); + } + + if (StringUtils.isNotEmpty(attr.prompt())) + { + + setXSSFPrompt(this.sheet, "", attr.prompt(), 1, 100, column, column); + } + + if ((attr.combo()).length > 0) + { + + setXSSFValidation(this.sheet, attr.combo(), 1, 100, column, column); + } + } + + + + + + public Cell addCell(Excel attr, Row row, T vo, Field field, int column) { + Cell cell = null; + + + try { + row.setHeight(this.maxHeight); + + if (attr.isExport()) + { + + cell = row.createCell(column); + int align = attr.align().value(); + cell.setCellStyle(this.styles.get("data" + ((align >= 1 && align <= 3) ? Integer.valueOf(align) : ""))); + + + Object value = getTargetValue(vo, field, attr); + String dateFormat = attr.dateFormat(); + String readConverterExp = attr.readConverterExp(); + String separator = attr.separator(); + String dictType = attr.dictType(); + if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) { + + cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date)value)); + } + else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) { + + cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator)); + } + else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value)) { + + cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator)); + } + else if (value instanceof BigDecimal && -1 != attr.scale()) { + + cell.setCellValue(((BigDecimal)value).setScale(attr.scale(), attr.roundingMode()).toString()); + + } + else { + + setCellVo(value, attr, cell); + } + addStatisticsData(Integer.valueOf(column), Convert.toStr(value), attr); + } + + } catch (Exception e) { + + log.error("导出Excel失败{}", e); + } + return cell; + } + + + + + + + + + + + + + + + public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, int firstCol, int endCol) { + DataValidationHelper helper = sheet.getDataValidationHelper(); + DataValidationConstraint constraint = helper.createCustomConstraint("DD1"); + CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + DataValidation dataValidation = helper.createValidation(constraint, regions); + dataValidation.createPromptBox(promptTitle, promptContent); + dataValidation.setShowPromptBox(true); + sheet.addValidationData(dataValidation); + } + + + + + + + + + + + + + + public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) { + DataValidationHelper helper = sheet.getDataValidationHelper(); + + DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist); + + CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + + DataValidation dataValidation = helper.createValidation(constraint, regions); + + if (dataValidation instanceof org.apache.poi.xssf.usermodel.XSSFDataValidation) { + + dataValidation.setSuppressDropDownArrow(true); + dataValidation.setShowErrorBox(true); + } + else { + + dataValidation.setSuppressDropDownArrow(false); + } + + sheet.addValidationData(dataValidation); + } + + + + + + + + + + + public static String convertByExp(String propertyValue, String converterExp, String separator) { + StringBuilder propertyString = new StringBuilder(); + String[] convertSource = converterExp.split(","); + for (String item : convertSource) { + + String[] itemArray = item.split("="); + if (StringUtils.containsAny(separator, propertyValue)) { + + for (String value : propertyValue.split(separator)) { + + if (itemArray[0].equals(value)) { + + propertyString.append(itemArray[1] + separator); + + + + break; + } + } + } else if (itemArray[0].equals(propertyValue)) { + + return itemArray[1]; + } + } + + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + + + + + + + + + + public static String reverseByExp(String propertyValue, String converterExp, String separator) { + StringBuilder propertyString = new StringBuilder(); + String[] convertSource = converterExp.split(","); + for (String item : convertSource) { + + String[] itemArray = item.split("="); + if (StringUtils.containsAny(separator, propertyValue)) { + + for (String value : propertyValue.split(separator)) { + + if (itemArray[1].equals(value)) { + + propertyString.append(itemArray[0] + separator); + + + + break; + } + } + } else if (itemArray[1].equals(propertyValue)) { + + return itemArray[0]; + } + } + + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + + + + + + + + + + public static String convertDictByExp(String dictValue, String dictType, String separator) { + return DictUtils.getDictLabel(dictType, dictValue, separator); + } + + + + + + + + + + + public static String reverseDictByExp(String dictLabel, String dictType, String separator) { + return DictUtils.getDictValue(dictType, dictLabel, separator); + } + + + + + + private void addStatisticsData(Integer index, String text, Excel entity) { + if (entity != null && entity.isStatistics()) { + + Double temp = Double.valueOf(0.0D); + if (!this.statistics.containsKey(index)) + { + this.statistics.put(index, temp); + } + + try { + temp = Double.valueOf(text); + } + catch (NumberFormatException numberFormatException) {} + + + this.statistics.put(index, Double.valueOf(((Double)this.statistics.get(index)).doubleValue() + temp.doubleValue())); + } + } + + + + + + public void addStatisticsRow() { + if (this.statistics.size() > 0) { + + Cell cell = null; + Row row = this.sheet.createRow(this.sheet.getLastRowNum() + 1); + Set keys = this.statistics.keySet(); + cell = row.createCell(0); + cell.setCellStyle(this.styles.get("total")); + cell.setCellValue("合计"); + + for (Integer key : keys) { + + cell = row.createCell(key.intValue()); + cell.setCellStyle(this.styles.get("total")); + cell.setCellValue(DOUBLE_FORMAT.format(this.statistics.get(key))); + } + this.statistics.clear(); + } + } + + + + + + public String encodingFilename(String filename) { + filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; + return filename; + } + + + + + + + + public String getAbsoluteFile(String filename) { + String downloadPath = ArchiveConfig.getInstance().getDownloadPath() + filename; + File desc = new File(downloadPath); + if (!desc.getParentFile().exists()) + { + desc.getParentFile().mkdirs(); + } + return downloadPath; + } + + + + + + + + + + + + private Object getTargetValue(T vo, Field field, Excel excel) throws Exception { + Object o = field.get(vo); + if (StringUtils.isNotEmpty(excel.targetAttr())) { + + String target = excel.targetAttr(); + if (target.indexOf(".") > -1) { + + String[] targets = target.split("[.]"); + for (String name : targets) + { + o = getValue(o, name); + } + } + else { + + o = getValue(o, target); + } + } + return o; + } + + + + + + + + + + + private Object getValue(Object o, String name) throws Exception { + if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name)) { + + Class clazz = o.getClass(); + Field field = clazz.getDeclaredField(name); + field.setAccessible(true); + o = field.get(o); + } + return o; + } + + + + + + private void createExcelField() { + this.fields = new ArrayList(); + List tempFields = new ArrayList<>(); + tempFields.addAll(Arrays.asList(this.clazz.getSuperclass().getDeclaredFields())); + tempFields.addAll(Arrays.asList(this.clazz.getDeclaredFields())); + for (Field field : tempFields) { + + + if (field.isAnnotationPresent((Class)Excel.class)) + { + putToField(field, field.getAnnotation(Excel.class)); + } + + + if (field.isAnnotationPresent((Class)Excels.class)) { + + Excels attrs = field.getAnnotation(Excels.class); + Excel[] excels = attrs.value(); + for (Excel excel : excels) + { + putToField(field, excel); + } + } + } + this.fields = (List)this.fields.stream().sorted(Comparator.comparing(objects -> Integer.valueOf(((Excel)objects[1]).sort()))).collect(Collectors.toList()); + this.maxHeight = getRowHeight(); + } + + + + + + public short getRowHeight() { + double maxHeight = 0.0D; + for (Object[] os : this.fields) { + + Excel excel = (Excel)os[1]; + maxHeight = (maxHeight > excel.height()) ? maxHeight : excel.height(); + } + return (short)(int)(maxHeight * 20.0D); + } + + + + + + private void putToField(Field field, Excel attr) { + if (attr != null && (attr.type() == Type.ALL || attr.type() == this.type)) + { + this.fields.add(new Object[] { field, attr }); + } + } + + + + + + public void createWorkbook() { + this.wb = (Workbook)new SXSSFWorkbook(500); + } + + + + + + + + + public void createSheet(double sheetNo, int index) { + this.sheet = this.wb.createSheet(); + this.styles = createStyles(this.wb); + + if (sheetNo == 0.0D) { + + this.wb.setSheetName(index, this.sheetName); + } + else { + + this.wb.setSheetName(index, this.sheetName + index); + } + } + + + + + + + + + + public Object getCellValue(Row row, int column) { + if (row == null) + { + return row; + } + Object val = ""; + + try { + Cell cell = row.getCell(column); + if (StringUtils.isNotNull(cell)) + { + if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) + { + val = Double.valueOf(cell.getNumericCellValue()); + if (DateUtil.isCellDateFormatted(cell)) + { + val = DateUtil.getJavaDate(((Double)val).doubleValue()); + + + } + else if (((Double)val).doubleValue() % 1.0D != 0.0D) + { + val = new BigDecimal(val.toString()); + } + else + { + val = (new DecimalFormat("0")).format(val); + } + + } + else if (cell.getCellType() == CellType.STRING) + { + val = cell.getStringCellValue(); + } + else if (cell.getCellType() == CellType.BOOLEAN) + { + val = Boolean.valueOf(cell.getBooleanCellValue()); + } + else if (cell.getCellType() == CellType.ERROR) + { + val = Byte.valueOf(cell.getErrorCellValue()); + } + + } + } + catch (Exception e) { + + return val; + } + return val; + } + + + + + + + + + private boolean isRowEmpty(Row row) { + if (row == null) + { + return true; + } + for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) { + + Cell cell = row.getCell(i); + if (cell != null && cell.getCellType() != CellType.BLANK) + { + return false; + } + } + return true; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\poi\ExcelUtil.class diff --git a/src/main/java/com/archive/framework/config/properties/DruidProperties.java b/src/main/java/com/archive/framework/config/properties/DruidProperties.java index b9f84b7..8cc6e39 100644 --- a/src/main/java/com/archive/framework/config/properties/DruidProperties.java +++ b/src/main/java/com/archive/framework/config/properties/DruidProperties.java @@ -1,82 +1,82 @@ -/* */ package com.archive.framework.config.properties + package com.archive.framework.config.properties ; -/* */ -/* */ import com.alibaba.druid.pool.DruidDataSource; -/* */ import org.springframework.beans.factory.annotation.Value; -/* */ import org.springframework.context.annotation.Configuration; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Configuration -/* */ public class DruidProperties -/* */ { -/* */ @Value("${spring.datasource.druid.initialSize}") -/* */ private int initialSize; -/* */ @Value("${spring.datasource.druid.minIdle}") -/* */ private int minIdle; -/* */ @Value("${spring.datasource.druid.maxActive}") -/* */ private int maxActive; -/* */ @Value("${spring.datasource.druid.maxWait}") -/* */ private int maxWait; -/* */ @Value("${spring.datasource.druid.timeBetweenEvictionRunsMillis}") -/* */ private int timeBetweenEvictionRunsMillis; -/* */ @Value("${spring.datasource.druid.minEvictableIdleTimeMillis}") -/* */ private int minEvictableIdleTimeMillis; -/* */ @Value("${spring.datasource.druid.maxEvictableIdleTimeMillis}") -/* */ private int maxEvictableIdleTimeMillis; -/* */ @Value("${spring.datasource.druid.validationQuery}") -/* */ private String validationQuery; -/* */ @Value("${spring.datasource.druid.testWhileIdle}") -/* */ private boolean testWhileIdle; -/* */ @Value("${spring.datasource.druid.testOnBorrow}") -/* */ private boolean testOnBorrow; -/* */ @Value("${spring.datasource.druid.testOnReturn}") -/* */ private boolean testOnReturn; -/* */ -/* */ public DruidDataSource dataSource(DruidDataSource datasource) { -/* 51 */ datasource.setInitialSize(this.initialSize); -/* 52 */ datasource.setMaxActive(this.maxActive); -/* 53 */ datasource.setMinIdle(this.minIdle); -/* */ -/* */ -/* 56 */ datasource.setMaxWait(this.maxWait); -/* */ -/* */ -/* 59 */ datasource.setTimeBetweenEvictionRunsMillis(this.timeBetweenEvictionRunsMillis); -/* */ -/* */ -/* 62 */ datasource.setMinEvictableIdleTimeMillis(this.minEvictableIdleTimeMillis); -/* 63 */ datasource.setMaxEvictableIdleTimeMillis(this.maxEvictableIdleTimeMillis); -/* */ -/* */ -/* */ -/* */ -/* 68 */ datasource.setValidationQuery(this.validationQuery); -/* */ -/* 70 */ datasource.setTestWhileIdle(this.testWhileIdle); -/* */ -/* 72 */ datasource.setTestOnBorrow(this.testOnBorrow); -/* */ -/* 74 */ datasource.setTestOnReturn(this.testOnReturn); -/* 75 */ return datasource; -/* */ } -/* */ } + + import com.alibaba.druid.pool.DruidDataSource; + import org.springframework.beans.factory.annotation.Value; + import org.springframework.context.annotation.Configuration; + + + + + + + + + + + + + + + + + + + @Configuration + public class DruidProperties + { + @Value("${spring.datasource.druid.initialSize}") + private int initialSize; + @Value("${spring.datasource.druid.minIdle}") + private int minIdle; + @Value("${spring.datasource.druid.maxActive}") + private int maxActive; + @Value("${spring.datasource.druid.maxWait}") + private int maxWait; + @Value("${spring.datasource.druid.timeBetweenEvictionRunsMillis}") + private int timeBetweenEvictionRunsMillis; + @Value("${spring.datasource.druid.minEvictableIdleTimeMillis}") + private int minEvictableIdleTimeMillis; + @Value("${spring.datasource.druid.maxEvictableIdleTimeMillis}") + private int maxEvictableIdleTimeMillis; + @Value("${spring.datasource.druid.validationQuery}") + private String validationQuery; + @Value("${spring.datasource.druid.testWhileIdle}") + private boolean testWhileIdle; + @Value("${spring.datasource.druid.testOnBorrow}") + private boolean testOnBorrow; + @Value("${spring.datasource.druid.testOnReturn}") + private boolean testOnReturn; + + public DruidDataSource dataSource(DruidDataSource datasource) { + datasource.setInitialSize(this.initialSize); + datasource.setMaxActive(this.maxActive); + datasource.setMinIdle(this.minIdle); + + + datasource.setMaxWait(this.maxWait); + + + datasource.setTimeBetweenEvictionRunsMillis(this.timeBetweenEvictionRunsMillis); + + + datasource.setMinEvictableIdleTimeMillis(this.minEvictableIdleTimeMillis); + datasource.setMaxEvictableIdleTimeMillis(this.maxEvictableIdleTimeMillis); + + + + + datasource.setValidationQuery(this.validationQuery); + + datasource.setTestWhileIdle(this.testWhileIdle); + + datasource.setTestOnBorrow(this.testOnBorrow); + + datasource.setTestOnReturn(this.testOnReturn); + return datasource; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\config\properties\DruidProperties.class diff --git a/src/main/java/com/archive/framework/datasource/DynamicDataSource.java b/src/main/java/com/archive/framework/datasource/DynamicDataSource.java index d6ef93f..4634235 100644 --- a/src/main/java/com/archive/framework/datasource/DynamicDataSource.java +++ b/src/main/java/com/archive/framework/datasource/DynamicDataSource.java @@ -1,31 +1,31 @@ -/* */ package com.archive.framework.datasource + package com.archive.framework.datasource ; -/* */ -/* */ import com.archive.framework.datasource.DynamicDataSourceContextHolder; -/* */ import java.util.Map; -/* */ import javax.sql.DataSource; -/* */ import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class DynamicDataSource -/* */ extends AbstractRoutingDataSource -/* */ { -/* */ public DynamicDataSource(DataSource defaultTargetDataSource, Map targetDataSources) { -/* 16 */ setDefaultTargetDataSource(defaultTargetDataSource); -/* 17 */ setTargetDataSources(targetDataSources); -/* 18 */ afterPropertiesSet(); -/* */ } -/* */ -/* */ -/* */ -/* */ protected Object determineCurrentLookupKey() { -/* 24 */ return DynamicDataSourceContextHolder.getDataSourceType(); -/* */ } -/* */ } + + import com.archive.framework.datasource.DynamicDataSourceContextHolder; + import java.util.Map; + import javax.sql.DataSource; + import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; + + + + + + public class DynamicDataSource + extends AbstractRoutingDataSource + { + public DynamicDataSource(DataSource defaultTargetDataSource, Map targetDataSources) { + setDefaultTargetDataSource(defaultTargetDataSource); + setTargetDataSources(targetDataSources); + afterPropertiesSet(); + } + + + + protected Object determineCurrentLookupKey() { + return DynamicDataSourceContextHolder.getDataSourceType(); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\datasource\DynamicDataSource.class diff --git a/src/main/java/com/archive/framework/datasource/DynamicDataSourceContextHolder.java b/src/main/java/com/archive/framework/datasource/DynamicDataSourceContextHolder.java index c2a5f17..3d23640 100644 --- a/src/main/java/com/archive/framework/datasource/DynamicDataSourceContextHolder.java +++ b/src/main/java/com/archive/framework/datasource/DynamicDataSourceContextHolder.java @@ -1,50 +1,50 @@ -/* */ package com.archive.framework.datasource + package com.archive.framework.datasource ; -/* */ -/* */ import org.slf4j.Logger; -/* */ import org.slf4j.LoggerFactory; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class DynamicDataSourceContextHolder -/* */ { -/* 13 */ public static final Logger log = LoggerFactory.getLogger(com.archive.framework.datasource.DynamicDataSourceContextHolder.class); -/* */ -/* */ -/* */ -/* */ -/* */ -/* 19 */ private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void setDataSourceType(String dsType) { -/* 26 */ log.info("切换到{}数据源", dsType); -/* 27 */ CONTEXT_HOLDER.set(dsType); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getDataSourceType() { -/* 35 */ return CONTEXT_HOLDER.get(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void clearDataSourceType() { -/* 43 */ CONTEXT_HOLDER.remove(); -/* */ } -/* */ } + + import org.slf4j.Logger; + import org.slf4j.LoggerFactory; + + + + + + + public class DynamicDataSourceContextHolder + { + public static final Logger log = LoggerFactory.getLogger(com.archive.framework.datasource.DynamicDataSourceContextHolder.class); + + + + + + private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); + + + + + + public static void setDataSourceType(String dsType) { + log.info("切换到{}数据源", dsType); + CONTEXT_HOLDER.set(dsType); + } + + + + + + public static String getDataSourceType() { + return CONTEXT_HOLDER.get(); + } + + + + + + public static void clearDataSourceType() { + CONTEXT_HOLDER.remove(); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\datasource\DynamicDataSourceContextHolder.class diff --git a/src/main/java/com/archive/framework/web/service/DictService.java b/src/main/java/com/archive/framework/web/service/DictService.java index 5bc7587..e01d77a 100644 --- a/src/main/java/com/archive/framework/web/service/DictService.java +++ b/src/main/java/com/archive/framework/web/service/DictService.java @@ -1,51 +1,51 @@ -/* */ package com.archive.framework.web.service + package com.archive.framework.web.service ; -/* */ -/* */ import com.archive.project.system.dict.domain.DictData; -/* */ import com.archive.project.system.dict.service.IDictDataService; -/* */ import com.archive.project.system.dict.service.IDictTypeService; -/* */ import java.util.List; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Service; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Service("dict") -/* */ public class DictService -/* */ { -/* */ @Autowired -/* */ private IDictTypeService dictTypeService; -/* */ @Autowired -/* */ private IDictDataService dictDataService; -/* */ -/* */ public List getType(String dictType) { -/* 32 */ return this.dictTypeService.selectDictDataByType(dictType); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public String getLabel(String dictType, String dictValue) { -/* 44 */ return this.dictDataService.selectDictLabel(dictType, dictValue); -/* */ } -/* */ } + + import com.archive.project.system.dict.domain.DictData; + import com.archive.project.system.dict.service.IDictDataService; + import com.archive.project.system.dict.service.IDictTypeService; + import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + + + + + + + + + + + + + + + @Service("dict") + public class DictService + { + @Autowired + private IDictTypeService dictTypeService; + @Autowired + private IDictDataService dictDataService; + + public List getType(String dictType) { + return this.dictTypeService.selectDictDataByType(dictType); + } + + + + + + + + + + public String getLabel(String dictType, String dictValue) { + return this.dictDataService.selectDictLabel(dictType, dictValue); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\web\service\DictService.class diff --git a/src/main/java/com/archive/project/document/controller/DocumentController.java b/src/main/java/com/archive/project/document/controller/DocumentController.java index 549e84c..4a1cd35 100644 --- a/src/main/java/com/archive/project/document/controller/DocumentController.java +++ b/src/main/java/com/archive/project/document/controller/DocumentController.java @@ -1,113 +1,113 @@ -/* */ package com.archive.project.document.controller + package com.archive.project.document.controller ; -/* */ -/* */ import com.archive.common.archiveUtil.TableUtil; -/* */ import com.archive.framework.web.controller.BaseController; -/* */ import com.archive.framework.web.domain.AjaxResult; -/* */ import com.archive.framework.web.page.TableDataInfo; -/* */ import com.archive.project.dasz.archivetype.domain.ArchiveType; -/* */ import com.archive.project.dasz.archivetype.service.IArchiveTypeService; -/* */ import com.archive.project.dasz.physicaltable.service.IPhysicalTableService; -/* */ import com.archive.project.dasz.physicaltablecolumn.service.IPhysicalTableColumnService; -/* */ import com.archive.project.document.domain.Document; -/* */ import com.archive.project.document.service.IDocumentService; -/* */ import java.util.List; -/* */ import org.apache.shiro.authz.annotation.RequiresPermissions; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Controller; -/* */ import org.springframework.ui.ModelMap; -/* */ import org.springframework.web.bind.annotation.GetMapping; -/* */ import org.springframework.web.bind.annotation.PathVariable; -/* */ import org.springframework.web.bind.annotation.PostMapping; -/* */ import org.springframework.web.bind.annotation.RequestMapping; -/* */ import org.springframework.web.bind.annotation.ResponseBody; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Controller -/* */ @RequestMapping({"/document"}) -/* */ public class DocumentController -/* */ extends BaseController -/* */ { -/* 47 */ private String prefix = "document"; -/* */ -/* */ @Autowired -/* */ private IDocumentService documentService; -/* */ -/* */ @Autowired -/* */ private IArchiveTypeService archiveTypeService; -/* */ -/* */ @Autowired -/* */ private IPhysicalTableColumnService physicalTableColumnService; -/* */ -/* */ @Autowired -/* */ private IPhysicalTableService physicalTableService; -/* */ -/* */ -/* */ @RequiresPermissions({"document"}) -/* */ @GetMapping -/* */ public String document() { -/* 65 */ return this.prefix + "/document"; -/* */ } -/* */ -/* */ -/* */ @RequiresPermissions({"document:qwgl"}) -/* */ @GetMapping({"/qwgl/{archiveId}/{type}/{id}"}) -/* */ public String qwgl(@PathVariable("archiveId") long archiveId, @PathVariable("type") String type, @PathVariable("id") String id, ModelMap mmap) { -/* 72 */ long tableId = TableUtil.getTableIdByArchiveTypeId(archiveId); -/* 73 */ mmap.put("tableId", Long.valueOf(tableId)); -/* 74 */ mmap.put("fileId", id); -/* 75 */ mmap.put("archiveTypeId", Long.valueOf(archiveId)); -/* 76 */ return this.prefix + "/document"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"document:list"}) -/* */ @PostMapping({"/list"}) -/* */ @ResponseBody -/* */ public TableDataInfo list(String ownerId, String tableId) { -/* 86 */ startPage(); -/* 87 */ Document document = new Document(); -/* 88 */ document.setTableId(tableId); -/* 89 */ document.setOwnerid(ownerId); -/* 90 */ List list = this.documentService.selectDocumentList(document); -/* 91 */ return getDataTable(list); -/* */ } -/* */ -/* */ @PostMapping({"/delete"}) -/* */ @ResponseBody -/* */ public AjaxResult delete(String id, String tableId) throws Exception { -/* 97 */ boolean res = this.documentService.deleteDocument(id, tableId); -/* */ -/* 99 */ return AjaxResult.success(!res ? "false" : "true"); -/* */ } -/* */ -/* */ @PostMapping({"/getArchiveTypeByTableId"}) -/* */ @ResponseBody -/* */ public AjaxResult getArchiveTypeByTableId(String tableId) { -/* 105 */ ArchiveType archiveType = this.documentService.selectArchiveTypeByTableId(tableId); -/* 106 */ return AjaxResult.success(archiveType); -/* */ } -/* */ } + + import com.archive.common.archiveUtil.TableUtil; + import com.archive.framework.web.controller.BaseController; + import com.archive.framework.web.domain.AjaxResult; + import com.archive.framework.web.page.TableDataInfo; + import com.archive.project.dasz.archivetype.domain.ArchiveType; + import com.archive.project.dasz.archivetype.service.IArchiveTypeService; + import com.archive.project.dasz.physicaltable.service.IPhysicalTableService; + import com.archive.project.dasz.physicaltablecolumn.service.IPhysicalTableColumnService; + import com.archive.project.document.domain.Document; + import com.archive.project.document.service.IDocumentService; + import java.util.List; + import org.apache.shiro.authz.annotation.RequiresPermissions; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Controller; + import org.springframework.ui.ModelMap; + import org.springframework.web.bind.annotation.GetMapping; + import org.springframework.web.bind.annotation.PathVariable; + import org.springframework.web.bind.annotation.PostMapping; + import org.springframework.web.bind.annotation.RequestMapping; + import org.springframework.web.bind.annotation.ResponseBody; + + + + + + + + + + + + + + + + + + + + @Controller + @RequestMapping({"/document"}) + public class DocumentController + extends BaseController + { + private String prefix = "document"; + + @Autowired + private IDocumentService documentService; + + @Autowired + private IArchiveTypeService archiveTypeService; + + @Autowired + private IPhysicalTableColumnService physicalTableColumnService; + + @Autowired + private IPhysicalTableService physicalTableService; + + + @RequiresPermissions({"document"}) + @GetMapping + public String document() { + return this.prefix + "/document"; + } + + + @RequiresPermissions({"document:qwgl"}) + @GetMapping({"/qwgl/{archiveId}/{type}/{id}"}) + public String qwgl(@PathVariable("archiveId") long archiveId, @PathVariable("type") String type, @PathVariable("id") String id, ModelMap mmap) { + long tableId = TableUtil.getTableIdByArchiveTypeId(archiveId); + mmap.put("tableId", Long.valueOf(tableId)); + mmap.put("fileId", id); + mmap.put("archiveTypeId", Long.valueOf(archiveId)); + return this.prefix + "/document"; + } + + + + + @RequiresPermissions({"document:list"}) + @PostMapping({"/list"}) + @ResponseBody + public TableDataInfo list(String ownerId, String tableId) { + startPage(); + Document document = new Document(); + document.setTableId(tableId); + document.setOwnerid(ownerId); + List list = this.documentService.selectDocumentList(document); + return getDataTable(list); + } + + @PostMapping({"/delete"}) + @ResponseBody + public AjaxResult delete(String id, String tableId) throws Exception { + boolean res = this.documentService.deleteDocument(id, tableId); + + return AjaxResult.success(!res ? "false" : "true"); + } + + @PostMapping({"/getArchiveTypeByTableId"}) + @ResponseBody + public AjaxResult getArchiveTypeByTableId(String tableId) { + ArchiveType archiveType = this.documentService.selectArchiveTypeByTableId(tableId); + return AjaxResult.success(archiveType); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\document\controller\DocumentController.class diff --git a/src/main/java/com/archive/project/document/domain/Document.java b/src/main/java/com/archive/project/document/domain/Document.java index 962f84d..fab4548 100644 --- a/src/main/java/com/archive/project/document/domain/Document.java +++ b/src/main/java/com/archive/project/document/domain/Document.java @@ -1,140 +1,140 @@ -/* */ package com.archive.project.document.domain; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class Document -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ private Long id; -/* */ private String createTime; -/* */ private String createUser; -/* */ private String fileName; -/* */ private String filehz; -/* */ private String filesize; -/* */ private String filepath; -/* */ private String filewaterpath; -/* */ private Long batcharchivetypeid; -/* */ private String ownerid; -/* */ private String tableId; -/* */ -/* */ public Long getId() { -/* 51 */ return this.id; -/* */ } -/* */ -/* */ public void setId(Long id) { -/* 55 */ this.id = id; -/* */ } -/* */ -/* */ public String getCreateTime() { -/* 59 */ return this.createTime; -/* */ } -/* */ -/* */ public void setCreateTime(String createTime) { -/* 63 */ this.createTime = createTime; -/* */ } -/* */ -/* */ public String getCreateUser() { -/* 67 */ return this.createUser; -/* */ } -/* */ -/* */ public void setCreateUser(String createUser) { -/* 71 */ this.createUser = createUser; -/* */ } -/* */ -/* */ public String getFileName() { -/* 75 */ return this.fileName; -/* */ } -/* */ -/* */ public void setFileName(String fileName) { -/* 79 */ this.fileName = fileName; -/* */ } -/* */ -/* */ public String getFilehz() { -/* 83 */ return this.filehz; -/* */ } -/* */ -/* */ public void setFilehz(String filehz) { -/* 87 */ this.filehz = filehz; -/* */ } -/* */ -/* */ public String getFilesize() { -/* 91 */ return this.filesize; -/* */ } -/* */ -/* */ public void setFilesize(String filesize) { -/* 95 */ this.filesize = filesize; -/* */ } -/* */ -/* */ public String getFilepath() { -/* 99 */ return this.filepath; -/* */ } -/* */ -/* */ public void setFilepath(String filepath) { -/* 103 */ this.filepath = filepath; -/* */ } -/* */ -/* */ public String getFilewaterpath() { -/* 107 */ return this.filewaterpath; -/* */ } -/* */ -/* */ public void setFilewaterpath(String filewaterpath) { -/* 111 */ this.filewaterpath = filewaterpath; -/* */ } -/* */ -/* */ public Long getBatcharchivetypeid() { -/* 115 */ return this.batcharchivetypeid; -/* */ } -/* */ -/* */ public void setBatcharchivetypeid(Long batcharchivetypeid) { -/* 119 */ this.batcharchivetypeid = batcharchivetypeid; -/* */ } -/* */ -/* */ public String getOwnerid() { -/* 123 */ return this.ownerid; -/* */ } -/* */ -/* */ public void setOwnerid(String ownerid) { -/* 127 */ this.ownerid = ownerid; -/* */ } -/* */ -/* */ public String getTableId() { -/* 131 */ return this.tableId; -/* */ } -/* */ -/* */ public void setTableId(String tableId) { -/* 135 */ this.tableId = tableId; -/* */ } -/* */ } + package com.archive.project.document.domain; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public class Document + { + private static final long serialVersionUID = 1L; + private Long id; + private String createTime; + private String createUser; + private String fileName; + private String filehz; + private String filesize; + private String filepath; + private String filewaterpath; + private Long batcharchivetypeid; + private String ownerid; + private String tableId; + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getCreateTime() { + return this.createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUser() { + return this.createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public String getFileName() { + return this.fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFilehz() { + return this.filehz; + } + + public void setFilehz(String filehz) { + this.filehz = filehz; + } + + public String getFilesize() { + return this.filesize; + } + + public void setFilesize(String filesize) { + this.filesize = filesize; + } + + public String getFilepath() { + return this.filepath; + } + + public void setFilepath(String filepath) { + this.filepath = filepath; + } + + public String getFilewaterpath() { + return this.filewaterpath; + } + + public void setFilewaterpath(String filewaterpath) { + this.filewaterpath = filewaterpath; + } + + public Long getBatcharchivetypeid() { + return this.batcharchivetypeid; + } + + public void setBatcharchivetypeid(Long batcharchivetypeid) { + this.batcharchivetypeid = batcharchivetypeid; + } + + public String getOwnerid() { + return this.ownerid; + } + + public void setOwnerid(String ownerid) { + this.ownerid = ownerid; + } + + public String getTableId() { + return this.tableId; + } + + public void setTableId(String tableId) { + this.tableId = tableId; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\document\domain\Document.class diff --git a/src/main/java/com/archive/project/document/service/impl/DocumentServiceImpl.java b/src/main/java/com/archive/project/document/service/impl/DocumentServiceImpl.java index 9fc6a0d..8f09e37 100644 --- a/src/main/java/com/archive/project/document/service/impl/DocumentServiceImpl.java +++ b/src/main/java/com/archive/project/document/service/impl/DocumentServiceImpl.java @@ -1,211 +1,211 @@ -/* */ package com.archive.project.document.service.impl + package com.archive.project.document.service.impl ; -/* */ -/* */ import com.archive.common.archiveUtil.FileUtils; -/* */ import com.archive.common.archiveUtil.TableUtil; -/* */ import com.archive.common.utils.DateUtils; -/* */ import com.archive.common.utils.security.ShiroUtils; -/* */ import com.archive.framework.config.ArchiveConfig; -/* */ import com.archive.project.common.service.IExecuteSqlService; -/* */ import com.archive.project.dajs.archiveimportbatch.service.IArchiveImportBatchService; -/* */ import com.archive.project.dasz.archivetype.domain.ArchiveType; -/* */ import com.archive.project.dasz.archivetype.mapper.ArchiveTypeMapper; -/* */ import com.archive.project.dasz.ccgl.service.ICcglService; -/* */ import com.archive.project.dasz.physicaltable.domain.PhysicalTable; -/* */ import com.archive.project.dasz.physicaltable.mapper.PhysicalTableMapper; -/* */ import com.archive.project.dasz.physicaltablecolumn.mapper.PhysicalTableColumnMapper; -/* */ import com.archive.project.document.domain.Document; -/* */ import com.archive.project.document.service.IDocumentService; -/* */ import com.archive.project.system.dict.service.IDictTypeService; -/* */ import com.archive.project.system.user.domain.User; -/* */ import java.io.File; -/* */ import java.io.IOException; -/* */ import java.util.ArrayList; -/* */ import java.util.HashMap; -/* */ import java.util.LinkedHashMap; -/* */ import java.util.List; -/* */ import java.util.Map; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Service; -/* */ import org.springframework.web.multipart.MultipartFile; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Service -/* */ public class DocumentServiceImpl -/* */ implements IDocumentService -/* */ { -/* */ @Autowired -/* */ private ArchiveTypeMapper archiveTypeMapper; -/* */ @Autowired -/* */ private PhysicalTableMapper physicalTableMapper; -/* */ @Autowired -/* */ private PhysicalTableColumnMapper physicalTableColumnMapper; -/* */ @Autowired -/* */ private IExecuteSqlService executeSqlService; -/* */ @Autowired -/* */ private ICcglService ccglService; -/* */ @Autowired -/* */ private IDictTypeService dictTypeService; -/* */ @Autowired -/* */ private IArchiveImportBatchService iArchiveImportBatchService; -/* */ -/* */ public List selectDocumentList(Document document) { -/* 64 */ List list = new ArrayList<>(); -/* 65 */ if (document.getOwnerid() != null && document.getTableId() != null) { -/* 66 */ String ownerid = document.getOwnerid(); -/* 67 */ String tableId = document.getTableId(); -/* 68 */ String tableName = TableUtil.getTableName(Long.valueOf(Long.parseLong(tableId))); -/* 69 */ String docuumentTableName = tableName.toLowerCase().replace("_folder", "_document"); -/* 70 */ docuumentTableName = docuumentTableName.toLowerCase().replace("_file", "_document"); -/* 71 */ String docTableId = TableUtil.getTableId(docuumentTableName); -/* 72 */ String sql = "select id,create_Time,create_User,fileName,filehz,filesize,filepath,filewaterpath,batcharchivetypeid,ownerid,tableId from " + docuumentTableName + " where ownerid='" + ownerid + "' and tableId='" + tableId + "'"; -/* */ -/* 74 */ List> datalist = this.executeSqlService.queryList(sql); -/* 75 */ for (int i = 0; i < datalist.size(); i++) { -/* 76 */ Document dc = new Document(); -/* 77 */ dc.setId(Long.valueOf((((LinkedHashMap)datalist.get(i)).get("id") == null) ? 0L : Long.parseLong(((LinkedHashMap)datalist.get(i)).get("id").toString()))); -/* 78 */ dc.setCreateTime((((LinkedHashMap)datalist.get(i)).get("create_Time") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("create_Time").toString()); -/* 79 */ dc.setCreateUser((((LinkedHashMap)datalist.get(i)).get("create_User") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("create_User").toString()); -/* 80 */ dc.setFileName((((LinkedHashMap)datalist.get(i)).get("fileName") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("fileName").toString()); -/* 81 */ dc.setFilehz((((LinkedHashMap)datalist.get(i)).get("filehz") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("filehz").toString()); -/* 82 */ dc.setFilesize((((LinkedHashMap)datalist.get(i)).get("filesize") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("filesize").toString()); -/* 83 */ dc.setFilepath((((LinkedHashMap)datalist.get(i)).get("filepath") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("filepath").toString()); -/* 84 */ dc.setFilewaterpath((((LinkedHashMap)datalist.get(i)).get("filewaterpath") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("filewaterpath").toString()); -/* 85 */ dc.setBatcharchivetypeid(Long.valueOf((((LinkedHashMap)datalist.get(i)).get("batcharchivetypeid") == null) ? 0L : Long.parseLong(((LinkedHashMap)datalist.get(i)).get("batcharchivetypeid").toString()))); -/* 86 */ dc.setOwnerid((((LinkedHashMap)datalist.get(i)).get("ownerid") == null) ? "0" : ((LinkedHashMap)datalist.get(i)).get("ownerid").toString()); -/* 87 */ dc.setTableId((((LinkedHashMap)datalist.get(i)).get("tableId") == null) ? "0" : ((LinkedHashMap)datalist.get(i)).get("tableId").toString()); -/* 88 */ list.add(dc); -/* */ } -/* */ } -/* 91 */ return list; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public Map getTableIdByArchiveTypeId(String archiveTypeId, String type) { -/* 105 */ Map map = new HashMap<>(); -/* 106 */ PhysicalTable physicalTable = new PhysicalTable(); -/* 107 */ physicalTable.setTableCode(type); -/* 108 */ physicalTable.setArchivetypeid(archiveTypeId); -/* 109 */ List tablesList = this.physicalTableMapper.selectPhysicalTableList(physicalTable); -/* 110 */ if (tablesList != null && tablesList.size() > 0) { -/* 111 */ String tableName = ((PhysicalTable)tablesList.get(0)).getTablename(); -/* 112 */ Long tableId = ((PhysicalTable)tablesList.get(0)).getId(); -/* 113 */ map.put("tableId", tableId); -/* 114 */ map.put("tableName", tableName); -/* */ } -/* 116 */ return map; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public boolean uploadFile(MultipartFile[] files, long tableId, long id) throws IOException { -/* 128 */ boolean res = false; -/* 129 */ if (files != null) { -/* 130 */ for (int i = 0; i < files.length; i++) { -/* 131 */ String fileName = files[i].getOriginalFilename(); -/* */ -/* */ -/* 134 */ String xdlj = this.ccglService.getCreateDocumentPathByFile(id, tableId); -/* 135 */ String filepath = ArchiveConfig.getInstance().getUploadPath() + File.separator + "DocumentFile" + File.separator + xdlj; -/* */ -/* 137 */ File localFile = new File(filepath); -/* 138 */ if (!localFile.exists()) { -/* 139 */ localFile.mkdirs(); -/* */ } -/* 141 */ String path = filepath + File.separator + fileName; -/* 142 */ File server_file = new File(path); -/* 143 */ files[i].transferTo(server_file); -/* 144 */ String newfileName = server_file.getName().substring(0, server_file.getName().lastIndexOf(".")); -/* 145 */ String hz = server_file.getName().substring(server_file.getName().lastIndexOf(".") + 1, server_file.getName().length()); -/* 146 */ String fileSize = FileUtils.changeValueType(Long.valueOf(server_file.length())); -/* */ -/* 148 */ String tableName = TableUtil.getTableName(Long.valueOf(tableId)); -/* 149 */ String docuumentTableName = tableName.toLowerCase().replace("_file", "_document"); -/* 150 */ String docTableId = TableUtil.getTableId(docuumentTableName); -/* 151 */ long newId = this.iArchiveImportBatchService.getTableNewId(Long.parseLong(docTableId)); -/* 152 */ User user = ShiroUtils.getSysUser(); -/* 153 */ String loginName = user.getLoginName(); -/* */ -/* */ -/* 156 */ String inserSql = "insert into " + docuumentTableName + "(id,ownerid,filename,filesize,filepath,filehz,tableId,create_user,create_time) values(" + newId + "," + id + ",'" + newfileName + "','" + fileSize + "','" + server_file.getPath().replaceAll("\\\\", "\\\\\\\\") + "','" + hz + "','" + tableId + "','" + loginName + "','" + DateUtils.getTime() + "')"; -/* 157 */ res = this.executeSqlService.insert(inserSql); -/* 158 */ System.out.println("文件" + path + "上传成功"); -/* */ } -/* */ } -/* 161 */ return res; -/* */ } -/* */ -/* */ -/* */ public boolean deleteDocument(String id, String tableId) throws Exception { -/* 166 */ boolean res = false; -/* 167 */ String fileTableName = TableUtil.getTableName(Long.valueOf(Long.parseLong(tableId))); -/* 168 */ String docTableName = fileTableName.toUpperCase().replace("_FOLDER", "_DOCUMENT"); -/* 169 */ docTableName = docTableName.toUpperCase().replace("_FILE", "_DOCUMENT"); -/* */ -/* */ -/* 172 */ String selectSql = "select filepath,filewaterpath,ownerid from " + docTableName + " where id=" + id; -/* 173 */ List> datalist = this.executeSqlService.queryList(selectSql); -/* 174 */ if (datalist != null && datalist.size() > 0 && datalist.get(0) != null) { -/* 175 */ String path = (((LinkedHashMap)datalist.get(0)).get("filepath") == null) ? "" : ((LinkedHashMap)datalist.get(0)).get("filepath").toString(); -/* */ -/* 177 */ String waterPath = (((LinkedHashMap)datalist.get(0)).get("filewaterpath") == null) ? "" : ((LinkedHashMap)datalist.get(0)).get("filewaterpath").toString(); -/* 178 */ String ownerId = (((LinkedHashMap)datalist.get(0)).get("ownerid") == null) ? "" : ((LinkedHashMap)datalist.get(0)).get("ownerid").toString(); -/* 179 */ File file = new File(path); -/* 180 */ if (file.exists()) { -/* 181 */ file.delete(); -/* */ } -/* 183 */ File waterFile = new File(waterPath); -/* 184 */ if (waterFile.exists()) { -/* 185 */ waterFile.delete(); -/* */ } -/* 187 */ String sql = "delete from " + docTableName + " where id=" + id; -/* 188 */ res = this.executeSqlService.delete(sql); -/* */ -/* 190 */ String updateSql = "update " + fileTableName + " set dqzws=dqzws-1 where id=" + ownerId; -/* 191 */ this.executeSqlService.update(updateSql); -/* */ } -/* 193 */ return res; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public ArchiveType selectArchiveTypeByTableId(String tableId) { -/* 203 */ long archiveTypeId = TableUtil.getArchiveTypeIdByTableId(Long.parseLong(tableId)); -/* 204 */ return this.archiveTypeMapper.selectArchiveTypeById(Long.valueOf(archiveTypeId)); -/* */ } -/* */ } + + import com.archive.common.archiveUtil.FileUtils; + import com.archive.common.archiveUtil.TableUtil; + import com.archive.common.utils.DateUtils; + import com.archive.common.utils.security.ShiroUtils; + import com.archive.framework.config.ArchiveConfig; + import com.archive.project.common.service.IExecuteSqlService; + import com.archive.project.dajs.archiveimportbatch.service.IArchiveImportBatchService; + import com.archive.project.dasz.archivetype.domain.ArchiveType; + import com.archive.project.dasz.archivetype.mapper.ArchiveTypeMapper; + import com.archive.project.dasz.ccgl.service.ICcglService; + import com.archive.project.dasz.physicaltable.domain.PhysicalTable; + import com.archive.project.dasz.physicaltable.mapper.PhysicalTableMapper; + import com.archive.project.dasz.physicaltablecolumn.mapper.PhysicalTableColumnMapper; + import com.archive.project.document.domain.Document; + import com.archive.project.document.service.IDocumentService; + import com.archive.project.system.dict.service.IDictTypeService; + import com.archive.project.system.user.domain.User; + import java.io.File; + import java.io.IOException; + import java.util.ArrayList; + import java.util.HashMap; + import java.util.LinkedHashMap; + import java.util.List; + import java.util.Map; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + import org.springframework.web.multipart.MultipartFile; + + + + + + + + + + + + + + + @Service + public class DocumentServiceImpl + implements IDocumentService + { + @Autowired + private ArchiveTypeMapper archiveTypeMapper; + @Autowired + private PhysicalTableMapper physicalTableMapper; + @Autowired + private PhysicalTableColumnMapper physicalTableColumnMapper; + @Autowired + private IExecuteSqlService executeSqlService; + @Autowired + private ICcglService ccglService; + @Autowired + private IDictTypeService dictTypeService; + @Autowired + private IArchiveImportBatchService iArchiveImportBatchService; + + public List selectDocumentList(Document document) { + List list = new ArrayList<>(); + if (document.getOwnerid() != null && document.getTableId() != null) { + String ownerid = document.getOwnerid(); + String tableId = document.getTableId(); + String tableName = TableUtil.getTableName(Long.valueOf(Long.parseLong(tableId))); + String docuumentTableName = tableName.toLowerCase().replace("_folder", "_document"); + docuumentTableName = docuumentTableName.toLowerCase().replace("_file", "_document"); + String docTableId = TableUtil.getTableId(docuumentTableName); + String sql = "select id,create_Time,create_User,fileName,filehz,filesize,filepath,filewaterpath,batcharchivetypeid,ownerid,tableId from " + docuumentTableName + " where ownerid='" + ownerid + "' and tableId='" + tableId + "'"; + + List> datalist = this.executeSqlService.queryList(sql); + for (int i = 0; i < datalist.size(); i++) { + Document dc = new Document(); + dc.setId(Long.valueOf((((LinkedHashMap)datalist.get(i)).get("id") == null) ? 0L : Long.parseLong(((LinkedHashMap)datalist.get(i)).get("id").toString()))); + dc.setCreateTime((((LinkedHashMap)datalist.get(i)).get("create_Time") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("create_Time").toString()); + dc.setCreateUser((((LinkedHashMap)datalist.get(i)).get("create_User") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("create_User").toString()); + dc.setFileName((((LinkedHashMap)datalist.get(i)).get("fileName") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("fileName").toString()); + dc.setFilehz((((LinkedHashMap)datalist.get(i)).get("filehz") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("filehz").toString()); + dc.setFilesize((((LinkedHashMap)datalist.get(i)).get("filesize") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("filesize").toString()); + dc.setFilepath((((LinkedHashMap)datalist.get(i)).get("filepath") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("filepath").toString()); + dc.setFilewaterpath((((LinkedHashMap)datalist.get(i)).get("filewaterpath") == null) ? "" : ((LinkedHashMap)datalist.get(i)).get("filewaterpath").toString()); + dc.setBatcharchivetypeid(Long.valueOf((((LinkedHashMap)datalist.get(i)).get("batcharchivetypeid") == null) ? 0L : Long.parseLong(((LinkedHashMap)datalist.get(i)).get("batcharchivetypeid").toString()))); + dc.setOwnerid((((LinkedHashMap)datalist.get(i)).get("ownerid") == null) ? "0" : ((LinkedHashMap)datalist.get(i)).get("ownerid").toString()); + dc.setTableId((((LinkedHashMap)datalist.get(i)).get("tableId") == null) ? "0" : ((LinkedHashMap)datalist.get(i)).get("tableId").toString()); + list.add(dc); + } + } + return list; + } + + + + + + + + + + + + public Map getTableIdByArchiveTypeId(String archiveTypeId, String type) { + Map map = new HashMap<>(); + PhysicalTable physicalTable = new PhysicalTable(); + physicalTable.setTableCode(type); + physicalTable.setArchivetypeid(archiveTypeId); + List tablesList = this.physicalTableMapper.selectPhysicalTableList(physicalTable); + if (tablesList != null && tablesList.size() > 0) { + String tableName = ((PhysicalTable)tablesList.get(0)).getTablename(); + Long tableId = ((PhysicalTable)tablesList.get(0)).getId(); + map.put("tableId", tableId); + map.put("tableName", tableName); + } + return map; + } + + + + + + + + + + public boolean uploadFile(MultipartFile[] files, long tableId, long id) throws IOException { + boolean res = false; + if (files != null) { + for (int i = 0; i < files.length; i++) { + String fileName = files[i].getOriginalFilename(); + + + String xdlj = this.ccglService.getCreateDocumentPathByFile(id, tableId); + String filepath = ArchiveConfig.getInstance().getUploadPath() + File.separator + "DocumentFile" + File.separator + xdlj; + + File localFile = new File(filepath); + if (!localFile.exists()) { + localFile.mkdirs(); + } + String path = filepath + File.separator + fileName; + File server_file = new File(path); + files[i].transferTo(server_file); + String newfileName = server_file.getName().substring(0, server_file.getName().lastIndexOf(".")); + String hz = server_file.getName().substring(server_file.getName().lastIndexOf(".") + 1, server_file.getName().length()); + String fileSize = FileUtils.changeValueType(Long.valueOf(server_file.length())); + + String tableName = TableUtil.getTableName(Long.valueOf(tableId)); + String docuumentTableName = tableName.toLowerCase().replace("_file", "_document"); + String docTableId = TableUtil.getTableId(docuumentTableName); + long newId = this.iArchiveImportBatchService.getTableNewId(Long.parseLong(docTableId)); + User user = ShiroUtils.getSysUser(); + String loginName = user.getLoginName(); + + + String inserSql = "insert into " + docuumentTableName + "(id,ownerid,filename,filesize,filepath,filehz,tableId,create_user,create_time) values(" + newId + "," + id + ",'" + newfileName + "','" + fileSize + "','" + server_file.getPath().replaceAll("\\\\", "\\\\\\\\") + "','" + hz + "','" + tableId + "','" + loginName + "','" + DateUtils.getTime() + "')"; + res = this.executeSqlService.insert(inserSql); + System.out.println("文件" + path + "上传成功"); + } + } + return res; + } + + + public boolean deleteDocument(String id, String tableId) throws Exception { + boolean res = false; + String fileTableName = TableUtil.getTableName(Long.valueOf(Long.parseLong(tableId))); + String docTableName = fileTableName.toUpperCase().replace("_FOLDER", "_DOCUMENT"); + docTableName = docTableName.toUpperCase().replace("_FILE", "_DOCUMENT"); + + + String selectSql = "select filepath,filewaterpath,ownerid from " + docTableName + " where id=" + id; + List> datalist = this.executeSqlService.queryList(selectSql); + if (datalist != null && datalist.size() > 0 && datalist.get(0) != null) { + String path = (((LinkedHashMap)datalist.get(0)).get("filepath") == null) ? "" : ((LinkedHashMap)datalist.get(0)).get("filepath").toString(); + + String waterPath = (((LinkedHashMap)datalist.get(0)).get("filewaterpath") == null) ? "" : ((LinkedHashMap)datalist.get(0)).get("filewaterpath").toString(); + String ownerId = (((LinkedHashMap)datalist.get(0)).get("ownerid") == null) ? "" : ((LinkedHashMap)datalist.get(0)).get("ownerid").toString(); + File file = new File(path); + if (file.exists()) { + file.delete(); + } + File waterFile = new File(waterPath); + if (waterFile.exists()) { + waterFile.delete(); + } + String sql = "delete from " + docTableName + " where id=" + id; + res = this.executeSqlService.delete(sql); + + String updateSql = "update " + fileTableName + " set dqzws=dqzws-1 where id=" + ownerId; + this.executeSqlService.update(updateSql); + } + return res; + } + + + + + + + + public ArchiveType selectArchiveTypeByTableId(String tableId) { + long archiveTypeId = TableUtil.getArchiveTypeIdByTableId(Long.parseLong(tableId)); + return this.archiveTypeMapper.selectArchiveTypeById(Long.valueOf(archiveTypeId)); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\document\service\impl\DocumentServiceImpl.class diff --git a/src/main/java/com/archive/project/monitor/druid/DruidController.java b/src/main/java/com/archive/project/monitor/druid/DruidController.java index e3e5fc7..a3d53f4 100644 --- a/src/main/java/com/archive/project/monitor/druid/DruidController.java +++ b/src/main/java/com/archive/project/monitor/druid/DruidController.java @@ -1,30 +1,30 @@ -/* */ package com.archive.project.monitor.druid + package com.archive.project.monitor.druid ; -/* */ -/* */ import com.archive.framework.web.controller.BaseController; -/* */ import org.apache.shiro.authz.annotation.RequiresPermissions; -/* */ import org.springframework.stereotype.Controller; -/* */ import org.springframework.web.bind.annotation.GetMapping; -/* */ import org.springframework.web.bind.annotation.RequestMapping; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Controller -/* */ @RequestMapping({"/monitor/data"}) -/* */ public class DruidController -/* */ extends BaseController -/* */ { -/* 18 */ private String prefix = "/druid"; -/* */ -/* */ -/* */ @RequiresPermissions({"monitor:data:view"}) -/* */ @GetMapping -/* */ public String index() { -/* 24 */ return redirect(this.prefix + "/index"); -/* */ } -/* */ } + + import com.archive.framework.web.controller.BaseController; + import org.apache.shiro.authz.annotation.RequiresPermissions; + import org.springframework.stereotype.Controller; + import org.springframework.web.bind.annotation.GetMapping; + import org.springframework.web.bind.annotation.RequestMapping; + + + + + + @Controller + @RequestMapping({"/monitor/data"}) + public class DruidController + extends BaseController + { + private String prefix = "/druid"; + + + @RequiresPermissions({"monitor:data:view"}) + @GetMapping + public String index() { + return redirect(this.prefix + "/index"); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\monitor\druid\DruidController.class diff --git a/src/main/java/com/archive/project/system/dept/service/DeptServiceImpl.java b/src/main/java/com/archive/project/system/dept/service/DeptServiceImpl.java index 2e9199e..0f34d4f 100644 --- a/src/main/java/com/archive/project/system/dept/service/DeptServiceImpl.java +++ b/src/main/java/com/archive/project/system/dept/service/DeptServiceImpl.java @@ -1,408 +1,408 @@ -/* */ package com.archive.project.system.dept.service + package com.archive.project.system.dept.service ; -/* */ -/* */ import com.archive.common.exception.BusinessException; -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.common.utils.security.ShiroUtils; -/* */ import com.archive.framework.aspectj.lang.annotation.DataScope; -/* */ import com.archive.framework.config.ArchiveConfig; -/* */ import com.archive.framework.web.domain.Ztree; -/* */ import com.archive.project.system.dept.domain.Dept; -/* */ import com.archive.project.system.dept.mapper.DeptMapper; -/* */ import com.archive.project.system.dept.service.IDeptService; -/* */ import com.archive.project.system.role.domain.Role; -/* */ import java.util.ArrayList; -/* */ import java.util.Iterator; -/* */ import java.util.List; -/* */ import org.apache.commons.lang3.ArrayUtils; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Service; -/* */ import org.springframework.transaction.annotation.Transactional; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Service -/* */ public class DeptServiceImpl -/* */ implements IDeptService -/* */ { -/* */ @Autowired -/* */ private DeptMapper deptMapper; -/* */ @Autowired -/* */ private ArchiveConfig archiveConfig; -/* */ -/* */ @DataScope(deptAlias = "d") -/* */ public List selectDeptList(Dept dept) { -/* 47 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 48 */ return this.deptMapper.selectDeptList(dept); -/* */ } -/* 50 */ if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 51 */ return this.deptMapper.selectDeptListSqlite(dept); -/* */ } -/* 53 */ return this.deptMapper.selectDeptList(dept); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @DataScope(deptAlias = "d") -/* */ public List selectDeptTree(Dept dept) { -/* 68 */ List deptList = null; -/* 69 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 70 */ deptList = this.deptMapper.selectDeptList(dept); -/* */ } -/* 72 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 73 */ deptList = this.deptMapper.selectDeptListSqlite(dept); -/* */ } -/* 75 */ List ztrees = initZtree(deptList); -/* 76 */ return ztrees; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @DataScope(deptAlias = "d") -/* */ public List selectDeptTreeExcludeChild(Dept dept) { -/* 89 */ Long deptId = dept.getDeptId(); -/* 90 */ List deptList = null; -/* 91 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 92 */ deptList = this.deptMapper.selectDeptList(dept); -/* */ } -/* 94 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 95 */ deptList = this.deptMapper.selectDeptListSqlite(dept); -/* */ } -/* 97 */ Iterator it = deptList.iterator(); -/* 98 */ while (it.hasNext()) { -/* */ -/* 100 */ Dept d = it.next(); -/* 101 */ if (d.getDeptId().intValue() == deptId.longValue() || -/* 102 */ ArrayUtils.contains((Object[])StringUtils.split(d.getAncestors(), ","), deptId + "")) -/* */ { -/* 104 */ it.remove(); -/* */ } -/* */ } -/* 107 */ List ztrees = initZtree(deptList); -/* 108 */ return ztrees; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public List roleDeptTreeData(Role role) { -/* 120 */ Long roleId = role.getRoleId(); -/* 121 */ List ztrees = new ArrayList<>(); -/* 122 */ List deptList = selectDeptList(new Dept()); -/* 123 */ if (StringUtils.isNotNull(roleId)) { -/* */ -/* 125 */ List roleDeptList = null; -/* 126 */ if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 127 */ roleDeptList = this.deptMapper.selectRoleDeptTreeSqlite(roleId); -/* */ } else { -/* 129 */ roleDeptList = this.deptMapper.selectRoleDeptTree(roleId); -/* */ } -/* */ -/* 132 */ ztrees = initZtree(deptList, roleDeptList); -/* */ } -/* */ else { -/* */ -/* 136 */ ztrees = initZtree(deptList); -/* */ } -/* 138 */ return ztrees; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public List initZtree(List deptList) { -/* 149 */ return initZtree(deptList, null); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public List initZtree(List deptList, List roleDeptList) { -/* 161 */ List ztrees = new ArrayList<>(); -/* 162 */ boolean isCheck = StringUtils.isNotNull(roleDeptList); -/* 163 */ for (Dept dept : deptList) { -/* */ -/* 165 */ if ("0".equals(dept.getStatus())) { -/* */ -/* 167 */ Ztree ztree = new Ztree(); -/* 168 */ ztree.setId(dept.getDeptId()); -/* 169 */ ztree.setpId(dept.getParentId()); -/* 170 */ ztree.setName(dept.getDeptName()); -/* 171 */ ztree.setTitle(dept.getDeptName()); -/* 172 */ if (isCheck) -/* */ { -/* 174 */ ztree.setChecked(roleDeptList.contains(dept.getDeptId() + dept.getDeptName())); -/* */ } -/* 176 */ ztrees.add(ztree); -/* */ } -/* */ } -/* 179 */ return ztrees; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int selectDeptCount(Long parentId) { -/* 191 */ Dept dept = new Dept(); -/* 192 */ dept.setParentId(parentId); -/* 193 */ return this.deptMapper.selectDeptCount(dept); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public boolean checkDeptExistUser(Long deptId) { -/* 205 */ int result = this.deptMapper.checkDeptExistUser(deptId); -/* 206 */ return (result > 0); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int deleteDeptById(Long deptId) { -/* 218 */ return this.deptMapper.deleteDeptById(deptId); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int insertDept(Dept dept) { -/* 230 */ Dept info = this.deptMapper.selectDeptById(dept.getParentId()); -/* */ -/* 232 */ if (!"0".equals(info.getStatus())) -/* */ { -/* 234 */ throw new BusinessException("部门停用,不允许新增"); -/* */ } -/* 236 */ dept.setCreateBy(ShiroUtils.getLoginName()); -/* 237 */ dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); -/* 238 */ if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 239 */ return this.deptMapper.insertDeptSqlite(dept); -/* */ } -/* 241 */ return this.deptMapper.insertDept(dept); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Transactional -/* */ public int updateDept(Dept dept) { -/* 255 */ Dept newParentDept = this.deptMapper.selectDeptById(dept.getParentId()); -/* 256 */ Dept oldDept = selectDeptById(dept.getDeptId()); -/* 257 */ if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { -/* */ -/* 259 */ String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); -/* 260 */ String oldAncestors = oldDept.getAncestors(); -/* 261 */ dept.setAncestors(newAncestors); -/* 262 */ updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); -/* */ } -/* 264 */ dept.setUpdateBy(ShiroUtils.getLoginName()); -/* 265 */ int result = 0; -/* 266 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 267 */ result = this.deptMapper.updateDept(dept); -/* */ } -/* 269 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 270 */ result = this.deptMapper.updateDeptSqlite(dept); -/* */ } -/* */ -/* 273 */ if ("0".equals(dept.getStatus())) -/* */ { -/* */ -/* 276 */ updateParentDeptStatus(dept); -/* */ } -/* 278 */ return result; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private void updateParentDeptStatus(Dept dept) { -/* 288 */ String updateBy = dept.getUpdateBy(); -/* 289 */ dept = this.deptMapper.selectDeptById(dept.getDeptId()); -/* 290 */ dept.setUpdateBy(updateBy); -/* 291 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 292 */ this.deptMapper.updateDeptStatus(dept); -/* */ } -/* 294 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 295 */ this.deptMapper.updateDeptStatusSqlite(dept); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) { -/* 309 */ List children = null; -/* 310 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 311 */ children = this.deptMapper.selectChildrenDeptById(deptId); -/* */ } -/* 313 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 314 */ children = this.deptMapper.selectChildrenDeptByIdSqlite(deptId); -/* */ } -/* */ -/* 317 */ for (Dept child : children) -/* */ { -/* 319 */ child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors)); -/* */ } -/* 321 */ if (children.size() > 0) -/* */ { -/* 323 */ this.deptMapper.updateDeptChildren(children); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void updateDeptChildren(Long deptId, String ancestors) { -/* 335 */ Dept dept = new Dept(); -/* 336 */ dept.setParentId(deptId); -/* 337 */ List childrens = null; -/* 338 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 339 */ childrens = this.deptMapper.selectDeptList(dept); -/* */ } -/* 341 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 342 */ childrens = this.deptMapper.selectDeptListSqlite(dept); -/* */ } -/* 344 */ for (Dept children : childrens) -/* */ { -/* 346 */ children.setAncestors(ancestors + "," + dept.getParentId()); -/* */ } -/* 348 */ if (childrens.size() > 0) -/* */ { -/* 350 */ this.deptMapper.updateDeptChildren(childrens); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public Dept selectDeptById(Long deptId) { -/* 363 */ return this.deptMapper.selectDeptById(deptId); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int selectNormalChildrenDeptById(Long deptId) { -/* 375 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 376 */ return this.deptMapper.selectNormalChildrenDeptById(deptId); -/* */ } -/* 378 */ if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 379 */ return this.deptMapper.selectNormalChildrenDeptByIdSqlite(deptId); -/* */ } -/* 381 */ return this.deptMapper.selectNormalChildrenDeptById(deptId); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public String checkDeptNameUnique(Dept dept) { -/* 395 */ Long deptId = Long.valueOf(StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId().longValue()); -/* 396 */ Dept info = this.deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); -/* 397 */ if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) -/* */ { -/* 399 */ return "1"; -/* */ } -/* 401 */ return "0"; -/* */ } -/* */ } + + import com.archive.common.exception.BusinessException; + import com.archive.common.utils.StringUtils; + import com.archive.common.utils.security.ShiroUtils; + import com.archive.framework.aspectj.lang.annotation.DataScope; + import com.archive.framework.config.ArchiveConfig; + import com.archive.framework.web.domain.Ztree; + import com.archive.project.system.dept.domain.Dept; + import com.archive.project.system.dept.mapper.DeptMapper; + import com.archive.project.system.dept.service.IDeptService; + import com.archive.project.system.role.domain.Role; + import java.util.ArrayList; + import java.util.Iterator; + import java.util.List; + import org.apache.commons.lang3.ArrayUtils; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + import org.springframework.transaction.annotation.Transactional; + + + + + + + + + + + + + + + + + @Service + public class DeptServiceImpl + implements IDeptService + { + @Autowired + private DeptMapper deptMapper; + @Autowired + private ArchiveConfig archiveConfig; + + @DataScope(deptAlias = "d") + public List selectDeptList(Dept dept) { + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + return this.deptMapper.selectDeptList(dept); + } + if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + return this.deptMapper.selectDeptListSqlite(dept); + } + return this.deptMapper.selectDeptList(dept); + } + + + + + + + + + + + + @DataScope(deptAlias = "d") + public List selectDeptTree(Dept dept) { + List deptList = null; + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + deptList = this.deptMapper.selectDeptList(dept); + } + else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + deptList = this.deptMapper.selectDeptListSqlite(dept); + } + List ztrees = initZtree(deptList); + return ztrees; + } + + + + + + + + + + @DataScope(deptAlias = "d") + public List selectDeptTreeExcludeChild(Dept dept) { + Long deptId = dept.getDeptId(); + List deptList = null; + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + deptList = this.deptMapper.selectDeptList(dept); + } + else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + deptList = this.deptMapper.selectDeptListSqlite(dept); + } + Iterator it = deptList.iterator(); + while (it.hasNext()) { + + Dept d = it.next(); + if (d.getDeptId().intValue() == deptId.longValue() || + ArrayUtils.contains((Object[])StringUtils.split(d.getAncestors(), ","), deptId + "")) + { + it.remove(); + } + } + List ztrees = initZtree(deptList); + return ztrees; + } + + + + + + + + + + public List roleDeptTreeData(Role role) { + Long roleId = role.getRoleId(); + List ztrees = new ArrayList<>(); + List deptList = selectDeptList(new Dept()); + if (StringUtils.isNotNull(roleId)) { + + List roleDeptList = null; + if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + roleDeptList = this.deptMapper.selectRoleDeptTreeSqlite(roleId); + } else { + roleDeptList = this.deptMapper.selectRoleDeptTree(roleId); + } + + ztrees = initZtree(deptList, roleDeptList); + } + else { + + ztrees = initZtree(deptList); + } + return ztrees; + } + + + + + + + + + public List initZtree(List deptList) { + return initZtree(deptList, null); + } + + + + + + + + + + public List initZtree(List deptList, List roleDeptList) { + List ztrees = new ArrayList<>(); + boolean isCheck = StringUtils.isNotNull(roleDeptList); + for (Dept dept : deptList) { + + if ("0".equals(dept.getStatus())) { + + Ztree ztree = new Ztree(); + ztree.setId(dept.getDeptId()); + ztree.setpId(dept.getParentId()); + ztree.setName(dept.getDeptName()); + ztree.setTitle(dept.getDeptName()); + if (isCheck) + { + ztree.setChecked(roleDeptList.contains(dept.getDeptId() + dept.getDeptName())); + } + ztrees.add(ztree); + } + } + return ztrees; + } + + + + + + + + + + public int selectDeptCount(Long parentId) { + Dept dept = new Dept(); + dept.setParentId(parentId); + return this.deptMapper.selectDeptCount(dept); + } + + + + + + + + + + public boolean checkDeptExistUser(Long deptId) { + int result = this.deptMapper.checkDeptExistUser(deptId); + return (result > 0); + } + + + + + + + + + + public int deleteDeptById(Long deptId) { + return this.deptMapper.deleteDeptById(deptId); + } + + + + + + + + + + public int insertDept(Dept dept) { + Dept info = this.deptMapper.selectDeptById(dept.getParentId()); + + if (!"0".equals(info.getStatus())) + { + throw new BusinessException("部门停用,不允许新增"); + } + dept.setCreateBy(ShiroUtils.getLoginName()); + dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); + if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + return this.deptMapper.insertDeptSqlite(dept); + } + return this.deptMapper.insertDept(dept); + } + + + + + + + + + + + @Transactional + public int updateDept(Dept dept) { + Dept newParentDept = this.deptMapper.selectDeptById(dept.getParentId()); + Dept oldDept = selectDeptById(dept.getDeptId()); + if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { + + String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); + String oldAncestors = oldDept.getAncestors(); + dept.setAncestors(newAncestors); + updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); + } + dept.setUpdateBy(ShiroUtils.getLoginName()); + int result = 0; + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + result = this.deptMapper.updateDept(dept); + } + else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + result = this.deptMapper.updateDeptSqlite(dept); + } + + if ("0".equals(dept.getStatus())) + { + + updateParentDeptStatus(dept); + } + return result; + } + + + + + + + + private void updateParentDeptStatus(Dept dept) { + String updateBy = dept.getUpdateBy(); + dept = this.deptMapper.selectDeptById(dept.getDeptId()); + dept.setUpdateBy(updateBy); + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + this.deptMapper.updateDeptStatus(dept); + } + else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + this.deptMapper.updateDeptStatusSqlite(dept); + } + } + + + + + + + + + + + public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) { + List children = null; + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + children = this.deptMapper.selectChildrenDeptById(deptId); + } + else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + children = this.deptMapper.selectChildrenDeptByIdSqlite(deptId); + } + + for (Dept child : children) + { + child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors)); + } + if (children.size() > 0) + { + this.deptMapper.updateDeptChildren(children); + } + } + + + + + + + + + public void updateDeptChildren(Long deptId, String ancestors) { + Dept dept = new Dept(); + dept.setParentId(deptId); + List childrens = null; + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + childrens = this.deptMapper.selectDeptList(dept); + } + else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + childrens = this.deptMapper.selectDeptListSqlite(dept); + } + for (Dept children : childrens) + { + children.setAncestors(ancestors + "," + dept.getParentId()); + } + if (childrens.size() > 0) + { + this.deptMapper.updateDeptChildren(childrens); + } + } + + + + + + + + + + public Dept selectDeptById(Long deptId) { + return this.deptMapper.selectDeptById(deptId); + } + + + + + + + + + + public int selectNormalChildrenDeptById(Long deptId) { + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + return this.deptMapper.selectNormalChildrenDeptById(deptId); + } + if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + return this.deptMapper.selectNormalChildrenDeptByIdSqlite(deptId); + } + return this.deptMapper.selectNormalChildrenDeptById(deptId); + } + + + + + + + + + + + + public String checkDeptNameUnique(Dept dept) { + Long deptId = Long.valueOf(StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId().longValue()); + Dept info = this.deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); + if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) + { + return "1"; + } + return "0"; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\dept\service\DeptServiceImpl.class diff --git a/src/main/java/com/archive/project/system/dict/controller/DictDataController.java b/src/main/java/com/archive/project/system/dict/controller/DictDataController.java index 8a1072d..371d50b 100644 --- a/src/main/java/com/archive/project/system/dict/controller/DictDataController.java +++ b/src/main/java/com/archive/project/system/dict/controller/DictDataController.java @@ -1,122 +1,122 @@ -/* */ package com.archive.project.system.dict.controller + package com.archive.project.system.dict.controller ; -/* */ -/* */ import com.archive.common.utils.poi.ExcelUtil; -/* */ import com.archive.framework.aspectj.lang.annotation.Log; -/* */ import com.archive.framework.aspectj.lang.enums.BusinessType; -/* */ import com.archive.framework.web.controller.BaseController; -/* */ import com.archive.framework.web.domain.AjaxResult; -/* */ import com.archive.framework.web.page.TableDataInfo; -/* */ import com.archive.project.system.dict.domain.DictData; -/* */ import com.archive.project.system.dict.service.IDictDataService; -/* */ import java.util.List; -/* */ import org.apache.shiro.authz.annotation.RequiresPermissions; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Controller; -/* */ import org.springframework.ui.ModelMap; -/* */ import org.springframework.validation.annotation.Validated; -/* */ import org.springframework.web.bind.annotation.GetMapping; -/* */ import org.springframework.web.bind.annotation.PathVariable; -/* */ import org.springframework.web.bind.annotation.PostMapping; -/* */ import org.springframework.web.bind.annotation.RequestMapping; -/* */ import org.springframework.web.bind.annotation.ResponseBody; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Controller -/* */ @RequestMapping({"/system/dict/data"}) -/* */ public class DictDataController -/* */ extends BaseController -/* */ { -/* 32 */ private String prefix = "system/dict/data"; -/* */ -/* */ @Autowired -/* */ private IDictDataService dictDataService; -/* */ -/* */ -/* */ @RequiresPermissions({"system:dict:view"}) -/* */ @GetMapping -/* */ public String dictData() { -/* 41 */ return this.prefix + "/data"; -/* */ } -/* */ -/* */ -/* */ @PostMapping({"/list"}) -/* */ @RequiresPermissions({"system:dict:list"}) -/* */ @ResponseBody -/* */ public TableDataInfo list(DictData dictData) { -/* 49 */ startPage(); -/* 50 */ List list = this.dictDataService.selectDictDataList(dictData); -/* 51 */ return getDataTable(list); -/* */ } -/* */ -/* */ -/* */ @Log(title = "字典数据", businessType = BusinessType.EXPORT) -/* */ @RequiresPermissions({"system:dict:export"}) -/* */ @PostMapping({"/export"}) -/* */ @ResponseBody -/* */ public AjaxResult export(DictData dictData) { -/* 60 */ List list = this.dictDataService.selectDictDataList(dictData); -/* 61 */ ExcelUtil util = new ExcelUtil(DictData.class); -/* 62 */ return util.exportExcel(list, "字典数据"); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @GetMapping({"/add/{dictType}"}) -/* */ public String add(@PathVariable("dictType") String dictType, ModelMap mmap) { -/* 71 */ mmap.put("dictType", dictType); -/* 72 */ return this.prefix + "/add"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Log(title = "字典数据", businessType = BusinessType.INSERT) -/* */ @RequiresPermissions({"system:dict:add"}) -/* */ @PostMapping({"/add"}) -/* */ @ResponseBody -/* */ public AjaxResult addSave(@Validated DictData dict) { -/* 84 */ return toAjax(this.dictDataService.insertDictData(dict)); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @GetMapping({"/edit/{dictCode}"}) -/* */ public String edit(@PathVariable("dictCode") Long dictCode, ModelMap mmap) { -/* 93 */ mmap.put("dict", this.dictDataService.selectDictDataById(dictCode)); -/* 94 */ return this.prefix + "/edit"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Log(title = "字典数据", businessType = BusinessType.UPDATE) -/* */ @RequiresPermissions({"system:dict:edit"}) -/* */ @PostMapping({"/edit"}) -/* */ @ResponseBody -/* */ public AjaxResult editSave(@Validated DictData dict) { -/* 106 */ return toAjax(this.dictDataService.updateDictData(dict)); -/* */ } -/* */ -/* */ -/* */ @Log(title = "字典数据", businessType = BusinessType.DELETE) -/* */ @RequiresPermissions({"system:dict:remove"}) -/* */ @PostMapping({"/remove"}) -/* */ @ResponseBody -/* */ public AjaxResult remove(String ids) { -/* 115 */ return toAjax(this.dictDataService.deleteDictDataByIds(ids)); -/* */ } -/* */ } + + import com.archive.common.utils.poi.ExcelUtil; + import com.archive.framework.aspectj.lang.annotation.Log; + import com.archive.framework.aspectj.lang.enums.BusinessType; + import com.archive.framework.web.controller.BaseController; + import com.archive.framework.web.domain.AjaxResult; + import com.archive.framework.web.page.TableDataInfo; + import com.archive.project.system.dict.domain.DictData; + import com.archive.project.system.dict.service.IDictDataService; + import java.util.List; + import org.apache.shiro.authz.annotation.RequiresPermissions; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Controller; + import org.springframework.ui.ModelMap; + import org.springframework.validation.annotation.Validated; + import org.springframework.web.bind.annotation.GetMapping; + import org.springframework.web.bind.annotation.PathVariable; + import org.springframework.web.bind.annotation.PostMapping; + import org.springframework.web.bind.annotation.RequestMapping; + import org.springframework.web.bind.annotation.ResponseBody; + + + + + + @Controller + @RequestMapping({"/system/dict/data"}) + public class DictDataController + extends BaseController + { + private String prefix = "system/dict/data"; + + @Autowired + private IDictDataService dictDataService; + + + @RequiresPermissions({"system:dict:view"}) + @GetMapping + public String dictData() { + return this.prefix + "/data"; + } + + + @PostMapping({"/list"}) + @RequiresPermissions({"system:dict:list"}) + @ResponseBody + public TableDataInfo list(DictData dictData) { + startPage(); + List list = this.dictDataService.selectDictDataList(dictData); + return getDataTable(list); + } + + + @Log(title = "字典数据", businessType = BusinessType.EXPORT) + @RequiresPermissions({"system:dict:export"}) + @PostMapping({"/export"}) + @ResponseBody + public AjaxResult export(DictData dictData) { + List list = this.dictDataService.selectDictDataList(dictData); + ExcelUtil util = new ExcelUtil(DictData.class); + return util.exportExcel(list, "字典数据"); + } + + + + + + @GetMapping({"/add/{dictType}"}) + public String add(@PathVariable("dictType") String dictType, ModelMap mmap) { + mmap.put("dictType", dictType); + return this.prefix + "/add"; + } + + + + + + @Log(title = "字典数据", businessType = BusinessType.INSERT) + @RequiresPermissions({"system:dict:add"}) + @PostMapping({"/add"}) + @ResponseBody + public AjaxResult addSave(@Validated DictData dict) { + return toAjax(this.dictDataService.insertDictData(dict)); + } + + + + + + @GetMapping({"/edit/{dictCode}"}) + public String edit(@PathVariable("dictCode") Long dictCode, ModelMap mmap) { + mmap.put("dict", this.dictDataService.selectDictDataById(dictCode)); + return this.prefix + "/edit"; + } + + + + + + @Log(title = "字典数据", businessType = BusinessType.UPDATE) + @RequiresPermissions({"system:dict:edit"}) + @PostMapping({"/edit"}) + @ResponseBody + public AjaxResult editSave(@Validated DictData dict) { + return toAjax(this.dictDataService.updateDictData(dict)); + } + + + @Log(title = "字典数据", businessType = BusinessType.DELETE) + @RequiresPermissions({"system:dict:remove"}) + @PostMapping({"/remove"}) + @ResponseBody + public AjaxResult remove(String ids) { + return toAjax(this.dictDataService.deleteDictDataByIds(ids)); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\dict\controller\DictDataController.class diff --git a/src/main/java/com/archive/project/system/dict/controller/DictTypeController.java b/src/main/java/com/archive/project/system/dict/controller/DictTypeController.java index b426cdd..3b1e4c5 100644 --- a/src/main/java/com/archive/project/system/dict/controller/DictTypeController.java +++ b/src/main/java/com/archive/project/system/dict/controller/DictTypeController.java @@ -1,190 +1,190 @@ -/* */ package com.archive.project.system.dict.controller + package com.archive.project.system.dict.controller ; -/* */ -/* */ import com.archive.common.utils.poi.ExcelUtil; -/* */ import com.archive.framework.aspectj.lang.annotation.Log; -/* */ import com.archive.framework.aspectj.lang.enums.BusinessType; -/* */ import com.archive.framework.web.controller.BaseController; -/* */ import com.archive.framework.web.domain.AjaxResult; -/* */ import com.archive.framework.web.domain.Ztree; -/* */ import com.archive.framework.web.page.TableDataInfo; -/* */ import com.archive.project.system.dict.domain.DictType; -/* */ import com.archive.project.system.dict.service.IDictTypeService; -/* */ import java.util.List; -/* */ import org.apache.shiro.authz.annotation.RequiresPermissions; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Controller; -/* */ import org.springframework.ui.ModelMap; -/* */ import org.springframework.validation.annotation.Validated; -/* */ import org.springframework.web.bind.annotation.GetMapping; -/* */ import org.springframework.web.bind.annotation.PathVariable; -/* */ import org.springframework.web.bind.annotation.PostMapping; -/* */ import org.springframework.web.bind.annotation.RequestMapping; -/* */ import org.springframework.web.bind.annotation.ResponseBody; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Controller -/* */ @RequestMapping({"/system/dict"}) -/* */ public class DictTypeController -/* */ extends BaseController -/* */ { -/* 34 */ private String prefix = "system/dict/type"; -/* */ -/* */ @Autowired -/* */ private IDictTypeService dictTypeService; -/* */ -/* */ -/* */ @RequiresPermissions({"system:dict:view"}) -/* */ @GetMapping -/* */ public String dictType() { -/* 43 */ return this.prefix + "/type"; -/* */ } -/* */ -/* */ -/* */ @PostMapping({"/list"}) -/* */ @RequiresPermissions({"system:dict:list"}) -/* */ @ResponseBody -/* */ public TableDataInfo list(DictType dictType) { -/* 51 */ startPage(); -/* 52 */ List list = this.dictTypeService.selectDictTypeList(dictType); -/* 53 */ return getDataTable(list); -/* */ } -/* */ -/* */ -/* */ -/* */ @Log(title = "字典类型", businessType = BusinessType.EXPORT) -/* */ @RequiresPermissions({"system:dict:export"}) -/* */ @PostMapping({"/export"}) -/* */ @ResponseBody -/* */ public AjaxResult export(DictType dictType) { -/* 63 */ List list = this.dictTypeService.selectDictTypeList(dictType); -/* 64 */ ExcelUtil util = new ExcelUtil(DictType.class); -/* 65 */ return util.exportExcel(list, "字典类型"); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @GetMapping({"/add"}) -/* */ public String add() { -/* 74 */ return this.prefix + "/add"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Log(title = "字典类型", businessType = BusinessType.INSERT) -/* */ @RequiresPermissions({"system:dict:add"}) -/* */ @PostMapping({"/add"}) -/* */ @ResponseBody -/* */ public AjaxResult addSave(@Validated DictType dict) { -/* 86 */ if ("1".equals(this.dictTypeService.checkDictTypeUnique(dict))) -/* */ { -/* 88 */ return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); -/* */ } -/* 90 */ return toAjax(this.dictTypeService.insertDictType(dict)); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @GetMapping({"/edit/{dictId}"}) -/* */ public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap) { -/* 99 */ mmap.put("dict", this.dictTypeService.selectDictTypeById(dictId)); -/* 100 */ return this.prefix + "/edit"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Log(title = "字典类型", businessType = BusinessType.UPDATE) -/* */ @RequiresPermissions({"system:dict:edit"}) -/* */ @PostMapping({"/edit"}) -/* */ @ResponseBody -/* */ public AjaxResult editSave(@Validated DictType dict) { -/* 112 */ if ("1".equals(this.dictTypeService.checkDictTypeUnique(dict))) -/* */ { -/* 114 */ return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); -/* */ } -/* 116 */ return toAjax(this.dictTypeService.updateDictType(dict)); -/* */ } -/* */ -/* */ -/* */ @Log(title = "字典类型", businessType = BusinessType.DELETE) -/* */ @RequiresPermissions({"system:dict:remove"}) -/* */ @PostMapping({"/remove"}) -/* */ @ResponseBody -/* */ public AjaxResult remove(String ids) { -/* 125 */ return toAjax(this.dictTypeService.deleteDictTypeByIds(ids)); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"system:dict:remove"}) -/* */ @Log(title = "字典类型", businessType = BusinessType.CLEAN) -/* */ @GetMapping({"/clearCache"}) -/* */ @ResponseBody -/* */ public AjaxResult clearCache() { -/* 137 */ this.dictTypeService.clearCache(); -/* 138 */ return success(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"system:dict:list"}) -/* */ @GetMapping({"/detail/{dictId}"}) -/* */ public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap) { -/* 148 */ mmap.put("dict", this.dictTypeService.selectDictTypeById(dictId)); -/* 149 */ mmap.put("dictList", this.dictTypeService.selectDictTypeAll()); -/* 150 */ return "system/dict/data/data"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @PostMapping({"/checkDictTypeUnique"}) -/* */ @ResponseBody -/* */ public String checkDictTypeUnique(DictType dictType) { -/* 160 */ return this.dictTypeService.checkDictTypeUnique(dictType); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @GetMapping({"/selectDictTree/{columnId}/{dictType}"}) -/* */ public String selectDeptTree(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType, ModelMap mmap) { -/* 170 */ mmap.put("columnId", columnId); -/* 171 */ mmap.put("dict", this.dictTypeService.selectDictTypeByType(dictType)); -/* 172 */ return this.prefix + "/tree"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @GetMapping({"/treeData"}) -/* */ @ResponseBody -/* */ public List treeData() { -/* 182 */ List ztrees = this.dictTypeService.selectDictTree(new DictType()); -/* 183 */ return ztrees; -/* */ } -/* */ } + + import com.archive.common.utils.poi.ExcelUtil; + import com.archive.framework.aspectj.lang.annotation.Log; + import com.archive.framework.aspectj.lang.enums.BusinessType; + import com.archive.framework.web.controller.BaseController; + import com.archive.framework.web.domain.AjaxResult; + import com.archive.framework.web.domain.Ztree; + import com.archive.framework.web.page.TableDataInfo; + import com.archive.project.system.dict.domain.DictType; + import com.archive.project.system.dict.service.IDictTypeService; + import java.util.List; + import org.apache.shiro.authz.annotation.RequiresPermissions; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Controller; + import org.springframework.ui.ModelMap; + import org.springframework.validation.annotation.Validated; + import org.springframework.web.bind.annotation.GetMapping; + import org.springframework.web.bind.annotation.PathVariable; + import org.springframework.web.bind.annotation.PostMapping; + import org.springframework.web.bind.annotation.RequestMapping; + import org.springframework.web.bind.annotation.ResponseBody; + + + + + + + @Controller + @RequestMapping({"/system/dict"}) + public class DictTypeController + extends BaseController + { + private String prefix = "system/dict/type"; + + @Autowired + private IDictTypeService dictTypeService; + + + @RequiresPermissions({"system:dict:view"}) + @GetMapping + public String dictType() { + return this.prefix + "/type"; + } + + + @PostMapping({"/list"}) + @RequiresPermissions({"system:dict:list"}) + @ResponseBody + public TableDataInfo list(DictType dictType) { + startPage(); + List list = this.dictTypeService.selectDictTypeList(dictType); + return getDataTable(list); + } + + + + @Log(title = "字典类型", businessType = BusinessType.EXPORT) + @RequiresPermissions({"system:dict:export"}) + @PostMapping({"/export"}) + @ResponseBody + public AjaxResult export(DictType dictType) { + List list = this.dictTypeService.selectDictTypeList(dictType); + ExcelUtil util = new ExcelUtil(DictType.class); + return util.exportExcel(list, "字典类型"); + } + + + + + + @GetMapping({"/add"}) + public String add() { + return this.prefix + "/add"; + } + + + + + + @Log(title = "字典类型", businessType = BusinessType.INSERT) + @RequiresPermissions({"system:dict:add"}) + @PostMapping({"/add"}) + @ResponseBody + public AjaxResult addSave(@Validated DictType dict) { + if ("1".equals(this.dictTypeService.checkDictTypeUnique(dict))) + { + return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); + } + return toAjax(this.dictTypeService.insertDictType(dict)); + } + + + + + + @GetMapping({"/edit/{dictId}"}) + public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap) { + mmap.put("dict", this.dictTypeService.selectDictTypeById(dictId)); + return this.prefix + "/edit"; + } + + + + + + @Log(title = "字典类型", businessType = BusinessType.UPDATE) + @RequiresPermissions({"system:dict:edit"}) + @PostMapping({"/edit"}) + @ResponseBody + public AjaxResult editSave(@Validated DictType dict) { + if ("1".equals(this.dictTypeService.checkDictTypeUnique(dict))) + { + return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); + } + return toAjax(this.dictTypeService.updateDictType(dict)); + } + + + @Log(title = "字典类型", businessType = BusinessType.DELETE) + @RequiresPermissions({"system:dict:remove"}) + @PostMapping({"/remove"}) + @ResponseBody + public AjaxResult remove(String ids) { + return toAjax(this.dictTypeService.deleteDictTypeByIds(ids)); + } + + + + + + @RequiresPermissions({"system:dict:remove"}) + @Log(title = "字典类型", businessType = BusinessType.CLEAN) + @GetMapping({"/clearCache"}) + @ResponseBody + public AjaxResult clearCache() { + this.dictTypeService.clearCache(); + return success(); + } + + + + + + @RequiresPermissions({"system:dict:list"}) + @GetMapping({"/detail/{dictId}"}) + public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap) { + mmap.put("dict", this.dictTypeService.selectDictTypeById(dictId)); + mmap.put("dictList", this.dictTypeService.selectDictTypeAll()); + return "system/dict/data/data"; + } + + + + + + @PostMapping({"/checkDictTypeUnique"}) + @ResponseBody + public String checkDictTypeUnique(DictType dictType) { + return this.dictTypeService.checkDictTypeUnique(dictType); + } + + + + + + + @GetMapping({"/selectDictTree/{columnId}/{dictType}"}) + public String selectDeptTree(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType, ModelMap mmap) { + mmap.put("columnId", columnId); + mmap.put("dict", this.dictTypeService.selectDictTypeByType(dictType)); + return this.prefix + "/tree"; + } + + + + + + @GetMapping({"/treeData"}) + @ResponseBody + public List treeData() { + List ztrees = this.dictTypeService.selectDictTree(new DictType()); + return ztrees; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\dict\controller\DictTypeController.class diff --git a/src/main/java/com/archive/project/system/dict/domain/DictData.java b/src/main/java/com/archive/project/system/dict/domain/DictData.java index d28fad6..f0fe834 100644 --- a/src/main/java/com/archive/project/system/dict/domain/DictData.java +++ b/src/main/java/com/archive/project/system/dict/domain/DictData.java @@ -1,181 +1,181 @@ -/* */ package com.archive.project.system.dict.domain + package com.archive.project.system.dict.domain ; -/* */ -/* */ import com.archive.framework.aspectj.lang.annotation.ColumnType; + + import com.archive.framework.aspectj.lang.annotation.ColumnType; import com.archive.framework.aspectj.lang.annotation.Excel; -/* */ import com.archive.framework.web.domain.BaseEntity; -/* */ import javax.validation.constraints.NotBlank; -/* */ import javax.validation.constraints.Size; -/* */ import org.apache.commons.lang3.builder.ToStringBuilder; -/* */ import org.apache.commons.lang3.builder.ToStringStyle; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class DictData -/* */ extends BaseEntity -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ @Excel(name = "字典编码", cellType = ColumnType.NUMERIC) -/* */ private Long dictCode; -/* */ @Excel(name = "字典排序", cellType = ColumnType.NUMERIC) -/* */ private Long dictSort; -/* */ @Excel(name = "字典标签") -/* */ private String dictLabel; -/* */ @Excel(name = "字典键值") -/* */ private String dictValue; -/* */ @Excel(name = "字典类型") -/* */ private String dictType; -/* */ @Excel(name = "字典样式") -/* */ private String cssClass; -/* */ private String listClass; -/* */ @Excel(name = "是否默认", readConverterExp = "Y=是,N=否") -/* */ private String isDefault; -/* */ @Excel(name = "状态", readConverterExp = "0=正常,1=停用") -/* */ private String status; -/* */ -/* */ public Long getDictCode() { -/* 57 */ return this.dictCode; -/* */ } -/* */ -/* */ -/* */ public void setDictCode(Long dictCode) { -/* 62 */ this.dictCode = dictCode; -/* */ } -/* */ -/* */ -/* */ public Long getDictSort() { -/* 67 */ return this.dictSort; -/* */ } -/* */ -/* */ -/* */ public void setDictSort(Long dictSort) { -/* 72 */ this.dictSort = dictSort; -/* */ } -/* */ -/* */ -/* */ @NotBlank(message = "字典标签不能为空") -/* */ @Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符") -/* */ public String getDictLabel() { -/* 79 */ return this.dictLabel; -/* */ } -/* */ -/* */ -/* */ public void setDictLabel(String dictLabel) { -/* 84 */ this.dictLabel = dictLabel; -/* */ } -/* */ -/* */ -/* */ @NotBlank(message = "字典键值不能为空") -/* */ @Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符") -/* */ public String getDictValue() { -/* 91 */ return this.dictValue; -/* */ } -/* */ -/* */ -/* */ public void setDictValue(String dictValue) { -/* 96 */ this.dictValue = dictValue; -/* */ } -/* */ -/* */ -/* */ @NotBlank(message = "字典类型不能为空") -/* */ @Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符") -/* */ public String getDictType() { -/* 103 */ return this.dictType; -/* */ } -/* */ -/* */ -/* */ public void setDictType(String dictType) { -/* 108 */ this.dictType = dictType; -/* */ } -/* */ -/* */ -/* */ @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符") -/* */ public String getCssClass() { -/* 114 */ return this.cssClass; -/* */ } -/* */ -/* */ -/* */ public void setCssClass(String cssClass) { -/* 119 */ this.cssClass = cssClass; -/* */ } -/* */ -/* */ -/* */ public String getListClass() { -/* 124 */ return this.listClass; -/* */ } -/* */ -/* */ -/* */ public void setListClass(String listClass) { -/* 129 */ this.listClass = listClass; -/* */ } -/* */ -/* */ -/* */ public boolean getDefault() { -/* 134 */ return "Y".equals(this.isDefault); -/* */ } -/* */ -/* */ -/* */ public String getIsDefault() { -/* 139 */ return this.isDefault; -/* */ } -/* */ -/* */ -/* */ public void setIsDefault(String isDefault) { -/* 144 */ this.isDefault = isDefault; -/* */ } -/* */ -/* */ -/* */ public String getStatus() { -/* 149 */ return this.status; -/* */ } -/* */ -/* */ -/* */ public void setStatus(String status) { -/* 154 */ this.status = status; -/* */ } -/* */ -/* */ @Override -/* */ public String toString() { -/* 159 */ return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)) -/* 160 */ .append("dictCode", getDictCode()) -/* 161 */ .append("dictSort", getDictSort()) -/* 162 */ .append("dictLabel", getDictLabel()) -/* 163 */ .append("dictValue", getDictValue()) -/* 164 */ .append("dictType", getDictType()) -/* 165 */ .append("cssClass", getCssClass()) -/* 166 */ .append("listClass", getListClass()) -/* 167 */ .append("isDefault", getIsDefault()) -/* 168 */ .append("status", getStatus()) -/* 169 */ .append("createBy", getCreateBy()) -/* 170 */ .append("createTime", getCreateTime()) -/* 171 */ .append("updateBy", getUpdateBy()) -/* 172 */ .append("updateTime", getUpdateTime()) -/* 173 */ .append("remark", getRemark()) -/* 174 */ .toString(); -/* */ } -/* */ } + import com.archive.framework.web.domain.BaseEntity; + import javax.validation.constraints.NotBlank; + import javax.validation.constraints.Size; + import org.apache.commons.lang3.builder.ToStringBuilder; + import org.apache.commons.lang3.builder.ToStringStyle; + + + + + + + + + + + + + + + + + + + + + + + + + + public class DictData + extends BaseEntity + { + private static final long serialVersionUID = 1L; + @Excel(name = "字典编码", cellType = ColumnType.NUMERIC) + private Long dictCode; + @Excel(name = "字典排序", cellType = ColumnType.NUMERIC) + private Long dictSort; + @Excel(name = "字典标签") + private String dictLabel; + @Excel(name = "字典键值") + private String dictValue; + @Excel(name = "字典类型") + private String dictType; + @Excel(name = "字典样式") + private String cssClass; + private String listClass; + @Excel(name = "是否默认", readConverterExp = "Y=是,N=否") + private String isDefault; + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + public Long getDictCode() { + return this.dictCode; + } + + + public void setDictCode(Long dictCode) { + this.dictCode = dictCode; + } + + + public Long getDictSort() { + return this.dictSort; + } + + + public void setDictSort(Long dictSort) { + this.dictSort = dictSort; + } + + + @NotBlank(message = "字典标签不能为空") + @Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符") + public String getDictLabel() { + return this.dictLabel; + } + + + public void setDictLabel(String dictLabel) { + this.dictLabel = dictLabel; + } + + + @NotBlank(message = "字典键值不能为空") + @Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符") + public String getDictValue() { + return this.dictValue; + } + + + public void setDictValue(String dictValue) { + this.dictValue = dictValue; + } + + + @NotBlank(message = "字典类型不能为空") + @Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符") + public String getDictType() { + return this.dictType; + } + + + public void setDictType(String dictType) { + this.dictType = dictType; + } + + + @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符") + public String getCssClass() { + return this.cssClass; + } + + + public void setCssClass(String cssClass) { + this.cssClass = cssClass; + } + + + public String getListClass() { + return this.listClass; + } + + + public void setListClass(String listClass) { + this.listClass = listClass; + } + + + public boolean getDefault() { + return "Y".equals(this.isDefault); + } + + + public String getIsDefault() { + return this.isDefault; + } + + + public void setIsDefault(String isDefault) { + this.isDefault = isDefault; + } + + + public String getStatus() { + return this.status; + } + + + public void setStatus(String status) { + this.status = status; + } + + @Override + public String toString() { + return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)) + .append("dictCode", getDictCode()) + .append("dictSort", getDictSort()) + .append("dictLabel", getDictLabel()) + .append("dictValue", getDictValue()) + .append("dictType", getDictType()) + .append("cssClass", getCssClass()) + .append("listClass", getListClass()) + .append("isDefault", getIsDefault()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\dict\domain\DictData.class diff --git a/src/main/java/com/archive/project/system/dict/domain/DictType.java b/src/main/java/com/archive/project/system/dict/domain/DictType.java index abca14e..2ffaf81 100644 --- a/src/main/java/com/archive/project/system/dict/domain/DictType.java +++ b/src/main/java/com/archive/project/system/dict/domain/DictType.java @@ -1,111 +1,111 @@ -/* */ package com.archive.project.system.dict.domain + package com.archive.project.system.dict.domain ; -/* */ -/* */ import com.archive.framework.aspectj.lang.annotation.ColumnType; + + import com.archive.framework.aspectj.lang.annotation.ColumnType; import com.archive.framework.aspectj.lang.annotation.Excel; -/* */ import com.archive.framework.web.domain.BaseEntity; -/* */ import javax.validation.constraints.NotBlank; -/* */ import javax.validation.constraints.Size; -/* */ import org.apache.commons.lang3.builder.ToStringBuilder; -/* */ import org.apache.commons.lang3.builder.ToStringStyle; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class DictType -/* */ extends BaseEntity -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ @Excel(name = "字典主键", cellType = ColumnType.NUMERIC) -/* */ private Long dictId; -/* */ @Excel(name = "字典名称") -/* */ private String dictName; -/* */ @Excel(name = "字典类型") -/* */ private String dictType; -/* */ @Excel(name = "状态", readConverterExp = "0=正常,1=停用") -/* */ private String status; -/* */ @Excel(name = "标签") -/* */ private String label; -/* */ -/* */ public Long getDictId() { -/* 41 */ return this.dictId; -/* */ } -/* */ -/* */ -/* */ public void setDictId(Long dictId) { -/* 46 */ this.dictId = dictId; -/* */ } -/* */ -/* */ -/* */ @NotBlank(message = "字典名称不能为空") -/* */ @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符") -/* */ public String getDictName() { -/* 53 */ return this.dictName; -/* */ } -/* */ -/* */ -/* */ public void setDictName(String dictName) { -/* 58 */ this.dictName = dictName; -/* */ } -/* */ -/* */ -/* */ @NotBlank(message = "字典类型不能为空") -/* */ @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") -/* */ public String getDictType() { -/* 65 */ return this.dictType; -/* */ } -/* */ -/* */ -/* */ public void setDictType(String dictType) { -/* 70 */ this.dictType = dictType; -/* */ } -/* */ -/* */ -/* */ public String getStatus() { -/* 75 */ return this.status; -/* */ } -/* */ -/* */ -/* */ public void setStatus(String status) { -/* 80 */ this.status = status; -/* */ } -/* */ -/* */ public String getLabel() { -/* 84 */ return this.label; -/* */ } -/* */ -/* */ public void setLabel(String label) { -/* 88 */ this.label = label; -/* */ } -/* */ -/* */ -/* */ public String toString() { -/* 93 */ return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)) -/* 94 */ .append("dictId", getDictId()) -/* 95 */ .append("dictName", getDictName()) -/* 96 */ .append("dictType", getDictType()) -/* 97 */ .append("status", getStatus()) -/* 98 */ .append("createBy", getCreateBy()) -/* 99 */ .append("createTime", getCreateTime()) -/* 100 */ .append("updateBy", getUpdateBy()) -/* 101 */ .append("updateTime", getUpdateTime()) -/* 102 */ .append("remark", getRemark()) -/* 103 */ .toString(); -/* */ } -/* */ } + import com.archive.framework.web.domain.BaseEntity; + import javax.validation.constraints.NotBlank; + import javax.validation.constraints.Size; + import org.apache.commons.lang3.builder.ToStringBuilder; + import org.apache.commons.lang3.builder.ToStringStyle; + + + + + + + + + + + + + + + + + public class DictType + extends BaseEntity + { + private static final long serialVersionUID = 1L; + @Excel(name = "字典主键", cellType = ColumnType.NUMERIC) + private Long dictId; + @Excel(name = "字典名称") + private String dictName; + @Excel(name = "字典类型") + private String dictType; + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + @Excel(name = "标签") + private String label; + + public Long getDictId() { + return this.dictId; + } + + + public void setDictId(Long dictId) { + this.dictId = dictId; + } + + + @NotBlank(message = "字典名称不能为空") + @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符") + public String getDictName() { + return this.dictName; + } + + + public void setDictName(String dictName) { + this.dictName = dictName; + } + + + @NotBlank(message = "字典类型不能为空") + @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") + public String getDictType() { + return this.dictType; + } + + + public void setDictType(String dictType) { + this.dictType = dictType; + } + + + public String getStatus() { + return this.status; + } + + + public void setStatus(String status) { + this.status = status; + } + + public String getLabel() { + return this.label; + } + + public void setLabel(String label) { + this.label = label; + } + + + public String toString() { + return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)) + .append("dictId", getDictId()) + .append("dictName", getDictName()) + .append("dictType", getDictType()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\dict\domain\DictType.class diff --git a/src/main/java/com/archive/project/system/dict/service/DictDataServiceImpl.java b/src/main/java/com/archive/project/system/dict/service/DictDataServiceImpl.java index 12be34b..35e1016 100644 --- a/src/main/java/com/archive/project/system/dict/service/DictDataServiceImpl.java +++ b/src/main/java/com/archive/project/system/dict/service/DictDataServiceImpl.java @@ -1,146 +1,146 @@ -/* */ package com.archive.project.system.dict.service + package com.archive.project.system.dict.service ; -/* */ -/* */ import com.archive.common.utils.security.ShiroUtils; -/* */ import com.archive.common.utils.text.Convert; -/* */ import com.archive.framework.config.ArchiveConfig; -/* */ import com.archive.project.system.dict.domain.DictData; -/* */ import com.archive.project.system.dict.mapper.DictDataMapper; -/* */ import com.archive.project.system.dict.service.IDictDataService; -/* */ import com.archive.project.system.dict.utils.DictUtils; -/* */ import java.util.List; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Service; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Service -/* */ public class DictDataServiceImpl -/* */ implements IDictDataService -/* */ { -/* */ @Autowired -/* */ private DictDataMapper dictDataMapper; -/* */ @Autowired -/* */ private ArchiveConfig archiveConfig; -/* */ -/* */ public List selectDictDataList(DictData dictData) { -/* 40 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 41 */ return this.dictDataMapper.selectDictDataList(dictData); -/* */ } -/* 43 */ if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 44 */ return this.dictDataMapper.selectDictDataListSqlite(dictData); -/* */ } -/* 46 */ return this.dictDataMapper.selectDictDataList(dictData); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public String selectDictLabel(String dictType, String dictValue) { -/* 60 */ return this.dictDataMapper.selectDictLabel(dictType, dictValue); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public DictData selectDictDataById(Long dictCode) { -/* 72 */ return this.dictDataMapper.selectDictDataById(dictCode); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int deleteDictDataByIds(String ids) { -/* 84 */ int row = this.dictDataMapper.deleteDictDataByIds(Convert.toStrArray(ids)); -/* 85 */ if (row > 0) -/* */ { -/* 87 */ DictUtils.clearDictCache(); -/* */ } -/* 89 */ return row; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int insertDictData(DictData dictData) { -/* 101 */ dictData.setCreateBy(ShiroUtils.getLoginName()); -/* 102 */ int row = 0; -/* 103 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 104 */ row = this.dictDataMapper.insertDictData(dictData); -/* */ } -/* 106 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 107 */ row = this.dictDataMapper.insertDictDataSqlite(dictData); -/* */ } -/* */ -/* 110 */ if (row > 0) -/* */ { -/* 112 */ DictUtils.clearDictCache(); -/* */ } -/* 114 */ return row; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int updateDictData(DictData dictData) { -/* 126 */ dictData.setUpdateBy(ShiroUtils.getLoginName()); -/* 127 */ int row = 0; -/* 128 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 129 */ row = this.dictDataMapper.updateDictData(dictData); -/* */ } -/* 131 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 132 */ row = this.dictDataMapper.updateDictDataSqlite(dictData); -/* */ } -/* */ -/* 135 */ if (row > 0) -/* */ { -/* 137 */ DictUtils.clearDictCache(); -/* */ } -/* 139 */ return row; -/* */ } -/* */ } + + import com.archive.common.utils.security.ShiroUtils; + import com.archive.common.utils.text.Convert; + import com.archive.framework.config.ArchiveConfig; + import com.archive.project.system.dict.domain.DictData; + import com.archive.project.system.dict.mapper.DictDataMapper; + import com.archive.project.system.dict.service.IDictDataService; + import com.archive.project.system.dict.utils.DictUtils; + import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + + + + + + + + + + + + + + + + + + @Service + public class DictDataServiceImpl + implements IDictDataService + { + @Autowired + private DictDataMapper dictDataMapper; + @Autowired + private ArchiveConfig archiveConfig; + + public List selectDictDataList(DictData dictData) { + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + return this.dictDataMapper.selectDictDataList(dictData); + } + if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + return this.dictDataMapper.selectDictDataListSqlite(dictData); + } + return this.dictDataMapper.selectDictDataList(dictData); + } + + + + + + + + + + + + public String selectDictLabel(String dictType, String dictValue) { + return this.dictDataMapper.selectDictLabel(dictType, dictValue); + } + + + + + + + + + + public DictData selectDictDataById(Long dictCode) { + return this.dictDataMapper.selectDictDataById(dictCode); + } + + + + + + + + + + public int deleteDictDataByIds(String ids) { + int row = this.dictDataMapper.deleteDictDataByIds(Convert.toStrArray(ids)); + if (row > 0) + { + DictUtils.clearDictCache(); + } + return row; + } + + + + + + + + + + public int insertDictData(DictData dictData) { + dictData.setCreateBy(ShiroUtils.getLoginName()); + int row = 0; + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + row = this.dictDataMapper.insertDictData(dictData); + } + else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + row = this.dictDataMapper.insertDictDataSqlite(dictData); + } + + if (row > 0) + { + DictUtils.clearDictCache(); + } + return row; + } + + + + + + + + + + public int updateDictData(DictData dictData) { + dictData.setUpdateBy(ShiroUtils.getLoginName()); + int row = 0; + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + row = this.dictDataMapper.updateDictData(dictData); + } + else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + row = this.dictDataMapper.updateDictDataSqlite(dictData); + } + + if (row > 0) + { + DictUtils.clearDictCache(); + } + return row; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\dict\service\DictDataServiceImpl.class diff --git a/src/main/java/com/archive/project/system/dict/service/DictTypeServiceImpl.java b/src/main/java/com/archive/project/system/dict/service/DictTypeServiceImpl.java index 6c91f25..f523d16 100644 --- a/src/main/java/com/archive/project/system/dict/service/DictTypeServiceImpl.java +++ b/src/main/java/com/archive/project/system/dict/service/DictTypeServiceImpl.java @@ -1,277 +1,277 @@ -/* */ package com.archive.project.system.dict.service + package com.archive.project.system.dict.service ; -/* */ -/* */ import com.archive.common.exception.BusinessException; -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.common.utils.security.ShiroUtils; -/* */ import com.archive.common.utils.text.Convert; -/* */ import com.archive.framework.config.ArchiveConfig; -/* */ import com.archive.framework.web.domain.Ztree; -/* */ import com.archive.project.system.dict.domain.DictData; -/* */ import com.archive.project.system.dict.domain.DictType; -/* */ import com.archive.project.system.dict.mapper.DictDataMapper; -/* */ import com.archive.project.system.dict.mapper.DictTypeMapper; -/* */ import com.archive.project.system.dict.service.IDictTypeService; -/* */ import com.archive.project.system.dict.utils.DictUtils; -/* */ import java.util.ArrayList; -/* */ import java.util.List; -/* */ import javax.annotation.PostConstruct; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Service; -/* */ import org.springframework.transaction.annotation.Transactional; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Service -/* */ public class DictTypeServiceImpl -/* */ implements IDictTypeService -/* */ { -/* */ @Autowired -/* */ private DictTypeMapper dictTypeMapper; -/* */ @Autowired -/* */ private DictDataMapper dictDataMapper; -/* */ @Autowired -/* */ private ArchiveConfig archiveConfig; -/* */ -/* */ @PostConstruct -/* */ public void init() { -/* 48 */ List dictTypeList = this.dictTypeMapper.selectDictTypeAll(); -/* 49 */ for (DictType dictType : dictTypeList) { -/* */ -/* 51 */ List dictDatas = this.dictDataMapper.selectDictDataByType(dictType.getDictType()); -/* 52 */ DictUtils.setDictCache(dictType.getDictType(), dictDatas); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public List selectDictTypeList(DictType dictType) { -/* 65 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 66 */ return this.dictTypeMapper.selectDictTypeList(dictType); -/* */ } -/* 68 */ if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 69 */ return this.dictTypeMapper.selectDictTypeListSqlite(dictType); -/* */ } -/* 71 */ return this.dictTypeMapper.selectDictTypeList(dictType); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public List selectDictTypeAll() { -/* 84 */ return this.dictTypeMapper.selectDictTypeAll(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public List selectDictDataByType(String dictType) { -/* 96 */ List dictDatas = DictUtils.getDictCache(dictType); -/* 97 */ if (StringUtils.isNotEmpty(dictDatas)) -/* */ { -/* 99 */ return dictDatas; -/* */ } -/* 101 */ dictDatas = this.dictDataMapper.selectDictDataByType(dictType); -/* 102 */ if (StringUtils.isNotEmpty(dictDatas)) { -/* */ -/* 104 */ DictUtils.setDictCache(dictType, dictDatas); -/* 105 */ return dictDatas; -/* */ } -/* 107 */ return null; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public DictType selectDictTypeById(Long dictId) { -/* 119 */ return this.dictTypeMapper.selectDictTypeById(dictId); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public DictType selectDictTypeByType(String dictType) { -/* 131 */ return this.dictTypeMapper.selectDictTypeByType(dictType); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int deleteDictTypeByIds(String ids) { -/* 143 */ Long[] dictIds = Convert.toLongArray(ids); -/* 144 */ for (Long dictId : dictIds) { -/* */ -/* 146 */ DictType dictType = selectDictTypeById(dictId); -/* 147 */ if (this.dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) -/* */ { -/* 149 */ throw new BusinessException(String.format("%1$s已分配,不能删除", new Object[] { dictType.getDictName() })); -/* */ } -/* */ } -/* 152 */ int count = this.dictTypeMapper.deleteDictTypeByIds(dictIds); -/* 153 */ if (count > 0) -/* */ { -/* 155 */ DictUtils.clearDictCache(); -/* */ } -/* 157 */ return count; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void clearCache() { -/* 166 */ DictUtils.clearDictCache(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int insertDictType(DictType dictType) { -/* 178 */ dictType.setCreateBy(ShiroUtils.getLoginName()); -/* 179 */ int row = 0; -/* 180 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 181 */ row = this.dictTypeMapper.insertDictType(dictType); -/* */ } -/* 183 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 184 */ row = this.dictTypeMapper.insertDictTypeSqlite(dictType); -/* */ } -/* */ -/* 187 */ if (row > 0) -/* */ { -/* 189 */ DictUtils.clearDictCache(); -/* */ } -/* 191 */ return row; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Transactional -/* */ public int updateDictType(DictType dictType) { -/* 204 */ dictType.setUpdateBy(ShiroUtils.getLoginName()); -/* 205 */ DictType oldDict = this.dictTypeMapper.selectDictTypeById(dictType.getDictId()); -/* 206 */ this.dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType()); -/* 207 */ int row = 0; -/* 208 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) { -/* 209 */ row = this.dictTypeMapper.updateDictType(dictType); -/* */ } -/* 211 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { -/* 212 */ row = this.dictTypeMapper.updateDictTypeSqlite(dictType); -/* */ } -/* */ -/* 215 */ if (row > 0) -/* */ { -/* 217 */ DictUtils.clearDictCache(); -/* */ } -/* 219 */ return row; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public String checkDictTypeUnique(DictType dict) { -/* 231 */ Long dictId = Long.valueOf(StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId().longValue()); -/* 232 */ DictType dictType = this.dictTypeMapper.checkDictTypeUnique(dict.getDictType()); -/* 233 */ if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) -/* */ { -/* 235 */ return "1"; -/* */ } -/* 237 */ return "0"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public List selectDictTree(DictType dictType) { -/* 249 */ List ztrees = new ArrayList<>(); -/* 250 */ List dictList = this.dictTypeMapper.selectDictTypeList(dictType); -/* 251 */ for (DictType dict : dictList) { -/* */ -/* 253 */ if ("0".equals(dict.getStatus())) { -/* */ -/* 255 */ Ztree ztree = new Ztree(); -/* 256 */ ztree.setId(dict.getDictId()); -/* 257 */ ztree.setName(transDictName(dict)); -/* 258 */ ztree.setTitle(dict.getDictType()); -/* 259 */ ztrees.add(ztree); -/* */ } -/* */ } -/* 262 */ return ztrees; -/* */ } -/* */ -/* */ -/* */ public String transDictName(DictType dictType) { -/* 267 */ StringBuffer sb = new StringBuffer(); -/* 268 */ sb.append("(" + dictType.getDictName() + ")"); -/* 269 */ sb.append("   " + dictType.getDictType()); -/* 270 */ return sb.toString(); -/* */ } -/* */ } + + import com.archive.common.exception.BusinessException; + import com.archive.common.utils.StringUtils; + import com.archive.common.utils.security.ShiroUtils; + import com.archive.common.utils.text.Convert; + import com.archive.framework.config.ArchiveConfig; + import com.archive.framework.web.domain.Ztree; + import com.archive.project.system.dict.domain.DictData; + import com.archive.project.system.dict.domain.DictType; + import com.archive.project.system.dict.mapper.DictDataMapper; + import com.archive.project.system.dict.mapper.DictTypeMapper; + import com.archive.project.system.dict.service.IDictTypeService; + import com.archive.project.system.dict.utils.DictUtils; + import java.util.ArrayList; + import java.util.List; + import javax.annotation.PostConstruct; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + import org.springframework.transaction.annotation.Transactional; + + + + + + + + + + + + + + + @Service + public class DictTypeServiceImpl + implements IDictTypeService + { + @Autowired + private DictTypeMapper dictTypeMapper; + @Autowired + private DictDataMapper dictDataMapper; + @Autowired + private ArchiveConfig archiveConfig; + + @PostConstruct + public void init() { + List dictTypeList = this.dictTypeMapper.selectDictTypeAll(); + for (DictType dictType : dictTypeList) { + + List dictDatas = this.dictDataMapper.selectDictDataByType(dictType.getDictType()); + DictUtils.setDictCache(dictType.getDictType(), dictDatas); + } + } + + + + + + + + + + public List selectDictTypeList(DictType dictType) { + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + return this.dictTypeMapper.selectDictTypeList(dictType); + } + if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + return this.dictTypeMapper.selectDictTypeListSqlite(dictType); + } + return this.dictTypeMapper.selectDictTypeList(dictType); + } + + + + + + + + + + + public List selectDictTypeAll() { + return this.dictTypeMapper.selectDictTypeAll(); + } + + + + + + + + + + public List selectDictDataByType(String dictType) { + List dictDatas = DictUtils.getDictCache(dictType); + if (StringUtils.isNotEmpty(dictDatas)) + { + return dictDatas; + } + dictDatas = this.dictDataMapper.selectDictDataByType(dictType); + if (StringUtils.isNotEmpty(dictDatas)) { + + DictUtils.setDictCache(dictType, dictDatas); + return dictDatas; + } + return null; + } + + + + + + + + + + public DictType selectDictTypeById(Long dictId) { + return this.dictTypeMapper.selectDictTypeById(dictId); + } + + + + + + + + + + public DictType selectDictTypeByType(String dictType) { + return this.dictTypeMapper.selectDictTypeByType(dictType); + } + + + + + + + + + + public int deleteDictTypeByIds(String ids) { + Long[] dictIds = Convert.toLongArray(ids); + for (Long dictId : dictIds) { + + DictType dictType = selectDictTypeById(dictId); + if (this.dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) + { + throw new BusinessException(String.format("%1$s已分配,不能删除", new Object[] { dictType.getDictName() })); + } + } + int count = this.dictTypeMapper.deleteDictTypeByIds(dictIds); + if (count > 0) + { + DictUtils.clearDictCache(); + } + return count; + } + + + + + + + public void clearCache() { + DictUtils.clearDictCache(); + } + + + + + + + + + + public int insertDictType(DictType dictType) { + dictType.setCreateBy(ShiroUtils.getLoginName()); + int row = 0; + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + row = this.dictTypeMapper.insertDictType(dictType); + } + else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + row = this.dictTypeMapper.insertDictTypeSqlite(dictType); + } + + if (row > 0) + { + DictUtils.clearDictCache(); + } + return row; + } + + + + + + + + + + @Transactional + public int updateDictType(DictType dictType) { + dictType.setUpdateBy(ShiroUtils.getLoginName()); + DictType oldDict = this.dictTypeMapper.selectDictTypeById(dictType.getDictId()); + this.dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType()); + int row = 0; + if ("mysql".equals(this.archiveConfig.getDatabaseType())) { + row = this.dictTypeMapper.updateDictType(dictType); + } + else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) { + row = this.dictTypeMapper.updateDictTypeSqlite(dictType); + } + + if (row > 0) + { + DictUtils.clearDictCache(); + } + return row; + } + + + + + + + + + + public String checkDictTypeUnique(DictType dict) { + Long dictId = Long.valueOf(StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId().longValue()); + DictType dictType = this.dictTypeMapper.checkDictTypeUnique(dict.getDictType()); + if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) + { + return "1"; + } + return "0"; + } + + + + + + + + + + public List selectDictTree(DictType dictType) { + List ztrees = new ArrayList<>(); + List dictList = this.dictTypeMapper.selectDictTypeList(dictType); + for (DictType dict : dictList) { + + if ("0".equals(dict.getStatus())) { + + Ztree ztree = new Ztree(); + ztree.setId(dict.getDictId()); + ztree.setName(transDictName(dict)); + ztree.setTitle(dict.getDictType()); + ztrees.add(ztree); + } + } + return ztrees; + } + + + public String transDictName(DictType dictType) { + StringBuffer sb = new StringBuffer(); + sb.append("(" + dictType.getDictName() + ")"); + sb.append("   " + dictType.getDictType()); + return sb.toString(); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\dict\service\DictTypeServiceImpl.class diff --git a/src/main/java/com/archive/project/system/dict/utils/DictUtils.java b/src/main/java/com/archive/project/system/dict/utils/DictUtils.java index c66da5e..3ae847d 100644 --- a/src/main/java/com/archive/project/system/dict/utils/DictUtils.java +++ b/src/main/java/com/archive/project/system/dict/utils/DictUtils.java @@ -1,186 +1,186 @@ -/* */ package com.archive.project.system.dict.utils + package com.archive.project.system.dict.utils ; -/* */ -/* */ import com.archive.common.utils.CacheUtils; -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.project.system.dict.domain.DictData; -/* */ import java.util.List; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class DictUtils -/* */ { -/* */ public static final String SEPARATOR = ","; -/* */ -/* */ public static void setDictCache(String key, List dictDatas) { -/* 29 */ CacheUtils.put(getCacheName(), getCacheKey(key), dictDatas); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static List getDictCache(String key) { -/* 40 */ Object cacheObj = CacheUtils.get(getCacheName(), getCacheKey(key)); -/* 41 */ if (StringUtils.isNotNull(cacheObj)) { -/* */ -/* 43 */ List DictDatas = (List)StringUtils.cast(cacheObj); -/* 44 */ return DictDatas; -/* */ } -/* 46 */ return null; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getDictLabel(String dictType, String dictValue) { -/* 58 */ return getDictLabel(dictType, dictValue, ","); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getDictValue(String dictType, String dictLabel) { -/* 70 */ return getDictValue(dictType, dictLabel, ","); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getDictLabel(String dictType, String dictValue, String separator) { -/* 83 */ StringBuilder propertyString = new StringBuilder(); -/* 84 */ List datas = getDictCache(dictType); -/* */ -/* 86 */ if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) { -/* */ -/* 88 */ for (DictData dict : datas) { -/* */ -/* 90 */ for (String value : dictValue.split(separator)) { -/* */ -/* 92 */ if (value.equals(dict.getDictValue())) { -/* */ -/* 94 */ propertyString.append(dict.getDictLabel() + separator); -/* */ -/* */ -/* */ break; -/* */ } -/* */ } -/* */ } -/* */ } else { -/* 102 */ for (DictData dict : datas) { -/* */ -/* 104 */ if (dictValue.equals(dict.getDictValue())) -/* */ { -/* 106 */ return dict.getDictLabel(); -/* */ } -/* */ } -/* */ } -/* 110 */ return StringUtils.stripEnd(propertyString.toString(), separator); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getDictValue(String dictType, String dictLabel, String separator) { -/* 123 */ StringBuilder propertyString = new StringBuilder(); -/* 124 */ List datas = getDictCache(dictType); -/* */ -/* 126 */ if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) { -/* */ -/* 128 */ for (DictData dict : datas) { -/* */ -/* 130 */ for (String label : dictLabel.split(separator)) { -/* */ -/* 132 */ if (label.equals(dict.getDictLabel())) { -/* */ -/* 134 */ propertyString.append(dict.getDictValue() + separator); -/* */ -/* */ -/* */ break; -/* */ } -/* */ } -/* */ } -/* */ } else { -/* 142 */ for (DictData dict : datas) { -/* */ -/* 144 */ if (dictLabel.equals(dict.getDictLabel())) -/* */ { -/* 146 */ return dict.getDictValue(); -/* */ } -/* */ } -/* */ } -/* 150 */ return StringUtils.stripEnd(propertyString.toString(), separator); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void clearDictCache() { -/* 158 */ CacheUtils.removeAll(getCacheName()); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getCacheName() { -/* 168 */ return "sys-dict"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getCacheKey(String configKey) { -/* 179 */ return "sys_dict:" + configKey; -/* */ } -/* */ } + + import com.archive.common.utils.CacheUtils; + import com.archive.common.utils.StringUtils; + import com.archive.project.system.dict.domain.DictData; + import java.util.List; + + + + + + + + + + + + + + + + + + public class DictUtils + { + public static final String SEPARATOR = ","; + + public static void setDictCache(String key, List dictDatas) { + CacheUtils.put(getCacheName(), getCacheKey(key), dictDatas); + } + + + + + + + + + public static List getDictCache(String key) { + Object cacheObj = CacheUtils.get(getCacheName(), getCacheKey(key)); + if (StringUtils.isNotNull(cacheObj)) { + + List DictDatas = (List)StringUtils.cast(cacheObj); + return DictDatas; + } + return null; + } + + + + + + + + + + public static String getDictLabel(String dictType, String dictValue) { + return getDictLabel(dictType, dictValue, ","); + } + + + + + + + + + + public static String getDictValue(String dictType, String dictLabel) { + return getDictValue(dictType, dictLabel, ","); + } + + + + + + + + + + + public static String getDictLabel(String dictType, String dictValue, String separator) { + StringBuilder propertyString = new StringBuilder(); + List datas = getDictCache(dictType); + + if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) { + + for (DictData dict : datas) { + + for (String value : dictValue.split(separator)) { + + if (value.equals(dict.getDictValue())) { + + propertyString.append(dict.getDictLabel() + separator); + + + break; + } + } + } + } else { + for (DictData dict : datas) { + + if (dictValue.equals(dict.getDictValue())) + { + return dict.getDictLabel(); + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + + + + + + + + + + public static String getDictValue(String dictType, String dictLabel, String separator) { + StringBuilder propertyString = new StringBuilder(); + List datas = getDictCache(dictType); + + if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) { + + for (DictData dict : datas) { + + for (String label : dictLabel.split(separator)) { + + if (label.equals(dict.getDictLabel())) { + + propertyString.append(dict.getDictValue() + separator); + + + break; + } + } + } + } else { + for (DictData dict : datas) { + + if (dictLabel.equals(dict.getDictLabel())) + { + return dict.getDictValue(); + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + + + + + public static void clearDictCache() { + CacheUtils.removeAll(getCacheName()); + } + + + + + + + + public static String getCacheName() { + return "sys-dict"; + } + + + + + + + + + public static String getCacheKey(String configKey) { + return "sys_dict:" + configKey; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\dic\\utils\DictUtils.class diff --git a/src/main/java/com/archive/project/ycts/ExceptionInfoController.java b/src/main/java/com/archive/project/ycts/ExceptionInfoController.java index 805eef0..fb600a1 100644 --- a/src/main/java/com/archive/project/ycts/ExceptionInfoController.java +++ b/src/main/java/com/archive/project/ycts/ExceptionInfoController.java @@ -1,34 +1,34 @@ -/* */ package com.archive.project.ycts + package com.archive.project.ycts ; -/* */ -/* */ import org.springframework.stereotype.Controller; -/* */ import org.springframework.web.bind.annotation.GetMapping; -/* */ import org.springframework.web.bind.annotation.RequestMapping; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Controller -/* */ @RequestMapping({"/ycts"}) -/* */ public class ExceptionInfoController -/* */ { -/* 19 */ private String prefix = "ycts"; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @GetMapping({"/fileNotExists"}) -/* */ public String fileNotExists() { -/* 27 */ return this.prefix + "/fileNotExists"; -/* */ } -/* */ } + + import org.springframework.stereotype.Controller; + import org.springframework.web.bind.annotation.GetMapping; + import org.springframework.web.bind.annotation.RequestMapping; + + + + + + + + + + @Controller + @RequestMapping({"/ycts"}) + public class ExceptionInfoController + { + private String prefix = "ycts"; + + + + + + @GetMapping({"/fileNotExists"}) + public String fileNotExists() { + return this.prefix + "/fileNotExists"; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\ycts\ExceptionInfoController.class