12 changed files with 908 additions and 1 deletions
@ -0,0 +1,106 @@ |
|||
package org.dromara.demo.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import lombok.RequiredArgsConstructor; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import jakarta.validation.constraints.*; |
|||
import cn.dev33.satoken.annotation.SaCheckPermission; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
|||
import org.dromara.common.log.annotation.Log; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.common.log.enums.BusinessType; |
|||
import org.dromara.common.excel.utils.ExcelUtil; |
|||
import org.dromara.demo.domain.vo.SiteEvaluationInfoVo; |
|||
import org.dromara.demo.domain.bo.SiteEvaluationInfoBo; |
|||
import org.dromara.demo.service.ISiteEvaluationInfoService; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
|
|||
/** |
|||
* 现场考核信息 |
|||
* |
|||
* @author GJH |
|||
* @date 2025-09-05 |
|||
*/ |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/air/evaluationInfo") |
|||
public class SiteEvaluationInfoController extends BaseController { |
|||
|
|||
private final ISiteEvaluationInfoService siteEvaluationInfoService; |
|||
|
|||
/** |
|||
* 查询现场考核信息列表 |
|||
*/ |
|||
//@SaCheckPermission("air:evaluationInfo:list")
|
|||
@GetMapping("/list") |
|||
public TableDataInfo<SiteEvaluationInfoVo> list(SiteEvaluationInfoBo bo, PageQuery pageQuery) { |
|||
return siteEvaluationInfoService.queryPageList(bo, pageQuery); |
|||
} |
|||
|
|||
/** |
|||
* 导出现场考核信息列表 |
|||
*/ |
|||
//@SaCheckPermission("air:evaluationInfo:export")
|
|||
@Log(title = "现场考核信息", businessType = BusinessType.EXPORT) |
|||
@PostMapping("/export") |
|||
public void export(SiteEvaluationInfoBo bo, HttpServletResponse response) { |
|||
List<SiteEvaluationInfoVo> list = siteEvaluationInfoService.queryList(bo); |
|||
ExcelUtil.exportExcel(list, "现场考核信息", SiteEvaluationInfoVo.class, response); |
|||
} |
|||
|
|||
/** |
|||
* 获取现场考核信息详细信息 |
|||
* |
|||
* @param id 主键 |
|||
*/ |
|||
//@SaCheckPermission("air:evaluationInfo:query")
|
|||
@GetMapping("/{id}") |
|||
public R<SiteEvaluationInfoVo> getInfo(@NotNull(message = "主键不能为空") |
|||
@PathVariable String id) throws JsonProcessingException { |
|||
return R.ok(siteEvaluationInfoService.queryById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增现场考核信息 |
|||
*/ |
|||
//@SaCheckPermission("air:evaluationInfo:add")
|
|||
@Log(title = "现场考核信息", businessType = BusinessType.INSERT) |
|||
@RepeatSubmit() |
|||
@PostMapping() |
|||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SiteEvaluationInfoBo bo) { |
|||
return toAjax(siteEvaluationInfoService.insertByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 修改现场考核信息 |
|||
*/ |
|||
//@SaCheckPermission("air:evaluationInfo:edit")
|
|||
@Log(title = "现场考核信息", businessType = BusinessType.UPDATE) |
|||
@RepeatSubmit() |
|||
@PutMapping() |
|||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SiteEvaluationInfoBo bo) { |
|||
return toAjax(siteEvaluationInfoService.updateByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 删除现场考核信息 |
|||
* |
|||
* @param ids 主键串 |
|||
*/ |
|||
//@SaCheckPermission("air:evaluationInfo:remove")
|
|||
@Log(title = "现场考核信息", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{ids}") |
|||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|||
@PathVariable String[] ids) { |
|||
return toAjax(siteEvaluationInfoService.deleteWithValidByIds(List.of(ids), true)); |
|||
} |
|||
} |
@ -0,0 +1,30 @@ |
|||
package org.dromara.demo.domain; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class Attachment { |
|||
/** |
|||
* 附件地址 |
|||
*/ |
|||
private String url; |
|||
|
|||
/** |
|||
* 附件名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 附件存储ID |
|||
*/ |
|||
private String ossId; |
|||
|
|||
/** |
|||
* 附件描述 |
|||
*/ |
|||
private String description; |
|||
} |
@ -0,0 +1,75 @@ |
|||
package org.dromara.demo.domain; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
public class AttachmentSerializer { |
|||
|
|||
private final ObjectMapper objectMapper = new ObjectMapper(); |
|||
|
|||
/** |
|||
* 将List<Attachment>序列化为JSON字符串。 |
|||
* 序列化 |
|||
* @param attachment 包含附件信息的列表 |
|||
* @return 序列化后的JSON字符串 |
|||
*/ |
|||
public String serializeAttachments(List<Attachment> attachment) { |
|||
try { |
|||
// 使用ObjectMapper将List<Attachment>转换为JSON字符串
|
|||
return objectMapper.writeValueAsString(attachment); |
|||
} catch (JsonProcessingException e) { |
|||
// 处理可能发生的异常
|
|||
e.printStackTrace(); |
|||
// 根据实际情况决定如何处理错误,这里简单地返回null
|
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将JSON字符串反序列化为List<Attachment>。 |
|||
* 反序列化 |
|||
* @param attachmentJson JSON格式的字符串 |
|||
* @return 反序列化后的List<Attachment> |
|||
*/ |
|||
public List<Attachment> deserializeAttachments(String attachmentJson) { |
|||
try { |
|||
// 使用ObjectMapper将JSON字符串转换回List<Attachment>
|
|||
return objectMapper.readValue(attachmentJson, new TypeReference<List<Attachment>>() {}); |
|||
} catch (JsonProcessingException e) { |
|||
// 处理可能发生的异常
|
|||
e.printStackTrace(); |
|||
// 根据实际情况决定如何处理错误,这里简单地返回null
|
|||
return null; |
|||
} |
|||
} |
|||
|
|||
// 测试方法
|
|||
public static void main(String[] args) { |
|||
AttachmentSerializer serializer = new AttachmentSerializer(); |
|||
|
|||
// 创建一些模拟数据
|
|||
List<Attachment> attachmentList = List.of( |
|||
new Attachment("http://example.com/file1.pdf", "File One", "ossId1", "Description One"), |
|||
new Attachment("http://example.com/file2.docx", "File Two", "ossId2","Description Two" ) |
|||
); |
|||
|
|||
// 序列化
|
|||
String serialized = serializer.serializeAttachments(attachmentList); |
|||
System.out.println(serialized); // 输出序列化后的JSON字符串
|
|||
|
|||
// 反序列化
|
|||
List<Attachment> deserializedAttachments = serializer.deserializeAttachments(serialized); |
|||
System.out.println("Deserialized:"); |
|||
if (deserializedAttachments != null) { |
|||
for (Attachment attachment : deserializedAttachments) { |
|||
System.out.println("URL: " + attachment.getUrl() + ", Name: " + attachment.getName()); |
|||
} |
|||
} else { |
|||
System.out.println("Failed to deserialize the JSON string."); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,129 @@ |
|||
package org.dromara.demo.domain; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 现场考核业务数据实体类(用于 JSON 序列化) |
|||
* 对应数据库中的 evaluation_data JSON 字段 |
|||
* checkDateTime 格式:yyyy-MM-dd HH:mm:ss |
|||
*/ |
|||
@Data |
|||
public class EvaluationDataJson implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** 站点名称 */ |
|||
private String siteName; |
|||
|
|||
/** |
|||
* 检查时间 |
|||
* 格式:yyyy-MM-dd HH:mm:ss(年月日时分秒) |
|||
* 注意:此处使用 String 类型以保持格式一致性,避免时区问题 |
|||
*/ |
|||
private String checkDateTime; |
|||
|
|||
/** 运维单位 */ |
|||
private String operationUnit; |
|||
|
|||
/** 检查人员 */ |
|||
private String checkPeople; |
|||
|
|||
/** 总分 */ |
|||
private String totalScore; // 使用 String 接收原始 JSON 字符串,或可改为 Integer
|
|||
|
|||
// -------------------- 评分项 score_01 到 score_28 --------------------
|
|||
private String score_01; |
|||
private String score_02; |
|||
private String score_03; |
|||
private String score_04; |
|||
private String score_05; |
|||
private String score_06; |
|||
private String score_07; |
|||
private String score_08; |
|||
private String score_09; |
|||
private String score_10; |
|||
private String score_11; |
|||
private String score_12; |
|||
private String score_13; |
|||
private String score_14; |
|||
private String score_15; |
|||
private String score_16; |
|||
private String score_17; |
|||
private String score_18; |
|||
private String score_19; |
|||
private String score_20; |
|||
private String score_21; |
|||
private String score_22; |
|||
private String score_23; |
|||
private String score_24; |
|||
private String score_25; |
|||
private String score_26; |
|||
private String score_27; |
|||
private String score_28; |
|||
|
|||
// -------------------- 零点校准 --------------------
|
|||
private String zero_flow; |
|||
private String zero_std; |
|||
private String zero_error; |
|||
|
|||
// -------------------- 量程校准 --------------------
|
|||
private String span_flow; |
|||
private String span_std; |
|||
private String span_error; |
|||
|
|||
// -------------------- SO 参数 --------------------
|
|||
private String so_display; |
|||
private String so_std; |
|||
private String so_error; |
|||
private String so_conc_output; |
|||
private String so_conc_response; |
|||
private String so_conc_error; |
|||
private String so_time; |
|||
|
|||
// -------------------- NO 参数 --------------------
|
|||
private String no_display; |
|||
private String no_std; |
|||
private String no_error; |
|||
private String no_conc_output; |
|||
private String no_conc_response; |
|||
private String no_conc_error; |
|||
private String no_time; |
|||
|
|||
// -------------------- CO 参数 --------------------
|
|||
private String co_display; |
|||
private String co_std; |
|||
private String co_error; |
|||
private String co_conc_output; |
|||
private String co_conc_response; |
|||
private String co_conc_error; |
|||
private String co_time; |
|||
|
|||
// -------------------- O2 参数 --------------------
|
|||
private String o_display; |
|||
private String o_std; |
|||
private String o_error; |
|||
private String o_conc_output; |
|||
private String o_conc_response; |
|||
private String o_conc_error; |
|||
private String o_time; |
|||
|
|||
// -------------------- PM10 参数 --------------------
|
|||
private String pm_ten_display; |
|||
private String pm_ten_std; |
|||
private String pm_ten_error; |
|||
private String pm_ten_k; |
|||
|
|||
// -------------------- PM2.5 参数 --------------------
|
|||
private String pm_two_display; |
|||
private String pm_two_std; |
|||
private String pm_two_error; |
|||
private String pm_two_k; |
|||
|
|||
// -------------------- 斜率参数 --------------------
|
|||
private String slope_a; |
|||
private String slope_b; |
|||
} |
@ -0,0 +1,76 @@ |
|||
package org.dromara.demo.domain; |
|||
|
|||
import org.dromara.common.tenant.core.TenantEntity; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.Date; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
|
|||
import java.io.Serial; |
|||
|
|||
/** |
|||
* 现场考核信息对象 site_evaluation_info |
|||
* |
|||
* @author GJH |
|||
* @date 2025-09-05 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@TableName("site_evaluation_info") |
|||
public class SiteEvaluationInfo extends TenantEntity { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键ID(MyBatis-Plus) |
|||
*/ |
|||
@TableId(value = "id") |
|||
private String id; |
|||
|
|||
/** |
|||
* 核查时间 |
|||
*/ |
|||
private LocalDateTime checkDateTime; |
|||
|
|||
/** |
|||
* 站点名称 |
|||
*/ |
|||
private String siteName; |
|||
|
|||
/** |
|||
* 核查人员 |
|||
*/ |
|||
private String checkPeople; |
|||
|
|||
/** |
|||
* 评分相关业务数据 |
|||
*/ |
|||
private String evaluationData; |
|||
|
|||
/** |
|||
* 图片附件数据 |
|||
*/ |
|||
private String imgData; |
|||
|
|||
/** |
|||
* 状态 |
|||
*/ |
|||
private String status; |
|||
|
|||
/** |
|||
* 监理类型 |
|||
*/ |
|||
private String monitorType; |
|||
|
|||
/** |
|||
* 删除标志 |
|||
*/ |
|||
@TableLogic |
|||
private Long delFlag; |
|||
|
|||
|
|||
} |
@ -0,0 +1,76 @@ |
|||
package org.dromara.demo.domain.bo; |
|||
|
|||
import org.dromara.demo.domain.SiteEvaluationInfo; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import jakarta.validation.constraints.*; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.Date; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
|
|||
/** |
|||
* 现场考核信息业务对象 site_evaluation_info |
|||
* |
|||
* @author GJH |
|||
* @date 2025-09-05 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@AutoMapper(target = SiteEvaluationInfo.class, reverseConvertGenerate = false) |
|||
public class SiteEvaluationInfoBo extends BaseEntity { |
|||
|
|||
/** |
|||
* 主键ID(MyBatis-Plus) |
|||
*/ |
|||
//@NotBlank(message = "主键ID(MyBatis-Plus)不能为空", groups = { EditGroup.class })
|
|||
private String id; |
|||
|
|||
/** |
|||
* 核查时间 |
|||
*/ |
|||
//@NotNull(message = "核查时间不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private LocalDateTime checkDateTime; |
|||
|
|||
/** |
|||
* 站点名称 |
|||
*/ |
|||
//@NotBlank(message = "站点名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String siteName; |
|||
|
|||
/** |
|||
* 核查人员 |
|||
*/ |
|||
//@NotBlank(message = "核查人员不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String checkPeople; |
|||
|
|||
/** |
|||
* 评分相关业务数据 |
|||
*/ |
|||
//@NotBlank(message = "评分相关业务数据不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String evaluationData; |
|||
|
|||
/** |
|||
* 图片附件数据 |
|||
*/ |
|||
//@NotBlank(message = "图片附件数据不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String imgData; |
|||
|
|||
/** |
|||
* 状态 |
|||
*/ |
|||
//@NotBlank(message = "状态不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String status; |
|||
|
|||
/** |
|||
* 监理类型 |
|||
*/ |
|||
//@NotBlank(message = "监理类型不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String monitorType; |
|||
|
|||
|
|||
} |
@ -0,0 +1,19 @@ |
|||
package org.dromara.demo.domain.vo; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
import org.dromara.demo.domain.Attachment; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class AttachmentVo { |
|||
private List<Attachment> attachmentList; |
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
} |
@ -0,0 +1,102 @@ |
|||
package org.dromara.demo.domain.vo; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.Date; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.NoArgsConstructor; |
|||
import org.dromara.demo.domain.Attachment; |
|||
import org.dromara.demo.domain.EvaluationDataJson; |
|||
import org.dromara.demo.domain.SiteEvaluationInfo; |
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import org.dromara.common.excel.annotation.ExcelDictFormat; |
|||
import org.dromara.common.excel.convert.ExcelDictConvert; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 现场考核信息视图对象 site_evaluation_info |
|||
* |
|||
* @author GJH |
|||
* @date 2025-09-05 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = SiteEvaluationInfo.class) |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class SiteEvaluationInfoVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键ID(MyBatis-Plus) |
|||
*/ |
|||
@ExcelProperty(value = "主键ID", converter = ExcelDictConvert.class) |
|||
@ExcelDictFormat(readConverterExp = "M=yBatis-Plus") |
|||
private String id; |
|||
|
|||
/** |
|||
* 核查时间 |
|||
*/ |
|||
@ExcelProperty(value = "核查时间") |
|||
private LocalDateTime checkDateTime; |
|||
|
|||
/** |
|||
* 站点名称 |
|||
*/ |
|||
@ExcelProperty(value = "站点名称") |
|||
private String siteName; |
|||
|
|||
/** |
|||
* 核查人员 |
|||
*/ |
|||
@ExcelProperty(value = "核查人员") |
|||
private String checkPeople; |
|||
|
|||
/** |
|||
* 评分相关业务数据 |
|||
*/ |
|||
@ExcelProperty(value = "评分相关业务数据") |
|||
private String evaluationData; |
|||
|
|||
/** |
|||
* 图片附件数据 |
|||
*/ |
|||
@ExcelProperty(value = "图片附件数据") |
|||
private String imgData; |
|||
|
|||
/** |
|||
* 状态 |
|||
*/ |
|||
@ExcelProperty(value = "状态") |
|||
private String status; |
|||
|
|||
/** |
|||
* 监理类型 |
|||
*/ |
|||
@ExcelProperty(value = "监理类型") |
|||
private String monitorType; |
|||
|
|||
/** |
|||
* 评分业务数据 |
|||
*/ |
|||
@TableField(exist = false) |
|||
private EvaluationDataJson evaluationDataVo; |
|||
|
|||
/** |
|||
* 附件业务数据 |
|||
*/ |
|||
@TableField(exist = false) |
|||
private List<AttachmentVo> attachmentVoList; |
|||
} |
@ -0,0 +1,15 @@ |
|||
package org.dromara.demo.mapper; |
|||
|
|||
import org.dromara.demo.domain.SiteEvaluationInfo; |
|||
import org.dromara.demo.domain.vo.SiteEvaluationInfoVo; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
|
|||
/** |
|||
* 现场考核信息Mapper接口 |
|||
* |
|||
* @author GJH |
|||
* @date 2025-09-05 |
|||
*/ |
|||
public interface SiteEvaluationInfoMapper extends BaseMapperPlus<SiteEvaluationInfo, SiteEvaluationInfoVo> { |
|||
|
|||
} |
@ -0,0 +1,69 @@ |
|||
package org.dromara.demo.service; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import org.dromara.demo.domain.vo.SiteEvaluationInfoVo; |
|||
import org.dromara.demo.domain.bo.SiteEvaluationInfoBo; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 现场考核信息Service接口 |
|||
* |
|||
* @author GJH |
|||
* @date 2025-09-05 |
|||
*/ |
|||
public interface ISiteEvaluationInfoService { |
|||
|
|||
/** |
|||
* 查询现场考核信息 |
|||
* |
|||
* @param id 主键 |
|||
* @return 现场考核信息 |
|||
*/ |
|||
SiteEvaluationInfoVo queryById(String id) throws JsonProcessingException; |
|||
|
|||
/** |
|||
* 分页查询现场考核信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 现场考核信息分页列表 |
|||
*/ |
|||
TableDataInfo<SiteEvaluationInfoVo> queryPageList(SiteEvaluationInfoBo bo, PageQuery pageQuery); |
|||
|
|||
/** |
|||
* 查询符合条件的现场考核信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 现场考核信息列表 |
|||
*/ |
|||
List<SiteEvaluationInfoVo> queryList(SiteEvaluationInfoBo bo); |
|||
|
|||
/** |
|||
* 新增现场考核信息 |
|||
* |
|||
* @param bo 现场考核信息 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
Boolean insertByBo(SiteEvaluationInfoBo bo); |
|||
|
|||
/** |
|||
* 修改现场考核信息 |
|||
* |
|||
* @param bo 现场考核信息 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
Boolean updateByBo(SiteEvaluationInfoBo bo); |
|||
|
|||
/** |
|||
* 校验并批量删除现场考核信息信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid); |
|||
} |
@ -0,0 +1,201 @@ |
|||
package org.dromara.demo.service.impl; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.databind.JavaType; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import org.dromara.common.core.utils.MapstructUtils; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.dromara.demo.domain.EvaluationDataJson; |
|||
import org.dromara.demo.domain.vo.AttachmentVo; |
|||
import org.springframework.stereotype.Service; |
|||
import org.dromara.demo.domain.bo.SiteEvaluationInfoBo; |
|||
import org.dromara.demo.domain.vo.SiteEvaluationInfoVo; |
|||
import org.dromara.demo.domain.SiteEvaluationInfo; |
|||
import org.dromara.demo.mapper.SiteEvaluationInfoMapper; |
|||
import org.dromara.demo.service.ISiteEvaluationInfoService; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* 现场考核信息Service业务层处理 |
|||
* |
|||
* @author GJH |
|||
* @date 2025-09-05 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class SiteEvaluationInfoServiceImpl implements ISiteEvaluationInfoService { |
|||
|
|||
private final SiteEvaluationInfoMapper baseMapper; |
|||
private final ObjectMapper objectMapper = new ObjectMapper(); |
|||
|
|||
/** |
|||
* 查询现场考核信息 |
|||
* |
|||
* @param id 主键 |
|||
* @return 现场考核信息 |
|||
*/ |
|||
@Override |
|||
public SiteEvaluationInfoVo queryById(String id) throws JsonProcessingException { |
|||
SiteEvaluationInfoVo target = baseMapper.selectVoById(id); |
|||
EvaluationDataJson evaluationDataJson = objectMapper.readValue(target.getEvaluationData(), EvaluationDataJson.class); |
|||
target.setEvaluationDataVo(evaluationDataJson); |
|||
// 假设 bo.getEvaluationData() 返回 JSON 字符串
|
|||
String imgData = target.getImgData(); |
|||
|
|||
List<AttachmentVo> attachmentList = null; |
|||
if (StringUtils.isNotBlank(imgData)) { |
|||
try { |
|||
// 关键:构造 List<AttachmentVo> 类型
|
|||
JavaType javaType = objectMapper.getTypeFactory() |
|||
.constructCollectionType(List.class, AttachmentVo.class); |
|||
|
|||
attachmentList = objectMapper.readValue(imgData, javaType); |
|||
} catch (Exception e) { |
|||
throw new RuntimeException("反序列化 img_data 失败", e); |
|||
} |
|||
} |
|||
target.setAttachmentVoList(attachmentList); |
|||
return target; |
|||
} |
|||
|
|||
/** |
|||
* 分页查询现场考核信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 现场考核信息分页列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo<SiteEvaluationInfoVo> queryPageList(SiteEvaluationInfoBo bo, PageQuery pageQuery) { |
|||
LambdaQueryWrapper<SiteEvaluationInfo> lqw = buildQueryWrapper(bo); |
|||
Page<SiteEvaluationInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
/** |
|||
* 查询符合条件的现场考核信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 现场考核信息列表 |
|||
*/ |
|||
@Override |
|||
public List<SiteEvaluationInfoVo> queryList(SiteEvaluationInfoBo bo) { |
|||
LambdaQueryWrapper<SiteEvaluationInfo> lqw = buildQueryWrapper(bo); |
|||
return baseMapper.selectVoList(lqw); |
|||
} |
|||
|
|||
private LambdaQueryWrapper<SiteEvaluationInfo> buildQueryWrapper(SiteEvaluationInfoBo bo) { |
|||
Map<String, Object> params = bo.getParams(); |
|||
LambdaQueryWrapper<SiteEvaluationInfo> lqw = Wrappers.lambdaQuery(); |
|||
lqw.eq(bo.getCheckDateTime() != null, SiteEvaluationInfo::getCheckDateTime, bo.getCheckDateTime()); |
|||
lqw.like(StringUtils.isNotBlank(bo.getSiteName()), SiteEvaluationInfo::getSiteName, bo.getSiteName()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getCheckPeople()), SiteEvaluationInfo::getCheckPeople, bo.getCheckPeople()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getEvaluationData()), SiteEvaluationInfo::getEvaluationData, bo.getEvaluationData()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getImgData()), SiteEvaluationInfo::getImgData, bo.getImgData()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SiteEvaluationInfo::getStatus, bo.getStatus()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getMonitorType()), SiteEvaluationInfo::getMonitorType, bo.getMonitorType()); |
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增现场考核信息 |
|||
* |
|||
* @param bo 现场考核信息 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(SiteEvaluationInfoBo bo) { |
|||
SiteEvaluationInfo add = MapstructUtils.convert(bo, SiteEvaluationInfo.class); |
|||
// 【关键】从 evaluation_data JSON 中提取结构化字段
|
|||
if (StringUtils.isNotBlank(bo.getEvaluationData())) { |
|||
try { |
|||
// 假设你有一个类来接收 JSON 结构
|
|||
EvaluationDataJson evalData = objectMapper.readValue(bo.getEvaluationData(), EvaluationDataJson.class); |
|||
|
|||
// 提取字段,填充到 Entity
|
|||
add.setCheckDateTime( |
|||
StringUtils.isNotBlank(evalData.getCheckDateTime()) ? |
|||
LocalDateTime.parse(evalData.getCheckDateTime(), |
|||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : |
|||
null |
|||
); |
|||
add.setSiteName(evalData.getSiteName()); |
|||
add.setCheckPeople(evalData.getCheckPeople()); |
|||
|
|||
} catch (Exception e) { |
|||
throw new RuntimeException("解析 evaluation_data JSON 失败", e); |
|||
} |
|||
} |
|||
validEntityBeforeSave(add); |
|||
boolean flag = baseMapper.insert(add) > 0; |
|||
if (flag) { |
|||
bo.setId(add.getId()); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改现场考核信息 |
|||
* |
|||
* @param bo 现场考核信息 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(SiteEvaluationInfoBo bo) { |
|||
if (StringUtils.isNotBlank(bo.getEvaluationData())) { |
|||
try { |
|||
// 假设你有一个类来接收 JSON 结构
|
|||
EvaluationDataJson evalData = objectMapper.readValue(bo.getEvaluationData(), EvaluationDataJson.class); |
|||
|
|||
// 提取字段,填充到 Entity
|
|||
bo.setCheckDateTime( |
|||
StringUtils.isNotBlank(evalData.getCheckDateTime()) ? |
|||
LocalDateTime.parse(evalData.getCheckDateTime(), |
|||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : |
|||
null |
|||
); |
|||
bo.setSiteName(evalData.getSiteName()); |
|||
bo.setCheckPeople(evalData.getCheckPeople()); |
|||
|
|||
} catch (Exception e) { |
|||
throw new RuntimeException("解析 evaluation_data JSON 失败", e); |
|||
} |
|||
} |
|||
SiteEvaluationInfo update = MapstructUtils.convert(bo, SiteEvaluationInfo.class); |
|||
validEntityBeforeSave(update); |
|||
return baseMapper.updateById(update) > 0; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(SiteEvaluationInfo entity){ |
|||
//TODO 做一些数据校验,如唯一约束
|
|||
} |
|||
|
|||
/** |
|||
* 校验并批量删除现场考核信息信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) { |
|||
if(isValid){ |
|||
//TODO 做一些业务上的校验,判断是否需要校验
|
|||
} |
|||
return baseMapper.deleteByIds(ids) > 0; |
|||
} |
|||
} |
Loading…
Reference in new issue