0
0

Merge branch 'dyf-device' into 6170

This commit is contained in:
2025-09-26 09:33:07 +08:00
17 changed files with 304 additions and 41 deletions

View File

@ -11,6 +11,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile;
@ -70,4 +72,6 @@ public class DeviceRepairRecordsBo extends BaseEntity {
@Schema(title = "维修后图片")
@JsonIgnore
private MultipartFile afterFile;
private List<Long> imageIds;
}

View File

@ -22,9 +22,6 @@ public class DeviceExcelExportDTO {
// @ExcelProperty("ID")
// private Long id;
@ExcelProperty("设备类型")
@ColumnWidth(20)
private String typeName;
// @ExcelProperty("设备类型")
// private Long deviceType;
@ -55,12 +52,25 @@ public class DeviceExcelExportDTO {
@ColumnWidth(20)
private String deviceImei;
@ExcelProperty("设备类型")
@ColumnWidth(20)
private String typeName;
// @ExcelProperty("经度")
// private String longitude;
// @ExcelProperty("纬度")
// private String latitude;
/**
* 绑定状态
* 0 未绑定
* 1 已绑定
*/
@ExcelProperty("绑定状态")
@ColumnWidth(20)
private String bindingStatus;
@ExcelProperty("备注")
@ColumnWidth(30)
private String remark;

View File

@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
@ -51,8 +52,10 @@ public class DeviceRepairRecordsQueryCriteria extends BaseEntity {
private String repairPerson;
@Schema(title = "维修开始时间")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date repairBeginTime;
@Schema(title = "维修结束时间")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date repairEndTime;
@Schema(title = "所属客户")

View File

@ -53,7 +53,9 @@ public class DeviceExportService {
dto.setTypeName(device.getTypeName());
dto.setCreateBy(device.getCreateByName());
Integer deviceStatus = device.getDeviceStatus();
Integer bindingStatus = device.getBindingStatus();
// dto.setDeviceStatus(deviceStatus == 1 ? "正常" : "失效");
dto.setBindingStatus(bindingStatus == 1 ? "已绑定" : "未绑定");
// 时间戳转换
dto.setCreateTime(DateUtils.format(device.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));

View File

@ -18,6 +18,7 @@ import com.fuyuanshen.equipment.domain.vo.DeviceRepairImagesVo;
import com.fuyuanshen.equipment.enums.RepairImageType;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.equipment.mapper.DeviceRepairImagesMapper;
import com.fuyuanshen.equipment.utils.FileHashUtil;
import com.fuyuanshen.system.domain.vo.SysOssVo;
import com.fuyuanshen.system.service.ISysOssService;
import lombok.RequiredArgsConstructor;
@ -32,6 +33,7 @@ import com.fuyuanshen.equipment.service.IDeviceRepairRecordsService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.*;
/**
@ -178,6 +180,10 @@ public class DeviceRepairRecordsServiceImpl extends ServiceImpl<DeviceRepairReco
if (!updated) {
return false;
}
// 3. 删除旧图片
if(bo.getImageIds() != null){
imagesMapper.deleteByIds(bo.getImageIds());
}
// 3. 收集需要保存的图片
List<DeviceRepairImages> images = new ArrayList<>(2);
@ -200,12 +206,28 @@ public class DeviceRepairRecordsServiceImpl extends ServiceImpl<DeviceRepairReco
if (file == null || file.isEmpty()) {
return;
}
SysOssVo ossVo = ossService.upload(file);
// 1. 计算文件哈希
String hash = null;
try {
hash = FileHashUtil.hash(file);
} catch (IOException e) {
throw new RuntimeException(e);
}
// 2. 先根据 hash 查库(秒传)
SysOssVo exist = ossService.selectByHash(hash);
if (exist == null) {
// 2.2 不存在,真正上传
exist = ossService.upload(file);
// 2.3 把 hash 写回记录(供下次去重)
ossService.updateHashById(exist.getOssId(), hash);
}
DeviceRepairImages image = new DeviceRepairImages();
image.setRecordId(recordId);
image.setImageType(imageType);
image.setImageUrl(ossVo.getUrl());
image.setImageUrl(exist.getUrl());
list.add(image);
}

View File

@ -0,0 +1,28 @@
package com.fuyuanshen.equipment.utils;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.util.HexFormat;
/**
* 文件哈希工具类
*/
public class FileHashUtil {
private static final String ALGORITHM = "SHA-256";
public static String hash(MultipartFile file) throws IOException {
MessageDigest digest = DigestUtils.getDigest(ALGORITHM);
try (InputStream in = file.getInputStream()) {
byte[] buf = new byte[8192];
int len;
while ((len = in.read(buf)) != -1) {
digest.update(buf, 0, len);
}
}
return HexFormat.of().formatHex(digest.digest());
}
}

View File

@ -29,9 +29,10 @@
and da.treatment_state = #{bo.treatmentState}
</if>
<if test="bo.queryTime1 != null and bo.queryTime2 != null ">
and da.start_time between #{bo.queryTime1} and #{bo.queryTime2}
and da.start_time BETWEEN #{bo.queryTime1} AND #{bo.queryTime2}
</if>
</where>
order by da.create_time DESC
</select>

View File

@ -23,6 +23,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM device_repair_records dr
JOIN device d ON dr.device_id = d.id
<where>
<if test="criteria.searchValue != null">
and d.device_name like concat('%', TRIM(#{criteria.searchValue}), '%')
</if>
<if test="criteria.deviceId != null">
and dr.device_id = #{criteria.deviceId}
</if>