fix:78298
This commit is contained in:
+28
-1
@@ -12,6 +12,7 @@ import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import com.jero.common.util.MessageUtils;
|
||||
import com.jero.modules.activiti.util.ExcelUtils;
|
||||
import com.jero.modules.laws.common.constant.ResultCommon;
|
||||
import com.jero.modules.sys.entity.LawsWorkingGroupUser;
|
||||
import com.jero.modules.sys.service.ILawsWorkingGroupUserService;
|
||||
@@ -20,6 +21,7 @@ import com.jero.modules.system.service.ISysUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
@@ -170,6 +172,21 @@ public class LawsWorkingGroupUserController extends JeroController<LawsWorkingGr
|
||||
if (fileName.lastIndexOf(".") != -1 && !".xlsx".equals(fileName.substring(fileName.lastIndexOf(".")))) {
|
||||
throw new JeroBootException(ResultCommon.PLEASE_USE_A_FILE_WITH_THE_SUFFIX_XLSX);
|
||||
}
|
||||
|
||||
// 获取Excel的header
|
||||
List<String> headers;
|
||||
try {
|
||||
headers = ExcelUtils.getHeaderFromExcel(file.getInputStream(), 0);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new JeroBootException("导入模板错误");
|
||||
}
|
||||
|
||||
// 使用静态方法验证header
|
||||
boolean isMatched = headers.equals(ExcelUtils.getSortedHeadersFromClass(LawsWorkingGroupUser.class));
|
||||
if (!isMatched) {
|
||||
throw new JeroBootException("导入模板错误");
|
||||
}
|
||||
InputStream inputStream = file.getInputStream();
|
||||
List<LawsWorkingGroupUser> all;
|
||||
try {
|
||||
@@ -303,7 +320,17 @@ public class LawsWorkingGroupUserController extends JeroController<LawsWorkingGr
|
||||
return String.join(";", errorMessages);
|
||||
}
|
||||
private List<String> validateWorkNo(List<LawsWorkingGroupUser> all) {
|
||||
Set<String> existingWorkNos = lawsWorkingGroupUserService.list().stream().map(LawsWorkingGroupUser::getWorkingGroupId).collect(Collectors.toSet());
|
||||
List<SysUser> listUser = sysUserService.list();
|
||||
all.stream().forEach(p->{
|
||||
p.setUsername("");
|
||||
if(!CollectionUtils.isEmpty(listUser)){
|
||||
Optional<SysUser> op = listUser.stream().filter(o->Objects.equals(o.getUsername(),p.getUsername())).findFirst();
|
||||
if(op.isPresent()){
|
||||
p.setUsername(op.get().getId());
|
||||
}
|
||||
}
|
||||
});
|
||||
Set<String> existingWorkNos = lawsWorkingGroupUserService.list().stream().map(LawsWorkingGroupUser::getUserId).collect(Collectors.toSet());
|
||||
return IntStream.range(0, all.size())
|
||||
.mapToObj(i -> {
|
||||
LawsWorkingGroupUser lawsWorkingGroupUser = all.get(i);
|
||||
|
||||
Reference in New Issue
Block a user