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);
|
||||
}
|
||||
|
||||
|
||||
+53
@@ -40,6 +40,8 @@ layout("/layouts/platform.html"){
|
||||
|
||||
<el-card shadow="never" class="mt10">
|
||||
<table-tool label="预算分配">
|
||||
<el-button @click="showBatchAllocateDialog" size="small" type="primary" :loading="formLoading">一键分配
|
||||
</el-button>
|
||||
<el-button @click="doAllocateRecord" size="small" type="primary" :loading="formLoading">季度记录生成
|
||||
</el-button>
|
||||
|
||||
@@ -95,6 +97,20 @@ layout("/layouts/platform.html"){
|
||||
</el-table>
|
||||
<!--#include("/layouts/pagination.html"){}#-->
|
||||
</el-card>
|
||||
|
||||
<el-dialog title="一键分配所有工会额度" :visible.sync="batchAllocateDialogVisible" width="500px">
|
||||
<el-form :model="batchAllocateForm" label-width="120px">
|
||||
<el-form-item label="统一分配额度">
|
||||
<el-input-number v-model="batchAllocateForm.allocateMoney" :min="0" :precision="2"
|
||||
style="width: 100%" placeholder="请输入每个工会的分配额度">
|
||||
</el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="batchAllocateDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doBatchAllocate" :loading="formLoading">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
</guava>
|
||||
</div>
|
||||
@@ -119,6 +135,10 @@ layout("/layouts/platform.html"){
|
||||
{prop: 'allocateMoney', label: '分配额度'},
|
||||
],
|
||||
quarterlyList: [],
|
||||
batchAllocateDialogVisible: false,
|
||||
batchAllocateForm: {
|
||||
allocateMoney: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -176,6 +196,39 @@ layout("/layouts/platform.html"){
|
||||
})
|
||||
})
|
||||
},
|
||||
showBatchAllocateDialog() {
|
||||
if (this.tableData.length === 0) {
|
||||
this.$message.warning('当前没有可分配的工会记录,请先生成季度记录')
|
||||
return
|
||||
}
|
||||
this.batchAllocateForm = {
|
||||
allocateMoney: 0
|
||||
}
|
||||
this.batchAllocateDialogVisible = true
|
||||
},
|
||||
doBatchAllocate() {
|
||||
if (!this.batchAllocateForm.allocateMoney || this.batchAllocateForm.allocateMoney <= 0) {
|
||||
this.$message.warning('请输入有效的分配额度')
|
||||
return
|
||||
}
|
||||
|
||||
const quarter = this.$moment().quarter()
|
||||
|
||||
this.formLoading = true
|
||||
this.$axios.post("/platform/outlay/outlayManage/unionAllocate/doBatchAllocate", {
|
||||
allocateMoney: this.batchAllocateForm.allocateMoney,
|
||||
quarterly: quarter,
|
||||
year: this.pageForm.year
|
||||
}).then((resp) => {
|
||||
if (resp.code === 0) {
|
||||
this.$message.success(resp.msg)
|
||||
this.batchAllocateDialogVisible = false
|
||||
this.doSearch()
|
||||
}
|
||||
}).finally(() => {
|
||||
this.formLoading = false
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.$businessTool.listUnion().then((data) => {
|
||||
|
||||
Reference in New Issue
Block a user