mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
feat: 商品添加保质期
This commit is contained in:
@@ -60,4 +60,12 @@ public class CreateWarehouseGoodsDto extends OrgCommonDto {
|
||||
@Comment("批发价")
|
||||
private Double price4;
|
||||
private Double price5;
|
||||
|
||||
@Comment("是否启用保质期")
|
||||
|
||||
private Boolean enableShelfLife;
|
||||
|
||||
|
||||
@Comment("保质期 天")
|
||||
private Integer shelfLife;
|
||||
}
|
||||
|
||||
@@ -58,4 +58,12 @@ public class UpdateWarehouseGoodsDto extends OrgCommonDto {
|
||||
@Comment("批发价")
|
||||
private Double price4;
|
||||
private Double price5;
|
||||
|
||||
@Comment("是否启用保质期")
|
||||
|
||||
private Boolean enableShelfLife;
|
||||
|
||||
|
||||
@Comment("保质期 天")
|
||||
private Integer shelfLife;
|
||||
}
|
||||
|
||||
@@ -59,4 +59,13 @@ public class WarehouseGoodsDto extends OrgCommonDto {
|
||||
@Comment("批发价")
|
||||
private Double price4;
|
||||
private Double price5;
|
||||
|
||||
|
||||
@Comment("是否启用保质期")
|
||||
|
||||
private Boolean enableShelfLife;
|
||||
|
||||
|
||||
@Comment("保质期 天")
|
||||
private Integer shelfLife;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
//
|
||||
|
||||
@@ -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<WarehouseGoodsSummaryDto> list(@RequestBody CommonQuery request) {
|
||||
// return this.service.list(request);
|
||||
// }
|
||||
//}
|
||||
@@ -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 {}
|
||||
@@ -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 {}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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> {}
|
||||
@@ -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<WarehouseGoodsSummaryEntity> {
|
||||
|
||||
@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<WarehouseGoodsSummaryEntity> findAllByWarehouseIdInAndShelveIdInAndGoodsIdIn(Set<String> warehouseIds, Set<String> shelveIds, Set<String> goodsIds);
|
||||
}
|
||||
@@ -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<WarehouseGoodsSummaryEntity, WarehouseGoodsSummaryRepository> {
|
||||
// @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<WarehouseGoodsSummaryDto> list(CommonQuery query) {
|
||||
// Page<WarehouseGoodsSummaryEntity> 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<WarehouseReceiptEntity> 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<Tuple2<String, String>, 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());
|
||||
// }
|
||||
//}
|
||||
@@ -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<WarehouseReceiptEntity> allById = this.repository.findAllById(request.getIds());
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
handleType3Delete(allById);
|
||||
|
||||
Reference in New Issue
Block a user