localizer
lzq 2025-10-03 11:05:35 +08:00
parent fb123655a9
commit fee617cfe3
3 changed files with 20 additions and 19 deletions

View File

@ -1,13 +1,11 @@
package com.njzscloud.supervisory.device.controller; package com.njzscloud.supervisory.device.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.njzscloud.common.core.utils.R; import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam; import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult; import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.device.pojo.entity.DeviceInfoEntity; import com.njzscloud.supervisory.device.pojo.entity.DeviceInfoEntity;
import com.njzscloud.supervisory.device.service.DeviceInfoService; import com.njzscloud.supervisory.device.service.DeviceInfoService;
import com.njzscloud.supervisory.order.pojo.param.DeviceRecognitionParam;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -87,7 +85,7 @@ public class DeviceInfoController {
*/ */
@PostMapping("/recognition") @PostMapping("/recognition")
public R<?> recognition(@RequestBody JSONObject param) { public R<?> recognition(@RequestBody JSONObject param) {
JSONObject alarmInfoPlate = param.getJSONObject("AlarmInfoPlate"); /* JSONObject alarmInfoPlate = param.getJSONObject("AlarmInfoPlate");
if (alarmInfoPlate == null) { if (alarmInfoPlate == null) {
alarmInfoPlate = param.getJSONObject("alarmInfoPlate"); alarmInfoPlate = param.getJSONObject("alarmInfoPlate");
} }
@ -116,7 +114,7 @@ public class DeviceInfoController {
return R.failed(); return R.failed();
} }
deviceInfoService.recognition(new DeviceRecognitionParam().setSn(serialno).setImg(imageFile).setLicensePlate(license)); deviceInfoService.recognition(new DeviceRecognitionParam().setSn(serialno).setImg(imageFile).setLicensePlate(license)); */
return R.success(); return R.success();
} }

View File

@ -60,6 +60,8 @@ public class DeviceInfoEntity {
*/ */
private Long stationId; private Long stationId;
private String cid;
/** /**
* ; lane * ; lane
*/ */

View File

@ -16,7 +16,6 @@ import com.njzscloud.supervisory.device.pojo.entity.DeviceInfoEntity;
import com.njzscloud.supervisory.order.contant.CheckStatus; import com.njzscloud.supervisory.order.contant.CheckStatus;
import com.njzscloud.supervisory.order.contant.OrderStatus; import com.njzscloud.supervisory.order.contant.OrderStatus;
import com.njzscloud.supervisory.order.pojo.entity.OrderInfoEntity; import com.njzscloud.supervisory.order.pojo.entity.OrderInfoEntity;
import com.njzscloud.supervisory.order.pojo.param.DeviceRecognitionParam;
import com.njzscloud.supervisory.order.pojo.param.TruckComingOrderParam; import com.njzscloud.supervisory.order.pojo.param.TruckComingOrderParam;
import com.njzscloud.supervisory.order.pojo.param.TruckLeavingOrderParam; import com.njzscloud.supervisory.order.pojo.param.TruckLeavingOrderParam;
import com.njzscloud.supervisory.order.pojo.result.OrderPagingResult; import com.njzscloud.supervisory.order.pojo.result.OrderPagingResult;
@ -91,7 +90,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
return PageResult.of(this.page(pageParam.toPage(), Wrappers.<DeviceInfoEntity>query(deviceInfoEntity))); return PageResult.of(this.page(pageParam.toPage(), Wrappers.<DeviceInfoEntity>query(deviceInfoEntity)));
} }
public void recognition(DeviceRecognitionParam deviceRecognitionParam) { /* public void recognition(DeviceRecognitionParam deviceRecognitionParam) {
String sn = deviceRecognitionParam.getSn(); String sn = deviceRecognitionParam.getSn();
DeviceInfoEntity deviceInfoEntity = this.getOne(Wrappers.<DeviceInfoEntity>lambdaQuery().eq(DeviceInfoEntity::getSn, sn)); DeviceInfoEntity deviceInfoEntity = this.getOne(Wrappers.<DeviceInfoEntity>lambdaQuery().eq(DeviceInfoEntity::getSn, sn));
if (deviceInfoEntity == null) { if (deviceInfoEntity == null) {
@ -175,7 +174,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
} }
} } */
public Map<String, Object> report1(JSONObject data) { public Map<String, Object> report1(JSONObject data) {
MapBuilder<String, Object> resBuilder = MapUtil.<String, Object>builder() MapBuilder<String, Object> resBuilder = MapUtil.<String, Object>builder()
@ -193,6 +192,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
.put("data", dataBuilder.put("type", 0).build()) .put("data", dataBuilder.put("type", 0).build())
.build(); .build();
} }
String cid = deviceInfoEntity.getCid();
OrderPagingResult orderPagingResult = orderInfoService.pendingOrder(licensePlate); OrderPagingResult orderPagingResult = orderInfoService.pendingOrder(licensePlate);
if (orderPagingResult == null) { if (orderPagingResult == null) {
// 播语音 // 播语音
@ -205,7 +205,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
OrderStatus orderStatus = orderPagingResult.getOrderStatus(); OrderStatus orderStatus = orderPagingResult.getOrderStatus();
if (deviceCode == DeviceCode.JinQianZhi && orderStatus == OrderStatus.QingYunZhong) { if (deviceCode == DeviceCode.JinQianZhi && orderStatus == OrderStatus.QingYunZhong) {
// 开门 // 开门
open(sn); open(sn, cid);
return resBuilder return resBuilder
.put("data", dataBuilder.put("type", 0).build()) .put("data", dataBuilder.put("type", 0).build())
.build(); .build();
@ -230,7 +230,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
if (deviceCode == DeviceCode.ChuQianZhi && orderStatus == OrderStatus.YiJinChang) { if (deviceCode == DeviceCode.ChuQianZhi && orderStatus == OrderStatus.YiJinChang) {
// 开门 // 开门
open(sn); open(sn, cid);
return resBuilder return resBuilder
.put("data", dataBuilder.put("type", 0).build()) .put("data", dataBuilder.put("type", 0).build())
.build(); .build();
@ -268,11 +268,12 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
.build(); .build();
} }
String cid = deviceInfoEntity.getCid();
DeviceCode deviceCode = deviceInfoEntity.getDeviceCode(); DeviceCode deviceCode = deviceInfoEntity.getDeviceCode();
OrderInfoEntity orderInfo = orderInfoService.getById(orderId); OrderInfoEntity orderInfo = orderInfoService.getById(orderId);
if (orderInfo == null) { if (orderInfo == null) {
// 播语音 // 播语音
playVoice(sn, "{}无订单", orderId); playVoice(sn, cid, "{}无订单", orderId);
return resBuilder return resBuilder
.put("data", dataBuilder.build()) .put("data", dataBuilder.build())
.build(); .build();
@ -291,7 +292,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
// 播语音 // 播语音
playVoice(sn, "{}称重完成,磅重{}吨", licensePlate, weight / 1000); playVoice(sn, "{}称重完成,磅重{}吨", licensePlate, weight / 1000);
// 开门 // 开门
open(sn); open(sn, cid);
orderInfoService.truckComing(new TruckComingOrderParam() orderInfoService.truckComing(new TruckComingOrderParam()
.setOrderId(orderId) .setOrderId(orderId)
.setWeight(weight) .setWeight(weight)
@ -311,9 +312,9 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
// 播语音 // 播语音
playVoice(sn, "{}称重完成,磅重{}吨", licensePlate, weight / 1000); playVoice(sn, "{}称重完成,磅重{}吨", licensePlate, weight / 1000);
// 开门 // 开门
open(sn); open(sn, cid);
} catch (Exception e) { } catch (Exception e) {
playVoice(sn, "{}称重异常,磅重{}吨", licensePlate, weight / 1000); playVoice(sn, cid, "{}称重异常,磅重{}吨", licensePlate, weight / 1000);
} }
} }
@ -322,17 +323,17 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
.build(); .build();
} }
private void open(String sn) { private void open(String sn, String cid) {
log.info("开门: {}", sn); log.info("开门: {} {}", sn, cid);
Mqtt.publish("zsy/1/barrier", MapUtil.builder() Mqtt.publish(cid + "/1/barrier", MapUtil.builder()
.put("deviceNo", sn) .put("deviceNo", sn)
.build()); .build());
} }
private void playVoice(String sn, String content, Object... params) { private void playVoice(String sn, String cid, String content, Object... params) {
String format = StrUtil.format(content, params); String format = StrUtil.format(content, params);
log.info("播语音: {} {}", sn, format); log.info("播语音: {} {} {}", sn, cid, format);
Mqtt.publish("zsy/1/voice", MapUtil.builder() Mqtt.publish(cid + "/1/voice", MapUtil.builder()
.put("deviceNo", sn) .put("deviceNo", sn)
.put("text", format) .put("text", format)
.build()); .build());