|
|
|
@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.logpm.basic.entity.BasicPrintTemplateEntity; |
|
|
|
|
import com.logpm.basic.feign.IBasicPrintTemplateClient; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataClientEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataStoreBusinessEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
|
@ -19,6 +21,7 @@ import com.logpm.distribution.entity.DistributionStockArticleEntity;
|
|
|
|
|
import com.logpm.distribution.feign.IDistributionParcelListClient; |
|
|
|
|
import com.logpm.distribution.feign.IDistributionParcelNumberClient; |
|
|
|
|
import com.logpm.distribution.feign.IDistributionStockArticleClient; |
|
|
|
|
import com.logpm.distribution.vo.print.PrintPreviewVO; |
|
|
|
|
import com.logpm.oldproject.entity.WayBillEntity; |
|
|
|
|
import com.logpm.oldproject.entity.WaybillDesEntity; |
|
|
|
|
import com.logpm.oldproject.feign.IWayBillClient; |
|
|
|
@ -40,17 +43,23 @@ import org.springblade.common.constant.DictBizConstant;
|
|
|
|
|
import org.springblade.common.constant.OldSystemDataPushConfig; |
|
|
|
|
import org.springblade.common.constant.TenantNum; |
|
|
|
|
import org.springblade.common.constant.order.*; |
|
|
|
|
import org.springblade.common.constant.printTemplate.PrintTemplateStatusConstant; |
|
|
|
|
import org.springblade.common.exception.CustomerException; |
|
|
|
|
import org.springblade.common.utils.TemplateUtil; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.constant.BladeConstant; |
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springblade.system.cache.DictBizCache; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -76,6 +85,8 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
|
|
|
|
|
private final IDistributionStockArticleClient distributionStockArticleClient; |
|
|
|
|
|
|
|
|
|
private final IBasicPrintTemplateClient basicPrintTemplateClient; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<WarehouseWaybillVO> selectWarehouseWaybillPage(IPage<WarehouseWaybillVO> page, WarehouseWaybillVO warehouseWaybill) { |
|
|
|
|
return page.setRecords(baseMapper.selectWarehouseWaybillPage(page, warehouseWaybill)); |
|
|
|
@ -109,13 +120,13 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
throw new CustomerException("老系统中未找到对应运单"); |
|
|
|
|
} |
|
|
|
|
Integer warehouseId = wayBillEntity.getWarehouseId(); |
|
|
|
|
if(!warehouseId.equals(oprationWarehouseId)){ |
|
|
|
|
log.warn("##############waybillDataHandler: 作业仓库与目的仓不同 warehouseId={} oprationWarehouseId={}", warehouseId,oprationWarehouseId); |
|
|
|
|
if (!warehouseId.equals(oprationWarehouseId)) { |
|
|
|
|
log.warn("##############waybillDataHandler: 作业仓库与目的仓不同 warehouseId={} oprationWarehouseId={}", warehouseId, oprationWarehouseId); |
|
|
|
|
throw new CustomerException("作业仓库与目的仓不同"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 需要验证当前需要开启的数据推送仓库
|
|
|
|
|
if(!OldSystemDataPushConfig.getWarehourseIdList().contains(warehouseId+"")){ |
|
|
|
|
if (!OldSystemDataPushConfig.getWarehourseIdList().contains(warehouseId + "")) { |
|
|
|
|
log.info(">>>> waybillDataHandler 当前开单仓库不是目前系统上线运行仓库 {}", warehouseId); |
|
|
|
|
throw new CustomerException("当前开单仓库不是目前系统上线运行仓库"); |
|
|
|
|
} |
|
|
|
@ -161,15 +172,15 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//创建在库订单
|
|
|
|
|
createStockArticle(warehouseWaybill,allNum); |
|
|
|
|
createStockArticle(warehouseWaybill, allNum); |
|
|
|
|
log.info("###############waybillDataHandler: 处理数据结束 waybillNo={}", waybillNo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void createStockArticle(WarehouseWaybillEntity warehouseWaybill,Integer allNum) { |
|
|
|
|
private void createStockArticle(WarehouseWaybillEntity warehouseWaybill, Integer allNum) { |
|
|
|
|
//判断新系统是否有这条订单数据
|
|
|
|
|
//自动生成的在库订单就用运单号作为订单号
|
|
|
|
|
|
|
|
|
|
try{ |
|
|
|
|
try { |
|
|
|
|
String waybillNo = warehouseWaybill.getWaybillNo(); |
|
|
|
|
Long waybillId = warehouseWaybill.getId(); |
|
|
|
|
String destinationWarehouse = warehouseWaybill.getDestinationWarehouseName();//目的仓
|
|
|
|
@ -178,7 +189,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
Integer stockCount = warehouseWaybill.getStockCount();//订单在库数量
|
|
|
|
|
String consignee = warehouseWaybill.getConsignee(); |
|
|
|
|
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(destinationWarehouseId); |
|
|
|
|
DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient.findByOrderSelfNum(waybillNo,destinationWarehouseId); |
|
|
|
|
DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient.findByOrderSelfNum(waybillNo, destinationWarehouseId); |
|
|
|
|
BasicdataClientEntity clientEntity = basicdataClientClient.findByName(consignee); |
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
|
|
|
@ -193,7 +204,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
distributionStockArticleEntity.setWaybillId(warehouseWaybill.getId()); |
|
|
|
|
distributionStockArticleEntity.setWarehouseId(basicdataWarehouseEntity.getId()); |
|
|
|
|
distributionStockArticleEntity.setMallName(consignee); |
|
|
|
|
if(!Objects.isNull(clientEntity)){ |
|
|
|
|
if (!Objects.isNull(clientEntity)) { |
|
|
|
|
distributionStockArticleEntity.setMallName(clientEntity.getClientName()); |
|
|
|
|
distributionStockArticleEntity.setMallCode(clientEntity.getClientCode()); |
|
|
|
|
distributionStockArticleEntity.setMallId(clientEntity.getId()); |
|
|
|
@ -323,15 +334,15 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
id = distributionStockArticleEntity.getId(); |
|
|
|
|
Integer handQuantity = distributionStockArticleEntity.getHandQuantity(); |
|
|
|
|
distributionStockArticleEntity.setTotalNumber(totalCount); |
|
|
|
|
distributionStockArticleEntity.setHandQuantity(handQuantity+allNum); |
|
|
|
|
distributionStockArticleEntity.setHandQuantity(handQuantity + allNum); |
|
|
|
|
distributionStockArticleEntity.setWarehouseEntryTimeEnd(date); |
|
|
|
|
log.info(">>>> 更新订单"); |
|
|
|
|
checkStatus(distributionStockArticleEntity); |
|
|
|
|
distributionStockArticleClient.saveOrUpdate(distributionStockArticleEntity); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error(">>>>> createStockArticle",e); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error(">>>>> createStockArticle", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -362,13 +373,13 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
for (SplitOrderDTO splitOrderDTO : splitOrderDTOList) { |
|
|
|
|
List<ProductDTO> products = splitOrderDTO.getProducts(); |
|
|
|
|
for (ProductDTO product : products) { |
|
|
|
|
total = total+ product.getSplitNum(); |
|
|
|
|
total = total + product.getSplitNum(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(handQuantity < total){ |
|
|
|
|
if (handQuantity < total) { |
|
|
|
|
log.warn("##############splitOrder: 在库件数不足"); |
|
|
|
|
throw new CustomerException(405,"在库件数不足"); |
|
|
|
|
throw new CustomerException(405, "在库件数不足"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String orderCode = distributionStockArticleEntity.getOrderCode(); |
|
|
|
@ -397,7 +408,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
stringBuffer.append(",").append(productDTO.getProductName()); |
|
|
|
|
} |
|
|
|
|
Integer splitNum = productDTO.getSplitNum(); |
|
|
|
|
if(Objects.isNull(splitNum)){ |
|
|
|
|
if (Objects.isNull(splitNum)) { |
|
|
|
|
splitNum = 0; |
|
|
|
|
} |
|
|
|
|
allNum = allNum + splitNum; |
|
|
|
@ -433,11 +444,11 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
if (aLong == 0) { |
|
|
|
|
log.warn("###########splitOrder: 保存新订单数据失败"); |
|
|
|
|
throw new CustomerException(405, "保存新订单数据失败"); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
List<DistributionParcelNumberEntity> parcelNumberList = new ArrayList<>(); |
|
|
|
|
for (ProductDTO productDTO : products) { |
|
|
|
|
Integer splitNum = productDTO.getSplitNum(); |
|
|
|
|
if(Objects.isNull(splitNum)){ |
|
|
|
|
if (Objects.isNull(splitNum)) { |
|
|
|
|
splitNum = 0; |
|
|
|
|
} |
|
|
|
|
DistributionParcelListEntity distributionParcelListEntity = new DistributionParcelListEntity(); |
|
|
|
@ -464,7 +475,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
distributionParcelNumberClient.addBatch(parcelNumberList); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
distributionStockArticleClient.submitHandleNumAndTotalNumberByOrderId(subNum,articleId); |
|
|
|
|
distributionStockArticleClient.submitHandleNumAndTotalNumberByOrderId(subNum, articleId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -570,6 +581,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 导出 |
|
|
|
|
* |
|
|
|
|
* @param warehouseWaybillEntity |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
@ -577,7 +589,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
public List<WarehouseWaybillExcel> exportWarehouseWarehousingDetail(Map<String, Object> warehouseWaybillEntity) { |
|
|
|
|
|
|
|
|
|
Object o = warehouseWaybillEntity.get("ids"); |
|
|
|
|
if(ObjectUtils.isNotNull(o)){ |
|
|
|
|
if (ObjectUtils.isNotNull(o)) { |
|
|
|
|
warehouseWaybillEntity.remove("ids"); |
|
|
|
|
} |
|
|
|
|
// BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse();
|
|
|
|
@ -596,16 +608,16 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
queryWrapper.lambda() |
|
|
|
|
.in(collect.size() > 0, WarehouseWaybillEntity::getDepartureWarehouseId, collect) |
|
|
|
|
.in(ObjectUtils.isNotNull(o), WarehouseWaybillEntity::getId,String.valueOf(o).split(",")) |
|
|
|
|
.in(ObjectUtils.isNotNull(o), WarehouseWaybillEntity::getId, String.valueOf(o).split(",")) |
|
|
|
|
.or() |
|
|
|
|
.in(collect.size() > 0, WarehouseWaybillEntity::getDestinationWarehouseId, collect) |
|
|
|
|
.in(ObjectUtils.isNotNull(o), WarehouseWaybillEntity::getId,String.valueOf(o).split(",")); |
|
|
|
|
.in(ObjectUtils.isNotNull(o), WarehouseWaybillEntity::getId, String.valueOf(o).split(",")); |
|
|
|
|
queryWrapper.lambda().eq(WarehouseWaybillEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED); |
|
|
|
|
List<WarehouseWaybillExcel> list = new ArrayList<>(); |
|
|
|
|
List<WarehouseWaybillVO> warehouseWaybillVOS = baseMapper.exportWarehouseWarehousingDetail(queryWrapper); |
|
|
|
|
warehouseWaybillVOS.forEach( w ->{ |
|
|
|
|
warehouseWaybillVOS.forEach(w -> { |
|
|
|
|
WarehouseWaybillExcel waybillExcel = new WarehouseWaybillExcel(); |
|
|
|
|
BeanUtil.copyProperties(w,waybillExcel); |
|
|
|
|
BeanUtil.copyProperties(w, waybillExcel); |
|
|
|
|
String value = DictBizCache.getValue(DictBizConstant.DISTRIBUTION_TYPE, w.getServiceType()); |
|
|
|
|
waybillExcel.setServiceTypeName(value); |
|
|
|
|
String value1 = DictBizCache.getValue(DictBizConstant.FREEZE_STATUS, w.getFreezeStatus()); |
|
|
|
@ -639,10 +651,10 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
record.setFreezeStatusStr(freezeStatusStr); |
|
|
|
|
|
|
|
|
|
Integer waybillType = record.getWaybillType(); |
|
|
|
|
if(waybillType.equals(2)){ |
|
|
|
|
if (waybillType.equals(2)) { |
|
|
|
|
String orderCode = record.getWaybillNo(); |
|
|
|
|
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); |
|
|
|
|
if(!Objects.isNull(stockArticleEntity)){ |
|
|
|
|
if (!Objects.isNull(stockArticleEntity)) { |
|
|
|
|
record.setHandleNum(stockArticleEntity.getHandQuantity()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -660,7 +672,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
|
|
|
|
|
Long warehouseId = waybillDTO.getWarehouseId(); |
|
|
|
|
|
|
|
|
|
IPage<WarehouseWaybillVO> pageList = baseMapper.pageList(page,waybillDTO); |
|
|
|
|
IPage<WarehouseWaybillVO> pageList = baseMapper.pageList(page, waybillDTO); |
|
|
|
|
List<WarehouseWaybillVO> records = pageList.getRecords(); |
|
|
|
|
for (WarehouseWaybillVO record : records) { |
|
|
|
|
// Integer waybillType = record.getWaybillType();
|
|
|
|
@ -682,14 +694,14 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
public R findWaybillInfo(String waybillNo) { |
|
|
|
|
|
|
|
|
|
QueryWrapper<WarehouseWaybillEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("waybill_no",waybillNo); |
|
|
|
|
queryWrapper.eq("waybill_no", waybillNo); |
|
|
|
|
WarehouseWaybillEntity warehouseWaybillEntity = baseMapper.selectOne(queryWrapper); |
|
|
|
|
if(Objects.isNull(warehouseWaybillEntity)){ |
|
|
|
|
log.warn("###############findWaybillInfo: 运单不存在 waybillNo={}",waybillNo); |
|
|
|
|
return R.fail(405,"运单不存在"); |
|
|
|
|
if (Objects.isNull(warehouseWaybillEntity)) { |
|
|
|
|
log.warn("###############findWaybillInfo: 运单不存在 waybillNo={}", waybillNo); |
|
|
|
|
return R.fail(405, "运单不存在"); |
|
|
|
|
} |
|
|
|
|
WarehouseWaybillVO warehouseWaybillVO = new WarehouseWaybillVO(); |
|
|
|
|
BeanUtil.copyProperties(warehouseWaybillEntity,warehouseWaybillVO); |
|
|
|
|
BeanUtil.copyProperties(warehouseWaybillEntity, warehouseWaybillVO); |
|
|
|
|
|
|
|
|
|
Long waybillId = warehouseWaybillEntity.getId(); |
|
|
|
|
|
|
|
|
@ -710,10 +722,270 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R findWaybillBillladingList(String waybillNo,Long warehouseId) { |
|
|
|
|
public R findWaybillBillladingList(String waybillNo, Long warehouseId) { |
|
|
|
|
|
|
|
|
|
List<WarehouseWaybillEntity> list = baseMapper.findWaybillBillladingList(waybillNo,warehouseId); |
|
|
|
|
List<WarehouseWaybillEntity> list = baseMapper.findWaybillBillladingList(waybillNo, warehouseId); |
|
|
|
|
|
|
|
|
|
return R.data(list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 打印运单 |
|
|
|
|
* |
|
|
|
|
* @param ids |
|
|
|
|
* @param tempId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<PrintPreviewVO> printBatch(String ids, String tempId) throws Exception { |
|
|
|
|
|
|
|
|
|
List<PrintPreviewVO> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
BasicPrintTemplateEntity template = basicPrintTemplateClient.getPrintTemplate(tempId); |
|
|
|
|
|
|
|
|
|
String[] idArray = ids.split(","); |
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isNull(idArray)) { |
|
|
|
|
throw new ServiceException("参数错误"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (String s : idArray) { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询运单 |
|
|
|
|
*/ |
|
|
|
|
WarehouseWaybillEntity warehouseWaybillEntity = baseMapper.selectById(Long.valueOf(s)); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询运单明明细 |
|
|
|
|
*/ |
|
|
|
|
List<WarehouseWayBillDetail> detailList = warehouseWayBillDetailService.findByWaybillId(Long.valueOf(s)); |
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isNotEmpty(detailList)) { |
|
|
|
|
// 得到需要打印的页面数量
|
|
|
|
|
int num = detailList.size() % 4; |
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= num; i++) { |
|
|
|
|
// 需要从detailList每次循环获取到4个数据
|
|
|
|
|
List<WarehouseWayBillDetail> warehouseWayBillDetails = null; |
|
|
|
|
if (i == num) { |
|
|
|
|
warehouseWayBillDetails = detailList.subList(i * 4, detailList.size()); |
|
|
|
|
} else { |
|
|
|
|
warehouseWayBillDetails = detailList.subList(i * 4, 4); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
PrintPreviewVO printPreviewVO = buildPrintWallet(warehouseWaybillEntity, warehouseWayBillDetails, template); |
|
|
|
|
|
|
|
|
|
list.add(printPreviewVO); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private PrintPreviewVO buildPrintWallet(WarehouseWaybillEntity warehouseWaybillEntity, List<WarehouseWayBillDetail> warehouseWayBillDetails, BasicPrintTemplateEntity template) throws Exception { |
|
|
|
|
PrintPreviewVO printPreviewVO = new PrintPreviewVO(); |
|
|
|
|
String html = TemplateUtil.getTemplateByUrl(template.getTemplateUrl()); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
map.put("查询单号", warehouseWaybillEntity.getWaybillNo()); |
|
|
|
|
map.put("起运地", warehouseWaybillEntity.getWaybillNo()); |
|
|
|
|
map.put("到达站", warehouseWaybillEntity.getWaybillNo()); |
|
|
|
|
map.put("客户车次号", warehouseWaybillEntity.getWaybillNo()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map.put("托运单位名称", warehouseWaybillEntity.getShipper()); |
|
|
|
|
map.put("托运单位电话", warehouseWaybillEntity.getShipperMobile()); |
|
|
|
|
map.put("托运单位地址", warehouseWaybillEntity.getShipperAddress()); |
|
|
|
|
|
|
|
|
|
map.put("收货单位名称", warehouseWaybillEntity.getConsignee()); |
|
|
|
|
map.put("收货单位电话", warehouseWaybillEntity.getConsigneeMobile()); |
|
|
|
|
map.put("收货单位地址", warehouseWaybillEntity.getConsigneeAddress()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map.put("备注", warehouseWaybillEntity.getRemark()); |
|
|
|
|
map.put("填票人", warehouseWaybillEntity.getAgent()); |
|
|
|
|
|
|
|
|
|
map.put("托运日期", DateUtil.format(warehouseWaybillEntity.getCreateTime(),"yyyy-MM-dd hh:mm:ss")); |
|
|
|
|
// 格式化费用 保留2位小数
|
|
|
|
|
map.put("运费总计", formatToTwoDecimalPlaces(sumFreight(warehouseWaybillEntity))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map.put("付款方式", checkPayWayString(warehouseWaybillEntity.getPayWay())); |
|
|
|
|
|
|
|
|
|
map.put("托运方式", checkTransportTypeString(warehouseWaybillEntity.getTransportType())); |
|
|
|
|
map.put("收货方付", ""); |
|
|
|
|
map.put("送货方式", checkDeliveryWayString(warehouseWaybillEntity.getDeliveryWay())); |
|
|
|
|
|
|
|
|
|
map.put("运费金额", formatToTwoDecimalPlaces(warehouseWaybillEntity.getTotalFreight())); |
|
|
|
|
map.put("仓储费金额", formatToTwoDecimalPlaces(warehouseWaybillEntity.getStorageFee())); |
|
|
|
|
map.put("送货费金额", formatToTwoDecimalPlaces(warehouseWaybillEntity.getDeliveryFee())); |
|
|
|
|
map.put("卸货费金额", formatToTwoDecimalPlaces(warehouseWaybillEntity.getHandlingFee())); |
|
|
|
|
map.put("提货费金额", formatToTwoDecimalPlaces(warehouseWaybillEntity.getPickupFee())); |
|
|
|
|
map.put("其它费用金额", formatToTwoDecimalPlaces(warehouseWaybillEntity.getOtherFee())); |
|
|
|
|
map.put("保价费金额", formatToTwoDecimalPlaces(warehouseWaybillEntity.getInstallFee())); |
|
|
|
|
map.put("货物申明价值费用金额", formatToTwoDecimalPlaces(warehouseWaybillEntity.getClaimingValue())); |
|
|
|
|
map.put("代收货款金额", formatToTwoDecimalPlaces(warehouseWaybillEntity.getReplacePrice())); |
|
|
|
|
map.put("仓库管理费金额", formatToTwoDecimalPlaces(warehouseWaybillEntity.getWarehouseManagementFee())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> ls = new ArrayList<>(); |
|
|
|
|
for (WarehouseWayBillDetail warehouseWayBillDetail : warehouseWayBillDetails) { |
|
|
|
|
Map<String,Object> t = new HashMap<>(); |
|
|
|
|
t.put("货物名称",warehouseWayBillDetail.getProductName()); |
|
|
|
|
t.put("件数",warehouseWayBillDetail.getNum()); |
|
|
|
|
t.put("包装",""); |
|
|
|
|
t.put("重量",warehouseWayBillDetail.getWeight()); |
|
|
|
|
t.put("体积",warehouseWayBillDetail.getVolume()); |
|
|
|
|
ls.add(t); |
|
|
|
|
} |
|
|
|
|
map.put("货物明细", ls); |
|
|
|
|
|
|
|
|
|
String popHtml = TemplateUtil.popTemplate("运单", map, html); |
|
|
|
|
printPreviewVO.setTemplateHtml(popHtml); |
|
|
|
|
return printPreviewVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String formatToTwoDecimalPlaces(BigDecimal value) { |
|
|
|
|
return value.setScale(2, RoundingMode.HALF_UP).toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 计算费用总计 |
|
|
|
|
* |
|
|
|
|
* @param warehouseWaybillEntity |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private BigDecimal sumFreight(WarehouseWaybillEntity warehouseWaybillEntity) { |
|
|
|
|
|
|
|
|
|
BigDecimal sum = new BigDecimal("0.00"); |
|
|
|
|
|
|
|
|
|
//运费
|
|
|
|
|
if (ObjectUtils.isNotEmpty(warehouseWaybillEntity.getTotalFreight())) { |
|
|
|
|
sum = sum.add(warehouseWaybillEntity.getTotalFreight()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isNotEmpty(warehouseWaybillEntity.getStorageFee())) { |
|
|
|
|
sum = sum.add(warehouseWaybillEntity.getStorageFee()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isNotEmpty(warehouseWaybillEntity.getDeliveryFee())) { |
|
|
|
|
sum = sum.add(warehouseWaybillEntity.getDeliveryFee()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isNotEmpty(warehouseWaybillEntity.getHandlingFee())) { |
|
|
|
|
sum = sum.add(warehouseWaybillEntity.getHandlingFee()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isNotEmpty(warehouseWaybillEntity.getPickupFee())) { |
|
|
|
|
sum = sum.add(warehouseWaybillEntity.getPickupFee()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isNotEmpty(warehouseWaybillEntity.getOtherFee())) { |
|
|
|
|
sum = sum.add(warehouseWaybillEntity.getOtherFee()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isNotEmpty(warehouseWaybillEntity.getInstallFee())) { |
|
|
|
|
sum = sum.add(warehouseWaybillEntity.getInstallFee()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isNotEmpty(warehouseWaybillEntity.getWarehouseManagementFee())) { |
|
|
|
|
sum = sum.add(warehouseWaybillEntity.getWarehouseManagementFee()); |
|
|
|
|
} |
|
|
|
|
return sum; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Object checkDeliveryWayString(String deliveryWay) { |
|
|
|
|
//送货方式 1自提 2送货 3送货上门 4送货上门(有电梯) 5送货上门(无电梯) 6送货卸货 7送货安装
|
|
|
|
|
String deliveryWayString = ""; |
|
|
|
|
switch (deliveryWay) { |
|
|
|
|
case "1": |
|
|
|
|
deliveryWayString = "自提"; |
|
|
|
|
break; |
|
|
|
|
case "2": |
|
|
|
|
deliveryWayString = "送货"; |
|
|
|
|
break; |
|
|
|
|
case "3": |
|
|
|
|
deliveryWayString = "送货上门"; |
|
|
|
|
break; |
|
|
|
|
case "4": |
|
|
|
|
deliveryWayString = "送货上门(有电梯)"; |
|
|
|
|
break; |
|
|
|
|
case "5": |
|
|
|
|
deliveryWayString = "送货上门(无电梯)"; |
|
|
|
|
break; |
|
|
|
|
case "6": |
|
|
|
|
deliveryWayString = "送货卸货"; |
|
|
|
|
break; |
|
|
|
|
case "7": |
|
|
|
|
deliveryWayString = "送货安装"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return deliveryWayString; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Object checkTransportTypeString(String transportType) { |
|
|
|
|
|
|
|
|
|
String transportTypeString = ""; |
|
|
|
|
switch (transportType) { |
|
|
|
|
case "1": |
|
|
|
|
transportTypeString = "汽运"; |
|
|
|
|
break; |
|
|
|
|
case "2": |
|
|
|
|
transportTypeString = "铁路"; |
|
|
|
|
break; |
|
|
|
|
case "3": |
|
|
|
|
transportTypeString = "铁路"; |
|
|
|
|
break; |
|
|
|
|
case "4": |
|
|
|
|
transportTypeString = "铁路"; |
|
|
|
|
break; |
|
|
|
|
case "5": |
|
|
|
|
transportTypeString = "铁路"; |
|
|
|
|
break; |
|
|
|
|
case "6": |
|
|
|
|
transportTypeString = "铁路"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return transportTypeString; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Object checkPayWayString(String payWay) { |
|
|
|
|
//1现付 2到付 3月结 4回付 5内部结算 6多笔付
|
|
|
|
|
String payWayString = ""; |
|
|
|
|
switch (payWay) { |
|
|
|
|
case "1": |
|
|
|
|
payWayString = "现付"; |
|
|
|
|
break; |
|
|
|
|
case "2": |
|
|
|
|
payWayString = "到付"; |
|
|
|
|
break; |
|
|
|
|
case "3": |
|
|
|
|
payWayString = "月结"; |
|
|
|
|
break; |
|
|
|
|
case "4": |
|
|
|
|
payWayString = "回付"; |
|
|
|
|
break; |
|
|
|
|
case "5": |
|
|
|
|
payWayString = "内部结算"; |
|
|
|
|
break; |
|
|
|
|
case "6": |
|
|
|
|
payWayString = "多笔付"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return payWayString; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|