Compare commits

..

No commits in common. 'ae38db469cc935306bb284c4c7f7e8df6255ef1d' and 'ef40ab58f40a6bd3c12cee529a2e94868b91de0c' have entirely different histories.

  1. 105
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java

@ -65,7 +65,6 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
message.put("closeable", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
try {
//创建输出流对象
Workbook wb;
/*判断文件是xlsx结尾还是xls结尾 声明XSSF或HSSF对象*/
@ -98,8 +97,8 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
Sheet sheet = wb.getSheetAt(0);
//获取工作表页中行数据
//读取的总的行数
int rowNum = sheet.getPhysicalNumberOfRows();
if (rowNum < 1) {
int lastRowIndex = sheet.getLastRowNum();
if (lastRowIndex < 1) {
message.put("isError", "true");
message.put("status", "文件无内容或格式错误");
message.put("closeable", "true");
@ -110,7 +109,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
webSocketUtils.sendMessage(loginUser.getId(), message);
List<FunctionxTest> listVo = new ArrayList<>();
for (int i = 1; i <= rowNum; i++) {
for (int i = 1; i <= lastRowIndex; i++) {
Row row = sheet.getRow(i); // 行
if (row == null ) {
continue;
@ -131,10 +130,6 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
list.add(cellValue);
}
}
if(!funCheck(list)){
continue;
}
//------------接收-------------
FunctionxTest fun = new FunctionxTest();
fun.setPModuleName(list.get(0));
@ -218,7 +213,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
functionx.setCreateTime(new Date()); //创建日期
if (StringUtils.isBlank(moduleId)) {
message.put("isError", "true");
message.put("status", "第" + i + "行数据对应模块不能为空");
message.put("status", "第" + (i + 2) + "行对应模块不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块不能为空");
@ -251,7 +246,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
}
if (functionx.getModuleId() == null) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据对应模块有错误");
message.put("status", "第" + (i + 2) + "行对应模块有错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("请输入正确的对应模块");
@ -260,7 +255,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
if (StringUtils.isBlank(functionName)) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据中文名称不能为空");
message.put("status", "第" + (i + 2) + "行中文名称不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("中文名称不能为空");
@ -271,7 +266,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
int count = functionxService.count(queryWrapper1);
if (count > 0) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据中文名称在模块下重复");
message.put("status", "第" + (i + 2) + "行中文名称在模块下重复");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("中文名称在模块下重复");
@ -280,7 +275,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
}
if (StringUtils.isBlank(functionEnName)) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据英文名称不能为空");
message.put("status", "第" + (i + 2) + "行英文名称不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("英文名称不能为空");
@ -291,7 +286,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
int count = functionxService.count(queryWrapper2);
if (count > 0) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据英文名称在模块下重复");
message.put("status", "第" + (i + 2) + "行英文名称在模块下重复");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("英文名称在模块下重复");
@ -303,7 +298,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
int type;
if (StringUtils.isBlank(functionType)) { // 空和null
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据功能类型不能为空");
message.put("status", "第" + (i + 2) + "行功能类型不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("功能类型不能为空");
@ -335,7 +330,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
break;
default:
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据功能类型错误");
message.put("status", "第" + (i + 2) + "行功能类型错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("功能类型错误");
@ -345,7 +340,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
// 模块编码+功能缩写;自动填充+手动修改
if (StringUtils.isBlank(functionCode)) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据功能编码不能为空");
message.put("status", "第" + (i + 2) + "行功能编码不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("功能编码不能为空");
@ -358,7 +353,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
String str = moduleCode + firstChar;
if (!str.equals(functionCode)) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据功能编码错误");
message.put("status", "第" + (i + 2) + "行功能编码错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("功能编码错误");
@ -373,12 +368,12 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
if (StringUtils.isNotBlank(userRole)) { // 用户角色
LambdaQueryWrapper<ProjectUserRole> queryWrapperUser = new LambdaQueryWrapper<>();
queryWrapperUser.eq(ProjectUserRole::getUserRole, userRole); // 是否匹配项目id?
List<ProjectUserRole> list1 = projectUserRoleService.list(queryWrapperUser);
if (list1.size() > 0)
functionx.setUserRole(list1.get(0).getId());
int count = projectUserRoleService.count(queryWrapperUser);
if (count > 0)
functionx.setUserRole(userRole);
else {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据请输入正确的用户角色");
message.put("status", "第" + (i + 2) + "行请输入正确的用户角色");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("请输入正确的用户角色");
@ -388,24 +383,20 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
if (StringUtils.isNotBlank(managerUsers)) { // 责任人
String[] splitManager = managerUsers.split("\\s+|,|;|、");
int count = 1;
String idManager = "";
int count = 0;
for (String manager : splitManager) {
LambdaQueryWrapper<SysUser> queryWrapperUserName = new LambdaQueryWrapper<>();
queryWrapperUserName.eq(!manager.isEmpty(), SysUser::getUsername, manager);
List<SysUser> list1 = sysUserService.list(queryWrapperUserName);
if (list1.isEmpty()) {
count=0;
count = sysUserService.count(queryWrapperUserName);
if (count == 0) {
break;
}
idManager = idManager+list1.get(0).getId()+",";
}
if (count > 0){
functionx.setManagerUsers(idManager);
}
if (count > 0)
functionx.setManagerUsers(managerUsers);
else {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据请输入正确的责任人,并确保多个责任人之间用空格或者逗号、分号隔开");
message.put("status", "第" + (i + 2) + "行请输入正确的责任人,并确保多个责任人之间用空格或者逗号、分号隔开");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("请输入正确的责任人,并确保多个责任人之间用空格或者逗号、分号隔开");
@ -415,7 +406,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
// 值:1、2、3、4、5,默认2
if (StringUtils.isBlank(workLevel)) { // 任务等级
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据任务等级不能为空");
message.put("status", "第" + (i + 2) + "行任务等级不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务等级不能为空");
@ -423,7 +414,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
int integer = Integer.parseInt(workLevel);
if (integer < 1 || integer > 5) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据任务等级错误");
message.put("status", "第" + (i + 2) + "行任务等级错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务等级错误");
@ -433,7 +424,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
if (StringUtils.isBlank(workStatus)) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据任务状态不能为空");
message.put("status", "第" + (i + 2) + "行任务状态不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务状态不能为空");
@ -460,7 +451,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
break;
default:
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据任务状态错误");
message.put("status", "第" + (i + 2) + "行任务状态错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务状态错误");
@ -473,7 +464,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
Boolean isTime = checkTime(publishTime);
if (!isTime) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据发布时间格式错误");
message.put("status", "第" + (i + 2) + "行发布时间格式错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("发布时间错误,应为" + pattern + "类型");
@ -482,7 +473,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
date = dateFormat.parse(publishTime);
} catch (Exception e) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据发布时间错误");
message.put("status", "第" + (i + 2) + "行发布时间错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("发布时间错误,应为" + pattern + "类型");
@ -495,7 +486,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
Boolean isTime = checkTime(startTime);
if (!isTime) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据开始时间格式错误");
message.put("status", "第" + (i + 2) + "行开始时间格式错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("开始时间错误,应为" + pattern + "类型");
@ -504,7 +495,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
date = dateFormat.parse(startTime);
} catch (Exception e) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据开始时间错误");
message.put("status", "第" + (i + 2) + "行开始时间错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("开始时间错误,应为" + pattern + "类型");
@ -522,7 +513,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
Boolean isTime = checkTime(submitTime);
if (!isTime) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据提交时间格式错误");
message.put("status", "第" + (i + 2) + "行提交时间格式错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("提交时间格式错误,应为" + pattern + "类型");
@ -531,7 +522,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
date = dateFormat.parse(submitTime);
} catch (Exception e) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据提交时间时间错误");
message.put("status", "第" + (i + 2) + "行提交时间时间错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("提交时间时间错误,应为" + pattern + "类型");
@ -542,7 +533,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
Double aDouble = Double.valueOf(realDuration);
if (aDouble < 0.1) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据实际时长错误");
message.put("status", "第" + (i + 2) + "行实际时长错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("实际时长错误");
@ -552,7 +543,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
}
if (StringUtils.isBlank(status)) { // 空和null
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据功能状态不能为空");
message.put("status", "第" + (i + 2) + "行功能状态不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("功能状态不能为空");
@ -570,7 +561,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
break;
default:
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据任务状态错误");
message.put("status", "第" + (i + 2) + "行任务状态错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务状态错误");
@ -579,7 +570,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
}
if (StringUtils.isBlank(verisonStatus)) { // 空和null
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据版本状态不能为空");
message.put("status", "第" + (i + 2) + "行版本状态不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本状态不能为空");
@ -594,7 +585,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
break;
default:
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据版本状态错误");
message.put("status", "第" + (i + 2) + "行版本状态错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本状态错误");
@ -603,7 +594,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
}
if (StringUtils.isBlank(verison)) {
message.put("isError", "true");
message.put("status", "第" + (i+1) + "行数据数据版本号不能为空");
message.put("status", "第" + (i + 2) + "行版本号不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本号不能为空");
@ -625,30 +616,12 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
return Result.error("导入失败");
}
} catch (Exception e) {
message.put("isError", "true");
message.put("status", "导入失败,请重新检查上传文件内容和格式");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败");
}
message.put("status", "上传成功");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.OK("导入成功");
}
private boolean funCheck(List<String> list) {
for (int i=0;i<list.size();i++){
if(list.get(i)!=null && list.get(i).length()>0){
return true;
}
}
return false;
}
private boolean isSuccessInsert(LoginUser loginUser, Map<String, String> message, List<Functionx> listInsert) {
message.put("status", "导入数据中");
message.put("records", String.valueOf(listInsert.size()));

Loading…
Cancel
Save