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;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.device.pojo.entity.DeviceInfoEntity;
import com.njzscloud.supervisory.device.service.DeviceInfoService;
import com.njzscloud.supervisory.order.pojo.param.DeviceRecognitionParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@ -87,7 +85,7 @@ public class DeviceInfoController {
*/
@PostMapping("/recognition")
public R<?> recognition(@RequestBody JSONObject param) {
JSONObject alarmInfoPlate = param.getJSONObject("AlarmInfoPlate");
/* JSONObject alarmInfoPlate = param.getJSONObject("AlarmInfoPlate");
if (alarmInfoPlate == null) {
alarmInfoPlate = param.getJSONObject("alarmInfoPlate");
}
@ -116,7 +114,7 @@ public class DeviceInfoController {
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();
}

View File

@ -60,6 +60,8 @@ public class DeviceInfoEntity {
*/
private Long stationId;
private String cid;
/**
* ; 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.OrderStatus;
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.TruckLeavingOrderParam;
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)));
}
public void recognition(DeviceRecognitionParam deviceRecognitionParam) {
/* public void recognition(DeviceRecognitionParam deviceRecognitionParam) {
String sn = deviceRecognitionParam.getSn();
DeviceInfoEntity deviceInfoEntity = this.getOne(Wrappers.<DeviceInfoEntity>lambdaQuery().eq(DeviceInfoEntity::getSn, sn));
if (deviceInfoEntity == null) {
@ -175,7 +174,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
}
}
} */
public Map<String, Object> report1(JSONObject data) {
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())
.build();
}
String cid = deviceInfoEntity.getCid();
OrderPagingResult orderPagingResult = orderInfoService.pendingOrder(licensePlate);
if (orderPagingResult == null) {
// 播语音
@ -205,7 +205,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
OrderStatus orderStatus = orderPagingResult.getOrderStatus();
if (deviceCode == DeviceCode.JinQianZhi && orderStatus == OrderStatus.QingYunZhong) {
// 开门
open(sn);
open(sn, cid);
return resBuilder
.put("data", dataBuilder.put("type", 0).build())
.build();
@ -230,7 +230,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
if (deviceCode == DeviceCode.ChuQianZhi && orderStatus == OrderStatus.YiJinChang) {
// 开门
open(sn);
open(sn, cid);
return resBuilder
.put("data", dataBuilder.put("type", 0).build())
.build();
@ -268,11 +268,12 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
.build();
}
String cid = deviceInfoEntity.getCid();
DeviceCode deviceCode = deviceInfoEntity.getDeviceCode();
OrderInfoEntity orderInfo = orderInfoService.getById(orderId);
if (orderInfo == null) {
// 播语音
playVoice(sn, "{}无订单", orderId);
playVoice(sn, cid, "{}无订单", orderId);
return resBuilder
.put("data", dataBuilder.build())
.build();
@ -291,7 +292,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
// 播语音
playVoice(sn, "{}称重完成,磅重{}吨", licensePlate, weight / 1000);
// 开门
open(sn);
open(sn, cid);
orderInfoService.truckComing(new TruckComingOrderParam()
.setOrderId(orderId)
.setWeight(weight)
@ -311,9 +312,9 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
// 播语音
playVoice(sn, "{}称重完成,磅重{}吨", licensePlate, weight / 1000);
// 开门
open(sn);
open(sn, cid);
} 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();
}
private void open(String sn) {
log.info("开门: {}", sn);
Mqtt.publish("zsy/1/barrier", MapUtil.builder()
private void open(String sn, String cid) {
log.info("开门: {} {}", sn, cid);
Mqtt.publish(cid + "/1/barrier", MapUtil.builder()
.put("deviceNo", sn)
.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);
log.info("播语音: {} {}", sn, format);
Mqtt.publish("zsy/1/voice", MapUtil.builder()
log.info("播语音: {} {} {}", sn, cid, format);
Mqtt.publish(cid + "/1/voice", MapUtil.builder()
.put("deviceNo", sn)
.put("text", format)
.build());