This commit is contained in:
zhengziru
2025-05-09 10:06:26 +08:00
12 changed files with 961 additions and 539 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));
@@ -8,6 +8,7 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.export.ExcelExportService;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
@@ -43,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;
@@ -96,16 +98,18 @@ 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
CASE
WHEN
wus.selectUserId IS NOT NULL THEN
1 ELSE 0
END AS isChoose,
wl.id,
wl.unionid,
wl.username,
wl.loginname,
wl.personType,
@@ -115,8 +119,13 @@ public class WelfareListController {
wl.listId,
wus.userSign,
wus.courierNumber,
wus.receiveAddress,
GROUP_CONCAT( DISTINCT wuso.optionName, '(', wus.receiveAddress, ')' ) AS receiveAddress2,
GROUP_CONCAT(
DISTINCT
CONCAT(
wuso.optionName,
IF(wus.receiveAddress IS NOT NULL AND wus.receiveAddress != '', CONCAT('(', wus.receiveAddress, ')'), '')
)
) AS receiveAddress,
GROUP_CONCAT( DISTINCT wuso.optionName, '(', wus.selectNum, '份)' ) AS gist_list
FROM
view_welfare_list wl
@@ -134,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);
@@ -161,11 +178,15 @@ public class WelfareListController {
sql.setCondition(cnd);
Pagination pagination = welfareListService.list(pageForm, sql);
List<NutMap> mapList = pagination.getList();
if (provideMode != 3) {
mapList.forEach(v -> {
v.put("receiveAddress",v.getString("receiveAddress2"));
});
}
List<WelfareMemberUnionConfirm> confirms = projectService.dao().query(WelfareMemberUnionConfirm.class, Cnd.where("projectId", "=", projectId));
mapList.forEach(v -> {
if (StrUtil.isNotBlank(v.getString("unionid"))) {
WelfareMemberUnionConfirm confirm = confirms.stream().filter(o -> o.getUnionId().equals(v.getString("unionid"))).findFirst().orElse(null);
v.setv("isAudit", confirm != null ? confirm.getIsAudit() : "");
v.setv("auditTime", confirm != null ? confirm.getAuditTime() : "");
}
});
pagination.setList(mapList);
return pagination;
}
@@ -514,7 +535,7 @@ public class WelfareListController {
WHERE
wpus.welfareId = @welfareId
AND wpus.selectOptionId = @selectOptionId and wpus.selectNum!=0
""").setParam("welfareId", projectId).setParam("selectOptionId", optionId);
// GROUP BY wpus.selectUserId,wpus.selectOptionId ORDER BY un.unioncode
@@ -652,4 +673,85 @@ 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")
public Object doAuditUser(@Param(value = "projectId", required = false) String projectId,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "flag") Boolean flag) {
if (flag) {
welfareListService.dao().update(WelfareMemberUnionConfirm.class, Chain.make("isAudit", true)
.add("auditTime", DateUtil.date()).add("auditUser", ShiroUtil.getUserId()),
Cnd.where("projectId", "=", projectId).and("unionId", "=", unionId));
} else {
welfareListService.dao().update(WelfareMemberUnionConfirm.class, Chain.make("isAudit", null)
.add("auditTime", null).add("auditUser", null),
Cnd.where("projectId", "=", projectId).and("unionId", "=", unionId));
}
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;
}
}
@@ -9,15 +9,13 @@ import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.utils.MsgApi;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.sys.models.Sys_home_activity;
import io.v.nutz.sys.models.Sys_union;
import io.v.nutz.sys.services.SysTaskService;
import io.v.nutz.task.services.TaskPlatformService;
import io.v.nutz.zhgh.data.model.MatchConditionStructure;
import io.v.nutz.zhgh.data.service.MatchConditionStructureService;
import io.v.nutz.zhgh.mobileHome.service.MobileHomeService;
import io.v.nutz.zhgh.welfare.model.WelfareProject;
import io.v.nutz.zhgh.welfare.model.WelfareProjectSubject;
import io.v.nutz.zhgh.welfare.model.WelfareProjectSubjectOption;
import io.v.nutz.zhgh.welfare.model.WelfareUserSelection;
import io.v.nutz.zhgh.welfare.model.*;
import io.v.nutz.zhgh.welfare.service.WelfareListService;
import io.v.nutz.zhgh.welfare.service.WelfareProjectService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -39,6 +37,7 @@ import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.trans.Trans;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -237,6 +236,21 @@ public class WelfareProjectMangeController {
dao.update(project);
}
dao.clear(WelfareMemberUnionConfirm.class, Cnd.where("projectId","=",project.getId()));
List<Sys_union> unionList = dao.query(Sys_union.class, Cnd.NEW());
List<WelfareMemberUnionConfirm> confirmList = new ArrayList<>();
for (Sys_union union : unionList) {
WelfareMemberUnionConfirm confirm = new WelfareMemberUnionConfirm();
confirm.setId(R.UU32());
confirm.setProjectId(project.getId());
confirm.setUnionId(union.getId());
confirm.setIsAudit(false);
confirmList.add(confirm);
}
dao.fastInsert(confirmList);
Sys_home_activity sysHomeActivity = project.covertToSysHomeActivity();
sysHomeActivity.setEnable(true);
dao.insertOrUpdate(sysHomeActivity);
@@ -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,25 +151,55 @@ public class WelfareUserChooseController {
@SLog(type = "welfare", tag = "选择福利", msg = "福利")
@RequiresPermissions("welfare.user.choose")
public Result confirmSelect(@Param("welfareUserSelections") WelfareUserSelection[] welfareUserSelections,
String projectId) {
//删除上次选择的
simpleService.dao().clear(WelfareUserSelection.class,
Cnd.where("welfareId", "=", projectId)
.and("selectUserId", "=", ShiroUtil.getUserId()));
String projectId, @Param(value = "mobile",required = false) String mobile) {
for (WelfareUserSelection welfareUserSelection : welfareUserSelections) {
welfareUserSelection.setSelectUserId(ShiroUtil.getUserId());
welfareUserSelection.setSelectTime(new Date());
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().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();
}
}
@@ -0,0 +1,49 @@
package io.v.nutz.zhgh.welfare.model;
import io.v.nutz.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import java.util.Date;
@Data
@Table
@EqualsAndHashCode(callSuper = true)
public class WelfareMemberUnionConfirm extends BaseModel {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(uu32 = true)
private String id;
@Column
@Comment("所属项目")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String projectId;
@Column
@Comment("工会id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unionId;
@Column
@Comment("是否确认")
@ColDefine(type = ColType.BOOLEAN)
private Boolean isAudit;
@Column
@Comment("确认时间")
@ColDefine(type = ColType.DATETIME)
private Date auditTime;
@Column
@Comment("操作人")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String auditUser;
}
@@ -203,11 +203,14 @@ public class WelfareSingleServiceImpl extends ViServiceImpl<WelfareProject> impl
boolean isThreeUnit = Globals.MyConfig.getBoolean("isThreeUnit");
Sql welfareUnitSql = Sqls.create("""
SELECT
unit.*
unit.*,
wmuc.isAudit
FROM
welfare_unit unit
LEFT JOIN welfare_member_union_confirm wmuc ON wmuc.projectId = @projectId
AND wmuc.unionId = unit.welfareUnitId
$condition
""");
""").setParam("projectId", projectId);
CndPlus cnd = CndPlus.create();
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin,SchoolUnionWelfareAdmin")) {