commit
This commit is contained in:
+64
@@ -25,6 +25,7 @@ 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 org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
@@ -142,6 +143,69 @@ public class OutlayManageUnionAllocateController {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("一键批量分配所有工会额度")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SLog(tag = "分工会预算-季度预算分配", msg = "一键批量分配所有工会额度")
|
||||
@SaCheckPermission("outlay.outlayManage.union.allocate")
|
||||
public Result doBatchAllocate(@Param("allocateMoney") BigDecimal allocateMoney,
|
||||
@Param("quarterly") Integer quarterly,
|
||||
@Param("year") Integer year) {
|
||||
List<OutLayAllocateUnion> allocateUnionList = baseService.dao().query(OutLayAllocateUnion.class,
|
||||
Cnd.where(OutLayAllocateUnion::getQuarterly, "=", quarterly)
|
||||
.and(OutLayAllocateUnion::getYear, "=", year)
|
||||
.and(OutLayAllocateUnion::getDelFlag, "=", 0));
|
||||
|
||||
if (allocateUnionList == null || allocateUnionList.isEmpty()) {
|
||||
return Result.error("当前季度没有分配记录!");
|
||||
}
|
||||
|
||||
for (OutLayAllocateUnion allocateUnion : allocateUnionList) {
|
||||
baseService.dao().update(OutLayAllocateUnion.class,
|
||||
Chain.make("allocateMoney", allocateMoney),
|
||||
Cnd.where(OutLayAllocateUnion::getId, "=", allocateUnion.getId()));
|
||||
|
||||
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())
|
||||
: 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(allocateMoney));
|
||||
} else {
|
||||
manageUnion.setTotalQuota(allocateMoney);
|
||||
}
|
||||
manageUnion.setUsedQuota(BigDecimal.ZERO);
|
||||
baseService.insert(manageUnion);
|
||||
}
|
||||
} else {
|
||||
baseService.dao().update(OutlayManageUnion.class,
|
||||
Chain.make("totalQuota", newOutlayManageUnion.getTotalQuota().add(allocateMoney)),
|
||||
Cnd.where(OutlayManageUnion::getId, "=", newOutlayManageUnion.getId()));
|
||||
}
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("重置预算季度记录")
|
||||
|
||||
+19
-3
@@ -18,6 +18,7 @@ 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.Condition;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
@@ -118,9 +119,24 @@ public class OutlayManageUnionUseDetailController {
|
||||
@ApiOperation("查询分工会今年每个季度的分配情况")
|
||||
@SaCheckPermission("outlay.outlayManage.union.useDetail")
|
||||
public Result queryQuarterlyList(Integer year, String unionId){
|
||||
List<OutLayAllocateUnion> allocateUnionList = outlayUseDetailService.dao().query(OutLayAllocateUnion.class,
|
||||
Cnd.where(OutLayAllocateUnion::getYear, "=", year).and(OutLayAllocateUnion::getUnionId, "=", unionId)
|
||||
.asc(OutLayAllocateUnion::getQuarterly));
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT t1.* FROM outlay_allocate_union t1
|
||||
INNER JOIN (
|
||||
SELECT quarterly, MAX(id) as max_id
|
||||
FROM outlay_allocate_union
|
||||
WHERE year = @year AND unionId = @unionId AND delFlag = 0
|
||||
GROUP BY quarterly
|
||||
) t2 ON t1.id = t2.max_id
|
||||
ORDER BY t1.quarterly ASC
|
||||
""");
|
||||
sql.setParam("year", year);
|
||||
sql.setParam("unionId", unionId);
|
||||
sql.setCallback(Sqls.callback.entities());
|
||||
sql.setEntity(outlayUseDetailService.dao().getEntity(OutLayAllocateUnion.class));
|
||||
|
||||
outlayUseDetailService.dao().execute(sql);
|
||||
List<OutLayAllocateUnion> allocateUnionList = sql.getList(OutLayAllocateUnion.class);
|
||||
|
||||
return Result.success(allocateUnionList);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user