解决删除图片遇到的空指针异常,增加判断
This commit is contained in:
@@ -228,7 +228,9 @@ public class AccountHeadService {
|
|||||||
List<String> pathList = new ArrayList<>();
|
List<String> pathList = new ArrayList<>();
|
||||||
for(AccountHead accountHead: list){
|
for(AccountHead accountHead: list){
|
||||||
sb.append("[").append(accountHead.getBillNo()).append("]");
|
sb.append("[").append(accountHead.getBillNo()).append("]");
|
||||||
|
if(StringUtil.isNotEmpty(accountHead.getFileName())) {
|
||||||
pathList.add(accountHead.getFileName());
|
pathList.add(accountHead.getFileName());
|
||||||
|
}
|
||||||
if("1".equals(accountHead.getStatus())) {
|
if("1".equals(accountHead.getStatus())) {
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_CODE,
|
||||||
String.format(ExceptionConstants.ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_MSG));
|
String.format(ExceptionConstants.ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_MSG));
|
||||||
|
|||||||
@@ -450,7 +450,9 @@ public class DepotHeadService {
|
|||||||
List<DepotHead> dhList = getDepotHeadListByIds(ids);
|
List<DepotHead> dhList = getDepotHeadListByIds(ids);
|
||||||
for(DepotHead depotHead: dhList){
|
for(DepotHead depotHead: dhList){
|
||||||
sb.append("[").append(depotHead.getNumber()).append("]");
|
sb.append("[").append(depotHead.getNumber()).append("]");
|
||||||
|
if(StringUtil.isNotEmpty(depotHead.getFileName())) {
|
||||||
pathList.add(depotHead.getFileName());
|
pathList.add(depotHead.getFileName());
|
||||||
|
}
|
||||||
//只有未审核的单据才能被删除
|
//只有未审核的单据才能被删除
|
||||||
if("0".equals(depotHead.getStatus())) {
|
if("0".equals(depotHead.getStatus())) {
|
||||||
User userInfo = userService.getCurrentUser();
|
User userInfo = userService.getCurrentUser();
|
||||||
|
|||||||
@@ -299,8 +299,10 @@ public class MaterialService {
|
|||||||
List<Material> list = getMaterialListByIds(ids);
|
List<Material> list = getMaterialListByIds(ids);
|
||||||
for(Material material: list){
|
for(Material material: list){
|
||||||
sb.append("[").append(material.getName()).append("]");
|
sb.append("[").append(material.getName()).append("]");
|
||||||
|
if(StringUtil.isNotEmpty(material.getImgName())) {
|
||||||
pathList.add(material.getImgName());
|
pathList.add(material.getImgName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
logService.insertLog("商品", sb.toString(),
|
logService.insertLog("商品", sb.toString(),
|
||||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||||
User userInfo=userService.getCurrentUser();
|
User userInfo=userService.getCurrentUser();
|
||||||
|
|||||||
@@ -364,9 +364,9 @@ public class SystemConfigService {
|
|||||||
if(fileUploadType == 1) {
|
if(fileUploadType == 1) {
|
||||||
//本地
|
//本地
|
||||||
for(String pathStr: pathList) {
|
for(String pathStr: pathList) {
|
||||||
|
if(StringUtil.isNotEmpty(pathStr)) {
|
||||||
String[] pathArr = pathStr.split(",");
|
String[] pathArr = pathStr.split(",");
|
||||||
for (int i = 0; i < pathArr.length; i++) {
|
for (String path : pathArr) {
|
||||||
String path = pathArr[i];
|
|
||||||
// 提取文件的路径
|
// 提取文件的路径
|
||||||
String pathDir = getDirByPath(path);
|
String pathDir = getDirByPath(path);
|
||||||
if (StringUtil.isNotEmpty(pathDir)) {
|
if (StringUtil.isNotEmpty(pathDir)) {
|
||||||
@@ -394,6 +394,7 @@ public class SystemConfigService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if(fileUploadType == 2) {
|
} else if(fileUploadType == 2) {
|
||||||
//oss
|
//oss
|
||||||
String endpoint = platformConfigService.getPlatformConfigByKey("aliOss_endpoint").getPlatformValue();
|
String endpoint = platformConfigService.getPlatformConfigByKey("aliOss_endpoint").getPlatformValue();
|
||||||
@@ -401,9 +402,10 @@ public class SystemConfigService {
|
|||||||
String accessKeySecret = platformConfigService.getPlatformConfigByKey("aliOss_accessKeySecret").getPlatformValue();
|
String accessKeySecret = platformConfigService.getPlatformConfigByKey("aliOss_accessKeySecret").getPlatformValue();
|
||||||
String bucketName = platformConfigService.getPlatformConfigByKey("aliOss_bucketName").getPlatformValue();
|
String bucketName = platformConfigService.getPlatformConfigByKey("aliOss_bucketName").getPlatformValue();
|
||||||
for(String pathStr: pathList) {
|
for(String pathStr: pathList) {
|
||||||
|
if(StringUtil.isNotEmpty(pathStr)) {
|
||||||
String[] pathArr = pathStr.split(",");
|
String[] pathArr = pathStr.split(",");
|
||||||
for (int i = 0; i < pathArr.length; i++) {
|
for (String path : pathArr) {
|
||||||
String path = pathArr[i];
|
if(StringUtil.isNotEmpty(path)) {
|
||||||
// 创建OSSClient实例。
|
// 创建OSSClient实例。
|
||||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||||
try {
|
try {
|
||||||
@@ -426,6 +428,8 @@ public class SystemConfigService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user