困难帮扶移植
This commit is contained in:
+77
@@ -1,7 +1,10 @@
|
||||
package com.budwk.app.zhgh.staffbenefit.difficulthelp.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
@@ -9,6 +12,7 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
@@ -24,10 +28,13 @@ import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.base.Globals;
|
||||
import com.budwk.app.zhgh.activity.declarereimbursement.vo.ActivityBudgetVO;
|
||||
import com.budwk.app.zhgh.dayofficework.exerciseCard.vo.ExercisePeopleImportVo;
|
||||
import com.budwk.app.zhgh.dayofficework.unionReimburse.model.UnionReimburse;
|
||||
import com.budwk.app.zhgh.staffbenefit.difficulthelp.models.DifficultHelpInfo;
|
||||
import com.budwk.app.zhgh.staffbenefit.difficulthelp.service.DifficultHelpCommonService;
|
||||
import com.budwk.app.zhgh.staffbenefit.difficulthelp.vo.DifficultHelpPageParam;
|
||||
import com.budwk.app.zhgh.staffbenefit.difficulthelp.vo.moneyImportVo;
|
||||
import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.param.AidFundPageForm;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.data.PictureRenderData;
|
||||
@@ -52,9 +59,12 @@ import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -66,6 +76,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@@ -118,6 +129,7 @@ public class DifficultHelpReadingController {
|
||||
LEFT(info.applyTime, 10) AS applyTime,
|
||||
info.applyCount,
|
||||
info.mobile,
|
||||
info.money,
|
||||
ins.id AS instanceId,
|
||||
ins.businessNo,
|
||||
ins.state instanceState,
|
||||
@@ -142,6 +154,7 @@ public class DifficultHelpReadingController {
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("ins.state", "=", 20);
|
||||
pageParam.buildSearch(cnd, "info.");
|
||||
cnd.groupBy("info.id");
|
||||
sql.setCondition(cnd);
|
||||
@@ -160,6 +173,70 @@ public class DifficultHelpReadingController {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@ApiOperation("导入模板下载")
|
||||
@SaCheckPermission("difficultHelp.reading")
|
||||
public void downloadTemplate(HttpServletResponse response) {
|
||||
try {
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String fileName = URLEncoder.encode("实际金额导入模版", "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=" + fileName + ".xlsx");
|
||||
EasyExcel.write(response.getOutputStream(), moneyImportVo.class)
|
||||
.sheet("实际金额导入模版")
|
||||
.doWrite(ArrayList::new);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("导出失败");
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@ApiOperation("导入实际金额")
|
||||
@SaCheckPermission("difficultHelp.reading")
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
public Result importMoney(TempFile file, Boolean isFlag) {
|
||||
try {
|
||||
System.out.println(isFlag);
|
||||
NutMap nutMap = difficultHelpCommonService.handlingMoneyImport(file, isFlag);
|
||||
if (Lang.isNotEmpty(nutMap)) {
|
||||
return Result.success(nutMap);
|
||||
}
|
||||
return Result.success("导入成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@ApiOperation("导出会员年度补助记录")
|
||||
@SaCheckPermission("difficultHelp.reading")
|
||||
public void exportYearPayRecord(DifficultHelpPageParam pageForm, HttpServletResponse response){
|
||||
List<Integer> years = IntStream.rangeClosed(2025, 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 = difficultHelpCommonService.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")
|
||||
public void doExportAllApply(DifficultHelpPageParam pageParam, HttpServletResponse response) throws Exception {
|
||||
|
||||
+15
@@ -2,6 +2,12 @@ package com.budwk.app.zhgh.staffbenefit.difficulthelp.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.zhgh.staffbenefit.difficulthelp.models.DifficultHelpInfo;
|
||||
import com.budwk.app.zhgh.staffbenefit.difficulthelp.vo.DifficultHelpPageParam;
|
||||
import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.param.AidFundPageForm;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
@@ -11,4 +17,13 @@ import com.budwk.app.zhgh.staffbenefit.difficulthelp.models.DifficultHelpInfo;
|
||||
* @注释
|
||||
*/
|
||||
public interface DifficultHelpCommonService extends BaseService<DifficultHelpInfo> {
|
||||
|
||||
/**
|
||||
* 导入实际金额数据处理
|
||||
* @param file 文件
|
||||
* @param isFlag 是否清空更新
|
||||
*/
|
||||
NutMap handlingMoneyImport(TempFile file, Boolean isFlag);
|
||||
|
||||
List<NutMap> getYearPayList(DifficultHelpPageParam pageForm);
|
||||
}
|
||||
|
||||
+154
@@ -1,10 +1,37 @@
|
||||
package com.budwk.app.zhgh.staffbenefit.difficulthelp.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.base.utils.ManyAddOrRenewUtil;
|
||||
import com.budwk.app.base.utils.easyexcel.EasyExcelUtil;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.views.View_user;
|
||||
import com.budwk.app.zhgh.staffbenefit.difficulthelp.models.DifficultHelpInfo;
|
||||
import com.budwk.app.zhgh.staffbenefit.difficulthelp.service.DifficultHelpCommonService;
|
||||
import com.budwk.app.zhgh.staffbenefit.difficulthelp.vo.DifficultHelpPageParam;
|
||||
import com.budwk.app.zhgh.staffbenefit.difficulthelp.vo.moneyImportVo;
|
||||
import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.model.AidFundMemberPay;
|
||||
import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.param.AidFundPageForm;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.entity.Record;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
@@ -19,4 +46,131 @@ public class DifficultHelpCommonServiceImpl extends BaseServiceImpl<DifficultHel
|
||||
public DifficultHelpCommonServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private ManyAddOrRenewUtil manyAddOrRenewUtil;
|
||||
|
||||
@Override
|
||||
public List<NutMap> getYearPayList(DifficultHelpPageParam pageForm) {
|
||||
// 1. 生成年份列表
|
||||
List<Integer> years = IntStream.rangeClosed(2025, DateUtil.thisYear())
|
||||
.boxed()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 查询符合条件的 DifficultHelpInfo 记录
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.and(Cnd.exps("loginName", "LIKE", "%" + pageForm.getSearchKeyword() + "%")
|
||||
.or("userName", "LIKE", "%" + pageForm.getSearchKeyword() + "%"));
|
||||
}
|
||||
List<DifficultHelpInfo> infoList = dao().query(DifficultHelpInfo.class, cnd);
|
||||
|
||||
// 3. 构建用户缴费索引 (userId -> year -> money)
|
||||
Map<String, Map<Integer, Double>> payIndex = new HashMap<>();
|
||||
for (DifficultHelpInfo info : infoList) {
|
||||
String userId = info.getId();
|
||||
int year = DateUtil.year(info.getApplyTime());
|
||||
double money = info.getMoney() != null ? info.getMoney() : 0.0;
|
||||
|
||||
payIndex.computeIfAbsent(userId, k -> new HashMap<>()).put(year, money);
|
||||
}
|
||||
|
||||
// 4. 组装结果数据
|
||||
List<NutMap> result = new ArrayList<>();
|
||||
for (DifficultHelpInfo info : infoList) {
|
||||
NutMap userData = NutMap.NEW();
|
||||
userData.put("userName", info.getUserName() + "-" + info.getLoginName());
|
||||
|
||||
double totalMoney = 0.0;
|
||||
for (Integer year : years) {
|
||||
Double yearMoney = Optional.ofNullable(payIndex.get(info.getId()))
|
||||
.map(map -> map.get(year))
|
||||
.orElse(0.0);
|
||||
userData.put(String.valueOf(year), yearMoney == 0.0 ? null : yearMoney);
|
||||
totalMoney += yearMoney;
|
||||
}
|
||||
userData.put("totalMoney", totalMoney);
|
||||
result.add(userData);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@Override
|
||||
public NutMap handlingMoneyImport(TempFile file, Boolean isFlag) {
|
||||
List<T> ts = EasyExcelUtil.syncReadModel(file.getFile(), moneyImportVo.class, 0, 1);
|
||||
List<moneyImportVo> list = JSONUtil.parseArray(JSONUtil.toJsonStr(ts)).toList(moneyImportVo.class);
|
||||
|
||||
// 返回错误记录
|
||||
List<moneyImportVo> errorInfos = new ArrayList<>();
|
||||
|
||||
for (moneyImportVo v : list) {
|
||||
if (StrUtil.isBlank(v.getLoginName())) {
|
||||
v.setErrorInfo("工号不能为空!");
|
||||
errorInfos.add(v);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(v.getYear())) {
|
||||
v.setErrorInfo("年份不能为空!");
|
||||
errorInfos.add(v);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (v.getMoney() == null) {
|
||||
v.setErrorInfo("金额不能为空!");
|
||||
errorInfos.add(v);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
Double money = Double.valueOf(v.getMoney());
|
||||
|
||||
// 根据年份和工号查找对应的困难补助记录
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("loginName", "=", v.getLoginName())
|
||||
.and("YEAR(applyTime)", "=", Integer.parseInt(v.getYear()));
|
||||
|
||||
// 只更新第一条匹配的记录
|
||||
DifficultHelpInfo existingRecord = dao().fetch(DifficultHelpInfo.class, cnd);
|
||||
|
||||
if (existingRecord != null) {
|
||||
// 更新金额字段
|
||||
existingRecord.setMoney(money);
|
||||
dao().update(existingRecord, "^(money)$"); // 只更新money字段
|
||||
} else {
|
||||
v.setErrorInfo("未找到对应年份和工号的记录!");
|
||||
errorInfos.add(v);
|
||||
continue;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
v.setErrorInfo("金额格式错误!");
|
||||
errorInfos.add(v);
|
||||
continue;
|
||||
} catch (Exception e) {
|
||||
v.setErrorInfo("年份格式错误!");
|
||||
errorInfos.add(v);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有错误数据就返回给前端
|
||||
if (Lang.isNotEmpty(errorInfos)) {
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
nutMap.setv("totalCount", list.size());
|
||||
nutMap.setv("successCount", Math.max(list.size() - errorInfos.size(), 0));
|
||||
nutMap.setv("errorCount", errorInfos.size());
|
||||
nutMap.setv("errorList", errorInfos.stream().map(v -> {
|
||||
return NutMap.NEW()
|
||||
.addv("年份", v.getYear())
|
||||
.addv("工号", v.getLoginName())
|
||||
.addv("姓名", v.getUsername())
|
||||
.addv("错误原因", v.getErrorInfo());
|
||||
}).collect(Collectors.toList()));
|
||||
return nutMap;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class AIdFundPayRecordController {
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/staffbenefit/medicalMutualAid/aidFund/payRecord/index.html")
|
||||
@Ok("beetl:/platform/zhgh/staffbenefit/medicalMutualAid/aidFund/paexportYearPayRecordyRecord/index.html")
|
||||
@SaCheckPermission("medicalMutualAid.aidFund.payRecord")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user