| | |
| | | package com.dy.pipIrrProject.controller; |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.support.ExcelTypeEnum; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | 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.excel.CellWriteHandler; |
| | | import com.dy.pipIrrGlobal.excel.ExcelUtil; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaClient; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrController; |
| | | import com.dy.pipIrrGlobal.voPr.VoController; |
| | |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | if (res.itemTotal != null && res.itemTotal > 0) { |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } else { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.NO_RECORDS.getMessage()); |
| | | return BaseResponseUtils.buildSuccess(ProjectResultCode.NO_RECORDS.getMessage()); |
| | | } |
| | | //return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | |
| | | try { |
| | | List<Map<String, Object>> list = Optional.ofNullable(controllerSv.getControllersByAddr(rtuAddr)).orElse(new ArrayList<>()); |
| | | if (list.size() <= 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.NO_RECORDS.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_RECORDS.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(list); |
| | | } catch (Exception e) { |
| | |
| | | //public BaseResponse<Boolean> add(@RequestBody @Valid DtoController po, BindingResult bindingResult){ |
| | | public BaseResponse<Boolean> add(@RequestBody @Valid PrController po, BindingResult bindingResult) { |
| | | if (bindingResult != null && bindingResult.hasErrors()) { |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | //PrController prController = DtoToPojo.INSTANCT.po2vo(po); |
| | |
| | | } |
| | | Integer rec = Optional.ofNullable(controllerSv.addController(po)).orElse(0); |
| | | if (rec == 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.CONTROLLER_FAIL.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(ProjectResultCode.CONTROLLER_FAIL.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> delete(@RequestBody Map map) { |
| | | if (map == null || map.size() <= 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.PLEASE_INPUT_CONTROLLER_ID.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(ProjectResultCode.PLEASE_INPUT_CONTROLLER_ID.getMessage()); |
| | | } |
| | | |
| | | Long controllerId = Long.parseLong(map.get("controllerId").toString()); |
| | | Integer recordCount = Optional.ofNullable(controllerSv.deleteControllerById(controllerId)).orElse(0); |
| | | if (recordCount == 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_CONTROLLER_FAIL.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_CONTROLLER_FAIL.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | |
| | | @SneakyThrows(IOException.class) |
| | | @RequestMapping(value = "/export", method = RequestMethod.GET) |
| | | public void export(HttpServletResponse response, QueryVo vo) { |
| | | setExcelRespProp(response, "控制器列表"); |
| | | //List<VoDivide> memberList = LocalJsonUtil.getListFromJson("json/members.json", VoDivide.class); |
| | | List<VoController> memberList = controllerSv.export(vo); |
| | | //setExcelRespProp(response, "控制器列表"); |
| | | List<VoController> controllerList = controllerSv.export(vo); |
| | | ExcelUtil.setExcelRespProp(response, "控制器列表" + LocalDate.now()); |
| | | EasyExcel.write(response.getOutputStream(), VoController.class) |
| | | .registerWriteHandler(new CellWriteHandler("控制器列表")) |
| | | .sheet("控制器") |
| | | .doWrite(controllerList); |
| | | |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head(VoController.class) |
| | | .excelType(ExcelTypeEnum.XLSX) |
| | | .sheet("控制器列表") |
| | | .doWrite(memberList); |
| | | //EasyExcel.write(response.getOutputStream()) |
| | | // .head(VoController.class) |
| | | // .excelType(ExcelTypeEnum.XLSX) |
| | | // .sheet("控制器列表") |
| | | // .doWrite(memberList); |
| | | } |
| | | |
| | | /** |