diff --git a/src/main/java/com/budwk/app/sys/services/SysRoleService.java b/src/main/java/com/budwk/app/sys/services/SysRoleService.java index f8cb5d87..1c6d6ebb 100644 --- a/src/main/java/com/budwk/app/sys/services/SysRoleService.java +++ b/src/main/java/com/budwk/app/sys/services/SysRoleService.java @@ -121,6 +121,13 @@ public interface SysRoleService extends BaseService { */ Sys_role getByCode(RoleConstant roleConstant); + /** + * 通过枚举获取角色 + * @param roleConstantList + * @return + */ + List getRoleIdsByCode(List roleConstantList); + /** * 清空缓存 */ diff --git a/src/main/java/com/budwk/app/sys/services/impl/SysRoleServiceImpl.java b/src/main/java/com/budwk/app/sys/services/impl/SysRoleServiceImpl.java index 40153528..b33dc62e 100644 --- a/src/main/java/com/budwk/app/sys/services/impl/SysRoleServiceImpl.java +++ b/src/main/java/com/budwk/app/sys/services/impl/SysRoleServiceImpl.java @@ -257,6 +257,19 @@ public class SysRoleServiceImpl extends BaseServiceImpl implements Sys return role; } + @Override + public List getRoleIdsByCode(List roleList) { + if (roleList.isEmpty()){ + return List.of(); + } + List roles = query(Cnd.where("code", "in", roleList)); + if (ObjectUtil.isEmpty(roles)) { + throw new BaseException("没有找到code为{}的角色,请检查!!!", roles); + } + List roleIds = roles.stream().map(Sys_role::getId).toList(); + return roleIds; + } + @Override public Sys_role getByCode(RoleConstant roleConstant) { return getByCode(roleConstant.name()); diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/controller/OutlayManageClubBackHistoryController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/controller/OutlayManageClubBackHistoryController.java new file mode 100644 index 00000000..74fb04c1 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/controller/OutlayManageClubBackHistoryController.java @@ -0,0 +1,139 @@ +package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.club.controller; + +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.result.Result; +import com.budwk.app.base.utils.CommonDownloadUtil; +import com.budwk.app.zhgh.club.service.impl.SysClubUserServiceImpl; +import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service.OutlayManageClubQueryService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.Workbook; +import org.nutz.dao.sql.Sql; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.util.NutMap; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; + +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * @author zhf + * @date 2026/2/5 18:02 + * @description 历史拨付查询 + */ +@IocBean +@At("/platform/outlay/outlayManage/backHistory") +@Ok("json:full") +@Slf4j +@Api(tags = "协会经费查询") +public class OutlayManageClubBackHistoryController { + + + @Inject + private OutlayManageClubQueryService clubQueryService; + + @At("") + @Ok("beetl:/platform/zhgh/dayofficework/outlay/outlayManage/club/backHistory/index.html") + @SaCheckPermission("outlay.outlayManage.club.backHistory") + public void index() { + } + + + @At + @ApiOperation("分页查询") + @SaCheckPermission("outlay.outlayManage.club.backHistory") + public Result pageData(PageForm pageForm, Integer year, String clubId, String isGiveMoney, String payed) { + String type = "historyUserNum"; + if (StrUtil.isNotBlank(isGiveMoney)) { + type = "1".equals(isGiveMoney) ? "historyGiveMoneyNum" : "historyNotGiveMoneyNum"; + } + Sql sql = clubQueryService.backUserSql(pageForm, clubId, type, year, payed); + Pagination pagination = clubQueryService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + List listMap = pagination.getList(); + for (NutMap map : listMap) { + List roleCodeList = JSONUtil.toList(map.getString("roleCode"), String.class); + List cleanedCodes = roleCodeList.stream() + .filter(Objects::nonNull) + .map(String::strip) + .map(code -> code.startsWith("\"") && code.endsWith("\"") + ? code.substring(1, code.length() - 1) + : code) + .toList(); + String roleName = SysClubUserServiceImpl.convertRoleName(cleanedCodes); + map.put("roleName", roleName); + map.put("roleCode", cleanedCodes); + } + pagination.setList(listMap); + return Result.success(pagination); + } + + + @At + @Ok("void") + @SaCheckPermission("outlay.outlayManage.club.backHistory") + public void doExcel(PageForm pageForm, Integer year, String clubId, String isGiveMoney, String payed, HttpServletResponse response) { + + String type = "historyUserNum"; + if (StrUtil.isNotBlank(isGiveMoney)) { + type = "1".equals(isGiveMoney) ? "historyGiveMoneyNum" : "historyNotGiveMoneyNum"; + } + Sql sql = clubQueryService.backUserSql(pageForm, clubId, type, year, payed); + List listMap = clubQueryService.listMap(sql); + + for (NutMap map : listMap) { + List roleCodeList = JSONUtil.toList(map.getString("roleCode"), String.class); + List cleanedCodes = roleCodeList.stream() + .filter(Objects::nonNull) + .map(String::strip) + .map(code -> code.startsWith("\"") && code.endsWith("\"") + ? code.substring(1, code.length() - 1) + : code) + .toList(); + String roleName = SysClubUserServiceImpl.convertRoleName(cleanedCodes); + map.put("roleName", roleName); + map.put("roleCode", cleanedCodes); + map.put("isGiveMoney", map.getInt("isGiveMoney") == 1 ? "已拨付" : "未拨付"); + map.put("payed", map.getInt("payed") == 1 ? "已缴费" : "未缴费"); + } + + + List exportEntities = new ArrayList<>(); + ExcelExportEntity no = new ExcelExportEntity("序号", "no", 10); + no.setFormat("isAddIndex"); + exportEntities.add(no); + exportEntities.add(new ExcelExportEntity("工号", "loginname", 20)); + exportEntities.add(new ExcelExportEntity("姓名", "username", 20)); + exportEntities.add(new ExcelExportEntity("性别", "sex", 20)); + exportEntities.add(new ExcelExportEntity("加入时间", "applyDate2", 20)); + exportEntities.add(new ExcelExportEntity("在职状态", "userState", 20)); + exportEntities.add(new ExcelExportEntity("是否拨付", "isGiveMoney", 20)); + exportEntities.add(new ExcelExportEntity("是否缴费", "payed", 20)); + exportEntities.add(new ExcelExportEntity("所在协会", "clubName", 20)); + exportEntities.add(new ExcelExportEntity("身份", "roleName", 20)); + + try { + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + exportParams.setTitle("历史拨付汇总"); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, listMap); + CommonDownloadUtil.download(year + "历史拨付汇总.xlsx", workbook, response); + } catch (Exception e) { + e.printStackTrace(); + } + } + + +} diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/controller/OutlayManageClubController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/controller/OutlayManageClubController.java index 47f07551..6f106547 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/controller/OutlayManageClubController.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/controller/OutlayManageClubController.java @@ -12,8 +12,10 @@ import com.budwk.app.flow.enums.ProcessInstanceStateEnum; import com.budwk.app.sys.models.Sys_role; import com.budwk.app.sys.models.Sys_user_role; import com.budwk.app.sys.services.SysRoleService; +import com.budwk.app.sys.views.View_user; import com.budwk.app.web.commons.auth.utils.AuthUtil; import com.budwk.app.web.commons.auth.utils.SecurityUtil; +import com.budwk.app.zhgh.club.model.ClubUser; import com.budwk.app.zhgh.club.model.SysClub; import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.club.model.OutlayManageClub; import io.swagger.annotations.Api; @@ -31,6 +33,7 @@ import org.nutz.mvc.annotation.Ok; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * @author zhf @@ -41,7 +44,7 @@ import java.util.List; @At("/platform/outlay/outlayManage/clubManage") @Ok("json:full") @Slf4j -@Api(tags = "分工会经费预算管理") +@Api(tags = "协会经费预算管理") public class OutlayManageClubController { @Inject @@ -59,7 +62,7 @@ public class OutlayManageClubController { @At @ApiOperation("分页查询") @SaCheckPermission("outlay.outlayManage.club.manage") - public Result pageData(PageForm pageForm, Integer year) { + public Result pageData(PageForm pageForm, Integer year, String clubId) { Cnd cnd = Cnd.NEW(); Sql sql = Sqls.create(""" SELECT * FROM `outlay_manage_club` $condition @@ -71,6 +74,7 @@ public class OutlayManageClubController { List myClubId = userRoles.stream().map(Sys_user_role::getClubId).toList(); cnd.andEX("clubId", "in", myClubId); } + cnd.andEX("clubId", "=", clubId); cnd.asc("clubCode"); sql.setCondition(cnd); Pagination pagination = baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); @@ -112,48 +116,94 @@ public class OutlayManageClubController { @SaCheckPermission("outlay.outlayManage.club.manage") @SLog(tag = "协会预算分配", msg = "根据申报的金额修改本年的预算预算") public Result issuedOutlay() { - /* Sql sql = Sqls.create(""" + Sql sql = Sqls.create(""" SELECT - ab.clubId, - ab.totalBudgetMoney + c.*, + COALESCE(pay_stats.historyGiveMoneyNum, 0) AS historyGiveMoneyNum, + COALESCE(pay_stats.historyNotGiveMoneyNum, 0) AS historyNotGiveMoneyNum, + COALESCE(pay_stats.historyUserNum, 0) AS historyUserNum FROM - activity_budget ab - LEFT JOIN wf_process_instance wpi ON wpi.businessNo = ab.id + sys_club c + LEFT JOIN wf_process_instance inst ON inst.businessNo = c.id + LEFT JOIN ( + SELECT + cu.clubId, + COUNT(CASE WHEN re.isGiveMoney = 1 THEN 1 END) AS historyGiveMoneyNum, + COUNT(CASE WHEN re.isGiveMoney = 0 THEN 1 END) AS historyNotGiveMoneyNum, + COUNT(*) AS historyUserNum + FROM + club_user cu + INNER JOIN club_user_apply cua + ON cu.userId = cua.userId + AND cu.clubId = cua.clubId + LEFT JOIN club_pay_record re + ON re.userId = cu.userId + AND re.clubId = cu.clubId + AND re.year = @year + WHERE + YEAR(cua.applyDate) < @year + AND cua.`mode` = 1 + GROUP BY + cu.clubId + ) pay_stats ON pay_stats.clubId = c.id WHERE - YEAR(ab.applyDate) = @year - AND ab.outlayManageSource = 'ACTIVITY_BUDGET_TYPE_THREE' - AND ab.isSchoolBudget =0 - AND wpi.state = 20 + inst.state = 20; """).setParam("year", DateUtil.thisYear()); - List budgetList = baseService.listMap(sql); -*/ - Sql sqlClub = Sqls.create(""" - SELECT - c.* - FROM - `sys_club` c - LEFT JOIN wf_process_instance inst ON inst.businessNo = c.id - WHERE - inst.state = @state - """).setParam("state", ProcessInstanceStateEnum.FINISHED.getCode()); - List clubList = baseService.listVO(sqlClub, SysClub.class); + + List clubList = baseService.listMap(sql); List insertUnionList = new ArrayList<>(); clubList.forEach(v -> { - /* BigDecimal totalBudgetMoney = budgetList.stream() - .filter(budget -> budget.getString("clubId").equals(v.getId())) - .map(budget -> new BigDecimal(budget.getString("totalBudgetMoney"))) // 提取 money 属性 - .reduce(BigDecimal.ZERO, BigDecimal::add);*/ + OutlayManageClub outlayManageClub = new OutlayManageClub(); outlayManageClub.setYear(DateUtil.thisYear()); - outlayManageClub.setClubName(v.getClubName()); - outlayManageClub.setClubCode(v.getClubCode()); - outlayManageClub.setClubId(v.getId()); -// outlayManageClub.setTotalQuota(totalBudgetMoney); + outlayManageClub.setClubName(v.getString("clubName")); + outlayManageClub.setClubCode(v.getString("clubCode")); + outlayManageClub.setClubId(v.getString("id")); + outlayManageClub.setHistoryUserNum(v.getInt("historyUserNum")); + outlayManageClub.setHistoryNotGiveMoneyNum(v.getInt("historyNotGiveMoneyNum")); + outlayManageClub.setHistoryGiveMoneyNum(v.getInt("historyGiveMoneyNum")); + + BigDecimal totalBudgetMoney; + //如果人数超过50人就是5000,否则就是3000 + if (v.getInt("historyGiveMoneyNum") >= 50) { + totalBudgetMoney = BigDecimal.valueOf(5000); + } else { + totalBudgetMoney = BigDecimal.valueOf(3000); + } + if (v.getInt("historyGiveMoneyNum") == 0) { + totalBudgetMoney = BigDecimal.ZERO; + } + outlayManageClub.setTotalQuota(totalBudgetMoney); insertUnionList.add(outlayManageClub); }); baseService.insert(insertUnionList); return Result.success(); } + + @At + @ApiOperation("给没有核对的人发送核对提醒") + @SaCheckPermission("outlay.outlayManage.club.manage") + @SLog(tag = "协会预算分配", msg = "给没有核对的人发送核对提醒") + public Result doMsg() { + List manageClubList = baseService.dao().query(OutlayManageClub.class, + Cnd.where(OutlayManageClub::getYear, "=", DateUtil.thisYear()) + .and(OutlayManageClub::getIsCheck, "=", 0)); + for (OutlayManageClub club : manageClubList) { + + List roleIds = sysRoleService.getRoleIdsByCode(List.of(RoleConstant.CLUB_PRESIDENT, RoleConstant.CLUB_SECRETARY)); + + List sysUserRoles = baseService.dao().query(Sys_user_role.class, + Cnd.where(Sys_user_role::getClubId, "=", club.getClubId()) + .and(Sys_user_role::getRoleId, "in", roleIds)); + List clubUserIds = sysUserRoles.stream().map(Sys_user_role::getUserId).toList(); + if (!clubUserIds.isEmpty()){ + List users = baseService.dao().query(View_user.class, Cnd.where("id", "in", clubUserIds)); + } + } + + + return Result.success(); + } } diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/controller/OutlayManageClubQueryController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/controller/OutlayManageClubQueryController.java new file mode 100644 index 00000000..b45ab07f --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/controller/OutlayManageClubQueryController.java @@ -0,0 +1,227 @@ +package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.club.controller; + +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.date.DateUtil; +import cn.hutool.json.JSONUtil; +import com.budwk.app.base.annotation.SLog; +import com.budwk.app.base.constant.RoleConstant; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.result.Result; +import com.budwk.app.base.service.BaseService; +import com.budwk.app.base.utils.CommonDownloadUtil; +import com.budwk.app.base.utils.SysOfficeTemplateUtil; +import com.budwk.app.sys.models.Sys_role; +import com.budwk.app.sys.models.Sys_user_role; +import com.budwk.app.sys.services.SysRoleService; +import com.budwk.app.web.commons.auth.utils.AuthUtil; +import com.budwk.app.web.commons.auth.utils.SecurityUtil; +import com.budwk.app.web.commons.base.Globals; +import com.budwk.app.zhgh.club.model.SysClub; +import com.budwk.app.zhgh.club.service.impl.SysClubUserServiceImpl; +import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.club.model.OutlayManageClub; +import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service.OutlayManageClubQueryService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.Workbook; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Sql; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.util.NutMap; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; + +import javax.servlet.http.HttpServletResponse; +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.List; +import java.util.Objects; + +/** + * @author zhf + * @date 2026/2/5 09:44 + * @description 协会经费查询 + */ +@IocBean +@At("/platform/outlay/outlayManage/query") +@Ok("json:full") +@Slf4j +@Api(tags = "协会经费查询") +public class OutlayManageClubQueryController { + + @Inject + private OutlayManageClubQueryService clubQueryService; + + @Inject + private SysRoleService sysRoleService; + + @Inject + private SysOfficeTemplateUtil sysOfficeTemplateUtil; + + + @At("") + @Ok("beetl:/platform/zhgh/dayofficework/outlay/outlayManage/club/query/index.html") + @SaCheckPermission("outlay.outlayManage.club.query") + public void index() { + } + + @At + @ApiOperation("分页查询") + @SaCheckPermission("outlay.outlayManage.club.query") + public Result pageData(PageForm pageForm, Integer year, String clubId) { + Cnd cnd = Cnd.NEW(); + Sql sql = Sqls.create(""" + SELECT * FROM `outlay_manage_club` $condition + """); + cnd.andEX("year", "=", year); + if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) { + List roleIds = sysRoleService.getRoleIdsByCode(List.of(RoleConstant.CLUB_PRESIDENT, RoleConstant.CLUB_SECRETARY)); + List userRoles = clubQueryService.dao().query(Sys_user_role.class, + Cnd.where("userId", "=", SecurityUtil.getUserId()) + .and("roleId", "in", roleIds)); + List myClubId = userRoles.stream().map(Sys_user_role::getClubId).toList(); + cnd.andEX("clubId", "in", myClubId); + } + cnd.andEX("clubId", "=", clubId); + cnd.asc("clubCode"); + sql.setCondition(cnd); + Pagination pagination = clubQueryService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + return Result.success(pagination); + } + + + @At + @ApiOperation("提交核对") + @SaCheckPermission("outlay.outlayManage.club.query") + @SLog(tag = "协会经费查询", msg = "提交核对") + public Result doAudit(String id) { + clubQueryService.dao().update(OutlayManageClub.class, + Chain.make("isCheck", true), + Cnd.where(OutlayManageClub::getId, "=", id)); + + return Result.success(); + } + + @At + @ApiOperation("取消核对") + @SaCheckPermission("outlay.outlayManage.club.query") + @SLog(tag = "协会经费查询", msg = "取消核对") + public Result cancelAudit(String id) { + clubQueryService.dao().update(OutlayManageClub.class, + Chain.make("isCheck", false), + Cnd.where(OutlayManageClub::getId, "=", id)); + + return Result.success(); + } + + @At + @ApiOperation("更新拨付金额") + @SaCheckPermission("outlay.outlayManage.club.query") + @SLog(tag = "协会经费查询", msg = "更新拨付金额") + public Result doMoney(String clubId) { + clubQueryService.doMoney(clubId); + + return Result.success(); + } + + + @At + @ApiOperation("关闭开启核对") + @SaCheckPermission("outlay.outlayManage.club.query") + public Result closeAudit(Boolean flag) { + clubQueryService.dao().update(OutlayManageClub.class, + Chain.make("isDisable", flag), + Cnd.where(OutlayManageClub::getYear, "=", DateUtil.thisYear())); + return Result.success(); + } + + + /** + * 查询已拨付未拨付人员列表 + * + * @param pageForm + * @param clubId 社团id + * @param type historyUserNum 全部、historyGiveMoneyNum 已拨付、historyNotGiveMoneyNum 未拨付 + * @param year + * @return + */ + @At + @ApiOperation("查询已拨付未拨付人员列表") + @SaCheckPermission("outlay.outlayManage.club.query") + public Result backUserPageData(PageForm pageForm, String clubId, String type, Integer year) { + Sql sql = clubQueryService.backUserSql(pageForm, clubId, type, year, null); + Pagination pagination = clubQueryService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + List listMap = pagination.getList(); + for (NutMap map : listMap) { + List roleCodeList = JSONUtil.toList(map.getString("roleCode"), String.class); + List cleanedCodes = roleCodeList.stream() + .filter(Objects::nonNull) + .map(String::strip) + .map(code -> code.startsWith("\"") && code.endsWith("\"") + ? code.substring(1, code.length() - 1) + : code) + .toList(); + String roleName = SysClubUserServiceImpl.convertRoleName(cleanedCodes); + map.put("roleName", roleName); + map.put("roleCode", cleanedCodes); + } + pagination.setList(listMap); + return Result.success(pagination); + } + + + @At + @Ok("void") + @SaCheckPermission("outlay.outlayManage.club.query") + public void doExcel(PageForm pageForm, String clubId, Integer year, HttpServletResponse response) { + SysClub sysClub = clubQueryService.dao().fetch(SysClub.class, clubId); + Sql sql = clubQueryService.backUserSql(pageForm, clubId, "historyUserNum", year,null); + List listMap = clubQueryService.listMap(sql); + for (NutMap map : listMap) { + List roleCodeList = JSONUtil.toList(map.getString("roleCode"), String.class); + List cleanedCodes = roleCodeList.stream() + .filter(Objects::nonNull) + .map(String::strip) + .map(code -> code.startsWith("\"") && code.endsWith("\"") + ? code.substring(1, code.length() - 1) + : code) + .toList(); + String roleName = SysClubUserServiceImpl.convertRoleName(cleanedCodes); + map.put("roleName", roleName); + map.put("roleCode", cleanedCodes); + + map.put("iszz", List.of("在职", "在岗").contains(map.getString("userState")) ? "是" : "否"); + map.put("isGiveMoney", map.getBoolean("isGiveMoney") ? "已拨付" : "未拨付"); + } + for (int i = 0; i < listMap.size(); i++) { + listMap.get(i).put("index", (i + 1)); + } + int zzNum = listMap.stream().filter(map -> List.of("在职", "在岗").contains(map.getString("userState"))).toList().size(); + + NutMap map = new NutMap(); + map.put("schoolName", Globals.MyConfig.getString("schoolName")); + map.put("date", DateUtil.thisYear() - 1 + "年12月31日"); + map.put("year", DateUtil.thisYear() - 1); + map.put("totalNum", listMap.size()); + map.put("zzNum", zzNum); + map.put("clubName", sysClub.getClubName()); + map.put("maplist", listMap); + try { + InputStream is = sysOfficeTemplateUtil.getTemplate("jfClubUserBack"); + TemplateExportParams exportParams = new TemplateExportParams(is, null); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, map); + CommonDownloadUtil.download(Globals.MyConfig.getString("schoolName") + "教职工社团会员统计表.xlsx", workbook, response); + } catch (Exception e) { + log.error("导出Excel汇总表失败", e); + throw new RuntimeException("导出Excel汇总表失败:" + e.getMessage()); + } + } + + +} diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/model/OutlayClubUserBackHistory.java b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/model/OutlayClubUserBackHistory.java new file mode 100644 index 00000000..c7b7540c --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/model/OutlayClubUserBackHistory.java @@ -0,0 +1,75 @@ +package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.club.model; + +import com.budwk.app.base.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.nutz.dao.entity.annotation.*; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author zhf + * @date 2026/2/5 14:07 + * @description 历史经费拨付情况 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Table("outlay_club_user_back_history") +@TableMeta("{'mysql-charset':'utf8mb4'}") +@Comment("历史经费拨付情况") +public class OutlayClubUserBackHistory extends BaseModel implements Serializable { + + + @Column + @Name + @Comment("id") + @ColDefine(type = ColType.VARCHAR, width = 32) + @Prev(els = {@EL("uuid()")}) + private String id; + + @Column + @Comment("协会ID") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String clubId; + + @Column + @Comment("用户ID") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String userId; + + @Column + @Comment("身份") + @ColDefine(type = ColType.VARCHAR, width = 100) + private List roleCode = new ArrayList<>(); + private String roleCodeStr; + + @Column + @Comment("申请时间") + @ColDefine(type = ColType.DATETIME) + private Date applyDate; + + @Column + @Comment("是否缴费") + @ColDefine(type = ColType.BOOLEAN) + @Default(value = "0") + private Boolean payed; + + @Column + @Comment("是否拨付") + @ColDefine(type = ColType.BOOLEAN) + @Default(value = "0") + private Boolean isGiveMoney; + + @Column + @Comment("备份年度") + @ColDefine(type = ColType.INT) + private Integer historyYear; + + @Column + @Comment("在职状态") + @ColDefine(type = ColType.VARCHAR, width = 20) + private String userState; +} diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/model/OutlayManageClub.java b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/model/OutlayManageClub.java index e70d25e8..b914a648 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/model/OutlayManageClub.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/club/model/OutlayManageClub.java @@ -44,6 +44,30 @@ public class OutlayManageClub extends BaseModel implements Serializable { @ColDefine(customType = "decimal(10,2)") private BigDecimal usedQuota; + @Column + @Comment("人均额度") + @Default("0") + @ColDefine(customType = "decimal(10,2)") + private BigDecimal userAvgMoney; + + @Column + @Comment("上年度社团人数") + @Default("0") + @ColDefine(type = ColType.INT) + private Integer historyUserNum; + + @Column + @Comment("上年度拨付人数") + @Default("0") + @ColDefine(type = ColType.INT) + private Integer historyGiveMoneyNum; + + @Column + @Comment("上年度未拨付人数") + @Default("0") + @ColDefine(type = ColType.INT) + private Integer historyNotGiveMoneyNum; + @Column @Comment("协会ID") @ColDefine(type = ColType.VARCHAR, width = 32) @@ -59,4 +83,16 @@ public class OutlayManageClub extends BaseModel implements Serializable { @ColDefine(type = ColType.VARCHAR, width = 32) private String clubCode; + @Column + @Comment("是否核对") + @Default("0") + @ColDefine(type = ColType.BOOLEAN) + private Boolean isCheck; + + @Column + @Comment("是否关闭") + @Default("0") + @ColDefine(type = ColType.BOOLEAN) + private Boolean isDisable; + } diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/service/OutlayManageClubQueryService.java b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/service/OutlayManageClubQueryService.java new file mode 100644 index 00000000..16fb7c90 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/service/OutlayManageClubQueryService.java @@ -0,0 +1,13 @@ +package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service; + +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.service.BaseService; +import org.nutz.dao.sql.Sql; + +public interface OutlayManageClubQueryService extends BaseService { + + void doMoney(String clubId); + + Sql backUserSql(PageForm pageForm, String clubId, String type, Integer year, String payed); +} diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/service/impl/OutlayManageClubQueryServiceImpl.java b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/service/impl/OutlayManageClubQueryServiceImpl.java new file mode 100644 index 00000000..7265e29d --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/service/impl/OutlayManageClubQueryServiceImpl.java @@ -0,0 +1,191 @@ +package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.budwk.app.base.constant.RoleConstant; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.service.impl.BaseServiceImpl; +import com.budwk.app.zhgh.club.service.impl.SysClubUserServiceImpl; +import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.club.model.OutlayClubUserBackHistory; +import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.club.model.OutlayManageClub; +import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service.OutlayManageClubQueryService; +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.dao.util.cri.SqlExpressionGroup; +import org.nutz.ioc.aop.Aop; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.util.NutMap; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @author zhf + * @date 2026/2/5 14:13 + * @description + */ +@IocBean(args = {"refer:dao"}) +public class OutlayManageClubQueryServiceImpl extends BaseServiceImpl implements OutlayManageClubQueryService { + public OutlayManageClubQueryServiceImpl(Dao dao) { + super(dao); + } + + @Aop(TransAop.READ_COMMITTED) + @Override + public void doMoney(String clubId) { + Sql sql = Sqls.create(""" + SELECT + c.*, + COALESCE(pay_stats.historyGiveMoneyNum, 0) AS historyGiveMoneyNum, + COALESCE(pay_stats.historyNotGiveMoneyNum, 0) AS historyNotGiveMoneyNum, + COALESCE(pay_stats.historyUserNum, 0) AS historyUserNum + FROM + sys_club c + LEFT JOIN wf_process_instance inst ON inst.businessNo = c.id + LEFT JOIN ( + SELECT + cu.clubId, + COUNT(CASE WHEN re.isGiveMoney = 1 THEN 1 END) AS historyGiveMoneyNum, + COUNT(CASE WHEN re.isGiveMoney = 0 THEN 1 END) AS historyNotGiveMoneyNum, + COUNT(*) AS historyUserNum + FROM + club_user cu + INNER JOIN club_user_apply cua + ON cu.userId = cua.userId + AND cu.clubId = cua.clubId + LEFT JOIN club_pay_record re + ON re.userId = cu.userId + AND re.clubId = cu.clubId + AND re.year = @year + WHERE + YEAR(cua.applyDate) < @year + AND cua.`mode` = 1 + GROUP BY + cu.clubId + ) pay_stats ON pay_stats.clubId = c.id + WHERE + inst.state = 20 and c.id=@clubId + """).setParam("year", DateUtil.thisYear()) + .setParam("clubId", clubId); + + sql.setCallback(Sqls.callback.map()); + dao().execute(sql); + NutMap info = (NutMap) sql.getResult(); + BigDecimal totalBudgetMoney; + //如果人数超过50人就是5000,否则就是3000 + if (info.getInt("historyGiveMoneyNum") >= 50) { + totalBudgetMoney = BigDecimal.valueOf(5000); + } else { + totalBudgetMoney = BigDecimal.valueOf(3000); + } + if (info.getInt("historyGiveMoneyNum") == 0) { + totalBudgetMoney = BigDecimal.ZERO; + } + dao().update(OutlayManageClub.class, + Chain.make("historyGiveMoneyNum", info.getInt("historyGiveMoneyNum")) + .add("historyNotGiveMoneyNum", info.getInt("historyNotGiveMoneyNum")) + .add("historyUserNum", info.getInt("historyUserNum")) + .add("totalQuota", totalBudgetMoney), + Cnd.where(OutlayManageClub::getClubId, "=", clubId) + .and(OutlayManageClub::getYear, "=", DateUtil.thisYear())); + + + //备份历史表 + dao().clear(OutlayClubUserBackHistory.class, Cnd.where(OutlayClubUserBackHistory::getClubId, "=", clubId) + .and(OutlayClubUserBackHistory::getHistoryYear, "=", DateUtil.thisYear())); + + + Sql sql1 = Sqls.create(""" + SELECT + cu.*, + cu.roleCode roleCodeStr, + cua.applyDate, + re.isGiveMoney, + re.payed, + us.userState + FROM + club_user cu + LEFT JOIN sys_user us on cu.userId=us.id + LEFT JOIN club_user_apply cua ON cu.userId = cua.userId + AND cu.clubId = cua.clubId + LEFT JOIN club_pay_record re ON re.userId = cu.userId + AND re.clubId = cu.clubId + AND re.YEAR = @year + WHERE + YEAR(cua.applyDate) < @year + AND cua.`mode` = 1 and cu.clubId=@clubId + """).setParam("year", DateUtil.thisYear()).setParam("clubId", clubId); + List listMap = listVO(sql1, OutlayClubUserBackHistory.class); + listMap.forEach(v -> { + String roleCodeStr = v.getRoleCodeStr(); + v.setRoleCode(JSONUtil.toList(roleCodeStr, String.class)); + v.setHistoryYear(DateUtil.thisYear()); + }); + insert(listMap); + } + + @Override + public Sql backUserSql(PageForm pageForm, String clubId, String type, Integer year, String payed) { + Sql sql = Sqls.create(""" + SELECT + clubUser.*, + TIMESTAMPDIFF(YEAR, us.birthday, CURDATE()) AS age, + DATE_FORMAT(clubUser.applyDate, '%Y-%m-%d') applyDate2, + us.sex, + us.mobile, + us.unitName, + us.username, + us.loginname, + club.clubName + FROM + `outlay_club_user_back_history` clubUser + LEFT JOIN vw_user us ON us.id = clubUser.userId + LEFT JOIN sys_club club on club.id=clubUser.clubId + $condition + $order + """); + Cnd cnd = Cnd.NEW(); + if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) { + SqlExpressionGroup group = new SqlExpressionGroup(); + group.or("us.username", "like", "%" + pageForm.getSearchKeyword() + "%"); + group.or("us.loginname", "like", "%" + pageForm.getSearchKeyword() + "%"); + cnd.and(group); + } + cnd.andEX("clubUser.clubId", "=", clubId); + if (StrUtil.isNotBlank(payed)){ + cnd.and("clubUser.payed", "=", "1".equals(payed) ? 1 : 0); + } + cnd.and("clubUser.historyYear", "=", year); + if (!Objects.equals("historyUserNum", type)) { + cnd.and("clubUser.isGiveMoney", "=", Objects.equals("historyGiveMoneyNum", type) ? 1 : 0); + } + if (StrUtil.isAllNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) { + cnd.orderBy(pageForm.getPageOrderName(), "descending".equals(pageForm.getPageOrderBy()) ? "desc" : "asc"); + } else { + sql.setVar("order", """ + ORDER BY + CASE + WHEN JSON_CONTAINS(clubUser.roleCode, '"CLUB_PRESIDENT"') THEN 1 + WHEN JSON_CONTAINS(clubUser.roleCode, '"CLUB_VICE_PRESIDENT"') THEN 2 + WHEN JSON_CONTAINS(clubUser.roleCode, '"CLUB_SECRETARY"') THEN 3 + WHEN JSON_CONTAINS(clubUser.roleCode, '"CLUB_VICE_SECRETARY"') THEN 4 + WHEN JSON_CONTAINS(clubUser.roleCode, '"CLUB_OPERATOR"') THEN 5 + WHEN JSON_CONTAINS(clubUser.roleCode, '"CLUB_MEMBER"') THEN 6 + ELSE 99 + END + """); + } + sql.setCondition(cnd); + return sql; + } +} diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/union/controller/OutlayManageUnionAllocateController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/union/controller/OutlayManageUnionAllocateController.java new file mode 100644 index 00000000..520f6020 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/union/controller/OutlayManageUnionAllocateController.java @@ -0,0 +1,227 @@ +package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.budwk.app.base.annotation.SLog; +import com.budwk.app.base.page.Pagination; +import com.budwk.app.base.param.PageForm; +import com.budwk.app.base.result.Result; +import com.budwk.app.base.service.BaseService; +import com.budwk.app.sys.models.Sys_union; +import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.model.OutLayAllocateUnion; +import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.model.OutlayManageUnion; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.nutz.aop.interceptor.ioc.TransAop; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; +import org.nutz.dao.Sqls; +import org.nutz.dao.sql.Sql; +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.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * @author zhf + * @date 2026/2/3 11:12 + * @description 分工会经费分配 + */ +@IocBean +@At("/platform/outlay/outlayManage/unionAllocate") +@Ok("json:full") +@Slf4j +@Api(tags = "分工会经费分配") +public class OutlayManageUnionAllocateController { + + @Inject + private BaseService baseService; + + @At("") + @Ok("beetl:/platform/zhgh/dayofficework/outlay/outlayManage/union/allocate/index.html") + @SaCheckPermission("outlay.outlayManage.union.allocate") + public void index() { + } + + @At + @ApiOperation("分页查询") + @SaCheckPermission("outlay.outlayManage.union.allocate") + public Result pageData(PageForm pageForm, + Integer year, + Integer quarterly, + String unionId) { + Sql sql = Sqls.create(""" + SELECT + oau.*, + un.`name` unionName + FROM + `outlay_allocate_union` oau + LEFT JOIN sys_union un ON un.id = oau.unionId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("oau.year", "=", year); + cnd.andEX("oau.unionId", "=", unionId); + cnd.andEX("oau.quarterly", "=", quarterly); + cnd.and("oau.delFlag", "=", 0); + cnd.asc("un.unionCode"); + sql.setCondition(cnd); + Pagination pagination = baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + return Result.success(pagination); + } + + + @At + @ApiOperation("分配金额") + @Aop(TransAop.READ_COMMITTED) + @SaCheckPermission("outlay.outlayManage.union.allocate") + public Result doEdit(String id, String allocateMoney) { + if (StrUtil.isEmpty(allocateMoney) || StrUtil.isEmpty(id)) { + return Result.error("参数错误!"); + } + + + OutLayAllocateUnion allocateUnion = baseService.dao().fetch(OutLayAllocateUnion.class, id); + int quarter = DateUtil.month(DateUtil.date()) / 3 + 1; + if (allocateUnion.getQuarterly() < quarter) { + return Result.error("当前是第【" + quarter + "季度】无法修改【第" + allocateUnion.getQuarterly() + "季度】的额度!"); + } + + baseService.dao().update(OutLayAllocateUnion.class, Chain.make("allocateMoney", allocateMoney), + Cnd.where(OutLayAllocateUnion::getId, "=", id)); + + //找出今年工会的预算表 + OutlayManageUnion newOutlayManageUnion = baseService.dao().fetch(OutlayManageUnion.class, + Cnd.where(OutlayManageUnion::getUnionId, "=", allocateUnion.getUnionId()) + .and(OutlayManageUnion::getYear, "=", DateUtil.thisYear())); + + if (allocateUnion.getQuarterly() == 1) { + //如果是第一季度,添加年度预算表 + Sys_union union = baseService.dao().fetch(Sys_union.class, allocateUnion.getUnionId()); + //找出去年剩余的钱 + OutlayManageUnion oldOutlayManageUnion = baseService.dao().fetch(OutlayManageUnion.class, + Cnd.where(OutlayManageUnion::getUnionId, "=", allocateUnion.getUnionId()) + .and(OutlayManageUnion::getYear, "=", DateUtil.thisYear() - 1)); + + BigDecimal newTotalQuota = Lang.isNotEmpty(oldOutlayManageUnion) ? oldOutlayManageUnion.getTotalQuota().subtract(oldOutlayManageUnion.getUsedQuota()) : new BigDecimal(allocateMoney); + + if (Lang.isNotEmpty(newOutlayManageUnion)) { + //如果有今年的预算,代表第一季度已经分配过一次,现在修改 + newOutlayManageUnion.setTotalQuota(newTotalQuota); + baseService.update(newOutlayManageUnion); + } else { + OutlayManageUnion manageUnion = new OutlayManageUnion(); + manageUnion.setYear(DateUtil.thisYear()); + manageUnion.setUnionId(union.getId()); + manageUnion.setUnionName(union.getName()); + manageUnion.setUnionCode(union.getUnionCode()); + //找出去年剩余多少钱, + if (Lang.isNotEmpty(oldOutlayManageUnion)) { + BigDecimal surplusMoney = oldOutlayManageUnion.getTotalQuota().subtract(oldOutlayManageUnion.getUsedQuota()); + //去年剩余的钱加上当年的分配金额 + manageUnion.setTotalQuota(surplusMoney.add(new BigDecimal(allocateMoney))); + } else { + manageUnion.setTotalQuota(new BigDecimal(allocateMoney)); + } + manageUnion.setUsedQuota(BigDecimal.ZERO); + baseService.insert(manageUnion); + } + } else { + baseService.dao().update(OutlayManageUnion.class, + Chain.make("totalQuota", newOutlayManageUnion.getTotalQuota().add(new BigDecimal(allocateMoney))), + Cnd.where(OutlayManageUnion::getId, "=", newOutlayManageUnion.getId())); + } + return Result.success(); + } + + + @At + @ApiOperation("重置预算季度记录") + @SLog(tag = "分工会预算-季度预算分配", msg = "重置预算季度记录") + @SaCheckPermission("outlay.outlayManage.union.allocate") + public Result deleteAllocateRecord() { + int quarter = DateUtil.month(DateUtil.date()) / 3 + 1; + // 查询当前季度 + int count = baseService.dao().count(OutLayAllocateUnion.class, Cnd.where(OutLayAllocateUnion::getQuarterly, "=", quarter) + .and(OutLayAllocateUnion::getYear, "=", DateUtil.thisYear())); + if (count == 0) { + return Result.error("当前季度还未分配,无法重置!"); + } + + baseService.dao().update(OutLayAllocateUnion.class, Chain.make("delFlag", 1), + Cnd.where(OutLayAllocateUnion::getQuarterly, "=", quarter) + .and(OutLayAllocateUnion::getYear, "=", DateUtil.thisYear())); + return Result.success(); + } + + @At + @ApiOperation("预算季度记录生成") + @SLog(tag = "分工会预算-季度预算分配", msg = "生成了预算分配记录") + @SaCheckPermission("outlay.outlayManage.union.allocate") + public Result doAllocateRecord() { + int quarter = DateUtil.month(DateUtil.date()) / 3 + 1; + // 查询当前季度 + int count = baseService.dao().count(OutLayAllocateUnion.class, Cnd.where(OutLayAllocateUnion::getQuarterly, "=", quarter) + .and(OutLayAllocateUnion::getYear, "=", DateUtil.thisYear()) + .and(OutLayAllocateUnion::getDelFlag, "=", 0)); + if (count > 0) { + return Result.error("当前季度已分配,如需重新分配请点击重置分配记录!"); + } + + List outlayManageUnionList; + if (quarter == 1) { + //如果是第一季度,查询去年剩余额度 + outlayManageUnionList = baseService.dao().query(OutlayManageUnion.class, + Cnd.where(OutlayManageUnion::getYear, "=", DateUtil.thisYear() - 1)); + } else { + //非第一季度 + outlayManageUnionList = baseService.dao().query(OutlayManageUnion.class, + Cnd.where(OutlayManageUnion::getYear, "=", DateUtil.thisYear())); + } + List insertList = this.initOutLayAllocateUnion(outlayManageUnionList); + baseService.insert(insertList); + return Result.success(); + } + + + /** + * 初始化需要添加的数据 + * + * @param outlayManageUnionList + * @return + */ + public List initOutLayAllocateUnion(List outlayManageUnionList) { + int quarter = DateUtil.month(DateUtil.date()) / 3 + 1; + + List unionList = baseService.dao().query(Sys_union.class, Cnd.NEW()); + List insertList = new ArrayList<>(); + for (Sys_union union : unionList) { + OutLayAllocateUnion allocateUnion = new OutLayAllocateUnion(); + allocateUnion.setYear(DateUtil.thisYear()); + allocateUnion.setQuarterly(quarter); + allocateUnion.setUnionId(union.getId()); + allocateUnion.setAllocateMoney(BigDecimal.ZERO); + //根据院级工会ID查询 + OutlayManageUnion outlayManageUnion = outlayManageUnionList.stream().filter(o -> o.getUnionId().equals(union.getId())).findFirst().orElse(null); + if (Lang.isNotEmpty(outlayManageUnion)) { + BigDecimal surplusMoney = outlayManageUnion.getTotalQuota().subtract(outlayManageUnion.getUsedQuota()); + allocateUnion.setAllocateHeadMoney(surplusMoney); + } else { + allocateUnion.setAllocateHeadMoney(BigDecimal.ZERO); + } + insertList.add(allocateUnion); + + } + return insertList; + } + + +} diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/union/controller/OutlayManageUnionUseDetailController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/union/controller/OutlayManageUnionUseDetailController.java index f7baf7ef..13549253 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/union/controller/OutlayManageUnionUseDetailController.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/union/controller/OutlayManageUnionUseDetailController.java @@ -12,6 +12,7 @@ import com.budwk.app.web.commons.auth.utils.AuthUtil; import com.budwk.app.web.commons.auth.utils.SecurityUtil; import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.model.OutlayUseDetail; import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service.OutlayUseDetailService; +import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.model.OutLayAllocateUnion; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -26,6 +27,8 @@ import org.nutz.lang.Strings; import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; +import java.util.List; + /** * @author zhf * @date 2025/7/21 17:19 @@ -62,10 +65,8 @@ public class OutlayManageUnionUseDetailController { Cnd cnd = Cnd.NEW(); cnd.and("totalQuota", "IS NOT", null); cnd.and("year", "=", year); - - if (AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) { - cnd.andEX("unionId", "=", unionId); - } else { + cnd.andEX("unionId", "=", unionId); + if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) { cnd.and("unionId", "=", SecurityUtil.getUnionId()); } @@ -98,7 +99,7 @@ public class OutlayManageUnionUseDetailController { @SaCheckPermission("outlay.outlayManage.union.useDetail") @SLog(tag = "分工会预算使用详情", msg = "删除了分工会预算使用详情:${args[0]}") public Result doDeleteDetail(String id) { - outlayUseDetailService.doDeleteDetail(id,"union"); + outlayUseDetailService.doDeleteDetail(id, "union"); return Result.success(); } @@ -109,9 +110,19 @@ public class OutlayManageUnionUseDetailController { @SaCheckPermission("outlay.outlayManage.union.useDetail") @SLog(tag = "分工会预算使用详情", msg = "编辑了分工会预算使用详情:${args[0]}") public Result doEditDetail(OutlayUseDetail outlayUseDetail) { - outlayUseDetailService.doEditDetail(outlayUseDetail,"union"); + outlayUseDetailService.doEditDetail(outlayUseDetail, "union"); return Result.success(); } + @At + @ApiOperation("查询分工会今年每个季度的分配情况") + @SaCheckPermission("outlay.outlayManage.union.useDetail") + public Result queryQuarterlyList(Integer year, String unionId){ + List allocateUnionList = outlayUseDetailService.dao().query(OutLayAllocateUnion.class, + Cnd.where(OutLayAllocateUnion::getYear, "=", year).and(OutLayAllocateUnion::getUnionId, "=", unionId) + .asc(OutLayAllocateUnion::getQuarterly)); + return Result.success(allocateUnionList); + } + } diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/union/model/OutLayAllocateUnion.java b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/union/model/OutLayAllocateUnion.java new file mode 100644 index 00000000..532995ad --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/outlay/outlayManage/union/model/OutLayAllocateUnion.java @@ -0,0 +1,55 @@ +package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.model; + +import com.budwk.app.base.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.nutz.dao.entity.annotation.*; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author zhf + * @date 2026/2/3 14:31 + * @description + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Table("outlay_allocate_union") +@Comment("分工会经费管理") +public class OutLayAllocateUnion extends BaseModel implements Serializable { + + @Column + @Name + @Comment("id") + @ColDefine(type = ColType.VARCHAR, width = 32) + @Prev(els = {@EL("uuid()")}) + private String id; + + @Column + @Comment("年份") + @ColDefine(type = ColType.INT) + private Integer year; + + @Column + @Comment("分工会Id") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String unionId; + + @Column + @Comment("季度") + @ColDefine(type = ColType.INT) + private Integer quarterly; + + @Column + @Comment("分配前额度") + @ColDefine(customType = "decimal(10,2)") + private BigDecimal allocateHeadMoney; + + @Column + @Comment("分配额度") + @ColDefine(customType = "decimal(10,2)") + private BigDecimal allocateMoney; + + +} diff --git a/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/club/backHistory/index.html b/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/club/backHistory/index.html new file mode 100644 index 00000000..df0bc187 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/club/backHistory/index.html @@ -0,0 +1,127 @@ + + + +
+ + + +
+ + diff --git a/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/club/manage/index.html b/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/club/manage/index.html index 2ecdf529..78b8c5cc 100644 --- a/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/club/manage/index.html +++ b/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/club/manage/index.html @@ -20,15 +20,25 @@ layout("/layouts/platform.html"){ value-format="yyyy"> + + + + + + 短信通知会长 + @@ -88,7 +98,7 @@ layout("/layouts/platform.html"){ + + + diff --git a/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/union/allocate/index.html b/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/union/allocate/index.html new file mode 100644 index 00000000..cf4bea1f --- /dev/null +++ b/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/union/allocate/index.html @@ -0,0 +1,197 @@ + + +
+ + + +
+ + + + + diff --git a/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/union/useDetail/index.html b/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/union/useDetail/index.html index ca19718d..14eead87 100644 --- a/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/union/useDetail/index.html +++ b/src/main/resources/views/platform/zhgh/dayofficework/outlay/outlayManage/union/useDetail/index.html @@ -63,8 +63,10 @@ layout("/layouts/platform.html"){ + fixed="right" width="250"> @@ -74,13 +76,19 @@ layout("/layouts/platform.html"){ + +