diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfoFlow.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfoFlow.java index 461630a3..6c778935 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfoFlow.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfoFlow.java @@ -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; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbConsInfoFlowDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbConsInfoFlowDto.java index ebbca0f0..6aa93f5b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbConsInfoFlowDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbConsInfoFlowDto.java @@ -53,7 +53,7 @@ public class TbConsInfoFlowDto implements Serializable { private String orderNo; private String coverImg; private String remark; - + private String operator; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java index 00f14d7a..b5658bc3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java @@ -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); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoFlowServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoFlowServiceImpl.java index 2aa8d71a..d805947c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoFlowServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoFlowServiceImpl.java @@ -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); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java index 4f0a8e04..a4b93b49 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java @@ -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); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductStockDetailDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductStockDetailDto.java index 74336128..9d010b18 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductStockDetailDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductStockDetailDto.java @@ -62,6 +62,8 @@ public class TbProductStockDetailDto implements Serializable { /** 关联订单Id */ private String orderId; + private String orderNo; + /** 1入库 -1出库 */ private Integer subType; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/rabbit/StockRecordMsg.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/rabbit/StockRecordMsg.java index 37920b1f..f288b39e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/rabbit/StockRecordMsg.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/rabbit/StockRecordMsg.java @@ -10,5 +10,6 @@ public class StockRecordMsg { private String type; private Integer subType; private Integer number; + private String operator; private String remark; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/product/TbProductStockDetailMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/product/TbProductStockDetailMapper.java index 1192666d..39677862 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/product/TbProductStockDetailMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/product/TbProductStockDetailMapper.java @@ -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 { + + + @Mapping(target = "orderNo", ignore = true) + TbProductStockDetailDto toDto(TbProductStockDetail entity); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java index cbfe7b46..bac4327d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java @@ -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 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()); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductStockDetailServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductStockDetailServiceImpl.java index 44f2c08f..81e1fcf3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductStockDetailServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductStockDetailServiceImpl.java @@ -103,21 +103,17 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Page map = page.map(tbProductStockDetailMapper::toDto); - ArrayList> contents = new ArrayList<>(); for (TbProductStockDetailDto tbProductStockDetailDto : map.getContent()) { - Map 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 info = new LinkedHashMap<>(2); - info.put("content",contents); + info.put("content",map.getContent()); info.put("totalElements",page.getTotalElements()); return info; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductStockOperateServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductStockOperateServiceImpl.java index 0fef070b..1bda9746 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductStockOperateServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductStockOperateServiceImpl.java @@ -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); }