commit
This commit is contained in:
+27
@@ -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")
|
||||
|
||||
+55
-18
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
+115
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user