diff --git a/adc-da-base/src/main/java/com/adc/da/util/WaterMarkUtil.java b/adc-da-base/src/main/java/com/adc/da/util/WaterMarkUtil.java index 5cf6f56a..304e9f35 100644 --- a/adc-da-base/src/main/java/com/adc/da/util/WaterMarkUtil.java +++ b/adc-da-base/src/main/java/com/adc/da/util/WaterMarkUtil.java @@ -2,7 +2,7 @@ package com.adc.da.util; /** * @Description:水印 - * @Author: yangxuenan + * @Author: super_liu * date: 2020/1/10 15:42 */ public class WaterMarkUtil { diff --git a/adc-da-jwtLogin/src/main/java/com/adc/da/login/util/UserUtils.java b/adc-da-jwtLogin/src/main/java/com/adc/da/login/util/UserUtils.java index ad20df07..0c3197ba 100644 --- a/adc-da-jwtLogin/src/main/java/com/adc/da/login/util/UserUtils.java +++ b/adc-da-jwtLogin/src/main/java/com/adc/da/login/util/UserUtils.java @@ -3,11 +3,14 @@ package com.adc.da.login.util; import com.adc.da.login.security.JWTRealm; import com.adc.da.login.security.JWTRealm.Principal; import com.adc.da.sys.entity.MenuEO; +import com.adc.da.sys.entity.RoleEO; import com.adc.da.sys.entity.UserEO; import com.adc.da.sys.service.IMenuEOService; +import com.adc.da.sys.service.IRoleEOService; import com.adc.da.sys.service.IUserEOService; import com.adc.da.util.SpringContextHolder; import com.google.common.collect.Maps; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; @@ -28,15 +31,23 @@ public class UserUtils { } private static Logger logger = LoggerFactory.getLogger(UserUtils.class); + /** - * 当前登陆用户 - */ + * 当前登陆用户 + */ public static final String CURRENT_USER = "currentUser"; - /** - * 菜单信息 - */ - public static final String CACHE_MENU_LIST = "menuList"; + /** + * 角色信息 + */ + public static final String CACHE_ROLE_LIST = "roleList"; + /** + * 菜单信息 + */ + public static final String CACHE_MENU_LIST = "menuList"; + public static final String CACHE_MENU_TREE = "menuTree"; + public static final String CACHE_AREA_LIST = "areaList"; + public static final String CACHE_OFFICE_LIST = "officeList"; /** * @see IUserEOService @@ -48,6 +59,11 @@ public class UserUtils { */ private static IMenuEOService menuService = SpringContextHolder.getBean(IMenuEOService.class); + /** + * @see IRoleEOService + */ + private static IRoleEOService roleEOService = SpringContextHolder.getBean(IRoleEOService.class); + /** * 退出 */ @@ -148,6 +164,33 @@ public class UserUtils { return info; } + /** + * 获取当前登录用户角色列表 + */ + public static List getRoleList() throws NumberFormatException, Exception { + List roleList = (List) CacheUtils.getCache(CACHE_ROLE_LIST); + if (roleList == null) { + UserEO user = getUser(); + if(user != null) { + roleList = roleEOService.getSysRoleListByUserId(user.getUsid()); + } + CacheUtils.putCache(CACHE_ROLE_LIST, roleList); + } + return roleList; + } + + public static String getRoleIds() throws NumberFormatException, Exception { + List roleList = getRoleList(); + if (CollectionUtils.isEmpty(roleList)) { + return ""; + } + StringBuilder roleIds = new StringBuilder(); + for (RoleEO sysRoleEO : roleList) { + roleIds.append(sysRoleEO.getId()).append(","); + } + return roleIds.substring(0, roleIds.length() - 1); + } + public static void flush() { CacheUtils.removeCache(CURRENT_USER); } diff --git a/adc-da-main/pom.xml b/adc-da-main/pom.xml index e5259ca9..b0803634 100644 --- a/adc-da-main/pom.xml +++ b/adc-da-main/pom.xml @@ -24,6 +24,11 @@ org.springframework.boot spring-boot-starter + + com.adc + adc-da-slrs + 3.0.0 + com.adc adc-da-sys @@ -41,6 +46,12 @@ + + + + + + diff --git a/adc-da-main/src/main/resources/application.properties b/adc-da-main/src/main/resources/application.properties index 3bd3954c..1976a88d 100644 --- a/adc-da-main/src/main/resources/application.properties +++ b/adc-da-main/src/main/resources/application.properties @@ -94,8 +94,21 @@ spring.activiti.process-definition-location-prefix=classpath:/mybatis/mapper/act maxLoginErrorCount=3 verifyCodeMode=1 -# ========================================= -# 上传文件配置 -# ========================================= +# ============================================================================= +# 文件上传管控及配置 +# ============================================================================= +# file模块上传文件的服务器地址 +file.path=D:/uploadfile/bus +# 文件下载地址参数 +file.downloadUrl=http://39.98.140.126:10001/uploadPath #上传文件白名单-以,分隔 -upload.file.white.lists = doc,docx,xls,xlsx,pdf,PDF,png,jpg \ No newline at end of file +upload.file.white.lists = doc,docx,xls,xlsx,pdf,PDF,png,jpg + +# ============================================================================= +# elasticsearch 配置 +# ============================================================================= +elasticsearch.clustername=laws +elasticsearch.ip=localhost +elasticsearch.port=9300 +elasticsearch.poolSize=5 +elas.flag=true \ No newline at end of file diff --git a/adc-da-slrs/pom.xml b/adc-da-slrs/pom.xml index deed6c60..5219d792 100644 --- a/adc-da-slrs/pom.xml +++ b/adc-da-slrs/pom.xml @@ -17,7 +17,23 @@ 3.0.0 compile + + com.adc + adc-da-sys + 3.0.0 + compile + + + net.sf.json-lib + json-lib + 2.2.3 + jdk15 + + + com.adc + adc-da-jwtLogin + 3.1.0 + compile + - - \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/FileUnZip.java b/adc-da-slrs/src/main/java/com/adc/da/common/FileUnZip.java new file mode 100644 index 00000000..15c9124b --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/FileUnZip.java @@ -0,0 +1,178 @@ +package com.adc.da.common; + +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; +import org.apache.commons.compress.archivers.zip.ZipFile; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.zip.ZipEntry; + +public class FileUnZip { + + private static final Logger logger = LoggerFactory.getLogger(FileUnZip.class); + + /** + * 解压zip文件 + * + * @param sourceFile,待解压的zip文件; toFolder,解压后的存放路径 + * @throws Exception + * @author gaoyan + **/ + public static String unZipFiles(String sourceFile, String descDir) throws IOException { + File zipFile = new File(sourceFile); + + File pathFile = new File(descDir); + if (!pathFile.exists()) { + pathFile.mkdirs(); + } + ZipFile zip = new ZipFile(zipFile,"gbk"); + String orgMkdirs = ""; + for (Enumeration entries = zip.getEntries(); entries.hasMoreElements(); ) { + ZipArchiveEntry entry = (ZipArchiveEntry) entries.nextElement(); + String zipEntryName = entry.getName(); + String outPath = (descDir + "/" + zipEntryName).replaceAll("\\*", "/"); + //判断路径是否存在,不存在则创建文件路径 + File file = new File(outPath.substring(0, outPath.lastIndexOf('/'))); + if (!file.exists()) { + orgMkdirs = outPath.substring(0, outPath.lastIndexOf('/')); + file.mkdirs(); + }else{ + orgMkdirs = outPath.substring(0, outPath.lastIndexOf('/')); + } + //判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压 + if (new File(outPath).isDirectory()) { + continue; + } + //输出文件路径信息 +// InputStream in = null; +// OutputStream out = null; + System.gc(); + try(InputStream in =zip.getInputStream(entry); + OutputStream out =new FileOutputStream(outPath) + ){ + byte[] buf1 = new byte[1024]; + int len; + while ((len = in.read(buf1)) > 0) { + out.write(buf1, 0, len); + } + }catch(IOException e){ + logger.error(e.getMessage(),e); + } + } + System.gc(); + zip.close(); + return orgMkdirs; + } + + /** + * 递归删除文件及文件夹 + * + * @throws Exception + * @author gaoyan + * toFolder,解压后的存放路径 + **/ + public static boolean deleteDir(File dir) { + if (dir.isDirectory()) { + String[] children = dir.list(); + for (int i = 0; i < children.length; i++) { + File files = new File(dir, children[i]); + boolean success = deleteDir(files); + if (!success) { + return false; + } + } + } + // 目录此时为空,可以删除 + return dir.delete(); + } + + /** + * 读取一个目录下所有的Excel文件 + * gaoyan + * + * @param path + */ + public static List readExcelFile(String path) { + File file = new File(path); + List resultlist = new ArrayList<>(); + if (file.isDirectory()) { + File[] files = file.listFiles(); + for (File fi : files) { + // 对文件进行过滤,只读取Excel文件 + if (fi.getName().contains(".xls") || fi.getName().contains(".xlsx")) { + resultlist.add(fi); + } + } + } + return resultlist; + } + + public static List readImpExcelFile(String path) { + File file = new File(path); + List resultlist = new ArrayList<>(); + if (file.isDirectory()) { + File[] files = file.listFiles(); + for (File fi : files) { + // 对文件进行过滤,只读取Excel文件 + String name = fi.getName(); +// "导入模板".equals(fi.getName()) || "导入模板.xlsx".equals(fi.getName()) + if (name != null &&( fi.getName().contains(".xls") || fi.getName().contains(".xlsx") )){ + resultlist.add(fi); + } + } + } + return resultlist; + } + + /** + * 根据文件名称读取固定目录下文件 + * gaoyan + * @param filename + */ + public static List readFileByFilename(String path,String filename) { + List resultlist = new ArrayList<>(); + if (StringUtils.isNotEmpty(path)){ + File file = new File(path); + if (file.isDirectory()) { + File[] files = file.listFiles(); + for (File fi : files) { + // 对文件进行过滤 + if (fi.getName().equals(filename)) { + resultlist.add(fi); + } + } + } + } + return resultlist; + } + + /** + *@Description: 删除某个文件 + *@Param: [file] + *@return: void + *@Author: duyunbao + *@date: 2019/5/23 20:31 + */ + public static void delete(File file) { + if (!file.exists()) return; + + if (file.isFile() || file.list() == null) { + file.delete(); + logger.info("删除了" + file.getName()); + } else { + File[] files = file.listFiles(); + for (File a : files) { + delete(a); + } + file.delete(); + logger.info("删除了" + file.getName()); + } + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/HandleFileIOMsg.java b/adc-da-slrs/src/main/java/com/adc/da/common/HandleFileIOMsg.java new file mode 100644 index 00000000..2d22aca7 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/HandleFileIOMsg.java @@ -0,0 +1,40 @@ +package com.adc.da.common; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import sun.misc.BASE64Encoder; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +public class HandleFileIOMsg { + + private static final Logger logger = LoggerFactory.getLogger(HandleFileIOMsg.class); + + /** + * @Description: 根据文件地址转换为base64编码字符串 + */ + public String getFileBase64Str(String filePath) throws Exception { + byte[] data = null; + try (InputStream inputStream = new FileInputStream(filePath)){ + File file = new File(filePath); + data = new byte[(int) file.length()]; + inputStream.read(data); + inputStream.close(); + } catch (IOException e) { + logger.info(e.getMessage(),e); + } + // 加密 + BASE64Encoder encoder = new BASE64Encoder(); + String codeStr = ""; + if(data != null){ + codeStr = encoder.encode(data); + codeStr = codeStr.replaceAll("\r|\n", ""); + } + return codeStr; + } + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/MapImportHandler.java b/adc-da-slrs/src/main/java/com/adc/da/common/MapImportHandler.java new file mode 100644 index 00000000..febd0d41 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/MapImportHandler.java @@ -0,0 +1,31 @@ +package com.adc.da.common; + +import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; +import cn.afterturn.easypoi.util.PoiPublicUtil; + +import java.util.Map; + +public class MapImportHandler extends ExcelDataHandlerDefaultImpl> { + + @Override + public void setMapValue(Map map, String originKey, Object value) { + if (value instanceof Double) { + map.put(originKey, PoiPublicUtil.doubleToString((Double) value)); + } else { + map.put(originKey, value != null ? value.toString() : null); + } + } + + private String getRealKey(String originKey) { + if (originKey.equals("交易账户")) { + return "accountNo"; + } + if (originKey.equals("姓名")) { + return "name"; + } + if (originKey.equals("客户类型")) { + return "type"; + } + return originKey; + } +} \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/ProcessConformStateEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/ProcessConformStateEnum.java new file mode 100644 index 00000000..020a85c5 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/ProcessConformStateEnum.java @@ -0,0 +1,27 @@ +package com.adc.da.common; + +/** + * @Description: 项目库标准符合性枚举类 + * @Author: super_liu + * date: 2020/11/5 14:14 + */ +public enum ProcessConformStateEnum { + + CHECK("3","待验证"),FIT("1","符合"), + UNFIT("2","不符合"), + NOT_INVOLVE("4","不涉及"); + + private String value; + private String lable; + + private ProcessConformStateEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/PropertyTypeEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/PropertyTypeEnum.java new file mode 100644 index 00000000..2f5b3336 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/PropertyTypeEnum.java @@ -0,0 +1,29 @@ +package com.adc.da.common; + +/** + * 标准库参数类型枚举设置 + * @author gaoyan + * date 2018/09/03 + */ +public enum PropertyTypeEnum { + + PROVETYPE("PROVETYPE","适用车型"),APPLY_ARCTIC("APPLY_ARCTIC","适用车型"), + ENERGY_KIND("ENERGY_KIND","能源种类"),APPLY_AUTH("APPLY_AUTH","适用认证"), + CAR_MODEL("CAR_MODEL","公告车型号"), + CATEGORY("CATEGORY","所属专业领域"),PRODUCT_TYPE("PRODUCT_TYPE","产品类别"); + + private String value; + private String lable; + + private PropertyTypeEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/ReadExcel.java b/adc-da-slrs/src/main/java/com/adc/da/common/ReadExcel.java new file mode 100644 index 00000000..53de254a --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/ReadExcel.java @@ -0,0 +1,175 @@ +package com.adc.da.common; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLEncoder; + +/** + * @des : excel信息读取 + * @author: duyunbao + * @email: 1114808306@qq.com + * @date 2017/10/27 17:06 + **/ +public class ReadExcel { + private static final Logger logger = LoggerFactory.getLogger(ReadExcel.class); + + /** + * 总行数 + */ + private int totalRows = 0; + /** + * 总条数 + */ + private int totalCells = 0; + /** + * 错误信息接收器 + */ + private String errorMsg; + + public ReadExcel() { + // 不做操作 + } + + public int getTotalRows() { + return totalRows; + } + + public int getTotalCells() { + return totalCells; + } + + public String getErrorInfo() {//获取错误信息 + return errorMsg; + } + + /** + * @method_name: validateExcel + * @des : 验证excel格式 + * @author: duyunbao + * @param: [filePath] + * @return: boolean + * @date: 2017/10/27 17:07 + **/ + public boolean validateExcel(String filePath) { + if (filePath == null || !(WDWUtil.isExcel2003(filePath) || WDWUtil.isExcel2007(filePath))) { + errorMsg = "文件名不是excel格式"; + return false; + } + return true; + } + + /** + * @method_name: getExcelInfo + * @des : 读EXCEL文件,获取信息集合 + * @author: duyunbao + * @param: [fileName, Mfile] + * @return: org.apache.poi.ss.usermodel.Workbook + * @date: 2017/10/27 17:08 + **/ + public Workbook getExcelInfo(String fileName, MultipartFile Mfile) { + Workbook wb = null; + //把spring文件上传的MultipartFile转换成CommonsMultipartFile类型 + CommonsMultipartFile cf = (CommonsMultipartFile) Mfile; //获取本地存储路径 + //初始化输入流 + InputStream is = null; + try { + //根据文件名判断文件是2003版本还是2007版本 + boolean isExcel2003 = true; + if (WDWUtil.isExcel2007(fileName)) { + isExcel2003 = false; + } + is = cf.getInputStream(); + //根据excel里面的内容读取客户信息 + wb = getExcelInfo(is, isExcel2003, wb); + is.close(); + } catch (Exception e) { + logger.error(e.getMessage(),e); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + is = null; + logger.error(e.getMessage(),e); + } + } + } + return wb; + } + + /*** + * @method_name: getExcelInfo + * @des : 判断excel版本 + * @author: duyunbao + * @param: [is, isExcel2003, wb] + * @return: org.apache.poi.ss.usermodel.Workbook + * @date: 2017/10/27 17:08 + **/ + private Workbook getExcelInfo(InputStream is, boolean isExcel2003, Workbook wb) { + Workbook workbook =wb; + try { + /** 根据版本选择创建Workbook的方式 */ + //当excel是2003时 + if (isExcel2003) { + workbook = new HSSFWorkbook(is); + } else {//当excel是2007时 + workbook = new XSSFWorkbook(is); + } + } catch (IOException e) { + logger.error(e.getMessage(),e); + } + return workbook; + } + + /** + * 获取sheet的名称 + * @MethodName:getSheetName + * @author: 马晓晨 + * @email: 747052172@qq.com + * @date 2017年11月24日 上午9:49:22 + * @version V1.0 + * @param filename + * @param file + * @param sheetIndex + * @return + */ + public String getSheetName(String filename, MultipartFile file, Integer sheetIndex) { + Workbook wb = getExcelInfo(filename, file); + return wb.getSheetName(sheetIndex); + } + + /** + * + * @Title: encodeFileName + * @Description: 导出文件转换文件名称编码 + * @param @param fileNames + * @param @param request + * @param @return 设定文件 + * @return String 返回类型 + * @throws + */ + public static String encodeFileName(String fileNames , HttpServletRequest request) { + try { + String agent = request.getHeader("User-Agent"); + if (agent.contains("Firefox")) { + fileNames = new String(fileNames.getBytes("UTF-8"), "ISO8859-1"); // firefox浏览器 + } else { + fileNames = URLEncoder.encode(fileNames, "utf-8"); + //谷歌中空格变为+问题 + fileNames = fileNames.replaceAll("\\+","%20"); + } + } catch (Exception e) { + logger.error(e.getMessage(),e); + } + return fileNames ; + } +} \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/ReadWordTable.java b/adc-da-slrs/src/main/java/com/adc/da/common/ReadWordTable.java new file mode 100644 index 00000000..0b0c83a7 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/ReadWordTable.java @@ -0,0 +1,236 @@ +package com.adc.da.common; + +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFTable; +import org.apache.poi.xwpf.usermodel.XWPFTableCell; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr; + +import java.io.FileInputStream; +import java.io.IOException; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +/** + * @Description: + * @Author: super_liu + * date: 2020/2/25 16:58 + */ +public class ReadWordTable { + + + /** + * 保存生成HTML时需要被忽略的单元格 + */ + private List omitCellsList = new ArrayList<>(); + + /** + * 生成忽略的单元格列表中的格式 + * + * @param row + * @param col + * @return + */ + public String generateOmitCellStr(int row, int col) { + return row + ":" + col; + } + + /** + * 获取当前单元格的colspan(列合并)的列数 + * + * @param tcPr 单元格属性 + * @return + */ + public int getColspan(CTTcPr tcPr) { + // 判断是否存在列合并 + CTDecimalNumber gridSpan = null; + if ((gridSpan = tcPr.getGridSpan()) != null) { // 合并的起始列 + // 获取合并的列数 + BigInteger num = gridSpan.getVal(); + return num.intValue(); + } else { // 其他被合并的列或正常列 + return 1; + } + } + + /** + * 获取当前单元格的rowspan(行合并)的行数 + * + * @param table 表格 + * @param row 行值 + * @param col 列值 + * @return + */ + public int getRowspan(XWPFTable table, int row, int col) { + + XWPFTableCell cell = table.getRow(row).getCell(col); + // 正常独立单元格 + if (!isContinueRow(cell) && !isRestartRow(cell)) { + return 1; + } + // 当前单元格的宽度 + int cellWidth = getCellWidth(table, row, col); + // 当前单元格距离左侧边框的距离 + int leftWidth = getLeftWidth(table, row, col); + + // 用户保存当前单元格行合并的单元格数-1(因为不包含自身) + List list = new ArrayList<>(); + getRowspan(table, row, cellWidth, leftWidth, list); + + return list.size() + 1; + } + + private void getRowspan(XWPFTable table, int row, int cellWidth, int leftWidth, + List list) { + // 已达到最后一行 + if (row + 1 >= table.getNumberOfRows()) { + return; + } + row = row + 1; + int colsNum = table.getRow(row).getTableCells().size(); + // 因为列合并单元格可能导致行合并的单元格并不在同一列,所以从头遍历列,通过属性、宽度以及距离左边框间距来判断是否是行合并 + for (int i = 0; i < colsNum; i++) { + XWPFTableCell testTable = table.getRow(row).getCell(i); + // 是否为合并单元格的中间行(包括结尾行) + if (isContinueRow(testTable)) { + // 是被上一行单元格合并的单元格 + if (getCellWidth(table, row, i) == cellWidth + && getLeftWidth(table, row, i) == leftWidth) { + list.add(true); + // 被合并的单元格在生成html时需要忽略 + addOmitCell(row, i); + // 去下一行继续查找 + getRowspan(table, row, cellWidth, leftWidth, list); + break; + } + } + } + } + + /** + * 判断是否是合并行的起始行单元格 + * + * @param tableCell + * @return + */ + public boolean isRestartRow(XWPFTableCell tableCell) { + CTTcPr tcPr = tableCell.getCTTc().getTcPr(); + if (tcPr.getVMerge() == null) { + return false; + } + if (tcPr.getVMerge().getVal() == null) { + return false; + } + if (tcPr.getVMerge().getVal().toString().equalsIgnoreCase("restart")) { + return true; + } + return false; + } + + /** + * 判断是否是合并行的中间行单元格(包括结尾的最后一行的单元格) + * + * @param tableCell + * @return + */ + public boolean isContinueRow(XWPFTableCell tableCell) { + CTTcPr tcPr = tableCell.getCTTc().getTcPr(); + if (tcPr.getVMerge() == null) { + return false; + } + if (tcPr.getVMerge().getVal() == null) { + return true; + } + return false; + } + + public int getLeftWidth(XWPFTable table, int row, int col) { + int leftWidth = 0; + for (int i = 0; i < col; i++) { + leftWidth += getCellWidth(table, row, i); + } + return leftWidth; + } + + public int getCellWidth(XWPFTable table, int row, int col) { + BigInteger width = table.getRow(row).getCell(col).getCTTc().getTcPr().getTcW().getW(); + return width.intValue(); + } + + /** + * 添加忽略的单元格(被行合并的单元格,生成HTML时需要忽略) + * + * @param row + * @param col + */ + public void addOmitCell(int row, int col) { + String omitCellStr = generateOmitCellStr(row, col); + omitCellsList.add(omitCellStr); + } + + public boolean isOmitCell(int row, int col) { + String cellStr = generateOmitCellStr(row, col); + return omitCellsList.contains(cellStr); + } + + public String readTable(XWPFTable table) throws IOException { + // 表格行数 + int tableRowsSize = table.getRows().size(); + StringBuilder tableToHtmlStr = new StringBuilder(""); + + for (int i = 0; i < tableRowsSize; i++) { + tableToHtmlStr.append(""); + int tableCellsSize = table.getRow(i).getTableCells().size(); + for (int j = 0; j < tableCellsSize; j++) { + if (isOmitCell(i, j)) { + continue; + } + XWPFTableCell tableCell = table.getRow(i).getCell(j); + // 获取单元格的属性 + CTTcPr tcPr = tableCell.getCTTc().getTcPr(); + int colspan = getColspan(tcPr); + if (colspan > 1) { // 合并的列 + tableToHtmlStr.append(""); + + } + tableToHtmlStr.append(""); + } + tableToHtmlStr.append("
1) { // 合并的行 + tableToHtmlStr.append(" rowspan='" + rowspan + "'>"); + } else { + tableToHtmlStr.append(">"); + } + String text = tableCell.getText(); + tableToHtmlStr.append(text + "
"); + + clearTableInfo(); + + return tableToHtmlStr.toString(); + } + + public void clearTableInfo() { + // System.out.println(omitCellsList); + omitCellsList.clear(); + } + + public static void main(String[] args) { + ReadWordTable readWordTable = new ReadWordTable(); + + try (FileInputStream fileInputStream = new FileInputStream("E:\\下载\\table1.docx"); + XWPFDocument document = new XWPFDocument(fileInputStream);) { + List tables = document.getTables(); + for (XWPFTable table : tables) { + System.out.println(readWordTable.readTable(table)); + } + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarAskNatureEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarAskNatureEnum.java new file mode 100644 index 00000000..b1c68bc1 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarAskNatureEnum.java @@ -0,0 +1,20 @@ +package com.adc.da.common; + +public enum SarAskNatureEnum { + ZR("ZR","准入"),ZRYY("ZRYY","准入引用"), + UNFIT("ZRWG","准入无关"); + + private String value; + private String lable; + + private SarAskNatureEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarAttrFieldEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarAttrFieldEnum.java new file mode 100644 index 00000000..0aec0817 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarAttrFieldEnum.java @@ -0,0 +1,25 @@ +package com.adc.da.common; + +/** + * @Description: 自定义属性字段 + * date: 2020/11/5 14:14 + */ +public enum SarAttrFieldEnum { + + FO("FO","FO"),YQLX("YQLX","要求类型"), + ZRBM("ZRBM","责任部门"),XMPGJS("XMPGJS","项目评估角色"); + + private String value; + private String lable; + + private SarAttrFieldEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarBussStandStatus.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarBussStandStatus.java new file mode 100644 index 00000000..16ddeeba --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarBussStandStatus.java @@ -0,0 +1,66 @@ +package com.adc.da.common; + +import java.util.HashMap; +import java.util.Map; + +/** + * @program: LAWSSystem + * @description: + * @version: 1.0 + * @author: LiuJiaQi + * @create: 2020-11-03 15:09 + **/ +public class SarBussStandStatus { + private Map planStatusMap = new HashMap(); + private Map planTypeMap =new HashMap(); + private Map planStatusMapExport =new HashMap(); + private Map planTypeMapExport =new HashMap(); + + public SarBussStandStatus() { + planStatusMap.put("制定中", "1"); + planStatusMap.put("修订中", "2"); + planStatusMap.put("已发布", "3"); + planStatusMap.put("计划已确认", "4"); + planTypeMap.put("制定", "1"); + planTypeMap.put("修订", "2"); + //用于导出 + planStatusMapExport.put("1", "制定中"); + planStatusMapExport.put("2", "修订中"); + planStatusMapExport.put("3", "已发布"); + planStatusMapExport.put("4", "计划已确认"); + planTypeMapExport.put("1", "制定"); + planTypeMapExport.put("2", "修订"); + } + + public Map getPlanStatusMap() { + return planStatusMap; + } + + public void setPlanStatusMap(Map planStatusMap) { + this.planStatusMap = planStatusMap; + } + + public Map getPlanTypeMap() { + return planTypeMap; + } + + public void setPlanTypeMap(Map planTypeMap) { + this.planTypeMap = planTypeMap; + } + + public Map getPlanStatusMapExport() { + return planStatusMapExport; + } + + public void setPlanStatusMapExport(Map planStatusMapExport) { + this.planStatusMapExport = planStatusMapExport; + } + + public Map getPlanTypeMapExport() { + return planTypeMapExport; + } + + public void setPlanTypeMapExport(Map planTypeMapExport) { + this.planTypeMapExport = planTypeMapExport; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarConformStateEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarConformStateEnum.java new file mode 100644 index 00000000..56041bd7 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarConformStateEnum.java @@ -0,0 +1,28 @@ +package com.adc.da.common; + +/** + * @Description: 项目库标准符合性枚举类 + * @Author: super_liu + * date: 2020/11/5 14:14 + */ +public enum SarConformStateEnum { + + CHECK(1,"待验证"),FIT(2,"符合"), + UNFIT(3,"不符合"),PART_FIT(4,"部分符合"), + NOT_INVOLVE(5,"不涉及"),ASSESS(6,"评估中"), + RESET(7,"整改中"),NOT_EVAL(8,"未评估"); + + private Integer value; + private String lable; + + private SarConformStateEnum(Integer value, String lable) { + this.value = value; + this.lable = lable; + } + public Integer getValue() { + return value; + } + public String getLable() { + return lable; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarNumberTypeEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarNumberTypeEnum.java new file mode 100644 index 00000000..14f48c72 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarNumberTypeEnum.java @@ -0,0 +1,30 @@ +package com.adc.da.common; + +/** + * 编号类型分类 + * @author gaoyan + * date 2018/09/19 + */ +public enum SarNumberTypeEnum { + + STAND_NUMBER("STAND_NUMBER","标准编号"),LAWS_NUMBER("LAWS_NUMBER","文件号"), + STAND_REPLACE_NUMBER("STAND_REPLACE_NUMBER","代替标准号"),LAWS_REPLACE_NUMBER("LAWS_REPLACE_NUMBER","代替文件号"); + + private String value; + private String lable; + + private SarNumberTypeEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + + + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarPutTimeEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarPutTimeEnum.java new file mode 100644 index 00000000..8efd87a1 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarPutTimeEnum.java @@ -0,0 +1,26 @@ +package com.adc.da.common; + +/** + * @Description: 预警实施日期种类 + * @Author: super_liu + * date: 2020/10/19 15:59 + */ +public enum SarPutTimeEnum { + XDXCSSRQ("XDXCSSRQ","新定型车实施日期"),ZCCSSRQ("ZCCSSRQ","在产车实施日期"), + XSCCSSRQ("XSCCSSRQ","新生产车实施日期"); + + private String value; + private String lable; + + private SarPutTimeEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarStandStateEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarStandStateEnum.java new file mode 100644 index 00000000..032b9d0e --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarStandStateEnum.java @@ -0,0 +1,42 @@ +package com.adc.da.common; + +/** + * @Description: + * @Author: super_liu + * date: 2020/12/18 13:51 + */ +public enum SarStandStateEnum { + + DRAFT("DRAFT","草稿"),ADVICE("ADVICE","征求意见稿"), + SUBMIT("SUBMIT","送审稿"),RADYSUBMIT("RADYSUBMIT","报批稿"), + FJNVYX9Q7J("FJNVYX9Q7J","发布稿"),ZTXXYX("ZTXXYX","计划修订"), + ZTJJSS("ZTJJSS","修订中"),TOVOID("TOVOID","已作废"), + N5KLTFLNRC("N5KLTFLNRC","已修订"),QBXDZ("XB2USRPXY5","企标修订中"), + QBYZF("AY9L9FMSEW","企标已作废"),QBYXD("7ZT7YWXFPK","企标已修订"), + QBJHYQR("4VKQX3V2QU","企标计划已确认"),QBYFB("N75QKJ5MWB","企标已发布"); + + private String value; + private String lable; + + private SarStandStateEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + + public static String getLableByVal(String val){ + for (SarStandStateEnum stateEnum : SarStandStateEnum.values()) { + if (stateEnum.getValue() == val) { + return stateEnum.getLable(); + } + } + return ""; + } + + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarStateColorEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarStateColorEnum.java new file mode 100644 index 00000000..e8a8d000 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarStateColorEnum.java @@ -0,0 +1,26 @@ +package com.adc.da.common; + +/** + * @Description: 合规性分级颜色枚举 + * @Author: super_liu + * date: 2021/3/10 15:45 + */ +public enum SarStateColorEnum { + + GREEN("green","绿色"),RED("red","红色"),BLUE("blue","蓝色"), + YELLOW("yellow","黄色"),NA("grey","灰色"),NOT("notSure","未反馈"); + + private String value; + private String lable; + + private SarStateColorEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarSychronEO.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarSychronEO.java new file mode 100644 index 00000000..0edfc679 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarSychronEO.java @@ -0,0 +1,54 @@ +package com.adc.da.common; + +public class SarSychronEO { + + private String sychronId; + + private String sarId; + + private String sarNumber; + + private String conflictType; + + private String standName; + + public String getSychronId() { + return sychronId; + } + + public void setSychronId(String sychronId) { + this.sychronId = sychronId; + } + + public String getSarId() { + return sarId; + } + + public void setSarId(String sarId) { + this.sarId = sarId; + } + + public String getSarNumber() { + return sarNumber; + } + + public void setSarNumber(String sarNumber) { + this.sarNumber = sarNumber; + } + + public String getConflictType() { + return conflictType; + } + + public void setConflictType(String conflictType) { + this.conflictType = conflictType; + } + + public String getStandName() { + return standName; + } + + public void setStandName(String standName) { + this.standName = standName; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarSynInputEO.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarSynInputEO.java new file mode 100644 index 00000000..68de1874 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarSynInputEO.java @@ -0,0 +1,72 @@ +package com.adc.da.common; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +public class SarSynInputEO { + private String id; + private String standSort; + private String standNumber; + private String standYear; + private String standType; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date modifyTime; + private String standName; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getStandSort() { + return standSort; + } + + public void setStandSort(String standSort) { + this.standSort = standSort; + } + + public String getStandNumber() { + return standNumber; + } + + public void setStandNumber(String standNumber) { + this.standNumber = standNumber; + } + + public String getStandYear() { + return standYear; + } + + public void setStandYear(String standYear) { + this.standYear = standYear; + } + + public String getStandType() { + return standType; + } + + public void setStandType(String standType) { + this.standType = standType; + } + + public Date getModifyTime() { + return modifyTime; + } + + public void setModifyTime(Date modifyTime) { + this.modifyTime = modifyTime; + } + + public String getStandName() { + return standName; + } + + public void setStandName(String standName) { + this.standName = standName; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SarTypeEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SarTypeEnum.java new file mode 100644 index 00000000..cc804198 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SarTypeEnum.java @@ -0,0 +1,43 @@ +package com.adc.da.common; + +/** + * 标准法规分类 + * @author gaoyan + * date 2018/09/19 + */ +public enum SarTypeEnum { + + INLAND_STAND("INLAND_STAND","国内标准法规"),INLAND_LAWS("INLAND_LAWS","国内政策"), + FOREIGN_STAND("FOREIGN_STAND","国外标准法规"),FOREIGN_LAWS("FOREIGN_LAWS","国外政策"), + STAND("STAND","国内外标准法规"), + LAWS("LAWS","国内外政策"), + BUSINESS("BUSINESS","企业标准"), + BUSS("BUSS","企业标准"), + SPLIT("SPLIT","标准拆分"), + ACCESS("ACCESS","标准法规清单"), + // 增加清单临时分类代码 后续通过同步按钮同步时切换类型 + INLAND_STAND_ACCESS("INLAND_STAND_ACCESS","国内标准法规清单"), + FOREIGN_STAND_ACCESS("FOREIGN_STAND_ACCESS","国外标准法规清单"), + FOREIGN_LAWS_ACCESS("FOREIGN_LAWS_ACCESS","国内外政策清单"), + BUSS_ACCESS("BUSS","企业标准清单"), + PRODUCT("PRODUCT","车型/项目库"), + RECORDS("RECORDS","企标备案库"); + + private String value; + private String lable; + + private SarTypeEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + + + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SelectionTypeEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SelectionTypeEnum.java new file mode 100644 index 00000000..70e1c5b6 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SelectionTypeEnum.java @@ -0,0 +1,26 @@ +package com.adc.da.common; + +/** + * @Description: + * @Author: super_liu + * date: 2020/12/17 11:23 + */ +public enum SelectionTypeEnum { + + ORGLIST("ORGLIST","组织机构"),USERLIST("USERLIST","用户"), + ROLELIST("ROLELIST","角色"),SVPPS("SVPPS","SVPPS"),GZZXX("GZZXX","工作组信息"); + + private String value; + private String lable; + + private SelectionTypeEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SorDivideEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SorDivideEnum.java new file mode 100644 index 00000000..204c1b2c --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SorDivideEnum.java @@ -0,0 +1,31 @@ +package com.adc.da.common; + +/** + * 标准法规分类 + * @author gaoyan + * date 2018/09/19 + */ +public enum SorDivideEnum { + + INLAND_STAND("INLAND_STAND","国内标准法规"),INLAND_LAWS("INLAND_LAWS","国内政策"), + FOREIGN_STAND("FOREIGN_STAND","国外标准法规"),FOREIGN_LAWS("FOREIGN_LAWS","国外政策"), + BUSINESS_STAND("BUSINESS_STAND","企业标准") ; + + private String value; + private String lable; + + private SorDivideEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + + + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SplitFilePragraTypeEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/SplitFilePragraTypeEnum.java new file mode 100644 index 00000000..9a7bfe56 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SplitFilePragraTypeEnum.java @@ -0,0 +1,26 @@ +package com.adc.da.common; + +/** + * 标准库参数类型枚举设置 + * @author gaoyan + * date 2018/09/03 + */ +public enum SplitFilePragraTypeEnum { + + TEXT("TEXT","文字"),IMG("IMG","图片"),TABLE("TABLE","表格"); + + private String value; + private String lable; + + private SplitFilePragraTypeEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/SplitTableInfo.java b/adc-da-slrs/src/main/java/com/adc/da/common/SplitTableInfo.java new file mode 100644 index 00000000..374cd5ad --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/SplitTableInfo.java @@ -0,0 +1,28 @@ +package com.adc.da.common; + +/** + * @Description: + * @Author: super_liu + * date: 2020/5/11 10:29 + */ +public class SplitTableInfo { + private String tableName; + + private String tableHtml; + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public String getTableHtml() { + return tableHtml; + } + + public void setTableHtml(String tableHtml) { + this.tableHtml = tableHtml; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/StandAttrTypeEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/StandAttrTypeEnum.java new file mode 100644 index 00000000..462fdc0e --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/StandAttrTypeEnum.java @@ -0,0 +1,28 @@ +package com.adc.da.common; + +/** + * @Description: 属性类型枚举类 + * @Author: super_liu + * date: 2020/8/17 17:02 + */ +public enum StandAttrTypeEnum { + + INPUT_STR("INPUT_STR","输入框(字符串)"),INPUT_NUM("INPUT_NUM","输入框(数字)"), + SELECT_OPTION("SEL_OPTION","单选下拉框"),SEL_OPTS("SEL_OPTS","多选下拉框"),DATE_PICKER("DATE_PICKER","日期选择"), + DATE_PIC_OPTS("DATE_PIC_OPTS","多日期选择"),FILE("FILE","文件"), + TEXTAREA("TEXTAREA","文本框") ; + + private String value; + private String lable; + + private StandAttrTypeEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/StandFileClassifyEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/StandFileClassifyEnum.java new file mode 100644 index 00000000..88a7b26f --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/StandFileClassifyEnum.java @@ -0,0 +1,32 @@ +package com.adc.da.common; + +/** + * 资源库文件分类枚举设置 + * @author gaoyan + * date 2018/09/03 + */ +public enum StandFileClassifyEnum { + + STAND_FILE("STAND_FILE","标准文本/法规文件"),STAND_MODIFY_FILE("STAND_MODIFY_FILE","标准修改单"), + DRAFT_FILE("DRAFT_FILE","草案文件"),OPINION_FILE("OPINION_FILE","征求意见稿"), + SENT_SCREEN_FILE("SENT_SCREEN_FILE","送审稿"),APPROVAL_FILE("APPROVAL_FILE","报批稿"), + RELEVANCE_FILE("RELEVANCE_FILE","关联文件"),LAWS_FILE("LAWS_FILE","法规文件") ; + + private String value; + private String lable; + + private StandFileClassifyEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + + + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/StandPlanSchedule.java b/adc-da-slrs/src/main/java/com/adc/da/common/StandPlanSchedule.java new file mode 100644 index 00000000..48baf5ff --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/StandPlanSchedule.java @@ -0,0 +1,54 @@ +package com.adc.da.common; + +public class StandPlanSchedule { + + private String value; + + private int countPlanSubmit = 0; + + private int countRealSubmit = 0; + + private int countPlanRelease = 0; + + private int countRealRelease = 0; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public int getCountPlanSubmit() { + return countPlanSubmit; + } + + public void setCountPlanSubmit(int countPlanSubmit) { + this.countPlanSubmit = countPlanSubmit; + } + + public int getCountRealSubmit() { + return countRealSubmit; + } + + public void setCountRealSubmit(int countRealSubmit) { + this.countRealSubmit = countRealSubmit; + } + + public int getCountPlanRelease() { + return countPlanRelease; + } + + public void setCountPlanRelease(int countPlanRelease) { + this.countPlanRelease = countPlanRelease; + } + + public int getCountRealRelease() { + return countRealRelease; + } + + public void setCountRealRelease(int countRealRelease) { + this.countRealRelease = countRealRelease; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/TaskCommonQuery.java b/adc-da-slrs/src/main/java/com/adc/da/common/TaskCommonQuery.java new file mode 100644 index 00000000..926117d9 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/TaskCommonQuery.java @@ -0,0 +1,40 @@ +package com.adc.da.common; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = false) +public class TaskCommonQuery { + + @ApiModelProperty(value = "当前页") + private int current; + @ApiModelProperty(value = "数量") + private int size; + @ApiModelProperty(value = "名称") + private String name; + @ApiModelProperty(value = "开始时间从") + private String startTime; + @ApiModelProperty(value = "到") + private String endTime; + @ApiModelProperty(value = "结束时间从") + private String finishStartTime; + @ApiModelProperty(value = "到") + private String finishEndTime; + @ApiModelProperty(value = "流程分类") + private String category_id; + + @ApiModelProperty(value = "用户Id") + private String userId; + + @ApiModelProperty(value = "流程名称") + private String prcName; + + @ApiModelProperty(value = "流程编号") + private String prcNum; + + @ApiModelProperty(value = "流程类型") + private String prcType; + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/TemplateOriData.java b/adc-da-slrs/src/main/java/com/adc/da/common/TemplateOriData.java new file mode 100644 index 00000000..39e0d689 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/TemplateOriData.java @@ -0,0 +1,45 @@ +package com.adc.da.common; + +/** + * @Description: + * @Author: super_liu + * date: 2020/2/21 16:34 + */ +public class TemplateOriData { + private String preMsg = "

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。

本标准由广州汽车集团股份有限公司汽车工程研究院XXX提出。

本标准由广州汽车集团股份有限公司汽车工程研究院质量管理部归口。

本标准由广州汽车集团股份有限公司汽车工程研究院XXXX起草。

本标准由广州汽车集团股份有限公司汽车工程研究院XXXX解释。

本标准主要起草人:XXX、XXX、XXX。

本标准于20XX年XX月首次发布。

本标准于20XX年XX月进行第X次修订,标准修订人:XXX。

本次主要修订内容如下:

a) 增加内容的表述

——增加第X.X条XXXX的要求。

b)修改内容的表述

——第X.X条XXXX的要求由“XXX”改为“XXX”。

c)删除内容的表述

——删除原标准第X.X条XXXX的要求。

本标准所替代标准的历次版本发布情况为:

——QJ/GAC XXXX.XXX-XXXX。


"; + private String titleOne = "

    本标准规定了XXXX的术语和定义、技术要求、试验方法、检验规则和标志、包装、运输及贮存。

    本标准适用于广汽研究院开发的乘用车用的XXXX。


"; + private String titleTwo = "

       下列文件对于本文件的应用是必不可少的。凡是注日期的引用文件,仅所注日期的版本适用于本文件。凡是不注日期的引用文件,其最新版本(包括所有的修改单)适用于本文件。

       [国家标准]

       [行业标准]

       [地方标准]

       [法规、规程、规范和其它有关文件]

       [ISO标准]

       [IEC标准]

       [ISO、IEC有关文件]

       [其它国际标准]

       [其它国际有关文件]

       [本企业已发布的院级标准]


"; + private String titleThree = "

        下列术语和定义适用于本标准。


"; + + public String getPreMsg() { + return preMsg; + } + + public void setPreMsg(String preMsg) { + this.preMsg = preMsg; + } + + public String getTitleOne() { + return titleOne; + } + + public void setTitleOne(String titleOne) { + this.titleOne = titleOne; + } + + public String getTitleTwo() { + return titleTwo; + } + + public void setTitleTwo(String titleTwo) { + this.titleTwo = titleTwo; + } + + public String getTitleThree() { + return titleThree; + } + + public void setTitleThree(String titleThree) { + this.titleThree = titleThree; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/TextCompare.java b/adc-da-slrs/src/main/java/com/adc/da/common/TextCompare.java new file mode 100644 index 00000000..00db0aae --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/TextCompare.java @@ -0,0 +1,9 @@ +package com.adc.da.common; + +/** + * @Description: + * @Author: super_liu + * date: 2019/12/5 13:50 + */ +public class TextCompare { +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/UploadFile.java b/adc-da-slrs/src/main/java/com/adc/da/common/UploadFile.java new file mode 100644 index 00000000..6a96f877 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/UploadFile.java @@ -0,0 +1,64 @@ +package com.adc.da.common; + +public class UploadFile { + + private String id; + + private String fileName; + + private String oldFileName; + + private String fileSuffix; + + private String filePath; + + private String attId; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getOldFileName() { + return oldFileName; + } + + public void setOldFileName(String oldFileName) { + this.oldFileName = oldFileName; + } + + public String getFileSuffix() { + return fileSuffix; + } + + public void setFileSuffix(String fileSuffix) { + this.fileSuffix = fileSuffix; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public String getAttId() { + return attId; + } + + public void setAttId(String attId) { + this.attId = attId; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/UploadFileInfo.java b/adc-da-slrs/src/main/java/com/adc/da/common/UploadFileInfo.java new file mode 100644 index 00000000..80e8050a --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/UploadFileInfo.java @@ -0,0 +1,36 @@ +package com.adc.da.common; + +/** + * @Description: + * @Author: super_liu + * date: 2020/1/9 18:59 + */ +public class UploadFileInfo { + private String id; + private String filePath; + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/UseModuleEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/UseModuleEnum.java new file mode 100644 index 00000000..ea7125c7 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/UseModuleEnum.java @@ -0,0 +1,26 @@ +package com.adc.da.common; + +/** + * 标准库参数类型枚举设置 + * @author gaoyan + * date 2018/09/03 + */ +public enum UseModuleEnum { + + SOURCE_FILE("SOURCE_FILE","源文件"),WEB_FILE("WEB_FILE","PC预览文件"),MOBLE_FILE("MOBLE_FILE","手机预览文件"); + + private String value; + private String lable; + + private UseModuleEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/WDWUtil.java b/adc-da-slrs/src/main/java/com/adc/da/common/WDWUtil.java new file mode 100644 index 00000000..7abbc115 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/WDWUtil.java @@ -0,0 +1,164 @@ +package com.adc.da.common; + +import org.apache.commons.lang3.StringUtils; + +import java.util.regex.Pattern; + +/** + * @des : excel版本判断类 + * @author: duyunbao + * @email: 1114808306@qq.com + * @date 2017/10/27 16:59 + **/ +public class WDWUtil { + + /** + * @method_name: isExcel2003 + * @des :是否是2003的excel,返回true是2003 + * @author: duyunbao + * @param: [filePath] + * @return: boolean + * @date: 2017/10/27 16:57 + **/ + public static boolean isExcel2003(String filePath) { + return filePath.matches("^.+\\.(?i)(xls)$"); + } + + /** + * @method_name: isExcel2007 + * @des : 是否是2007的excel,返回true是2007 + * @author: duyunbao + * @param: [filePath] + * @return: boolean + * @date: 2017/10/27 16:57 + **/ + public static boolean isExcel2007(String filePath) { + return filePath.matches("^.+\\.(?i)(xlsx)$"); + } + + + /** + * 判断字符串是否是整数 + * @MethodName:isInteger + * @author: DuYunbao + * @date: 2018/5/22 18:00 + */ + public static boolean isNumeric(String str){ + for (int i = str.length();--i>=0;){ + if (!Character.isDigit(str.charAt(i))){ + return false; + } + } + return true; + } + + /**方法二:推荐,速度最快 + * 判断是否为整数 + * @param str 传入的字符串 + * @return 是整数返回true,否则返回false + */ + public static boolean isInteger(String str) { + Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); + return pattern.matcher(str).matches(); + } + + /** + * 字母或数字 + * + * @MethodName:isLetterDigitOrChinese + * @author: DuYunbao + * @date: 2018/5/30 15:26 + */ + public static boolean isLetterOrNumber(String str) { + String regex = "^(\\d|[a-zA-Z])+$"; + return !str.matches(regex); + } + + /** + * 汉字、字母、() + * + * @MethodName:isLetterOrChineseOrChar1 + * @author: DuYunbao + * @date: 2018/5/30 15:53 + */ + public static boolean isLetterOrChineseOrChar1(String str) { + String regex = "[^\\a-\\z\\A-\\Z\\u4E00-\\u9FA5\\()\\()]"; + return str.matches(regex); + } + + /** + * 汉字、字母、数字 + * + * @MethodName:isLetterOrChineseOrNumber + * @author: DuYunbao + * @date: 2018/5/30 15:56 + */ + public static boolean isLetterOrChineseOrNumber(String str) { + String regex = "^[\\u4E00-\\u9FA5A-Za-z0-9]+$"; + return !str.matches(regex); + } + + /** + * 汉字、字母、()、-、下划线 + * + * @MethodName:isChineseOrLetterOrUnderlineOrChar1 + * @author: DuYunbao + * @date: 2018/5/30 16:03 + */ + public static boolean isChineseOrLetterOrUnderlineOrChar1(String str) { + String regex = "^[\\u4E00-\\u9FA5A-Za-z_\\-\\()\\()]+$"; + return !str.matches(regex); + } + + /** + * 数字 + * + * @MethodName:isNumbee + * @author: DuYunbao + * @date: 2018/5/30 16:09 + */ + public static boolean isNumber(String str) { + String regex = "\\D"; + return str.matches(regex); + } + + /** + * 数字、大写字母、- + * + * @MethodName:isNumberOrLowerLetterOrChar1 + * @author: DuYunbao + * @date: 2018/5/30 16:41 + */ + public static boolean isNumberOrLowerLetterOrChar1(String str) { + String regex = "^[A-Z0-9\\-]+$"; + return !str.matches(regex); + } + + /** + * 汉字、数字、字母、()、-、下划线 + * + * @MethodName:isChineseOrNumberOrLetterOrUnderlineOrChar + * @author: DuYunbao + * @date: 2018/5/30 16:45 + */ + public static boolean isChineseOrNumberOrLetterOrUnderlineOrChar(String str) { + String regex = "^[\\u4E00-\\u9FA5A-Za-z0-9_\\-\\()\\()]+$"; + return !str.matches(regex); + } + + + /** + * 去除整数含有小数点 + * @MethodName:subStr + * @author: DuYunbao + * @date: 2018/5/31 11:19 + */ + public static String subStr(String text) { + if (StringUtils.isNotEmpty(text)) { + if(text.contains(".0") && text.substring(text.length()-2,text.length()).equals(".0")) { + text = text.substring(0,text.length()-2); + } + } + return text; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/WarnPutTypeEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/WarnPutTypeEnum.java new file mode 100644 index 00000000..b670c489 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/WarnPutTypeEnum.java @@ -0,0 +1,30 @@ +package com.adc.da.common; + +/** + * 标准法规分类 + * @author gaoyan + * date 2018/09/19 + */ +public enum WarnPutTypeEnum { + + NEWCAR("NEWCAR","新定车型"),NEWPRODUCT("NEWPRODUCT","新生产车型"), + PRODUCT("PRODUCT","在产车型"); + + private String value; + private String lable; + + private WarnPutTypeEnum(String value, String lable) { + this.value = value; + this.lable = lable; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + + + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/WarnTimeEnum.java b/adc-da-slrs/src/main/java/com/adc/da/common/WarnTimeEnum.java new file mode 100644 index 00000000..9a8e3725 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/WarnTimeEnum.java @@ -0,0 +1,33 @@ +package com.adc.da.common; + +/** + * 预警时间间隔 + * @author syt + * date 2018/09/19 + */ +public enum WarnTimeEnum { + + THREEMONTH("THREEMONTH","三个月",3),SIXMONTH("SIXMONTH","六个月",6), + ONEYEAR("ONEYEAR","一年",12),TWOYEAR("TWOYEAR","两年",24); + + private String value; + private String lable; + private int month; + + private WarnTimeEnum(String value, String lable,int month) { + this.value = value; + this.lable = lable; + this.month = month; + } + public String getValue() { + return value; + } + public String getLable() { + return lable; + } + + + public int getMonth() { + return month; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/common/Wrapper.java b/adc-da-slrs/src/main/java/com/adc/da/common/Wrapper.java new file mode 100644 index 00000000..ebf1743f --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/common/Wrapper.java @@ -0,0 +1,94 @@ +package com.adc.da.common; + +import java.io.Serializable; + +public class Wrapper implements Serializable { + private static final long serialVersionUID = 1L; + public static final int SUCCESS_CODE = 200; + public static final String SUCCESS_MESSAGE = "操作成功"; + public static final int ERROR_CODE = 500; + public static final String ERROR_MESSAGE = "内部异常"; + public static final int ILLEGAL_ARGUMENT_CODE_ = 100; + public static final String ILLEGAL_ARGUMENT_MESSAGE = "参数非法"; + private boolean success; + private int code; + private String message; + private T result; + + Wrapper() { + this(200, "操作成功"); + } + + Wrapper(int code, String message) { + this(code, message, (T) null); + } + + Wrapper(int code, String message, T result) { + this.success = true; + this.code(code).message(message).result(result); + } + + private Wrapper code(int code) { + this.setCode(code); + return this; + } + + private Wrapper message(String message) { + this.setMessage(message); + return this; + } + + public Wrapper result(T result) { + this.setResult(result); + return this; + } + + public boolean success() { + return 200 == this.code; + } + + public boolean error() { + return !this.success(); + } + + public boolean isSuccess() { + return this.success; + } + + public int getCode() { + return this.code; + } + + public String getMessage() { + return this.message; + } + + public T getResult() { + return this.result; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public void setCode(int code) { + this.code = code; + } + + public void setMessage(String message) { + this.message = message; + } + + public void setResult(T result) { + this.result = result; + } + + protected boolean canEqual(Object other) { + return other instanceof Wrapper; + } + + + public String toString() { + return "Wrapper(success=" + this.isSuccess() + ", code=" + this.getCode() + ", message=" + this.getMessage() + ", result=" + this.getResult() + ")"; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/controller/OtSvppsController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/controller/OtSvppsController.java new file mode 100644 index 00000000..b1c936c4 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/controller/OtSvppsController.java @@ -0,0 +1,23 @@ +package com.adc.da.slrs.otSvpps.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; +import com.adc.da.slrs.otSvpps.entity.OtSvpps; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RestController; +import com.adc.da.base.web.BaseController; + +/** +*

+ * SVPPS结构数据 SVPPS数据 前端控制器 + *

+* +* @author super_liu +* @since 2021-06-02 +*/ +@RestController +@Api(description = "|OtSvpps|") +@RequestMapping("/otSvpps/ot-svpps") +public class OtSvppsController extends BaseController { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/dao/OtSvppsDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/dao/OtSvppsDao.java new file mode 100644 index 00000000..a5ff896b --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/dao/OtSvppsDao.java @@ -0,0 +1,24 @@ +package com.adc.da.slrs.otSvpps.dao; + +import com.adc.da.slrs.otSvpps.entity.OtSvpps; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * SVPPS结构数据 SVPPS数据 Mapper 接口 + *

+ * + * @author super_liu + * @since 2021-06-02 + */ +public interface OtSvppsDao extends BaseMapper { + + List getNamesByIds(@Param("list") String[] list); + + List getNamesTipByIds(@Param("list") String[] list); + + List getIdsByNames(@Param("list") String[] list); +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/entity/OtSvpps.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/entity/OtSvpps.java new file mode 100644 index 00000000..8df0bac3 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/entity/OtSvpps.java @@ -0,0 +1,82 @@ +package com.adc.da.slrs.otSvpps.entity; + +import com.adc.da.base.entity.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * SVPPS结构数据 SVPPS数据 + *

+ * + * @author super_liu + * @since 2021-06-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@ApiModel(value="OtSvpps对象", description="SVPPS结构数据 SVPPS数据") +public class OtSvpps extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键 主键ID") + @TableId("ID") + private String id; + + @ApiModelProperty(value = "父级ID 父级ID引用本表的主键") + @TableField("P_ID") + private String pId; + + @ApiModelProperty(value = "一级编码 对应excel中的B列") + @TableField("F_NUM") + private String fNum; + + @ApiModelProperty(value = "二级编码 对应Excel中的C列") + @TableField("S_NUM") + private String sNum; + + @ApiModelProperty(value = "三级编码 对应excel中的D列") + @TableField("T_NUM") + private String tNum; + + @ApiModelProperty(value = "SVPPS编码 对应Excel中的E列") + @TableField("SVPPS_CODE") + private String svppsCode; + + @ApiModelProperty(value = "SVPPS英文名称 对应excel中的G列") + @TableField("SVPPS_EN_NAME") + private String svppsEnName; + + @ApiModelProperty(value = "SVPPS中文名称 对应excel中的I列") + @TableField("SVPPS_CN_NAME") + private String svppsCnName; + + @ApiModelProperty(value = "同步数据ID 对应同步系统中的ID") + @TableField("SYNC_ID") + private String syncId; + + @ApiModelProperty(value = "是否有效 默认为0") + @TableField("VALID_FLAG") + private Integer validFlag; + + @ApiModelProperty(value = "创建时间 数据入库时间") + @TableField("CREATED_TIME") + private LocalDateTime createdTime; + + @ApiModelProperty(value = "更新时间 数据更新时间") + @TableField("MODIFY_TIME") + private LocalDateTime modifyTime; + + @ApiModelProperty(value = "自定义数据标识") + @TableField("SELF_FALG") + private String selfFalg; + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/service/IOtSvppsService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/service/IOtSvppsService.java new file mode 100644 index 00000000..9c65e260 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/service/IOtSvppsService.java @@ -0,0 +1,16 @@ +package com.adc.da.slrs.otSvpps.service; + +import com.adc.da.slrs.otSvpps.entity.OtSvpps; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * SVPPS结构数据 SVPPS数据 服务类 + *

+ * + * @author super_liu + * @since 2021-06-02 + */ +public interface IOtSvppsService extends IService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/service/impl/OtSvppsServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/service/impl/OtSvppsServiceImpl.java new file mode 100644 index 00000000..17f25dee --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/otSvpps/service/impl/OtSvppsServiceImpl.java @@ -0,0 +1,20 @@ +package com.adc.da.slrs.otSvpps.service.impl; + +import com.adc.da.slrs.otSvpps.entity.OtSvpps; +import com.adc.da.slrs.otSvpps.dao.OtSvppsDao; +import com.adc.da.slrs.otSvpps.service.IOtSvppsService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * SVPPS结构数据 SVPPS数据 服务实现类 + *

+ * + * @author super_liu + * @since 2021-06-02 + */ +@Service +public class OtSvppsServiceImpl extends ServiceImpl implements IOtSvppsService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/controller/SarGroupMenuController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/controller/SarGroupMenuController.java new file mode 100644 index 00000000..8b7736d6 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/controller/SarGroupMenuController.java @@ -0,0 +1,23 @@ +package com.adc.da.slrs.sarGroupMenu.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; +import com.adc.da.slrs.sarGroupMenu.entity.SarGroupMenu; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RestController; +import com.adc.da.base.web.BaseController; + +/** +*

+ * 树形结构 前端控制器 + *

+* +* @author super_liu +* @since 2021-06-02 +*/ +@RestController +@Api(description = "|SarGroupMenu|") +@RequestMapping("/sarGroupMenu/sar-group-menu") +public class SarGroupMenuController extends BaseController { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/dao/SarGroupMenuDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/dao/SarGroupMenuDao.java new file mode 100644 index 00000000..ac1ec360 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/dao/SarGroupMenuDao.java @@ -0,0 +1,22 @@ +package com.adc.da.slrs.sarGroupMenu.dao; + +import com.adc.da.slrs.sarGroupMenu.entity.SarGroupMenu; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * 树形结构 Mapper 接口 + *

+ * + * @author super_liu + * @since 2021-06-02 + */ +public interface SarGroupMenuDao extends BaseMapper { + + String getNamesByIds(@Param("list") String[] list); + + String getIdsByNames(@Param("list") String[] list); +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/entity/SarGroupMenu.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/entity/SarGroupMenu.java new file mode 100644 index 00000000..cff8217b --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/entity/SarGroupMenu.java @@ -0,0 +1,73 @@ +package com.adc.da.slrs.sarGroupMenu.entity; + +import com.adc.da.base.entity.BaseEntity; +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 树形结构 + *

+ * + * @author super_liu + * @since 2021-06-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@ApiModel(value="SarGroupMenu对象", description="树形结构") +public class SarGroupMenu extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "ID") + @TableId("ID") + private String id; + + @ApiModelProperty(value = "PID") + @TableField("PID") + private String pid; + + @ApiModelProperty(value = "节点名称") + @TableField("MENU_NAME") + private String menuName; + + @ApiModelProperty(value = "节点类型") + @TableField("MENU_TYPE") + private String menuType; + + @ApiModelProperty(value = "节点层级") + @TableField("MENU_LEVEL") + private BigDecimal menuLevel; + + @ApiModelProperty(value = "创建时间") + @TableField("CREATE_TIME") + private LocalDateTime createTime; + + @TableField("CREATE_USERID") + private String createUserid; + + @ApiModelProperty(value = "修改时间") + @TableField("MODIFY_TIME") + private LocalDateTime modifyTime; + + @TableField("MODIFY_USERID") + private String modifyUserid; + + @ApiModelProperty(value = "判断标识") + @TableField("VLAG_FLAG") + private BigDecimal vlagFlag; + + @ApiModelProperty(value = "标准编号") + @TableField("STAND_NO") + private String standNo; + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/service/ISarGroupMenuService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/service/ISarGroupMenuService.java new file mode 100644 index 00000000..e7788340 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/service/ISarGroupMenuService.java @@ -0,0 +1,16 @@ +package com.adc.da.slrs.sarGroupMenu.service; + +import com.adc.da.slrs.sarGroupMenu.entity.SarGroupMenu; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 树形结构 服务类 + *

+ * + * @author super_liu + * @since 2021-06-02 + */ +public interface ISarGroupMenuService extends IService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/service/impl/SarGroupMenuServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/service/impl/SarGroupMenuServiceImpl.java new file mode 100644 index 00000000..6b925162 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarGroupMenu/service/impl/SarGroupMenuServiceImpl.java @@ -0,0 +1,20 @@ +package com.adc.da.slrs.sarGroupMenu.service.impl; + +import com.adc.da.slrs.sarGroupMenu.entity.SarGroupMenu; +import com.adc.da.slrs.sarGroupMenu.dao.SarGroupMenuDao; +import com.adc.da.slrs.sarGroupMenu.service.ISarGroupMenuService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 树形结构 服务实现类 + *

+ * + * @author super_liu + * @since 2021-06-02 + */ +@Service +public class SarGroupMenuServiceImpl extends ServiceImpl implements ISarGroupMenuService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/controller/SarMenuController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/controller/SarMenuController.java new file mode 100644 index 00000000..89e1bf9e --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/controller/SarMenuController.java @@ -0,0 +1,23 @@ +package com.adc.da.slrs.sarMenu.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; +import com.adc.da.slrs.sarMenu.entity.SarMenu; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RestController; +import com.adc.da.base.web.BaseController; + +/** +*

+ * 前端控制器 + *

+* +* @author super_liu +* @since 2021-06-01 +*/ +@RestController +@Api(description = "|SarMenu|") +@RequestMapping("/sarMenu/sar-menu") +public class SarMenuController extends BaseController { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/dao/SarMenuDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/dao/SarMenuDao.java new file mode 100644 index 00000000..8aaae7e9 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/dao/SarMenuDao.java @@ -0,0 +1,26 @@ +package com.adc.da.slrs.sarMenu.dao; + +import com.adc.da.slrs.sarMenu.entity.SarMenu; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +public interface SarMenuDao extends BaseMapper { + + List queryMenuByDis(SarMenu sarMenuEO); + + List selectMenuByRole(SarMenu sarMenuEO); + + List queryMenuByPid(SarMenu sarMenuEO); + + List queryByPidExcpetSelf(SarMenu sarMenuEO); + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/entity/SarMenu.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/entity/SarMenu.java new file mode 100644 index 00000000..7896b316 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/entity/SarMenu.java @@ -0,0 +1,79 @@ +package com.adc.da.slrs.sarMenu.entity; + +import com.adc.da.base.entity.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.springframework.data.annotation.Transient; + +/** + *

+ * + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@ApiModel(value="SarMenu对象", description="") +public class SarMenu extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId("ID") + private String id; + + @ApiModelProperty(value = "标准法规划分") + @TableField("SOR_DIVIDE") + private String sorDivide; + + @ApiModelProperty(value = "目录名称") + @TableField("MENU_NAME") + private String menuName; + + @ApiModelProperty(value = "父级ID") + @TableField("PARENT_ID") + private String parentId; + + @ApiModelProperty(value = "父级ID集合") + @TableField("PARENT_IDS") + private String parentIds; + + @ApiModelProperty(value = "排序序号") + @TableField("DISPLAY_SEQ") + private Integer displaySeq; + + @ApiModelProperty(value = "是否有效") + @TableField("VALID_FLAG") + private Integer validFlag; + + @ApiModelProperty(value = "创建时间") + @TableField("CREATION_TIME") + private Date creationTime; + + @ApiModelProperty(value = "修改时间") + @TableField("MODIFY_TIME") + private Date modifyTime; + + @ApiModelProperty(value = "备注") + @TableField("REMARKS") + private String remarks; + + @TableField(exist=false) + private List roleIds; + + @TableField(exist=false) + private List childMenuIds; + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/service/ISarMenuService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/service/ISarMenuService.java new file mode 100644 index 00000000..663740d8 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/service/ISarMenuService.java @@ -0,0 +1,23 @@ +package com.adc.da.slrs.sarMenu.service; + +import com.adc.da.slrs.sarMenu.entity.SarMenu; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +public interface ISarMenuService extends IService { + + List getParentMenuId(String menuId); + + List queryRoleMenuIdList(String sordDivide, String menuId) throws Exception; + + List getChildMenuList(String menuId); +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/service/impl/SarMenuServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/service/impl/SarMenuServiceImpl.java new file mode 100644 index 00000000..b5c7490b --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenu/service/impl/SarMenuServiceImpl.java @@ -0,0 +1,155 @@ +package com.adc.da.slrs.sarMenu.service.impl; + +import com.adc.da.login.util.UserUtils; +import com.adc.da.slrs.sarMenu.entity.SarMenu; +import com.adc.da.slrs.sarMenu.dao.SarMenuDao; +import com.adc.da.slrs.sarMenu.service.ISarMenuService; +import com.adc.da.utils.treetool.Tree; +import com.adc.da.utils.treetool.TreeNode; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + *

+ * 服务实现类 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +@Service +public class SarMenuServiceImpl extends ServiceImpl implements ISarMenuService { + + @Autowired + private SarMenuDao dao; + + public List getParentMenuId (String menuId) { + List parentIds = new ArrayList<>(); + if (StringUtils.isNotEmpty(menuId)) { + List sarMenuEOList = dao.selectList(new QueryWrapper<>()); + Tree tree = new Tree(sarMenuEOList); + TreeNode treeNode = tree.getTreeNode(menuId); + while (treeNode.getParent() != null) { + parentIds.add(treeNode.getParent().getNodeId()); + treeNode = treeNode.getParent(); + } + } + return parentIds; + } + + public List queryRoleMenuIdList(String sordDivide, String menuId) throws Exception{ + // 根据当前登录人id查出对应角色 + SarMenu sarMenu = new SarMenu(); + sarMenu.setSorDivide(sordDivide); + String roleIds = UserUtils.getRoleIds(); + String[] roleArr = roleIds.split(","); + List roleIdList = Arrays.asList(roleArr); + sarMenu.setRoleIds(roleIdList); + //角色未配置根节点,手动加入根节点权限 + List resultList = queryMenuByDis(sarMenu); + List list = selectMenuByRole(sarMenu); + if(!"BUSINESS_STAND".equals(sarMenu.getSorDivide())){ + resultList.addAll(list); + } else { + // 如果是企标,并且两个根节点都有权限,最先只查已分配下的节点 + if (resultList != null && resultList.size() == 2) { + SarMenu menu1 = resultList.get(0); + SarMenu menu2 = resultList.get(1); + if (list != null && list.size()>1) { + int menu1Index = -1; + int menu2Index = -1; + for (int i = 0;i < list.size();i++) { + if (list.get(i).getId().equals(menu1.getId())) { + menu1Index = i; + } else if (list.get(i).getId().equals(menu2.getId())) { + menu2Index = i; + } + } + if (menu1Index>0 && menu2Index>0 && StringUtils.isEmpty(menuId)) { + list.remove(menu2Index); + } + } + } + resultList = list; + } + List getMenuIds = new ArrayList<>(); + if(resultList != null && !resultList.isEmpty()){ + for(SarMenu menu : resultList){ + getMenuIds.add(menu.getId()); + } + } + return getMenuIds; + } + + public List queryMenuByDis(SarMenu sarMenu) { + return dao.queryMenuByDis(sarMenu); + } + + public List selectMenuByRole(SarMenu sarMenu) { + List list = dao.selectMenuByRole(sarMenu); + if (list == null) { + list = new ArrayList<>(); + } + SarMenu collectMenu = new SarMenu(); + collectMenu.setId("wdsc"); + collectMenu.setSorDivide(sarMenu.getSorDivide()); + collectMenu.setMenuName("我的收藏"); + collectMenu.setParentId("1"); + collectMenu.setDisplaySeq(9999); + list.add(collectMenu); + SarMenu labeltMenu = new SarMenu(); + labeltMenu.setId("gxhbq"); + labeltMenu.setSorDivide(sarMenu.getSorDivide()); + labeltMenu.setMenuName("个性化标签"); + labeltMenu.setParentId("1"); + labeltMenu.setDisplaySeq(10000); + if(!"BUSINESS_STAND".equals(sarMenu.getSorDivide())) { + list.add(labeltMenu); + } + return list; + } + + public List queryRoleMenuIdListForLaws(String sordDivide) throws Exception{ + // 根据当前登录人id查出对应角色 + SarMenu sarMenu = new SarMenu(); + sarMenu.setSorDivide(sordDivide); + String roleIds = UserUtils.getRoleIds(); + String[] roleArr = roleIds.split(","); + List roleIdList = Arrays.asList(roleArr); + sarMenu.setRoleIds(roleIdList); + //角色未配置根节点,手动加入根节点权限 +// List resultList = queryMenuByDis(SarMenu); + List list = selectMenuByRole(sarMenu); +// resultList.addAll(list); + List getMenuIds = new ArrayList<>(); + if(list != null && !list.isEmpty()){ + for(SarMenu menu : list){ + getMenuIds.add(menu.getId()); + } + } + return getMenuIds; + } + + public List getChildMenuList (String menuId) { + List menuIds = new ArrayList<>(); + if (StringUtils.isNotEmpty(menuId)) { + List SarMenuList = dao.selectList(new QueryWrapper<>()); + Tree tree = new Tree(SarMenuList); + TreeNode treeNode = tree.getTreeNode(menuId); + if (treeNode != null) { + menuIds.add(treeNode.getNodeId()); + for (TreeNode node : treeNode.getAllChildren()) { + menuIds.add(node.getNodeId()); + } + } + } + return menuIds; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/controller/SarStandAttrDetailsController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/controller/SarStandAttrDetailsController.java new file mode 100644 index 00000000..b1e87e5d --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/controller/SarStandAttrDetailsController.java @@ -0,0 +1,23 @@ +package com.adc.da.slrs.sarStandAttrDetails.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; +import com.adc.da.slrs.sarStandAttrDetails.entity.SarStandAttrDetails; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RestController; +import com.adc.da.base.web.BaseController; + +/** +*

+ * 前端控制器 + *

+* +* @author super_liu +* @since 2021-06-01 +*/ +@RestController +@Api(description = "|SarStandAttrDetails|") +@RequestMapping("/sarStandAttrDetails/sar-stand-attr-details") +public class SarStandAttrDetailsController extends BaseController { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/dao/SarStandAttrDetailsDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/dao/SarStandAttrDetailsDao.java new file mode 100644 index 00000000..7d609729 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/dao/SarStandAttrDetailsDao.java @@ -0,0 +1,21 @@ +package com.adc.da.slrs.sarStandAttrDetails.dao; + +import com.adc.da.slrs.sarStandAttrDetails.entity.SarStandAttrDetails; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +/** + *

+ * Mapper 接口 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +public interface SarStandAttrDetailsDao extends BaseMapper { + + String selectNameByField(@Param("attrField") String attrField, @Param("sarType") String sarType); + + SarStandAttrDetails selectFieldByName(@Param("attrName") String attrName, @Param("sarType") String sarType); + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/entity/SarStandAttrDetails.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/entity/SarStandAttrDetails.java new file mode 100644 index 00000000..c270b78f --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/entity/SarStandAttrDetails.java @@ -0,0 +1,111 @@ +package com.adc.da.slrs.sarStandAttrDetails.entity; + +import com.adc.da.base.entity.BaseEntity; +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.springframework.data.annotation.Transient; + +/** + *

+ * + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@ApiModel(value="SarStandAttrDetails对象", description="") +public class SarStandAttrDetails extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId("ID") + private String id; + + @ApiModelProperty(value = "属性字段") + @TableField("ATTR_FIELD") + private String attrField; + + @ApiModelProperty(value = "属性名称") + @TableField("ATTR_NAME") + private String attrName; + + @ApiModelProperty(value = "类型(INPUT_STR字符串输入框,INPUT_NUM数字输入框,SELECT_OPTION下拉框,DATE_PICKER日期选择,FILE文件,TEXTAREA文本框)") + @TableField("ATTR_TYPE") + private String attrType; + + @ApiModelProperty(value = "属性字段长度") + @TableField("ATTR_LEN") + private Long attrLen; + + @ApiModelProperty(value = "展示顺序") + @TableField("ORDER_NUM") + private Long orderNum; + + @ApiModelProperty(value = "是否可编辑(0是,1否)") + @TableField("IS_EDIT") + private String isEdit; + + @TableField("CREATION_USER") + private String creationUser; + + @ApiModelProperty(value = "是否有效") + @TableField("VALID_FLAG") + private String validFlag; + + @ApiModelProperty(value = "创建时间") + @TableField("CREATION_TIME") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + private Date creationTime; + + @ApiModelProperty(value = "修改时间") + @TableField("MODIFY_TIME") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + private Date modifyTime; + + @ApiModelProperty(value = "是否必填") + @TableField("IS_MUST") + private String isMust; + + @ApiModelProperty(value = "是否展示") + @TableField("IS_SHOW_IMP") + private String isShowImp; + + @ApiModelProperty(value = "展示区域") + @TableField("SHOW_REGION_ID") + private String showRegionId; + + @ApiModelProperty(value = "下拉选项所用的值") + @TableField("SEL_VAL") + private String selVal; + + @ApiModelProperty(value = "模块类型(STAND标准,LAWS政策)") + @TableField("SAR_TYPE") + private String sarType; + + @ApiModelProperty(value = "是否作为检索条件") + @TableField("IS_SEARCH") + private String isSearch; + + @ApiModelProperty(value = "是否预警") + @TableField("IS_WARN") + private String isWarn; + + @ApiModelProperty(value = "是否检索字段") + @TableField("IS_JANSUO") + private String isJansuo; + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/page/SarStandAttrDetailsEOPage.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/page/SarStandAttrDetailsEOPage.java new file mode 100644 index 00000000..1b0f4a82 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/page/SarStandAttrDetailsEOPage.java @@ -0,0 +1,46 @@ +package com.adc.da.slrs.sarStandAttrDetails.page; + +import com.adc.da.base.page.BasePage; +import lombok.Data; + +/** + * 功能:SAR_STAND_ATTR_DETAILS SarStandAttrDetailsEOPage
+ * 作者:code generator
+ * 日期: 2020-08-17
+ * 版权所有:版权归北京卡达克数据技术中心所有。
+ */ +@Data +public class SarStandAttrDetailsEOPage extends BasePage { + + private String id; + private String idOperator = "="; + private String attrField; + private String attrFieldOperator = "="; + private String attrName; + private String attrNameOperator = "="; + private String attrType; + private String attrTypeOperator = "="; + private String orderNum; + private String orderNumOperator = "="; + private String isEdit; + private String isEditOperator = "="; + private String creationUser; + private String creationUserOperator = "="; + private String validFlag; + private String validFlagOperator = "="; + private String creationTime; + private String creationTime1; + private String creationTime2; + private String creationTimeOperator = "="; + private String modifyTime; + private String modifyTime1; + private String modifyTime2; + private String modifyTimeOperator = "="; + private String attrLen; + private String attrLenOperator = "="; + private String[] idList; + private String notId; + private String sarType; + private String isSearch; + private String isWarn; +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/service/ISarStandAttrDetailsService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/service/ISarStandAttrDetailsService.java new file mode 100644 index 00000000..33684797 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/service/ISarStandAttrDetailsService.java @@ -0,0 +1,16 @@ +package com.adc.da.slrs.sarStandAttrDetails.service; + +import com.adc.da.slrs.sarStandAttrDetails.entity.SarStandAttrDetails; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +public interface ISarStandAttrDetailsService extends IService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/service/impl/SarStandAttrDetailsServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/service/impl/SarStandAttrDetailsServiceImpl.java new file mode 100644 index 00000000..eca61d31 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/service/impl/SarStandAttrDetailsServiceImpl.java @@ -0,0 +1,20 @@ +package com.adc.da.slrs.sarStandAttrDetails.service.impl; + +import com.adc.da.slrs.sarStandAttrDetails.entity.SarStandAttrDetails; +import com.adc.da.slrs.sarStandAttrDetails.dao.SarStandAttrDetailsDao; +import com.adc.da.slrs.sarStandAttrDetails.service.ISarStandAttrDetailsService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +@Service +public class SarStandAttrDetailsServiceImpl extends ServiceImpl implements ISarStandAttrDetailsService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/controller/SarStandAttrInfoController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/controller/SarStandAttrInfoController.java new file mode 100644 index 00000000..38050470 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/controller/SarStandAttrInfoController.java @@ -0,0 +1,23 @@ +package com.adc.da.slrs.sarStandAttrInfo.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; +import com.adc.da.slrs.sarStandAttrInfo.entity.SarStandAttrInfo; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RestController; +import com.adc.da.base.web.BaseController; + +/** +*

+ * 前端控制器 + *

+* +* @author super_liu +* @since 2021-06-01 +*/ +@RestController +@Api(description = "|SarStandAttrInfo|") +@RequestMapping("/SarStandAttrInfo/sar-stand-attr-info") +public class SarStandAttrInfoController extends BaseController { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/dao/SarStandAttrInfoDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/dao/SarStandAttrInfoDao.java new file mode 100644 index 00000000..bda32502 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/dao/SarStandAttrInfoDao.java @@ -0,0 +1,40 @@ +package com.adc.da.slrs.sarStandAttrInfo.dao; + +import com.adc.da.slrs.sarStandAttrInfo.entity.SarStandAttrInfo; +import com.adc.da.sys.common.SelectionResult; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + *

+ * Mapper 接口 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +public interface SarStandAttrInfoDao extends BaseMapper { + + void alterStandAttr(@Param("fieldInfo") String fieldInfo); + + void deleteStandAttr(@Param("fieldInfo") String fieldInfo); + + void updateAttrLen(@Param("fieldInfo") String fieldInfo); + + Integer selectStandAttrColumn(@Param("columnName") String columnName); + + Map selectStandFieldAndData(@Param("fieldInfo") String fieldInfo, @Param("standId") String standId); + + int insertStandAttr(@Param("fieldInfo") String fieldInfo, @Param("fieldValue") String fieldValue); + + int deleteStandAttrByStandId(@Param("standId") String standId); + + int updateStandInfo(@Param("standId") String standId, @Param("field") String field, @Param("value") String value); + + String selectFieldValByStandId(@Param("field") String field, @Param("standId") String standId); + + List selectFieldValByContainsVal(@Param("field") String field, @Param("value") String value, @Param("standIds") List standIds); +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/entity/SarStandAttrInfo.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/entity/SarStandAttrInfo.java new file mode 100644 index 00000000..46e74505 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/entity/SarStandAttrInfo.java @@ -0,0 +1,172 @@ +package com.adc.da.slrs.sarStandAttrInfo.entity; + +import com.adc.da.base.entity.BaseEntity; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@ApiModel(value="SarStandAttrInfo对象", description="") +public class SarStandAttrInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableField("ID") + private String id; + + @ApiModelProperty(value = "标准基础表主键") + @TableField("STAND_ID") + private String standId; + + @TableField("CREATION_USER") + private String creationUser; + + @ApiModelProperty(value = "是否有效") + @TableField("VALID_FLAG") + private String validFlag; + + @ApiModelProperty(value = "创建时间") + @TableField("CREATION_TIME") + private LocalDateTime creationTime; + + @ApiModelProperty(value = "修改时间") + @TableField("MODIFY_TIME") + private LocalDateTime modifyTime; + + @TableField("GKDW") + private String gkdw; + + @TableField("FBJG") + private String fbjg; + + @TableField("CYSD") + private String cysd; + + @TableField("XCXSSRQ") + private String xcxssrq; + + @TableField("ZCCSSRQ") + private String zccssrq; + + @TableField("EOPSSRQ") + private String eopssrq; + + @TableField("CBBH") + private String cbbh; + + @TableField("CLLX") + private String cllx; + + @TableField("GXHBQ") + private String gxhbq; + + @TableField("XGBM") + private String xgbm; + + @TableField("ZGRZLX") + private String zgrzlx; + + @TableField("GZZXX") + private String gzzxx; + + @TableField("FO") + private String fo; + + @TableField("XMPGJS") + private String xmpgjs; + + @TableField("SVPPS") + private String svpps; + + @TableField("CA") + private String ca; + + @TableField("ZQYJG") + private String zqyjg; + + @TableField("SSG") + private String ssg; + + @TableField("BPG") + private String bpg; + + @TableField("CGBM") + private String cgbm; + + @TableField("FBGBJBD") + private String fbgbjbd; + + @TableField("ZBJBD") + private String zbjbd; + + @TableField("ZRBM") + private String zrbm; + + @TableField("FGWHR") + private String fgwhr; + + @TableField("DTBJH") + private String dtbjh; + + @TableField("YYBJ") + private String yybj; + + @TableField("BYYBJ") + private String byybj; + + @TableField("XGLC") + private String xglc; + + @TableField("CHJL") + private String chjl; + + @TableField("XCXSSRQXM") + private String xcxssrqxm; + + @TableField("ZCCSSRQXM") + private String zccssrqxm; + + @TableField("EOPSSRQXM") + private String eopssrqxm; + + @TableField("CBCD") + private String cbcd; + + @TableField("ZRLX") + private String zrlx; + + @TableField("YQLX") + private String yqlx; + + @TableField("XXZLXX") + private String xxzlxx; + + @TableField("NRDBZFGQD") + private String nrdbzfgqd; + + @TableField("FGXXSXXX") + private String fgxxsxxx; + + @TableField("DXBZ") + private String dxbz; + + @TableField("BDTBZBH") + private String bdtbzbh; + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/service/ISarStandAttrInfoService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/service/ISarStandAttrInfoService.java new file mode 100644 index 00000000..06bfb514 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/service/ISarStandAttrInfoService.java @@ -0,0 +1,16 @@ +package com.adc.da.slrs.sarStandAttrInfo.service; + +import com.adc.da.slrs.sarStandAttrInfo.entity.SarStandAttrInfo; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +public interface ISarStandAttrInfoService extends IService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/service/impl/SarStandAttrInfoServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/service/impl/SarStandAttrInfoServiceImpl.java new file mode 100644 index 00000000..9f66424e --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrInfo/service/impl/SarStandAttrInfoServiceImpl.java @@ -0,0 +1,20 @@ +package com.adc.da.slrs.sarStandAttrInfo.service.impl; + +import com.adc.da.slrs.sarStandAttrInfo.entity.SarStandAttrInfo; +import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao; +import com.adc.da.slrs.sarStandAttrInfo.service.ISarStandAttrInfoService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +@Service +public class SarStandAttrInfoServiceImpl extends ServiceImpl implements ISarStandAttrInfoService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/controller/SarStandItemsController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/controller/SarStandItemsController.java new file mode 100644 index 00000000..f8869a44 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/controller/SarStandItemsController.java @@ -0,0 +1,23 @@ +package com.adc.da.slrs.sarStandItems.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; +import com.adc.da.slrs.sarStandItems.entity.SarStandItems; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RestController; +import com.adc.da.base.web.BaseController; + +/** +*

+ * 前端控制器 + *

+* +* @author super_liu +* @since 2021-06-01 +*/ +@RestController +@Api(description = "|SarStandItems|") +@RequestMapping("/SarStandItems/sar-stand-items") +public class SarStandItemsController extends BaseController { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/dao/SarStandItemsDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/dao/SarStandItemsDao.java new file mode 100644 index 00000000..20e88748 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/dao/SarStandItemsDao.java @@ -0,0 +1,53 @@ +package com.adc.da.slrs.sarStandItems.dao; + +import com.adc.da.slrs.sarStandItems.entity.SarStandItems; +import com.adc.da.slrs.sarStandItems.page.SarStandItemsEOPage; +import com.adc.da.sys.common.SelectionResult; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Set; + +/** + *

+ * Mapper 接口 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +public interface SarStandItemsDao extends BaseMapper { + + List querySarStandItemsList(SarStandItemsEOPage page); + + int querySarStandItemsListCount(SarStandItemsEOPage page); + + List queryItemsByList(SarStandItemsEOPage page); + + List selectItemByItemNum(SarStandItemsEOPage page); + + + @Select("SELECT id,VALID_FLAG FROM SAR_STAND_ITEMS WHERE id = #{id}") + SarStandItems getSarStandItemsEOById(String id); + + List queryIdsByList(SarStandItemsEOPage page); + + int insertForeach(List list); + + int updateForeach(List list); + + int deleteByStandIdAndFileType(@Param("standId") String standId, @Param("fileType") String fileType); + + Set selectClaimTypesByStandId(@Param("standId") String standId, @Param("fileType") String fileType, @Param("idList") String[] idList); + + Set selectSvppsByStandId(@Param("standId") String standId, @Param("fileType") String fileType, @Param("idList") String[] idList); + + int deleteByIds(@Param("idList") String[] idList); + + List selectAllItemsClaimType(SarStandItems sarStandItemsEO); + + List selectAllItemsSvpps(SarStandItems sarStandItemsEO); + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/entity/SarStandItems.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/entity/SarStandItems.java new file mode 100644 index 00000000..b4412414 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/entity/SarStandItems.java @@ -0,0 +1,117 @@ +package com.adc.da.slrs.sarStandItems.entity; + +import com.adc.da.base.entity.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@ApiModel(value="SarStandItems对象", description="") +public class SarStandItems extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId("ID") + private String id; + + @ApiModelProperty(value = "标准ID") + @TableField("STAND_ID") + private String standId; + + @ApiModelProperty(value = "条目编号") + @TableField("ITEMS_NUM") + private String itemsNum; + + @ApiModelProperty(value = "条目内容") + @TableField("ITEMS_NAME") + private String itemsName; + + @ApiModelProperty(value = "涉及零部件") + @TableField("PARTS") + private String parts; + + @ApiModelProperty(value = "特殊生效时间") + @TableField("TACK_TIME") + private LocalDateTime tackTime; + + @ApiModelProperty(value = "适用车型") + @TableField("APPLY_ARCTIC") + private String applyArctic; + + @ApiModelProperty(value = "能源类型") + @TableField("ENERGY_KIND") + private String energyKind; + + @ApiModelProperty(value = "责任部门") + @TableField("RESPONSIBLE_UNIT") + private String responsibleUnit; + + @ApiModelProperty(value = "备注") + @TableField("REMARKS") + private String remarks; + + @ApiModelProperty(value = "是否有效") + @TableField("VALID_FLAG") + private Boolean validFlag; + + @TableField("CREATION_USER") + private String creationUser; + + @ApiModelProperty(value = "创建时间") + @TableField("CREATION_TIME") + private LocalDateTime creationTime; + + @ApiModelProperty(value = "修改时间") + @TableField("MODIFY_TIME") + private LocalDateTime modifyTime; + + @ApiModelProperty(value = "条款要求") + @TableField("TERMS_CONDITIONS") + private String termsConditions; + + @ApiModelProperty(value = "实施要点") + @TableField("MAINPOINTS_IMPEMENTATION") + private String mainpointsImpementation; + + @ApiModelProperty(value = "FO") + @TableField("FO") + private String fo; + + @ApiModelProperty(value = "责任工程师") + @TableField("DUTY_ENGINEER") + private String dutyEngineer; + + @ApiModelProperty(value = "SVPPS") + @TableField("SVPPS") + private String svpps; + + @ApiModelProperty(value = "要求类型") + @TableField("CLAIM_TYPE") + private String claimType; + + @ApiModelProperty(value = "企标覆盖关系") + @TableField("BUS_STAND_COVER") + private String busStandCover; + + @ApiModelProperty(value = "文件类型") + @TableField("FILE_TYPE") + private String fileType; + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/page/SarStandItemsEOPage.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/page/SarStandItemsEOPage.java new file mode 100644 index 00000000..cdae20ca --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/page/SarStandItemsEOPage.java @@ -0,0 +1,59 @@ +package com.adc.da.slrs.sarStandItems.page; + +import com.adc.da.base.page.BasePage; +import lombok.Data; + +/** + * 功能:SAR_STAND_ITEMS SarStandItemsEOPage
+ * 作者:code generator
+ * 日期: 2018-09-03
+ * 版权所有:版权归北京卡达克数据技术中心所有。
+ */ +@Data +public class SarStandItemsEOPage extends BasePage { + + private String modifyTime; + private String modifyTime1; + private String modifyTime2; + private String modifyTimeOperator = "="; + private String creationTime; + private String creationTime1; + private String creationTime2; + private String creationTimeOperator = "="; + private String creationUser; + private String creationUserOperator = "="; + private String validFlag; + private String validFlagOperator = "="; + private String remarks; + private String remarksOperator = "="; + private String responsibleUnit; + private String responsibleUnitOperator = "="; + private String energyKind; + private String energyKindOperator = "="; + private String applyArctic; + private String applyArcticOperator = "="; + private String tackTime; + private String tackTime1; + private String tackTime2; + private String tackTimeOperator = "="; + private String parts; + private String partsOperator = "="; + private String itemsName; + private String itemsNameOperator = "="; + private String itemsNum; + private String itemsNumOperator = "="; + private String standId; + private String standIdOperator = "="; + private String id; + private String idOperator = "="; + private String nameOrRequest; + private String standNum; + private String processFlag; + private String fileType; + private String proType; + private String[] idlist; + private String noId; + private String productId; + private String lawsId; + private String sarState; +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/service/ISarStandItemsService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/service/ISarStandItemsService.java new file mode 100644 index 00000000..99dbf734 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/service/ISarStandItemsService.java @@ -0,0 +1,16 @@ +package com.adc.da.slrs.sarStandItems.service; + +import com.adc.da.slrs.sarStandItems.entity.SarStandItems; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +public interface ISarStandItemsService extends IService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/service/impl/SarStandItemsServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/service/impl/SarStandItemsServiceImpl.java new file mode 100644 index 00000000..5637b414 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandItems/service/impl/SarStandItemsServiceImpl.java @@ -0,0 +1,20 @@ +package com.adc.da.slrs.sarStandItems.service.impl; + +import com.adc.da.slrs.sarStandItems.entity.SarStandItems; +import com.adc.da.slrs.sarStandItems.dao.SarStandItemsDao; +import com.adc.da.slrs.sarStandItems.service.ISarStandItemsService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +@Service +public class SarStandItemsServiceImpl extends ServiceImpl implements ISarStandItemsService { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/controller/SarStandardsInfoController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/controller/SarStandardsInfoController.java index 7d370774..c332350b 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/controller/SarStandardsInfoController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/controller/SarStandardsInfoController.java @@ -1,11 +1,45 @@ package com.adc.da.slrs.sarStandardsInfo.controller; -import org.springframework.web.bind.annotation.RequestMapping; -import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; +import cn.hutool.core.util.ZipUtil; +import com.adc.da.att.entity.AttFileEO; +import com.adc.da.common.FileUnZip; +import com.adc.da.common.ReadExcel; +import com.adc.da.exception.AdcDaBaseException; +import com.adc.da.http.PageInfo; +import com.adc.da.http.ResponseMessage; +import com.adc.da.http.Result; +import com.adc.da.slrs.sarStandardsInfo.entity.*; +import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService; +import com.adc.da.util.LoginUserUtil; +import com.adc.da.util.UUIDUtils; +import com.adc.da.utils.util.*; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.util.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; import io.swagger.annotations.Api; -import org.springframework.web.bind.annotation.RestController; import com.adc.da.base.web.BaseController; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; /** *

@@ -16,8 +50,94 @@ import com.adc.da.base.web.BaseController; * @since 2021-05-31 */ @RestController -@Api(description = "|SarStandardsInfo|") +@Api(tags = "福田标准法规--标准法规库--国内标准法规") @RequestMapping("/sarStandardsInfo/sar-standards-info") public class SarStandardsInfoController extends BaseController { + private static final Logger logger = LoggerFactory.getLogger(SarStandardsInfoController.class); + + @Autowired + private ISarStandardsInfoService sarStandardsInfoEOService; + + + @Value("${file.path}") + private String filePath; + + @Value("${file.downloadUrl}") + private String fileDownloadPath; + + @ApiOperation(value = "|SarStandardsInfoEO|自定义分页查询") + @GetMapping("/getSarStandardsInfoPage") + //@RequiresPermissions("lawss:sarStandardsInfo:getSarStandardsInfoPage") + public ResponseMessage> getSarStandardsInfoPage(SarStandardsInfoEOPage page) throws Exception { + int isNull = -1; + if (null != page.getNowOrderBy()) { + switch (page.getNowOrderBy()) { + case 1: + page.setOrderBy1("issueTime"); + break; + case 2: + page.setOrderBy1("XCXSSRQPAIXU"); + break; + case 3: + page.setOrderBy1("ZCCSSRQPAIXU"); + break; + case 4: + page.setOrderBy1("standStateShow"); + break; + case 5: + page.setOrderBy1("paixu"); + break; + default: + page.setNowOrder(null); + break; + } + if (null != page.getNowOrder()) { + switch (page.getNowOrder()) { + case 1: + page.setOrder1("desc"); + break; + case 2: + page.setOrder1("asc"); + default: + page.setOrder1(null); + break; + } + } + } + if (StringUtils.isNotBlank(page.getAdvanceSearchVOStr())) { + List searchList = JSONObject.parseArray(page.getAdvanceSearchVOStr(),SarAdvanceSearchVO.class); + int i = 0; + for (SarAdvanceSearchVO sarAdvanceSearchVO:searchList){ + if ("SVPPS".equals(sarAdvanceSearchVO.getField()) && StringUtils.isBlank(sarAdvanceSearchVO.getValue())){ + isNull = i; + } + i++; + } + if (-1 != isNull) { + searchList.remove(isNull); + } + if (isNull == 0 && searchList.size() > 0){ + searchList.get(0).setConnect(""); + } + String advanceStr = SarAdvanceSearchUtil.createSql(searchList); + if (null != advanceStr) { + advanceStr = advanceStr.replace("stand_number", "concat(SAR_STANDARDS_INFO.STAND_SORT,' ',SAR_STANDARDS_INFO.STAND_NUMBER,'-',SAR_STANDARDS_INFO.STAND_YEAR)"); + } + if (-1 != isNull && StringUtils.isBlank(advanceStr)){ + advanceStr = advanceStr + " SVPPS is null"; + }else if (-1 != isNull && StringUtils.isNotBlank(advanceStr)){ + advanceStr = advanceStr + " and SVPPS is null"; + } + if (StringUtils.isNotBlank(advanceStr)) { + page.setAdvanceSearchStr(advanceStr); + } else { + page.setAdvanceSearchStr(null); + } + } + page.setUserId(LoginUserUtil.getUserId()); + List rows = sarStandardsInfoEOService.getSarStandardsInfoPage(page); + return Result.success(getPageInfo(page.getPager(), rows)); + } + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/dao/SarStandardsInfoDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/dao/SarStandardsInfoDao.java index d5d1accb..8258abd1 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/dao/SarStandardsInfoDao.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/dao/SarStandardsInfoDao.java @@ -1,7 +1,12 @@ package com.adc.da.slrs.sarStandardsInfo.dao; +import com.adc.da.slrs.sarStandardsInfo.entity.RecommendVO; import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; +import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfoEOPage; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** *

@@ -13,4 +18,49 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; */ public interface SarStandardsInfoDao extends BaseMapper { + List getSarStandardsInfoPage(SarStandardsInfoEOPage page); + + int getSarStandardsInfoCount(SarStandardsInfoEOPage page); + + SarStandardsInfo selectByPrimaryKeyAndModifyTime(SarStandardsInfo page); + + List selectStandardsByStandnumber(SarStandardsInfo sarStandardsInfoEO); + + Integer selectStandColumn(@Param("columnName") String columnName); + + Integer selectCounterStandardsCount(SarStandardsInfo sarStandardsInfoEO); + + int deleteByPrimaryKeyFlag(String id); + + int updateByStandNum(SarStandardsInfo standardsInfoEO); + + List selectStandardsInfoByIdAndRole(SarStandardsInfoEOPage standEO); + + int updateReplacedNumById(SarStandardsInfo sarStandardsInfoEO); + + int updateCitedStandById(SarStandardsInfo sarStandardsInfoEO); + + List getSarStandardsExportInfo(SarStandardsInfoEOPage page); + + List selectStandardsInfoByKey(String id); + + List selectRecommendStand(SarStandardsInfoEOPage pagenew); + + List countReplaceMsg(@Param("standNum") String standNum); + + List selectStandToUpState(@Param("stateName") String stateName); + + List selectStandToUpRepState(); + + List selectStandToUpRepAndTime(); + + int updateStateById(@Param("state") String state,@Param("list") List list); + + int selectIsExit(@Param("id") String id); + + //添加一个查询标准,但是不判断标准是否删除 + List selectStandardsInfoByIdAndRoleAll(SarStandardsInfoEOPage standEO); + + List selectStandardsInfoBynumber(SarStandardsInfoEOPage page); + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/RecommendVO.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/RecommendVO.java new file mode 100644 index 00000000..bb4006b0 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/RecommendVO.java @@ -0,0 +1,20 @@ +package com.adc.da.slrs.sarStandardsInfo.entity; + +import com.adc.da.base.entity.BaseEntity; +import lombok.Data; + +/** + * Created by super_liu + * 用于搜索中心的推荐 + */ + +@Data +public class RecommendVO extends BaseEntity { + + private String nameShow; + private String numberShow; + private String typeShow; + private String id; + private String module; + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarAdvanceSearchVO.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarAdvanceSearchVO.java new file mode 100644 index 00000000..3e6c41d5 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarAdvanceSearchVO.java @@ -0,0 +1,69 @@ +package com.adc.da.slrs.sarStandardsInfo.entity; + +/** + * @Description: 标准法规库高级查询 + * @Author: yangxuenan + * date: 2020/12/11 9:22 + */ +public class SarAdvanceSearchVO { + + private String field; //字段 如 标准类别 + + private String value; //值 + + private String type; //查询类型 如 = != like + + private String connect; //连接符号 如 and or + + private String timeSt; + + private String timeEd; + + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getConnect() { + return connect; + } + + public void setConnect(String connect) { + this.connect = connect; + } + + public String getTimeSt() { + return timeSt; + } + + public void setTimeSt(String timeSt) { + this.timeSt = timeSt; + } + + public String getTimeEd() { + return timeEd; + } + + public void setTimeEd(String timeEd) { + this.timeEd = timeEd; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandImportDto.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandImportDto.java new file mode 100644 index 00000000..bd1d96bf9 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandImportDto.java @@ -0,0 +1,67 @@ +package com.adc.da.slrs.sarStandardsInfo.entity; + + + +import java.text.SimpleDateFormat; + +/*** + * @Description: 根据导入模板的标题,基础表填写对应数据 + * @Author: yangxuenan + * @Date: 2020/9/22 10:33 + * @Param: + * @Return: + */ +public class SarStandImportDto { + + public static void compareFieldAndName (String name, String value,SarStandardsInfo sarStandardsInfoEO) throws Exception{ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + switch(name){ + case "适用区域": + sarStandardsInfoEO.setCountry(value); + break; + case "标准类别": + sarStandardsInfoEO.setStandSort(value); + break; + case "标准编号": + sarStandardsInfoEO.setStandNumber(value); + break; + case "标准年份": + sarStandardsInfoEO.setStandYear(value); + break; + case "中文名称": + sarStandardsInfoEO.setStandName(value); + break; + case "英文名称": + sarStandardsInfoEO.setStandEnName(value); + break; + case "标准状态": + sarStandardsInfoEO.setStandState(value); + break; + case "标准性质": + sarStandardsInfoEO.setStandNature(value); + break; + case "发布日期": +// Date iuuseDate = sdf.parse(value); + sarStandardsInfoEO.setIssueTime(value); + break; + case "实施日期": +// Date putDate = sdf.parse(value); + sarStandardsInfoEO.setPutTime2(value); + break; + case "文本说明": + sarStandardsInfoEO.setSynopsis(value); + break; + case "代替标准号": + sarStandardsInfoEO.setReplaceStandNum(value); + break; + case "被代替标准号": + sarStandardsInfoEO.setReplacedStandNum(value); + break; + case "重要度": + sarStandardsInfoEO.setIsRelateAccess(value); + break; + default: + break; + } + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java index 46e69548..1cf21e9c 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java @@ -1,18 +1,24 @@ package com.adc.da.slrs.sarStandardsInfo.entity; import com.adc.da.base.entity.BaseEntity; +import com.adc.da.slrs.sarStandItems.entity.SarStandItems; +import com.adc.da.sys.entity.DicTypeEO; import com.baomidou.mybatisplus.annotation.TableId; import java.time.LocalDateTime; +import java.util.*; + import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.springframework.data.annotation.Transient; /** *

- * + * *

* * @author super_liu @@ -72,7 +78,8 @@ public class SarStandardsInfo extends BaseEntity { @ApiModelProperty(value = "实施日期") @TableField("PUT_TIME") - private LocalDateTime putTime; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + private Date putTime; @ApiModelProperty(value = "内容摘要") @TableField("SYNOPSIS") @@ -95,11 +102,13 @@ public class SarStandardsInfo extends BaseEntity { @ApiModelProperty(value = "创建时间") @TableField("CREATION_TIME") - private LocalDateTime creationTime; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + private Date creationTime; @ApiModelProperty(value = "修改时间") @TableField("MODIFY_TIME") - private LocalDateTime modifyTime; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + private Date modifyTime; @ApiModelProperty(value = "是否法规清单相关(0否 1是)") @TableField("IS_RELATE_ACCESS") @@ -114,4 +123,57 @@ public class SarStandardsInfo extends BaseEntity { private String citedStand; + // 以下为非表中字段 + @Transient + private String collectId; // 收藏表ID + @Transient + private String countryShow; //国家地区显示名称 + @Transient + private String standSortShow; // 标准类别显示名称 + @Transient + private String standStateShow; // 标准状态显示名称 + @Transient + private String standNatureShow; // 标准性质显示名称 + @Transient + private String sychronId; // 同步数据ID + @Transient + private List dicTypeList = new ArrayList(); // 记录标准涉及到的所有数据字典数据 + @Transient + private Map attrInfoMap = new LinkedHashMap<>(); //属性表字段与值 + @Transient + private String sarStandAttrEOStr; //新增修改时属性表信息 + @Transient + private String menuId; //目录ID + @Transient + private int upReplaceNumFlag; //记录是否修改了替代文件号 + @Transient + private int upNumFlag; //记录是否修改了文件号 + @Transient + private String fileIds; //全部文件ID + @Transient + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + private Date newCarPutTime; + @Transient + private List itemsList = new ArrayList<>(); + @Transient + private String relateStand;//对应其他标准 + @Transient + private String accessCountry;//纳入清单的国家 + @Transient + private String processNum;//流程编号 + @Transient + private String textStatus;//文本状态 + // 在库里的标准节点类型(工作组) + @Transient + private String menuType; + @Transient + private String allPutTime; + @Transient + private String jspg; + @Transient + private String CHJL; + + @Transient + private String putTime2; + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfoEOPage.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfoEOPage.java new file mode 100644 index 00000000..dcf25cca --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfoEOPage.java @@ -0,0 +1,91 @@ +package com.adc.da.slrs.sarStandardsInfo.entity; + +import com.adc.da.base.page.BasePage; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * 功能:SAR_STANDARDS_INFO SarStandardsInfoEOPage
+ * 作者:code generator
+ * 日期: 2020-08-19
+ * 版权所有:版权归北京卡达克数据技术中心所有。
+ */ + +@Data +public class SarStandardsInfoEOPage extends BasePage { + + private String id; + private String idOperator = "="; + private String standType; + private String standTypeOperator = "="; + private String country; + private String countryOperator = "="; + private String standSort; + private String standSortOperator = "="; + private String standNumber; + private String standNumberOperator = "="; + private String standYear; + private String standYearOperator = "="; + private String standName; + private String standNameOperator = "="; + private String standEnName; + private String standEnNameOperator = "="; + private String standState; + private String standStateOperator = "="; + private String standNature; + private String standNatureOperator = "="; + private String issueTime; + private String issueTime1; + private String issueTime2; + private String issueTimeOperator = "="; + private String putTime; + private String putTime1; + private String putTime2; + private String putTimeOperator = "="; + private String synopsis; + private String synopsisOperator = "="; + private String replaceStandNum; + private String replaceStandNumOperator = "="; + private String replacedStandNum; + private String replacedStandNumOperator = "="; + private String creationUser; + private String creationUserOperator = "="; + private String validFlag; + private String validFlagOperator = "="; + private String creationTime; + private String creationTime1; + private String creationTime2; + private String creationTimeOperator = "="; + private String modifyTime; + private String isRelateAccess; + private String modifyTime1; + private String modifyTime2; + private String modifyTimeOperator = "="; + private List menuRoleList; //有权限的目录 + private String[] idlist; //多个id + private String menuId; //目录ID + private String rootMenuId; + private String attrSearchStr; + private String advanceSearchStr; + private Map attrSearchMap; //属性表数据条件查询 + // 树结构增加搜索条件 + private String collectMenuId; + private String labelMenuId; + private String applyArctic; + private String ids; + private List replaceStandNumList; + private List menuAllChildrenIdList; + private List advanceSearchVOList; + private String advanceSearchVOStr; + private String proType; // 请求的流程类型 + private String userId; + private String productId; + private Integer nowOrder; + private Integer nowOrderBy; + private String orderBy1 = "SAR_STANDARDS_INFO.issue_time"; + private String order1 = "desc"; + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/StandardsInfoExcelVO.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/StandardsInfoExcelVO.java new file mode 100644 index 00000000..9283ddc5 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/StandardsInfoExcelVO.java @@ -0,0 +1,17 @@ +package com.adc.da.slrs.sarStandardsInfo.entity; + +import lombok.Data; + +@Data +public class StandardsInfoExcelVO { + String exportType; + String menuId; + String labelMenuId; + String exportContent; + String exportName; + String standType; + String standSort; + String standNumber; + String collectMenuId; + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/ISarStandardsInfoService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/ISarStandardsInfoService.java index 1d9558ed..7efdb319 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/ISarStandardsInfoService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/ISarStandardsInfoService.java @@ -1,8 +1,15 @@ package com.adc.da.slrs.sarStandardsInfo.service; +import com.adc.da.slrs.sarStandardsInfo.entity.RecommendVO; import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; +import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfoEOPage; +import com.adc.da.slrs.sarStandardsInfo.entity.StandardsInfoExcelVO; +import com.adc.da.http.ResponseMessage; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; +import java.util.Map; + /** *

* 服务类 @@ -13,4 +20,25 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface ISarStandardsInfoService extends IService { + List getSarStandardsInfoPage(SarStandardsInfoEOPage page) throws Exception; + +// void createSarStandardsInfo(SarStandardsInfo sarStandardsInfoEO) throws Exception; +// +// int updateSarStandardsInfo(SarStandardsInfo sarStandardsInfoEO) throws Exception; +// +// int deleteSarStandards(String ids); +// +// List getExportDatas (StandardsInfoExcelVO standardsInfoExcelVO) throws Exception; +// +// ResponseMessage importSarStandardsInfoData(List> dataList, String standType, String menuId, String filepath); +// +// List selectStandardsByStandnumber(String replaceStandNum, String standType); +// +// SarStandardsInfo selectStandardsInfoByKey(String id) throws Exception; +// +// boolean updateStandardsMenu(SarStandardsInfoEOPage standardsInfoEO); +// +// boolean updateStandInfo(SarStandardsInfoEOPage standardsInfoEO); +// +// List selectRecommendStand(SarStandardsInfoEOPage pagenew); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java index 06e09598..1906aebb 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java @@ -1,11 +1,30 @@ package com.adc.da.slrs.sarStandardsInfo.service.impl; -import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; +import com.adc.da.att.entity.AttFileEO; +import com.adc.da.att.service.IAttFileEOService; +import com.adc.da.common.*; +import com.adc.da.person.service.IPersonCollectEOService; +import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao; +import com.adc.da.slrs.sarStandItems.dao.SarStandItemsDao; +import com.adc.da.slrs.sarStandItems.entity.SarStandItems; +import com.adc.da.slrs.sarStandardsInfo.entity.*; +import com.adc.da.slrs.sarMenu.service.ISarMenuService; import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao; import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService; +import com.adc.da.slrs.sysInfo.service.SysInfoEOService; +import com.adc.da.sys.dao.DicTypeEODao; +import com.adc.da.utils.util.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import java.sql.Clob; +import java.util.*; + /** *

* 服务实现类 @@ -17,4 +36,199 @@ import org.springframework.stereotype.Service; @Service public class SarStandardsInfoServiceImpl extends ServiceImpl implements ISarStandardsInfoService { + private static final Logger logger = LoggerFactory.getLogger(SarStandardsInfoServiceImpl.class); + + @Value("${elas.flag}") + private boolean elasflag; //ES是否启用 + + @Autowired + private SarStandardsInfoDao dao; + + @Autowired + private ISarMenuService sarMenuEOService; + + @Autowired + private IPersonCollectEOService personCollectEOService; + + @Autowired + private SarStandAttrInfoDao sarStandAttrInfoEODao; + + @Autowired + private IAttFileEOService attFileEOService; + + @Autowired + private DicTypeEODao dicTypeEODao; + + @Autowired + private SarStandItemsDao sarStandItemsEODao; + + @Autowired + private SysInfoEOService sysInfoEOService; + + + + /*** + * @Description: 分页查询 + * @Author: super_liu + * @Date: 2020/8/19 10:23 + * @Param: [page] + * @Return: java.util.List + */ + public List getSarStandardsInfoPage(SarStandardsInfoEOPage page) throws Exception { + //查询当前登录人角色拥有权限的菜单 + List getMenuIdList = sarMenuEOService.queryRoleMenuIdList(page.getStandType()+"_STAND",null); + if(getMenuIdList != null && !getMenuIdList.isEmpty()){ + page.setMenuRoleList(getMenuIdList); + } else { + page.setMenuRoleList(null); + } + List ids = sarMenuEOService.getChildMenuList(page.getMenuId()); + if (ids != null && !ids.isEmpty()) { + page.setMenuAllChildrenIdList(ids); + } + Integer rowCount = dao.getSarStandardsInfoCount(page); + page.getPager().setRowCount(rowCount); + List sarlist = dao.getSarStandardsInfoPage(page); + attrInfo(sarlist); + return sarlist; + } + + /*** + * @Description: 处理属性表数据 + * @Author: super_liu + * @Date: 2021/6/1 9:37 + * @Param: [sarlist] + * @Return: void + */ + public void attrInfo (List sarlist) throws Exception { + for(SarStandardsInfo row : sarlist){ + attrInfoDetails(row); + } + } + + public void attrInfoDetails (SarStandardsInfo row) throws Exception { + String fieldInfo = InitStandAttrUtil.queryField; + String collectId = personCollectEOService.queryCollectByUserAndId(row.getId()); + row.setCollectId(collectId); + // 查询属性表数据 + if (StringUtils.isNotBlank(fieldInfo)) { + Map getAttrMap = sarStandAttrInfoEODao.selectStandFieldAndData(fieldInfo,row.getId()); + if (InitStandAttrUtil.clobFieldList != null && !InitStandAttrUtil.clobFieldList.isEmpty()) { + // 遍历修改所有clob类型的值 + for (String clobField : InitStandAttrUtil.clobFieldList) { + Clob clobValue = (Clob) getAttrMap.get(clobField); + String fieldValue = FieldConvertUtil.ClobToString(clobValue); + getAttrMap.put(clobField,fieldValue); + } + } + // 组织机构和人员 + Map newMap = new HashMap<>(); + if (getAttrMap != null) { + for (Map.Entry entry : getAttrMap.entrySet()) { + if ("EOPSSRQ".equals(entry.getKey())){ + if (entry.getValue() != null && entry.getValue().toString().length()>10){ + String time = DateUtil.formatStrUTCToDateStr(entry.getValue().toString()); + entry.setValue(time); + } + } + String name = entry.getKey(); + if ("\"null\"".equals(entry.getValue())) { + entry.setValue(""); + } + if ("SVPPS".equals(name)) { + Set set = new HashSet(); + // 查询条款svpps + Set itemSvpps = sarStandItemsEODao.selectSvppsByStandId(row.getId(),null,null); + if (itemSvpps != null && !itemSvpps.isEmpty()) { + set.addAll(itemSvpps); + } + Object value = entry.getValue(); + if (value != null && StringUtils.isNotBlank(value.toString())) { + set.addAll(Arrays.asList(value.toString().split(","))); + } + String allVal = ConcatStringUtil.concatSet(set); + if (StringUtils.isNotBlank(allVal)) { + entry.setValue(allVal); + value = sysInfoEOService.getSvppsNamesByIds(allVal); + } + newMap.put(name + "Name",value); + } else if ("YQLX".equals(name)) { + //要求类型来源于条款 + SarStandItems sarStandItemsEO = new SarStandItems(); + sarStandItemsEO.setStandId(row.getId()); + Set itemClaimType = sarStandItemsEODao.selectClaimTypesByStandId(row.getId(),null,null); + if (itemClaimType != null && itemClaimType.size() > 1) { + entry.setValue("RENVECPFGT"); + } else if (itemClaimType != null && itemClaimType.size() == 1) { + entry.setValue(itemClaimType.toArray()[0]); + } + } else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) { + String value = entry.getValue().toString(); + String selVal = InitStandAttrUtil.selectFieldMap.get(name); + if (SelectionTypeEnum.ORGLIST.getValue().equals(selVal)) { + value = sysInfoEOService.getOrgNamesByIds(value); + newMap.put(name + "Name",value); + } else if (SelectionTypeEnum.USERLIST.getValue().equals(selVal)) { + value = sysInfoEOService.getUserNamesByIds(value); + newMap.put(name + "Name",value); + } else if (SelectionTypeEnum.ROLELIST.getValue().equals(selVal)) { + value = sysInfoEOService.getRoleNamesByIds(value); + newMap.put(name + "Name",value); + } + } + } + getAttrMap.putAll(newMap); + } + row.setAttrInfoMap(getAttrMap); + } + } + + public void attrInfoShow (List sarlist) throws Exception { + for(SarStandardsInfo row : sarlist){ + attrInfoDetails(row); + Map getAttrMap = row.getAttrInfoMap(); + Map getNewMap = new LinkedHashMap<>(); + if (getAttrMap != null && getAttrMap.size() > 0) { + String svppsTip = ""; + for (Map.Entry entry : getAttrMap.entrySet()) { + String name = entry.getKey(); + String value = ""; + if ("SVPPS".equals(name)) { + Object svpps = entry.getValue(); + if (svpps != null && StringUtils.isNotBlank(svpps.toString())) { + svppsTip = svpps.toString(); + } + if (StringUtils.isNotBlank(svppsTip)) { + svppsTip = sysInfoEOService.getSvppsNamesTipByIds(svppsTip); + } + value = String.valueOf(getAttrMap.get("SVPPSName")); + entry.setValue(value); + } else if (entry.getValue() != null && InitStandAttrUtil.fileFieldList != null && InitStandAttrUtil.fileFieldList.size() > 0 && InitStandAttrUtil.fileFieldList.contains(name)) { + value = entry.getValue().toString(); + if (StringUtils.isNotBlank(value)) { + List fileObj = attFileEOService.getMultiFileInfos(value); + entry.setValue(fileObj); + } + } else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) { + value = entry.getValue().toString(); + if ("GZZXX".equals(name)) { + value = sysInfoEOService.getGroupNamesByIds(value); + } else { + String selVal = InitStandAttrUtil.selectFieldMap.get(name); + if (SelectionTypeEnum.ORGLIST.getValue().equals(selVal) || SelectionTypeEnum.USERLIST.getValue().equals(selVal) || SelectionTypeEnum.ROLELIST.getValue().equals(selVal)) { + if(getAttrMap.get(name + "Name") != null){ + value = String.valueOf(getAttrMap.get(name + "Name")); + } + } else { + List valArr = Arrays.asList(value.split(",")); + value = dicTypeEODao.getDicNamesByCodes(valArr); + } + } + entry.setValue(value); + } + } + getAttrMap.put("SVPPSTips",svppsTip); + } + } + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sysInfo/service/SysInfoEOService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sysInfo/service/SysInfoEOService.java new file mode 100644 index 00000000..717efb75 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sysInfo/service/SysInfoEOService.java @@ -0,0 +1,431 @@ +package com.adc.da.slrs.sysInfo.service; + +import com.adc.da.att.entity.AttFileEO; +import com.adc.da.att.service.IAttFileEOService; +import com.adc.da.common.SarConformStateEnum; +import com.adc.da.common.SelectionTypeEnum; +import com.adc.da.slrs.otSvpps.dao.OtSvppsDao; +import com.adc.da.slrs.sarGroupMenu.dao.SarGroupMenuDao; +import com.adc.da.sys.dao.DicTypeEODao; +import com.adc.da.sys.dao.OrgEODao; +import com.adc.da.sys.dao.RoleEODao; +import com.adc.da.sys.dao.UserEODao; +import com.adc.da.sys.entity.DicTypeEO; +import com.adc.da.sys.page.DicTypeEOPage; +import com.adc.da.utils.util.InitStandAttrUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description: + * @Author: super_liu + * date: 2020/06/02 9:43 + */ +@Service("sysInfoEOService") +public class SysInfoEOService { + + @Autowired + private DicTypeEODao dicTypeEODao; + + @Autowired + private OrgEODao orgEODao; + + @Autowired + private UserEODao userEODao; + + @Autowired + private RoleEODao roleEODao; + + @Autowired + private SarGroupMenuDao sarGroupMenuEODao; + + @Autowired + private OtSvppsDao otSvppsEODao; + + @Autowired + private IAttFileEOService attFileEOService; + + /** + * @Description: 根据用户id返回逗号分隔字符串名称 + * @Author: yangxuenan + * @Date: 2020/06/02 9:50 + * @Param: [userIds] + * @Return: java.lang.String + */ + public String getUserNamesByIds(String userIds){ + String userNames = ""; + if (StringUtils.isNotBlank(userIds)) { + String[] idArr = userIds.split(","); + userNames = userEODao.getNamesByIds(idArr); + if (StringUtils.isBlank(userNames) || "null".equals(userNames)) { + userNames = ""; + } + } + return userNames; + } + + /*** + * @Description: 根据机构id返回逗号分隔字符串名称 + * @Author: yangxuenan + * @Date: 2020/06/02 9:50 + * @Param: [userIds] + * @Return: java.lang.String + */ + public String getOrgNamesByIds(String orgIds){ + String names = ""; + if (StringUtils.isNotBlank(orgIds)) { + String[] idArr = orgIds.split(","); + names = orgEODao.getNamesByIds(idArr); + if (StringUtils.isBlank(names) || "null".equals(names)) { + names = ""; + } + } + return names; + } + + /*** + * @Description: 根据标准法规属性code返回逗号分隔字符串名称 + * @Author: yangxuenan + * @Date: 2020/06/02 9:51 + * @Param: [userIds] + * @Return: java.lang.String + */ + public String getDicNamesByCodes(String codes){ + String names = ""; + if (StringUtils.isNotBlank(codes)) { + String[] idArr = codes.split(","); + names = dicTypeEODao.getDicNamesByCodes(Arrays.asList(idArr)); + } + return names; + } + + /*** + * @Description: 根据角色id查询名称 + * @Author: yangxuenan + * @Date: 2020/12/17 11:28 + * @Param: [roleIds] + * @Return: java.lang.String + */ + public String getRoleNamesByIds(String roleIds){ + String names = ""; + if (StringUtils.isNotBlank(roleIds)) { + String[] idArr = roleIds.split(","); + names = roleEODao.getNamesByIds(idArr); + if (StringUtils.isBlank(names) || "null".equals(names)) { + names = ""; + } +// for (String id : idArr) { +// RoleEO roleEO = roleEODao.selectByPrimaryKey(id); +// if (roleEO != null) { +// names += roleEO.getName() + ","; +// } +// } + } +// if (StringUtils.isNotBlank(names)) { +// names = names.substring(0,names.length()-1); +// } + return names; + } + + /*** + * @Description: 根据名称查属性id + * @Author: yangxuenan + * @Date: 2020/11/24 9:40 + * @Param: [str] + * @Return: com.adc.da.sys.entity.DicTypeEO + */ + public DicTypeEO getDicType(String str, String dicId){ + DicTypeEOPage dicTypeEO = new DicTypeEOPage(); + dicTypeEO.setDicTypeName(str); + dicTypeEO.setDicId(dicId); + List resultList = dicTypeEODao.queryByList(dicTypeEO); + if(resultList!= null && !resultList.isEmpty()){ + return resultList.get(0); + }else{ + return null; + } + } + + /*** + * @Description: 仅根据名称查询属性数据 + * @Author: yangxuenan + * @Date: 2020/12/7 9:40 + * @Param: [str] + * @Return: com.adc.da.sys.entity.DicTypeEO + */ + public DicTypeEO getDicTypeByName(String str) throws Exception { + DicTypeEOPage dicTypeEO = new DicTypeEOPage(); + dicTypeEO.setDicTypeName(str); + List resultList = dicTypeEODao.queryByList(dicTypeEO); + if(resultList!= null && !resultList.isEmpty()){ + return resultList.get(0); + }else{ + return null; + } + } + + public Map changeSelectInfo (Map attrInfoMap,String type,String baseSearchContent) { + if (attrInfoMap != null && !attrInfoMap.isEmpty()) { + Map nameMap = new HashMap<>(); + for (Map.Entry entry : attrInfoMap.entrySet()) { + baseSearchContent += String.valueOf(entry.getValue()) + ","; + String field = entry.getKey(); + String value = String.valueOf(entry.getValue()); + List fieldList = new ArrayList<>(); + List multiTimeList = new ArrayList<>(); + if ("stand".equals(type)) { + fieldList = InitStandAttrUtil.selectionFieldList; + multiTimeList = InitStandAttrUtil.multiTimeFieldList; + } else if ("laws".equals(type)) { + fieldList = InitStandAttrUtil.selectionFieldListLaws; + multiTimeList = InitStandAttrUtil.multiTimeFieldListLaws; + } else { + fieldList = InitStandAttrUtil.selectionFieldListBuss; + multiTimeList = InitStandAttrUtil.multiTimeFieldListBuss; + } + if (multiTimeList != null && multiTimeList.contains(field)) { + nameMap.put(field, " " + value); + } + if (fieldList.contains(field)) { + String selVal = ""; + String valueName = ""; + if ("stand".equals(type)) { + selVal = InitStandAttrUtil.selectFieldMap.get(field); + } else if ("laws".equals(type)) { + selVal = InitStandAttrUtil.selectFieldMapLaws.get(field); + } else { + selVal = InitStandAttrUtil.selectFieldMapBuss.get(field); + } + if (StringUtils.isNotBlank(value)) { + if (SelectionTypeEnum.ORGLIST.getValue().equals(selVal)) { + valueName = getOrgNamesByIds(value); + } else if (SelectionTypeEnum.USERLIST.getValue().equals(selVal)) { + valueName = getUserNamesByIds(value); + } else if (SelectionTypeEnum.ROLELIST.getValue().equals(selVal)) { + valueName = getRoleNamesByIds(value); + } else { + List valArr = Arrays.asList(value.split(",")); + valueName = dicTypeEODao.getDicNamesByCodes(valArr); + } + } + nameMap.put(field+"Show", valueName); + baseSearchContent += valueName + ","; + } + } + attrInfoMap.putAll(nameMap); + } + return attrInfoMap; + } + + /*** + * @Description: 根据用户名称查询id + * @Author: yangxuenan + * @Date: 2020/12/29 19:01 + * @Param: [names] + * @Return: java.lang.String + */ + public String getUserIdByName (String names,String orgIds) { + String ids = ""; + if (StringUtils.isNotBlank(names)) { + String[] nameArr = names.split(","); + if (StringUtils.isNotBlank(orgIds)) { + String[] orgIdArr = orgIds.split(","); + ids = userEODao.getIdsByNames(nameArr,orgIdArr); + } else { + ids = userEODao.getIdsByNames(nameArr,null); + } +// for (String name : nameArr) { +// if (StringUtils.isNotBlank(name)) { +// UserEOPage page = new UserEOPage(); +// page.setValidFlag("0"); +// page.setUname(name); +// List userList = userEODao.queryUserEoList(page); +// if (userList != null && !userList.isEmpty()) { +// ids += userList.get(0).getUsid() + ","; +// } +// } +// } + } +// if (StringUtils.isNotBlank(ids)) { +// ids = ids.substring(0,ids.length()-1); +// } + return ids; + } + + /*** + * @Description: 根据机构名称查询id + * @Author: yangxuenan + * @Date: 2020/12/29 19:04 + * @Param: [names] + * @Return: java.lang.String + */ + public String getOrgIdByName (String names,String orgType) { + String ids = ""; + if (StringUtils.isNotBlank(names)) { + String[] nameArr = names.split(","); + ids = orgEODao.getIdsByNames(nameArr,orgType); + } + return ids; + } + + /*** + * @Description: 根据角色名称查id + * @Author: yangxuenan + * @Date: 2020/12/29 19:07 + * @Param: [names] + * @Return: java.lang.String + */ + public String getRoleIdByName (String names) { + String ids = ""; + if (StringUtils.isNotBlank(names)) { + String[] nameArr = names.split(","); + ids = roleEODao.getIdsByNames(nameArr); +// for (String name : nameArr) { +// if (StringUtils.isNotBlank(name)) { +// List list = roleEODao.selectByNameAndId(null,name); +// if (list != null && !list.isEmpty()) { +// ids += list.get(0).getId() + ","; +// } +// } +// } + } +// if (StringUtils.isNotBlank(ids)) { +// ids = ids.substring(0,ids.length()-1); +// } + return ids; + } + + /*** + * @Description: 根据id查询工作组信息 + * @Author: yangxuenan + * @Date: 2020/12/30 15:03 + * @Param: [ids] + * @Return: java.lang.String + */ + public String getGroupNamesByIds(String ids){ + String names = ""; + if (StringUtils.isNotBlank(ids)) { + String[] idArr = ids.split(","); + names = sarGroupMenuEODao.getNamesByIds(idArr); + if (StringUtils.isBlank(names) || "null".equals(names)) { + names = ""; + } + } + return names; + } + + public String getGroupIdByNames(String names){ + String ids = ""; + if (StringUtils.isNotBlank(names)) { + String[] nameArr = names.split(","); + ids = sarGroupMenuEODao.getIdsByNames(nameArr); + } + return ids; + } + + /*** + * @Description: 根据id查询svpps名称 + * @Author: yangxuenan + * @Date: 2020/12/31 17:25 + * @Param: [ids] + * @Return: java.lang.String + */ + public String getSvppsNamesByIds(String ids){ + String names = ""; + if (StringUtils.isNotBlank(ids)) { + String[] idArr = ids.split(","); + List getList = otSvppsEODao.getNamesByIds(idArr).parallelStream() .filter(Objects::nonNull) .collect(Collectors.toList()); + if (getList != null && !getList.isEmpty()) { + if (getList.size() == 1) { + names = getList.get(0); + } else { + names = getList.get(0) + "," + getList.get(1); + } + } + } + return names; + } + + public String getSvppsNamesTipByIds(String ids){ + String names = ""; + if (StringUtils.isNotBlank(ids)) { + String[] idArr = ids.split(","); + List getList = otSvppsEODao.getNamesTipByIds(idArr); + if (getList != null && !getList.isEmpty()) { + if (getList.size() == 1) { + names = getList.get(0); + } else { + names = getList.get(0) + "," + getList.get(1); + } + } + } + if (StringUtils.isBlank(names) || "null".equals(names)) { + names = ""; + } + return names; + } + + /*** + * @Description: 根据名称查询id + * @Author: yangxuenan + * @Date: 2021/1/7 17:12 + * @Param: [names] + * @Return: java.lang.String + */ + public String getSvppsIdByName (String names) { + String ids = ""; + if (StringUtils.isNotBlank(names)) { + String[] nameArr = names.split(","); + List getList = otSvppsEODao.getIdsByNames(nameArr); + if (getList != null && !getList.isEmpty()) { + if (getList.size() == 1) { + ids = getList.get(0); + } else { + ids = getList.get(0) + "," + getList.get(1); + } + } + } + return ids; + } + + /*** + * @Description: 根据文件id返回文件名称 + * @Author: yangxuenan + * @Date: 2021/1/15 14:02 + * @Param: [ids] + * @Return: java.lang.String + */ + public String getFileNamesByIds (String ids) { + String names = ""; + if (StringUtils.isNotBlank(ids)) { + List infos = attFileEOService.getMultiFileInfos(ids); + if (infos != null && !infos.isEmpty()) { + for (AttFileEO attFileEO : infos) { + names += attFileEO.getOldFileName() + ","; + } + } + } + if (StringUtils.isNotBlank(names)) { + names = names.substring(0,names.length()-1); + } + return names; + } + + public String changeCompStatus (String prcStatus) { + if (StringUtils.isBlank(prcStatus)) { + return ""; + } + switch (prcStatus) { + case "1": return SarConformStateEnum.FIT.getValue().toString(); + case "2": return SarConformStateEnum.UNFIT.getValue().toString(); + case "3": return SarConformStateEnum.CHECK.getValue().toString(); + case "4": return SarConformStateEnum.NOT_INVOLVE.getValue().toString(); + default: return ""; + } + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/tree/ITree.java b/adc-da-slrs/src/main/java/com/adc/da/utils/tree/ITree.java new file mode 100644 index 00000000..9938d387 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/tree/ITree.java @@ -0,0 +1,32 @@ +package com.adc.da.utils.tree; + +import java.util.List; + +/** + * 操作树的接口类 + * + */ +public interface ITree { + /** + * 获取构建数的list,因为根节点可能不止一个,所有返回List + * 获取的结构与getRoot基本一致,但是后边增加了另外的数据,不建议调用 + * + * @return + */ + List getTree(); + + /** + * 获取根节点树结构,因为根节点可能不止一个,所有返回List + * + * @return + */ + List getRoot(); + + /** + * 获取指定节点数据 + * + * @param nodeId + * @return + */ + TreeNode getTreeNode(String nodeId); +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/tree/ITreeNode.java b/adc-da-slrs/src/main/java/com/adc/da/utils/tree/ITreeNode.java new file mode 100644 index 00000000..a58c48de --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/tree/ITreeNode.java @@ -0,0 +1,43 @@ +package com.adc.da.utils.tree; + +/** + * 需要实现树的实体类需要实现的接口,获取关键数据 + * + */ +public interface ITreeNode { + /** + * TreeNode获取nodeId + * + * @return + */ + String getNodeId(); + + /** + * TreeNode获取nodeName + * + * @return + */ + String getNodeName(); + + /** + * TreeNode获取nodeParentId(父id) + * + * @return + */ + String getNodeParentId(); + + /** + * TreeNode获取orderNum(排序字段用于排序) + * + * @return + */ + Integer getOrderNum(); + + /** + * TreeNode获取nodeLevel(当前属于第几层级) + * + * @return + */ + Integer getNodeLevel(); + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/tree/Tree.java b/adc-da-slrs/src/main/java/com/adc/da/utils/tree/Tree.java new file mode 100644 index 00000000..23332c20 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/tree/Tree.java @@ -0,0 +1,132 @@ +package com.adc.da.utils.tree; + +import org.apache.commons.lang3.StringUtils; + +import java.util.*; + +/** + * 构建树形建构 + */ +public class Tree implements ITree { + /** + * 用于存放treeNode的Map + */ + private LinkedHashMap treeNodesMap = new LinkedHashMap<>(); + /** + * 用于存放treeNode的list + */ + private List treeNodesList = new ArrayList<>(); + + /** + * 构造方法 + * + * @param list + */ + public Tree(List list) { + initTreeNodeMap(list); + initTreeNodeList(); + } + + /** + * 将List对象数据转为TreeNodeMap + * + * @param list + */ + private void initTreeNodeMap(List list) { + TreeNode treeNode; + for (ITreeNode item : list) { + treeNode = new TreeNode(item); + treeNode.setLastNodeNum(1); + treeNodesMap.put(treeNode.getNodeId(), treeNode); + } + Iterator iterator = treeNodesMap.values().iterator(); + TreeNode parentTreeNode; + while (iterator.hasNext()) { + treeNode = iterator.next(); + if (StringUtils.isEmpty(treeNode.getParentNodeId())) { + continue; + } + parentTreeNode = treeNodesMap.get(treeNode.getParentNodeId()); + if (parentTreeNode != null) { + treeNode.setParent(parentTreeNode); + parentTreeNode.addChild(treeNode); + // 按照orderNum排序 + Collections.sort(parentTreeNode.getChildren(), new OrdNamComparator()); + // 判断这个节点是否是最子节点 + if (treeNode.getChildren().size() == 0) { + treeNode.setLastNode(true); + } + // 计算每一个节点的最子节点的数量 + List children = parentTreeNode.getChildren(); + if (children.size() > 0) { + int sum = 0; + for (TreeNode treeNode2 : children) { + sum += treeNode2.getLastNodeNum(); + } + parentTreeNode.setLastNodeNum(sum); + } + } + } + } + + /** + * 根据treeNodesMap转为treeNodesList + */ + private void initTreeNodeList() { + if (treeNodesList.size() > 0) { + return; + } + if (treeNodesMap.size() == 0) { + return; + } + Iterator iterator = treeNodesMap.values().iterator(); + TreeNode treeNode; + while (iterator.hasNext()) { + treeNode = iterator.next(); + if (treeNode.getParent() == null) { + this.treeNodesList.add(treeNode); + this.treeNodesList.addAll(treeNode.getAllChildren()); + } + } + } + + @Override + public List getTree() { + return this.treeNodesList; + } + + @Override + public List getRoot() { + List rootList = new ArrayList<>(); + if (this.treeNodesList.size() > 0) { + for (TreeNode node : treeNodesList) { + if (node.getParent() == null) { + rootList.add(node); + Collections.sort(rootList, new OrdNamComparator()); + } + } + } + return rootList; + } + + @Override + public TreeNode getTreeNode(String nodeId) { + return this.treeNodesMap.get(nodeId); + } +} + +/** + * 自定义排序,按照orderNum排序 + */ +class OrdNamComparator implements Comparator { + @Override + public int compare(TreeNode t1, TreeNode t2) { + if (t1.getOrderNum() > t2.getOrderNum()) { + return 1; + } + if (t1.getOrderNum() < t2.getOrderNum()) { + return -1; + } + return t1.getNodeName().compareTo(t2.getNodeName()); + } +} \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/tree/TreeNode.java b/adc-da-slrs/src/main/java/com/adc/da/utils/tree/TreeNode.java new file mode 100644 index 00000000..6276f0ba --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/tree/TreeNode.java @@ -0,0 +1,187 @@ +package com.adc.da.utils.tree; + +import com.alibaba.fastjson.annotation.JSONField; + +import java.util.ArrayList; +import java.util.List; + +public class TreeNode { + + /** + * 树节点ID + */ + @JSONField(ordinal = 1) + private String nodeId; + /** + * 树节点名称 + */ + @JSONField(ordinal = 2) + private String nodeName; + /** + * 父节点ID + */ + @JSONField(ordinal = 3) + private String parentNodeId; + /** + * 节点在树中的排序号 + */ + @JSONField(ordinal = 4) + private int orderNum; + /** + * 节点所在的层级 + */ + @JSONField(ordinal = 5) + private int level; + /** + * 最子节点的数量 + */ + @JSONField(ordinal = 6) + private int lastNodeNum; + + /** + * 是否是最子节点 + */ + @JSONField(ordinal = 7) + private boolean lastNode; + + /** + * 当前节点的儿子节点 + */ + @JSONField(ordinal = 8) + private List children = new ArrayList<>(); + + /** + * 当前节点的完整路径 + */ + @JSONField(ordinal = 9) + private String completeName; + + /** + * 当前节点的父级节点 + * 转json的时候忽略此属性,因为此属性到前端无作用 + */ + @JSONField(serialize = false) + private TreeNode parent; + + /** + * 当前节点的子孙节点 + * 转json的时候忽略此属性,因为此属性到前端无作用 + */ + @JSONField(serialize = false) + private List allChildren = new ArrayList<>(); + + public TreeNode(ITreeNode obj) { + this.nodeId = obj.getNodeId(); + this.nodeName = obj.getNodeName(); + this.parentNodeId = obj.getNodeParentId(); + this.orderNum = obj.getOrderNum(); + this.level = obj.getNodeLevel(); + } + + public TreeNode(TreeNode obj) { + this.orderNum = obj.getOrderNum(); + this.level = obj.getLevel(); + this.lastNodeNum = obj.getLastNodeNum(); + } + + public TreeNode() { + } + + public void addChild(TreeNode treeNode) { + this.children.add(treeNode); + } + + public void removeChild(TreeNode treeNode) { + this.children.remove(treeNode); + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + public String getParentNodeId() { + return parentNodeId; + } + + public void setParentNodeId(String parentNodeId) { + this.parentNodeId = parentNodeId; + } + + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level = level; + } + + public TreeNode getParent() { + return parent; + } + + public void setParent(TreeNode parent) { + this.parent = parent; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public int getOrderNum() { + return orderNum; + } + + public void setOrderNum(int orderNum) { + this.orderNum = orderNum; + } + + public int getLastNodeNum() { + return lastNodeNum; + } + + public void setLastNodeNum(int lastNodeNum) { + this.lastNodeNum = lastNodeNum; + } + + public boolean isLastNode() { + return lastNode; + } + + public void setLastNode(boolean lastNode) { + this.lastNode = lastNode; + } + + public List getAllChildren() { + if (this.allChildren.isEmpty()) { + for (TreeNode treeNode : this.children) { + this.allChildren.add(treeNode); + this.allChildren.addAll(treeNode.getAllChildren()); + } + } + return this.allChildren; + } + + public String getCompleteName() { + return completeName; + } + + public void setCompleteName(String completeName) { + this.completeName = completeName; + } +} \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/OrdNamComparator.java b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/OrdNamComparator.java new file mode 100644 index 00000000..84416535 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/OrdNamComparator.java @@ -0,0 +1,21 @@ +package com.adc.da.utils.treetool; + +import java.util.Comparator; + +/** + * List 排序 Comparator + * @author david + */ +public class OrdNamComparator implements Comparator { + + @Override + public int compare(TreeNode t1, TreeNode t2) { + if (t1.getOrderNum() > t2.getOrderNum()) { + return 1; + } + if (t1.getOrderNum() < t2.getOrderNum()) { + return -1; + } + return t1.getNodeName().compareTo(t2.getNodeName()); + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/Tree.java b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/Tree.java new file mode 100644 index 00000000..708f5a3b --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/Tree.java @@ -0,0 +1,179 @@ +package com.adc.da.utils.treetool; + +import com.adc.da.utils.treetool.annotation.*; +import org.apache.commons.lang3.StringUtils; + +import java.lang.reflect.Field; +import java.util.*; + +//import group.ipp.tree.util.annotation.TreeNodeLevel; +//import group.ipp.tree.util.annotation.TreeNodeName; +//import group.ipp.tree.util.annotation.TreeNodeOrder; +//import group.ipp.tree.util.annotation.TreeNodeParentId; + +/** + * 构建树形建构 + * + * @author David + */ +public class Tree { + /** + * 用于存放treeNode的Map + */ + private LinkedHashMap treeNodesMap = new LinkedHashMap<>(); + /** + * 用于存放treeNode的list + */ + private List treeNodesList = new ArrayList<>(); + + /** + * 构造方法 + * + * @param list + */ + public Tree(List list) { + initTreeNodeMap(list); + initTreeNodeList(); + } + + /** + * 将List对象数据转为TreeNodeMap + * + * @param list + */ + private void initTreeNodeMap(List list) { + TreeNode treeNode; + for (Object item : list) { + treeNode = new TreeNode(); + treeNode.setNodeId(getFieldValue(item, "TreeNodeId")); + treeNode.setNodeName(getFieldValue(item, "TreeNodeName")); + treeNode.setParentNodeId(getFieldValue(item, "TreeNodeParentId")); + if(StringUtils.isEmpty(getFieldValue(item, "TreeNodeLevel"))) { + treeNode.setLevel(0); + } else { + treeNode.setLevel(Integer.parseInt(getFieldValue(item, "TreeNodeLevel"))); + } + if(StringUtils.isEmpty(getFieldValue(item, "TreeNodeOrder"))) { + treeNode.setOrderNum(0); + } else { + treeNode.setOrderNum(Integer.parseInt(getFieldValue(item, "TreeNodeOrder"))); + } + treeNode.setLastNodeNum(1); + treeNode.setData(item); + treeNodesMap.put(treeNode.getNodeId(), treeNode); + } + Iterator iterator = treeNodesMap.values().iterator(); + TreeNode parentTreeNode; + while (iterator.hasNext()) { + treeNode = iterator.next(); + if (StringUtils.isEmpty(treeNode.getParentNodeId())) { + continue; + } + parentTreeNode = treeNodesMap.get(treeNode.getParentNodeId()); + if (parentTreeNode != null) { + treeNode.setParent(parentTreeNode); + parentTreeNode.addChild(treeNode); + // 按照orderNum排序 + Collections.sort(parentTreeNode.getChildren(), new OrdNamComparator()); + // 判断这个节点是否是最子节点 + if (treeNode.getChildren().size() == 0) { + treeNode.setLastNode(true); + } + // 计算每一个节点的最子节点的数量 + List children = parentTreeNode.getChildren(); + if (children.size() > 0) { + int sum = 0; + for (TreeNode treeNode2 : children) { + sum += treeNode2.getLastNodeNum(); + } + parentTreeNode.setLastNodeNum(sum); + } + } + } + } + + private String getFieldValue(Object obj, String type) { + Class clz = obj.getClass(); + Field[] fields = clz.getDeclaredFields(); + String value = null; + try { + for(Field field : fields){ + field.setAccessible(true); + switch (type){ + case "TreeNodeId": + if(field.isAnnotationPresent(TreeNodeId.class)) { + value = String.valueOf(field.get(obj)); + } + break; + case "TreeNodeParentId": + if(field.isAnnotationPresent(TreeNodeParentId.class)) { + value = String.valueOf(field.get(obj)); + } + break; + case "TreeNodeName": + if(field.isAnnotationPresent(TreeNodeName.class)) { + value = String.valueOf(field.get(obj)); + } + break; + case "TreeNodeOrder": + if(field.isAnnotationPresent(TreeNodeOrder.class)) { + value = String.valueOf(field.get(obj)); + } + break; + case "TreeNodeLevel": + if(field.isAnnotationPresent(TreeNodeLevel.class)) { + value = String.valueOf(field.get(obj)); + } + break; + default: + break; + } + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return value; + } + + /** + * 根据treeNodesMap转为treeNodesList + */ + private void initTreeNodeList() { + if (treeNodesList.size() > 0) { + return; + } + if (treeNodesMap.size() == 0) { + return; + } + Iterator iterator = treeNodesMap.values().iterator(); + TreeNode treeNode; + while (iterator.hasNext()) { + treeNode = iterator.next(); + if (treeNode.getParent() == null) { + this.treeNodesList.add(treeNode); + this.treeNodesList.addAll(treeNode.getAllChildren()); + } + } + } + + public List getTree() { + return this.treeNodesList; + } + + public List getRoot() { + List rootList = new ArrayList<>(); + if (this.treeNodesList.size() > 0) { + for (TreeNode node : treeNodesList) { + if (node.getParent() == null) { + rootList.add(node); + Collections.sort(rootList, new OrdNamComparator()); + } + } + } + return rootList; + } + + public TreeNode getTreeNode(String nodeId) { + return this.treeNodesMap.get(nodeId); + } +} \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/TreeNode.java b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/TreeNode.java new file mode 100644 index 00000000..dec442ad --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/TreeNode.java @@ -0,0 +1,202 @@ +package com.adc.da.utils.treetool; + +import com.alibaba.fastjson.annotation.JSONField; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author David + */ +public class TreeNode { + + /** + * 树节点ID + */ + @JSONField(ordinal = 1) + private String nodeId; + /** + * 树节点名称 + */ + @JSONField(ordinal = 2) + private String nodeName; + /** + * 父节点ID + */ + @JSONField(ordinal = 3) + private String parentNodeId; + /** + * 节点在树中的排序号 + */ + @JSONField(ordinal = 4) + private int orderNum; + /** + * 节点所在的层级 + */ + @JSONField(ordinal = 5) + private int level; + /** + * 最子节点的数量 + */ + @JSONField(ordinal = 6) + private int lastNodeNum; + + /** + * 是否是最子节点 + */ + @JSONField(ordinal = 7) + private boolean lastNode; + + private Object data; + + /** + * 当前节点的儿子节点 + */ + @JSONField(ordinal = 8) + private List children = new ArrayList<>(); + + /** + * 当前节点的完整路径 + */ + @JSONField(ordinal = 9) + private String completeName; + + /** + * 当前节点的父级节点 + * 转json的时候忽略此属性,因为此属性到前端无作用 + */ + @JSONField(serialize = false) + private TreeNode parent; + + /** + * 当前节点的子孙节点 + * 转json的时候忽略此属性,因为此属性到前端无作用 + */ + @JSONField(serialize = false) + private List allChildren = new ArrayList<>(); + + private int standFlag; + + public TreeNode(TreeNode obj) { + this.orderNum = obj.getOrderNum(); + this.level = obj.getLevel(); + this.lastNodeNum = obj.getLastNodeNum(); + } + + public TreeNode() { + } + + public void addChild(TreeNode treeNode) { + this.children.add(treeNode); + } + + public void removeChild(TreeNode treeNode) { + this.children.remove(treeNode); + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + public String getParentNodeId() { + return parentNodeId; + } + + public void setParentNodeId(String parentNodeId) { + this.parentNodeId = parentNodeId; + } + + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level = level; + } + + public TreeNode getParent() { + return parent; + } + + public void setParent(TreeNode parent) { + this.parent = parent; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public int getOrderNum() { + return orderNum; + } + + public void setOrderNum(int orderNum) { + this.orderNum = orderNum; + } + + public int getLastNodeNum() { + return lastNodeNum; + } + + public void setLastNodeNum(int lastNodeNum) { + this.lastNodeNum = lastNodeNum; + } + + public boolean isLastNode() { + return lastNode; + } + + public void setLastNode(boolean lastNode) { + this.lastNode = lastNode; + } + + public List getAllChildren() { + if (this.allChildren.isEmpty()) { + for (TreeNode treeNode : this.children) { + this.allChildren.add(treeNode); + this.allChildren.addAll(treeNode.getAllChildren()); + } + } + return this.allChildren; + } + + public String getCompleteName() { + return completeName; + } + + public void setCompleteName(String completeName) { + this.completeName = completeName; + } + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + + public int getStandFlag() { + return standFlag; + } + + public void setStandFlag(int standFlag) { + this.standFlag = standFlag; + } +} \ No newline at end of file diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeId.java b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeId.java new file mode 100644 index 00000000..3395f5b3 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeId.java @@ -0,0 +1,12 @@ +package com.adc.da.utils.treetool.annotation; + +import java.lang.annotation.*; + +/** + * @author david + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +@Documented +public @interface TreeNodeId { +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeLevel.java b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeLevel.java new file mode 100644 index 00000000..38cfcb84 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeLevel.java @@ -0,0 +1,12 @@ +package com.adc.da.utils.treetool.annotation; + +import java.lang.annotation.*; + +/** + * @author david + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +@Documented +public @interface TreeNodeLevel { +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeName.java b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeName.java new file mode 100644 index 00000000..b184b9e6 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeName.java @@ -0,0 +1,12 @@ +package com.adc.da.utils.treetool.annotation; + +import java.lang.annotation.*; + +/** + * @author david + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +@Documented +public @interface TreeNodeName { +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeOrder.java b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeOrder.java new file mode 100644 index 00000000..0f4299cf --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeOrder.java @@ -0,0 +1,12 @@ +package com.adc.da.utils.treetool.annotation; + +import java.lang.annotation.*; + +/** + * @author david + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +@Documented +public @interface TreeNodeOrder { +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeParentId.java b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeParentId.java new file mode 100644 index 00000000..e4864369 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/treetool/annotation/TreeNodeParentId.java @@ -0,0 +1,12 @@ +package com.adc.da.utils.treetool.annotation; + +import java.lang.annotation.*; + +/** + * @author david + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +@Documented +public @interface TreeNodeParentId { +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/AESUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/AESUtil.java new file mode 100644 index 00000000..181cd902 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/AESUtil.java @@ -0,0 +1,109 @@ +package com.adc.da.utils.util; + +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class AESUtil { + private static final String KEY_ALGORITHM = "AES"; + private static final String DEFAULT_CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";//默认的加密算法 + + /** + * AES 加密操作 + * + * @param content 待加密内容 + * @param password 加密密码 + * @return 返回Base64转码后的加密数据 + */ + public static String encrypt(String content, String password) { + try { + Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);// 创建密码器 + + byte[] byteContent = content.getBytes("utf-8"); + + cipher.init(Cipher.ENCRYPT_MODE, getSecretKey(password));// 初始化为加密模式的密码器 + + byte[] result = cipher.doFinal(byteContent);// 加密 + + return Base64.encodeBase64String(result);//通过Base64转码返回 + } catch (Exception ex) { + Logger.getLogger(AESUtil.class.getName()).log(Level.SEVERE, null, ex); + } + + return null; + } + + /** + * AES 解密操作 + * + * @param content + * @param password + * @return + */ + public static String decrypt(String content, String password) { + + try { + //实例化 + Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM); + + //使用密钥初始化,设置为解密模式 + cipher.init(Cipher.DECRYPT_MODE, getSecretKey(password)); + + //执行操作 + byte[] result = cipher.doFinal(Base64.decodeBase64(content)); + + return new String(result, "utf-8"); + } catch (Exception ex) { + Logger.getLogger(AESUtil.class.getName()).log(Level.SEVERE, null, ex); + } + + return null; + } + + /** + * 生成加密秘钥 + * + * @return + */ + private static SecretKeySpec getSecretKey(final String password) { + //返回生成指定算法密钥生成器的 KeyGenerator 对象 + KeyGenerator kg = null; + + try { + kg = KeyGenerator.getInstance(KEY_ALGORITHM); + + //AES 要求密钥长度为 128 + kg.init(128, new SecureRandom(password.getBytes())); + + //生成一个密钥 + SecretKey secretKey = kg.generateKey(); + + return new SecretKeySpec(secretKey.getEncoded(), KEY_ALGORITHM);// 转换为AES专用密钥 + } catch (NoSuchAlgorithmException ex) { + Logger.getLogger(AESUtil.class.getName()).log(Level.SEVERE, null, ex); + } + + return null; + } + + public static void main(String[] args) { + String s = "hello,您好"; + + System.out.println("s:" + s); + + String s1 = AESUtil.encrypt(s, "1234"); + System.out.println("s1:" + s1); + + System.out.println("s2:"+AESUtil.decrypt(s1, "1234")); + + + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/CompLDUtils.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/CompLDUtils.java new file mode 100644 index 00000000..defc314e --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/CompLDUtils.java @@ -0,0 +1,156 @@ +package com.adc.da.utils.util; + +public class CompLDUtils { + + private static int min(int one, int two, int three) { + int min = one; + if (two < min) { + min = two; + } + if (three < min) { + min = three; + } + return min; + } + + public static int ld(String str1, String str2) { + int d[][]; // 矩阵 + int n = str1.length(); + int m = str2.length(); + int i; // 遍历str1的 + int j; // 遍历str2的 + char ch1; // str1的 + char ch2; // str2的 + int temp; // 记录相同字符,在某个矩阵位置值的增量,不是0就是1 + if (n == 0) { + return m; + } + if (m == 0) { + return n; + } + d = new int[n + 1][m + 1]; + for (i = 0; i <= n; i++) { // 初始化第一列 + d[i][0] = i; + } + for (j = 0; j <= m; j++) { // 初始化第一行 + d[0][j] = j; + } + for (i = 1; i <= n; i++) { // 遍历str1 + ch1 = str1.charAt(i - 1); + // 去匹配str2 + for (j = 1; j <= m; j++) { + ch2 = str2.charAt(j - 1); + if (ch1 == ch2) { + temp = 0; + } else { + temp = 1; + } + // 左边+1,上边+1, 左上角+temp取最小 + d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1]+ temp); + } + } + return d[n][m]; + } + public static double sim(String str1, String str2) { + try { + double ld = (double)ld(str1, str2); + return (1-ld/(double)Math.max(str1.length(), str2.length())); + } catch (Exception e) { + return 0.1; + } + } + + public static void main(String[] args) { + String str1="6转向系\n" + + "6.1汽车(三轮汽车除外)的方向盘应设置于左侧,其他机动车的方向盘不得设置于右侧;专项作业车、教练车按需要可设置左右两个方向盘。有驾驶室的正三轮摩托车如使用方向盘转向,则方向盘中心立柱距车辆纵向中心平面的水平距离应小于等于200 mm;其他摩托车不得使用方向盘转向。\n" + + "6.2机动车的方向盘(或方向把)应转动灵活,操纵方便,无卡滞现象。机动车应设置转向限位装置。转向系统在任何操作位置上,不得与其他部件有干涉现象。\n" + + "6.3机动车(摩托车、三轮汽车、手扶拖拉机运输机组除外)正常行驶时,转向轮转向后应有一定的回正能力(允许有残余角),以使机动车具有稳定的直线行驶能力。\n" + + "6.4机动车方向盘的最大自由转动量应小于或等于:\n" + + "a) 最大设计车速大于或等于100 km/h 的机动车:15°\n" + + "b) 三轮汽车:35°;\n" + + "c) 其他机动车:25° 。\n" + + "6.5汽车(三轮汽车除外)应具有适度的不足转向特性。\n" + + "6.6三轮汽车、摩托车的转向轮向左或向右转角应小于等于:\n" + + "a)\t三轮汽车、三轮摩托车、正三轮轻便摩托车:45°;\n" + + "6)\t\t两轮普通摩托车、两轮轻便摩托车:48°。\n" + + "6.6机动车在平坦、硬实、干燥和清洁的道路上行驶不应跑偏,其方向盘(或方向把)不应有摆振、路感不灵或其他异常现象。\n" + + "6.8机动车在平坦、硬实、干燥和清洁的水泥或沥青道路上行驶,以10 km/h的速度在5 s之内沿螺旋线从直线行驶过渡到外圆直径为25 m的车辆通道圆行驶,施加于方向盘外缘的最大切向力应小于等于245 N。\n" + + "6.9专用校车应采用转向助力装置;其他机动车转向轴最大设计轴荷大于4 000 kg时,也应采用转向助力装置。装有转向助力装置的机动车,转向时其转向助力功能不得出现时有时无的现象,且转向助力装置失效时仍应具有用方向盘控制机动车的能力。装有电动转向助力装置的汽车,在产品使用说明书规定的正常使用状态下,应保证转向助力装置的电能供应。\n" + + "6.10汽车和汽车列车(不计具有作业功能的专用装置的突出部分)、轮式拖拉机运输机组应能在同一个车辆通道圆内通过,车辆通道圆的外圆直径认为25.00 m,车辆通道圆的内圆直径D2为10.60 m。 汽车和汽车列车、轮式拖拉机运输机组由直线行驶过渡到上述圆周运动时,任何部分超出直线行驶时的 车辆外侧面垂直面的值(外摆值)应小于等于0.80 m(对铰接客车和铰接式无轨电车外摆值应小于等于 1.20 m),其试验方法见GB 1589。\n" + + "6.11汽车(三轮汽车除外)的车轮定位应与该车型的技术要求一致。对前轴采用非独立悬架的汽车(前轴采用双转向轴时除外),其转向轮的横向侧滑量,用侧滑台检验时侧滑量值应在±5 m/km之间。\n" + + "6.12转向节及臂,转向横、直拉杆及球销不得有裂纹和损伤,并且转向球销不应松旷。对机动车进行改装或修理时横、直拉杆不得拼焊。\n" + + "6.13三轮汽车、摩托车的前减振器、上下联板和方向把不应有变形和裂损。\n"; + String str2="6转向系\n" + + "6.1汽车(三轮汽车除外)的方向盘应设置于左侧,其他机动车的方向盘不应设置于右侧;专项作业车、教练车按需要可设置左右两个方向盘。装有两个后轮、有驾驶室的正三轮摩托车如使用方向盘转向,则方向盘中心立柱距车辆纵向中心平面的水平距离应小于或等于200 mm ;其他摩托车不应使用方向盘转向。\n" + + "6.2机动车的方向盘(或方向把)应转动灵活,无卡滞现象。机动车应设置转向限位装置。转向系统在任何操作位置上,不应与其他部件有干涉现象。\n" + + "6.3机动车(摩托车、三轮汽车、手扶拖拉机运输机组除外〉正常行驶时,转向轮转向后应有一定的回正能力(允许有残余角),以使机动车具有稳定的直线行驶能力0\n" + + "6.4机动车方向盘的最大自由转动量应小于或等于:\n" + + "a) 最大设计车速大于或等于100 km/h 的机动车:15°\n" + + "b) 三轮汽车:35°;\n" + + "c) 其他机动车:25° 。\n" + + "6.5汽车(三轮汽车除外)应具有适度的不足转向特性。\n" + + "6.6三轮汽车、摩托车的转向轮向左或向右转角应小于或等于:\n" + + "a) 三轮汽车、三轮摩托车、正三轮轻便摩托车:45°;\n" + + "b)两轮普通摩托车、两轮轻便摩托车:48°0\n" + + "6.7机动车在平坦、硬实、干燥和清洁的道路上行驶不应跑偏,其方向盘(或方向把)不应有摆振等异常现象。\n" + + "6.8机动车在平坦、硬实、干燥和清洁的水泥或沥青道路上行驶,以10 km/h 的速度在5 s 之内沿螺旋线从直线行驶过渡到外圆直径为25m 的车辆通道圆行驶,施加于方向盘外缘的最大切向力应小于或等于245 N。\n" + + "6.9汽车(三轮汽车除外)的车轮定位应与该车型的技术要求一致。对前轴采用非独立悬架的汽车(前轴采用双转向轴时除外),其转向轮的横向侧滑量,用侧滑台检验时侧滑量值应小于或等于5 m/km。\n" + + "6.10 专用校车应采用转向助力装置;其他机动车转向轴最大设计轴荷大于4 000 kg 时,也应采用转向助力装置。装有转向助力装置的机动车,转向时其转向助力功能不应出现时有时无的现象,且转向助力装置失效时仍应具有用方向盘控制机动车的能力。\n" + + "6.11转向节及臂,转向横、直拉杆及球销应连接可靠,且不应有裂纹和损伤,并且转向球销不应松旷。对机动车进行改装或修理时横、直拉杆不应拼焊。\n" + + "6.12三轮汽车、摩托车的前减振器、上下联板和方向把不应有变形和裂损。"; + String str3="\n" + + "5车辆识别代号的标示位置\n" + + "5.1每辆车辆都应具有唯一的车辆识别代号,并永久保持地标示在车辆上,同一车辆上标示的所有的 车辆识别代号的字码构成与排列顺序应相同。除第9章规定的情况外,不得对已标示的车辆识别代号 进行变更。\n" + + "5.2车辆应在产品标牌上标示车辆识别代号(L1、L3类车辆可除外),产品标牌的型式、标示位置、标示要求应符合GB/T 18411的规定。\n" + + "5.3车辆应至少有一个车辆识别代号直接打刻在车架(无车架的车辆为车身主要承载且不能拆卸的部件)能防止锈烛、磨损的部位上。其中:\n" + + "a)\tM1类车辆的车辆识别代号应打刻在发动机舱内能防止替换的车辆结构件上,或打刻在车门 立柱上,如受结构限制没有打刻空间时也可打刻在右侧除行李舱外的车辆其他结构件上;\n" + + "b)\t最大设计总质量大于或等于12000 kg的货车及所有牵引杆挂车,车辆识别代号应打刻在右前轮纵向中心线前端纵梁外侧,如受结构限制也可打刻在右前轮纵向中心线附近纵梁外侧;\n" + + "c)\t半挂车和中置轴挂车的车辆识别代号应打刻在右前支腿前端纵梁外侧(无纵梁车辆除外);\n" + + "d)\t其他汽车和无纵梁挂车的车辆识别代号应打刻在车辆右侧前部的车辆结构件上,如受结构限 制也可打刻在右侧其他车辆结构件上。\n" + + "打刻车辆识别代号的部件不应采用打磨、挖补、垫片、凿改、重新涂漆(设计和制造上为保护打刻的 车辆识别代号而采取涂漆工艺的情形除外)等方式处理,从上(前)方观察时,打刻区域周边足够大面积 的表面不应有任何覆盖物,如有覆盖物,该覆盖物的表面应明确标示“车辆识别代号”或“VIN”字样,且覆盖物在不使用任何专用工具的情况下能直接取下(或揭开)及复原,以方便地观察到足够大的包括打刻区域的表面。\n" + + "注1:打刻区域周边足够大面积的表面(足够大的包括打刻区域的表面)是指打刻车辆识别代号的部件的全部表面,但所暴露表面能满足查看打刻车辆识别代号的部件有无挖补、重新焊接、粘贴等痕迹的需要时,也应视为满足要求。\n" + + "注2:对摩托车,打刻的车辆识别代号在不举升车辆的情形下可观察、拓印的,视为满足要求。\n" + + "打刻的车辆识别代号从上(前)方应易于观察、拓印,对于汽车和挂车还应能拍照。\n" + + "5.4具有电子控制单元的汽车,其至少有一个电子控制单元应不可篡改地存储车辆识别代号。\n" + + "5.5 M1、N1类车辆应在靠近风窗立柱的位置标示车辆识别代号,该车辆识别代号在白天不需移动任何部件从车外即能清晰识读。\n" + + "5.6除按照5.2、5.3、5.4、5.5规定标示车辆识别代号之外,类车辆还应在行李舱的易见部位标示车辆识别代号;且若车辆制造厂选取车辆识别代号作为车辆及部件识别标记的标识信息,还应按照GB 30509的规定,标示车辆识别代号。\n" + + "5.7除按照5.2、5.3、5.4规定标示车辆识别代号之外,最大设计总质量大于或等于12000 kg的栏板式、仓栅式、自卸式、罐式货车及最大设计总质量大于或等于10000 kg的栏板式、仓栅式、自卸式、罐式挂车还应在其货箱或常压罐体(或设计和制造上固定在货箱或常压罐体上且用于与车架连接的结构件)上打刻至少两个车辆识别代号。打刻的车辆识别代号应位于货箱(常压罐体)左、右两侧或前端面且易于拍照;且若打刻在货箱(常压罐体)左、右两侧时,打刻的车辆识别代号距货箱(常压罐体)前端面的距离应小于或等于1 000 mm,若打刻在左、右两侧连接结构件时应尽量靠近货箱(常压罐体)前端面。\n" + + "5.8车辆制造厂应至少在一种随车文件中标示车辆识别代号。"; + + String str4 = "\n" + + "5.3车辆的驱动\n" + + "5.3.1车辆不应靠自身动力驱动。\n" + + "5.3.2在碰撞瞬间,车辆应不冉承受任何附加转向或驱动装置的作用。\n" + + "5.3.3车辆到达壁障的路线在横向任一方向偏离理论轨迹均不应超过150 mm。\n" + + "5.4 试验速度\n" + + "在碰撞瞬间,车辆速度应为504 km/h。如果试验在更高的碰撞速度下进行并且车辆符合要求,也认为试验合格。\n" + + "5.5对前排座椅假人的测量\n" + + "5.5.1为确定性能指标必需的所有测量,均应采用符合附录D要求的测量系统。\n" + + "5.5.2不同的参数应通过具备下列CFC(通道的频率等级)的独立数据通道来记录。\n" + + "5.5.2.1对假人头部的测量\n" + + "重心处的加速度(a)由加速度的二维分量计算得出。加速度分量测量时,CFC为1000。\n" + + "5.5.2.2对假人颈部的测量\n" + + "5.5.2.2.1在头颈连接处测量的轴向张力和前后剪切力,CFC为1000。\n" + + "5.5.2.2.2在头颈连接处测量的对Y轴的弯矩,CFC为600。\n" + + "5.5.2.3对假人胸部的测量\n" + + "胸部变形测量时,CFC为180。\n" + + "5.5.2.4对假人大腿的测量\n" + + "轴向压缩力测量时,CFC为600。"; + + System.out.println("ld=" + ld(str1, str2)); + System.out.println("sim=" + sim(str1, str2)); + System.out.println("===================================================="); + System.out.println("ld=" + ld(str1, str3)); + System.out.println("sim=" + sim(str1, str3)); + + System.out.println("===================================================="); + System.out.println("ld=" + ld(str1, str4)); + System.out.println("sim=" + sim(str1, str4)); + + System.out.println("===================================================="); + System.out.println("ld=" + ld(str3, str4)); + System.out.println("sim=" + sim(str3, str4)); + } + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/CompareListUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/CompareListUtil.java new file mode 100644 index 00000000..e5b47a32 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/CompareListUtil.java @@ -0,0 +1,78 @@ +package com.adc.da.utils.util; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +/** + * @Description: + * @Author: super_liu + * date: 2020/12/9 10:00 + */ +public class CompareListUtil { + /** + * @param aList 本列表 + * @param bList 对照列表 + * @return 返回增加的元素组成的列表 + * @Description: 计算列表aList相对于bList的增加的情况,兼容任何类型元素的列表数据结构 + */ + public static List getAddaListThanbList(List aList, List bList) { + List addList = new ArrayList(); + for (int i = 0; i < aList.size(); i++) { + if (!myListContains(bList, aList.get(i))) { + addList.add(aList.get(i)); + } + } + return addList; + } + + /** + * @param aList 本列表 + * @param bList 对照列表 + * @return 返回减少的元素组成的列表 + * @Description: 计算列表aList相对于bList的减少的情况,兼容任何类型元素的列表数据结构 + */ + public static List getReduceaListThanbList(List aList, List bList) { + List reduceaList = new ArrayList(); + for (int i = 0; i < bList.size(); i++) { + if (!myListContains(aList, bList.get(i))) { + reduceaList.add(bList.get(i)); + } + } + return reduceaList; + } + + + /** + * @param sourceList 源列表 + * @param element 待判断的包含元素 + * @return 包含返回 true,不包含返回 false + * @Description: 判断元素element是否是sourceList列表中的一个子元素 + */ + private static boolean myListContains(List sourceList, E element) { + if (sourceList == null || element == null) { + return false; + } + if (sourceList.isEmpty()) { + return false; + } + for (E tip : sourceList) { + if (element.equals(tip)) { + return true; + } + } + return false; + } + + /** + * @param list + * @return list + * @Description: 去除list重复数据 + */ + public static List cleanDisRepet(List list) { + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + return list; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/ConcatStringUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/ConcatStringUtil.java new file mode 100644 index 00000000..25041407 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/ConcatStringUtil.java @@ -0,0 +1,28 @@ +package com.adc.da.utils.util; + +import org.apache.commons.lang.StringUtils; + +import java.util.Set; + +/** + * @Description: 各种类型数据,拼接成逗号分隔字符串 + * @Author: super_liu + * date: 2020/11/23 14:30 + */ +public class ConcatStringUtil { + + public static String concatSet (Set setVal) { + String resultStr = ""; + if (setVal != null && !setVal.isEmpty()) { + for (String val : setVal) { + if (StringUtils.isNotBlank(val) && !"null".equals(val)) { + resultStr += val + ","; + } + } + if (StringUtils.isNotBlank(resultStr)) { + resultStr = resultStr.substring(0,resultStr.length()-1); + } + } + return resultStr; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/DateUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/DateUtil.java new file mode 100644 index 00000000..7ef009f3 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/DateUtil.java @@ -0,0 +1,66 @@ +package com.adc.da.utils.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +/** + * @Description: 判断是否为日期格式 + * @Author: super_liu + * date: 2020/12/31 11:25 + */ +public class DateUtil { + + /*** + * @Description: 判断多个日期是否都符合日期格式 + * @Author: super_liu + * @Date: 2020/12/31 11:31 + * @Param: [str] + * @Return: boolean + */ + public static boolean isValidDate(String str) throws Exception{ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String[] strArr = str.split(","); + for (String dateStr : strArr) { + try { + simpleDateFormat.setLenient(false); + simpleDateFormat.parse(dateStr); + } catch (Exception e){ + return false; + } + } + return true; + } + + /** + * utc 时间格式转换正常格式 2018-08-07T03:41:59Z + * @param utcTime 时间 + * @return + */ + public static String formatStrUTCToDateStr(String utcTime) { + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.SIMPLIFIED_CHINESE); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + TimeZone utcZone = TimeZone.getTimeZone("UTC"); + sf.setTimeZone(utcZone); + Date date = null; + String dateTime = ""; + try { + date = sf.parse(utcTime); + dateTime = sdf.format(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return dateTime; + } + + + public static void main(String[] args) { + String utcTime = "2021-04-15T01:43:54.296Z"; + String time = formatStrUTCToDateStr("2021-04-15T01:43:54.296Z"); + System.out.println("utcTime 转换前:" + utcTime); + System.out.println("utcTime 转换后 time :" + time); + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/DiffUtils.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/DiffUtils.java new file mode 100644 index 00000000..21c81917 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/DiffUtils.java @@ -0,0 +1,2311 @@ +package com.adc.da.utils.util; + + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class DiffUtils { + // Defaults. + // Set these on your diff_match_patch instance to override the defaults. + + /** + * Number of seconds to map a diff before giving up (0 for infinity). + */ + public float Diff_Timeout = 1.0f; + /** + * Cost of an empty edit operation in terms of edit characters. + */ + public short Diff_EditCost = 4; + /** + * The size beyond which the double-ended diff activates. + * Double-ending is twice as fast, but less accurate. + */ + public short Diff_DualThreshold = 32; + /** + * At what point is no match declared (0.0 = perfection, 1.0 = very loose). + */ + public float Match_Threshold = 0.5f; + /** + * How far to search for a match (0 = exact location, 1000+ = broad match). + * A match this many characters away from the expected location will add + * 1.0 to the score (0.0 is a perfect match). + */ + public int Match_Distance = 1000; + /** + * When deleting a large block of text (over ~64 characters), how close does + * the contents have to match the expected contents. (0.0 = perfection, + * 1.0 = very loose). Note that Match_Threshold controls how closely the + * end points of a delete need to match. + */ + public float Patch_DeleteThreshold = 0.5f; + /** + * Chunk size for context length. + */ + public short Patch_Margin = 4; + /** + * The number of bits in an int. + */ + private int Match_MaxBits = 32; + + /** + * Internal class for returning results from diff_linesToChars(). + * Other less paranoid languages just use a three-element array. + */ + protected static class LinesToCharsResult { + protected String chars1; + protected String chars2; + protected List lineArray; + + protected LinesToCharsResult(String chars1, String chars2, + List lineArray) { + this.chars1 = chars1; + this.chars2 = chars2; + this.lineArray = lineArray; + } + } + // DIFF FUNCTIONS + /** + * The data structure representing a diff is a Linked list of Diff objects: + * {Diff(Operation.DELETE, "Hello"), Diff(Operation.INSERT, "Goodbye"), + * Diff(Operation.EQUAL, " world.")} + * which means: delete "Hello", add "Goodbye" and keep " world." + */ + public enum Operation { + DELETE, INSERT, EQUAL + } + /** + * Find the differences between two texts. + * Run a faster slightly less optimal diff + * This method allows the 'checklines' of diff_main() to be optional. + * Most of the time checklines is wanted, so default to true. + * @param text1 Old string to be diffed. + * @param text2 New string to be diffed. + * @return Linked List of Diff objects. + */ + public LinkedList diff_main(String text1, String text2) { + return diff_main(text1, text2, true); + } + /** + * Find the differences between two texts. Simplifies the problem by + * stripping any common prefix or suffix off the texts before diffing. + * @param text1 Old string to be diffed. + * @param text2 New string to be diffed. + * @param checklines Speedup flag. If false, then don't run a + * line-level diff first to identify the changed areas. + * If true, then run a faster slightly less optimal diff + * @return Linked List of Diff objects. + */ + public LinkedList diff_main(String text1, String text2, boolean checklines) { + // Check for equality (speedup) + LinkedList diffs; + if (text1.equals(text2)) { + diffs = new LinkedList(); + diffs.add(new Diff(Operation.EQUAL, text1)); + return diffs; + } + // Trim off common prefix (speedup) + int commonlength = diff_commonPrefix(text1, text2); + String commonprefix = text1.substring(0, commonlength); + text1 = text1.substring(commonlength); + text2 = text2.substring(commonlength); + // Trim off common suffix (speedup) + commonlength = diff_commonSuffix(text1, text2); + String commonsuffix = text1.substring(text1.length() - commonlength); + text1 = text1.substring(0, text1.length() - commonlength); + text2 = text2.substring(0, text2.length() - commonlength); + // Compute the diff on the middle block + diffs = diff_compute(text1, text2, checklines); + + // Restore the prefix and suffix + if (commonprefix.length() != 0) { + diffs.addFirst(new Diff(Operation.EQUAL, commonprefix)); + } + if (commonsuffix.length() != 0) { + diffs.addLast(new Diff(Operation.EQUAL, commonsuffix)); + } + diff_cleanupMerge(diffs); + return diffs; + } + /** + * Find the differences between two texts. Assumes that the texts do not + * have any common prefix or suffix. + * @param text1 Old string to be diffed. + * @param text2 New string to be diffed. + * @param checklines Speedup flag. If false, then don't run a + * line-level diff first to identify the changed areas. + * If true, then run a faster slightly less optimal diff + * @return Linked List of Diff objects. + */ + protected LinkedList diff_compute(String text1, String text2,boolean checklines) { + LinkedList diffs = new LinkedList(); + if (text1.length() == 0) { + // Just add some text (speedup) + diffs.add(new Diff(Operation.INSERT, text2)); + return diffs; + } + if (text2.length() == 0) { + // Just delete some text (speedup) + diffs.add(new Diff(Operation.DELETE, text1)); + return diffs; + } + String longtext = text1.length() > text2.length() ? text1 : text2; + String shorttext = text1.length() > text2.length() ? text2 : text1; + int i = longtext.indexOf(shorttext); + if (i != -1) { + // Shorter text is inside the longer text (speedup) + Operation op = (text1.length() > text2.length()) ? + Operation.DELETE : Operation.INSERT; + diffs.add(new Diff(op, longtext.substring(0, i))); + diffs.add(new Diff(Operation.EQUAL, shorttext)); + diffs.add(new Diff(op, longtext.substring(i + shorttext.length()))); + return diffs; + } + longtext = shorttext = null; // Garbage collect. + // Check to see if the problem can be split in two. + String[] hm = diff_halfMatch(text1, text2); + if (hm != null) { + // A half-match was found, sort out the return data. + String text1_a = hm[0]; + String text1_b = hm[1]; + String text2_a = hm[2]; + String text2_b = hm[3]; + String mid_common = hm[4]; + // Send both pairs off for separate processing. + LinkedList diffs_a = diff_main(text1_a, text2_a, checklines); + LinkedList diffs_b = diff_main(text1_b, text2_b, checklines); + // Merge the results. + diffs = diffs_a; + diffs.add(new Diff(Operation.EQUAL, mid_common)); + diffs.addAll(diffs_b); + return diffs; + } + // Perform a real diff. + if (checklines && (text1.length() < 100 || text2.length() < 100)) { + checklines = false; // Too trivial for the overhead. + } + List linearray = null; + if (checklines) { + // Scan the text on a line-by-line basis first. + LinesToCharsResult b = diff_linesToChars(text1, text2); + text1 = b.chars1; + text2 = b.chars2; + linearray = b.lineArray; + } + diffs = diff_map(text1, text2); + if (diffs == null) { + // No acceptable result. + diffs = new LinkedList(); + diffs.add(new Diff(Operation.DELETE, text1)); + diffs.add(new Diff(Operation.INSERT, text2)); + } + if (checklines) { + // Convert the diff back to original text. + diff_charsToLines(diffs, linearray); + // Eliminate freak matches (e.g. blank lines) + diff_cleanupSemantic(diffs); + // Rediff any replacement blocks, this time character-by-character. + // Add a dummy entry at the end. + diffs.add(new Diff(Operation.EQUAL, "")); + int count_delete = 0; + int count_insert = 0; + String text_delete = ""; + String text_insert = ""; + ListIterator pointer = diffs.listIterator(); + Diff thisDiff = pointer.next(); + while (thisDiff != null) { + switch (thisDiff.operation) { + case INSERT: + count_insert++; + text_insert += thisDiff.text; + break; + case DELETE: + count_delete++; + text_delete += thisDiff.text; + break; + case EQUAL: + // Upon reaching an equality, check for prior redundancies. + if (count_delete >= 1 && count_insert >= 1) { + // Delete the offending records and add the merged ones. + pointer.previous(); + for (int j = 0; j < count_delete + count_insert; j++) { + pointer.previous(); + pointer.remove(); + } + for (Diff newDiff : diff_main(text_delete, text_insert, false)) { + pointer.add(newDiff); + } + } + count_insert = 0; + count_delete = 0; + text_delete = ""; + text_insert = ""; + break; + } + thisDiff = pointer.hasNext() ? pointer.next() : null; + } + diffs.removeLast(); // Remove the dummy entry at the end. + } + return diffs; + } + /** + * Split two texts into a list of strings. Reduce the texts to a string of + * hashes where each Unicode character represents one line. + * @param text1 First string. + * @param text2 Second string. + * @return An object containing the encoded text1, the encoded text2 and + * the List of unique strings. The zeroth element of the List of + * unique strings is intentionally blank. + */ + protected LinesToCharsResult diff_linesToChars(String text1, String text2) { + List lineArray = new ArrayList(); + Map lineHash = new HashMap(); + // e.g. linearray[4] == "Hello\n" + // e.g. linehash.get("Hello\n") == 4 + // "\x00" is a valid character, but various debuggers don't like it. + // So we'll insert a junk entry to avoid generating a null character. + lineArray.add(""); + String chars1 = diff_linesToCharsMunge(text1, lineArray, lineHash); + String chars2 = diff_linesToCharsMunge(text2, lineArray, lineHash); + return new LinesToCharsResult(chars1, chars2, lineArray); + } + /** + * Split a text into a list of strings. Reduce the texts to a string of + * hashes where each Unicode character represents one line. + * @param text String to encode. + * @param lineArray List of unique strings. + * @param lineHash Map of strings to indices. + * @return Encoded string. + */ + private String diff_linesToCharsMunge(String text, List lineArray, + Map lineHash) { + int lineStart = 0; + int lineEnd = -1; + String line; + StringBuilder chars = new StringBuilder(); + // Walk the text, pulling out a substring for each line. + // text.split('\n') would would temporarily double our memory footprint. + // Modifying text would create many large strings to garbage collect. + while (lineEnd < text.length() - 1) { + lineEnd = text.indexOf('\n', lineStart); + if (lineEnd == -1) { + lineEnd = text.length() - 1; + } + line = text.substring(lineStart, lineEnd + 1); + lineStart = lineEnd + 1; + + if (lineHash.containsKey(line)) { + chars.append(String.valueOf((char) (int) lineHash.get(line))); + } else { + lineArray.add(line); + lineHash.put(line, lineArray.size() - 1); + chars.append(String.valueOf((char) (lineArray.size() - 1))); + } + } + return chars.toString(); + } + /** + * Rehydrate the text in a diff from a string of line hashes to real lines of + * text. + * @param diffs LinkedList of Diff objects. + * @param lineArray List of unique strings. + */ + protected void diff_charsToLines(LinkedList diffs, + List lineArray) { + StringBuilder text; + for (Diff diff : diffs) { + text = new StringBuilder(); + for (int y = 0; y < diff.text.length(); y++) { + text.append(lineArray.get(diff.text.charAt(y))); + } + diff.text = text.toString(); + } + } + /** + * Explore the intersection points between the two texts. + * @param text1 Old string to be diffed. + * @param text2 New string to be diffed. + * @return LinkedList of Diff objects or null if no diff available. + */ + protected LinkedList diff_map(String text1, String text2) { + long ms_end = System.currentTimeMillis() + (long) (Diff_Timeout * 1000); + // Cache the text lengths to prevent multiple calls. + int text1_length = text1.length(); + int text2_length = text2.length(); + int max_d = text1_length + text2_length - 1; + boolean doubleEnd = Diff_DualThreshold * 2 < max_d; + List> v_map1 = new ArrayList>(); + List> v_map2 = new ArrayList>(); + Map v1 = new HashMap(); + Map v2 = new HashMap(); + v1.put(1, 0); + v2.put(1, 0); + int x, y; + Long footstep = 0L; // Used to track overlapping paths. + Map footsteps = new HashMap(); + boolean done = false; + // If the total number of characters is odd, then the front path will + // collide with the reverse path. + boolean front = ((text1_length + text2_length) % 2 == 1); + for (int d = 0; d < max_d; d++) { + // Bail out if timeout reached. + if (Diff_Timeout > 0 && System.currentTimeMillis() > ms_end) { + return null; + } + + // Walk the front path one step. + v_map1.add(new HashSet()); // Adds at index 'd'. + for (int k = -d; k <= d; k += 2) { + if (k == -d || k != d && v1.get(k - 1) < v1.get(k + 1)) { + x = v1.get(k + 1); + } else { + x = v1.get(k - 1) + 1; + } + y = x - k; + if (doubleEnd) { + footstep = diff_footprint(x, y); + if (front && (footsteps.containsKey(footstep))) { + done = true; + } + if (!front) { + footsteps.put(footstep, d); + } + } + while (!done && x < text1_length && y < text2_length + && text1.charAt(x) == text2.charAt(y)) { + x++; + y++; + if (doubleEnd) { + footstep = diff_footprint(x, y); + if (front && (footsteps.containsKey(footstep))) { + done = true; + } + if (!front) { + footsteps.put(footstep, d); + } + } + } + v1.put(k, x); + v_map1.get(d).add(diff_footprint(x, y)); + if (x == text1_length && y == text2_length) { + // Reached the end in single-path mode. + return diff_path1(v_map1, text1, text2); + } else if (done) { + // Front path ran over reverse path. + v_map2 = v_map2.subList(0, footsteps.get(footstep) + 1); + LinkedList a = diff_path1(v_map1, text1.substring(0, x), + text2.substring(0, y)); + a.addAll(diff_path2(v_map2, text1.substring(x), text2.substring(y))); + return a; + } + } + if (doubleEnd) { + // Walk the reverse path one step. + v_map2.add(new HashSet()); // Adds at index 'd'. + for (int k = -d; k <= d; k += 2) { + if (k == -d || k != d && v2.get(k - 1) < v2.get(k + 1)) { + x = v2.get(k + 1); + } else { + x = v2.get(k - 1) + 1; + } + y = x - k; + footstep = diff_footprint(text1_length - x, text2_length - y); + if (!front && (footsteps.containsKey(footstep))) { + done = true; + } + if (front) { + footsteps.put(footstep, d); + } + while (!done && x < text1_length && y < text2_length + && text1.charAt(text1_length - x - 1) + == text2.charAt(text2_length - y - 1)) { + x++; + y++; + footstep = diff_footprint(text1_length - x, text2_length - y); + if (!front && (footsteps.containsKey(footstep))) { + done = true; + } + if (front) { + footsteps.put(footstep, d); + } + } + v2.put(k, x); + v_map2.get(d).add(diff_footprint(x, y)); + if (done) { + // Reverse path ran over front path. + v_map1 = v_map1.subList(0, footsteps.get(footstep) + 1); + LinkedList a + = diff_path1(v_map1, text1.substring(0, text1_length - x), + text2.substring(0, text2_length - y)); + a.addAll(diff_path2(v_map2, text1.substring(text1_length - x), + text2.substring(text2_length - y))); + return a; + } + } + } + } + // Number of diffs equals number of characters, no commonality at all. + return null; + } + /** + * Work from the middle back to the start to determine the path. + * @param v_map List of path sets. + * @param text1 Old string fragment to be diffed. + * @param text2 New string fragment to be diffed. + * @return LinkedList of Diff objects. + */ + protected LinkedList diff_path1(List> v_map, + String text1, String text2) { + LinkedList path = new LinkedList(); + int x = text1.length(); + int y = text2.length(); + Operation last_op = null; + for (int d = v_map.size() - 2; d >= 0; d--) { + while (true) { + if (v_map.get(d).contains(diff_footprint(x - 1, y))) { + x--; + if (last_op == Operation.DELETE) { + path.getFirst().text = text1.charAt(x) + path.getFirst().text; + } else { + path.addFirst(new Diff(Operation.DELETE, + text1.substring(x, x + 1))); + } + last_op = Operation.DELETE; + break; + } else if (v_map.get(d).contains(diff_footprint(x, y - 1))) { + y--; + if (last_op == Operation.INSERT) { + path.getFirst().text = text2.charAt(y) + path.getFirst().text; + } else { + path.addFirst(new Diff(Operation.INSERT, + text2.substring(y, y + 1))); + } + last_op = Operation.INSERT; + break; + } else { + x--; + y--; + assert (text1.charAt(x) == text2.charAt(y)) + : "No diagonal. Can't happen. (diff_path1)"; + if (last_op == Operation.EQUAL) { + path.getFirst().text = text1.charAt(x) + path.getFirst().text; + } else { + path.addFirst(new Diff(Operation.EQUAL, text1.substring(x, x + 1))); + } + last_op = Operation.EQUAL; + } + } + } + return path; + } + /** + * Work from the middle back to the end to determine the path. + * @param v_map List of path sets. + * @param text1 Old string fragment to be diffed. + * @param text2 New string fragment to be diffed. + * @return LinkedList of Diff objects. + */ + protected LinkedList diff_path2(List> v_map, + String text1, String text2) { + LinkedList path = new LinkedList(); + int x = text1.length(); + int y = text2.length(); + Operation last_op = null; + for (int d = v_map.size() - 2; d >= 0; d--) { + while (true) { + if (v_map.get(d).contains(diff_footprint(x - 1, y))) { + x--; + if (last_op == Operation.DELETE) { + path.getLast().text += text1.charAt(text1.length() - x - 1); + } else { + path.addLast(new Diff(Operation.DELETE, + text1.substring(text1.length() - x - 1, text1.length() - x))); + } + last_op = Operation.DELETE; + break; + } else if (v_map.get(d).contains(diff_footprint(x, y - 1))) { + y--; + if (last_op == Operation.INSERT) { + path.getLast().text += text2.charAt(text2.length() - y - 1); + } else { + path.addLast(new Diff(Operation.INSERT, + text2.substring(text2.length() - y - 1, text2.length() - y))); + } + last_op = Operation.INSERT; + break; + } else { + x--; + y--; + assert (text1.charAt(text1.length() - x - 1) + == text2.charAt(text2.length() - y - 1)) + : "No diagonal. Can't happen. (diff_path2)"; + if (last_op == Operation.EQUAL) { + path.getLast().text += text1.charAt(text1.length() - x - 1); + } else { + path.addLast(new Diff(Operation.EQUAL, + text1.substring(text1.length() - x - 1, text1.length() - x))); + } + last_op = Operation.EQUAL; + } + } + } + return path; + } + /** + * Compute a good hash of two integers. + * @param x First int. + * @param y Second int. + * @return A long made up of both ints. + */ + protected long diff_footprint(int x, int y) { + // The maximum size for a long is 9,223,372,036,854,775,807 + // The maximum size for an int is 2,147,483,647 + // Two ints fit nicely in one long. + long result = x; + result = result << 32; + result += y; + return result; + } + /** + * Determine the common prefix of two strings + * @param text1 First string. + * @param text2 Second string. + * @return The number of characters common to the start of each string. + */ + public int diff_commonPrefix(String text1, String text2) { + // Performance analysis: http://neil.fraser.name/news/2007/10/09/ + int n = Math.min(text1.length(), text2.length()); + for (int i = 0; i < n; i++) { + if (text1.charAt(i) != text2.charAt(i)) { + return i; + } + } + return n; + } + /** + * Determine the common suffix of two strings + * @param text1 First string. + * @param text2 Second string. + * @return The number of characters common to the end of each string. + */ + public int diff_commonSuffix(String text1, String text2) { + // Performance analysis: http://neil.fraser.name/news/2007/10/09/ + int text1_length = text1.length(); + int text2_length = text2.length(); + int n = Math.min(text1_length, text2_length); + for (int i = 1; i <= n; i++) { + if (text1.charAt(text1_length - i) != text2.charAt(text2_length - i)) { + return i - 1; + } + } + return n; + } + /** + * Do the two texts share a substring which is at least half the length of + * the longer text? + * @param text1 First string. + * @param text2 Second string. + * @return Five element String array, containing the prefix of text1, the + * suffix of text1, the prefix of text2, the suffix of text2 and the + * common middle. Or null if there was no match. + */ + protected String[] diff_halfMatch(String text1, String text2) { + String longtext = text1.length() > text2.length() ? text1 : text2; + String shorttext = text1.length() > text2.length() ? text2 : text1; + if (longtext.length() < 10 || shorttext.length() < 1) { + return null; // Pointless. + } + + // First check if the second quarter is the seed for a half-match. + String[] hm1 = diff_halfMatchI(longtext, shorttext, + (longtext.length() + 3) / 4); + // Check again based on the third quarter. + String[] hm2 = diff_halfMatchI(longtext, shorttext, + (longtext.length() + 1) / 2); + String[] hm; + if (hm1 == null && hm2 == null) { + return null; + } else if (hm2 == null) { + hm = hm1; + } else if (hm1 == null) { + hm = hm2; + } else { + // Both matched. Select the longest. + hm = hm1[4].length() > hm2[4].length() ? hm1 : hm2; + } + // A half-match was found, sort out the return data. + if (text1.length() > text2.length()) { + return hm; + //return new String[]{hm[0], hm[1], hm[2], hm[3], hm[4]}; + } else { + return new String[]{hm[2], hm[3], hm[0], hm[1], hm[4]}; + } + } + /** + * Does a substring of shorttext exist within longtext such that the + * substring is at least half the length of longtext? + * @param longtext Longer string. + * @param shorttext Shorter string. + * @param i Start index of quarter length substring within longtext. + * @return Five element String array, containing the prefix of longtext, the + * suffix of longtext, the prefix of shorttext, the suffix of shorttext + * and the common middle. Or null if there was no match. + */ + private String[] diff_halfMatchI(String longtext, String shorttext, int i) { + // Start with a 1/4 length substring at position i as a seed. + String seed = longtext.substring(i, i + longtext.length() / 4); + int j = -1; + String best_common = ""; + String best_longtext_a = "", best_longtext_b = ""; + String best_shorttext_a = "", best_shorttext_b = ""; + while ((j = shorttext.indexOf(seed, j + 1)) != -1) { + int prefixLength = diff_commonPrefix(longtext.substring(i), shorttext.substring(j)); + int suffixLength = diff_commonSuffix(longtext.substring(0, i), + shorttext.substring(0, j)); + if (best_common.length() < suffixLength + prefixLength) { + best_common = shorttext.substring(j - suffixLength, j) + + shorttext.substring(j, j + prefixLength); + best_longtext_a = longtext.substring(0, i - suffixLength); + best_longtext_b = longtext.substring(i + prefixLength); + best_shorttext_a = shorttext.substring(0, j - suffixLength); + best_shorttext_b = shorttext.substring(j + prefixLength); + } + } + if (best_common.length() >= longtext.length() / 2) { + return new String[]{best_longtext_a, best_longtext_b, + best_shorttext_a, best_shorttext_b, best_common}; + } else { + return null; + } + } + /** + * Reduce the number of edits by eliminating semantically trivial equalities. + * @param diffs LinkedList of Diff objects. + */ + public void diff_cleanupSemantic(LinkedList diffs) { + if (diffs.isEmpty()) { + return; + } + boolean changes = false; + Stack equalities = new Stack(); // Stack of qualities. + String lastequality = null; // Always equal to equalities.lastElement().text + ListIterator pointer = diffs.listIterator(); + // Number of characters that changed prior to the equality. + int length_changes1 = 0; + // Number of characters that changed after the equality. + int length_changes2 = 0; + Diff thisDiff = pointer.next(); + while (thisDiff != null) { + if (thisDiff.operation == Operation.EQUAL) { + // equality found + equalities.push(thisDiff); + length_changes1 = length_changes2; + length_changes2 = 0; + lastequality = thisDiff.text; + } else { + // an insertion or deletion + length_changes2 += thisDiff.text.length(); + if (lastequality != null && (lastequality.length() <= length_changes1) + && (lastequality.length() <= length_changes2)) { + //System.out.println("Splitting: '" + lastequality + "'"); + // Walk back to offending equality. + while (thisDiff != equalities.lastElement()) { + thisDiff = pointer.previous(); + } + pointer.next(); + // Replace equality with a delete. + pointer.set(new Diff(Operation.DELETE, lastequality)); + // Insert a corresponding an insert. + pointer.add(new Diff(Operation.INSERT, lastequality)); + + equalities.pop(); // Throw away the equality we just deleted. + if (!equalities.empty()) { + // Throw away the previous equality (it needs to be reevaluated). + equalities.pop(); + } + if (equalities.empty()) { + // There are no previous equalities, walk back to the start. + while (pointer.hasPrevious()) { + pointer.previous(); + } + } else { + // There is a safe equality we can fall back to. + thisDiff = equalities.lastElement(); + while (thisDiff != pointer.previous()) { + // Intentionally empty loop. + } + } + length_changes1 = 0; // Reset the counters. + length_changes2 = 0; + lastequality = null; + changes = true; + } + } + thisDiff = pointer.hasNext() ? pointer.next() : null; + } + if (changes) { + diff_cleanupMerge(diffs); + } + diff_cleanupSemanticLossless(diffs); + } + /** + * Look for single edits surrounded on both sides by equalities + * which can be shifted sideways to align the edit to a word boundary. + * e.g: The cat came. -> The cat came. + * @param diffs LinkedList of Diff objects. + */ + public void diff_cleanupSemanticLossless(LinkedList diffs) { + String equality1, edit, equality2; + String commonString; + int commonOffset; + int score, bestScore; + String bestEquality1, bestEdit, bestEquality2; + // Create a new iterator at the start. + ListIterator pointer = diffs.listIterator(); + Diff prevDiff = pointer.hasNext() ? pointer.next() : null; + Diff thisDiff = pointer.hasNext() ? pointer.next() : null; + Diff nextDiff = pointer.hasNext() ? pointer.next() : null; + // Intentionally ignore the first and last element (don't need checking). + while (nextDiff != null) { + if (prevDiff.operation == Operation.EQUAL && + nextDiff.operation == Operation.EQUAL) { + // This is a single edit surrounded by equalities. + equality1 = prevDiff.text; + edit = thisDiff.text; + equality2 = nextDiff.text; + + // First, shift the edit as far left as possible. + commonOffset = diff_commonSuffix(equality1, edit); + if (commonOffset != 0) { + commonString = edit.substring(edit.length() - commonOffset); + equality1 = equality1.substring(0, equality1.length() - commonOffset); + edit = commonString + edit.substring(0, edit.length() - commonOffset); + equality2 = commonString + equality2; + } + // Second, step character by character right, looking for the best fit. + bestEquality1 = equality1; + bestEdit = edit; + bestEquality2 = equality2; + bestScore = diff_cleanupSemanticScore(equality1, edit) + + diff_cleanupSemanticScore(edit, equality2); + while (edit.length() != 0 && equality2.length() != 0 + && edit.charAt(0) == equality2.charAt(0)) { + equality1 += edit.charAt(0); + edit = edit.substring(1) + equality2.charAt(0); + equality2 = equality2.substring(1); + score = diff_cleanupSemanticScore(equality1, edit) + + diff_cleanupSemanticScore(edit, equality2); + // The >= encourages trailing rather than leading whitespace on edits. + if (score >= bestScore) { + bestScore = score; + bestEquality1 = equality1; + bestEdit = edit; + bestEquality2 = equality2; + } + } + + if (!prevDiff.text.equals(bestEquality1)) { + // We have an improvement, save it back to the diff. + if (bestEquality1.length() != 0) { + prevDiff.text = bestEquality1; + } else { + pointer.previous(); // Walk past nextDiff. + pointer.previous(); // Walk past thisDiff. + pointer.previous(); // Walk past prevDiff. + pointer.remove(); // Delete prevDiff. + pointer.next(); // Walk past thisDiff. + pointer.next(); // Walk past nextDiff. + } + thisDiff.text = bestEdit; + if (bestEquality2.length() != 0) { + nextDiff.text = bestEquality2; + } else { + pointer.remove(); // Delete nextDiff. + nextDiff = thisDiff; + thisDiff = prevDiff; + } + } + } + prevDiff = thisDiff; + thisDiff = nextDiff; + nextDiff = pointer.hasNext() ? pointer.next() : null; + } + } + /** + * Given two strings, compute a score representing whether the internal + * boundary falls on logical boundaries. + * Scores range from 5 (best) to 0 (worst). + * @param one First string. + * @param two Second string. + * @return The score. + */ + private int diff_cleanupSemanticScore(String one, String two) { + if (one.length() == 0 || two.length() == 0) { + // Edges are the best. + return 5; + } + // Each port of this function behaves slightly differently due to + // subtle differences in each language's definition of things like + // 'whitespace'. Since this function's purpose is largely cosmetic, + // the choice has been made to use each language's native features + // rather than force total conformity. + int score = 0; + // One point for non-alphanumeric. + if (!Character.isLetterOrDigit(one.charAt(one.length() - 1)) + || !Character.isLetterOrDigit(two.charAt(0))) { + score++; + // Two points for whitespace. + if (Character.isWhitespace(one.charAt(one.length() - 1)) + || Character.isWhitespace(two.charAt(0))) { + score++; + // Three points for line breaks. + if (Character.getType(one.charAt(one.length() - 1)) == Character.CONTROL + || Character.getType(two.charAt(0)) == Character.CONTROL) { + score++; + // Four points for blank lines. + if (BLANKLINEEND.matcher(one).find() + || BLANKLINESTART.matcher(two).find()) { + score++; + } + } + } + } + return score; + } + private Pattern BLANKLINEEND + = Pattern.compile("\\n\\r?\\n\\Z", Pattern.DOTALL); + private Pattern BLANKLINESTART + = Pattern.compile("\\A\\r?\\n\\r?\\n", Pattern.DOTALL); + /** + * Reduce the number of edits by eliminating operationally trivial equalities. + * @param diffs LinkedList of Diff objects. + */ + public void diff_cleanupEfficiency(LinkedList diffs) { + if (diffs.isEmpty()) { + return; + } + boolean changes = false; + Stack equalities = new Stack(); // Stack of equalities. + String lastequality = null; // Always equal to equalities.lastElement().text + ListIterator pointer = diffs.listIterator(); + // Is there an insertion operation before the last equality. + boolean pre_ins = false; + // Is there a deletion operation before the last equality. + boolean pre_del = false; + // Is there an insertion operation after the last equality. + boolean post_ins = false; + // Is there a deletion operation after the last equality. + boolean post_del = false; + Diff thisDiff = pointer.next(); + Diff safeDiff = thisDiff; // The last Diff that is known to be unsplitable. + while (thisDiff != null) { + if (thisDiff.operation == Operation.EQUAL) { + // equality found + if (thisDiff.text.length() < Diff_EditCost && (post_ins || post_del)) { + // Candidate found. + equalities.push(thisDiff); + pre_ins = post_ins; + pre_del = post_del; + lastequality = thisDiff.text; + } else { + // Not a candidate, and can never become one. + equalities.clear(); + lastequality = null; + safeDiff = thisDiff; + } + post_ins = post_del = false; + } else { + // an insertion or deletion + if (thisDiff.operation == Operation.DELETE) { + post_del = true; + } else { + post_ins = true; + } + /* + * Five types to be split: + * ABXYCD + * AXCD + * ABXC + * AXCD + * ABXC + */ + if (lastequality != null + && ((pre_ins && pre_del && post_ins && post_del) + || ((lastequality.length() < Diff_EditCost / 2) + && ((pre_ins ? 1 : 0) + (pre_del ? 1 : 0) + + (post_ins ? 1 : 0) + (post_del ? 1 : 0)) == 3))) { + //System.out.println("Splitting: '" + lastequality + "'"); + // Walk back to offending equality. + while (thisDiff != equalities.lastElement()) { + thisDiff = pointer.previous(); + } + pointer.next(); + + // Replace equality with a delete. + pointer.set(new Diff(Operation.DELETE, lastequality)); + // Insert a corresponding an insert. + pointer.add(thisDiff = new Diff(Operation.INSERT, lastequality)); + + equalities.pop(); // Throw away the equality we just deleted. + lastequality = null; + if (pre_ins && pre_del) { + // No changes made which could affect previous entry, keep going. + post_ins = post_del = true; + equalities.clear(); + safeDiff = thisDiff; + } else { + if (!equalities.empty()) { + // Throw away the previous equality (it needs to be reevaluated). + equalities.pop(); + } + if (equalities.empty()) { + // There are no previous questionable equalities, + // walk back to the last known safe diff. + thisDiff = safeDiff; + } else { + // There is an equality we can fall back to. + thisDiff = equalities.lastElement(); + } + while (thisDiff != pointer.previous()) { + // Intentionally empty loop. + } + post_ins = post_del = false; + } + changes = true; + } + } + thisDiff = pointer.hasNext() ? pointer.next() : null; + } + if (changes) { + diff_cleanupMerge(diffs); + } + } + /** + * Reorder and merge like edit sections. Merge equalities. + * Any edit section can move as long as it doesn't cross an equality. + * @param diffs LinkedList of Diff objects. + */ + public void diff_cleanupMerge(LinkedList diffs) { + diffs.add(new Diff(Operation.EQUAL, "")); // Add a dummy entry at the end. + ListIterator pointer = diffs.listIterator(); + int count_delete = 0; + int count_insert = 0; + String text_delete = ""; + String text_insert = ""; + Diff thisDiff = pointer.next(); + Diff prevEqual = null; + int commonlength; + while (thisDiff != null) { + switch (thisDiff.operation) { + case INSERT: + count_insert++; + text_insert += thisDiff.text; + prevEqual = null; + break; + case DELETE: + count_delete++; + text_delete += thisDiff.text; + prevEqual = null; + break; + case EQUAL: + if (count_delete != 0 || count_insert != 0) { + // Delete the offending records. + pointer.previous(); // Reverse direction. + while (count_delete-- > 0) { + pointer.previous(); + pointer.remove(); + } + while (count_insert-- > 0) { + pointer.previous(); + pointer.remove(); + } + if (count_delete != 0 && count_insert != 0) { + // Factor out any common prefixies. + commonlength = diff_commonPrefix(text_insert, text_delete); + if (commonlength != 0) { + if (pointer.hasPrevious()) { + thisDiff = pointer.previous(); + assert thisDiff.operation == Operation.EQUAL + : "Previous diff should have been an equality."; + thisDiff.text += text_insert.substring(0, commonlength); + pointer.next(); + } else { + pointer.add(new Diff(Operation.EQUAL, + text_insert.substring(0, commonlength))); + } + text_insert = text_insert.substring(commonlength); + text_delete = text_delete.substring(commonlength); + } + // Factor out any common suffixies. + commonlength = diff_commonSuffix(text_insert, text_delete); + if (commonlength != 0) { + thisDiff = pointer.next(); + thisDiff.text = text_insert.substring(text_insert.length() + - commonlength) + thisDiff.text; + text_insert = text_insert.substring(0, text_insert.length() + - commonlength); + text_delete = text_delete.substring(0, text_delete.length() + - commonlength); + pointer.previous(); + } + } + // Insert the merged records. + if (text_delete.length() != 0) { + pointer.add(new Diff(Operation.DELETE, text_delete)); + } + if (text_insert.length() != 0) { + pointer.add(new Diff(Operation.INSERT, text_insert)); + } + // Step forward to the equality. + thisDiff = pointer.hasNext() ? pointer.next() : null; + } else if (prevEqual != null) { + // Merge this equality with the previous one. + prevEqual.text += thisDiff.text; + pointer.remove(); + thisDiff = pointer.previous(); + pointer.next(); // Forward direction + } + count_insert = 0; + count_delete = 0; + text_delete = ""; + text_insert = ""; + prevEqual = thisDiff; + break; + } + thisDiff = pointer.hasNext() ? pointer.next() : null; + } + // System.out.println(diff); + if (diffs.getLast().text.length() == 0) { + diffs.removeLast(); // Remove the dummy entry at the end. + } + /* + * Second pass: look for single edits surrounded on both sides by equalities + * which can be shifted sideways to eliminate an equality. + * e.g: ABAC -> ABAC + */ + boolean changes = false; + // Create a new iterator at the start. + // (As opposed to walking the current one back.) + pointer = diffs.listIterator(); + Diff prevDiff = pointer.hasNext() ? pointer.next() : null; + thisDiff = pointer.hasNext() ? pointer.next() : null; + Diff nextDiff = pointer.hasNext() ? pointer.next() : null; + // Intentionally ignore the first and last element (don't need checking). + while (nextDiff != null) { + if (prevDiff.operation == Operation.EQUAL && + nextDiff.operation == Operation.EQUAL) { + // This is a single edit surrounded by equalities. + if (thisDiff.text.endsWith(prevDiff.text)) { + // Shift the edit over the previous equality. + thisDiff.text = prevDiff.text + thisDiff.text.substring(0, thisDiff.text.length() - prevDiff.text.length()); + nextDiff.text = prevDiff.text + nextDiff.text; + pointer.previous(); // Walk past nextDiff. + pointer.previous(); // Walk past thisDiff. + pointer.previous(); // Walk past prevDiff. + pointer.remove(); // Delete prevDiff. + pointer.next(); // Walk past thisDiff. + thisDiff = pointer.next(); // Walk past nextDiff. + nextDiff = pointer.hasNext() ? pointer.next() : null; + changes = true; + } else if (thisDiff.text.startsWith(nextDiff.text)) { + // Shift the edit over the next equality. + prevDiff.text += nextDiff.text; + thisDiff.text = thisDiff.text.substring(nextDiff.text.length()) + + nextDiff.text; + pointer.remove(); // Delete nextDiff. + nextDiff = pointer.hasNext() ? pointer.next() : null; + changes = true; + } + } + prevDiff = thisDiff; + thisDiff = nextDiff; + nextDiff = pointer.hasNext() ? pointer.next() : null; + } + // If shifts were made, the diff needs reordering and another shift sweep. + if (changes) { + diff_cleanupMerge(diffs); + } + } + /** + * loc is a location in text1, compute and return the equivalent location in + * text2. + * e.g. "The cat" vs "The big cat", 1->1, 5->8 + * @param diffs LinkedList of Diff objects. + * @param loc Location within text1. + * @return Location within text2. + */ + public int diff_xIndex(LinkedList diffs, int loc) { + int chars1 = 0; + int chars2 = 0; + int last_chars1 = 0; + int last_chars2 = 0; + Diff lastDiff = null; + for (Diff aDiff : diffs) { + if (aDiff.operation != Operation.INSERT) { + // Equality or deletion. + chars1 += aDiff.text.length(); + } + if (aDiff.operation != Operation.DELETE) { + // Equality or insertion. + chars2 += aDiff.text.length(); + } + if (chars1 > loc) { + // Overshot the location. + lastDiff = aDiff; + break; + } + last_chars1 = chars1; + last_chars2 = chars2; + } + if (lastDiff != null && lastDiff.operation == Operation.DELETE) { + // The location was deleted. + return last_chars2; + } + // Add the remaining character length. + return last_chars2 + (loc - last_chars1); + } + /** + * Convert a Diff list into a pretty HTML report. + * @param diffs LinkedList of Diff objects. + * @return HTML representation. + */ + public String diff_prettyHtml(LinkedList diffs) { + StringBuilder html = new StringBuilder(); + int i = 0; + for (Diff aDiff : diffs) { + String text = aDiff.text.replace("&", "&").replace("<", "<") + .replace(">", ">").replace("\n", "¶
"); + switch (aDiff.operation) { + case INSERT: + html.append("").append(text).append(""); + break; + case DELETE: + html.append("").append(text).append(""); + break; + case EQUAL: + html.append("").append(text) + .append(""); + break; + } + if (aDiff.operation != Operation.DELETE) { + i += aDiff.text.length(); + } + } + return html.toString(); + } + /** + * Compute and return the source text (all equalities and deletions). + * @param diffs LinkedList of Diff objects. + * @return Source text. + */ + public String diff_text1(LinkedList diffs) { + StringBuilder text = new StringBuilder(); + for (Diff aDiff : diffs) { + if (aDiff.operation != Operation.INSERT) { + text.append(aDiff.text); + } + } + return text.toString(); + } + /** + * Compute and return the destination text (all equalities and insertions). + * @param diffs LinkedList of Diff objects. + * @return Destination text. + */ + public String diff_text2(LinkedList diffs) { + StringBuilder text = new StringBuilder(); + for (Diff aDiff : diffs) { + if (aDiff.operation != Operation.DELETE) { + text.append(aDiff.text); + } + } + return text.toString(); + } + /** + * Compute the Levenshtein distance; the number of inserted, deleted or + * substituted characters. + * @param diffs LinkedList of Diff objects. + * @return Number of changes. + */ + public int diff_levenshtein(LinkedList diffs) { + int levenshtein = 0; + int insertions = 0; + int deletions = 0; + for (Diff aDiff : diffs) { + switch (aDiff.operation) { + case INSERT: + insertions += aDiff.text.length(); + break; + case DELETE: + deletions += aDiff.text.length(); + break; + case EQUAL: + // A deletion and an insertion is one substitution. + levenshtein += Math.max(insertions, deletions); + insertions = 0; + deletions = 0; + break; + } + } + levenshtein += Math.max(insertions, deletions); + return levenshtein; + } + /** + * Crush the diff into an encoded string which describes the operations + * required to transform text1 into text2. + * E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'. + * Operations are tab-separated. Inserted text is escaped using %xx notation. + * @param diffs Array of diff tuples. + * @return Delta text. + */ + public String diff_toDelta(LinkedList diffs) { + StringBuilder text = new StringBuilder(); + for (Diff aDiff : diffs) { + switch (aDiff.operation) { + case INSERT: + try { + text.append("+").append(URLEncoder.encode(aDiff.text, "UTF-8") + .replace('+', ' ')).append("\t"); + } catch (UnsupportedEncodingException e) { + // Not likely on modern system. + throw new Error("This system does not support UTF-8.", e); + } + break; + case DELETE: + text.append("-").append(aDiff.text.length()).append("\t"); + break; + case EQUAL: + text.append("=").append(aDiff.text.length()).append("\t"); + break; + } + } + String delta = text.toString(); + if (delta.length() != 0) { + // Strip off trailing tab character. + delta = delta.substring(0, delta.length() - 1); + delta = unescapeForEncodeUriCompatability(delta); + } + return delta; + } + /** + * Given the original text1, and an encoded string which describes the + * operations required to transform text1 into text2, compute the full diff. + * @param text1 Source string for the diff. + * @param delta Delta text. + * @return Array of diff tuples or null if invalid. + * @throws IllegalArgumentException If invalid input. + */ + public LinkedList diff_fromDelta(String text1, String delta) + throws IllegalArgumentException { + LinkedList diffs = new LinkedList(); + int pointer = 0; // Cursor in text1 + String[] tokens = delta.split("\t"); + for (String token : tokens) { + if (token.length() == 0) { + // Blank tokens are ok (from a trailing \t). + continue; + } + // Each token begins with a one character parameter which specifies the + // operation of this token (delete, insert, equality). + String param = token.substring(1); + switch (token.charAt(0)) { + case '+': + // decode would change all "+" to " " + param = param.replace("+", "%2B"); + try { + param = URLDecoder.decode(param, "UTF-8"); + } catch (UnsupportedEncodingException e) { + // Not likely on modern system. + throw new Error("This system does not support UTF-8.", e); + } catch (IllegalArgumentException e) { + // Malformed URI sequence. + throw new IllegalArgumentException( + "Illegal escape in diff_fromDelta: " + param, e); + } + diffs.add(new Diff(Operation.INSERT, param)); + break; + case '-': + // Fall through. + case '=': + int n; + try { + n = Integer.parseInt(param); + } catch (NumberFormatException e) { + throw new IllegalArgumentException( + "Invalid number in diff_fromDelta: " + param, e); + } + if (n < 0) { + throw new IllegalArgumentException( + "Negative number in diff_fromDelta: " + param); + } + String text; + try { + text = text1.substring(pointer, pointer += n); + } catch (StringIndexOutOfBoundsException e) { + throw new IllegalArgumentException("Delta length (" + pointer + + ") larger than source text length (" + text1.length() + + ").", e); + } + if (token.charAt(0) == '=') { + diffs.add(new Diff(Operation.EQUAL, text)); + } else { + diffs.add(new Diff(Operation.DELETE, text)); + } + break; + default: + // Anything else is an error. + throw new IllegalArgumentException( + "Invalid diff operation in diff_fromDelta: " + token.charAt(0)); + } + } + if (pointer != text1.length()) { + throw new IllegalArgumentException("Delta length (" + pointer + + ") smaller than source text length (" + text1.length() + ")."); + } + return diffs; + } + // MATCH FUNCTIONS + /** + * Locate the best instance of 'pattern' in 'text' near 'loc'. + * Returns -1 if no match found. + * @param text The text to search. + * @param pattern The pattern to search for. + * @param loc The location to search around. + * @return Best match index or -1. + */ + public int match_main(String text, String pattern, int loc) { + loc = Math.max(0, Math.min(loc, text.length())); + if (text.equals(pattern)) { + // Shortcut (potentially not guaranteed by the algorithm) + return 0; + } else if (text.length() == 0) { + // Nothing to match. + return -1; + } else if (loc + pattern.length() <= text.length() + && text.substring(loc, loc + pattern.length()).equals(pattern)) { + // Perfect match at the perfect spot! (Includes case of null pattern) + return loc; + } else { + // Do a fuzzy compare. + return match_bitap(text, pattern, loc); + } + } + /** + * Locate the best instance of 'pattern' in 'text' near 'loc' using the + * Bitap algorithm. Returns -1 if no match found. + * @param text The text to search. + * @param pattern The pattern to search for. + * @param loc The location to search around. + * @return Best match index or -1. + */ + protected int match_bitap(String text, String pattern, int loc) { + assert (Match_MaxBits == 0 || pattern.length() <= Match_MaxBits) + : "Pattern too long for this application."; + // Initialise the alphabet. + Map s = match_alphabet(pattern); + // Highest score beyond which we give up. + double score_threshold = Match_Threshold; + // Is there a nearby exact match? (speedup) + int best_loc = text.indexOf(pattern, loc); + if (best_loc != -1) { + score_threshold = Math.min(match_bitapScore(0, best_loc, loc, pattern), + score_threshold); + // What about in the other direction? (speedup) + best_loc = text.lastIndexOf(pattern, loc + pattern.length()); + if (best_loc != -1) { + score_threshold = Math.min(match_bitapScore(0, best_loc, loc, pattern), + score_threshold); + } + } + // Initialise the bit arrays. + int matchmask = 1 << (pattern.length() - 1); + best_loc = -1; + int bin_min, bin_mid; + int bin_max = pattern.length() + text.length(); + // Empty initialization added to appease Java compiler. + int[] last_rd = new int[0]; + for (int d = 0; d < pattern.length(); d++) { + // Scan for the best match; each iteration allows for one more error. + // Run a binary search to determine how far from 'loc' we can stray at + // this error level. + bin_min = 0; + bin_mid = bin_max; + while (bin_min < bin_mid) { + if (match_bitapScore(d, loc + bin_mid, loc, pattern) + <= score_threshold) { + bin_min = bin_mid; + } else { + bin_max = bin_mid; + } + bin_mid = (bin_max - bin_min) / 2 + bin_min; + } + // Use the result from this iteration as the maximum for the next. + bin_max = bin_mid; + int start = Math.max(1, loc - bin_mid + 1); + int finish = Math.min(loc + bin_mid, text.length()) + pattern.length(); + int[] rd = new int[finish + 2]; + rd[finish + 1] = (1 << d) - 1; + for (int j = finish; j >= start; j--) { + int charMatch; + if (text.length() <= j - 1 || !s.containsKey(text.charAt(j - 1))) { + // Out of range. + charMatch = 0; + } else { + charMatch = s.get(text.charAt(j - 1)); + } + if (d == 0) { + // First pass: exact match. + rd[j] = ((rd[j + 1] << 1) | 1) & charMatch; + } else { + // Subsequent passes: fuzzy match. + rd[j] = ((rd[j + 1] << 1) | 1) & charMatch + | (((last_rd[j + 1] | last_rd[j]) << 1) | 1) | last_rd[j + 1]; + } + if ((rd[j] & matchmask) != 0) { + double score = match_bitapScore(d, j - 1, loc, pattern); + // This match will almost certainly be better than any existing + // match. But check anyway. + if (score <= score_threshold) { + // Told you so. + score_threshold = score; + best_loc = j - 1; + if (best_loc > loc) { + // When passing loc, don't exceed our current distance from loc. + start = Math.max(1, 2 * loc - best_loc); + } else { + // Already passed loc, downhill from here on in. + break; + } + } + } + } + if (match_bitapScore(d + 1, loc, loc, pattern) > score_threshold) { + // No hope for a (better) match at greater error levels. + break; + } + last_rd = rd; + } + return best_loc; + } + /** + * Compute and return the score for a match with e errors and x location. + * @param e Number of errors in match. + * @param x Location of match. + * @param loc Expected location of match. + * @param pattern Pattern being sought. + * @return Overall score for match (0.0 = good, 1.0 = bad). + */ + private double match_bitapScore(int e, int x, int loc, String pattern) { + float accuracy = (float) e / pattern.length(); + int proximity = Math.abs(loc - x); + if (Match_Distance == 0) { + // Dodge divide by zero error. + return proximity == 0 ? accuracy : 1.0; + } + return accuracy + (proximity / (float) Match_Distance); + } + /** + * Initialise the alphabet for the Bitap algorithm. + * @param pattern The text to encode. + * @return Hash of character locations. + */ + protected Map match_alphabet(String pattern) { + Map s = new HashMap(); + char[] char_pattern = pattern.toCharArray(); + for (char c : char_pattern) { + s.put(c, 0); + } + int i = 0; + for (char c : char_pattern) { + s.put(c, s.get(c) | (1 << (pattern.length() - i - 1))); + i++; + } + return s; + } + // PATCH FUNCTIONS + /** + * Increase the context until it is unique, + * but don't let the pattern expand beyond Match_MaxBits. + * @param patch The patch to grow. + * @param text Source text. + */ + protected void patch_addContext(Patch patch, String text) { + if (text.length() == 0) { + return; + } + String pattern = text.substring(patch.start2, patch.start2 + patch.length1); + int padding = 0; + // Look for the first and last matches of pattern in text. If two different + // matches are found, increase the pattern length. + while (text.indexOf(pattern) != text.lastIndexOf(pattern) + && pattern.length() < Match_MaxBits - Patch_Margin - Patch_Margin) { + padding += Patch_Margin; + pattern = text.substring(Math.max(0, patch.start2 - padding), + Math.min(text.length(), patch.start2 + patch.length1 + padding)); + } + // Add one chunk for good luck. + padding += Patch_Margin; + // Add the prefix. + String prefix = text.substring(Math.max(0, patch.start2 - padding), + patch.start2); + if (prefix.length() != 0) { + patch.diffs.addFirst(new Diff(Operation.EQUAL, prefix)); + } + // Add the suffix. + String suffix = text.substring(patch.start2 + patch.length1, + Math.min(text.length(), patch.start2 + patch.length1 + padding)); + if (suffix.length() != 0) { + patch.diffs.addLast(new Diff(Operation.EQUAL, suffix)); + } + // Roll back the start points. + patch.start1 -= prefix.length(); + patch.start2 -= prefix.length(); + // Extend the lengths. + patch.length1 += prefix.length() + suffix.length(); + patch.length2 += prefix.length() + suffix.length(); + } + /** + * Compute a list of patches to turn text1 into text2. + * A set of diffs will be computed. + * @param text1 Old text. + * @param text2 New text. + * @return LinkedList of Patch objects. + */ + public LinkedList patch_make(String text1, String text2) { + // No diffs provided, compute our own. + LinkedList diffs = diff_main(text1, text2, true); + if (diffs.size() > 2) { + diff_cleanupSemantic(diffs); + diff_cleanupEfficiency(diffs); + } + return patch_make(text1, diffs); + } + /** + * Compute a list of patches to turn text1 into text2. + * text1 will be derived from the provided diffs. + * @param diffs Array of diff tuples for text1 to text2. + * @return LinkedList of Patch objects. + */ + public LinkedList patch_make(LinkedList diffs) { + // No origin string provided, compute our own. + String text1 = diff_text1(diffs); + return patch_make(text1, diffs); + } + /** + * Compute a list of patches to turn text1 into text2. + * text2 is ignored, diffs are the delta between text1 and text2. + * @param text1 Old text + * @param text2 Ignored. + * @param diffs Array of diff tuples for text1 to text2. + * @return LinkedList of Patch objects. + * @deprecated Prefer patch_make(String text1, LinkedList diffs). + */ + public LinkedList patch_make(String text1, String text2, + LinkedList diffs) { + return patch_make(text1, diffs); + } + /** + * Compute a list of patches to turn text1 into text2. + * text2 is not provided, diffs are the delta between text1 and text2. + * @param text1 Old text. + * @param diffs Array of diff tuples for text1 to text2. + * @return LinkedList of Patch objects. + */ + public LinkedList patch_make(String text1, LinkedList diffs) { + LinkedList patches = new LinkedList(); + if (diffs.isEmpty()) { + return patches; // Get rid of the null case. + } + Patch patch = new Patch(); + int char_count1 = 0; // Number of characters into the text1 string. + int char_count2 = 0; // Number of characters into the text2 string. + // Start with text1 (prepatch_text) and apply the diffs until we arrive at + // text2 (postpatch_text). We recreate the patches one by one to determine + // context info. + String prepatch_text = text1; + String postpatch_text = text1; + for (Diff aDiff : diffs) { + if (patch.diffs.isEmpty() && aDiff.operation != Operation.EQUAL) { + // A new patch starts here. + patch.start1 = char_count1; + patch.start2 = char_count2; + } + switch (aDiff.operation) { + case INSERT: + patch.diffs.add(aDiff); + patch.length2 += aDiff.text.length(); + postpatch_text = postpatch_text.substring(0, char_count2) + + aDiff.text + postpatch_text.substring(char_count2); + break; + case DELETE: + patch.length1 += aDiff.text.length(); + patch.diffs.add(aDiff); + postpatch_text = postpatch_text.substring(0, char_count2) + + postpatch_text.substring(char_count2 + aDiff.text.length()); + break; + case EQUAL: + if (aDiff.text.length() <= 2 * Patch_Margin + && !patch.diffs.isEmpty() && aDiff != diffs.getLast()) { + // Small equality inside a patch. + patch.diffs.add(aDiff); + patch.length1 += aDiff.text.length(); + patch.length2 += aDiff.text.length(); + } + if (aDiff.text.length() >= 2 * Patch_Margin) { + // Time for a new patch. + if (!patch.diffs.isEmpty()) { + patch_addContext(patch, prepatch_text); + patches.add(patch); + patch = new Patch(); + // Unlike Unidiff, our patch lists have a rolling context. + // http://code.google.com/p/google-diff-match-patch/wiki/Unidiff + // Update prepatch text & pos to reflect the application of the + // just completed patch. + prepatch_text = postpatch_text; + char_count1 = char_count2; + } + } + break; + } + // Update the current character count. + if (aDiff.operation != Operation.INSERT) { + char_count1 += aDiff.text.length(); + } + if (aDiff.operation != Operation.DELETE) { + char_count2 += aDiff.text.length(); + } + } + // Pick up the leftover patch if not empty. + if (!patch.diffs.isEmpty()) { + patch_addContext(patch, prepatch_text); + patches.add(patch); + } + return patches; + } + /** + * Given an array of patches, return another array that is identical. + * @param patches Array of patch objects. + * @return Array of patch objects. + */ + public LinkedList patch_deepCopy(LinkedList patches) { + LinkedList patchesCopy = new LinkedList(); + for (Patch aPatch : patches) { + Patch patchCopy = new Patch(); + for (Diff aDiff : aPatch.diffs) { + Diff diffCopy = new Diff(aDiff.operation, aDiff.text); + patchCopy.diffs.add(diffCopy); + } + patchCopy.start1 = aPatch.start1; + patchCopy.start2 = aPatch.start2; + patchCopy.length1 = aPatch.length1; + patchCopy.length2 = aPatch.length2; + patchesCopy.add(patchCopy); + } + return patchesCopy; + } + /** + * Merge a set of patches onto the text. Return a patched text, as well + * as an array of true/false values indicating which patches were applied. + * @param patches Array of patch objects + * @param text Old text. + * @return Two element Object array, containing the new text and an array of + * boolean values. + */ + public Object[] patch_apply(LinkedList patches, String text) { + if (patches.isEmpty()) { + return new Object[]{text, new boolean[0]}; + } + // Deep copy the patches so that no changes are made to originals. + patches = patch_deepCopy(patches); + String nullPadding = patch_addPadding(patches); + text = nullPadding + text + nullPadding; + patch_splitMax(patches); + int x = 0; + // delta keeps track of the offset between the expected and actual location + // of the previous patch. If there are patches expected at positions 10 and + // 20, but the first patch was found at 12, delta is 2 and the second patch + // has an effective expected position of 22. + int delta = 0; + boolean[] results = new boolean[patches.size()]; + for (Patch aPatch : patches) { + int expected_loc = aPatch.start2 + delta; + String text1 = diff_text1(aPatch.diffs); + int start_loc; + int end_loc = -1; + if (text1.length() > this.Match_MaxBits) { + // patch_splitMax will only provide an oversized pattern in the case of + // a monster delete. + start_loc = match_main(text, + text1.substring(0, this.Match_MaxBits), expected_loc); + if (start_loc != -1) { + end_loc = match_main(text, + text1.substring(text1.length() - this.Match_MaxBits), + expected_loc + text1.length() - this.Match_MaxBits); + if (end_loc == -1 || start_loc >= end_loc) { + // Can't find valid trailing context. Drop this patch. + start_loc = -1; + } + } + } else { + start_loc = match_main(text, text1, expected_loc); + } + if (start_loc == -1) { + // No match found. :( + results[x] = false; + // Subtract the delta for this failed patch from subsequent patches. + delta -= aPatch.length2 - aPatch.length1; + } else { + // Found a match. :) + results[x] = true; + delta = start_loc - expected_loc; + String text2; + if (end_loc == -1) { + text2 = text.substring(start_loc, + Math.min(start_loc + text1.length(), text.length())); + } else { + text2 = text.substring(start_loc, + Math.min(end_loc + this.Match_MaxBits, text.length())); + } + if (text1.equals(text2)) { + // Perfect match, just shove the replacement text in. + text = text.substring(0, start_loc) + diff_text2(aPatch.diffs) + + text.substring(start_loc + text1.length()); + } else { + // Imperfect match. Run a diff to get a framework of equivalent + // indices. + LinkedList diffs = diff_main(text1, text2, false); + if (text1.length() > this.Match_MaxBits + && diff_levenshtein(diffs) / (float) text1.length() + > this.Patch_DeleteThreshold) { + // The end points match, but the content is unacceptably bad. + results[x] = false; + } else { + diff_cleanupSemanticLossless(diffs); + int index1 = 0; + for (Diff aDiff : aPatch.diffs) { + if (aDiff.operation != Operation.EQUAL) { + int index2 = diff_xIndex(diffs, index1); + if (aDiff.operation == Operation.INSERT) { + // Insertion + text = text.substring(0, start_loc + index2) + aDiff.text + + text.substring(start_loc + index2); + } else if (aDiff.operation == Operation.DELETE) { + // Deletion + text = text.substring(0, start_loc + index2) + + text.substring(start_loc + diff_xIndex(diffs, + index1 + aDiff.text.length())); + } + } + if (aDiff.operation != Operation.DELETE) { + index1 += aDiff.text.length(); + } + } + } + } + } + x++; + } + // Strip the padding off. + text = text.substring(nullPadding.length(), text.length() + - nullPadding.length()); + return new Object[]{text, results}; + } + /** + * Add some padding on text start and end so that edges can match something. + * Intended to be called only from within patch_apply. + * @param patches Array of patch objects. + * @return The padding string added to each side. + */ + public String patch_addPadding(LinkedList patches) { + int paddingLength = this.Patch_Margin; + String nullPadding = ""; + for (int x = 1; x <= paddingLength; x++) { + nullPadding += String.valueOf((char) x); + } + // Bump all the patches forward. + for (Patch aPatch : patches) { + aPatch.start1 += paddingLength; + aPatch.start2 += paddingLength; + } + // Add some padding on start of first diff. + Patch patch = patches.getFirst(); + LinkedList diffs = patch.diffs; + if (diffs.isEmpty() || diffs.getFirst().operation != Operation.EQUAL) { + // Add nullPadding equality. + diffs.addFirst(new Diff(Operation.EQUAL, nullPadding)); + patch.start1 -= paddingLength; // Should be 0. + patch.start2 -= paddingLength; // Should be 0. + patch.length1 += paddingLength; + patch.length2 += paddingLength; + } else if (paddingLength > diffs.getFirst().text.length()) { + // Grow first equality. + Diff firstDiff = diffs.getFirst(); + int extraLength = paddingLength - firstDiff.text.length(); + firstDiff.text = nullPadding.substring(firstDiff.text.length()) + + firstDiff.text; + patch.start1 -= extraLength; + patch.start2 -= extraLength; + patch.length1 += extraLength; + patch.length2 += extraLength; + } + // Add some padding on end of last diff. + patch = patches.getLast(); + diffs = patch.diffs; + if (diffs.isEmpty() || diffs.getLast().operation != Operation.EQUAL) { + // Add nullPadding equality. + diffs.addLast(new Diff(Operation.EQUAL, nullPadding)); + patch.length1 += paddingLength; + patch.length2 += paddingLength; + } else if (paddingLength > diffs.getLast().text.length()) { + // Grow last equality. + Diff lastDiff = diffs.getLast(); + int extraLength = paddingLength - lastDiff.text.length(); + lastDiff.text += nullPadding.substring(0, extraLength); + patch.length1 += extraLength; + patch.length2 += extraLength; + } + return nullPadding; + } + /** + * Look through the patches and break up any which are longer than the + * maximum limit of the match algorithm. + * @param patches LinkedList of Patch objects. + */ + public void patch_splitMax(LinkedList patches) { + int patch_size; + String precontext, postcontext; + Patch patch; + int start1, start2; + boolean empty; + Operation diff_type; + String diff_text; + ListIterator pointer = patches.listIterator(); + Patch bigpatch = pointer.hasNext() ? pointer.next() : null; + while (bigpatch != null) { + if (bigpatch.length1 <= Match_MaxBits) { + bigpatch = pointer.hasNext() ? pointer.next() : null; + continue; + } + // Remove the big old patch. + pointer.remove(); + patch_size = Match_MaxBits; + start1 = bigpatch.start1; + start2 = bigpatch.start2; + precontext = ""; + while (!bigpatch.diffs.isEmpty()) { + // Create one of several smaller patches. + patch = new Patch(); + empty = true; + patch.start1 = start1 - precontext.length(); + patch.start2 = start2 - precontext.length(); + if (precontext.length() != 0) { + patch.length1 = patch.length2 = precontext.length(); + patch.diffs.add(new Diff(Operation.EQUAL, precontext)); + } + while (!bigpatch.diffs.isEmpty() + && patch.length1 < patch_size - Patch_Margin) { + diff_type = bigpatch.diffs.getFirst().operation; + diff_text = bigpatch.diffs.getFirst().text; + if (diff_type == Operation.INSERT) { + // Insertions are harmless. + patch.length2 += diff_text.length(); + start2 += diff_text.length(); + patch.diffs.addLast(bigpatch.diffs.removeFirst()); + empty = false; + } else if (diff_type == Operation.DELETE && patch.diffs.size() == 1 + && patch.diffs.getFirst().operation == Operation.EQUAL + && diff_text.length() > 2 * patch_size) { + // This is a large deletion. Let it pass in one chunk. + patch.length1 += diff_text.length(); + start1 += diff_text.length(); + empty = false; + patch.diffs.add(new Diff(diff_type, diff_text)); + bigpatch.diffs.removeFirst(); + } else { + // Deletion or equality. Only take as much as we can stomach. + diff_text = diff_text.substring(0, Math.min(diff_text.length(), + patch_size - patch.length1 - Patch_Margin)); + patch.length1 += diff_text.length(); + start1 += diff_text.length(); + if (diff_type == Operation.EQUAL) { + patch.length2 += diff_text.length(); + start2 += diff_text.length(); + } else { + empty = false; + } + patch.diffs.add(new Diff(diff_type, diff_text)); + if (diff_text.equals(bigpatch.diffs.getFirst().text)) { + bigpatch.diffs.removeFirst(); + } else { + bigpatch.diffs.getFirst().text = bigpatch.diffs.getFirst().text + .substring(diff_text.length()); + } + } + } + // Compute the head context for the next patch. + precontext = diff_text2(patch.diffs); + precontext = precontext.substring(Math.max(0, precontext.length() + - Patch_Margin)); + // Append the end context for this patch. + if (diff_text1(bigpatch.diffs).length() > Patch_Margin) { + postcontext = diff_text1(bigpatch.diffs).substring(0, Patch_Margin); + } else { + postcontext = diff_text1(bigpatch.diffs); + } + if (postcontext.length() != 0) { + patch.length1 += postcontext.length(); + patch.length2 += postcontext.length(); + if (!patch.diffs.isEmpty() + && patch.diffs.getLast().operation == Operation.EQUAL) { + patch.diffs.getLast().text += postcontext; + } else { + patch.diffs.add(new Diff(Operation.EQUAL, postcontext)); + } + } + if (!empty) { + pointer.add(patch); + } + } + bigpatch = pointer.hasNext() ? pointer.next() : null; + } + } + /** + * Take a list of patches and return a textual representation. + * @param patches List of Patch objects. + * @return Text representation of patches. + */ + public String patch_toText(List patches) { + StringBuilder text = new StringBuilder(); + for (Patch aPatch : patches) { + text.append(aPatch); + } + return text.toString(); + } + /** + * Parse a textual representation of patches and return a List of Patch + * objects. + * @param textline Text representation of patches. + * @return List of Patch objects. + * @throws IllegalArgumentException If invalid input. + */ + public List patch_fromText(String textline) + throws IllegalArgumentException { + List patches = new LinkedList(); + if (textline.length() == 0) { + return patches; + } + List textList = Arrays.asList(textline.split("\n")); + LinkedList text = new LinkedList(textList); + Patch patch; + Pattern patchHeader + = Pattern.compile("^@@ -(\\d+),?(\\d*) \\+(\\d+),?(\\d*) @@$"); + Matcher m; + char sign; + String line; + while (!text.isEmpty()) { + m = patchHeader.matcher(text.getFirst()); + if (!m.matches()) { + throw new IllegalArgumentException( + "Invalid patch string: " + text.getFirst()); + } + patch = new Patch(); + patches.add(patch); + patch.start1 = Integer.parseInt(m.group(1)); + if (m.group(2).length() == 0) { + patch.start1--; + patch.length1 = 1; + } else if (m.group(2).equals("0")) { + patch.length1 = 0; + } else { + patch.start1--; + patch.length1 = Integer.parseInt(m.group(2)); + } + patch.start2 = Integer.parseInt(m.group(3)); + if (m.group(4).length() == 0) { + patch.start2--; + patch.length2 = 1; + } else if (m.group(4).equals("0")) { + patch.length2 = 0; + } else { + patch.start2--; + patch.length2 = Integer.parseInt(m.group(4)); + } + text.removeFirst(); + + while (!text.isEmpty()) { + try { + sign = text.getFirst().charAt(0); + } catch (IndexOutOfBoundsException e) { + // Blank line? Whatever. + text.removeFirst(); + continue; + } + line = text.getFirst().substring(1); + line = line.replace("+", "%2B"); // decode would change all "+" to " " + try { + line = URLDecoder.decode(line, "UTF-8"); + } catch (UnsupportedEncodingException e) { + // Not likely on modern system. + throw new Error("This system does not support UTF-8.", e); + } catch (IllegalArgumentException e) { + // Malformed URI sequence. + throw new IllegalArgumentException( + "Illegal escape in patch_fromText: " + line, e); + } + if (sign == '-') { + // Deletion. + patch.diffs.add(new Diff(Operation.DELETE, line)); + } else if (sign == '+') { + // Insertion. + patch.diffs.add(new Diff(Operation.INSERT, line)); + } else if (sign == ' ') { + // Minor equality. + patch.diffs.add(new Diff(Operation.EQUAL, line)); + } else if (sign == '@') { + // Start of next patch. + break; + } else { + // WTF? + throw new IllegalArgumentException( + "Invalid patch mode '" + sign + "' in: " + line); + } + text.removeFirst(); + } + } + return patches; + } + + + /** + * Class representing one diff operation. + */ + public static class Diff { + /** + * One of: INSERT, DELETE or EQUAL. + */ + public Operation operation; + /** + * The text associated with this diff operation. + */ + public String text; + + /** + * Constructor. Initializes the diff with the provided values. + * @param operation One of INSERT, DELETE or EQUAL. + * @param text The text being applied. + */ + public Diff(Operation operation, String text) { + // Construct a diff with the specified operation and text. + this.operation = operation; + this.text = text; + } + + + /** + * Display a human-readable version of this Diff. + * @return text version. + */ + public String toString() { + String prettyText = this.text.replace('\n', '\u00b6'); + return "Diff(" + this.operation + ",\"" + prettyText + "\")"; + } + + + /** + * Is this Diff equivalent to another Diff? + * @param d Another Diff to compare against. + * @return true or false. + */ + public boolean equals(Object d) { + try { + return (((Diff) d).operation == this.operation) + && (((Diff) d).text.equals(this.text)); + } catch (ClassCastException e) { + return false; + } + } + } + + + /** + * Class representing one patch operation. + */ + public static class Patch { + public LinkedList diffs; + public int start1; + public int start2; + public int length1; + public int length2; + + + /** + * Constructor. Initializes with an empty list of diffs. + */ + public Patch() { + this.diffs = new LinkedList(); + } + + + /** + * Emmulate GNU diff's format. + * Header: @@ -382,8 +481,9 @@ + * Indicies are printed as 1-based, not 0-based. + * @return The GNU diff string. + */ + public String toString() { + String coords1, coords2; + if (this.length1 == 0) { + coords1 = this.start1 + ",0"; + } else if (this.length1 == 1) { + coords1 = Integer.toString(this.start1 + 1); + } else { + coords1 = (this.start1 + 1) + "," + this.length1; + } + if (this.length2 == 0) { + coords2 = this.start2 + ",0"; + } else if (this.length2 == 1) { + coords2 = Integer.toString(this.start2 + 1); + } else { + coords2 = (this.start2 + 1) + "," + this.length2; + } + StringBuilder text = new StringBuilder(); + text.append("@@ -").append(coords1).append(" +").append(coords2) + .append(" @@\n"); + // Escape the body of the patch with %xx notation. + for (Diff aDiff : this.diffs) { + switch (aDiff.operation) { + case INSERT: + text.append('+'); + break; + case DELETE: + text.append('-'); + break; + case EQUAL: + text.append(' '); + break; + } + try { + text.append(URLEncoder.encode(aDiff.text, "UTF-8").replace('+', ' ')) + .append("\n"); + } catch (UnsupportedEncodingException e) { + // Not likely on modern system. + throw new Error("This system does not support UTF-8.", e); + } + } + return unescapeForEncodeUriCompatability(text.toString()); + } + } + + + /** + * Unescape selected chars for compatability with JavaScript's encodeURI. + * In speed critical applications this could be dropped since the + * receiving application will certainly decode these fine. + * Note that this function is case-sensitive. Thus "%3f" would not be + * unescaped. But this is ok because it is only called with the output of + * URLEncoder.encode which returns uppercase hex. + * + * Example: "%3F" -> "?", "%24" -> "$", etc. + * + * @param str The string to escape. + * @return The escaped string. + */ + private static String unescapeForEncodeUriCompatability(String str) { + return str.replace("%21", "!").replace("%7E", "~") + .replace("%27", "'").replace("%28", "(").replace("%29", ")") + .replace("%3B", ";").replace("%2F", "/").replace("%3F", "?") + .replace("%3A", ":").replace("%40", "@").replace("%26", "&") + .replace("%3D", "=").replace("%2B", "+").replace("%24", "$") + .replace("%2C", ",").replace("%23", "#"); + } + + public String getHtmlDiffString(String text1,String text2){ + return diff_prettyHtml(diff_main(text1,text2)); + } + + public List getHtmlDiffStr(String text1,String text2){ + LinkedList diffs = diff_main(text1, text2); + //定义输出结果 + String LResultStr=""; + String RResultStr=""; + for(Diff deff:diffs){ + String text = deff.text.replace("&", "&").replace("<", "<") + .replace(">", ">").replace("\n", "
"); + switch (deff.operation) { + case INSERT: + RResultStr+=""+text+""; + break; + case DELETE://删除 说明是左边有变化 右边没有变化 + LResultStr+=""+text+""; + break; + case EQUAL: + LResultStr+=text; + RResultStr+=text; + break; + } + } + List result =new ArrayList<>(); + result.add(LResultStr); + result.add(RResultStr); + return result; + } + + + public static void main(String[] args){ + DiffUtils dmp = new DiffUtils(); +// String text1 = "我方在“福市财政资金补助项目管理系统”的项目实施过程,为保证该项目的工程进度、zhiliang,符合数办项目的实施管理规范与要求。"; +// String text2 = "我方在“福州市财政资金补助项目管理系统”的项目实施过程,为保证该项目的工程进度、质量,符合目的实施管理规范与要求。"; + String str1="6转向系\n" + + "6.1汽车(三轮汽车除外)的方向盘应设置于左侧,其他机动车的方向盘不得设置于右侧;专项作业车、教练车按需要可设置左右两个方向盘。有驾驶室的正三轮摩托车如使用方向盘转向,则方向盘中心立柱距车辆纵向中心平面的水平距离应小于等于200 mm;其他摩托车不得使用方向盘转向。\n" + + "6.2机动车的方向盘(或方向把)应转动灵活,操纵方便,无卡滞现象。机动车应设置转向限位装置。转向系统在任何操作位置上,不得与其他部件有干涉现象。\n" + + "6.3机动车(摩托车、三轮汽车、手扶拖拉机运输机组除外)正常行驶时,转向轮转向后应有一定的回正能力(允许有残余角),以使机动车具有稳定的直线行驶能力。\n" + + "6.4机动车方向盘的最大自由转动量应小于或等于:\n" + + "a) 最大设计车速大于或等于100 km/h 的机动车:15°\n" + + "b) 三轮汽车:35°;\n" + + "c) 其他机动车:25° 。\n" + + "6.5汽车(三轮汽车除外)应具有适度的不足转向特性。\n" + + "6.6三轮汽车、摩托车的转向轮向左或向右转角应小于等于:\n" + + "a)\t三轮汽车、三轮摩托车、正三轮轻便摩托车:45°;\n" + + "6)\t\t两轮普通摩托车、两轮轻便摩托车:48°。\n" + + "6.6机动车在平坦、硬实、干燥和清洁的道路上行驶不应跑偏,其方向盘(或方向把)不应有摆振、路感不灵或其他异常现象。\n" + + "6.8机动车在平坦、硬实、干燥和清洁的水泥或沥青道路上行驶,以10 km/h的速度在5 s之内沿螺旋线从直线行驶过渡到外圆直径为25 m的车辆通道圆行驶,施加于方向盘外缘的最大切向力应小于等于245 N。\n" + + "6.9专用校车应采用转向助力装置;其他机动车转向轴最大设计轴荷大于4 000 kg时,也应采用转向助力装置。装有转向助力装置的机动车,转向时其转向助力功能不得出现时有时无的现象,且转向助力装置失效时仍应具有用方向盘控制机动车的能力。装有电动转向助力装置的汽车,在产品使用说明书规定的正常使用状态下,应保证转向助力装置的电能供应。\n" + + "6.10汽车和汽车列车(不计具有作业功能的专用装置的突出部分)、轮式拖拉机运输机组应能在同一个车辆通道圆内通过,车辆通道圆的外圆直径认为25.00 m,车辆通道圆的内圆直径D2为10.60 m。 汽车和汽车列车、轮式拖拉机运输机组由直线行驶过渡到上述圆周运动时,任何部分超出直线行驶时的 车辆外侧面垂直面的值(外摆值)应小于等于0.80 m(对铰接客车和铰接式无轨电车外摆值应小于等于 1.20 m),其试验方法见GB 1589。\n" + + "6.11汽车(三轮汽车除外)的车轮定位应与该车型的技术要求一致。对前轴采用非独立悬架的汽车(前轴采用双转向轴时除外),其转向轮的横向侧滑量,用侧滑台检验时侧滑量值应在±5 m/km之间。\n" + + "6.12转向节及臂,转向横、直拉杆及球销不得有裂纹和损伤,并且转向球销不应松旷。对机动车进行改装或修理时横、直拉杆不得拼焊。\n" + + "6.13三轮汽车、摩托车的前减振器、上下联板和方向把不应有变形和裂损。\n"; + String str2="6转向系\n" + + "6.1汽车(三轮汽车除外)的方向盘应设置于左侧,其他机动车的方向盘不应设置于右侧;专项作业车、教练车按需要可设置左右两个方向盘。装有两个后轮、有驾驶室的正三轮摩托车如使用方向盘转向,则方向盘中心立柱距车辆纵向中心平面的水平距离应小于或等于200 mm ;其他摩托车不应使用方向盘转向。\n" + + "6.2机动车的方向盘(或方向把)应转动灵活,无卡滞现象。机动车应设置转向限位装置。转向系统在任何操作位置上,不应与其他部件有干涉现象。\n" + + "6.3机动车(摩托车、三轮汽车、手扶拖拉机运输机组除外〉正常行驶时,转向轮转向后应有一定的回正能力(允许有残余角),以使机动车具有稳定的直线行驶能力0\n" + + "6.4机动车方向盘的最大自由转动量应小于或等于:\n" + + "a) 最大设计车速大于或等于100 km/h 的机动车:15°\n" + + "b) 三轮汽车:35°;\n" + + "c) 其他机动车:25° 。\n" + + "6.5汽车(三轮汽车除外)应具有适度的不足转向特性。\n" + + "6.6三轮汽车、摩托车的转向轮向左或向右转角应小于或等于:\n" + + "a) 三轮汽车、三轮摩托车、正三轮轻便摩托车:45°;\n" + + "b)两轮普通摩托车、两轮轻便摩托车:48°0\n" + + "6.7机动车在平坦、硬实、干燥和清洁的道路上行驶不应跑偏,其方向盘(或方向把)不应有摆振等异常现象。\n" + + "6.8机动车在平坦、硬实、干燥和清洁的水泥或沥青道路上行驶,以10 km/h 的速度在5 s 之内沿螺旋线从直线行驶过渡到外圆直径为25m 的车辆通道圆行驶,施加于方向盘外缘的最大切向力应小于或等于245 N。\n" + + "6.9汽车(三轮汽车除外)的车轮定位应与该车型的技术要求一致。对前轴采用非独立悬架的汽车(前轴采用双转向轴时除外),其转向轮的横向侧滑量,用侧滑台检验时侧滑量值应小于或等于5 m/km。\n" + + "6.10 专用校车应采用转向助力装置;其他机动车转向轴最大设计轴荷大于4 000 kg 时,也应采用转向助力装置。装有转向助力装置的机动车,转向时其转向助力功能不应出现时有时无的现象,且转向助力装置失效时仍应具有用方向盘控制机动车的能力。\n" + + "6.11转向节及臂,转向横、直拉杆及球销应连接可靠,且不应有裂纹和损伤,并且转向球销不应松旷。对机动车进行改装或修理时横、直拉杆不应拼焊。\n" + + "6.12三轮汽车、摩托车的前减振器、上下联板和方向把不应有变形和裂损。"; + String line1="6.1汽车(三轮汽车除外)的方向盘应设置于左侧,其他机动车的方向盘不得设置于右侧;专项作业车、教练车按需要可设置左右两个方向盘。有驾驶室的正三轮摩托车如使用方向盘转向,则方向盘中心立柱距车辆纵向中心平面的水平距离应小于等于200 mm;其他摩托车不得使用方向盘转向。"; + String line2="6.1汽车(三轮汽车除外)的方向盘应设置于左侧,其他机动车的方向盘不应设置于右侧;专项作业车、教练车按需要可设置左右两个方向盘。装有两个后轮、有驾驶室的正三轮摩托车如使用方向盘转向,则方向盘中心立柱距车辆纵向中心平面的水平距离应小于或等于200 mm ;其他摩托车不应使用方向盘转向。"; + String compareStr = dmp.getHtmlDiffString(str1,str2); + //String compareStr = dmp.getHtmlDiffString(line1,line2); + System.out.println(compareStr); + System.out.println("---------------------------------------------------"); + List htmlDiffStr = dmp.getHtmlDiffStr(str1, str2); + System.out.println(htmlDiffStr.get(0)); + System.out.println("=============================================="); + System.out.println(htmlDiffStr.get(1)); + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/ExcelUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/ExcelUtil.java new file mode 100644 index 00000000..9c653f09 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/ExcelUtil.java @@ -0,0 +1,271 @@ +package com.adc.da.utils.util;/** + * Created by Administrator on 2018/12/20 16:42 + */ + +import org.apache.commons.lang.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.List; + +/** + * @Author Administrator + * @Description TODO + * Date 2018/12/20 16:42 + * @Param + * @return + **/ +public class ExcelUtil { + + private static final Logger logger = LoggerFactory.getLogger(ExcelUtil.class); + + + private static String EDGE = "Edge"; + private static String CHROME = "Chrome"; + private static String FIREFOX = "Firefox"; + private static String USERAGENT = "USER-AGENT"; + private static String UTF8 = "UTF8"; + private static String ISO88591 = "ISO8859-1"; + + /** + * @param filePath 需要读取的文件路径 + * @param column 指定需要获取的列数,例如第一列 1 + * @param startRow 指定从第几行开始读取数据 + * @param endRow 指定结束行 + * @return 返回读取列数据的set + */ + public static List getColumnSet(String fileOrginName, MultipartFile file, int column, int startRow, int endRow) throws IOException { + Workbook wb = readExcel(fileOrginName, file.getInputStream()); //文件 + Sheet sheet = wb.getSheetAt(0); //sheet + int rownum = sheet.getPhysicalNumberOfRows(); //行数 + Row row = null; + List result = new ArrayList<>(); + String cellData = null; + if (wb != null) { + for (int i = startRow - 1; i <= endRow; i++) { + System.out.println(i); + row = sheet.getRow(i); + if (row != null) { + if (row.getCell(column - 1) != null) {//单元格为空,不进入 + row.getCell(column - 1).setCellType(CellType.STRING);//设置单元格类型 + cellData = row.getCell(column - 1).getStringCellValue(); + result.add(cellData); + } else { + result.add(""); + } + } else { + + break; + } + System.out.println(cellData); + } + } + return result; + } + + /** + * @param column 指定需要获取的列数,例如第一列 1 + * @param startRow 指定从第几行开始读取数据 + * @return 返回读取列数据的set + */ + public static List getColumnSet(String fileOrginName, MultipartFile file, int column, int startRow) throws IOException { + Workbook wb = readExcel(fileOrginName, file.getInputStream()); //文件 + Sheet sheet = wb.getSheetAt(0); //sheet + int rownum = sheet.getPhysicalNumberOfRows(); //行数 + System.out.println("sumrows " + rownum); + + return getColumnSet(fileOrginName, file, column, startRow, rownum - 1); + } + + + //读取excel + public static Workbook readExcel(String fileOrginName, InputStream is) { + Workbook wb = null; + String extString = fileOrginName.substring(fileOrginName.lastIndexOf(".")); + try { + if (".xls".equals(extString)) { + return wb = new HSSFWorkbook(is); + } else if (".xlsx".equals(extString)) { + return wb = new XSSFWorkbook(is); + } else { + return wb = null; + } + } catch (FileNotFoundException e) { + logger.error("异常:", e); + } catch (IOException e) { + logger.error("异常:", e); + } + return wb; + } + + /*public static Object getCellFormatValue(Cell cell){ + Object cellValue = null; + if(cell!=null){ + //判断cell类型 + switch(cell.getCellType()){ + case NUMERIC:{ + cell.setCellType(CellType.STRING); //将数值型cell设置为string型 + cellValue = cell.getStringCellValue(); + break; + } + case FORMULA:{ + //判断cell是否为日期格式 + if(DateUtil.isCellDateFormatted(cell)){ + //转换为日期格式YYYY-mm-dd + cellValue = cell.getDateCellValue(); + }else{ + //数字 + cellValue = String.valueOf(cell.getNumericCellValue()); + } + break; + } + case STRING:{ + cellValue = cell.getRichStringCellValue().getString(); + break; + } + default: + cellValue = ""; + } + }else{ + cellValue = ""; + } + return cellValue; + }*/ + + public static String validatePattern(String fileName) { + if (StringUtils.isNotEmpty(fileName)) { + Boolean isOk = false; + if (fileName.lastIndexOf(".docx") != -1) { + isOk = true; + } + if (fileName.lastIndexOf(".pdf") != -1) { + isOk = true; + } + if (fileName.lastIndexOf(".doc") != -1) { + isOk = true; + } + if (fileName.lastIndexOf(".PDF") != -1) { + isOk = true; + } + if(fileName.lastIndexOf(".ppt") != -1){ + isOk = true; + } + if(fileName.lastIndexOf(".pptx") != -1){ + isOk = true; + } + if(fileName.lastIndexOf(".xls") != -1){ + isOk = true; + } + if(fileName.lastIndexOf(".xlsx") != -1){ + isOk = true; + } + if(fileName.lastIndexOf(".jpg") != -1){ + isOk = true; + } + if(fileName.lastIndexOf(".JPG") != -1){ + isOk = true; + } + if(fileName.lastIndexOf(".png") != -1){ + isOk = true; + } + if(fileName.lastIndexOf(".PNG") != -1){ + isOk = true; + } + if(fileName.lastIndexOf(".PPT") != -1){ + isOk = true; + } + if(fileName.lastIndexOf(".PPTX") != -1){ + isOk = true; + } + if (isOk) { + //其格式满足条件,无需提示 + return null; + } else { + return "请上传PDF、pdf、doc、docx、ppt、pptx、xls、xlsx、jpg、JPG、png、PNG、PPT、PPTX文件;"; + } + } + return null; + } + + /** + * 判断对象中属性值是否全为空 + * + * @param object + * @return + */ + public static boolean checkObjAllFieldsIsNull(Object object) { + if (null == object) { + return true; + } + + try { + for (Field f : object.getClass().getDeclaredFields()) { + f.setAccessible(true); + + if (f.get(object) != null && StringUtils.isNotBlank(f.get(object).toString())) { + return false; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return true; + } + + + public static String isUserAgent(String fileName, HttpServletRequest request) throws UnsupportedEncodingException { + String userAgent = request.getHeader(USERAGENT); + if (userAgent.contains(EDGE)) { + //其他浏览器 + fileName = URLEncoder.encode(fileName, UTF8); + //google,火狐浏览器 + } else if (userAgent.contains(CHROME) || userAgent.contains(FIREFOX)) { + fileName = new String((fileName).getBytes(UTF8), ISO88591); + } else { + //其他浏览器 + fileName = URLEncoder.encode(fileName, UTF8); + } + return fileName; + } + + public static boolean checkHeader(Sheet sheet, String names) throws IOException { + Row row = sheet.getRow(0); + List modelNamesList = new ArrayList<>(); + for (int i = 0; i < row.getPhysicalNumberOfCells(); i++) { + if (org.apache.commons.lang.StringUtils.isNotBlank(row.getCell(i).getStringCellValue())) { + modelNamesList.add(row.getCell(i).getStringCellValue()); + } + } + if (org.apache.commons.lang.StringUtils.join(modelNamesList, ',').equals(names)) { + return true; + } + return false; + } + + public static String getCellString(Cell cell) { + if (cell == null){ + return ""; + } + if (String.valueOf(cell).endsWith(".0")) { + return StringUtils.removeEnd(String.valueOf(cell.getNumericCellValue()), ".0"); + } + if (String.valueOf(cell).contains(".")) { + cell.setCellType(CellType.NUMERIC); + return String.valueOf(cell.getNumericCellValue()); + } + return cell.getStringCellValue(); + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/ExportTempUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/ExportTempUtil.java new file mode 100644 index 00000000..7777fbf6 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/ExportTempUtil.java @@ -0,0 +1,86 @@ +package com.adc.da.utils.util; + +import cn.hutool.core.util.ZipUtil; +import com.adc.da.common.ReadExcel; +import com.adc.da.exception.AdcDaBaseException; +import com.adc.da.util.UUIDUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.util.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.OutputStream; + +/** + * @Description: + * @Author: super_liu + * date: 2021/3/4 13:32 + */ +public class ExportTempUtil { + + private static final Logger logger = LoggerFactory.getLogger(ExportTempUtil.class); + + public static void exportZipTemp (String filePath, String exportName, String header, HttpServletResponse response, HttpServletRequest request) { + OutputStream os = null; + OutputStream excelOS = null; + HSSFWorkbook workbook = new HSSFWorkbook(); + try{ + //创建临时文件夹 + String fileNowPath = filePath + "/tempZip/" + UUIDUtils.randomUUID20() + "/" + exportName; + File nowFile = new File(fileNowPath); + if (nowFile.exists()){ + nowFile.delete(); + } + nowFile.mkdirs(); + String fileName = "导入模板.xls"; + HSSFSheet sheetItems = workbook.createSheet("模板"); + sheetItems.setDefaultColumnWidth(16); + HSSFCellStyle cellStyle =workbook.createCellStyle(); + cellStyle.setWrapText(true); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + Row rowHeader = sheetItems.createRow(0);//开始创建标题行 + if (StringUtils.isNotBlank(header)) { + String[] headerArr = header.split(","); + for (int i=0;i < headerArr.length; i++) { + rowHeader.createCell(i).setCellValue(headerArr[i]); + } + } + String repFileName = fileName.replaceAll("/","_"); + excelOS = new FileOutputStream(fileNowPath + "/" + repFileName); + response.setHeader("Content-Disposition", + "attachment; filename=\""+ ReadExcel.encodeFileName(exportName+".zip", request) +"\""); + response.setContentType("application/force-download"); + response.flushBuffer(); + os = response.getOutputStream(); + workbook.write(excelOS); + excelOS.flush(); + excelOS.close(); + ZipUtil.zip(fileNowPath,fileNowPath+".zip"); + FileInputStream fis = new FileInputStream(fileNowPath+".zip"); + int len = 0; + while ((len = fis.read()) != -1) { + os.write(len); + } + os.flush(); + os.close(); // 后开先关 + fis.close(); // 先开后关 + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AdcDaBaseException("下载文件失败,请重试"); + } finally { + IOUtils.closeQuietly(os); + IOUtils.closeQuietly(excelOS); + } + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java new file mode 100644 index 00000000..ddfe9cfa --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java @@ -0,0 +1,141 @@ +package com.adc.da.utils.util; + +import com.adc.da.util.LoginUserUtil; +import com.adc.da.util.UUIDUtils; +import org.apache.commons.lang.StringUtils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; +import java.sql.Clob; +import java.sql.SQLException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * @Description: 处理各类型字段 + * @Author: super_liu + * date: 2021/6/1 9:37 + */ +public class FieldConvertUtil { + + public static void main(String[] args) { + } + + public static String mustFields = "id,stand_id,valid_flag,creation_user,creation_time,modify_time"; // 自定义属性表中必须字段 + + public static String mustFieldsLaws = "id,laws_id,valid_flag,creation_user,creation_time,modify_time"; // 自定义属性表中必须字段 + + public static String exportBaseFieldNames = "适用区域,重要度,标准类别,标准编号,标准年份,中文名称,英文名称," + + "标准状态,发布日期,文本说明"; // 导出基础表字段 //删除 实施日期 2021-05-28 + + public static String exportBaseFieldNamesForeign = "重要度,标准类别,标准编号,标准年份/系列,中文名称,英文名称," + + "标准状态,发布日期,文本说明"; // 导出基础表字段 + + public static String exportAttrFieldNamesInland = "归口管理部门,发布机构,工作组信息,我司参与深度,适用车辆类型,要求类型," + + "标签,发布稿(必读),增补件(必读),报批稿,送审稿,征求意见稿,草案,相关资料,新车型实施日期(文本),在产车实施日期(文本)," + + "EOP实施日期(文本),责任部门,相关部门,SVPPS,FO,项目评估角色,法规维护人,代替标准编号," + + "对应其他标准,文字描述,引用标准,被引用标准,覆盖关系"; + + public static String exportAttrFieldNamesForeign = "适用车辆类型,要求类型," + + "标签,发布稿(必读),增补件(必读),报批稿,送审稿,征求意见稿,草案,相关资料,新车型实施日期(文本),在产车实施日期(文本)," + + "EOP实施日期(文本),责任部门,相关部门,SVPPS,FO,项目评估角色,法规维护人,代替标准编号," + + "对应其他标准,文字描述,等效标准,引用标准,被引用标准,覆盖关系"; + + public static String exportBaseFieldNamesLaws = "政策编号,中文名称,英文名称," + + "政策状态,适用区域,重要度,代替政策编号,发布日期"; + + public static String exportAttrFieldNamesLaws = "适用车辆类型,要求类型," + + "个性化标签,政策文本,过程稿件,新车型实施日期(文本),在产车实施日期(文本),EOP实施日期(文本),SVPPS," + + "相关部门,责任部门,FO,维护工程师,归口管理部门,发布机构,我司是否参与,相关资料"; + + public static String exportBaseFieldNamesBuss = "企标编号,中文名称,英文名称,标准状态,发布日期,标准实施日期," + + "代替企标编号,被代替企标编号"; + + public static String exportAttrFieldNamesBuss = "SVPPS,规范性引用文件,废止日期,复审日期,密级,授权,相关部门," + + "需会签部门,起草部门,主要起草人,起草分标委,企标文本,过程文本"; + + public static String exportBaseFieldNamesBussRecords = "标准编号,标准名称,发布日期,实施日期,标准状态,项目名称," + + "代替标准编号,公开状态,产品类型,能源类型,企标备案文件,发布版文件,其他备案文件"; + + public static String exportBaseFieldNamesSarSarAccess = "标准号,中文名称,英文名称,新车型实施日期(项目)," + + "在产车实施日期(项目),EOP实施日期(项目),实施说明,认证交付物,认证对象,监管类型,适用车辆类型,责任部门,相关部门,FO,项目评估角色," + + "文本说明,标签,要求类型,清单类型,入库模块"; + + /*** + * @Description: Clob类型 转String + * @Author: super_liu + * @Date: 2021/6/1 13:49 + * @Param: [clob] + * @Return: java.lang.String + */ + public static String ClobToString(Clob clob) throws SQLException, IOException { + String ret = ""; + Reader read= clob.getCharacterStream(); + BufferedReader br = new BufferedReader(read); + String s = br.readLine(); + StringBuffer sb = new StringBuffer(); + while (s != null) { + sb.append(s); + s = br.readLine(); + } + ret = sb.toString(); + if(br != null){ + br.close(); + } + if(read != null){ + read.close(); + } + return ret; + } + + /*** + * @Description: 向数据库存储时,处理时间类型数据 + * @Author: super_liu + * @Date: 2021/6/1 13:51 + * @Param: [time] + * @Return: java.lang.String + */ + public static String changeTimeValue (String timeStr) { + if (StringUtils.isNotBlank(timeStr)) { + timeStr = "str_to_date('" + timeStr + "','%Y-%m-%d %H:%i:%s')"; + } else { + timeStr = "null"; + } + return timeStr; + } + + /** + * 数据库中的时间格式转换成字符串格式 + * @param time + * @param strFormat + * @return + */ + public static String dateToStr(java.sql.Timestamp time, String strFormat) { + DateFormat df = new SimpleDateFormat(strFormat); + String str = ""; + if (time != null) { + str = df.format(time); + } + return str; + } + + /*** + * @Description: 自定义属性表中必须字段值 + * @Author: super_liu + * @Date: 2021/6/1 14:14 + * @Param: [id] + * @Return: java.lang.String + */ + public static String mustValues (String id) { + String mustValue = "'"+ UUIDUtils.randomUUID20() + "','" + id + "','0','" + + LoginUserUtil.getUserId() + "'"; + Date date = new Date(); + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String nowTime = sf.format(date); + String timeValue = "," + changeTimeValue(nowTime); + mustValue += timeValue + timeValue; + return mustValue; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/InitStandAttrUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/InitStandAttrUtil.java new file mode 100644 index 00000000..419338c0 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/InitStandAttrUtil.java @@ -0,0 +1,221 @@ +package com.adc.da.utils.util; + +import com.adc.da.common.SarTypeEnum; +import com.adc.da.common.StandAttrTypeEnum; +import com.adc.da.slrs.sarStandAttrDetails.entity.SarStandAttrDetails; +import com.adc.da.slrs.sarStandAttrDetails.page.SarStandAttrDetailsEOPage; +import com.adc.da.slrs.sarStandAttrDetails.service.ISarStandAttrDetailsService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description: 启动项目时加载标准属性信息 + * @Author: super_liu + * date: 2020/9/7 10:54 + */ + +@Component +public class InitStandAttrUtil implements ApplicationRunner { + + private static final Logger logger = LoggerFactory.getLogger(InitStandAttrUtil.class); + + @Autowired + private ISarStandAttrDetailsService sarStandAttrDetailsEOService; + + private final static List standTypeList = new ArrayList<>(); + private final static List lawsTypeList = new ArrayList<>(); + public final static List standStateList = new ArrayList<>(); + static { + standTypeList.add(SarTypeEnum.STAND.getValue()); + standTypeList.add(SarTypeEnum.INLAND_STAND.getValue()); + standTypeList.add(SarTypeEnum.FOREIGN_STAND.getValue()); + lawsTypeList.add(SarTypeEnum.LAWS.getValue()); + lawsTypeList.add(SarTypeEnum.INLAND_LAWS.getValue()); + lawsTypeList.add(SarTypeEnum.FOREIGN_LAWS.getValue()); + standStateList.add("DRAFT"); + standStateList.add("ADVICE"); + standStateList.add("RADYSUBMIT"); + standStateList.add("SUBMIT"); + standStateList.add("FJNVYX9Q7J"); + standStateList.add("ZTJJSS"); + standStateList.add("TOVOID"); + standStateList.add("ZTXXYX"); + standStateList.add("5E5Z3CELX6"); + standStateList.add("N5KLTFLNRC"); + } + + // 标准属性字段信息 + public static String queryField = ""; //所有属性表需要查询的字段以逗号分隔 + public static String queryFieldNames = ""; //所有属性表需要查询的字段名以逗号分隔 + public static List queryFieldList = new ArrayList<>(); //所有属性表需要查询的字段 + public static List selectionFieldList = new ArrayList<>(); // 属性表下拉选项类型字段 + public static List fileFieldList = new ArrayList<>(); // 属性表文件类型字段 + public static List clobFieldList = new ArrayList<>(); // 属性表clob类型字段 + public static List timeFieldList = new ArrayList<>(); // 属性表日期类型字段 + public static List multiTimeFieldList = new ArrayList<>(); // 属性表多个日期类型字段 + public static List numFieldList = new ArrayList<>(); // 属性表数字类型字段 + public static List standInlandAttrFieldList = new ArrayList<>(); // 全部国内标准字段属性 + public static List standForeignAttrFieldList = new ArrayList<>(); // 全部海外标准字段属性 + public static Map selectFieldMap = new HashMap<>(); // 下拉属性字段及选项值 + + // 政策属性字段信息 + public static String queryFieldLaws = ""; //所有属性表需要查询的字段以逗号分隔 + public static String queryFieldNamesLaws = ""; //所有属性表需要查询的字段名以逗号分隔 + public static List queryFieldListLaws = new ArrayList<>(); //所有属性表需要查询的字段 + public static List selectionFieldListLaws = new ArrayList<>(); // 属性表下拉选项类型字段 + public static List fileFieldListLaws = new ArrayList<>(); // 属性表文件类型字段 + public static List clobFieldListLaws = new ArrayList<>(); // 属性表clob类型字段 + public static List timeFieldListLaws = new ArrayList<>(); // 属性表日期类型字段 + public static List multiTimeFieldListLaws = new ArrayList<>(); // 属性表多个日期类型字段 + public static List numFieldListLaws = new ArrayList<>(); // 属性表数字类型字段 + public static List lawsInlandAttrFieldList = new ArrayList<>(); // 属性表数字类型字段 + public static List lawsForeignAttrFieldList = new ArrayList<>(); // 全部政策字段属性 + public static Map selectFieldMapLaws = new HashMap<>(); // 下拉属性字段及选项值 + + // 企标属性字段信息 + public static String queryFieldBuss = ""; //所有属性表需要查询的字段以逗号分隔 + public static String queryFieldNamesBuss = ""; //所有属性表需要查询的字段名以逗号分隔 + public static List queryFieldListBuss = new ArrayList<>(); //所有属性表需要查询的字段 + public static List selectionFieldListBuss = new ArrayList<>(); // 属性表下拉选项类型字段 + public static List fileFieldListBuss = new ArrayList<>(); // 属性表文件类型字段 + public static List clobFieldListBuss = new ArrayList<>(); // 属性表clob类型字段 + public static List timeFieldListBuss = new ArrayList<>(); // 属性表日期类型字段 + public static List multiTimeFieldListBuss = new ArrayList<>(); // 属性表多个日期类型字段 + public static List numFieldListBuss = new ArrayList<>(); // 属性表数字类型字段 + public static List bussAttrFieldList = new ArrayList<>(); // 全部企标字段属性 + public static Map selectFieldMapBuss = new HashMap<>(); // 下拉属性字段及选项值 + + @Override + public void run(ApplicationArguments args) throws Exception { + logger.info("项目启动时加载--查询标准属性类!"); + // 属性表需要查询的字段 + StringBuilder fieldInfoBuilder = new StringBuilder(); + StringBuilder fieldInfoBuilderLaws = new StringBuilder(); + StringBuilder fieldInfoBuilderBuss = new StringBuilder(); + StringBuilder fieldInfoNameBuilder = new StringBuilder(); + StringBuilder fieldInfoNameBuilderLaws = new StringBuilder(); + StringBuilder fieldInfoNameBuilderBuss = new StringBuilder(); + QueryWrapper qw = new QueryWrapper(); + List getDetailsList = sarStandAttrDetailsEOService.list(qw); + if (getDetailsList != null && !getDetailsList.isEmpty()) { + logger.info("项目启动时加载--查询标准属性类--查询到" + getDetailsList.size() + "条属性字段数据!"); + for (SarStandAttrDetails detailsEO : getDetailsList) { + String sarType = detailsEO.getSarType(); + String attrType = detailsEO.getAttrType(); + if (standTypeList.contains(sarType)) { + if (!SarTypeEnum.FOREIGN_STAND.getValue().equals(sarType)) { + standInlandAttrFieldList.add(detailsEO); + } + if (!SarTypeEnum.INLAND_STAND.getValue().equals(sarType)) { + standForeignAttrFieldList.add(detailsEO); + } + fieldInfoBuilder.append(detailsEO.getAttrField() + ","); + fieldInfoNameBuilder.append(detailsEO.getAttrName() + ","); + queryFieldList.add(detailsEO.getAttrField()); + if (StandAttrTypeEnum.SELECT_OPTION.getValue().equals(attrType) || StandAttrTypeEnum.SEL_OPTS.getValue().equals(attrType)) { + selectionFieldList.add(detailsEO.getAttrField()); + selectFieldMap.put(detailsEO.getAttrField(),detailsEO.getSelVal()); + } else if (StandAttrTypeEnum.FILE.getValue().equals(attrType)) { + fileFieldList.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.TEXTAREA.getValue().equals(attrType) && detailsEO.getAttrLen() >= 4000) { + clobFieldList.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.DATE_PICKER.getValue().equals(attrType)) { + timeFieldList.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.DATE_PIC_OPTS.getValue().equals(attrType)) { + multiTimeFieldList.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.INPUT_NUM.getValue().equals(attrType)) { + numFieldList.add(detailsEO.getAttrField()); + } + } else if (lawsTypeList.contains(sarType)) { + if (!SarTypeEnum.FOREIGN_LAWS.getValue().equals(sarType)) { + lawsInlandAttrFieldList.add(detailsEO); + } + if (!SarTypeEnum.INLAND_LAWS.getValue().equals(sarType)) { + lawsForeignAttrFieldList.add(detailsEO); + } + fieldInfoBuilderLaws.append(detailsEO.getAttrField() + ","); + fieldInfoNameBuilderLaws.append(detailsEO.getAttrName() + ","); + queryFieldListLaws.add(detailsEO.getAttrField()); + if (StandAttrTypeEnum.SELECT_OPTION.getValue().equals(attrType) || StandAttrTypeEnum.SEL_OPTS.getValue().equals(attrType)) { + selectionFieldListLaws.add(detailsEO.getAttrField()); + selectFieldMapLaws.put(detailsEO.getAttrField(),detailsEO.getSelVal()); + } else if (StandAttrTypeEnum.FILE.getValue().equals(attrType)) { + fileFieldListLaws.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.TEXTAREA.getValue().equals(attrType) && detailsEO.getAttrLen() >= 4000) { + clobFieldListLaws.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.DATE_PICKER.getValue().equals(attrType)) { + timeFieldListLaws.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.DATE_PIC_OPTS.getValue().equals(attrType)) { + multiTimeFieldListLaws.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.INPUT_NUM.getValue().equals(attrType)) { + numFieldListLaws.add(detailsEO.getAttrField()); + } + } else if (SarTypeEnum.BUSS.getValue().equals(sarType)) { + bussAttrFieldList.add(detailsEO); + fieldInfoBuilderBuss.append(detailsEO.getAttrField() + ","); + fieldInfoNameBuilderBuss.append(detailsEO.getAttrName() + ","); + queryFieldListBuss.add(detailsEO.getAttrField()); + if (StandAttrTypeEnum.SELECT_OPTION.getValue().equals(attrType) || StandAttrTypeEnum.SEL_OPTS.getValue().equals(attrType)) { + selectionFieldListBuss.add(detailsEO.getAttrField()); + selectFieldMapBuss.put(detailsEO.getAttrField(),detailsEO.getSelVal()); + } else if (StandAttrTypeEnum.FILE.getValue().equals(attrType)) { + fileFieldListBuss.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.TEXTAREA.getValue().equals(attrType) && detailsEO.getAttrLen() >= 4000) { + clobFieldListBuss.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.DATE_PICKER.getValue().equals(attrType)) { + timeFieldListBuss.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.DATE_PIC_OPTS.getValue().equals(attrType)) { + multiTimeFieldListBuss.add(detailsEO.getAttrField()); + } else if (StandAttrTypeEnum.INPUT_NUM.getValue().equals(attrType)) { + numFieldListBuss.add(detailsEO.getAttrField()); + } + } + } + queryField = fieldInfoBuilder.toString(); + queryFieldLaws = fieldInfoBuilderLaws.toString(); + queryFieldBuss = fieldInfoBuilderBuss.toString(); + if (StringUtils.isNotBlank(queryField)) { + queryField = queryField.substring(0,queryField.length()-1); + } + if (StringUtils.isNotBlank(queryFieldLaws)) { + queryFieldLaws = queryFieldLaws.substring(0,queryFieldLaws.length()-1); + } + if (StringUtils.isNotBlank(queryFieldBuss)) { + queryFieldBuss = queryFieldBuss.substring(0,queryFieldBuss.length()-1); + } + logger.info("项目启动时加载--查询标准属性类--查询到属性字段为:" + queryField); + logger.info("项目启动时加载--查询政策属性类--查询到属性字段为:" + queryFieldLaws); + logger.info("项目启动时加载--查询企标属性类--查询到属性字段为:" + queryFieldBuss); + queryFieldNames = fieldInfoNameBuilder.toString(); + queryFieldNamesLaws = fieldInfoNameBuilderLaws.toString(); + queryFieldNamesBuss = fieldInfoNameBuilderBuss.toString(); + if (StringUtils.isNotBlank(queryFieldNames)) { + queryFieldNames = queryFieldNames.substring(0,queryFieldNames.length()-1); + } + if (StringUtils.isNotBlank(queryFieldNamesLaws)) { + queryFieldNamesLaws = queryFieldNamesLaws.substring(0,queryFieldNamesLaws.length()-1); + } + if (StringUtils.isNotBlank(queryFieldNamesBuss)) { + queryFieldNamesBuss = queryFieldNamesBuss.substring(0,queryFieldNamesBuss.length()-1); + } + logger.info("项目启动时加载--查询标准属性类--查询到属性字段名称为:" + queryFieldNames); + logger.info("项目启动时加载--查询政策属性类--查询到属性字段名称为:" + queryFieldNamesLaws); + logger.info("项目启动时加载--查询企标属性类--查询到属性字段名称为:" + queryFieldNamesBuss); + } else { + logger.error("项目启动时加载--查询标准属性类--未查询到属性字段数据!"); + } + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/ObjectToMapUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/ObjectToMapUtil.java new file mode 100644 index 00000000..d50ec5a5 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/ObjectToMapUtil.java @@ -0,0 +1,32 @@ +package com.adc.da.utils.util; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; + +import static cn.hutool.core.map.MapUtil.removeNullValue; + +public class ObjectToMapUtil { + + public static Map objectToMap(Object object){ + Map dataMap = new HashMap<>(); + Class clazz = object.getClass(); + for (Field field : clazz.getDeclaredFields()) { + try { + field.setAccessible(true); + dataMap.put(field.getName(),field.get(object)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + return dataMap; + } + + /** + * 移除map中空key或者value空值 + * @param map + */ + public static void removeNullEntry(Map map){ + removeNullValue(map); + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/POIReadExcelToHtml.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/POIReadExcelToHtml.java new file mode 100644 index 00000000..22c9f68b --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/POIReadExcelToHtml.java @@ -0,0 +1,651 @@ +package com.adc.da.utils.util; + + +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ooxml.POIXMLDocumentPart; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.*; +import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker; + +import java.io.*; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description: + * @Author: super_liu + * date: 2020/5/11 10:39 + */ +public class POIReadExcelToHtml { + private static Map map[]; + + /** + * 程序入口方法(将excel文件读取成字符串) + * @param isWithStyle 是否需要表格样式 包含 字体 颜色 边框 对齐方式 + * @return ...
字符串 + */ + public static String readExcelToHtml(Workbook xWb, int sheetNum, boolean isWithStyle){ + String htmlExcel = null; + htmlExcel = readWorkbook(xWb,sheetNum,isWithStyle); + /*try { +// Workbook wb = WorkbookFactory.create(is); + + } catch (Exception e) { + e.printStackTrace(); + }finally{ + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + }*/ + return htmlExcel; + } + + /** + * 根据excel的版本分配不同的读取方法进行处理 + * @param wb + * @param isWithStyle + * @return + */ + private static String readWorkbook(Workbook wb, int sheetNum, boolean isWithStyle){ + String htmlExcel = ""; + if (wb instanceof XSSFWorkbook) { + XSSFWorkbook xWb = (XSSFWorkbook) wb; + htmlExcel = getExcelInfo(xWb,sheetNum, isWithStyle); + }else if(wb instanceof HSSFWorkbook){ + HSSFWorkbook hWb = (HSSFWorkbook) wb; + htmlExcel = getExcelInfo(hWb,sheetNum, isWithStyle); + } + return htmlExcel; + } + + /** + * 读取excel成string + * @param wb + * @param isWithStyle + * @return + */ + public static String getExcelInfo(Workbook wb, int sheetNum, boolean isWithStyle){ + + StringBuffer sb = new StringBuffer(); + Sheet sheet = wb.getSheetAt(sheetNum);//获取第一个Sheet的内容 + // map等待存储excel图片 +// Map sheetIndexPicMap = getSheetPictrues(0, sheet, wb); + //临时保存位置,正式环境根据部署环境存放其他位置 +// try { +// if(sheetIndexPicMap != null) +// printImg(sheetIndexPicMap); +// } catch (IOException e) { +// e.printStackTrace(); +// } + + //读取excel拼装html + int lastRowNum = sheet.getLastRowNum(); + map = getRowSpanColSpanMap(sheet); + sb.append(""); + Row row = null; //兼容 + Cell cell = null; //兼容 + + for (int rowNum = sheet.getFirstRowNum(); rowNum <= lastRowNum; rowNum ++) { + if(rowNum > 1000) break; + row = sheet.getRow(rowNum); + + int lastColNum = POIReadExcelToHtml.getColsOfTable(sheet)[0]; + int rowHeight = POIReadExcelToHtml.getColsOfTable(sheet)[1]; + + if(null != row) { + lastColNum = row.getLastCellNum(); + rowHeight = row.getHeight(); + } + + if (null == row) { + sb.append(""); + continue; + }else if(row.getZeroHeight()){ + continue; + }else if(0 == rowHeight){ + continue; //针对jxl的隐藏行(此类隐藏行只是把高度设置为0,单getZeroHeight无法识别) + } + sb.append(""); + + for (int colNum = 0; colNum < lastColNum; colNum ++) { + if(sheet.isColumnHidden(colNum)) continue; + String imageRowNum = "0_" + rowNum + "_" + colNum; + String imageHtml = ""; + cell = row.getCell(colNum); + /*if ((sheetIndexPicMap != null && !sheetIndexPicMap.containsKey(imageRowNum) || sheetIndexPicMap == null) && cell == null) { //特殊情况 空白的单元格会返回null+//判断该单元格是否包含图片,为空时也可能包含图片 + sb.append(""); + continue; + } + if(sheetIndexPicMap!=null && sheetIndexPicMap.containsKey(imageRowNum)){ + //待修改路径 + String imagePath = "D:\\pic" + imageRowNum + ".jpeg"; + + imageHtml = ""; + }*/ + String stringValue = getCellValue(cell); + if (map[0].containsKey(rowNum + "," + colNum)) { + String pointString = (String)map[0].get(rowNum + "," + colNum); + int bottomeRow = Integer.valueOf(pointString.split(",")[0]); + int bottomeCol = Integer.valueOf(pointString.split(",")[1]); + int rowSpan = bottomeRow - rowNum + 1; + int colSpan = bottomeCol - colNum + 1; + if(map[2].containsKey(rowNum + "," + colNum)){ + rowSpan = rowSpan - (Integer)map[2].get(rowNum + "," + colNum); + } + sb.append(""); + } + sb.append(""); + continue; + } + sb.append("
3 && map[3].containsKey(rowNum + "," + colNum)){ + //此类数据首行被隐藏,value为空,需使用其他方式获取值 + stringValue = getMergedRegionValue(sheet, rowNum, colNum); + } + } else if (map[1].containsKey(rowNum + "," + colNum)) { + map[1].remove(rowNum + "," + colNum); + continue; + } else { + sb.append(""); +// if(sheetIndexPicMap!=null && sheetIndexPicMap.containsKey(imageRowNum)) sb.append(imageHtml); + if (stringValue == null || "".equals(stringValue.trim())) { + sb.append(" "); + } else { + // 将ascii码为160的空格转换为html下的空格( ) + sb.append(stringValue.replace(String.valueOf((char) 160)," ")); + } + sb.append("
"); + return sb.toString(); + } + + /** + * 分析excel表格,记录合并单元格相关的参数,用于之后html页面元素的合并操作 + * @param sheet + * @return + */ + private static Map[] getRowSpanColSpanMap(Sheet sheet) { + Map map0 = new HashMap(); //保存合并单元格的对应起始和截止单元格 + Map map1 = new HashMap(); //保存被合并的那些单元格 + Map map2 = new HashMap(); //记录被隐藏的单元格个数 + Map map3 = new HashMap(); //记录合并了单元格,但是合并的首行被隐藏的情况 + int mergedNum = sheet.getNumMergedRegions(); + CellRangeAddress range = null; + Row row = null; + for (int i = 0; i < mergedNum; i++) { + range = sheet.getMergedRegion(i); + int topRow = range.getFirstRow(); + int topCol = range.getFirstColumn(); + int bottomRow = range.getLastRow(); + int bottomCol = range.getLastColumn(); + /** + * 此类数据为合并了单元格的数据 + * 1.处理隐藏(只处理行隐藏,列隐藏poi已经处理) + */ + if(topRow != bottomRow){ + int zeroRoleNum = 0; + int tempRow = topRow; + for(int j = topRow; j <= bottomRow; j ++){ + row = sheet.getRow(j); + if(row.getZeroHeight() || row.getHeight() == 0){ + if(j == tempRow){ + //首行就进行隐藏,将rowTop向后移 + tempRow ++; + continue;//由于top下移,后面计算rowSpan时会扣除移走的列,所以不必增加zeroRoleNum; + } + zeroRoleNum ++; + } + } + if(tempRow != topRow){ + map3.put(tempRow + "," + topCol,topRow + "," + topCol); + topRow = tempRow; + } + if(zeroRoleNum!=0) map2.put(topRow + "," + topCol, zeroRoleNum); + } + map0.put(topRow + "," + topCol, bottomRow + "," + bottomCol); + int tempRow = topRow; + while (tempRow <= bottomRow) { + int tempCol = topCol; + while (tempCol <= bottomCol) { + map1.put(tempRow + "," + tempCol, topRow + "," + topCol); + tempCol++; + } + tempRow++; + } + map1.remove(topRow + "," + topCol); + } + Map[] map = { map0, map1 ,map2,map3}; + System.err.println(map0); + return map; + } + + + /** + * 获取合并单元格的值 + * @param sheet + * @param row + * @param column + * @return + */ + public static String getMergedRegionValue(Sheet sheet, int row, int column){ + int sheetMergeCount = sheet.getNumMergedRegions(); + for(int i = 0 ; i < sheetMergeCount ; i++){ + CellRangeAddress ca = sheet.getMergedRegion(i); + int firstColumn = ca.getFirstColumn(); + int lastColumn = ca.getLastColumn(); + int firstRow = ca.getFirstRow(); + int lastRow = ca.getLastRow(); + + if(row >= firstRow && row <= lastRow){ + + if(column >= firstColumn && column <= lastColumn){ + Row fRow = sheet.getRow(firstRow); + Cell fCell = fRow.getCell(firstColumn); + + return getCellValue(fCell) ; + } + } + } + return null ; + } + /** + * 获取表格单元格Cell内容 + * @param cell + * @return + */ + private static String getCellValue(Cell cell) { + String result = new String(); + switch (cell.getCellType()) { + case NUMERIC:// 数字类型 + if (HSSFDateUtil.isCellDateFormatted(cell)) {// 处理日期格式、时间格式 + SimpleDateFormat sdf = null; + if (cell.getCellStyle().getDataFormat() == HSSFDataFormat.getBuiltinFormat("h:mm")) { + sdf = new SimpleDateFormat("HH:mm"); + } else {// 日期 + sdf = new SimpleDateFormat("yyyy-MM-dd"); + } + Date date = cell.getDateCellValue(); + result = sdf.format(date); + } else if (cell.getCellStyle().getDataFormat() == 58) { + // 处理自定义日期格式:m月d日(通过判断单元格的格式id解决,id的值是58) + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + double value = cell.getNumericCellValue(); + Date date = org.apache.poi.ss.usermodel.DateUtil + .getJavaDate(value); + result = sdf.format(date); + } else { + double value = cell.getNumericCellValue(); + CellStyle style = cell.getCellStyle(); + DecimalFormat format = new DecimalFormat(); + String temp = style.getDataFormatString(); + // 单元格设置成常规 + if (temp.equals("General")) { + format.applyPattern("#"); + } + result = format.format(value); + } + break; + case STRING:// String类型 + result = cell.getRichStringCellValue().toString(); + break; + case BLANK: + result = ""; + break; + default: + result = ""; + break; + } + return result; + } + + /** + * 处理表格样式 + * @param wb + * @param sheet + * @param cell + * @param sb + */ + private static void dealExcelStyle(Workbook wb, Sheet sheet, Cell cell, StringBuffer sb){ + CellStyle cellStyle = cell.getCellStyle(); + if (cellStyle != null) { + + HorizontalAlignment alignment = cellStyle.getAlignment(); + sb.append("align='" + convertAlignToHtml(alignment) + "' ");//单元格内容的水平对齐方式 + VerticalAlignment verticalAlignment = cellStyle.getVerticalAlignment(); + sb.append("valign='"+ convertVerticalAlignToHtml(verticalAlignment)+ "' ");//单元格中内容的垂直排列方式 + + if (wb instanceof XSSFWorkbook) { + + XSSFFont xf = ((XSSFCellStyle) cellStyle).getFont(); + //short boldWeight = Font.BOLDWEIGHT_BOLD; + sb.append("style='"); + //sb.append("font-weight:" + boldWeight + ";"); // 字体加粗 + sb.append("font-size: " + xf.getFontHeight() / 2 + "%;"); // 字体大小 + + int topRow = cell.getRowIndex(),topColumn = cell.getColumnIndex(); + if(map[0].containsKey(topRow+","+topColumn)){//该单元格为合并单元格,宽度需要获取所有单元格宽度后合并 + String value = (String)map[0].get(topRow+","+topColumn); + String[] ary = value.split(","); + int bottomColumn = Integer.parseInt(ary[1]); + if(topColumn!=bottomColumn){//合并列,需要计算相应宽度 + int columnWidth = 0; + for(int i=topColumn;i<=bottomColumn;i++){ + columnWidth += sheet.getColumnWidth(i); + } + sb.append("width:" + columnWidth/256*xf.getFontHeight()/20 + "pt;"); + }else{ + int columnWidth = sheet.getColumnWidth(cell.getColumnIndex()) ; + sb.append("width:" + columnWidth/256*xf.getFontHeight()/20 + "pt;"); + } + }else{ + int columnWidth = sheet.getColumnWidth(cell.getColumnIndex()) ; + sb.append("width:" + columnWidth/256*xf.getFontHeight()/20 + "pt;"); + } + + XSSFColor xc = xf.getXSSFColor(); + if (xc != null && !"".equals(xc.toString())) { + sb.append("color:#" + xc.getARGBHex().substring(2) + ";"); // 字体颜色 + } + + XSSFColor bgColor = (XSSFColor) cellStyle.getFillForegroundColorColor(); + if (bgColor != null && !"".equals(bgColor.toString())) { + sb.append("background-color:#" + bgColor.getARGBHex().substring(2) + ";"); // 背景颜色 + } + sb.append("border:solid #000000 1px;"); + // sb.append(getBorderStyle(0,cellStyle.getBorderTop(), ((XSSFCellStyle) cellStyle).getTopBorderXSSFColor())); + // sb.append(getBorderStyle(1,cellStyle.getBorderRight(), ((XSSFCellStyle) cellStyle).getRightBorderXSSFColor())); + // sb.append(getBorderStyle(2,cellStyle.getBorderBottom(), ((XSSFCellStyle) cellStyle).getBottomBorderXSSFColor())); + // sb.append(getBorderStyle(3,cellStyle.getBorderLeft(), ((XSSFCellStyle) cellStyle).getLeftBorderXSSFColor())); + }else if(wb instanceof HSSFWorkbook){ + HSSFFont hf = ((HSSFCellStyle) cellStyle).getFont(wb); + //short boldWeight = hf.getBoldweight(); + short fontColor = hf.getColor(); + sb.append("style='"); + + HSSFPalette palette = ((HSSFWorkbook) wb).getCustomPalette(); // 类HSSFPalette用于求的颜色的国际标准形式 + HSSFColor hc = palette.getColor(fontColor); + //sb.append("font-weight:" + boldWeight + ";"); // 字体加粗 + sb.append("font-size: " + hf.getFontHeight() / 2 + "%;"); // 字体大小 + String fontColorStr = convertToStardColor(hc); + if (fontColorStr != null && !"".equals(fontColorStr.trim())) { + sb.append("color:" + fontColorStr + ";"); // 字体颜色 + } + + int topRow = cell.getRowIndex(),topColumn = cell.getColumnIndex(); + if(map[0].containsKey(topRow + "," + topColumn)){//该单元格为合并单元格,宽度需要获取所有单元格宽度后合并 + String value = (String)map[0].get(topRow + "," + topColumn); + String[] ary = value.split(","); + int bottomColumn = Integer.parseInt(ary[1]); + if(topColumn != bottomColumn){//合并列,需要计算相应宽度 + int columnWidth = 0; + for(int i = topColumn; i <= bottomColumn; i++){ + columnWidth += sheet.getColumnWidth(i); + } + sb.append("width:" + columnWidth / 256 * hf.getFontHeight() / 20 + "pt;"); + }else{ + int columnWidth = sheet.getColumnWidth(cell.getColumnIndex()) ; + sb.append("width:" + columnWidth / 256 * hf.getFontHeight() / 20 + "pt;"); + } + }else{ + int columnWidth = sheet.getColumnWidth(cell.getColumnIndex()) ; + sb.append("width:" + columnWidth / 256 * hf.getFontHeight() / 20 + "pt;"); + } + + short bgColor = cellStyle.getFillForegroundColor(); + hc = palette.getColor(bgColor); + String bgColorStr = convertToStardColor(hc); + if (bgColorStr != null && !"".equals(bgColorStr.trim())) { + sb.append("background-color:" + bgColorStr + ";"); // 背景颜色 + } + sb.append("border:solid #000000 1px;"); + } + sb.append("' "); + } + } + + /** + * 单元格内容的水平对齐方式 + * @param alignment + * @return + */ + private static String convertAlignToHtml(HorizontalAlignment alignment) { + String align = "left"; + switch (alignment) { + case LEFT: + align = "left"; + break; + case CENTER: + align = "center"; + break; + case RIGHT: + align = "right"; + break; + default: + break; + } + return align; + } + + /** + * 单元格中内容的垂直排列方式 + * @param verticalAlignment + * @return + */ + private static String convertVerticalAlignToHtml(VerticalAlignment verticalAlignment) { + String valign = "middle"; + switch (verticalAlignment) { + case BOTTOM: + valign = "bottom"; + break; + case CENTER: + valign = "center"; + break; + case TOP: + valign = "top"; + break; + default: + break; + } + return valign; + } + + private static String convertToStardColor(HSSFColor hc) { + StringBuffer sb = new StringBuffer(""); + if (hc != null) { + if (IndexedColors.AUTOMATIC.index == hc.getIndex()) { + return null; + } + sb.append("#"); + for (int i = 0; i < hc.getTriplet().length; i ++) { + sb.append(fillWithZero(Integer.toHexString(hc.getTriplet()[i]))); + } + } + return sb.toString(); + } + + private static String fillWithZero(String str) { + if (str != null && str.length() < 2) { + return "0" + str; + } + return str; + } + + static String[] bordesr = {"border-top:", "border-right:", "border-bottom:", "border-left:"}; + static String[] borderStyles = {"solid ", "solid ", "solid ", "solid ", "solid ", "solid ", "solid ", "solid ", "solid ", "solid", "solid", "solid", "solid", "solid"}; + + @SuppressWarnings("unused") + private static String getBorderStyle(HSSFPalette palette , int b, short s, short t){ + if(s == 0) return bordesr[b] + borderStyles[s] + "#d0d7e5 1px;"; + String borderColorStr = convertToStardColor( palette.getColor(t)); + borderColorStr = borderColorStr == null || borderColorStr.length() < 1 ? "#000000" : borderColorStr; + return bordesr[b] + borderStyles[s] + borderColorStr + " 1px;"; + } + + @SuppressWarnings("unused") + private static String getBorderStyle(int b, short s, XSSFColor xc){ + if(s == 0)return bordesr[b] + borderStyles[s] + "#d0d7e5 1px;"; + if (xc != null && ! "".equals(xc)) { + String borderColorStr = xc.getARGBHex();//t.getARGBHex(); + borderColorStr=borderColorStr == null || borderColorStr.length() < 1 ? "#000000" : borderColorStr.substring(2); + return bordesr[b] + borderStyles[s]+borderColorStr+" 1px;"; + } + return ""; + } + + @SuppressWarnings("unused") + private static void writeFile(String content, String path) { + OutputStream os = null; + BufferedWriter bw = null; + try { + File file = new File(path); + os = new FileOutputStream(file); + bw = new BufferedWriter(new OutputStreamWriter(os,"GBK")); + bw.write(content); + } catch (FileNotFoundException fnfe) { + fnfe.printStackTrace(); + } catch (IOException ioe) { + ioe.printStackTrace(); + } finally { + try { + if (null != bw) + bw.close(); + if (null != os) + os.close(); + } catch (IOException ie) { + ie.printStackTrace(); + } + } + } + + + /** + * 获取Excel图片公共方法 + * @param sheetNum 当前sheet编号 + * @param sheet 当前sheet对象 + * @param workbook 工作簿对象 + * @return Map key:图片单元格索引(0_1_1)String,value:图片流PictureData + */ + public static Map getSheetPictrues(int sheetNum, Sheet sheet, Workbook workbook) { + if(workbook instanceof HSSFWorkbook){ + return getSheetPictrues03(sheetNum, (HSSFSheet) sheet, (HSSFWorkbook) workbook); + }else if(workbook instanceof XSSFWorkbook){ + return getSheetPictrues07(sheetNum, (XSSFSheet) sheet, (XSSFWorkbook) workbook); + }else{ + return null; + } + } + + /** + * 获取Excel2003图片 + * @param sheetNum 当前sheet编号 + * @param sheet 当前sheet对象 + * @param workbook 工作簿对象 + * @return Map key:图片单元格索引(0_1_1)String,value:图片流PictureData + * @throws IOException + */ + private static Map getSheetPictrues03(int sheetNum, + HSSFSheet sheet, HSSFWorkbook workbook) { + + Map sheetIndexPicMap = new HashMap(); + List pictures = workbook.getAllPictures(); + if (pictures.size() != 0) { + for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) { + HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor(); + shape.getLineWidth(); + if (shape instanceof HSSFPicture) { + HSSFPicture pic = (HSSFPicture) shape; + int pictureIndex = pic.getPictureIndex() - 1; + HSSFPictureData picData = pictures.get(pictureIndex); + String picIndex = String.valueOf(sheetNum) + "_" + + String.valueOf(anchor.getRow1()) + "_" + + String.valueOf(anchor.getCol1()); + sheetIndexPicMap.put(picIndex, picData); + } + } + return sheetIndexPicMap; + } else { + return null; + } + } + + /** + * 获取Excel2007图片 + * @param sheetNum 当前sheet编号 + * @param sheet 当前sheet对象 + * @param workbook 工作簿对象 + * @return Map key:图片单元格索引(0_1_1)String,value:图片流PictureData + */ + private static Map getSheetPictrues07(int sheetNum, + XSSFSheet sheet, XSSFWorkbook workbook) { + Map sheetIndexPicMap = new HashMap(); + + for (POIXMLDocumentPart dr : sheet.getRelations()) { + if (dr instanceof XSSFDrawing) { + XSSFDrawing drawing = (XSSFDrawing) dr; + List shapes = drawing.getShapes(); + for (XSSFShape shape : shapes) { + XSSFPicture pic = (XSSFPicture) shape; + XSSFClientAnchor anchor = pic.getPreferredSize(); + CTMarker ctMarker = anchor.getFrom(); + String picIndex = String.valueOf(sheetNum) + "_" + + ctMarker.getRow() + "_" + ctMarker.getCol(); + sheetIndexPicMap.put(picIndex, pic.getPictureData()); + } + } + } + + return sheetIndexPicMap; + } + + public static void printImg(List> sheetList) throws IOException { + for (Map map : sheetList) { + printImg(map); + } + } + + public static void printImg(Map map) throws IOException { + Object key[] = map.keySet().toArray(); + for (int i = 0; i < map.size(); i++) { + // 获取图片流 + PictureData pic = map.get(key[i]); + // 获取图片索引 + String picName = key[i].toString(); + // 获取图片格式 + String ext = pic.suggestFileExtension(); + + byte[] data = pic.getData(); + + FileOutputStream out = new FileOutputStream("D:\\pic" + picName + "." + ext); + out.write(data); + out.flush(); + out.close(); + } + } + + private static int[] getColsOfTable(Sheet sheet) { + int[] data = {0, 0}; + for (int i = sheet.getFirstRowNum(); i < sheet.getLastRowNum(); i++) { + if (null != sheet.getRow(i)) { + data[0] = sheet.getRow(i).getLastCellNum(); + data[1] = sheet.getRow(i).getHeight(); + } else + continue; + } + return data; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/SarAdvanceSearchUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/SarAdvanceSearchUtil.java new file mode 100644 index 00000000..7201ccae --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/SarAdvanceSearchUtil.java @@ -0,0 +1,81 @@ +package com.adc.da.utils.util; + +import com.adc.da.slrs.sarStandardsInfo.entity.SarAdvanceSearchVO; +import org.apache.commons.lang3.StringUtils; + +import java.util.Arrays; +import java.util.List; + +/** + * @Description: 根据前台传值,生成对应sql + * @Author: super_liu + * date: 2020/12/11 9:27 + */ +public class SarAdvanceSearchUtil { + + // 拼接sql语句 + public static String createSql (List searchVOList) { + String sqlInfo = ""; + StringBuilder sqlBuilder = new StringBuilder(); + if (searchVOList != null && !searchVOList.isEmpty()) { + for (SarAdvanceSearchVO searchVO : searchVOList) { + String sql = ""; + if (StringUtils.isNotBlank(searchVO.getValue())) { + if(searchVO.getValue().contains(",")){ + sql += searchVO.getConnect()+"("; + List list = Arrays.asList(searchVO.getValue().split(",")); + for(int i =0;i datas, String standType) { + Workbook workbook = new XSSFWorkbook(); + try { + standType += "_STAND"; + StringBuilder attrBud = new StringBuilder(); + List detailsEOList = new ArrayList<>(); + Map attrInfoMap = new HashMap<>(); + if (SarTypeEnum.INLAND_STAND.getValue().equals(standType)) { + detailsEOList = InitStandAttrUtil.standInlandAttrFieldList; + } else { + detailsEOList = InitStandAttrUtil.standForeignAttrFieldList; + } + for (SarStandAttrDetails detailsEO : detailsEOList) { + if (!InitStandAttrUtil.fileFieldList.contains(detailsEO.getAttrField())) { + attrBud.append(detailsEO.getAttrName() + ","); + attrInfoMap.put(detailsEO.getAttrName(),detailsEO.getAttrField()); + } + } + String header = FieldConvertUtil.exportBaseFieldNames + "," + attrBud.toString(); + if (SarTypeEnum.FOREIGN_STAND.getValue().equals(standType)) { + header = FieldConvertUtil.exportBaseFieldNamesForeign + "," + attrBud.toString(); + } + //创建工作表对象 + Sheet sheet = workbook.createSheet(); + // 创建头部 + createHeader(workbook,sheet,header); + // 创建数据 + createDatas(workbook,sheet,datas,header,attrInfoMap); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + return workbook; + } + + public static void createHeader(Workbook workbook, Sheet sheet, String header){ + CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象 + cellStyle.setAlignment(HorizontalAlignment.CENTER); + Row rowHeader = sheet.createRow(0);//开始创建标题行 + if (StringUtils.isNotBlank(header)) { + String[] headerArr = header.split(","); + for (int i=0;i < headerArr.length; i++) { + rowHeader.createCell(i).setCellValue(headerArr[i]); +// rowHeader.createCell(i).setCellStyle(cellStyle); + } + } + } + + public static void createDatas(Workbook workbook, Sheet sheet, List datas, + String header, Map attrInfoMap) throws Exception{ + CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象 + cellStyle.setAlignment(HorizontalAlignment.CENTER); + if (datas != null && !datas.isEmpty()) { + for (int i=0;i < datas.size(); i++) { + SarStandardsInfo sarStandardsInfoEO = datas.get(i); + Row row = sheet.createRow(i+1); + String[] headerArr = header.split(","); + int sheetNum = 0; + for (String headerName : headerArr) { + String value = getValueByName(headerName,sarStandardsInfoEO,attrInfoMap); + if (StringUtils.isBlank(value) || "null".equals(value)) { + value = ""; + } + row.createCell(sheetNum).setCellValue(value); + sheetNum++; + } + } + } + } + + // 根据表头返回相应值 + public static String getValueByName (String name,SarStandardsInfo sarStandardsInfoEO,Map attrInfoMap) throws Exception{ + String value = ""; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH"); + Map attrValueMap = sarStandardsInfoEO.getAttrInfoMap(); + switch (name) { + case "适用区域": + value = sarStandardsInfoEO.getCountryShow(); + break; + case "标准类别": + value = sarStandardsInfoEO.getStandSortShow(); + break; + case "重要度": + if (StringUtils.isNotBlank(sarStandardsInfoEO.getIsRelateAccess())) { + if ("1".equals(sarStandardsInfoEO.getIsRelateAccess())) { + sarStandardsInfoEO.setIsRelateAccess("A"); + } else { + sarStandardsInfoEO.setIsRelateAccess("B"); + } + } + value = sarStandardsInfoEO.getIsRelateAccess(); + break; + case "标准编号": + value = sarStandardsInfoEO.getStandNumber(); + break; + case "标准年份": + value = sarStandardsInfoEO.getStandYear(); + break; + case "中文名称": + value = sarStandardsInfoEO.getStandName(); + break; + case "英文名称": + value = sarStandardsInfoEO.getStandEnName(); + break; + case "标准状态": + value = sarStandardsInfoEO.getStandStateShow(); + break; + case "发布日期": + if (sarStandardsInfoEO.getIssueTime() != null) { + String issueTime = sarStandardsInfoEO.getIssueTime(); + if (issueTime.length() > 10) { + issueTime = issueTime.substring(0,10); + } + value = issueTime; + } + break; + case "文本说明": + value = sarStandardsInfoEO.getSynopsis(); + break; + default: + String field = attrInfoMap.get(name); + if (attrValueMap != null) { + value = String.valueOf(attrValueMap.get(field)); + } + break; + } + return value; + } + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/Utils.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/Utils.java new file mode 100644 index 00000000..27a7a463 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/Utils.java @@ -0,0 +1,57 @@ +package com.adc.da.utils.util; + +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; + +/** + * @Description: TODO + * @author: super_liu + * @date: 2021年06月01日 13:37 + */ +public class Utils { + + //判断row是否为空 空返回true + public static boolean isRowEmpty(Row row) { + if (null == row) { + return true; + } + int firstCellNum = row.getFirstCellNum(); //第一个列位置 + int lastCellNum = row.getLastCellNum(); //最后一列位置 + int nullCellNum = 0; //空列数量 + for (int c = firstCellNum; c < lastCellNum; c++) { + Cell cell = row.getCell(c); + if (null == cell || CellType.BLANK == cell.getCellType()) { + nullCellNum ++; + continue; + } + String value = ""; + switch (cell.getCellType()) { + case NUMERIC: // 数字 + //如果为时间格式的内容 + value = String.valueOf(cell.getNumericCellValue()); + break; + case STRING: // 字符串 + value = cell.getStringCellValue(); + break; + case BOOLEAN: // Boolean + value = cell.getBooleanCellValue() + ""; + break; + case FORMULA: // 公式 + value = cell.getCellFormula() + ""; + break; + default: + break; + } + if (StringUtils.isEmpty(value)) { + nullCellNum ++; + } + } + //所有列都为空 + if (nullCellNum == (lastCellNum - firstCellNum)) { + return true; + } + return false; + } +} diff --git a/adc-da-slrs/src/main/lib/pageoffice4.5.0.9.jar b/adc-da-slrs/src/main/lib/pageoffice4.5.0.9.jar new file mode 100644 index 00000000..a308eed2 Binary files /dev/null and b/adc-da-slrs/src/main/lib/pageoffice4.5.0.9.jar differ diff --git a/adc-da-slrs/src/main/lib/poi-tl-1.5.1-SNAPSHOT.jar b/adc-da-slrs/src/main/lib/poi-tl-1.5.1-SNAPSHOT.jar new file mode 100644 index 00000000..f7f6ad3a Binary files /dev/null and b/adc-da-slrs/src/main/lib/poi-tl-1.5.1-SNAPSHOT.jar differ diff --git a/adc-da-slrs/src/main/lib/poseal.db b/adc-da-slrs/src/main/lib/poseal.db new file mode 100644 index 00000000..d215a9c0 Binary files /dev/null and b/adc-da-slrs/src/main/lib/poseal.db differ diff --git a/adc-da-slrs/src/main/lib/sqlite-jdbc-3.7.2.jar b/adc-da-slrs/src/main/lib/sqlite-jdbc-3.7.2.jar new file mode 100644 index 00000000..b0bec7b0 Binary files /dev/null and b/adc-da-slrs/src/main/lib/sqlite-jdbc-3.7.2.jar differ diff --git a/adc-da-slrs/src/main/lib/zip4j-1.3.1.jar b/adc-da-slrs/src/main/lib/zip4j-1.3.1.jar new file mode 100644 index 00000000..c0b03953 Binary files /dev/null and b/adc-da-slrs/src/main/lib/zip4j-1.3.1.jar differ diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandAttrInfo/SarStandAttrInfoMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandAttrInfo/SarStandAttrInfoMapper.xml new file mode 100644 index 00000000..b8df1548 --- /dev/null +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandAttrInfo/SarStandAttrInfoMapper.xml @@ -0,0 +1,233 @@ + + + + + + + + + + + + + + + + + id, stand_id, creation_user, valid_flag, creation_time, modify_time + + + + + where 1=1 + + + and id ${idOperator} #{id} + + + and stand_id ${standIdOperator} #{standId} + + + and creation_user ${creationUserOperator} #{creationUser} + + + and valid_flag ${validFlagOperator} #{validFlag} + + + and creation_time ${creationTimeOperator} #{creationTime} + + + and creation_time >= #{creationTime1} + + + and creation_time <= #{creationTime2} + + + and modify_time ${modifyTimeOperator} #{modifyTime} + + + and modify_time >= #{modifyTime1} + + + and modify_time <= #{modifyTime2} + + + and GZZXX ${GZZXXOperator} #{GZZXX} + + + + + + + + insert into SAR_STAND_ATTR_INFO() + values (#{id, jdbcType=VARCHAR}, #{standId, jdbcType=VARCHAR}, #{creationUser, jdbcType=VARCHAR}, #{validFlag, jdbcType=VARCHAR}, #{creationTime, jdbcType=TIMESTAMP}, #{modifyTime, jdbcType=TIMESTAMP}) + + + + + + insert into SAR_STAND_ATTR_INFO + + id, + stand_id, + creation_user, + valid_flag, + creation_time, + modify_time, + + + #{id, jdbcType=VARCHAR}, + #{standId, jdbcType=VARCHAR}, + #{creationUser, jdbcType=VARCHAR}, + #{validFlag, jdbcType=VARCHAR}, + #{creationTime, jdbcType=TIMESTAMP}, + #{modifyTime, jdbcType=TIMESTAMP}, + + + + + + update SAR_STAND_ATTR_INFO + set stand_id = #{standId}, + creation_user = #{creationUser}, + valid_flag = #{validFlag}, + creation_time = #{creationTime}, + modify_time = #{modifyTime} + where id = #{id} + + + + + update SAR_STAND_ATTR_INFO + + + stand_id = #{standId}, + + + creation_user = #{creationUser}, + + + valid_flag = #{validFlag}, + + + creation_time = #{creationTime}, + + + modify_time = #{modifyTime}, + + + where id = #{id} + + + + + + + + delete from SAR_STAND_ATTR_INFO + where id = #{value} + + + + + + + + + + + + + + alter table SAR_STAND_ATTR_INFO + add ${fieldInfo} + + + + + alter table SAR_STAND_ATTR_INFO + drop COLUMN ${fieldInfo} + + + + + + + + ALTER table SAR_STAND_ATTR_INFO + MODIFY ${fieldInfo} + + + + + + + insert into SAR_STAND_ATTR_INFO(${fieldInfo}) + values (${fieldValue}) + + + + delete from SAR_STAND_ATTR_INFO + where stand_id = #{standId} + + + + update SAR_STAND_ATTR_INFO set ${field}=#{value} + where stand_id = #{standId} + + + + + + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandItems/SarStandItemsMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandItems/SarStandItemsMapper.xml new file mode 100644 index 00000000..c3388be6 --- /dev/null +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandItems/SarStandItemsMapper.xml @@ -0,0 +1,642 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SAR_STAND_ITEMS.modify_time, SAR_STAND_ITEMS.creation_time, SAR_STAND_ITEMS.creation_user, SAR_STAND_ITEMS.valid_flag, SAR_STAND_ITEMS.remarks, SAR_STAND_ITEMS.responsible_unit, SAR_STAND_ITEMS.energy_kind, SAR_STAND_ITEMS.apply_arctic, tack_time, parts, SAR_STAND_ITEMS.items_name, SAR_STAND_ITEMS.items_num, SAR_STAND_ITEMS.stand_id, SAR_STAND_ITEMS.id + ,TS_ORG.org_name as responsibleUnitShow,SAR_STAND_ITEMS.MAINPOINTS_IMPEMENTATION,SAR_STAND_ITEMS.TERMS_CONDITIONS,tsFo.UNAME as foShow,SAR_STAND_ITEMS.duty_engineer,SAR_STAND_ITEMS.svpps, + SAR_STAND_ITEMS.claim_type,SAR_STAND_ITEMS.bus_stand_cover,SAR_STAND_ITEMS.file_type,dicClaimType.DIC_TYPE_NAME as claimTypeShow,tsdutyEngineer.UNAME as dutyEngineerShow,SAR_STAND_ITEMS.fo + + + + SAR_STAND_ITEMS.modify_time, SAR_STAND_ITEMS.creation_time, SAR_STAND_ITEMS.creation_user, SAR_STAND_ITEMS.valid_flag, SAR_STAND_ITEMS.remarks, SAR_STAND_ITEMS.responsible_unit, + SAR_STAND_ITEMS.energy_kind, SAR_STAND_ITEMS.apply_arctic, tack_time, parts, SAR_STAND_ITEMS.items_name, SAR_STAND_ITEMS.items_num, SAR_STAND_ITEMS.stand_id, SAR_STAND_ITEMS.id + ,SAR_STAND_ITEMS.MAINPOINTS_IMPEMENTATION,SAR_STAND_ITEMS.TERMS_CONDITIONS,SAR_STAND_ITEMS.duty_engineer,SAR_STAND_ITEMS.svpps, + SAR_STAND_ITEMS.claim_type,SAR_STAND_ITEMS.bus_stand_cover,SAR_STAND_ITEMS.file_type,SAR_STAND_ITEMS.fo + + + + + left join SAR_STANDARDS_INFO on (SAR_STANDARDS_INFO.id = SAR_STAND_ITEMS.stand_id and SAR_STANDARDS_INFO.valid_flag=0) + left join TS_DICTYPE dicClaimType on (dicClaimType.dic_type_code = SAR_STAND_ITEMS.claim_type and dicClaimType.dic_id is + not null and dicClaimType.valid_flag = 0) + left join TS_USER tsdutyEngineer on (tsdutyEngineer.USID = SAR_STAND_ITEMS.duty_engineer and tsdutyEngineer.valid_flag=0 + and tsdutyEngineer.DISABLE_FLAG=0) + left join TS_USER tsFo on (tsFo.USID = SAR_STAND_ITEMS.fo and tsFo.valid_flag=0 + and tsFo.DISABLE_FLAG=0) + where 1=1 + + + and SAR_STAND_ITEMS.file_type = #{fileType} + + + and SAR_STAND_ITEMS.modify_time ${modifyTimeOperator} #{modifyTime} + + + and SAR_STAND_ITEMS.modify_time >= #{modifyTime1} + + + and SAR_STAND_ITEMS.modify_time <= #{modifyTime2} + + + and SAR_STAND_ITEMS.creation_time ${creationTimeOperator} #{creationTime} + + + and SAR_STAND_ITEMS.creation_time >= #{creationTime1} + + + and SAR_STAND_ITEMS.creation_time <= #{creationTime2} + + + and SAR_STAND_ITEMS.creation_user ${creationUserOperator} #{creationUser} + + + and SAR_STAND_ITEMS.valid_flag ${validFlagOperator} #{validFlag} + + + and SAR_STAND_ITEMS.remarks ${remarksOperator} #{remarks} + + + and SAR_STAND_ITEMS.responsible_unit = #{responsibleUnit} + + + and SAR_STAND_ITEMS.energy_kind ${energyKindOperator} #{energyKind} + + + and SAR_STAND_ITEMS.apply_arctic ${applyArcticOperator} #{applyArctic} + + + and SAR_STAND_ITEMS.tack_time ${tackTimeOperator} #{tackTime} + + + and SAR_STAND_ITEMS.tack_time >= #{tackTime1} + + + and SAR_STAND_ITEMS.tack_time <= #{tackTime2} + + + and SAR_STAND_ITEMS.parts like concat(concat('%', #{parts}),'%') + + + and (SAR_STAND_ITEMS.items_name like concat(concat('%', #{nameOrRequest}),'%') or SAR_STAND_ITEMS.TERMS_CONDITIONS like concat(concat('%', #{nameOrRequest}),'%')) + + + and SAR_STAND_ITEMS.items_name ${itemsNameOperator} #{itemsName} + + + and SAR_STAND_ITEMS.items_num ${itemsNumOperator} #{itemsNum} + + + and SAR_STAND_ITEMS.stand_id ${standIdOperator} #{standId} + + + and ((SAR_STANDARDS_INFO.STAND_SORT || ' ' || SAR_STANDARDS_INFO.STAND_NUMBER || '-' || + SAR_STANDARDS_INFO.STAND_YEAR like concat(concat('%',#{standNum}),'%') and SAR_STANDARDS_INFO.STAND_YEAR is not null) + or (SAR_STANDARDS_INFO.STAND_SORT || ' ' || SAR_STANDARDS_INFO.STAND_NUMBER like concat(concat('%',#{standNum}),'%') + and SAR_STANDARDS_INFO.STAND_YEAR is null)) + + + and SAR_STAND_ITEMS.id ${idOperator} #{id} + + + and SAR_STAND_ITEMS.id != #{noId} + + + and SAR_PRODUCT_SAR_STATE.product_id = #{productId} + + + and SAR_STAND_ITEMS.id in + + #{item} + + + + and (SAR_STAND_ITEMS.claim_type='L7N7EEDAPR' or SAR_STAND_ITEMS.claim_type='RENVECPFGT') + + + + + + + + insert into SAR_STAND_ITEMS() + values (#{modifyTime, jdbcType=TIMESTAMP}, #{creationTime, jdbcType=TIMESTAMP}, #{creationUser, jdbcType=VARCHAR}, #{validFlag, jdbcType=INTEGER}, #{remarks, jdbcType=VARCHAR}, #{responsibleUnit, jdbcType=VARCHAR}, #{energyKind, jdbcType=VARCHAR}, #{applyArctic, jdbcType=VARCHAR}, #{tackTime, jdbcType=TIMESTAMP}, #{parts, jdbcType=VARCHAR}, #{itemsName, jdbcType=VARCHAR}, #{itemsNum, jdbcType=VARCHAR}, #{standId, jdbcType=VARCHAR}, #{id, jdbcType=VARCHAR}) + + + + + + insert into SAR_STAND_ITEMS + + modify_time, + creation_time, + creation_user, + valid_flag, + remarks, + responsible_unit, + energy_kind, + apply_arctic, + tack_time, + parts, + items_name, + items_num, + stand_id, + id, + MAINPOINTS_IMPEMENTATION, + TERMS_CONDITIONS, + + fo, + duty_engineer, + svpps, + claim_type, + bus_stand_cover, + file_type + + + + #{modifyTime, jdbcType=TIMESTAMP}, + #{creationTime, jdbcType=TIMESTAMP}, + #{creationUser, jdbcType=VARCHAR}, + #{validFlag, jdbcType=INTEGER}, + #{remarks, jdbcType=VARCHAR}, + #{responsibleUnit, jdbcType=VARCHAR}, + #{energyKind, jdbcType=VARCHAR}, + #{applyArctic, jdbcType=VARCHAR}, + #{tackTime, jdbcType=TIMESTAMP}, + #{parts, jdbcType=VARCHAR}, + #{itemsName, jdbcType=VARCHAR}, + #{itemsNum, jdbcType=VARCHAR}, + #{standId, jdbcType=VARCHAR}, + #{id, jdbcType=VARCHAR}, + #{mainPointImplementation,jdbcType=VARCHAR}, + #{termsConditions,jdbcType=CLOB}, + + #{fo, jdbcType=VARCHAR}, + #{dutyEngineer, jdbcType=VARCHAR}, + #{svpps, jdbcType=VARCHAR}, + #{claimType, jdbcType=VARCHAR}, + #{busStandCover, jdbcType=VARCHAR}, + #{fileType, jdbcType=VARCHAR} + + + + + + update SAR_STAND_ITEMS + set modify_time = #{modifyTime}, + creation_time = #{creationTime}, + creation_user = #{creationUser}, + valid_flag = #{validFlag}, + remarks = #{remarks}, + responsible_unit = #{responsibleUnit}, + energy_kind = #{energyKind}, + apply_arctic = #{applyArctic}, + tack_time = #{tackTime}, + parts = #{parts}, + items_name = #{itemsName}, + items_num = #{itemsNum}, + stand_id = #{standId} + where id = #{id} + + + + + update SAR_STAND_ITEMS + + + modify_time = #{modifyTime}, + + + creation_time = #{creationTime}, + + + creation_user = #{creationUser}, + + + valid_flag = #{validFlag}, + + + remarks = #{remarks}, + + + responsible_unit = #{responsibleUnit}, + + + energy_kind = #{energyKind}, + + + apply_arctic = #{applyArctic}, + + + tack_time = #{tackTime}, + + + tack_time = null, + + + parts = #{parts}, + + + items_name = #{itemsName}, + + + items_num = #{itemsNum}, + + + stand_id = #{standId}, + + + MAINPOINTS_IMPEMENTATION = #{mainPointImplementation}, + + + TERMS_CONDITIONS = #{termsConditions,jdbcType=CLOB}, + + + + fo = #{fo}, + + + duty_engineer = #{dutyEngineer}, + + + svpps = #{svpps}, + + + claim_type = #{claimType}, + + + bus_stand_cover = #{busStandCover}, + + + where id = #{id} + + + + + + + + delete from SAR_STAND_ITEMS + where id = #{value} + + + + + + + + + + + + + + + + + + insert into SAR_STAND_ITEMS(svpps,fo,file_type,modify_time,creation_time,creation_user,valid_flag,apply_arctic, + items_name,items_num,stand_id,id,terms_conditions,responsible_unit,duty_engineer) + values + + (#{item.svpps, jdbcType=VARCHAR}, + #{item.fo, jdbcType=VARCHAR}, + #{item.fileType, jdbcType=VARCHAR}, + #{item.modifyTime, jdbcType=DATE}, + #{item.creationTime, jdbcType=DATE}, + #{item.creationUser, jdbcType=VARCHAR}, + #{item.validFlag, jdbcType=INTEGER}, + #{item.applyArctic, jdbcType=VARCHAR}, + #{item.itemsName, jdbcType=VARCHAR}, + #{item.itemsNum, jdbcType=VARCHAR}, + #{item.standId, jdbcType=VARCHAR}, + #{item.id, jdbcType=VARCHAR}, + #{item.termsConditions,jdbcType=VARCHAR}, + #{item.responsibleUnit,jdbcType=VARCHAR}, + #{item.dutyEngineer,jdbcType=VARCHAR} + ) + + + + + + update SAR_STAND_ITEMS + + + svpps = #{item.svpps}, + + + fo = #{item.fo}, + + + file_type = #{item.fileType}, + + + modify_time = #{item.modifyTime}, + + + remarks = #{item.remarks}, + + + apply_arctic = #{item.applyArctic}, + + + items_name = #{item.itemsName}, + + + items_num = #{item.itemsNum}, + + + stand_id = #{item.standId}, + + + TERMS_CONDITIONS = #{item.termsConditions,jdbcType=CLOB}, + + + where id = #{item.id, jdbcType=VARCHAR} + + ; + + + + delete from SAR_STAND_ITEMS + where stand_id = #{standId} + + and file_type = #{fileType} + + + + + delete from SAR_STAND_ITEMS + where id in + + #{item} + + + + + + + + + + + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/otSvpps/OtSvppsMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/otSvpps/OtSvppsMapper.xml new file mode 100644 index 00000000..84bfc7f7 --- /dev/null +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/otSvpps/OtSvppsMapper.xml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + id, p_id, f_num, s_num, t_num, svpps_code, svpps_en_name, svpps_cn_name, sync_id, valid_flag, created_time, modify_time + + + + + where 1=1 + + + and id ${idOperator} #{id} + + + and p_id ${pIdOperator} #{pId} + + + and f_num ${fNumOperator} #{fNum} + + + and s_num ${sNumOperator} #{sNum} + + + and t_num ${tNumOperator} #{tNum} + + + and svpps_code ${svppsCodeOperator} #{svppsCode} + + + and svpps_en_name ${svppsEnNameOperator} #{svppsEnName} + + + and svpps_cn_name ${svppsCnNameOperator} #{svppsCnName} + + + and sync_id ${syncIdOperator} #{syncId} + + + and valid_flag ${validFlagOperator} #{validFlag} + + + and created_time ${createdTimeOperator} #{createdTime} + + + and created_time >= #{createdTime1} + + + and created_time <= #{createdTime2} + + + and modify_time ${modifyTimeOperator} #{modifyTime} + + + and modify_time >= #{modifyTime1} + + + and modify_time <= #{modifyTime2} + + + + + + + + + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarGroupMenu/SarGroupMenuMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarGroupMenu/SarGroupMenuMapper.xml new file mode 100644 index 00000000..2e4f864b --- /dev/null +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarGroupMenu/SarGroupMenuMapper.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + SAR_GROUP_MENU.id, pid, menu_name, menu_type, menu_level, SAR_GROUP_MENU.create_time, SAR_GROUP_MENU.create_userid, SAR_GROUP_MENU.modify_time, SAR_GROUP_MENU.modify_userid, SAR_GROUP_MENU.vlag_flag, stand_no + + + + + + where 1=1 + + + and SAR_GROUP_MENU.id ${idOperator} #{id} + + + and pid ${pidOperator} #{pid} + + + and menu_name ${menuNameOperator} #{menuName} + + + and menu_type ${menuTypeOperator} #{menuType} + + + and menu_level ${menuLevelOperator} #{menuLevel} + + + and SAR_GROUP_MENU.create_time ${createTimeOperator} #{createTime} + + + and SAR_GROUP_MENU.create_time >= #{createTime1} + + + and SAR_GROUP_MENU.create_time <= #{createTime2} + + + and SAR_GROUP_MENU.create_userid ${createUseridOperator} #{createUserid} + + + and SAR_GROUP_MENU.modify_time ${modifyTimeOperator} #{modifyTime} + + + and SAR_GROUP_MENU.modify_time >= #{modifyTime1} + + + and SAR_GROUP_MENU.modify_time <= #{modifyTime2} + + + and SAR_GROUP_MENU.modify_userid ${modifyUseridOperator} #{modifyUserid} + + + and SAR_GROUP_MENU.vlag_flag ${vlagFlagOperator} #{vlagFlag} + + + and stand_no ${standNoOperator} #{standNo} + + + + + + where 1=1 + + + and id like concat(#{id},'%') + + + and pid ${pidOperator} #{pid} + + + and menu_name ${menuNameOperator} #{menuName} + + + and menu_type ${menuTypeOperator} #{menuType} + + + and menu_level ${menuLevelOperator} #{menuLevel} + + + and create_time ${createTimeOperator} #{createTime} + + + and create_time >= #{createTime1} + + + and create_time <= #{createTime2} + + + and create_userid ${createUseridOperator} #{createUserid} + + + and modify_time ${modifyTimeOperator} #{modifyTime} + + + and modify_time >= #{modifyTime1} + + + and modify_time <= #{modifyTime2} + + + and modify_userid ${modifyUseridOperator} #{modifyUserid} + + + and vlag_flag ${vlagFlagOperator} #{vlagFlag} + + + and stand_no ${standNoOperator} #{standNo} + + + + + + + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarMenu/SarMenuMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarMenu/SarMenuMapper.xml new file mode 100644 index 00000000..1cfc68a6 --- /dev/null +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarMenu/SarMenuMapper.xml @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + parent_id, menu_name, sor_divide, id, modify_time, creation_time, valid_flag, display_seq, parent_ids, remarks + + + + + where 1=1 + + + and parent_id ${parentIdOperator} #{parentId} + + + and menu_name ${menuNameOperator} #{menuName} + + + and sor_divide ${sorDivideOperator} #{sorDivide} + + + and id ${idOperator} #{id} + + + and modify_time ${modifyTimeOperator} #{modifyTime} + + + and modify_time >= #{modifyTime1} + + + and modify_time <= #{modifyTime2} + + + and creation_time ${creationTimeOperator} #{creationTime} + + + and creation_time >= #{creationTime1} + + + and creation_time <= #{creationTime2} + + + and valid_flag ${validFlagOperator} #{validFlag} + + + and display_seq ${displaySeqOperator} #{displaySeq} + + + and parent_ids ${parentIdsOperator} #{parentIds} + + + and remarks = #{remarks} + + + + + + + + insert into SAR_MENU() + values (#{parentId, jdbcType=VARCHAR}, #{menuName, jdbcType=VARCHAR}, #{sorDivide, jdbcType=VARCHAR}, #{id, jdbcType=VARCHAR}, #{modifyTime, jdbcType=TIMESTAMP}, #{creationTime, jdbcType=TIMESTAMP}, #{validFlag, jdbcType=INTEGER}, #{displaySeq, jdbcType=INTEGER}, #{parentIds, jdbcType=VARCHAR},#{remarks, jdbcType=VARCHAR}) + + + + + + insert into SAR_MENU + + parent_id, + menu_name, + sor_divide, + id, + modify_time, + creation_time, + valid_flag, + display_seq, + parent_ids, + remarks, + + + #{parentId, jdbcType=VARCHAR}, + #{menuName, jdbcType=VARCHAR}, + #{sorDivide, jdbcType=VARCHAR}, + #{id, jdbcType=VARCHAR}, + #{modifyTime, jdbcType=TIMESTAMP}, + #{creationTime, jdbcType=TIMESTAMP}, + #{validFlag, jdbcType=INTEGER}, + #{displaySeq, jdbcType=INTEGER}, + #{parentIds, jdbcType=VARCHAR}, + #{remarks, jdbcType=VARCHAR}, + + + + + + update SAR_MENU + set parent_id = #{parentId}, + menu_name = #{menuName}, + sor_divide = #{sorDivide}, + modify_time = #{modifyTime}, + creation_time = #{creationTime}, + valid_flag = #{validFlag}, + display_seq = #{displaySeq}, + parent_ids = #{parentIds} + remarks = #{remarks} + where id = #{id} + + + + + update SAR_MENU + + + parent_id = #{parentId}, + + + menu_name = #{menuName}, + + + sor_divide = #{sorDivide}, + + + modify_time = #{modifyTime}, + + + creation_time = #{creationTime}, + + + valid_flag = #{validFlag}, + + + display_seq = #{displaySeq}, + + + parent_ids = #{parentIds}, + + + remarks = #{remarks}, + + + where id = #{id} + + + + + + + + delete from SAR_MENU + where id = #{value} + + + + + + + + + + + + + + + + + + + + + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandAttrDetails/SarStandAttrDetailsMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandAttrDetails/SarStandAttrDetailsMapper.xml new file mode 100644 index 00000000..5a83b7d3 --- /dev/null +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandAttrDetails/SarStandAttrDetailsMapper.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, attr_field, attr_name, attr_type, order_num, is_edit, creation_user, + valid_flag, creation_time, modify_time, + attr_len,is_must,is_show_imp,show_region_id,sel_val,sar_type,is_search,is_warn + + + + SAR_STAND_ATTR_DETAILS.id, attr_field, attr_name, attr_type, SAR_STAND_ATTR_DETAILS.order_num, is_edit, SAR_STAND_ATTR_DETAILS.creation_user, + SAR_STAND_ATTR_DETAILS.valid_flag, SAR_STAND_ATTR_DETAILS.creation_time, SAR_STAND_ATTR_DETAILS.modify_time, + attr_len,is_must,is_show_imp,show_region_id,sel_val,SAR_STAND_ATTR_DETAILS.sar_type,is_search,is_warn + + + + + where 1=1 and SAR_STAND_ATTR_DETAILS.valid_flag=0 + + + and SAR_STAND_ATTR_DETAILS.id ${idOperator} #{id} + + + and attr_field ${attrFieldOperator} #{attrField} + + + and attr_name ${attrNameOperator} #{attrName} + + + and attr_type ${attrTypeOperator} #{attrType} + + + and SAR_STAND_ATTR_DETAILS.order_num ${orderNumOperator} #{orderNum} + + + and is_edit ${isEditOperator} #{isEdit} + + + and SAR_STAND_ATTR_DETAILS.creation_user ${creationUserOperator} #{creationUser} + + + and SAR_STAND_ATTR_DETAILS.valid_flag ${validFlagOperator} #{validFlag} + + + and SAR_STAND_ATTR_DETAILS.creation_time ${creationTimeOperator} #{creationTime} + + + and SAR_STAND_ATTR_DETAILS.creation_time >= #{creationTime1} + + + and SAR_STAND_ATTR_DETAILS.creation_time <= #{creationTime2} + + + and SAR_STAND_ATTR_DETAILS.modify_time ${modifyTimeOperator} #{modifyTime} + + + and SAR_STAND_ATTR_DETAILS.modify_time >= #{modifyTime1} + + + and SAR_STAND_ATTR_DETAILS.modify_time <= #{modifyTime2} + + + and attr_len ${attrLenOperator} #{attrLen} + + + and SAR_STAND_ATTR_DETAILS.sar_type like concat(concat('%',#{sarType}),'%') + + + and is_search = #{isSearch} + + + and is_warn = #{isWarn} + + + and SAR_STAND_ATTR_DETAILS.ID != #{notId} + + + and SAR_STAND_ATTR_DETAILS.ID in + + #{item} + + + + + + + + + + diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandardsInfo/SarStandardsInfoMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandardsInfo/SarStandardsInfoMapper.xml index 9eae18bc..3edba64f 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandardsInfo/SarStandardsInfoMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarStandardsInfo/SarStandardsInfoMapper.xml @@ -2,4 +2,833 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SAR_STANDARDS_INFO.id, SAR_STANDARDS_INFO.stand_type, SAR_STANDARDS_INFO.country, SAR_STANDARDS_INFO.stand_sort, + SAR_STANDARDS_INFO.stand_number, SAR_STANDARDS_INFO.stand_year, SAR_STANDARDS_INFO.stand_name, SAR_STANDARDS_INFO.stand_en_name, + SAR_STANDARDS_INFO.stand_state, SAR_STANDARDS_INFO.stand_nature, SAR_STANDARDS_INFO.issue_time, SAR_STANDARDS_INFO.put_time, + SAR_STANDARDS_INFO.synopsis, SAR_STANDARDS_INFO.creation_user, SAR_STANDARDS_INFO.valid_flag, + SAR_STANDARDS_INFO.creation_time, SAR_STANDARDS_INFO.modify_time,SAR_STANDARDS_INFO.is_relate_access,SAR_STANDARDS_INFO.cite_stand,SAR_STANDARDS_INFO.cited_stand + + + + SAR_STANDARDS_INFO.id, SAR_STANDARDS_INFO.stand_type, SAR_STANDARDS_INFO.country, SAR_STANDARDS_INFO.stand_sort, + SAR_STANDARDS_INFO.stand_number, SAR_STANDARDS_INFO.stand_year, SAR_STANDARDS_INFO.stand_name, SAR_STANDARDS_INFO.stand_en_name, + SAR_STANDARDS_INFO.stand_state, SAR_STANDARDS_INFO.stand_nature, SAR_STANDARDS_INFO.issue_time, SAR_STANDARDS_INFO.put_time, + concat(SAR_STANDARDS_INFO.synopsis, '') as synopsis, concat(replace_stand_num, '') as replace_stand_num, replaced_stand_num, SAR_STANDARDS_INFO.creation_user, SAR_STANDARDS_INFO.valid_flag, + SAR_STANDARDS_INFO.creation_time, SAR_STANDARDS_INFO.modify_time,dicountry.DIC_TYPE_NAME as countryShow, dicstandSort.DIC_TYPE_NAME as standSortShow, + dicstandState.DIC_TYPE_NAME as standStateShow,dicstandNature.DIC_TYPE_NAME as standNatureShow,is_relate_access,cite_stand,cited_stand + + + + SAR_STANDARDS_INFO.id, SAR_STANDARDS_INFO.stand_type, SAR_STANDARDS_INFO.country, SAR_STANDARDS_INFO.stand_sort, + SAR_STANDARDS_INFO.stand_number, SAR_STANDARDS_INFO.stand_year, SAR_STANDARDS_INFO.stand_name, SAR_STANDARDS_INFO.stand_en_name, + SAR_STANDARDS_INFO.stand_state, SAR_STANDARDS_INFO.stand_nature, SAR_STANDARDS_INFO.issue_time, SAR_STANDARDS_INFO.put_time, + concat(SAR_STANDARDS_INFO.synopsis, ''), concat(replace_stand_num, ''), replaced_stand_num, SAR_STANDARDS_INFO.creation_user, SAR_STANDARDS_INFO.valid_flag, + SAR_STANDARDS_INFO.creation_time, SAR_STANDARDS_INFO.modify_time,dicountry.DIC_TYPE_NAME, dicstandSort.DIC_TYPE_NAME, + dicstandState.DIC_TYPE_NAME,dicstandNature.DIC_TYPE_NAME,is_relate_access,cite_stand,cited_stand + + + + + where 1=1 and SAR_STANDARDS_INFO.valid_flag=0 + + + and id ${idOperator} #{id} + + + and stand_type ${standTypeOperator} #{standType} + + + and country ${countryOperator} #{country} + + + and stand_sort ${standSortOperator} #{standSort} + + + and stand_number ${standNumberOperator} #{standNumber} + + + and stand_year ${standYearOperator} #{standYear} + + + and stand_name ${standNameOperator} #{standName} + + + and stand_en_name ${standEnNameOperator} #{standEnName} + + + and stand_state ${standStateOperator} #{standState} + + + and stand_nature ${standNatureOperator} #{standNature} + + + and issue_time ${issueTimeOperator} #{issueTime} + + + and issue_time >= #{issueTime1} + + + and issue_time <= #{issueTime2} + + + and put_time ${putTimeOperator} #{putTime} + + + and put_time >= #{putTime1} + + + and put_time <= #{putTime2} + + + and synopsis ${synopsisOperator} #{synopsis} + + + and replace_stand_num ${replaceStandNumOperator} #{replaceStandNum} + + + and replaced_stand_num ${replacedStandNumOperator} #{replacedStandNum} + + + and creation_user ${creationUserOperator} #{creationUser} + + + and valid_flag ${validFlagOperator} #{validFlag} + + + and creation_time ${creationTimeOperator} #{creationTime} + + + and creation_time >= #{creationTime1} + + + and creation_time <= #{creationTime2} + + + and modify_time ${modifyTimeOperator} #{modifyTime} + + + and modify_time >= #{modifyTime1} + + + and modify_time <= #{modifyTime2} + + + and is_relate_access = #{isRelateAccess} + + + + + + + insert into SAR_STANDARDS_INFO() + values (#{id, jdbcType=VARCHAR}, #{standType, jdbcType=VARCHAR}, #{country, jdbcType=VARCHAR}, #{standSort, jdbcType=VARCHAR}, #{standNumber, jdbcType=VARCHAR}, #{standYear, jdbcType=VARCHAR}, #{standName, jdbcType=VARCHAR}, #{standEnName, jdbcType=VARCHAR}, #{standState, jdbcType=VARCHAR}, #{standNature, jdbcType=VARCHAR}, #{issueTime, jdbcType=TIMESTAMP}, #{putTime, jdbcType=TIMESTAMP}, #{synopsis, jdbcType=CLOB}, #{replaceStandNum, jdbcType=CLOB}, #{replacedStandNum, jdbcType=VARCHAR}, #{creationUser, jdbcType=VARCHAR}, #{validFlag, jdbcType=VARCHAR}, #{creationTime, jdbcType=TIMESTAMP}, #{modifyTime, jdbcType=TIMESTAMP}) + + + + + insert into SAR_STANDARDS_INFO + + id, + stand_type, + country, + stand_sort, + stand_number, + stand_year, + stand_name, + stand_en_name, + stand_state, + stand_nature, + issue_time, + put_time, + synopsis, + replace_stand_num, + replaced_stand_num, + creation_user, + valid_flag, + creation_time, + modify_time, + is_relate_access, + cite_stand, + cited_stand, + + + #{id, jdbcType=VARCHAR}, + #{standType, jdbcType=VARCHAR}, + #{country, jdbcType=VARCHAR}, + #{standSort, jdbcType=VARCHAR}, + #{standNumber, jdbcType=VARCHAR}, + #{standYear, jdbcType=VARCHAR}, + #{standName, jdbcType=VARCHAR}, + #{standEnName, jdbcType=VARCHAR}, + #{standState, jdbcType=VARCHAR}, + #{standNature, jdbcType=VARCHAR}, + #{issueTime, jdbcType=VARCHAR}, + #{putTime, jdbcType=TIMESTAMP}, + #{synopsis, jdbcType=CLOB}, + #{replaceStandNum, jdbcType=CLOB}, + #{replacedStandNum, jdbcType=VARCHAR}, + #{creationUser, jdbcType=VARCHAR}, + #{validFlag, jdbcType=VARCHAR}, + #{creationTime, jdbcType=TIMESTAMP}, + #{modifyTime, jdbcType=TIMESTAMP}, + #{isRelateAccess, jdbcType=VARCHAR}, + #{citeStand, jdbcType=VARCHAR}, + #{citedStand, jdbcType=VARCHAR}, + + + + + + update SAR_STANDARDS_INFO + set stand_type = #{standType}, + country = #{country}, + stand_sort = #{standSort}, + stand_number = #{standNumber}, + stand_year = #{standYear}, + stand_name = #{standName}, + stand_en_name = #{standEnName}, + stand_state = #{standState}, + stand_nature = #{standNature}, + issue_time = #{issueTime}, + put_time = #{putTime}, + synopsis = #{synopsis}, + replace_stand_num = #{replaceStandNum}, + replaced_stand_num = #{replacedStandNum}, + creation_user = #{creationUser}, + valid_flag = #{validFlag}, + creation_time = #{creationTime}, + modify_time = #{modifyTime} + where id = #{id} + + + + + update SAR_STANDARDS_INFO + + + stand_type = #{standType}, + + + country = #{country}, + + + stand_sort = #{standSort}, + + + stand_number = #{standNumber}, + + + stand_year = #{standYear}, + + + stand_name = #{standName}, + + + stand_en_name = #{standEnName}, + + + stand_state = #{standState}, + + + stand_nature = #{standNature}, + + + issue_time = #{issueTime}, + + + put_time = #{putTime}, + + + synopsis = #{synopsis}, + + + replace_stand_num = #{replaceStandNum}, + + + replaced_stand_num = #{replacedStandNum}, + + + creation_user = #{creationUser}, + + + valid_flag = #{validFlag}, + + + creation_time = #{creationTime}, + + + modify_time = #{modifyTime}, + + + is_relate_access = #{isRelateAccess}, + + + cite_stand = #{citeStand}, + + + cited_stand = #{citedStand}, + + + where id = #{id} + + + + + + + + delete from SAR_STANDARDS_INFO + where id = #{value} + + + + + + + + + + + + + left join TS_DICTYPE dicountry on (dicountry.dic_type_code = SAR_STANDARDS_INFO.country and dicountry.dic_id is + not null and dicountry.valid_flag = 0) + left join TS_DICTYPE dicstandSort on (dicstandSort.dic_type_code = SAR_STANDARDS_INFO.stand_sort and + dicstandSort.dic_id is not null and dicstandSort.valid_flag = 0 and dicstandSort.PARENT_ID is null) + left join TS_DICTYPE dicstandState on (dicstandState.dic_type_code = SAR_STANDARDS_INFO.stand_state and + dicstandState.dic_id is not null and dicstandState.valid_flag = 0 ) + left join TS_DICTYPE dicstandNature on (dicstandNature.dic_type_code = SAR_STANDARDS_INFO.stand_nature and + dicstandNature.dic_id is not null and dicstandNature.valid_flag = 0 ) + left join SAR_STAND_MENU ON SAR_STANDARDS_INFO.id = SAR_STAND_MENU.stand_id + left join SAR_MENU on SAR_STAND_MENU.menu_id = SAR_MENU.id + left join SAR_STAND_ATTR_INFO on (SAR_STAND_ATTR_INFO.stand_id = SAR_STANDARDS_INFO.id and SAR_STAND_ATTR_INFO.valid_flag=0) + left join TS_PERSON_COLLECT on (TS_PERSON_COLLECT.COLLECT_RES_ID = SAR_STANDARDS_INFO.id and TS_PERSON_COLLECT.VALID_FLAG=0) + where 1=1 and SAR_STANDARDS_INFO.valid_flag=0 + + + + and stand_type = #{standType} + + + + + and country = #{country} + + + + and ( + (concat(SAR_STANDARDS_INFO.STAND_SORT,' ',SAR_STANDARDS_INFO.STAND_NUMBER,'-', + SAR_STANDARDS_INFO.STAND_YEAR) like concat(concat('%',#{standNumber}),'%') and SAR_STANDARDS_INFO.STAND_YEAR != '') + or (concat(SAR_STANDARDS_INFO.STAND_SORT,' ',SAR_STANDARDS_INFO.STAND_NUMBER) like concat(concat('%',#{standNumber}),'%') + and SAR_STANDARDS_INFO.STAND_YEAR = '') + or (stand_name like concat(concat('%',#{standNumber}),'%')) + ) + + + + and stand_name like concat(concat('%',#{standName}),'%') + + + and stand_en_name like concat(concat('%',#{standEnName}),'%') + + + + and stand_state = #{standState} + + + + + and stand_nature = #{standNature} + + + + and replace_stand_num like concat(concat('%',#{replaceStandNum}),'%') + + + + and replaced_stand_num like concat(concat('%',#{replacedStandNum}),'%') + + + + and SAR_STAND_MENU.MENU_ID in + + #{item} + + + + + + + + + + + + + + + + and SAR_STAND_MENU.MENU_ID in + + #{item} + + + + + + + + + + + + and SAR_STANDARDS_INFO.id in + + #{item} + + + + and SAR_STANDARDS_INFO.stand_sort = #{standSort} + + + + AND dbms_lob.instr(SYNOPSIS, #{synopsis} ,1,1) > 0 + + + and SAR_STANDARDS_INFO.id in ( + select COLLECT_RES_ID from TS_PERSON_COLLECT where TS_PERSON_COLLECT.VALID_FLAG=0 + and (collect_type='INLAND_STAND' or collect_type='FOREIGN_STAND') + and TS_PERSON_COLLECT.user_id=#{userId} + ) + + + and SAR_STAND_ATTR_INFO.GXHBQ is not null + + + and SAR_STAND_ATTR_INFO.GXHBQ like concat(concat('%',#{labelMenuId}),'%') + + + and SAR_STAND_ATTR_INFO.SYCLLX = #{applyArctic} + + + and is_relate_access = #{isRelateAccess} + + + and (${advanceSearchStr}) + + + + + + + + + + + + + + + + + + + + + + + + update SAR_STANDARDS_INFO set + stand_state=#{standState} where 1=1 and valid_flag=0 + + and stand_sort = #{standSort} + + + and stand_Number = #{standNumber} + + + and stand_year = #{standYear} + + + + + + + delete from SAR_STANDARDS_INFO + where id = #{id} and valid_flag=1 + + + + update SAR_STANDARDS_INFO set REPLACED_STAND_NUM = #{replacedStandNum} where id = #{id} + + + + update SAR_STANDARDS_INFO set CITED_STAND = #{citedStand} where id = #{id} + + + + + + + + + + + + + + + + + + + + + update SAR_STANDARDS_INFO set stand_state = #{state} + where id in + + #{item} + + + + + + + diff --git a/adc-da-sys/src/main/java/com/adc/da/att/controller/AttFileEOController.java b/adc-da-sys/src/main/java/com/adc/da/att/controller/AttFileEOController.java index e3de920f..4db17119 100644 --- a/adc-da-sys/src/main/java/com/adc/da/att/controller/AttFileEOController.java +++ b/adc-da-sys/src/main/java/com/adc/da/att/controller/AttFileEOController.java @@ -118,7 +118,7 @@ public class AttFileEOController { } /** - * @Author yangxuenan + * @Author super_liu * @Description 下载文件 * Date 2018/10/10 18:36 * @Param [response, fileId] @@ -293,7 +293,7 @@ public class AttFileEOController { } /** - * @Author yangxuenan + * @Author super_liu * @Description 根据不同浏览器定义下载文件编码 * Date 2018/10/11 10:40 * @Param [fileName, request] @@ -316,7 +316,7 @@ public class AttFileEOController { /** - * @Author yangxuenan + * @Author super_liu * @Description 查询文件信息 * Date 2018/10/10 18:41 * @Param [fileId] @@ -330,7 +330,7 @@ public class AttFileEOController { } /** - * @Author yangxuenan + * @Author super_liu * @Description 查询多个文件信息 * Date 2018/10/24 9:47 * @Param [fileIds] diff --git a/adc-da-sys/src/main/java/com/adc/da/att/entity/AttFileEO.java b/adc-da-sys/src/main/java/com/adc/da/att/entity/AttFileEO.java index b99fc909..3035ab76 100644 --- a/adc-da-sys/src/main/java/com/adc/da/att/entity/AttFileEO.java +++ b/adc-da-sys/src/main/java/com/adc/da/att/entity/AttFileEO.java @@ -29,12 +29,17 @@ public class AttFileEO extends BaseEntity implements Serializable{ private Date creationTime; @org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") private Date modifyTime; - + private String tableName; private String resId; - - + + /** + * 文件下载地址 + */ + private String downLoadUrl; + + /** * java字段名转换为原始数据库列名。如果不存在则返回null
*

字段列表:

@@ -92,26 +97,26 @@ public class AttFileEO extends BaseEntity implements Serializable{ default: return null; } } - + /** **/ public String getId() { - int tableNameIndex = this.id.lastIndexOf("_"); - if(tableNameIndex!= -1){ + int tableNameIndex = this.id.lastIndexOf("_"); + if(tableNameIndex!= -1){ String tableName = this.id.substring(0, tableNameIndex); this.tableName=tableName; }else{ - logger.error("文件ID格式错误:"+this.id); + logger.error("文件ID格式错误:"+this.id); } return this.id; } /** **/ public void setId(String id) { - if(tableName!=null && !tableName.isEmpty()){ - this.id = tableName+"_"+id; - } - //此处注意保存时表结构是否存在 - this.id=id; + if(tableName!=null && !tableName.isEmpty()){ + this.id = tableName+"_"+id; + } + //此处注意保存时表结构是否存在 + this.id=id; } /** **/ @@ -184,7 +189,7 @@ public class AttFileEO extends BaseEntity implements Serializable{ this.modifyTime = modifyTime; } - public String getTableName() { + public String getTableName() { if(this.tableName !=null && !this.tableName.isEmpty()){ return this.tableName; }else{ @@ -197,11 +202,11 @@ public class AttFileEO extends BaseEntity implements Serializable{ } return this.tableName; } - } + } - public void setTableName(String tableName) { - this.tableName = tableName; - } + public void setTableName(String tableName) { + this.tableName = tableName; + } public static long getSerialVersionUID() { return serialVersionUID; @@ -214,4 +219,12 @@ public class AttFileEO extends BaseEntity implements Serializable{ public void setResId(String resId) { this.resId = resId; } + + public String getDownLoadUrl() { + return downLoadUrl; + } + + public void setDownLoadUrl(String downLoadUrl) { + this.downLoadUrl = downLoadUrl; + } } diff --git a/adc-da-sys/src/main/java/com/adc/da/att/service/impl/AttFileEOServiceImpl.java b/adc-da-sys/src/main/java/com/adc/da/att/service/impl/AttFileEOServiceImpl.java index 2d60007c..f2d24b35 100644 --- a/adc-da-sys/src/main/java/com/adc/da/att/service/impl/AttFileEOServiceImpl.java +++ b/adc-da-sys/src/main/java/com/adc/da/att/service/impl/AttFileEOServiceImpl.java @@ -265,7 +265,7 @@ public class AttFileEOServiceImpl extends ServiceImpl i /** - * @Author yangxuenan + * @Author super_liu * @Description 多文件查询 * Date 2018/10/24 11:08 * @Param [fileIds] @@ -296,7 +296,7 @@ public class AttFileEOServiceImpl extends ServiceImpl i /** - * @Author yangxuenan + * @Author super_liu * @Description 获取attId * Date 2018/10/30 21:05 * @Param [file] diff --git a/adc-da-sys/src/main/java/com/adc/da/person/service/impl/PersonCollectEOServiceImpl.java b/adc-da-sys/src/main/java/com/adc/da/person/service/impl/PersonCollectEOServiceImpl.java index ed0d425f..eb744b72 100644 --- a/adc-da-sys/src/main/java/com/adc/da/person/service/impl/PersonCollectEOServiceImpl.java +++ b/adc-da-sys/src/main/java/com/adc/da/person/service/impl/PersonCollectEOServiceImpl.java @@ -66,7 +66,7 @@ public class PersonCollectEOServiceImpl extends ServiceImpl { /** * @return com.adc.da.util.http.ResponseMessage> - * @Author yangxuenan + * @Author super_liu * @Description 根据数据字典编码查询字典类型 * Date 2018/9/12 10:12 * @Param [dicCode] @@ -346,7 +346,7 @@ public class DicTypeEORestController extends BaseController { /** * @return com.adc.da.util.http.ResponseMessage>> - * @Author yangxuenan + * @Author super_liu * @Description 根据父级code查询 * Date 2018/10/9 14:11 * @Param [dicTypeCode] diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/dao/DicTypeEODao.java b/adc-da-sys/src/main/java/com/adc/da/sys/dao/DicTypeEODao.java index 2203bcf4..5a730ac0 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/dao/DicTypeEODao.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/dao/DicTypeEODao.java @@ -24,7 +24,7 @@ public interface DicTypeEODao extends BaseMapper { public void deleteDicTypeByDicId(String id); /** - * @Author yangxuenan + * @Author super_liu * @Description 根据数据字典编码查询字典类型 * Date 2018/9/11 15:09 * @Param [dictionaryCode] diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/dao/OrgEODao.java b/adc-da-sys/src/main/java/com/adc/da/sys/dao/OrgEODao.java index 6a30117b..2cec8f1a 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/dao/OrgEODao.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/dao/OrgEODao.java @@ -21,6 +21,9 @@ public interface OrgEODao extends BaseMapper { //liwenxuan:判断组织机构简称不重复 public OrgEO getOrgEOByShotNameAndPidAndId(@Param("shotName") String shotName, @Param("pId") String pId, @Param("id") String id); + String getNamesByIds(@Param("list") String[] list); + + String getIdsByNames(@Param("list") String[] list, @Param("orgType") String orgType); public List getOrgEOByPid(@Param("pId") String pId); diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/dao/RoleEODao.java b/adc-da-sys/src/main/java/com/adc/da/sys/dao/RoleEODao.java index ddd40b51..06663fb4 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/dao/RoleEODao.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/dao/RoleEODao.java @@ -24,6 +24,9 @@ public interface RoleEODao extends BaseMapper { List queryByPage(BasePage page); + String getNamesByIds(@Param("list") String[] list); + + String getIdsByNames(@Param("list") String[] list); public void save(RoleEO sysRoleEO); diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/dao/UserEODao.java b/adc-da-sys/src/main/java/com/adc/da/sys/dao/UserEODao.java index f47cf1c6..3444cd07 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/dao/UserEODao.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/dao/UserEODao.java @@ -23,6 +23,10 @@ public interface UserEODao extends BaseMapper { public void updateUserEO(UserEO userEO); + String getNamesByIds(@Param("list") String[] list); + + String getIdsByNames(@Param("list") String[] list,@Param("orgIdList") String[] orgIdList); + public List getRoleIdListByUserId(Integer usid); public void saveUserRole(@Param("usid") String usid, @Param("roleId") String roleId); diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/service/IDicTypeEOService.java b/adc-da-sys/src/main/java/com/adc/da/sys/service/IDicTypeEOService.java index f656c0f5..a2763196 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/service/IDicTypeEOService.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/service/IDicTypeEOService.java @@ -24,7 +24,7 @@ public interface IDicTypeEOService extends IService { public void deleteDicTypeByDicId(String id); /** - * @Author yangxuenan + * @Author super_liu * @Description 根据数据字典编码查询字典类型 * Date 2018/9/11 15:09 * @Param [dictionaryCode] diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/DicEOServiceImpl.java b/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/DicEOServiceImpl.java index 31f54ad0..f2d1d588 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/DicEOServiceImpl.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/DicEOServiceImpl.java @@ -136,7 +136,7 @@ public class DicEOServiceImpl extends ServiceImpl impleme /*** * @Description: 新增数据字典 - * @Author: yangxuenan + * @Author: super_liu * @Date: 2020/8/21 14:34 * @Param: [dictionaryEO] * @Return: int @@ -173,7 +173,7 @@ public class DicEOServiceImpl extends ServiceImpl impleme /*** * @Description: 修改数据字典 - * @Author: yangxuenan + * @Author: super_liu * @Date: 2020/8/21 15:42 * @Param: [dictionaryEO] * @Return: java.lang.String @@ -217,7 +217,7 @@ public class DicEOServiceImpl extends ServiceImpl impleme /*** * @Description: 以下拉框格式查询所有类别 - * @Author: yangxuenan + * @Author: super_liu * @Date: 2020/9/3 10:08 * @Param: [id] * @Return: java.util.List diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/DicTypeEOServiceImpl.java b/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/DicTypeEOServiceImpl.java index 461e9da3..015599ec 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/DicTypeEOServiceImpl.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/service/impl/DicTypeEOServiceImpl.java @@ -122,7 +122,7 @@ public class DicTypeEOServiceImpl extends ServiceImpl im } /** - * @Author yangxuenan + * @Author super_liu * @Description 根据数据字典编码查询字典类型 * Date 2018/9/12 10:18 * @Param [dictionaryCode] @@ -192,7 +192,7 @@ public class DicTypeEOServiceImpl extends ServiceImpl im } /** - * @Author yangxuenan + * @Author super_liu * @Description 根据父级code查询 * Date 2018/10/9 14:08 * @Param [dicTypeCode] @@ -212,7 +212,7 @@ public class DicTypeEOServiceImpl extends ServiceImpl im } /** - * @Author yangxuenan + * @Author super_liu * @Description 传递多个code值 * Date 2019/1/2 16:38 * @Param [dicTypeCode] diff --git a/adc-da-sys/src/main/resources/mybatis/mapper/sys/DicTypeEOMapper.xml b/adc-da-sys/src/main/resources/mybatis/mapper/sys/DicTypeEOMapper.xml index e332bd74..1f1c03cc 100644 --- a/adc-da-sys/src/main/resources/mybatis/mapper/sys/DicTypeEOMapper.xml +++ b/adc-da-sys/src/main/resources/mybatis/mapper/sys/DicTypeEOMapper.xml @@ -387,7 +387,7 @@ where id = #{id} --> - + + + + + + + + + + + + + + + + +