|
@@ -12,16 +12,21 @@ import org.springblade.business.mapper.MetadataClassificationMapper;
|
|
import org.springblade.business.service.IArchiveFileService;
|
|
import org.springblade.business.service.IArchiveFileService;
|
|
import org.springblade.business.service.IMetadataClassificationService;
|
|
import org.springblade.business.service.IMetadataClassificationService;
|
|
|
|
|
|
|
|
+import org.springblade.business.vo.MetadataClassificationVO;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.secure.BladeUser;
|
|
import org.springblade.core.secure.BladeUser;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.tool.constant.BladeConstant;
|
|
import org.springblade.core.tool.constant.BladeConstant;
|
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
|
+import org.springblade.core.tool.utils.DateUtil;
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
import org.springblade.manager.entity.ArchiveTreeContract;
|
|
import org.springblade.manager.entity.ArchiveTreeContract;
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
import org.springblade.manager.feign.ArchiveTreeContractClient;
|
|
import org.springblade.manager.feign.ArchiveTreeContractClient;
|
|
import org.springblade.manager.feign.ContractClient;
|
|
import org.springblade.manager.feign.ContractClient;
|
|
|
|
+import org.springblade.manager.vo.WbsTreeVO;
|
|
|
|
+import org.springframework.dao.DataAccessException;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -167,6 +172,49 @@ public class MetadataClassificationServiceImpl
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<MetadataClassificationVO> getMetadataFile(Long fileId) {
|
|
|
|
+ List<HashMap<String,Object>> metadataMapList = baseMapper.getMetadaFileByFileId(fileId);
|
|
|
|
+ if(metadataMapList != null && metadataMapList.size()>0) {
|
|
|
|
+ Map<String,Object> map = metadataMapList.get(0);
|
|
|
|
+ QueryWrapper<MetadataClassification> metadata = new QueryWrapper<>();
|
|
|
|
+ metadata.lambda().eq(MetadataClassification::getIsDeleted, 0);
|
|
|
|
+ List<MetadataClassification> metadataClassifications = baseMapper.selectList(metadata);
|
|
|
|
+ if(metadataClassifications != null && metadataClassifications.size()>0) {
|
|
|
|
+ List<MetadataClassificationVO> metadataClassificationVOS = Objects.requireNonNull(BeanUtil.copy(metadataClassifications, MetadataClassificationVO.class));
|
|
|
|
+ for (MetadataClassificationVO vo : metadataClassificationVOS) {
|
|
|
|
+ vo.setKeyValue(map.get(vo.getFieldKey()) == null?null:map.get(vo.getFieldKey()).toString());
|
|
|
|
+ vo.setFileId(fileId);
|
|
|
|
+ }
|
|
|
|
+ return metadataClassificationVOS;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean updateMetadata(List<MetadataClassificationVO> vos) {
|
|
|
|
+ try {
|
|
|
|
+ BladeUser user = AuthUtil.getUser();
|
|
|
|
+ StringBuilder sqlBuild = new StringBuilder();
|
|
|
|
+ sqlBuild.append("update u_metadata_file set ");
|
|
|
|
+ for(MetadataClassificationVO key : vos){
|
|
|
|
+ if(key.getFileId() != null){
|
|
|
|
+ sqlBuild.append(" "+key.getFieldKey() + " = '"+key.getKeyValue()+"' , ");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ sqlBuild.append(" update_user = '"+user.getUserId()+"' , ");
|
|
|
|
+ sqlBuild.append(" update_time = '"+DateUtil.formatDateTime(new Date())+"' ");
|
|
|
|
+ sqlBuild.append(" where file_id = "+vos.get(0).getFileId());
|
|
|
|
+ jdbcTemplate.execute(sqlBuild.toString());
|
|
|
|
+ } catch (DataAccessException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**文件收集上传**/
|
|
/**文件收集上传**/
|
|
private void archiveFileMetadata(Long fileId,List<MetadataClassification> metadataClassifications,BladeUser user,boolean isAdd,Map<String,Object> metadataMap){
|
|
private void archiveFileMetadata(Long fileId,List<MetadataClassification> metadataClassifications,BladeUser user,boolean isAdd,Map<String,Object> metadataMap){
|
|
ArchiveFile byId = iArchiveFileService.getById(fileId);
|
|
ArchiveFile byId = iArchiveFileService.getById(fileId);
|
|
@@ -231,11 +279,11 @@ public class MetadataClassificationServiceImpl
|
|
/**文号**/
|
|
/**文号**/
|
|
keyValue.put("文号", byId.getFileNumber());
|
|
keyValue.put("文号", byId.getFileNumber());
|
|
/**格式名称**/
|
|
/**格式名称**/
|
|
- keyValue.put("格式名称", byId.getFileUrl().substring(byId.getFileUrl().lastIndexOf(".")));
|
|
|
|
|
|
+ keyValue.put("格式名称", byId.getFileUrl().substring(byId.getFileUrl().lastIndexOf(".")+1));
|
|
/**存储位置**/
|
|
/**存储位置**/
|
|
keyValue.put("存储位置", byId.getFileUrl());
|
|
keyValue.put("存储位置", byId.getFileUrl());
|
|
/**计算机文件名**/
|
|
/**计算机文件名**/
|
|
- String substring = byId.getFileUrl().substring(byId.getFileUrl().lastIndexOf("/"), byId.getFileUrl().lastIndexOf("."));
|
|
|
|
|
|
+ String substring = byId.getFileUrl().substring(byId.getFileUrl().lastIndexOf("/")+1, byId.getFileUrl().lastIndexOf("."));
|
|
keyValue.put("计算机文件名", substring);
|
|
keyValue.put("计算机文件名", substring);
|
|
/**计算机文件大小**/
|
|
/**计算机文件大小**/
|
|
keyValue.put("计算机文件大小", byId.getFileSize());
|
|
keyValue.put("计算机文件大小", byId.getFileSize());
|
|
@@ -261,16 +309,16 @@ public class MetadataClassificationServiceImpl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sqlBuild.append("(id,tenant_id, create_user, create_time, update_user, update_time, status, is_deleted,contract_id, file_id " + fieldBuild.toString() + " ) ");
|
|
sqlBuild.append("(id,tenant_id, create_user, create_time, update_user, update_time, status, is_deleted,contract_id, file_id " + fieldBuild.toString() + " ) ");
|
|
- sqlBuild.append("values('" + SnowFlakeUtil.getId() + "','" + user.getTenantId() + "','" + user.getUserId() + "', '" + new Date() + "', '" + user.getUserId() + "', '" + new Date() + "', '0', '0','" + byId.getContractId() + "', '" + fileId + "'," + valueBuild.toString() + ")");
|
|
|
|
|
|
+ sqlBuild.append("values('" + SnowFlakeUtil.getId() + "','" + user.getTenantId() + "','" + user.getUserId() + "', '" + DateUtil.formatDateTime(new Date()) + "', '" + user.getUserId() + "', '" + DateUtil.formatDateTime(new Date()) + "', '0', '0','" + byId.getContractId() + "', '" + fileId + "' " + valueBuild.toString() + ")");
|
|
}else{
|
|
}else{
|
|
sqlBuild.append("update u_metadata_file set ");
|
|
sqlBuild.append("update u_metadata_file set ");
|
|
for(MetadataClassification key : metadataClassifications){
|
|
for(MetadataClassification key : metadataClassifications){
|
|
if(keyValue.get(key.getContainerName()) != null){
|
|
if(keyValue.get(key.getContainerName()) != null){
|
|
- fieldBuild.append(" "+key.getFieldKey() + " = '"+keyValue.get(key.getContainerName())+"' , ");
|
|
|
|
|
|
+ sqlBuild.append(" "+key.getFieldKey() + " = '"+keyValue.get(key.getContainerName())+"' , ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sqlBuild.append(" update_user = '"+user.getUserId()+"' , ");
|
|
sqlBuild.append(" update_user = '"+user.getUserId()+"' , ");
|
|
- sqlBuild.append(" update_time = '"+new Date()+"' , ");
|
|
|
|
|
|
+ sqlBuild.append(" update_time = '"+DateUtil.formatDateTime(new Date())+"' ");
|
|
sqlBuild.append(" where id = "+metadataMap.get("id"));
|
|
sqlBuild.append(" where id = "+metadataMap.get("id"));
|
|
}
|
|
}
|
|
jdbcTemplate.execute(sqlBuild.toString());
|
|
jdbcTemplate.execute(sqlBuild.toString());
|