文档--导入(英文提示)

This commit is contained in:
zhn
2022-04-13 10:08:40 +08:00
parent 83a18675fe
commit f661ed41b5
5 changed files with 184 additions and 41 deletions
@@ -394,9 +394,10 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
@ApiOperation(value = "导入.zip")
@PostMapping(value = "/importZip")
@RequiresPermissions("document:importZip")
public Result<?> importZip(@RequestParam(value = "file", required = false) MultipartFile file) throws Exception {
public Result<?> importZip(@RequestParam(value = "file", required = false) MultipartFile file,
@RequestParam(value = "cut",required = false) String cut) throws Exception {
try {
bussDocumentLibraryEOService.importZip(file);
bussDocumentLibraryEOService.importZip(file,cut);
} catch (Exception e) {
e.printStackTrace();
return Result.error(e.getMessage());
@@ -189,7 +189,7 @@ public interface IBussDocumentLibraryEOService extends IService<BussDocumentLibr
String pullMessage(String departIds, String ids, String documentIds);
void importZip(MultipartFile file);
void importZip(MultipartFile file,String cut);
String verifyBind(List<String> ids);
@@ -2960,8 +2960,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
throw new JeroBootException("下载文件失败,请重试");
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("下载文件失败");
}else{
throw new JeroBootException("Failed to download file");
}
} finally {
IOUtils.closeQuietly(os);
File file = new File(uploadpath + "/tempZip");
@@ -3676,14 +3679,19 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
@SneakyThrows
@Override
public void importZip(MultipartFile file) {
public void importZip(MultipartFile file,String cut) {
List<String> list = getWorkbookTitle("cn");
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")) {
throw new JeroBootException("请上传zip格式的文件或rar格式的文件");
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("请上传zip格式的文件或rar格式的文件");
}else{
throw new JeroBootException("Please upload a zip file or rar file");
}
}
String path = uploadpath + File.separator + "modal" + File.separator + filenameorg + System.currentTimeMillis();
File saveDirectory = new File(path);
@@ -3706,7 +3714,12 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if (length > 2) {
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException("压缩包中必须有且仅有一个文件夹,请重新上传");
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("压缩包中必须有且仅有一个文件夹,请重新上传");
}else{
throw new JeroBootException("There must be only one folder in the compressed package Please upload it again");
}
}
File fileNew = new File(zipEntryName);
List<File> fileList = new ArrayList<>();
@@ -3718,11 +3731,21 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if (fileList.size() == 0) {
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException("压缩包根目录下没有excel作为导入数据,请重新上传");
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("压缩包根目录下没有excel作为导入数据,请重新上传");
}else{
throw new JeroBootException("Excel does not exist in the root directory of the compressed package Please upload it again");
}
} else if (fileList.size() > 1) {
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException("压缩包根目录下仅能存在一个excel为导入数据,请重新上传");
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("压缩包根目录下仅能存在一个excel为导入数据,请重新上传");
}else{
throw new JeroBootException("Only one Excel file can be imported in the compressed package root directory. Please upload data again");
}
}
// 数据相关处理,
@@ -3732,11 +3755,21 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if (excelfilelist.size() < 1) {
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException("压缩包内没有上传Excel数据");
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("压缩包内没有上传Excel数据");
}else{
throw new JeroBootException("No Excel data is uploaded in the compressed package");
}
} else if (excelfilelist.size() > 1) {
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException("压缩包内有多个Excel数据源");
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("压缩包内有多个Excel数据源");
}else{
throw new JeroBootException("There are multiple Excel data sources in the zip package");
}
}
File excelfile = excelfilelist.get(0);
@@ -3795,7 +3828,12 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if (dataList.size() == 0) {
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException("请填写必填字段内容,带*的为必填");
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("请填写必填字段内容,带*的为必填");
}else{
throw new JeroBootException("Please fill in the required fields marked with *");
}
}
// 校验头部是否符合模板
String fields = list.get(0);
@@ -3811,7 +3849,12 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
workbook.close();
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException("读取失败,请严格按照模板文件导入数据");
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("读取失败,请严格按照模板文件导入数据");
}else{
throw new JeroBootException("The data fails to be read. Import data strictly according to the template file");
}
}
}
}
@@ -3822,7 +3865,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
List<SysDictItem> dictItemList = sysDictItemServiceImpl.selectItemsAll();
//表头
List<Map<String, Object>> addForm = getField(ModuleEnum.DOCUMENT_LIBRARY.getValue(), "cn", "add");
exportDatas(dataList, addForm, categoryList, dictItemList, zipEntryName,saveDirectory);
exportDatas(dataList, addForm, categoryList, dictItemList, zipEntryName,saveDirectory,cut);
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
@@ -3833,7 +3876,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
List<SysCategory> categoryList,
List<SysDictItem> dictItemList,
String zipEntryName,
File saveDirectory) {
File saveDirectory,
String cut) {
//树形数据字典
List<String> treeNameList = categoryList.stream().map(SysCategory::getName).collect(Collectors.toList());
//普通数据字典
@@ -3845,7 +3889,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
Map<String, Object> mapResult = new HashMap<>();
i++;
int countError = 0; //记录失败数据数量
String errorMsg = "" + i + "行:";
String errorMsg = "";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg = "" + i + "行:";
}else{
errorMsg = i + " line";
}
//判断发布日期,新车型实施日期,在产车实施日期
// try {
@@ -3895,19 +3945,31 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//树形
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += key + "为必填项,不能为空";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "为必填项,不能为空";
}else{
errorMsg += key + " This parameter is mandatory and cannot be empty";
}
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += key + "不能超过" + dbLength + "个字符";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "不能超过" + dbLength + "个字符";
}else{
errorMsg += key + " Can not be more than " + dbLength + " char";
}
countError++;
}
//判断数据是否匹配
if (StringUtils.isNotBlank(value)) {
for (String valueTemp : value.split(",")) {
if (!treeNameList.contains(valueTemp)) {
errorMsg += key + "中的" + valueTemp + "与数据字典不匹配";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "中的" + valueTemp + "与数据字典不匹配";
}else{
errorMsg += key +" "+ valueTemp + " Does not match the data dictionary";
}
countError++;
}
}
@@ -3928,12 +3990,20 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//输入框
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += key + "为必填项,不能为空";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "为必填项,不能为空";
}else{
errorMsg += key + " This parameter is mandatory and cannot be empty";
}
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += key + "不能超过" + dbLength + "个字符";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "不能超过" + dbLength + "个字符";
}else{
errorMsg += key + " Can not be more than" + dbLength + "char";
}
countError++;
}
@@ -3945,23 +4015,40 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//下拉单选
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += key + "为必填项,不能为空";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "为必填项,不能为空";
}else{
errorMsg += key + " This parameter is mandatory and cannot be empty";
}
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += key + "不能超过" + dbLength + "个字符";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "不能超过" + dbLength + "个字符";
}else{
errorMsg += key + " Can not be more than" + dbLength + " char";
}
countError++;
}
//判断是否是单选
if (StringUtils.isNotBlank(value) && value.contains(",")) {
errorMsg += key + "为单选项";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "为单选项";
}else{
errorMsg += key + " Is multiple Choice";
}
countError++;
}
//判断数据是否匹配
if (StringUtils.isNotBlank(value)) {
if (!itemNameList.contains(value)) {
errorMsg += key + "中的" + value + "与数据字典不匹配";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "中的" + value + "与数据字典不匹配";
}else{
errorMsg += key + " " + value + " Does not match the data dictionary";
}
countError++;
}
}
@@ -3976,19 +4063,31 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} else if (FieldTypeEnum.PULL_MORE.getValue().equals(fieldShowType)) {
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += key + "为必填项,不能为空";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "为必填项,不能为空";
}else{
errorMsg += key + " This parameter is mandatory and cannot be empty";
}
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += key + "不能超过" + dbLength + "个字符";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "不能超过" + dbLength + "个字符";
}else{
errorMsg += key + " Can not be more than" + dbLength + " char";
}
countError++;
}
//下拉多选
if (StringUtils.isNotBlank(value)) {
for (String valueTemp : value.split(",")) {
if (!itemNameList.contains(valueTemp)) {
errorMsg += key + "中的" + valueTemp + "与数据字典不匹配";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "中的" + valueTemp + "与数据字典不匹配";
}else{
errorMsg += key +" "+ valueTemp + " Does not match the data dictionary";
}
countError++;
}
}
@@ -4013,17 +4112,29 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//单选日期
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += key + "为必填项,不能为空";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "为必填项,不能为空";
}else{
errorMsg += key + " This parameter is mandatory and cannot be empty";
}
countError++;
}
//a判断是否是单日期选择
if (StringUtils.isNotBlank(value) && value.contains(",")) {
errorMsg += key + "为单日期选项";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "为单日期选项";
}else{
errorMsg += key + " Is single date option";
}
countError++;
}
//判断格式是否正确
if (!DateUtils.isValidDate((String) value)) {
errorMsg += key + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
}else{
errorMsg += key + " Incorrect format correct format is:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
}
countError++;
}
@@ -4031,12 +4142,20 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//多选日期
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += key + "为必填项,不能为空";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "为必填项,不能为空";
}else{
errorMsg += key + " This parameter is mandatory and cannot be empty";
}
countError++;
}
//判断格式是否正确
if (!DateUtils.isValidDate((String) value)) {
errorMsg += key + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
}else{
errorMsg += key + " Incorrect format correct format is:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
}
countError++;
}
@@ -4045,12 +4164,20 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//文件
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += key + "为必填项,不能为空";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "为必填项,不能为空";
}else{
errorMsg += key + " This parameter is mandatory and cannot be empty";
}
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += key + "不能超过" + dbLength + "个字符";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "不能超过" + dbLength + "个字符";
}else{
errorMsg += key + " Can not be more than " + dbLength + " char";
}
countError++;
}
if (StringUtils.isNotBlank(value)) {
@@ -4058,7 +4185,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
for (String fileName : value.split(",")) {
List<File> nowFileList = FileUnZip.readFileByFilename(zipEntryName, fileName);
if (nowFileList.size() == 0) {
errorMsg += key + "压缩包中没有" + fileName + "文件; ";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "压缩包中没有" + fileName + "文件; ";
}else{
errorMsg += key + " Not in the zip package" + fileName + "file; ";
}
countError++;
} else {
try {
@@ -4085,12 +4216,20 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//标准选择
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += key + "为必填项,不能为空";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "为必填项,不能为空";
}else{
errorMsg += key + " This parameter is mandatory and cannot be empty";
}
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += key + "不能超过" + dbLength + "个字符";
if(CutEnum.CN.getValue().equals(cut)){
errorMsg += key + "不能超过" + dbLength + "个字符";
}else{
errorMsg += key + " Can not be more than " + dbLength + " char";
}
countError++;
}
//判断库中是否存在,如果存在则存id,如果不存在则存输入的值
@@ -4269,7 +4408,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
*
* @param fieldFileList 文件排序字段
* @param oSSFileAll 所有文件
* @param maps key-->字段 value-->关联文件connect_id
* @param -->字段 value-->关联文件connect_id
*/
public List<OSSFile> fileSort(List<OnlCgformField> fieldFileList,List<OSSFile> oSSFileAll,Map<String,Object> map){
List<OSSFile> result = new LinkedList<>();
@@ -40,6 +40,9 @@ public class DummyInventoryBaseEO implements Serializable {
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
@TableField(exist = false)
private java.lang.String createByCn;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@@ -134,7 +134,7 @@ public class DummyInventoryBaseEOServiceImpl extends ServiceImpl<DummyInventoryB
String createBy = record.getCreateBy();
List<SysUser> sysUserList = userList.stream().filter(e -> createBy.equals(e.getUsername())).collect(Collectors.toList());
if (sysUserList.size() == 1) {
record.setCreateBy(sysUserList.get(0).getRealname());
record.setCreateByCn(sysUserList.get(0).getRealname());
}
//订阅标识
if(dummyReadIdList.contains(record.getId())){