feat: 调整事由相关接口

This commit is contained in:
2024-11-24 22:15:47 +08:00
parent 0dac827b16
commit 4b01a567d4
8 changed files with 27 additions and 98 deletions

View File

@@ -5,7 +5,6 @@ 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;
@@ -54,8 +53,5 @@ public class WarehouseGoodsController {
}
@PostMapping("/goodsCount")
public Integer goodsCount(@RequestBody GoodsCountRequest request) {
return this.service.goodsCount(request);
}
}

View File

@@ -5,7 +5,6 @@ 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;
@@ -77,20 +76,7 @@ public class WarehouseGoodsService
@Autowired
private CommonMapper commonMapper;
public Integer goodsCount(GoodsCountRequest request) {
Double result =
em.createQuery(
"select sum(case when receiptType = '0' then number when receiptType = '1' then number * -1 end ) from WarehouseReceiptDetailEntity where warehouse.id = :warehouseId and shelve.id = :shelveId and goods.id = :goodsIds",
Double.class)
.setParameter("warehouseId", request.getWarehouseId())
.setParameter("shelveId", request.getShelveId())
.setParameter("goodsIds", request.getGoodsId())
.getSingleResult();
if (result == null){
return 0;
}
return result.intValue();
}
}

View File

@@ -32,14 +32,6 @@ public class WarehouseReceiptEntity extends OrgCommonEntity {
@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)")
// private String receiptTypeName;
@Comment("单据编号")
@Column(nullable = false)

View File

@@ -260,7 +260,7 @@ public class WarehouseReceiptService
request.setWarehouseId(warehouseReceiptDetailEntity.getWarehouse().getId());
request.setShelveId(warehouseReceiptDetailEntity.getShelve().getId());
Integer goodsCount = warehouseGoodsService.goodsCount(request);
Integer goodsCount = getGoodsCount(request);
WarehouseGoodsDto goods =
warehouseGoodsService.getById(
@@ -292,6 +292,29 @@ public class WarehouseReceiptService
}
}
private Integer getGoodsCount(GoodsCountRequest request) {
WarehouseReportRequest reportRequest = new WarehouseReportRequest();
reportRequest.setGoodsIds(List.of(request.getGoodsId()));
reportRequest.setWarehouseIds(List.of(request.getWarehouseId()));
reportRequest.setShelveIds(List.of(request.getShelveId()));
reportRequest.setShelveSummary(true);
reportRequest.setExcludeEmpty(true);
reportRequest.setIncludeSum(false);
Object report = report(reportRequest);
List content = ((PageImpl) report).getContent();
if (content.isEmpty()) {
return 0;
}
Map map = (Map) content.get(0);
return NumberUtil.parseInt(map.get("currNumber").toString());
}
private void handleType3Create(WarehouseReceiptEntity entity) {
// 生成入库单
@@ -642,7 +665,7 @@ public class WarehouseReceiptService
</#if>
join t_warehouse_receipt_detail d on d.goods_id = gs.id
join t_warehouse_receipt_detail d on d.goods_id = gs.id and d.warehouse_id = w.id
left join t_warehouse_receipt re on d.receipt_id = re.id
left join t_warehouse_goods_unit gu on gs.unit_id = gu.id
left join t_warehouse_goods_brand gb on gs.brand_id = gb.id

View File

@@ -9,7 +9,6 @@ import jakarta.persistence.Column;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Type;
import java.util.List;
@@ -17,22 +16,6 @@ import java.util.List;
@Data
public class CreateWarehouseReceiptReasonDto 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)")
private String receiptTypeName;
@Comment("事由")
private String reason;

View File

@@ -9,7 +9,6 @@ import jakarta.persistence.Column;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Type;
import java.util.List;
@@ -17,22 +16,7 @@ import java.util.List;
@Data
public class UpdateWarehouseReceiptReasonDto 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)")
private String receiptTypeName;
@Comment("事由")
private String reason;

View File

@@ -9,7 +9,6 @@ import jakarta.persistence.Column;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Type;
import java.util.List;
@@ -18,23 +17,6 @@ import java.util.List;
public class WarehouseReceiptReasonDto 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)")
private String receiptTypeName;
@Comment("事由")
private String reason;
@Comment("用于存储多个事由说明, 用于下拉框展示和快速填写")

View File

@@ -10,7 +10,6 @@ import jakarta.persistence.Entity;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Type;
import java.util.List;
@@ -23,22 +22,6 @@ import java.util.List;
public class WarehouseReceiptReasonEntity extends OrgCommonEntity {
@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)")
private String receiptTypeName;
@Comment("事由")
private String reason;