From ada46b8bbde250f7b5f32072e36490d5de3f55ef Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 25 Feb 2026 11:15:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=85=B0=E9=97=AE=E6=8A=A5=E9=94=80?= =?UTF-8?q?=E5=8D=95=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/budwk/app/base/utils/MoneyUtil.java | 166 ++++++++++++ .../controller/CondolenceMineController.java | 256 +++++++++++++++++- .../condolence/model/Condolence.java | 5 + .../activity/sports/infoManage/addActivity.js | 2 +- .../staffbenefit/condolence/apply/index.html | 21 +- .../staffbenefit/condolence/common/info.js | 14 +- .../staffbenefit/condolence/mine/index.html | 4 + .../staffbenefit/condolence/apply/index.html | 21 +- .../staffbenefit/condolence/common/info.js | 14 +- 9 files changed, 490 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/budwk/app/base/utils/MoneyUtil.java diff --git a/src/main/java/com/budwk/app/base/utils/MoneyUtil.java b/src/main/java/com/budwk/app/base/utils/MoneyUtil.java new file mode 100644 index 0000000..c489cb1 --- /dev/null +++ b/src/main/java/com/budwk/app/base/utils/MoneyUtil.java @@ -0,0 +1,166 @@ +package com.budwk.app.base.utils; +import java.math.BigDecimal; + +/** + * @author : hongqiwei + * @description : + * @createDate : 2026/1/20 15:41 + */ +public class MoneyUtil { + public MoneyUtil() { + } + + public static String toRMBUpper(String money) throws Exception { + boolean lessZero = false; + if (money.contains("E")) { + BigDecimal bg = new BigDecimal(Double.valueOf(money)); + money = bg.toPlainString(); + } + + if (money.startsWith("-")) { + money = money.substring(1); + lessZero = true; + } + + if (!money.matches("^[0-9]*$|^0+\\.[0-9]+$|^[1-9]+[0-9]*$|^[1-9]+[0-9]*.[0-9]+$")) { + throw new Exception("钱数格式错误!"); + } else { + String[] part = money.split("\\."); + String integerData = part[0]; + String decimalData = part.length > 1 ? part[1] : ""; + if (integerData.matches("^0+$")) { + integerData = "0"; + } else if (integerData.matches("^0+(\\d+)$")) { + integerData = integerData.replaceAll("^0+(\\d+)$", "$1"); + } + + StringBuffer integer = new StringBuffer(); + + for(int i = 0; i < integerData.length(); ++i) { + char perchar = integerData.charAt(i); + integer.append(upperNumber(perchar)); + integer.append(upperNumber(integerData.length() - i - 1)); + } + + StringBuffer decimal = new StringBuffer(); + if (part.length > 1 && !"00".equals(decimalData)) { + int length = decimalData.length() >= 2 ? 2 : decimalData.length(); + + for(int i = 0; i < length; ++i) { + char perchar = decimalData.charAt(i); + decimal.append(upperNumber(perchar)); + if (i == 0) { + decimal.append('角'); + } + + if (i == 1) { + decimal.append('分'); + } + } + } + + String var10000 = integer.toString(); + String result = var10000 + decimal.toString(); + result = dispose(result); + if (lessZero && !"零圆整".equals(result)) { + result = "负" + result; + } + + return result; + } + } + + private static char upperNumber(char number) { + switch (number) { + case '0' -> { + return '零'; + } + case '1' -> { + return '壹'; + } + case '2' -> { + return '贰'; + } + case '3' -> { + return '叁'; + } + case '4' -> { + return '肆'; + } + case '5' -> { + return '伍'; + } + case '6' -> { + return '陆'; + } + case '7' -> { + return '柒'; + } + case '8' -> { + return '捌'; + } + case '9' -> { + return '玖'; + } + default -> { + return '0'; + } + } + } + + private static char upperNumber(int index) { + int realIndex = index % 9; + if (index > 8) { + realIndex = (index - 9) % 8; + ++realIndex; + } + + switch (realIndex) { + case 0 -> { + return '圆'; + } + case 1 -> { + return '拾'; + } + case 2 -> { + return '佰'; + } + case 3 -> { + return '仟'; + } + case 4 -> { + return '万'; + } + case 5 -> { + return '拾'; + } + case 6 -> { + return '佰'; + } + case 7 -> { + return '仟'; + } + case 8 -> { + return '亿'; + } + default -> { + return '0'; + } + } + } + + private static String dispose(String result) { + result = result.replaceAll("0", ""); + result = result.replaceAll("零仟零佰零拾|零仟零佰|零佰零拾|零仟|零佰|零拾", "零"); + result = result.replaceAll("零+", "零").replace("零亿", "亿"); + result = result.matches("^.*亿零万[^零]仟.*$") ? result.replace("零万", "零") : result.replace("零万", "万"); + result = result.replace("亿万", "亿"); + result = result.replace("零角", "零").replace("零分", ""); + result = result.replaceAll("(^[零圆]*)(.+$)", "$2"); + result = result.replaceAll("(^.*)([零]+圆)(.+$)", "$1圆零$3"); + result = result.replaceAll("圆零角零分|圆零角$|圆$|^零$|圆零$|圆零零$|零圆$", "圆整"); + result = result.replaceAll("^圆整$", "零圆整"); + return result; + } +} + diff --git a/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/controller/CondolenceMineController.java b/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/controller/CondolenceMineController.java index 99cebbd..2e9c069 100644 --- a/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/controller/CondolenceMineController.java +++ b/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/controller/CondolenceMineController.java @@ -3,25 +3,41 @@ package com.budwk.app.zhgh.staffbenefit.condolence.controller; import cn.dev33.satoken.annotation.SaCheckLogin; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaMode; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.Dict; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; import com.budwk.app.base.annotation.SLog; import com.budwk.app.base.constant.RoleConstant; import com.budwk.app.base.page.Pagination; import com.budwk.app.base.param.PageForm; import com.budwk.app.base.result.Result; import com.budwk.app.base.sms.SmsService; +import com.budwk.app.base.utils.CommonDownloadUtil; +import com.budwk.app.base.utils.MoneyUtil; import com.budwk.app.base.utils.PageUtil; +import com.budwk.app.base.utils.SysOfficeTemplateUtil; import com.budwk.app.flow.engine.FlowEngine; +import com.budwk.app.flow.entity.ProcessTask; +import com.budwk.app.flow.vo.ProcessTaskVO; 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.dayofficework.unionReimburse.model.UnionReimburse; import com.budwk.app.zhgh.staffbenefit.condolence.model.Condolence; import com.budwk.app.zhgh.staffbenefit.condolence.model.CondolenceType; import com.budwk.app.zhgh.staffbenefit.condolence.service.CondolenceService; +import com.deepoove.poi.XWPFTemplate; +import com.deepoove.poi.config.Configure; +import com.deepoove.poi.data.PictureRenderData; +import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.beetl.ext.fn.Print; 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.sql.Sql; import org.nutz.dao.util.cri.SqlExpressionGroup; @@ -34,6 +50,21 @@ import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Param; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.URLEncoder; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + /** * @ClassName CondolenceApplyController * @Author JyuHsin @@ -45,12 +76,19 @@ import org.nutz.mvc.annotation.Param; @At("/platform/condolence/mine") @Api("职工慰问我的") @Ok("json:full") +@Slf4j public class CondolenceMineController { @Inject private CondolenceService condolenceService; @Inject + private Dao dao; + @Inject private FlowEngine flowEngine; + @Inject + private SmsService smsService; + @Inject + private SysOfficeTemplateUtil sysOfficeTemplateUtil; @At("/") @Ok("beetl:/platform/zhgh/staffbenefit/condolence/mine/index.html") @@ -140,6 +178,220 @@ public class CondolenceMineController { //smsService.send("20182040", "这是一条由智慧工会系统发出的测试消息。"); return Result.success(nutMap); } - @Inject - private SmsService smsService; + + + @At + @Ok("void") + public void doExport(String id, HttpServletResponse response) throws Exception { + Condolence condolence = condolenceService.fetch(id); + if (condolence == null) { + throw new RuntimeException("慰问记录不存在"); + } + + Sql sql = Sqls.create(""" + SELECT + info.*, + ins.id AS instanceId + FROM + `condolence` info + LEFT JOIN wf_process_instance ins ON ins.businessNo = info.id + WHERE + ins.state = 20 AND info.id = @id + """).setParam("id", id); + sql.setCallback(Sqls.callback.map()); + dao.execute(sql); + NutMap info = (NutMap) sql.getResult(); + + HashMap docData = new HashMap<>(); + HashMap docData2 = new HashMap<>(); + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime createTime = LocalDateTime.parse(condolence.getCreateTime(), formatter); + + docData.put("createTime", DateUtil.format(createTime, "yyyy年MM月dd日")); + docData.put("applyUnionName", condolence.getApplyUnionName()); + docData.put("info", info); + + docData2.put("createTime", DateUtil.format(createTime, "yyyy年MM月dd日")); + docData2.put("applyUnionName", condolence.getApplyUnionName()); + docData2.put("bankUserName", condolence.getBankUserName()); + docData2.put("bankCardNumber", condolence.getBankCardNumber()); + docData2.put("bankOfDeposit", condolence.getBankOfDeposit()); + docData2.put("info", info); + + // 金额转大写 +// if (condolence.getMoney() != null) { +// docData.put("money_big", MoneyUtil.toRMBUpper(String.valueOf(condolence.getMoney()))); +// } else { +// docData.put("money_big", ""); +// } +// docData.put("money", condolence.getMoney()); + + String fileName; + String templateName; + String type = condolence.getType(); + + if (("6fb2ae129e674c0dbadc21d9abc22943").equals(type)) { + fileName = "工会会员结婚慰问报销审批单"+ "_" + + DateUtil.format(createTime, "yyyyMMdd") + ".docx"; + templateName = "condolence_marry"; + + docData.put("type", "会员结婚慰问"); + docData.put("way", "现金"); + docData.put("occurTime", condolence.getOccurTime()); + + docData2.put("type", "会员结婚慰问"); + docData2.put("money", "1000"); + docData2.put("money_big", "壹仟元整"); + } else if (("cf4ce7af322d464f8f86d818fcc00203").equals(type)){ + fileName = "工会会员生病住院慰问报销审批单"+ "_" + + DateUtil.format(createTime, "yyyyMMdd") + ".docx"; + templateName = "condolence_hospitalization"; + + docData.put("type", "会员生病慰问"); + docData.put("way", "现金"); + docData.put("hospitalizationTime", condolence.getHospitalizationTime()); + docData.put("leaveHospitalTime", condolence.getLeaveHospitalTime()); + docData.put("thisYearHospitalizationNum", condolence.getThisYearHospitalizationNum()); + + docData2.put("type", "会员生病慰问"); + docData2.put("money", "1000"); + docData2.put("money_big", "壹仟元整"); + } else if (("c90cb10dce6542e99ae271bee6fe8cc0").equals(type)){ + fileName = "工会会员生育慰问报销审批单"+ "_" + + DateUtil.format(createTime, "yyyyMMdd") + ".docx"; + templateName = "condolence_birth"; + + docData.put("type", "会员生育慰问"); + docData.put("way", "现金"); + docData.put("occurTime", condolence.getOccurTime()); + docData.put("hospitalizationTime", condolence.getHospitalizationTime()); + docData.put("leaveHospitalTime", condolence.getLeaveHospitalTime()); + + docData2.put("type", "会员生育慰问"); + docData2.put("money", "1000"); + docData2.put("money_big", "壹仟元整"); + }else if (("4e316737e71047e0b01aea78524c1416").equals(type)){ + fileName = "工会会员直系亲属去世报销审批单"+ "_" + + DateUtil.format(createTime, "yyyyMMdd") + ".docx"; + templateName = "condolence_relative_died"; + + docData.put("type", "会员直系亲属去世慰问"); + docData.put("way", "现金"); + docData.put("relation", condolence.getRelation()); + docData.put("occurTime", condolence.getOccurTime()); + + docData2.put("type", "会员直系亲属去世慰问"); + docData2.put("money", "1000"); + docData2.put("money_big", "壹仟元整"); + }else if (("b8ee30faacb2469593dfedb5b52565aa").equals(type)){ + fileName = "工会会员职工去世慰问报销审批单"+ "_" + + DateUtil.format(createTime, "yyyyMMdd") + ".docx"; + templateName = "condolence_died"; + + docData.put("type", "会员职工去世慰问"); + docData.put("way", "现金"); + docData.put("occurTime", condolence.getOccurTime()); + + docData2.put("type", "会员职工去世慰问"); + docData2.put("money", "3000"); + docData2.put("money_big", "叁仟元整"); + }else if (("1a2f7e8decb649a6ba8ca76e2af07779").equals(type)){ + fileName = "工会会员退休慰问报销审批单"+ "_" + + DateUtil.format(createTime, "yyyyMMdd") + ".docx"; + templateName = "condolence_retirement"; + + docData.put("type", "会员退休慰问"); + docData.put("way", "工会统一发放慰问信及慰问卷"); + docData.put("occurTime", condolence.getOccurTime()); + + docData2.put("type", "会员退休慰问"); + docData2.put("money", "1000"); + docData2.put("money_big", "壹仟元整"); + } else { + fileName = "工会会员慰问报销审批单"+ "_" + + DateUtil.format(createTime, "yyyyMMdd") + ".docx"; + templateName = "condolence_other"; + + docData.put("type", "会员其他慰问"); + docData.put("way", "现金"); + docData.put("occurTime", condolence.getOccurTime()); + } + + List doneTaskVos = new ArrayList<>(); + List doneTaskList = flowEngine.processTaskService().getDoneTaskList(info.getLong("instanceId"), null); + for (ProcessTask doneTask : doneTaskList) { + ProcessTaskVO taskVO = flowEngine.processTaskService().findById(doneTask.getId()); + doneTaskVos.add(taskVO); + } + + // 分工会审核 + doneTaskVos.stream().filter(task -> "分工会审核".equals(task.getDisplayName())) + .max(Comparator.comparing(ProcessTaskVO::getCreatedAt)) + .ifPresent(v -> { + Dict taskFormData = v.getTaskFormData(); + HashMap approval = new HashMap<>(); + + approval.put("date", DateUtil.format(v.getFinishTime(), "yyyy年MM月dd日")); + approval.put("user", taskFormData.getStr("tf_userName")); + if (StrUtil.isNotBlank(taskFormData.getStr("tf_sign"))) { + approval.put("sign", sysOfficeTemplateUtil.createPictureRenderData(taskFormData.getStr("tf_sign"))); + } + approval.put("opinion", taskFormData.getStr("tf_opinion")); + docData.put("fgh", approval); + docData2.put("fgh", approval); + }); + + // 校工会副主席审核 + doneTaskVos.stream().filter(task -> "校工会审核".equals(task.getDisplayName())) + .max(Comparator.comparing(ProcessTaskVO::getCreatedAt)) + .ifPresent(v -> { + Dict taskFormData = v.getTaskFormData(); + HashMap approval = new HashMap<>(); + + approval.put("date", DateUtil.format(v.getFinishTime(), "yyyy年MM月dd日")); + approval.put("user", taskFormData.getStr("tf_userName")); + if (StrUtil.isNotBlank(taskFormData.getStr("tf_sign"))) { + approval.put("sign", sysOfficeTemplateUtil.createPictureRenderData(taskFormData.getStr("tf_sign"))); + } + approval.put("opinion", taskFormData.getStr("tf_opinion")); + docData.put("xzx", approval); + docData2.put("xzx", approval); + }); + + response.setContentType("application/octet-stream"); + response.setHeader("content-disposition", "attachment;filename=" + + URLEncoder.encode("报销审批单.zip", "UTF-8")); + + try (ZipOutputStream zipOut = new ZipOutputStream(response.getOutputStream())) { + ZipEntry zipEntry = new ZipEntry(fileName); + zipOut.putNextEntry(zipEntry); + + try (ByteArrayOutputStream wordOut = new ByteArrayOutputStream()) { + XWPFTemplate.compile(sysOfficeTemplateUtil.getTemplate(templateName)) + .render(docData) + .writeAndClose(wordOut); + zipOut.write(wordOut.toByteArray()); + } + + zipOut.closeEntry(); + + String fileName2 = "武汉城市职业学院报销审批单" + ".docx"; + ZipEntry zipEntry2 = new ZipEntry(fileName2); + zipOut.putNextEntry(zipEntry2); + + try (ByteArrayOutputStream wordOut2 = new ByteArrayOutputStream()) { + XWPFTemplate.compile(sysOfficeTemplateUtil.getTemplate("reimbursement_approval")) + .render(docData2) + .writeAndClose(wordOut2); + zipOut.write(wordOut2.toByteArray()); + } + + zipOut.closeEntry(); + zipOut.finish(); + } catch (IOException e) { + log.error("导出 ZIP 文件失败,ID: {}, 错误信息: {}", id, e.getMessage()); + throw e; + } + } } diff --git a/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/model/Condolence.java b/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/model/Condolence.java index 8d6ce49..724ea8f 100644 --- a/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/model/Condolence.java +++ b/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/model/Condolence.java @@ -293,4 +293,9 @@ public class Condolence extends BaseModel { @ColDefine(type = ColType.INT) private Integer thisYearHospitalizationNum; + @Column + @Comment("与会员的关系") + @ColDefine(type = ColType.VARCHAR, width = 20) + private String relation; + } diff --git a/src/main/resources/views/platform/zhgh/activity/sports/infoManage/addActivity.js b/src/main/resources/views/platform/zhgh/activity/sports/infoManage/addActivity.js index 2183bc5..46bd47d 100644 --- a/src/main/resources/views/platform/zhgh/activity/sports/infoManage/addActivity.js +++ b/src/main/resources/views/platform/zhgh/activity/sports/infoManage/addActivity.js @@ -380,7 +380,7 @@ let ACTIVITY_SPORTS_ADD_ACTIVITY = { - - + + + placeholder="请选择时间"> + + + + + + -