采购计划-2
This commit is contained in:
1 parent
a27a485426
commit
22de433d1d
9 files changed
+514
No files matched your search
+25
@@ -0,0 +1,25 @@
|
||||
package com.bsd.pjcloud.supermarket.constant;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 出库入口
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum OrderTypeEnum {
|
||||
|
||||
RK("1", "入库"),
|
||||
CK("2", "出库"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.bsd.pjcloud.supermarket.dto.puchase;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(description = "采购计划选择商品分页查询dto")
|
||||
public class ErpPurchaseDTO {
|
||||
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description="商品名称")
|
||||
private String productName;
|
||||
|
||||
|
||||
/**
|
||||
* 货号
|
||||
*/
|
||||
@Schema(description="货号")
|
||||
private String productCode;
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
package com.bsd.pjcloud.supermarket.dto.puchase;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 新增一个采购计划
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "采购计划保存对象")
|
||||
public class ErpPurchaseSaveDTO {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 单据编号
|
||||
*/
|
||||
@Schema(description="单据编号")
|
||||
private String orderCode;
|
||||
|
||||
/**
|
||||
* 单据日期
|
||||
*/
|
||||
@Schema(description="单据日期")
|
||||
private LocalDate orderDate;
|
||||
|
||||
/**
|
||||
* 单据类型(字典inventory_type)
|
||||
*/
|
||||
@Schema(description="单据类型(字典inventory_type)")
|
||||
private String inventoryType;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
@Schema(description="商品id")
|
||||
private Long erpSpuId;
|
||||
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
@Schema(description="仓库id")
|
||||
private String warehouseId;
|
||||
|
||||
/**
|
||||
* 经办人id
|
||||
*/
|
||||
@Schema(description="经办人id")
|
||||
private Long handlerUserId;
|
||||
|
||||
/**
|
||||
* 审批状态
|
||||
*/
|
||||
@Schema(description="审批状态")
|
||||
private String checkStatus;
|
||||
|
||||
/**
|
||||
* 审批人id
|
||||
*/
|
||||
@Schema(description="审批人id")
|
||||
private String checkUserId;
|
||||
|
||||
/**
|
||||
* 审核日期
|
||||
*/
|
||||
@Schema(description="审核日期")
|
||||
private LocalDateTime checkTime;
|
||||
|
||||
/**
|
||||
* 商户编号
|
||||
*/
|
||||
@Schema(description="商户编号")
|
||||
private Long merchantId;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
@Schema(description="部门id")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 出入库数量
|
||||
*/
|
||||
@Schema(description="出入库数量")
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
@Schema(description="单价")
|
||||
private Integer unitPrice;
|
||||
|
||||
/**
|
||||
* 总金额
|
||||
*/
|
||||
@Schema(description="总金额")
|
||||
private Integer totalAmount;
|
||||
|
||||
/**
|
||||
* 税率%
|
||||
*/
|
||||
@Schema(description="税率%")
|
||||
private Integer taxRate;
|
||||
|
||||
/**
|
||||
* 税前金额
|
||||
*/
|
||||
@Schema(description="税前金额")
|
||||
private Integer taxAmount;
|
||||
|
||||
/**
|
||||
* 货商
|
||||
*/
|
||||
@Schema(description="货商")
|
||||
private Long supplierId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description="备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
@Schema(description="订单编号")
|
||||
private String orderNumber;
|
||||
|
||||
/**
|
||||
* 订单类型(1入库 2出库)
|
||||
*/
|
||||
@Schema(description="订单类型(1入库 2出库)")
|
||||
private String orderType;
|
||||
|
||||
|
||||
}
|
||||
File renamed without changes.
+90
@@ -0,0 +1,90 @@
|
||||
package com.bsd.pjcloud.supermarket.vo.purchase;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 采购计划选择对应的商品选择 vo
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "库存商品和包装单位vo")
|
||||
public class ErpSpuWithUnitPageVo {
|
||||
|
||||
/**
|
||||
* 商品 SPU 编号,自增
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="商品 SPU 编号,自增")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 货号
|
||||
*/
|
||||
@Schema(description="货号")
|
||||
private String productCode;
|
||||
|
||||
/**
|
||||
* 自编码/条码
|
||||
*/
|
||||
@Schema(description="自编码/条码")
|
||||
private String barcode;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description="商品名称")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 商品分类编号
|
||||
*/
|
||||
@Schema(description="商品分类编号")
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 商品封面图
|
||||
*/
|
||||
@Schema(description="商品封面图")
|
||||
private String picUrl;
|
||||
|
||||
|
||||
/**
|
||||
* 商品状态:
|
||||
*/
|
||||
@Schema(description="商品状态: 0 上架(开启) 1 下架(禁用) -1 回收")
|
||||
private String status;
|
||||
|
||||
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
@Schema(description="库存")
|
||||
@TableField(exist = false)
|
||||
private Integer stock;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
@Schema(description="部门id")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 品牌id
|
||||
*/
|
||||
@Schema(description="品牌id")
|
||||
private Long brandId;
|
||||
|
||||
/**
|
||||
* 货商id
|
||||
*/
|
||||
@Schema(description="货商id")
|
||||
private Long supplierId;
|
||||
|
||||
|
||||
@Schema(description = "包装对象集合对象")
|
||||
private List<ErpUnitVo> erpUnitVos;
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package com.bsd.pjcloud.supermarket.vo.purchase;
|
||||
|
||||
import com.bsd.pjcloud.common.core.util.MoneyDeserializer;
|
||||
import com.bsd.pjcloud.common.core.util.MoneySerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
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 ErpUnitVo {
|
||||
|
||||
/**
|
||||
* 规格
|
||||
*/
|
||||
@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="零售价(分为单位)")
|
||||
@JsonSerialize(using = MoneySerializer.class) // 分 -> 元
|
||||
@JsonDeserialize(using = MoneyDeserializer.class) // 元 -> 分
|
||||
private Integer retailPrice;
|
||||
|
||||
/**
|
||||
* 成本单价,单位: 分
|
||||
*/
|
||||
@Schema(description="成本单价,单位: 分")
|
||||
@JsonSerialize(using = MoneySerializer.class) // 分 -> 元
|
||||
@JsonDeserialize(using = MoneyDeserializer.class) // 元 -> 分
|
||||
private Integer costPrice;
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
package com.bsd.pjcloud.supermarket.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.supermarket.constant.OrderTypeEnum;
|
||||
import com.bsd.pjcloud.supermarket.dto.puchase.ErpPurchaseDTO;
|
||||
import com.bsd.pjcloud.supermarket.dto.puchase.ErpPurchaseSaveDTO;
|
||||
import com.bsd.pjcloud.supermarket.entity.SmErpInventoryRecordsEntity;
|
||||
import com.bsd.pjcloud.supermarket.service.SmErpInventoryRecordsService;
|
||||
import com.bsd.pjcloud.supermarket.service.SmErpSpuService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 采购计划
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2025-02-10 12:15:37
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/smErpPurchase" )
|
||||
@Tag(description = "smErpPurchase" , name = "采购计划" )
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class SmErpPurchaseController {
|
||||
|
||||
private final SmErpInventoryRecordsService smErpInventoryRecordsService;
|
||||
|
||||
private final SmErpSpuService smErpSpuService;
|
||||
|
||||
/**
|
||||
* 采购计划选择商品分页数据
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询" , description = "分页查询" )
|
||||
@GetMapping("/erpSpuPage" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_smErpInventoryRecords_view')" )
|
||||
public R getErpSpuPage(@ParameterObject Page page, @ParameterObject ErpPurchaseDTO erpPurchaseDTO) {
|
||||
return R.ok(smErpSpuService.getErpSpuPage(page, erpPurchaseDTO));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增采购计划
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增采购计划" , description = "新增采购计划" )
|
||||
@SysLog("新增采购计划" )
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_smErpInventoryRecords_add')" )
|
||||
public R save(@RequestBody ErpPurchaseSaveDTO erpPurchaseSaveDTO) {
|
||||
SmErpInventoryRecordsEntity smErpInventoryRecordsEntity = BeanUtils.toBean(erpPurchaseSaveDTO, SmErpInventoryRecordsEntity.class);
|
||||
smErpInventoryRecordsEntity.setOrderType(OrderTypeEnum.RK.getType());
|
||||
return R.ok(smErpInventoryRecordsService.save(smErpInventoryRecordsEntity));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询出入库记录表
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
||||
@GetMapping("/{id}" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_smErpInventoryRecords_view')" )
|
||||
public R getById(@PathVariable("id" ) Long id) {
|
||||
return R.ok(smErpInventoryRecordsService.getById(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改出入库记录表
|
||||
* @param smErpInventoryRecords 出入库记录表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改出入库记录表" , description = "修改出入库记录表" )
|
||||
@SysLog("修改出入库记录表" )
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_smErpInventoryRecords_edit')" )
|
||||
public R updateById(@RequestBody SmErpInventoryRecordsEntity smErpInventoryRecords) {
|
||||
return R.ok(smErpInventoryRecordsService.updateById(smErpInventoryRecords));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除出入库记录表
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除出入库记录表" , description = "通过id删除出入库记录表" )
|
||||
@SysLog("通过id删除出入库记录表" )
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_smErpInventoryRecords_del')" )
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(smErpInventoryRecordsService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param smErpInventoryRecords 查询条件
|
||||
* @param ids 导出指定ID
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_smErpInventoryRecords_export')" )
|
||||
public List<SmErpInventoryRecordsEntity> export(SmErpInventoryRecordsEntity smErpInventoryRecords,Long[] ids) {
|
||||
return smErpInventoryRecordsService.list(Wrappers.lambdaQuery(smErpInventoryRecords).in(ArrayUtil.isNotEmpty(ids), SmErpInventoryRecordsEntity::getId, ids));
|
||||
}
|
||||
}
|
||||
+6
@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuQueryDTO;
|
||||
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.supermarket.dto.puchase.ErpPurchaseDTO;
|
||||
import com.bsd.pjcloud.supermarket.entity.SmErpSpuEntity;
|
||||
import com.bsd.pjcloud.supermarket.vo.purchase.ErpSpuWithUnitPageVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.sm.smspu.SmErpPageScopeVo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -70,4 +72,8 @@ public interface SmErpSpuService extends IService<SmErpSpuEntity> {
|
||||
* @return
|
||||
*/
|
||||
Page<SmErpPageScopeVo> OnlineSpuPageScope(Page page, LambdaQueryWrapper<SmErpSpuEntity> wrapper);
|
||||
|
||||
|
||||
|
||||
Page<ErpSpuWithUnitPageVo> getErpSpuPage(Page page, ErpPurchaseDTO erpPurchaseDTO);
|
||||
}
|
||||
+34
@@ -8,6 +8,7 @@ import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuQueryDTO;
|
||||
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.supermarket.dto.puchase.ErpPurchaseDTO;
|
||||
import com.bsd.pjcloud.supermarket.entity.SmErpAuxiliaryCodeEntity;
|
||||
import com.bsd.pjcloud.supermarket.entity.SmErpSpuEntity;
|
||||
import com.bsd.pjcloud.supermarket.entity.SmErpStockEntity;
|
||||
@@ -22,9 +23,12 @@ import com.bsd.pjcloud.supermarket.vo.app.SupermarketAppUnitVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.erp.SmErpAuxiliaryCodeVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.erp.SmErpSpuVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.erp.SmErpUnitVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.purchase.ErpSpuWithUnitPageVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.purchase.ErpUnitVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.sm.smspu.SmErpPageScopeVo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -206,4 +210,34 @@ public class SmErpSpuServiceImpl extends ServiceImpl<SmErpSpuMapper, SmErpSpuEnt
|
||||
|
||||
return resultPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ErpSpuWithUnitPageVo> getErpSpuPage(Page page, ErpPurchaseDTO erpPurchaseDTO) {
|
||||
LambdaQueryWrapper<SmErpSpuEntity> smErpUnitEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
smErpUnitEntityLambdaQueryWrapper.eq(SmErpSpuEntity::getStatus,"0");
|
||||
smErpUnitEntityLambdaQueryWrapper.eq(StringUtils.isNotBlank(erpPurchaseDTO.getProductCode()),SmErpSpuEntity::getProductCode,erpPurchaseDTO.getProductCode());
|
||||
smErpUnitEntityLambdaQueryWrapper.like(StringUtils.isNotBlank(erpPurchaseDTO.getProductName()),SmErpSpuEntity::getProductName,erpPurchaseDTO.getProductName());
|
||||
Page<SmErpSpuEntity> spuPage = baseMapper.selectPageByScope(page, smErpUnitEntityLambdaQueryWrapper, DataScope.of());
|
||||
|
||||
// 将 SmErpSpuEntity 转换为 SmErpPageScopeVo
|
||||
List<ErpSpuWithUnitPageVo> voList = spuPage.getRecords().stream()
|
||||
.map(entity -> BeanUtils.toBean(entity, ErpSpuWithUnitPageVo.class))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//复制unit
|
||||
List<Long> spuIds = voList.stream().map(vo -> vo.getId()).collect(Collectors.toList());
|
||||
|
||||
List<SmErpUnitEntity> unitList = smErpUnitService.list(new LambdaQueryWrapper<SmErpUnitEntity>().in(SmErpUnitEntity::getSpuId, spuIds));
|
||||
|
||||
voList.stream().forEach(vo -> {
|
||||
List<SmErpUnitEntity> unitEntities = unitList.stream().filter(unit -> unit.getSpuId().equals(vo.getId())).collect(Collectors.toList());
|
||||
vo.setErpUnitVos(BeanUtils.toBean(unitEntities, ErpUnitVo.class));
|
||||
});
|
||||
|
||||
// 创建新的 Page 对象并设置数据
|
||||
Page<ErpSpuWithUnitPageVo> resultPage = new Page<>();
|
||||
org.springframework.beans.BeanUtils.copyProperties(spuPage, resultPage);
|
||||
resultPage.setRecords(voList);
|
||||
return resultPage;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user