Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
0a3de7088c
@ -0,0 +1,14 @@
|
||||
package com.cdzy.operations.mapper;
|
||||
|
||||
import com.cdzy.operations.model.entity.EbikeBikeConfiguration;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
|
||||
/**
|
||||
* 车辆相关配置 映射层
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2025-12-03 16:21
|
||||
*/
|
||||
|
||||
public interface EbikeBikeConfigurationMapper extends BaseMapper<EbikeBikeConfiguration> {
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.cdzy.operations.model.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 配置项 实体类
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2025-12-03 16:31
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EbikeBikeConfigurationDto {
|
||||
|
||||
/**
|
||||
* 运营商id
|
||||
*/
|
||||
@NotNull(message = "运营商id不能为空")
|
||||
private Long operatorId;
|
||||
|
||||
/**
|
||||
* 配置项时长
|
||||
*/
|
||||
@NotNull(message = "配置项时长不能为空")
|
||||
private Integer configurationDuration;
|
||||
|
||||
/**
|
||||
* 配置项描述
|
||||
*/
|
||||
@NotBlank(message = "配置项描述不能为空")
|
||||
private String configurationDescription;
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.cdzy.operations.model.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 车辆相关配置 实体类
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2025-12-03 16:18
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("ebike_bike_configuration")
|
||||
public class EbikeBikeConfiguration implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 操作主键id
|
||||
*/
|
||||
@Id
|
||||
private Long batteryId;
|
||||
|
||||
/**
|
||||
* 运营商id
|
||||
*/
|
||||
private Long operatorId;
|
||||
|
||||
/**
|
||||
* 配置项时长
|
||||
*/
|
||||
private Integer configurationDuration;
|
||||
|
||||
/**
|
||||
* 配置项描述
|
||||
*/
|
||||
private String configurationDescription;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createdBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Column(onUpdateValue = "now()")
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private Long updatedBy;
|
||||
|
||||
/**
|
||||
* 删除与否
|
||||
*/
|
||||
private Boolean isDeleted;
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.cdzy.operations.service;
|
||||
|
||||
import com.cdzy.operations.model.dto.EbikeBikeConfigurationDto;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeConfiguration;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆相关配置 服务层
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2025-12-03 16:22
|
||||
*/
|
||||
|
||||
public interface EbikeBikeConfigurationService extends IService<EbikeBikeConfiguration> {
|
||||
|
||||
/**
|
||||
* 根据运营商id获取配置项(sql会自动拼接运营商id)
|
||||
*
|
||||
* @return 配置项
|
||||
*/
|
||||
List<EbikeBikeConfiguration> getConfigurationByOperationId();
|
||||
|
||||
/**
|
||||
* 配置项保存
|
||||
*
|
||||
* @param configurationDto 配置项参数
|
||||
*/
|
||||
void saveConfiguration(EbikeBikeConfigurationDto configurationDto);
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.cdzy.operations.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cdzy.operations.mapper.EbikeBikeConfigurationMapper;
|
||||
import com.cdzy.operations.model.dto.EbikeBikeConfigurationDto;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeConfiguration;
|
||||
import com.cdzy.operations.service.EbikeBikeConfigurationService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeBikeConfigurationTableDef.EBIKE_BIKE_CONFIGURATION;
|
||||
|
||||
|
||||
/**
|
||||
* 车辆相关配置 实现类
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2025-12-03 16:22
|
||||
*/
|
||||
@Service
|
||||
public class EbikeBikeConfigurationServiceImpl extends ServiceImpl<EbikeBikeConfigurationMapper, EbikeBikeConfiguration> implements EbikeBikeConfigurationService {
|
||||
|
||||
@Override
|
||||
public List<EbikeBikeConfiguration> getConfigurationByOperationId() {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(EBIKE_BIKE_CONFIGURATION.ALL_COLUMNS);
|
||||
return this.mapper.selectListByQuery(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfiguration(EbikeBikeConfigurationDto configurationDto) {
|
||||
EbikeBikeConfiguration configuration = EbikeBikeConfiguration.builder()
|
||||
.operatorId(configurationDto.getOperatorId())
|
||||
.configurationDuration(configurationDto.getConfigurationDuration())
|
||||
.configurationDescription(configurationDto.getConfigurationDescription())
|
||||
.createdBy(StpUtil.getLoginIdAsLong())
|
||||
.build();
|
||||
this.mapper.insert(configuration);
|
||||
}
|
||||
}
|
||||
@ -204,75 +204,69 @@ public class EbikeFaultReportServiceImpl extends ServiceImpl<EbikeFaultReportMap
|
||||
.updateBy(ebikeFaultReportDto.getUserId())
|
||||
.build();
|
||||
this.updateById(userFaultReport);
|
||||
List<EbikeFaultFileDto> attachmentFiles = ebikeFaultReportDto.getAttachmentFiles();
|
||||
// 更新文件信息
|
||||
if (!CollectionUtils.isEmpty(attachmentFiles)) {
|
||||
List<EbikeFaultFile> existingFiles = ebikeAttachmentFileService.queryFiles(ebikeFaultReportDto.getReportId());
|
||||
|
||||
Set<Long> existingFileIds = existingFiles.stream()
|
||||
// 文件处理
|
||||
List<EbikeFaultFileDto> attachments = ebikeFaultReportDto.getAttachmentFiles();
|
||||
if (!CollectionUtils.isEmpty(attachments)) {
|
||||
List<EbikeFaultFile> existingFiles = ebikeAttachmentFileService.queryFiles(ebikeFaultReportDto.getReportId());
|
||||
Set<Long> existingIds = existingFiles.stream()
|
||||
.map(EbikeFaultFile::getFileId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 分离前端数据,无id的新增,有id的对比
|
||||
Set<Long> incomingFileIds = new HashSet<>();
|
||||
List<EbikeFaultFile> filesToInsert = new ArrayList<>();
|
||||
Set<Long> incomingIds = new HashSet<>();
|
||||
List<EbikeFaultFile> toInsert = new ArrayList<>();
|
||||
|
||||
for (EbikeFaultFileDto dto : attachmentFiles) {
|
||||
if (dto.getFileId() != null) {
|
||||
incomingFileIds.add(dto.getFileId());
|
||||
for (EbikeFaultFileDto f : attachments) {
|
||||
if (f.getFileId() != null) {
|
||||
incomingIds.add(f.getFileId());
|
||||
} else {
|
||||
// fileId 为空,则是新文件,插入数据
|
||||
EbikeFaultFile newFile = EbikeFaultFile.builder()
|
||||
toInsert.add(EbikeFaultFile.builder()
|
||||
.reportId(ebikeFaultReportDto.getReportId())
|
||||
.fileName(dto.getFileName())
|
||||
.fileUrl(dto.getFileUrl())
|
||||
//.createBy(userId)
|
||||
.build();
|
||||
filesToInsert.add(newFile);
|
||||
.fileName(f.getFileName())
|
||||
.fileUrl(f.getFileUrl())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
// 对比incomingFileIds与existingFileIds的id,在existingFileIds数据库存在,但是不在incomingFileIds存在的已经被删除
|
||||
List<Long> fileIdsToDelete = existingFileIds.stream()
|
||||
.filter(id -> !incomingFileIds.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 根据主键id删除文件数据
|
||||
if (!fileIdsToDelete.isEmpty()) {
|
||||
ebikeAttachmentFileService.removeByIds(fileIdsToDelete);
|
||||
// 删除:存在但前端没传
|
||||
existingIds.removeAll(incomingIds);
|
||||
if (!existingIds.isEmpty()) {
|
||||
ebikeAttachmentFileService.removeByIds(new ArrayList<>(existingIds));
|
||||
}
|
||||
|
||||
// 插入新文件
|
||||
if (!filesToInsert.isEmpty()) {
|
||||
ebikeAttachmentFileService.saveBatch(filesToInsert);
|
||||
// 新增
|
||||
if (!toInsert.isEmpty()) {
|
||||
ebikeAttachmentFileService.saveBatch(toInsert);
|
||||
}
|
||||
}
|
||||
List<Integer> faultPart = ebikeFaultReportDto.getFaultPart();
|
||||
List<Integer> existingFaultParts = ebikeFaultPartService.getFaultPartByReportId(ebikeFaultReportDto.getReportId());
|
||||
|
||||
// 需要删除的
|
||||
List<Integer> toDelete = existingFaultParts.stream()
|
||||
.filter(part -> !faultPart.contains(part))
|
||||
.toList();
|
||||
// 故障部位处理
|
||||
List<Integer> newParts = ebikeFaultReportDto.getFaultPart();
|
||||
List<Integer> oldParts = ebikeFaultPartService.getFaultPartByReportId(ebikeFaultReportDto.getReportId());
|
||||
|
||||
// 需要新增的
|
||||
List<Integer> toInsert = faultPart.stream()
|
||||
.filter(part -> !existingFaultParts.contains(part))
|
||||
.toList();
|
||||
List<EbikeFaultPart> partsToSave = toInsert.stream()
|
||||
.map(fp -> EbikeFaultPart.builder()
|
||||
.reportId(ebikeFaultReportDto.getReportId())
|
||||
.faultPart(fp)
|
||||
.isDeleted(false)
|
||||
.createBy(ebikeFaultReportDto.getUserId())
|
||||
.build())
|
||||
// 删除:旧有但新数据没有的
|
||||
List<Integer> toDelete = oldParts.stream()
|
||||
.filter(part -> !newParts.contains(part))
|
||||
.toList();
|
||||
if (!toDelete.isEmpty()) {
|
||||
ebikeFaultPartService.removeByIds(toDelete);
|
||||
}
|
||||
if (!partsToSave.isEmpty()) {
|
||||
ebikeFaultPartService.saveBatch(partsToSave);
|
||||
|
||||
// 新增:新有但旧数据没有的
|
||||
List<Integer> toInsertParts = newParts.stream()
|
||||
.filter(part -> !oldParts.contains(part))
|
||||
.toList();
|
||||
if (!toInsertParts.isEmpty()) {
|
||||
List<EbikeFaultPart> parts = toInsertParts.stream()
|
||||
.map(fp -> EbikeFaultPart.builder()
|
||||
.reportId(ebikeFaultReportDto.getReportId())
|
||||
.faultPart(fp)
|
||||
.isDeleted(false)
|
||||
.createBy(ebikeFaultReportDto.getUserId())
|
||||
.build())
|
||||
.toList();
|
||||
ebikeFaultPartService.saveBatch(parts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user