This commit is contained in:
Paidax
2025-05-09 10:03:47 +08:00
parent 3d5927ec6f
commit 69ae3c7409
7 changed files with 926 additions and 650 deletions
@@ -523,6 +523,7 @@ public class WelfareCommonController {
Sql sql = Sqls.create("""
SELECT
id,
mobile,
loginname,
username,
personType,
@@ -571,8 +572,9 @@ public class WelfareCommonController {
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
entityList.add(new ExcelExportEntity("姓名", "username", 20));
entityList.add(new ExcelExportEntity("联系电话", "mobile", 20));
entityList.add(new ExcelExportEntity("在职状态", "userState", 20));
entityList.add(new ExcelExportEntity("人员性质", "personType", 20));
// entityList.add(new ExcelExportEntity("人员类型", "personType", 20));
entityList.add(new ExcelExportEntity("所属工会", "unionname", 50));
entityList.add(new ExcelExportEntity("所属单位", "unitname", 50));
@@ -44,6 +44,7 @@ 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.random.R;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At;
@@ -97,6 +98,7 @@ public class WelfareListController {
@Param(value = "provideMode", required = false) Integer provideMode,
@Param(value = "optionId", required = false) String optionId,
@Param(value = "month", required = false) String month,
@Param(value = "isChoose", required = false) Integer isChoose,
@Param(value = "courierNumber", required = false) String courierNumber) {
Sql sql = Sqls.create("""
SELECT
@@ -141,6 +143,14 @@ public class WelfareListController {
cnd.andEX("wl.unionid", "=", pageParam.getWelfareUnit());
cnd.andEX("wl.unitid", "=", pageParam.getUnit());
if (isChoose != null) {
if (isChoose.equals(1)) {
cnd.and("wus.selectUserId", "is not", null);
} else if (isChoose.equals(2)) {
cnd.and("wus.selectUserId", "is", null);
}
}
if (Lang.isNotEmpty(pageParam.getPersonTypes())) {
String personTypes = pageParam.getPersonTypes();
String[] personTypeArray = Json.fromJsonAsArray(String.class, personTypes);
@@ -665,6 +675,36 @@ public class WelfareListController {
}
@At
@ViReturn
@RequiresPermissions("welfare.list.mange")
public Object queryNotWelfareListUsers(@Param("projectId") String projectId, @Param("query") String query){
if (StrUtil.isBlank(query)) {
return null;
}
Sql sql = Sqls.create("""
SELECT
id,
loginname,
username,
unitid,
unitname
FROM
`user`
$condition
AND id not in (select userId from welfare_list where projectId = @projectId)
""").setParam("projectId", projectId);
Cnd cnd = Cnd.NEW();
SqlExpressionGroup seg = new SqlExpressionGroup();
seg.orLike("loginname", query);
seg.orLike("username", query);
cnd.and(seg);
sql.setCondition(cnd);
Pagination pagination = welfareListService.listPageMap(1, 10, sql);
return pagination;
}
@At
@ViReturn
@RequiresPermissions("welfare.list.mange")
@@ -682,4 +722,36 @@ public class WelfareListController {
}
return null;
}
@At
@ViReturn
@RequiresPermissions("welfare.list.mange")
public Object addWelfareList(@Param("projectId") String projectId, @Param("userIds") String[] userIds) {
List<String> userIdList = Arrays.stream(userIds).collect(Collectors.toList());
Sql sql = Sqls.create("select id,loginname,username,unionid,unitid,userState,personType from `user` where id in (@userIdList)")
.setParam("userIdList", userIdList);
sql.setCallback(Sqls.callback.maps());
dao.execute(sql);
List<NutMap> userInfoList = (List<NutMap>) sql.getResult();
List<WelfareList> welfareLists = userInfoList.stream().map(v -> {
WelfareList welfareList = new WelfareList();
welfareList.setId(R.UU32());
welfareList.setProjectId(projectId);
welfareList.setUserId(v.getString("id"));
welfareList.setWelfareUnitId(v.getString("unionid"));
welfareList.setWelfareSecondLevelUnitId(v.getString("unitid"));
welfareList.setIsReceive(null);
welfareList.setIsAutoSelect(null);
welfareList.setUserState(v.getString("userState"));
welfareList.setPersonType(v.getString("personType"));
return welfareList;
}).collect(Collectors.toList());
dao.fastInsert(welfareLists);
return null;
}
}
@@ -1,10 +1,13 @@
package io.v.nutz.zhgh.welfare.controller;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.service.SimpleService;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.web.commons.slog.annotation.SLog;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.welfare.model.WelfareList;
@@ -14,6 +17,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
@@ -27,6 +31,7 @@ import org.nutz.mvc.annotation.Param;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
/**
* @ClassName WelfareChooseController
@@ -39,12 +44,17 @@ import java.util.List;
@At("/platform/welfare/userChoose")
public class WelfareUserChooseController {
@Inject
private Dao dao;
@Inject
private SimpleService simpleService;
@Inject
private SysUserService sysUserService;
@Inject
private WelfareProjectService welfareProjectService;
private final ReentrantLock lock = new ReentrantLock(true);
@At("")
@Ok("beetl:/platform/welfare/userChoose.html")
@RequiresPermissions("welfare.user.choose")
@@ -94,30 +104,44 @@ public class WelfareUserChooseController {
@Aop(TransAop.READ_COMMITTED)
@SLog(type = "welfare", tag = "pc电脑选福利", msg = "福利")
@RequiresPermissions("welfare.user.choose")
public Object doChoose(String chooseIds, String projectId, String subjectId, String receiveAddress) {
//删除上次选择的
simpleService.dao().clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId)
.and("selectUserId", "=", ShiroUtil.getUserId()));
public Object doChoose(String chooseIds, String projectId, String subjectId, String receiveAddress,
@Param(value = "mobile",required = false) String mobile) {
try {
lock.lock();
String userId = ShiroUtil.getUserId();
//删除上次选择的
simpleService.dao().clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId)
.and("selectUserId", "=", userId));
List<WelfareUserSelection> insertList = new ArrayList<>();
List<String> ids = Json.fromJsonAsList(String.class, chooseIds);
ids.forEach(s -> {
WelfareUserSelection selection = new WelfareUserSelection();
selection.setWelfareId(projectId);
selection.setSubjectId(subjectId);
selection.setSelectUserId(ShiroUtil.getUserId());
selection.setSelectTime(new Date());
selection.setSelectOptionId(s);
selection.setReceiveAddress(receiveAddress);
insertList.add(selection);
});
simpleService.dao().insert(insertList);
simpleService.dao().update(WelfareList.class,
Chain.make("isReceive", true),
Cnd.where("projectId", "=", projectId)
.and("userId", "=", ShiroUtil.getUserId()));
return null;
List<WelfareUserSelection> insertList = new ArrayList<>();
List<String> ids = Json.fromJsonAsList(String.class, chooseIds);
ids.forEach(s -> {
WelfareUserSelection selection = new WelfareUserSelection();
selection.setWelfareId(projectId);
selection.setSubjectId(subjectId);
selection.setSelectUserId(userId);
selection.setSelectTime(new Date());
selection.setSelectOptionId(s);
selection.setReceiveAddress(receiveAddress);
insertList.add(selection);
});
simpleService.dao().insert(insertList);
simpleService.dao().update(WelfareList.class,
Chain.make("isReceive", true),
Cnd.where("projectId", "=", projectId)
.and("userId", "=", userId));
if (StrUtil.isNotBlank(mobile)) {
dao.update(Sys_user.class, Chain.make("mobile", mobile), Cnd.where("id", "=", userId));
}
return Result.success();
} catch (Exception e) {
e.printStackTrace();
return Result.error();
} finally {
lock.unlock();
}
}
@@ -127,31 +151,55 @@ public class WelfareUserChooseController {
@SLog(type = "welfare", tag = "选择福利", msg = "福利")
@RequiresPermissions("welfare.user.choose")
public Result confirmSelect(@Param("welfareUserSelections") WelfareUserSelection[] welfareUserSelections,
String projectId) {
String projectId, @Param(value = "mobile",required = false) String mobile) {
int count = simpleService.dao().count(WelfareList.class, Cnd.where("projectId", "=", projectId).and("userId", "=", ShiroUtil.getUserId()));
if (count == 0) {
return Result.error("您暂无权限!");
try {
lock.lock();
String userId = ShiroUtil.getUserId();
int count = simpleService.dao().count(WelfareList.class, Cnd.where("projectId", "=", projectId).and("userId", "=", userId));
if (count <= 0) {
return Result.error("您不在此次选择名单中,如有疑问请及时联系校工会");
}
//删除上次选择的
simpleService.dao().clear(WelfareUserSelection.class,
Cnd.where("welfareId", "=", projectId)
.and("selectUserId", "=", userId));
for (WelfareUserSelection welfareUserSelection : welfareUserSelections) {
welfareUserSelection.setSelectUserId(userId);
welfareUserSelection.setSelectTime(new Date());
}
simpleService.dao().insert(welfareUserSelections);
simpleService.dao().update(WelfareList.class,
Chain.make("isReceive", true),
Cnd.where("projectId", "=", projectId)
.and("userId", "=", userId));
if (StrUtil.isNotBlank(mobile)) {
dao.update(Sys_user.class, Chain.make("mobile", mobile), Cnd.where("id", "=", userId));
}
return Result.success("选择成功");
} catch (Exception e) {
e.printStackTrace();
return Result.error();
} finally {
lock.unlock();
}
//删除上次选择的
simpleService.dao().clear(WelfareUserSelection.class,
Cnd.where("welfareId", "=", projectId)
.and("selectUserId", "=", ShiroUtil.getUserId()));
for (WelfareUserSelection welfareUserSelection : welfareUserSelections) {
welfareUserSelection.setSelectUserId(ShiroUtil.getUserId());
welfareUserSelection.setSelectTime(new Date());
}
simpleService.dao().insert(welfareUserSelections);
simpleService.dao().update(WelfareList.class,
Chain.make("isReceive", true),
Cnd.where("projectId", "=", projectId)
.and("userId", "=", ShiroUtil.getUserId()));
return Result.success("选择成功");
}
@At
@ViReturn
@RequiresPermissions("welfare.user.choose")
public Object getUserMobile() {
Sql sql = Sqls.create("SELECT mobile FROM sys_user WHERE id = @userId").setParam("userId", ShiroUtil.getUserId());
sql.setCallback(Sqls.callback.str());
dao.execute(sql);
return sql.getResult();
}
}