| | |
| | | package com.dy.pipIrrBase.rtuUpgrade.task; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.support.ExcelTypeEnum; |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.common.webUtil.ResultCodeMsg; |
| | | import com.dy.pipIrrGlobal.pojoRm.UgRtuTask; |
| | | import com.dy.pipIrrGlobal.pojoUg.UgRtuTask; |
| | | import com.dy.pipIrrGlobal.voUg.VoUgResult; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.media.Content; |
| | |
| | | import io.swagger.v3.oas.annotations.responses.ApiResponse; |
| | | import io.swagger.v3.oas.annotations.responses.ApiResponses; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | if (vo.taskId == null) { |
| | | return BaseResponseUtils.buildErrorMsg("升级任务id不能为空"); |
| | | } |
| | | try { |
| | | QueryResultVo<List<VoUgResult>> res = this.sv.selectSome(vo); |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("查询RTU升级任务异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | if(vo.state != null && vo.state == 1){ |
| | | //查询升级成功的 |
| | | vo.fail = null ; |
| | | } |
| | | if(vo.state == null && vo.fail != null){ |
| | | //查询升级失败的 |
| | | vo.state = 0 ; |
| | | } |
| | | QueryResultVo<List<VoUgResult>> res = this.sv.selectSome(vo); |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } |
| | | |
| | | /** |
| | | * 导出升级结果RTU列表 |
| | | * @param response |
| | | */ |
| | | @RequestMapping(value = "/exportAll", method = RequestMethod.GET) |
| | | @SsoAop() |
| | | public void exportAll(HttpServletResponse response, QueryUgResultVo vo) throws Exception { |
| | | if(vo.state != null && vo.state == 1){ |
| | | //查询升级成功的 |
| | | vo.fail = null ; |
| | | } |
| | | if(vo.state == null && vo.fail != null){ |
| | | //查询升级失败的 |
| | | vo.state = 0 ; |
| | | } |
| | | setExcelRespProp(response, "升级结果列表"); |
| | | List<VoUgResult> rsList = this.sv.selectAll(vo); |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head(VoUgResult.class) |
| | | .excelType(ExcelTypeEnum.XLSX) |
| | | .sheet("升级结果列表") |
| | | .doWrite(rsList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置excel下载响应头属性 |
| | | */ |
| | | private void setExcelRespProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException { |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | } |
| | | } |