设备上电审核基本信息上报接口,逻辑完善
This commit is contained in:
@ -0,0 +1,210 @@
|
||||
package com.fastbee.common.core.domain;
|
||||
|
||||
import com.fastbee.common.constant.HttpStatus;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 操作消息提醒
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class AjaxResultPro extends HashMap<String, Object>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 状态码 */
|
||||
public static final String CODE_TAG = "code";
|
||||
|
||||
/** 返回内容 */
|
||||
public static final String MSG_TAG = "msg";
|
||||
|
||||
/** 数据对象 */
|
||||
public static final String DATA_TAG = "data";
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
||||
*/
|
||||
public AjaxResultPro()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
*/
|
||||
public AjaxResultPro(int code, String msg)
|
||||
{
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
*/
|
||||
public AjaxResultPro(int code, String msg, Object data)
|
||||
{
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
super.put(DATA_TAG, data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
*/
|
||||
public AjaxResultPro(int code, String msg, Object data, int total)
|
||||
{
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
|
||||
super.put(DATA_TAG, data);
|
||||
super.put("total",total);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResultPro success()
|
||||
{
|
||||
return AjaxResultPro.success("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功数据
|
||||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResultPro success(Object data)
|
||||
{
|
||||
return AjaxResultPro.success("操作成功", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功数据
|
||||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResultPro success(Object data, int total)
|
||||
{
|
||||
return new AjaxResultPro(HttpStatus.SUCCESS, "操作成功", data,total);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResultPro success(String msg)
|
||||
{
|
||||
return AjaxResultPro.success(msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResultPro success(String msg, Object data)
|
||||
{
|
||||
return new AjaxResultPro(HttpStatus.SUCCESS, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回警告消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResultPro warn(String msg)
|
||||
{
|
||||
return AjaxResultPro.warn(msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回警告消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResultPro warn(String msg, Object data)
|
||||
{
|
||||
return new AjaxResultPro(HttpStatus.WARN, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResultPro error()
|
||||
{
|
||||
return AjaxResultPro.error("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResultPro error(String msg)
|
||||
{
|
||||
return AjaxResultPro.error(msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResultPro error(String msg, Object data)
|
||||
{
|
||||
return new AjaxResultPro(HttpStatus.ERROR, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResultPro error(int code, String msg)
|
||||
{
|
||||
return new AjaxResultPro(code, msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 方便链式调用
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return 数据对象
|
||||
*/
|
||||
@Override
|
||||
public AjaxResultPro put(String key, Object value)
|
||||
{
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -133,6 +133,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/test/**/*").permitAll()
|
||||
.antMatchers("/prod-api/**").permitAll()
|
||||
.antMatchers("/system/district/tree").permitAll()
|
||||
.antMatchers("/sse/**").permitAll()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated()
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.fastbee.data.controller.gis.mqtt;
|
||||
|
||||
import com.fastbee.mqttclient.PubMqttCallBack;
|
||||
import com.fastbee.mqttclient.PubMqttClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/mqtt")
|
||||
public class MqttTest {
|
||||
|
||||
@Autowired
|
||||
private PubMqttClient pubMqttClient;
|
||||
|
||||
@Autowired
|
||||
private PubMqttCallBack pubMqttCallBack;
|
||||
|
||||
/**
|
||||
* 测试平台mqtt发布消息
|
||||
*/
|
||||
@GetMapping("/publish")
|
||||
public String test(){
|
||||
pubMqttClient.publish(1,true,"/topic/test","mqtt测试主题发布消息!");
|
||||
return "test";
|
||||
}
|
||||
/**
|
||||
* 测试创建mqtt客户端
|
||||
*/
|
||||
@GetMapping("/subscribe")
|
||||
public String test2(){
|
||||
// pubMqttClient
|
||||
return "test2";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.fastbee.data.controller.sse;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.core.domain.AjaxResultPro;
|
||||
import com.fastbee.iot.domain.DeviceReportInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@RestController
|
||||
@RequestMapping("/sse")
|
||||
@Slf4j
|
||||
@CrossOrigin(origins = "*")
|
||||
public class DeviceReportSSEController extends BaseController {
|
||||
private final Map<String, SseEmitter> emitters = new ConcurrentHashMap<>();//用户消息推送集合
|
||||
|
||||
/**
|
||||
* 与客户端建立http长链接
|
||||
*/
|
||||
@PostMapping(value = "/device/init",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public SseEmitter getReport() throws IOException {
|
||||
SseEmitter emitter= new SseEmitter(0L);
|
||||
emitters.put("device-init",emitter);
|
||||
emitter.send(JSONUtil.toJsonStr(Message.builder().event(1).content("连接成功!").build()));
|
||||
return emitter;
|
||||
}
|
||||
|
||||
@PostMapping("/device/init/new")
|
||||
public AjaxResultPro sendMsg(@RequestBody DeviceReportInfo reportInfo) {
|
||||
try{
|
||||
SseEmitter emitter = emitters.get("device-init");
|
||||
if(emitter==null){
|
||||
return AjaxResultPro.error("审核员离线!请到管理后台打开设备初始化页面!");
|
||||
}
|
||||
emitter.send(JSONUtil.toJsonStr(Message.builder().event(2).content("新的消息").data(reportInfo).build()));
|
||||
return AjaxResultPro.success();
|
||||
}catch (Exception e){
|
||||
log.error("发送消息失败",e);
|
||||
return AjaxResultPro.error("系统错误!");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/device/init/new/remove")
|
||||
public AjaxResultPro removeMsg() {
|
||||
emitters.clear();
|
||||
return AjaxResultPro.success();
|
||||
}
|
||||
|
||||
@PostMapping("/device/init/new/text")
|
||||
public void sendMsgText(@RequestBody DeviceReportInfo reportInfo) throws IOException {
|
||||
SseEmitter emitter = emitters.get("device-init");
|
||||
DeviceReportInfo deviceReportInfo = new DeviceReportInfo();
|
||||
deviceReportInfo.setImei("10086");
|
||||
deviceReportInfo.setIccid("10086");
|
||||
deviceReportInfo.setMcuId("wqewqewq");
|
||||
deviceReportInfo.setBspType("iwqjriqw");
|
||||
deviceReportInfo.setLteType("rui");
|
||||
deviceReportInfo.setMcuType("mcu");
|
||||
deviceReportInfo.setMcuFw("1.0.0");
|
||||
deviceReportInfo.setLteFw("opodaojdao");
|
||||
deviceReportInfo.setLcdManufacturer(1L);
|
||||
deviceReportInfo.setVoiceManufacturer(1L);
|
||||
deviceReportInfo.setFramModel("BTOOO");
|
||||
deviceReportInfo.setReplaceManufacturer(1L);
|
||||
deviceReportInfo.setTestRecord("test");
|
||||
if(emitter!=null){
|
||||
emitter.send(JSONUtil.toJsonStr(Message.builder().event(2).content("新的消息").data(deviceReportInfo).build()));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.fastbee.data.controller.sse;
|
||||
|
||||
import com.fastbee.iot.domain.DeviceReportInfo;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author mijiupro
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class Message {
|
||||
private String content;
|
||||
private Integer event;
|
||||
private DeviceReportInfo data;
|
||||
}
|
@ -13,7 +13,7 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
* 设备上电审核前上报的基础信息对象 iot_device_report_info
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-12-05
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@ApiModel(value = "DeviceReportInfo",description = "设备上电审核前上报的基础信息 iot_device_report_info")
|
||||
@Data
|
||||
@ -22,7 +22,7 @@ public class DeviceReportInfo extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
/** */
|
||||
private Long id;
|
||||
|
||||
/** 模组IMEI号 */
|
||||
@ -95,4 +95,14 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("批号")
|
||||
private Long batchNumber;
|
||||
|
||||
/** 设备编号 */
|
||||
@Excel(name = "设备编号")
|
||||
@ApiModelProperty("设备编号")
|
||||
private String serialNumber;
|
||||
|
||||
/** 二维码 */
|
||||
@Excel(name = "二维码")
|
||||
@ApiModelProperty("二维码")
|
||||
private String qrCode;
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
|
||||
@Autowired
|
||||
private DeviceReportInfoMapper deviceReportInfoMapper;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备上电审核前上报的基础信息
|
||||
*
|
||||
|
@ -20,10 +20,12 @@
|
||||
<result property="replaceManufacturer" column="replace_manufacturer" />
|
||||
<result property="testRecord" column="test_record" />
|
||||
<result property="batchNumber" column="batch_number" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="qrCode" column="qr_code" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeviceReportInfoVo">
|
||||
select id, imei, iccid, mcu_id, bsp_type, lte_type, mcu_type, mcu_fw, lte_fw, lcd_manufacturer, voice_manufacturer, fram_model, replace_manufacturer, test_record, batch_number from iot_device_report_info
|
||||
select id, imei, iccid, mcu_id, bsp_type, lte_type, mcu_type, mcu_fw, lte_fw, lcd_manufacturer, voice_manufacturer, fram_model, replace_manufacturer, test_record, batch_number, serial_number, qr_code from iot_device_report_info
|
||||
</sql>
|
||||
|
||||
<select id="selectDeviceReportInfoList" parameterType="DeviceReportInfo" resultMap="DeviceReportInfoResult">
|
||||
@ -43,6 +45,8 @@
|
||||
<if test="replaceManufacturer != null "> and replace_manufacturer = #{replaceManufacturer}</if>
|
||||
<if test="testRecord != null and testRecord != ''"> and test_record = #{testRecord}</if>
|
||||
<if test="batchNumber != null "> and batch_number = #{batchNumber}</if>
|
||||
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
|
||||
<if test="qrCode != null and qrCode != ''"> and qr_code = #{qrCode}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -68,6 +72,8 @@
|
||||
<if test="replaceManufacturer != null">replace_manufacturer,</if>
|
||||
<if test="testRecord != null">test_record,</if>
|
||||
<if test="batchNumber != null">batch_number,</if>
|
||||
<if test="serialNumber != null">serial_number,</if>
|
||||
<if test="qrCode != null">qr_code,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="imei != null and imei != ''">#{imei},</if>
|
||||
@ -84,6 +90,8 @@
|
||||
<if test="replaceManufacturer != null">#{replaceManufacturer},</if>
|
||||
<if test="testRecord != null">#{testRecord},</if>
|
||||
<if test="batchNumber != null">#{batchNumber},</if>
|
||||
<if test="serialNumber != null">#{serialNumber},</if>
|
||||
<if test="qrCode != null">#{qrCode},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -104,6 +112,8 @@
|
||||
<if test="replaceManufacturer != null">replace_manufacturer = #{replaceManufacturer},</if>
|
||||
<if test="testRecord != null">test_record = #{testRecord},</if>
|
||||
<if test="batchNumber != null">batch_number = #{batchNumber},</if>
|
||||
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
|
||||
<if test="qrCode != null">qr_code = #{qrCode},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
@ -69,7 +69,6 @@ public class ProjectServiceImpl implements IProjectService
|
||||
this.toolService = toolService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据主键查询项目
|
||||
*
|
||||
|
Reference in New Issue
Block a user