Parcourir la source

新增功率统计以及实时数据接口

lingpeng.li il y a 5 mois
Parent
commit
49ea4026f5

+ 242 - 117
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/controller/DeviceRegionController.java

@@ -19,127 +19,128 @@ import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.Arrays;
+import java.text.ParseException;
+import java.util.*;
 
- /**
- * @Description: 区域管理信息表
- * @Author: jeecg-boot
- * @Date:   2024-09-19
- * @Version: V1.0
+/**
+ * @Description区域管理信息表
+ * @Authorjeecg-boot
+ * @Date 2024-09-19
+ * @VersionV1.0
  */
-@Api(tags="区域管理信息表")
+@Api(tags = "区域管理信息表")
 @RestController
 @RequestMapping("/device/deviceRegion")
 @Slf4j
 public class DeviceRegionController extends JeecgController<DeviceRegion, IDeviceRegionService> {
-	@Autowired
-	private IDeviceRegionService deviceRegionService;
-	
-	/**
-	 * 分页列表查询
-	 *
-	 * @param deviceRegion
-	 * @param pageNo
-	 * @param pageSize
-	 * @param req
-	 * @return
-	 */
-	//@AutoLog(value = "区域管理信息表-分页列表查询")
-	@ApiOperation(value="区域管理信息表-分页列表查询", notes="区域管理信息表-分页列表查询")
-	@GetMapping(value = "/list")
-	public Result<IPage<DeviceRegion>> queryPageList(DeviceRegion deviceRegion,
-								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-								   HttpServletRequest req) {
-		QueryWrapper<DeviceRegion> queryWrapper = QueryGenerator.initQueryWrapper(deviceRegion, req.getParameterMap());
-		Page<DeviceRegion> page = new Page<DeviceRegion>(pageNo, pageSize);
-		IPage<DeviceRegion> pageList = deviceRegionService.page(page, queryWrapper);
-		return Result.OK(pageList);
-	}
-	
-	/**
-	 *   添加
-	 *
-	 * @param deviceRegion
-	 * @return
-	 */
-	@AutoLog(value = "区域管理信息表-添加")
-	@ApiOperation(value="区域管理信息表-添加", notes="区域管理信息表-添加")
+    @Autowired
+    private IDeviceRegionService deviceRegionService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param deviceRegion
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    //@AutoLog(value = "区域管理信息表-分页列表查询")
+    @ApiOperation(value = "区域管理信息表-分页列表查询", notes = "区域管理信息表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<DeviceRegion>> queryPageList(DeviceRegion deviceRegion,
+                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                     HttpServletRequest req) {
+        QueryWrapper<DeviceRegion> queryWrapper = QueryGenerator.initQueryWrapper(deviceRegion, req.getParameterMap());
+        Page<DeviceRegion> page = new Page<DeviceRegion>(pageNo, pageSize);
+        IPage<DeviceRegion> pageList = deviceRegionService.page(page, queryWrapper);
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 添加
+     *
+     * @param deviceRegion
+     * @return
+     */
+    @AutoLog(value = "区域管理信息表-添加")
+    @ApiOperation(value = "区域管理信息表-添加", notes = "区域管理信息表-添加")
 //	@RequiresPermissions("device:device_region:add")
-	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody DeviceRegion deviceRegion) {
-		deviceRegionService.save(deviceRegion);
-		return Result.OK("添加成功!");
-	}
-	
-	/**
-	 *  编辑
-	 *
-	 * @param deviceRegion
-	 * @return
-	 */
-	@AutoLog(value = "区域管理信息表-编辑")
-	@ApiOperation(value="区域管理信息表-编辑", notes="区域管理信息表-编辑")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody DeviceRegion deviceRegion) {
+        deviceRegionService.save(deviceRegion);
+        return Result.OK("添加成功!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param deviceRegion
+     * @return
+     */
+    @AutoLog(value = "区域管理信息表-编辑")
+    @ApiOperation(value = "区域管理信息表-编辑", notes = "区域管理信息表-编辑")
 //	@RequiresPermissions("device:device_region:edit")
-	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody DeviceRegion deviceRegion) {
-		deviceRegionService.updateById(deviceRegion);
-		return Result.OK("编辑成功!");
-	}
-	
-	/**
-	 *   通过id删除
-	 *
-	 * @param id
-	 * @return
-	 */
-	@AutoLog(value = "区域管理信息表-通过id删除")
-	@ApiOperation(value="区域管理信息表-通过id删除", notes="区域管理信息表-通过id删除")
-	@RequiresPermissions("device:device_region:delete")
-	@DeleteMapping(value = "/delete")
-	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
-		deviceRegionService.removeById(id);
-		return Result.OK("删除成功!");
-	}
-	
-	/**
-	 *  批量删除
-	 *
-	 * @param ids
-	 * @return
-	 */
-	@AutoLog(value = "区域管理信息表-批量删除")
-	@ApiOperation(value="区域管理信息表-批量删除", notes="区域管理信息表-批量删除")
-	@RequiresPermissions("device:device_region:deleteBatch")
-	@DeleteMapping(value = "/deleteBatch")
-	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		this.deviceRegionService.removeByIds(Arrays.asList(ids.split(",")));
-		return Result.OK("批量删除成功!");
-	}
-	
-	/**
-	 * 通过id查询
-	 *
-	 * @param id
-	 * @return
-	 */
-	//@AutoLog(value = "区域管理信息表-通过id查询")
-	@ApiOperation(value="区域管理信息表-通过id查询", notes="区域管理信息表-通过id查询")
-	@GetMapping(value = "/queryById")
-	public Result<DeviceRegion> queryById(@RequestParam(name="id",required=true) String id) {
-		DeviceRegion deviceRegion = deviceRegionService.getById(id);
-		if(deviceRegion==null) {
-			return Result.error("未找到对应数据");
-		}
-		return Result.OK(deviceRegion);
-	}
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> edit(@RequestBody DeviceRegion deviceRegion) {
+        deviceRegionService.updateById(deviceRegion);
+        return Result.OK("编辑成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "区域管理信息表-通过id删除")
+    @ApiOperation(value = "区域管理信息表-通过id删除", notes = "区域管理信息表-通过id删除")
+    @RequiresPermissions("device:device_region:delete")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        deviceRegionService.removeById(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "区域管理信息表-批量删除")
+    @ApiOperation(value = "区域管理信息表-批量删除", notes = "区域管理信息表-批量删除")
+    @RequiresPermissions("device:device_region:deleteBatch")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.deviceRegionService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("批量删除成功!");
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    //@AutoLog(value = "区域管理信息表-通过id查询")
+    @ApiOperation(value = "区域管理信息表-通过id查询", notes = "区域管理信息表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<DeviceRegion> queryById(@RequestParam(name = "id", required = true) String id) {
+        DeviceRegion deviceRegion = deviceRegionService.getById(id);
+        if (deviceRegion == null) {
+            return Result.error("未找到对应数据");
+        }
+        return Result.OK(deviceRegion);
+    }
 
     /**
-    * 导出excel
-    *
-    * @param request
-    * @param deviceRegion
-    */
+     * 导出excel
+     *
+     * @param request
+     * @param deviceRegion
+     */
     @RequiresPermissions("device:device_region:exportXls")
     @RequestMapping(value = "/exportXls")
     public ModelAndView exportXls(HttpServletRequest request, DeviceRegion deviceRegion) {
@@ -147,16 +148,140 @@ public class DeviceRegionController extends JeecgController<DeviceRegion, IDevic
     }
 
     /**
-      * 通过excel导入数据
-    *
-    * @param request
-    * @param response
-    * @return
-    */
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
     @RequiresPermissions("device:device_region:importExcel")
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
         return super.importExcel(request, response, DeviceRegion.class);
     }
 
+    /**
+     * 功率统计
+     *
+     * @return
+     */
+    @AutoLog(value = "功率统计")
+    @ApiOperation(value = "功率统计", notes = "功率统计")
+    @GetMapping(value = "/powerStatistics")
+    public Result<List<String>> powerStatistics() throws ParseException {
+        List<Map<String, Object>> maps = deviceRegionService.powerStatistics();
+
+        // 验证是否存在数据
+        if (maps == null || maps.isEmpty()) {
+            return Result.OK(Collections.emptyList());
+        }
+
+        // 用于存储结果字符串的列表
+        List<String> result = new ArrayList<>();
+
+        // 遍历 maps 提取数据并格式化
+        for (Map<String, Object> map : maps) {
+            // 提取并格式化 "公司" 数据
+            String companyData = String.format(
+                    "公司, 实时%s, 累计%s, 尖%s, 峰%s, 平%s, 谷%s",
+                    map.getOrDefault("公司实时总功率", "0"),
+                    map.getOrDefault("公司累计总功率", "0"),
+                    map.getOrDefault("公司尖时段总功率占比", "0"),
+                    map.getOrDefault("公司峰时段总功率占比", "0"),
+                    map.getOrDefault("公司平时段总功率占比", "0"),
+                    map.getOrDefault("公司谷时段总功率占比", "0")
+            );
+            result.add(companyData);
+
+            // 提取并格式化 "炼铁" 数据
+            String ironData = String.format(
+                    "炼铁, 实时%s, 累计%s, 尖%s, 峰%s, 平%s, 谷%s",
+                    map.getOrDefault("炼铁厂实时总功率", "0"),
+                    map.getOrDefault("炼铁厂累计总功率", "0"),
+                    map.getOrDefault("炼铁厂尖时段总功率占比", "0"),
+                    map.getOrDefault("炼铁厂峰时段总功率占比", "0"),
+                    map.getOrDefault("炼铁厂平时段总功率占比", "0"),
+                    map.getOrDefault("炼铁厂谷时段总功率占比", "0")
+            );
+            result.add(ironData);
+
+            // 提取并格式化 "轧钢" 数据
+            String zgData = String.format(
+                    "轧钢, 实时%s, 累计%s, 尖%s, 峰%s, 平%s, 谷%s",
+                    map.getOrDefault("轧钢厂实时总功率", "0"),
+                    map.getOrDefault("轧钢厂累计总功率", "0"),
+                    map.getOrDefault("轧钢厂尖时段总功率占比", "0"),
+                    map.getOrDefault("轧钢厂峰时段总功率占比", "0"),
+                    map.getOrDefault("轧钢厂平时段总功率占比", "0"),
+                    map.getOrDefault("轧钢厂谷时段总功率占比", "0")
+            );
+            result.add(zgData);
+
+            // 提取并格式化 "棒一" 数据
+            String bOneData = String.format(
+                    "棒一, 实时%s, 累计%s, 尖%s, 峰%s, 平%s, 谷%s",
+                    map.getOrDefault("棒一实时总功率", "0"),
+                    map.getOrDefault("棒一累计总功率", "0"),
+                    map.getOrDefault("棒一尖时段总功率占比", "0"),
+                    map.getOrDefault("棒一峰时段总功率占比", "0"),
+                    map.getOrDefault("棒一平时段总功率占比", "0"),
+                    map.getOrDefault("棒一谷时段总功率占比", "0")
+            );
+            result.add(bOneData);
+
+
+            // 提取并格式化 "棒二" 数据
+            String bTwoData = String.format(
+                    "棒二, 实时%s, 累计%s, 尖%s, 峰%s, 平%s, 谷%s",
+                    map.getOrDefault("棒二实时总功率", "0"),
+                    map.getOrDefault("棒二累计总功率", "0"),
+                    map.getOrDefault("棒二尖时段总功率占比", "0"),
+                    map.getOrDefault("棒二峰时段总功率占比", "0"),
+                    map.getOrDefault("棒二平时段总功率占比", "0"),
+                    map.getOrDefault("棒二谷时段总功率占比", "0")
+            );
+            result.add(bTwoData);
+
+
+            // 提取并格式化 "棒三" 数据
+            String bThree = String.format(
+                    "棒三, 实时%s, 累计%s, 尖%s, 峰%s, 平%s, 谷%s",
+                    map.getOrDefault("棒三实时总功率", "0"),
+                    map.getOrDefault("棒三累计总功率", "0"),
+                    map.getOrDefault("棒三尖时段总功率占比", "0"),
+                    map.getOrDefault("棒三峰时段总功率占比", "0"),
+                    map.getOrDefault("棒三平时段总功率占比", "0"),
+                    map.getOrDefault("棒三谷时段总功率占比", "0")
+            );
+            result.add(bThree);
+
+
+            // 提取并格式化 "高线" 数据
+            String gxData = String.format(
+                    "高线, 实时%s, 累计%s, 尖%s, 峰%s, 平%s, 谷%s",
+                    map.getOrDefault("高线实时总功率", "0"),
+                    map.getOrDefault("高线累计总功率", "0"),
+                    map.getOrDefault("高线尖时段总功率占比", "0"),
+                    map.getOrDefault("高线峰时段总功率占比", "0"),
+                    map.getOrDefault("高线平时段总功率占比", "0"),
+                    map.getOrDefault("高线谷时段总功率占比", "0")
+            );
+            result.add(gxData);
+
+            // 提取并格式化 "板带" 数据
+            String bdDate = String.format(
+                    "板带, 实时%s, 累计%s, 尖%s, 峰%s, 平%s, 谷%s",
+                    map.getOrDefault("板带实时总功率", "0"),
+                    map.getOrDefault("板带累计总功率", "0"),
+                    map.getOrDefault("板带尖时段总功率占比", "0"),
+                    map.getOrDefault("板带峰时段总功率占比", "0"),
+                    map.getOrDefault("板带平时段总功率占比", "0"),
+                    map.getOrDefault("板带谷时段总功率占比", "0")
+            );
+            result.add(bdDate);
+        }
+
+        return Result.OK(result);
+    }
+
 }

