库存记录 操作人

This commit is contained in:
wangw 2024-09-26 17:01:35 +08:00
parent 7467cfa444
commit 1198781b61
11 changed files with 46 additions and 33 deletions

View File

@ -104,6 +104,10 @@ public class TbConsInfoFlow implements Serializable {
@ApiModelProperty(value = "备注")
private String remark;
@Column(name = "`operator`")
@ApiModelProperty(value = "操作人")
private String operator;
@Transient
@TableField(exist = false)
private String productName;

View File

@ -53,7 +53,7 @@ public class TbConsInfoFlowDto implements Serializable {
private String orderNo;
private String coverImg;
private String remark;
private String operator;
}

View File

@ -6,10 +6,7 @@ import cn.ysk.cashier.cons.domain.TbConsInfoFlow;
import cn.ysk.cashier.cons.repository.TbConsInfoFlowRepository;
import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.ValidationUtil;
import cn.ysk.cashier.utils.*;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.cons.repository.TbConCheckRepository;
import cn.ysk.cashier.cons.service.TbConCheckService;
@ -97,13 +94,12 @@ public class TbConCheckServiceImpl implements TbConCheckService {
flow.setConsId(consInfo.getId());
flow.setShopId(consInfo.getShopId());
flow.setConName(consInfo.getConName());
flow.setAmount(consInfo.getStockNumber());
flow.setBalance(consInfo.getStockNumber());
flow.setOperator(SecurityUtils.getCurrentUsername());
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoFlowRepository.save(flow);

View File

@ -175,6 +175,7 @@ public class TbConsInfoFlowServiceImpl implements TbConsInfoFlowService {
tbConsInfoFlow.setBizName("报损");
tbConsInfoFlow.setBizType("-");
tbConsInfoFlow.setCreateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoFlow.setOperator(SecurityUtils.getCurrentUsername());
tbConsInfoFlowRepository.save(tbConsInfoFlow);
tbConsInfo.setStockNumber(balance);
consInfoRepository.save(tbConsInfo);

View File

@ -136,7 +136,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
flow.setConName(resource.getConName());
flow.setAmount(BigDecimal.ZERO);
flow.setBalance(BigDecimal.ZERO);
flow.setOperator(SecurityUtils.getCurrentUsername());
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoFlowRepository.save(flow);
@ -346,7 +346,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
flow.setConName(info.getConName());
flow.setAmount(conInfos.getStockNumber());
flow.setBalance(info.getStockNumber().subtract(info.getStockConsume()));
flow.setOperator(SecurityUtils.getCurrentUsername());
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoFlowRepository.save(flow);
}
@ -456,7 +456,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
flow.setConName(consInfo.getConName());
flow.setAmount(consInfo.getStockNumber());
flow.setBalance(consInfo.getStockNumber());
flow.setOperator(SecurityUtils.getCurrentUsername());
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoFlowRepository.save(flow);
@ -481,7 +481,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
flow.setConName(consInfo.getConName());
flow.setAmount(consInfo.getStockNumber());
flow.setBalance(consInfo.getStockNumber());
flow.setOperator(SecurityUtils.getCurrentUsername());
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoFlowRepository.save(flow);
}
@ -512,7 +512,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
flow.setConName(consInfo.getConName());
flow.setAmount(consInfo.getStockNumber());
flow.setBalance(consInfo.getStockNumber());
flow.setOperator(SecurityUtils.getCurrentUsername());
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoFlowRepository.save(flow);

View File

@ -62,6 +62,8 @@ public class TbProductStockDetailDto implements Serializable {
/** 关联订单Id */
private String orderId;
private String orderNo;
/** 1入库 -1出库 */
private Integer subType;

View File

@ -10,5 +10,6 @@ public class StockRecordMsg {
private String type;
private Integer subType;
private Integer number;
private String operator;
private String remark;
}

View File

@ -1,24 +1,10 @@
/*
* 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.mapper.product;
import cn.ysk.cashier.base.BaseMapper;
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
import cn.ysk.cashier.dto.product.TbProductStockDetailDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
/**
@ -29,4 +15,8 @@ import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TbProductStockDetailMapper extends BaseMapper<TbProductStockDetailDto, TbProductStockDetail> {
@Mapping(target = "orderNo", ignore = true)
TbProductStockDetailDto toDto(TbProductStockDetail entity);
}

View File

@ -208,6 +208,7 @@ public class StockServiceImpl implements StockService {
stockDetail.setUpdatedAt(System.currentTimeMillis());
stockDetail.setSourcePath("SHOP");
stockDetail.setRemark("一次性入库覆盖库存");
stockDetail.setOperator(SecurityUtils.getCurrentUsername());
if ("sku".equals(productIdStr)) {
Optional<TbProductSku> byId = skuRepository.findById(Double.valueOf(row.getCell(2).toString()).intValue());
if (byId.isPresent()) {
@ -393,6 +394,27 @@ public class StockServiceImpl implements StockService {
case "stockNumber"://库存
description.append(" 库存数量修改为:"+updateValueVO.getValue()+" 原库存:"+product.getStockNumber());
sqlQuery.append(" set stock_number = ").append(updateValueVO.getValue());
TbProductStockDetail detail=new TbProductStockDetail();
detail.setProductId(product.getId().toString());
detail.setProductName(product.getName());
detail.setShopId(product.getShopId());
detail.setOperator(SecurityUtils.getCurrentUsername());
detail.setSourcePath("NORMAL");
detail.setLeftNumber(product.getStockNumber());
detail.setStockNumber(new Double(Integer.valueOf(updateValueVO.getValue())-product.getStockNumber()));
TbShopUnit tbShopUnit = shopUnitRepository.findById(product.getUnitId()).orElse(null);
if(tbShopUnit!=null){
detail.setUnitName(tbShopUnit.getName());
}
if (product.getStockNumber() > Integer.valueOf(updateValueVO.getValue())) {
detail.setSubType(-1);
detail.setType("盘点出库");
} else {
detail.setSubType(1);
detail.setType("盘点入库");
}
detail.setCreatedAt(System.currentTimeMillis());
tbProductStockDetailRepository.save(detail);
break;
case "salePrice"://价格
description.append("修改价格为" + updateValueVO.getValue());

View File

@ -103,21 +103,17 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
-> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
Page<TbProductStockDetailDto> map = page.map(tbProductStockDetailMapper::toDto);
ArrayList<Map<String, Object>> contents = new ArrayList<>();
for (TbProductStockDetailDto tbProductStockDetailDto : map.getContent()) {
Map<String, Object> map1 = BeanUtil.transBean2Map(tbProductStockDetailDto);
if (StrUtil.isNotBlank(tbProductStockDetailDto.getOrderId())) {
TbOrderInfo tbOrderInfo = tbOrderInfoRepository.findById(Integer.valueOf(tbProductStockDetailDto.getOrderId())).orElse(null);
if (tbOrderInfo != null) {
map1.put("orderNo", tbOrderInfo.getOrderNo());
tbProductStockDetailDto.setOrderNo(tbOrderInfo.getOrderNo());
}
}
contents.add(map1);
tbProductStockDetailDto.setTypes();
}
Map<String,Object> info = new LinkedHashMap<>(2);
info.put("content",contents);
info.put("content",map.getContent());
info.put("totalElements",page.getTotalElements());
return info;
}

View File

@ -501,6 +501,7 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
productStockDetail.setStockSnap(JSONObject.toJSONString(snapItem));
productStockDetail.setSourcePath("CASHIER");
productStockDetail.setRemark(stockRecordMsg.getRemark());
productStockDetail.setOperator(stockRecordMsg.getOperator());
productStockDetailRepository.save(productStockDetail);
}