feat(bpm): 添加生产开支申请 Excel 导出功能
- 新增 BpmOAExpensesExportVO 类用于 Excel 导出 - 在 BpmOAExpensesController 中添加 exportExpensesExcel 方法处理导出逻辑 - 在 BpmOAExpensesService 接口中定义 convertExpensesList 方法用于数据转换- 在 BpmOAExpensesServiceImpl 中实现 convertExpensesList 方法,将费用列表转换为导出 VO 列表
This commit is contained in:
parent
411812d35b
commit
f9efa7aea0
@ -1,8 +1,11 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.expenses.*;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAExpensesDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAExpensesService;
|
||||
@ -13,9 +16,13 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
/**
|
||||
@ -106,4 +113,19 @@ public class BpmOAExpensesController {
|
||||
expensesService.oneClickPayment(month);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出生产开支申请 Excel")
|
||||
@DataPermission(enable = false)
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportExpensesExcel(@Valid BpmOAExpensesPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
PageResult<BpmOAExpensesPageRespVO> pageResult = expensesService.getExpensesPage(pageReqVO);
|
||||
//转换
|
||||
List<BpmOAExpensesExportVO> list = expensesService.convertExpensesList(pageResult.getList());
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "生产开支申请.xls", "数据", BpmOAExpensesExportVO.class, list);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.expenses;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 生产开支 Excel 导出 VO
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false)
|
||||
public class BpmOAExpensesExportVO {
|
||||
|
||||
@ExcelProperty("申请用户")
|
||||
private String userName;
|
||||
|
||||
// @ExcelProperty("费用类型")
|
||||
private Integer type;
|
||||
|
||||
// @ExcelProperty("费用板块")
|
||||
private Integer costSection;
|
||||
|
||||
@ExcelProperty("费用类型 bpm_oa_expenses_type")
|
||||
private String typeName;
|
||||
|
||||
@ExcelProperty("费用板块 费用板块 | 1叉车 2打包 3搬运 4运输")
|
||||
private String costSectionName;
|
||||
|
||||
@ExcelProperty("费用产生部门")
|
||||
private String deptName;
|
||||
|
||||
@ExcelProperty("支出金额(元)")
|
||||
private BigDecimal amount;
|
||||
|
||||
@ExcelProperty("费用明细")
|
||||
private String detail;
|
||||
|
||||
@ExcelProperty("报销总金额(元)")
|
||||
private BigDecimal totalMoney;
|
||||
|
||||
@ExcelProperty("收款人")
|
||||
private String payeeName;
|
||||
|
||||
@ExcelProperty("开户行")
|
||||
private String bankName;
|
||||
|
||||
@ExcelProperty("银行卡号")
|
||||
private String bankNo;
|
||||
|
||||
// @ExcelProperty("审批时间")
|
||||
private String endTime;
|
||||
|
||||
// @ExcelProperty("支付状态")
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("支付状态 | 0未支付 1已支付")
|
||||
private String statusName;
|
||||
|
||||
|
||||
}
|
@ -97,4 +97,11 @@ public interface BpmOAExpensesService {
|
||||
* @param month 月份
|
||||
*/
|
||||
void oneClickPayment(String month);
|
||||
|
||||
/**
|
||||
* 转换
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
List<BpmOAExpensesExportVO> convertExpensesList(List<BpmOAExpensesPageRespVO> list);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -25,6 +27,8 @@ import cn.iocoder.yudao.module.smartfactory.api.staff.StaffApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO;
|
||||
import cn.iocoder.yudao.module.system.api.bank.BankApi;
|
||||
import cn.iocoder.yudao.module.system.api.bank.dto.BankRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.loan.LoanApi;
|
||||
import cn.iocoder.yudao.module.system.api.loan.dto.LoanDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
@ -39,6 +43,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -92,6 +97,8 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
|
||||
@Resource
|
||||
private StaffApi staffApi;
|
||||
@Resource
|
||||
private DictDataApi dictDataApi;
|
||||
|
||||
@Override
|
||||
public Long createExpenses(Long userId, BpmOAExpensesCreateReqVO createReqVO) {
|
||||
@ -160,7 +167,7 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
// 设置开支日报支付状态为 已抵扣
|
||||
expenses.setStatus(2).setAmountPaid(expenses.getTotalMoney());
|
||||
|
||||
}else {
|
||||
} else {
|
||||
|
||||
// 设置开支日报支付状态为 未抵扣完毕
|
||||
expenses.setStatus(3).setAmountPaid(loanDTO.getRemainingAmount());
|
||||
@ -237,7 +244,7 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
|
||||
@Override
|
||||
public PageResult<BpmOAExpensesPageRespVO> getExpensesPage(BpmOAExpensesPageReqVO pageReqVO) {
|
||||
IPage<BpmOAExpensesPageRespVO> page = expensesMapper.selectExpensesPage(MyBatisUtils.buildPage(pageReqVO) ,pageReqVO);
|
||||
IPage<BpmOAExpensesPageRespVO> page = expensesMapper.selectExpensesPage(MyBatisUtils.buildPage(pageReqVO), pageReqVO);
|
||||
return new PageResult<>(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@ -295,7 +302,7 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExpenses(Long id ,Integer status, BigDecimal amountPaid) {
|
||||
public void updateExpenses(Long id, Integer status, BigDecimal amountPaid) {
|
||||
|
||||
expensesMapper.updateById(new BpmOAExpensesDO()
|
||||
.setId(id)
|
||||
@ -320,4 +327,26 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
|
||||
expensesMapper.oneClickPayment(month);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BpmOAExpensesExportVO> convertExpensesList(List<BpmOAExpensesPageRespVO> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Map<Integer, String> costSectionMap = new HashMap<>();
|
||||
costSectionMap.put(1, "叉车");
|
||||
costSectionMap.put(2, "打包");
|
||||
costSectionMap.put(3, "搬运");
|
||||
costSectionMap.put(4, "运输");
|
||||
List<DictDataRespDTO> bpmOaExpensesType = dictDataApi.getDictDataList("bpm_oa_expenses_type").getCheckedData();
|
||||
Map<String, String> typeMap = bpmOaExpensesType.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
|
||||
List<BpmOAExpensesExportVO> vos = BeanUtil.copyToList(list, BpmOAExpensesExportVO.class);
|
||||
for (BpmOAExpensesExportVO vo : vos) {
|
||||
vo.setTypeName(typeMap.get(String.valueOf(vo.getType())));
|
||||
vo.setStatusName(vo.getStatus() == 0 ? "未支付" : "已支付");
|
||||
// 费用板块 费用板块 | 1叉车 2打包 3搬运 4运输
|
||||
vo.setCostSectionName(costSectionMap.get(vo.getCostSection()));
|
||||
}
|
||||
return vos;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user