package com.ruoyi.web.controller.project;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.NotRepeatCommit;
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.constant.HttpStatus;
|
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.base.BaseException;
|
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.bean.DtoConversionUtils;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.project.domain.*;
|
import com.ruoyi.project.domain.vo.*;
|
import com.ruoyi.project.mapper.ServiceFunddetailMapper;
|
import com.ruoyi.project.service.*;
|
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysUserService;
|
import freemarker.template.Configuration;
|
import freemarker.template.Template;
|
import freemarker.template.TemplateException;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.ibatis.annotations.Options;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
import org.springframework.transaction.TransactionDefinition;
|
import org.springframework.util.CollectionUtils;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.io.*;
|
import java.math.BigDecimal;
|
import java.text.SimpleDateFormat;
|
import java.time.LocalDate;
|
import java.util.*;
|
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.stream.Collectors;
|
|
import static com.ruoyi.web.controller.project.ServiceReimbursementController.convert;
|
|
/**
|
* 案例统计
|
*
|
* @author ruoyi
|
* @date 2022-01-24
|
*/
|
@Slf4j
|
@Api("案例统计")
|
@RestController
|
@RequestMapping("/project/spstatcase")
|
public class SpStatCaseController extends BaseController {
|
|
@Autowired
|
SpstatCaseService spstatCaseService;
|
|
/**
|
* 查询案例统计
|
*/
|
@ApiOperation("查询案例统计")
|
@PostMapping("/spStatCaselist")
|
public TableDataInfo spStatCaselist(@RequestBody SpStatCaseReq spStatCaseReq) {
|
startPage();
|
return getDataTable(spstatCaseService.getListBypower(spStatCaseReq));
|
}
|
|
/**
|
* 导出案例统计
|
*/
|
@ApiOperation("导出案例统计")
|
@Log(title = "案例统计", businessType = BusinessType.EXPORT)
|
@GetMapping("/export")
|
public AjaxResult export(SpStatCaseReq spStatCaseReq) {
|
List<SpStatCase> list = spstatCaseService.getListBypower(spStatCaseReq);
|
ExcelUtil<SpStatCase> util = new ExcelUtil<SpStatCase>(SpStatCase.class);
|
return util.exportExcel(list, "案例统计数据");
|
}
|
|
/**
|
* 导出案例统计(按业务组)
|
*/
|
@ApiOperation("导出案例统计(按业务组)")
|
@Log(title = "案例统计", businessType = BusinessType.EXPORT)
|
@GetMapping("/exportDept")
|
public AjaxResult exportDept(SpStatCaseReq spStatCaseReq) {
|
List<SpStatCase> list = spstatCaseService.getListBypower(spStatCaseReq);
|
Map<String, SpStatCaseDept> grouped = new LinkedHashMap<String, SpStatCaseDept>();
|
for (SpStatCase row : list) {
|
String key = StringUtils.isNotEmpty(row.getDeptid()) ? row.getDeptid() : row.getDeptname();
|
if (key == null) {
|
key = "";
|
}
|
SpStatCaseDept dept = grouped.get(key);
|
if (dept == null) {
|
dept = new SpStatCaseDept();
|
dept.setDeptname(row.getDeptname() == null ? "未分组" : row.getDeptname());
|
dept.setCaseTotal(0);
|
dept.setTerminationTotal(0);
|
grouped.put(key, dept);
|
}
|
dept.setCaseTotal(dept.getCaseTotal() + toInt(row.getWorkflowsum()));
|
dept.setTerminationTotal(dept.getTerminationTotal() + toInt(row.getTerminationcase()));
|
}
|
List<SpStatCaseDept> result = new ArrayList<SpStatCaseDept>(grouped.values());
|
ExcelUtil<SpStatCaseDept> util = new ExcelUtil<SpStatCaseDept>(SpStatCaseDept.class);
|
return util.exportExcel(result, "案例统计(按业务组)");
|
}
|
|
private int toInt(String value) {
|
if (StringUtils.isEmpty(value)) {
|
return 0;
|
}
|
try {
|
return Integer.parseInt(value.trim());
|
} catch (NumberFormatException e) {
|
return 0;
|
}
|
}
|
|
|
}
|