Browse Source

1.取消提货,运单提货件数还原

dev
zhenghaoyu 6 days ago
parent
commit
870576e285
  1. 41
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineBillladingServiceImpl.java

41
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineBillladingServiceImpl.java

@ -5,6 +5,7 @@ import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.logpm.basicdata.feign.*;
@ -33,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@ -535,6 +537,45 @@ public class TrunklineBillladingServiceImpl extends BaseServiceImpl<TrunklineBil
billladingEntity.setBillladingStatus("5");
updateEntity.setBillladingStatus(billladingEntity.getBillladingStatus());
stringBuffer.append(",变更为取消提货,时间").append(CommonUtil.dateToString(new Date())).append(",变更人").append(AuthUtil.getNickName());
List<WarehouseWaybillEntity> updateList = new ArrayList<>();
QueryWrapper<TrunklineBillladingWaybillEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("billlading_id",billladingId);
List<TrunklineBillladingWaybillEntity> trunklineBillladingWaybillEntities = billladingWaybillService.list(queryWrapper);
if(CollUtil.isNotEmpty(trunklineBillladingWaybillEntities)){
//把trunklineBillladingWaybillEntities中所有的waybillId放入一个List,排除掉null的waybillId
List<Long> waybillIdList = trunklineBillladingWaybillEntities.stream().map(TrunklineBillladingWaybillEntity::getWaybillId).filter(Objects::nonNull).collect(Collectors.toList());
List<WarehouseWaybillEntity> listByWaybillIds = warehouseWaybillClient.findListByWaybillIds(waybillIdList);
//把listByWaybillIds中的waybillId放入一个Map,key为waybillId,value为WarehouseWaybillEntity
Map<Long, WarehouseWaybillEntity> map = listByWaybillIds.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getId, Function.identity()));
trunklineBillladingWaybillEntities.forEach(billladingWaybillEntity -> {
String waybillNo = billladingWaybillEntity.getWaybillNo();
Long waybillId = billladingWaybillEntity.getWaybillId();
Integer realNum = billladingWaybillEntity.getRealNum();
billladingWaybillEntity.setRealNum(0);
if(!"--".equals(waybillNo)){
WarehouseWaybillEntity warehouseWaybill = map.get(waybillId);
if(!Objects.isNull(warehouseWaybill)){
Integer billladingNum = warehouseWaybill.getBillladingNum();
WarehouseWaybillEntity updateWaybillEntity = new WarehouseWaybillEntity();
updateWaybillEntity.setId(billladingWaybillEntity.getWaybillId());
updateWaybillEntity.setBillladingNum(billladingNum-realNum);
updateList.add(updateWaybillEntity);
}
}
});
billladingWaybillService.updateBatchById(trunklineBillladingWaybillEntities);
if(CollUtil.isNotEmpty(updateList)){
warehouseWaybillClient.updateList(updateList);
}
}
break;
default:
log.warn("#############updateBillladingStatus: 未知的更新操作");

Loading…
Cancel
Save