库存记录 存入 统计 列表 详情列表
This commit is contained in:
@@ -1,35 +1,22 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.service.impl.productimpl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.product.StockCountDTO;
|
||||
import cn.ysk.cashier.dto.product.*;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbProducSkutMapper;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
|
||||
import cn.ysk.cashier.repository.order.StockCountRepository;
|
||||
import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
|
||||
import cn.ysk.cashier.repository.product.ProductStockCountRepository;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import cn.ysk.cashier.vo.TbProductStockCountVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cn.ysk.cashier.repository.product.TbProductStockDetailRepository;
|
||||
import cn.ysk.cashier.service.product.TbProductStockDetailService;
|
||||
import cn.ysk.cashier.dto.product.TbProductStockDetailDto;
|
||||
import cn.ysk.cashier.dto.product.TbProductStockDetailQueryCriteria;
|
||||
import cn.ysk.cashier.mapper.product.TbProductStockDetailMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -38,6 +25,8 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.persistence.EntityManager;
|
||||
@@ -58,6 +47,7 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
||||
private final TbProductStockDetailMapper tbProductStockDetailMapper;
|
||||
|
||||
private final StockCountRepository stockCountRepository;
|
||||
private final ProductStockCountRepository stockRepository;
|
||||
private final EntityManager entityManager;
|
||||
private final TbOrderInfoRepository tbOrderInfoRepository;
|
||||
private final TbProducSkutMapper skutMapper;
|
||||
@@ -72,6 +62,33 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryPage(TbProductStockDetailQueryCriteria criteria){
|
||||
if(StringUtils.isBlank(criteria.getColumn())){
|
||||
throw new BadRequestException("必填参数未填写");
|
||||
}
|
||||
switch (criteria.getColumn()){
|
||||
case "addCountNumber":
|
||||
criteria.setType(Arrays.asList("供应商入库", "盘点入库", "其他入库", "退单"));
|
||||
break;
|
||||
case "addNumber":
|
||||
criteria.setType(Arrays.asList("供应商入库", "盘点入库", "其他入库"));
|
||||
break;
|
||||
case "refundNumber":
|
||||
criteria.setType(Arrays.asList("退单"));
|
||||
break;
|
||||
case "subCountNumber":
|
||||
criteria.setType(Arrays.asList("供应商出库","其他出库","盘点出库","售出记录","报损"));
|
||||
break;
|
||||
case "subNumber":
|
||||
criteria.setType(Arrays.asList("供应商出库","其他出库","盘点出库","售出记录"));
|
||||
break;
|
||||
case "saleNumber":
|
||||
criteria.setType(Arrays.asList("售出记录"));
|
||||
break;
|
||||
case "lossNumber":
|
||||
criteria.setType(Arrays.asList("报损"));
|
||||
break;
|
||||
}
|
||||
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
|
||||
|
||||
@@ -98,6 +115,39 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbProductStockCountVo stockCount(TbProductStockCountQueryCriteria criteria) throws ParseException {
|
||||
if (criteria.getStartTime() == null || criteria.getEndTime() == null) {
|
||||
criteria.setEndTime(new Date());//
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
criteria.setStartTime(sdf.parse("2024-01-01"));//创建2024年1月1日的Date对象
|
||||
}
|
||||
return stockRepository.stockCount(criteria.getShopId().toString(), criteria.getProductName(),
|
||||
criteria.getCategoryId(), criteria.getStartTime().getTime(), criteria.getEndTime().getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> stockList(TbProductStockCountQueryCriteria criteria) throws ParseException {
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
|
||||
if (criteria.getStartTime() == null || criteria.getEndTime() == null) {
|
||||
criteria.setEndTime(new Date());//
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
criteria.setStartTime(sdf.parse("2024-01-01"));//创建2024年1月1日的Date对象
|
||||
}
|
||||
Page<TbProductStockListDto> tbProductStockCountDtos = stockRepository.stock2(
|
||||
criteria.getShopId().toString(),
|
||||
criteria.getProductName(),
|
||||
criteria.getCategoryId(),
|
||||
criteria.getStartTime().getTime(), criteria.getEndTime().getTime(), pageable);
|
||||
if (!tbProductStockCountDtos.isEmpty()) {
|
||||
tbProductStockCountDtos.getContent().parallelStream().forEach(s->{
|
||||
s.setCountNumber(s.getStockNumber().add(s.getSubCountNumber()));
|
||||
});
|
||||
}
|
||||
return PageUtil.toPage(tbProductStockCountDtos);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TbProductStockDetailDto> queryAll(TbProductStockDetailQueryCriteria criteria){
|
||||
|
||||
@@ -259,24 +259,6 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
|
||||
BigDecimal totalCostPrice;
|
||||
productStockDetail.setType(resources.getType());
|
||||
switch (resources.getType()) {
|
||||
case "sale":
|
||||
productStockDetail.setStockNumber((double) -productListDto.getNumber());
|
||||
productStockDetail.setSubType(-1);
|
||||
break;
|
||||
//后台出库
|
||||
case "refund":
|
||||
productStockDetail.setStockNumber((double) -productListDto.getNumber());
|
||||
productStockDetail.setSubType(1);
|
||||
totalCostPrice = productListDto.getCostPrice().multiply(BigDecimal.valueOf(productListDto.getNumber()));
|
||||
productStockDetail.setCostAmount(totalCostPrice);
|
||||
productStockDetail.setType("供应商出库");
|
||||
|
||||
// 获取增加后的库存
|
||||
double refundStockNum = getStockNum(product, tbProductSku, productListDto.getNumber(), false);
|
||||
setProSpecInfo(product, tbProductSku, refundStockNum,
|
||||
productListDto.getCostPrice(), isDistribute);
|
||||
|
||||
break;
|
||||
case "reject":
|
||||
productStockDetail.setStockNumber((double) -productListDto.getNumber());
|
||||
productStockDetail.setSubType(-1);
|
||||
@@ -517,7 +499,8 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
|
||||
: productSku.getStockNumber().intValue() - stockRecordMsg.getNumber());
|
||||
productStockDetail.setRecordId(stockOperate.getId().toString());
|
||||
productStockDetail.setStockSnap(JSONObject.toJSONString(snapItem));
|
||||
productStockDetail.setSourcePath("NORMAL");
|
||||
productStockDetail.setSourcePath("CASHIER");
|
||||
productStockDetail.setRemark(stockRecordMsg.getRemark());
|
||||
productStockDetailRepository.save(productStockDetail);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,15 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.service.product;
|
||||
|
||||
import cn.ysk.cashier.dto.product.TbProductStockCountQueryCriteria;
|
||||
import cn.ysk.cashier.dto.rabbit.StockRecordMsg;
|
||||
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
|
||||
import cn.ysk.cashier.dto.product.TbProductStockDetailDto;
|
||||
import cn.ysk.cashier.dto.product.TbProductStockDetailQueryCriteria;
|
||||
import cn.ysk.cashier.vo.TbProductStockCountVo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
@@ -45,6 +33,8 @@ public interface TbProductStockDetailService {
|
||||
Map<String,Object> queryAll(TbProductStockDetailQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
Map<String,Object> queryPage(TbProductStockDetailQueryCriteria criteria);
|
||||
TbProductStockCountVo stockCount(TbProductStockCountQueryCriteria criteria) throws ParseException;
|
||||
Map<String,Object> stockList(TbProductStockCountQueryCriteria criteria) throws ParseException;
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
|
||||
Reference in New Issue
Block a user