设备上电审核前上报的基础信息表管理接口,以及设备厂商管理接口调整等

This commit is contained in:
mi9688 2024-12-06 17:34:01 +08:00
parent 6aaed01915
commit 71f4f3b139
15 changed files with 260 additions and 48 deletions

View File

@ -23,7 +23,8 @@
<scope>test</scope>
</dependency>
<!-- spring-boot-devtools -->
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>

View File

@ -16,7 +16,7 @@ public class FastBeeApplication
{
public static void main(String[] args)
{
// System.setProperty("spring.devtools.restart.enabled", "false");
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(FastBeeApplication.class, args);
}
}

View File

@ -143,4 +143,5 @@ public class SysDictTypeController extends BaseController
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
return success(dictTypes);
}
}

View File

@ -29,6 +29,13 @@
<artifactId>spring-web</artifactId>
</dependency>
<!-- websocket-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- spring security 安全认证 -->
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -62,6 +62,8 @@
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.fastbee</groupId>-->
<!-- <artifactId>fastbee-project-service</artifactId>-->

View File

@ -31,7 +31,7 @@ import com.fastbee.common.core.page.TableDataInfo;
* @date 2024-12-05
*/
@RestController
@RequestMapping("/iot/info")
@RequestMapping("/iot/device/report/info")
@Api(tags = "设备上电审核前上报的基础信息")
public class DeviceReportInfoController extends BaseController
{
@ -41,9 +41,9 @@ public class DeviceReportInfoController extends BaseController
/**
* 查询设备上电审核前上报的基础信息列表
*/
@PreAuthorize("@ss.hasPermi('iot:info:list')")
@GetMapping("/list")
@ApiOperation("查询设备上电审核前上报的基础信息列表")
@PreAuthorize("@ss.hasPermi('iot:info:list')")
@GetMapping("/list")
@ApiOperation("查询设备上电审核前上报的基础信息列表")
public TableDataInfo list(DeviceReportInfo deviceReportInfo)
{
startPage();

View File

@ -30,7 +30,7 @@ import com.fastbee.common.core.page.TableDataInfo;
* @date 2024-11-13
*/
@RestController
@RequestMapping("/renke/manufacturers")
@RequestMapping("/device/manufacturers")
@Api(tags = "设备厂家信息")
public class DeviceManufacturersController extends BaseController
{

View File

@ -0,0 +1,18 @@
package com.fastbee.data.controller.websocket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* @author hanjinqun
* @date 2022/10/24
*/
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}

View File

@ -0,0 +1,34 @@
package com.fastbee.data.controller.websocket;
import com.fastbee.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* ws发送消息测试
*/
@RestController
@RequestMapping(value = "/api/v1/websocket")
public class WebSocketController {
@Autowired
private WebSocketService webSocketServer;
/**
* 模拟数据发送
*/
@RequestMapping(value = "/sendTestMessage", method = RequestMethod.GET)
public AjaxResult sendTestMessage(String message) {
try {
// webSocketServer.sendAllMessage(message);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error();
}
return AjaxResult.success("发送成功");
}
}

View File

@ -0,0 +1,134 @@
package com.fastbee.data.controller.websocket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
@Component
@ServerEndpoint("/websocket/{userId}")
public class WebSocketService {
/**
* 日志工具
*/
private Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* 与某个客户端的连接会话需要通过它来给客户端发送数据
*/
private Session session;
/**
* 用户id
*/
private String userId;
/**
* 用来存放每个客户端对应的MyWebSocket对象
*/
private static CopyOnWriteArraySet<WebSocketService> webSockets = new CopyOnWriteArraySet<>();
/**
* 用来存在线连接用户信息
*/
private static ConcurrentHashMap<String, Session> sessionPool = new ConcurrentHashMap<String, Session>();
/**
* 链接成功调用的方法
*/
@OnOpen
public void onOpen(Session session, @PathParam(value = "userId") String userId) {
try {
this.session = session;
this.userId = userId;
webSockets.add(this);
sessionPool.put(userId, session);
logger.info("【websocket消息】有新的连接总数为:" + webSockets.size());
} catch (Exception e) {
}
}
/**
* 链接关闭调用的方法
*/
@OnClose
public void onClose() {
try {
webSockets.remove(this);
sessionPool.remove(this.userId);
logger.info("【websocket消息】连接断开总数为:" + webSockets.size());
} catch (Exception e) {
}
}
/**
* 收到客户端消息后调用的方法
*/
@OnMessage
public void onMessage(String message) {
logger.info("【websocket消息】收到客户端消息:" + message);
}
/**
* 发送错误时的处理
*
* @param session
* @param error
*/
@OnError
public void onError(Session session, Throwable error) {
logger.error("用户错误,原因:" + error.getMessage());
error.printStackTrace();
}
/**
* 此为广播消息
*/
public void sendAllMessage(String message) {
logger.info("【websocket消息】广播消息:" + message);
for (WebSocketService webSocket : webSockets) {
try {
if (webSocket.session.isOpen()) {
webSocket.session.getAsyncRemote().sendText(message);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 此为单点消息
*/
public void sendOneMessage(String userId, String message) {
Session session = sessionPool.get(userId);
if (session != null && session.isOpen()) {
try {
logger.info("【websocket消息】 单点消息:" + message);
session.getAsyncRemote().sendText(message);
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 此为单点消息(多人)
*/
public void sendMoreMessage(String[] userIds, String message) {
for (String userId : userIds) {
Session session = sessionPool.get(userId);
if (session != null && session.isOpen()) {
try {
logger.info("【websocket消息】 单点消息:" + message);
session.getAsyncRemote().sendText(message);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -13,64 +13,69 @@ import com.fastbee.common.core.domain.BaseEntity;
* 设备厂家信息对象 iot_device_manufacturers
*
* @author kerwincui
* @date 2024-11-13
* @date 2024-12-06
*/
@ApiModel(value = "DeviceManufacturers",description = "设备厂家信息 iot_device_manufacturers")
@Data
@EqualsAndHashCode(callSuper = true)
public class DeviceManufacturers extends BaseEntity
{
private static final long serialVersionUID = 1L;
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 厂家链接,接口基地址 */
@Excel(name = "厂家链接,接口基地址")
@ApiModelProperty("厂家链接,接口基地址")
@Excel(name = "厂家链接,接口基地址")
@ApiModelProperty("厂家链接,接口基地址")
private String endpoint;
/** 厂名称 */
@Excel(name = "厂名称")
@ApiModelProperty("厂名称")
@Excel(name = "厂名称")
@ApiModelProperty("厂名称")
private String manufacturerName;
/** 帐户 */
@Excel(name = "帐户")
@ApiModelProperty("帐户")
@Excel(name = "帐户")
@ApiModelProperty("帐户")
private String account;
/** 密码 */
@Excel(name = "密码")
@ApiModelProperty("密码")
@Excel(name = "密码")
@ApiModelProperty("密码")
private String password;
/** 接口文档 */
@Excel(name = "接口文档")
@ApiModelProperty("接口文档")
@Excel(name = "接口文档")
@ApiModelProperty("接口文档")
private String interfaceDocumentation;
/** api-key */
@Excel(name = "api-key")
@ApiModelProperty("api-key")
@Excel(name = "api-key")
@ApiModelProperty("api-key")
private String apiKey;
/** authId */
@Excel(name = "authId")
@ApiModelProperty("authId")
@Excel(name = "authId")
@ApiModelProperty("authId")
private String authid;
/** secret-key */
@Excel(name = "secret-key")
@ApiModelProperty("secret-key")
@Excel(name = "secret-key")
@ApiModelProperty("secret-key")
private String secretKey;
/** 厂家鉴权接口地址 */
@Excel(name = "厂家鉴权接口地址")
@ApiModelProperty("厂家鉴权接口地址")
@Excel(name = "厂家鉴权接口地址")
@ApiModelProperty("厂家鉴权接口地址")
private String tokenendpoint;
/** 删除标志0代表存在2代表删除 */
private Integer delFlag;
/** 厂家类型 */
@Excel(name = "厂家类型")
@ApiModelProperty("厂家类型")
private String manufacturerType;
}

View File

@ -3,7 +3,6 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fastbee.deviceData.mapper.DeviceManufacturersMapper">
<resultMap type="DeviceManufacturers" id="DeviceManufacturersResult">
<result property="id" column="id" />
<result property="endpoint" column="endpoint" />
@ -20,10 +19,11 @@
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="manufacturerType" column="manufacturer_type" />
</resultMap>
<sql id="selectDeviceManufacturersVo">
select id, endpoint, manufacturer_name, account, password, interface_documentation, api_key, authId, secret_key, tokenEndpoint, del_flag, create_time, create_by, update_time, update_by from iot_device_manufacturers
select id, endpoint, manufacturer_name, account, password, interface_documentation, api_key, authId, secret_key, tokenEndpoint, del_flag, create_time, create_by, update_time, update_by, manufacturer_type from iot_device_manufacturers
</sql>
<select id="selectDeviceManufacturersList" parameterType="DeviceManufacturers" resultMap="DeviceManufacturersResult">
@ -38,6 +38,7 @@
<if test="authid != null and authid != ''"> and authId = #{authid}</if>
<if test="secretKey != null and secretKey != ''"> and secret_key = #{secretKey}</if>
<if test="tokenendpoint != null and tokenendpoint != ''"> and tokenEndpoint = #{tokenendpoint}</if>
<if test="manufacturerType != null and manufacturerType != ''"> and manufacturer_type = #{manufacturerType}</if>
</where>
</select>
@ -63,6 +64,7 @@
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="manufacturerType != null">manufacturer_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="endpoint != null">#{endpoint},</if>
@ -79,6 +81,7 @@
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="manufacturerType != null">#{manufacturerType},</if>
</trim>
</insert>
@ -99,6 +102,7 @@
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="manufacturerType != null">manufacturer_type = #{manufacturerType},</if>
</trim>
where id = #{id}
</update>

View File

@ -58,12 +58,12 @@ private static final long serialVersionUID = 1L;
/** MCU固件包含了固件的名称和版本 */
@Excel(name = "MCU固件包含了固件的名称和版本")
@ApiModelProperty("MCU固件包含了固件的名称和版本")
private String mcufw;
private String mcuFw;
/** 模组固件,包含了固件的名称和版本 */
@Excel(name = "模组固件,包含了固件的名称和版本")
@ApiModelProperty("模组固件,包含了固件的名称和版本")
private String ltefw;
private String lteFw;
/** 显示屏厂家上报123等类似的数值通过后台进行录入数值和显示屏厂家对应关系例1对应GT2116 */
@Excel(name = "显示屏厂家上报123等类似的数值通过后台进行录入数值和显示屏厂家对应关系例1对应GT2116")
@ -90,4 +90,9 @@ private static final long serialVersionUID = 1L;
@ApiModelProperty("记录测试的过程,包括了测试脉冲次数、第一次上电时间等待补充信息")
private String testRecord;
/** 批号 */
@Excel(name = "批号")
@ApiModelProperty("批号")
private Long batchNumber;
}

View File

@ -154,7 +154,6 @@ public class DeviceDateTask {
catch (Exception e){
offlineDeviceList.add(deviceEncoding);
}
DeviceRealtimedataMeteorology deviceRealtimedataMeteorology = metDataService.setData(deviceRealTimeData);
boolean save = meteorologySaveDataService.save(deviceRealtimedataMeteorology);
if (!save){
@ -172,8 +171,6 @@ public class DeviceDateTask {
new LambdaUpdateChainWrapper<>(meteorologyMapper).in(DeviceInformationMeteorology::getDeviceEncoding,offlineDeviceList).set(DeviceInformationMeteorology::getStatus, 0).update();
}
}
}
/**
* 获取墒情设备实时数据并保存
@ -186,7 +183,6 @@ public class DeviceDateTask {
//在线设备列表
List<String> onlineDeviceList = new ArrayList<>();
try{
deviceEncodingList.forEach(deviceEncoding->{
Map<String, String> deviceRealTimeData = new HashMap<>();
try {
@ -206,7 +202,7 @@ public class DeviceDateTask {
}
}
catch (Exception e){
log.error("获取墒情设备实时数据失败",e);
log.error("获取墒情设备实时数据失败:{}",e.getMessage());
if(!offlineDeviceList.isEmpty()){
new LambdaUpdateChainWrapper<>(moistureMapper).in(DeviceInformationMoisture::getDeviceEncoding,offlineDeviceList).set(DeviceInformationMoisture::getStatus, 0).update();
}

View File

@ -12,17 +12,18 @@
<result property="bspType" column="bsp_type" />
<result property="lteType" column="lte_type" />
<result property="mcuType" column="mcu_type" />
<result property="mcufw" column="mcuFw" />
<result property="ltefw" column="lteFw" />
<result property="mcuFw" column="mcu_fw" />
<result property="lteFw" column="lte_fw" />
<result property="lcdManufacturer" column="lcd_manufacturer" />
<result property="voiceManufacturer" column="voice_manufacturer" />
<result property="framModel" column="fram_model" />
<result property="replaceManufacturer" column="replace_manufacturer" />
<result property="testRecord" column="test_record" />
<result property="batchNumber" column="batch_number" />
</resultMap>
<sql id="selectDeviceReportInfoVo">
select id, imei, iccid, mcu_id, bsp_type, lte_type, mcu_type, mcuFw, lteFw, lcd_manufacturer, voice_manufacturer, fram_model, replace_manufacturer, test_record 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 from iot_device_report_info
</sql>
<select id="selectDeviceReportInfoList" parameterType="DeviceReportInfo" resultMap="DeviceReportInfoResult">
@ -34,13 +35,14 @@
<if test="bspType != null and bspType != ''"> and bsp_type = #{bspType}</if>
<if test="lteType != null and lteType != ''"> and lte_type = #{lteType}</if>
<if test="mcuType != null and mcuType != ''"> and mcu_type = #{mcuType}</if>
<if test="mcufw != null and mcufw != ''"> and mcuFw = #{mcufw}</if>
<if test="ltefw != null and ltefw != ''"> and lteFw = #{ltefw}</if>
<if test="mcuFw != null and mcuFw != ''"> and mcu_fw = #{mcuFw}</if>
<if test="lteFw != null and lteFw != ''"> and lte_fw = #{lteFw}</if>
<if test="lcdManufacturer != null "> and lcd_manufacturer = #{lcdManufacturer}</if>
<if test="voiceManufacturer != null "> and voice_manufacturer = #{voiceManufacturer}</if>
<if test="framModel != null and framModel != ''"> and fram_model = #{framModel}</if>
<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>
</where>
</select>
@ -58,13 +60,14 @@
<if test="bspType != null and bspType != ''">bsp_type,</if>
<if test="lteType != null and lteType != ''">lte_type,</if>
<if test="mcuType != null and mcuType != ''">mcu_type,</if>
<if test="mcufw != null and mcufw != ''">mcuFw,</if>
<if test="ltefw != null and ltefw != ''">lteFw,</if>
<if test="mcuFw != null and mcuFw != ''">mcu_fw,</if>
<if test="lteFw != null and lteFw != ''">lte_fw,</if>
<if test="lcdManufacturer != null">lcd_manufacturer,</if>
<if test="voiceManufacturer != null">voice_manufacturer,</if>
<if test="framModel != null and framModel != ''">fram_model,</if>
<if test="replaceManufacturer != null">replace_manufacturer,</if>
<if test="testRecord != null">test_record,</if>
<if test="batchNumber != null">batch_number,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="imei != null and imei != ''">#{imei},</if>
@ -73,13 +76,14 @@
<if test="bspType != null and bspType != ''">#{bspType},</if>
<if test="lteType != null and lteType != ''">#{lteType},</if>
<if test="mcuType != null and mcuType != ''">#{mcuType},</if>
<if test="mcufw != null and mcufw != ''">#{mcufw},</if>
<if test="ltefw != null and ltefw != ''">#{ltefw},</if>
<if test="mcuFw != null and mcuFw != ''">#{mcuFw},</if>
<if test="lteFw != null and lteFw != ''">#{lteFw},</if>
<if test="lcdManufacturer != null">#{lcdManufacturer},</if>
<if test="voiceManufacturer != null">#{voiceManufacturer},</if>
<if test="framModel != null and framModel != ''">#{framModel},</if>
<if test="replaceManufacturer != null">#{replaceManufacturer},</if>
<if test="testRecord != null">#{testRecord},</if>
<if test="batchNumber != null">#{batchNumber},</if>
</trim>
</insert>
@ -92,13 +96,14 @@
<if test="bspType != null and bspType != ''">bsp_type = #{bspType},</if>
<if test="lteType != null and lteType != ''">lte_type = #{lteType},</if>
<if test="mcuType != null and mcuType != ''">mcu_type = #{mcuType},</if>
<if test="mcufw != null and mcufw != ''">mcuFw = #{mcufw},</if>
<if test="ltefw != null and ltefw != ''">lteFw = #{ltefw},</if>
<if test="mcuFw != null and mcuFw != ''">mcu_fw = #{mcuFw},</if>
<if test="lteFw != null and lteFw != ''">lte_fw = #{lteFw},</if>
<if test="lcdManufacturer != null">lcd_manufacturer = #{lcdManufacturer},</if>
<if test="voiceManufacturer != null">voice_manufacturer = #{voiceManufacturer},</if>
<if test="framModel != null and framModel != ''">fram_model = #{framModel},</if>
<if test="replaceManufacturer != null">replace_manufacturer = #{replaceManufacturer},</if>
<if test="testRecord != null">test_record = #{testRecord},</if>
<if test="batchNumber != null">batch_number = #{batchNumber},</if>
</trim>
where id = #{id}
</update>