慰问申请表导出
This commit is contained in:
+177
-65
@@ -3,6 +3,8 @@ package com.budwk.app.zhgh.staffbenefit.condolence.controller;
|
|||||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import cn.dev33.satoken.annotation.SaMode;
|
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.core.util.StrUtil;
|
||||||
import com.budwk.app.base.annotation.SLog;
|
import com.budwk.app.base.annotation.SLog;
|
||||||
import com.budwk.app.base.constant.RoleConstant;
|
import com.budwk.app.base.constant.RoleConstant;
|
||||||
@@ -11,18 +13,26 @@ import com.budwk.app.base.param.PageForm;
|
|||||||
import com.budwk.app.base.result.Result;
|
import com.budwk.app.base.result.Result;
|
||||||
import com.budwk.app.base.utils.CommonDownloadUtil;
|
import com.budwk.app.base.utils.CommonDownloadUtil;
|
||||||
import com.budwk.app.base.utils.PageUtil;
|
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.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.sys.views.View_user;
|
||||||
import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
||||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||||
|
import com.budwk.app.web.commons.base.Globals;
|
||||||
import com.budwk.app.zhgh.democratic.proposal.models.ProposalInfo;
|
import com.budwk.app.zhgh.democratic.proposal.models.ProposalInfo;
|
||||||
import com.budwk.app.zhgh.staffbenefit.condolence.model.Condolence;
|
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.model.CondolenceType;
|
||||||
import com.budwk.app.zhgh.staffbenefit.condolence.service.CondolenceService;
|
import com.budwk.app.zhgh.staffbenefit.condolence.service.CondolenceService;
|
||||||
|
import com.deepoove.poi.XWPFTemplate;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||||
|
import org.nutz.boot.starter.ftp.FtpService;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
|
import org.nutz.dao.Dao;
|
||||||
import org.nutz.dao.FieldFilter;
|
import org.nutz.dao.FieldFilter;
|
||||||
import org.nutz.dao.Sqls;
|
import org.nutz.dao.Sqls;
|
||||||
import org.nutz.dao.sql.Sql;
|
import org.nutz.dao.sql.Sql;
|
||||||
@@ -41,6 +51,10 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName CondolenceApplyController
|
* @ClassName CondolenceApplyController
|
||||||
@@ -53,30 +67,39 @@ import java.io.IOException;
|
|||||||
@At("/platform/condolence/mine")
|
@At("/platform/condolence/mine")
|
||||||
@Api("职工慰问我的")
|
@Api("职工慰问我的")
|
||||||
@Ok("json:full")
|
@Ok("json:full")
|
||||||
|
@Slf4j
|
||||||
public class CondolenceMineController {
|
public class CondolenceMineController {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CondolenceService condolenceService;
|
private CondolenceService condolenceService;
|
||||||
@Inject
|
@Inject
|
||||||
private FlowEngine flowEngine;
|
private FlowEngine flowEngine;
|
||||||
|
@Inject
|
||||||
|
private FtpService ftpService;
|
||||||
|
@Inject
|
||||||
|
private Dao dao;
|
||||||
|
@Inject
|
||||||
|
private SysOfficeTemplateUtil sysOfficeTemplateUtil;
|
||||||
|
|
||||||
@At("/")
|
@At("/")
|
||||||
@Ok("beetl:/platform/zhgh/staffbenefit/condolence/mine/index.html")
|
@Ok("beetl:/platform/zhgh/staffbenefit/condolence/mine/index.html")
|
||||||
@SaCheckPermission("condolence.mine")
|
@SaCheckPermission("condolence.mine")
|
||||||
public void index() {}
|
public void index() {
|
||||||
|
}
|
||||||
|
|
||||||
@At("/h5")
|
@At("/h5")
|
||||||
@Ok("beetl:/platform/zhghh5/staffbenefit/condolence/mine/index.html")
|
@Ok("beetl:/platform/zhghh5/staffbenefit/condolence/mine/index.html")
|
||||||
@SaCheckPermission("h5.condolence.mine")
|
@SaCheckPermission("h5.condolence.mine")
|
||||||
public void h5Index() {}
|
public void h5Index() {
|
||||||
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@ApiOperation("分页查询")
|
@ApiOperation("分页查询")
|
||||||
@SaCheckPermission(value = {"condolence.mine", "h5.condolence.mine"}, mode = SaMode.OR)
|
@SaCheckPermission(value = {"condolence.mine", "h5.condolence.mine"}, mode = SaMode.OR)
|
||||||
public Result pageData(PageForm pageForm,
|
public Result pageData(PageForm pageForm,
|
||||||
@Param(value = "year") Integer year,
|
@Param(value = "year") Integer year,
|
||||||
@Param(value = "type") String type) {
|
@Param(value = "type") String type) {
|
||||||
Sql sql = Sqls.create("""
|
Sql sql = Sqls.create("""
|
||||||
SELECT
|
SELECT
|
||||||
info.*,
|
info.*,
|
||||||
type.name as typeName,
|
type.name as typeName,
|
||||||
@@ -104,59 +127,148 @@ public class CondolenceMineController {
|
|||||||
LEFT JOIN wf_process_task_actor ta ON ta.processTaskId = t.id
|
LEFT JOIN wf_process_task_actor ta ON ta.processTaskId = t.id
|
||||||
$condition
|
$condition
|
||||||
""");
|
""");
|
||||||
Cnd cnd = Cnd.NEW();
|
Cnd cnd = Cnd.NEW();
|
||||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||||
seg.or(Condolence::getHelpUserName, "like", "%" + pageForm.getSearchKeyword() + "%");
|
seg.or(Condolence::getHelpUserName, "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||||
seg.or(Condolence::getHelpLoginName, "like", "%" + pageForm.getSearchKeyword() + "%");
|
seg.or(Condolence::getHelpLoginName, "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||||
cnd.and(seg);
|
cnd.and(seg);
|
||||||
}
|
}
|
||||||
cnd.andEX("year(info.createTime)", "=", year);
|
cnd.andEX("year(info.createTime)", "=", year);
|
||||||
cnd.andEX("info.type", "=", type);
|
cnd.andEX("info.type", "=", type);
|
||||||
cnd.and("info.createdBy", "=", SecurityUtil.getUserId());
|
cnd.and("info.createdBy", "=", SecurityUtil.getUserId());
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(pageForm.getPageOrderName()) && StrUtil.isNotBlank(pageForm.getPageOrderBy())) {
|
if (StrUtil.isNotBlank(pageForm.getPageOrderName()) && StrUtil.isNotBlank(pageForm.getPageOrderBy())) {
|
||||||
cnd.orderBy(pageForm.getPageOrderName(), PageUtil.getOrder(pageForm.getPageOrderBy()));
|
cnd.orderBy(pageForm.getPageOrderName(), PageUtil.getOrder(pageForm.getPageOrderBy()));
|
||||||
} else {
|
} else {
|
||||||
cnd.desc("info.createTime");
|
cnd.desc("info.createTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
sql.setCondition(cnd);
|
sql.setCondition(cnd);
|
||||||
Pagination<NutMap> pagination = condolenceService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
Pagination<NutMap> pagination = condolenceService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||||
return Result.success(pagination);
|
return Result.success(pagination);
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@ApiOperation("删除")
|
@ApiOperation("删除")
|
||||||
@Aop(TransAop.READ_COMMITTED)
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
@SaCheckPermission(value = {"condolence.mine", "h5.condolence.mine"}, mode = SaMode.OR)
|
@SaCheckPermission(value = {"condolence.mine", "h5.condolence.mine"}, mode = SaMode.OR)
|
||||||
@SLog(tag = "职工慰问系统-我的申请", msg = "删除职工慰问")
|
@SLog(tag = "职工慰问系统-我的申请", msg = "删除职工慰问")
|
||||||
public Result delete(@Param("id") String id) {
|
public Result delete(@Param("id") String id) {
|
||||||
condolenceService.delete(id);
|
condolenceService.delete(id);
|
||||||
flowEngine.processInstanceService().deleteProcessInstanceByBusinessKey(id);
|
flowEngine.processInstanceService().deleteProcessInstanceByBusinessKey(id);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@ApiOperation("查询单个慰问申请信息")
|
@ApiOperation("查询单个慰问申请信息")
|
||||||
@SaCheckPermission("condolence")
|
@SaCheckPermission("condolence")
|
||||||
public Result info(String id) {
|
public Result info(String id) {
|
||||||
Condolence condolence = condolenceService.fetch(id);
|
Condolence condolence = condolenceService.fetch(id);
|
||||||
CondolenceType type = condolenceService.dao().fetch(CondolenceType.class, Cnd.where(CondolenceType::getId, "=", condolence.getType()));
|
CondolenceType type = condolenceService.dao().fetch(CondolenceType.class, Cnd.where(CondolenceType::getId, "=", condolence.getType()));
|
||||||
NutMap nutMap = Lang.obj2nutmap(condolence);
|
NutMap nutMap = Lang.obj2nutmap(condolence);
|
||||||
nutMap.put("typeName", type.getName());
|
nutMap.put("typeName", type.getName());
|
||||||
return Result.success(nutMap);
|
return Result.success(nutMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@ApiOperation("导出单个慰问申请信息")
|
@ApiOperation("导出单个慰问申请信息")
|
||||||
@SaCheckPermission("condolence")
|
@SaCheckPermission("condolence")
|
||||||
public void onExport(@Valid String id, HttpServletResponse response){
|
public void onExport(@Valid String id, HttpServletResponse response) throws ParseException {
|
||||||
Condolence condolence = condolenceService.fetch(id);
|
HashMap<String, Object> docData = new HashMap<>();
|
||||||
|
|
||||||
String fileName;
|
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
|
||||||
|
info.id = @id
|
||||||
|
""").setParam("id", id);
|
||||||
|
sql.setCallback(Sqls.callback.map());
|
||||||
|
dao.execute(sql);
|
||||||
|
NutMap info = (NutMap) sql.getResult();
|
||||||
|
|
||||||
|
// 根据慰问类型选择不同的模板和文件名
|
||||||
|
String type = info.getString("type");
|
||||||
|
String templateName;
|
||||||
|
String fileName;
|
||||||
|
|
||||||
|
if ("a6be188e586e4df091d0fcc37b5ecfd0".equals(type)) {
|
||||||
|
templateName = "zzjzgqs_table";
|
||||||
|
fileName = "河北地质大学在职教职工去世慰问金额申请表" + ".docx";
|
||||||
|
} else {
|
||||||
|
templateName = "zzjzgfmqs_table";
|
||||||
|
fileName = "河北地质大学在职教职工父母去世慰问金额申请表" + ".docx";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 添加日期格式化处理
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
|
||||||
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
}
|
if (info.get("createTime") != null) {
|
||||||
|
if (info.get("createTime") instanceof String) {
|
||||||
|
String createTimeStr = (String) info.get("createTime");
|
||||||
|
Date date = inputFormat.parse(createTimeStr);
|
||||||
|
info.put("createTime", sdf.format(date));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(info.getString("signature"))) {
|
||||||
|
info.put("signature", sysOfficeTemplateUtil.createPictureRenderData(info.getString("signature")));
|
||||||
|
}
|
||||||
|
|
||||||
|
docData.put("schoolName", Globals.AppName);
|
||||||
|
docData.put("info", info);
|
||||||
|
|
||||||
|
List<ProcessTaskVO> doneTaskVos = new ArrayList<>();
|
||||||
|
List<ProcessTask> 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<String, Object> 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_userSign"))) {
|
||||||
|
approval.put("sign", sysOfficeTemplateUtil.createPictureRenderData(taskFormData.getStr("tf_userSign")));
|
||||||
|
}
|
||||||
|
approval.put("opinion", taskFormData.getStr("tf_opinion"));
|
||||||
|
docData.put("fgh", approval);
|
||||||
|
});
|
||||||
|
|
||||||
|
doneTaskVos.stream().filter(task -> "校工会审核".equals(task.getDisplayName()))
|
||||||
|
.max(Comparator.comparing(ProcessTaskVO::getCreatedAt))
|
||||||
|
.ifPresent(v -> {
|
||||||
|
Dict taskFormData = v.getTaskFormData();
|
||||||
|
HashMap<String, Object> 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_userSign"))) {
|
||||||
|
approval.put("sign", sysOfficeTemplateUtil.createPictureRenderData(taskFormData.getStr("tf_userSign")));
|
||||||
|
}
|
||||||
|
approval.put("opinion", taskFormData.getStr("tf_opinion"));
|
||||||
|
docData.put("xgh", approval);
|
||||||
|
});
|
||||||
|
|
||||||
|
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
||||||
|
XWPFTemplate.compile(sysOfficeTemplateUtil.getTemplate(templateName)).render(docData).writeAndClose(byteArrayOutputStream);
|
||||||
|
CommonDownloadUtil.download(fileName, byteArrayOutputStream.toByteArray(), response);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("河北地质大学教在职职工去世/在职教职工父母去世慰问金额申请表导出失败,id:{},错误信息:{}", id, e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user