diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/CreateWarehouseGoodsDto.java b/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/CreateWarehouseGoodsDto.java index 13960911..85cc9fa5 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/CreateWarehouseGoodsDto.java +++ b/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/CreateWarehouseGoodsDto.java @@ -60,4 +60,12 @@ public class CreateWarehouseGoodsDto extends OrgCommonDto { @Comment("批发价") private Double price4; private Double price5; + + @Comment("是否启用保质期") + + private Boolean enableShelfLife; + + + @Comment("保质期 天") + private Integer shelfLife; } diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/UpdateWarehouseGoodsDto.java b/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/UpdateWarehouseGoodsDto.java index b23a5fad..1988eec2 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/UpdateWarehouseGoodsDto.java +++ b/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/UpdateWarehouseGoodsDto.java @@ -58,4 +58,12 @@ public class UpdateWarehouseGoodsDto extends OrgCommonDto { @Comment("批发价") private Double price4; private Double price5; + + @Comment("是否启用保质期") + + private Boolean enableShelfLife; + + + @Comment("保质期 天") + private Integer shelfLife; } diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/WarehouseGoodsDto.java b/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/WarehouseGoodsDto.java index 5b7400e5..002784bb 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/WarehouseGoodsDto.java +++ b/src/main/java/cn/lihongjie/coal/warehouseGoods/dto/WarehouseGoodsDto.java @@ -59,4 +59,13 @@ public class WarehouseGoodsDto extends OrgCommonDto { @Comment("批发价") private Double price4; private Double price5; + + + @Comment("是否启用保质期") + + private Boolean enableShelfLife; + + + @Comment("保质期 天") + private Integer shelfLife; } diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoods/entity/WarehouseGoodsEntity.java b/src/main/java/cn/lihongjie/coal/warehouseGoods/entity/WarehouseGoodsEntity.java index 44f8c7c2..56e2ba92 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseGoods/entity/WarehouseGoodsEntity.java +++ b/src/main/java/cn/lihongjie/coal/warehouseGoods/entity/WarehouseGoodsEntity.java @@ -70,6 +70,16 @@ public class WarehouseGoodsEntity extends OrgCommonEntity { private Double price4; private Double price5; + + + @Comment("是否启用保质期") + + private Boolean enableShelfLife; + + + @Comment("保质期 天") + private Integer shelfLife; + // @Comment("是否启用属性") // private Boolean enableAttribute; // diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/controller/WarehouseGoodsSummaryController.java b/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/controller/WarehouseGoodsSummaryController.java deleted file mode 100644 index d3fb0917..00000000 --- a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/controller/WarehouseGoodsSummaryController.java +++ /dev/null @@ -1,54 +0,0 @@ -//package cn.lihongjie.coal.warehouseGoodsSummary.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.warehouseGoodsSummary.dto.CreateWarehouseGoodsSummaryDto; -//import cn.lihongjie.coal.warehouseGoodsSummary.dto.UpdateWarehouseGoodsSummaryDto; -//import cn.lihongjie.coal.warehouseGoodsSummary.dto.WarehouseGoodsSummaryDto; -//import cn.lihongjie.coal.warehouseGoodsSummary.service.WarehouseGoodsSummaryService; -// -//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("/warehouseGoodsSummary") -//@SysLog(module = "仓库商品统计") -//@Slf4j -//@OrgScope -//public class WarehouseGoodsSummaryController { -// @Autowired private WarehouseGoodsSummaryService service; -// -// @PostMapping("/create") -// public WarehouseGoodsSummaryDto create(@RequestBody CreateWarehouseGoodsSummaryDto request) { -// return this.service.create(request); -// } -// -// @PostMapping("/update") -// public WarehouseGoodsSummaryDto update(@RequestBody UpdateWarehouseGoodsSummaryDto request) { -// return this.service.update(request); -// } -// -// @PostMapping("/delete") -// public Object delete(@RequestBody IdRequest request) { -// this.service.delete(request); -// return true; -// } -// -// @PostMapping("/getById") -// public WarehouseGoodsSummaryDto 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/warehouseGoodsSummary/dto/CreateWarehouseGoodsSummaryDto.java b/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/dto/CreateWarehouseGoodsSummaryDto.java deleted file mode 100644 index ce2ca8fb..00000000 --- a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/dto/CreateWarehouseGoodsSummaryDto.java +++ /dev/null @@ -1,8 +0,0 @@ -package cn.lihongjie.coal.warehouseGoodsSummary.dto; - -import cn.lihongjie.coal.base.dto.OrgCommonDto; - -import lombok.Data; - -@Data -public class CreateWarehouseGoodsSummaryDto extends OrgCommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/dto/UpdateWarehouseGoodsSummaryDto.java b/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/dto/UpdateWarehouseGoodsSummaryDto.java deleted file mode 100644 index 734a6412..00000000 --- a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/dto/UpdateWarehouseGoodsSummaryDto.java +++ /dev/null @@ -1,8 +0,0 @@ -package cn.lihongjie.coal.warehouseGoodsSummary.dto; - -import cn.lihongjie.coal.base.dto.OrgCommonDto; - -import lombok.Data; - -@Data -public class UpdateWarehouseGoodsSummaryDto extends OrgCommonDto {} diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/dto/WarehouseGoodsSummaryDto.java b/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/dto/WarehouseGoodsSummaryDto.java deleted file mode 100644 index bc287db7..00000000 --- a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/dto/WarehouseGoodsSummaryDto.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.lihongjie.coal.warehouseGoodsSummary.dto; - -import cn.lihongjie.coal.base.dto.OrgCommonDto; -import cn.lihongjie.coal.warehouse.dto.WarehouseDto; -import cn.lihongjie.coal.warehouseGoods.dto.WarehouseGoodsDto; -import cn.lihongjie.coal.warehouseReceipt.dto.WarehouseReceiptDto; -import cn.lihongjie.coal.warehouseShelve.dto.WarehouseShelveDto; - -import jakarta.persistence.ManyToOne; - -import lombok.Data; - -import org.hibernate.annotations.Comment; -import org.hibernate.annotations.Formula; - -@Data -public class WarehouseGoodsSummaryDto extends OrgCommonDto { - - @ManyToOne - private WarehouseGoodsDto goods; - - - - - @ManyToOne - private WarehouseDto warehouse; - - @ManyToOne - private WarehouseShelveDto shelve; - - @ManyToOne - private WarehouseReceiptDto receipt; - - @Comment("数量") - private Double number; - - - @Comment("单价") - private Double price; - - - @Formula("(number * price)") - private Double amount; -} diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/entity/WarehouseGoodsSummaryEntity.java b/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/entity/WarehouseGoodsSummaryEntity.java deleted file mode 100644 index 36eecd07..00000000 --- a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/entity/WarehouseGoodsSummaryEntity.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.lihongjie.coal.warehouseGoodsSummary.entity; - -import cn.lihongjie.coal.base.entity.OrgCommonEntity; -import cn.lihongjie.coal.warehouse.entity.WarehouseEntity; -import cn.lihongjie.coal.warehouseGoods.entity.WarehouseGoodsEntity; -import cn.lihongjie.coal.warehouseReceipt.entity.WarehouseReceiptEntity; -import cn.lihongjie.coal.warehouseShelve.entity.WarehouseShelveEntity; - -import jakarta.persistence.Entity; -import jakarta.persistence.ManyToOne; - -import lombok.Data; - -import org.hibernate.annotations.Comment; -import org.hibernate.annotations.Formula; - -@Data -@Entity - -@jakarta.persistence.Table(indexes = @jakarta.persistence.Index(name ="idx_warehouse_goods_summary_org_id", columnList = "organization_id")) - -public class WarehouseGoodsSummaryEntity extends OrgCommonEntity { - - - @ManyToOne - private WarehouseGoodsEntity goods; - - - - - @ManyToOne - private WarehouseEntity warehouse; - - @ManyToOne - private WarehouseShelveEntity shelve; - - @ManyToOne - private WarehouseReceiptEntity receipt; - - @Comment("数量") - private Double number; - - - @Comment("单价") - private Double price; - - - @Formula("(number * price)") - private Double amount; - -} \ No newline at end of file diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/mapper/WarehouseGoodsSummaryMapper.java b/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/mapper/WarehouseGoodsSummaryMapper.java deleted file mode 100644 index 40abd48b..00000000 --- a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/mapper/WarehouseGoodsSummaryMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.lihongjie.coal.warehouseGoodsSummary.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.warehouseGoodsSummary.dto.CreateWarehouseGoodsSummaryDto; -import cn.lihongjie.coal.warehouseGoodsSummary.dto.UpdateWarehouseGoodsSummaryDto; -import cn.lihongjie.coal.warehouseGoodsSummary.dto.WarehouseGoodsSummaryDto; -import cn.lihongjie.coal.warehouseGoodsSummary.entity.WarehouseGoodsSummaryEntity; - -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 WarehouseGoodsSummaryMapper - extends BaseMapper< - WarehouseGoodsSummaryEntity, - WarehouseGoodsSummaryDto, - CreateWarehouseGoodsSummaryDto, - UpdateWarehouseGoodsSummaryDto> {} diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/repository/WarehouseGoodsSummaryRepository.java b/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/repository/WarehouseGoodsSummaryRepository.java deleted file mode 100644 index 5ef21595..00000000 --- a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/repository/WarehouseGoodsSummaryRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.lihongjie.coal.warehouseGoodsSummary.repository; - -import cn.lihongjie.coal.base.dao.BaseRepository; -import cn.lihongjie.coal.warehouseGoodsSummary.entity.WarehouseGoodsSummaryEntity; - -import org.springframework.data.jpa.repository.Query; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.Set; - -@Repository -public interface WarehouseGoodsSummaryRepository - extends BaseRepository { - - @Query("select w from WarehouseGoodsSummaryEntity w where w.warehouse.id in ?1 and w.shelve.id in ?2 and w.goods.id in ?3 ") - List findAllByWarehouseIdInAndShelveIdInAndGoodsIdIn(Set warehouseIds, Set shelveIds, Set goodsIds); -} diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/service/WarehouseGoodsSummaryService.java b/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/service/WarehouseGoodsSummaryService.java deleted file mode 100644 index f960d220..00000000 --- a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/service/WarehouseGoodsSummaryService.java +++ /dev/null @@ -1,147 +0,0 @@ -//package cn.lihongjie.coal.warehouseGoodsSummary.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.warehouseGoodsSummary.dto.CreateWarehouseGoodsSummaryDto; -//import cn.lihongjie.coal.warehouseGoodsSummary.dto.UpdateWarehouseGoodsSummaryDto; -//import cn.lihongjie.coal.warehouseGoodsSummary.dto.WarehouseGoodsSummaryDto; -//import cn.lihongjie.coal.warehouseGoodsSummary.entity.WarehouseGoodsSummaryEntity; -//import cn.lihongjie.coal.warehouseGoodsSummary.mapper.WarehouseGoodsSummaryMapper; -//import cn.lihongjie.coal.warehouseGoodsSummary.repository.WarehouseGoodsSummaryRepository; -//import cn.lihongjie.coal.warehouseReceipt.entity.WarehouseReceiptEntity; -//import cn.lihongjie.coal.warehouseReceipt.repository.WarehouseReceiptRepository; -//import cn.lihongjie.coal.warehouseReceiptDetail.repository.WarehouseReceiptDetailRepository; -// -//import io.vavr.Tuple; -//import io.vavr.Tuple2; -// -//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; -// -//import java.util.HashMap; -//import java.util.List; -//import java.util.Map; -//import java.util.stream.Collectors; -// -//@Service -//@Slf4j -//@Transactional -//public class WarehouseGoodsSummaryService -// extends BaseService { -// @Autowired private WarehouseGoodsSummaryRepository repository; -// -// @Autowired private WarehouseGoodsSummaryMapper mapper; -// -// @Autowired private ConversionService conversionService; -// @Autowired private WarehouseReceiptDetailRepository warehouseReceiptDetailRepository; -// @Autowired private WarehouseReceiptRepository warehouseReceiptRepository; -// -// public WarehouseGoodsSummaryDto create(CreateWarehouseGoodsSummaryDto request) { -// WarehouseGoodsSummaryEntity entity = mapper.toEntity(request); -// -// this.repository.save(entity); -// return getById(entity.getId()); -// } -// -// public WarehouseGoodsSummaryDto update(UpdateWarehouseGoodsSummaryDto request) { -// WarehouseGoodsSummaryEntity entity = this.repository.get(request.getId()); -// this.mapper.updateEntity(entity, request); -// -// this.repository.save(entity); -// -// return getById(entity.getId()); -// } -// -// public void delete(IdRequest request) { -// this.repository.deleteAllById(request.getIds()); -// } -// -// public WarehouseGoodsSummaryDto getById(String id) { -// WarehouseGoodsSummaryEntity 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); -// } -// -// public void refresh(List receipt) { -// -// var warehouseIds = -// receipt.stream().map(r -> r.getWarehouse().getId()).collect(Collectors.toSet()); -// -// var shelveIds = -// receipt.stream() -// .flatMap(r -> r.getDetail().stream().map(x -> x.getShelve().getId())) -// .collect(Collectors.toSet()); -// var goodsIds = -// receipt.stream() -// .flatMap(r -> r.getDetail().stream().map(x -> x.getGoods().getId())) -// .collect(Collectors.toSet()); -// -// var all = -// warehouseReceiptRepository.findAllByWarehouseIdInAndShelveIdInAndGoodsIdIn( -// warehouseIds, shelveIds, goodsIds); -// -// Map, WarehouseGoodsSummaryEntity> cache = new HashMap<>(); -// -// for (WarehouseReceiptEntity receiptEntity : all) { -// -// for (var detail : receiptEntity.getDetail()) { -// -// WarehouseGoodsSummaryEntity defaultEntity = new WarehouseGoodsSummaryEntity(); -// -// defaultEntity.setWarehouse(receiptEntity.getWarehouse()); -// defaultEntity.setGoods(detail.getGoods()); -// defaultEntity.setShelve(detail.getShelve()); -// defaultEntity.setNumber(0.0); -// defaultEntity.setAmount(0.0); -// WarehouseGoodsSummaryEntity summary = -// cache.getOrDefault( -// Tuple.of(detail.getShelve().getId(), detail.getGoods().getId()), -// defaultEntity); -// -// switch (receiptEntity.getReceiptType()) { -// case "0": -// summary.setNumber(summary.getNumber() + detail.getNumber()); -// summary.setPrice(detail.getPrice()); -// break; -// case "1": -// summary.setNumber(summary.getNumber() - detail.getNumber()); -// summary.setPrice(detail.getPrice()); -// break; -// -// case "2": -// // 调库单不处理, 由调库单的出库和入库单处理 -// break; -// default: -// throw new RuntimeException( -// "unknown receipt type " + receiptEntity.getReceiptType()); -// } -// } -// } -// -// repository.deleteAll( -// repository.findAllByWarehouseIdInAndShelveIdInAndGoodsIdIn( -// warehouseIds, shelveIds, goodsIds)); -// -// repository.saveAll(cache.values()); -// } -//} diff --git a/src/main/java/cn/lihongjie/coal/warehouseReceipt/service/WarehouseReceiptService.java b/src/main/java/cn/lihongjie/coal/warehouseReceipt/service/WarehouseReceiptService.java index cfba2b91..88ff57b8 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseReceipt/service/WarehouseReceiptService.java +++ b/src/main/java/cn/lihongjie/coal/warehouseReceipt/service/WarehouseReceiptService.java @@ -104,7 +104,7 @@ public class WarehouseReceiptService Integer goodsCount = warehouseGoodsService.goodsCount(request); WarehouseGoodsDto goods = warehouseGoodsService.getById(warehouseReceiptDetailEntity.getGoods().getId()); - if (ObjectUtils.notEqual(goodsCount, warehouseReceiptDetailEntity.getNumber())){ + if (ObjectUtils.notEqual(goodsCount, warehouseReceiptDetailEntity.getStock())){ throw new BizException("商品 " + goods.getName() + @@ -248,6 +248,9 @@ public class WarehouseReceiptService // } public void delete(IdRequest request) { + if (this.repository.containArchived(request)){ + throw new BizException("部分数据已归档,无法编辑或删除"); + } List allById = this.repository.findAllById(request.getIds()); this.repository.deleteAllById(request.getIds()); handleType3Delete(allById);