文档库--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 * @auth zhn
*/ */
public enum IsMustEnum { public enum IsMustEnum {
YES("是","0"), YES("是","1"),
NO("否","1"); NO("否","0");
String name; String name;
+11
View File
@@ -131,6 +131,17 @@
<artifactId>easypoi-annotation</artifactId> <artifactId>easypoi-annotation</artifactId>
<version>3.2.0</version> <version>3.2.0</version>
</dependency> </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> </dependencies>
</project> </project>
@@ -35,154 +35,4 @@ public class BussDocumentLibraryEO implements Serializable {
@ApiModelProperty(value = "主键") @ApiModelProperty(value = "主键")
private java.lang.String id; 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>> getListBySerialNumber(@Param("serialNumbers") String serialNumbers);
List<Map<String,Object>> selectMapsAll(@Param("ids") String ids);
} }
@@ -82,4 +82,16 @@
</if> </if>
</select> </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> </mapper>
@@ -164,27 +164,72 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
*/ */
@Override @Override
public void deleteByIds(List<String> ids) { public void deleteByIds(List<String> ids) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//字段属性 //字段属性
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue()); 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()); List<OnlCgformField> fieldFileList = fieldList.stream().filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
//删除文件 //删除文件
LambdaQueryWrapper<BussDocumentLibraryEO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMapsAll(StringUtils.join(ids,","));
lambdaQueryWrapper.in(BussDocumentLibraryEO::getId, ids);
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMaps(lambdaQueryWrapper);
List<String> connectIdList = new ArrayList<>(); List<String> connectIdList = new ArrayList<>();
for (OnlCgformField onlCgformField : fieldFileList) { for (OnlCgformField onlCgformField : fieldFileList) {
String connectId = (String) mapList.get(0).get(onlCgformField.getDbFieldName()); for (Map<String, Object> map : mapList) {
String connectId = (String) map.get(onlCgformField.getDbFieldName());
if (StringUtils.isNotBlank(connectId)) { if (StringUtils.isNotBlank(connectId)) {
connectIdList.add(connectId); connectIdList.add(connectId);
} }
} }
}
//删除文件 //删除文件
iOSSFileService.deleteByConnectIdList(connectIdList); iOSSFileService.deleteByConnectIdList(connectIdList);
//删除文档库数据 //删除文档库数据
removeByIds(ids); 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); 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) { if (fieldList.size() != 0) {
//过滤出表单字段(is_show_form-->表单是否显示0否 1是) //过滤出表单字段(is_show_form-->表单是否显示0否 1是)
@@ -351,9 +394,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BussDocumentLibraryEO::getId, id); queryWrapper.eq(BussDocumentLibraryEO::getId, id);
//通过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 //对应标准id
String correspondingStandard = (String) dataList.get(0).get("corresponding_standard"); String correspondingStandard = (String) dataList.get(0).get("corresponding_standard");
//代替标准id //代替标准id
@@ -433,11 +476,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
@Override @Override
public List<Map<String, Object>> getInfoById(String id, String cut) { public List<Map<String, Object>> getInfoById(String id, String cut) {
//通过id查询数据 //通过id查询数据
LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>(); List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMapsAll(id);
queryWrapper.eq(BussDocumentLibraryEO::getId, id);
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMaps(queryWrapper);
//查询所有 //查询所有
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMaps(null); List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMapsAll(null);
//原始对应标准,代替标准,被代替标准(原始数据存的是iD) //原始对应标准,代替标准,被代替标准(原始数据存的是iD)
String correspondingStandardId = (String) dataList.get(0).get("corresponding_standard");//对应标准 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()); 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()); 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"); String id = (String) map.get("id");
//通过id查询数据 //通过id查询数据
LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>(); List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMapsAll(id);
queryWrapper.eq(BussDocumentLibraryEO::getId, id);
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMaps(queryWrapper);
Map<String, Object> mapTemp = new HashMap<>(); Map<String, Object> mapTemp = new HashMap<>();
mapCopy(map, mapTemp); mapCopy(map, mapTemp);
@@ -817,8 +854,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
StringBuilder fieldsBuilder = new StringBuilder(); StringBuilder fieldsBuilder = new StringBuilder();
//数据值 //数据值
StringBuilder valuesBuilder = 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()) { for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
Object value = entry.getValue(); Object value = entry.getValue();
@@ -891,9 +926,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//编辑数据采用先删除在新增的方法 //编辑数据采用先删除在新增的方法
//删除文件 //删除文件
LambdaQueryWrapper<BussDocumentLibraryEO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMapsAll((String) map.get("id"));
lambdaQueryWrapper.eq(BussDocumentLibraryEO::getId, (String) map.get("id"));
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMaps(lambdaQueryWrapper);
List<String> connectIdList = new ArrayList<>(); List<String> connectIdList = new ArrayList<>();
for (OnlCgformField onlCgformField : fieldFileList) { 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()); 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() List<OnlCgformField> treeFieldList = fieldList.stream()
.filter(e -> FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType())) .filter(e -> FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType()))
@@ -979,6 +1010,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
Object value = entry.getValue(); Object value = entry.getValue();
//字段中文名 //字段中文名
List<OnlCgformField> fields = fieldList.stream().filter(e -> e.getDbFieldName().equals(key)).collect(Collectors.toList()); List<OnlCgformField> fields = fieldList.stream().filter(e -> e.getDbFieldName().equals(key)).collect(Collectors.toList());
if(fields.size() != 0){
String dbFieldTxt = fields.get(0).getDbFieldTxt(); String dbFieldTxt = fields.get(0).getDbFieldTxt();
if (value == null) { if (value == null) {
value = ""; value = "";
@@ -1068,6 +1101,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} }
} }
} }
}
}); });
return sb; return sb;
} }
@@ -1791,7 +1825,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
List<OSSFile> fileInfosList = iOSSFileService.getFileInfosByConnectId(StringUtils.join(valueList, ",")); List<OSSFile> fileInfosList = iOSSFileService.getFileInfosByConnectId(StringUtils.join(valueList, ","));
for (OSSFile ossFile : fileInfosList) { for (OSSFile ossFile : fileInfosList) {
String url = ossFile.getUrl(); 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; OutputStream os = null;
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
String fileOriName = "导入模板"; String fileOriName = "导入模板";
String filePath = uploadpath + "/" + fileOriName; String filePath = uploadpath + File.separator + fileOriName;
try { try {
List<String> list = getWorkbookTitle((String) map.get("cut")); 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> dateMoreList = new LinkedList<>();//多选日期字段
List<String> standardList = new LinkedList<>();//标准选择字段 List<String> standardList = new LinkedList<>();//标准选择字段
for (Map<String, Object> map : addForm) { 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") + ","); sb.append("*" + map.get("db_field_txt") + ",");
} else { } else {
sb.append(map.get("db_field_txt") + ","); sb.append(map.get("db_field_txt") + ",");
@@ -2362,14 +2396,21 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if (!str.equals("zip") && !str.equals("rar")) { if (!str.equals("zip") && !str.equals("rar")) {
throw new JeroBootException("请上传zip格式的文件或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); File saveDirectory = new File(path);
if (!saveDirectory.isDirectory()) { if (!saveDirectory.isDirectory()) {
saveDirectory.mkdir(); 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); File fileTemp = new File(path);
int length = fileTemp.listFiles().length; int length = fileTemp.listFiles().length;
@@ -2618,12 +2659,14 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
countError++; countError++;
} }
//下拉多选 //下拉多选
if(StringUtils.isNotBlank(value)){
for (String valueTemp : value.split(",")) { for (String valueTemp : value.split(",")) {
if (!itemNameList.contains(valueTemp)) { if (!itemNameList.contains(valueTemp)) {
errorMsg += key + "中的" + valueTemp + "与数据字典不匹配"; errorMsg += key + "中的" + valueTemp + "与数据字典不匹配";
countError++; countError++;
} }
} }
}
String valueId = ""; String valueId = "";
//文字转数据字典id //文字转数据字典id
@@ -2733,11 +2776,13 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
sb.append((String) stringObjectMap.get("id") + ","); sb.append((String) stringObjectMap.get("id") + ",");
list.add((String) stringObjectMap.get("serial_number")); list.add((String) stringObjectMap.get("serial_number"));
} }
if(StringUtils.isNotBlank(value)){
for (String s : value.split(",")) { for (String s : value.split(",")) {
if (!list.contains(s)) { if (!list.contains(s)) {
sb.append(s); sb.append(s);
} }
} }
}
if (ObjectUtils.isNotEmpty(sb)) { if (ObjectUtils.isNotEmpty(sb)) {
String substring = sb.substring(0, sb.length() - 1); String substring = sb.substring(0, sb.length() - 1);
value = substring; value = substring;
@@ -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);
}
}
}