diff --git a/jero-boot/db/蔚来标准sql/dev_third_record.sql b/jero-boot/db/蔚来标准sql/dev_third_record.sql index aa02d7fe1..e5eaf7717 100644 --- a/jero-boot/db/蔚来标准sql/dev_third_record.sql +++ b/jero-boot/db/蔚来标准sql/dev_third_record.sql @@ -1203,3 +1203,9 @@ MODIFY COLUMN `content_en` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ALTER TABLE `laws_weilai`.`laws_monthly_report_write` MODIFY COLUMN `work_progress_cn` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'NIO工作进展中文' AFTER `content_en`, MODIFY COLUMN `work_progress_en` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'NIO工作进展英文' AFTER `work_progress_cn`; + + +--参数收集清单 添加英文 +UPDATE `laws_weilai`.`onl_cgform_field` SET `db_field_en_name` = 'Control Component' WHERE `id` = '84fec4a260dc646dc570cbf7cb581dab'; +UPDATE `laws_weilai`.`onl_cgform_field` SET `db_field_en_name` = 'Component Value' WHERE `id` = '5d468613746f413a53fa0b485089839b'; +UPDATE `laws_weilai`.`onl_cgform_field` SET `db_field_en_name` = 'Validate Component' WHERE `id` = '608274a6a6dfed0e183093d9ea357436'; \ No newline at end of file diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java index b9da4fa4e..4007acac3 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java @@ -19,6 +19,7 @@ import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; @@ -531,6 +532,25 @@ public class ParamsCollectManifestEOController extends JeroController importParamsInfo( MultipartFile file, + @RequestParam(value = "cut") String cut, + @RequestParam(value = "paramsManifestId") String paramsManifestId) throws Exception { + return paramsCollectManifestEOService.importDre(file, cut, paramsManifestId); + } + /** * 调整责任领域 * diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/mapper/ParamsCollectManifestEOMapper.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/mapper/ParamsCollectManifestEOMapper.java index 1166ad6d3..8c03b7113 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/mapper/ParamsCollectManifestEOMapper.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/mapper/ParamsCollectManifestEOMapper.java @@ -18,7 +18,7 @@ public interface ParamsCollectManifestEOMapper extends BaseMapper listInfo(@Param("paramsCollectManifestEO") ParamsCollectManifestEO paramsCollectManifestEO); - List> listInfoForExport(@Param("paramsCollectManifestEO") ParamsCollectManifestEO paramsCollectManifestEO); + List> listInfoForExport(@Param("paramsCollectManifestEO") ParamsCollectManifestEO paramsCollectManifestEO, @Param("ids") String ids); // 查询控件类型为 标题的 参数项 List listInfoOfTitle(@Param("paramsManifestId") String paramsManifestId); diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/mapper/xml/ParamsCollectManifestEOMapper.xml b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/mapper/xml/ParamsCollectManifestEOMapper.xml index 26f0ae6c0..822188743 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/mapper/xml/ParamsCollectManifestEOMapper.xml +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/mapper/xml/ParamsCollectManifestEOMapper.xml @@ -51,7 +51,10 @@ AND duty_territory = #{paramsCollectManifestEO.dutyTerritory} - AND state = #{paramsCollectManifestEO.state} + AND state in + + #{item} + AND params_manifest_id = #{paramsCollectManifestEO.paramsManifestId} @@ -85,6 +88,12 @@ select * from params_collect_manifest + + AND id in + + #{item} + + and control_type != '11' order by del_flag desc, add_flag desc, change_flag desc, nio_number asc diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java index 16249bc07..8fd0da033 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java @@ -2,11 +2,14 @@ package com.jero.modules.cert.collect.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.jero.common.api.vo.Result; import com.jero.modules.cert.collect.entity.ParamsCollectManifestEO; import com.jero.modules.cert.collect.vo.ParamsCollectManifestVO; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.List; import java.util.Map; @@ -162,6 +165,17 @@ public interface IParamsCollectManifestEOService extends IService importDre(MultipartFile file, String cut, String paramsManifestId) throws IOException; + + Result importData(List> dataList, + String unzipfilepath, + String cut, + String paramsManifestId) throws IOException; + // 调整责任领域 List updateBatchDutyTerritory(ParamsCollectManifestVO paramsCollectManifestVO); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java index 34349bfc1..0d38f314a 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java @@ -1,5 +1,6 @@ package com.jero.modules.cert.collect.service.impl; +import cn.afterturn.easypoi.excel.entity.ImportParams; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ZipUtil; @@ -9,12 +10,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Lists; +import com.jero.common.api.vo.Result; import com.jero.common.constant.CommonConstant; import com.jero.common.constant.WebsocketConst; -import com.jero.common.constant.enums.CutEnum; -import com.jero.common.constant.enums.MessageTypeEnum; -import com.jero.common.constant.enums.ModuleEnum; -import com.jero.common.constant.enums.YesOrNoEnum; +import com.jero.common.constant.enums.*; import com.jero.common.exception.JeroBootException; import com.jero.common.system.query.QueryGenerator; import com.jero.common.system.vo.LoginUser; @@ -34,8 +33,10 @@ import com.jero.modules.cert.collect.vo.ParamsManifestVO; import com.jero.modules.cert.report.entity.*; import com.jero.modules.cert.report.service.*; import com.jero.modules.cert.template.entity.CertCategoryParamsInfoPublishEO; +import com.jero.modules.cert.template.entity.ParamsInfoEO; import com.jero.modules.cert.template.entity.ParamsInfoPublishEO; import com.jero.modules.cert.template.enums.ControlTypeEnum; +import com.jero.modules.cert.template.enums.ControlVerifyEnum; import com.jero.modules.cert.template.enums.ParamsIsMustEnum; import com.jero.modules.cert.template.service.ICertCategoryParamsInfoPublishEOService; import com.jero.modules.cert.template.service.IParamsInfoPublishEOService; @@ -50,6 +51,8 @@ import com.jero.modules.project.entity.ProjectLibraryBase; import com.jero.modules.project.entity.ProjectRelatedPersonnel; import com.jero.modules.project.mapper.ProjectLibraryBaseMapper; import com.jero.modules.project.service.IProjectRelatedPersonnelService; +import com.jero.modules.split.common.FileUnZip; +import com.jero.modules.split.common.ReadExcel; import com.jero.modules.system.entity.SysAnnouncement; import com.jero.modules.system.entity.SysDictItem; import com.jero.modules.system.entity.SysUser; @@ -58,9 +61,12 @@ import com.jero.modules.system.service.ISysAnnouncementService; import com.jero.modules.system.service.ISysDictItemService; import com.jero.modules.system.service.ISysUserRoleService; import com.jero.modules.system.service.ISysUserService; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.usermodel.*; import org.apache.shiro.SecurityUtils; @@ -88,6 +94,8 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; +import static com.jero.modules.split.util.ExcelUtil.checkObjAllFieldsIsNull; + /** * @Description: 参数项收集清单 * @Author: jero-boot @@ -2317,6 +2325,375 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl fieldList = Arrays.asList(field.split(",")); // list形式 + + // 查询导出数据 + List> allParamsInfoList = queryForExportDre(paramsCollectManifestVO); // id记得去掉 + + // 在excel表中添加表头 + XSSFRow row = sheetItems.createRow(0); + for (int i = 0; i < headers.length; i++) { + XSSFCell cell = row.createCell(i); + XSSFRichTextString text = new XSSFRichTextString(headers[i]); + cell.setCellValue(text); + cell.setCellStyle(cellStyle1); + sheetItems.setColumnWidth(i, 20 * 256); // 设置单元格宽度 + } + // 在excel表中添加添加填写说明 + String explanation = ""; + if (CutEnum.EN.getValue().equals(paramsCollectManifestVO.getCut())) { + explanation = "Filling explanation\n" + + "1.Import data starts at the third line, the first line is the header, the second line is the description, the third line is the example, and the fourth line is the official data\n" + + "2.All fields is filled in according to Validate Component and Component Value\n" + + "3.If the control type is drop-down multi-selection, multiple entries are separated by English or Chinese exclamation points\n" + + "4.Configuration data is filled in according to the control type, and if there are multiple control types, it needs to be separated by \"#\"\n" + + "5.When filling in, start in column G and do not modify information such as NIO number and parameter name\n" + + "6.File fields are file type, must create a folder in the directory of the same level as the file with the name of the nio number and place the file in the folder. Assume that the file is saved in the A number B.pdf,Should fill in A/B.pdf\n" + + "7.When importing into the system, you need to put the Excel into a folder, place other attachment files correctly as required, and finally compress the folder into zip format for import\n"; + } else { + explanation = "填写说明\n" + + "1.导入数据从第三行开始,第一行为表头,第二行为填写说明,第三行是示例数据,需要从第四行开始填写\n" + + "2.填写时需按照控件校验和控件备选值进行填写\n" + + "3.控件类型为下拉多选时,填写多个时采用英文或中文感叹号分割\n" + + "4.配置数据按照控件类型进行填写,若存在多种控件类型填写时需要通过“#”隔开\n" + + "5.填写时从G列开始,请勿修改NIO编号和参数名称等信息\n" + + "6.上传附件为文件属性,填写时需要在本文件同级目录下以NIO编号为名称建立文件夹,并在文件夹下放置文件且该文件夹下只能有一层级,假设在NIO.XXXX下放置了B.pdf,则应填写NIO.XXXX/B.pdf\n" + + "7.导入系统时,需要将该Excel放入文件夹内,并按照要求正确放置其他附件文件,最后将文件夹压缩为zip格式进行导入\n"; + } + XSSFRow row2 = sheetItems.createRow(1); + row2.setHeight((short) 1000); + Cell cell2 = row2.createCell(0); + cell2.setCellStyle(cellStyle); + cell2.setCellValue(new XSSFRichTextString(explanation)); + + // 在excel表中添加添加填写示例 + String[] exampleRow = titles[2].split(","); + XSSFRow row3 = sheetItems.createRow(2); + for (int i = 0; i < exampleRow.length; i++) { + XSSFCell cell3 = row3.createCell(i); + XSSFRichTextString text = new XSSFRichTextString(exampleRow[i]); + cell3.setCellValue(text); + cell3.setCellStyle(cellStyle1); + sheetItems.setColumnWidth(i, 20 * 256); // 设置单元格宽度 + } + + //放文字内容 + int allRow = 2; + for(int rowNum = 0;rowNum < allParamsInfoList.size(); rowNum++){ + Map exportDto = allParamsInfoList.get(rowNum); + + allRow++; + XSSFRow row1 = sheetItems.createRow(allRow); + for(int cellNum = 0; cellNum < fieldList.size(); cellNum++){ + if (ObjectUtils.isNotEmpty(exportDto.get(fieldList.get(cellNum)))) { + row1.createCell(cellNum).setCellValue(exportDto.get(fieldList.get(cellNum)).toString()); + row1.getCell(cellNum).setCellStyle(cellStyle); + + } + } + + } + + String repFileName = fileName.replaceAll("/","_"); + excelOS = new FileOutputStream(fileNowPath + File.separator + repFileName); + response.setHeader("Content-Disposition", + "attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".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) { + if (e instanceof JeroBootException){ + throw new JeroBootException(e.getMessage()); + } else { + log.error(e.getMessage(), e); + if (CutEnum.EN.getValue().equals(paramsCollectManifestVO.getCut())) { + throw new JeroBootException("Failed to download file, please try again"); + } else { + throw new JeroBootException("下载文件失败,请重试"); + } + + } + } finally { +// IOUtils.closeQuietly(os); + IOUtils.closeQuietly(excelOS); + File tempZipFile = new File(uploadpath + "/tempZip"); + FileUtil.deleteContents(tempZipFile); + } + } + + @Override + public Result importDre(MultipartFile file, String cut, String paramsManifestId) throws IOException { + //验证文件名是否合格 + /* 截取后缀名 */ + int pos = file.getOriginalFilename().lastIndexOf("."); + String str = file.getOriginalFilename().substring(pos+1).toLowerCase(); + String filenameorg = file.getOriginalFilename().substring(0,pos); + String resultMsg = ""; + //判断上传文件必须是zip + if (!str.equals("zip")) { + if(CutEnum.CN.getValue().equals(cut)){ + resultMsg = "请上传zip文件"; + }else{ + resultMsg = "Please upload a zip file"; + } + return Result.error(resultMsg); + } + String path = uploadpath + File.separator + "modal" + File.separator + filenameorg + System.currentTimeMillis(); + File saveDirectory = new File(path); + if(!saveDirectory.isDirectory()){ + saveDirectory.mkdir(); + } + FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path +File.separator+ file.getOriginalFilename())); + try{ + //解压缩 + String zipEntryName = FileUnZip.unZipFiles2(path +File.separator+ file.getOriginalFilename(), path); + // 数据相关处理, + // 1.获取其中的Excel, + List excelfilelist = FileUnZip.readExcelFile(zipEntryName); + if(excelfilelist.size()<1){ + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + if(CutEnum.CN.getValue().equals(cut)){ + resultMsg = "压缩包内没有上传Excel数据"; + }else{ + resultMsg = "In the cabinet did not upload the Excel data"; + } + return Result.error(1, resultMsg); + + } else if (excelfilelist.size()>1) { + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + if(CutEnum.CN.getValue().equals(cut)){ + resultMsg = "压缩包根目录下仅能存在一个excel为导入数据"; + }else{ + resultMsg = "Only one Excel file can be imported in the compressed package root directory"; + } + return Result.error(1, resultMsg); + } + File excelfile = excelfilelist.get(0); + // 导入参数设置,默认即可 + ImportParams params = new ImportParams(); + try { + // 导入表头 + ParamsCollectManifestVO paramsCollectManifestVO = new ParamsCollectManifestVO(); + paramsCollectManifestVO.setCut(cut); + paramsCollectManifestVO.setParamsManifestId(paramsManifestId); + String titles[] = getWorkbookTitleForExportDre(paramsCollectManifestVO); // 有顺序 + String headers[] = titles[1].split(","); + params.setImportFields(headers); + + List> result = new ArrayList<>(); + List dbfieldList = Arrays.asList(titles[0].split(",")); // 有顺序 + + // 解析excel + result = read(excelfile, dbfieldList, headers, cut); + + //excel读取到的数据 + List> datas = result; + if(datas!=null &&!datas.isEmpty()){ + try { + //获取全部sheet页中表格 + XSSFWorkbook workbook=new XSSFWorkbook(new FileInputStream(excelfile)); + int i = 0 ; + List> datasUpdate = new ArrayList<>(); + //处理空行数据,当读取exceL出现空行过多时,空行数为20以上时中断读取,将数据清洗为新的list + for(Map importDto :datas){ + if(i>20){ + break; + } + //判断此行数据是否全部为空 + if(checkObjAllFieldsIsNull(importDto)){ + i++; + //是则不读取 + continue; + } + i = 0; + datasUpdate.add(importDto); + } + String unzipfilepath = zipEntryName; + Result message = importData(datasUpdate,unzipfilepath,cut,paramsManifestId); + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return message; + } catch (Exception e) { + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return Result.error(e.getMessage()); + } + }else{ + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + if(CutEnum.CN.getValue().equals(cut)){ + resultMsg = "没有可导入的数据,请检查!"; + }else{ + resultMsg = "No data to import, please check"; + } + return Result.error(1, resultMsg); + } + } catch (NoSuchElementException e){ + FileUnZip.deleteDir(saveDirectory); + if(CutEnum.CN.getValue().equals(cut)){ + resultMsg = "没有可导入的数据,请检查!"; + }else{ + resultMsg = "No data to import, please check"; + } + return Result.error(1, resultMsg); + } catch (JeroBootException e){ + FileUnZip.deleteDir(saveDirectory); + return Result.error(1, e.getMessage()); + } catch (Exception e) { + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + if(CutEnum.CN.getValue().equals(cut)){ + resultMsg = "读取失败,请严格按照模板文件导入数据"; + }else{ + resultMsg = "The data fails to be read. Import data strictly according to the template file"; + } + return Result.error(1, resultMsg); + } + } catch (Exception e) { + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + if(CutEnum.CN.getValue().equals(cut)){ + resultMsg = "读取失败,请严格按照模板文件导入数据"; + }else{ + resultMsg = "The data fails to be read. Import data strictly according to the template file"; + } + return Result.error(1, resultMsg); + } + } + + @Override + public Result importData(List> dataList, + String unzipfilepath, + String cut, + String paramsManifestId) throws IOException { + //验证导入数据是否符合规则 + Map map = validateImportDatas(dataList,unzipfilepath,cut,paramsManifestId); + boolean isOk = (boolean) map.get("result"); + if (!isOk) { + //验证没有通过 + String message = (String) map.get("message"); + return Result.error(message); + } + //将导入数据循环合并整理后 新增至相应表 + List configDataList = (List) map.get("configDataList"); + + + + List paramsInfoEOS = new ArrayList<>(); + for (ParamsConfigDataEO importDto : configDataList) { + //判断此行数据是否全部为空,是则不读取 + if (checkObjAllFieldsIsNull(importDto)) { + continue; + } + // 处理文件 + if (StringUtils.isNotBlank(importDto.getFileConnectId())) { // 判空,否则报空指针异常 + List nowFileList = FileUnZip.readFileByFilename(unzipfilepath, importDto.getFileConnectId(), null, null, null, null, null); + + FileInputStream input = new FileInputStream(nowFileList.get(0)); + MultipartFile multipartFile = + new MockMultipartFile(nowFileList.get(0).getName(), nowFileList.get(0).getName(), "text/plain", input); + //文件存入文件表 + OSSFile ossFile = ossFileService.uploadLocalOfCos(multipartFile, "", null, null); + if (ObjectUtils.isNotEmpty(ossFile)) { + String connectId = UUID.randomUUID().toString().replace("-", ""); + OSSFile ossFileUpdate = new OSSFile(); + ossFileUpdate.setId(ossFile.getId()); + ossFileUpdate.setConnectId(connectId); + ossFileService.updateById(ossFileUpdate); + + importDto.setFileConnectId(connectId); + } + } + + // 处理下拉值 + String newPullData = importDto.getPullData().replaceAll("!", "!").replaceAll("!",","); + importDto.setPullData(newPullData); + } + + // 批量新增参数项 + Boolean isSuccess = paramsConfigDataEOService.saveOrUpdateBatch(configDataList); + + String msg = ""; + if (isSuccess) { + int countSuccess = paramsInfoEOS.size(); + if (CutEnum.CN.getValue().equals(cut)) { + msg = "成功导入" + countSuccess + "条"; + } else { + msg = "import " + countSuccess + " datas successfully"; + } + return Result.OK(msg, null); + } else { + if (CutEnum.CN.getValue().equals(cut)) { + msg = "导入失败"; + } else { + msg = "import failed"; + } + return Result.error(1, msg); + } + } + @Override public List updateBatchDutyTerritory(ParamsCollectManifestVO paramsCollectManifestVO) { if (StringUtils.isEmpty(paramsCollectManifestVO.getIds()) @@ -2457,6 +2834,88 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl fieldList = onlCgformFieldService.getFieldList(ModuleEnum.PARAMS_COLLECT_MANIFEST.getValue()); + + List dbFieldNameList = new LinkedList<>(); + List dbFieldList = new LinkedList<>(); + List dbFieldExampleList = new LinkedList<>(); + + // 固定列 + for (int i = 0; i < fieldList.size(); i++) { + OnlCgformField onlCgformField = fieldList.get(i); + String dbFieldName = onlCgformField.getDbFieldName(); + if ("nio_number".equals(dbFieldName) || "params_name".equals(dbFieldName) || "description".equals(dbFieldName) + || "control_type".equals(dbFieldName) || "control_verify".equals(dbFieldName) || "control_values".equals(dbFieldName)) { + dbFieldList.add(dbFieldName); + + if(CutEnum.CN.getValue().equals(cut)){ + dbFieldNameList.add(onlCgformField.getDbFieldTxt()); // 字段中文名 + if("nio_number".equals(dbFieldName)) { + dbFieldExampleList.add("例NIO.XXXX"); + } else if("params_name".equals(dbFieldName) || "description".equals(dbFieldName)) { + dbFieldExampleList.add("XXXXX"); + + } else if("control_verify".equals(dbFieldName)) { + dbFieldExampleList.add("数据来源于参数模版管理中控件校验数据"); + + } else if("control_values".equals(dbFieldName)) { + dbFieldExampleList.add("数据来源于参数模版管理中控件备选值数据"); + + } else { + dbFieldExampleList.add("下拉多选#文本"); + } + }else{ + dbFieldNameList.add(onlCgformField.getDbFieldEnName()); // 字段英文名 + if("nio_number".equals(dbFieldName)) { + dbFieldExampleList.add("Example:NIO.XXXX"); + } else if("params_name".equals(dbFieldName) || "description".equals(dbFieldName)) { + dbFieldExampleList.add("XXXXX"); + + } else if("control_verify".equals(dbFieldName)) { + dbFieldExampleList.add("The data comes from Validate Component in the parameter template management"); + + } else if("control_values".equals(dbFieldName)) { + dbFieldExampleList.add("The data comes from Component Value in the parameter template management"); + + } else { + dbFieldExampleList.add("Pull more+File"); + } + } + + + } + } + + // 配置列 + List dbFieldNameListConfig = new LinkedList<>(); + List dbFieldListConfig = new LinkedList<>(); + List paramsConfigEOList = paramsConfigEOService.queryList(paramsManifestId); + for (ParamsConfigEO paramsConfigEO : paramsConfigEOList) { + if (ConfigLockEnum.NO.getValue().equals(paramsConfigEO.getIsLock())) { // 只导出未冻结的配置列 + dbFieldListConfig.add(paramsConfigEO.getId()); + dbFieldNameListConfig.add(paramsConfigEO.getConfigName()); + } + } + + // 插入配置列 + dbFieldList.addAll(dbFieldListConfig); + dbFieldNameList.addAll(dbFieldNameListConfig); + + String[] title = new String[3]; + String dbFieldStr = StringUtils.join(dbFieldList, ","); + String dbFieldNameStr = StringUtils.join(dbFieldNameList, ","); + String dbFieldExampleStr = StringUtils.join(dbFieldExampleList, ","); + + title[0] = dbFieldStr; + title[1] = dbFieldNameStr; + title[2] = dbFieldExampleStr; + return title; + } + private List> queryForExportAll(ParamsCollectManifestVO paramsCollectManifestVO) { String paramsManifestId = paramsCollectManifestVO.getParamsManifestId(); String paramsTemplateId = paramsCollectManifestVO.getParamsTemplateId(); @@ -2474,7 +2933,7 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl> dataList = paramsCollectManifestEOMapper.listInfoForExport(queryEO); // 查询导出数据 + List> dataList = paramsCollectManifestEOMapper.listInfoForExport(queryEO, null); // 查询导出数据 if (dataList == null || dataList.isEmpty()){ // 没有查到数据,进行提示 if (CutEnum.EN.getValue().equals(paramsCollectManifestVO.getCut())) { @@ -2567,6 +3026,51 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl> queryForExportDre(ParamsCollectManifestVO paramsCollectManifestVO) { + String paramsManifestId = paramsCollectManifestVO.getParamsManifestId(); +// String paramsTemplateId = paramsCollectManifestVO.getParamsTemplateId(); +// Integer paramsTemplatePublishVersion = paramsCollectManifestVO.getParamsTemplatePublishVersion(); + String cut = paramsCollectManifestVO.getCut(); + String ids = paramsCollectManifestVO.getIds(); + + LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + + ParamsCollectManifestEO queryEO = new ParamsCollectManifestEO(); + queryEO.setParamsManifestId(paramsManifestId); + +// String userTypes = paramsCollectManifestVO.getUserTypes(); + queryEO.setUserTypes(CollectManifestUserTypeEnum.DRE.getValue()); + queryEO.setDreForAuth(loginUser.getUsername()); + queryEO.setState(CollectManifestStateEnum.WAIT_FILL.getValue() + "," + CollectManifestStateEnum.CERT_BACK.getValue()); + + List> dataList = paramsCollectManifestEOMapper.listInfoForExport(queryEO, ids); // 查询导出数据 + if (dataList == null || dataList.isEmpty()){ + // 没有查到数据,进行提示 + if (CutEnum.EN.getValue().equals(paramsCollectManifestVO.getCut())) { + throw new JeroBootException("No data, unable to export"); + } else { + throw new JeroBootException("无数据,无法导出"); + } + } + + Map isMustMap = ParamsIsMustEnum.toMapForExport(cut); + Map controlVerifyMap = ControlVerifyEnum.toMapForExport(cut); + Map controlTypeMap = ControlTypeEnum.toMapForExport(cut); + // 插入配置列和认证类别列数据 + for (Map record1 : dataList) { + String controlType = (String) record1.get("control_type"); + String controlVerify = (String) record1.get("control_verify"); + String isMust = (String) record1.get("is_must"); + + record1.put("is_must", isMustMap.get(isMust)); + record1.put("control_type", controlTypeMap.get(controlType)); + record1.put("control_verify", controlVerifyMap.get(controlVerify)); + + } + return dataList; + } + private void downLoadFileList(List fileTemplateList,Map fileNowPathMap) { for(OSSFile fileExportDto : fileTemplateList){ String fileNowPath = fileNowPathMap.get(fileExportDto.getId()); @@ -2735,6 +3239,621 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl> read(File file, List dbfieldList, String[] titles, String cut) throws Exception { + + //最终返回数据 + List> list = new ArrayList<>(); + + Workbook workbook = null; + InputStream is = new FileInputStream(file); + String name = file.getName().toLowerCase(); + // 创建excel操作对象 + if (name.contains(".xlsx")) { + workbook = WorkbookFactory.create(is); + } else { + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("请导入正确模板!"); + } else { + throw new JeroBootException("Please import the correct template"); + } + } + //得到一个工作表 + Sheet sheet = workbook.getSheetAt(0); + + //获得数据的总行数 + int totalRowNum = sheet.getLastRowNum(); + + //获得总列数 + int cellLength = sheet.getRow(0).getPhysicalNumberOfCells(); + // 验证模板表头是否正确 + Row rowTitle = sheet.getRow(0); + for (int i = 0; i < cellLength; i++) { + if (rowTitle != null) { + Cell cell = rowTitle.getCell(i); + if(ObjectUtil.isNotNull(cell)){ + //设置单元格类型 + cell.setCellType(CellType.STRING); + String cellValue = cell.getStringCellValue().substring(cell.getStringCellValue().indexOf("*")+1); + if(!cellValue.equals(titles[i])){ + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("请导入正确模板!"); + } else { + throw new JeroBootException("Please import the correct template"); + } + } + } else{ + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("请导入正确模板!"); + } else { + throw new JeroBootException("Please import the correct template"); + } + } + }else{ + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("请导入正确模板!"); + } else { + throw new JeroBootException("Please import the correct template"); + } + } + } + Row rowDescription= sheet.getRow(1); + if (rowDescription != null) { + Cell cell = rowDescription.getCell(0); + if(ObjectUtil.isNotNull(cell)){ + //设置单元格类型 + cell.setCellType(CellType.STRING); + String cellValue = cell.getStringCellValue(); + if(!cellValue.startsWith("填写说明") || !cellValue.startsWith("Filling explanation")){ + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("请导入正确模板!"); + } else { + throw new JeroBootException("Please import the correct template"); + } + } + } else{ + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("请导入正确模板!"); + } else { + throw new JeroBootException("Please import the correct template"); + } + } + }else{ + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("请导入正确模板!"); + } else { + throw new JeroBootException("Please import the correct template"); + } + } + Row rowExample= sheet.getRow(2); + if (rowExample != null) { + Cell cell = rowExample.getCell(0); + if(ObjectUtil.isNotNull(cell)){ + //设置单元格类型 + cell.setCellType(CellType.STRING); + String cellValue = cell.getStringCellValue(); + if(!cellValue.startsWith("例") || !cellValue.startsWith("Example")){ + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("请导入正确模板!"); + } else { + throw new JeroBootException("Please import the correct template"); + } + } + } else{ + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("请导入正确模板!"); + } else { + throw new JeroBootException("Please import the correct template"); + } + } + }else{ + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("请导入正确模板!"); + } else { + throw new JeroBootException("Please import the correct template"); + } + } + + Map map = null; + //获得所有数据 + //从第4行开始获取,第一行是表头,第二行是填写说明, 第三行是填写示例 + for (int x = 3; x <= totalRowNum; x++) { + map = new HashMap(); + //获得第i行对象 + Row row= sheet.getRow(x); + //如果一行里的所有单元格都为空则不放进list里面 + int a = 0; + for (int y = 0; y < cellLength; y++) { + if (!(row == null)) { + Cell cell = row.getCell(y); // cell 为空时会抛空指针异常 + if(ObjectUtil.isNull(cell)) { + map.put(dbfieldList.get(y), ""); + continue; + } + + cell.setCellType(CellType.STRING); //设置单元格类型 + String cellValue = cell.getStringCellValue(); + + // + map.put(dbfieldList.get(y), cellValue); + if (map.get(dbfieldList.get(y)) == null || "".equals(map.get(dbfieldList.get(y)))) { + a++; + } + } + } + // 当前行所有单元格均不为空时 + if (a != cellLength && row != null) { + list.add(map); + } + } + return list; + } + + private Map validateImportDatas(List> dataList, + String unzipfilepath, + String cut, + String paramsManifestId) { + // 查询清单的配置列信息 + List paramsConfigEOList = paramsConfigEOService.queryList(paramsManifestId); + Map configMap = paramsConfigEOList.stream().collect(Collectors.toMap(ParamsConfigEO::getConfigName, ParamsConfigEO::getId)); + // 查询清单参数项 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ParamsCollectManifestEO::getParamsManifestId, paramsManifestId); + List paramsCollectManifestEOList = paramsCollectManifestEOMapper.selectList(queryWrapper); + Map collectManifestMap = paramsCollectManifestEOList.stream().collect(Collectors.toMap(ParamsCollectManifestEO::getNioNumber, ParamsCollectManifestEO::getId)); + // 查询清单的配置数据 + List configIdList = paramsConfigEOList.stream().map(ParamsConfigEO::getId).collect(Collectors.toList()); + List paramsConfigDataEOList = paramsConfigDataEOService.queryListByConfigIdList(configIdList); + + Map controlTypeMap = ControlTypeEnum.toMapForImport(cut); + Map controlVerifyMap = ControlVerifyEnum.toMapForImport(cut); + Map paramsIsMustMap = ParamsIsMustEnum.toMapForImport(cut); + + //存放数据验证结果信息 + List configDataList = new ArrayList<>(); + List stringMessage = new ArrayList<>(); + int i = 2; //记录行号 + int num = 0; //记录是第几条数据 + //循环验证数据 + for (Map dto : dataList) { + i++; + int countError = 0; //记录失败数据数量 + String errorMsg = ""; + if (CutEnum.CN.getValue().equals(cut)) { + errorMsg = "第" + i + "行:"; + } else { + errorMsg = i + " line:"; + } + + Map resultMap = new HashMap<>(); + String nioNumber = (String) dto.get("nio_number"); + String controlType = controlTypeMap.get((String) dto.get("control_type")); + String controlVerify = controlVerifyMap.get((String) dto.get("control_verify")); + String controlValues = (String) dto.get("control_values"); + String isMust = paramsIsMustMap.get((String) dto.get("is_must")); + for (Map.Entry entry : dto.entrySet()) { + String key = entry.getKey(); + String value = (String) entry.getValue(); + + if ("nio_number".equals(key) || "params_name".equals(key) || "description".equals(key) + || "control_type".equals(key) || "control_verify".equals(key) || "control_values".equals(key)) { + continue; + } + // + ParamsConfigDataEO configDataEO = new ParamsConfigDataEO(); + List list = paramsConfigDataEOList.stream().filter(e-> collectManifestMap.get(nioNumber).equals(e.getParamsCollectManifestId()) + && configMap.get(key).equals(e.getParamsConfigId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(list)) { + configDataEO.setId(list.get(0).getId()); + } + configDataEO.setParamsCollectManifestId(collectManifestMap.get(nioNumber)); + configDataEO.setParamsConfigId(configMap.get(key)); + + + // 校验配置列 + if (ControlTypeEnum.TEXT.getValue().equals(value)) { + resultMap = validateText(key, controlVerify, value, isMust, "1000", cut); + errorMsg += (String)resultMap.get("errorMsg"); + countError += (int)resultMap.get("countError"); + + configDataEO.setTextData(value); + + } else if (ControlTypeEnum.PULL_SINGLE.getValue().equals(value)) { + resultMap = validatePull(key, controlValues, value, isMust, true, cut); + errorMsg += (String)resultMap.get("errorMsg"); + countError += (int)resultMap.get("countError"); + + configDataEO.setPullData(value); + + } else if (ControlTypeEnum.PULL_MORE.getValue().equals(value)) { + resultMap = validatePull(key, controlValues, value, isMust, false, cut); + errorMsg += (String)resultMap.get("errorMsg"); + countError += (int)resultMap.get("countError"); + + configDataEO.setPullData(value); + + } else if (ControlTypeEnum.FILE.getValue().equals(value)) { + resultMap = validateFile(key, unzipfilepath, value, isMust , cut); + errorMsg += (String)resultMap.get("errorMsg"); + countError += (int)resultMap.get("countError"); + + configDataEO.setFileConnectId(value); + + } else if (ControlTypeEnum.TEXT_PULL_SINGLE.getValue().equals(value)) { + // 校验必填 + if (ParamsIsMustEnum.YES.getValue().equals(isMust) && StringUtils.isEmpty(value)) { + if(CutEnum.CN.getValue().equals(cut)) { + errorMsg += key + "为必填项,不能为空;"; + } else { + errorMsg += key + " is mandatory and cannot be empty; "; + } + countError++; + } else { + resultMap = validatePull(key, controlValues, value.split("#")[0], isMust, true, cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setPullData(value.split("#")[0]); + + if (value.split("#").length > 1) { + resultMap = validateText(key, controlVerify, value.split("#")[1], ParamsIsMustEnum.NO.getValue(), "1000", cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setTextData(value.split("#")[1]); + } + } + + } else if (ControlTypeEnum.TEXT_PULL_MORE.getValue().equals(value)) { + // 校验必填 + if (ParamsIsMustEnum.YES.getValue().equals(isMust) && StringUtils.isEmpty(value)) { + if(CutEnum.CN.getValue().equals(cut)) { + errorMsg += key + "为必填项,不能为空;"; + } else { + errorMsg += key + " is mandatory and cannot be empty; "; + } + countError++; + } else { + resultMap = validatePull(key, controlValues, value.split("#")[0], isMust, false, cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setPullData(value.split("#")[0]); + + if (value.split("#").length > 1) { + resultMap = validateText(key, controlVerify, value.split("#")[1], ParamsIsMustEnum.NO.getValue(), "1000", cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setTextData(value.split("#")[1]); + } + } + + } else if (ControlTypeEnum.TEXT_FILE.getValue().equals(value)) { + // 校验必填 + if (ParamsIsMustEnum.YES.getValue().equals(isMust) && StringUtils.isEmpty(value)) { + if(CutEnum.CN.getValue().equals(cut)) { + errorMsg += key + "为必填项,不能为空;"; + } else { + errorMsg += key + " is mandatory and cannot be empty; "; + } + countError++; + } else { + resultMap = validateText(key, controlVerify, value.split("#")[0], isMust, "1000", cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setTextData(value.split("#")[0]); + + if (value.split("#").length > 1) { + resultMap = validateFile(key, unzipfilepath, value.split("#")[1], ParamsIsMustEnum.NO.getValue(), cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setFileConnectId(value.split("#")[1]); + } + } + + } else if (ControlTypeEnum.PULL_SINGLE_FILE.getValue().equals(value)) { + // 校验必填 + if (ParamsIsMustEnum.YES.getValue().equals(isMust) && StringUtils.isEmpty(value)) { + if(CutEnum.CN.getValue().equals(cut)) { + errorMsg += key + "为必填项,不能为空;"; + } else { + errorMsg += key + " is mandatory and cannot be empty; "; + } + countError++; + } else { + resultMap = validatePull(key, controlValues, value.split("#")[0], isMust, true, cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setPullData(value.split("#")[0]); + + if (value.split("#").length > 1) { + resultMap = validateFile(key, unzipfilepath, value.split("#")[1], ParamsIsMustEnum.NO.getValue(), cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setFileConnectId(value.split("#")[1]); + } + } + + } else if (ControlTypeEnum.PULL_MORE_FILE.getValue().equals(value)) { + // 校验必填 + if (ParamsIsMustEnum.YES.getValue().equals(isMust) && StringUtils.isEmpty(value)) { + if(CutEnum.CN.getValue().equals(cut)) { + errorMsg += key + "为必填项,不能为空;"; + } else { + errorMsg += key + " is mandatory and cannot be empty; "; + } + countError++; + } else { + resultMap = validatePull(key, controlValues, value.split("#")[0], isMust, false, cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setPullData(value.split("#")[0]); + + if (value.split("#").length > 1) { + resultMap = validateFile(key, unzipfilepath, value.split("#")[1], ParamsIsMustEnum.NO.getValue(), cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setFileConnectId(value.split("#")[1]); + } + } + + } else if (ControlTypeEnum.TEXT_PULL_SINGLE_FILE.getValue().equals(value)) { + // 校验必填 + if (ParamsIsMustEnum.YES.getValue().equals(isMust) && StringUtils.isEmpty(value)) { + if(CutEnum.CN.getValue().equals(cut)) { + errorMsg += key + "为必填项,不能为空;"; + } else { + errorMsg += key + " is mandatory and cannot be empty; "; + } + countError++; + } else { + resultMap = validatePull(key, controlValues, value.split("#")[0], isMust, false, cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setPullData(value.split("#")[0]); + + if (value.split("#").length > 1) { + resultMap = validateText(key, controlVerify, value.split("#")[1], ParamsIsMustEnum.NO.getValue(), "1000", cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setTextData(value.split("#")[1]); + } + + if (value.split("#").length > 2) { + resultMap = validateFile(key, unzipfilepath, value.split("#")[2], ParamsIsMustEnum.NO.getValue(), cut); + errorMsg += (String) resultMap.get("errorMsg"); + countError += (int) resultMap.get("countError"); + configDataEO.setFileConnectId(value.split("#")[2]); + } + } + + } else { + + if (CutEnum.EN.getValue().equals(cut)) { + errorMsg += key + "did not match the Control Component in the system; "; + countError ++; + } else { + errorMsg += key + "未匹配到系统中的控件类型"; + countError ++; + } + } + configDataList.add(configDataEO); + } + + if (countError > 0) { + stringMessage.add(errorMsg); + } + + } + Map map = new HashMap(); + if (stringMessage.isEmpty()) { + map.put("result", true); + map.put("configDataList", configDataList); + map.put("message", ""); + } else { + map.put("result", false); + String html = ""; + for (String message : stringMessage) { + html += message + "
"; + } + map.put("message", html); + } + return map; + + } + + private Map validateFile(String configName, String unzipfilepath, String value, String mustInput, String cut) { + String errorMsg = ""; + int countError= 0; + Map resultMap = new HashMap<>(); + + // 校验必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isEmpty(value)) { + if(CutEnum.CN.getValue().equals(cut)) { + errorMsg += configName + "为必填项,不能为空;"; + } else { + errorMsg += configName + " is mandatory and cannot be empty; "; + } + countError++; + } + + String fileName = value; + if (StringUtils.isNotBlank(fileName)) { + fileName = fileName.replace(",", ","); + if (fileName.contains(",")) { + if (CutEnum.CN.getValue().equals(cut)) { + errorMsg += "附件模板只能上传一个文件;"; + } else { + errorMsg += "File template only can upload one; "; + } + } + List nowFileList = FileUnZip.readFileByFilename(unzipfilepath, fileName, null, null, null, null, null); +// List nowFileList = FileUnZip.readFileByFilename(filepath, fileName); + if (nowFileList.size() == 0) { + if (CutEnum.CN.getValue().equals(cut)) { + errorMsg += "附件模板压缩包中没有" + fileName + "文件; "; + } else { + errorMsg += "File template " + fileName + "isn't present in the cabinet; "; + } + countError++; + } + } + + resultMap.put("errorMsg", errorMsg); + resultMap.put("countError", countError); + return resultMap; + } + + private Map validatePull(String configName, String controlValues, String value, String mustInput, Boolean isSingle, String cut) { + String errorMsg = ""; + int countError= 0; + List controlValueList = Arrays.asList(controlValues.split(",")); + Map resultMap = new HashMap<>(); +// StringBuilder newValue = new StringBuilder(); + + // 校验必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isEmpty(value)) { + if(CutEnum.CN.getValue().equals(cut)) { + errorMsg += configName + "为必填项,不能为空;"; + } else { + errorMsg += configName + " is mandatory and cannot be empty; "; + } + countError++; + } + + //判断是否是单选 + if (isSingle) { + if (StringUtils.isNotBlank(value) && value.contains(",")) { + if (CutEnum.CN.getValue().equals(cut)) { + errorMsg += configName + "为单选项;"; + } else { + errorMsg += configName + " is single type; "; + } + countError++; + } else { + // 判断是否符合备选值 + if (!controlValueList.contains(value)) { + if (CutEnum.CN.getValue().equals(cut)) { + errorMsg += configName + "中的" + value + "不正确;"; + } else { + errorMsg += configName + " " + value + " is not correct; "; + } + countError++; + } + } + } else { + // 判断是否符合备选值 + value = value.replaceAll("!", "!"); + List valueList = Arrays.asList(value.split("!")); + for(String v : valueList) { + if (!controlValueList.contains(v)) { + if (CutEnum.CN.getValue().equals(cut)) { + errorMsg += configName + "中的" + value + "不正确;"; + } else { + errorMsg += configName + " " + value + " is not correct; "; + } + countError++; + } +// else { +// +// newValue.append(v).append(","); +// } + } + } + +// resultMap.put("value", newValue.toString()); + resultMap.put("errorMsg", errorMsg); + resultMap.put("countError", countError); + return resultMap; + } + + private Map validateText(String configName, String controlVerify, String value, String mustInput, String dbLength, String cut) { + String errorMsg = ""; + int countError= 0; + Map resultMap = new HashMap<>(); + + // 校验必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isEmpty(value)) { + if(CutEnum.CN.getValue().equals(cut)) { + errorMsg += configName + "为必填项,不能为空;"; + } else { + errorMsg += configName + " is mandatory and cannot be empty; "; + } + countError++; + } + + // 校验长度 + if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) { + if(CutEnum.CN.getValue().equals(cut)) { + errorMsg += configName + "不能超过" + dbLength + "个字符;"; + } else { + errorMsg += configName + " can not be more than " + dbLength + " char; "; + } + countError++; + } + + String regex = ""; + Boolean result = false; + Boolean flag = false; + if (ControlVerifyEnum.CHINESE.getValue().equals(controlVerify)) { + regex = "^[\\u4e00-\\u9fa5]{0,}$"; + result = value.matches(regex); + + } else if (ControlVerifyEnum.POSITIVE_INTEGER.getValue().equals(controlVerify)) { + regex = "^[0-9]*$"; + result = value.matches(regex); + + } else if (ControlVerifyEnum.POSITIVE_FLOAT.getValue().equals(controlVerify)) { + regex = "^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*$ 或 ^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$"; + result = value.matches(regex); + + } else if (ControlVerifyEnum.INTEGER_DECIMAL.getValue().equals(controlVerify)) { + regex = "^(\\-|\\+)?\\d+(\\.\\d+)?$"; + result = value.matches(regex); + + } else if (ControlVerifyEnum.DECIMAL_ONE.getValue().equals(controlVerify)) { + regex = "^(\\-)?\\d+(\\.\\d{1})$"; + result = value.matches(regex); + + } else if (ControlVerifyEnum.DECIMAL_TWO.getValue().equals(controlVerify)) { + regex = "^(\\-)?\\d+(\\.\\d{2})$"; + result = value.matches(regex); + + } else if (ControlVerifyEnum.DECIMAL_THREE.getValue().equals(controlVerify)) { + regex = "^(\\-)?\\d+(\\.\\d{3})$"; + result = value.matches(regex); + + } else if (ControlVerifyEnum.DECIMAL_FOUR.getValue().equals(controlVerify)) { + regex = "^(\\-)?\\d+(\\.\\d{4})$"; + result = value.matches(regex); + + } else { + flag = true; + } + + if (CutEnum.EN.getValue().equals(cut)) { + if (flag) { + errorMsg += configName + " did not match the Validate Component in the system; "; + countError++; + } else { + if(result) { + errorMsg += configName + " Validate Component is wrong; "; + countError++; + } + } + + } else { + if (flag) { + errorMsg += configName + "未匹配到系统中的控件校验;"; + countError++; + } else { + if(result) { + errorMsg += configName + "文本的控件校验不正确;"; + countError++; + } + } + } + + resultMap.put("errorMsg", errorMsg); + resultMap.put("countError", countError); + return resultMap; + } /** * 实体对象转成Map * @param obj 实体对象 diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsManifestEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsManifestEOServiceImpl.java index 114509fbc..90ac5c6ba 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsManifestEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsManifestEOServiceImpl.java @@ -693,7 +693,7 @@ public class ParamsManifestEOServiceImpl extends ServiceImpl> listAll = paramsCollectManifestEOMapper.listInfoForExport(paramsCollectManifestEO); + List> listAll = paramsCollectManifestEOMapper.listInfoForExport(paramsCollectManifestEO, null); // 循环责任领域,计算每个责任领域中的四种状态数据 for (DictModel item : dutyTerritoryDictList) { diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ControlTypeEnum.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ControlTypeEnum.java index 9304ce180..a6948d07d 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ControlTypeEnum.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ControlTypeEnum.java @@ -70,4 +70,18 @@ public enum ControlTypeEnum { } return map; } + + public static Map toMapForExport(String cut){ + Map map = new HashMap<>(); + if (CutEnum.CN.getValue().equals(cut)) { + for (ControlTypeEnum controlTypeEnum : ControlTypeEnum.values()) { + map.put(controlTypeEnum.getValue(), controlTypeEnum.getName()); + } + } else if (CutEnum.EN.getValue().equals(cut)) { + for (ControlTypeEnum controlTypeEnum : ControlTypeEnum.values()) { + map.put(controlTypeEnum.getValue(), controlTypeEnum.getEnName()); + } + } + return map; + } } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ControlVerifyEnum.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ControlVerifyEnum.java index 8bb6ccc20..d51ff4bef 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ControlVerifyEnum.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ControlVerifyEnum.java @@ -68,4 +68,18 @@ public enum ControlVerifyEnum { } return map; } + + public static Map toMapForExport(String cut){ + Map map = new HashMap<>(); + if (CutEnum.CN.getValue().equals(cut)) { + for (ControlVerifyEnum controlVerifyEnum : ControlVerifyEnum.values()) { + map.put(controlVerifyEnum.getValue(), controlVerifyEnum.getName()); + } + } else if (CutEnum.EN.getValue().equals(cut)) { + for (ControlVerifyEnum controlVerifyEnum : ControlVerifyEnum.values()) { + map.put(controlVerifyEnum.getValue(), controlVerifyEnum.getEnName()); + } + } + return map; + } } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ParamsIsMustEnum.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ParamsIsMustEnum.java index 5c8ea1caf..630579765 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ParamsIsMustEnum.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/template/enums/ParamsIsMustEnum.java @@ -62,4 +62,18 @@ public enum ParamsIsMustEnum { return map; } + public static Map toMapForExport(String cut){ + Map map = new HashMap<>(); + if (CutEnum.CN.getValue().equals(cut)) { + for (ParamsIsMustEnum paramsIsMustEnum : ParamsIsMustEnum.values()) { + map.put(paramsIsMustEnum.getValue(), paramsIsMustEnum.getName()); + } + } else if (CutEnum.EN.getValue().equals(cut)) { + for (ParamsIsMustEnum paramsIsMustEnum : ParamsIsMustEnum.values()) { + map.put(paramsIsMustEnum.getValue(), paramsIsMustEnum.getEnName()); + } + } + return map; + } + }