xuhy
2025-11-12 30bd0425caaee2e105aac054bcdf94e9a58a2d3b
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package com.ruoyi.web.controller.api;
 
 
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.WebUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.HandleAppealServicesDTO;
import com.ruoyi.system.export.TAppealServicesExport;
import com.ruoyi.system.export.TRefundOrderExport;
import com.ruoyi.system.model.TAppealServices;
import com.ruoyi.system.query.TAppealServicesQuery;
import com.ruoyi.system.query.TCourseOrderQuery;
import com.ruoyi.system.service.TAppealServicesService;
import com.ruoyi.system.vo.TAppealServicesVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
 
/**
 * <p>
 * 诉求服务 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-11-06
 */
@Api(tags = "诉求服务管理")
@RestController
@RequestMapping("/t-appeal-services")
public class TAppealServicesController {
 
    private final TAppealServicesService appealServicesService;
    private final TokenService tokenService;
    @Autowired
    public TAppealServicesController(TAppealServicesService appealServicesService, TokenService tokenService) {
        this.appealServicesService = appealServicesService;
        this.tokenService = tokenService;
    }
 
    /**
     * 获取诉求服务管理管理列表
     */
    @ApiOperation(value = "获取诉求服务管理分页列表")
    @PostMapping(value = "/pageList")
    public R<PageInfo<TAppealServicesVO>> pageList(@Validated @RequestBody TAppealServicesQuery query) {
        return R.ok(appealServicesService.pageList(query));
    }
    /**
     * 获取诉求服务管理管理列表
     */
    @ApiOperation(value = "获取诉求服务管理分页列表-大屏使用")
    @PostMapping(value = "/pageListLarge")
    public R<PageInfo<TAppealServicesVO>> pageListLarge(@RequestBody TAppealServicesQuery query) {
        return R.ok(appealServicesService.pageList(query));
    }
 
    /**
     * 获取诉求服务管理管理列表
     */
    @ApiOperation(value = "获取诉求服务管理列表")
    @PostMapping(value = "/list")
    public R<List<TAppealServices>> list() {
        return R.ok(appealServicesService.list(Wrappers.lambdaQuery(TAppealServices.class).orderByDesc(TAppealServices::getCreateTime)));
    }
 
    /**
     * 查看诉求服务管理详情
     */
    @ApiOperation(value = "查看诉求服务管理详情")
    @GetMapping(value = "/getDetailById")
    public R<TAppealServices> getDetailById(@RequestParam String id) {
        return R.ok(appealServicesService.getById(id));
    }
 
    /**
     * 删除诉求服务管理
     */
    @Log(title = "诉求服务管理信息-删除诉求服务管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除诉求服务管理")
    @DeleteMapping(value = "/deleteById")
    public R<Boolean> deleteById(@RequestParam String id) {
        return R.ok(appealServicesService.removeById(id));
    }
 
    /**
     * 批量删除诉求服务管理
     */
    @Log(title = "诉求服务管理信息-删除诉求服务管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "批量删除诉求服务管理")
    @DeleteMapping(value = "/deleteByIds")
    public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
        return R.ok(appealServicesService.removeByIds(ids));
    }
 
    /**
     * 处理诉求
     */
    @Log(title = "诉求服务管理信息-处理诉求", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "处理诉求")
    @PostMapping(value = "/handleAppealServices")
    public R<String> handleAppealServices(@RequestBody HandleAppealServicesDTO dto) {
 
        Long userId = tokenService.getLoginUser().getUserId();
        String nickName = tokenService.getLoginUser().getUser().getNickName();
 
        TAppealServices appealServices = appealServicesService.getById(dto.getId());
        appealServices.setStatus(2);
        appealServices.setUserId(userId);
        appealServices.setProcessPersonName(nickName);
        appealServices.setProcessTime(LocalDateTime.now());
        appealServices.setProcessRemark(dto.getProcessRemark());
        appealServices.setProcessPictures(dto.getProcessPictures());
        appealServicesService.updateById(appealServices);
        return R.ok();
    }
 
 
    @Log(title = "诉求服务管理信息-群众诉求服务导出", businessType = BusinessType.EXPORT)
    @ApiOperation(value = "群众诉求服务导出")
    @PostMapping("/exportAppealServices")
    public void exportAppealServices(@RequestBody TAppealServicesQuery query){
        query.setAppealType(1);
        List<TAppealServicesExport> appealServicesExports = appealServicesService.exportAppealServices(query);
        for (TAppealServicesExport appealServicesExport : appealServicesExports) {
            if(Objects.nonNull(appealServicesExport.getCreateTime())){
                appealServicesExport.setCreateTimeStr(DateUtils.localDateTimeToString(appealServicesExport.getCreateTime()));
            }
            if(Objects.nonNull(appealServicesExport.getProcessTime())){
                appealServicesExport.setProcessTimeStr(DateUtils.localDateTimeToString(appealServicesExport.getProcessTime()));
            }
        }
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TAppealServicesExport.class, appealServicesExports);
        HttpServletResponse response = WebUtils.response();
        assert response != null;
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("群众诉求服务导出.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
 
    @Log(title = "诉求服务管理信息-随心拍导出", businessType = BusinessType.EXPORT)
    @ApiOperation(value = "随心拍导出")
    @PostMapping("/exportAppealServicesGratified")
    public void exportAppealServicesGratified(@RequestBody TAppealServicesQuery query){
        query.setAppealType(2);
        List<TAppealServicesExport> appealServicesExports = appealServicesService.exportAppealServices(query);
        for (TAppealServicesExport appealServicesExport : appealServicesExports) {
            if(Objects.nonNull(appealServicesExport.getCreateTime())){
                appealServicesExport.setCreateTimeStr(DateUtils.localDateTimeToString(appealServicesExport.getCreateTime()));
            }
            if(Objects.nonNull(appealServicesExport.getProcessTime())){
                appealServicesExport.setProcessTimeStr(DateUtils.localDateTimeToString(appealServicesExport.getProcessTime()));
            }
        }
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TAppealServicesExport.class, appealServicesExports);
        HttpServletResponse response = WebUtils.response();
        assert response != null;
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("随心拍导出.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    
}