文档库--bud修改

This commit is contained in:
zhn
2022-03-10 20:44:29 +08:00
parent ca0e81a9c0
commit 35dc96c080
8 changed files with 407 additions and 267 deletions
@@ -7,8 +7,8 @@ package com.jero.common.constant.enums;
* @auth zhn
*/
public enum IsMustEnum {
YES("","0"),
NO("","1");
YES("","1"),
NO("","0");
String name;
+11
View File
@@ -131,6 +131,17 @@
<artifactId>easypoi-annotation</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>com.github.junrar</groupId>
<artifactId>junrar</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>net.sf.sevenzipjbinding</groupId>
<artifactId>sevenzipjbinding</artifactId>
<version>16.02-2.01</version>
</dependency>
</dependencies>
</project>
@@ -35,154 +35,4 @@ public class BussDocumentLibraryEO implements Serializable {
@ApiModelProperty(value = "主键")
private java.lang.String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private java.lang.String sysOrgCode;
/**适用地区*/
@Excel(name = "适用地区", width = 15)
@ApiModelProperty(value = "适用地区")
private java.lang.String region;
/**类别*/
@Excel(name = "类别", width = 15)
@ApiModelProperty(value = "类别")
private java.lang.String type;
/**标准体系*/
@Excel(name = "标准体系", width = 15)
@ApiModelProperty(value = "标准体系")
private java.lang.String standardSystem;
/**状态*/
@Excel(name = "状态", width = 15)
@ApiModelProperty(value = "状态")
private java.lang.String state;
/**适用车型*/
@Excel(name = "适用车型", width = 15)
@ApiModelProperty(value = "适用车型")
private java.lang.String carType;
/**能源种类*/
@Excel(name = "能源种类", width = 15)
@ApiModelProperty(value = "能源种类")
private java.lang.String energyType;
/**适用范围*/
@Excel(name = "适用范围", width = 15)
@ApiModelProperty(value = "适用范围")
private java.lang.String applyScope;
/**功能领域*/
@Excel(name = "功能领域", width = 15)
@ApiModelProperty(value = "功能领域")
@Dict(dicCode = "functional_domain")
private java.lang.String functionTerritory;
/**技术领域*/
@Excel(name = "技术领域", width = 15)
@Dict(dicCode = "technology_territory")
@ApiModelProperty(value = "技术领域")
private java.lang.String technologyTerritory;
/**编号*/
@Excel(name = "编号", width = 15)
@ApiModelProperty(value = "编号")
private java.lang.String serialNumber;
/**标题*/
@Excel(name = "标题", width = 15)
@ApiModelProperty(value = "标题")
private java.lang.String title;
/**发布日期*/
@Excel(name = "发布日期", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "发布日期")
private java.util.Date issueTime;
/**标准实施日期*/
@Excel(name = "标准实施日期", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "标准实施日期")
private java.util.Date implementTime;
/**代替标准*/
@Excel(name = "代替标准", width = 15)
@ApiModelProperty(value = "代替标准")
private java.lang.String replaceStandard;
/**被代替标准*/
@Excel(name = "被代替标准", width = 15)
@ApiModelProperty(value = "被代替标准")
private java.lang.String replacedStandard;
/**描述*/
@Excel(name = "描述", width = 15)
@ApiModelProperty(value = "描述")
private java.lang.String description;
/**对应标准*/
@Excel(name = "对应标准", width = 15)
@ApiModelProperty(value = "对应标准")
private java.lang.String correspondingStandard;
/**测试程序*/
@Excel(name = "测试程序", width = 15)
@ApiModelProperty(value = "测试程序")
private java.lang.String testProgram;
/**发布稿(必读)*/
@Excel(name = "发布稿(必读)", width = 15)
@ApiModelProperty(value = "发布稿(必读)")
private java.lang.String releaseDraft;
/**增补件(必读)*/
@Excel(name = "增补件(必读)", width = 15)
@ApiModelProperty(value = "增补件(必读)")
private java.lang.String supplement;
/**报批稿*/
@Excel(name = "报批稿", width = 15)
@ApiModelProperty(value = "报批稿")
private java.lang.String approvalDraft;
/**征求意见稿*/
@Excel(name = "征求意见稿", width = 15)
@ApiModelProperty(value = "征求意见稿")
private java.lang.String exposureDraft;
/**相关资料*/
@Excel(name = "相关资料", width = 15)
@ApiModelProperty(value = "相关资料")
private java.lang.String datum;
/**预警标识*/
@Excel(name = "预警标识", width = 15)
@ApiModelProperty(value = "预警标识")
private java.lang.String warnFlag;
}
@@ -81,4 +81,7 @@ public interface BussDocumentLibraryEOMapper extends BaseMapper<BussDocumentLibr
List<Map<String,Object>> getListBySerialNumber(@Param("serialNumbers") String serialNumbers);
List<Map<String,Object>> selectMapsAll(@Param("ids") String ids);
}
@@ -82,4 +82,16 @@
</if>
</select>
<!--分页-->
<select id="selectMapsAll" resultType="java.util.LinkedHashMap">
select * from buss_document_library
where 1=1
<if test="ids != null" >
and id in
<foreach collection="ids.split(',')" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
@@ -164,27 +164,72 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
*/
@Override
public void deleteByIds(List<String> ids) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//字段属性
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue());
//文件类型字段
List<OnlCgformField> fieldFileList = fieldList.stream().filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
//删除文件
LambdaQueryWrapper<BussDocumentLibraryEO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(BussDocumentLibraryEO::getId, ids);
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMaps(lambdaQueryWrapper);
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMapsAll(StringUtils.join(ids,","));
List<String> connectIdList = new ArrayList<>();
for (OnlCgformField onlCgformField : fieldFileList) {
String connectId = (String) mapList.get(0).get(onlCgformField.getDbFieldName());
if (StringUtils.isNotBlank(connectId)) {
connectIdList.add(connectId);
for (Map<String, Object> map : mapList) {
String connectId = (String) map.get(onlCgformField.getDbFieldName());
if (StringUtils.isNotBlank(connectId)) {
connectIdList.add(connectId);
}
}
}
//删除文件
iOSSFileService.deleteByConnectIdList(connectIdList);
//删除文档库数据
removeByIds(ids);
//订阅用户发送消息
//订阅的文档
LambdaQueryWrapper<OnlCgformSubscribe> wrapper = new LambdaQueryWrapper<>();
wrapper.in(OnlCgformSubscribe::getDocumentId, ids);
List<OnlCgformSubscribe> onlCgformSubscribeList = iOnlCgformSubscribeService.list(wrapper);
//订阅的文档id
List<String> documentIds = onlCgformSubscribeList.stream().map(OnlCgformSubscribe::getDocumentId).collect(Collectors.toList());
List<String> serialNumberList = new ArrayList<>();
StringBuilder sb = new StringBuilder();
for (Map<String, Object> map : mapList) {
if(documentIds.size() != 0 && documentIds.contains((String) map.get("id"))){
String id = (String) map.get("id");
String serialNumber = (String) map.get("serial_number");
String title = (String) map.get("title");
serialNumberList.add(serialNumber);
String href = "<a href='/docManage/library?id:" + id +
"&title:" + title +
"&serial_number:" + serialNumber + "'" + " target='_blank'>" + serialNumber + "</a>,";
sb.append(href);
}
}
String sbStr = "";
if (ObjectUtils.isNotEmpty(sb)) {
sbStr = sb.substring(0, sb.length() - 1);
}
List<String> userNameList = new ArrayList<>();
if (onlCgformSubscribeList.size() != 0) {
for (OnlCgformSubscribe onlCgformSubscribe : onlCgformSubscribeList) {
userNameList.add(onlCgformSubscribe.getCreateBy());
}
List<SysUser> userList = sysUserMapper.getUserListByNames(StringUtils.join(userNameList, ","));
List<String> userIdList = userList.stream().map(SysUser::getId).collect(Collectors.toList());
String content = sysUser.getRealname() + "删除了" + StringUtils.join(serialNumberList,",") + "请知晓";
String contentInfo = sysUser.getRealname() + "删除了" + sbStr + "请知晓";
//封装消息的实体类
SysAnnouncement sysAnnouncement = getSysAnnouncement(userIdList, content, contentInfo);
sysAnnouncementService.saveAnnouncement(sysAnnouncement);
sendWebsocket(StringUtils.join(serialNumberList,","), StringUtils.join(serialNumberList,","));
}
}
/**
@@ -296,8 +341,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//字段属性
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(flag);
//过滤出字段为树形结构的
//TODO 未使用的删掉就完了
List<OnlCgformField> onlCgformFieldTree = fieldList.stream().filter(e -> FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
if (fieldList.size() != 0) {
//过滤出表单字段(is_show_form-->表单是否显示0否 1是)
@@ -351,9 +394,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BussDocumentLibraryEO::getId, id);
//通过id查询数据
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMaps(queryWrapper);
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMapsAll(id);;
//查询所有
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMaps(null);
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMapsAll(null);
//对应标准id
String correspondingStandard = (String) dataList.get(0).get("corresponding_standard");
//代替标准id
@@ -433,11 +476,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
@Override
public List<Map<String, Object>> getInfoById(String id, String cut) {
//通过id查询数据
LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BussDocumentLibraryEO::getId, id);
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMaps(queryWrapper);
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMapsAll(id);
//查询所有
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMaps(null);
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMapsAll(null);
//原始对应标准,代替标准,被代替标准(原始数据存的是iD)
String correspondingStandardId = (String) dataList.get(0).get("corresponding_standard");//对应标准
@@ -681,8 +722,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//字段属性
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue());
//时间类型字段
//TODO 未被使用删除即可
List<OnlCgformField> fieldDateList = fieldList.stream().filter(e -> FieldTypeEnum.DATE_SINGLE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
//文件类型字段
List<OnlCgformField> fieldFileList = fieldList.stream().filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
//下拉单选或下拉多选
@@ -792,9 +831,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
String id = (String) map.get("id");
//通过id查询数据
LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BussDocumentLibraryEO::getId, id);
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMaps(queryWrapper);
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMapsAll(id);
Map<String, Object> mapTemp = new HashMap<>();
mapCopy(map, mapTemp);
@@ -817,8 +854,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
StringBuilder fieldsBuilder = new StringBuilder();
//数据值
StringBuilder valuesBuilder = new StringBuilder();
//TODO 未被使用删除即可
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
@@ -891,9 +926,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//编辑数据采用先删除在新增的方法
//删除文件
LambdaQueryWrapper<BussDocumentLibraryEO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BussDocumentLibraryEO::getId, (String) map.get("id"));
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMaps(lambdaQueryWrapper);
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMapsAll((String) map.get("id"));
List<String> connectIdList = new ArrayList<>();
for (OnlCgformField onlCgformField : fieldFileList) {
@@ -944,8 +977,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//文件类型的字段
List<String> fieldFile = fieldFileList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
//下拉类型的字段
//TODO 未被使用删除即可
List<String> fieldPull = fieldPullList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
//过滤出树形字段
List<OnlCgformField> treeFieldList = fieldList.stream()
.filter(e -> FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType()))
@@ -979,89 +1010,92 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
Object value = entry.getValue();
//字段中文名
List<OnlCgformField> fields = fieldList.stream().filter(e -> e.getDbFieldName().equals(key)).collect(Collectors.toList());
String dbFieldTxt = fields.get(0).getDbFieldTxt();
if (value == null) {
value = "";
}
for (Map.Entry<String, Object> entryTemp : mapTemp.entrySet()) {
String keyTemp = entryTemp.getKey();
Object valueTemp = entryTemp.getValue();
if (valueTemp == null) {
valueTemp = "";
if(fields.size() != 0){
String dbFieldTxt = fields.get(0).getDbFieldTxt();
if (value == null) {
value = "";
}
if (!"create_time".equals(key) && !"update_time".equals(key)) {
if (key.equals(keyTemp)) {
if (fieldDate.contains(key)) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if (ObjectUtils.isNotEmpty(value)) {
value = sdf.format(value);
}
if (ObjectUtils.isNotEmpty(valueTemp)) {
try {
valueTemp = sdf.format(sdf.parse((String) valueTemp));
} catch (ParseException e) {
}
}
//处理时间类型字段
if (ObjectUtils.isNotEmpty(value)) {
if (ObjectUtils.isNotEmpty(valueTemp) && !value.equals(valueTemp)) {
sb.append(dbFieldTxt + "" + value + "改为" + valueTemp + ",");
} else if (ObjectUtils.isEmpty(valueTemp)) {
sb.append(dbFieldTxt + "" + value + "改为空" + ",");
}
} else {
if (ObjectUtils.isNotEmpty(valueTemp)) {
sb.append(dbFieldTxt + "由空改为" + valueTemp + ",");
}
}
} else if (fieldFile.contains(key)) {
//处理文件类型字段
List<String> fileNameList = new ArrayList<>();
List<String> fileNameListTemp = new ArrayList<>();
//之前的文件
if (ObjectUtils.isNotEmpty(value)) {
List<OSSFile> fileInfos = iOSSFileService.getFileInfosByConnectId((String) value);
fileNameList = fileInfos.stream().map(OSSFile::getFileName).collect(Collectors.toList());
}
//修改的文件
if (ObjectUtils.isNotEmpty(valueTemp)) {
List<OSSFile> fileInfosTemp = iOSSFileService.getFileInfos((String) valueTemp);
fileNameListTemp = fileInfosTemp.stream().map(OSSFile::getFileName).collect(Collectors.toList());
}
if (ObjectUtils.isNotEmpty(value)) {
boolean checkDiffrent = checkDiffrent(fileNameList, fileNameListTemp);
if (fileNameListTemp.size() != 0 && !checkDiffrent) {
sb.append(dbFieldTxt + "" + StringUtils.join(fileNameList, ",") + "改为" + StringUtils.join(fileNameListTemp, ",") + ",");
} else if (fileNameListTemp.size() == 0) {
sb.append(dbFieldTxt + "" + StringUtils.join(fileNameList, ",") + "改为空" + ",");
}
} else {
if (fileNameListTemp.size() != 0) {
sb.append(dbFieldTxt + "由空改为" + StringUtils.join(fileNameListTemp, ",") + ",");
}
}
} else {
if ("replace_standard".equals(key)) {
for (Map.Entry<String, Object> entryTemp : mapTemp.entrySet()) {
String keyTemp = entryTemp.getKey();
Object valueTemp = entryTemp.getValue();
if (valueTemp == null) {
valueTemp = "";
}
if (!"create_time".equals(key) && !"update_time".equals(key)) {
if (key.equals(keyTemp)) {
if (fieldDate.contains(key)) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if (ObjectUtils.isNotEmpty(value)) {
value = getReplaceStandardName(value);
value = sdf.format(value);
}
if (ObjectUtils.isNotEmpty(valueTemp)) {
valueTemp = getReplaceStandardName(valueTemp);
try {
valueTemp = sdf.format(sdf.parse((String) valueTemp));
} catch (ParseException e) {
}
}
}
//其他类型
if (ObjectUtils.isNotEmpty(value)) {
if (ObjectUtils.isNotEmpty(valueTemp) && !value.equals(valueTemp)) {
sb.append(dbFieldTxt + "" + value + "改为" + valueTemp + ",");
} else if (ObjectUtils.isEmpty(valueTemp)) {
sb.append(dbFieldTxt + "" + value + "改为空" + ",");
//处理时间类型字段
if (ObjectUtils.isNotEmpty(value)) {
if (ObjectUtils.isNotEmpty(valueTemp) && !value.equals(valueTemp)) {
sb.append(dbFieldTxt + "" + value + "改为" + valueTemp + ",");
} else if (ObjectUtils.isEmpty(valueTemp)) {
sb.append(dbFieldTxt + "" + value + "改为空" + ",");
}
} else {
if (ObjectUtils.isNotEmpty(valueTemp)) {
sb.append(dbFieldTxt + "由空改为" + valueTemp + ",");
}
}
} else if (fieldFile.contains(key)) {
//处理文件类型字段
List<String> fileNameList = new ArrayList<>();
List<String> fileNameListTemp = new ArrayList<>();
//之前的文件
if (ObjectUtils.isNotEmpty(value)) {
List<OSSFile> fileInfos = iOSSFileService.getFileInfosByConnectId((String) value);
fileNameList = fileInfos.stream().map(OSSFile::getFileName).collect(Collectors.toList());
}
//修改的文件
if (ObjectUtils.isNotEmpty(valueTemp)) {
List<OSSFile> fileInfosTemp = iOSSFileService.getFileInfos((String) valueTemp);
fileNameListTemp = fileInfosTemp.stream().map(OSSFile::getFileName).collect(Collectors.toList());
}
if (ObjectUtils.isNotEmpty(value)) {
boolean checkDiffrent = checkDiffrent(fileNameList, fileNameListTemp);
if (fileNameListTemp.size() != 0 && !checkDiffrent) {
sb.append(dbFieldTxt + "" + StringUtils.join(fileNameList, ",") + "改为" + StringUtils.join(fileNameListTemp, ",") + ",");
} else if (fileNameListTemp.size() == 0) {
sb.append(dbFieldTxt + "" + StringUtils.join(fileNameList, ",") + "改为空" + ",");
}
} else {
if (fileNameListTemp.size() != 0) {
sb.append(dbFieldTxt + "由空改为" + StringUtils.join(fileNameListTemp, ",") + ",");
}
}
} else {
if (ObjectUtils.isNotEmpty(valueTemp)) {
sb.append(dbFieldTxt + "由空改为" + valueTemp + ",");
if ("replace_standard".equals(key)) {
if (ObjectUtils.isNotEmpty(value)) {
value = getReplaceStandardName(value);
}
if (ObjectUtils.isNotEmpty(valueTemp)) {
valueTemp = getReplaceStandardName(valueTemp);
}
}
//其他类型
if (ObjectUtils.isNotEmpty(value)) {
if (ObjectUtils.isNotEmpty(valueTemp) && !value.equals(valueTemp)) {
sb.append(dbFieldTxt + "" + value + "改为" + valueTemp + ",");
} else if (ObjectUtils.isEmpty(valueTemp)) {
sb.append(dbFieldTxt + "" + value + "改为空" + ",");
}
} else {
if (ObjectUtils.isNotEmpty(valueTemp)) {
sb.append(dbFieldTxt + "由空改为" + valueTemp + ",");
}
}
}
}
@@ -1791,7 +1825,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
List<OSSFile> fileInfosList = iOSSFileService.getFileInfosByConnectId(StringUtils.join(valueList, ","));
for (OSSFile ossFile : fileInfosList) {
String url = ossFile.getUrl();
copyFile(url, fileNowPath + "/" + ossFile.getFileName());
copyFile(url, fileNowPath + File.separator + ossFile.getFileName());
}
}
}
@@ -2013,7 +2047,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
OutputStream os = null;
HSSFWorkbook workbook = new HSSFWorkbook();
String fileOriName = "导入模板";
String filePath = uploadpath + "/" + fileOriName;
String filePath = uploadpath + File.separator + fileOriName;
try {
List<String> list = getWorkbookTitle((String) map.get("cut"));
//创建临时文件夹
@@ -2086,7 +2120,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
List<String> dateMoreList = new LinkedList<>();//多选日期字段
List<String> standardList = new LinkedList<>();//标准选择字段
for (Map<String, Object> map : addForm) {
if ("0".equals(map.get("field_must_input"))) {
if ("1".equals(map.get("field_must_input"))) {
sb.append("*" + map.get("db_field_txt") + ",");
} else {
sb.append(map.get("db_field_txt") + ",");
@@ -2362,14 +2396,21 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if (!str.equals("zip") && !str.equals("rar")) {
throw new JeroBootException("请上传zip格式的文件或rar格式的文件") ;
}
String path = uploadpath + "/modal/" + filenameorg;
String path = uploadpath + File.separator+"modal"+File.separator + filenameorg;
File saveDirectory = new File(path);
if (!saveDirectory.isDirectory()) {
saveDirectory.mkdir();
}
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path + "/" + file.getOriginalFilename()));
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path + File.separator + file.getOriginalFilename()));
//解压缩
String zipEntryName = FileUnZip.unZipFiles(path + "/" + file.getOriginalFilename(), path);
String zipEntryName = "";
if(str.equals("zip")){
zipEntryName = FileUnZip.unZipFiles(path + File.separator + file.getOriginalFilename(), path);
}else{
// zipEntryName = FileRarUtils.rarUnCompress(path + File.separator + file.getOriginalFilename(), path);
}
//判断压缩包下是否只有一个文件夹
File fileTemp = new File(path);
int length = fileTemp.listFiles().length;
@@ -2618,10 +2659,12 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
countError++;
}
//下拉多选
for (String valueTemp : value.split(",")) {
if (!itemNameList.contains(valueTemp)) {
errorMsg += key + "中的" + valueTemp + "与数据字典不匹配";
countError++;
if(StringUtils.isNotBlank(value)){
for (String valueTemp : value.split(",")) {
if (!itemNameList.contains(valueTemp)) {
errorMsg += key + "中的" + valueTemp + "与数据字典不匹配";
countError++;
}
}
}
@@ -2733,9 +2776,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
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(StringUtils.isNotBlank(value)){
for (String s : value.split(",")) {
if (!list.contains(s)) {
sb.append(s);
}
}
}
if (ObjectUtils.isNotEmpty(sb)) {
@@ -0,0 +1,77 @@
package com.jero.modules.split.util;
import net.sf.sevenzipjbinding.ExtractAskMode;
import net.sf.sevenzipjbinding.ExtractOperationResult;
import net.sf.sevenzipjbinding.IArchiveExtractCallback;
import net.sf.sevenzipjbinding.IInArchive;
import net.sf.sevenzipjbinding.ISequentialOutStream;
import net.sf.sevenzipjbinding.PropID;
import net.sf.sevenzipjbinding.SevenZipException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
*/
public class ExtractCallback implements IArchiveExtractCallback {
private int index;
private IInArchive inArchive;
private String ourDir;
public ExtractCallback(IInArchive inArchive, String ourDir) {
this.inArchive = inArchive;
this.ourDir = ourDir;
}
@Override
public void setCompleted(long arg0) {
}
@Override
public void setTotal(long arg0) {
}
@Override
public ISequentialOutStream getStream(int index, ExtractAskMode extractAskMode) throws SevenZipException {
this.index = index;
final String path = (String) inArchive.getProperty(index, PropID.PATH);
final boolean isFolder = (boolean) inArchive.getProperty(index, PropID.IS_FOLDER);
return data -> {
if (!isFolder) {
File file = new File(ourDir + path);
save2File(file, data);
}
return data.length;
};
}
@Override
public void prepareOperation(ExtractAskMode arg0) {
}
@Override
public void setOperationResult(ExtractOperationResult extractOperationResult) {
}
public static boolean save2File(File file, byte[] msg) {
File parent = file.getParentFile();
if ((!parent.exists()) && (!parent.mkdirs())) {
return false;
}
try (OutputStream fos = new FileOutputStream(file, true);) {
fos.write(msg);
fos.flush();
return true;
} catch (FileNotFoundException e) {
return false;
} catch (IOException e) {
return false;
}
}
}
@@ -0,0 +1,142 @@
package com.jero.modules.split.util;
import com.jero.common.exception.JeroBootException;
import net.sf.sevenzipjbinding.IInArchive;
import net.sf.sevenzipjbinding.SevenZip;
import net.sf.sevenzipjbinding.SevenZipException;
import net.sf.sevenzipjbinding.impl.RandomAccessFileInStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
/**
* @Description:文件压缩与解压工具类
* @Auther: wcj
* @Date: 2021/7/31 11:40
*/
public class FileRarUtils {
public static void main(String[] args) {
String rarDir = "E:\\DeskTop\\文档库1111111.rar";
String outDir = "E:\\DeskTop\\rar";
try (InputStream in = new FileInputStream(rarDir)){
List<String> list = fileUnRar(in, outDir, System.currentTimeMillis());
System.out.println(list);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// ExpertUtils.fileUnRar(inputStream, upLoadPath, nowTime);
}
/**
* 解压压缩包(rar)
* @param inputStream
* @param upLoadPath
* @param nowTime
* @return
*/
public static List<String> fileUnRar(InputStream inputStream, String upLoadPath, long nowTime) {
String savePath = upLoadPath + File.separator + nowTime + File.separator + nowTime + ".rar";
String ftpUpPath = upLoadPath + File.separator + nowTime + File.separator + "zipUnCompress";
try {
File saveFile = new File(savePath);
if (!saveFile.exists()) {
saveFile.getParentFile().mkdirs();
saveFile.createNewFile();
//首次写入获取
}
try (FileOutputStream fos = new FileOutputStream(saveFile);) {
int len;
byte[] buffer = new byte[2048];
while ((len = inputStream.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
} catch (Exception e) {
throw new JeroBootException(e);
}
//压缩包解压
FileRarUtils.rarUnCompress(savePath,ftpUpPath);
List<String> files = new ArrayList<>();
//获取解压后的所有文件
File foundFile = new File(ftpUpPath);
fundFile(foundFile, files);
return files;
} catch (Exception e) {
throw new JeroBootException(e);
}
}
/**
* 文件递归查找
*
* @param file
* @param result
* @return
*/
public static void fundFile(File file, List<String> result) {
if (result == null) {
return;
}
File[] fs = file.listFiles();
for (File f : fs) {
//若是目录,则递归打印该目录下的文件
if (f.isDirectory()) {
fundFile(f, result);
} else {
String path = f.getPath();
//若是文件,直接返回
result.add(path);
}
}
}
/**
* 解压rar文件
*
* @param rarDir 需要解压的文件
* @param outDir 解压后的路径
*/
public static void rarUnCompress(String rarDir, String outDir) {
// 第一个参数是需要解压的压缩包路径,第二个参数参考JdkAPI文档的RandomAccessFile
//r代表以只读的方式打开文本,也就意味着不能用write来操作文件
try (
RandomAccessFile randomAccessFile = new RandomAccessFile(rarDir, "r");
IInArchive archive = SevenZip.openInArchive(null, // null - autodetect
new RandomAccessFileInStream(randomAccessFile));) {
int[] in = new int[archive.getNumberOfItems()];
for (int i = 0; i < in.length; i++) {
in[i] = i;
}
File file = new File(outDir);
if (!file.exists()) {
//如果不存在,创建
file.mkdirs();
}
archive.extract(in, false, new ExtractCallback(archive, outDir + "/"));
} catch (FileNotFoundException e) {
throw new JeroBootException("文件没找到",e);
} catch (SevenZipException e) {
throw new JeroBootException("SevenZip文件异常",e);
} catch (IOException e) {
throw new JeroBootException("文件解析异常",e);
}catch (Exception e){
throw new JeroBootException(e);
}
}
}