Commit ecb7b3fa authored by yanghao's avatar yanghao

task: #230 出货-入仓信息新增/修改

parent 0e9ab1d2
......@@ -105,6 +105,13 @@ public class OrderWarehouseInDO extends BaseDO {
*/
private String remark;
/**
* 出货后新添加的商品
*/
private Boolean isShipmentNewIn = false;
/**
* 入仓纪录明细VO
*/
......
......@@ -431,4 +431,15 @@ public interface ErrorCodeConstants {
ErrorCode ORDER_APPROVAL_IS_NOT_EXISTS = new ErrorCode(1004001171, "order.approval.is.not.exists");
ErrorCode FEE_APPLICATION_NOT_IS_ZERO = new ErrorCode(1004001172, "fee.application.not.is.zero");
ErrorCode GUAN_LIAN_ORDER_IS_APPROVAL_IN_PROCESS = new ErrorCode(1004001173, "guan.lian.order.is.approval.in.process");
//订单不是已装柜/已出货,不可操作
ErrorCode WAREHOUSE_IN_UPDATE_NOT_SHIPMENT = new ErrorCode(1004001181, "warehouse.in.update.not.shipment");
//订单已放货,无法修改
ErrorCode CARGO_CONTROL_ORDER_ALREADY_PICKED = new ErrorCode(1004001182, "cargo.control.order.already.picked");
//订单已提货,无法修改
ErrorCode CARGO_UNCONTROL_ORDER_ALREADY_PICKED = new ErrorCode(1004001183, "cargo.uncontrol.order.already.picked");
}
......@@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.customer.vo.zhongPao.ZhongPaoBestVO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderWarehouseIn.OrderWarehouseInDO;
import cn.iocoder.yudao.module.order.vo.order.OrderWarehouseInCommonAttrVO;
import cn.iocoder.yudao.module.order.vo.order.OrderWarehouseInWithAttrVO;
import cn.iocoder.yudao.module.order.vo.order.WarehouseInInfoVO;
import cn.iocoder.yudao.module.order.vo.orderItem.OrderItemBackVO;
......@@ -151,6 +150,23 @@ public interface OrderWarehouseInService extends IService<OrderWarehouseInDO> {
String updateOrUpdateApply(@Valid OrderWarehouseInUpdateApplyReqVO updateReqVO);
/**
* 出货阶段-追加申请
*
* @param createReqVO 创建信息
* @return 编号
*/
boolean appendApplyWhenShipment(@Valid OrderWarehouseInCreateReqVO createReqVO);
/**
* 出货阶段-入仓修改申请
* @param updateReqVO
* @return
*/
String updateApplyWhenShipment(@Valid OrderWarehouseInUpdateApplyReqVO updateReqVO);
/**
* 入仓修改回调
*
......
......@@ -116,6 +116,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
......@@ -133,7 +134,8 @@ import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.apollo.core.constants.Constants.NOT_ACCEPTED_PROD_CODE;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.*;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.WAREHOUSE_ROLLBACK;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.WAREHOUSE_UPDATE;
import static cn.iocoder.yudao.module.wealth.enums.ErrorCodeConstants.RECEIVABLE_WRITE_OFF_ING_NO_NEED_TO_PACK;
/**
......@@ -1327,23 +1329,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
// 保存箱号
if (finishReqVO.getUpdateLabel()) {
List<OrderLabelDto> labelDtoList = finishReqVO.getLabelList();
if (CollectionUtil.isEmpty(labelDtoList)) {
// 若没有标签号列表参数,则说明不是更新的,就查一下是否有1~sum的标签号,若有,就不需要再重新生成了。
List<OrderLabelBackVO> orderLabelBackVOS =
orderLabelService.getLabelListByOrder(orderId);
if (CollectionUtil.isNotEmpty(orderLabelBackVOS)
&& orderLabelBackVOS.size() == 1
&& orderLabelBackVOS.get(0).getEnd() == numSum2) {
// do nothing
labelDtoList = new ArrayList<>();
} else {
labelDtoList = CollectionUtil.newArrayList(new OrderLabelDto(null, 1, numSum2));
}
}
if (CollectionUtil.isNotEmpty(labelDtoList)) {
orderLabelService.saveOrUpdateLabel(SaveOrUpdateOrderLabelDto.builder().orderId(orderId).orderLabelDtoList(labelDtoList).isAddLog(false).build());
}
saveOrUpdateLabel(orderId, numSum2, labelDtoList);
}
// 针对未处理的异常,判断异常的orderItemId不在订单的orderItemList中的,
......@@ -1478,6 +1464,32 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
return exceptionNum > 0;
}
/**
* 保存标签号
* @param orderId 订单id
* @param numSum 总数量
* @param labelDtoList 编号集合,若不为空则直接更新。若为空,则更新为1~sum
*/
private void saveOrUpdateLabel(Long orderId, int numSum, List<OrderLabelDto> labelDtoList) {
if (CollectionUtil.isEmpty(labelDtoList)) {
// 若没有标签号列表参数,则说明不是更新的,就查一下是否有1~sum的标签号,若有,就不需要再重新生成了。
List<OrderLabelBackVO> orderLabelBackVOS =
orderLabelService.getLabelListByOrder(orderId);
if (CollectionUtil.isNotEmpty(orderLabelBackVOS)
&& orderLabelBackVOS.size() == 1
&& orderLabelBackVOS.get(0).getEnd() == numSum) {
// do nothing
labelDtoList = new ArrayList<>();
} else {
labelDtoList = CollectionUtil.newArrayList(new OrderLabelDto(null, 1, numSum));
}
}
if (CollectionUtil.isNotEmpty(labelDtoList)) {
orderLabelService.saveOrUpdateLabel(SaveOrUpdateOrderLabelDto.builder().orderId(orderId).orderLabelDtoList(labelDtoList).isAddLog(false).build());
}
}
private void processOrderPayException(Long orderId, OrderDO orderDO, Integer result) {
if (result == 1) {
List<OrderItemDO> payAdanceOrderItemList = orderItemService.getOrderItemsByOrderId(Arrays.asList(orderId)).stream()
......@@ -3413,151 +3425,670 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
}
@Override
@Transactional(rollbackFor = {Exception.class})
public void updateApplyCallback(String bizId, Integer result) {
// OrderWarehouseApprovalDO orderWarehouseApprovalDO = orderWarehouseApprovalService.selectOne(OrderWarehouseApprovalTypeEnum.WAREHOUSE_IN_UPDATE.getValue(), Long.parseLong(bizId));
OrderWarehouseApprovalDO orderWarehouseApprovalDO =
orderWarehouseApprovalService.getById(bizId);
private void compareOrderItemFieldAppend(OrderWarehouseInCreateReqVO createReqVO, OrderItemDO orderItemOld, List<ApplyInfoVO> applyInfoList) {
String prodName = String.format("商品:%s - ", orderItemOld.getProdTitleZh());
// 更新审批单状态
orderWarehouseApprovalService.callbackUpdate(orderWarehouseApprovalDO,
result);
Boolean isNew = createReqVO.getIsAppend();
if (isNew) {
prodName = String.format("出货追加新商品:%s - ", orderItemOld.getProdTitleZh());
}
long orderId = Long.parseLong(orderWarehouseApprovalDO.getOrderIds());
String processingResults = orderWarehouseApprovalDO.getProcessingResults();
// 通过
if (ApprovalResultStatusEnum.pass.getValue().equals(result)) {
// 将老的信息更新成新的信息
Long orderItemId = orderWarehouseApprovalDO.getOrderItemId();
OrderItemDO orderItemDO = orderItemService.getById(orderItemId);
OrderDO orderDO = orderService.getById(orderId);
BigDecimal sumVolumeBeforeUpdate = orderDO.getSumVolume();
BigDecimal sumWeightBeforeUpdate = orderDO.getSumWeight();
ApplyInfoVO infoVO;
if (isNew || !Objects.equals(orderItemOld.getProdId(), createReqVO.getProdId())) {
infoVO = new ApplyInfoVO();
infoVO.setName(isNew ? "新增商品" : "商品");
Long prodId = createReqVO.getProdId();
ProductDO productDONew = productService.getProduct(prodId);
infoVO.setNewValue(productDONew == null ? "空" : (I18nMessage.getLang() == 0 ? productDONew.getTitleZh() : productDONew.getTitleEn()));
applyInfoList.add(infoVO);
}
// 验证是否不可接受货物
this.validateProdAttrAccess(orderItemDO.getProdId(),
orderDO.getOrderNo());
if (isNew || !Objects.equals(orderItemOld.getBrand(), createReqVO.getBrand())) {
infoVO = new ApplyInfoVO();
infoVO.setName(prodName + "品牌");
if (isNew) {
infoVO.setOrgValue("空");
} else {
ProductBrankDO productBrankDOOld = productBrankMapper.selectById(orderItemOld.getBrand());
infoVO.setOrgValue(productBrankDOOld == null ? "无" : (I18nMessage.getLang() == 0 ? productBrankDOOld.getTitleZh() : productBrankDOOld.getTitleEn()));
}
ProductBrankDO productBrankDONew = productBrankMapper.selectById(createReqVO.getBrand());
infoVO.setNewValue(productBrankDONew == null ? "无" : (I18nMessage.getLang() == 0 ? productBrankDONew.getTitleZh() : productBrankDONew.getTitleEn()));
applyInfoList.add(infoVO);
}
// Integer brandTypeOld = orderItemOld.getBrandType();
// Integer brandTypeNew = updateReqVO.getBrandType();
// if (!Objects.equals(brandTypeOld, brandTypeNew)) {
// infoVO = new ApplyInfoVO();
// infoVO.setName(prodName + "是否备案");
// infoVO.setOrgValue(brandTypeOld.equals(0) ? "无备案" : (brandTypeOld.equals(1) ? "有备案" : "中性"));
// infoVO.setNewValue(brandTypeNew.equals(0) ? "无备案" : (brandTypeNew.equals(1) ? "有备案" : "中性"));
// applyInfoList.add(infoVO);
// }
if (isNew || !Objects.equals(orderItemOld.getFeeType(), createReqVO.getFeeType())) {
// 通过orderItemId查询db中的 orderWarehouseInDO
List<OrderWarehouseInDO> orderWarehouseInListOld =
orderWarehouseInMapper
.selectList(new LambdaQueryWrapperX<OrderWarehouseInDO>().eq(OrderWarehouseInDO::getOrderId, orderId)
.eq(OrderWarehouseInDO::getOrderItemId, orderItemId));
infoVO = new ApplyInfoVO();
infoVO.setName(prodName + "收费模式");
if (isNew) {
infoVO.setOrgValue("空");
} else {
infoVO.setOrgValue(orderItemOld.getFeeType().equals(0) ? "无牌价" : (orderItemOld.getFeeType().equals(1) ? "有牌价" : "中性品牌价"));
}
infoVO.setNewValue(createReqVO.getFeeType().equals(0) ? "无牌价" : (createReqVO.getFeeType().equals(1) ? "有牌价" : "中性品牌价"));
applyInfoList.add(infoVO);
}
String details = orderWarehouseApprovalDO.getDetails();
if (StringUtils.isNotEmpty(details)) {
OrderWarehouseInUpdateApplyReqVO updateReqVO =
JSON.parseObject(details, OrderWarehouseInUpdateApplyReqVO.class);
// 先更新入仓
List<OrderWarehouseInItemDto> orderWarehouseInItemDtoListNew =
updateReqVO.getOrderWarehouseInUpdateItemDoList();
// 统计总入仓数量,体积,重量
List<OrderWarehouseInItemDto> orderWarehouseInItemDoList = createReqVO.getOrderWarehouseInItemDoList();
Integer totalNum = orderWarehouseInItemDoList.stream().map(OrderWarehouseInItemDto::getCartonsNum).reduce(0, Integer::sum);
BigDecimal totalVolume = orderWarehouseInItemDoList.stream().map(OrderWarehouseInItemDto::getVolume).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalWeight = orderWarehouseInItemDoList.stream().map(OrderWarehouseInItemDto::getWeight).reduce(BigDecimal.ZERO, BigDecimal::add);
ZhongPaoBestVO zhongPaoBest = getZhongPaoBest(orderDO);
BigDecimal zhongEdge = zhongPaoBest != null ? zhongPaoBest.getZhongEdge() : null;
BigDecimal paoEdge = zhongPaoBest != null ? zhongPaoBest.getPaoEdge() : null;
Integer numOld = 0;
BigDecimal volumeOld = BigDecimal.ZERO;
BigDecimal weightOld = BigDecimal.ZERO;
if (CollectionUtil.isNotEmpty(orderWarehouseInItemDtoListNew)) {
if (!isNew) {
// 统计原来的入仓数理,体积,重量
WarehouseInInfoVO warehouseInInfoVO = orderItemOld.getWarehouseInInfoVO();
numOld = warehouseInInfoVO == null ? 0 : warehouseInInfoVO.getCartonsNum();
// 体积
volumeOld = warehouseInInfoVO == null ? BigDecimal.ZERO : warehouseInInfoVO.getVolume();
// 重量
weightOld = warehouseInInfoVO == null ? BigDecimal.ZERO : warehouseInInfoVO.getWeight();
}
// 2023-04-20 1.入仓修改可以添加入仓记录,添加审核通过后,入仓时间为提交入仓的系统时间,无需选择入仓时间。
Date inTime = orderWarehouseApprovalDO.getCreateTime();
// 1、新增 (只有新增的可能有储位,修改储位是直接调用修改接口的。)
List<OrderWarehouseInItemDto> addList =
orderWarehouseInItemDtoListNew.stream().filter(t -> t.getId() == null).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(addList)) {
for (OrderWarehouseInItemDto orderWarehouseInItemDto : addList) {
infoVO = new ApplyInfoVO();
infoVO.setName(prodName + "填单数量");
infoVO.setOrgValue(numOld != null ? numOld.toString() : "0");
infoVO.setNewValue(totalNum != null ? totalNum.toString() : "0");
applyInfoList.add(infoVO);
OrderWarehouseInDO orderWarehouseInDO = convertOrderWarehouseInItemDo(orderDO, orderItemId, zhongPaoBest, zhongEdge, paoEdge, orderWarehouseInItemDto, inTime);
orderWarehouseInMapper.insert(orderWarehouseInDO);
// 体积
infoVO = new ApplyInfoVO();
infoVO.setName(prodName + "填单体积");
infoVO.setOrgValue(volumeOld != null ? volumeOld.toPlainString() : "0");
infoVO.setNewValue(totalVolume.toPlainString());
applyInfoList.add(infoVO);
// 保存储位
List<OrderLocationCreateReqVO> orderLocationCreateReqVOList = orderWarehouseInItemDto.getOrderLocationCreateReqVOList();
if (CollectionUtil.isNotEmpty(orderLocationCreateReqVOList)) {
for (OrderLocationCreateReqVO orderLocationCreateReqVO : orderLocationCreateReqVOList) {
// 设置入仓纪录id
orderLocationCreateReqVO.setWarehouseInId(orderWarehouseInDO.getId());
orderLocationService.createOrderLocation(orderLocationCreateReqVO);
}
// 重量
infoVO = new ApplyInfoVO();
infoVO.setName(prodName + "填单重量");
infoVO.setOrgValue(weightOld != null ? weightOld.toPlainString() : "0");
infoVO.setNewValue(totalWeight.toPlainString());
applyInfoList.add(infoVO);
if (!Objects.equals(orderItemOld.getMaterial(), createReqVO.getMaterial())) {
String materialOld = orderItemOld.getMaterial();
String materialNew = createReqVO.getMaterial();
infoVO = new ApplyInfoVO();
infoVO.setName(prodName + "材质");
if (!isNew && StringUtils.isNotEmpty(materialOld)) {
DictDataRespDTO material = DictFrameworkUtils.getDictDataFromCache("product_material", materialOld);
String labelEn = material != null ? material.getLabelEn() : materialOld;
String label = material != null ? material.getLabel() : materialOld;
infoVO.setOrgValue(I18nMessage.getLang() == 0 ? label : labelEn);
} else {
infoVO.setOrgValue("空");
}
if (StringUtils.isNotEmpty(materialNew)) {
DictDataRespDTO material = DictFrameworkUtils.getDictDataFromCache("product_material", materialNew);
String labelEn = material != null ? material.getLabelEn() : materialNew;
String label = material != null ? material.getLabel() : materialNew;
infoVO.setNewValue(I18nMessage.getLang() == 0 ? label : labelEn);
} else {
infoVO.setNewValue("空");
}
applyInfoList.add(infoVO);
}
// 2、更新 //2023-04-20 入仓修改若修改已有入仓记录,
// 有改动(储位或其他信息修改)修改入仓记录的最新操作时间,
// 不修改入仓时间,不修改未发生变化的入仓记录的入仓时间和最新操作时间。
if (CollectionUtil.isNotEmpty(orderWarehouseInItemDtoListNew)) {
//更新的
List<OrderWarehouseInItemDto> orderWarehouseInItemDtoListUpdate =
orderWarehouseInItemDtoListNew.stream().filter(t -> t.getId() != null
&& orderWarehouseInListOld.stream().anyMatch(old -> old.getId().equals(t.getId()))).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(orderWarehouseInItemDtoListUpdate)) {
String warehouseInProdAttrIdsNew = createReqVO.getWarehouseInProdAttrIds();
String warehouseInProdAttrIdsOld = isNew == null ? "" : StringUtils.isNotEmpty(orderItemOld.getWarehouseInProdAttrIds()) ? orderItemOld.getWarehouseInProdAttrIds() : orderItemOld.getProdAttrIds();
String prodAttrIdsSortOld = isNew == null ? "" : StringUtils.isNotEmpty(warehouseInProdAttrIdsOld) ?
Arrays.stream(warehouseInProdAttrIdsOld.split(",")).filter(Objects::nonNull).sorted(Comparator.comparingInt(Integer::parseInt)).collect(Collectors.joining(",")) : "";
for (OrderWarehouseInItemDto itemDtoNew :
orderWarehouseInItemDtoListUpdate) {
String prodAttrIdsSortNew = StringUtils.isNotEmpty(warehouseInProdAttrIdsNew) ?
Arrays.stream(warehouseInProdAttrIdsNew.split(",")).filter(Objects::nonNull).sorted(Comparator.comparingInt(Integer::parseInt)).collect(Collectors.joining(",")) : "";
OrderWarehouseInDO orderWarehouseInDONew =
convertOrderWarehouseInItemDo(orderDO, orderItemId, zhongPaoBest, zhongEdge, paoEdge, itemDtoNew, inTime);
if (!Objects.equals(prodAttrIdsSortOld, prodAttrIdsSortNew)) {
// 判断有无变化
OrderWarehouseInDO old = orderWarehouseInMapper.selectById(itemDtoNew.getId());
List<ApplyInfoVO> applyInfoVOListTmp = new ArrayList<>();
compareOrderWarehouseInField("", Arrays.asList(old), Arrays.asList(itemDtoNew), applyInfoVOListTmp);
// 有变化才更新
if (CollectionUtil.isNotEmpty(applyInfoVOListTmp)) {
orderWarehouseInMapper.updateById(orderWarehouseInDONew);
infoVO = new ApplyInfoVO();
infoVO.setName(prodName + "入仓商品特性");
applyInfoVOListTmp.clear();
if (StringUtils.isNotEmpty(warehouseInProdAttrIdsOld)) {
List<ProductAttrDO> productAttrDOS = productAttrMapper.selectBatchIds(Arrays.asList(warehouseInProdAttrIdsOld.split(StrUtil.COMMA)));
if (CollectionUtil.isNotEmpty(productAttrDOS)) {
infoVO.setOrgValue(I18nMessage.getLang() == 0 ? productAttrDOS.stream().map(ProductAttrDO::getAttrName).collect(Collectors.joining(","))
: productAttrDOS.stream().map(ProductAttrDO::getAttrNameEn).collect(Collectors.joining(",")));
} else {
//20230821 fix: #4304 订单完成入仓后修改商品名称未更新最后入仓时间
Long warehouseInId = orderWarehouseInDONew.getId();
this.update(new LambdaUpdateWrapper<OrderWarehouseInDO>()
.set(OrderWarehouseInDO::getUpdater,
WebFrameworkUtils.getLoginUserId() + "")
.set(OrderWarehouseInDO::getUpdateTime, new Date())
.eq(OrderWarehouseInDO::getId, warehouseInId));
}
infoVO.setOrgValue("空");
}
} else {
infoVO.setOrgValue("空");
}
// 3、删除
List<Long> deleteIds = orderWarehouseInListOld.stream()
.filter(old -> orderWarehouseInItemDtoListNew.stream().noneMatch(n -> old.getId().equals(n.getId()))).map(OrderWarehouseInDO::getId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(deleteIds)) {
orderWarehouseInMapper.deleteBatchIds(deleteIds);
if (StringUtils.isNotEmpty(warehouseInProdAttrIdsNew)) {
List<ProductAttrDO> productAttrDOS = productAttrMapper.selectBatchIds(Arrays.asList(warehouseInProdAttrIdsNew.split(StrUtil.COMMA)));
if (CollectionUtil.isNotEmpty(productAttrDOS)) {
infoVO.setNewValue(I18nMessage.getLang() == 0 ? productAttrDOS.stream().map(ProductAttrDO::getAttrName).collect(Collectors.joining(","))
: productAttrDOS.stream().map(ProductAttrDO::getAttrNameEn).collect(Collectors.joining(",")));
} else {
infoVO.setNewValue("空");
}
} else {
infoVO.setNewValue("空");
}
applyInfoList.add(infoVO);
}
// 3、删除
else {
List<Long> deleteIds =
orderWarehouseInListOld.stream().map(OrderWarehouseInDO::getId).collect(Collectors.toList());
orderWarehouseInMapper.deleteBatchIds(deleteIds);
//根据订单ID删除储位
orderLocationService.deleteIfPresent(orderId, null, null);
// 入仓影像
List<String> pictureUrls =
CollectionUtil.isNotEmpty(createReqVO.getPictureUrls()) ? createReqVO.getPictureUrls() : new ArrayList<>();
List<String> pictureUrlsOld = isNew ? new ArrayList<>() :
orderWarehousePictureService.getWarehousePictureUrlList(5,
orderItemOld.getOrderItemId());
if (pictureUrlsOld.size() != pictureUrls.size() ||
pictureUrlsOld.containsAll(pictureUrls)) {
infoVO = new ApplyInfoVO();
infoVO.setName(prodName + "入仓影像");
infoVO.setOrgValue((CollectionUtil.isEmpty(pictureUrlsOld) ? 0 : pictureUrlsOld.size()) + "个");
infoVO.setNewValue((CollectionUtil.isEmpty(pictureUrls) ? 0 : pictureUrls.size()) + "个");
applyInfoList.add(infoVO);
}
orderItemDO.setNum(updateReqVO.getNum());
orderItemDO.setVolume(updateReqVO.getVolume());
orderItemDO.setWeight(updateReqVO.getWeight());
orderItemDO.setMaterial(updateReqVO.getMaterial());
orderItemDO.setWarehouseInProdAttrIds(updateReqVO.getWarehouseInProdAttrIds());
orderItemDO.setBrand(Objects.isNull(updateReqVO.getBrand()) ? 0L : updateReqVO.getBrand());// 使用的跟新方法不会将null值更新到数据库,所以给默认值0
orderItemDO.setProdType(updateReqVO.getProdType());
orderItemDO.setProdTitleZh(updateReqVO.getProdTitleZh());
orderItemDO.setProdTitleEn(updateReqVO.getProdTitleEn());
orderItemDO.setUsageIds(StringUtils.isEmpty(updateReqVO.getUsageIds()) ? "" : updateReqVO.getUsageIds());
// 入仓商品用途
String usageIdsNew = createReqVO.getUsageIds();
String usageIdsOld = isNew ? null : orderItemOld.getUsageIds();
String usageIdsSortOld = StringUtils.isNotEmpty(usageIdsOld) ?
Arrays.stream(usageIdsOld.split(",")).filter(Objects::nonNull).sorted(Comparator.comparingInt(Integer::parseInt)).collect(Collectors.joining(",")) : null;
String usageIdsSortNew = StringUtils.isNotEmpty(usageIdsNew) ?
Arrays.stream(usageIdsNew.split(",")).filter(Objects::nonNull).sorted(Comparator.comparingInt(Integer::parseInt)).collect(Collectors.joining(",")) : null;
Long prodIdNew = updateReqVO.getProdId();
if (!Objects.equals(usageIdsSortOld, usageIdsSortNew)) {
infoVO = new ApplyInfoVO();
infoVO.setName(prodName + "入仓商品用途");
if (StringUtils.isNotEmpty(usageIdsOld)) {
StringJoiner labelEnJoiner = new StringJoiner(",");
StringJoiner labelJoiner = new StringJoiner(",");
for (String usageId : usageIdsOld.split(",")) {
DictDataRespDTO usageValue = DictFrameworkUtils.getDictDataFromCache("order_item_usage", usageId);
if (usageValue != null) {
labelEnJoiner.add(usageValue.getLabelEn());
labelJoiner.add(usageValue.getLabel());
}
}
infoVO.setOrgValue(I18nMessage.getLang() == 0 ? labelJoiner.toString() : labelEnJoiner.toString());
} else {
infoVO.setOrgValue("空");
}
if (StringUtils.isNotEmpty(usageIdsNew)) {
StringJoiner labelEnJoiner = new StringJoiner(",");
StringJoiner labelJoiner = new StringJoiner(",");
for (String usageId : usageIdsNew.split(",")) {
DictDataRespDTO usageValue = DictFrameworkUtils.getDictDataFromCache("order_item_usage", usageId);
if (usageValue != null) {
labelEnJoiner.add(usageValue.getLabelEn());
labelJoiner.add(usageValue.getLabel());
}
}
infoVO.setNewValue(I18nMessage.getLang() == 0 ? labelJoiner.toString() : labelEnJoiner.toString());
} else {
infoVO.setNewValue("空");
}
applyInfoList.add(infoVO);
}
}
@Override
public boolean appendApplyWhenShipment(OrderWarehouseInCreateReqVO createReqVO) {
Long orderId = createReqVO.getOrderId();
Long brand = createReqVO.getBrand();
Long orderItemId = createReqVO.getOrderItemId();
Long prodId = createReqVO.getProdId();
List<OrderWarehouseInItemDto> orderWarehouseInItemDoList =
createReqVO.getOrderWarehouseInItemDoList();
// 非下单货物,请求中包含
String prodTitleZh = createReqVO.getProdTitleZh();
String prodTitleEn = createReqVO.getProdTitleEn();
OrderItemDO orderItemDO = null;
// 下单货物,
if (orderItemId != null) {
orderItemDO = orderItemService.selectOne(OrderItemDO::getOrderItemId,
orderItemId);
prodTitleZh = orderItemDO.getProdTitleZh();
prodTitleEn = orderItemDO.getProdTitleEn();
}
OrderDO orderDO = orderService.getById(orderId);
if (orderDO == null) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_NOT_EXISTS);
}
if (OrderStatusEnum.DRAFT.getValue().equals(orderDO.getStatus())) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_DRAFT_STATUS_NOT_ALLOWED_WAREHOUSE_IN);
}
if (OrderStatusEnum.WAREHOUSE_ADJUSTMENT.getValue().equals(orderDO.getStatus())) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_WAREHOUSE_ADJUSTMENT_STATUS_NOT_ALLOWED_WAREHOUSE_IN);
}
// 校验是否有已核销的应收单,如果有,则不能再次入仓修改
receivableService.verificationReceivableIsWriteOff(orderId, null);
// 入仓追加必须处于已装货柜或者出货阶段
if (!(orderDO.getShipmentState() > 0 && orderDO.getInWarehouseState() == 0)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.WAREHOUSE_IN_UPDATE_NOT_SHIPMENT);
}
// 订单有提货记录或放货记录,弹出提示“**订单已放货/提货,无法修改**”,不允许提交
if (Objects.equals(OrderStatusEnum.PICKED_UP.getValue(), orderDO.getStatus())
|| Objects.equals(OrderStatusEnum.PART_PICKED_UP.getValue(), orderDO.getStatus())) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.CARGO_UNCONTROL_ORDER_ALREADY_PICKED);
}
// 控货订单->部分控货和已放完货的订单不支持入仓修改
if (orderDO.getIsCargoControl() && orderDO.getCargoControlStatus() > 0) {
throw exception(CARGO_CONTROL_ORDER_ALREADY_PICKED);
}
// 判断是否有未处理的审核单
orderQueryService.throwProcessingApproval(orderId, WAREHOUSE_UPDATE);
this.validateProdAttrAccess(createReqVO.getProdId(),
orderDO.getOrderNo());
validateWarehouseInItem(orderDO,
brand,
orderWarehouseInItemDoList,
prodTitleZh,
prodTitleEn);
// 若已经存在入仓纪录,则就是追加。
List<OrderWarehouseInDO> orderWarehouseInDOS =
orderWarehouseInMapper.selectList(new LambdaQueryWrapperX<OrderWarehouseInDO>()
.eq(OrderWarehouseInDO::getOrderId, orderId).eq(OrderWarehouseInDO::getOrderItemId, orderItemId));
boolean isAppend = CollectionUtil.isNotEmpty(orderWarehouseInDOS);
createReqVO.setIsAppend(isAppend);
List<ApplyInfoVO> applyInfoList = new ArrayList<>();
compareOrderItemFieldAppend(createReqVO, orderItemDO, applyInfoList);
// 设置差异对象
createReqVO.setApplyInfoVOList(applyInfoList);
// 将createReqVo转换为 updateApplyReqVo
OrderWarehouseInUpdateApplyReqVO updateApplyReqVO = new OrderWarehouseInUpdateApplyReqVO();
BeanUtils.copyProperties(createReqVO, updateApplyReqVO);
updateApplyReqVO.setOrderWarehouseInUpdateItemDoList(createReqVO.getOrderWarehouseInItemDoList());
updateApplyReqVO.setIsShipmentAppend(true);
String details = JSON.toJSONString(updateApplyReqVO);
log.info("出货后入仓追加json = {}", details);
OrderWarehouseApprovalDO orderWarehouseApprovalDO =
OrderWarehouseApprovalDO.builder()
.orderIds(orderId.toString())
.orderItemId(createReqVO.getOrderItemId())
.type(OrderWarehouseApprovalTypeEnum.WAREHOUSE_IN_UPDATE.getValue())
.followUpAdminId(WebFrameworkUtils.getLoginUserId())
.details(details).build();
// 创建审核单,发起审批流程
orderWarehouseApprovalService.applyAndCreate(orderWarehouseApprovalDO,
WorkFlowEmus.ORDER_WAREHOUSING_MODIFICATION,
createReqVO.getCopyUserId());
// 更新订单状态
Integer auditType = OrderApprovalTypeResultEnum.warehouse_update_processing.getType();
orderService.updateStatus(orderId, null, null, null,
null, null, auditType, OrderApprovalTypeResultEnum.typeAndResultOf(auditType, 1).getDesc(), false);
orderBusinessService.addOrderOperateLog(orderId, "仓库操作",
"航运中-追加-" + (isAppend ? "添加新品名" : "入仓"), applyInfoList);
// 返回
return true;
}
@Override
@Transactional(rollbackFor = {Exception.class})
public String updateApplyWhenShipment(@Valid OrderWarehouseInUpdateApplyReqVO updateReqVO) {
// 处理删除记录失效的问题
Long orderId = updateReqVO.getOrderId();
Long orderItemId = updateReqVO.getOrderItemId();
Long prodId = updateReqVO.getProdId();
Long brand = updateReqVO.getBrand();
// 设置是否备案和收费模式
GetFeeTypeProductBrandEmpowerRespVO feeTypeByOrder =
getGetFeeTypeProductBrandEmpowerRespVO(orderId, prodId, brand);
if (feeTypeByOrder != null) {
// //当订单项的brandType为null时才设置。(说明是新品入仓)
// if (StringUtils.isNotEmpty(feeTypeByOrder.getRecordMode())) {
// updateReqVO.setBrandType(Integer.parseInt(feeTypeByOrder.getRecordMode()));
// }
if (StringUtils.isNotEmpty(feeTypeByOrder.getFeeType())) {
updateReqVO.setFeeType(Integer.parseInt(feeTypeByOrder.getFeeType()));
}
}
//如仓记录项
List<OrderWarehouseInItemDto> orderWarehouseInUpdateItemDoList =
updateReqVO.getOrderWarehouseInUpdateItemDoList();
ProductDO productDO = productService.getProduct(prodId);
if (productDO == null) {
throw exception(PROD_NOT_EXISTS);
}
OrderDO orderDO = orderService.getById(orderId);
if (orderDO == null) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_NOT_EXISTS);
}
if (OrderStatusEnum.WAREHOUSE_ADJUSTMENT.getValue().equals(orderDO.getStatus())) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_WAREHOUSE_ADJUSTMENT_STATUS_NOT_ALLOWED_WAREHOUSE_IN);
}
this.validateProdAttrAccess(prodId, orderDO.getOrderNo());
String prodTitleZh = productDO.getTitleZh();
String prodTitleEn = productDO.getTitleEn();
// 校验是否有已核销的应收单,如果有,则不能再次入仓修改
receivableService.verificationReceivableIsWriteOff(orderId, null);
// 入仓修改必须处于已装货柜或者出货阶段
if (!(orderDO.getShipmentState() > 0 && orderDO.getInWarehouseState() == 0)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.WAREHOUSE_IN_UPDATE_NOT_SHIPMENT);
}
// 订单有提货记录或放货记录,弹出提示“**订单已放货/提货,无法修改**”,不允许提交
if (Objects.equals(OrderStatusEnum.PICKED_UP.getValue(), orderDO.getStatus())
|| Objects.equals(OrderStatusEnum.PART_PICKED_UP.getValue(), orderDO.getStatus())) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.CARGO_UNCONTROL_ORDER_ALREADY_PICKED);
}
// 控货订单->部分控货和已放完货的订单不支持入仓修改
if (orderDO.getIsCargoControl() && orderDO.getCargoControlStatus() > 0) {
throw exception(CARGO_CONTROL_ORDER_ALREADY_PICKED);
}
validateWarehouseInItem(orderDO, brand,
orderWarehouseInUpdateItemDoList, prodTitleZh, prodTitleEn);
if (CollectionUtil.isEmpty(updateReqVO.getPictureUrls())) {
throw exception(ErrorCodeConstants.ORDER_WAREHOUSE_IN_PICTURE_NOT_NULL);
}
// 添加订单仓库操作日志
OrderItemDO orderItemOld = orderItemService.selectOne(OrderItemDO::getOrderItemId, orderItemId);
// 通过orderItemId查询db中的 orderWarehouseInDO
List<OrderWarehouseInDO> orderWarehouseInListOld = orderWarehouseInMapper
.selectList(new LambdaQueryWrapperX<OrderWarehouseInDO>().eq(OrderWarehouseInDO::getOrderId, orderId)
.eq(OrderWarehouseInDO::getOrderItemId, orderItemId));
// 需要提交审批,则不能有其他任何审批
orderQueryService.throwProcessingApproval(orderId, WAREHOUSE_UPDATE);
List<ApplyInfoVO> applyInfoList = new ArrayList<>();
// 处理每一个属性
compareOrderItemField(updateReqVO, orderItemOld, applyInfoList);
// 开始处理入仓纪录
compareOrderWarehouseInField(orderItemOld.getProdTitleZh(),
orderWarehouseInListOld,
orderWarehouseInUpdateItemDoList,
applyInfoList);
if (CollectionUtil.isNotEmpty(applyInfoList)) {
// 仅有入仓明细直接更新,不提交审批
if (applyInfoList.size() == 1 &&
applyInfoList.get(0).getName().endsWith("入仓明细")) {
updateOrderWarehouseInDetails(orderItemId, orderWarehouseInUpdateItemDoList, orderWarehouseInListOld);
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "货物入仓明细单独修改", "");
return I18nMessage.getMessage("order.warehousein.details.update.finished");
}
// 仅有入仓影像直接更新,不提交审批
else if (applyInfoList.size() == 1 &&
applyInfoList.get(0).getName().endsWith("入仓影像")) {
// 影像
orderWarehousePictureService.createWarehousePictureBatch(updateReqVO.getPictureUrls(), 5, orderItemId);
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "货物入仓影像单独修改", applyInfoList);
return I18nMessage.getMessage("order.warehousein.image.update.finished");
}
// 仅有入仓明细和入仓影像直接更新,不提交审批
else if (applyInfoList.size() == 2 &&
applyInfoList.get(0).getName().endsWith("入仓影像") && applyInfoList.get(1).getName().endsWith("入仓明细")) {
// 影像
orderWarehousePictureService.createWarehousePictureBatch(updateReqVO.getPictureUrls(), 5, orderItemId);
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "货物入仓影像修改", applyInfoList);
// 入仓明细更新
updateOrderWarehouseInDetails(orderItemId, orderWarehouseInUpdateItemDoList, orderWarehouseInListOld);
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "货物入仓明细修改", "");
return I18nMessage.getMessage("order.warehousein.image.and.details.update.finished");
}
// 包含其他更新 发起审核流程
else {
// 删除入仓明细的比较,因为纪录的值会很长,没意义。
applyInfoList.removeIf(t -> t.getName().endsWith("入仓明细"));
// 设置差异对象
updateReqVO.setApplyInfoVOList(applyInfoList);
String details = JSON.toJSONString(updateReqVO);
log.info("出货后入仓修改json = {}", details);
OrderWarehouseApprovalDO orderWarehouseApprovalDO =
OrderWarehouseApprovalDO.builder()
.orderIds(orderId.toString())
.orderItemId(updateReqVO.getOrderItemId())
.type(OrderWarehouseApprovalTypeEnum.WAREHOUSE_IN_UPDATE.getValue())
.followUpAdminId(WebFrameworkUtils.getLoginUserId())
.details(details).build();
// 创建审核单,发起审批流程
orderWarehouseApprovalService.applyAndCreate(orderWarehouseApprovalDO,
WorkFlowEmus.ORDER_WAREHOUSING_MODIFICATION,
updateReqVO.getCopyUserId());
// 更新订单状态
Integer auditType = OrderApprovalTypeResultEnum.warehouse_update_processing.getType();
orderService.updateStatus(orderId, null, null, null,
null, null, auditType, OrderApprovalTypeResultEnum.typeAndResultOf(auditType, 1).getDesc(), false);
orderBusinessService.addOrderOperateLog(orderId, "仓库操作",
"航运中-提交货物入仓修改", applyInfoList);
}
return I18nMessage.getMessage("order.warehousein.update.apply.success");
} else {
return I18nMessage.getMessage("order.warehousein.update.nothing");
}
}
@Override
@Transactional(rollbackFor = {Exception.class})
public void updateApplyCallback(String bizId, Integer result) {
// OrderWarehouseApprovalDO orderWarehouseApprovalDO = orderWarehouseApprovalService.selectOne(OrderWarehouseApprovalTypeEnum.WAREHOUSE_IN_UPDATE.getValue(), Long.parseLong(bizId));
OrderWarehouseApprovalDO orderWarehouseApprovalDO =
orderWarehouseApprovalService.getById(bizId);
// 更新审批单状态
orderWarehouseApprovalService.callbackUpdate(orderWarehouseApprovalDO,
result);
long orderId = Long.parseLong(orderWarehouseApprovalDO.getOrderIds());
String processingResults = orderWarehouseApprovalDO.getProcessingResults();
// 通过
if (ApprovalResultStatusEnum.pass.getValue().equals(result)) {
String details = orderWarehouseApprovalDO.getDetails();
if (StringUtils.isNotEmpty(details)) {
OrderWarehouseInUpdateApplyReqVO updateReqVO =
JSON.parseObject(details, OrderWarehouseInUpdateApplyReqVO.class);
Boolean isShipmentUpdate = updateReqVO.getIsShipmentUpdate();
Boolean isShipmentAppend = updateReqVO.getIsShipmentAppend();
OrderDO orderDO = orderService.getById(orderId);
// 不是出货阶段追加入仓的情况: 1。入仓修改 2。出货入仓修改
if (!isShipmentAppend) {
// 将老的信息更新成新的信息
Long orderItemId = orderWarehouseApprovalDO.getOrderItemId();
OrderItemDO orderItemDO = orderItemService.getById(orderItemId);
BigDecimal sumVolumeBeforeUpdate = orderDO.getSumVolume();
BigDecimal sumWeightBeforeUpdate = orderDO.getSumWeight();
// 验证是否不可接受货物
this.validateProdAttrAccess(orderItemDO.getProdId(),
orderDO.getOrderNo());
// 通过orderItemId查询db中的 orderWarehouseInDO
List<OrderWarehouseInDO> orderWarehouseInListOld =
orderWarehouseInMapper
.selectList(new LambdaQueryWrapperX<OrderWarehouseInDO>().eq(OrderWarehouseInDO::getOrderId, orderId)
.eq(OrderWarehouseInDO::getOrderItemId, orderItemId));
// 先更新入仓
List<OrderWarehouseInItemDto> orderWarehouseInItemDtoListNew =
updateReqVO.getOrderWarehouseInUpdateItemDoList();
ZhongPaoBestVO zhongPaoBest = getZhongPaoBest(orderDO);
BigDecimal zhongEdge = zhongPaoBest != null ? zhongPaoBest.getZhongEdge() : null;
BigDecimal paoEdge = zhongPaoBest != null ? zhongPaoBest.getPaoEdge() : null;
if (CollectionUtil.isNotEmpty(orderWarehouseInItemDtoListNew)) {
// 2023-04-20 1.入仓修改可以添加入仓记录,添加审核通过后,入仓时间为提交入仓的系统时间,无需选择入仓时间。
Date inTime = orderWarehouseApprovalDO.getCreateTime();
// 1、新增 (只有新增的可能有储位,修改储位是直接调用修改接口的。)
List<OrderWarehouseInItemDto> addList =
orderWarehouseInItemDtoListNew.stream().filter(t -> t.getId() == null).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(addList)) {
for (OrderWarehouseInItemDto orderWarehouseInItemDto : addList) {
OrderWarehouseInDO orderWarehouseInDO = convertOrderWarehouseInItemDo(orderDO, orderItemId, zhongPaoBest, zhongEdge, paoEdge, orderWarehouseInItemDto, inTime);
orderWarehouseInMapper.insert(orderWarehouseInDO);
// 保存储位
List<OrderLocationCreateReqVO> orderLocationCreateReqVOList = orderWarehouseInItemDto.getOrderLocationCreateReqVOList();
if (CollectionUtil.isNotEmpty(orderLocationCreateReqVOList)) {
for (OrderLocationCreateReqVO orderLocationCreateReqVO : orderLocationCreateReqVOList) {
// 设置入仓纪录id
orderLocationCreateReqVO.setWarehouseInId(orderWarehouseInDO.getId());
orderLocationService.createOrderLocation(orderLocationCreateReqVO);
}
}
}
}
// 2、更新 //2023-04-20 入仓修改若修改已有入仓记录,
// 有改动(储位或其他信息修改)修改入仓记录的最新操作时间,
// 不修改入仓时间,不修改未发生变化的入仓记录的入仓时间和最新操作时间。
if (CollectionUtil.isNotEmpty(orderWarehouseInItemDtoListNew)) {
//更新的
List<OrderWarehouseInItemDto> orderWarehouseInItemDtoListUpdate =
orderWarehouseInItemDtoListNew.stream().filter(t -> t.getId() != null
&& orderWarehouseInListOld.stream().anyMatch(old -> old.getId().equals(t.getId()))).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(orderWarehouseInItemDtoListUpdate)) {
for (OrderWarehouseInItemDto itemDtoNew :
orderWarehouseInItemDtoListUpdate) {
OrderWarehouseInDO orderWarehouseInDONew =
convertOrderWarehouseInItemDo(orderDO, orderItemId, zhongPaoBest, zhongEdge, paoEdge, itemDtoNew, inTime);
// 判断有无变化
OrderWarehouseInDO old = orderWarehouseInMapper.selectById(itemDtoNew.getId());
List<ApplyInfoVO> applyInfoVOListTmp = new ArrayList<>();
compareOrderWarehouseInField("", Arrays.asList(old), Arrays.asList(itemDtoNew), applyInfoVOListTmp);
// 有变化才更新
if (CollectionUtil.isNotEmpty(applyInfoVOListTmp)) {
orderWarehouseInMapper.updateById(orderWarehouseInDONew);
applyInfoVOListTmp.clear();
} else {
//20230821 fix: #4304 订单完成入仓后修改商品名称未更新最后入仓时间
Long warehouseInId = orderWarehouseInDONew.getId();
this.update(new LambdaUpdateWrapper<OrderWarehouseInDO>()
.set(OrderWarehouseInDO::getUpdater,
WebFrameworkUtils.getLoginUserId() + "")
.set(OrderWarehouseInDO::getUpdateTime, new Date())
.eq(OrderWarehouseInDO::getId, warehouseInId));
}
}
}
// 3、删除
List<Long> deleteIds = orderWarehouseInListOld.stream()
.filter(old -> orderWarehouseInItemDtoListNew.stream().noneMatch(n -> old.getId().equals(n.getId()))).map(OrderWarehouseInDO::getId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(deleteIds)) {
orderWarehouseInMapper.deleteBatchIds(deleteIds);
}
}
}
// 3、删除
else {
List<Long> deleteIds =
orderWarehouseInListOld.stream().map(OrderWarehouseInDO::getId).collect(Collectors.toList());
orderWarehouseInMapper.deleteBatchIds(deleteIds);
//根据订单ID删除储位
orderLocationService.deleteIfPresent(orderId, null, null);
}
orderItemDO.setNum(updateReqVO.getNum());
orderItemDO.setVolume(updateReqVO.getVolume());
orderItemDO.setWeight(updateReqVO.getWeight());
orderItemDO.setMaterial(updateReqVO.getMaterial());
orderItemDO.setWarehouseInProdAttrIds(updateReqVO.getWarehouseInProdAttrIds());
orderItemDO.setBrand(Objects.isNull(updateReqVO.getBrand()) ? 0L : updateReqVO.getBrand());// 使用的跟新方法不会将null值更新到数据库,所以给默认值0
orderItemDO.setProdType(updateReqVO.getProdType());
orderItemDO.setProdTitleZh(updateReqVO.getProdTitleZh());
orderItemDO.setProdTitleEn(updateReqVO.getProdTitleEn());
orderItemDO.setUsageIds(StringUtils.isEmpty(updateReqVO.getUsageIds()) ? "" : updateReqVO.getUsageIds());
Long prodIdNew = updateReqVO.getProdId();
// 更新订单的和订单项的入仓信息
updateOrderAndOrderItemWarehouseIn(orderId, orderItemDO.getProdId(), prodIdNew, CollectionUtil.newArrayList(orderItemDO), zhongPaoBest);
......@@ -3600,9 +4131,10 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
Integer inWarehouseState = null;
//非清关和出货的入仓修改,执行正常入仓修改流程
if (!Objects.equals(OrderStatusEnum.CLEARED.getValue(), orderDO.getStatus())
&& !Objects.equals(OrderStatusEnum.INSTALLED_CABINET.getValue(), orderDO.getStatus())
&& !Objects.equals(OrderStatusEnum.SHIPMENT.getValue(), orderDO.getStatus())) {
// if (!Objects.equals(OrderStatusEnum.CLEARED.getValue(), orderDO.getStatus())
// && !Objects.equals(OrderStatusEnum.INSTALLED_CABINET.getValue(), orderDO.getStatus())
// && !Objects.equals(OrderStatusEnum.SHIPMENT.getValue(), orderDO.getStatus())) {
if (!isShipmentUpdate) {
inWarehouseState = OrderWarehouseInStatusEnum.warehouse_finished.getValue();
orderService.updateStatus(orderId, null, null, null,
......@@ -3633,15 +4165,70 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
log.error("入仓修改通过后重新入仓发生异常", e);
}
// 添加仓库操作日志
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "货物入仓修改已通过", updateReqVO.getApplyInfoVOList());
} else {
// 处理标签号
saveOrUpdateLabel(orderId, numSum, null);
//清关和出货的入仓修改,只需要更新审核状态,不更新订单主状态
orderService.updateStatus(orderId, null, null, null,
null, null, 0, OrderApprovalTypeResultEnum.typeAndResultOf(auditType, result).getDesc(), false);
// 更新计价
OrderWarehouseInVO orderWarehouseInVO = new OrderWarehouseInVO();
orderWarehouseInVO.setOrderId(orderId);
orderService.shipmentOrderInWarehouse(orderWarehouseInVO);
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "航运中修改", updateReqVO.getApplyInfoVOList());
}
}
// 出货阶段 入仓追加 (有可能orderItemId为null)
else {
// copy
OrderWarehouseInCreateReqVO createReqVO = new OrderWarehouseInCreateReqVO();
BeanUtils.copyProperties(updateReqVO, createReqVO);
createReqVO.setOrderWarehouseInItemDoList(updateReqVO.getOrderWarehouseInUpdateItemDoList());
Long orderItemId = createReqVO.getOrderItemId();
// 执行入仓
orderItemId = this.doSaveOrUpdateOrderWarehouseInDo(createReqVO, orderId, orderItemId, orderDO, createReqVO.getPictureUrls(), false, true);
// 更新计价
OrderWarehouseInVO orderWarehouseInVO = new OrderWarehouseInVO();
orderWarehouseInVO.setOrderId(orderId);
orderService.shipmentOrderInWarehouse(orderWarehouseInVO);
// 空运更新订单项打包状态
if (orderDO.getTransportId() == 3 || orderDO.getTransportId() == 4) {
// 添加新品标识
boolean isAddNewOrderItem = createReqVO.getType() != 0;
// 备货时添加新品,纪录个空的打包历史。因为在入仓后才会产生orderItemId,所以才在这里纪录。
if (isAddNewOrderItem) {
saveNewOrderItemPackLog(orderId, orderItemId);
}
// 设置打包状态`
OrderItemDO orderItemDO = orderItemService.getOrderItem(orderItemId);
orderItemDO.setPackStatus(OrderItemPackStatusEnum.PACKED.getValue());
// 更新订单项
orderItemService.updateById(orderItemDO);
}
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "航运中追加", updateReqVO.getApplyInfoVOList());
}
// 添加仓库操作日志
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "货物入仓修改已通过", updateReqVO.getApplyInfoVOList());
}
} else if (ApprovalResultStatusEnum.reject.getValue().equals(result)) {
......@@ -3651,11 +4238,15 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
OrderDO orderDO = orderQueryService.getOrderById(orderId);
Integer inWarehouseState = null;
//清关和出货的入仓修改,只需要更新审核状态,不更新订单主状态。 其他更新为完成入仓状态
if (!Objects.equals(OrderStatusEnum.CLEARED.getValue(), orderDO.getStatus())
&& !Objects.equals(OrderStatusEnum.INSTALLED_CABINET.getValue(), orderDO.getStatus())
&& !Objects.equals(OrderStatusEnum.SHIPMENT.getValue(), orderDO.getStatus())) {
// if (!Objects.equals(OrderStatusEnum.CLEARED.getValue(), orderDO.getStatus())
// && !Objects.equals(OrderStatusEnum.INSTALLED_CABINET.getValue(), orderDO.getStatus())
// && !Objects.equals(OrderStatusEnum.SHIPMENT.getValue(), orderDO.getStatus())) {
// inWarehouseState = OrderWarehouseInStatusEnum.warehouse_finished.getValue();
// }
if (!(orderDO.getShipmentState() > 0 && orderDO.getInWarehouseState() == 0)) {
inWarehouseState = OrderWarehouseInStatusEnum.warehouse_finished.getValue();
}
orderService.updateStatus(orderId, null, null, null,
inWarehouseState, null, 0, OrderApprovalTypeResultEnum.typeAndResultOf(auditType, result).getDesc(), false);
......@@ -3672,9 +4263,12 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
OrderDO orderDO = orderQueryService.getOrderById(orderId);
Integer inWarehouseState = null;
if (!Objects.equals(OrderStatusEnum.CLEARED.getValue(), orderDO.getStatus())
&& !Objects.equals(OrderStatusEnum.INSTALLED_CABINET.getValue(), orderDO.getStatus())
&& !Objects.equals(OrderStatusEnum.SHIPMENT.getValue(), orderDO.getStatus())) {
// if (!Objects.equals(OrderStatusEnum.CLEARED.getValue(), orderDO.getStatus())
// && !Objects.equals(OrderStatusEnum.INSTALLED_CABINET.getValue(), orderDO.getStatus())
// && !Objects.equals(OrderStatusEnum.SHIPMENT.getValue(), orderDO.getStatus())) {
// inWarehouseState = OrderWarehouseInStatusEnum.warehouse_finished.getValue();
// }
if (!(orderDO.getShipmentState() > 0 && orderDO.getInWarehouseState() == 0)) {
inWarehouseState = OrderWarehouseInStatusEnum.warehouse_finished.getValue();
}
//清关和出货的入仓修改,只需要更新审核状态,不更新订单主状态。 其他更新为完成入仓状态
......@@ -3684,8 +4278,13 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
String details = orderWarehouseApprovalDO.getDetails();
if (StringUtils.isNotEmpty(details)) {
OrderWarehouseInUpdateApplyReqVO updateReqVO = JSON.parseObject(details, OrderWarehouseInUpdateApplyReqVO.class);
String prefixStr = "";
if (updateReqVO.getIsShipmentAppend() || updateReqVO.getIsShipmentUpdate()) {
prefixStr = "航运中-";
}
// 添加仓库操作日志
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "货物入仓修改申请已取消", updateReqVO.getApplyInfoVOList());
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", prefixStr + "货物入仓修改申请已取消", updateReqVO.getApplyInfoVOList());
}
}
}
......
package cn.iocoder.yudao.module.order.vo.orderWarehouseIn;
import cn.iocoder.yudao.module.order.vo.order.ApplyInfoVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -112,4 +113,17 @@ public class OrderWarehouseInCreateReqVO {
private Boolean isProcessPicture = true;
// ---------------- 下面属性是给出货阶段 追加入仓申请 使用的 ----------------
@ApiModelProperty(value = "抄送人userId")
private String[] copyUserId;
@ApiModelProperty(value = "修改的信息,返回给前端拼装使用")
private List<ApplyInfoVO> applyInfoVOList;
}
......@@ -8,12 +8,16 @@ import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 入仓货物详情更新 发起请求 Request VO")
@Data
@EqualsAndHashCode
......@@ -109,4 +113,31 @@ public class OrderWarehouseInUpdateApplyReqVO {
@ApiModelProperty(value = "修改的信息,返回给前端拼装使用")
private List<ApplyInfoVO> applyInfoVOList;
// ---------------- 下面属性是给出货阶段 追加入仓申请 使用的 ----------------
@ApiModelProperty(value = "订单项-入仓时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date inTime;
@ApiModelProperty(value = "入仓货物-0下单货物;1非下单货物")
private Integer type = 0;
/**
* 入仓来源 字典order_warehouse_in_source 1-始发港入仓、2-调拨入仓、3-目的港入仓、4-退场入仓 5-拆单后入仓
*/
@ApiModelProperty(value = "入仓来源 字典order_warehouse_in_source 1-始发港入仓、2-调拨入仓、3-目的港入仓、4-退场入仓 5-拆单后入仓")
private Integer source = 1;
// 出货阶段 追加,到仓
private Boolean isShipmentAppend = false;
// 出货阶段 修改
private Boolean isShipmentUpdate = false;
}
......@@ -13,7 +13,6 @@ import cn.iocoder.yudao.module.order.service.orderLabel.OrderLabelService;
import cn.iocoder.yudao.module.order.service.orderWarehouseAdjust.OrderWarehouseAdjustService;
import cn.iocoder.yudao.module.order.service.orderWarehouseApproval.OrderWarehouseApprovalService;
import cn.iocoder.yudao.module.order.service.orderWarehouseIn.OrderWarehouseInService;
import cn.iocoder.yudao.module.order.vo.order.OrderWarehouseInCommonAttrVO;
import cn.iocoder.yudao.module.order.vo.order.OrderWarehouseInWithAttrVO;
import cn.iocoder.yudao.module.order.vo.order.WarehouseInInfoVO;
import cn.iocoder.yudao.module.order.vo.orderLabel.OrderLabelBackVO;
......@@ -158,6 +157,41 @@ public class OrderWarehouseInController {
}
/**
* 出货阶段 - 追加
*
* @param createReqVO
* @return
*/
@PostMapping("/append-apply-when-shipment")
@ApiOperation("出货阶段 - 入仓/追加申请")
@Idempotent(timeout = 8)
public CommonResult<Boolean> appendApplyWhenShipment(@Valid @RequestBody OrderWarehouseInCreateReqVO createReqVO) {
return success(orderWarehouseInService.appendApplyWhenShipment(createReqVO));
}
/*
* 出货阶段-入仓修改申请
*/
@PutMapping("/update-apply-when-shipment")
@ApiOperation("出货阶段 - 入仓修改申请")
public CommonResult<Boolean> updateApplyWhenShipment(@Valid @RequestBody OrderWarehouseInUpdateApplyReqVO updateReqVO) {
// 校验存在
String msg = orderWarehouseInService.updateApplyWhenShipment(updateReqVO);
CommonResult<Boolean> success = success(true);
success.setMsg(msg);
return success;
}
@GetMapping("/update-callback-when-shipment")
@ApiOperation("出货阶段-入仓修改回调")
public CommonResult<Boolean> updateCallbackWhenShipment(String formId, Integer result) {
orderWarehouseInService.updateApplyCallback(formId, result);
return success(true);
}
@PostMapping("/save-or-update-order-location")
@ApiOperation("新增/更新入仓储位")
@Idempotent(timeout = 5)
......
......@@ -305,6 +305,16 @@ order.not.is.overseas.warehouse.order=
area.code.not.null=
currency.id.not.null=
warehouse.in.update.not.shipment=
air.port.dest.customer.customs.clear.and.single.shipment.method=
air.delivery.way.not.null=
air.port.dest.customs.clear.not.null=
app.message.update.control.password.title=
consignee.limit.update.cancel=
score.rule.orderentry.error=
orderv.score.rule.error=
cargo.control.order.already.picked=
cargo.uncontrol.order.already.picked=
order.approval.is.not.exists=
fee.application.not.is.zero=
......
......@@ -1119,6 +1119,10 @@ order.not.is.overseas.warehouse.order=This order is already a non overseas wareh
area.code.not.null=The national mobile phone area code cannot be empty
currency.id.not.null=The country ID cannot be empty
warehouse.in.update.not.shipment=Warehouse update is only allowed after the shipment has been loaded into the container by sea or shipped by air.
cargo.control.order.already.picked=cargo control order already picked
cargo.uncontrol.order.already.picked=cargo uncontrol order already picked
order.approval.is.not.exists=Order approval type does not exist
fee.application.not.is.zero=The expense application amount is not 0, and cannot be directly deleted
......
......@@ -126,9 +126,9 @@ not.find.currency=\u672A\u627E\u5230\u53EF\u7528\u8D27\u5E01\u5355\u4F4D
order.warehouse.in.not.exists=\u5165\u4ED3\u8D27\u7269\u8BE6\u60C5\u4E0D\u5B58\u5728
order.warehouse.in.update.not.exists=\u6CA1\u6709\u8981\u4FEE\u6539\u7684\u5165\u4ED3\u6570\u636E
order.warehouse.approval.not.exists=\u5165\u4ED3\u5355\u5BA1\u6838\u4E0D\u5B58\u5728
order.warehouse.check.not.exists=\u5230\u4ed3\u8d27\u7269\u8be6\u60c5\u4e0d\u5b58\u5728
order.warehouse.check.bad.volume=\u5230\u4ed3\u8d27\u7269\u4f53\u79ef\u8d85\u51fa
order.warehouse.check.bad.weight=\u5230\u4ed3\u8d27\u7269\u91cd\u91cf\u8d85\u51fa
order.warehouse.check.not.exists=\u5230\u4ED3\u8D27\u7269\u8BE6\u60C5\u4E0D\u5B58\u5728
order.warehouse.check.bad.volume=\u5230\u4ED3\u8D27\u7269\u4F53\u79EF\u8D85\u51FA
order.warehouse.check.bad.weight=\u5230\u4ED3\u8D27\u7269\u91CD\u91CF\u8D85\u51FA
warehouse.adjust.not.exists=\u8C03\u4ED3\u8BB0\u5F55\u4E0D\u5B58\u5728
shipment.not.exists=\u51FA\u8D27\u4E0D\u5B58\u5728
shipment.order.exit.not.exists=\u8BA2\u5355\u9000\u573A\u4FE1\u606F\u4E0D\u5B58\u5728
......@@ -303,7 +303,7 @@ order.label.overlap=\u6807\u7B7E\u53F7\u672C\u8EAB\u5B58\u5728\u91CD\u53E0
transfer.goods.order.not.null=\u8C03\u8D27\u8BA2\u5355\u4E0D\u80FD\u4E3A\u7A7A
file.format.is.excel=\u6587\u4EF6\u683C\u5F0F\u53EA\u652F\u6301excel
prod.volume.beyond.day.upper.limit=\u5546\u54C1{}\u65B9\u6570\u8D85\u51FA\u4ED3\u5E93\u5F53\u65E5\u63A5\u53D7\u4E0A\u9650
prod.weight.beyond.day.upper.limit=\u5546\u54c1{}\u91cd\u91cf\u8d85\u51fa\u4ed3\u5e93\u5f53\u65e5\u63a5\u53d7\u4e0a\u9650
prod.weight.beyond.day.upper.limit=\u5546\u54C1{}\u91CD\u91CF\u8D85\u51FA\u4ED3\u5E93\u5F53\u65E5\u63A5\u53D7\u4E0A\u9650
coupon.full.reduce.value.gt.payment.value=\u4F18\u60E0\u6D3B\u52A8\u6EE1\u51CF\u503C\u4E0D\u80FD\u5927\u4E8E\u539F\u503C
coupon.full.net.value.gt.payment.value=\u4F18\u60E0\u6D3B\u52A8\u7684\u6EE1\u6536\u4EF7\u4E0D\u80FD\u5927\u4E8E\u539F\u4EF7
coupon.currency.or.unit.not.null=\u4F18\u60E0\u6D3B\u52A8\u6761\u4EF6\u8D27\u5E01\u5355\u4F4D\u6216\u8BA1\u91CF\u5355\u4F4D\u4E0D\u80FD\u4E3A\u7A7A
......@@ -654,9 +654,9 @@ order.cargo.control.cancel.pick.reject=\u63A7\u8D27\u8BA2\u5355\u5DF2\u653E\u8D2
order.cargo.control.cancel.pick.cancel=\u63A7\u8D27\u8BA2\u5355\u5DF2\u653E\u8D27\u8BB0\u5F55\u8C03\u8D27\u5BA1\u6279\u53D6\u6D88
warehouse.in.item.quantity.required=\u5165\u4ED3\u9879\u6570\u91CF\u5FC5\u586B
order.line.not.exist=\u8BA2\u5355\u7EBF\u8DEF\u4E0D\u5B58\u5728
line.not.exist=\u7ebf\u8def\u4e0d\u5b58\u5728
line.not.exist=\u7EBF\u8DEF\u4E0D\u5B58\u5728
order.departure.objective.and.line.not.agreement=\u8BA2\u5355\u59CB\u53D1\u5730\u76EE\u7684\u5730\u4E0E\u7EBF\u8DEF\u4E0D\u4E00\u81F4
offer.departure.objective.and.line.not.agreement=\u62a5\u4ef7\u5355\u59cb\u53d1\u5730\u76ee\u7684\u5730\u4e0e\u7ebf\u8def\u4e0d\u4e00\u81f4
offer.departure.objective.and.line.not.agreement=\u62A5\u4EF7\u5355\u59CB\u53D1\u5730\u76EE\u7684\u5730\u4E0E\u7EBF\u8DEF\u4E0D\u4E00\u81F4
transport.and.line.not.agreement=\u8BA2\u5355\u8FD0\u8F93\u65B9\u5F0F\u4E0E\u7EBF\u8DEF\u4FE1\u606F\u4E0D\u5339\u914D\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u7EBF\u8DEF\u4FE1\u606F
prod.brand.not.null=\u54C1\u724C\u4E0D\u80FD\u4E3A\u7A7A\u62160
preload.not.exist=\u51FA\u8D27\u5355\u672A\u9884\u88C5\u8D27\u7269
......@@ -1112,14 +1112,17 @@ customer.approval.in.processing=\u975E\u4E3B\u5BA2\u6237\u5BA1\u6279\u6B63\u5728
order.overseas.warehouse.update.is.or.no=\u8bf7\u9009\u62e9\u8ba2\u5355\u6d77\u5916\u4ed3\u4fee\u6539\u662f\u6216\u5426
order.is.overseas.warehouse.order=\u8be5\u8ba2\u5355\u5df2\u7ecf\u662f\u6d77\u5916\u4ed3\u8ba2\u5355
order.not.is.overseas.warehouse.order=\u8be5\u8ba2\u5355\u5df2\u7ecf\u662f\u975e\u6d77\u5916\u4ed3\u8ba2\u5355
order.overseas.warehouse.update.is.or.no=\u8BF7\u9009\u62E9\u8BA2\u5355\u6D77\u5916\u4ED3\u4FEE\u6539\u662F\u6216\u5426
order.is.overseas.warehouse.order=\u8BE5\u8BA2\u5355\u5DF2\u7ECF\u662F\u6D77\u5916\u4ED3\u8BA2\u5355
order.not.is.overseas.warehouse.order=\u8BE5\u8BA2\u5355\u5DF2\u7ECF\u662F\u975E\u6D77\u5916\u4ED3\u8BA2\u5355
area.code.not.null=\u56fd\u5bb6\u624b\u673a\u533a\u53f7\u4e0d\u80fd\u4e3a\u7a7a
currency.id.not.null=\u56fd\u5bb6id\u4e0d\u80fd\u4e3a\u7a7a
area.code.not.null=\u56FD\u5BB6\u624B\u673A\u533A\u53F7\u4E0D\u80FD\u4E3A\u7A7A
currency.id.not.null=\u56FD\u5BB6id\u4E0D\u80FD\u4E3A\u7A7A
warehouse.in.update.not.shipment=\u8BA2\u5355\u4E0D\u662F\u5DF2\u88C5\u67DC/\u5DF2\u51FA\u8D27\uFF0C\u4E0D\u53EF\u64CD\u4F5C
cargo.control.order.already.picked=\u8BA2\u5355\u5DF2\u653E\u8D27\uFF0C\u65E0\u6CD5\u4FEE\u6539
cargo.uncontrol.order.already.picked=\u8BA2\u5355\u5DF2\u63D0\u8D27\uFF0C\u65E0\u6CD5\u4FEE\u6539
order.approval.is.not.exists=\u8ba2\u5355\u5ba1\u6279\u7c7b\u578b\u4e0d\u5b58\u5728
fee.application.not.is.zero=\u8d39\u7528\u7533\u8bf7\u91d1\u989d\u4e0d\u4e3a0\uff0c\u4e0d\u80fd\u8fdb\u884c\u76f4\u63a5\u5220\u9664
guan.lian.order.is.approval.in.process=\u5173\u8054\u8ba2\u5355\u3010{}\u3011\u6709\u5ba1\u6279\u6b63\u5728\u8fdb\u884c\u4e2d
order.approval.is.not.exists=\u8BA2\u5355\u5BA1\u6279\u7C7B\u578B\u4E0D\u5B58\u5728
fee.application.not.is.zero=\u8D39\u7528\u7533\u8BF7\u91D1\u989D\u4E0D\u4E3A0\uFF0C\u4E0D\u80FD\u8FDB\u884C\u76F4\u63A5\u5220\u9664
guan.lian.order.is.approval.in.process=\u5173\u8054\u8BA2\u5355\u3010{}\u3011\u6709\u5BA1\u6279\u6B63\u5728\u8FDB\u884C\u4E2D
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment