| | |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.softUpgrade.parse.HexFileParse; |
| | | import com.dy.common.softUpgrade.parse.HexFileVo; |
| | | import com.dy.common.util.DateTime; |
| | | import com.dy.common.util.ByteUtil; |
| | | 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.UgRtuProgram; |
| | | import com.dy.pipIrrGlobal.voRm.VoRtuProgram; |
| | | import com.dy.pipIrrGlobal.pojoUg.UgRtuProgram; |
| | | import com.dy.pipIrrGlobal.voUg.VoRtuProgram; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.media.Content; |
| | |
| | | } |
| | | return BaseResponseUtils.buildSuccess(po); |
| | | }else{ |
| | | return BaseResponseUtils.buildException("未查询到对应的记录") ; |
| | | return BaseResponseUtils.buildErrorMsg("未查询到对应的记录") ; |
| | | } |
| | | } |
| | | /** |
| | |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("查询RTU升级程序异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("查询RTU升级程序异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | |
| | | schema = @Schema(implementation = Boolean.class))} |
| | | ) |
| | | }) |
| | | @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @PostMapping(path = "save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> save(@RequestBody @Valid VoRtuProgram vo, @Parameter(hidden = true) BindingResult bindingResult){ |
| | | public BaseResponse<Boolean> save(@Parameter(description = "form表单数据", required = true) @Valid VoRtuProgram vo, @Parameter(hidden = true) BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | if(vo.storeRamAddr == null |
| | | || vo.storeRamAddr.trim().equals("") |
| | | || vo.storeRamAddr.length() != 8 |
| | | || !HexUtil.isHexNumber(vo.storeRamAddr)){ |
| | | return BaseResponseUtils.buildErrorMsg("升级程序存放地址(4字节,8位十六进制数)不正确") ; |
| | | } |
| | | if(vo.startRamAddr == null |
| | | || vo.startRamAddr.trim().equals("") |
| | | || vo.startRamAddr.length() != 8 |
| | | || !HexUtil.isHexNumber(vo.startRamAddr)){ |
| | | return BaseResponseUtils.buildErrorMsg("程序覆盖起始地址(4字节,8位十六进制数)不正确") ; |
| | | } |
| | | if(vo.file == null){ |
| | | return BaseResponseUtils.buildFail("RTU程序文件必须上传") ; |
| | | return BaseResponseUtils.buildErrorMsg("RTU程序文件必须上传") ; |
| | | } |
| | | String fileName = vo.file.getOriginalFilename() ; |
| | | if(this.sv.existFileName(fileName)){ |
| | | return BaseResponseUtils.buildErrorMsg("RTU程序文件名已存在") ; |
| | | } |
| | | |
| | | HexFileVo fileVo = null ; |
| | |
| | | } |
| | | }catch (Exception e){ |
| | | fileVo = null ; |
| | | return BaseResponseUtils.buildFail("解析RTU程序文件异常:" + e.getMessage()) ; |
| | | return BaseResponseUtils.buildErrorMsg("解析RTU程序文件异常:" + e.getMessage()) ; |
| | | } |
| | | if(fileVo != null){ |
| | | UgRtuProgram po = new UgRtuProgram(); |
| | | po.hexFileName = vo.file.getOriginalFilename() ; |
| | | po.hexFileName = fileName ; |
| | | po.programCalculateBytes = (int)fileVo.calculateBytes ; |
| | | po.programCrc16 = fileVo.bytesCrc16 ; |
| | | po.programBytes = fileVo.bytes; |
| | |
| | | count = this.sv.save(po); |
| | | } catch (Exception e) { |
| | | log.error("保存RTU升级程序异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; |
| | | } |
| | | if(count <= 0){ |
| | | return BaseResponseUtils.buildFail("数据库存储失败") ; |
| | | return BaseResponseUtils.buildErrorMsg("数据库存储失败") ; |
| | | }else{ |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | | }else{ |
| | | return BaseResponseUtils.buildFail("解析RTU程序文件异常") ; |
| | | return BaseResponseUtils.buildErrorMsg("解析RTU程序文件异常") ; |
| | | } |
| | | } |
| | | /** |
| | |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> delete(Long id){ |
| | | if(id == null){ |
| | | return BaseResponseUtils.buildFail("id不能为空") ; |
| | | return BaseResponseUtils.buildErrorMsg("id不能为空") ; |
| | | } |
| | | int count; |
| | | try { |
| | | count = this.sv.delete(id); |
| | | } catch (Exception e) { |
| | | log.error("删除RTU升级程序异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; |
| | | } |
| | | if(count <= 0){ |
| | | return BaseResponseUtils.buildFail("数据库存储失败") ; |
| | | return BaseResponseUtils.buildErrorMsg("数据库存储失败") ; |
| | | }else{ |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |