| | |
| | | package com.xiaopeng.operation.controller; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.xiaopeng.api.feignClient.account.XpOperationUserClient; |
| | | import com.xiaopeng.api.model.account.SysUser; |
| | | import com.xiaopeng.api.model.account.XpOperationsUser; |
| | | 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.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.common.security.service.TokenService; |
| | | import com.xiaopeng.operation.exportExcle.XpPointSituationReportExportExcel; |
| | | import com.xiaopeng.operation.service.IXpPointSituationReportService; |
| | | import com.xiaopeng.operation.vo.XpAgreementVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RestController |
| | | @RequestMapping("") |
| | | @Api("现场情况上报") |
| | | public class XpPointSituationReportController { |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private XpOperationUserClient xpOperationUserClient; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 分页查询路线规划配置列表 |
| | | */ |
| | | @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 = {"运维APP-站点管理"}, response = XpPointSituationReport.class) |
| | | /** |
| | | * 详情现场情况上报 |
| | | */ |
| | | @ApiOperation(value = "详情现场情况上报", tags = {"管理后台-运维-现场情况上报"}) |
| | | @GetMapping("/api/v1/pointSituationReport/getdetail/{id}") |
| | | public R<?> getdetail(@PathVariable Long id) { |
| | | XpPointSituationReportVo detail = xpPointSituationReportService.getdetail(id); |
| | | return R.ok(detail); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除路线规划配置 |
| | | */ |
| | | @ApiOperation(value = "删除现场情况上报", tags = {"管理后台-运维-现场情况上报"}) |
| | | @DeleteMapping("/api/v1/pointSituationReport/deleteById/{id}") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.POINT_SITUATION_REPORT, |
| | | operationType = AdminOperationType.DELETE, |
| | | contentExpression = "'删除现场情况上报,id=' + #p0", |
| | | appendRequestData = false |
| | | ) |
| | | public R<?> deleteById(@PathVariable Long id) { |
| | | |
| | | try { |
| | | boolean b = xpPointSituationReportService.deleteById(id); |
| | | if(b){ |
| | | return R.ok(); |
| | | } |
| | | return R.fail("删除失败"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @ApiOperation(value = "导出现场情况上报", tags = {"管理后台-运维-现场情况上报"}) |
| | | @PostMapping(value = "/api/v1/pointSituationReport/exportExcels") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.POINT_SITUATION_REPORT, |
| | | operationType = AdminOperationType.EXPORT, |
| | | content = "导出现场情况上报", |
| | | appendRequestData = true |
| | | ) |
| | | public void exportExcels(@RequestBody XpPointSituationReportQuery query) { |
| | | if(query.getIds().isEmpty()){ |
| | | return; |
| | | } |
| | | 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(); |