parent
8ae14ae51a
commit
4cb88e72e9
11 changed files with 616 additions and 0 deletions
@ -0,0 +1,46 @@ |
|||||||
|
package org.springblade.desk.device.pojo.entity; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.core.mp.base.BaseEntity; |
||||||
|
|
||||||
|
import java.io.Serial; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 实体类 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
* @since 2026-01-06 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("MES_RECORDER") |
||||||
|
@Schema(description = "Recorder对象") |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class RecorderEntity extends BaseEntity { |
||||||
|
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪 |
||||||
|
*/ |
||||||
|
@Schema(description = "记录仪") |
||||||
|
private BigDecimal recorder; |
||||||
|
/** |
||||||
|
* 记录时间 |
||||||
|
*/ |
||||||
|
@Schema(description = "记录时间") |
||||||
|
private Date recordDate; |
||||||
|
/** |
||||||
|
* 数据信息 |
||||||
|
*/ |
||||||
|
@Schema(description = "数据信息") |
||||||
|
private String memo; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,52 @@ |
|||||||
|
package org.springblade.desk.device.pojo.excel; |
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||||
|
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||||
|
import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
||||||
|
import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.io.Serial; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 Excel实体类 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
* @since 2026-01-06 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ColumnWidth(25) |
||||||
|
@HeadRowHeight(20) |
||||||
|
@ContentRowHeight(18) |
||||||
|
public class RecorderExcel implements Serializable { |
||||||
|
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪 |
||||||
|
*/ |
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("记录仪") |
||||||
|
private BigDecimal recorder; |
||||||
|
/** |
||||||
|
* 记录时间 |
||||||
|
*/ |
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("记录时间") |
||||||
|
private Date recordDate; |
||||||
|
/** |
||||||
|
* 数据信息 |
||||||
|
*/ |
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("数据信息") |
||||||
|
private String memo; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,36 @@ |
|||||||
|
package org.springblade.desk.device.pojo.request; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import jakarta.validation.constraints.NotBlank; |
||||||
|
import jakarta.validation.constraints.NotNull; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪历史曲线 - 请求参数 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class RecorderQuery { |
||||||
|
/** |
||||||
|
* 设备编码 |
||||||
|
*/ |
||||||
|
@NotBlank(message = "设备编码不能为空") |
||||||
|
private String code; |
||||||
|
|
||||||
|
/** |
||||||
|
* 开始日期 |
||||||
|
*/ |
||||||
|
@NotNull(message = "开始日期不能为空") |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
||||||
|
private Date startDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 结束日期 |
||||||
|
*/ |
||||||
|
@NotNull(message = "结束日期不能为空") |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
||||||
|
private Date endDate; |
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
package org.springblade.desk.device.pojo.vo; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.desk.device.pojo.entity.RecorderEntity; |
||||||
|
|
||||||
|
import java.io.Serial; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录曲线 视图实体类 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
* @since 2026-01-06 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class LoadRecorderVO extends RecorderEntity { |
||||||
|
//X轴间隔
|
||||||
|
private int x = 0; |
||||||
|
//X轴数据
|
||||||
|
private List<String> xData = new ArrayList<>(); |
||||||
|
//Y轴
|
||||||
|
private List<Map<String, Object>> yArray = new ArrayList<>(); |
||||||
|
} |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
package org.springblade.desk.device.pojo.vo; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.desk.device.pojo.entity.RecorderEntity; |
||||||
|
|
||||||
|
import java.io.Serial; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 视图实体类 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
* @since 2026-01-06 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class RecorderVO extends RecorderEntity { |
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,140 @@ |
|||||||
|
package org.springblade.desk.device.controller; |
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import jakarta.validation.Valid; |
||||||
|
|
||||||
|
import org.springblade.core.secure.BladeUser; |
||||||
|
import org.springblade.core.secure.annotation.IsAdmin; |
||||||
|
import org.springblade.core.mp.support.Condition; |
||||||
|
import org.springblade.core.mp.support.Query; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.core.tool.utils.Func; |
||||||
|
import org.springblade.desk.device.pojo.excel.RecorderExcel; |
||||||
|
import org.springblade.desk.device.pojo.request.RecorderQuery; |
||||||
|
import org.springblade.desk.device.pojo.vo.LoadRecorderVO; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.springblade.desk.device.pojo.entity.RecorderEntity; |
||||||
|
import org.springblade.desk.device.pojo.vo.RecorderVO; |
||||||
|
import org.springblade.desk.device.wrapper.RecorderWrapper; |
||||||
|
import org.springblade.desk.device.service.IRecorderService; |
||||||
|
import org.springblade.core.boot.ctrl.BladeController; |
||||||
|
import org.springblade.core.tool.utils.DateUtil; |
||||||
|
import org.springblade.core.excel.util.ExcelUtil; |
||||||
|
import org.springblade.core.tool.constant.BladeConstant; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 控制器 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
* @since 2026-01-06 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@AllArgsConstructor |
||||||
|
@RequestMapping("/recorder") |
||||||
|
@Tag(name = "记录仪记录", description = "记录仪记录接口") |
||||||
|
public class RecorderController extends BladeController { |
||||||
|
|
||||||
|
private final IRecorderService recorderService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 详情 |
||||||
|
*/ |
||||||
|
@GetMapping("/detail") |
||||||
|
@ApiOperationSupport(order = 1) |
||||||
|
@Operation(summary = "详情", description = "传入recorder") |
||||||
|
public R<RecorderVO> detail(RecorderEntity recorder) { |
||||||
|
RecorderEntity detail = recorderService.getOne(Condition.getQueryWrapper(recorder)); |
||||||
|
return R.data(RecorderWrapper.build().entityVO(detail)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 自定义分页 |
||||||
|
*/ |
||||||
|
@GetMapping("/page") |
||||||
|
@ApiOperationSupport(order = 3) |
||||||
|
@Operation(summary = "分页", description = "传入recorder") |
||||||
|
public R<IPage<RecorderVO>> page(RecorderVO recorder, Query query) { |
||||||
|
IPage<RecorderVO> pages = recorderService.selectRecorderPage(Condition.getPage(query), recorder); |
||||||
|
return R.data(pages); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 新增 |
||||||
|
*/ |
||||||
|
@PostMapping("/save") |
||||||
|
@ApiOperationSupport(order = 4) |
||||||
|
@Operation(summary = "新增", description = "传入recorder") |
||||||
|
public R save(@Valid @RequestBody RecorderEntity recorder) { |
||||||
|
return R.status(recorderService.save(recorder)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 修改 |
||||||
|
*/ |
||||||
|
@PostMapping("/update") |
||||||
|
@ApiOperationSupport(order = 5) |
||||||
|
@Operation(summary = "修改", description = "传入recorder") |
||||||
|
public R update(@Valid @RequestBody RecorderEntity recorder) { |
||||||
|
return R.status(recorderService.updateById(recorder)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 新增或修改 |
||||||
|
*/ |
||||||
|
@PostMapping("/submit") |
||||||
|
@ApiOperationSupport(order = 6) |
||||||
|
@Operation(summary = "新增或修改", description = "传入recorder") |
||||||
|
public R submit(@Valid @RequestBody RecorderEntity recorder) { |
||||||
|
return R.status(recorderService.saveOrUpdate(recorder)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 删除 |
||||||
|
*/ |
||||||
|
@PostMapping("/remove") |
||||||
|
@ApiOperationSupport(order = 7) |
||||||
|
@Operation(summary = "逻辑删除", description = "传入ids") |
||||||
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { |
||||||
|
return R.status(recorderService.deleteLogic(Func.toLongList(ids))); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 加载曲线图数据 |
||||||
|
*/ |
||||||
|
@PostMapping("/loadCalRecorder") |
||||||
|
@ApiOperationSupport(order = 8) |
||||||
|
@Operation(summary = "记录仪历史曲线", description = "") |
||||||
|
public R<LoadRecorderVO> loadCalRecorder(@Valid @RequestBody RecorderQuery recorderQuery) { |
||||||
|
return R.data(recorderService.loadCalRecorder(recorderQuery)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 导出数据 |
||||||
|
*/ |
||||||
|
@IsAdmin |
||||||
|
@GetMapping("/export-recorder") |
||||||
|
@ApiOperationSupport(order = 9) |
||||||
|
@Operation(summary = "导出数据", description = "传入recorder") |
||||||
|
public void exportRecorder(@Parameter(hidden = true) @RequestParam Map<String, Object> recorder, BladeUser bladeUser, HttpServletResponse response) { |
||||||
|
QueryWrapper<RecorderEntity> queryWrapper = Condition.getQueryWrapper(recorder, RecorderEntity.class); |
||||||
|
//if (!AuthUtil.isAdministrator()) {
|
||||||
|
// queryWrapper.lambda().eq(Recorder::getTenantId, bladeUser.getTenantId());
|
||||||
|
//}
|
||||||
|
//queryWrapper.lambda().eq(RecorderEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED);
|
||||||
|
List<RecorderExcel> list = recorderService.exportRecorder(queryWrapper); |
||||||
|
ExcelUtil.export(response, "记录仪记录数据" + DateUtil.time(), "记录仪记录数据表", list, RecorderExcel.class); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,39 @@ |
|||||||
|
package org.springblade.desk.device.mapper; |
||||||
|
|
||||||
|
import org.springblade.desk.device.pojo.entity.RecorderEntity; |
||||||
|
import org.springblade.desk.device.pojo.excel.RecorderExcel; |
||||||
|
import org.springblade.desk.device.pojo.vo.RecorderVO; |
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 Mapper 接口 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
* @since 2026-01-06 |
||||||
|
*/ |
||||||
|
public interface RecorderMapper extends BaseMapper<RecorderEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 自定义分页 |
||||||
|
* |
||||||
|
* @param page 分页参数 |
||||||
|
* @param recorder 查询参数 |
||||||
|
* @return List<RecorderVO> |
||||||
|
*/ |
||||||
|
List<RecorderVO> selectRecorderPage(IPage page, RecorderVO recorder); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 获取导出数据 |
||||||
|
* |
||||||
|
* @param queryWrapper 查询条件 |
||||||
|
* @return List<RecorderExcel> |
||||||
|
*/ |
||||||
|
List<RecorderExcel> exportRecorder(@Param("ew") Wrapper<RecorderEntity> queryWrapper); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,34 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="org.springblade.desk.device.mapper.RecorderMapper"> |
||||||
|
|
||||||
|
<!-- 通用查询映射结果 --> |
||||||
|
<resultMap id="mesRecorderResultMap" type="org.springblade.desk.device.pojo.entity.RecorderEntity"> |
||||||
|
<result column="TENANT_ID" property="tenantId"/> |
||||||
|
<result column="CREATE_USER" property="createUser"/> |
||||||
|
<result column="CREATE_TIME" property="createTime"/> |
||||||
|
<result column="CREATE_DEPT" property="createDept"/> |
||||||
|
<result column="UPDATE_USER" property="updateUser"/> |
||||||
|
<result column="UPDATE_TIME" property="updateTime"/> |
||||||
|
<result column="STATUS" property="status"/> |
||||||
|
<result column="IS_DELETED" property="isDeleted"/> |
||||||
|
<result column="RECORDER" property="recorder"/> |
||||||
|
<result column="RECORD_DATE" property="recordDate"/> |
||||||
|
<result column="MEMO" property="memo"/> |
||||||
|
<result column="ID" property="id"/> |
||||||
|
</resultMap> |
||||||
|
|
||||||
|
|
||||||
|
<select id="selectRecorderPage" resultMap="mesRecorderResultMap"> |
||||||
|
select * |
||||||
|
from MES_RECORDER |
||||||
|
where is_deleted = 0 |
||||||
|
</select> |
||||||
|
|
||||||
|
|
||||||
|
<select id="exportRecorder" resultType="org.springblade.desk.device.pojo.excel.RecorderExcel"> |
||||||
|
SELECT * |
||||||
|
FROM MES_RECORDER ${ew.customSqlSegment} |
||||||
|
</select> |
||||||
|
|
||||||
|
</mapper> |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
package org.springblade.desk.device.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||||
|
import org.springblade.desk.device.pojo.entity.RecorderEntity; |
||||||
|
import org.springblade.desk.device.pojo.excel.RecorderExcel; |
||||||
|
import org.springblade.desk.device.pojo.request.RecorderQuery; |
||||||
|
import org.springblade.desk.device.pojo.vo.LoadRecorderVO; |
||||||
|
import org.springblade.desk.device.pojo.vo.RecorderVO; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.springblade.core.mp.base.BaseService; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 服务类 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
* @since 2026-01-06 |
||||||
|
*/ |
||||||
|
public interface IRecorderService extends BaseService<RecorderEntity> { |
||||||
|
/** |
||||||
|
* 自定义分页 |
||||||
|
* |
||||||
|
* @param page 分页参数 |
||||||
|
* @param recorder 查询参数 |
||||||
|
* @return IPage<RecorderVO> |
||||||
|
*/ |
||||||
|
IPage<RecorderVO> selectRecorderPage(IPage<RecorderVO> page, RecorderVO recorder); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 导出数据 |
||||||
|
* |
||||||
|
* @param queryWrapper 查询条件 |
||||||
|
* @return List<RecorderExcel> |
||||||
|
*/ |
||||||
|
List<RecorderExcel> exportRecorder(Wrapper<RecorderEntity> queryWrapper); |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪历史曲线 |
||||||
|
* |
||||||
|
* @param recorderQuery |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
LoadRecorderVO loadCalRecorder(RecorderQuery recorderQuery); |
||||||
|
} |
||||||
@ -0,0 +1,140 @@ |
|||||||
|
package org.springblade.desk.device.service.impl; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||||
|
import org.springblade.desk.device.pojo.entity.RecorderCompareEntity; |
||||||
|
import org.springblade.desk.device.pojo.entity.RecorderEntity; |
||||||
|
import org.springblade.desk.device.pojo.excel.RecorderExcel; |
||||||
|
import org.springblade.desk.device.pojo.request.RecorderCompareSave; |
||||||
|
import org.springblade.desk.device.pojo.request.RecorderQuery; |
||||||
|
import org.springblade.desk.device.pojo.vo.LoadRecorderVO; |
||||||
|
import org.springblade.desk.device.pojo.vo.RecorderVO; |
||||||
|
import org.springblade.desk.device.mapper.RecorderMapper; |
||||||
|
import org.springblade.desk.device.service.IRecorderCompareService; |
||||||
|
import org.springblade.desk.device.service.IRecorderService; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
|
||||||
|
import java.util.*; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 服务实现类 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
* @since 2026-01-06 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class RecorderServiceImpl extends BaseServiceImpl<RecorderMapper, RecorderEntity> implements IRecorderService { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IRecorderCompareService iRecorderCompareService; |
||||||
|
|
||||||
|
@Override |
||||||
|
public IPage<RecorderVO> selectRecorderPage(IPage<RecorderVO> page, RecorderVO recorder) { |
||||||
|
return page.setRecords(baseMapper.selectRecorderPage(page, recorder)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public List<RecorderExcel> exportRecorder(Wrapper<RecorderEntity> queryWrapper) { |
||||||
|
List<RecorderExcel> recorderList = baseMapper.exportRecorder(queryWrapper); |
||||||
|
//recorderList.forEach(recorder -> {
|
||||||
|
// recorder.setTypeName(DictCache.getValue(DictEnum.YES_NO, Recorder.getType()));
|
||||||
|
//});
|
||||||
|
return recorderList; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public LoadRecorderVO loadCalRecorder(RecorderQuery recorderQuery) { |
||||||
|
LoadRecorderVO loadRecorderVO = new LoadRecorderVO(); |
||||||
|
LambdaQueryWrapper<RecorderCompareEntity> wrapper = Wrappers.<RecorderCompareEntity>lambdaQuery(); |
||||||
|
wrapper.like(Objects.nonNull(recorderQuery.getCode()), RecorderCompareEntity::getCode, recorderQuery.getCode()); |
||||||
|
List<RecorderCompareEntity> recorderCompareEntities = iRecorderCompareService.list(wrapper); |
||||||
|
if (recorderCompareEntities == null || recorderCompareEntities.size() < 1) { |
||||||
|
return loadRecorderVO; |
||||||
|
} |
||||||
|
Map<String, RecorderCompareEntity> compreLst = recorderCompareEntities.stream() |
||||||
|
.collect(Collectors.toMap( |
||||||
|
RecorderCompareEntity::getName, // 键的映射函数
|
||||||
|
var -> var, // 值的映射函数
|
||||||
|
(existing, replacement) -> existing // 键冲突时的处理策略
|
||||||
|
)); |
||||||
|
LambdaQueryWrapper<RecorderEntity> queryWrapper = Wrappers.<RecorderEntity>lambdaQuery() |
||||||
|
.eq(RecorderEntity::getRecorder, recorderQuery.getCode()) // 精确匹配code
|
||||||
|
.ge(RecorderEntity::getRecordDate, recorderQuery.getStartDate()) // 大于等于开始日期
|
||||||
|
.le(RecorderEntity::getRecordDate, recorderQuery.getEndDate()); // 小于等于结束日期
|
||||||
|
List<RecorderEntity> recorderEntities = baseMapper.selectList(queryWrapper); |
||||||
|
|
||||||
|
// 组装chart数据
|
||||||
|
if (recorderEntities != null && recorderEntities.size() > 0) { |
||||||
|
|
||||||
|
//X轴间隔
|
||||||
|
int x = 0; |
||||||
|
//X轴数据
|
||||||
|
List<String> xData = new ArrayList<>(); |
||||||
|
|
||||||
|
Map<String, List<Double>> yMap = new HashMap<>(); |
||||||
|
List<Double> ydataLst = null; |
||||||
|
JSONObject jsonObject = null; |
||||||
|
for (RecorderEntity recorderEntity : recorderEntities) { |
||||||
|
|
||||||
|
jsonObject = JSONObject.parseObject(recorderEntity.getMemo(), JSONObject.class); |
||||||
|
|
||||||
|
if (jsonObject == null) continue; |
||||||
|
xData.add(recorderEntity.getRecordDate().toString()); |
||||||
|
|
||||||
|
for (Map.Entry<String, RecorderCompareEntity> var : compreLst.entrySet()) { |
||||||
|
Double d = 0d; |
||||||
|
if (StringUtils.isBlank(var.getKey())) continue; |
||||||
|
String objData = jsonObject.getString(var.getKey()); |
||||||
|
if (StringUtils.isNotBlank(objData)) { |
||||||
|
d = Double.parseDouble(objData + ""); |
||||||
|
} |
||||||
|
|
||||||
|
if (yMap.containsKey(var.getKey())) { |
||||||
|
ydataLst = yMap.get(var.getKey()); |
||||||
|
|
||||||
|
} else { |
||||||
|
ydataLst = new ArrayList<>(); |
||||||
|
yMap.put(var.getKey(), ydataLst); |
||||||
|
} |
||||||
|
ydataLst.add(d); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//Y轴数据
|
||||||
|
//Y轴显示名称
|
||||||
|
//Y轴比例尺
|
||||||
|
|
||||||
|
List<Map<String, Object>> yArray = new ArrayList<>(); |
||||||
|
for (Map.Entry<String, List<Double>> var : yMap.entrySet()) { |
||||||
|
RecorderCompareEntity compare = compreLst.get(var.getKey()); |
||||||
|
|
||||||
|
JSONObject yObj = new JSONObject(); |
||||||
|
if (compare.getShowName() == null || compare.getName() == "") { |
||||||
|
yObj.put("showName", compare.getName()); |
||||||
|
} else |
||||||
|
yObj.put("showName", compare.getShowName()); |
||||||
|
yObj.put("crcY", compare.getCrcY()); |
||||||
|
yObj.put("yData", var.getValue()); |
||||||
|
|
||||||
|
if (compare.getCrcX() != null && compare.getCrcX() > x) |
||||||
|
x = compare.getCrcX(); |
||||||
|
yArray.add(yObj); |
||||||
|
} |
||||||
|
loadRecorderVO.setX(x); |
||||||
|
loadRecorderVO.setXData(xData); |
||||||
|
loadRecorderVO.setYArray(yArray); |
||||||
|
return loadRecorderVO; |
||||||
|
} |
||||||
|
return loadRecorderVO; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
package org.springblade.desk.device.wrapper; |
||||||
|
|
||||||
|
import org.springblade.core.mp.support.BaseEntityWrapper; |
||||||
|
import org.springblade.core.tool.utils.BeanUtil; |
||||||
|
import org.springblade.desk.device.pojo.entity.RecorderEntity; |
||||||
|
import org.springblade.desk.device.pojo.vo.RecorderVO; |
||||||
|
|
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录仪记录 包装类,返回视图层所需的字段 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
* @since 2026-01-06 |
||||||
|
*/ |
||||||
|
public class RecorderWrapper extends BaseEntityWrapper<RecorderEntity, RecorderVO> { |
||||||
|
|
||||||
|
public static RecorderWrapper build() { |
||||||
|
return new RecorderWrapper(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public RecorderVO entityVO(RecorderEntity recorder) { |
||||||
|
RecorderVO recorderVO = Objects.requireNonNull(BeanUtil.copyProperties(recorder, RecorderVO.class)); |
||||||
|
|
||||||
|
//User createUser = UserCache.getUser(recorder.getCreateUser());
|
||||||
|
//User updateUser = UserCache.getUser(recorder.getUpdateUser());
|
||||||
|
//recorderVO.setCreateUserName(createUser.getName());
|
||||||
|
//recorderVO.setUpdateUserName(updateUser.getName());
|
||||||
|
|
||||||
|
return recorderVO; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue