sinake
2 天以前 49120f2b9db33455756a911e56cfefd7c3120a14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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;
        }
    }
 
 
}