yyy
2026-04-21 6f55da80d19cba61bd23cd302b76bbb23038f7bd
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
package com.xiaopeng.operation.controller;
 
 
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.xiaopeng.api.model.account.SysUser;
import com.xiaopeng.api.model.operation.XpPasswordFreePolicy;
import com.xiaopeng.api.model.operation.XpPointSituationReport;
import com.xiaopeng.api.query.operation.XpPointSituationReportQuery;
import com.xiaopeng.api.vo.account.LoginOperationUser;
import com.xiaopeng.api.vo.operation.XpPointSituationReportVo;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.utils.WebUtils;
import com.xiaopeng.common.core.web.page.PageInfo;
import com.xiaopeng.common.security.service.TokenService;
import com.xiaopeng.operation.exportExcle.XpPointSituationReportExportExcel;
import com.xiaopeng.operation.service.IXpPointSituationReportService;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
 
@RestController
@RequestMapping("")
public class XpPointSituationReportController {
 
    @Resource
    private IXpPointSituationReportService xpPointSituationReportService;
 
    @Resource
    private TokenService tokenService;
 
 
 
    /**
     * 分页查询路线规划配置列表
     */
    @ApiOperation(value = "现场情况上报分页列表", tags = {"管理后台-运维-现场情况上报"}, response = XpPasswordFreePolicy.class)
    @PostMapping("/api/v1/pointSituationReport/pageList")
    public R<PageInfo<XpPointSituationReportVo>> pageList(@RequestBody XpPointSituationReportQuery query) {
        PageInfo<XpPointSituationReportVo> pageInfo = xpPointSituationReportService.pageList(query);
        return R.ok(pageInfo);
    }
 
 
    /**
     * 删除路线规划配置
     */
    @ApiOperation(value = "详情现场情况上报", tags = {"管理后台-运维-现场情况上报"})
    @DeleteMapping("/api/v1/pointSituationReport/getdetail/{id}")
    public R<?> getdetail(@PathVariable Long id) {
        xpPointSituationReportService.getdetail(id);
        return R.ok();
    }
 
 
    /**
     * 删除路线规划配置
     */
    @ApiOperation(value = "删除现场情况上报", tags = {"管理后台-运维-现场情况上报"})
    @DeleteMapping("/api/v1/pointSituationReport/deleteById/{id}")
    public R<?> deleteById(@PathVariable Long id) {
        xpPointSituationReportService.deleteById(id);
        return R.ok();
    }
 
    @ApiOperation(value = "导出现场情况上报", tags = {"管理后台-运维-现场情况上报"})
    @PostMapping(value = "/api/v1/pointSituationReport/exportExcels")
    public void exportExcels(@RequestBody XpPointSituationReportQuery query) {
        List<XpPointSituationReportVo> exportList = xpPointSituationReportService.exportList(query);
        List<XpPointSituationReportExportExcel> exportExcels = new ArrayList<>();
        long sequence = 1L;
        for (XpPointSituationReportVo bean : exportList) {
            XpPointSituationReportExportExcel exportExcel = new XpPointSituationReportExportExcel();
            BeanUtils.copyProperties(bean,exportExcel);
            exportExcel.setId(sequence++);
            LocalDateTime time = bean.getReportingTime();
            exportExcel.setReportingTimeStr(time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")));
            exportExcels.add(exportExcel);
        }
        SysUser sysUser = tokenService.getLoginUser().getSysUser();
        //1.获取excel模板
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), XpPointSituationReportExportExcel.class, exportExcels);
        HttpServletResponse response = WebUtils.response();
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("现场情况上报列表.xls", "utf-8");
            response.setHeader("Content-dispodition", "attachment;filename=" + fileName);
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
 
    }
 
 
    @ApiOperation(value = "现场情况上报", tags = {"运维APP-站点管理"}, response = XpPointSituationReport.class)
    @PostMapping("/maintenance-app/api/v1/pointSituationReport/addPointSituationReport")
    public R<?> addPointSituationReport(@RequestBody XpPointSituationReport xpPointSituationReport){
        LoginOperationUser loginOperationUser = tokenService.getLoginOperationUser();
        xpPointSituationReport.setOperationsUserId(loginOperationUser.getId());
        xpPointSituationReport.setReportingTime(LocalDateTime.now());
        xpPointSituationReport.setDeleted(false);
        xpPointSituationReportService.save(xpPointSituationReport);
        return R.ok();
    }
}