修改接口逻辑
This commit is contained in:
parent
4a38fb84a0
commit
fafd3ad8d3
@ -103,16 +103,16 @@ public class AjaxResultPro extends HashMap<String, Object>
|
|||||||
return new AjaxResultPro(HttpStatus.SUCCESS, "操作成功", data,total);
|
return new AjaxResultPro(HttpStatus.SUCCESS, "操作成功", data,total);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 返回成功消息
|
// * 返回成功消息
|
||||||
*
|
// *
|
||||||
* @param msg 返回内容
|
// * @param msg 返回内容
|
||||||
* @return 成功消息
|
// * @return 成功消息
|
||||||
*/
|
// */
|
||||||
public static AjaxResultPro success(String msg)
|
// public static AjaxResultPro success(String msg)
|
||||||
{
|
// {
|
||||||
return AjaxResultPro.success(msg, null);
|
// return AjaxResultPro.success(msg, null);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
|
@ -35,7 +35,6 @@ public class DeviceOtherMsgConsumer {
|
|||||||
String serialNumber=bo.getSerialNumber();//设备序列号
|
String serialNumber=bo.getSerialNumber();//设备序列号
|
||||||
Long productId;//产品id
|
Long productId;//产品id
|
||||||
|
|
||||||
|
|
||||||
Long packetId;//包号
|
Long packetId;//包号
|
||||||
byte[] data = bo.getData();//数据
|
byte[] data = bo.getData();//数据
|
||||||
String topic=bo.getTopicName();//主题
|
String topic=bo.getTopicName();//主题
|
||||||
|
@ -28,7 +28,7 @@ import com.fastbee.common.core.page.TableDataInfo;
|
|||||||
* 设备上电审核前上报的基础信息Controller
|
* 设备上电审核前上报的基础信息Controller
|
||||||
*
|
*
|
||||||
* @author kerwincui
|
* @author kerwincui
|
||||||
* @date 2024-12-05
|
* @date 2024-12-05
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/iot/device/report/info")
|
@RequestMapping("/iot/device/report/info")
|
||||||
@ -107,4 +107,14 @@ public class DeviceReportInfoController extends BaseController
|
|||||||
{
|
{
|
||||||
return toAjax(deviceReportInfoService.deleteDeviceReportInfoByIds(ids));
|
return toAjax(deviceReportInfoService.deleteDeviceReportInfoByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量更新状态为已打印
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:info:edit')")
|
||||||
|
@PutMapping("/updateStatus")
|
||||||
|
@ApiOperation("批量更新状态")
|
||||||
|
public AjaxResult updateStatus(@RequestBody List<DeviceReportInfo> deviceReportInfos){
|
||||||
|
return toAjax(deviceReportInfoService.updateDeviceReportStatus(deviceReportInfos));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ public class PrinterController extends BaseController {
|
|||||||
printerService.imagePrint(imageUrl);
|
printerService.imagePrint(imageUrl);
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -74,7 +74,6 @@ public class GenerateQRCodeImage {
|
|||||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int textX = qrCodeWidth-5; // 问文本与二维码的水平间距
|
int textX = qrCodeWidth-5; // 问文本与二维码的水平间距
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,8 +10,14 @@ import org.springframework.http.MediaType;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备审核前上电基本信息
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/sse")
|
@RequestMapping("/sse")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -37,6 +43,9 @@ public class DeviceReportSSEController extends BaseController {
|
|||||||
if(emitter==null){
|
if(emitter==null){
|
||||||
return AjaxResultPro.error("审核员离线!请到管理后台打开设备初始化页面!");
|
return AjaxResultPro.error("审核员离线!请到管理后台打开设备初始化页面!");
|
||||||
}
|
}
|
||||||
|
//生成设备默认编号
|
||||||
|
// reportInfo.setDeviceId("10086");
|
||||||
|
String deviceNumber = generateDeviceNumber();
|
||||||
emitter.send(JSONUtil.toJsonStr(Message.builder().event(2).content("新的消息").data(reportInfo).build()));
|
emitter.send(JSONUtil.toJsonStr(Message.builder().event(2).content("新的消息").data(reportInfo).build()));
|
||||||
return AjaxResultPro.success();
|
return AjaxResultPro.success();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
@ -72,4 +81,40 @@ public class DeviceReportSSEController extends BaseController {
|
|||||||
emitter.send(JSONUtil.toJsonStr(Message.builder().event(2).content("新的消息").data(deviceReportInfo).build()));
|
emitter.send(JSONUtil.toJsonStr(Message.builder().event(2).content("新的消息").data(deviceReportInfo).build()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成当前批次的设备编码
|
||||||
|
*/
|
||||||
|
@GetMapping("/device/init/deviceNumber")
|
||||||
|
public AjaxResultPro getDeviceNumber() {
|
||||||
|
return AjaxResultPro.success(generateDeviceNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据给定规则生成当前批次的起始设备编号
|
||||||
|
* @return 生成的设备编号字符串
|
||||||
|
*/
|
||||||
|
public String generateDeviceNumber() {
|
||||||
|
StringBuilder deviceNumber = new StringBuilder();
|
||||||
|
// 添加固定的第一个字符'H'
|
||||||
|
deviceNumber.append("H");
|
||||||
|
// 获取当前日期
|
||||||
|
LocalDate currentDate = LocalDate.now();
|
||||||
|
int year = currentDate.getYear();
|
||||||
|
int month = currentDate.getMonthValue();
|
||||||
|
// 根据年份确定对应的字符,以2024年对应'A'为起始,依次往后按字母顺序
|
||||||
|
char yearChar = (char) ('A' + (year - 2024));
|
||||||
|
deviceNumber.append(yearChar);
|
||||||
|
// 月份转换为两位字符串格式,不足两位前面补0
|
||||||
|
String monthStr = String.format("%02d", month);
|
||||||
|
deviceNumber.append(monthStr);
|
||||||
|
return deviceNumber.toString()+"00001";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
package com.fastbee.iot.domain;
|
package com.fastbee.iot.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
import com.fastbee.common.annotation.Excel;
|
import com.fastbee.common.annotation.Excel;
|
||||||
import com.fastbee.common.core.domain.BaseEntity;
|
import com.fastbee.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备上电审核前上报的基础信息对象 iot_device_report_info
|
* 设备上电审核前上报的基础信息对象 iot_device_report_info
|
||||||
*
|
*
|
||||||
@ -136,4 +138,16 @@ public class DeviceReportInfo extends BaseEntity
|
|||||||
@Excel(name = "状态:0未审核,1已审核,2已打印")
|
@Excel(name = "状态:0未审核,1已审核,2已打印")
|
||||||
@ApiModelProperty("状态:0未审核,1已审核,2已打印")
|
@ApiModelProperty("状态:0未审核,1已审核,2已打印")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
/** 上电时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Excel(name = "上电时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty("上电时间")
|
||||||
|
private Date powersTime;
|
||||||
|
|
||||||
|
//----------------------------------------------------------业务字段-----------------------------------------------------------
|
||||||
|
/** 是否自动审核 */
|
||||||
|
private Boolean autoReview ;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,4 +58,6 @@ public interface IDeviceReportInfoService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteDeviceReportInfoById(Long id);
|
public int deleteDeviceReportInfoById(Long id);
|
||||||
|
|
||||||
|
boolean updateDeviceReportStatus(List<DeviceReportInfo> deviceReportInfo);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.fastbee.iot.service.impl;
|
package com.fastbee.iot.service.impl;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
@ -23,9 +24,6 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
|
|||||||
private DeviceReportInfoMapper deviceReportInfoMapper;
|
private DeviceReportInfoMapper deviceReportInfoMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询设备上电审核前上报的基础信息
|
* 查询设备上电审核前上报的基础信息
|
||||||
*
|
*
|
||||||
@ -47,7 +45,11 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
|
|||||||
@Override
|
@Override
|
||||||
public List<DeviceReportInfo> selectDeviceReportInfoList(DeviceReportInfo deviceReportInfo)
|
public List<DeviceReportInfo> selectDeviceReportInfoList(DeviceReportInfo deviceReportInfo)
|
||||||
{
|
{
|
||||||
return deviceReportInfoMapper.selectDeviceReportInfoList(deviceReportInfo);
|
List<DeviceReportInfo> deviceReportInfos = deviceReportInfoMapper.selectDeviceReportInfoList(deviceReportInfo);
|
||||||
|
//按照时间由近到远进行排序
|
||||||
|
deviceReportInfos.sort((o1, o2) -> o2.getPowersTime().compareTo(o1.getPowersTime()));
|
||||||
|
|
||||||
|
return deviceReportInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,17 +64,22 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
|
|||||||
//设备编码查重
|
//设备编码查重
|
||||||
List<DeviceReportInfo> list = new LambdaQueryChainWrapper<>(deviceReportInfoMapper)
|
List<DeviceReportInfo> list = new LambdaQueryChainWrapper<>(deviceReportInfoMapper)
|
||||||
.select(DeviceReportInfo::getSerialNumber,DeviceReportInfo::getImei)
|
.select(DeviceReportInfo::getSerialNumber,DeviceReportInfo::getImei)
|
||||||
.eq(DeviceReportInfo::getSerialNumber, deviceReportInfo.getSerialNumber())
|
// .eq(DeviceReportInfo::getSerialNumber, deviceReportInfo.getSerialNumber())
|
||||||
.or()
|
// .or()
|
||||||
.eq(DeviceReportInfo::getImei, deviceReportInfo.getImei())
|
.eq(DeviceReportInfo::getImei, deviceReportInfo.getImei())
|
||||||
.list();
|
.list();
|
||||||
System.err.println("查重:"+list);
|
// System.err.println("查重:"+list);
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
if (list.get(0).getImei().equals(deviceReportInfo.getImei())) {
|
if (list.get(0).getImei().equals(deviceReportInfo.getImei())) {
|
||||||
throw new ServiceException("IMEI号重复!");
|
throw new ServiceException("IMEI号重复!");
|
||||||
} else if (list.get(0).getSerialNumber().equals(deviceReportInfo.getSerialNumber())) {
|
|
||||||
throw new ServiceException("设备编号重复!");
|
|
||||||
}
|
}
|
||||||
|
// else if (list.get(0).getSerialNumber().equals(deviceReportInfo.getSerialNumber())) {
|
||||||
|
// throw new ServiceException("设备编号重复!");
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
//处理自动审核
|
||||||
|
if(deviceReportInfo.getAutoReview()!=null&&deviceReportInfo.getAutoReview()){
|
||||||
|
deviceReportInfo.setStatus(2);//修改状态为已审核
|
||||||
}
|
}
|
||||||
return deviceReportInfoMapper.insertDeviceReportInfo(deviceReportInfo);
|
return deviceReportInfoMapper.insertDeviceReportInfo(deviceReportInfo);
|
||||||
}
|
}
|
||||||
@ -112,4 +119,11 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
|
|||||||
{
|
{
|
||||||
return deviceReportInfoMapper.deleteDeviceReportInfoById(id);
|
return deviceReportInfoMapper.deleteDeviceReportInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateDeviceReportStatus(List<DeviceReportInfo> deviceReportInfo) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,11 @@
|
|||||||
<result property="replaceManufacturerName" column="replace_manufacturer_name" />
|
<result property="replaceManufacturerName" column="replace_manufacturer_name" />
|
||||||
<result property="deviceId" column="device_id" />
|
<result property="deviceId" column="device_id" />
|
||||||
<result property="status" column="status" />
|
<result property="status" column="status" />
|
||||||
|
<result property="powersTime" column="powers_time" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectDeviceReportInfoVo">
|
<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, serial_number, qr_code, name, lcd_manufacturer_name, voice_manufacturer_name, replace_manufacturer_name, device_id, status 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, name, lcd_manufacturer_name, voice_manufacturer_name, replace_manufacturer_name, device_id, status, powers_time from iot_device_report_info
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectDeviceReportInfoList" parameterType="DeviceReportInfo" resultMap="DeviceReportInfoResult">
|
<select id="selectDeviceReportInfoList" parameterType="DeviceReportInfo" resultMap="DeviceReportInfoResult">
|
||||||
@ -59,6 +60,7 @@
|
|||||||
<if test="replaceManufacturerName != null and replaceManufacturerName != ''"> and replace_manufacturer_name like concat('%', #{replaceManufacturerName}, '%')</if>
|
<if test="replaceManufacturerName != null and replaceManufacturerName != ''"> and replace_manufacturer_name like concat('%', #{replaceManufacturerName}, '%')</if>
|
||||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||||
<if test="status != null "> and status = #{status}</if>
|
<if test="status != null "> and status = #{status}</if>
|
||||||
|
<if test="powersTime != null "> and powers_time = #{powersTime}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -92,6 +94,7 @@
|
|||||||
<if test="replaceManufacturerName != null">replace_manufacturer_name,</if>
|
<if test="replaceManufacturerName != null">replace_manufacturer_name,</if>
|
||||||
<if test="deviceId != null">device_id,</if>
|
<if test="deviceId != null">device_id,</if>
|
||||||
<if test="status != null">status,</if>
|
<if test="status != null">status,</if>
|
||||||
|
<if test="powersTime != null">powers_time,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="imei != null and imei != ''">#{imei},</if>
|
<if test="imei != null and imei != ''">#{imei},</if>
|
||||||
@ -116,6 +119,7 @@
|
|||||||
<if test="replaceManufacturerName != null">#{replaceManufacturerName},</if>
|
<if test="replaceManufacturerName != null">#{replaceManufacturerName},</if>
|
||||||
<if test="deviceId != null">#{deviceId},</if>
|
<if test="deviceId != null">#{deviceId},</if>
|
||||||
<if test="status != null">#{status},</if>
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="powersTime != null">#{powersTime},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@ -144,6 +148,7 @@
|
|||||||
<if test="replaceManufacturerName != null">replace_manufacturer_name = #{replaceManufacturerName},</if>
|
<if test="replaceManufacturerName != null">replace_manufacturer_name = #{replaceManufacturerName},</if>
|
||||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||||
<if test="status != null">status = #{status},</if>
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="powersTime != null">powers_time = #{powersTime},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user