|
@@ -17,6 +17,7 @@ import com.xy.collections.list.JList;
|
|
|
import com.xy.collections.map.JHashMap;
|
|
|
import com.xy.collections.map.JMap;
|
|
|
import com.xy.config.DeviceThreadPoolConfig;
|
|
|
+import com.xy.dto.CommandMqtt;
|
|
|
import com.xy.dto.DeviceAnnualFeeDto;
|
|
|
import com.xy.dto.MqttUserDto;
|
|
|
import com.xy.dto.be.MercDto;
|
|
@@ -44,10 +45,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static com.xy.utils.PlusBeans.toIPage;
|
|
|
import static com.xy.utils.PlusBeans.toPageBean;
|
|
@@ -83,6 +81,8 @@ public class DeviceAnnualFeeServiceImpl extends ServiceImpl<DeviceAnnualFeeMappe
|
|
|
|
|
|
private MercService mercService;
|
|
|
|
|
|
+ private MqttService mqttService;
|
|
|
+
|
|
|
@PostMapping("check")
|
|
|
@ApiOperation("检查")
|
|
|
public R<String> check(@RequestBody @Validated DeviceAnnualFeeDto.Check check) {
|
|
@@ -292,6 +292,8 @@ public class DeviceAnnualFeeServiceImpl extends ServiceImpl<DeviceAnnualFeeMappe
|
|
|
//发送请求
|
|
|
FunctionUtils.ParamsNoResult<Map<Long, JSONObject>> sendPost = jsonObjects -> {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
+ Map<String, SysDictRedis> map = SysDictUtils.get("mqtt_cmd_templet_task");
|
|
|
+ String value = map.get("env").getValue();
|
|
|
ThreadPoolUtils.Execute execute = ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_COMMON_POLL, deviceIds.size());
|
|
|
//多线程逐条发送,发送集合担心参数体过大
|
|
|
deviceIds.forEach(deviceId -> execute.execute(() -> {
|
|
@@ -300,7 +302,10 @@ public class DeviceAnnualFeeServiceImpl extends ServiceImpl<DeviceAnnualFeeMappe
|
|
|
return;
|
|
|
}
|
|
|
SysDictRedis sysDictRedis = stringSysDictRedisMap.get(String.valueOf(deviceAnnualFee.getMercId()));
|
|
|
- String url = JSONUtil.parseObj(sysDictRedis.getValue()).getStr("device_send_url");
|
|
|
+ JSONObject obj = JSONUtil.parseObj(sysDictRedis.getValue());
|
|
|
+ String url = obj.getStr("device_send_url");
|
|
|
+ JSONObject env = JSONUtil.parseObj(value)
|
|
|
+ .set("env", obj.getStr("env"));
|
|
|
JSONObject jsonObject = jsonObjects.get(deviceId);
|
|
|
JSONObject result = send(url, jsonObject, "发送设备数据到商家平台");
|
|
|
//修改设备年费注册信息
|
|
@@ -308,6 +313,11 @@ public class DeviceAnnualFeeServiceImpl extends ServiceImpl<DeviceAnnualFeeMappe
|
|
|
deviceAnnualFee.setRegisterStatus(true)
|
|
|
.setRegisterTime(now);
|
|
|
updateById(deviceAnnualFee);
|
|
|
+ //发送环境切换指令
|
|
|
+ CommandMqtt commandMqtt = new CommandMqtt()
|
|
|
+ .setDeviceId(deviceId)
|
|
|
+ .setTemplet(env);
|
|
|
+ mqttService.senCommand(Collections.singletonList(commandMqtt));
|
|
|
}
|
|
|
})
|
|
|
.error(e -> log.error("", e))
|