diff --git a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/constant/enums/IsMustEnum.java b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/constant/enums/IsMustEnum.java new file mode 100644 index 000000000..e2729e565 --- /dev/null +++ b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/constant/enums/IsMustEnum.java @@ -0,0 +1,37 @@ +package com.jero.common.constant.enums; + +/** + * 中英文切换标识 + * @description + * @date 2022/1/21 15:22 + * @auth zhn + */ +public enum IsMustEnum { + YES("是","0"), + NO("否","1"); + + + String name; + String value; + + private IsMustEnum(String name, String value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/DateUtils.java b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/DateUtils.java index c6712e45a..60c42825d 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/DateUtils.java +++ b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/DateUtils.java @@ -646,5 +646,26 @@ public class DateUtils extends PropertyEditorSupport { calendar.setTime(getDate()); return calendar.get(Calendar.YEAR); } + /*** + * @Description: 判断多个日期是否都符合日期格式 + * @Author: yangxuenan + * @Date: 2020/12/31 11:31 + * @Param: [str] + * @Return: boolean + */ + public static boolean isValidDate(String str){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String[] strArr = str.split(","); + for (String dateStr : strArr) { + String replace = dateStr.replace("/", "-"); + try { + simpleDateFormat.setLenient(false); + simpleDateFormat.parse(replace); + } catch (Exception e){ + return false; + } + } + return true; + } -} \ No newline at end of file +} diff --git a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java index 3ebbdd6d7..285b1a5fa 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java +++ b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java @@ -71,6 +71,7 @@ public class ShiroConfig { } // 配置不会被拦截的链接 顺序判断 filterChainDefinitionMap.put("/sys/cas/client/validateLogin", "anon"); //cas验证登录 + filterChainDefinitionMap.put("/ocr/OcrRestful/ocrHandleResult", "anon"); //ocr回调接口 filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除 filterChainDefinitionMap.put("/sys/checkCaptcha", "anon"); //登录验证码接口排除 filterChainDefinitionMap.put("/sys/getRSAPublicKey", "anon"); //获取RSA公钥接口排除 diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/vo/OcrVO.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/vo/OcrVO.java index 0d24949c9..f9f868ab5 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/vo/OcrVO.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/vo/OcrVO.java @@ -1,6 +1,8 @@ package com.jero.modules.system.vo; +import lombok.Data; + import java.io.Serializable; /** @@ -9,6 +11,7 @@ import java.io.Serializable; * 日期: 2019-03-25
* 版权所有:版权归北京卡达克数据技术中心所有。
*/ +@Data public class OcrVO implements Serializable{ private String restHandleFileUrl; private String OcrUserId; @@ -18,68 +21,5 @@ public class OcrVO implements Serializable{ private String fileContent; private String taskId; private String RestCallBackUrl; - - public String getRestHandleFileUrl() { - return restHandleFileUrl; - } - - public void setRestHandleFileUrl(String restHandleFileUrl) { - this.restHandleFileUrl = restHandleFileUrl; - } - - public String getOcrUserId() { - return OcrUserId; - } - - public void setOcrUserId(String ocrUserId) { - OcrUserId = ocrUserId; - } - - public String getAuthCode() { - return authCode; - } - - public void setAuthCode(String authCode) { - this.authCode = authCode; - } - - public String getConvertType() { - return convertType; - } - - public void setConvertType(String convertType) { - this.convertType = convertType; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public String getFileContent() { - return fileContent; - } - - public void setFileContent(String fileContent) { - this.fileContent = fileContent; - } - - public String getTaskId() { - return taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getRestCallBackUrl() { - return RestCallBackUrl; - } - - public void setRestCallBackUrl(String restCallBackUrl) { - RestCallBackUrl = restCallBackUrl; - } + private Boolean isThird; //调用方:单纯获取识别的返回结果 } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/controller/BussDocumentLibraryEOController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/controller/BussDocumentLibraryEOController.java index ff3c249e8..e8f88c00d 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/controller/BussDocumentLibraryEOController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/controller/BussDocumentLibraryEOController.java @@ -413,16 +413,8 @@ public class BussDocumentLibraryEOController extends JeroController importZip(@RequestParam(value = "file", required = false) MultipartFile file) throws Exception { - //验证文件名是否合格 - //截取后缀名 - int pos = file.getOriginalFilename().lastIndexOf("."); - String str = file.getOriginalFilename().substring(pos+1).toLowerCase(); - String filenameorg = file.getOriginalFilename().substring(0,pos); - //判断上传文件必须是zip - if (!str.equals("zip")) { - return Result.error("请上传zip文件"); - } - return Result.OK("导入成功"); + String result = bussDocumentLibraryEOService.importZip(file); + return Result.OK(result); } @ApiOperation(value = "推送") diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/mapper/BussDocumentLibraryEOMapper.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/mapper/BussDocumentLibraryEOMapper.java index 06ace19ea..0f90c43a9 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/mapper/BussDocumentLibraryEOMapper.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/mapper/BussDocumentLibraryEOMapper.java @@ -78,4 +78,7 @@ public interface BussDocumentLibraryEOMapper extends BaseMapper> getInfoListByReplaceStandard(@Param("replaceStandard") String replaceStandard); + List> getListBySerialNumber(@Param("serialNumbers") String serialNumbers); + + } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/mapper/xml/BussDocumentLibraryEOMapper.xml b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/mapper/xml/BussDocumentLibraryEOMapper.xml index 8ddc33411..a8b0524f0 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/mapper/xml/BussDocumentLibraryEOMapper.xml +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/mapper/xml/BussDocumentLibraryEOMapper.xml @@ -70,5 +70,16 @@ + + diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/IBussDocumentLibraryEOService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/IBussDocumentLibraryEOService.java index 39941478f..d780a39f3 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/IBussDocumentLibraryEOService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/IBussDocumentLibraryEOService.java @@ -3,7 +3,7 @@ package com.jero.modules.document.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.jero.modules.document.entity.BussDocumentLibraryEO; -import org.apache.poi.ss.usermodel.Workbook; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -13,164 +13,180 @@ import java.util.Map; /** * @Description: 文档库信息表 * @Author: jero-boot - * @Date: 2022-01-21 + * @Date: 2022-01-21 * @Version: V1.0 */ public interface IBussDocumentLibraryEOService extends IService { - /** - * 通过id删除 - * - * @param id - * @return - */ + /** + * 通过id删除 + * + * @param id + * @return + */ void deleteById(String id); - /** - * 批量删除 - * - * @param ids - * @return - */ + /** + * 批量删除 + * + * @param ids + * @return + */ void deleteByIds(List ids); - /** - * 通过id查询 - * - * @param id - * @return - */ + /** + * 通过id查询 + * + * @param id + * @return + */ BussDocumentLibraryEO queryById(String id); /** - * 列表查询 - * - * @return - */ + * 列表查询 + * + * @return + */ List queryList(); /** - * 查询条件 - * - * @return - */ - List> queryCondition(String flag,String cut); + * 查询条件 + * + * @return + */ + List> queryCondition(String flag, String cut); /** - * 列表表头 - * - * @return - */ - List> getHeader(String flag,String cut); + * 列表表头 + * + * @return + */ + List> getHeader(String flag, String cut); /** - * 新增表单 - * - * @return - */ - List> getAddForm(String flag,String cut,String type); + * 新增表单 + * + * @return + */ + List> getAddForm(String flag, String cut, String type); - /** - * 编辑数据查询 - * @param id - * @return - */ - List> getDocumentInfoById(String id,String cut); + /** + * 编辑数据查询 + * + * @param id + * @return + */ + List> getDocumentInfoById(String id, String cut); - /** - * 详情数据查询 - * @param id - * @return - */ - List> getInfoById(String id,String cut); + /** + * 详情数据查询 + * + * @param id + * @return + */ + List> getInfoById(String id, String cut); - /** - * 新增数据 - * @param map - */ - void addInfo(Map map); + /** + * 新增数据 + * + * @param map + */ + void addInfo(Map map); - /** - * 编辑数据 - * @param map - */ - void updateInfo(Map map); + /** + * 编辑数据 + * + * @param map + */ + void updateInfo(Map map); - /** - * 分页 - * @param parameter - * @return - */ - IPage getInfoPage(Map parameter); + /** + * 分页 + * + * @param parameter + * @return + */ + IPage getInfoPage(Map parameter); - /** - * 代替标准分页 - * @param parameter - * @return - */ - IPage replacePageInfo(Map parameter); + /** + * 代替标准分页 + * + * @param parameter + * @return + */ + IPage replacePageInfo(Map parameter); - /** - * ocr识别调取已入库文件分页 - * @param parameter - * @return - */ - IPage ocrPageInfo(Map parameter); + /** + * ocr识别调取已入库文件分页 + * + * @param parameter + * @return + */ + IPage ocrPageInfo(Map parameter); - /** - * 添加收藏 - * @param id - */ - void addCollect(String id); + /** + * 添加收藏 + * + * @param id + */ + void addCollect(String id); - /** - * 取消收藏 - * @param id - */ - void cancelCollect(String id); + /** + * 取消收藏 + * + * @param id + */ + void cancelCollect(String id); - /** - * 添加订阅 - * @param id - */ - void addSubscribe(String id); + /** + * 添加订阅 + * + * @param id + */ + void addSubscribe(String id); - /** - * 取消订阅 - * @param id - */ - void cancelSubscribe(String id); + /** + * 取消订阅 + * + * @param id + */ + void cancelSubscribe(String id); - /** - * 导出excel - * @param map - * @param response - * @param request - */ - void exportExcel(Map map, - HttpServletResponse response, - HttpServletRequest request); + /** + * 导出excel + * + * @param map + * @param response + * @param request + */ + void exportExcel(Map map, + HttpServletResponse response, + HttpServletRequest request); - void exportZip(Map map, - HttpServletResponse response, - HttpServletRequest request); + void exportZip(Map map, + HttpServletResponse response, + HttpServletRequest request); - /** - * 模板下载 - * @param response - * @param request - */ - void exportTemplate(Map map,HttpServletResponse response, HttpServletRequest request); + /** + * 模板下载 + * + * @param response + * @param request + */ + void exportTemplate(Map map, HttpServletResponse response, HttpServletRequest request); - /** - * ocr识别调取已入库文件-中英文切换 - * @param flag - * @param cut - * @return - */ - List> getHeaderOrConditionForOcr(String flag, String cut); + /** + * ocr识别调取已入库文件-中英文切换 + * + * @param flag + * @param cut + * @return + */ + List> getHeaderOrConditionForOcr(String flag, String cut); - String pullMessage(String departIds,String ids,String documentIds); + String pullMessage(String departIds, String ids, String documentIds); + + String importZip(MultipartFile file); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java index 39a839166..1559b4c6a 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java @@ -10,12 +10,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.IsMustEnum; 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.exception.JeroBootException; import com.jero.common.system.api.ISysBaseAPI; import com.jero.common.system.vo.LoginUser; +import com.jero.common.util.DateUtils; import com.jero.generater.modules.online.cgform.entity.OnlCgformField; import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl; import com.jero.modules.collection.entity.OnlCgformCollection; @@ -30,6 +32,7 @@ import com.jero.modules.log.service.IBussLogEOService; import com.jero.modules.message.websocket.WebSocket; import com.jero.modules.oss.entity.OSSFile; import com.jero.modules.oss.service.IOSSFileService; +import com.jero.modules.split.common.FileUnZip; import com.jero.modules.subscribe.entity.OnlCgformSubscribe; import com.jero.modules.subscribe.service.IOnlCgformSubscribeService; import com.jero.modules.system.entity.SysAnnouncement; @@ -44,9 +47,13 @@ import com.jero.modules.system.service.impl.SysCategoryServiceImpl; import com.jero.modules.system.service.impl.SysDictItemServiceImpl; import com.jero.modules.tag.entity.OnlCgformArea; import com.jero.modules.tag.service.impl.OnlCgformAreaServiceImpl; +import lombok.SneakyThrows; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.hssf.usermodel.HSSFRichTextString; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; @@ -57,6 +64,7 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.shiro.SecurityUtils; @@ -64,7 +72,9 @@ import org.aspectj.util.FileUtil; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.mock.web.MockMultipartFile; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -74,6 +84,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -81,12 +92,14 @@ import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; + /** * @Description: 文档库信息表 * @Author: jero-boot @@ -211,11 +224,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl> list = new ArrayList<>(); for (OnlCgformField onlCgformField : fieldList) { Map map = new HashMap<>(); - if("technology_territory".equals(onlCgformField.getDbFieldName())){ + if ("technology_territory".equals(onlCgformField.getDbFieldName())) { List sysCategoryTreeVOList = sysCategoryTree.stream().filter(e -> onlCgformField.getDictId().equals(e.getDictId())).collect(Collectors.toList()); - map.put("tree",sysCategoryTreeVOList); - }else{ - map.put("tree",new ArrayList<>()); + map.put("tree", sysCategoryTreeVOList); + } else { + map.put("tree", new ArrayList<>()); } map.put("field_show_type", onlCgformField.getFieldShowType());//类型(判断是下拉还是输入框,等等) @@ -289,7 +302,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowForm())) && !"replaced_standard" .equals(e.getDbFieldName())) + .filter(e -> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowForm())) && !"replaced_standard".equals(e.getDbFieldName())) .collect(Collectors.toList()); } else { fieldList = fieldList.stream() @@ -312,12 +325,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl sysCategoryTreeVOList = new ArrayList<>(); - if(StringUtils.isNotBlank(dictId)){ + if (StringUtils.isNotBlank(dictId)) { sysCategoryTreeVOList = sysCategoryTree.stream().filter(e -> dictId.equals(e.getDictId())).collect(Collectors.toList()); } Map map = new HashMap<>(); - mapPut(cut, map, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName,sysCategoryTreeVOList); - map.put("field_must_input", onlCgformField.getFieldMustInput());//区域 + mapPut(cut, map, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, sysCategoryTreeVOList); + map.put("field_must_input", onlCgformField.getFieldMustInput());//是否必填 + map.put("db_length", onlCgformField.getDbLength());//字段长度 result.add(map); } } @@ -378,9 +392,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl replaceStandardNameList = new ArrayList<>();//代替标准编码 List replacedStandardNameList = new ArrayList<>();//被代替标准编码 - List> listCorrespondingStandard = new ArrayList<>(); - List> listReplaceStandard = new ArrayList<>(); - List> listReplacedStandard = new ArrayList<>(); + List> listCorrespondingStandard = new ArrayList<>(); + List> listReplaceStandard = new ArrayList<>(); + List> listReplacedStandard = new ArrayList<>(); //处理被代替标准和对应标准 for (Map map : mapList) { - Map mapTemp = new HashMap<>(); + Map mapTemp = new HashMap<>(); //对应标准处理 if (StringUtils.isNotBlank(correspondingStandardId) && correspondingStandardId.contains((String) map.get("id"))) { correspondingStandardNameList.add((String) map.get("serial_number")); - mapTemp.put("title",(String) map.get("serial_number")); - mapTemp.put("id",(String) map.get("id")); - if(ObjectUtils.isNotEmpty(mapTemp)){ + mapTemp.put("title", (String) map.get("serial_number")); + mapTemp.put("id", (String) map.get("id")); + if (ObjectUtils.isNotEmpty(mapTemp)) { listCorrespondingStandard.add(mapTemp); } } //代替标准 - if(StringUtils.isNotBlank(replaceStandardId) && replaceStandardId.contains((String) map.get("id"))){ + if (StringUtils.isNotBlank(replaceStandardId) && replaceStandardId.contains((String) map.get("id"))) { replaceStandardNameList.add((String) map.get("serial_number")); - mapTemp.put("title",(String) map.get("serial_number")); - mapTemp.put("id",(String) map.get("id")); - if(ObjectUtils.isNotEmpty(mapTemp)){ + mapTemp.put("title", (String) map.get("serial_number")); + mapTemp.put("id", (String) map.get("id")); + if (ObjectUtils.isNotEmpty(mapTemp)) { listReplaceStandard.add(mapTemp); } } @@ -443,9 +457,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl { //下拉选处理数据字典 - treeDictItem(categoryList, entry, treeFieldList,cut); + treeDictItem(categoryList, entry, treeFieldList, cut); }); //下拉单选和下拉多选数据字典处理 dataList.get(0).entrySet().forEach(entry -> { if (fieldPullList.contains(entry.getKey())) { //下拉选处理数据字典 - dictItem(sysDictItems, entry, onlCgformFieldList,cut); + dictItem(sysDictItems, entry, onlCgformFieldList, cut); } }); @@ -528,7 +542,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl mapNew = new HashMap<>(); mapNew.put("value", fileInfo); - mapPut(cut, mapNew, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName,null); + mapPut(cut, mapNew, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, null); resultTemp.add(mapNew); } } @@ -536,13 +550,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl mapNew = new HashMap<>(); mapNew.put("value", fileInfos.get(0)); - mapPut(cut, mapNew, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName,null); + mapPut(cut, mapNew, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, null); resultTemp.add(mapNew); } - }else{ + } else { Map mapNew = new HashMap<>(); mapNew.put("value", ""); - mapPut(cut, mapNew, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName,null); + mapPut(cut, mapNew, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, null); resultTemp.add(mapNew); } } else { @@ -553,22 +567,22 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl sysCategoryTreeVOS) { + String area, String showArea, List sysCategoryTreeVOS) { map.put(field_show_type, fieldShowType2);//类型(判断是下拉还是输入框,等等) map.put(dict_field, dictField); map.put(db_field_name, dbFieldName2);//字段 @@ -616,7 +630,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl> dataList = bussDocumentLibraryEOMapper.selectMaps(queryWrapper); - Map mapTemp = new HashMap<>(); + Map mapTemp = new HashMap<>(); mapCopy(map, mapTemp); - List> dataListTemp = new ArrayList<>(); + List> dataListTemp = new ArrayList<>(); for (Map stringObjectMap : dataList) { - Map mapT = new HashMap<>(); + Map mapT = new HashMap<>(); mapCopy(stringObjectMap, mapT); dataListTemp.add(mapT); } //更新log - updateLog(map, dataList, fieldList, fieldDateList, fieldFileList, fieldPullList,cut); + updateLog(map, dataList, fieldList, fieldDateList, fieldFileList, fieldPullList, cut); //判断该条数据是否订阅 //处理修改代替标准,发送通知 - sendMessageUpdate(mapTemp, dataListTemp, fieldList, fieldDateList, fieldFileList, fieldPullList,cut); + sendMessageUpdate(mapTemp, dataListTemp, fieldList, fieldDateList, fieldFileList, fieldPullList, cut); //字段 StringBuilder fieldsBuilder = new StringBuilder(); @@ -872,14 +886,14 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl entry.getKey().equals(e.getDictField())) .collect(Collectors.toList()); //下拉选处理数据字典 - dictItem(sysDictItems, entry, collect,cut); + dictItem(sysDictItems, entry, collect, cut); } for (Map.Entry entry : mapTemp.entrySet()) { List collect = fieldPullList.stream() .filter(e -> entry.getKey().equals(e.getDictField())) .collect(Collectors.toList()); //下拉选处理数据字典 - dictItem(sysDictItems, entry, collect,cut); + dictItem(sysDictItems, entry, collect, cut); } StringBuilder sb = new StringBuilder(); @@ -953,11 +967,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); - String valueStr = (String )value; + String valueStr = (String) value; lambdaQueryWrapper.in(BussDocumentLibraryEO::getId, Arrays.asList(valueStr.split(","))); List> mapList = this.listMaps(lambdaQueryWrapper); List serialNumberList = new ArrayList<>(); for (Map stringObjectMap : mapList) { serialNumberList.add((String) stringObjectMap.get("serial_number")); } - if(serialNumberList.size() != 0){ - value = StringUtils.join(serialNumberList,","); + if (serialNumberList.size() != 0) { + value = StringUtils.join(serialNumberList, ","); } return value; } @@ -1002,28 +1016,28 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl map, - List> dataList, - List fieldList, - List fieldDateList, - List fieldFileList, - List fieldPullList, - String cut) { + List> dataList, + List fieldList, + List fieldDateList, + List fieldFileList, + List fieldPullList, + String cut) { //1. 处理订阅的发送消息 //修改的内容 StringBuilder sb = getUpdateInfo(map, dataList, fieldList, fieldDateList, fieldFileList, fieldPullList, cut); String sbStr = ""; - if(ObjectUtils.isNotEmpty(sb)){ - sbStr = sb.substring(0,sb.length()-1); + if (ObjectUtils.isNotEmpty(sb)) { + sbStr = sb.substring(0, sb.length() - 1); } LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String serialNumber = (String) dataList.get(0).get("serial_number"); //只要修改了标准,就需要向订阅用户发送消息(内容为-->XXX对“GB 7258 进行了修改请及时查看”) //1.先判断是否订阅 LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(OnlCgformSubscribe::getDocumentId, (String)map.get("id")); + lambdaQueryWrapper.in(OnlCgformSubscribe::getDocumentId, (String) map.get("id")); List onlCgformSubscribeList = iOnlCgformSubscribeService.list(lambdaQueryWrapper); List userNameList = new ArrayList<>(); - if(onlCgformSubscribeList.size() != 0){ + if (onlCgformSubscribeList.size() != 0) { for (OnlCgformSubscribe onlCgformSubscribe : onlCgformSubscribeList) { userNameList.add(onlCgformSubscribe.getCreateBy()); } @@ -1034,14 +1048,14 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl"+serialNumber+""; + "&serial_number:" + serialNumber + "'" + " target='_blank'>" + serialNumber + ""; - String content = sysUser.getRealname()+"对"+serialNumber+"进行了修改请及时查看"; - String contentInfo = sysUser.getRealname()+"修改标准"+href+"中"+sbStr.toString(); + String content = sysUser.getRealname() + "对" + serialNumber + "进行了修改请及时查看"; + String contentInfo = sysUser.getRealname() + "修改标准" + href + "中" + sbStr.toString(); //封装消息的实体类 SysAnnouncement sysAnnouncement = getSysAnnouncement(userIdList, content, contentInfo); sysAnnouncementService.saveAnnouncement(sysAnnouncement); - sendWebsocket((String) map.get("id"),(String) map.get("id")); + sendWebsocket((String) map.get("id"), (String) map.get("id")); } //2. 处理修改代替标准的发送消息 //处理修改代替标准,发送通知 @@ -1059,17 +1073,17 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl listNew = list.stream().filter(e -> !listTemp.contains(e)).collect(Collectors.toList()); //向listNew对应的工程师发飞书通知 replaceStandardSend(listNew); - sendWebsocket((String) map.get("id"),(String) map.get("id")); - } else if(StringUtils.isBlank(replaceStandardTemp) && StringUtils.isNotBlank(replaceStandard)) { + sendWebsocket((String) map.get("id"), (String) map.get("id")); + } else if (StringUtils.isBlank(replaceStandardTemp) && StringUtils.isNotBlank(replaceStandard)) { //(2)此种情况为编辑前代替标准没有数据 //向replaceStandard对应的工程师发飞书通知 replaceStandardSend(Arrays.asList(replaceStandard.split(","))); - sendWebsocket((String) map.get("id"),(String) map.get("id")); + sendWebsocket((String) map.get("id"), (String) map.get("id")); } } } - private void sendWebsocket(String msgId,String msgTet) { + private void sendWebsocket(String msgId, String msgTet) { JSONObject obj = new JSONObject(); obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC); obj.put(WebsocketConst.MSG_ID, msgId); @@ -1092,13 +1106,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl"+serialNumber+","; + "&title:" + title + + "&serial_number:" + serialNumber + "'" + " target='_blank'>" + serialNumber + ","; sb.append(href); } String sbStr = ""; - if(ObjectUtils.isNotEmpty(sb)){ - sbStr = sb.substring(0,sb.length()-1); + if (ObjectUtils.isNotEmpty(sb)) { + sbStr = sb.substring(0, sb.length() - 1); } List userList = sysUserMapper.getUserListByNames(StringUtils.join(userNameListTemp, ",")); List userIdList = userList.stream().map(SysUser::getId).collect(Collectors.toList()); @@ -1107,7 +1121,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl state = stateList.stream().filter(e -> e.getItemValue().equals(entry.getValue())).collect(Collectors.toList()); if (state.size() != 0) { - if(CutEnum.CN.getValue().equals((String) parameter.get("cut"))){ + if (CutEnum.CN.getValue().equals((String) parameter.get("cut"))) { entry.setValue(state.get(0).getItemText()); - }else{ + } else { entry.setValue(state.get(0).getEnName()); } } @@ -1341,8 +1355,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl entry.getKey().equals(e.getDictField()) && !FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType())) .collect(Collectors.toList()); //下拉选处理数据字典 - dictItem(sysDictItems, entry, collect,cut); - treeDictItem(categoryList, entry, treeFieldList,cut); + dictItem(sysDictItems, entry, collect, cut); + treeDictItem(categoryList, entry, treeFieldList, cut); } } //收藏和订阅 @@ -1428,13 +1442,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.in(OnlCgformCollection::getDocumentId, idList); - wrapper.eq(OnlCgformCollection::getCreateBy,sysUser.getUsername()); + wrapper.eq(OnlCgformCollection::getCreateBy, sysUser.getUsername()); List collectList = iOnlCgformCollectionService.list(wrapper); List collectIdList = collectList.stream().map(OnlCgformCollection::getDocumentId).collect(Collectors.toList()); //订阅 LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.in(OnlCgformSubscribe::getDocumentId, idList); - lambdaQueryWrapper.eq(OnlCgformSubscribe::getCreateBy,sysUser.getUsername()); + lambdaQueryWrapper.eq(OnlCgformSubscribe::getCreateBy, sysUser.getUsername()); List subscribeList = iOnlCgformSubscribeService.list(lambdaQueryWrapper); List subscribeIdList = subscribeList.stream().map(OnlCgformSubscribe::getDocumentId).collect(Collectors.toList()); @@ -1463,7 +1477,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl sysDictItems, Map.Entry entry, List collect,String cut) { + private void dictItem(List sysDictItems, Map.Entry entry, List collect, String cut) { Map map = new HashMap<>(); //通过dictField判断字段是否为下拉选(不为空则为下拉选) if (collect.size() != 0 && StringUtils.isNotBlank(collect.get(0).getDictField())) { @@ -1483,9 +1497,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl itemText = new ArrayList<>(); - if(CutEnum.CN.getValue().equals(cut)){ + if (CutEnum.CN.getValue().equals(cut)) { itemText = dictItems.stream().map(SysDictItem::getItemText).collect(Collectors.toList()); - }else { + } else { itemText = dictItems.stream().map(SysDictItem::getEnName).collect(Collectors.toList()); } dictItemsCh.addAll(itemText); @@ -1494,9 +1508,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl !FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList()); } - if(CutEnum.CN.getValue().equals(cut)){ + if (CutEnum.CN.getValue().equals(cut)) { headerFieldList = fieldListTemp.stream().map(OnlCgformField::getDbFieldTxt).collect(Collectors.toList()); - }else{ + } else { headerFieldList = fieldListTemp.stream().map(OnlCgformField::getDbFieldEnName).collect(Collectors.toList()); } } @@ -1642,7 +1658,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl> datas) { List> datasTemp = new ArrayList<>(); for (Map data : datas) { - Map mapTemp = new HashMap<>(); - mapCopy(data,mapTemp); + Map mapTemp = new HashMap<>(); + mapCopy(data, mapTemp); datasTemp.add(mapTemp); } for (Map data : datas) { @@ -1733,40 +1750,40 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl{ + datasTemp.forEach(entry -> { String id = (String) entry.get("id"); String replaceStandardTemp = (String) entry.get("replace_standard"); //对应标准 - if(StringUtils.isNotBlank(correspondingStandard) && correspondingStandard.contains(id)){ - correspondingStandardSb.append((String) entry.get("serial_number")+","); + if (StringUtils.isNotBlank(correspondingStandard) && correspondingStandard.contains(id)) { + correspondingStandardSb.append((String) entry.get("serial_number") + ","); } //代替标准 - if(StringUtils.isNotBlank(replaceStandard) && replaceStandard.contains(id)){ - replaceStandardSb.append((String) entry.get("serial_number")+","); + if (StringUtils.isNotBlank(replaceStandard) && replaceStandard.contains(id)) { + replaceStandardSb.append((String) entry.get("serial_number") + ","); } //被代替标准 - if(StringUtils.isNotBlank(replaceStandardTemp) && replaceStandardTemp.contains(idTemp)){ - replacedStandardSb.append((String) entry.get("serial_number")+","); + if (StringUtils.isNotBlank(replaceStandardTemp) && replaceStandardTemp.contains(idTemp)) { + replacedStandardSb.append((String) entry.get("serial_number") + ","); } }); //对应标准 - if(StringUtils.isNotBlank(correspondingStandardSb)){ + if (StringUtils.isNotBlank(correspondingStandardSb)) { String correspondingStandardStr = correspondingStandardSb.substring(0, correspondingStandardSb.length() - 1); - data.put("corresponding_standard",correspondingStandardStr); + data.put("corresponding_standard", correspondingStandardStr); } //代替标准 - if(StringUtils.isNotBlank(replaceStandardSb)){ + if (StringUtils.isNotBlank(replaceStandardSb)) { String replaceStandardStr = replaceStandardSb.substring(0, replaceStandardSb.length() - 1); - data.put("replace_standard",replaceStandardStr); + data.put("replace_standard", replaceStandardStr); } - if(StringUtils.isNotBlank(replacedStandardSb)){ + if (StringUtils.isNotBlank(replacedStandardSb)) { String replacedStandardStr = replacedStandardSb.substring(0, replacedStandardSb.length() - 1); - data.put("replaced_standard",replacedStandardStr); + data.put("replaced_standard", replacedStandardStr); } } } - public void createDatas(Workbook workbook, Sheet sheet, List> datas, String header, List fieldList,String cut) { + public void createDatas(Workbook workbook, Sheet sheet, List> datas, String header, List fieldList, String cut) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象 cellStyle.setAlignment(HorizontalAlignment.CENTER); @@ -1803,13 +1820,12 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl entry.getKey().equals(e.getDictField()) && !FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType())) .collect(Collectors.toList()); //下拉选处理数据字典 - dictItem(sysDictItems, entry, collect,cut); + dictItem(sysDictItems, entry, collect, cut); //处理树形数据字典 - treeDictItem(categoryList, entry, treeFieldList,cut); + treeDictItem(categoryList, entry, treeFieldList, cut); } - Row row = sheet.createRow(i + 1); i++; int sheetNum = 0; @@ -2182,21 +2198,22 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl userIdList = new ArrayList<>(); - if(StringUtils.isNotBlank(departIds)){ + if (StringUtils.isNotBlank(departIds)) { //查询部门下的人员 List userList = sysUserService.getUserListByDepIds(Arrays.asList(departIds.split(","))); - if(userList.size() != 0){ + if (userList.size() != 0) { userIdList = userList.stream().map(SysUser::getId).collect(Collectors.toList()); } } @@ -2204,44 +2221,484 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper(); - lambdaQueryWrapper.in(BussDocumentLibraryEO::getId,Arrays.asList(documentIds.split(","))); + lambdaQueryWrapper.in(BussDocumentLibraryEO::getId, Arrays.asList(documentIds.split(","))); List> mapList = this.listMaps(lambdaQueryWrapper); List serialNumberList = new ArrayList<>(); for (Map map : mapList) { serialNumberList.add((String) map.get("serial_number")); } LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String content = sysUser.getRealname()+"向内推送了"+StringUtils.join(serialNumberList,",")+",请注意查看。"; - String contentInfo = sysUser.getRealname()+"向内推送了"+StringUtils.join(serialNumberList,",")+",请注意查看。"; + String content = sysUser.getRealname() + "向内推送了" + StringUtils.join(serialNumberList, ",") + ",请注意查看。"; + String contentInfo = sysUser.getRealname() + "向内推送了" + StringUtils.join(serialNumberList, ",") + ",请注意查看。"; //封装消息的实体类 SysAnnouncement sysAnnouncement = getSysAnnouncement(userIdList, content, contentInfo); sysAnnouncementService.saveAnnouncement(sysAnnouncement); - return "推送成功" ; + return "推送成功"; } + /** * 属性字典处理中文 + * * @param categoryList * @param entry * @param treeFieldList * @param cut */ - private void treeDictItem(List categoryList ,Map.Entry entry,List treeFieldList,String cut){ + private void treeDictItem(List categoryList, Map.Entry entry, List treeFieldList, String cut) { List treeFields = treeFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList()); String key = entry.getKey(); - if(treeFields.contains(entry.getKey())){ + if (treeFields.contains(entry.getKey())) { String value = (String) entry.getValue(); - if(StringUtils.isNotBlank(value)){ + if (StringUtils.isNotBlank(value)) { List idList = Arrays.asList(value.split(",")); List sysCategoryList = categoryList.stream().filter(e -> idList.contains(e.getId())).collect(Collectors.toList()); List nameList = sysCategoryList.stream().map(SysCategory::getName).collect(Collectors.toList()); List nameEnList = sysCategoryList.stream().map(SysCategory::getEnName).collect(Collectors.toList()); - if(CutEnum.CN.getValue().equals(cut)){ - entry.setValue(StringUtils.join(nameList,",")); - }else{ - entry.setValue(StringUtils.join(nameEnList,",")); + if (CutEnum.CN.getValue().equals(cut)) { + entry.setValue(StringUtils.join(nameList, ",")); + } else { + entry.setValue(StringUtils.join(nameEnList, ",")); } } } } + + + @SneakyThrows + @Override + public String importZip(MultipartFile file) { + List list = getWorkbookTitle("cn"); + String result = ""; + int pos = file.getOriginalFilename().lastIndexOf("."); + String str = file.getOriginalFilename().substring(pos + 1).toLowerCase(); + String filenameorg = file.getOriginalFilename().substring(0, pos); + //判断上传文件必须是zip + if (!str.equals("zip") && !str.equals("rar")) { + return "请上传zip格式的文件或rar格式的文件"; + } + String path = uploadpath + "/modal/" + filenameorg; + File saveDirectory = new File(path); + if (!saveDirectory.isDirectory()) { + saveDirectory.mkdir(); + } + FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path + "/" + file.getOriginalFilename())); + //解压缩 + String zipEntryName = FileUnZip.unZipFiles(path + "/" + file.getOriginalFilename(), path); + //判断压缩包下是否只有一个文件夹 + File fileTemp = new File(path); + int length = fileTemp.listFiles().length; + if(length > 2){ + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return "压缩包中必须有且仅有一个文件夹,请重新上传"; + } + File fileNew = new File(zipEntryName); + List fileList = new ArrayList<>(); + for (File file1 : fileNew.listFiles()) { + if(file1.getName().contains(".xls") || file1.getName().contains(".xlsx")){ + fileList.add(file1); + } + } + if(fileList.size() ==0 ){ + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return "压缩包根目录下没有excel作为导入数据,请重新上传"; + }else if(fileList.size() > 1){ + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return "压缩包根目录下仅能存在一个excel为导入数据,请重新上传"; + } + + // 数据相关处理, + // 1.获取其中的Excel, + List excelfilelist = FileUnZip.readImpExcelFile(zipEntryName); + System.gc(); + if (excelfilelist.size() < 1) { + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return "压缩包内没有上传Excel数据"; + } else if (excelfilelist.size() > 1) { + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return "压缩包内有多个Excel数据源"; + } + File excelfile = excelfilelist.get(0); + + + Workbook workbook = WorkbookFactory.create(excelfile); + List> dataList = new ArrayList<>(); + if (workbook != null) { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + Sheet sheet = workbook.getSheetAt(0); + if (sheet != null) { + StringBuilder headerSb = new StringBuilder(); + int rowNos = sheet.getLastRowNum();// 得到excel的总记录条数 + for (int i = 0; i <= rowNos; i++) {// 遍历行 + if (i == 1) { + continue; + } + Row row = sheet.getRow(i); + Row headerRow = sheet.getRow(0); + boolean isBlank = isRowEmpty(row); + if (row != null && !isBlank) { + int columNos = headerRow.getLastCellNum();// 表头总共的列数 + Map rowList = new LinkedHashMap<>(); + for (int j = 0; j < columNos; j++) { + Cell cell = row.getCell(j); + Cell headerCell = headerRow.getCell(j); + if (cell != null) { + if (i == 0) { + cell.setCellType(HSSFCell.CELL_TYPE_STRING); + headerSb.append(cell.getStringCellValue() + ","); + } else { + if (HSSFCell.CELL_TYPE_NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) { + Date d = cell.getDateCellValue(); + rowList.put(headerCell.getStringCellValue(), df.format(d)); + } else { + cell.setCellType(HSSFCell.CELL_TYPE_STRING); + String stringCellValue = cell.getStringCellValue(); + if (StringUtils.isNotBlank(stringCellValue)) { + String replace = stringCellValue.replace(",", ","); + rowList.put(headerCell.getStringCellValue(), replace); + } + } + } + } else { + if (i != 0) { + rowList.put(headerCell.getStringCellValue(), ""); + } + } + } + if (i != 0) { + dataList.add(rowList); + } + } + } + // 校验头部是否符合模板 + String fields = list.get(0); + String substring = headerSb.substring(0, headerSb.length() - 1); + String excelHeader = substring.toString(); + if (!fields.equals(excelHeader)) { + workbook.close(); + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return "读取失败,请严格按照模板文件导入数据"; + } + } + } + //树形数据字典 + List categoryList = sysCategoryService.list(); + //普通数据字典 + List dictItemList = sysDictItemServiceImpl.selectItemsAll(); + //表头 + List> addForm = getAddForm(ModuleEnum.DOCUMENT_LIBRARY.getValue(), "cn", "add"); + result = exportDatas(dataList, addForm, categoryList, dictItemList, zipEntryName); + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return result; + + } + + String exportDatas(List> dataList, + List> fieldList, + List categoryList, + List dictItemList, + String zipEntryName) { + //树形数据字典 + List treeNameList = categoryList.stream().map(SysCategory::getName).collect(Collectors.toList()); + //普通数据字典 + List itemNameList = dictItemList.stream().map(SysDictItem::getItemText).collect(Collectors.toList()); + int i = 2; + List msgList = new ArrayList<>(); + List> mapList = new ArrayList<>(); + for (Map stringStringMap : dataList) { + Map mapResult = new HashMap<>(); + i++; + for (Map.Entry entry : stringStringMap.entrySet()) { + int countError = 0; //记录失败数据数量 + String errorMsg = "第" + i + "行:"; + String key = entry.getKey(); + if (key.contains("*")) { + key = key.replace("*", ""); + } + String value = entry.getValue(); + String field = ""; + for (Map map : fieldList) { + String fieldNameCn = (String) map.get("db_field_txt");//中文名称 + String fieldName = (String) map.get("db_field_name");//字段名 + String mustInput = (String) map.get("field_must_input");//是否必填 + String dbLength = map.get("db_length").toString();//字段长度 + String fieldShowType = (String) map.get("field_show_type");//字段类型 + + if (key.equals(fieldNameCn)) { + field = fieldName; + //验证字段是否必填,长度,下拉框和树形的值是否匹配 + if (FieldTypeEnum.TREE.getValue().equals(fieldShowType)) { + //树形 + //判断是否必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) { + errorMsg += key + "为必填项,不能为空"; + countError++; + } + //判断数据是否匹配 + if (StringUtils.isNotBlank(value)) { + for (String valueTemp : value.split(",")) { + if (!treeNameList.contains(valueTemp)) { + errorMsg += key + "中的" + valueTemp + "与数据字典不匹配"; + countError++; + } + } + } + String valueId = ""; + //文字转ID + if (StringUtils.isNotBlank(value)) { + for (String valueTemp : value.split(",")) { + if (treeNameList.contains(valueTemp)) { + List collect = categoryList.stream().filter(e -> e.getName().equals(valueTemp)).collect(Collectors.toList()); + valueId += collect.get(0).getId(); + } + } + value = valueId; + } + + } else if (FieldTypeEnum.TEXT_STRING.getValue().equals(fieldShowType)) { + //输入框 + //判断是否必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) { + errorMsg += key + "为必填项,不能为空"; + countError++; + } + //判断长度 + if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) { + errorMsg += key + "不能超过" + dbLength + "个字符"; + countError++; + } + + } else if (FieldTypeEnum.TEXT_NUMBER.getValue().equals(fieldShowType)) { + //正则判断仅能为 负号(-),小数点(.)和数字 + + + } else if (FieldTypeEnum.PULL_SINGLE.getValue().equals(fieldShowType)) { + //下拉单选 + //判断是否必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) { + errorMsg += key + "为必填项,不能为空"; + countError++; + } + //判断是否是单选 + if (StringUtils.isNotBlank(value) && value.contains(",")) { + errorMsg += key + "为单选项"; + countError++; + } + //判断数据是否匹配 + if (StringUtils.isNotBlank(value)) { + if (!itemNameList.contains(value)) { + errorMsg += key + "中的" + value + "与数据字典不匹配"; + countError++; + } + } + //文字转数据字典编码 + if (itemNameList.contains(value)) { + String finalValue = value; + List collect = dictItemList.stream().filter(e -> e.getItemText().equals(finalValue)).collect(Collectors.toList()); + value = collect.get(0).getItemValue(); + } + + } else if (FieldTypeEnum.PULL_MORE.getValue().equals(fieldShowType)) { + //判断是否必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) { + errorMsg += key + "为必填项,不能为空"; + countError++; + } + //下拉多选 + for (String valueTemp : value.split(",")) { + if (!itemNameList.contains(valueTemp)) { + errorMsg += key + "中的" + valueTemp + "与数据字典不匹配"; + countError++; + } + } + + String valueId = ""; + //文字转数据字典id + if (StringUtils.isNotBlank(value)) { + for (String valueTemp : value.split(",")) { + if (itemNameList.contains(valueTemp)) { + List collect = dictItemList.stream().filter(e -> e.getItemText().equals(valueTemp)).collect(Collectors.toList()); + valueId += collect.get(0).getItemValue() + ","; + } + } + value = valueId.substring(0,valueId.length()-1); + } + + + } else if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldShowType)) { + //单选日期 + //判断是否必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) { + errorMsg += key + "为必填项,不能为空"; + countError++; + } + //a判断是否是单日期选择 + if (StringUtils.isNotBlank(value) && value.contains(",")) { + errorMsg += key + "为单日期选项"; + countError++; + } + //判断格式是否正确 + if (!DateUtils.isValidDate((String) value)) { + errorMsg += key + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日"; + countError++; + } + + } else if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldShowType)) { + //多选日期 + //判断是否必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) { + errorMsg += key + "为必填项,不能为空"; + countError++; + } + //判断格式是否正确 + if (!DateUtils.isValidDate((String) value)) { + errorMsg += key + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日"; + countError++; + } + + + } else if (FieldTypeEnum.FILE.getValue().equals(fieldShowType)) { + //文件 + //判断是否必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) { + errorMsg += key + "为必填项,不能为空"; + countError++; + } + if (StringUtils.isNotBlank(value)) { + StringBuilder sb = new StringBuilder(); + for (String fileName : value.split(",")) { + List nowFileList = FileUnZip.readFileByFilename(zipEntryName, fileName); + if (nowFileList.size() == 0) { + errorMsg += key + "压缩包中没有" + fileName + "文件; "; + countError++; + } else { + try { + FileInputStream input = new FileInputStream(nowFileList.get(0)); + MultipartFile multipartFile = + new MockMultipartFile(nowFileList.get(0).getName(), nowFileList.get(0).getName(), "text/plain", input); + //文件存入文件表 + OSSFile ossFile = iOSSFileService.uploadLocal(multipartFile, ""); + if(ObjectUtils.isNotEmpty(ossFile)){ + sb.append(ossFile.getId()+","); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + if(StringUtils.isNotBlank(sb)){ + String substring = sb.substring(0, sb.length() - 1); + value = substring; + } + } + + } else if (FieldTypeEnum.STANDARD.getValue().equals(fieldShowType)) { + //标准选择 + //判断是否必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) { + errorMsg += key + "为必填项,不能为空"; + countError++; + } + //判断库中是否存在,如果存在则存id,如果不存在则存输入的值 + List> listBySerialNumber = getListBySerialNumber(value); + String serialNumberStr = ""; + StringBuilder sb = new StringBuilder(); + List list = new ArrayList<>(); + for (Map stringObjectMap : listBySerialNumber) { + sb.append((String) stringObjectMap.get("id") + ","); + list.add((String) stringObjectMap.get("serial_number")); + } + for (String s : value.split(",")) { + if (!list.contains(s)) { + sb.append(s); + } + } + if (ObjectUtils.isNotEmpty(sb)) { + String substring = sb.substring(0, sb.length() - 1); + value = substring; + } + } + } + } + + if (countError > 0) { + msgList.add(errorMsg); + } + mapResult.put(field, value); + } + mapList.add(mapResult); + } + if (msgList.size() > 0) { + //返回报错信息 + String html = ""; + for (String s : msgList) { + html += s + "
"; + } + return html; + } else { + if(mapList.size() != 0){ + for (Map map : mapList) { + this.addInfo(map); + } + } + } + return "数据导入成功"; + + } + + + //判断row是否为空 空返回true + public 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) { + nullCellNum++; + continue; + } + String value = ""; + switch (cell.getCellType()) { + case HSSFCell.CELL_TYPE_NUMERIC: // 数字 + //如果为时间格式的内容 + value = String.valueOf(cell.getNumericCellValue()); + break; + case HSSFCell.CELL_TYPE_STRING: // 字符串 + value = cell.getStringCellValue(); + break; + case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean + value = cell.getBooleanCellValue() + ""; + break; + case HSSFCell.CELL_TYPE_FORMULA: // 公式 + value = cell.getCellFormula() + ""; + break; + default: + break; + } + if (org.apache.commons.lang.StringUtils.isEmpty(value)) { + nullCellNum++; + } + } + //所有列都为空 + if (nullCellNum == (lastCellNum - firstCellNum)) { + return true; + } + return false; + } + + public List> getListBySerialNumber(String serialNumbers) { + return bussDocumentLibraryEOMapper.getListBySerialNumber(serialNumbers); + } + } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/controller/OcrRecordEOController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/controller/OcrRecordEOController.java index e506e9d8c..686997b33 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/controller/OcrRecordEOController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/controller/OcrRecordEOController.java @@ -7,11 +7,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.jero.common.api.vo.Result; import com.jero.common.aspect.annotation.AutoLog; import com.jero.common.system.base.controller.JeroController; -import com.jero.modules.document.entity.BussDocumentLibraryEO; import com.jero.modules.document.service.IBussDocumentLibraryEOService; import com.jero.modules.ocr.entity.OcrRecordEO; +import com.jero.modules.ocr.enums.FileSourceEnum; import com.jero.modules.ocr.enums.FileSyncStateEnum; -import com.jero.modules.ocr.enums.FileTypeEnum; import com.jero.modules.ocr.page.OcrRecordEOPage; import com.jero.modules.ocr.service.IOcrRecordEOService; import com.jero.modules.oss.entity.OSSFile; @@ -28,7 +27,9 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.*; +import java.util.Arrays; +import java.util.List; +import java.util.Map; /** @@ -72,6 +73,11 @@ public class OcrRecordEOController extends JeroController pageList = ocrRecordService.page(page, queryWrapper); List rows = pageList.getRecords(); for (OcrRecordEO row : rows){ + if(StringUtils.isNotEmpty(row.getConnectId())) { + row.setFileSource(FileSourceEnum.IMPORT.getValue()); + }else{ + row.setFileSource(FileSourceEnum.UPLOAD.getValue()); + } if(StringUtils.isNotEmpty(row.getDocRealName())) { row.setDocRealFile(ocrDownPath + row.getDocRealName()); } @@ -86,97 +92,29 @@ public class OcrRecordEOController extends JeroController syncToDocument(@RequestBody OcrRecordEO ocrRecordEO) { - if(StringUtils.isBlank(ocrRecordEO.getAttId())){ - return Result.error("没有可同步的文档"); + if(StringUtils.isBlank(ocrRecordEO.getConnectId())){ + return Result.error("同步失败"); } - if (StringUtils.isBlank(ocrRecordEO.getStandName()) - || StringUtils.isBlank(ocrRecordEO.getStandNumber())){ - return Result.error("参数不能为空"); + //查询doc文件的id + LambdaQueryWrapper ossFileLambdaQueryWrapper = new LambdaQueryWrapper<>(); + ossFileLambdaQueryWrapper.eq(OSSFile::getUrl, ocrRecordEO.getDocName()); + List ossFiles = ossFileService.list(ossFileLambdaQueryWrapper); + if (CollectionUtil.isEmpty(ossFiles)) { + return Result.error("没有可同步的文件"); } - if (StringUtils.isBlank(ocrRecordEO.getFileType())) { - return Result.error("文本状态不能为空"); - } - //通过编号和标题查询对应文档 - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(BussDocumentLibraryEO::getTitle, ocrRecordEO.getStandName()) - .eq(BussDocumentLibraryEO::getSerialNumber, ocrRecordEO.getStandNumber()); - List bussDocumentLibraryEOList = bussDocumentLibraryEOService.list(queryWrapper); - if(CollectionUtil.isNotEmpty(bussDocumentLibraryEOList)){ - //查询doc文件的id - LambdaQueryWrapper ossFileLambdaQueryWrapper = new LambdaQueryWrapper<>(); - ossFileLambdaQueryWrapper.eq(OSSFile::getUrl, ocrRecordEO.getDocName()); - List ossFiles = ossFileService.list(ossFileLambdaQueryWrapper); - if (CollectionUtil.isEmpty(ossFiles)) { - return Result.error("没有可同步的文件"); - } - //开始同步 - int countSuccess = 0; - for(BussDocumentLibraryEO documentLibraryEO : bussDocumentLibraryEOList) { - OSSFile ossFile = new OSSFile(); - String docFileId = ossFiles.get(0).getId(); - ossFile.setId(docFileId); - //设置doc文件的关联id - if (FileTypeEnum.RELEASE_DRAFT.getValue().equals(ocrRecordEO.getFileType())) { - String connectId = documentLibraryEO.getReleaseDraft(); - if (StringUtils.isBlank(connectId)) { - connectId = UUID.randomUUID().toString().replace("-", ""); - //修改文档库相关字段 - BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO(); - bussDocumentLibraryEO.setId(documentLibraryEO.getId()); - bussDocumentLibraryEO.setReleaseDraft(connectId); - bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO); - } - ossFile.setConnectId(connectId); + OSSFile ossFile = new OSSFile(); + String docFileId = ossFiles.get(0).getId(); + ossFile.setId(docFileId); + ossFile.setConnectId(ocrRecordEO.getConnectId()); + ossFileService.updateById(ossFile); - } else if (FileTypeEnum.SUPPLEMENT.getValue().equals(ocrRecordEO.getFileType())) { - String connectId = documentLibraryEO.getSupplement(); - if (StringUtils.isBlank(connectId)) { - connectId = UUID.randomUUID().toString().replace("-", ""); - //修改文档库相关字段 - BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO(); - bussDocumentLibraryEO.setId(documentLibraryEO.getId()); - bussDocumentLibraryEO.setSupplement(connectId); - bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO); - } - ossFile.setConnectId(connectId); + //修改记录表的同步情况 + OcrRecordEO updateOcrRecordEO = new OcrRecordEO(); + updateOcrRecordEO.setId(ocrRecordEO.getId()); + updateOcrRecordEO.setSyncState(FileSyncStateEnum.SYNC_YES.getValue()); + ocrRecordService.editById(updateOcrRecordEO); - } else if (FileTypeEnum.APPROVAL_DRAFT.getValue().equals(ocrRecordEO.getFileType())) { - String connectId = documentLibraryEO.getApprovalDraft(); - if (StringUtils.isBlank(connectId)) { - connectId = UUID.randomUUID().toString().replace("-", ""); - //修改文档库相关字段 - BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO(); - bussDocumentLibraryEO.setId(documentLibraryEO.getId()); - bussDocumentLibraryEO.setApprovalDraft(connectId); - bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO); - } - ossFile.setConnectId(connectId); - - } else if (FileTypeEnum.EXPOSURE_DRAFT.getValue().equals(ocrRecordEO.getFileType())) { - String connectId = documentLibraryEO.getExposureDraft(); - if (StringUtils.isBlank(connectId)) { - connectId = UUID.randomUUID().toString().replace("-", ""); - //修改文档库相关字段 - BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO(); - bussDocumentLibraryEO.setId(documentLibraryEO.getId()); - bussDocumentLibraryEO.setExposureDraft(connectId); - bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO); - } - ossFile.setConnectId(connectId); - - } - ossFileService.updateById(ossFile); - //修改记录表的同步情况 - OcrRecordEO updateOcrRecordEO = new OcrRecordEO(); - updateOcrRecordEO.setId(ocrRecordEO.getId()); - updateOcrRecordEO.setSyncState(FileSyncStateEnum.SYNC_YES.getValue()); - ocrRecordService.editById(updateOcrRecordEO); - countSuccess++; - } - return Result.OK("同步成功", countSuccess); - }else{ - return Result.error("没有可同步的文档"); - } + return Result.OK("同步成功", ossFile); } /** diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/controller/OcrRestfulController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/controller/OcrRestfulController.java index d9686a8a5..dec4efd75 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/controller/OcrRestfulController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/controller/OcrRestfulController.java @@ -1,11 +1,10 @@ package com.jero.modules.ocr.controller; -import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; -import com.alibaba.fastjson.JSON; import com.jero.common.api.vo.Result; -import com.jero.modules.ocr.entity.OcrCallBackResultEO; +import com.jero.common.exception.JeroBootException; import com.jero.modules.ocr.entity.OcrRecordEO; +import com.jero.modules.ocr.enums.ResultContentEnum; import com.jero.modules.ocr.service.IOcrRecordEOService; import com.jero.modules.ocr.service.IOcrRestfulService; import com.jero.modules.ocr.util.MD5Util; @@ -14,6 +13,7 @@ import com.jero.modules.oss.service.IOSSFileService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.apache.http.entity.ContentType; import org.springframework.beans.factory.annotation.Autowired; @@ -22,11 +22,11 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import java.io.File; -import java.io.FileInputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.List; /** * @program: OcrDemo @@ -56,9 +56,37 @@ public class OcrRestfulController{ @Value("${OCR.ocrDownPath}") private String ocrDownPath; + @Value("${OCR.ocrPath}") + private String ocrPath; + @Value("${jero.path.upload}") private String filePath;//文件存储路径 + @ApiOperation(value = "下载word文件") + @GetMapping("/downFile") + public void downFile(String fileName, HttpServletResponse response, HttpServletRequest request) throws Exception { + InputStream is = null; + OutputStream os = null; + response.reset(); + try { + response.setHeader("Content-Disposition", "attachment; filename=" + fileName); + response.setContentType("application/octet-stream"); + + String fullPath = ocrPath + fileName; + is = new FileInputStream(fullPath); + os = response.getOutputStream(); + IOUtils.copy(is, os); + os.flush(); + } catch (FileNotFoundException var4) { + throw new JeroBootException("文件[" + ocrPath + fileName + "]不存在"); + } catch (IOException e) { + log.error(e.getMessage(), e); + } finally { + is.close(); + os.close(); + } + } + /** * 测试OCR * @param file @@ -77,34 +105,38 @@ public class OcrRestfulController{ * OCR回调 * @param wordFile * @param jsonFile - * @param ocrCallBackResultEo + * @param taskId + * @param result + * @param key * @return */ @ApiOperation(value = "OCR回调") - @PostMapping("/OcrHandleResult") - public String OcrHandleResult(@RequestParam("wordFile") MultipartFile wordFile,@RequestParam("jsonFile") MultipartFile jsonFile, OcrCallBackResultEO ocrCallBackResultEo) { + @PostMapping("/ocrHandleResult") + public String ocrHandleResult(@RequestParam("wordFile") MultipartFile wordFile, + @RequestParam("jsonFile") MultipartFile jsonFile, + @RequestParam("taskId") String taskId, + @RequestParam("result") String result, + @RequestParam("key") String key) { try{ log.info("调取到我了"); - log.info("接口回调结果:"+ JSON.toJSONString(ocrCallBackResultEo)); log.info("接口回调时所传文件---wordFile:"+ wordFile.toString() +"; jsonFile:"+jsonFile.toString()); - if("error".equals(ocrCallBackResultEo.getResult())){ + if("error".equals(result)){ log.info("客户接口处理文件失败"); - ocrRestfulService.updateDb(ocrCallBackResultEo.getTaskID(),"客户接口处理文件失败"); + ocrRestfulService.updateDb(taskId,"客户接口处理文件失败"); return "{\"result\":\"error\"}"; } //1.验证 key 是否符合,不符合打回,符合继续 //2.向后传递文件 - String key = ocrCallBackResultEo.getKey(); - String sign = ocrCallBackResultEo.getTaskID() + OcrPublicKey; + String sign = taskId + OcrPublicKey; String signMD5 = MD5Util.string2MD5(sign); // String encpySign =MD5Util.convertMD5(signMD5); if(!signMD5.equals(key)){ //不同,则认证失败 log.info("认证失败"); - ocrRestfulService.updateDb(ocrCallBackResultEo.getTaskID(),"回调接口认证失败"); + ocrRestfulService.updateDb(taskId, ResultContentEnum.OCR_CONVERT_FAIL.getValue()); return "{\"result\":\"Authentication failed\"}"; } - return ocrRestfulService.OcrHandleResult(wordFile,jsonFile,ocrCallBackResultEo.getTaskID()); + return ocrRestfulService.ocrHandleResult(wordFile,jsonFile,taskId); }catch (Exception e){ log.error(e.getMessage(),e); return "{\"result\":\"runTimeException\"}"; diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/entity/OcrRecordEO.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/entity/OcrRecordEO.java index c23b80c5c..1c49f6f67 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/entity/OcrRecordEO.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/entity/OcrRecordEO.java @@ -1,22 +1,20 @@ package com.jero.modules.ocr.entity; -import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; import com.fasterxml.jackson.annotation.JsonFormat; -import org.springframework.format.annotation.DateTimeFormat; -import org.jeecgframework.poi.excel.annotation.Excel; import com.jero.common.aspect.annotation.Dict; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; /** @@ -128,9 +126,15 @@ public class OcrRecordEO implements Serializable { @Excel(name = "同步状态", width = 15) @ApiModelProperty(value = "同步状态") private String syncState; + + /**文档库关联文件id*/ + @ApiModelProperty(value = "文档库关联文件id") + private String connectId; @TableField(exist = false) private String docRealFile; @TableField(exist = false) private String jsonRealFile; + @TableField(exist = false) + private String fileSource; //文件来源:0-上传 1-导入 } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/enums/FileSourceEnum.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/enums/FileSourceEnum.java new file mode 100644 index 000000000..92e6f5b38 --- /dev/null +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/enums/FileSourceEnum.java @@ -0,0 +1,36 @@ +package com.jero.modules.ocr.enums; + +/** + * @Author: liyawei + * @Description: + * @Date: Created in 16:04 2022/3/8 + */ +public enum FileSourceEnum { + UPLOAD("上传","0"), + IMPORT("导入","1"); + + String name; + String value; + + FileSourceEnum(String name, String value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/mapper/xml/OcrRecordEOMapper.xml b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/mapper/xml/OcrRecordEOMapper.xml index 1f4706a18..6c646df99 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/mapper/xml/OcrRecordEOMapper.xml +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/mapper/xml/OcrRecordEOMapper.xml @@ -21,5 +21,6 @@ + \ No newline at end of file diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/IOcrRestfulService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/IOcrRestfulService.java index 084b098c0..d6c6e7833 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/IOcrRestfulService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/IOcrRestfulService.java @@ -1,6 +1,5 @@ package com.jero.modules.ocr.service; -import com.baomidou.mybatisplus.extension.service.IService; import com.jero.common.api.vo.Result; import com.jero.modules.ocr.entity.OcrRecordEO; import org.springframework.web.multipart.MultipartFile; @@ -13,7 +12,7 @@ import org.springframework.web.multipart.MultipartFile; public interface IOcrRestfulService{ Result handleFile(MultipartFile file, String fileName, OcrRecordEO getOcrEO, String type) throws Exception; - String OcrHandleResult(MultipartFile wordFile,MultipartFile jsonFile,String taskId) throws Exception; + String ocrHandleResult(MultipartFile wordFile,MultipartFile jsonFile,String taskId) throws Exception; OcrRecordEO getOcrResult(String taskId, int i) throws Exception; diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/impl/OcrRestfulServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/impl/OcrRestfulServiceImpl.java index 6e1c12ae7..24388ccae 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/impl/OcrRestfulServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/impl/OcrRestfulServiceImpl.java @@ -10,6 +10,9 @@ import com.jero.modules.ocr.service.IOcrRecordEOService; import com.jero.modules.ocr.service.IOcrRestfulService; import com.jero.modules.ocr.util.Base64Util; import com.jero.modules.ocr.util.RsaUtil; +import com.jero.modules.ocr.util.UUIDUtils; +import com.jero.modules.oss.entity.OSSFile; +import com.jero.modules.oss.service.IOSSFileService; import com.jero.modules.system.vo.OcrVO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; @@ -52,6 +55,8 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService { @Autowired private IOcrRecordEOService ocrRecordEOService; + @Autowired + private IOSSFileService ossFileService; //请求处理文件url @@ -86,7 +91,7 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService { public Result handleFile(MultipartFile file, String fileName, OcrRecordEO getOcrEO, String type) throws Exception { String taskId = ""; if ("add".equals(type)) { - taskId = UUID.randomUUID().toString().replace("-", ""); + taskId = UUIDUtils.randomUUID20(); } else { taskId = getOcrEO.getId(); } @@ -126,6 +131,7 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService { ocrVO.setFileContent(fileContent); ocrVO.setTaskId(taskId); ocrVO.setRestCallBackUrl(RestCallBackUrl); + ocrVO.setIsThird(true); ResponseEntity responseEntity = localToolFeignClient.getFile(ocrVO); log.info("请求OCR接口完毕,返回响应状态:【"+sdf.format(new Date())+"】"); @@ -145,6 +151,7 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService { ocrRecordEO.setStandNumber(getOcrEO.getStandNumber()); ocrRecordEO.setStandName(getOcrEO.getStandName()); ocrRecordEO.setFileType(getOcrEO.getFileType()); + ocrRecordEO.setConnectId(getOcrEO.getConnectId()); // LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); // ocrRecordEO.setCreateBy(sysUser.getId()); // ocrRecordEO.setCreateTime(new Date()); @@ -160,6 +167,7 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService { ocrRecordEO.setStandName(getOcrEO.getStandName()); ocrRecordEO.setFileType(getOcrEO.getFileType()); ocrRecordEO.setCreateTime(new Date()); + ocrRecordEO.setConnectId(getOcrEO.getConnectId()); ocrRecordEOService.editById(ocrRecordEO); //TODO ?? return Result.OK( "加入转换成功", taskId); } @@ -173,19 +181,19 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService { } } - public String OcrHandleResult(MultipartFile wordFile,MultipartFile jsonFile,String taskId) throws Exception { + public String ocrHandleResult(MultipartFile wordFile,MultipartFile jsonFile,String taskId) throws Exception { //首先将文件保存至本地 String saveWordFilePath=null; String saveWordFileName=null; if(wordFile!=null && !wordFile.isEmpty()){ - saveWordFileName= UUID.randomUUID().toString().replace("-", "") + "_"+wordFile.getOriginalFilename(); + saveWordFileName= UUIDUtils.randomUUID20() + "_"+wordFile.getOriginalFilename(); saveWordFilePath=ocrFilePath+saveWordFileName; FileUtils.copyInputStreamToFile(wordFile.getInputStream(),new File(saveWordFilePath)); } String saveJsonFilePath=null; String saveJsonFileName=null; if(jsonFile!=null && !jsonFile.isEmpty()){ - saveJsonFileName=UUID.randomUUID().toString().replace("-", "") + "_"+jsonFile.getOriginalFilename(); + saveJsonFileName=UUIDUtils.randomUUID20() + "_"+jsonFile.getOriginalFilename(); saveJsonFilePath=ocrFilePath+saveJsonFileName; FileUtils.copyInputStreamToFile(jsonFile.getInputStream(),new File(saveJsonFilePath)); } @@ -201,7 +209,15 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService { ocrRecordEO.setJsonFileCode(null); ocrRecordEO.setUpdateTime(new Date()); ocrRecordEO.setResultContent("转换成功"); - ocrRecordEOService.editById(ocrRecordEO); + ocrRecordEOService.updateById(ocrRecordEO); + + //记录doc文件信息 + OSSFile docFile = new OSSFile(); + docFile.setId(UUID.randomUUID().toString().replace("-", "")); + docFile.setUrl(saveWordFilePath); + docFile.setFileName(saveWordFilePath.substring(saveWordFilePath.lastIndexOf("_")+1)); + ossFileService.save(docFile); + return "{\"result\":\"success\"}"; }else{ updateDb(taskId,"error:File does not exist"); @@ -236,7 +252,7 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService { ocrRecordEO.setId(taskId); ocrRecordEO.setUpdateTime(new Date()); ocrRecordEO.setResultContent(result); - ocrRecordEOService.editById(ocrRecordEO); + ocrRecordEOService.updateById(ocrRecordEO); } public boolean checkFileName(String fileName){ diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/util/RandomUtils.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/util/RandomUtils.java new file mode 100644 index 000000000..a727749f3 --- /dev/null +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/util/RandomUtils.java @@ -0,0 +1,57 @@ +package com.jero.modules.ocr.util; + +import java.awt.*; +import java.util.Random; + +/** + * @Author: liyawei + * @Description: + * @Date: Created in 0:09 2022/3/8 + */ +public class RandomUtils extends org.apache.commons.lang3.RandomUtils { + private static final char[] codeSeq = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', '8', '9'}; + private static final char[] numberArray = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; + private static Random random = new Random(); + + public RandomUtils() { + } + + public static final String randomString(int length) { + StringBuilder sb = new StringBuilder(); + + for(int i = 0; i < length; ++i) { + sb.append(String.valueOf(codeSeq[random.nextInt(codeSeq.length)])); + } + + return sb.toString(); + } + + public static final String randomNumberString(int length) { + StringBuilder sb = new StringBuilder(); + + for(int i = 0; i < length; ++i) { + sb.append(String.valueOf(numberArray[random.nextInt(numberArray.length)])); + } + + return sb.toString(); + } + + public static Color randomColor(int fc, int bc) { + int f = fc; + int b = bc; + Random random = new Random(); + if (fc > 255) { + f = 255; + } + + if (bc > 255) { + b = 255; + } + + return new Color(f + random.nextInt(b - f), f + random.nextInt(b - f), f + random.nextInt(b - f)); + } + + public static int nextInt(int bound) { + return random.nextInt(bound); + } +} diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/util/UUIDUtils.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/util/UUIDUtils.java new file mode 100644 index 000000000..b94deb1ab --- /dev/null +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/util/UUIDUtils.java @@ -0,0 +1,38 @@ +package com.jero.modules.ocr.util; + + +import java.util.Random; + +public class UUIDUtils { + + public static String randomUUID10() { + return RandomUtils.randomString(10); + } + + public static String randomUUID20() { + return RandomUtils.randomString(20); + } + + public static String randomUUID(int length) { + return RandomUtils.randomString(length); + } + + public static String getUUIDPath(String uuid){ + StringBuilder builder=new StringBuilder(); + builder.append("/"); + builder.append((uuid.substring(0, 3).hashCode())%100+"").append("/"); + builder.append((uuid.substring(7,10).hashCode())%100+"").append("/"); + builder.append((uuid.substring(11,14).hashCode())%100+"").append("/"); + return builder.toString(); + } + + public static String getAttTable(){ + Random rand = new Random(); + int nextInt = rand.nextInt(10)+1; + StringBuilder builder=new StringBuilder(); + builder.append("ATT_FILE_").append(String.format("%02d", nextInt)); + return builder.toString(); + } + + +} diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/common/FileUnZip.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/common/FileUnZip.java index a5c3af002..b74ecdecf 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/common/FileUnZip.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/common/FileUnZip.java @@ -113,21 +113,51 @@ public class FileUnZip { * @param filename */ public static List readFileByFilename(String path,String filename) { + if(filename.contains("/")){ + filename = filename.split("/")[1]; + } List resultlist = new ArrayList<>(); if (StringUtil.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); + if(fi.isDirectory()){ + File[] filesTemp = fi.listFiles(); + for (File fileTemp : filesTemp) { + // 对文件进行过滤 + if (fileTemp.getName().equals(filename)) { + resultlist.add(fileTemp); + } + } + }else{ + // 对文件进行过滤 + if (fi.getName().equals(filename)) { + resultlist.add(fi); + } } + } } } return resultlist; } +// public static List readFileByFilename(String path,String filename) { +// List resultlist = new ArrayList<>(); +// if (StringUtil.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: 删除某个文件 @@ -152,4 +182,21 @@ public class FileUnZip { } } + 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; + } + } diff --git a/jero-boot/jero-boot-single-startup/src/main/resources/application-dev.yml b/jero-boot/jero-boot-single-startup/src/main/resources/application-dev.yml index 3dc0af395..b8ab33495 100644 --- a/jero-boot/jero-boot-single-startup/src/main/resources/application-dev.yml +++ b/jero-boot/jero-boot-single-startup/src/main/resources/application-dev.yml @@ -299,11 +299,11 @@ justauth: # 云端OCR识别集成配置参数 OCR: #请求OCR转换接口 - handleFileUrl: https://sws.trans-cosmos.com.cn/WebService.asmx/FileConversion - #handleFileUrl = https://61.136.1.103:8091/WebService.asmx/FileConversion +# handleFileUrl: https://sws.trans-cosmos.com.cn/WebService.asmx/FileConversion + handleFileUrl: http://61.136.1.103:8091/WebService.asmx/FileConversion # OCR回调接口地址 配置客户本地的IP及端口号 -# callBackUrl: http://139.9.235.66:9110/api/ocr/OCRRestful/OcrHandleResult - callBackUrl: http://127.0.0.1:8080/api/ocr/OCRRestful/OcrHandleResult +# callBackUrl: http://139.9.235.66:9110//api/ocr/OCRRestful/OcrHandleResult + callBackUrl: http://139.9.235.66:9022/local-tool/ocr/ocrHandleResult # OCR认证用户 userId: dayuzhou1234 # OCR认证编码 @@ -320,11 +320,6 @@ OCR: times: 20 # OCR转换类型 convertType: BOTH -## 这个IFeignService是加了@FeignClient注解的类 -local-tool: - ribbon: - ## 服务提供者的地址,不是服务注册中心的地址 - listOfServers: http://139.9.235.66:9022 ## 这个要有,如果不加,只加了上面也没用 ribbon: diff --git a/jero-web/src/common/lang/en-us.js b/jero-web/src/common/lang/en-us.js index 4e0beea87..596e3765d 100644 --- a/jero-web/src/common/lang/en-us.js +++ b/jero-web/src/common/lang/en-us.js @@ -500,4 +500,10 @@ module.exports = { ProcessStatus:'Process status', CompletionTime:'Completion time', draft:'draft', + CannotExceed100characters:'cannot exceed 100 characters', + cantExeed:'cannot exceed ', + characters:' characters', + + Processing:'Processing', + See:'See', } \ No newline at end of file diff --git a/jero-web/src/common/lang/zh-cn.js b/jero-web/src/common/lang/zh-cn.js index 6e19388c9..30ab98321 100644 --- a/jero-web/src/common/lang/zh-cn.js +++ b/jero-web/src/common/lang/zh-cn.js @@ -424,7 +424,7 @@ module.exports = { LabeItemName:'标签项名称', PleaseEnterLabelName:'请输入标签名称', DisplayArea:'展示区域', - ChineseName:'中文名称', + ChineseName:'属性名称', AttributeType:'属性类型', FieldLength:'字段长度', DisplayOrder:'展示顺序', @@ -504,4 +504,9 @@ module.exports = { ProcessStatus:'流程状态', CompletionTime:'完成时间', draft:'草稿', + CannotExceed100characters:'不能超过100字符', + cantExeed:'不能超过', + characters:'字符', + Processing:'办理', + See:'查看', } \ No newline at end of file diff --git a/jero-web/src/components/libraryAddForm/index.vue b/jero-web/src/components/libraryAddForm/index.vue index 321e58705..a8152d060 100644 --- a/jero-web/src/components/libraryAddForm/index.vue +++ b/jero-web/src/components/libraryAddForm/index.vue @@ -322,12 +322,12 @@ }) }, dateChange(item) { - this.formInline[item.db_field_name] = moment(this.formInline[item.db_field_name]).format('YYYY-MM-DD') + this.formInline[item.db_field_name] = this.formInline[item.db_field_name] ? moment(this.formInline[item.db_field_name]).format('YYYY-MM-DD') : '' }, onChange(item) { let dateOne = moment(this.formInline[item][0]).format('YYYY-MM-DD') let dateTwo = moment(this.formInline[item][1]).format('YYYY-MM-DD') - this.formInline[item] = [dateOne, dateTwo] + this.formInline[item] =dateOne ? [dateOne, dateTwo] : [] }, clickButtonToUpload(current) { diff --git a/jero-web/src/components/ocrAddForm/index.vue b/jero-web/src/components/ocrAddForm/index.vue index abf2d9c62..daed13cb8 100644 --- a/jero-web/src/components/ocrAddForm/index.vue +++ b/jero-web/src/components/ocrAddForm/index.vue @@ -271,7 +271,7 @@ }, methods: { sumber() { - console.log('vilidate',this.$refs.ruleForm1) + console.log('vilidate',this.formInline) this.$refs.ruleForm1.validate(valid => { console.log('va',valid) if (valid) { @@ -283,11 +283,11 @@ } postAction(url, this.formInline).then((res) => { if (res.success) { - this.$message.success(res.message) + this.$message.success(this.$t('OperationSuccessful')) eventBUs.$emit('searchReset') this.$emit('addFormClick') } else { - this.$message.warning(res.message) + this.$message.warning(this.$t('operationFailed')) } }) } else { @@ -310,6 +310,7 @@ /** 赋值给当前对应的表单文件 */ this.formInline[this.uploadName] = attIdList.join(',') this.formInline = { ...this.formInline } + console.log('form',this.formInline) } }, handleInput(value) { @@ -371,7 +372,6 @@ this.$set(this, 'rules', rules) this.isFormInline = true this.confirmLoading = false - console.log('rules',rules,this) }, getForm() { this.confirmLoading = true diff --git a/jero-web/src/components/ocrTable/docTable.vue b/jero-web/src/components/ocrTable/docTable.vue index dce4b8bae..4c19b02a2 100644 --- a/jero-web/src/components/ocrTable/docTable.vue +++ b/jero-web/src/components/ocrTable/docTable.vue @@ -16,7 +16,7 @@ - {{record.resultContent=='转换成功'&&record.syncState=='未同步'?ol.text:''}} + {{record.resultContent=='转换成功'&&record.syncState=='未同步'&&record.fileSource=='1'?ol.text:''}} {{record.resultContent=='转换成功'&&record.syncState=='未同步'?ol.text:''}} @@ -112,6 +112,7 @@ }) eventBUs.$on('searchReset', target => { this.searchParmes = {} + this.selectedRowKeys=[] this.getData() this.getTableList() }) diff --git a/jero-web/src/components/ocrTable/index.vue b/jero-web/src/components/ocrTable/index.vue index 0f5f258e8..d25438b7c 100644 --- a/jero-web/src/components/ocrTable/index.vue +++ b/jero-web/src/components/ocrTable/index.vue @@ -16,7 +16,7 @@ - {{record.resultContent=='转换成功'&&record.syncState=='未同步'?ol.text:''}} + {{record.resultContent=='转换成功'&&record.syncState=='未同步'&&record.fileSource=='1'?ol.text:''}} {{record.resultContent=='转换成功'&&record.syncState=='未同步'?ol.text:''}} diff --git a/jero-web/src/components/tableDate/index.vue b/jero-web/src/components/tableDate/index.vue index 7d83774ed..ca11dfd73 100644 --- a/jero-web/src/components/tableDate/index.vue +++ b/jero-web/src/components/tableDate/index.vue @@ -27,7 +27,9 @@ - {{text}} + + {{text && text.length > 18?text.slice(0,17)+'...':text}} + @@ -187,6 +189,11 @@ this.loading = true postAction(this.url.tableList, params).then((res) => { if (res.success) { + if (res.result.current > 1 && res.result.records.length == 0){ + this.pageNo = res.result.current - 1 + this.getTableList() + return + } this.dataSource = res.result.records this.total = res.result.total this.loading = false diff --git a/jero-web/src/components/uploadFile/file.vue b/jero-web/src/components/uploadFile/file.vue index 2e2f81ab2..aae9857dd 100644 --- a/jero-web/src/components/uploadFile/file.vue +++ b/jero-web/src/components/uploadFile/file.vue @@ -1,68 +1,71 @@ \ No newline at end of file diff --git a/jero-web/src/views/documentManage/ocr/index.vue b/jero-web/src/views/documentManage/ocr/index.vue index 22a33ce1a..b620dcd95 100644 --- a/jero-web/src/views/documentManage/ocr/index.vue +++ b/jero-web/src/views/documentManage/ocr/index.vue @@ -164,7 +164,9 @@ confirmLoading: false, selectedIds:'', //选择行id record:{}, - accept:'application/pdf' + accept:'application/pdf', + today:'', + timer:'' } }, props:{ @@ -173,9 +175,26 @@ mounted() { // this.loadData() }, + created() { + const date = new Date(), + year = date.getFullYear(), + month = date.getMonth()+1, + myDate = date.getDate() + this.today = `${year}/${month < 10 ? '0'+month : month}/${myDate < 10 ? '0'+myDate : myDate}` + if(this.timer){ + clearInterval(this.timer) + }else{ + eventBUs.$emit('searchReset') + this.initSetTimeout(this.today)//调用每隔10秒刷新数据 + } + }, + methods:{ //上传 handleUpload(){ + // if(this.timer){ + // clearInterval(this.timer) + // } this.fileVisible=true }, //调取已入库文件 @@ -229,8 +248,9 @@ //下载 actionDown(val){ // downloadFile('/sys/common/download', val.docRealName, { id: val.attId }) + downloadFile('ocr/OcrRestful/downFile', val.docRealName, { fileName: val.docRealName }) // downloadFile(val.docRealFile) - window.open(val.docRealFile) + // window.open(val.docRealFile) }, //删除 actionDelete(record){ @@ -264,6 +284,7 @@ }, //上传确定按钮 modalOk(){ + this.$refs.fileForm.sumber() }, handleCancel(){ @@ -325,8 +346,17 @@ }, addFormClick() { this.fileVisible = false - } - } + }, + //10秒刷新页面 + initSetTimeout(today) {//每隔10秒刷新数据,也就是每隔10秒向后台请求一次数据 + this.timer=setInterval( () => { + eventBUs.$emit('searchReset') + }, 10000) + }, + }, + beforeDestroy(){ + clearInterval(this.timer) + }, } diff --git a/jero-web/src/views/documentManage/ocr/modules/docTable.vue b/jero-web/src/views/documentManage/ocr/modules/docTable.vue index f080108d7..17f488db6 100644 --- a/jero-web/src/views/documentManage/ocr/modules/docTable.vue +++ b/jero-web/src/views/documentManage/ocr/modules/docTable.vue @@ -190,7 +190,8 @@ let params = { attId: this.rows.id, standName: this.rows.title, - standNumber: this.rows.serial_number + standNumber: this.rows.serial_number, + connectId:this.rows.connect_id } if(this.rows.text_info=='发布稿(必读)'){ params.fileType='1' diff --git a/jero-web/src/views/documentManage/tags/dialog/OnlCgformTagForm.vue b/jero-web/src/views/documentManage/tags/dialog/OnlCgformTagForm.vue index e0fd425aa..36eda5b2b 100644 --- a/jero-web/src/views/documentManage/tags/dialog/OnlCgformTagForm.vue +++ b/jero-web/src/views/documentManage/tags/dialog/OnlCgformTagForm.vue @@ -76,8 +76,8 @@ - - + + {{item.showArea}} @@ -176,9 +176,14 @@ ], dbFieldTxt: [ { required: true, message: this.$t('PleaseEnterPropertyName'),trigger: 'blur'}, + { min:1, max: 20, message: this.$t('cantExeed')+'20'+this.$t('characters'), trigger: 'blur' }, ], dbFieldName: [ { required: true, message: this.$t('PleaseEnterYourEnglishName'),trigger: 'blur'}, + { min:1, max: 20, message: this.$t('cantExeed')+'20'+this.$t('characters'), trigger: 'blur' }, + ], + dbFieldEnName:[ + { max: 50, message: this.$t('cantExeed')+'50'+this.$t('characters'), trigger: 'blur' }, ], fieldShowType: [ { required: true, message: this.$t('PleaseSelectAttributeType'),trigger: 'change'}, @@ -198,7 +203,7 @@ isShowForm: [ { required: true, message: this.$t('SelectWhetherDisplayList'),trigger: 'change'}, ], - areaId: [ + showArea: [ { required: true, message: this.$t('SelectDisplayArea'),trigger: 'change'}, ], isQuery: [ @@ -351,6 +356,7 @@ httpurl+=this.url.add; method = 'post'; this.form.id='' + this.form.isReadOnly=0 }else if(this.submitEdit=='edit'){ httpurl+=this.url.edit; method = 'put'; diff --git a/jero-web/src/views/documentManage/tags/dialog/areaManage.vue b/jero-web/src/views/documentManage/tags/dialog/areaManage.vue index fb256919e..a51a0d19d 100644 --- a/jero-web/src/views/documentManage/tags/dialog/areaManage.vue +++ b/jero-web/src/views/documentManage/tags/dialog/areaManage.vue @@ -111,8 +111,8 @@ columns: [ { title: this.$t('DisplayArea'), - dataIndex: 'show_area', - key: 'show_rea', + dataIndex: 'showArea', + key: 'showArea', align: "center", width: 100, }, @@ -120,13 +120,13 @@ title: this.$t('enName'), align: "center", width: 100, - dataIndex: 'en_name', + dataIndex: 'enName', }, { title: this.$t('Module'), align: "center", width: 100, - dataIndex: 'item_text', + dataIndex: 'isModel_dictText', }, { title: this.$t('SortNumber'), @@ -162,6 +162,10 @@ { required: true, message: this.$t('PleaseSelectModule'), trigger: 'change' }, ], + enName:[ + { max: 100, message: this.$t('CannotExceed100characters'), trigger: 'blur' }, + + ], showArea:[ { required: true, message: this.$t('enterDisplayArea'), trigger: 'blur' }, { min:1, max: 50, message: this.$t('charactersLength'), trigger: 'blur' }, @@ -184,9 +188,9 @@ let params={ ...this.queryParams } - getAction(`tag/onlCgformArea/page`,params).then(res=>{ + postAction(`tag/onlCgformArea/page`,params).then(res=>{ if(res.success){ - this.areaTable=res.result + this.areaTable=[...res.result.records] this.total=res.result.total } }) diff --git a/jero-web/src/views/documentManage/tags/dialog/dicList.vue b/jero-web/src/views/documentManage/tags/dialog/dicList.vue index f51360e11..5b21c47cc 100644 --- a/jero-web/src/views/documentManage/tags/dialog/dicList.vue +++ b/jero-web/src/views/documentManage/tags/dialog/dicList.vue @@ -36,7 +36,10 @@ :label-col="labelCol" :wrapper-col="wrapperCol" > - + + + + @@ -102,6 +105,10 @@ newVisible:false, rules:{ name:[ + { required: true, message: this.$t('enterName'), trigger: 'blur' }, + { min:1, max: 30, message: this.$t('charactersLength130'), trigger: 'blur' }, + ], + itemText:[ { required: true, message: this.$t('enterName'), trigger: 'blur' }, { min:1, max: 30, message: this.$t('charactersLength130'), trigger: 'blur' }, ], @@ -127,17 +134,36 @@ total:0, isEdit:false, selectedIds:[], //树形选中的id - parentData:[] + parentData:[], + editPId:'', + tabletreeDataSource:[] } }, watch: { parentName(value) { console.log(value); }, + editPId(){ + this.parentData=this.getParents + }, }, mounted() { this.loadData() }, + computed:{ + //获取父级名称 + getParents(){ + let parents=[] + if(this.tabletreeDataSource&&this.tabletreeDataSource.length>0){ + this.tabletreeDataSource.forEach((item)=>{ + if(item.pid=='0'&&item.id!=this.editPId){ + parents.push(item) + } + }) + } + return parents + }, + }, methods:{ //获取列表数据 loadData(){ @@ -164,25 +190,16 @@ isTagDict:1 }).then(res=>{ let parentNode=[] - let tabletreeData=[...res.result] - let data = this.toTree(tabletreeData) + this.tabletreeDataSource=[...res.result] + let data = this.toTree(this.tabletreeDataSource) this.tabletreeData=data - this.parentData=this.getParents(tabletreeData) + this.parentData=this.getParents this.dataFlag=true }) } }, - //获取父级名称 - getParents(data){ - let parents=[] - data.forEach((item)=>{ - if(item.pid=='0'){ - parents.push(item) - } - }) - return parents - }, + //将数据拼成树形结构 toTree(config) { config.forEach(function(item) { @@ -313,6 +330,8 @@ //树状编辑 editTreeDict(val,form){ this.title=this.$t('edit') + this.editPId=form.id + // console.log('dictId',form) this.isEdit=true this.form={...form} if(form.pid=='0'){ diff --git a/jero-web/src/views/documentManage/tags/dialog/listTable.vue b/jero-web/src/views/documentManage/tags/dialog/listTable.vue index 6a4177d13..5aee55af8 100644 --- a/jero-web/src/views/documentManage/tags/dialog/listTable.vue +++ b/jero-web/src/views/documentManage/tags/dialog/listTable.vue @@ -128,6 +128,7 @@ } .page{ margin-top: 20px; + text-align: right; } } \ No newline at end of file diff --git a/jero-web/src/views/documentManage/tags/dialog/treeTable.vue b/jero-web/src/views/documentManage/tags/dialog/treeTable.vue index 49ce0b94c..1f4f2ebd3 100644 --- a/jero-web/src/views/documentManage/tags/dialog/treeTable.vue +++ b/jero-web/src/views/documentManage/tags/dialog/treeTable.vue @@ -133,7 +133,7 @@ deleteAction(`sys/category/delete`, { id: val.id }).then((res) => { if (res.success) { this.$message.success(this.$t('OperationSuccessful')); - this.$emit('ok') + this.$emit('ok',this.queryParams) }else{ this.$message.warning(this.$t('operationFailed')); } @@ -293,6 +293,7 @@ .tree-table{ .page{ margin-top: 20px; + text-align: right; } } diff --git a/jero-web/src/views/documentManage/tags/tabs/tabTable.vue b/jero-web/src/views/documentManage/tags/tabs/tabTable.vue index e5c79ec4a..80abf37e9 100644 --- a/jero-web/src/views/documentManage/tags/tabs/tabTable.vue +++ b/jero-web/src/views/documentManage/tags/tabs/tabTable.vue @@ -11,9 +11,9 @@ :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" @change="handleTableChange"> - {{$t('edit')}} - - {{$t('delete')}} + {{$t('edit')}} + + {{$t('delete')}}
@@ -50,10 +50,14 @@ props:{ tableData:Array, columns:Array, - total:Number + total:Number, + parm:Object }, mounted() { + this.queryParams.pageNo=this.parm.pageNo + this.queryParams.pageSize=this.parm.pageSize // console.log('colum',this.tableData,this.columns) + console.log('query',this.queryParams) }, methods:{ onSelectChange(selectedRowKeys) { @@ -90,6 +94,7 @@ } .page{ margin-top: 20px; + text-align: right; } } \ No newline at end of file diff --git a/jero-web/src/views/documentManage/tags/tabs/tagContent.vue b/jero-web/src/views/documentManage/tags/tabs/tagContent.vue index 03933dc65..4a30135d6 100644 --- a/jero-web/src/views/documentManage/tags/tabs/tagContent.vue +++ b/jero-web/src/views/documentManage/tags/tabs/tagContent.vue @@ -111,8 +111,8 @@ columns: [ { title: this.$t('LabelName'), - dataIndex: 'dict_name', - key: 'dict_name', + dataIndex: 'dictName', + key: 'dictName', align: "center", width: 100, }, @@ -120,7 +120,7 @@ title: this.$t('LabelType'), align: "center", width: 100, - dataIndex: 'attribute_type_name', + dataIndex: 'attributeType_dictText', }, { title: this.$t('describe'), @@ -170,7 +170,7 @@ getAction(`sys/dict/page`,params).then(res=>{ if(res.success){ this.total=res.result.total - this.tableData=[...res.result] + this.tableData=[...res.result.records] } }) }, @@ -328,7 +328,7 @@ } .page{ margin-top: 20px; - + text-align: right; } } .type-popover{ diff --git a/jero-web/src/views/documentManage/tags/tabs/tagItem.vue b/jero-web/src/views/documentManage/tags/tabs/tagItem.vue index b763edd95..15ef6a9be 100644 --- a/jero-web/src/views/documentManage/tags/tabs/tagItem.vue +++ b/jero-web/src/views/documentManage/tags/tabs/tagItem.vue @@ -44,7 +44,7 @@ - + @@ -88,37 +88,37 @@ title: this.$t('ChineseName'), align: "center", width: 100, - dataIndex: 'db_field_txt', + dataIndex: 'dbFieldTxt_dictText', }, { title: this.$t('enName'), align: "center", width: 100, - dataIndex: 'db_field_en_name', + dataIndex: 'dbFieldEnName_dictText', }, { title: this.$t('AttributeType'), align: "center", width: 100, - dataIndex: 'item_text', + dataIndex: 'fieldShowType_dictText', }, { title: this.$t('FieldLength'), align: "center", width: 80, - dataIndex: 'db_length' + dataIndex: 'dbLength_dictText' }, { title: this.$t('DisplayOrder'), align: "center", width: 80, - dataIndex: 'order_num' + dataIndex: 'orderNum_dictText' }, { title: this.$t('DisplayArea'), align: "center", width: 80, - dataIndex: 'show_area' + dataIndex: 'showAreaName' }, { title: this.$t('operation'), @@ -212,7 +212,10 @@ postAction(`tag/onlCgformTag/page`,params).then(res=>{ if(res.success){ this.total=res.result.total - this.tableData= [ ...res.result] + this.tableData= [ ...res.result.records] + this.spinning=false + }else{ + this.$message.warning(res.message) this.spinning=false } }) @@ -279,6 +282,7 @@ if (res.success) { if (this.key == 1) { this.$message.success(this.$t('OperationSuccessful')) + this.queryParam.pageNo=1 this.loadData(1) } else if (this.key == 2) { this.$message.success(this.$t('OperationSuccessful')) diff --git a/jero-web/src/views/processCenter/processList/tabComponents/alreadyProcess/index.vue b/jero-web/src/views/processCenter/processList/tabComponents/alreadyProcess/index.vue index cd4c891aa..18225f430 100644 --- a/jero-web/src/views/processCenter/processList/tabComponents/alreadyProcess/index.vue +++ b/jero-web/src/views/processCenter/processList/tabComponents/alreadyProcess/index.vue @@ -11,6 +11,9 @@ :loading="loading" :columns="columns" > + + {{$t('See')}} +
+ + {{$t('See')}} +
+ + {{$t('See')}} +
+ + {{$t('Processing')}} +
+ + {{$t('Processing')}} + {{$t('deleteLib')}} +
{ - this.$http.get('lawss/activiti/deleteDraft', { id: row.id }, { - _this: this, - loading: 'loading' - }, res => { - if (res.success) { - this.$message.success('删除成功') - this.pageNo = 1 - this.queryProcess() - } else { - } - }) + let _this = this + this.$confirm({ + content: _this.$t('ConfirmDelete'), + onOk() { + deleteAction('task/deleteDraft', { id: row.id }).then((res) => { + if (res.success) { + _this.$message.success(_this.$t('OperationSuccessful')); + this.pageNo = 1 + _this.queryProcess() + } else { + _this.$message.warning(_this.$t('operationFailed')) + } + }) + } }) }, // 查询待办流程 diff --git a/jero-web/src/views/system/MessageDetails.vue b/jero-web/src/views/system/MessageDetails.vue index e9a2c8dce..cc50cb3c6 100644 --- a/jero-web/src/views/system/MessageDetails.vue +++ b/jero-web/src/views/system/MessageDetails.vue @@ -9,8 +9,8 @@ {{$t('NotificationTime')}}: {{this.$route.query.sendTime}}
-
- {{this.$route.query.msgContentInfo}} +
+
diff --git a/jero-web/src/views/system/UserAnnouncementList.vue b/jero-web/src/views/system/UserAnnouncementList.vue index 718770312..7a5a08b23 100644 --- a/jero-web/src/views/system/UserAnnouncementList.vue +++ b/jero-web/src/views/system/UserAnnouncementList.vue @@ -65,8 +65,8 @@ :loading="loading" @change="handleTableChange"> - - {{text}} + + {{text && text.length > 25?text.slice(0,24)+'...':text}}