|
@@ -0,0 +1,115 @@
|
|
|
|
|
+package com.platform.api.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.platform.api.manager.WeighbridgeRecordManage;
|
|
|
|
|
+import com.platform.api.request.LicensePlateValidateRequest;
|
|
|
|
|
+import com.platform.api.request.WeighbridgePushRequest;
|
|
|
|
|
+import com.platform.api.response.LicensePlateValidateResponse;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
+
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 地磅数据上报接口
|
|
|
|
|
+ * @author cxf
|
|
|
|
|
+ */
|
|
|
|
|
+@Tag(name = "地磅数据接口", description = "地磅过磅数据上报相关接口")
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/api/v2/device")
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class WeighbridgeV2Controller {
|
|
|
|
|
+
|
|
|
|
|
+ private final WeighbridgeRecordManage weighbridgeRecordManage;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 地磅过磅数据上报
|
|
|
|
|
+ */
|
|
|
|
|
+ @Operation(summary = "地磅过磅数据上报", description = "接收地磅设备上报的过磅数据和图片")
|
|
|
|
|
+ @PostMapping("/weighBridgePush")
|
|
|
|
|
+ public LicensePlateValidateResponse weighBridgePush(
|
|
|
|
|
+ @Parameter(description = "车牌号") @RequestParam("licensePlate") String licensePlate,
|
|
|
|
|
+ @Parameter(description = "地磅编号") @RequestParam("weighbridgeCode") String weighbridgeCode,
|
|
|
|
|
+ @Parameter(description = "称重重量(吨)") @RequestParam("grossWeight") String grossWeight,
|
|
|
|
|
+ @Parameter(description = "时间戳(秒或毫秒)") @RequestParam("timestamp") String timestamp,
|
|
|
|
|
+ @Parameter(description = "处理标签") @RequestParam(value = "tag", required = false) String tag,
|
|
|
|
|
+ @Parameter(description = "车辆照片") @RequestParam(value = "images[]", required = false) MultipartFile[] images
|
|
|
|
|
+ ) {
|
|
|
|
|
+ // 构建请求对象
|
|
|
|
|
+ WeighbridgePushRequest request = new WeighbridgePushRequest();
|
|
|
|
|
+ String lience = StringUtils.isNotBlank(licensePlate) ? licensePlate.trim().replace("\\r", "").replace("\\n", ""):"";
|
|
|
|
|
+ request.setLicensePlate(lience);
|
|
|
|
|
+ String weighCode =StringUtils.isNotBlank(weighbridgeCode) ? weighbridgeCode.trim().replace("\\r", "").replace("\\n", ""):"";
|
|
|
|
|
+ request.setWeighbridgeCode(weighCode);
|
|
|
|
|
+ String rossWeight = StringUtils.isNotBlank(grossWeight) ?grossWeight.trim().replace("\\r", "").replace("\\n", ""):"";
|
|
|
|
|
+ request.setGrossWeight(new BigDecimal(rossWeight));
|
|
|
|
|
+ String time = StringUtils.isNotBlank(timestamp) ? timestamp.trim().replace("\\r", "").replace("\\n", ""):"";
|
|
|
|
|
+ request.setTimestamp(Long.valueOf(time));
|
|
|
|
|
+ request.setTag(tag);
|
|
|
|
|
+ request.setImages(images);
|
|
|
|
|
+
|
|
|
|
|
+ // 调用业务层处理
|
|
|
|
|
+ return weighbridgeRecordManage.handleWeighbridgePush(request);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 车牌验证
|
|
|
|
|
+ */
|
|
|
|
|
+ @Operation(summary = "车牌验证", description = "用于验证车牌是否合法,允许上磅")
|
|
|
|
|
+ @PostMapping("/validateLicensePlate")
|
|
|
|
|
+ public LicensePlateValidateResponse validateLicensePlate(
|
|
|
|
|
+ @Parameter(description = "车牌号") @RequestParam("licensePlate") String licensePlate,
|
|
|
|
|
+ @Parameter(description = "厂商来源标识") @RequestParam("uuid") String uuid
|
|
|
|
|
+ ) {
|
|
|
|
|
+ LicensePlateValidateRequest request = new LicensePlateValidateRequest();
|
|
|
|
|
+ String replac2 = "";
|
|
|
|
|
+ if (StringUtils.isNotBlank(licensePlate)) {
|
|
|
|
|
+ String trim = licensePlate.trim();
|
|
|
|
|
+ String replace = trim.replace("\\r", "");
|
|
|
|
|
+ String replace1 = replace.replace("\\n", "");
|
|
|
|
|
+ replac2 = replace1.replace("\\r\\n", "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ request.setLicensePlate(replac2);
|
|
|
|
|
+ request.setUuid(uuid);
|
|
|
|
|
+ return weighbridgeRecordManage.handleValidateLicensePlate(request);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Operation(summary = "地磅过磅数据上报", description = "接收地磅设备上报的过磅数据和图片")
|
|
|
|
|
+ @PostMapping("/weighBridgePush")
|
|
|
|
|
+ public LicensePlateValidateResponse weighBridgePushV2(
|
|
|
|
|
+ @Parameter(description = "车牌号") @RequestParam("licensePlate") String licensePlate,
|
|
|
|
|
+ @Parameter(description = "地磅编号") @RequestParam("weighbridgeCode") String weighbridgeCode,
|
|
|
|
|
+ @Parameter(description = "称重重量(吨)") @RequestParam("grossWeight") String grossWeight,
|
|
|
|
|
+ @Parameter(description = "时间戳(秒或毫秒)") @RequestParam("timestamp") String timestamp,
|
|
|
|
|
+ @Parameter(description = "处理标签") @RequestParam(value = "tag", required = false) String tag,
|
|
|
|
|
+ @Parameter(description = "车辆照片") @RequestParam(value = "images", required = false) List<String> images
|
|
|
|
|
+ ) {
|
|
|
|
|
+ // 构建请求对象
|
|
|
|
|
+ WeighbridgePushRequest request = new WeighbridgePushRequest();
|
|
|
|
|
+ String lience = StringUtils.isNotBlank(licensePlate) ? licensePlate.trim().replace("\\r", "").replace("\\n", ""):"";
|
|
|
|
|
+ request.setLicensePlate(lience);
|
|
|
|
|
+ String weighCode =StringUtils.isNotBlank(weighbridgeCode) ? weighbridgeCode.trim().replace("\\r", "").replace("\\n", ""):"";
|
|
|
|
|
+ request.setWeighbridgeCode(weighCode);
|
|
|
|
|
+ String rossWeight = StringUtils.isNotBlank(grossWeight) ?grossWeight.trim().replace("\\r", "").replace("\\n", ""):"";
|
|
|
|
|
+ request.setGrossWeight(new BigDecimal(rossWeight));
|
|
|
|
|
+ String time = StringUtils.isNotBlank(timestamp) ? timestamp.trim().replace("\\r", "").replace("\\n", ""):"";
|
|
|
|
|
+ request.setTimestamp(Long.valueOf(time));
|
|
|
|
|
+ request.setTag(tag);
|
|
|
|
|
+ request.setBase64Images(images);
|
|
|
|
|
+
|
|
|
|
|
+ // 调用业务层处理
|
|
|
|
|
+ return weighbridgeRecordManage.handleWeighbridgePushV2(request);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|