| | |
| | | private String c3Mac; |
| | | |
| | | /** |
| | | * 故障码 |
| | | */ |
| | | private Integer errorCode; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private LocalDateTime createTime; |
| | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.C3mReportError"> |
| | | <id property="c3mErrorId" column="c3m_error_id" jdbcType="BIGINT"/> |
| | | <result property="c3Mac" column="c3_mac" jdbcType="VARCHAR"/> |
| | | <result property="errorCode" column="error_code" jdbcType="INTEGER"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | <result property="errorMsg" column="error_msg" jdbcType="VARCHAR"/> |
| | |
| | | return ResponseUtil.success(c3ChargingService.getChargingInfo(poleId)); |
| | | } |
| | | |
| | | // /** |
| | | // * 充电开启 |
| | | // */ |
| | | // @AnonymousAccess |
| | | // @PostMapping("/startCharging") |
| | | // public ResponseVO<Object> startCharging(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | // String result = c3ChargingService.startCharging(c3ChargingParam.getC3Mac(), c3ChargingParam.getChargingCapacity(), c3ChargingParam.getChargeAmount()); |
| | | // if ("操作成功".equals(result)) { |
| | | // return ResponseUtil.success(result); |
| | | // } else { |
| | | // return ResponseUtil.fail(result); |
| | | // } |
| | | // |
| | | // } |
| | | /** |
| | | * 充电开启 |
| | | */ |
| | | @AnonymousAccess |
| | | @PostMapping("/startCharging") |
| | | public ResponseVO<Object> startCharging(@RequestBody C3ChargingParam c3ChargingParam) { |
| | | String result = c3ChargingService.startCharging(c3ChargingParam.getC3Mac(), c3ChargingParam.getChargingCapacity(), c3ChargingParam.getChargeAmount()); |
| | | if ("操作成功".equals(result)) { |
| | | return ResponseUtil.success(result); |
| | | } else { |
| | | return ResponseUtil.fail(result); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 充电结束——小程序用户结束,不需要token,需要openId |
| | |
| | | /** |
| | | * 保存C3充电桩故障数据 |
| | | */ |
| | | if (errorCodeRequestFrame.isValidate() && (errorCodeRequestFrame.getErrorCode() != 0)) { |
| | | if (errorCodeRequestFrame.isValidate() && errorCodeRequestFrame.getErrorMessage() != null) { |
| | | SpringContextHolder.getBean(C3mReportErrorService.class).saveReportError(errorCodeRequestFrame); |
| | | } else { |
| | | System.out.println("数据校验异常!"); |
| | | } |
| | | |
| | | } else if (C3ChargingEnum.StartCharging.getCode().equals(functionCode)) { |
| | |
| | | import cn.hutool.core.util.HexUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.C3ErrorEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | import com.sandu.ximon.admin.utils.StringUtil; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | |
| | | /** |
| | | * 故障码 |
| | | */ |
| | | private int errorCode; |
| | | private String errorMessage; |
| | | |
| | | @Override |
| | | public A5C3ErrorCodeReportInnerFrame transformFrame(String hex) { |
| | | //F04500080000048E0000001CA2D92F64 |
| | | if (StrUtil.isBlank(hex)) { |
| | | return null; |
| | | } |
| | |
| | | |
| | | setDestinationAddress(hex.substring(8, 16)); |
| | | |
| | | //故障码 |
| | | //故障信息 |
| | | String errorCodeHex = hex.substring(16, hex.length() - 8); |
| | | errorCode = HexUtil.hexToInt(errorCodeHex); |
| | | String errorInfo = errorInfo(errorCodeHex); |
| | | if (!StringUtil.strIsNullOrEmpty(errorInfo)) { |
| | | setErrorMessage(errorInfo); |
| | | } |
| | | |
| | | setCrc32(hex.substring(hex.length() - 8)); |
| | | // 校验CRC32 |
| | | String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + errorCodeHex; |
| | | String frame = hex.substring(2,hex.length()-8); |
| | | this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * 收集故障信息 |
| | | * |
| | | * @param hexStr |
| | | * @return |
| | | */ |
| | | public String errorInfo(String hexStr) { |
| | | String errorMsg = ""; |
| | | String str = hexStr2BinStr(hexStr); |
| | | |
| | | int index = str.indexOf("1"); |
| | | while ((index = str.indexOf("1", index)) > 0) { |
| | | C3ErrorEnum[] values = C3ErrorEnum.values(); |
| | | for (C3ErrorEnum value : values) { |
| | | if (value.getCode() == index) { |
| | | errorMsg = errorMsg + value.getMessage() + ";"; |
| | | } |
| | | } |
| | | index = index + 1; |
| | | } |
| | | return errorMsg; |
| | | } |
| | | |
| | | /** |
| | | * 16进制字符串转为二进制 |
| | | */ |
| | | public String hexStr2BinStr(String hexStr) { |
| | | if (hexStr == null || hexStr.length() % 2 != 0) { |
| | | return null; |
| | | } |
| | | String bString = "", tmp; |
| | | for (int i = 0; i < hexStr.length(); i++) { |
| | | tmp = "0000" + Integer.toBinaryString(Integer.parseInt(hexStr.substring(i, i + 1), 16)); |
| | | bString += tmp.substring(tmp.length() - 4); |
| | | } |
| | | return bString; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 通信流程超时 |
| | | */ |
| | | IO_OVER_TIME(1, "通信流程超时"), |
| | | IO_OVER_TIME(31, "通信流程超时"), |
| | | /** |
| | | * 无电压 |
| | | */ |
| | | NO_VOL(2, "无电压"), |
| | | NO_VOL(30, "无电压"), |
| | | /** |
| | | * 无电流 |
| | | */ |
| | | NO_CUR(4, "无电流"), |
| | | NO_CUR(29, "无电流"), |
| | | /** |
| | | * 无功率 |
| | | */ |
| | | NO_POWER(8, "无功率"), |
| | | NO_POWER(28, "无功率"), |
| | | /** |
| | | * 充电功率过小 |
| | | */ |
| | | LOWER_POWER(16, "充电功率过小"), |
| | | LOWER_POWER(27, "充电功率过小"), |
| | | /** |
| | | * 漏电 |
| | | */ |
| | | OUTPUT_ELE_LEAKAGE(32, "漏电"), |
| | | OUTPUT_ELE_LEAKAGE(26, "漏电"), |
| | | /** |
| | | * 设备温度过高 |
| | | */ |
| | | DEVICE_TEMPERATURE_HIGHER(64, "设备温度过高"), |
| | | DEVICE_TEMPERATURE_HIGHER(25, "设备温度过高"), |
| | | /** |
| | | * 设备温度过低 |
| | | */ |
| | | DEVICE_TEMPERATURE_LOW(128, "设备温度过低"), |
| | | DEVICE_TEMPERATURE_LOW(24, "设备温度过低"), |
| | | /** |
| | | * 充电超时 |
| | | */ |
| | | CHARING_OVER_TIME(256, "充电超时"), |
| | | CHARING_OVER_TIME(23, "充电超时"), |
| | | /** |
| | | * 无网络 |
| | | */ |
| | | NO_NETWORK(512, "无网络"), |
| | | NO_NETWORK(22, "无网络"), |
| | | /** |
| | | * 连接主机超时 |
| | | */ |
| | | CONNECT_HOST_OVER_TIMED(1024, "连接主机超时"), |
| | | CONNECT_HOST_OVER_TIMED(21, "连接主机超时"), |
| | | /** |
| | | * 连接服务器超时 |
| | | */ |
| | | CONNECT_SERVICE_OVER_TIMED(2048, "连接服务器超时"), |
| | | CONNECT_SERVICE_OVER_TIMED(20, "连接服务器超时"), |
| | | /** |
| | | * 触摸屏无响应 |
| | | */ |
| | | LED_ERROR(4096, "触摸屏无响应"), |
| | | LED_ERROR(19, "触摸屏无响应"), |
| | | /** |
| | | * 写入Flash失败 |
| | | */ |
| | | INPUT_FLASH_ERROR(8192, "写入Flash失败"), |
| | | INPUT_FLASH_ERROR(18, "写入Flash失败"), |
| | | /** |
| | | * 写入EEProm失败 |
| | | */ |
| | | INPUT_EEPROM_ERROR(16384, "写入EEProm失败"), |
| | | INPUT_EEPROM_ERROR(17, "写入EEProm失败"), |
| | | /** |
| | | * 电压过低 |
| | | */ |
| | | LOWER_VOL(32768, "电压过低"), |
| | | LOWER_VOL(16, "电压过低"), |
| | | /** |
| | | * 电压过高 |
| | | */ |
| | | OVER_VOL(65536, "电压过高"), |
| | | OVER_VOL(15, "电压过高"), |
| | | /** |
| | | * 地锁故障(不能锁上) |
| | | */ |
| | | LOCK_ERROR(131072, "地锁故障(不能锁上)"), |
| | | LOCK_ERROR(14, "地锁故障(不能锁上)"), |
| | | /** |
| | | * 地锁故障(不能解锁) |
| | | */ |
| | | UNLOCK_ERROR(262144, "地锁故障(不能解锁)"), |
| | | UNLOCK_ERROR(13, "地锁故障(不能解锁)"), |
| | | /** |
| | | * 充电口1故障 |
| | | */ |
| | | Charging_port_error(524288, "充电口1故障"), |
| | | Charging_port_error(12, "充电口1故障"), |
| | | /** |
| | | * 充电口1不能连接车机 |
| | | */ |
| | | CONNECT_DEVICE_ERROR(2097152, "充电口1不能连接车机"), |
| | | CONNECT_DEVICE_ERROR(10, "充电口1不能连接车机"), |
| | | |
| | | ; |
| | | |
| | |
| | | public void saveReportError(A5C3ErrorCodeReportInnerFrame codeRespInnerFrame) { |
| | | C3mReportError c3MReportError = new C3mReportError(); |
| | | c3MReportError.setC3Mac(codeRespInnerFrame.getDestinationAddress()); |
| | | c3MReportError.setErrorCode(codeRespInnerFrame.getErrorCode()); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | Integer errorCode = codeRespInnerFrame.getErrorCode(); |
| | | C3ErrorEnum[] values = C3ErrorEnum.values(); |
| | | for (C3ErrorEnum value : values) { |
| | | if ((value.getCode() & errorCode) > 0) { |
| | | sb.append(value.getMessage()); |
| | | } |
| | | } |
| | | c3MReportError.setErrorMsg(sb.toString()); |
| | | c3MReportError.setErrorMsg(codeRespInnerFrame.getErrorMessage()); |
| | | save(c3MReportError); |
| | | } |
| | | |
| | |
| | | c3ReportErrorBos.forEach(c3ReportError -> { |
| | | ErrorMsgDto errorMsgDto = new ErrorMsgDto(); |
| | | errorMsgDto.setMac(c3ReportError.getC3Mac()); |
| | | errorMsgDto.setErrorCode(c3ReportError.getErrorCode()); |
| | | errorMsgDto.setErrorDesc(c3ReportError.getErrorMsg()); |
| | | errorMsgDto.setErrorTime(c3ReportError.getCreateTime()); |
| | | errorMsgDto.setDeviceType(3); |