库存盘点save get
This commit is contained in:
1 parent
d918b3b2ee
commit
6e8ef838f9
8 files changed
+337
-16
No files matched your search
+6
-8
@@ -1,6 +1,7 @@
|
||||
package com.bsd.pjcloud.supermarket.dto.inventoryrecords;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -24,12 +25,15 @@ public class PDItemSaveDTO {
|
||||
|
||||
|
||||
@Schema(description="账面数量")
|
||||
@NotNull
|
||||
private Double accountNumber;
|
||||
|
||||
@Schema(description="实际数量")
|
||||
@NotNull
|
||||
private Double realNumber;
|
||||
|
||||
@Schema(description="账面单价")
|
||||
@NotNull
|
||||
private Integer unitPrice;
|
||||
|
||||
|
||||
@@ -37,6 +41,7 @@ public class PDItemSaveDTO {
|
||||
* 数据库意思就是实际单价,这里等价于盘点单价
|
||||
*/
|
||||
@Schema(description="盘点单价")
|
||||
@NotNull
|
||||
private Integer realPrice;
|
||||
/**
|
||||
* 盘盈盘亏
|
||||
@@ -51,14 +56,6 @@ public class PDItemSaveDTO {
|
||||
private Double loss;
|
||||
|
||||
|
||||
/**
|
||||
* 包装单位id
|
||||
*/
|
||||
@Schema(description="包装单位id")
|
||||
private Long unitId;
|
||||
|
||||
|
||||
|
||||
|
||||
@Schema(description="盘后总数")
|
||||
private Integer totalNumber;
|
||||
@@ -74,6 +71,7 @@ public class PDItemSaveDTO {
|
||||
* 1等于盘盈 2等于盘亏
|
||||
*/
|
||||
@Schema(description="订单类型,1入库,2出库")
|
||||
@NotNull
|
||||
private String orderType;
|
||||
|
||||
/**
|
||||
|
||||
+5
-1
@@ -21,12 +21,14 @@ public class PDSaveDTO {
|
||||
* 采编号
|
||||
*/
|
||||
@Schema(description="编号")
|
||||
@NotNull
|
||||
private String inventoryCode;
|
||||
|
||||
/**
|
||||
* 采购计划单据日期
|
||||
*/
|
||||
@Schema(description="单据日期")
|
||||
@NotNull
|
||||
private LocalDate inventoryDate;
|
||||
|
||||
/**
|
||||
@@ -54,13 +56,15 @@ public class PDSaveDTO {
|
||||
* 单据类型(字典inventory_type)采购入库、采购退货、盘点入库等
|
||||
*/
|
||||
@Schema(description="单据类型(字典inventory_type)采购入库、采购退货、盘点入库等")
|
||||
@NotNull
|
||||
private String inventoryType;
|
||||
|
||||
|
||||
/**
|
||||
* @Link SmCgPlanSaveItemDTO
|
||||
*/
|
||||
@Schema(description="采购计划-item")
|
||||
@Schema(description="盘点-item")
|
||||
@NotNull
|
||||
private List<PDItemSaveDTO> items;
|
||||
|
||||
|
||||
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
package com.bsd.pjcloud.supermarket.vo.inventoryrecord;
|
||||
|
||||
import com.bsd.pjcloud.common.core.util.MoneyDeserializer;
|
||||
import com.bsd.pjcloud.common.core.util.MoneySerializer;
|
||||
import com.bsd.pjcloud.supermarket.vo.cgplan.ErpUnitVo;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pd-item
|
||||
*
|
||||
* @author zjf
|
||||
* @date 2025-02-11 17:11:41
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "pd-item-vo")
|
||||
public class PDItemVo {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 库存商品id
|
||||
*/
|
||||
@Schema(description="库存商品id")
|
||||
private Long erpSpuId;
|
||||
|
||||
@Schema(description="账面数量")
|
||||
private Double accountNumber;
|
||||
|
||||
@Schema(description="实际数量")
|
||||
private Double realNumber;
|
||||
|
||||
@Schema(description="账面单价")
|
||||
private Integer unitPrice;
|
||||
|
||||
/**
|
||||
* 数据库意思就是实际单价,这里等价于盘点单价
|
||||
*/
|
||||
@Schema(description="盘点单价")
|
||||
private Integer realPrice;
|
||||
|
||||
/**
|
||||
* 盘盈盘亏
|
||||
*/
|
||||
@Schema(description="盈")
|
||||
private Double profit;
|
||||
|
||||
/**
|
||||
* 盘盈盘亏
|
||||
*/
|
||||
@Schema(description="亏")
|
||||
private Double loss;
|
||||
|
||||
|
||||
/**
|
||||
* 主表id
|
||||
*/
|
||||
@Schema(description="主表id")
|
||||
private Long inventoryId;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@Schema(description="数量")
|
||||
private Integer quantity;
|
||||
|
||||
|
||||
@Schema(description="盘后总数")
|
||||
private Integer totalNumber;
|
||||
|
||||
/**
|
||||
* 累计总金额
|
||||
*/
|
||||
@Schema(description="盘后总金额")
|
||||
private Integer totalAmount;
|
||||
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description="备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 包装单位id
|
||||
*/
|
||||
@Schema(description="包装单位id")
|
||||
private Long unitId;
|
||||
|
||||
|
||||
/**
|
||||
* 规格
|
||||
*/
|
||||
@Schema(description="规格")
|
||||
private String spec;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
@Schema(description="单位")
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* 装数
|
||||
*/
|
||||
@Schema(description="装数")
|
||||
private Integer packageNum;
|
||||
|
||||
/**
|
||||
* 1等于盘盈 2等于盘亏
|
||||
*/
|
||||
@Schema(description="订单类型,1入库,2出库")
|
||||
@NotNull
|
||||
private String orderType;
|
||||
|
||||
|
||||
@Schema(description = "包装对象集合对象")
|
||||
private List<PDUnitVo> erpUnitVos;
|
||||
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.bsd.pjcloud.supermarket.vo.inventoryrecord;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @link com.bsd.pjcloud.supermarket.vo.purchase.ErpSpuWithUnitVo
|
||||
*/
|
||||
@Schema(description = "包装单位vo")
|
||||
@Data
|
||||
public class PDUnitVo {
|
||||
|
||||
@Schema(description="包装单位id")
|
||||
private Long id;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 规格
|
||||
*/
|
||||
@Schema(description="规格")
|
||||
private String spec;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
@Schema(description="单位")
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* 装数
|
||||
*/
|
||||
@Schema(description="装数")
|
||||
private Integer packageNum;
|
||||
|
||||
/**
|
||||
* 进价(分为单位)
|
||||
*/
|
||||
@Schema(description="进价(分为单位)")
|
||||
// @JsonSerialize(using = MoneySerializer.class) // 分 -> 元
|
||||
// @JsonDeserialize(using = MoneyDeserializer.class) // 元 -> 分
|
||||
private Integer purchasePrice;
|
||||
|
||||
|
||||
|
||||
|
||||
@Schema(description="是否基础单位")
|
||||
private Boolean isBase;
|
||||
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.bsd.pjcloud.supermarket.vo.inventoryrecord;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "盘点-编辑回显 vo")
|
||||
@Data
|
||||
public class PDVo {
|
||||
|
||||
@Schema(description ="id")
|
||||
private Long id;
|
||||
/**
|
||||
* 采购计划编号
|
||||
*/
|
||||
@Schema(description="编号")
|
||||
private String inventoryCode;
|
||||
|
||||
/**
|
||||
* 采购计划单据日期
|
||||
*/
|
||||
@Schema(description="单据日期")
|
||||
private LocalDate inventoryDate;
|
||||
|
||||
|
||||
@Schema(description="商品名称")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 经办人id
|
||||
*/
|
||||
@Schema(description="经办人id")
|
||||
private Long handlerUserId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description="备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @link InventoryRecordItemVo
|
||||
*/
|
||||
@Schema(description="item")
|
||||
private List<PDItemVo> items;
|
||||
|
||||
}
|
||||
+9
-2
@@ -251,10 +251,17 @@ public class SmErpInventoryRecordsController {
|
||||
|
||||
@Operation(summary = "库存盘点新增" , description = "库存盘点新增" )
|
||||
@SysLog("库存盘点新增" )
|
||||
@PostMapping
|
||||
@PostMapping("/savePD")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_smErpInventoryRecords_add')" )
|
||||
public R save(@RequestBody PDSaveDTO pdSaveDTO) {
|
||||
public R savePD(@RequestBody PDSaveDTO pdSaveDTO) {
|
||||
return R.ok(smErpInventoryRecordsService.savePD(pdSaveDTO));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "通过id查询库存盘点详情" , description = "通过id查询库存盘点详情" )
|
||||
@GetMapping("/getPD/{id}" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_smErpInventoryRecords_view')" )
|
||||
public R getPDById(@PathVariable("id" ) Long id) {
|
||||
return R.ok(smErpInventoryRecordsService.getPDDetailById(id));
|
||||
}
|
||||
}
|
||||
+4
@@ -89,4 +89,8 @@ public interface SmErpInventoryRecordsService extends IService<SmErpInventoryRec
|
||||
* @return
|
||||
*/
|
||||
Object savePD(PDSaveDTO pdSaveDTO);
|
||||
|
||||
|
||||
|
||||
Object getPDDetailById(Long id);
|
||||
}
|
||||
+68
-5
@@ -20,10 +20,7 @@ import com.bsd.pjcloud.supermarket.service.SmErpStockService;
|
||||
import com.bsd.pjcloud.supermarket.vo.cgplan.ErpUnitVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.cgplan.SmErpCgPlanItemVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.cgplan.SmErpCgPlanVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.inventoryrecord.InventoryRecordItemVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.inventoryrecord.InventoryRecordPageVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.inventoryrecord.InventoryRecordSumVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.inventoryrecord.InventoryRecordVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.inventoryrecord.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -408,8 +405,74 @@ public class SmErpInventoryRecordsServiceImpl extends ServiceImpl<SmErpInventory
|
||||
|
||||
int insert = baseMapper.insert(smErpCgDdEntity);
|
||||
List<SmErpInventoryRecordsItemEntity> cgPlanItemEntities = BeanUtils.toBean(items, SmErpInventoryRecordsItemEntity.class);
|
||||
List<UpdateStockDTO> updateStockDTOS = new ArrayList<>();
|
||||
List<SmErpInventoryRecordsItemEntity> smErpInventoryRecordsItemEntities = new ArrayList<>();
|
||||
for (PDItemSaveDTO item : items){
|
||||
//库存更新对象
|
||||
UpdateStockDTO updateStockDTO = new UpdateStockDTO();
|
||||
updateStockDTO.setId(item.getErpSpuId());
|
||||
|
||||
//出入库对象
|
||||
SmErpInventoryRecordsItemEntity smErpInventoryRecordsItemEntity = new SmErpInventoryRecordsItemEntity();
|
||||
org.springframework.beans.BeanUtils.copyProperties(item,smErpInventoryRecordsItemEntity);
|
||||
smErpInventoryRecordsItemEntity.setInventoryId(smErpCgDdEntity.getId());
|
||||
smErpInventoryRecordsItemEntity.setDeptId(deptId);
|
||||
String orderType = item.getOrderType();
|
||||
smErpInventoryRecordsItemEntity.setOrderType(orderType);
|
||||
if (orderType.equals(OrderTypeEnum.RK.getType())){
|
||||
Double profit = item.getProfit();
|
||||
updateStockDTO.setIncrCount(profit);
|
||||
smErpInventoryRecordsItemEntity.setQuantity(profit);
|
||||
}else if (orderType.equals(OrderTypeEnum.CK.getType())){
|
||||
Double loss = item.getLoss();
|
||||
updateStockDTO.setIncrCount(loss);
|
||||
smErpInventoryRecordsItemEntity.setQuantity(loss);
|
||||
}else {
|
||||
throw new RuntimeException("订单类型错误");
|
||||
}
|
||||
|
||||
smErpInventoryRecordsItemEntities.add(smErpInventoryRecordsItemEntity);
|
||||
updateStockDTOS.add(updateStockDTO);
|
||||
}
|
||||
smErpInventoryRecordsItemMapper.insert(cgPlanItemEntities);
|
||||
|
||||
//todo 实际上应该审批后才会入库
|
||||
//更新库存
|
||||
smErpStockService.updateStock(updateStockDTOS);
|
||||
return insert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPDDetailById(Long id) {
|
||||
SmErpInventoryRecordsEntity smErpInventoryRecordsEntity = this.getById(id);
|
||||
List<SmErpInventoryRecordsItemEntity> list =smErpInventoryRecordsItemMapper.selectList(new LambdaQueryWrapper<SmErpInventoryRecordsItemEntity>()
|
||||
.eq(SmErpInventoryRecordsItemEntity::getInventoryId, id));
|
||||
|
||||
//获取item下已选择的item的所有包装单位
|
||||
List<Long> spuIds =list.stream().map(vo -> vo.getErpSpuId()).collect(Collectors.toList());
|
||||
List<SmErpUnitEntity> unitList = smErpUnitMapper.selectList(new LambdaQueryWrapper<SmErpUnitEntity>().in(SmErpUnitEntity::getSpuId, spuIds));
|
||||
|
||||
|
||||
//
|
||||
PDVo bean = BeanUtils.toBean(smErpInventoryRecordsEntity, PDVo.class, (source) -> {
|
||||
List<PDItemVo> smeErpCgPlanItemVos = BeanUtils.toBean(list, PDItemVo.class);
|
||||
smeErpCgPlanItemVos.stream().forEach(item -> {
|
||||
List<SmErpUnitEntity> unitEntities = unitList.stream().filter(unit -> unit.getSpuId().equals(item.getErpSpuId())).collect(Collectors.toList());
|
||||
// unitList.stream().forEach(unit -> {
|
||||
// if(unit.getId().equals(item.getUnitId())){
|
||||
// item.setSpec(unit.getSpec());
|
||||
// item.setUnit(unit.getUnit());
|
||||
// item.setPackageNum(unit.getPackageNum());
|
||||
// item.setPurchasePrice(unit.getPurchasePrice());
|
||||
// }
|
||||
// });
|
||||
item.setErpUnitVos(BeanUtils.toBean(unitEntities, PDUnitVo.class));
|
||||
});
|
||||
source.setItems(smeErpCgPlanItemVos);
|
||||
});
|
||||
|
||||
return bean;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user