This commit is contained in:
zhouhefeng
2026-04-27 08:39:59 +08:00
118 changed files with 2078 additions and 806 deletions
@@ -153,6 +153,7 @@ public class ActivitySportsApplyUserServiceImpl extends BaseServiceImpl<Activity
school.applyType,
school.image,
school.eventNotification,
school.activityGroupId,
(SELECT count( 1 ) FROM activity_school_apply app WHERE app.activityId = school.id AND app.`status` = 2 ) apply_num,
(SELECT count( 1 ) FROM activity_school_apply app WHERE app.activityId = school.id AND ( app.applyUser = @userid OR app.userId = @userid )) > 0 applyed,
(SELECT COUNT(1) FROM activity_school_apply app WHERE app.activityId=school.id AND app.unionId=@unionId AND app.unionLeader=TRUE) LeaderCount,
@@ -8,11 +8,9 @@ import com.budwk.app.base.service.BaseService;
import com.budwk.app.bpm.enums.BpmProcessInstanceStatusEnum;
import com.budwk.app.bpm.enums.BpmProcessTaskStatusEnum;
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.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.club.service.SysClubService;
import org.nutz.dao.Cnd;
@@ -38,8 +36,6 @@ public class ClubCommonController {
@Inject
private SysClubService sysClubService;
@Inject
private SysRoleService sysRoleService;
@At
@SaCheckLogin
@@ -62,9 +58,9 @@ public class ClubCommonController {
public Result listClubByRole() {
Cnd cnd = Cnd.NEW();
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
Sys_role sysRole = sysRoleService.getByCode(RoleConstant.CLUB_PRESIDENT);
List<Sys_user_role> userRoles = sysClubService.dao().query(Sys_user_role.class, Cnd.where("userId", "=", SecurityUtil.getUserId()).and("roleId", "=", sysRole.getId()));
List<String> myClubId = userRoles.stream().map(Sys_user_role::getClubId).toList();
// 报销申请只允许选择当前用户已加入的协会,避免看到未加入的协会数据。
List<ClubUser> clubUsers = sysClubService.dao().query(ClubUser.class, Cnd.where("userId", "=", SecurityUtil.getUserId()));
List<String> myClubId = clubUsers.stream().map(ClubUser::getClubId).distinct().toList();
cnd.and("c.id", "in", myClubId);
}
cnd.and("inst.state","=",ProcessInstanceStateEnum.FINISHED.getCode());
@@ -3,8 +3,12 @@ package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service;
import com.budwk.app.base.result.Result;
import com.budwk.app.base.service.BaseService;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.model.OutLayAllocateUnion;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.vo.OutlayUnionAllocateImportVo;
import org.apache.poi.ss.usermodel.Workbook;
import org.nutz.mvc.upload.TempFile;
import java.math.BigDecimal;
import java.util.List;
/**
* 分工会季度额度分配服务。
@@ -36,12 +40,63 @@ public interface OutlayManageUnionAllocateService extends BaseService<OutLayAllo
Result doBatchAllocate(BigDecimal allocateMoney, Integer quarterly, Integer year);
/**
* 重置当前季度的分配记录
* 判断某年某季度是否已经做过额度分配
*
* <p>重置时会先回滚 outlay_manage_union.totalQuota
* 再将当前季度的 outlay_allocate_union 记录标记删除。</p>
* <p>只要当前季度记录中存在分配额度大于 0 的有效记录
* 就认为该季度已经分配过额度,前端据此决定是否提示再次分配。</p>
*
* @param quarterly 要检查的季度,例如 1/2/3/4
* @param year 要检查的年份
* @return true 已分配过;false 未分配
*/
boolean hasAllocated(Integer quarterly, Integer year);
/**
* 解析导入文件并返回预览数据。
*
* @param file Excel 文件
* @return 解析后的预览数据
*/
List<OutlayUnionAllocateImportVo> readImportExcel(TempFile file);
/**
* 根据导入数据按分工会逐条分配季度额度。
*
* @param importList 导入预览数据
* @param quarterly 当前季度
* @param year 当前年度
* @return 导入分配结果
*/
Result doImportAllocate(List<OutlayUnionAllocateImportVo> importList, Integer quarterly, Integer year);
/**
* 导出分工会额度导入模板。
*
* @return 模板工作簿
*/
Workbook exportImportTemplate();
/**
* 重置指定年度季度的分配记录。
*
* <p>页面支持切换年度和季度,所以重置动作必须严格使用前端当前选择值,
* 不能再按系统当前自然季度处理,否则会出现页面筛选季度和实际重置季度不一致的问题。</p>
*
* @param quarterly 要重置的季度,例如 1/2/3/4
* @param year 要重置的年份
* @return Result 成功时返回 success;失败时返回错误信息
*/
Result deleteAllocateRecord();
Result deleteAllocateRecord(Integer quarterly, Integer year);
/**
* 按指定年度季度生成分工会预算记录。
*
* <p>生成前会先校验该年度季度是否已存在有效记录;
* 若已存在,则直接提示前端需要先重置后再重新生成。</p>
*
* @param quarterly 要生成的季度,例如 1/2/3/4
* @param year 要生成的年份
* @return Result 成功时返回 success;失败时返回错误信息
*/
Result doAllocateRecord(Integer quarterly, Integer year);
}
@@ -1,20 +1,36 @@
package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service.impl;
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.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.budwk.app.base.result.Result;
import com.budwk.app.base.service.impl.BaseServiceImpl;
import com.budwk.app.sys.models.Sys_union;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service.OutlayManageUnionAllocateService;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.model.OutLayAllocateUnion;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.model.OutlayManageUnion;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.vo.OutlayUnionAllocateImportVo;
import org.apache.poi.ss.usermodel.Workbook;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.mvc.upload.TempFile;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 分工会季度额度分配实现。
@@ -44,6 +60,10 @@ public class OutlayManageUnionAllocateServiceImpl extends BaseServiceImpl<OutLay
@Override
public Result doBatchAllocate(BigDecimal allocateMoney, Integer quarterly, Integer year) {
Result validateResult = validateCurrentQuarterOperation(quarterly);
if (validateResult != null) {
return validateResult;
}
List<OutLayAllocateUnion> allocateUnionList = dao().query(OutLayAllocateUnion.class,
Cnd.where(OutLayAllocateUnion::getQuarterly, "=", quarterly)
.and(OutLayAllocateUnion::getYear, "=", year)
@@ -58,11 +78,155 @@ public class OutlayManageUnionAllocateServiceImpl extends BaseServiceImpl<OutLay
}
@Override
public Result deleteAllocateRecord() {
int currentQuarter = getCurrentQuarter();
public boolean hasAllocated(Integer quarterly, Integer year) {
if (quarterly == null || year == null) {
return false;
}
int count = dao().count(OutLayAllocateUnion.class,
Cnd.where(OutLayAllocateUnion::getQuarterly, "=", quarterly)
.and(OutLayAllocateUnion::getYear, "=", year)
.and(OutLayAllocateUnion::getDelFlag, "=", false)
.and("allocateMoney", ">", BigDecimal.ZERO));
return count > 0;
}
@Override
public List<OutlayUnionAllocateImportVo> readImportExcel(TempFile file) {
String extName = FileUtil.extName(file.getFile());
if (!"xlsx".equalsIgnoreCase(extName) && !"xls".equalsIgnoreCase(extName)) {
throw Lang.makeThrow("请上传xlsx或xls格式文件");
}
List<OutlayUnionAllocateImportVo> importList = ExcelImportUtil.importExcel(file.getFile(),
OutlayUnionAllocateImportVo.class, new ImportParams());
List<Sys_union> unionList = dao().query(Sys_union.class, Cnd.NEW());
Map<String, Sys_union> unionMap = new HashMap<>();
for (Sys_union union : unionList) {
unionMap.put(union.getUnionCode(), union);
}
Set<String> duplicateUnionCodeSet = new LinkedHashSet<>();
Set<String> existUnionCodeSet = new LinkedHashSet<>();
for (OutlayUnionAllocateImportVo item : importList) {
if (StrUtil.isBlank(item.getUnionCode())) {
continue;
}
if (!existUnionCodeSet.add(item.getUnionCode())) {
duplicateUnionCodeSet.add(item.getUnionCode());
}
}
for (int i = 0; i < importList.size(); i++) {
OutlayUnionAllocateImportVo item = importList.get(i);
item.setRowNum(i + 2);
if (StrUtil.isBlank(item.getUnionCode())) {
item.setErrMsg("工会编码不能为空");
continue;
}
if (item.getAllocateMoney() == null) {
item.setErrMsg("分配额度不能为空");
continue;
}
if (item.getAllocateMoney().compareTo(BigDecimal.ZERO) < 0) {
item.setErrMsg("分配额度不能小于0");
continue;
}
Sys_union union = unionMap.get(item.getUnionCode());
if (Lang.isEmpty(union)) {
item.setErrMsg("工会编码不存在");
continue;
}
item.setUnionName(union.getName());
if (duplicateUnionCodeSet.contains(item.getUnionCode())) {
item.setErrMsg("工会编码重复");
}
}
return importList;
}
@Override
public Result doImportAllocate(List<OutlayUnionAllocateImportVo> importList, Integer quarterly, Integer year) {
Result validateResult = validateCurrentQuarterOperation(quarterly);
if (validateResult != null) {
return validateResult;
}
if (importList == null || importList.isEmpty()) {
return Result.error("请先上传导入数据");
}
List<OutLayAllocateUnion> allocateUnionList = dao().query(OutLayAllocateUnion.class,
Cnd.where(OutLayAllocateUnion::getQuarterly, "=", currentQuarter)
.and(OutLayAllocateUnion::getYear, "=", DateUtil.thisYear())
Cnd.where(OutLayAllocateUnion::getQuarterly, "=", quarterly)
.and(OutLayAllocateUnion::getYear, "=", year)
.and(OutLayAllocateUnion::getDelFlag, "=", false));
if (allocateUnionList == null || allocateUnionList.isEmpty()) {
return Result.error("当前季度没有分配记录!");
}
List<Sys_union> unionList = dao().query(Sys_union.class, Cnd.NEW());
Map<String, Sys_union> unionMap = new HashMap<>();
for (Sys_union union : unionList) {
unionMap.put(union.getUnionCode(), union);
}
Map<String, OutLayAllocateUnion> allocateUnionMap = new HashMap<>();
for (OutLayAllocateUnion allocateUnion : allocateUnionList) {
allocateUnionMap.put(allocateUnion.getUnionId(), allocateUnion);
}
List<String> errorList = new ArrayList<>();
for (OutlayUnionAllocateImportVo item : importList) {
if (StrUtil.isBlank(item.getUnionCode())) {
errorList.add("" + item.getRowNum() + "行:工会编码不能为空");
continue;
}
if (item.getAllocateMoney() == null) {
errorList.add("" + item.getRowNum() + "行:分配额度不能为空");
continue;
}
if (item.getAllocateMoney().compareTo(BigDecimal.ZERO) < 0) {
errorList.add("" + item.getRowNum() + "行:分配额度不能小于0");
continue;
}
if (StrUtil.isNotBlank(item.getErrMsg())) {
errorList.add("" + item.getRowNum() + "行:" + item.getErrMsg());
continue;
}
Sys_union union = unionMap.get(item.getUnionCode());
if (Lang.isEmpty(union)) {
errorList.add("" + item.getRowNum() + "行:工会编码不存在");
continue;
}
if (!allocateUnionMap.containsKey(union.getId())) {
errorList.add("" + item.getRowNum() + "行:当前季度未生成该分工会分配记录");
}
}
if (!errorList.isEmpty()) {
return Result.error(String.join("", errorList));
}
for (OutlayUnionAllocateImportVo item : importList) {
Sys_union union = unionMap.get(item.getUnionCode());
OutLayAllocateUnion allocateUnion = allocateUnionMap.get(union.getId());
// 导入分配与手工分配保持同一套金额同步规则,确保季度表和年度预算表数据一致。
applyAllocateMoney(allocateUnion, item.getAllocateMoney());
}
return Result.success("导入分配成功");
}
@Override
public Workbook exportImportTemplate() {
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("工会编码", "unionCode", 20));
entityList.add(new ExcelExportEntity("分配额度", "allocateMoney", 20));
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
return ExcelExportUtil.exportExcel(exportParams, entityList, new ArrayList<>());
}
@Override
public Result deleteAllocateRecord(Integer quarterly, Integer year) {
if (quarterly == null || year == null) {
return Result.error("参数错误!");
}
Result validateResult = validateCurrentQuarterOperation(quarterly);
if (validateResult != null) {
return validateResult;
}
List<OutLayAllocateUnion> allocateUnionList = dao().query(OutLayAllocateUnion.class,
Cnd.where(OutLayAllocateUnion::getQuarterly, "=", quarterly)
.and(OutLayAllocateUnion::getYear, "=", year)
.and(OutLayAllocateUnion::getDelFlag, "=", false));
if (allocateUnionList == null || allocateUnionList.isEmpty()) {
return Result.error("当前季度还未分配,无法重置!");
@@ -73,12 +237,38 @@ public class OutlayManageUnionAllocateServiceImpl extends BaseServiceImpl<OutLay
}
dao().update(OutLayAllocateUnion.class, Chain.make("delFlag", true),
Cnd.where(OutLayAllocateUnion::getQuarterly, "=", currentQuarter)
.and(OutLayAllocateUnion::getYear, "=", DateUtil.thisYear())
Cnd.where(OutLayAllocateUnion::getQuarterly, "=", quarterly)
.and(OutLayAllocateUnion::getYear, "=", year)
.and(OutLayAllocateUnion::getDelFlag, "=", false));
return Result.success();
}
@Override
public Result doAllocateRecord(Integer quarterly, Integer year) {
if (quarterly == null || year == null) {
return Result.error("参数错误!");
}
Result validateResult = validateCurrentQuarterOperation(quarterly);
if (validateResult != null) {
return validateResult;
}
int count = dao().count(OutLayAllocateUnion.class,
Cnd.where(OutLayAllocateUnion::getQuarterly, "=", quarterly)
.and(OutLayAllocateUnion::getYear, "=", year)
.and(OutLayAllocateUnion::getDelFlag, "=", false));
if (count > 0) {
return Result.error("当前季度已分配,如需重新分配请点击重置分配记录!");
}
// 第一季度需要承接上一年度剩余额度,其余季度承接当年预算额度,确保生成记录时的分配前额度准确。
Integer sourceYear = quarterly == 1 ? year - 1 : year;
List<OutlayManageUnion> outlayManageUnionList = dao().query(OutlayManageUnion.class,
Cnd.where(OutlayManageUnion::getYear, "=", sourceYear));
List<OutLayAllocateUnion> insertList = buildAllocateUnionList(outlayManageUnionList, quarterly, year);
insert(insertList);
return Result.success();
}
/**
* 按“先回退旧额度,再写入新额度”的方式同步季度记录和年度预算表。
*
@@ -89,7 +279,7 @@ public class OutlayManageUnionAllocateServiceImpl extends BaseServiceImpl<OutLay
BigDecimal oldAllocateMoney = defaultValue(allocateUnion.getAllocateMoney());
OutlayManageUnion manageUnion = dao().fetch(OutlayManageUnion.class,
Cnd.where(OutlayManageUnion::getUnionId, "=", allocateUnion.getUnionId())
.and(OutlayManageUnion::getYear, "=", DateUtil.thisYear()));
.and(OutlayManageUnion::getYear, "=", allocateUnion.getYear()));
if (Lang.isEmpty(manageUnion)) {
manageUnion = buildManageUnion(allocateUnion, newAllocateMoney);
@@ -115,7 +305,7 @@ public class OutlayManageUnionAllocateServiceImpl extends BaseServiceImpl<OutLay
private void rollbackAllocateMoney(OutLayAllocateUnion allocateUnion) {
OutlayManageUnion manageUnion = dao().fetch(OutlayManageUnion.class,
Cnd.where(OutlayManageUnion::getUnionId, "=", allocateUnion.getUnionId())
.and(OutlayManageUnion::getYear, "=", DateUtil.thisYear()));
.and(OutlayManageUnion::getYear, "=", allocateUnion.getYear()));
if (Lang.isEmpty(manageUnion)) {
return;
}
@@ -135,7 +325,7 @@ public class OutlayManageUnionAllocateServiceImpl extends BaseServiceImpl<OutLay
private OutlayManageUnion buildManageUnion(OutLayAllocateUnion allocateUnion, BigDecimal allocateMoney) {
Sys_union union = dao().fetch(Sys_union.class, allocateUnion.getUnionId());
OutlayManageUnion manageUnion = new OutlayManageUnion();
manageUnion.setYear(DateUtil.thisYear());
manageUnion.setYear(allocateUnion.getYear());
manageUnion.setUnionId(allocateUnion.getUnionId());
manageUnion.setTotalQuota(defaultValue(allocateUnion.getAllocateHeadMoney()).add(allocateMoney));
manageUnion.setUsedQuota(BigDecimal.ZERO);
@@ -164,4 +354,54 @@ public class OutlayManageUnionAllocateServiceImpl extends BaseServiceImpl<OutLay
private int getCurrentQuarter() {
return DateUtil.month(DateUtil.date()) / 3 + 1;
}
/**
* 预算季度记录相关操作只能针对当前自然季度执行。
*
* @param quarterly 前端传入的目标季度
* @return Result 不允许操作时返回错误结果;允许操作时返回 null
*/
private Result validateCurrentQuarterOperation(Integer quarterly) {
if (quarterly == null) {
return Result.error("参数错误!");
}
int currentQuarter = getCurrentQuarter();
if (!quarterly.equals(currentQuarter)) {
return Result.error("当前仅允许操作第" + currentQuarter + "季度数据,请切换后再操作!");
}
return null;
}
/**
* 按目标年度季度初始化要生成的分工会分配记录。
*
* @param outlayManageUnionList 用于计算“分配前额度”的年度预算数据
* @param quarterly 目标季度
* @param year 目标年度
* @return List<OutLayAllocateUnion> 待插入的季度分配记录
*/
private List<OutLayAllocateUnion> buildAllocateUnionList(List<OutlayManageUnion> outlayManageUnionList, Integer quarterly, Integer year) {
List<Sys_union> unionList = dao().query(Sys_union.class, Cnd.NEW());
List<OutLayAllocateUnion> insertList = new ArrayList<>();
for (Sys_union union : unionList) {
OutLayAllocateUnion allocateUnion = new OutLayAllocateUnion();
allocateUnion.setYear(year);
allocateUnion.setQuarterly(quarterly);
allocateUnion.setUnionId(union.getId());
allocateUnion.setAllocateMoney(BigDecimal.ZERO);
OutlayManageUnion outlayManageUnion = outlayManageUnionList.stream()
.filter(o -> o.getUnionId().equals(union.getId()))
.findFirst()
.orElse(null);
if (Lang.isNotEmpty(outlayManageUnion)) {
BigDecimal surplusMoney = defaultValue(outlayManageUnion.getTotalQuota())
.subtract(defaultValue(outlayManageUnion.getUsedQuota()));
allocateUnion.setAllocateHeadMoney(surplusMoney);
} else {
allocateUnion.setAllocateHeadMoney(BigDecimal.ZERO);
}
insertList.add(allocateUnion);
}
return insertList;
}
}
@@ -1,6 +1,7 @@
package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service.impl;
import com.budwk.app.base.service.impl.BaseServiceImpl;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.club.model.OutlayManageClub;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.model.OutlayUseDetail;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.school.model.OutlayManageSchool;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.service.OutlayUseDetailService;
@@ -21,49 +22,65 @@ public class OutlayUseDetailServiceImpl extends BaseServiceImpl<OutlayUseDetail>
@Override
public void doDeleteDetail(String id, String outlayType) {
//更新预算表的金额
updateOutlayManage(id, null,outlayType,false);
//更新完删除
// 先回滚对应预算的已使用额度,再删除详情记录。
updateOutlayManage(id, null, outlayType, false);
delete(id);
}
@Override
public void doEditDetail(OutlayUseDetail outlayUseDetail,String outlayType) {
updateOutlayManage(outlayUseDetail.getId(), outlayUseDetail,outlayType,true);
public void doEditDetail(OutlayUseDetail outlayUseDetail, String outlayType) {
// 编辑详情时需要先回退旧金额,再叠加新金额,保证预算台账准确。
updateOutlayManage(outlayUseDetail.getId(), outlayUseDetail, outlayType, true);
update(outlayUseDetail);
}
/**
* 更新预算表
* 同步预算主表的已使用额度,保证校工会、分工会、协会三类台账口径一致。
*
* @param id
* @param outlayType
* @param id 详情主键
* @param outlayUseDetail 编辑后的详情对象,删除场景可为空
* @param outlayType 预算类型:school/union/club
* @param isEdit 是否为编辑场景
*/
private void updateOutlayManage(String id, OutlayUseDetail outlayUseDetail,String outlayType,Boolean isEdit) {
//找到是哪一条的预算详情
private void updateOutlayManage(String id, OutlayUseDetail outlayUseDetail, String outlayType, Boolean isEdit) {
OutlayUseDetail detail = fetch(id);
//拿到预算详情的调整金额
if (outlayType.equals("school")) {
//找到预算分配的记录
if (detail == null) {
return;
}
if ("school".equals(outlayType)) {
OutlayManageSchool manageSchool = dao().fetch(OutlayManageSchool.class, detail.getOutlayManageId());
if (manageSchool == null) {
return;
}
manageSchool.setUsedQuota(manageSchool.getUsedQuota().subtract(detail.getAdjustMoney()));
if (isEdit){
//如果是修改,就先减去原来的值在加上现在新的值
if (Boolean.TRUE.equals(isEdit) && outlayUseDetail != null) {
manageSchool.setUsedQuota(manageSchool.getUsedQuota().add(outlayUseDetail.getAdjustMoney()));
}
update(manageSchool);
} else if (outlayType.equals("union")) {
return;
}
if ("union".equals(outlayType)) {
OutlayManageUnion manageUnion = dao().fetch(OutlayManageUnion.class, detail.getOutlayManageId());
if (manageUnion == null) {
return;
}
manageUnion.setUsedQuota(manageUnion.getUsedQuota().subtract(detail.getAdjustMoney()));
if (isEdit){
//如果是修改,就先减去原来的值在加上现在新的值
if (Boolean.TRUE.equals(isEdit) && outlayUseDetail != null) {
manageUnion.setUsedQuota(manageUnion.getUsedQuota().add(outlayUseDetail.getAdjustMoney()));
}
update(manageUnion);
return;
}
if ("club".equals(outlayType)) {
OutlayManageClub manageClub = dao().fetch(OutlayManageClub.class, detail.getOutlayManageId());
if (manageClub == null) {
return;
}
manageClub.setUsedQuota(manageClub.getUsedQuota().subtract(detail.getAdjustMoney()));
if (Boolean.TRUE.equals(isEdit) && outlayUseDetail != null) {
manageClub.setUsedQuota(manageClub.getUsedQuota().add(outlayUseDetail.getAdjustMoney()));
}
update(manageClub);
}
}
}
@@ -1,20 +1,19 @@
package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.controller;
import com.budwk.app.base.utils.CommonDownloadUtil;
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.service.OutlayManageUnionAllocateService;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.model.OutLayAllocateUnion;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.model.OutlayManageUnion;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.vo.OutlayUnionAllocateImportVo;
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.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
@@ -22,13 +21,18 @@ 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.json.Json;
import org.nutz.lang.Lang;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.upload.TempFile;
import org.nutz.mvc.upload.UploadAdaptor;
import org.nutz.mvc.annotation.AdaptBy;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
@@ -107,76 +111,82 @@ public class OutlayManageUnionAllocateController {
return outlayManageUnionAllocateService.doBatchAllocate(allocateMoney, quarterly, year);
}
@At
@ApiOperation("校验当前季度是否已分配额度")
@SaCheckPermission("outlay.outlayManage.union.allocate")
public Result hasAllocated(@Param("quarterly") Integer quarterly,
@Param("year") Integer year) {
if (quarterly == null || year == null) {
return Result.error("参数错误!");
}
return Result.success(outlayManageUnionAllocateService.hasAllocated(quarterly, year));
}
@At
@POST
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@ApiOperation("读取导入分配Excel")
@SaCheckPermission("outlay.outlayManage.union.allocate")
public Result readImportExcel(TempFile file) {
try {
return Result.success(outlayManageUnionAllocateService.readImportExcel(file));
} catch (Exception e) {
log.error("读取分工会额度导入文件失败", e);
return Result.error(e.getMessage());
}
}
@At
@ApiOperation("导入分配分工会额度")
@Aop(TransAop.READ_COMMITTED)
@SLog(tag = "分工会预算-季度预算分配", msg = "导入分配分工会额度")
@SaCheckPermission("outlay.outlayManage.union.allocate")
public Result doImportAllocate(String data,
@Param("quarterly") Integer quarterly,
@Param("year") Integer year) {
if (StrUtil.isBlank(data) || quarterly == null || year == null) {
return Result.error("参数错误!");
}
List<OutlayUnionAllocateImportVo> importList = Json.fromJsonAsList(OutlayUnionAllocateImportVo.class, data);
return outlayManageUnionAllocateService.doImportAllocate(importList, quarterly, year);
}
@At
@Ok("void")
@ApiOperation("下载导入分配模板")
@SaCheckPermission("outlay.outlayManage.union.allocate")
public void downloadImportTemplate(HttpServletResponse response) {
try {
Workbook workbook = outlayManageUnionAllocateService.exportImportTemplate();
CommonDownloadUtil.download("分工会额度导入模板.xlsx", workbook, response);
} catch (Exception e) {
log.error("下载分工会额度导入模板失败", e);
}
}
@At
@ApiOperation("重置预算季度记录")
@Aop(TransAop.READ_COMMITTED)
@SLog(tag = "分工会预算-季度预算分配", msg = "重置预算季度记录")
@SaCheckPermission("outlay.outlayManage.union.allocate")
public Result deleteAllocateRecord() {
return outlayManageUnionAllocateService.deleteAllocateRecord();
public Result deleteAllocateRecord(@Param("quarterly") Integer quarterly,
@Param("year") Integer year) {
if (quarterly == null || year == null) {
return Result.error("参数错误!");
}
return outlayManageUnionAllocateService.deleteAllocateRecord(quarterly, year);
}
@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("当前季度已分配,如需重新分配请点击重置分配记录!");
public Result doAllocateRecord(@Param("quarterly") Integer quarterly,
@Param("year") Integer year) {
if (quarterly == null || year == null) {
return Result.error("参数错误!");
}
List<OutlayManageUnion> 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<OutLayAllocateUnion> insertList = this.initOutLayAllocateUnion(outlayManageUnionList);
baseService.insert(insertList);
return Result.success();
return outlayManageUnionAllocateService.doAllocateRecord(quarterly, year);
}
/**
* 初始化需要添加的数据
*
* @param outlayManageUnionList
* @return
*/
public List<OutLayAllocateUnion> initOutLayAllocateUnion(List<OutlayManageUnion> outlayManageUnionList) {
int quarter = DateUtil.month(DateUtil.date()) / 3 + 1;
List<Sys_union> unionList = baseService.dao().query(Sys_union.class, Cnd.NEW());
List<OutLayAllocateUnion> 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;
}
}
@@ -0,0 +1,34 @@
package com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.math.BigDecimal;
/**
* 分工会季度额度导入行数据。
*/
@Data
public class OutlayUnionAllocateImportVo {
@Excel(name = "工会编码")
private String unionCode;
@Excel(name = "分配额度")
private BigDecimal allocateMoney;
/**
* 预览时展示匹配到的工会名称。
*/
private String unionName;
/**
* 预览时展示当前行错误信息。
*/
private String errMsg;
/**
* Excel 行号,便于用户定位问题数据。
*/
private Integer rowNum;
}
@@ -259,7 +259,14 @@ public class UnionReimburseApplyController {
return Result.success(value);
}
// 如果没有找到该社团的经费记录,返回0
return Result.success(0.0);
// 协会在年度预算分配之后才创建时,不会自动生成当年预算记录,这里给出明确提示。
return Result.error("该协会本年度未生成预算记录,请先在协会预算分配中补分配");
}
@At
@ApiOperation("统一查询经费余额")
@SaCheckPermission(value = {"unionReimburse.apply", "h5.unionReimburse.apply"}, mode = SaMode.OR)
public Result getBudgetBalance(String reimburseFundSource, String clubId) {
return unionReimburseService.getBudgetBalance(reimburseFundSource, clubId);
}
}
@@ -15,7 +15,6 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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;
@@ -27,18 +26,15 @@ import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Date;
import java.util.List;
@IocBean
@At("/platform/unionReimburse/review")
@Ok("json:full")
@Api("审核报销")
@Api("工会报销审核")
@Slf4j
public class UnionReimburseReviewController {
@Inject
private Dao dao;
@Inject
private UnionReimburseService unionReimburseService;
@@ -98,42 +94,34 @@ public class UnionReimburseReviewController {
}
@At
@ApiOperation("审核")
@ApiOperation("审核报销")
@Aop(TransAop.READ_COMMITTED)
@SaCheckPermission(value = {"unionReimburse.review", "h5.unionReimburse.review"}, mode = SaMode.OR)
@SLog(tag = "审核工会报销", msg = "审核工会报销")
@SLog(tag = "工会报销审核", msg = "审核工会报销")
public Result reviewTask(@Param("data") UnionReimburse unionReimburse, String submitType) {
if (submitType == null || !List.of("3", "4", "5").contains(submitType)) {
return Result.error("无效的审核操作类型");
}
UnionReimburse dbRecord = dao.fetch(UnionReimburse.class, unionReimburse.getId());
if (dbRecord == null) {
return Result.error("记录不存在");
}
dbRecord.setReviewTime(new Date());
dbRecord.setStateId(Integer.parseInt(submitType));
dbRecord.setReviewOpinion(unionReimburse.getReviewOpinion());
dao.update(dbRecord);
return Result.success();
return unionReimburseService.reviewApply(unionReimburse.getId(), unionReimburse.getReviewOpinion(), Integer.parseInt(submitType));
}
@At
@ApiOperation("一键审核")
@Aop(TransAop.READ_COMMITTED)
@SaCheckPermission(value = {"unionReimburse.review", "h5.unionReimburse.review"}, mode = SaMode.OR)
@SLog(tag = "一键审核", msg = "一键审核")
@SLog(tag = "工会报销审核", msg = "一键审核工会报销")
public Result allReview() {
try {
List<UnionReimburse> reimbursements = unionReimburseService.query(Cnd.where("stateId", "=", 2));
for (UnionReimburse reimbursement : reimbursements) {
reimbursement.setStateId(3);
reimbursement.setReviewTime(new Date());
reimbursement.setReviewOpinion("通过");
dao.update(reimbursement);
Result result = unionReimburseService.reviewApply(reimbursement.getId(), "通过", 3);
if (result.getCode() != 0) {
return result;
}
}
return Result.success("一键审核完成,共处理 " + reimbursements.size() + " 条记录");
return Result.success("一键审核完成,共处理" + reimbursements.size() + "条记录");
} catch (Exception e) {
log.error("一键审核失败");
log.error("一键审核失败", e);
return Result.error("一键审核失败: " + e.getMessage());
}
}
@@ -1,7 +1,7 @@
package com.budwk.app.zhgh.dayofficework.unionReimburse.service;
import com.budwk.app.base.service.BaseService;
import com.budwk.app.base.result.Result;
import com.budwk.app.base.service.BaseService;
import com.budwk.app.zhgh.dayofficework.unionReimburse.model.UnionReimburse;
import com.budwk.app.zhgh.dayofficework.unionReimburse.param.UnionReimbursePageForm;
import com.budwk.app.zhgh.dayofficework.unionReimburse.vo.UnionReimburseBankHistoryVO;
@@ -9,7 +9,7 @@ import org.nutz.dao.sql.Sql;
import java.util.List;
public interface UnionReimburseService extends BaseService<UnionReimburse> {
public interface UnionReimburseService extends BaseService<UnionReimburse> {
Sql getSql(UnionReimbursePageForm pageForm);
@@ -19,7 +19,7 @@ public interface UnionReimburseService extends BaseService<UnionReimburse> {
Result saveApply(UnionReimburse unionReimburse, int stateId);
/**
* 查询申请表单详情,补齐发票明细回显数据。
* 查询申请表单详情,补齐发票明细回显数据。
*/
UnionReimburse getApplyForm(String id);
@@ -34,8 +34,17 @@ public interface UnionReimburseService extends BaseService<UnionReimburse> {
Result checkInvoiceDuplicate(String invoiceNo, String reimburseId);
/**
* 识别单张发票文件,并在需要时调用腾讯云验真接口补齐票面信息。
* 识别单张发票文件,并在需要时调用验真接口补齐票面信息。
*/
Result recognizeInvoice(String fileId, Boolean verifySwitch);
/**
* 查询报销可用经费余额,同时校验是否已分配以及协会归属权限。
*/
Result getBudgetBalance(String reimburseFundSource, String clubId);
/**
* 审核报销,审核通过时扣减对应预算并新增预算使用详情。
*/
Result reviewApply(String reimburseId, String reviewOpinion, int submitType);
}
@@ -8,6 +8,11 @@ import com.budwk.app.base.result.Result;
import com.budwk.app.base.service.impl.BaseServiceImpl;
import com.budwk.app.sys.models.Sys_file;
import com.budwk.app.sys.services.SysFileService;
import com.budwk.app.zhgh.club.model.ClubUser;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.club.model.OutlayManageClub;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.model.OutlayUseDetail;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.school.model.OutlayManageSchool;
import com.budwk.app.zhgh.dayofficework.outlay.outlayManage.union.model.OutlayManageUnion;
import com.budwk.app.zhgh.dayofficework.unionReimburse.model.UnionReimburse;
import com.budwk.app.zhgh.dayofficework.unionReimburse.model.UnionReimburseInvoiceDetail;
import com.budwk.app.zhgh.dayofficework.unionReimburse.param.UnionReimbursePageForm;
@@ -123,6 +128,10 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
if (validateResult != null) {
return validateResult;
}
Result fundValidateResult = validateFundSourceBeforeSubmit(unionReimburse);
if (fundValidateResult != null) {
return fundValidateResult;
}
Result duplicateResult = validateInvoiceDuplicate(unionReimburse);
if (duplicateResult != null) {
return duplicateResult;
@@ -232,8 +241,80 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
}
/**
* 统一规整发票明细中的文本和金额,避免空格、空数组等脏数据进入库表
* 按经费来源统一查询当前可用余额,未分配或权限不匹配时直接拦截
*/
@Override
public Result getBudgetBalance(String reimburseFundSource, String clubId) {
if (StrUtil.isBlank(reimburseFundSource)) {
return Result.error("请选择经费来源");
}
if ("UNION_REIMBURSE_FUND_SOURCE_1".equals(reimburseFundSource)) {
OutlayManageSchool outlayManageSchool = dao().fetch(OutlayManageSchool.class,
Cnd.where("year", "=", DateUtil.thisYear()));
if (outlayManageSchool == null) {
return Result.error("校工会经费未分配");
}
return Result.success(formatMoney(outlayManageSchool.getTotalQuota().subtract(outlayManageSchool.getUsedQuota())));
}
if ("UNION_REIMBURSE_FUND_SOURCE_2".equals(reimburseFundSource)) {
OutlayManageUnion outlayManageUnion = dao().fetch(OutlayManageUnion.class,
Cnd.where("unionId", "=", SecurityUtil.getUnionId()).and("year", "=", DateUtil.thisYear()));
if (outlayManageUnion == null) {
return Result.error("分工会经费未分配");
}
return Result.success(formatMoney(outlayManageUnion.getTotalQuota().subtract(outlayManageUnion.getUsedQuota())));
}
if ("UNION_REIMBURSE_FUND_SOURCE_3".equals(reimburseFundSource)) {
if (StrUtil.isBlank(clubId)) {
return Result.error("请选择协会");
}
List<String> myClubIds = getCurrentUserClubIds();
if (!isAdmin() && !myClubIds.contains(clubId)) {
return Result.error("当前用户无权使用该协会经费");
}
OutlayManageClub outlayManageClub = dao().fetch(OutlayManageClub.class,
Cnd.where("clubId", "=", clubId).and("year", "=", DateUtil.thisYear()));
if (outlayManageClub == null) {
return Result.error("该协会本年度未生成预算记录,请先在协会预算分配中补分配");
}
return Result.success(formatMoney(outlayManageClub.getTotalQuota().subtract(outlayManageClub.getUsedQuota())));
}
return Result.error("不支持的经费来源");
}
/**
* 审核通过时统一校验余额、扣减预算并写入预算使用详情,避免控制器分散业务逻辑。
*/
@Override
public Result reviewApply(String reimburseId, String reviewOpinion, int submitType) {
if (!List.of(3, 4, 5).contains(submitType)) {
return Result.error("无效的审核操作类型");
}
UnionReimburse dbRecord = this.fetch(reimburseId);
if (dbRecord == null) {
return Result.error("记录不存在");
}
if (submitType == 3) {
// 已通过的单据再次触发通过时直接返回,避免重复扣减预算。
if (Integer.valueOf(3).equals(dbRecord.getStateId())) {
return Result.success();
}
Result validateResult = validateFundSourceBeforeSubmit(dbRecord);
if (validateResult != null) {
return validateResult;
}
Result deductResult = deductBudgetAndSaveUseDetail(dbRecord);
if (deductResult != null && deductResult.getCode() != 0) {
return deductResult;
}
}
dbRecord.setReviewTime(new Date());
dbRecord.setStateId(submitType);
dbRecord.setReviewOpinion(reviewOpinion);
dao().update(dbRecord);
return Result.success();
}
private void normalizeInvoiceDetails(UnionReimburse unionReimburse) {
if (unionReimburse.getInvoiceDetails() == null) {
unionReimburse.setInvoiceDetails(new ArrayList<>());
@@ -289,15 +370,15 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
if (!isValidContact(unionReimburse.getMobile())) {
return Result.error("请输入正确的联系方式");
}
if (StrUtil.isBlank(unionReimburse.getBankUserName())) {
return Result.error("请填写户名");
}
if (StrUtil.isBlank(unionReimburse.getBankCardNumber())) {
return Result.error("请填写银行账号");
}
if (StrUtil.isBlank(unionReimburse.getBankOfDeposit())) {
return Result.error("请填写开户行");
}
// if (StrUtil.isBlank(unionReimburse.getBankUserName())) {
// return Result.error("请填写户名");
// }
// if (StrUtil.isBlank(unionReimburse.getBankCardNumber())) {
// return Result.error("请填写银行账号");
// }
// if (StrUtil.isBlank(unionReimburse.getBankOfDeposit())) {
// return Result.error("请填写开户行");
// }
if (StrUtil.isBlank(unionReimburse.getPaymentNotes())) {
return Result.error("请填写支付内容");
}
@@ -342,8 +423,159 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
}
/**
* 同次提交和历史记录都要拦截重复发票,避免重复报销
* 提交和审核前统一校验预算是否已分配、余额是否充足
*/
private Result validateFundSourceBeforeSubmit(UnionReimburse unionReimburse) {
Result balanceResult = getBudgetBalance(unionReimburse.getReimburseFundSource(), unionReimburse.getClubId());
if (balanceResult == null || balanceResult.getCode() != 0) {
return balanceResult == null ? Result.error("经费余额校验失败") : balanceResult;
}
BigDecimal applyMoney = getApplyMoney(unionReimburse);
if (applyMoney.compareTo(BigDecimal.ZERO) <= 0) {
return Result.error("报销金额必须大于0");
}
BigDecimal balance = new BigDecimal(String.valueOf(balanceResult.getData()));
if (balance.compareTo(applyMoney) < 0) {
return Result.error("经费余额不足,当前余额:" + formatMoney(balance));
}
unionReimburse.setFundBalance(balance.doubleValue());
return null;
}
/**
* 审核通过后按经费来源扣减预算,并补写预算使用详情,便于后续台账追踪。
*/
private Result deductBudgetAndSaveUseDetail(UnionReimburse unionReimburse) {
BigDecimal applyMoney = getApplyMoney(unionReimburse);
String reimburseFundSource = unionReimburse.getReimburseFundSource();
if ("UNION_REIMBURSE_FUND_SOURCE_1".equals(reimburseFundSource)) {
OutlayManageSchool outlayManageSchool = dao().fetch(OutlayManageSchool.class,
Cnd.where("year", "=", DateUtil.thisYear()));
if (outlayManageSchool == null) {
return Result.error("校工会经费未分配");
}
if (outlayManageSchool.getTotalQuota().subtract(outlayManageSchool.getUsedQuota()).compareTo(applyMoney) < 0) {
return Result.error("校工会经费余额不足");
}
outlayManageSchool.setUsedQuota(outlayManageSchool.getUsedQuota().add(applyMoney));
dao().updateIgnoreNull(outlayManageSchool);
insertUseDetail(unionReimburse, outlayManageSchool.getId(), applyMoney);
return Result.success();
}
if ("UNION_REIMBURSE_FUND_SOURCE_2".equals(reimburseFundSource)) {
OutlayManageUnion outlayManageUnion = dao().fetch(OutlayManageUnion.class,
Cnd.where("unionId", "=", unionReimburse.getUnionId()).and("year", "=", DateUtil.thisYear()));
if (outlayManageUnion == null) {
return Result.error("分工会经费未分配");
}
if (outlayManageUnion.getTotalQuota().subtract(outlayManageUnion.getUsedQuota()).compareTo(applyMoney) < 0) {
return Result.error("分工会经费余额不足");
}
outlayManageUnion.setUsedQuota(outlayManageUnion.getUsedQuota().add(applyMoney));
dao().updateIgnoreNull(outlayManageUnion);
insertUseDetail(unionReimburse, outlayManageUnion.getId(), applyMoney);
return Result.success();
}
if ("UNION_REIMBURSE_FUND_SOURCE_3".equals(reimburseFundSource)) {
OutlayManageClub outlayManageClub = dao().fetch(OutlayManageClub.class,
Cnd.where("clubId", "=", unionReimburse.getClubId()).and("year", "=", DateUtil.thisYear()));
if (outlayManageClub == null) {
return Result.error("该协会本年度未生成预算记录,请先在协会预算分配中补分配");
}
if (outlayManageClub.getTotalQuota().subtract(outlayManageClub.getUsedQuota()).compareTo(applyMoney) < 0) {
return Result.error("协会经费余额不足");
}
outlayManageClub.setUsedQuota(outlayManageClub.getUsedQuota().add(applyMoney));
dao().updateIgnoreNull(outlayManageClub);
insertUseDetail(unionReimburse, outlayManageClub.getId(), applyMoney);
return Result.success();
}
return Result.error("不支持的经费来源");
}
/**
* 一张报销单只写入一条预算使用详情,避免重复通过或重复点击造成重复明细。
*/
private void insertUseDetail(UnionReimburse unionReimburse, String outlayManageId, BigDecimal applyMoney) {
OutlayUseDetail oldDetail = dao().fetch(OutlayUseDetail.class, Cnd.where("outlayReimburseId", "=", unionReimburse.getId()));
if (oldDetail != null) {
return;
}
OutlayUseDetail detail = new OutlayUseDetail();
detail.setOutlayManageId(outlayManageId);
detail.setOutlayReimburseId(unionReimburse.getId());
detail.setAdjustMoney(applyMoney);
detail.setAdjustReason(StrUtil.blankToDefault(unionReimburse.getPaymentNotes(), getReimburseProjectName(unionReimburse.getReimburseProject())));
detail.setAdjustUserId(SecurityUtil.getUserId());
detail.setAdjustUserName(SecurityUtil.getUserUsername());
detail.setAdjustLoginName(SecurityUtil.getUserLoginname());
detail.setProjectName(buildUseDetailProjectName(unionReimburse));
detail.setActivityNumber(unionReimburse.getActivityNumber());
detail.setActivityTime(buildUseDetailTime(unionReimburse));
dao().insert(detail);
}
private BigDecimal getApplyMoney(UnionReimburse unionReimburse) {
Double money = "UNION_REIMBURSE_PROJECT_1".equals(unionReimburse.getReimburseProject())
? unionReimburse.getCondolenceMoney() : unionReimburse.getMoney();
return BigDecimal.valueOf(money == null ? 0D : money).setScale(2, RoundingMode.HALF_UP);
}
private String buildUseDetailProjectName(UnionReimburse unionReimburse) {
if (StrUtil.isNotBlank(unionReimburse.getActivityName())) {
return unionReimburse.getActivityName();
}
if (StrUtil.isNotBlank(unionReimburse.getCondolenceUserName())) {
return getReimburseProjectName(unionReimburse.getReimburseProject()) + "-" + unionReimburse.getCondolenceUserName();
}
return StrUtil.blankToDefault(unionReimburse.getDocumentNo(), getReimburseProjectName(unionReimburse.getReimburseProject()));
}
private String buildUseDetailTime(UnionReimburse unionReimburse) {
if (unionReimburse.getActivityTime() != null) {
return DateUtil.formatDate(unionReimburse.getActivityTime());
}
if (unionReimburse.getCondolenceTime() != null) {
return DateUtil.formatDate(unionReimburse.getCondolenceTime());
}
if (unionReimburse.getCreateTime() != null) {
return DateUtil.formatDate(unionReimburse.getCreateTime());
}
return "";
}
private String getReimburseProjectName(String reimburseProject) {
if ("UNION_REIMBURSE_PROJECT_1".equals(reimburseProject)) {
return "慰问申请";
}
if ("UNION_REIMBURSE_PROJECT_2".equals(reimburseProject)) {
return "文体活动申请";
}
if ("UNION_REIMBURSE_PROJECT_3".equals(reimburseProject)) {
return "日常活动申请";
}
if ("UNION_REIMBURSE_PROJECT_4".equals(reimburseProject)) {
return "专项活动申请";
}
return "报销申请";
}
private Double formatMoney(BigDecimal money) {
return money == null ? 0D : money.setScale(2, RoundingMode.HALF_UP).doubleValue();
}
private List<String> getCurrentUserClubIds() {
if (isAdmin()) {
return new ArrayList<>();
}
List<ClubUser> clubUsers = dao().query(ClubUser.class, Cnd.where("userId", "=", SecurityUtil.getUserId()));
return clubUsers.stream()
.map(ClubUser::getClubId)
.filter(StrUtil::isNotBlank)
.distinct()
.collect(Collectors.toList());
}
private Result validateInvoiceDuplicate(UnionReimburse unionReimburse) {
Map<String, List<Integer>> currentInvoiceMap = new LinkedHashMap<>();
List<UnionReimburseInvoiceDetail> details = unionReimburse.getInvoiceDetails();
@@ -84,6 +84,9 @@ public class DifficultHelpApplyController {
public Result getIsCanPlay() {
//获取申请次数,不想再写一个接口, are you ok? .and("zt", "=", 600)
int applyCount = dao.count(DifficultHelpInfo.class, Cnd.where("proxyUserId", "=", SecurityUtil.getUserId()));
// 页面初始化时需要先判断当前登录人本年度是否已经申请过,避免重复进入新增申请。
boolean hasCurrentYearApply = dao.count(DifficultHelpInfo.class, Cnd.where("userId", "=", SecurityUtil.getUserId())
.and("YEAR(applyTime)", "=", DateUtil.getYear())) > 0;
Sys_config startConfig = dao.fetch(Sys_config.class, Cnd.where("configKey", "=", "DifficultyApplyStartTime"));
Sys_config endConfig = dao.fetch(Sys_config.class, Cnd.where("configKey", "=", "DifficultyApplyEndTime"));
if(startConfig != null && endConfig != null) {
@@ -98,9 +101,9 @@ public class DifficultHelpApplyController {
int endResult = cn.hutool.core.date.DateUtil.compare(cn.hutool.core.date.DateUtil.parse(today), cn.hutool.core.date.DateUtil.parse(end));
String time = startConfig.getConfigValue().replace("-", "") + "日-" + endConfig.getConfigValue().replace("-", "") + "";
return Result.success(Map.of("applyCount", applyCount,"time", time, "result", startResult >=0 && endResult <= 0));
return Result.success(Map.of("applyCount", applyCount,"time", time, "result", startResult >=0 && endResult <= 0, "hasCurrentYearApply", hasCurrentYearApply));
} else {
return Result.success(Map.of("applyCount", applyCount,"time", "", "result", false));
return Result.success(Map.of("applyCount", applyCount,"time", "", "result", false, "hasCurrentYearApply", hasCurrentYearApply));
}
}
@@ -110,6 +113,10 @@ public class DifficultHelpApplyController {
@SLog(tag = "困难补助申请", msg = "保存申请,填写人: ${args[0].proxyUserName}")
public Result save(@Param("data") DifficultHelpInfo difficultHelpInfo) {
difficultHelpInfo.setApplyTime(ObjectUtil.defaultIfNull(difficultHelpInfo.getApplyTime(), new Date()));
difficultHelpCommonService.refreshApplyCount(difficultHelpInfo);
if (difficultHelpCommonService.hasAppliedInYear(difficultHelpInfo.getUserId(), difficultHelpInfo.getApplyTime(), difficultHelpInfo.getId())) {
return Result.error("该人员本年度已申请困难帮扶,不能重复申请");
}
dao.insertOrUpdate(difficultHelpInfo);
return Result.success();
}
@@ -122,6 +129,10 @@ public class DifficultHelpApplyController {
@SLog(tag = "困难补助申请", msg = "提交申请,填写人: ${args[0].proxyUserName}")
public Result submit(@Param("data") DifficultHelpInfo difficultHelpInfo){
difficultHelpInfo.setApplyTime(new Date());
difficultHelpCommonService.refreshApplyCount(difficultHelpInfo);
if (difficultHelpCommonService.hasAppliedInYear(difficultHelpInfo.getUserId(), difficultHelpInfo.getApplyTime(), difficultHelpInfo.getId())) {
return Result.error("该人员本年度已申请困难帮扶,不能重复申请");
}
dao.insertOrUpdate(difficultHelpInfo);
// 开启流程实例
@@ -146,6 +157,10 @@ public class DifficultHelpApplyController {
@SLog(tag = "困难补助申请", msg = "重新提交申请,填写人: ${args[0].proxyUserName}")
public Result submitAgain(@Param("data") DifficultHelpInfo difficultHelpInfo, @Param("taskId") Long taskId) {
difficultHelpInfo.setApplyTime(ObjectUtil.defaultIfNull(difficultHelpInfo.getApplyTime(), new Date()));
difficultHelpCommonService.refreshApplyCount(difficultHelpInfo);
if (difficultHelpCommonService.hasAppliedInYear(difficultHelpInfo.getUserId(), difficultHelpInfo.getApplyTime(), difficultHelpInfo.getId())) {
return Result.error("该人员本年度已申请困难帮扶,不能重复申请");
}
dao.insertOrUpdate(difficultHelpInfo);
Dict dict = Dict.create();
@@ -7,6 +7,7 @@ import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.param.AidFundPag
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.upload.TempFile;
import java.util.Date;
import java.util.List;
/**
@@ -26,4 +27,21 @@ public interface DifficultHelpCommonService extends BaseService<DifficultHelpInf
NutMap handlingMoneyImport(TempFile file, Boolean isFlag);
List<NutMap> getYearPayList(DifficultHelpPageParam pageForm);
/**
* 校验同一受补助人同一年是否已存在申请记录。
*
* @param userId 受补助人id
* @param applyTime 申请时间
* @param excludeRecordId 排除的当前记录id,编辑/重新提交时使用
* @return true 已存在同年申请记录
*/
boolean hasAppliedInYear(String userId, Date applyTime, String excludeRecordId);
/**
* 新申请时按历史总申请次数重新计算申请次数字段,已有记录则保留原值。
*
* @param difficultHelpInfo 申请信息
*/
void refreshApplyCount(DifficultHelpInfo difficultHelpInfo);
}
@@ -50,6 +50,38 @@ public class DifficultHelpCommonServiceImpl extends BaseServiceImpl<DifficultHel
@Inject
private ManyAddOrRenewUtil manyAddOrRenewUtil;
@Override
public boolean hasAppliedInYear(String userId, Date applyTime, String excludeRecordId) {
if (StrUtil.isBlank(userId) || applyTime == null) {
return false;
}
Cnd cnd = Cnd.where("userId", "=", userId);
cnd.and("YEAR(applyTime)", "=", DateUtil.year(applyTime));
if (StrUtil.isNotBlank(excludeRecordId)) {
cnd.and("id", "<>", excludeRecordId);
}
// 按受补助人和申请年份校验,确保同一个人每年只能保留一条申请记录。
return dao().count(DifficultHelpInfo.class, cnd) > 0;
}
@Override
public void refreshApplyCount(DifficultHelpInfo difficultHelpInfo) {
if (difficultHelpInfo == null || StrUtil.isBlank(difficultHelpInfo.getUserId())) {
return;
}
if (StrUtil.isNotBlank(difficultHelpInfo.getId())) {
DifficultHelpInfo dbInfo = dao().fetch(DifficultHelpInfo.class, difficultHelpInfo.getId());
if (dbInfo != null) {
// 已存在的申请记录沿用原申请次数,避免编辑或重新提交时重复累加。
difficultHelpInfo.setApplyCount(dbInfo.getApplyCount());
return;
}
}
int historyApplyCount = dao().count(DifficultHelpInfo.class, Cnd.where("userId", "=", difficultHelpInfo.getUserId()));
// 新申请记录按历史总申请次数 + 1 重新计算申请次数,不使用前端传入值。
difficultHelpInfo.setApplyCount(historyApplyCount + 1);
}
@Override
public List<NutMap> getYearPayList(DifficultHelpPageParam pageForm) {
// 1. 生成年份列表
@@ -126,6 +126,37 @@ public class AIdFundPayRecordController {
CommonDownloadUtil.download(pageForm.getYear() + "会员年度缴费记录.xlsx", workbook, response);
}
@At
@Ok("void")
@ApiOperation("导出年度缴费名单")
@SaCheckPermission("medicalMutualAid.aidFund.payRecord")
public void exportAnnualPayMemberList(AidFundPageForm pageForm, HttpServletResponse response) {
/*
* 导出参数说明
* pageForm 可传所属工会所属单位会员类型姓名/工号关键字等筛选条件
* 返回 Excel 列为工号姓名单位以及 2015 到当前年度的动态缴费金额列
*/
List<Integer> years = IntStream.rangeClosed(2015, DateUtil.thisYear())
.boxed()
.toList();
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
entityList.add(new ExcelExportEntity("姓名", "username", 20));
entityList.add(new ExcelExportEntity("单位", "unitName", 30));
years.forEach(year -> {
ExcelExportEntity entity = new ExcelExportEntity(String.valueOf(year), String.valueOf(year), 20);
entity.setType(10);
entityList.add(entity);
});
List<NutMap> list = aidFundMemberPayService.getAnnualPayMemberList(pageForm);
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
CommonDownloadUtil.download("年度缴费名单.xlsx", workbook, response);
}
@At
@Ok("void")
@ApiOperation("导出缴费名单")
@@ -3,23 +3,28 @@ package com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
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.result.Result;
import com.budwk.app.base.utils.PageUtil;
import com.budwk.app.flow.engine.FlowEngine;
import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.param.AidFundPageForm;
import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.service.AidFundMemberChangeRecordService;
import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.service.AidFundMemberService;
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.Cnd;
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.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
/**
* @author zhf
@@ -37,6 +42,9 @@ public class AidFundChangeRecordController {
@Inject
private AidFundMemberChangeRecordService changeRecordService;
@Inject
private FlowEngine flowEngine;
@At("")
@Ok("beetl:/platform/zhgh/staffbenefit/medicalMutualAid/aidFund/changeRecord/index.html")
@SaCheckPermission("medicalMutualAid.aidFund.changeRecord")
@@ -105,5 +113,25 @@ public class AidFundChangeRecordController {
return Result.success(pagination);
}
/**
* 删除基金会员变更记录
*
* @param id 变更记录 ID前端列表行中的 row.id
* @return Result删除成功时返回 successID 为空时返回失败提示
*/
@At
@ApiOperation("删除")
@Aop(TransAop.READ_COMMITTED)
@SaCheckPermission("medicalMutualAid.aidFund.changeRecord")
@SLog(tag = "基金会员-变更记录", msg = "删除变更记录")
public Result delete(@Param("id") String id) {
if (StrUtil.isBlank(id)) {
return Result.error("请选择需要删除的变更记录");
}
changeRecordService.delete(id);
flowEngine.processInstanceService().deleteProcessInstanceByBusinessKey(id);
return Result.success();
}
}
@@ -3,11 +3,13 @@ package com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import cn.hutool.core.util.StrUtil;
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.utils.PageUtil;
import com.budwk.app.flow.enums.ProcessTaskStateEnum;
import com.budwk.app.web.commons.auth.utils.AuthUtil;
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
import com.budwk.app.zhgh.staffbenefit.condolence.model.Condolence;
import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.service.AidFundMemberChangeRecordService;
@@ -26,6 +28,7 @@ import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.List;
import java.util.Objects;
/**
* @author zhf
@@ -115,7 +118,9 @@ public class AidFundUnionAuditController {
cnd.andEX("info.changeType", "=", changeType);
cnd.and("t.taskName", "=", "06ed1d6d-5f96-485f-9150-ed1ef4a082d6");
cnd.and("ta.actorId", "in", List.of(SecurityUtil.getUserId()));
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name())){
cnd.and("ta.actorId", "in", List.of(SecurityUtil.getUserId()));
}
if (approval) {
cnd.and("t.taskState", "in", List.of(ProcessTaskStateEnum.FINISHED.getCode(), ProcessTaskStateEnum.INTERRUPT.getCode()));
@@ -133,4 +138,50 @@ public class AidFundUnionAuditController {
Pagination<NutMap> pageVO = changeRecordService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
return Result.success(pageVO);
}
/**
* 查询所有未审核分工会对应的分工会主席工号
*
* @param year 年度按变更记录申请时间的年份筛选
* @param aidFundMemberUserType 基金会员类型传字典编码为空时不限制
* @param changeType 变更类型传字典编码为空时不限制
* @return Resultdata 为需要发送通知的分工会主席工号列表
*/
@At
@ApiOperation("查询未审核分工会主席工号")
@SaCheckPermission("medicalMutualAid.aidFund.unionAudit")
public Result notifyUnapprovedUnionChairman(@Param(value = "year") Integer year,
@Param(value = "aidFundMemberUserType") String aidFundMemberUserType,
@Param(value = "changeType") String changeType) {
Sql sql = Sqls.create("""
SELECT DISTINCT
chairman.loginname
FROM
wf_process_task t
LEFT JOIN wf_process_instance ins ON ins.id = t.processInstanceId
LEFT JOIN aid_fund_member_change_record info ON info.id = ins.businessNo
LEFT JOIN vw_user us ON us.id = info.userId
LEFT JOIN sys_user_role ur ON ur.unionId = us.unionId
LEFT JOIN sys_role role ON role.id = ur.roleId
LEFT JOIN sys_user chairman ON chairman.id = ur.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.andEX("YEAR(info.applyTime)", "=", year);
cnd.andEX("IFNULL(info.aidFundMemberUserType, us.aidFundMemberUserType)", "=", aidFundMemberUserType);
cnd.andEX("info.changeType", "=", changeType);
cnd.and("t.taskName", "=", "06ed1d6d-5f96-485f-9150-ed1ef4a082d6");
cnd.and("t.taskState", "=", ProcessTaskStateEnum.DOING.getCode());
cnd.and("role.code", "=", RoleConstant.BRANCH_UNION_CHAIRMAN.name());
cnd.and("chairman.loginname", "is not", null);
sql.setCondition(cnd);
// 这里只返回需要发送通知的主席工号真实消息发送功能由后续消息接口接入
List<String> loginNames = changeRecordService.listMap(sql).stream()
.map(map -> map.getString("loginname"))
.filter(Objects::nonNull)
.distinct()
.toList();
return Result.success(loginNames);
}
}
@@ -15,4 +15,12 @@ public interface AidFundMemberPayService extends BaseService<AidFundMemberPay> {
Sql getSql(AidFundPageForm pageForm);
List<NutMap> getYearPayList(AidFundPageForm pageForm);
/**
* 查询年度缴费名单导出数据
*
* @param pageForm 页面筛选参数包含所属工会所属单位会员类型姓名/工号关键字等条件
* @return 返回导出行数据字段包含 loginnameusernameunitName以及 2015 到当前年度的缴费金额字段
*/
List<NutMap> getAnnualPayMemberList(AidFundPageForm pageForm);
}
@@ -201,4 +201,102 @@ public class AidFundMemberPayServiceImpl extends BaseServiceImpl<AidFundMemberPa
}
return nutMaps;
}
@Override
public List<NutMap> getAnnualPayMemberList(AidFundPageForm pageForm) {
/*
* 导出参数说明
* pageForm.unionId按所属工会筛选
* pageForm.unitId按所属单位筛选
* pageForm.aidFundMemberUserType按基金会员类型筛选
* pageForm.searchKeyword按姓名或工号模糊筛选
* 返回值字段loginnameusernameunitName 为人员基础信息2015 到当前年度字段为对应年度缴费金额
*/
List<Integer> years = IntStream.rangeClosed(2015, DateUtil.thisYear())
.boxed()
.toList();
Cnd userCnd = Cnd.where(View_user::getAidFundMember, "=", 1);
userCnd.andEX(View_user::getUnionId, "=", pageForm.getUnionId());
userCnd.andEX(View_user::getUnitId, "=", pageForm.getUnitId());
userCnd.andEX(View_user::getAidFundMemberUserType, "=", pageForm.getAidFundMemberUserType());
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
SqlExpressionGroup group = new SqlExpressionGroup();
group.orLike(View_user::getLoginname, pageForm.getSearchKeyword(), true);
group.orLike(View_user::getUsername, pageForm.getSearchKeyword(), true);
userCnd.and(group);
}
userCnd.desc(View_user::getUnitCode);
List<View_user> userList = dao().query(View_user.class, userCnd);
Set<String> oldLoginNames = new HashSet<>();
Map<String, String> oldLoginToUserId = new HashMap<>();
for (View_user user : userList) {
if (StrUtil.isNotBlank(user.getOldLoginName())) {
oldLoginNames.add(user.getOldLoginName());
}
}
if (!oldLoginNames.isEmpty()) {
List<Sys_user> oldUsers = dao().query(Sys_user.class,
Cnd.where(Sys_user::getLoginname, "in", new ArrayList<>(oldLoginNames)));
for (Sys_user oldUser : oldUsers) {
oldLoginToUserId.put(oldUser.getLoginname(), oldUser.getId());
}
}
Set<String> allUserIds = new HashSet<>();
for (View_user user : userList) {
allUserIds.add(user.getId());
if (StrUtil.isNotBlank(user.getOldLoginName())) {
String oldUserId = oldLoginToUserId.get(user.getOldLoginName());
if (oldUserId != null) {
allUserIds.add(oldUserId);
}
}
}
List<AidFundMemberPay> payList = allUserIds.isEmpty()
? new ArrayList<>()
: query(Cnd.where(AidFundMemberPay::getUserId, "in", new ArrayList<>(allUserIds)));
Map<String, Map<Integer, Double>> payIndex = new HashMap<>();
for (AidFundMemberPay pay : payList) {
if (pay.getUserId() == null || pay.getYear() == null || pay.getMoney() == null) {
continue;
}
payIndex.computeIfAbsent(pay.getUserId(), k -> new HashMap<>())
.put(pay.getYear(), pay.getMoney());
}
List<NutMap> result = new ArrayList<>();
for (View_user user : userList) {
NutMap row = NutMap.NEW();
row.put("loginname", user.getLoginname());
row.put("username", user.getUsername());
row.put("unitName", user.getUnitName());
Set<String> userIds = new HashSet<>();
userIds.add(user.getId());
if (StrUtil.isNotBlank(user.getOldLoginName())) {
String oldUserId = oldLoginToUserId.get(user.getOldLoginName());
if (oldUserId != null) {
userIds.add(oldUserId);
}
}
for (Integer year : years) {
Double yearMoney = 0.0;
for (String userId : userIds) {
Double money = Optional.ofNullable(payIndex.get(userId))
.map(map -> map.get(year))
.orElse(0.0);
yearMoney += money;
}
row.put(String.valueOf(year), yearMoney == 0.0 ? null : yearMoney);
}
result.add(row);
}
return result;
}
}