Commit 57099e20 by 叶立庆
2 parents 973314e7 910fe0b5
......@@ -12,9 +12,9 @@ import com.glsx.plat.core.web.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -25,22 +25,28 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Tag(name = "读取实时数据")
@RestController
@RequestMapping(value = "/getdata")
@RequestMapping(value = "/api/charging/realtime")
@ResponseResultBody
public class GetDataController extends BaseController {
@Operation(summary = "读取实时监测数据", description = "读取实时监测数据")
@GetMapping("/realtime")
public R<Boolean> getRealTimeData(@Param("pileId") String pileId, @Param("gunNumber") String gunNumber) {
log.info("读取实时监测数据,充电桩编号:{}", pileId);
log.info("读取实时监测数据,枪号:{}", gunNumber);
RealTimeReq req = new RealTimeReq();
RealTimeDataReqData data = new RealTimeDataReqData();
data.setPileId(Ocpp16Helper.strToBcd(pileId, data.getPileId()));
data.setGunNumber(Ocpp16Helper.strToBcd(gunNumber, new byte[] {})[0]);
TcpCallback<TcpRsp> tcpRspTcpCallback = ServerMain.getServer().sendSync(req);
TcpRsp tcpRsp = tcpRspTcpCallback.get();
return R.ok().data(tcpRsp);
@GetMapping("/get")
public R<Boolean> getRealTimeData(@RequestParam String pileId, @RequestParam String gunNumber) {
try {
log.info("读取实时监测数据,充电桩编号:{}", pileId);
log.info("读取实时监测数据,枪号:{}", gunNumber);
RealTimeReq req = new RealTimeReq();
RealTimeDataReqData data = new RealTimeDataReqData();
data.setPileId(Ocpp16Helper.strToBcd(pileId, data.getPileId()));
data.setGunNumber((byte) 1);
req.setData(data);
TcpCallback<TcpRsp> tcpRspTcpCallback = ServerMain.getServer().sendSync(req);
TcpRsp tcpRsp = tcpRspTcpCallback.get();
return R.ok().data(tcpRsp);
} catch (Exception e) {
log.error("读取实时监测数据error:{}", e.getMessage(), e);
return R.error();
}
}
}
......@@ -101,10 +101,10 @@ public class PileControController extends BaseController {
ModelSetReqData data = new ModelSetReqData();
data.setPileId(Ocpp16Helper.strToBcd(pileId, data.getPileId()));
data.setModelCode(Ocpp16Helper.strToBcd(modelcode, data.getModelCode()));
byte[] byteArray1 = new byte[]{(byte) 0x8D, 0x40, 0x10, 0x00};
byte[] byteArray = new byte[]{(byte) 0x9C, 0x40, 0x01, 0x00};
data.setValleyDreRate(byteArray);
data.setValleyEleRate(byteArray);
data.setValleyDreRate(byteArray1);
data.setValleyEleRate(byteArray1);
data.setTopDreRate(byteArray);
data.setTopEleRate(byteArray);
data.setFlatDreRate(byteArray);
......@@ -112,17 +112,17 @@ public class PileControController extends BaseController {
data.setPeakDreRate(byteArray);
data.setPeakEleRate(byteArray);
data.setLossCalRatio((byte) 0);
data.setPeriodRate1((byte) 1);
data.setPeriodRate2((byte) 1);
data.setPeriodRate3((byte) 1);
data.setPeriodRate4((byte) 1);
data.setPeriodRate5((byte) 1);
data.setPeriodRate6((byte) 1);
data.setPeriodRate7((byte) 1);
data.setPeriodRate8((byte) 1);
data.setPeriodRate9((byte) 1);
data.setPeriodRate10((byte) 1);
data.setPeriodRate11((byte) 1);
data.setPeriodRate1((byte) 0);
data.setPeriodRate2((byte) 0);
data.setPeriodRate3((byte) 0);
data.setPeriodRate4((byte) 0);
data.setPeriodRate5((byte) 0);
data.setPeriodRate6((byte) 0);
data.setPeriodRate7((byte) 0);
data.setPeriodRate8((byte) 0);
data.setPeriodRate9((byte) 0);
data.setPeriodRate10((byte) 0);
data.setPeriodRate11((byte) 0);
data.setPeriodRate12((byte) 1);
data.setPeriodRate13((byte) 1);
data.setPeriodRate14((byte) 1);
......@@ -168,10 +168,7 @@ public class PileControController extends BaseController {
}
public static void main(String[] args) {
byte[] modelcodeByte = new byte[]{(byte) 0x00, 0x01};
BigDecimal bigDecimal = Ocpp16Helper.bytesBinToBigDecimal(modelcodeByte, 0);
System.out.println(bigDecimal);
byte[] byteArray = new byte[]{(byte) 0x9C, 0x40, 0x01, 0x00};
byte[] byteArray = new byte[]{(byte) 0x8D, 0x40, 0x10, 0x00};
BigDecimal bigDecimal1 = Ocpp16Helper.bytesBinToBigDecimal(byteArray, 5);
System.out.println(bigDecimal1);
......
......@@ -29,8 +29,8 @@ public class UploadRealTimeRspHandler implements TcpHandler<UploadRealtimeDataRs
log.info("实时监测数据为空");
return null;
}
uploadRealTimeData(notify.getData());
log.info("实时监测数据:{}", data);
uploadRealTimeData(notify.getData());
return null;
}
......
......@@ -212,7 +212,8 @@ public class ByteUtils {
* @date 2018年1月17日 上午9:36:49
* @since 1.0.0
*/
public static byte getByte(byte[] buff, int offset) {
public static byte
getByte(byte[] buff, int offset) {
return buff[offset];
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!