|  |  |  | 
|---|
|  |  |  | package com.dy.pipIrrRemote.rtuUpgrage; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.excel.EasyExcel; | 
|---|
|  |  |  | import com.alibaba.excel.support.ExcelTypeEnum; | 
|---|
|  |  |  | import com.dy.common.aop.SsoAop; | 
|---|
|  |  |  | import com.dy.common.multiDataSource.DataSourceContext; | 
|---|
|  |  |  | import com.dy.common.softUpgrade.state.UpgradeRtu; | 
|---|
|  |  |  | import com.dy.common.softUpgrade.state.UpgradeTaskVo; | 
|---|
|  |  |  | import com.dy.common.springUtil.SpringContextUtil; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponse; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.dy.common.webUtil.ResultCodeMsg; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoUg.UgRtuProgram; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoUg.UgRtuTask; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.rtuMw.ToRtuMwCom; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voUg.VoUgRtuResult4Failure; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voUg.VoUgRtuResult4Success; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voUg.VoWatch; | 
|---|
|  |  |  | 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.core.env.Environment; | 
|---|
|  |  |  | 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 org.springframework.web.client.RestTemplate; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.io.UnsupportedEncodingException; | 
|---|
|  |  |  | import java.net.URLEncoder; | 
|---|
|  |  |  | import java.util.Base64; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | @Tag(name = "rtu远程升级任务", description = "rtu远程升级任务相关操作") | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping(path = "rtuUpgrade") | 
|---|
|  |  |  | public class RtuUpgradeCtrl extends ToRtuMwCom { | 
|---|
|  |  |  | public class RtuUpgradeCtrl extends Web2RtuMw { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RtuUpgradeSv sv ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RtuUpgradeResSv resSv ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Environment env; | 
|---|
|  |  |  | 
|---|
|  |  |  | @GetMapping(path = "/issuedTask") | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<Boolean> issuedTask(String id){ | 
|---|
|  |  |  | if(id == null || !id.trim().equals("")){ | 
|---|
|  |  |  | return BaseResponseUtils.buildError("任务id不能为空") ; | 
|---|
|  |  |  | if(id == null || id.trim().equals("")){ | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("任务id不能为空") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | UgRtuTask tpo = this.sv.selectTaskById(id) ; | 
|---|
|  |  |  | if(tpo == null){ | 
|---|
|  |  |  | return BaseResponseUtils.buildError("任务不存在") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("任务不存在") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(tpo.isExecute == 1){ | 
|---|
|  |  |  | return BaseResponseUtils.buildError("任务已下发,不能重复下发任务") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("任务已下发,不能重复下发任务") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | UgRtuProgram ppo = this.sv.selectProgramById(tpo.programId) ; | 
|---|
|  |  |  | if(ppo == null){ | 
|---|
|  |  |  | return BaseResponseUtils.buildError("任务对应的程序不存在") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("任务对应的程序不存在") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<String> taskRtuAddrs = this.sv.selectAllRtuAddrByTask(id) ; | 
|---|
|  |  |  | if(taskRtuAddrs == null || taskRtuAddrs.size() == 0){ | 
|---|
|  |  |  | return BaseResponseUtils.buildError("任务所涉及的控制器还未设置") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("任务所涉及的控制器还未设置") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String ugCallbackUrl_rm = env.getProperty("mw." + DataSourceContext.get() + ".ugCallbackUrl_rm" ); | 
|---|
|  |  |  | String ugCallbackUrl_rm = env.getProperty("mw.ugCallbackUrl_rm" ); | 
|---|
|  |  |  | if(ugCallbackUrl_rm == null || ugCallbackUrl_rm.trim().equals("")){ | 
|---|
|  |  |  | return BaseResponseUtils.buildError("未配置升级任务回调网址") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("未配置升级任务回调网址") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | UpgradeTaskVo vo = new UpgradeTaskVo() ; | 
|---|
|  |  |  | 
|---|
|  |  |  | vo.rtuAddrList = taskRtuAddrs ; | 
|---|
|  |  |  | vo.callbackWebUrl = ugCallbackUrl_rm ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String ugSendUrl = this.getToMwUgUrl(this.env) ; | 
|---|
|  |  |  | BaseResponse res = sendUpgradeTask2Mw(restTemplate, ugSendUrl, vo) ; | 
|---|
|  |  |  | String rqUrl = this.get2MwRequestUrl(this.env, ContextUgTaskSend) ; | 
|---|
|  |  |  | BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, vo) ; | 
|---|
|  |  |  | if(res != null){ | 
|---|
|  |  |  | if(res.isSuccess()){ | 
|---|
|  |  |  | this.sv.setUpgradeTaskExecuted(id); | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(true) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | log.error("通信中间件执行下发升级任务失败" + (res.getMsg() == null? "" : ("," + res.getMsg()))) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildFail("通信中间件执行失败" + (res.getMsg() == null? "" : ("," + res.getMsg()))) ; | 
|---|
|  |  |  | String msg = res.getContent()==null?null:(String)res.getContent() ; | 
|---|
|  |  |  | if(msg == null){ | 
|---|
|  |  |  | msg = res.getMsg() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.error("通信中间件执行下发升级任务失败," + msg) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("通信中间件执行失败," + msg) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | log.error("通信中间件返回结果为null") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildFail("通信中间件返回结果为null") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("通信中间件返回结果为null") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 下发强制结束当前rtu远程升级任务 | 
|---|
|  |  |  | * @return 操作结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Operation(summary = "下发强制结束当前rtu远程升级任务", description = "下发强制结束当前rtu远程升级任务") | 
|---|
|  |  |  | @ApiResponses(value = { | 
|---|
|  |  |  | @ApiResponse( | 
|---|
|  |  |  | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, | 
|---|
|  |  |  | description = "返回操作成功与否数据(BaseResponse.content:Boolean)", | 
|---|
|  |  |  | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, | 
|---|
|  |  |  | schema = @Schema(implementation = String.class))} | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @GetMapping(path = "/forceOver") | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<String> forceOver() { | 
|---|
|  |  |  | String rqUrl = this.get2MwRequestUrl(this.env, ContextUgForceOver) ; | 
|---|
|  |  |  | BaseResponse res = sendGetRequest2Mw(restTemplate, rqUrl) ; | 
|---|
|  |  |  | if(res != null){ | 
|---|
|  |  |  | if(res.isSuccess()){ | 
|---|
|  |  |  | RtuUpgradeStateReceiverCtrl.afterMwForceOverCurUgTask(); | 
|---|
|  |  |  | String msg = res.getContent()==null?null:(String)res.getContent() ; | 
|---|
|  |  |  | if(msg == null){ | 
|---|
|  |  |  | msg = res.getMsg() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, msg, msg) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | String msg = res.getContent()==null?null:(String)res.getContent() ; | 
|---|
|  |  |  | if(msg == null){ | 
|---|
|  |  |  | msg = res.getMsg() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.error("通信中间件执行下发强制结束当前rtu远程升级任务失败:" + msg) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("通信中间件执行强制结束当前rtu远程升级任务失败:" + msg) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | log.error("通信中间件返回结果为null") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("通信中间件返回结果为null") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void valueFromPo(UpgradeTaskVo vo, UgRtuTask tpo, UgRtuProgram ppo){ | 
|---|
|  |  |  | vo.id = "" + tpo.id ; | 
|---|
|  |  |  | vo.softFileName = ppo.hexFileName ; | 
|---|
|  |  |  | vo.softStoreAddr = ppo.storeRamAddr ; | 
|---|
|  |  |  | vo.softStartAddr = ppo.startRamAddr ; | 
|---|
|  |  |  | vo.softFileData = ppo.programBytes ; | 
|---|
|  |  |  | vo.softFileData64 = Base64.getEncoder().encodeToString(ppo.programBytes) ; | 
|---|
|  |  |  | //vo.softFileData = ppo.programBytes ; | 
|---|
|  |  |  | vo.softBytesCalculate = ppo.programCalculateBytes ; | 
|---|
|  |  |  | vo.softByteSrc16 = ppo.programCrc16 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | *  监视: | 
|---|
|  |  |  | * 重置,演示的重置 | 
|---|
|  |  |  | * 重置远程升级演示程序 | 
|---|
|  |  |  | * @return 操作结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping(path = "/demoReset") | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<Boolean> demoReset(){ | 
|---|
|  |  |  | if(RtuUpgradeStateReceiverCtrl.cache == null){ | 
|---|
|  |  |  | if(RtuUpgradeStateReceiverCtrl.cache != null){ | 
|---|
|  |  |  | //return BaseResponseUtils.buildError("当前没有升级任务") ; | 
|---|
|  |  |  | //正式运行时,下面两行去掉,上面一行打开 | 
|---|
|  |  |  | RtuUpgradeStateReceiverCtrl ctrl = SpringContextUtil.getBean(RtuUpgradeStateReceiverCtrl.class); | 
|---|
|  |  |  | 
|---|
|  |  |  | public BaseResponse<QueryResultVo<VoWatch> > curUpgradeState(QueryVo qvo){ | 
|---|
|  |  |  | if(qvo == null){ | 
|---|
|  |  |  | qvo = new QueryVo(); | 
|---|
|  |  |  | qvo.pageCurr = 1 ; | 
|---|
|  |  |  | qvo.pageSize = 49 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(RtuUpgradeStateReceiverCtrl.cache == null){ | 
|---|
|  |  |  | //return BaseResponseUtils.buildError("当前没有升级任务") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("当前没有升级任务") ; | 
|---|
|  |  |  | //正式运行时,下面两行去掉,上面一行打开 | 
|---|
|  |  |  | RtuUpgradeStateReceiverCtrl ctrl = SpringContextUtil.getBean(RtuUpgradeStateReceiverCtrl.class); | 
|---|
|  |  |  | ctrl.demo(); | 
|---|
|  |  |  | //RtuUpgradeStateReceiverCtrl ctrl = SpringContextUtil.getBean(RtuUpgradeStateReceiverCtrl.class); | 
|---|
|  |  |  | //ctrl.demo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | QueryResultVo<VoWatch> rsVo = new QueryResultVo(); | 
|---|
|  |  |  | VoWatch vo = new VoWatch() ; | 
|---|
|  |  |  | List<UpgradeRtu> listFiltered = null ; | 
|---|
|  |  |  | if(RtuUpgradeStateReceiverCtrl.cache != null && RtuUpgradeStateReceiverCtrl.cache.ugTaskId != null){ | 
|---|
|  |  |  | vo.upgrade = this.sv.selectTaskDetail(RtuUpgradeStateReceiverCtrl.cache.ugTaskId); | 
|---|
|  |  |  | vo.overall = RtuUpgradeStateReceiverCtrl.cache.ugOverallState ; | 
|---|
|  |  |  | vo.rtus = new ArrayList<>() ; | 
|---|
|  |  |  | if(RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList != null && RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.size() > 0) { | 
|---|
|  |  |  | listFiltered = filterByQuery(qvo) ; | 
|---|
|  |  |  | if (listFiltered.size() > 0) { | 
|---|
|  |  |  | if(qvo.pageCurr < 1){ | 
|---|
|  |  |  | qvo.pageCurr = 1 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int start = (qvo.pageCurr - 1) * qvo.pageSize ; | 
|---|
|  |  |  | if(start >= listFiltered.size()){ | 
|---|
|  |  |  | if(listFiltered.size()%qvo.pageSize > 0){ | 
|---|
|  |  |  | start = listFiltered.size() - listFiltered.size()%qvo.pageSize ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | start = listFiltered.size() - qvo.pageSize ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(int i = start; i < (start + qvo.pageSize) && i < listFiltered.size(); i++){ | 
|---|
|  |  |  | UpgradeRtu ugRtu = listFiltered.get(i) ; | 
|---|
|  |  |  | VoWatch.VoWatchRtu rtu = new VoWatch.VoWatchRtu() ; | 
|---|
|  |  |  | rtu.fromCache(ugRtu) ; | 
|---|
|  |  |  | vo.rtus.add(rtu) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | rsVo.obj = vo ; | 
|---|
|  |  |  | rsVo.pageSize = qvo.pageSize ; | 
|---|
|  |  |  | rsVo.pageCurr = qvo.pageCurr ; | 
|---|
|  |  |  | rsVo.calculateAndSet(0L + (listFiltered==null?0:listFiltered.size()), null); | 
|---|
|  |  |  | QueryResultVo<VoWatch> rsVo = this.resSv.curUpgradeState(qvo) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(rsVo) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private List<UpgradeRtu> filterByQuery(QueryVo qvo){ | 
|---|
|  |  |  | if (qvo.status != null || qvo.result != null) { | 
|---|
|  |  |  | final Integer qvoStatus = qvo.status ; | 
|---|
|  |  |  | final Integer qvoResult = qvo.result ; | 
|---|
|  |  |  | final String qvoRtuAddr = qvo.rtuAddr ; | 
|---|
|  |  |  | return RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.stream().filter(rtu -> { | 
|---|
|  |  |  | boolean ok = false; | 
|---|
|  |  |  | if (qvoStatus != null) { | 
|---|
|  |  |  | if (qvoStatus.intValue() == 1) { | 
|---|
|  |  |  | if (rtu.state == UpgradeRtu.STATE_RUNNING) { | 
|---|
|  |  |  | ok = true; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | ok = false ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if (qvoStatus.intValue() == 0) { | 
|---|
|  |  |  | if (rtu.isOver) { | 
|---|
|  |  |  | ok = true; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | ok = false ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (qvoResult != null) { | 
|---|
|  |  |  | if (qvoResult.intValue() == 1) { | 
|---|
|  |  |  | if (rtu.state == UpgradeRtu.STATE_SUCCESS) { | 
|---|
|  |  |  | ok = true; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | ok = false ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if (qvoResult.intValue() == 0) { | 
|---|
|  |  |  | if (rtu.state == UpgradeRtu.STATE_OFFLINE | 
|---|
|  |  |  | || rtu.state == UpgradeRtu.STATE_FAILONE | 
|---|
|  |  |  | || rtu.state == UpgradeRtu.STATE_FAIL | 
|---|
|  |  |  | || rtu.state == UpgradeRtu.STATE_FAILOFFLINE) { | 
|---|
|  |  |  | ok = true; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | ok = false ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(qvoRtuAddr != null && !qvoRtuAddr.trim().equals("")){ | 
|---|
|  |  |  | if(rtu.rtuAddr.equals(qvoRtuAddr)){ | 
|---|
|  |  |  | ok = true; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | ok = false ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ok; | 
|---|
|  |  |  | }).toList() ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 导出升级失败RTU列表 | 
|---|
|  |  |  | * @param response | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping(value = "/exportUgFail", method = RequestMethod.GET) | 
|---|
|  |  |  | public void exportUgFail(HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | setExcelRespProp(response, "升级失败RTU列表"); | 
|---|
|  |  |  | List<VoUgRtuResult4Failure> rsList = resSv.exportUgFail(); | 
|---|
|  |  |  | EasyExcel.write(response.getOutputStream()) | 
|---|
|  |  |  | .head(VoUgRtuResult4Failure.class) | 
|---|
|  |  |  | .excelType(ExcelTypeEnum.XLSX) | 
|---|
|  |  |  | .sheet("升级失败RTU列表") | 
|---|
|  |  |  | .doWrite(rsList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 导出长级成功RTU列表 | 
|---|
|  |  |  | * @param response | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping(value = "/exportUgSuccess", method = RequestMethod.GET) | 
|---|
|  |  |  | public void exportUgSuccess(HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | setExcelRespProp(response, "升级成功RTU列表"); | 
|---|
|  |  |  | List<VoUgRtuResult4Success> rsList = resSv.exportUgSuccess(); | 
|---|
|  |  |  | EasyExcel.write(response.getOutputStream()) | 
|---|
|  |  |  | .head(VoUgRtuResult4Success.class) | 
|---|
|  |  |  | .excelType(ExcelTypeEnum.XLSX) | 
|---|
|  |  |  | .sheet("升级成功RTU列表") | 
|---|
|  |  |  | .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"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|