+ 70 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/entity/DeviceOperationLog.java

@@ -0,0 +1,70 @@
+package org.jeecg.modules.deviceLesm.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Description: 设备启动停止记录日志
+ * @Author: llp
+ * @Date:   2024-12-13
+ * @Version: V1.0
+ */
+@Data
+@TableName("device_operation_log")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="device_operation_log对象", description="设备启动停止记录日志")
+public class DeviceOperationLog implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	/**主键*/
+	@TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "主键")
+    private String id;
+	/**创建人*/
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+	/**创建日期*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建日期")
+    private Date createTime;
+	/**更新人*/
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+	/**更新日期*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新日期")
+    private Date updateTime;
+	/**设备名称*/
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+	/**操作类型*/
+	@Excel(name = "操作类型:启动/停止", width = 15)
+    @ApiModelProperty(value = "操作类型:启动/停止")
+    private String operationType;
+	/**时间*/
+	@Excel(name = "操作时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "操作时间")
+    private Date operationTime;
+
+    public DeviceOperationLog() {
+    }
+
+
+}

+ 14 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/mapper/DeviceOperationLogMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.deviceLesm.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.deviceLesm.entity.DeviceOperationLog;
+
+
+/**
+ * @Description: 设备启动停止记录日志
+ * @Author: jeecg-boot
+ * @Date:   2024-12-13
+ * @Version: V1.0
+ */
+public interface DeviceOperationLogMapper extends BaseMapper<DeviceOperationLog> {
+}

