|
@@ -4,7 +4,6 @@ import com.ruoyi.common.core.utils.SpringUtils;
|
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
|
import com.ruoyi.system.api.RemoteConfigService;
|
|
|
import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionAttach;
|
|
|
-import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionSafetyinspectionrecords;
|
|
|
import com.sooka.sponest.data.housingconstruction.mapper.CenterdataTHousingconstructionAttachMapper;
|
|
|
import com.sooka.sponest.data.housingconstruction.service.ICenterdataTHousingconstructionAttachService;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
@@ -27,6 +26,7 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
private CenterdataTHousingconstructionAttachMapper centerdataTHousingconstructionAttachMapper;
|
|
|
|
|
|
//*******************************************删除*****************************************************/
|
|
|
+
|
|
|
/**
|
|
|
* 根据业务数据id删除附件信息
|
|
|
*/
|
|
@@ -36,8 +36,10 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
}
|
|
|
|
|
|
//*******************************************新增List<CenterdataTHousingconstructionAttach>*****************************************************/
|
|
|
+
|
|
|
/**
|
|
|
* 新增附件
|
|
|
+ *
|
|
|
* @param attachList 参数为附件实体的集合
|
|
|
* @return int 写入的数据条数
|
|
|
*/
|
|
@@ -49,13 +51,14 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
|
|
|
/**
|
|
|
* 根据业务id获取附件集合
|
|
|
+ *
|
|
|
* @return List<CenterdataTHousingconstructionAttach> 附件实体集合
|
|
|
*/
|
|
|
@Override
|
|
|
public List<CenterdataTHousingconstructionAttach> getAttachPathToEntityArray(String busId) {
|
|
|
List<CenterdataTHousingconstructionAttach> attachListByBusId = centerdataTHousingconstructionAttachMapper.getAttachListByBusId(busId);
|
|
|
String fileUrl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey("fileUrl").getData();
|
|
|
- attachListByBusId.forEach(attach->{
|
|
|
+ attachListByBusId.forEach(attach -> {
|
|
|
attach.setAttachPath(fileUrl + attach.getAttachPath());
|
|
|
});
|
|
|
return attachListByBusId;
|
|
@@ -63,12 +66,14 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
|
|
|
|
|
|
//*******************************************新增List<String>*****************************************************/
|
|
|
+
|
|
|
/**
|
|
|
* 新增附件
|
|
|
+ *
|
|
|
* @param attachList 参数为附件路径集合
|
|
|
- * @param busId 业务数据id
|
|
|
- * @param dictType 字典key,可以为null
|
|
|
- * @param dictValue 字典值,可以为null
|
|
|
+ * @param busId 业务数据id
|
|
|
+ * @param dictType 字典key,可以为null
|
|
|
+ * @param dictValue 字典值,可以为null
|
|
|
* @return int 写入的数据条数
|
|
|
*/
|
|
|
@Override
|
|
@@ -77,10 +82,10 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
int index = 0;
|
|
|
String[] fileNameArray = fileName.split(",");
|
|
|
for (String s : attachList) {
|
|
|
- if(fileNameArray.length < 0 || StringUtils.isEmpty(fileName)){
|
|
|
+ if (fileNameArray.length < 0 || StringUtils.isEmpty(fileName)) {
|
|
|
String[] split = s.split("/");
|
|
|
dataList.add(new CenterdataTHousingconstructionAttach(busId, dictType, dictValue, s, split[split.length - 1], 0L));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
dataList.add(new CenterdataTHousingconstructionAttach(busId, dictType, dictValue, s, fileNameArray[index], 0L));
|
|
|
index++;
|
|
|
}
|
|
@@ -91,6 +96,7 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
|
|
|
/**
|
|
|
* 根据业务id获取附件集合
|
|
|
+ *
|
|
|
* @return List<String> 附件路径集合
|
|
|
*/
|
|
|
@Override
|
|
@@ -106,11 +112,13 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
}
|
|
|
|
|
|
//*******************************************新增String*****************************************************/
|
|
|
+
|
|
|
/**
|
|
|
* 新增附件
|
|
|
+ *
|
|
|
* @param attachStr 参数为附件路径字符串拼接,以英文逗号分隔
|
|
|
- * @param busId 业务数据id
|
|
|
- * @param dictType 字典key,可以为null
|
|
|
+ * @param busId 业务数据id
|
|
|
+ * @param dictType 字典key,可以为null
|
|
|
* @param dictValue 字典值,可以为null
|
|
|
* @return int 写入的数据条数
|
|
|
*/
|
|
@@ -121,6 +129,7 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
|
|
|
/**
|
|
|
* 根据业务id获取附件集合
|
|
|
+ *
|
|
|
* @return String 附件路径拼接字符串,以英文逗号分隔
|
|
|
*/
|
|
|
@Override
|
|
@@ -142,17 +151,19 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
}
|
|
|
|
|
|
//*******************************************新增List<Map<String, Object>>*****************************************************/
|
|
|
+
|
|
|
/**
|
|
|
* 新增附件
|
|
|
+ *
|
|
|
* @param attachList 新增的附件集合
|
|
|
- * 请求样例:[{
|
|
|
- * "key":"字段名",
|
|
|
- * "value":"附件路径"
|
|
|
- * },{
|
|
|
- * "key":"字段名",
|
|
|
- * "value":"附件路径"
|
|
|
- * }]
|
|
|
- * @param busId 业务id
|
|
|
+ * 请求样例:[{
|
|
|
+ * "key":"字段名",
|
|
|
+ * "value":"附件路径"
|
|
|
+ * },{
|
|
|
+ * "key":"字段名",
|
|
|
+ * "value":"附件路径"
|
|
|
+ * }]
|
|
|
+ * @param busId 业务id
|
|
|
* @return int 新增的数据条数
|
|
|
*/
|
|
|
@Override
|
|
@@ -169,25 +180,25 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
|
|
|
/**
|
|
|
* 根据业务id获取附件
|
|
|
+ *
|
|
|
* @param busId 业务id
|
|
|
* @return Map<String, Object>
|
|
|
* 返回样例:{
|
|
|
- * "新增时设置的key":"附件路径",
|
|
|
- * "新增时设置的key":"附件路径"
|
|
|
+ * "新增时设置的key":"附件路径",
|
|
|
+ * "新增时设置的key":"附件路径"
|
|
|
* }
|
|
|
*/
|
|
|
@Override
|
|
|
- public Map<String, Object> getAttachToMap(String busId){
|
|
|
+ public Map<String, Object> getAttachToMap(String busId) {
|
|
|
List<CenterdataTHousingconstructionAttach> attachPathToEntityArray = getAttachPathToEntityArray(busId);
|
|
|
HashMap<String, Object> result = new HashMap<>();
|
|
|
- attachPathToEntityArray.forEach(attach->{
|
|
|
+ attachPathToEntityArray.forEach(attach -> {
|
|
|
result.put(attach.getDictType(), attach.getAttachPath());
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 新增时路径处理(私有方法)
|
|
|
*/
|
|
@@ -221,33 +232,32 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
|
|
|
|
/**
|
|
|
* 针对文件类型数据处理
|
|
|
+ *
|
|
|
* @param busId 业务id
|
|
|
- * @param type 要与附件表中dict_type匹配的字符串
|
|
|
+ * @param type 要与附件表中dict_type匹配的字符串
|
|
|
* @return String 附件路径+文件名 以逗号拼接
|
|
|
*/
|
|
|
@Override
|
|
|
- public String replasePathToFile(String busId,String type){
|
|
|
+ public String replasePathToFile(String busId, String type) {
|
|
|
List<CenterdataTHousingconstructionAttach> attachList = getAttachPathToEntityArray(busId);
|
|
|
StringBuilder newDiles = new StringBuilder();
|
|
|
String fileurl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(DOWNLOAD_URL).getData();
|
|
|
- attachList.forEach(attach->{
|
|
|
- if(StringUtils.isNotEmpty(type)){
|
|
|
- if(type.equals(attach.getDictType())){
|
|
|
- String filename = attach.getFileName(); //新建 Microsoft Excel 工作表 (2).xlsx
|
|
|
- String url = attach.getAttachPath().substring(attach.getAttachPath().indexOf("group1"),attach.getAttachPath().length()); //group1/M00/00/84/wKgKEGawNfGAW7bwAAAxRySSUAM25.xlsx
|
|
|
- String group = url.substring(0, url.indexOf('/')); //group1
|
|
|
- newDiles.append(fileurl + "Download?fileName=" + filename + "&&group=" + group + "&&path=" + url.substring(url.indexOf('/') + 1) + "+" + filename + ",");
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(type.equals(attach.getDictValue())){
|
|
|
+ attachList.forEach(attach -> {
|
|
|
+ if (StringUtils.isNotEmpty(type)) {
|
|
|
+ if (type.equals(attach.getDictType())) {
|
|
|
String filename = attach.getFileName(); //新建 Microsoft Excel 工作表 (2).xlsx
|
|
|
- String url = attach.getAttachPath().substring(attach.getAttachPath().indexOf("group1"),attach.getAttachPath().length()); //group1/M00/00/84/wKgKEGawNfGAW7bwAAAxRySSUAM25.xlsx
|
|
|
+ String url = attach.getAttachPath().substring(attach.getAttachPath().indexOf("group1"), attach.getAttachPath().length()); //group1/M00/00/84/wKgKEGawNfGAW7bwAAAxRySSUAM25.xlsx
|
|
|
String group = url.substring(0, url.indexOf('/')); //group1
|
|
|
newDiles.append(fileurl + "Download?fileName=" + filename + "&&group=" + group + "&&path=" + url.substring(url.indexOf('/') + 1) + "+" + filename + ",");
|
|
|
}
|
|
|
+ } else {
|
|
|
+ String filename = attach.getFileName(); //新建 Microsoft Excel 工作表 (2).xlsx
|
|
|
+ String url = attach.getAttachPath().substring(attach.getAttachPath().indexOf("group1"), attach.getAttachPath().length()); //group1/M00/00/84/wKgKEGawNfGAW7bwAAAxRySSUAM25.xlsx
|
|
|
+ String group = url.substring(0, url.indexOf('/')); //group1
|
|
|
+ newDiles.append(fileurl + "Download?fileName=" + filename + "&&group=" + group + "&&path=" + url.substring(url.indexOf('/') + 1) + "+" + filename + ",");
|
|
|
}
|
|
|
});
|
|
|
- if(newDiles.length() > 0){
|
|
|
+ if (newDiles.length() > 0) {
|
|
|
newDiles.deleteCharAt(newDiles.length() - 1);
|
|
|
}
|
|
|
return newDiles.toString();
|