commit
This commit is contained in:
+105
-9
@@ -1,8 +1,11 @@
|
||||
package io.v.nutz.zhgh.activity.controller.basic;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
@@ -15,31 +18,35 @@ import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.sys.models.Sys_role;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.activity.template.UserTemp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.dao.util.cri.Static;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.annotation.*;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,6 +63,9 @@ public class ActivityBasicScopeController {
|
||||
@Inject
|
||||
private SimpleService simpleService;
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
|
||||
@Inject
|
||||
private ActivityBasicScopeService activityBasicScopeService;
|
||||
|
||||
@@ -105,7 +115,8 @@ public class ActivityBasicScopeController {
|
||||
@Param(value = "clubId", required = false) String clubId,
|
||||
@Param(value = "reverseSelection") boolean reverseSelection,
|
||||
@Param(value = "activityGroupId", required = false) Integer activityGroupId,
|
||||
@Param(value = "activityUserCnd", required = false) String activityUserCndStr) {
|
||||
@Param(value = "activityUserCnd", required = false) String activityUserCndStr,
|
||||
@Param(value = "existsLoginNameRedisKey", required = false) String existsLoginNameRedisKey) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
DISTINCT(u.id) as id,
|
||||
@@ -127,7 +138,10 @@ public class ActivityBasicScopeController {
|
||||
""");
|
||||
try {
|
||||
Cnd cnd = getCnd(pageForm, unionId, unitId, personTypes, userStates, memberTypes, sexTypes, age, teacherMeetingId, roleIds, userId, clubId, reverseSelection, activityGroupId, activityUserCndStr);
|
||||
|
||||
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
|
||||
List<String> loginNames = redisService.lrange(existsLoginNameRedisKey, 0, -1);
|
||||
cnd.andEX("u.loginname", "in", loginNames);
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
return simpleService.list(pageForm, sql);
|
||||
@@ -169,7 +183,8 @@ public class ActivityBasicScopeController {
|
||||
@Param(value = "userId", required = false) String[] userId,
|
||||
@Param(value = "clubId", required = false) String clubId,
|
||||
@Param(value = "reverseSelection") boolean reverseSelection,
|
||||
@Param(value = "activityUserCnd", required = false) String activityUserCndStr) {
|
||||
@Param(value = "activityUserCnd", required = false) String activityUserCndStr,
|
||||
@Param(value = "existsLoginNameRedisKey", required = false) String existsLoginNameRedisKey) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT DISTINCT
|
||||
( u.id ) AS userId
|
||||
@@ -181,6 +196,11 @@ public class ActivityBasicScopeController {
|
||||
""");
|
||||
Cnd cnd = getCnd(pageForm, unionId, unitId, personTypes, userStates, memberTypes, sexTypes, age, teacherMeetingId, roleIds, userId, clubId, reverseSelection, activityGroupId, activityUserCndStr);
|
||||
|
||||
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
|
||||
List<String> loginNames = redisService.lrange(existsLoginNameRedisKey, 0, -1);
|
||||
cnd.andEX("u.loginname", "in", loginNames);
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
sql.setCallback(Sqls.callback.entities());
|
||||
sql.setEntity(dao.getEntity(ActivityUserScope.class));
|
||||
@@ -339,7 +359,9 @@ public class ActivityBasicScopeController {
|
||||
@Param(value = "clubId", required = false) String clubId,
|
||||
@Param(value = "reverseSelection") boolean reverseSelection,
|
||||
@Param(value = "activityGroupId", required = false) Integer activityGroupId,
|
||||
@Param(value = "activityUserCnd", required = false) String activityUserCndStr, HttpServletResponse response) {
|
||||
@Param(value = "activityUserCnd", required = false) String activityUserCndStr,
|
||||
@Param(value = "existsLoginNameRedisKey", required = false) String existsLoginNameRedisKey,
|
||||
HttpServletResponse response) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
@@ -363,7 +385,10 @@ public class ActivityBasicScopeController {
|
||||
|
||||
try {
|
||||
Cnd cnd = getCnd(pageForm, unionId, unitId, personTypes, userStates, memberTypes, sexTypes, age, teacherMeetingId, roleIds, userId, clubId, reverseSelection, activityGroupId, activityUserCndStr);
|
||||
|
||||
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
|
||||
List<String> loginNames = redisService.lrange(existsLoginNameRedisKey, 0, -1);
|
||||
cnd.andEX("u.loginname", "in", loginNames);
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<NutMap> map = simpleService.listMap(sql);
|
||||
@@ -461,5 +486,76 @@ public class ActivityBasicScopeController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空查询条件
|
||||
*
|
||||
* @param existsLoginNameRedisKey
|
||||
* @return java.lang.Object
|
||||
* @author zhf
|
||||
* @description
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@ViReturn
|
||||
@RequiresPermissions("activity.basic.scope")
|
||||
public Object clearSearchCnd(String existsLoginNameRedisKey) {
|
||||
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
|
||||
redisService.del(existsLoginNameRedisKey);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@RequiresPermissions("activity.basic.scope")
|
||||
public Object doImport(String groupId, TempFile file) {
|
||||
String matchUserLoginNamesKey = "ActivityBasicScopeController.doImport.time=" + System.currentTimeMillis();
|
||||
|
||||
List<UserTemp> userImportList = ExcelImportUtil.importExcel(file.getFile(), UserTemp.class, new ImportParams());
|
||||
|
||||
//判断人员哪些存在哪些不存在
|
||||
Sql sql = Sqls.queryString("""
|
||||
SELECT
|
||||
u.loginname
|
||||
FROM
|
||||
sys_user u
|
||||
""");
|
||||
dao.execute(sql);
|
||||
String[] sysLoginNames = (String[]) sql.getResult();
|
||||
|
||||
//存在的工号
|
||||
List<String> existsLoginNames = new ArrayList<>();
|
||||
|
||||
for (UserTemp excelUser : userImportList) {
|
||||
if (ArrayUtil.contains(sysLoginNames, excelUser.getLoginname())) {
|
||||
existsLoginNames.add(excelUser.getLoginname());
|
||||
} else {
|
||||
excelUser.setRemarks("系统查不到此人");
|
||||
}
|
||||
}
|
||||
|
||||
//匹配不到的用户
|
||||
List<UserTemp> errorExcelTempUsers = userImportList.stream().filter(v -> StrUtil.isNotBlank(v.getRemarks())).collect(Collectors.toList());
|
||||
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
nutMap.setv("totalCount", userImportList.size());
|
||||
nutMap.setv("successCount", existsLoginNames.size());
|
||||
nutMap.setv("errorCount", errorExcelTempUsers.size());
|
||||
nutMap.setv("errorList", errorExcelTempUsers.stream().map(v -> {
|
||||
return new NutMap().addv("工号", v.getLoginname()).addv("姓名", v.getUsername()).addv("错误信息", v.getRemarks());
|
||||
}).collect(Collectors.toList()));
|
||||
nutMap.setv("existsLoginNameRedisKey", matchUserLoginNamesKey);
|
||||
|
||||
//保存存在的工号
|
||||
if (Lang.isNotEmpty(existsLoginNames)) {
|
||||
redisService.lpush(matchUserLoginNamesKey, existsLoginNames.toArray(new String[0]));
|
||||
redisService.expire(matchUserLoginNamesKey, 60 * 3);
|
||||
}
|
||||
|
||||
return Result.success(nutMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+154
-45
@@ -1,30 +1,39 @@
|
||||
package io.v.nutz.zhgh.activity.controller.basic;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.zhgh.activity.models.ActivityUserScope;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.service.SimpleService;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.service.SimpleService;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.sys.models.User;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.zhgh.activity.models.ActivityUserScope;
|
||||
import io.v.nutz.zhgh.activity.template.UserTemp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.Static;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.annotation.*;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
@@ -45,6 +54,9 @@ public class ActivityBasicUserController {
|
||||
@Inject
|
||||
private SimpleService simpleService;
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:platform/activity/basic/ActivityUser.html")
|
||||
@RequiresPermissions("activity.basic.user")
|
||||
@@ -62,7 +74,8 @@ public class ActivityBasicUserController {
|
||||
@Param(value = "userState", required = false) String userState,
|
||||
@Param(value = "groupId", required = false) Integer groupId,
|
||||
@Param(value = "activityUnionId", required = false) String activityUnionId,
|
||||
@Param(value = "activityUnitId", required = false) String activityUnitId) {
|
||||
@Param(value = "activityUnitId", required = false) String activityUnitId,
|
||||
@Param(value = "existsLoginNameRedisKey", required = false) String existsLoginNameRedisKey) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
aus.id,
|
||||
@@ -90,6 +103,9 @@ public class ActivityBasicUserController {
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchName()) && StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.and(Cnd.likeEX(pageForm.getSearchName(), pageForm.getSearchKeyword()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pageForm.getPageOrderName()) && StrUtil.isNotBlank(pageForm.getPageOrderBy())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), pageForm.getPageOrderBy().equalsIgnoreCase("ascending") ? "ASC" : "DESC");
|
||||
}
|
||||
cnd.andEX("actit.unionid", "=", activityUnionId);
|
||||
cnd.andEX("actit.id", "=", activityUnitId);
|
||||
cnd.andEX("aus.groupId", "=", groupId);
|
||||
@@ -101,6 +117,11 @@ public class ActivityBasicUserController {
|
||||
cnd.andEX("aus.creator", "=", ShiroUtil.getPrincipalProperty("id"));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
|
||||
List<String> loginNames = redisService.lrange(existsLoginNameRedisKey, 0, -1);
|
||||
cnd.andEX("u.loginname", "in", loginNames);
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
return simpleService.list(pageForm, sql);
|
||||
}
|
||||
@@ -120,46 +141,41 @@ public class ActivityBasicUserController {
|
||||
@Param(value = "searchName", required = false) String searchName,
|
||||
@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "unitId", required = false) String unitId,
|
||||
@Param(value = "activityUnionId", required = false) String activityUnionId,
|
||||
@Param(value = "activityUnitId", required = false) String activityUnitId,
|
||||
@Param(value = "personType", required = false) String personType,
|
||||
@Param(value = "userState", required = false) String userState) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(id)) {
|
||||
cnd.and("id", "=", id);
|
||||
simpleService.dao().clear(ActivityUserScope.class, cnd);
|
||||
} else {
|
||||
List<User> users = simpleService.dao().query(User.class, Cnd.NEW());
|
||||
if (StrUtil.isNotBlank(searchKeyword) && StrUtil.isNotBlank(searchName)) {
|
||||
users = users.stream().filter(v -> v.getLoginname().equals(searchKeyword) || v.getUsername().equals(searchKeyword)).collect(Collectors.toList());
|
||||
@Param(value = "userState", required = false) String userState,
|
||||
@Param(value = "existsLoginNameRedisKey", required = false) String existsLoginNameRedisKey) {
|
||||
List<String> existsLoginNames = new ArrayList<>();
|
||||
if(StrUtil.isNotBlank(existsLoginNameRedisKey) && redisService.exists(existsLoginNameRedisKey)){
|
||||
existsLoginNames = redisService.lrange(existsLoginNameRedisKey, 0, -1);
|
||||
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
|
||||
redisService.del(existsLoginNameRedisKey);
|
||||
}
|
||||
if (StrUtil.isNotBlank(unionId)) {
|
||||
users = users.stream().filter(v -> StrUtil.isNotBlank(v.getUnionid()) && v.getUnionid().equals(unionId)).collect(Collectors.toList());
|
||||
}
|
||||
if (StrUtil.isNotBlank(unitId)) {
|
||||
users = users.stream().filter(v -> StrUtil.isNotBlank(v.getUnitid()) && v.getUnitid().equals(unitId)).collect(Collectors.toList());
|
||||
}
|
||||
if (StrUtil.isNotBlank(personType)) {
|
||||
users = users.stream().filter(v -> StrUtil.isNotBlank(v.getPersonType()) && v.getPersonType().equals(personType)).collect(Collectors.toList());
|
||||
}
|
||||
if (StrUtil.isNotBlank(userState)) {
|
||||
users = users.stream().filter(v -> StrUtil.isNotBlank(v.getUserState()) && v.getUserState().equals(userState)).collect(Collectors.toList());
|
||||
}
|
||||
if (StrUtil.isNotBlank(activityUnitId)) {
|
||||
users = users.stream().filter(v -> StrUtil.isNotBlank(v.getActivityUnitId()) && v.getActivityUnitId().equals(activityUnitId)).collect(Collectors.toList());
|
||||
}
|
||||
if (StrUtil.isNotBlank(activityUnionId)) {
|
||||
users = users.stream().filter(v -> StrUtil.isNotBlank(v.getActivityUnionId()) && v.getActivityUnionId().equals(activityUnionId)).collect(Collectors.toList());
|
||||
}
|
||||
List<String> ids = users.stream().map(User::getId).collect(Collectors.toList());
|
||||
cnd.andEX("userId", "in", ids);
|
||||
cnd.andEX("groupId", "=", groupId);
|
||||
if (Lang.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
simpleService.dao().clear(ActivityUserScope.class, cnd);
|
||||
}
|
||||
|
||||
Sql sql = Sqls.create("select id from `user` u $condition");
|
||||
Cnd userCnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(searchName) && StrUtil.isNotBlank(searchKeyword)) {
|
||||
userCnd.and(Cnd.likeEX(searchName, searchKeyword));
|
||||
}
|
||||
userCnd.andEX("u.unionid", "=", unionId);
|
||||
userCnd.andEX("u.unitid", "=", unitId);
|
||||
userCnd.andEX("u.personType", "=", personType);
|
||||
userCnd.andEX("u.userState", "=", userState);
|
||||
userCnd.andEX("u.id", "=", id);
|
||||
userCnd.andEX("u.loginname","in",existsLoginNames);
|
||||
sql.setCondition(userCnd);
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("groupId","=",groupId);
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
|
||||
cnd.andEX("creator", "=", ShiroUtil.getPrincipalProperty("id"));
|
||||
}
|
||||
if(StrUtil.isNotBlank(id)){
|
||||
cnd.and("id","=",id);
|
||||
}else {
|
||||
cnd.and(new Static("userId in ("+ sql +")"));
|
||||
}
|
||||
simpleService.dao().clear(ActivityUserScope.class,cnd);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -178,6 +194,7 @@ public class ActivityBasicUserController {
|
||||
u.loginname AS loginName,
|
||||
u.sex,
|
||||
u.mobile,
|
||||
u.idcard,
|
||||
u.unitname AS unitName,
|
||||
u.unionName AS unionName
|
||||
FROM
|
||||
@@ -198,6 +215,7 @@ public class ActivityBasicUserController {
|
||||
exportEntities.add(new ExcelExportEntity("工会", "unionName", 20));
|
||||
exportEntities.add(new ExcelExportEntity("单位", "unitName", 20));
|
||||
exportEntities.add(new ExcelExportEntity("手机号码", "mobile", 20));
|
||||
exportEntities.add(new ExcelExportEntity("身份证号", "idcard", 20));
|
||||
|
||||
|
||||
ViTool.excelResponse(response, "活动分组人员.xls");
|
||||
@@ -209,5 +227,96 @@ public class ActivityBasicUserController {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("activity.basic.user")
|
||||
public void downloadImport(HttpServletResponse response) {
|
||||
try {
|
||||
ViTool.excelResponse(response, "人员导入模板.xlsx");
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, new ArrayList<>());
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@RequiresPermissions("activity.basic.user")
|
||||
public Object doImport(String groupId, TempFile file) {
|
||||
String matchUserLoginNamesKey = "ActivityBasicUserController.doImport.groupId=" + groupId + "time=" + System.currentTimeMillis();
|
||||
|
||||
List<UserTemp> userImportList = ExcelImportUtil.importExcel(file.getFile(), UserTemp.class, new ImportParams());
|
||||
|
||||
//判断人员哪些存在哪些不存在
|
||||
Sql sql = Sqls.queryString("""
|
||||
SELECT
|
||||
u.loginname
|
||||
FROM
|
||||
activity_user_scope aus
|
||||
LEFT JOIN sys_user u ON u.id = aus.userId
|
||||
WHERE
|
||||
aus.groupId = @groupId
|
||||
""").setParam("groupId", groupId);
|
||||
simpleService.execute(sql);
|
||||
String[] sysLoginNames = (String[]) sql.getResult();
|
||||
|
||||
//存在的工号
|
||||
List<String> existsLoginNames = new ArrayList<>();
|
||||
|
||||
for (UserTemp excelUser : userImportList) {
|
||||
if (ArrayUtil.contains(sysLoginNames, excelUser.getLoginname())) {
|
||||
existsLoginNames.add(excelUser.getLoginname());
|
||||
} else {
|
||||
excelUser.setRemarks("系统查不到此人");
|
||||
}
|
||||
}
|
||||
|
||||
//匹配不到的用户
|
||||
List<UserTemp> errorExcelTempUsers = userImportList.stream().filter(v -> StrUtil.isNotBlank(v.getRemarks())).collect(Collectors.toList());
|
||||
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
nutMap.setv("totalCount", userImportList.size());
|
||||
nutMap.setv("successCount", existsLoginNames.size());
|
||||
nutMap.setv("errorCount", errorExcelTempUsers.size());
|
||||
nutMap.setv("errorList", errorExcelTempUsers.stream().map(v -> {
|
||||
return new NutMap().addv("工号", v.getLoginname()).addv("姓名", v.getUsername()).addv("错误信息", v.getRemarks());
|
||||
}).collect(Collectors.toList()));
|
||||
nutMap.setv("existsLoginNameRedisKey", matchUserLoginNamesKey);
|
||||
|
||||
//保存存在的工号
|
||||
if (Lang.isNotEmpty(existsLoginNames)) {
|
||||
redisService.lpush(matchUserLoginNamesKey, existsLoginNames.toArray(new String[0]));
|
||||
redisService.expire(matchUserLoginNamesKey, 60 * 3);
|
||||
}
|
||||
|
||||
return Result.success(nutMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空查询条件
|
||||
*
|
||||
* @param existsLoginNameRedisKey
|
||||
* @return java.lang.Object
|
||||
* @author zhf
|
||||
* @description
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@RequiresPermissions("activity.basic.user")
|
||||
public Object clearSearchCnd(String existsLoginNameRedisKey) {
|
||||
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
|
||||
redisService.del(existsLoginNameRedisKey);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package io.v.nutz.zhgh.activity.template;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserTemp {
|
||||
|
||||
@Excel(name = "工号")
|
||||
private String loginname;
|
||||
|
||||
@Excel(name = "姓名")
|
||||
private String username;
|
||||
|
||||
@Excel(name = "备注")
|
||||
private String remarks;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user