| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.project.domain.SpStatExpense; |
| | | import com.ruoyi.project.domain.SpStatExpenseDept; |
| | | import com.ruoyi.project.domain.SpStatExpenseReq; |
| | | import com.ruoyi.project.service.SpstatExpenseService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 报销统计 |
| | |
| | | return util.exportExcel(list, "费用统计数据"); |
| | | } |
| | | |
| | | /** |
| | | * 导出费用统计(按业务组) |
| | | */ |
| | | @ApiOperation("导出费用统计(按业务组)") |
| | | @Log(title = "费用统计", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/exportDept") |
| | | public AjaxResult exportDept(SpStatExpenseReq spStatExpenseReq) { |
| | | List<SpStatExpense> list = spstatExpenseService.getListBySpstatExpense(spStatExpenseReq); |
| | | Map<String, SpStatExpenseDept> grouped = new LinkedHashMap<String, SpStatExpenseDept>(); |
| | | for (SpStatExpense row : list) { |
| | | String key = row.getDeptmentno() != null ? row.getDeptmentno() : row.getDeptmentName(); |
| | | if (key == null) { |
| | | key = ""; |
| | | } |
| | | SpStatExpenseDept dept = grouped.get(key); |
| | | if (dept == null) { |
| | | dept = new SpStatExpenseDept(); |
| | | dept.setDeptname(row.getDeptmentName() == null ? "未分组" : row.getDeptmentName()); |
| | | dept.setAmount(BigDecimal.ZERO); |
| | | dept.setExpertfee(BigDecimal.ZERO); |
| | | dept.setEthicalistfee(BigDecimal.ZERO); |
| | | dept.setMedicalcost(BigDecimal.ZERO); |
| | | dept.setOfficecost(BigDecimal.ZERO); |
| | | dept.setReimcost(BigDecimal.ZERO); |
| | | grouped.put(key, dept); |
| | | } |
| | | dept.setAmount(dept.getAmount().add(nz(row.getAmount()))); |
| | | dept.setExpertfee(dept.getExpertfee().add(nz(row.getExpertfee()))); |
| | | dept.setEthicalistfee(dept.getEthicalistfee().add(nz(row.getEthicalistfee()))); |
| | | dept.setMedicalcost(dept.getMedicalcost().add(nz(row.getMedicalcost()))); |
| | | dept.setOfficecost(dept.getOfficecost().add(nz(row.getOfficecost()))); |
| | | dept.setReimcost(dept.getReimcost().add(nz(row.getReimcost()))); |
| | | } |
| | | List<SpStatExpenseDept> result = new ArrayList<SpStatExpenseDept>(grouped.values()); |
| | | for (SpStatExpenseDept dept : result) { |
| | | dept.setAmount(blankZero(dept.getAmount())); |
| | | dept.setExpertfee(blankZero(dept.getExpertfee())); |
| | | dept.setEthicalistfee(blankZero(dept.getEthicalistfee())); |
| | | dept.setMedicalcost(blankZero(dept.getMedicalcost())); |
| | | dept.setOfficecost(blankZero(dept.getOfficecost())); |
| | | dept.setReimcost(blankZero(dept.getReimcost())); |
| | | } |
| | | ExcelUtil<SpStatExpenseDept> util = new ExcelUtil<SpStatExpenseDept>(SpStatExpenseDept.class); |
| | | return util.exportExcel(result, "费用统计(按业务组)"); |
| | | } |
| | | |
| | | private BigDecimal nz(BigDecimal value) { |
| | | return value == null ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | private BigDecimal blankZero(BigDecimal value) { |
| | | return (value == null || value.compareTo(BigDecimal.ZERO) == 0) ? null : value; |
| | | } |