This commit is contained in:
2026-02-02 10:30:15 +08:00
parent 1ab7c6c998
commit e76d8123cb
9 changed files with 362 additions and 34 deletions
@@ -222,4 +222,7 @@ public class View_user {
@Column
private Date aidFundMemberQuitTime;
@Column
private String oldLoginName;
}
@@ -7,6 +7,7 @@ import cn.afterturn.easypoi.excel.entity.ImportParams;
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.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.budwk.app.base.annotation.SLog;
import com.budwk.app.base.page.Pagination;
@@ -38,6 +39,7 @@ import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* @author zhf
@@ -98,6 +100,31 @@ public class AIdFundPayRecordController {
return Result.success();
}
@At
@Ok("void")
@ApiOperation("导出会员年度缴费记录")
@SaCheckPermission("medicalMutualAid.aidFund.payRecord")
public void exportYearPayRecord(AidFundPageForm pageForm, HttpServletResponse response){
List<Integer> years = IntStream.rangeClosed(2015, DateUtil.thisYear())
.boxed()
.toList();
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("姓名", "userName", 20));
years.forEach(year -> {
ExcelExportEntity entity = new ExcelExportEntity(String.valueOf(year), String.valueOf(year), 20);
entity.setType(10);
entityList.add(entity);
});
ExcelExportEntity entity = new ExcelExportEntity("合计", "totalMoney", 20);
entity.setType(10);
entityList.add(entity);
List<NutMap> list = aidFundMemberPayService.getYearPayList(pageForm);
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
CommonDownloadUtil.download(pageForm.getYear() + "会员年度缴费记录.xlsx", workbook, response);
}
@At
@Ok("void")
@@ -77,7 +77,7 @@ public class AidFundManageController {
@At
@ApiOperation("分页查询")
@SaCheckPermission(value = {"medicalMutualAid.aidFund.manage", "h5.medicalMutualAid.aidFund.manage"}, mode = SaMode.OR)
@SaCheckPermission("medicalMutualAid.aidFund.manage")
public Result pageData(AidFundPageForm pageForm) {
Sql sql = Sqls.create("""
SELECT
@@ -130,7 +130,7 @@ public class AidFundManageController {
@At
@SaCheckPermission(value = {"medicalMutualAid.aidFund.manage", "h5.medicalMutualAid.aidFund.manage"}, mode = SaMode.OR)
@SaCheckPermission("medicalMutualAid.aidFund.manage")
@Ok("void")
@ApiOperation("导出本年新进会员")
public void exportNewMember(HttpServletResponse response) {
@@ -161,12 +161,12 @@ public class AidFundManageController {
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, listMap);
CommonDownloadUtil.download(DateUtil.thisYear()+"年度新加入会员名单.xlsx", workbook, response);
CommonDownloadUtil.download(DateUtil.thisYear() + "年度新加入会员名单.xlsx", workbook, response);
}
@At
@SaCheckPermission(value = {"medicalMutualAid.aidFund.manage", "h5.medicalMutualAid.aidFund.manage"}, mode = SaMode.OR)
@SaCheckPermission("medicalMutualAid.aidFund.manage")
@ApiOperation("生成缴费名单")
@Aop(TransAop.READ_COMMITTED)
@SLog(tag = "基金会员-基金会员台账", msg = "生成缴费名单")
@@ -177,7 +177,7 @@ public class AidFundManageController {
}
@At
@SaCheckPermission(value = {"medicalMutualAid.aidFund.manage", "h5.medicalMutualAid.aidFund.manage"}, mode = SaMode.OR)
@SaCheckPermission("medicalMutualAid.aidFund.manage")
@SLog(tag = "基金会员-基金会员台账", msg = "备份基金会员")
@ApiOperation("备份基金会员")
@Aop(TransAop.READ_COMMITTED)
@@ -189,7 +189,7 @@ public class AidFundManageController {
@At
@SaCheckPermission(value = {"medicalMutualAid.aidFund.manage", "h5.medicalMutualAid.aidFund.manage"}, mode = SaMode.OR)
@SaCheckPermission("medicalMutualAid.aidFund.manage")
@SLog(tag = "基金会员-基金会员台账", msg = "批量设置退会")
@ApiOperation("批量设置退会")
@Aop(TransAop.READ_COMMITTED)
@@ -211,9 +211,40 @@ public class AidFundManageController {
return Result.success();
}
@At
@SaCheckPermission("medicalMutualAid.aidFund.manage")
@SLog(tag = "基金会员-基金会员台账", msg = "批量更改基金会员状态")
@ApiOperation("批量更改基金会员状态")
@Aop(TransAop.READ_COMMITTED)
public Result doBatchChangeType(@Param("ids") String[] ids, String changeType) {
if (ObjectUtil.isEmpty(ids) || StrUtil.isBlank(changeType)) {
return Result.error("参数错误");
}
List<AidFundMemberChangeRecord> recordArrayList = new ArrayList<>();
for (String id : ids) {
AidFundMemberChangeRecord record = new AidFundMemberChangeRecord()
.setUserId(id)
.setApplyTime(new Date())
.setChangeType(changeType);
recordArrayList.add(record);
}
Chain add;
if (changeType.equals("AIDFUND_MEMBER_CHANGE_TYPE_EIGTH")) {
//会员退休
add = Chain.make("aidFundMemberUserType", "离退休人员");
} else {
add = Chain.make("aidFundMember", AidFundMemberMode.NONE.getCode())
.add("aidFundMemberQuitTime", new Date());
}
userService.update(add, Cnd.where("id", "in", ids));
userService.insert(recordArrayList);
return Result.success();
}
@At
@SaCheckPermission(value = {"medicalMutualAid.aidFund.manage", "h5.medicalMutualAid.aidFund.manage"}, mode = SaMode.OR)
@SaCheckPermission("medicalMutualAid.aidFund.manage")
@SLog(tag = "基金会员-基金会员台账", msg = "修改基金会员类型")
@ApiOperation("修改基金会员类型")
public Result doEditAidFundMemberUserType(String userId, String aidFundMemberUserType) {
@@ -222,26 +253,33 @@ public class AidFundManageController {
}
@At
@SaCheckPermission(value = {"medicalMutualAid.aidFund.manage", "h5.medicalMutualAid.aidFund.manage"}, mode = SaMode.OR)
@SLog(tag = "基金会员-基金会员台账", msg = "基金会员状态")
@ApiOperation("基金会员状态")
@SaCheckPermission("medicalMutualAid.aidFund.manage")
@SLog(tag = "基金会员-基金会员台账", msg = "更基金会员")
@ApiOperation("更基金会员")
@Aop(TransAop.READ_COMMITTED)
public Result doEditChangeType(String userId, String changeType) {
AidFundMemberChangeRecord record = new AidFundMemberChangeRecord()
.setUserId(userId)
.setApplyTime(new Date())
.setChangeType(changeType);
aidFundMemberService.insert(record);
userService.update(Chain.make("aidFundMember", AidFundMemberMode.NONE.getCode())
.add("aidFundMemberQuitTime", new Date()), Cnd.where("id", "=", userId));
Chain add;
if (changeType.equals("AIDFUND_MEMBER_CHANGE_TYPE_EIGTH")) {
//会员退休
add = Chain.make("aidFundMemberUserType", "离退休人员");
} else {
add = Chain.make("aidFundMember", AidFundMemberMode.NONE.getCode())
.add("aidFundMemberQuitTime", new Date());
}
userService.update(add, Cnd.where("id", "=", userId));
return Result.success();
}
@At
@SaCheckPermission(value = {"medicalMutualAid.aidFund.manage", "h5.medicalMutualAid.aidFund.manage"}, mode = SaMode.OR)
public Result findOne(String userId){
@SaCheckPermission("medicalMutualAid.aidFund.manage")
public Result findOne(String userId) {
Sql sql = Sqls.create("""
SELECT
us.username,
@@ -263,10 +301,9 @@ public class AidFundManageController {
}
@At
@SaCheckPermission(value = {"medicalMutualAid.aidFund.manage", "h5.medicalMutualAid.aidFund.manage"}, mode = SaMode.OR)
public Result findChangeRecordList(String userId){
@SaCheckPermission("medicalMutualAid.aidFund.manage")
public Result findChangeRecordList(String userId) {
List<NutMap> changeRecordList = aidFundMemberService.findChangeRecordList(userId);
return Result.success(changeRecordList);
@@ -5,9 +5,14 @@ import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.model.AidFundMem
import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.param.AidFundPageForm;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.lang.util.NutMap;
import java.util.List;
public interface AidFundMemberPayService extends BaseService<AidFundMemberPay> {
Sql getSql(AidFundPageForm pageForm);
List<NutMap> getYearPayList(AidFundPageForm pageForm);
}
@@ -1,10 +1,13 @@
package com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.budwk.app.base.constant.RoleConstant;
import com.budwk.app.base.service.impl.BaseServiceImpl;
import com.budwk.app.base.utils.PageUtil;
import com.budwk.app.sys.models.Sys_user;
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.staffbenefit.medicalMutualAid.aidFund.model.AidFundMemberPay;
@@ -16,6 +19,10 @@ import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import java.util.*;
import java.util.stream.IntStream;
/**
* @author zhf
@@ -49,7 +56,7 @@ public class AidFundMemberPayServiceImpl extends BaseServiceImpl<AidFundMemberPa
$condition
""");
Cnd cnd = Cnd.NEW();
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())){
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
SqlExpressionGroup group = new SqlExpressionGroup();
group.orLike("us.loginname", pageForm.getSearchKeyword());
group.orLike("us.username", pageForm.getSearchKeyword());
@@ -76,7 +83,7 @@ public class AidFundMemberPayServiceImpl extends BaseServiceImpl<AidFundMemberPa
cnd.and(group);
}
if (ObjectUtil.isNotEmpty(pageForm.getIsPayed())){
if (ObjectUtil.isNotEmpty(pageForm.getIsPayed())) {
cnd.and("pay.isPayed", "=", pageForm.getIsPayed());
}
@@ -88,4 +95,110 @@ public class AidFundMemberPayServiceImpl extends BaseServiceImpl<AidFundMemberPa
sql.setCondition(cnd);
return sql;
}
@Override
public List<NutMap> getYearPayList(AidFundPageForm pageForm) {
// 1. 生成年份列表
List<Integer> years = IntStream.rangeClosed(2015, DateUtil.thisYear())
.boxed()
.toList();
// 2. 查询主用户列表
List<View_user> sysUserList = dao().query(View_user.class,
Cnd.where(View_user::getAidFundMember, "=", 1)
.andEX(View_user::getUnionId, "=", pageForm.getUnionId())
.andEX(View_user::getAidFundMemberUserType, "=", pageForm.getAidFundMemberUserType()));
// >>> 新增:预加载旧用户映射 <<<
Set<String> oldLoginNames = new HashSet<>();
Map<String, String> oldLoginToUserId = new HashMap<>(); // loginName -> userId
// 收集所有需要查询的旧登录名
for (View_user user : sysUserList) {
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());
}
}
// <<< 预加载结束 >>>
// 3. 收集所有关联的用户ID(当前 + 旧账号)
Set<String> allUserIds = new HashSet<>();
for (View_user user : sysUserList) {
allUserIds.add(user.getId());
if (StrUtil.isNotBlank(user.getOldLoginName())) {
String oldUserId = oldLoginToUserId.get(user.getOldLoginName());
if (oldUserId != null) {
allUserIds.add(oldUserId);
}
}
}
// 4. 一次性查询缴费记录
List<AidFundMemberPay> payList = query(Cnd.where(AidFundMemberPay::getUserId, "in", new ArrayList<>(allUserIds)));
// 5. 构建缴费索引
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());
}
// 6. 构建结果
List<NutMap> nutMaps = new ArrayList<>();
for (View_user user : sysUserList) {
NutMap nutMap = NutMap.NEW();
nutMap.put("userName", user.getUsername() + "-" + user.getLoginname());
// 获取该用户关联的所有ID(当前 + 旧账号)
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);
}
}
Double totalMoney = 0.0;
for (Integer year : years) {
Double yearMoney = 0.0;
// 累加所有关联账号在该年的缴费
for (String uid : userIds) {
Double money = Optional.ofNullable(payIndex.get(uid))
.map(map -> map.get(year))
.orElse(0.0);
yearMoney += money;
}
// 只有当年缴费 > 0 时才计入 totalMoney(可选,根据业务)
// 如果业务要求 totalMoney 包含 0 记录,则保留下面这行
totalMoney += yearMoney;
// >>> 关键修改:0 显示为 null <<<
if (yearMoney == 0.0) {
nutMap.put(String.valueOf(year), null); // 或者不 put,但显式 put(null) 更明确
} else {
nutMap.put(String.valueOf(year), yearMoney);
}
}
nutMap.put("totalMoney", totalMoney);
nutMaps.add(nutMap);
}
return nutMaps;
}
}
@@ -50,7 +50,7 @@ const AID_FUND_INFO = {
</el-table>
</el-tab-pane>
<el-tab-pane label="缴费记录" name="three">
<pay_record ref="payRecord"></pay_record>
<pay_record ref="payRecord" :max-height="650"></pay_record>
</el-tab-pane>
</el-tabs>
@@ -2,9 +2,9 @@ const PAY_RECORD = {
template: /*language=HTML*/
`
<div>
<el-table :data="payRecordList" row-key="id" style="width: 100%"max-height="300">
<el-table-column label="序号"
type="index"></el-table-column>
<el-table :data="payRecordList" row-key="id" style="width: 100%" :max-height="maxHeight" show-summary
:summary-method="getSummaries">
<el-table-column label="序号" type="index" width="80"></el-table-column>
<el-table-column label="缴费年份" prop="year"></el-table-column>
@@ -14,7 +14,7 @@ const PAY_RECORD = {
</template>
</el-table-column>
<el-table-column label="是否扣款"prop="isPayed">
<el-table-column label="是否扣款" prop="isPayed">
<template scope="{row:{isPayed}}">
<el-tag v-if="isPayed" type="success">已扣款</el-tag>
<el-tag v-else-if="!isPayed" type="info">未扣款</el-tag>
@@ -23,14 +23,49 @@ const PAY_RECORD = {
</el-table>
</div>
`,
props: {
maxHeight: {
type: String,
default: '300'
}
},
data() {
return {
payRecordList: [],
}
},
methods: {
getSummaries(param) {
const {columns, data} = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计';
return;
}
const values = data.map(item => Number(item[column.property]));
if ([1, 3].includes(index)) {
sums[index] = '';
} else {
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] += ' 元';
} else {
sums[index] = '';
}
}
});
return sums;
},
getUserPayRecordList(userId) {
this.$axios.post('/platform/medicalMutualAid/aidFund/apply/getUserPayRecordList',{userId}).then(resp => {
this.$axios.post('/platform/medicalMutualAid/aidFund/apply/getUserPayRecordList', {userId}).then(resp => {
if (resp.code === 0) {
this.payRecordList = resp.data
}
@@ -50,6 +50,12 @@ layout("/layouts/platform.html"){
批量设置为退会
</el-button>
<el-button @click="openBatchChangeType" size="small"
type="primary"
v-if="$auth.hasPermission('medicalMutualAid.aidFund.manage.createPayList')">
批量变更
</el-button>
<el-button @click="exportNewMember" icon="el-icon-download" size="small" type="primary"
v-if="$auth.hasPermission('medicalMutualAid.aidFund.manage.exportNewMember')" class="mr10">
导出{{new
@@ -168,6 +174,39 @@ layout("/layouts/platform.html"){
</span>
</el-dialog>
<el-dialog
:visible.sync="batchChangeTypeVisible"
title="会员批量变更"
width="40%">
<el-form :model="formData" :rules="formRules" label-width="100px"
ref="form">
<el-form-item>
<el-table :data="changeTableData" ref="changeTable" row-key="id" style="width: 100%" max-height="300">
<el-table-column label="序号" type="index" width="60px"></el-table-column>
<el-table-column label="工号" prop="loginname"></el-table-column>
<el-table-column label="姓名" prop="username"></el-table-column>
<el-table-column label="操作" fixed="right" width="100">
<template slot-scope="{row}">
<el-button @click="rowTableDelete(row)" size="mini" type="danger">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
<el-form-item label="变更类型" prop="changeType">
<dict-select v-model="formData.changeType" clearable code="AIDFUND_MEMBER_CHANGE_TYPE"
placeholder="请选择变更类型"
style="width: 100%"></dict-select>
</el-form-item>
</el-form>
<span class="dialog-footer" slot="footer">
<el-button @click="batchChangeTypeVisible = false">取 消</el-button>
<el-button @click="doBatchChangeType" type="primary">提 交</el-button>
</span>
</el-dialog>
<el-dialog
:visible.sync="changeTypeVisible"
title="会员变更"
@@ -242,13 +281,67 @@ layout("/layouts/platform.html"){
changeType: [
{required: true, message: '请选择变更类型', trigger: 'change'}
]
}
},
batchChangeTypeVisible: false,
changeTableData: []
}
},
components: {
'info': AID_FUND_INFO,
},
methods: {
doBatchChangeType() {
const selection = this.$refs.table.selection
if (selection.length === 0) {
this.$message.warning('请勾选需要变更的人员')
return
}
this.$refs.form.validate(valid => {
if (!valid) {
return
}
this.$confirm('确定要变更【' + selection.map(v => v.username) + '】吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const ids = selection.map(v => v.id)
this.$axios.post('/platform/medicalMutualAid/aidFund/manage/doBatchChangeType', {
ids: JSON.stringify(ids),
changeType: this.formData.changeType
}).then(resp => {
if (resp.code === 0) {
this.$message.success(resp.msg)
this.doSearch()
this.$refs.table.clearSelection()
this.batchChangeTypeVisible = false
}
})
})
})
},
rowTableDelete(row) {
this.$confirm('确定要删除【' + row.username + '】吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$refs.table.toggleRowSelection(row, false)
})
},
openBatchChangeType() {
const selection = this.$refs.table.selection
if (selection.length === 0) {
this.$message.warning('请勾选需要变更的人员')
return
}
this.changeTableData = selection
this.batchChangeTypeVisible = true
},
onEditChangeType(row) {
this.formData = clone(row)
this.changeTypeVisible = true
@@ -69,6 +69,12 @@ layout("/layouts/platform.html"){
type="primary">导出名单
</el-button>
<el-button @click="exportYearPayRecord"
size="small"
icon="el-icon-download"
type="primary">导出会员缴费金额
</el-button>
<el-button :disabled="tableData.length==0" :loading="tableLoading" @click="clearPayRecord"
icon="el-icon-delete"
size="small"
@@ -113,7 +119,6 @@ layout("/layouts/platform.html"){
</el-table-column>
</el-table>
<!--#include("/layouts/pagination.html"){}#-->
</el-card>
<template #edit>
@@ -125,12 +130,17 @@ layout("/layouts/platform.html"){
></file-import>
</template>
<template #view>
<info ref="infoRef"></info>
</template>
</guava>
</div>
<script nonce="${cspNonce!}">
<!--#include("../common/aidFundInfo.js"){}#-->
new Vue({
el: "#app",
mixins: [initTableMixins],
@@ -160,17 +170,27 @@ layout("/layouts/platform.html"){
}
},
components: {
'info': AID_FUND_INFO,
"file-import": httpVueLoader("/components/plugins/sysImport/index.vue"),
},
methods: {
onView(row) {
this.$refs.guava.view(() => {
this.showApprovalForm = false
this.$refs.infoRef.onOpen({"id": row.userId})
})
},
openImport() {
this.$refs.guava.edit(()=>{
this.$refs.guava.edit(() => {
setTimeout(() => {
this.$refs.viewImport.resetImportData()
this.$refs.viewImport.importData.year = this.pageForm.year
}, 500)
})
},
exportYearPayRecord(){
this.$downLoad('/platform/medicalMutualAid/aidFund/payRecord/exportYearPayRecord', this.pageForm)
},
exportPayRecord() {
this.$downLoad('/platform/medicalMutualAid/aidFund/payRecord/exportPayRecord', this.pageForm)
},
@@ -214,11 +234,6 @@ layout("/layouts/platform.html"){
})
})
},
onView(row) {
this.$refs.guava.view(() => {
this.$refs.infoRef.onOpen(row)
})
},
async unionChange(val) {
this.pageForm.unitId = null
this.unitList = await this.$businessTool.listUnit(val)