package com.dk.mdm.service.ivt.outbound; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.dk.common.exception.BaseBusinessException; import com.dk.common.infrastructure.annotaiton.Pagination; import com.dk.common.infrastructure.constant.Constant; import com.dk.common.infrastructure.enums.ErrorCodeEnum; import com.dk.common.mapper.BaseMapper; import com.dk.common.model.pojo.PageList; import com.dk.common.response.ResponseCodeEnum; import com.dk.common.response.ResponseResultUtil; import com.dk.common.response.ResponseResultVO; import com.dk.common.service.BaseService; import com.dk.mdm.infrastructure.convert.ivt.OutboundConvert; import com.dk.mdm.infrastructure.convert.ivt.OutboundItemConvert; import com.dk.mdm.mapper.ivt.OutboundItemMapper; import com.dk.mdm.mapper.ivt.OutboundMapper; import com.dk.mdm.mapper.sale.OrderItemMapper; import com.dk.mdm.mapper.sale.OrderMapper; import com.dk.mdm.model.pojo.ivt.Outbound; import com.dk.mdm.model.pojo.ivt.OutboundItem; import com.dk.mdm.model.pojo.sale.Order; import com.dk.mdm.model.pojo.sale.OrderItem; import com.dk.mdm.model.query.ivt.OutboundItemQuery; import com.dk.mdm.model.query.ivt.OutboundQuery; import com.dk.mdm.model.response.ivt.InboundResponse; import com.dk.mdm.model.response.ivt.OutboundItemResponse; import com.dk.mdm.model.response.ivt.OutboundResponse; import com.dk.mdm.model.response.sale.OrderItemResponse; import com.dk.mdm.model.response.sale.OrderResponse; import com.dk.mdm.model.vo.ivt.OutboundItemVO; import com.dk.mdm.model.vo.ivt.OutboundVO; import com.dk.mdm.service.common.CommonService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; /** * @desc : 销售出库业务层 * @date : 2024/3/18 15:33 * @author : 寇珊珊 */ @Service public class OutboundSaleOrderService extends BaseService { @Override public BaseMapper getRepository() { return outboundMapper; } @Autowired private CommonService commonService; @Autowired private OutboundMapper outboundMapper; @Autowired private OutboundConvert outboundConvert; @Autowired private OutboundItemMapper outboundItemMapper; @Autowired private OutboundItemConvert outboundItemConvert; @Autowired private OrderMapper orderMapper; @Autowired private OrderItemMapper orderItemMapper; /** * @desc : 条件查询 * @date : 2024/3/18 11:20 * @author : 寇珊珊 */ @Pagination public ResponseResultVO> selectByCond(OutboundQuery outboundQuery) { return super.mergeListWithCount(outboundQuery, outboundMapper.selectByCond(outboundQuery), outboundMapper.countByCond(outboundQuery)); } /** * @desc : 查询明细 * @date : 2024/3/15 16:43 * @author : 寇珊珊 */ @Pagination public ResponseResultVO> selectOutBoundSaleOrderItemInfoById(String id) { Map result = new HashMap<>(); // 商品明细 List outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id)); result.put("itemList", outboundItemResponseList); // 收款 // 附件 return ResponseResultUtil.success(result); } /** * @desc : 销售出库新建 * @date : 2024/3/7 14:13 * @author : 寇珊珊 */ @Transactional(rollbackFor = {Exception.class}) public ResponseResultVO saleOrderOutboundInsert(OutboundVO outboundVO) { //region 总单 //获取 id/单号 Map codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.SALEORDER.getName(), false); outboundVO.setOutId(codeMap.get("outId").toString()). setOutNo(codeMap.get("outNote").toString()); //出库类型 outboundVO.setOutType(Constant.OutType.SALE.getName()); //自动入库标识 if (outboundVO.getAutomaticFlg()) { //已出库 outboundVO.setOutStatus(Constant.OutStatus.YICHUKU.getName()); } else { //出库中 outboundVO.setOutStatus(Constant.OutStatus.CHUKUZHONG.getName()); } //出库状态等于已出库 更新合计出库数量/金额 = 出库中数量/出库中金额 if (Constant.OutStatus.YICHUKU.getName().equals(outboundVO.getOutStatus())) { outboundVO .setOutQty(outboundVO.getOutingQty()) .setOutAmt(outboundVO.getOutingAmt()) .setOutingQty(BigDecimal.ZERO) .setOutingAmt(BigDecimal.ZERO) ; } else { outboundVO .setOutQty(BigDecimal.ZERO) .setOutAmt(BigDecimal.ZERO) ; } //实体转换 Outbound outbound = outboundConvert.convertToPo(outboundVO); outboundMapper.insert(outbound); //endregion //region 销售退货 if (outboundVO.getFromId() != null) { //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量) Order order = new Order(); order.setOrderId(outboundVO.getFromId()); //已出库 if (Constant.OutStatus.YICHUKU.getName().equals(outboundVO.getOutStatus())){ order.setOutingQty(outboundVO.getOutQty().negate()); order.setOutingAmt(outboundVO.getOutAmt().negate()); order.setOutQty(outboundVO.getOutQty()); order.setOutAmt(outboundVO.getOutAmt()); } //出库中 else{ order.setOutingQty(outboundVO.getOutingQty()); order.setOutingAmt(outboundVO.getOutingAmt()); } //根据id查询 OrderResponse orderResponse = orderMapper.selectById(outboundVO.getFromId()); //入库状态 String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()), orderResponse.getOutQty().add(order.getOutQty())); order.setOutStatus(outStatus); //修改 int countRow = orderMapper.updateById(order); //数量超出 if (countRow == 0) { throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage()); } } //endregion //region 明细 //校验明细 if (outboundVO.getItemList().size() == 0) { return ResponseResultUtil.error(ErrorCodeEnum.OUTBOUND_ITEM_NOT_EXIST.getCode(), ErrorCodeEnum.OUTBOUND_ITEM_NOT_EXIST.getMessage()); } for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) { //总单id outboundItemVO.setOutId(outboundVO.getOutId()); //出库类型 outboundItemVO.setOutType(outboundVO.getOutType()); //出库状态等于已出库 更新合计出库数量/金额 = 出库中数量/出库中金额 if (Constant.OutStatus.YICHUKU.getName().equals(outboundVO.getOutStatus())) { outboundItemVO .setOutQty(outboundItemVO.getOutingQty()) .setOutAmt(outboundItemVO.getOutingAmt()) .setOutingQty(BigDecimal.ZERO) .setOutingAmt(BigDecimal.ZERO) .setCostPrice(outboundItemVO.getPriceOut()) .setCostAmt(outboundItemVO.getOutQty().multiply(outboundItemVO.getPriceOut()).setScale(2, BigDecimal.ROUND_HALF_UP)) ; } else { outboundItemVO .setOutQty(BigDecimal.ZERO) .setOutAmt(BigDecimal.ZERO); } //入库状态 outboundItemVO.setOutStatus(outboundItemVO.getOutStatus()); //实体转换 OutboundItem outboundItem = outboundItemConvert.convertToPo(outboundItemVO); outboundItemMapper.insert(outboundItem); //endregion //region 销售退货明细 if (outboundItemVO.getFromItemId() != null) { //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量) OrderItem orderItem = new OrderItem(); orderItem.setItemId(outboundItemVO.getFromItemId()); //已出库 if (Constant.OutStatus.YICHUKU.getName().equals(outboundVO.getOutStatus())){ orderItem.setOutingQty(outboundVO.getOutQty().negate()); orderItem.setOutingAmt(outboundVO.getOutAmt().negate()); orderItem.setOutQty(outboundVO.getOutQty()); orderItem.setOutAmt(outboundVO.getOutAmt()); } //出库中 else{ orderItem.setOutingQty(outboundVO.getOutingQty()); orderItem.setOutingAmt(outboundVO.getOutingAmt()); } //根据id查询 OrderItemResponse orderItemResponse = orderItemMapper.selectById(outboundItemVO.getFromItemId()); //入库状态 String outStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()), orderItemResponse.getOutQty().add(orderItem.getOutQty())); orderItem.setOutStatus(outStatus); //修改 int countRow = orderItemMapper.updateById(orderItem); //数量超出 if (countRow == 0) { throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage()); } } //endregion } //endregion //todo 如果是已出库 调用库存 后续写库存这里补上 //region 库存 //endregion return ResponseResultUtil.success(outboundVO); } /** * @desc : 销售出库办理 * @date : 2024/3/7 15:47 * @author : 寇珊珊 */ @Transactional(rollbackFor = {Exception.class}) public ResponseResultVO saleOrderHandleOutbound(OutboundVO outboundVO) { //region 编辑明细 //校验明细 if (outboundVO.getItemList().size() == 0) { return ResponseResultUtil.error(ErrorCodeEnum.OUTBOUND_ITEM_NOT_EXIST.getCode(), ErrorCodeEnum.OUTBOUND_ITEM_NOT_EXIST.getMessage()); } for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) { if (outboundItemVO.getItemId() != null) { //查询原单 OutboundItemResponse outboundItemResponse = outboundItemMapper.selectById(outboundItemVO.getItemId()); //编辑明细 outboundItemVO .setOutQty(outboundItemResponse.getOutQty().add(outboundItemVO.getOutingQty())) .setOutAmt(outboundItemResponse.getOutAmt().add(outboundItemVO.getOutingAmt())) .setOutingQty(outboundItemResponse.getOutingQty().subtract(outboundItemVO.getOutingQty())) .setOutAmt(outboundItemResponse.getOutingAmt().subtract(outboundItemVO.getOutingAmt())) .setCostPrice(outboundItemVO.getPriceOut()) .setCostAmt(outboundItemVO.getOutQty().multiply(outboundItemVO.getPriceOut()).setScale(2, BigDecimal.ROUND_HALF_UP)) ; //出库状态 String outStatus = this.setOutStatus(outboundItemVO.getOutingQty(), outboundItemVO.getOutQty()); outboundItemVO.setOutStatus(outStatus); //实体转换 OutboundItem outboundItem = outboundItemConvert.convertToPo(outboundItemVO); //修改 outboundItemMapper.update(outboundItem, new UpdateWrapper().lambda() .eq(OutboundItem::getItemId, UUID.fromString(outboundItem.getItemId())) ); } //endregion //region 新建明细 else { outboundItemVO .setOutId(outboundItemVO.getOutId()) .setOutQty(outboundItemVO.getOutQty()) .setOutAmt(outboundItemVO.getOutAmt()) .setCostPrice(outboundItemVO.getPriceOut()) .setCostAmt(outboundItemVO.getOutQty().multiply(outboundItemVO.getPriceOut()).setScale(2, BigDecimal.ROUND_HALF_UP)) .setOutType(Constant.OutType.SALE.getName()); //入库状态 String outStatus = this.setOutStatus(outboundItemVO.getOutingQty(), outboundItemVO.getOutQty()); outboundItemVO.setOutStatus(outStatus); //实体转换 OutboundItem outboundItem = outboundItemConvert.convertToPo(outboundItemVO); //新建 outboundItemMapper.insert(outboundItem); } //endregion //region 销售订单明细 if (outboundItemVO.getFromItemId() != null) { //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量) OrderItem orderItem = new OrderItem(); orderItem.setItemId(outboundItemVO.getFromItemId()); orderItem.setOutingQty(outboundItemVO.getOutingQty()); orderItem.setOutingAmt(outboundItemVO.getOutingAmt()); orderItem.setOutQty(outboundItemVO.getOutQty()); orderItem.setOutAmt(outboundItemVO.getOutAmt()); //根据id查询 OrderItemResponse orderItemResponse = orderItemMapper.selectById(outboundItemVO.getFromItemId()); //出库状态 String outStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()), orderItemResponse.getOutQty().add(orderItem.getOutQty())); orderItem.setOutStatus(outStatus); //修改 int countRow = orderItemMapper.updateById(orderItem); //数量超出 if (countRow == 0) { throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage()); } } //endregion } //endregion //region 删除明细 todo 2024年3月20日13:17:33 这里可能用不到 // BigDecimal sumDelOutQty = BigDecimal.ZERO; // BigDecimal sumDelOutAmt = BigDecimal.ZERO; // BigDecimal sumDelOutingQty = BigDecimal.ZERO; // BigDecimal sumDelOutingAmt = BigDecimal.ZERO; // if (outboundVO.getDeleteItemList() != null) { // sumDelOutQty = outboundVO.getDeleteItemList().stream().map(OutboundItemVO::getOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP); // sumDelOutAmt = outboundVO.getDeleteItemList().stream().map(OutboundItemVO::getOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP); // sumDelOutingQty = outboundVO.getDeleteItemList().stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP); // sumDelOutingAmt = outboundVO.getDeleteItemList().stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP); // for (OutboundItemVO outboundItemVO : outboundVO.getDeleteItemList()) { // if (outboundItemVO.getItemId() != null) { // OutboundItem outboundItem = outboundItemConvert.convertToPo(outboundItemVO); // outboundItem.setFlgValid(false); // //修改 // outboundItemMapper.update(outboundItem, // new UpdateWrapper().lambda() // .eq(OutboundItem::getItemId, UUID.fromString(outboundItem.getItemId())) // ); // } // //region 销售退货明细 // if (outboundItemVO.getFromItemId() != null) { // //region 销售退货订单明细 // //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量) // OrderItem orderItem = new OrderItem(); // orderItem.setItemId(outboundItemVO.getFromItemId()); // orderItem.setOutingQty(outboundItemVO.getOutingQty().negate()); // orderItem.setOutingAmt(outboundItemVO.getOutingAmt().negate()); // orderItem.setOutQty(outboundItemVO.getOutQty().negate()); // orderItem.setOutAmt(outboundItemVO.getOutAmt().negate()); // //根据id查询 // OrderItemResponse orderItemResponse = orderItemMapper.selectById(outboundItemVO.getFromItemId()); // //出库状态 // String outStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()), orderItemResponse.getOutQty().add(orderItem.getOutQty())); // orderItem.setOutStatus(outStatus); // //修改 // int countRow = orderItemMapper.updateById(orderItem); // //数量超出 // if (countRow == 0) { // throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage()); // } // //endregion // } // //endregion // } // } //endregion //region 编辑总单 OutboundResponse outboundResponse = outboundMapper.selectById(outboundVO.getOutId()); BigDecimal sumOutQty = outboundVO.getItemList().stream().map(OutboundItemVO::getOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP); BigDecimal sumOutAmt = outboundVO.getItemList().stream().map(OutboundItemVO::getOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP); // BigDecimal sumOutingQty = outboundVO.getItemList().stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP); // BigDecimal sumOutingAmt = outboundVO.getItemList().stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP); outboundVO.setOutQty(sumOutQty); outboundVO.setOutAmt(sumOutAmt); outboundVO.setOutingQty(outboundResponse.getOutingQty().subtract(sumOutQty)); outboundVO.setOutingAmt(outboundResponse.getOutingAmt().subtract(sumOutAmt)); //出库状态 String outStatus = this.setOutStatus(outboundVO.getOutingQty(), outboundVO.getOutQty()); outboundVO.setOutStatus(outStatus); //实体转换 Outbound outbound = outboundConvert.convertToPo(outboundVO); //修改 outboundMapper.update(outbound, new UpdateWrapper().lambda() .eq(Outbound::getOutId, UUID.fromString(outbound.getOutId())) ); //endregion //region 修改销售退货订单 if (outboundVO.getFromId() != null) { //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量) Order order = new Order(); order.setOrderId(outboundVO.getFromId()); //region todo 2024年3月20日13:18:14 这里可能不用 // order.setOutingQty(sumOutQty.subtract(sumDelOutQty)); // order.setOutingAmt(sumOutAmt.subtract(sumDelOutAmt)); // order.setOutQty((sumOutingQty.add(sumDelOutingQty)).negate()); // order.setOutAmt((sumOutingAmt.add(sumDelOutingAmt)).negate()); //endregion order.setOutingQty(sumOutQty); order.setOutingAmt(sumOutAmt); order.setOutQty(sumOutQty.negate()); order.setOutAmt(sumOutAmt.negate()); //根据id查询 OrderResponse orderResponse = orderMapper.selectById(outboundVO.getFromId()); //出库状态 String orderOutStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()), orderResponse.getOutQty().add(order.getOutQty())); order.setOutStatus(orderOutStatus); //修改 int countRow = orderMapper.updateById(order); //数量超出 if (countRow == 0) { throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage()); } } //endregion //todo 如果是已出库 调用库存 后续写库存这里补上 //region 修改库存 //endregion return ResponseResultUtil.success(outboundVO); } /** * @desc : 销售出库撤销 * @date : 2024/3/7 17:06 * @author : 寇珊珊 */ @Transactional(rollbackFor = {Exception.class}) public ResponseResultVO saleOrderOutboundCancel(OutboundVO outboundVO) { //region 查询出库总单数据信息 OutboundResponse outboundResponse = outboundMapper.selectById(outboundVO.getOutId()); //endregion //region 修改订单数据信息 if (outboundResponse.getFromId() != null) { //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量) Order order = new Order(); order.setOrderId(outboundVO.getFromId()); order.setOutingQty(outboundVO.getOutingQty()); order.setOutingAmt(outboundVO.getOutingAmt()); order.setOutQty(outboundVO.getOutQty().negate()); order.setOutAmt(outboundVO.getOutAmt().negate()); //根据id查询 OrderResponse orderResponse = orderMapper.selectById(outboundVO.getFromId()); //出库状态 String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()), orderResponse.getOutQty().add(order.getOutQty())); order.setOutStatus(outStatus); //修改 int countRow = orderMapper.updateById(order); //数量超出 if (countRow == 0) { throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage()); } } //endregion //region 修改总单数据信息 Outbound outbound = new Outbound(); outbound.setOutId(outboundVO.getOutId()); outbound.setOutDate(null); outbound.setOutStatus(Constant.OutStatus.CHUKUZHONG.getName()); outbound.setOutQty(BigDecimal.ZERO); outbound.setOutAmt(BigDecimal.ZERO); //修改 outboundMapper.update(outbound, new UpdateWrapper().lambda() .eq(Outbound::getOutId, UUID.fromString(outbound.getOutId())) ); //endregion //region 明细数据 //根据总单id查明细 List outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(outboundVO.getOutId())); for (OutboundItemResponse outboundItemResponse : outboundItemResponseList) { //region 修改销售退货明细数据信息 if (outboundItemResponse.getFromItemId() != null) { //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量) OrderItem orderItem = new OrderItem(); orderItem.setItemId(outboundItemResponse.getFromItemId()); orderItem.setOutQty(outboundItemResponse.getOutQty().negate()); orderItem.setOutAmt(outboundItemResponse.getOutAmt().negate()); orderItem.setOutingQty(outboundItemResponse.getOutingQty()); orderItem.setOutingAmt(outboundItemResponse.getOutingAmt()); //根据id查询 OrderItemResponse orderItemResponse = orderItemMapper.selectById(outboundItemResponse.getFromItemId()); //出库状态 String outStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()), orderItemResponse.getOutQty().add(orderItem.getOutQty())); orderItem.setOutStatus(outStatus); //修改 int countRow = orderItemMapper.updateById(orderItem); //数量超出 if (countRow == 0) { throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage()); } } //endregion //region修改出库明细信息 OutboundItem outboundItem = new OutboundItem(); outboundItem .setOutId(outboundResponse.getOutId()) .setOutStatus(Constant.OutStatus.CHUKUZHONG.getName()) .setOutingQty(outboundItemResponse.getOutingQty().add(outboundItemResponse.getOutQty())) .setOutAmt(outboundItemResponse.getOutingAmt().add(outboundItemResponse.getOutAmt())) .setOutQty(BigDecimal.ZERO) .setOutAmt(BigDecimal.ZERO) .setCostPrice(BigDecimal.ZERO) .setCostAmt(BigDecimal.ZERO) .setItemId(outboundItemResponse.getItemId()); //修改 outboundItemMapper.update(outboundItem, new UpdateWrapper().lambda() .eq(OutboundItem::getItemId, UUID.fromString(outboundItem.getItemId())) ); //endregion } //endregion //todo 调用库存 后续写库存这里补上 //region 修改库存 //endregion return ResponseResultUtil.success(); } /** * @desc : 入库状态通用(目前本页面) * @date : 2024/3/9 8:59 * @author : 寇珊珊 */ public String setIntoStatus(BigDecimal intoingQty, BigDecimal intoQty) { //入库状态 String intoStatus = null; //已出库数量>0 出库中数量>0 if (intoQty.compareTo(BigDecimal.ZERO) > 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0) { //出库中 intoStatus = Constant.IntoStatus.RUKUZHONG.getName(); } //已出库数量=0 出库中数量=0 else if (intoQty.compareTo(BigDecimal.ZERO) == 0 && intoingQty.compareTo(BigDecimal.ZERO) == 0) { //待入库 intoStatus = Constant.IntoStatus.DAIRUKU.getName(); } //已出库数量>0 出库中数量=0 else if (intoQty.compareTo(BigDecimal.ZERO) > 0 && intoingQty.compareTo(BigDecimal.ZERO) == 0) { //已出库 intoStatus = Constant.IntoStatus.YIRUKU.getName(); } return intoStatus; } /** * @desc : 出库状态通用(目前本页面) * @date : 2024/3/9 8:59 * @author : 寇珊珊 */ public String setOutStatus(BigDecimal outingQty, BigDecimal outQty) { //出库状态 String outStatus = null; //已出库数量>0 出库中数量>0 if (outQty.compareTo(BigDecimal.ZERO) > 0 && outingQty.compareTo(BigDecimal.ZERO) > 0) { //出库中 outStatus = Constant.OutStatus.CHUKUZHONG.getName(); } //出入库数量=0 出库中数量=0 else if (outQty.compareTo(BigDecimal.ZERO) == 0 && outingQty.compareTo(BigDecimal.ZERO) == 0) { //待出库 outStatus = Constant.OutStatus.DAICHUKU.getName(); } //已出库数量>0 出库中数量=0 else if (outQty.compareTo(BigDecimal.ZERO) > 0 && outingQty.compareTo(BigDecimal.ZERO) == 0) { //已出库 outStatus = Constant.OutStatus.YICHUKU.getName(); } return outStatus; } /** * @desc : 获取单据信息(编辑用) * @date : 2024/3/16 16:28 * @author : 寇珊珊 */ public ResponseResultVO selectByUpdate(String id) { Map dataInfo = new HashMap<>(); //总单 OutboundResponse outboundResponse = outboundMapper.selectMessageByOtherQuery(new OutboundQuery().setOutId(id).setOutStatus(Constant.OutStatus.CHUKUZHONG.getName())); //单据不存在 if (outboundResponse == null) { return ResponseResultUtil.error(ErrorCodeEnum.THERE_ORDER_IS_NOT_CAN_OUTBOUND_QUANTITY.getCode(), ErrorCodeEnum.THERE_ORDER_IS_NOT_CAN_OUTBOUND_QUANTITY.getMessage()); } dataInfo.put("data", outboundResponse); // 明细 List outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(outboundResponse.getOutId())); dataInfo.put("dataItem", outboundItemResponseList); return ResponseResultUtil.success(dataInfo); } }