mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-24 23:41:21 +08:00
feat: 添加商品数量接口
This commit is contained in:
@@ -109,6 +109,7 @@ rabbitmqctl set_permissions --vhost /coal/test datacollector '' 'sysExchange|amq
|
||||
|
||||
|
||||
|
||||
|
||||
本地端口映射
|
||||
|
||||
|
||||
|
||||
@@ -350,6 +350,7 @@ public class CommonQuery {
|
||||
@Override
|
||||
public Predicate toPredicate(
|
||||
Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) {
|
||||
query.distinct(true);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(items)) {
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.CreateWarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.GoodsCountRequest;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.UpdateWarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.WarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.service.WarehouseGoodsService;
|
||||
@@ -51,4 +52,10 @@ public class WarehouseGoodsController {
|
||||
public Page<WarehouseGoodsDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/goodsCount")
|
||||
public Integer goodsCount(@RequestBody GoodsCountRequest request) {
|
||||
return this.service.goodsCount(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.lihongjie.coal.warehouseGoods.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class GoodsCountRequest {
|
||||
private String warehouseId;
|
||||
|
||||
private String goodsId;
|
||||
}
|
||||
@@ -2,14 +2,19 @@ package cn.lihongjie.coal.warehouseGoods.service;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.CreateWarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.GoodsCountRequest;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.UpdateWarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.WarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.entity.WarehouseGoodsEntity;
|
||||
import cn.lihongjie.coal.warehouseGoods.mapper.WarehouseGoodsMapper;
|
||||
import cn.lihongjie.coal.warehouseGoods.repository.WarehouseGoodsRepository;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -25,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Transactional
|
||||
public class WarehouseGoodsService
|
||||
extends BaseService<WarehouseGoodsEntity, WarehouseGoodsRepository> {
|
||||
@PersistenceContext EntityManager em;
|
||||
@Autowired private WarehouseGoodsRepository repository;
|
||||
|
||||
@Autowired private WarehouseGoodsMapper mapper;
|
||||
@@ -68,4 +74,15 @@ public class WarehouseGoodsService
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
@Autowired
|
||||
private CommonMapper commonMapper;
|
||||
|
||||
public Integer goodsCount(GoodsCountRequest request) {
|
||||
|
||||
return commonMapper.toInt((em.createQuery(
|
||||
"select sum(case when receipt.receiptType = '0' then number when receipt.receiptType = '1' then number * -1 end ) from WarehouseReceiptDetailEntity where warehouse.id = :warehouseId and goods.id = :goodsIds")
|
||||
.setParameter("warehouseId", request.getWarehouseId())
|
||||
.setParameter("goodsIds", request.getGoodsId())
|
||||
.getSingleResult() + ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +51,17 @@ public class WarehouseReceiptController {
|
||||
public Page<WarehouseReceiptDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/archive")
|
||||
public Object archive(@RequestBody IdRequest request) {
|
||||
this.service.archive(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/unarchive")
|
||||
public Object unarchive(@RequestBody IdRequest request) {
|
||||
this.service.unarchive(request);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package cn.lihongjie.coal.warehouseReceipt.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.common.DictCode;
|
||||
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
import cn.lihongjie.coal.warehouse.dto.WarehouseDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.dto.WarehouseReceiptDetailDto;
|
||||
|
||||
@@ -9,6 +11,7 @@ import jakarta.persistence.OneToMany;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
@@ -22,13 +25,7 @@ public class WarehouseReceiptDto extends OrgCommonDto {
|
||||
@Comment("单据类型")
|
||||
private String receiptType;
|
||||
|
||||
@Formula(
|
||||
"(select i.name\n"
|
||||
+ "from t_dictionary d,\n"
|
||||
+ " t_dictionary_item i\n"
|
||||
+ "where d.id = i.dictionary_id\n"
|
||||
+ " and d.code = 'warehouse.receiptType'\n"
|
||||
+ " and i.code = receipt_type)")
|
||||
@DictTranslate(dictKey = DictCode.WAREHOUSE_RECEIPTTYPE)
|
||||
private String receiptTypeName;
|
||||
|
||||
@Comment("单据编号")
|
||||
@@ -65,4 +62,15 @@ public class WarehouseReceiptDto extends OrgCommonDto {
|
||||
@Comment("制单人")
|
||||
private String creator;
|
||||
|
||||
|
||||
private String location;
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
|
||||
|
||||
|
||||
@DictTranslate(dictKey = DictCode.ARCHIVESTATUS)
|
||||
private String archiveStatusName;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import jakarta.persistence.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -69,4 +70,11 @@ public class WarehouseReceiptEntity extends OrgCommonEntity {
|
||||
|
||||
@Comment("制单人")
|
||||
private String creator;
|
||||
|
||||
|
||||
|
||||
private String location;
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
}
|
||||
|
||||
@@ -243,4 +243,13 @@ public class WarehouseReceiptService
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
public void archive(IdRequest dto) {
|
||||
this.repository.archive(dto);
|
||||
}
|
||||
|
||||
public void unarchive(IdRequest dto) {
|
||||
this.repository.unArchive(dto);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.lihongjie.coal.warehouseReceiptDetail.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.base.dto.SimpleDto;
|
||||
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;
|
||||
@@ -33,7 +33,7 @@ public class WarehouseReceiptDetailDto extends OrgCommonDto {
|
||||
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseReceiptDto receipt;
|
||||
private SimpleDto receipt;
|
||||
|
||||
@Comment("数量")
|
||||
private Double number;
|
||||
|
||||
@@ -47,6 +47,10 @@ public class WarehouseReceiptDetailEntity extends OrgCommonEntity {
|
||||
private Double number;
|
||||
|
||||
|
||||
|
||||
@Comment("单据类型")
|
||||
private String receiptType;
|
||||
|
||||
@Comment("单价")
|
||||
private Double price;
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
|
||||
@@ -23,14 +21,14 @@ public class WarehouseShelveEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
|
||||
@Formula("(select count(1) from t_warehouse_goods_summary s where s.shelve_id = id)")
|
||||
// @Formula("(select count(1) from t_warehouse_goods_summary s where s.shelve_id = id)")
|
||||
private Double goodsCount;
|
||||
|
||||
|
||||
@Formula("(select sum(s.number) from t_warehouse_goods_summary s where s.shelve_id = id)")
|
||||
// @Formula("(select sum(s.number) from t_warehouse_goods_summary s where s.shelve_id = id)")
|
||||
private Double goodsNumber;
|
||||
|
||||
@Formula("(select sum(s.number * s.price) from t_warehouse_goods_summary s where s.shelve_id = id)")
|
||||
// @Formula("(select sum(s.number * s.price) from t_warehouse_goods_summary s where s.shelve_id = id)")
|
||||
private Double goodsAmount;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user