This commit is contained in:
2026-05-07 10:27:43 +08:00
parent d615098f50
commit 63e2091cbb
7 changed files with 132 additions and 93 deletions
@@ -26,44 +26,45 @@ import java.util.List;
*/
public class FlowUnitPartySecretaryHandler implements AssignmentHandler {
@Override
public List<String> assign(TaskModel model, Execution execution) {
String unitId = SecurityUtil.getUnitId();
@Override
public List<String> assign(TaskModel model, Execution execution) {
String unitId = SecurityUtil.getUnitId();
SysRoleService sysRoleService = ServiceContext.find(SysRoleService.class);
Sys_role role = sysRoleService.getByCode(RoleConstant.UNIT_PARTY_SECRETARY);
SysRoleService sysRoleService = ServiceContext.find(SysRoleService.class);
Sys_role role = sysRoleService.getByCode(RoleConstant.UNIT_PARTY_SECRETARY);
View_user user = ServiceContext.find(Dao.class).fetch(View_user.class, Cnd.where(View_user::getId, "=", SecurityUtil.getUserId()));
List<Sys_user_role> roles;
if(user.getUnionName().contains("行政")){
List<Sys_unit> unitList = ServiceContext.find(Dao.class).query(Sys_unit.class, Cnd.where(Sys_unit::getUnionId, "=", user.getUnionId()));
List<String> unitIds = unitList.stream().map(Sys_unit::getId).toList();
roles = ServiceContext.find(Dao.class).query(
Sys_user_role.class,
Cnd.where(Sys_user_role::getRoleId, "=", role.getId())
.and(Sys_user_role::getUnitId, "in", unitIds)
);
}else{
roles = ServiceContext.find(Dao.class).query(
Sys_user_role.class,
Cnd.where(Sys_user_role::getRoleId, "=", role.getId())
.and(Sys_user_role::getUnitId, "=", unitId)
);
}
View_user user = ServiceContext.find(Dao.class).fetch(View_user.class, Cnd.where(View_user::getId, "=", SecurityUtil.getUserId()));
List<Sys_user_role> roles;
if (Lang.isEmpty(roles)) {
throw new RuntimeException("当前登录用户所在单位未设置单位党委书记,请联系校工会进行设置。");
}
return roles.stream().map(Sys_user_role::getUserId).toList();
}
roles = ServiceContext.find(Dao.class).query(
Sys_user_role.class,
Cnd.where(Sys_user_role::getRoleId, "=", role.getId())
.and(Sys_user_role::getUnitId, "=", unitId)
);
@Override
public String getMessage() {
return "获取当前登录用户所在单位党委书记,若是行政就找出行政分下的党委书记。因为行政只有一个党委书记";
}
if (Lang.isEmpty(roles)) {
List<Sys_unit> unitList = ServiceContext.find(Dao.class).query(Sys_unit.class, Cnd.where(Sys_unit::getUnionId, "=", user.getUnionId()));
List<String> unitIds = unitList.stream().map(Sys_unit::getId).toList();
roles = ServiceContext.find(Dao.class).query(
Sys_user_role.class,
Cnd.where(Sys_user_role::getRoleId, "=", role.getId())
.and(Sys_user_role::getUnitId, "in", unitIds)
);
}
@Override
public int getOrder() {
return AssignmentHandler.super.getOrder();
}
if (Lang.isEmpty(roles)) {
throw new RuntimeException("当前登录用户所在单位未设置单位党委书记,请联系校工会进行设置。");
}
return roles.stream().map(Sys_user_role::getUserId).toList();
}
@Override
public String getMessage() {
return "获取当前登录用户所在单位党委书记";
}
@Override
public int getOrder() {
return AssignmentHandler.super.getOrder();
}
}
@@ -268,6 +268,6 @@ public class UnionReimburseApplyController {
@ApiOperation("统一查询经费余额")
@SaCheckPermission(value = {"unionReimburse.apply", "h5.unionReimburse.apply"}, mode = SaMode.OR)
public Result getBudgetBalance(String reimburseFundSource, String clubId) {
return unionReimburseService.getBudgetBalance(reimburseFundSource, clubId);
return unionReimburseService.getBudgetBalance(reimburseFundSource, clubId, null);
}
}
@@ -12,7 +12,6 @@ import com.budwk.app.zhgh.dayofficework.unionReimburse.model.UnionReimburse;
import com.budwk.app.zhgh.dayofficework.unionReimburse.service.UnionReimburseService;
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;
@@ -32,7 +31,6 @@ import java.util.List;
@At("/platform/unionReimburse/review")
@Ok("json:full")
@Api("工会报销审核")
@Slf4j
public class UnionReimburseReviewController {
@Inject
@@ -110,19 +108,7 @@ public class UnionReimburseReviewController {
@Aop(TransAop.READ_COMMITTED)
@SaCheckPermission(value = {"unionReimburse.review", "h5.unionReimburse.review"}, mode = SaMode.OR)
@SLog(tag = "工会报销审核", msg = "一键审核工会报销")
public Result allReview() {
try {
List<UnionReimburse> reimbursements = unionReimburseService.query(Cnd.where("stateId", "=", 2));
for (UnionReimburse reimbursement : reimbursements) {
Result result = unionReimburseService.reviewApply(reimbursement.getId(), "通过", 3);
if (result.getCode() != 0) {
return result;
}
}
return Result.success("一键审核完成,共处理" + reimbursements.size() + "条记录");
} catch (Exception e) {
log.error("一键审核失败", e);
return Result.error("一键审核失败: " + e.getMessage());
}
public Result allReview(@Param("ids[]") String[] ids) {
return unionReimburseService.batchReviewApply(ids);
}
}
@@ -41,10 +41,18 @@ public interface UnionReimburseService extends BaseService<UnionReimburse> {
/**
* 查询报销可用经费余额,同时校验是否已分配以及协会归属权限。
*/
Result getBudgetBalance(String reimburseFundSource, String clubId);
Result getBudgetBalance(String reimburseFundSource, String clubId, String unionId);
/**
* 审核报销,审核通过时扣减对应预算并新增预算使用详情。
*/
Result reviewApply(String reimburseId, String reviewOpinion, int submitType);
/**
* 批量审核选中的待审核报销申请。
*
* @param reimburseIds 前端表格勾选的报销申请ID数组,只处理状态为待审核确认的数据
* @return Result,成功时返回本次实际审核通过的记录数量,失败时返回具体错误原因
*/
Result batchReviewApply(String[] reimburseIds);
}
@@ -244,7 +244,7 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
* 按经费来源统一查询当前可用余额,未分配或权限不匹配时直接拦截。
*/
@Override
public Result getBudgetBalance(String reimburseFundSource, String clubId) {
public Result getBudgetBalance(String reimburseFundSource, String clubId, String unionId) {
if (StrUtil.isBlank(reimburseFundSource)) {
return Result.error("请选择经费来源");
}
@@ -257,8 +257,9 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
return Result.success(formatMoney(outlayManageSchool.getTotalQuota().subtract(outlayManageSchool.getUsedQuota())));
}
if ("UNION_REIMBURSE_FUND_SOURCE_2".equals(reimburseFundSource)) {
String queryUnionId = StrUtil.blankToDefault(unionId, SecurityUtil.getUnionId());
OutlayManageUnion outlayManageUnion = dao().fetch(OutlayManageUnion.class,
Cnd.where("unionId", "=", SecurityUtil.getUnionId()).and("year", "=", DateUtil.thisYear()));
Cnd.where("unionId", "=", queryUnionId).and("year", "=", DateUtil.thisYear()));
if (outlayManageUnion == null) {
return Result.error("分工会经费未分配");
}
@@ -315,6 +316,27 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
return Result.success();
}
/**
* 批量审核前只查询前端勾选且仍处于待审核确认状态的数据,避免误处理未勾选或状态已变化的申请。
*/
@Override
public Result batchReviewApply(String[] reimburseIds) {
if (reimburseIds == null || reimburseIds.length == 0) {
return Result.error("请选择需要审核的报销申请");
}
List<UnionReimburse> reimbursements = this.query(Cnd.where("id", "in", reimburseIds).and("stateId", "=", 2));
if (reimbursements.isEmpty()) {
return Result.error("所选记录中没有待审核的数据");
}
for (UnionReimburse reimbursement : reimbursements) {
Result result = this.reviewApply(reimbursement.getId(), "通过", 3);
if (result.getCode() != 0) {
return result;
}
}
return Result.success("一键审核完成,共处理" + reimbursements.size() + "条记录");
}
private void normalizeInvoiceDetails(UnionReimburse unionReimburse) {
if (unionReimburse.getInvoiceDetails() == null) {
unionReimburse.setInvoiceDetails(new ArrayList<>());
@@ -426,7 +448,7 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
* 提交和审核前统一校验预算是否已分配、余额是否充足。
*/
private Result validateFundSourceBeforeSubmit(UnionReimburse unionReimburse) {
Result balanceResult = getBudgetBalance(unionReimburse.getReimburseFundSource(), unionReimburse.getClubId());
Result balanceResult = getBudgetBalance(unionReimburse.getReimburseFundSource(), unionReimburse.getClubId(), unionReimburse.getUnionId());
if (balanceResult == null || balanceResult.getCode() != 0) {
return balanceResult == null ? Result.error("经费余额校验失败") : balanceResult;
}