|  |  |  | 
|---|
|  |  |  | package com.dy.pipIrrProject.intakeController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.hutool.core.date.DateTime; | 
|---|
|  |  |  | import com.dy.common.aop.SsoAop; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponse; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponseUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | prController.setIntakeId(intakeId); | 
|---|
|  |  |  | prController.setRtuAddr(prControllerTramp.getRtuAddr()); | 
|---|
|  |  |  | prController.setProtocol(prControllerTramp.getProtocol()); | 
|---|
|  |  |  | prController.setProtocolVersion(prControllerTramp.getProtocolVersion()); | 
|---|
|  |  |  | prController.setFindDt(prControllerTramp.getFindDt()); | 
|---|
|  |  |  | prController.setOrgTag(prControllerTramp.getOrgTag()); | 
|---|
|  |  |  | prController.setAddWays((byte) 1); | 
|---|
|  |  |  | prController.setOperator(operator); | 
|---|
|  |  |  | Date operateTime = new Date(); | 
|---|
|  |  |  | 
|---|
|  |  |  | prControllerTramp.setRtuAddr(ControllerList.getRtuAddr()); | 
|---|
|  |  |  | prControllerTramp.setProtocol(ControllerList.getProtocol()); | 
|---|
|  |  |  | prControllerTramp.setFindDt(new Date()); | 
|---|
|  |  |  | prControllerTramp.setOrgTag(ControllerList.getOrgTag()); | 
|---|
|  |  |  | Integer rec_addControllerTramp = Optional.ofNullable(intakeControllerSv.addTrampController(prControllerTramp)).orElse(0); | 
|---|
|  |  |  | if (rec_addControllerTramp == 0) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(ProjectResultCode.ADD_TRAMP_CONTROLLER_FAIL.getMessage()); | 
|---|
|  |  |  | 
|---|
|  |  |  | @GetMapping(path = "/getTrampControllers") | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<QueryResultVo<List<PrControllerTramp>>> getTrampControllers(TrampControllerQueryVo vo) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | QueryResultVo<List<PrControllerTramp>> res = intakeControllerSv.getTrampControllers(vo); | 
|---|
|  |  |  | if (res.itemTotal != null && res.itemTotal > 0) { | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(res); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //请求成功但数据为空 | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(res); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //return BaseResponseUtils.buildSuccess(res); | 
|---|
|  |  |  | //QueryResultVo<List<PrControllerTramp>> res = intakeControllerSv.getTrampControllers(vo); | 
|---|
|  |  |  | //if (res.itemTotal != null && res.itemTotal > 0) { | 
|---|
|  |  |  | //    return BaseResponseUtils.buildSuccess(res); | 
|---|
|  |  |  | //} else { | 
|---|
|  |  |  | //    //请求成功但数据为空 | 
|---|
|  |  |  | //    return BaseResponseUtils.buildSuccess(res); | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(intakeControllerSv.getTrampControllers(vo)); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("获取流浪控制器记录异常", e); | 
|---|
|  |  |  | return BaseResponseUtils.buildException(e.getMessage()); | 
|---|
|  |  |  | 
|---|
|  |  |  | pct.setFindDt(new Date()); | 
|---|
|  |  |  | Integer rows = intakeControllerSv.addTrampController(pct); | 
|---|
|  |  |  | if (rows == 0) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(ProjectResultCode.ADD_TRAMP_CONTROLLER_FAIL.getMessage()); | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(ProjectResultCode.ADD_TRAMP_CONTROLLER_FAIL.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("deleteTrampController") | 
|---|
|  |  |  | @GetMapping("deleteTrampController") | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<Boolean> deleteTrampController(Long id) { | 
|---|
|  |  |  | PrControllerTramp controllerInfo = intakeControllerSv.getTrampControllerInfo(id); | 
|---|
|  |  |  | if (controllerInfo == null) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(ProjectResultCode.NO_EXIST_TRAMP_CONTROLLER.getMessage()); | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_EXIST_TRAMP_CONTROLLER.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer rows = intakeControllerSv.deleteTrampController(id); | 
|---|
|  |  |  | //        if (rows == 0) { | 
|---|
|  |  |  | //            return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_TRAMP_CONTROLLER_FAIL.getMessage()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 清空流浪控制器 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("emptyTrampController") | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<Boolean> emptyTrampController() { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer rows = intakeControllerSv.emptyTrampController(); | 
|---|
|  |  |  | if (rows == 0) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_TRAMP_CONTROLLER_FAIL.getMessage()); | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_TRAMP_CONTROLLER_FAIL.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(true); | 
|---|
|  |  |  | } | 
|---|