流量计设备实时数据接口修改,修复设备码字体服务器不支持问题。流量计设备实时数据接口调整等

This commit is contained in:
蒾酒 2024-12-23 14:47:34 +08:00
parent 38a856af55
commit a2d9eaa80e
11 changed files with 128 additions and 49 deletions

View File

@ -42,7 +42,7 @@ public class SysDictTypeController extends BaseController
private ISysDictTypeService dictTypeService; private ISysDictTypeService dictTypeService;
@ApiOperation("获取字典分页列表") @ApiOperation("获取字典分页列表")
@PreAuthorize("@ss.hasPermi('system:dict:list')") // @PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysDictType dictType) public TableDataInfo list(SysDictType dictType)
{ {
@ -53,7 +53,7 @@ public class SysDictTypeController extends BaseController
@ApiOperation("导出字典列表") @ApiOperation("导出字典列表")
@Log(title = "字典类型", businessType = BusinessType.EXPORT) @Log(title = "字典类型", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')") // @PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, SysDictType dictType) public void export(HttpServletResponse response, SysDictType dictType)
{ {
@ -66,7 +66,7 @@ public class SysDictTypeController extends BaseController
* 查询字典类型详细 * 查询字典类型详细
*/ */
@ApiOperation("查询字典类型详细") @ApiOperation("查询字典类型详细")
@PreAuthorize("@ss.hasPermi('system:dict:query')") // @PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictId}") @GetMapping(value = "/{dictId}")
public AjaxResult getInfo(@PathVariable Long dictId) public AjaxResult getInfo(@PathVariable Long dictId)
{ {
@ -77,7 +77,7 @@ public class SysDictTypeController extends BaseController
* 新增字典类型 * 新增字典类型
*/ */
@ApiOperation("新增字典类型") @ApiOperation("新增字典类型")
@PreAuthorize("@ss.hasPermi('system:dict:add')") // @PreAuthorize("@ss.hasPermi('system:dict:add')")
@Log(title = "字典类型", businessType = BusinessType.INSERT) @Log(title = "字典类型", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@Validated @RequestBody SysDictType dict) public AjaxResult add(@Validated @RequestBody SysDictType dict)
@ -94,7 +94,7 @@ public class SysDictTypeController extends BaseController
* 修改字典类型 * 修改字典类型
*/ */
@ApiOperation("新增字典类型") @ApiOperation("新增字典类型")
@PreAuthorize("@ss.hasPermi('system:dict:edit')") // @PreAuthorize("@ss.hasPermi('system:dict:edit')")
@Log(title = "字典类型", businessType = BusinessType.UPDATE) @Log(title = "字典类型", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictType dict) public AjaxResult edit(@Validated @RequestBody SysDictType dict)
@ -111,7 +111,7 @@ public class SysDictTypeController extends BaseController
* 删除字典类型 * 删除字典类型
*/ */
@ApiOperation("删除字典类型") @ApiOperation("删除字典类型")
@PreAuthorize("@ss.hasPermi('system:dict:remove')") // @PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE) @Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictIds}") @DeleteMapping("/{dictIds}")
public AjaxResult remove(@PathVariable Long[] dictIds) public AjaxResult remove(@PathVariable Long[] dictIds)
@ -124,7 +124,7 @@ public class SysDictTypeController extends BaseController
* 刷新字典缓存 * 刷新字典缓存
*/ */
@ApiOperation("刷新字典缓存") @ApiOperation("刷新字典缓存")
@PreAuthorize("@ss.hasPermi('system:dict:refresh')") // @PreAuthorize("@ss.hasPermi('system:dict:refresh')")
@Log(title = "字典类型", businessType = BusinessType.CLEAN) @Log(title = "字典类型", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache") @DeleteMapping("/refreshCache")
public AjaxResult refreshCache() public AjaxResult refreshCache()

View File

@ -56,16 +56,26 @@ public class DeviceOtherMsgConsumer {
System.err.println("主题:"+topic+"--产品id:"+productId+"--设备序列号:"+serialNumber); System.err.println("主题:"+topic+"--产品id:"+productId+"--设备序列号:"+serialNumber);
//设备上报数据消息 //设备上报数据消息
if(topic.endsWith("hzlink/info/up")){ if(topic.endsWith("/info/up")){
deviceDataReportHandler(new String(data)); deviceDataReportHandler(new String(data));
//保存使用记录 //保存使用记录
NgWaterPumpUsageRecords pumpUsageRecords=new NgWaterPumpUsageRecords(); NgWaterPumpUsageRecords pumpUsageRecords=new NgWaterPumpUsageRecords();
pumpUsageRecords.setDeviceNumber(serialNumber); pumpUsageRecords.setDeviceNumber(serialNumber);
pumpUsageRecords.setMessageContent(new String(data)); JSONObject jsonObject = JSONUtil.parseObj(data);
int i = ngWaterPumpUsageRecordsMapper.insertNgWaterPumpUsageRecords(pumpUsageRecords); if(jsonObject.getStr("type")!=null){
if(i<1){ if(jsonObject.getStr("type").equals("waterEleData")){
System.err.println("--------------------------保存使用记录失败!---------------------------"); String data1 = jsonObject.getStr("data");
if(JSONUtil.parseObj(data1).get("action").equals("timeMsg")){
pumpUsageRecords.setMessageContent(JSONUtil.toJsonStr(jsonObject));
int i = ngWaterPumpUsageRecordsMapper.insertNgWaterPumpUsageRecords(pumpUsageRecords);
if(i<1){
System.err.println("--------------------------保存使用记录失败!---------------------------");
}
}
}
} }
//构建回复消息 //构建回复消息
Map<String,Object> reportMsg=new HashMap<>(); Map<String,Object> reportMsg=new HashMap<>();
reportMsg.put("code",0); reportMsg.put("code",0);
@ -74,7 +84,7 @@ public class DeviceOtherMsgConsumer {
} else if ( topic.endsWith("/info/reply")) { } else if ( topic.endsWith("/info/reply")) {
platformDataReportAckHandler(new String(data)); platformDataReportAckHandler(new String(data));
} else if (topic.endsWith("hzlink/cmd/down")) { } else if (topic.endsWith("/cmd/down")) {
platformCmdHandler(new String(data)); platformCmdHandler(new String(data));
//回应 //回应

View File

@ -55,7 +55,7 @@ public class DeviceReportInfoController extends BaseController
* 导出设备上电审核前上报的基础信息列表 * 导出设备上电审核前上报的基础信息列表
*/ */
@ApiOperation("导出设备上电审核前上报的基础信息列表") @ApiOperation("导出设备上电审核前上报的基础信息列表")
@PreAuthorize("@ss.hasPermi('iot:info:export')") // @PreAuthorize("@ss.hasPermi('iot:info:export')")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, DeviceReportInfo deviceReportInfo) public void export(HttpServletResponse response, DeviceReportInfo deviceReportInfo)
{ {
@ -67,7 +67,7 @@ public class DeviceReportInfoController extends BaseController
/** /**
* 获取设备上电审核前上报的基础信息详细信息 * 获取设备上电审核前上报的基础信息详细信息
*/ */
@PreAuthorize("@ss.hasPermi('iot:info:query')") // @PreAuthorize("@ss.hasPermi('iot:info:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiOperation("获取设备上电审核前上报的基础信息详细信息") @ApiOperation("获取设备上电审核前上报的基础信息详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id)
@ -78,7 +78,7 @@ public class DeviceReportInfoController extends BaseController
/** /**
* 新增设备上电审核前上报的基础信息 * 新增设备上电审核前上报的基础信息
*/ */
@PreAuthorize("@ss.hasPermi('iot:info:add')") // @PreAuthorize("@ss.hasPermi('iot:info:add')")
@PostMapping @PostMapping
@ApiOperation("新增设备上电审核前上报的基础信息") @ApiOperation("新增设备上电审核前上报的基础信息")
public AjaxResult add(@RequestBody DeviceReportInfo deviceReportInfo) public AjaxResult add(@RequestBody DeviceReportInfo deviceReportInfo)
@ -89,7 +89,7 @@ public class DeviceReportInfoController extends BaseController
/** /**
* 修改设备上电审核前上报的基础信息 * 修改设备上电审核前上报的基础信息
*/ */
@PreAuthorize("@ss.hasPermi('iot:info:edit')") // @PreAuthorize("@ss.hasPermi('iot:info:edit')")
@PutMapping @PutMapping
@ApiOperation("修改设备上电审核前上报的基础信息") @ApiOperation("修改设备上电审核前上报的基础信息")
public AjaxResult edit(@RequestBody DeviceReportInfo deviceReportInfo) public AjaxResult edit(@RequestBody DeviceReportInfo deviceReportInfo)
@ -100,7 +100,7 @@ public class DeviceReportInfoController extends BaseController
/** /**
* 删除设备上电审核前上报的基础信息 * 删除设备上电审核前上报的基础信息
*/ */
@PreAuthorize("@ss.hasPermi('iot:info:remove')") // @PreAuthorize("@ss.hasPermi('iot:info:remove')")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@ApiOperation("删除设备上电审核前上报的基础信息") @ApiOperation("删除设备上电审核前上报的基础信息")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids)
@ -111,7 +111,7 @@ public class DeviceReportInfoController extends BaseController
/** /**
* 批量更新状态为已打印 * 批量更新状态为已打印
*/ */
@PreAuthorize("@ss.hasPermi('iot:info:edit')") // @PreAuthorize("@ss.hasPermi('iot:info:edit')")
@PutMapping("/updateStatus") @PutMapping("/updateStatus")
@ApiOperation("批量更新状态") @ApiOperation("批量更新状态")
public AjaxResult updateStatus(@RequestBody List<DeviceReportInfo> deviceReportInfos){ public AjaxResult updateStatus(@RequestBody List<DeviceReportInfo> deviceReportInfos){

View File

@ -50,7 +50,7 @@ public class UploadedPhotosController extends BaseController {
/** /**
* 查询设备告警上传列表 * 查询设备告警上传列表
*/ */
@PreAuthorize("@ss.hasPermi('iot:photos:list')") // @PreAuthorize("@ss.hasPermi('iot:photos:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(UploadedPhotos uploadedPhotos) { public TableDataInfo list(UploadedPhotos uploadedPhotos) {
startPage(); startPage();

View File

@ -40,7 +40,7 @@ public class DeviceManufacturersController extends BaseController
/** /**
* 查询设备厂家信息列表 * 查询设备厂家信息列表
*/ */
@PreAuthorize("@ss.hasPermi('renke:manufacturers:list')") // @PreAuthorize("@ss.hasPermi('renke:manufacturers:list')")
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("查询设备厂家信息列表") @ApiOperation("查询设备厂家信息列表")
public TableDataInfo list(DeviceManufacturers deviceManufacturers) public TableDataInfo list(DeviceManufacturers deviceManufacturers)
@ -52,7 +52,7 @@ public class DeviceManufacturersController extends BaseController
/** /**
* 查询设备厂家信息列表 * 查询设备厂家信息列表
*/ */
@PreAuthorize("@ss.hasPermi('renke:manufacturers:list')") // @PreAuthorize("@ss.hasPermi('renke:manufacturers:list')")
@GetMapping("/type") @GetMapping("/type")
@ApiOperation("查询设备厂家信息列表") @ApiOperation("查询设备厂家信息列表")
public TableDataInfo listType(String type) public TableDataInfo listType(String type)
@ -66,7 +66,7 @@ public class DeviceManufacturersController extends BaseController
* 导出设备厂家信息列表 * 导出设备厂家信息列表
*/ */
@ApiOperation("导出设备厂家信息列表") @ApiOperation("导出设备厂家信息列表")
@PreAuthorize("@ss.hasPermi('renke:manufacturers:export')") // @PreAuthorize("@ss.hasPermi('renke:manufacturers:export')")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, DeviceManufacturers deviceManufacturers) public void export(HttpServletResponse response, DeviceManufacturers deviceManufacturers)
{ {
@ -78,7 +78,7 @@ public class DeviceManufacturersController extends BaseController
/** /**
* 获取设备厂家信息详细信息 * 获取设备厂家信息详细信息
*/ */
@PreAuthorize("@ss.hasPermi('renke:manufacturers:query')") // @PreAuthorize("@ss.hasPermi('renke:manufacturers:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiOperation("获取设备厂家信息详细信息") @ApiOperation("获取设备厂家信息详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id)
@ -89,7 +89,7 @@ public class DeviceManufacturersController extends BaseController
/** /**
* 新增设备厂家信息 * 新增设备厂家信息
*/ */
@PreAuthorize("@ss.hasPermi('renke:manufacturers:add')") // @PreAuthorize("@ss.hasPermi('renke:manufacturers:add')")
@PostMapping @PostMapping
@ApiOperation("新增设备厂家信息") @ApiOperation("新增设备厂家信息")
public AjaxResult add(@RequestBody DeviceManufacturers deviceManufacturers) public AjaxResult add(@RequestBody DeviceManufacturers deviceManufacturers)
@ -100,7 +100,7 @@ public class DeviceManufacturersController extends BaseController
/** /**
* 修改设备厂家信息 * 修改设备厂家信息
*/ */
@PreAuthorize("@ss.hasPermi('renke:manufacturers:edit')") // @PreAuthorize("@ss.hasPermi('renke:manufacturers:edit')")
@PutMapping @PutMapping
@ApiOperation("修改设备厂家信息") @ApiOperation("修改设备厂家信息")
public AjaxResult edit(@RequestBody DeviceManufacturers deviceManufacturers) public AjaxResult edit(@RequestBody DeviceManufacturers deviceManufacturers)
@ -111,7 +111,7 @@ public class DeviceManufacturersController extends BaseController
/** /**
* 删除设备厂家信息 * 删除设备厂家信息
*/ */
@PreAuthorize("@ss.hasPermi('renke:manufacturers:remove')") // @PreAuthorize("@ss.hasPermi('renke:manufacturers:remove')")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@ApiOperation("删除设备厂家信息") @ApiOperation("删除设备厂家信息")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids)

View File

@ -41,7 +41,7 @@ public class DeviceModelController extends BaseController
/** /**
* 查询设备型号列表 * 查询设备型号列表
*/ */
@PreAuthorize("@ss.hasPermi('deviceModel:model:list')") // @PreAuthorize("@ss.hasPermi('deviceModel:model:list')")
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("查询设备型号列表") @ApiOperation("查询设备型号列表")
public TableDataInfo list(DeviceModel deviceModel) public TableDataInfo list(DeviceModel deviceModel)
@ -55,7 +55,7 @@ public class DeviceModelController extends BaseController
* 导出设备型号列表 * 导出设备型号列表
*/ */
@ApiOperation("导出设备型号列表") @ApiOperation("导出设备型号列表")
@PreAuthorize("@ss.hasPermi('deviceModel:model:export')") // @PreAuthorize("@ss.hasPermi('deviceModel:model:export')")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, DeviceModel deviceModel) public void export(HttpServletResponse response, DeviceModel deviceModel)
{ {
@ -67,7 +67,7 @@ public class DeviceModelController extends BaseController
/** /**
* 获取设备型号详细信息 * 获取设备型号详细信息
*/ */
@PreAuthorize("@ss.hasPermi('deviceModel:model:query')") // @PreAuthorize("@ss.hasPermi('deviceModel:model:query')")
@GetMapping(value = "/{modelId}") @GetMapping(value = "/{modelId}")
@ApiOperation("获取设备型号详细信息") @ApiOperation("获取设备型号详细信息")
public AjaxResult getInfo(@PathVariable("modelId") Long modelId) public AjaxResult getInfo(@PathVariable("modelId") Long modelId)
@ -89,7 +89,7 @@ public class DeviceModelController extends BaseController
/** /**
* 修改设备型号 * 修改设备型号
*/ */
@PreAuthorize("@ss.hasPermi('deviceModel:model:edit')") // @PreAuthorize("@ss.hasPermi('deviceModel:model:edit')")
@PutMapping @PutMapping
@ApiOperation("修改设备型号") @ApiOperation("修改设备型号")
public AjaxResult edit(@RequestBody DeviceModel deviceModel) public AjaxResult edit(@RequestBody DeviceModel deviceModel)
@ -100,7 +100,7 @@ public class DeviceModelController extends BaseController
/** /**
* 删除设备型号 * 删除设备型号
*/ */
@PreAuthorize("@ss.hasPermi('deviceModel:model:remove')") // @PreAuthorize("@ss.hasPermi('deviceModel:model:remove')")
@DeleteMapping("/{modelIds}") @DeleteMapping("/{modelIds}")
@ApiOperation("删除设备型号") @ApiOperation("删除设备型号")
public AjaxResult remove(@PathVariable Long[] modelIds) public AjaxResult remove(@PathVariable Long[] modelIds)

View File

@ -68,7 +68,7 @@ public class GenerateQRCodeImage {
g2d.drawRect(50, 41, qrCodeImage.getWidth()-62, qrCodeImage.getHeight()-62); g2d.drawRect(50, 41, qrCodeImage.getWidth()-62, qrCodeImage.getHeight()-62);
// 绘制文字 // 绘制文字
g2d.setColor(Color.BLACK); g2d.setColor(Color.BLACK);
g2d.setFont(new Font("黑体", Font.BOLD, 20)); g2d.setFont(new Font("WenQuanYi Micro Hei", Font.BOLD, 20));
// 绘制第一段文字 // 绘制第一段文字
String text1 = deviceReportInfo.getName(); String text1 = deviceReportInfo.getName();
FontMetrics fontMetrics = g2d.getFontMetrics(); FontMetrics fontMetrics = g2d.getFontMetrics();
@ -85,7 +85,7 @@ public class GenerateQRCodeImage {
// 绘制第二段文字 // 绘制第二段文字
String text2 = "◉系列:"+deviceReportInfo.getMcuFw(); String text2 = "◉系列:"+deviceReportInfo.getMcuFw();
g2d.setFont(new Font("Dialog", Font.BOLD, 18)); g2d.setFont(new Font("WenQuanYi Micro Hei", Font.BOLD, 18));
int textY2 = textY1 + fontMetrics.getHeight() + 10; // 在第一段文字下方添加一些间距 int textY2 = textY1 + fontMetrics.getHeight() + 10; // 在第一段文字下方添加一些间距

View File

@ -1,5 +1,6 @@
package com.fastbee.data.controller.userRecharge; package com.fastbee.data.controller.userRecharge;
import java.util.Comparator;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -48,6 +49,9 @@ public class NgUserRechargeRecordsController extends BaseController
{ {
startPage(); startPage();
List<NgUserRechargeRecords> list = ngUserRechargeRecordsService.selectNgUserRechargeRecordsList(ngUserRechargeRecords); List<NgUserRechargeRecords> list = ngUserRechargeRecordsService.selectNgUserRechargeRecordsList(ngUserRechargeRecords);
//按照充值时间由近到远排序
list.sort(Comparator.comparing(NgUserRechargeRecords::getRechargeTime).reversed());
System.err.println("充值list = " + list);
return getDataTable(list); return getDataTable(list);
} }

View File

@ -67,7 +67,7 @@ public class NgWaterPumpUsageRecordsController extends BaseController
/** /**
* 获取水泵设备使用记录详细信息 * 获取水泵设备使用记录详细信息
*/ */
@PreAuthorize("@ss.hasPermi('rechargecard:records:query')") // @PreAuthorize("@ss.hasPermi('rechargecard:records:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiOperation("获取水泵设备使用记录详细信息") @ApiOperation("获取水泵设备使用记录详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id)
@ -78,7 +78,7 @@ public class NgWaterPumpUsageRecordsController extends BaseController
/** /**
* 新增水泵设备使用记录 * 新增水泵设备使用记录
*/ */
@PreAuthorize("@ss.hasPermi('rechargecard:records:add')") // @PreAuthorize("@ss.hasPermi('rechargecard:records:add')")
@PostMapping @PostMapping
@ApiOperation("新增水泵设备使用记录") @ApiOperation("新增水泵设备使用记录")
public AjaxResult add(@RequestBody NgWaterPumpUsageRecords ngWaterPumpUsageRecords) public AjaxResult add(@RequestBody NgWaterPumpUsageRecords ngWaterPumpUsageRecords)
@ -89,7 +89,7 @@ public class NgWaterPumpUsageRecordsController extends BaseController
/** /**
* 修改水泵设备使用记录 * 修改水泵设备使用记录
*/ */
@PreAuthorize("@ss.hasPermi('rechargecard:records:edit')") // @PreAuthorize("@ss.hasPermi('rechargecard:records:edit')")
@PutMapping @PutMapping
@ApiOperation("修改水泵设备使用记录") @ApiOperation("修改水泵设备使用记录")
public AjaxResult edit(@RequestBody NgWaterPumpUsageRecords ngWaterPumpUsageRecords) public AjaxResult edit(@RequestBody NgWaterPumpUsageRecords ngWaterPumpUsageRecords)
@ -100,7 +100,7 @@ public class NgWaterPumpUsageRecordsController extends BaseController
/** /**
* 删除水泵设备使用记录 * 删除水泵设备使用记录
*/ */
@PreAuthorize("@ss.hasPermi('rechargecard:records:remove')") // @PreAuthorize("@ss.hasPermi('rechargecard:records:remove')")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@ApiOperation("删除水泵设备使用记录") @ApiOperation("删除水泵设备使用记录")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids)

View File

@ -1,6 +1,12 @@
package com.fastbee.data.controller.userRecharge.zhanLian; package com.fastbee.data.controller.userRecharge.zhanLian;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.fastbee.common.core.domain.AjaxResultPro; import com.fastbee.common.core.domain.AjaxResultPro;
import com.fastbee.rechargecard.domain.NgUserRechargeRecords;
import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords;
import com.fastbee.rechargecard.mapper.NgWaterPumpUsageRecordsMapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
@ -9,7 +15,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -22,22 +30,79 @@ public class ZhanLianFlowDeviceDataController {
@Autowired @Autowired
private ZhanLianBaseService zhanLianBaseService; private ZhanLianBaseService zhanLianBaseService;
@Autowired
private NgWaterPumpUsageRecordsMapper ngWaterPumpUsageRecordsMapper;
@GetMapping("/realtimeData") @GetMapping("/realtimeData")
public AjaxResultPro realtimeData(@Param("deviceNumber") String deviceNumber) { public AjaxResultPro realtimeData(@Param("deviceNumber") String deviceNumber) {
System.err.println(deviceNumber); System.err.println(deviceNumber);
try { // try {
Map<String, String> deviceRealTimeData = zhanLianBaseService.getDeviceRealTimeData(deviceNumber); // Map<String, String> deviceRealTimeData = zhanLianBaseService.getDeviceRealTimeData(deviceNumber);
return AjaxResultPro.success(deviceRealTimeData); // return AjaxResultPro.success(deviceRealTimeData);
} catch (Exception e) { // } catch (Exception e) {
// HashMap<String, String> deviceData = new HashMap<>();
// deviceData.put("realTime", "2024-12-21 23:24:52");
// deviceData.put("sumFlow_l", "0");
// deviceData.put("sumFlow_F", "0");
// deviceData.put("deviceId", "3852");
// deviceData.put("inFlow", "0");
// deviceData.put("status", "2");
// return AjaxResultPro.success(deviceData);
// }
NgWaterPumpUsageRecords ngWaterPumpUsageRecords1 = new NgWaterPumpUsageRecords();
ngWaterPumpUsageRecords1.setDeviceNumber(deviceNumber);
List<NgWaterPumpUsageRecords> ngWaterPumpUsageRecords = ngWaterPumpUsageRecordsMapper.selectNgWaterPumpUsageRecordsList(ngWaterPumpUsageRecords1);
System.err.println(ngWaterPumpUsageRecords);
//根据pump_start_time排序时间由近到远
if(!ngWaterPumpUsageRecords.isEmpty()){
ngWaterPumpUsageRecords.sort(Comparator.comparing(NgWaterPumpUsageRecords::getPumpStartTime).reversed());
HashMap<String, String> deviceData = new HashMap<>(); HashMap<String, String> deviceData = new HashMap<>();
NgWaterPumpUsageRecords data = ngWaterPumpUsageRecords.get(0);
String messageContent = data.getMessageContent();
JSONObject jsonObject = JSONUtil.parseObj(messageContent);
String data1 = jsonObject.getStr("data");
JSONObject jsonObject1 = JSONUtil.parseObj(data1);
//获取瞬时流量
String inFlow = jsonObject1.getStr("insFlow");
float in = Float.parseFloat(inFlow);
if(in!=0){
//精确到小数点后两位
inFlow= String.format("%.2f", in/100);
}
//获取累计水量
String sumFlow = jsonObject1.getStr("sumFlow");
//解析成整型除以100
float sum = Float.parseFloat(sumFlow);
if(sum!=0){
//精确到小数点后两位
sumFlow= String.format("%.2f", sum/100);
}
deviceData.put("realTime", "2024-12-21 23:24:52"); deviceData.put("realTime", "2024-12-21 23:24:52");
deviceData.put("sumFlow_l", "0"); deviceData.put("sumFlow_l", sumFlow.split("\\.")[0]);
deviceData.put("sumFlow_F", "0"); deviceData.put("sumFlow_F", sumFlow.split("\\.")[1]);
deviceData.put("deviceId", "3852"); deviceData.put("deviceId", "3852");
deviceData.put("inFlow", "0"); deviceData.put("inFlow",inFlow);
deviceData.put("status", "2"); deviceData.put("status", "2");
return AjaxResultPro.success(deviceData); return AjaxResultPro.success(deviceData);
}else {
HashMap<String, String> deviceData = new HashMap<>();
deviceData.put("realTime", "2024-12-21 23:24:52");
deviceData.put("sumFlow_l", "0");
deviceData.put("sumFlow_F", "0");
deviceData.put("deviceId", "3852");
deviceData.put("inFlow", "0");
deviceData.put("status", "2");
return AjaxResultPro.success(deviceData);
} }
} }
} }

View File

@ -207,8 +207,8 @@ public class UserRechargeCardsServiceImpl implements IUserRechargeCardsService
data.put("orderNum", ngUserRechargeRecords.getId()); data.put("orderNum", ngUserRechargeRecords.getId());
data.put("cardNum",rechargecardUser.getCardnumber()); data.put("cardNum",rechargecardUser.getCardnumber());
data.put("areaCode",rechargecardUser.getAreacode()); data.put("areaCode",rechargecardUser.getAreacode());
data.put("investBalance",rechargecardUser.getAmount().doubleValue()); data.put("investBalance",rechargecardUser.getAmount().doubleValue()*100);
data.put("investWater",rechargecardUser.getWater()); data.put("investWater",rechargecardUser.getWater()*100);
param.put("data",data); param.put("data",data);
pubMqttClient.publish(1,true,topic, JSONUtil.toJsonStr(param)); pubMqttClient.publish(1,true,topic, JSONUtil.toJsonStr(param));