+ 15 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/service/IDeviceOperationLogService.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.deviceLesm.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.deviceLesm.entity.DeviceOperationLog;
+
+import java.util.List;
+
+
+public interface IDeviceOperationLogService extends IService<DeviceOperationLog> {
+
+
+    List<DeviceOperationLog> queryList();
+
+
+}

+ 11 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/service/IDeviceRegionService.java

@@ -3,6 +3,10 @@ package org.jeecg.modules.deviceLesm.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
 
+import java.text.ParseException;
+import java.util.List;
+import java.util.Map;
+
 
 /**
  * @Description: 区域管理信息表
@@ -12,4 +16,11 @@ import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
  */
 public interface IDeviceRegionService extends IService<DeviceRegion> {
 
+        /**
+         * 功率统计
+         *
+         * @return
+         */
+        List<Map<String,Object>> powerStatistics() throws ParseException;
+
 }

+ 414 - 2
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/service/impl/DeviceRegionServiceImpl.java

@@ -1,19 +1,431 @@
 package org.jeecg.modules.deviceLesm.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.collections.CollectionUtils;
+import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
 import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
+import org.jeecg.modules.deviceLesm.mapper.DeviceInformationMapper;
 import org.jeecg.modules.deviceLesm.mapper.DeviceRegionMapper;
 import org.jeecg.modules.deviceLesm.service.IDeviceRegionService;
