Browse Source

音箱

master
shenzhouyu 6 days ago
parent
commit
7531ba4244
  1. 2
      src/main/java/com/xujie/sys/modules/pms/service/ILoraWatchUtils.java
  2. 39
      src/main/java/com/xujie/sys/modules/pms/service/Impl/EamServiceImpl.java
  3. 14
      src/main/java/com/xujie/sys/modules/pms/util/LoraWatchUtils.java

2
src/main/java/com/xujie/sys/modules/pms/service/ILoraWatchUtils.java

@ -13,4 +13,6 @@ public interface ILoraWatchUtils {
SoundBoxResponseVo sendSoundBox(String loraurl, int site, int vodTimes , String vodBuf);
SoundBoxResponseVo changeSoundBoxVolume(String loraurl, int site, int volume);
SoundBoxResponseVo sendBeepBox(String loraurl, int site, int vodTimes , int vodBeep);
}

39
src/main/java/com/xujie/sys/modules/pms/service/Impl/EamServiceImpl.java

@ -4155,16 +4155,41 @@ public class EamServiceImpl implements EamService {
}
}
//发送语音播报
for (SOIssueNotifyOrderMaterialListData data : soIssueNotifyOrderMaterialListData) {
String vodBuf = "现在播报," + data.getNotifyNo() + "申请单," + addSpace(data.getComponentPartNo()) + "料号未及时配料";
loraWatchUtils.sendSoundBox(newLocation.getIp(), 1, 1, vodBuf);
if(soIssueNotifyOrderMaterialListData !=null && soIssueNotifyOrderMaterialListData.size()>0){
loraWatchUtils.sendBeepBox(newLocation.getIp(), 1, 1, 1);
try {
Thread.sleep(10000);
Thread.sleep(2000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
// 发送语音播报大于 2 条时每 3 条播报一次剩余不足 3 条在结束时一起播报
int batchSize = soIssueNotifyOrderMaterialListData.size() > 2
? 3
: soIssueNotifyOrderMaterialListData.size();
int batchCount = 0;
int processed = 0;
String vodBuf = "";
for (SOIssueNotifyOrderMaterialListData data : soIssueNotifyOrderMaterialListData) {
vodBuf += data.getNotifyNo() + "申请单," + addSpace(data.getComponentPartNo()) + "料号未及时配料,,,,";
batchCount++;
processed++;
boolean reachBatch = batchCount == batchSize;
boolean isLast = processed == soIssueNotifyOrderMaterialListData.size();
if (reachBatch || isLast) {
loraWatchUtils.sendSoundBox(newLocation.getIp(), 1, 1, vodBuf);
vodBuf = "";
batchCount = 0;
// 批次发送之间保持间隔避免设备被频繁触发
if (!isLast && soIssueNotifyOrderMaterialListData.size() > batchSize) {
try {
Thread.sleep(28000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
}
}
}

14
src/main/java/com/xujie/sys/modules/pms/util/LoraWatchUtils.java

@ -45,6 +45,8 @@ public class LoraWatchUtils implements ILoraWatchUtils {
private static String CMDSENDSOUND = "sendSound";
private static String CMDCHANGEVOLUME = "sendVolume";
private static String SENDBEEP = "sendBeep";
/**
* 发送消息
@ -168,6 +170,18 @@ public class LoraWatchUtils implements ILoraWatchUtils {
return vo;
}
@Override
public SoundBoxResponseVo sendBeepBox(String loraurl, int site, int vodTimes , int vodBeep) {
Map<String,Integer> map = new LinkedHashMap<>();
map.put("site",site);
map.put("vodTimes",vodTimes);
map.put("vodBeep",vodBeep);
String jsonString = new GsonBuilder().disableHtmlEscaping().create().toJson(map);
SoundBoxResponseVo vo = doPostSetHeaderSendSoundBox(loraurl, CMD,SENDBEEP, jsonString,100000);
return vo;
}
public static LoraWatchResponseVo doPostSetHeaderSendEntity(String url, String headerKey,String headerValue, String params,int time){
CloseableHttpClient httpClient = HttpClientBuilder.create().build();

Loading…
Cancel
Save