From 9fbb74f0a2d82647b8882a88e91a67bf75518464 Mon Sep 17 00:00:00 2001 From: lihongjie0209 Date: Sun, 25 May 2025 10:52:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(coalWashingDailyAnalysis):=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20KF=20=E9=A1=B9=E7=9B=AE=E7=9B=B8=E5=85=B3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 CoalWashingDailyAnalysisKFItem 相关的实体、DTO、Mapper 和 Service - 在 CoalWashingDailyAnalysis 中集成 KF 项目 - 优化 CoalWashingDailyAnalysis 的创建、更新和列表展示功能 --- .../CoalWashingDailyAnalysisController.java | 7 +- .../dto/CoalWashingDailyAnalysisDto.java | 3 + .../dto/CoalWashingDailyAnalysisListDto.java | 113 ++++++++++++++++++ .../CoalWashingDailyAnalysisEntity.java | 6 + .../CoalWashingDailyAnalysisMapper.java | 5 +- .../CoalWashingDailyAnalysisService.java | 90 +++++++++----- ...lWashingDailyAnalysisKFItemController.java | 56 +++++++++ .../CoalWashingDailyAnalysisKFItemDto.java | 8 ++ ...eateCoalWashingDailyAnalysisKFItemDto.java | 8 ++ ...dateCoalWashingDailyAnalysisKFItemDto.java | 8 ++ .../CoalWashingDailyAnalysisKFItemEntity.java | 58 +++++++++ .../CoalWashingDailyAnalysisKFItemMapper.java | 23 ++++ ...lWashingDailyAnalysisKFItemRepository.java | 19 +++ ...CoalWashingDailyAnalysisKFItemService.java | 84 +++++++++++++ .../coalWashingDailyAnalysisKFItemDict.groovy | 19 +++ 15 files changed, 472 insertions(+), 35 deletions(-) create mode 100644 src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/dto/CoalWashingDailyAnalysisListDto.java create mode 100644 src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/controller/CoalWashingDailyAnalysisKFItemController.java create mode 100644 src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/CoalWashingDailyAnalysisKFItemDto.java create mode 100644 src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/CreateCoalWashingDailyAnalysisKFItemDto.java create mode 100644 src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/UpdateCoalWashingDailyAnalysisKFItemDto.java create mode 100644 src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/entity/CoalWashingDailyAnalysisKFItemEntity.java create mode 100644 src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/mapper/CoalWashingDailyAnalysisKFItemMapper.java create mode 100644 src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/repository/CoalWashingDailyAnalysisKFItemRepository.java create mode 100644 src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/service/CoalWashingDailyAnalysisKFItemService.java create mode 100644 src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisKFItemDict.groovy diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/controller/CoalWashingDailyAnalysisController.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/controller/CoalWashingDailyAnalysisController.java index fb38cf77..6988fb72 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/controller/CoalWashingDailyAnalysisController.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/controller/CoalWashingDailyAnalysisController.java @@ -5,10 +5,7 @@ import cn.lihongjie.coal.annotation.SysLog; import cn.lihongjie.coal.base.controller.BaseController; import cn.lihongjie.coal.base.dto.CommonQuery; import cn.lihongjie.coal.base.dto.IdRequest; -import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisCoalReportRequest; -import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisDto; -import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CreateCoalWashingDailyAnalysisDto; -import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.UpdateCoalWashingDailyAnalysisDto; +import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.*; import cn.lihongjie.coal.coalWashingDailyAnalysis.service.CoalWashingDailyAnalysisService; import cn.lihongjie.coal.sse.service.SseService; @@ -92,7 +89,7 @@ public class CoalWashingDailyAnalysisController extends BaseController { } @PostMapping("/list") - public Page list(@RequestBody CommonQuery dto) { + public Page list(@RequestBody CommonQuery dto) { return this.service.list(dto); } diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/dto/CoalWashingDailyAnalysisDto.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/dto/CoalWashingDailyAnalysisDto.java index aef09e05..9eb049a1 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/dto/CoalWashingDailyAnalysisDto.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/dto/CoalWashingDailyAnalysisDto.java @@ -57,6 +57,9 @@ public class CoalWashingDailyAnalysisDto extends OrgCommonDto { @CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) private List kfItems; + + + // @ElementCollection // @Comment("连续平均值") // @CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/dto/CoalWashingDailyAnalysisListDto.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/dto/CoalWashingDailyAnalysisListDto.java new file mode 100644 index 00000000..57c0740e --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/dto/CoalWashingDailyAnalysisListDto.java @@ -0,0 +1,113 @@ +package cn.lihongjie.coal.coalWashingDailyAnalysis.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; +import cn.lihongjie.coal.common.DictCode; +import cn.lihongjie.coal.pojoProcessor.DictTranslate; +import cn.lihongjie.coal.product.dto.ProductDto; + +import jakarta.persistence.*; + +import lombok.Data; + +import org.hibernate.annotations.Comment; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** */ +@Data +@Comment("洗煤报告表") +public class CoalWashingDailyAnalysisListDto extends OrgCommonDto { + + @Comment("日期") + private LocalDate date; + + @ManyToOne + @Comment("产品信息") + private ProductDto product; + + @Comment("归档状态") + private String archiveStatus; + @DictTranslate(dictKey = DictCode.ARCHIVESTATUS) + private String archiveStatusName; + + @Comment("开机时间") + private LocalDateTime startTime; + + @Comment("停机时间") + private LocalDateTime endTime; + + @Comment("运行时长(小时)") + private Double runHours; + @Comment("皮带秤设备组") + private String pdcDeviceGroup; + + +// @ElementCollection +// @CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) +// private List inputItems; +// private List ymDetails; +// +// @ElementCollection +// @CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) +// private List kfItems; + + // @ElementCollection + // @Comment("连续平均值") + // @CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) + // private List rollingAvgItems; + +// @ElementCollection +// @CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) +// private List paramsInfo; + + @Comment("目标大堆 灰") + private Double ddp1; + + @Comment("目标大堆 灰") + private Double ddp1Min; + + @Comment("目标大堆 硫") + private Double ddp2Min; + + @Comment("目标大堆 挥发") + private Double ddp3Min; + + @Comment("目标大堆 粘结") + private Double ddp4Min; + + @Comment("目标大堆 备用") + private Double ddp5Min; + + @Comment("目标大堆 灰") + private Double ddp1Max; + + @Comment("目标大堆 硫") + private Double ddp2Max; + + @Comment("目标大堆 挥发") + private Double ddp3Max; + + @Comment("目标大堆 粘结") + private Double ddp4Max; + + @Comment("目标大堆 备用") + private Double ddp5Max; + + @Comment("产量初始值") + private Double initTotalNumber = 0.0; + + private String remark1; + private String remark2; + private String remark3; + private String remark4; + private String remark5; + private String remark6; + private String remark7; + private String remark8; + private String remark9; + private String remark10; + private String remark11; + private String remark12; + +} diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/entity/CoalWashingDailyAnalysisEntity.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/entity/CoalWashingDailyAnalysisEntity.java index 4919f6ac..4fc5eb5a 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/entity/CoalWashingDailyAnalysisEntity.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/entity/CoalWashingDailyAnalysisEntity.java @@ -1,6 +1,7 @@ package cn.lihongjie.coal.coalWashingDailyAnalysis.entity; import cn.lihongjie.coal.base.entity.OrgCommonEntity; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.entity.CoalWashingDailyAnalysisKFItemEntity; import cn.lihongjie.coal.exception.BizException; import cn.lihongjie.coal.product.entity.ProductEntity; @@ -76,6 +77,11 @@ public class CoalWashingDailyAnalysisEntity extends OrgCommonEntity { @Fetch(FetchMode.SUBSELECT) private List kfItems; + + @OneToMany(mappedBy = "coalWashingDailyAnalysis") + private List kfItemsNew; + + // @ElementCollection // @Comment("连续平均值") // @CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/mapper/CoalWashingDailyAnalysisMapper.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/mapper/CoalWashingDailyAnalysisMapper.java index ec649293..f3d5d69b 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/mapper/CoalWashingDailyAnalysisMapper.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/mapper/CoalWashingDailyAnalysisMapper.java @@ -2,6 +2,7 @@ package cn.lihongjie.coal.coalWashingDailyAnalysis.mapper; import cn.lihongjie.coal.base.mapper.BaseMapper; import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisDto; +import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisListDto; import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CreateCoalWashingDailyAnalysisDto; import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.UpdateCoalWashingDailyAnalysisDto; import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity; @@ -19,4 +20,6 @@ public interface CoalWashingDailyAnalysisMapper CoalWashingDailyAnalysisEntity, CoalWashingDailyAnalysisDto, CreateCoalWashingDailyAnalysisDto, - UpdateCoalWashingDailyAnalysisDto> {} + UpdateCoalWashingDailyAnalysisDto> { + CoalWashingDailyAnalysisListDto toListDto(CoalWashingDailyAnalysisEntity coalWashingDailyAnalysisEntity); +} diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java index a988a264..d5960cc7 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java @@ -4,15 +4,14 @@ import cn.hutool.core.bean.BeanUtil; import cn.lihongjie.coal.base.dto.CommonQuery; import cn.lihongjie.coal.base.dto.IdRequest; import cn.lihongjie.coal.base.service.BaseService; -import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisCoalReportRequest; -import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisDto; -import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CreateCoalWashingDailyAnalysisDto; -import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.UpdateCoalWashingDailyAnalysisDto; +import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.*; import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity; import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisKFItemVo; import cn.lihongjie.coal.coalWashingDailyAnalysis.mapper.CoalWashingDailyAnalysisMapper; import cn.lihongjie.coal.coalWashingDailyAnalysis.mapper.RoundMapper; import cn.lihongjie.coal.coalWashingDailyAnalysis.repository.CoalWashingDailyAnalysisRepository; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.entity.CoalWashingDailyAnalysisKFItemEntity; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.repository.CoalWashingDailyAnalysisKFItemRepository; import cn.lihongjie.coal.common.Ctx; import cn.lihongjie.coal.common.FreeMakerUtils; import cn.lihongjie.coal.common.JpaUtils; @@ -59,6 +58,8 @@ public class CoalWashingDailyAnalysisService @Autowired RoundMapper roundMapper; @Autowired ConversionService conversionService; + @Autowired CoalWashingDailyAnalysisKFItemRepository kfItemRepository; + @PostConstruct public void init() {} @@ -128,12 +129,45 @@ public class CoalWashingDailyAnalysisService } this.repository.save(entity); - sseService.broadcast("coalWashingDailyAnalysis." + entity.getId(), ImmutableMap.of("id", entity.getId(), "event", "update", "sessionId", Ctx.getSessionIdMd5())); + if (CollectionUtils.isNotEmpty(request.getKfItems())) { + + + + synchronizeKfItems(entity, request.getKfItems()); + + + + } + + sseService.broadcast( + "coalWashingDailyAnalysis." + entity.getId(), + ImmutableMap.of( + "id", + entity.getId(), + "event", + "update", + "sessionId", + Ctx.getSessionIdMd5())); return getById(entity.getId()); } + private void synchronizeKfItems(CoalWashingDailyAnalysisEntity entity, List kfItems) { + kfItemRepository.deleteAllByCoalWashingDailyAnalysis(entity); + + List list = BeanUtil.copyToList(kfItems, CoalWashingDailyAnalysisKFItemEntity.class); + + list.forEach( + item -> { + item.setCoalWashingDailyAnalysis(entity); + item.setOrganizationId(Ctx.activeOrganizationId()); + }); + + if (CollectionUtils.isNotEmpty(list)) { + kfItemRepository.saveAll(list); + } + } public CoalWashingDailyAnalysisDto updateKfItems(UpdateCoalWashingDailyAnalysisDto request) { @@ -143,8 +177,6 @@ public class CoalWashingDailyAnalysisService throw new BizException("部分数据已归档,无法编辑或删除"); } - - entity.setKfItems(request.getKfItems()); entity.setOrganizationId(Ctx.activeOrganizationId()); @@ -155,13 +187,19 @@ public class CoalWashingDailyAnalysisService entity.setName(productService.get(entity.getProduct().getId()).getName()); } this.repository.save(entity); - sseService.broadcast("coalWashingDailyAnalysis." + entity.getId(), ImmutableMap.of("id", entity.getId(), "event", "updateKfItems", "sessionId", Ctx.getSessionIdMd5())); + sseService.broadcast( + "coalWashingDailyAnalysis." + entity.getId(), + ImmutableMap.of( + "id", + entity.getId(), + "event", + "updateKfItems", + "sessionId", + Ctx.getSessionIdMd5())); return getById(entity.getId()); } - - public CoalWashingDailyAnalysisDto updateMain(UpdateCoalWashingDailyAnalysisDto request) { CoalWashingDailyAnalysisEntity entity = this.repository.get(request.getId()); @@ -173,7 +211,6 @@ public class CoalWashingDailyAnalysisService } this.mapper.updateEntity(entity, request); - entity.setKfItems(kfItems); entity.setOrganizationId(Ctx.activeOrganizationId()); @@ -184,23 +221,19 @@ public class CoalWashingDailyAnalysisService entity.setName(productService.get(entity.getProduct().getId()).getName()); } this.repository.save(entity); - sseService.broadcast("coalWashingDailyAnalysis." + entity.getId(), ImmutableMap.of("id", entity.getId(), "event", "updateMain", "sessionId", Ctx.getSessionIdMd5())); + sseService.broadcast( + "coalWashingDailyAnalysis." + entity.getId(), + ImmutableMap.of( + "id", + entity.getId(), + "event", + "updateMain", + "sessionId", + Ctx.getSessionIdMd5())); return getById(entity.getId()); } - - - - - - - - - - - - public void delete(IdRequest request) { if (this.repository.containArchived(request)) { @@ -209,12 +242,11 @@ public class CoalWashingDailyAnalysisService this.repository.deleteAllById(request.getIds()); - for (String id : request.getIds()) { - sseService.broadcast("coalWashingDailyAnalysis." + id, ImmutableMap.of("id", id, "event", "delete")); + sseService.broadcast( + "coalWashingDailyAnalysis." + id, ImmutableMap.of("id", id, "event", "delete")); } - } public CoalWashingDailyAnalysisDto getById(String id) { @@ -224,7 +256,7 @@ public class CoalWashingDailyAnalysisService return mapper.toDto(entity); } - public Page list(CommonQuery query) { + public Page list(CommonQuery query) { Page page = repository.findAll( @@ -234,7 +266,7 @@ public class CoalWashingDailyAnalysisService query.getPageSize(), Sort.by(query.getOrders()))); - return page.map(this.mapper::toDto); + return page.map(this.mapper::toListDto); } public void archive(IdRequest dto) { diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/controller/CoalWashingDailyAnalysisKFItemController.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/controller/CoalWashingDailyAnalysisKFItemController.java new file mode 100644 index 00000000..d401b5d9 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/controller/CoalWashingDailyAnalysisKFItemController.java @@ -0,0 +1,56 @@ +package cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.controller; + +import cn.lihongjie.coal.annotation.OrgScope; +import cn.lihongjie.coal.annotation.SysLog; +import cn.lihongjie.coal.base.dto.CommonQuery; +import cn.lihongjie.coal.base.dto.IdRequest; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto.CoalWashingDailyAnalysisKFItemDto; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto.CreateCoalWashingDailyAnalysisKFItemDto; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto.UpdateCoalWashingDailyAnalysisKFItemDto; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.service.CoalWashingDailyAnalysisKFItemService; + +import lombok.extern.slf4j.Slf4j; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/coalWashingDailyAnalysisKFItem") +@SysLog(module = "") +@Slf4j +@OrgScope +public class CoalWashingDailyAnalysisKFItemController { + @Autowired private CoalWashingDailyAnalysisKFItemService service; + + @PostMapping("/create") + public CoalWashingDailyAnalysisKFItemDto create( + @RequestBody CreateCoalWashingDailyAnalysisKFItemDto request) { + return this.service.create(request); + } + + @PostMapping("/update") + public CoalWashingDailyAnalysisKFItemDto update( + @RequestBody UpdateCoalWashingDailyAnalysisKFItemDto request) { + return this.service.update(request); + } + + @PostMapping("/delete") + public Object delete(@RequestBody IdRequest request) { + this.service.delete(request); + return true; + } + + @PostMapping("/getById") + public CoalWashingDailyAnalysisKFItemDto getById(@RequestBody IdRequest request) { + return this.service.getById(request.getId()); + } + + @PostMapping("/list") + public Page list(@RequestBody CommonQuery request) { + return this.service.list(request); + } +} diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/CoalWashingDailyAnalysisKFItemDto.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/CoalWashingDailyAnalysisKFItemDto.java new file mode 100644 index 00000000..a8388295 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/CoalWashingDailyAnalysisKFItemDto.java @@ -0,0 +1,8 @@ +package cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; + +import lombok.Data; + +@Data +public class CoalWashingDailyAnalysisKFItemDto extends OrgCommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/CreateCoalWashingDailyAnalysisKFItemDto.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/CreateCoalWashingDailyAnalysisKFItemDto.java new file mode 100644 index 00000000..7adda5b9 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/CreateCoalWashingDailyAnalysisKFItemDto.java @@ -0,0 +1,8 @@ +package cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; + +import lombok.Data; + +@Data +public class CreateCoalWashingDailyAnalysisKFItemDto extends OrgCommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/UpdateCoalWashingDailyAnalysisKFItemDto.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/UpdateCoalWashingDailyAnalysisKFItemDto.java new file mode 100644 index 00000000..2c3bc9df --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/dto/UpdateCoalWashingDailyAnalysisKFItemDto.java @@ -0,0 +1,8 @@ +package cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto; + +import cn.lihongjie.coal.base.dto.OrgCommonDto; + +import lombok.Data; + +@Data +public class UpdateCoalWashingDailyAnalysisKFItemDto extends OrgCommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/entity/CoalWashingDailyAnalysisKFItemEntity.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/entity/CoalWashingDailyAnalysisKFItemEntity.java new file mode 100644 index 00000000..6bee5538 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/entity/CoalWashingDailyAnalysisKFItemEntity.java @@ -0,0 +1,58 @@ +package cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.entity; + +import cn.lihongjie.coal.base.entity.OrgCommonEntity; +import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity; + +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalTime; + +@Data +@Entity +@Table( + indexes = + @jakarta.persistence.Index( + name = "idx_coalWashingDailyAnalysisKFItem_org_id", + columnList = "organization_id")) +public class CoalWashingDailyAnalysisKFItemEntity extends OrgCommonEntity { + + + @ManyToOne + private CoalWashingDailyAnalysisEntity coalWashingDailyAnalysis; + + private LocalDate date; + private LocalTime time; + + private String name; + private Double param1; + private Double param2; + private Double param3; + private Double param4; + private Double param5; + private Double param6; + private Double param7; + private Double param8; + private Double param9; + private Double param10; + private Double param11; + private Double param12; + private Double param13; + private Double param14; + private Double param15; + private Double param16; + private Double param17; + private Double param18; + private Double param19; + private Double param20; + + private String remark1; + private String remark2; + private String remark3; + private String remark4; + +} diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/mapper/CoalWashingDailyAnalysisKFItemMapper.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/mapper/CoalWashingDailyAnalysisKFItemMapper.java new file mode 100644 index 00000000..b421830b --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/mapper/CoalWashingDailyAnalysisKFItemMapper.java @@ -0,0 +1,23 @@ +package cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.mapper; + +import cn.lihongjie.coal.base.mapper.BaseMapper; +import cn.lihongjie.coal.base.mapper.CommonEntityMapper; +import cn.lihongjie.coal.base.mapper.CommonMapper; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto.CoalWashingDailyAnalysisKFItemDto; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto.CreateCoalWashingDailyAnalysisKFItemDto; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto.UpdateCoalWashingDailyAnalysisKFItemDto; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.entity.CoalWashingDailyAnalysisKFItemEntity; + +import org.mapstruct.Mapper; +import org.mapstruct.control.DeepClone; + +@Mapper( + componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING, + uses = {CommonMapper.class, CommonEntityMapper.class}, + mappingControl = DeepClone.class) +public interface CoalWashingDailyAnalysisKFItemMapper + extends BaseMapper< + CoalWashingDailyAnalysisKFItemEntity, + CoalWashingDailyAnalysisKFItemDto, + CreateCoalWashingDailyAnalysisKFItemDto, + UpdateCoalWashingDailyAnalysisKFItemDto> {} diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/repository/CoalWashingDailyAnalysisKFItemRepository.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/repository/CoalWashingDailyAnalysisKFItemRepository.java new file mode 100644 index 00000000..d4f1648d --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/repository/CoalWashingDailyAnalysisKFItemRepository.java @@ -0,0 +1,19 @@ +package cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.repository; + +import cn.lihongjie.coal.base.dao.BaseRepository; +import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.entity.CoalWashingDailyAnalysisKFItemEntity; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface CoalWashingDailyAnalysisKFItemRepository + extends BaseRepository { + @Query("select false") + boolean isLinked(List ids); + + void deleteAllByCoalWashingDailyAnalysis(CoalWashingDailyAnalysisEntity entity); +} diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/service/CoalWashingDailyAnalysisKFItemService.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/service/CoalWashingDailyAnalysisKFItemService.java new file mode 100644 index 00000000..ec6b69a2 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysisKFItem/service/CoalWashingDailyAnalysisKFItemService.java @@ -0,0 +1,84 @@ +package cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.service; + +import cn.lihongjie.coal.base.dto.CommonQuery; +import cn.lihongjie.coal.base.dto.IdRequest; +import cn.lihongjie.coal.base.service.BaseService; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto.CoalWashingDailyAnalysisKFItemDto; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto.CreateCoalWashingDailyAnalysisKFItemDto; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.dto.UpdateCoalWashingDailyAnalysisKFItemDto; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.entity.CoalWashingDailyAnalysisKFItemEntity; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.mapper.CoalWashingDailyAnalysisKFItemMapper; +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.repository.CoalWashingDailyAnalysisKFItemRepository; +import cn.lihongjie.coal.dbFunctions.DbFunctionService; +import cn.lihongjie.coal.exception.BizException; + +import lombok.extern.slf4j.Slf4j; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.convert.ConversionService; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Slf4j +@Transactional +public class CoalWashingDailyAnalysisKFItemService + extends BaseService< + CoalWashingDailyAnalysisKFItemEntity, CoalWashingDailyAnalysisKFItemRepository> { + @Autowired private CoalWashingDailyAnalysisKFItemRepository repository; + + @Autowired private CoalWashingDailyAnalysisKFItemMapper mapper; + + @Autowired private ConversionService conversionService; + + @Autowired private DbFunctionService dbFunctionService; + + public CoalWashingDailyAnalysisKFItemDto create( + CreateCoalWashingDailyAnalysisKFItemDto request) { + CoalWashingDailyAnalysisKFItemEntity entity = mapper.toEntity(request); + + this.repository.save(entity); + return getById(entity.getId()); + } + + public CoalWashingDailyAnalysisKFItemDto update( + UpdateCoalWashingDailyAnalysisKFItemDto request) { + CoalWashingDailyAnalysisKFItemEntity entity = this.repository.get(request.getId()); + this.mapper.updateEntity(entity, request); + + this.repository.save(entity); + + return getById(entity.getId()); + } + + public void delete(IdRequest request) { + boolean linked = this.repository.isLinked(request.getIds()); + + if (linked) { + throw new BizException("数据已被关联,无法删除"); + } + + this.repository.deleteAllById(request.getIds()); + } + + public CoalWashingDailyAnalysisKFItemDto getById(String id) { + CoalWashingDailyAnalysisKFItemEntity entity = repository.get(id); + + return mapper.toDto(entity); + } + + public Page list(CommonQuery query) { + Page page = + repository.findAll( + query.specification(conversionService), + PageRequest.of( + query.getPageNo(), + query.getPageSize(), + Sort.by(query.getOrders()))); + + return page.map(this.mapper::toDto); + } +} diff --git a/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisKFItemDict.groovy b/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisKFItemDict.groovy new file mode 100644 index 00000000..a1ec7069 --- /dev/null +++ b/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisKFItemDict.groovy @@ -0,0 +1,19 @@ + +package scripts.dict + +import cn.lihongjie.coal.base.dto.CommonQuery +import cn.lihongjie.coal.coalWashingDailyAnalysisKFItem.controller.CoalWashingDailyAnalysisKFItemController +import com.fasterxml.jackson.databind.ObjectMapper +import org.springframework.context.ApplicationContext + +ApplicationContext ioc = ioc + +def controller = ioc.getBean(CoalWashingDailyAnalysisKFItemController.class) +def objectMapper = ioc.getBean(ObjectMapper.class) as ObjectMapper + + + + +return controller.list(params!=null ? objectMapper.convertValue(params, CommonQuery.class ) : new CommonQuery()) + +