+import org.jeecg.modules.gatherData.entity.FpgGatherData;
+import org.jeecg.modules.gatherData.mapper.FpgGatherDataMapper;
+import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
+import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static net.sf.jsqlparser.parser.feature.Feature.limit;
+
 /**
  * @Description: 区域管理信息表
  * @Author: jeecg-boot
- * @Date:   2024-09-19
+ * @Date: 2024-09-19
  * @Version: V1.0
  */
 @Service
 public class DeviceRegionServiceImpl extends ServiceImpl<DeviceRegionMapper, DeviceRegion> implements IDeviceRegionService {
 
-}
+    @Autowired
+    private IPeaksAndValleysTimeConfigService peaksAndValleysTimeConfigService;
+
+    @Autowired
+    private FpgGatherDataMapper fpgGatherDataMapper;
+
+    @Autowired
+    private DeviceInformationMapper deviceInformationMapper;
+
+    @Override
+    public List<Map<String, Object>> powerStatistics() throws ParseException {
+
+        List<Map<String, Object>> arrayList = new ArrayList<>();
+
+        // 获取前一天的开始和结束时间
+        LocalDate today = LocalDate.now();
+        String startOfDayString = today.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " 00:00:00";
+        String endOfDayString = today.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " 23:59:59";
+
+        // 转换为 Date 类型
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date startOfDay = sdf.parse(startOfDayString);
+        Date endOfDay = sdf.parse(endOfDayString);
+
+        LambdaQueryWrapper<DeviceRegion> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(DeviceRegion::getStatus, "1")
+                .notIn(DeviceRegion::getRegionTitle, "储运中心", "能管中心", "炼钢厂");
+        List<DeviceRegion> deviceRegions = baseMapper.selectList(wrapper);
+
+        Map<String, Object> powerMap = new HashMap<>();
+
+        powerMap.put("公司实时总功率", null);
+        powerMap.put("公司累计总功率", null);
+
+        // 初始化公司实时总功率和累计总功率的变量
+        BigDecimal companyRealTimeTotalPower = BigDecimal.ZERO;
+        BigDecimal companyAccumulatedTotalPower = BigDecimal.ZERO;
+        // 初始化公司尖、峰、平、谷时段总功率的变量
+        BigDecimal companyTopsPower = BigDecimal.ZERO;
+        BigDecimal companyPeaksPower = BigDecimal.ZERO;
+        BigDecimal companyFlatPower = BigDecimal.ZERO;
+        BigDecimal companyValleysPower = BigDecimal.ZERO;
+
+        for (DeviceRegion deviceRegion : deviceRegions) {
+
+            powerMap.put(deviceRegion.getRegionTitle() + "实时总功率", null);
+            powerMap.put(deviceRegion.getRegionTitle() + "累计总功率", null);
+
+            // 初始化 LambdaQueryWrapper
+            LambdaQueryWrapper<FpgGatherData> fpgGatherDataQueryWrapper = new LambdaQueryWrapper<>();
+            fpgGatherDataQueryWrapper
+                    .eq(FpgGatherData::getDeviceRegionId, deviceRegion.getId())
+                    .ge(FpgGatherData::getCreateTime, startOfDay)
+                    .le(FpgGatherData::getCreateTime, endOfDay)
+                    .orderByDesc(FpgGatherData::getCreateTime);
+
+            List<FpgGatherData> resultList = fpgGatherDataMapper.selectList(fpgGatherDataQueryWrapper);
+
+            // 累加 RunCurrent 并设置值到 powerMap
+            BigDecimal realTimeRunCurrent = BigDecimal.ZERO;
+            BigDecimal totalRunCurrent = BigDecimal.ZERO;
+
+            if (resultList != null && !resultList.isEmpty()) {
+                // 累加 RunCurrent,判空处理
+                totalRunCurrent = resultList.stream()
+                        .map(FpgGatherData::getRunCurrent)
+                        .filter(Objects::nonNull)  // 过滤掉 null 值
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+                // 获取第一个数据的 RunCurrent(最新值,按降序排列后第一个),判空处理
+                realTimeRunCurrent = resultList.get(0).getRunCurrent();
+                if (realTimeRunCurrent == null) {
+                    realTimeRunCurrent = BigDecimal.ZERO;  // 如果为 null,设置为零
+                }
+            }
+
+            // 更新区域实时和累计功率到 powerMap
+            powerMap.put(deviceRegion.getRegionTitle() + "实时总功率", realTimeRunCurrent);
+            powerMap.put(deviceRegion.getRegionTitle() + "累计总功率", totalRunCurrent);
+
+            // 累加到公司实时和累计功率
+            companyRealTimeTotalPower = companyRealTimeTotalPower.add(realTimeRunCurrent);
+            companyAccumulatedTotalPower = companyAccumulatedTotalPower.add(totalRunCurrent);
+
+
+            Date todayDate = new Date();
+            // 使用 Calendar 获取前一天日期
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(todayDate);
+            calendar.add(Calendar.DAY_OF_YEAR, -0);  // 减去一天
+
+            // 获取前一天的日期
+            Date yesterdayDate = calendar.getTime();
+            String dayDate = new SimpleDateFormat("yyyy-MM-dd").format(yesterdayDate);
+            List<PeaksAndValleysTimeConfig> peaksAndValleysTimeConfiglist = peaksAndValleysTimeConfigService.list();
+
+            Map<String, String> map = new HashMap<>();
+            Map<String, Object> mapSum = new HashMap<>();
+            mapSum.put("topsSum", 0.00);
+            mapSum.put("peaksSum", 0.00);
+            mapSum.put("flatSum", 0.00);
+            mapSum.put("valleysSum", 0.00);
+
+            // 峰平谷时段处理
+            peaksAndValleysTimeConfiglist.forEach(peaksAndValleysTime -> {
+                String startDate = dayDate + " " + peaksAndValleysTime.getStartTime();
+                String endDate = dayDate + " " + peaksAndValleysTime.getEndTime();
+                Map peaksAndValleysTimeMap = fpgGatherDataMapper.getFpgTheLeftSideOneData(deviceRegion.getId(), startDate, endDate);
+                if (peaksAndValleysTimeMap != null) {
+                    if ("tops".equals(peaksAndValleysTime.getType())) { // 尖值处理
+                        BigDecimal topsAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                        BigDecimal topsSum = new BigDecimal(String.valueOf(mapSum.get("topsSum")));
+                        mapSum.put("topsSum", topsSum.add(topsAmount));
+                    } else if ("peaks".equals(peaksAndValleysTime.getType())) { // 峰值处理
+                        BigDecimal peaksAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                        BigDecimal peaksSum = new BigDecimal(String.valueOf(mapSum.get("peaksSum")));
+                        mapSum.put("peaksSum", peaksSum.add(peaksAmount));
+                    } else if ("flat".equals(peaksAndValleysTime.getType())) { // 平值处理
+                        BigDecimal flatAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                        BigDecimal flatSum = new BigDecimal(String.valueOf(mapSum.get("flatSum")));
+                        mapSum.put("flatSum", flatSum.add(flatAmount));
+                    } else if ("valleys".equals(peaksAndValleysTime.getType())) { // 谷值处理
+                        BigDecimal valleysAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                        BigDecimal valleysSum = new BigDecimal(String.valueOf(mapSum.get("valleysSum")));
+                        mapSum.put("valleysSum", valleysSum.add(valleysAmount));
+                    }
+                }
+            });
+            map.put("name", deviceRegion.getRegionTitle());
+            map.put("tops", String.format("%.2f", mapSum.get("topsSum")));
+            map.put("peaks", String.format("%.2f", mapSum.get("peaksSum")));
+            map.put("flat", String.format("%.2f", mapSum.get("flatSum")));
+            map.put("valleys", String.format("%.2f", mapSum.get("valleysSum")));
+
+            // 将区域的尖、峰、平、谷时段功率转换为 BigDecimal 并累加到公司的变量
+            BigDecimal regionTopsPower = new BigDecimal(map.get("tops"));
+            BigDecimal regionPeaksPower = new BigDecimal(map.get("peaks"));
+            BigDecimal regionFlatPower = new BigDecimal(map.get("flat"));
+            BigDecimal regionValleysPower = new BigDecimal(map.get("valleys"));
+
+            companyTopsPower = companyTopsPower.add(regionTopsPower);
+            companyPeaksPower = companyPeaksPower.add(regionPeaksPower);
+            companyFlatPower = companyFlatPower.add(regionFlatPower);
+            companyValleysPower = companyValleysPower.add(regionValleysPower);
+
+            powerMap.put(deviceRegion.getRegionTitle() + "尖时段总功率", map.get("tops"));
+            powerMap.put(deviceRegion.getRegionTitle() + "峰时段总功率", map.get("peaks"));
+            powerMap.put(deviceRegion.getRegionTitle() + "平时段总功率", map.get("flat"));
+            powerMap.put(deviceRegion.getRegionTitle() + "谷时段总功率", map.get("valleys"));
+
+
+            // 获取各时段总功率
+            BigDecimal topsPower1 = map.containsKey("tops") && map.get("tops") != null ?
+                    new BigDecimal(String.valueOf(map.get("tops"))) : BigDecimal.ZERO;
+
+            BigDecimal peaksPower1 = map.containsKey("peaks") && map.get("peaks") != null ?
+                    new BigDecimal(String.valueOf(map.get("peaks"))) : BigDecimal.ZERO;
+
+            BigDecimal flatPower1 = map.containsKey("flat") && map.get("flat") != null ?
+                    new BigDecimal(String.valueOf(map.get("flat"))) : BigDecimal.ZERO;
+
+            BigDecimal valleysPower1 = map.containsKey("valleys") && map.get("valleys") != null ?
+                    new BigDecimal(String.valueOf(map.get("valleys"))) : BigDecimal.ZERO;
+
+            // 计算总功率
+            BigDecimal totalPower1 = topsPower1.add(peaksPower1).add(flatPower1).add(valleysPower1);
+
+            // 避免除以零的情况
+            if (totalPower1.compareTo(BigDecimal.ZERO) > 0) {
+                // 计算占比
+                BigDecimal topsRatio = topsPower1.divide(totalPower1, 4, RoundingMode.HALF_UP);
+                BigDecimal peaksRatio = peaksPower1.divide(totalPower1, 4, RoundingMode.HALF_UP);
+                BigDecimal flatRatio = flatPower1.divide(totalPower1, 4, RoundingMode.HALF_UP);
+                BigDecimal valleysRatio = valleysPower1.divide(totalPower1, 4, RoundingMode.HALF_UP);
+
+                // 更新到 powerMap,转换为百分比格式
+                powerMap.put(deviceRegion.getRegionTitle() + "尖时段总功率占比", formatPercentage(topsRatio));
+                powerMap.put(deviceRegion.getRegionTitle() + "峰时段总功率占比", formatPercentage(peaksRatio));
+                powerMap.put(deviceRegion.getRegionTitle() + "平时段总功率占比", formatPercentage(flatRatio));
+                powerMap.put(deviceRegion.getRegionTitle() + "谷时段总功率占比", formatPercentage(valleysRatio));
+            } else {
+                // 如果总功率为 0,所有占比设为 0%
+                powerMap.put(deviceRegion.getRegionTitle() + "尖时段总功率占比", "0%");
+                powerMap.put(deviceRegion.getRegionTitle() + "峰时段总功率占比", "0%");
+                powerMap.put(deviceRegion.getRegionTitle() + "平时段总功率占比", "0%");
+                powerMap.put(deviceRegion.getRegionTitle() + "谷时段总功率占比", "0%");
+            }
+
+
+
+
+//            deviceInformationWrapper.eq(DeviceInformation::getDeviceRegionId, deviceRegion.getId())
+//                    .orderByAsc(DeviceInformation::getDeviceType);
+//            ;
+//            List<DeviceInformation> deviceInformations = deviceInformationMapper.selectList(deviceInformationWrapper);
+
+            List<String> stringList = new ArrayList<>();
+            stringList.add("1");
+            stringList.add("2");
+            stringList.add("3");
+            stringList.add("4");
+            stringList.add("5");
+
+            // 遍历每个 deviceInformation,根据 deviceType 分组查询
+            for (String type : stringList) {
+
+                Map<String, String> map1 = new HashMap<>();
+                Map<String, Object> mapSum1 = new HashMap<>();
+                mapSum1.put("topsSum", 0.00);
+                mapSum1.put("peaksSum", 0.00);
+                mapSum1.put("flatSum", 0.00);
+                mapSum1.put("valleysSum", 0.00);
+                String deviceType = type;
+
+                if (null != deviceType) {
+                    LambdaQueryWrapper<DeviceInformation> deviceInformationWrapper = new LambdaQueryWrapper<>();
+                    deviceInformationWrapper.eq(DeviceInformation::getDeviceType, deviceType);
+                    List<DeviceInformation> deviceInformationList = deviceInformationMapper.selectList(deviceInformationWrapper);
+
+                    List<String> deviceIds = deviceInformationList.stream()
+                            .map(DeviceInformation::getId)  // 获取每个 DeviceInformation 的 id 属性
+                            .collect(Collectors.toList());
+
+                    if (!CollectionUtils.isEmpty(deviceIds)) {
+                        for (PeaksAndValleysTimeConfig peaksAndValleysTimeConfig : peaksAndValleysTimeConfiglist) {
+                            String startDate = dayDate + " " + peaksAndValleysTimeConfig.getStartTime();
+                            String endDate = dayDate + " " + peaksAndValleysTimeConfig.getEndTime();
+                            Map peaksAndValleysTimeMap = fpgGatherDataMapper.getDeviceTypeData(deviceIds, startDate, endDate);
+                            if (peaksAndValleysTimeMap != null) {
+                                if ("tops".equals(peaksAndValleysTimeConfig.getType())) { // 尖值处理
+                                    BigDecimal topsAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                                    BigDecimal topsSum = new BigDecimal(String.valueOf(mapSum1.get("topsSum")));
+                                    mapSum1.put("topsSum", topsSum.add(topsAmount));
+                                } else if ("peaks".equals(peaksAndValleysTimeConfig.getType())) { // 峰值处理
+                                    BigDecimal peaksAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                                    BigDecimal peaksSum = new BigDecimal(String.valueOf(mapSum1.get("peaksSum")));
+                                    mapSum1.put("peaksSum", peaksSum.add(peaksAmount));
+                                } else if ("flat".equals(peaksAndValleysTimeConfig.getType())) { // 平值处理
+                                    BigDecimal flatAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                                    BigDecimal flatSum = new BigDecimal(String.valueOf(mapSum1.get("flatSum")));
+                                    mapSum1.put("flatSum", flatSum.add(flatAmount));
+                                } else if ("valleys".equals(peaksAndValleysTimeConfig.getType())) { // 谷值处理
+                                    BigDecimal valleysAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
+                                    BigDecimal valleysSum = new BigDecimal(String.valueOf(mapSum1.get("valleysSum")));
+                                    mapSum1.put("valleysSum", valleysSum.add(valleysAmount));
+                                }
+                            }
+//                            // 检查 peaksAndValleysTimeMapLast 是否包含 "active_power" 且值不为 null 或空
+//                            if (peaksAndValleysTimeMapLast != null && peaksAndValleysTimeMapLast.containsKey("active_power")
+//                                    && peaksAndValleysTimeMapLast.get("active_power") != null) {
+//                                powerMap.put(mapDeviceType(deviceType) + "累计总功率", peaksAndValleysTimeMapLast.get("active_power"));
+//                            } else {
+//                                powerMap.put(mapDeviceType(deviceType) + "累计总功率", "0");  // 如果值为空,设置为默认值
+//                            }
+//
+//                            powerMap.put(mapDeviceType(deviceType) + "累计总功率", peaksAndValleysTimeMapLast.get("active_power"));
+
+                        }
+
+                        BigDecimal totalActivePower2 = BigDecimal.ZERO; // 假设需要累加 activePower
+
+                        for (String deviceId : deviceIds) {
+                            // 构造查询条件
+                            LambdaQueryWrapper<FpgGatherData> fpgGatherQueryWrapper = new LambdaQueryWrapper<>();
+                            fpgGatherQueryWrapper
+                                    .eq(FpgGatherData::getDeviceInformationId, deviceId) // 针对当前 deviceId 查询
+                                    .ge(FpgGatherData::getCreateTime, startOfDay)       // 创建时间大于等于开始时间
+                                    .le(FpgGatherData::getCreateTime, endOfDay)         // 创建时间小于等于结束时间
+                                    .orderByDesc(FpgGatherData::getCreateTime)          // 按时间降序排列
+                                    .last("limit 1");                                   // 只取最新的一条数据
+
+                            // 查询数据
+                            List<FpgGatherData> singleList = fpgGatherDataMapper.selectList(fpgGatherQueryWrapper);
+
+                            // 如果查询结果非空,进行累加
+                            if (singleList != null && !singleList.isEmpty()) {
+                                FpgGatherData data = singleList.get(0); // 最新的一条数据
+                                totalActivePower2 = totalActivePower2.add(data.getActivePower() == null ? BigDecimal.ZERO : data.getActivePower());
+                            }
+                        }
+                        // 对累计总功率处理,去除无效小数
+                        powerMap.put(mapDeviceType(deviceType) + "实时总功率", totalActivePower2.stripTrailingZeros().toPlainString());
+
+
+                    }
+                }
+                map1.put("name", mapDeviceType(deviceType));
+                map1.put("tops", String.format("%.2f", mapSum1.get("topsSum")));
+                map1.put("peaks", String.format("%.2f", mapSum1.get("peaksSum")));
+                map1.put("flat", String.format("%.2f", mapSum1.get("flatSum")));
+                map1.put("valleys", String.format("%.2f", mapSum1.get("valleysSum")));
+
+                // 假设 powerMap 里已经包含了各个时段的总功率
+                BigDecimal totalPower = BigDecimal.ZERO;
+
+                BigDecimal topsPower = new BigDecimal(String.valueOf(map1.get("tops")));
+                BigDecimal peaksPower = new BigDecimal(String.valueOf(map1.get("peaks")));
+                BigDecimal flatPower = new BigDecimal(String.valueOf(map1.get("flat")));
+                BigDecimal valleysPower = new BigDecimal(String.valueOf(map1.get("valleys")));
+
+                // 计算总功率
+                totalPower = totalPower.add(topsPower).add(peaksPower).add(flatPower).add(valleysPower);
+
+                // 计算每个时段的占比
+                BigDecimal topsRatio = totalPower.compareTo(BigDecimal.ZERO) != 0 ? topsPower.divide(totalPower, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+                BigDecimal peaksRatio = totalPower.compareTo(BigDecimal.ZERO) != 0 ? peaksPower.divide(totalPower, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+                BigDecimal flatRatio = totalPower.compareTo(BigDecimal.ZERO) != 0 ? flatPower.divide(totalPower, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+                BigDecimal valleysRatio = totalPower.compareTo(BigDecimal.ZERO) != 0 ? valleysPower.divide(totalPower, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+
+                // 将占比放入 powerMap
+                // 格式化为百分比并去除无效小数
+                powerMap.put(mapDeviceType(deviceType) + "尖时段总功率占比", formatPercentage(topsRatio));
+                powerMap.put(mapDeviceType(deviceType) + "峰时段总功率占比", formatPercentage(peaksRatio));
+                powerMap.put(mapDeviceType(deviceType) + "平时段总功率占比", formatPercentage(flatRatio));
+                powerMap.put(mapDeviceType(deviceType) + "谷时段总功率占比", formatPercentage(valleysRatio));
+
+                // 对累计总功率处理,去除无效小数
+                powerMap.put(mapDeviceType(deviceType) + "累计总功率", totalPower.stripTrailingZeros().toPlainString());
+
+            }
+
+        }
+
+        // 更新公司实时和累计功率到 powerMap
+        powerMap.put("公司实时总功率", companyRealTimeTotalPower);
+        powerMap.put("公司累计总功率", companyAccumulatedTotalPower);
+        // 更新公司的尖、峰、平、谷时段总功率到 powerMap
+        powerMap.put("公司尖时段总功率", companyTopsPower);
+        powerMap.put("公司峰时段总功率", companyPeaksPower);
+        powerMap.put("公司平时段总功率", companyFlatPower);
+        powerMap.put("公司谷时段总功率", companyValleysPower);
+
+
+//        // 假设 powerMap 里已经包含了公司相关的总功率
+//        BigDecimal companyTotalPower = companyAccumulatedTotalPower != null ? companyAccumulatedTotalPower : BigDecimal.ZERO;  // 公司累计总功率
+
+        BigDecimal companyTotalPower = BigDecimal.ZERO;
+
+        // 获取各时段总功率,若值为 null,使用 BigDecimal.ZERO
+        BigDecimal companyTopsPower1 = powerMap.containsKey("公司尖时段总功率") && powerMap.get("公司尖时段总功率") != null ?
+                new BigDecimal(String.valueOf(powerMap.get("公司尖时段总功率"))) : BigDecimal.ZERO;
+
+        BigDecimal companyPeaksPower1 = powerMap.containsKey("公司峰时段总功率") && powerMap.get("公司峰时段总功率") != null ?
+                new BigDecimal(String.valueOf(powerMap.get("公司峰时段总功率"))) : BigDecimal.ZERO;
+
+        BigDecimal companyFlatPower1 = powerMap.containsKey("公司平时段总功率") && powerMap.get("公司平时段总功率") != null ?
+                new BigDecimal(String.valueOf(powerMap.get("公司平时段总功率"))) : BigDecimal.ZERO;
+
+        BigDecimal companyValleysPower1 = powerMap.containsKey("公司谷时段总功率") && powerMap.get("公司谷时段总功率") != null ?
+                new BigDecimal(String.valueOf(powerMap.get("公司谷时段总功率"))) : BigDecimal.ZERO;
+
+        // 计算总功率
+        companyTotalPower = companyTotalPower.add(companyTopsPower1).add(companyPeaksPower1).add(companyFlatPower1).add(companyValleysPower1);
+
+        // 计算占比:每个时段的总功率 / 公司累计总功率
+        BigDecimal topsRatio = companyTotalPower.compareTo(BigDecimal.ZERO) != 0 ? companyTopsPower1.divide(companyTotalPower, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+        BigDecimal peaksRatio = companyTotalPower.compareTo(BigDecimal.ZERO) != 0 ? companyPeaksPower1.divide(companyTotalPower, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+        BigDecimal flatRatio = companyTotalPower.compareTo(BigDecimal.ZERO) != 0 ? companyFlatPower1.divide(companyTotalPower, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+        BigDecimal valleysRatio = companyTotalPower.compareTo(BigDecimal.ZERO) != 0 ? companyValleysPower1.divide(companyTotalPower, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+
+        // 将占比放入 powerMap,转换为百分比格式
+        powerMap.put("公司尖时段总功率占比", formatPercentage(topsRatio));
+        powerMap.put("公司峰时段总功率占比", formatPercentage(peaksRatio));
+        powerMap.put("公司平时段总功率占比", formatPercentage(flatRatio));
+        powerMap.put("公司谷时段总功率占比", formatPercentage(valleysRatio));
+
+
+        arrayList.add(powerMap);
+
+        return arrayList;
+    }
+
+    public String mapDeviceType(String deviceType) {
+        // 定义映射关系
+        Map<String, String> deviceTypeMap = new HashMap<>();
+        deviceTypeMap.put("1", "棒一");
+        deviceTypeMap.put("2", "棒二");
+        deviceTypeMap.put("3", "棒三");
+        deviceTypeMap.put("4", "高线");
+        deviceTypeMap.put("5", "板带");
+
+        // 返回映射值,如果找不到对应的 key,则返回默认值
+        return deviceTypeMap.getOrDefault(deviceType, "未知类型");
+    }
+
+    /**
+     * 格式化百分比,保留最多两位小数,去除无效零
+     */
+    private String formatPercentage(BigDecimal ratio) {
+        BigDecimal percentage = ratio.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
+        return percentage.stripTrailingZeros().toPlainString() + "%";
+    }
+}

+ 27 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/service/impl/IDeviceOperationLogServiceImpl.java

@@ -0,0 +1,27 @@
+package org.jeecg.modules.deviceLesm.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.deviceLesm.entity.DeviceOperationLog;
+import org.jeecg.modules.deviceLesm.mapper.DeviceOperationLogMapper;
+import org.jeecg.modules.deviceLesm.service.IDeviceOperationLogService;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.List;
+
+
+@Service
+public class IDeviceOperationLogServiceImpl extends ServiceImpl<DeviceOperationLogMapper, DeviceOperationLog> implements IDeviceOperationLogService {
+
+
+    @Override
+    public List<DeviceOperationLog> queryList() {
+
+        LambdaQueryWrapper<DeviceOperationLog> wrapper = new LambdaQueryWrapper<>();
+        wrapper.orderByDesc(DeviceOperationLog::getOperationTime);
+        List<DeviceOperationLog> deviceOperationLogs = baseMapper.selectList(wrapper);
+        return deviceOperationLogs;
+    }
+}

+ 2 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/gatherData/mapper/FpgGatherDataMapper.java

@@ -18,5 +18,7 @@ import java.util.Map;
 public interface FpgGatherDataMapper extends BaseMapper<FpgGatherData> {
     Map getFpgTheLeftSideOneData(@Param("deviceRegionId")String deviceRegionId, @Param("startTime")String startTime, @Param("endTime")String endTime);
 
+    Map getDeviceTypeData(@Param("deviceInformations")List<String> deviceInformations, @Param("startTime")String startTime, @Param("endTime")String endTime);
+
     List<FpgMiddleTwoData> getFpgTheLeftSideOneData(@Param("startTime")String startTime);
 }

+ 15 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/gatherData/mapper/xml/FpgGatherDataMapper.xml

@@ -20,4 +20,19 @@
         GROUP BY gfd.formatted_date
 
     </select>
+
+    <select id="getDeviceTypeData" parameterType="java.util.List" resultType="map">
+        SELECT
+        SUM(run_current) AS currents,
+        SUM(active_power) AS active_power
+        FROM
+        fpg_gather_data
+        WHERE
+        device_information_id IN
+        <foreach item="item" collection="deviceInformations" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        AND create_time BETWEEN #{startTime} AND #{endTime}
+    </select>
+
 </mapper>

+ 1 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/controller/HomePageDataController.java

@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.deviceLesm.entity.DeviceOperationLog;
 import org.jeecg.modules.homePageData.service.IHomePageDataService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;

+ 2 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/service/IHomePageDataService.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.homePageData.service;
 
+import org.jeecg.modules.deviceLesm.entity.DeviceOperationLog;
+
 import java.util.List;
 import java.util.Map;
 

+ 23 - 3
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/service/impl/HomePageDataServiceImpl.java

@@ -5,10 +5,12 @@ import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.common.ModelCodeContant;
 import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
+import org.jeecg.modules.deviceLesm.entity.DeviceOperationLog;
 import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
 import org.jeecg.modules.deviceLesm.mapper.DevicePointMapper;
 import org.jeecg.modules.deviceLesm.service.IDeviceInformationService;
 import org.jeecg.modules.deviceLesm.service.IDeviceRegionService;
+import org.jeecg.modules.deviceLesm.service.impl.IDeviceOperationLogServiceImpl;
 import org.jeecg.modules.fpgLeanModel.entity.DeviceStatiscsModelMongodb;
 import org.jeecg.modules.fpgLeanModel.entity.FpgLeanModel;
 import org.jeecg.modules.fpgLeanModel.service.IFpgLeanModelService;
@@ -61,6 +63,9 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
     @Autowired
     private IDeviceInformationService deviceInformationService;
 
+    @Autowired
+    private IDeviceOperationLogServiceImpl deviceOperationLogService;
+
     @Override
     public List<Map<String, String>> regionPfvElectricity(String modelId) {
         String leanModelCode = queryLeanModelCodeById(modelId);
@@ -322,9 +327,24 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
 
     @Override
     public List<String> latestMsg() {
-        String[] alarms = new String[]{"设备故障","用电统计报表待审批","设备状态待检查"};
-        List<String> res = Arrays.asList(alarms);
-        return res;
+
+        List<String> list = new ArrayList<>();
+        List<DeviceOperationLog> deviceOperationLogs = deviceOperationLogService.queryList();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        for (DeviceOperationLog deviceOperationLog : deviceOperationLogs) {
+
+            // 将 operationTime 转换为字符串
+            String formattedTime = sdf.format(deviceOperationLog.getOperationTime());
+            // 拼接name、operationTime、operationType
+            String message = deviceOperationLog.getDeviceName() + "在" +
+                    formattedTime + deviceOperationLog.getOperationType();
+
+            // 将拼接的字符串添加到list中
+            list.add(message);
+        }
+
+        return list;
     }