修改接口逻辑
This commit is contained in:
@ -28,7 +28,7 @@ import com.fastbee.common.core.page.TableDataInfo;
|
||||
* 设备上电审核前上报的基础信息Controller
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-12-05
|
||||
* @date 2024-12-05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/iot/device/report/info")
|
||||
@ -107,4 +107,14 @@ public class DeviceReportInfoController extends BaseController
|
||||
{
|
||||
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);
|
||||
Thread.sleep(200);
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
/**
|
||||
|
@ -74,7 +74,6 @@ public class GenerateQRCodeImage {
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||
|
||||
|
||||
|
||||
int textX = qrCodeWidth-5; // 问文本与二维码的水平间距
|
||||
|
||||
|
||||
|
@ -10,8 +10,14 @@ 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.time.LocalDate;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 设备审核前上电基本信息
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sse")
|
||||
@Slf4j
|
||||
@ -37,6 +43,9 @@ public class DeviceReportSSEController extends BaseController {
|
||||
if(emitter==null){
|
||||
return AjaxResultPro.error("审核员离线!请到管理后台打开设备初始化页面!");
|
||||
}
|
||||
//生成设备默认编号
|
||||
// reportInfo.setDeviceId("10086");
|
||||
String deviceNumber = generateDeviceNumber();
|
||||
emitter.send(JSONUtil.toJsonStr(Message.builder().event(2).content("新的消息").data(reportInfo).build()));
|
||||
return AjaxResultPro.success();
|
||||
}catch (Exception e){
|
||||
@ -72,4 +81,40 @@ public class DeviceReportSSEController extends BaseController {
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user