diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/DistributionTypeConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/DistributionTypeConstant.java index fd15d84a5..2c7035341 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/DistributionTypeConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/DistributionTypeConstant.java @@ -1,5 +1,7 @@ package org.springblade.common.constant; +import org.springblade.common.constant.driver.DriverApprovedDrivingModelConstant; + /** * 配送类型枚举 * 对应码表 distribution_type @@ -43,4 +45,13 @@ public enum DistributionTypeConstant { public void setValue(String value) { this.value = value; } + + public static String getName(String value) { + for (DistributionTypeConstant t : DistributionTypeConstant.values()) { + if (t.getValue().equals(value)) { + return t.getName(); + } + } + return null; + } } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWarehousingEntryServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWarehousingEntryServiceImpl.java index 87e94a938..47051787c 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWarehousingEntryServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWarehousingEntryServiceImpl.java @@ -19,6 +19,7 @@ package com.logpm.warehouse.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils; @@ -58,16 +59,22 @@ import com.logpm.warehouse.service.IWarehouseWarehousingEntryService; import com.logpm.warehouse.vo.WarehouseWarehousingEntryVO; import lombok.AllArgsConstructor; import lombok.extern.log4j.Log4j2; +import org.jetbrains.annotations.NotNull; +import org.springblade.common.constant.DistributionTypeConstant; 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.utils.BeanUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.DictBiz; +import org.springblade.system.entity.User; import org.springblade.system.feign.IDictBizClient; +import org.springblade.system.feign.IUserClient; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -101,6 +108,7 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl>>>>>>>>>>>>>>>>>>>>>入库单录入》》》》》》》》》》loadingType:{}",warehousingDetail.getLoadingType()); - log.info(">>>>>>>>>>>>>>>>>>>>>>入库单录入》》》》》》》》》》allocationId:{}",warehousingDetail.getAllocationId()); - if (loadingType.equals(1)){ + if (Func.isNotEmpty(loadingType)) { + log.info(">>>>>>>>>>>>>>>>>>>>>>入库单录入》》》》》》》》》》loadingType:{}", warehousingDetail.getLoadingType()); + log.info(">>>>>>>>>>>>>>>>>>>>>>入库单录入》》》》》》》》》》allocationId:{}", warehousingDetail.getAllocationId()); + if (loadingType.equals(1)) { //上架至库位 List list = new ArrayList<>(); UpShelfStockDTO upShelfStockDTO = new UpShelfStockDTO(); @@ -395,8 +403,8 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl printBatch(String ids, Integer type) { - BasicPrintTemplateEntity printTemplate = basicPrintTemplateClient.getPrintTemplate(PrintTemplateStatusConstant.stock_import_1.getValue()); - if (ObjectUtils.isNull(printTemplate)){ - throw new ServiceException("打印模板不存在!"); + + try { + List printPreviewVOList = new ArrayList<>(); + BasicPrintTemplateEntity printTemplate = basicPrintTemplateClient.getPrintTemplate(PrintTemplateStatusConstant.stock_import_1.getValue()); + String html = TemplateUtil.getTemplateByUrl(printTemplate.getTemplateUrl()); + if (ObjectUtils.isNull(printTemplate)) { + throw new ServiceException("打印模板不存在!"); + } + + String[] idsArr = ids.split(","); + + List list = baseMapper.selectBatchIds(Arrays.asList(idsArr)); + + // 根据入库ID查询 库存品详情 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(WarehouseWarehousingDetailEntity::getWarehousingEntryId, Arrays.asList(idsArr)); + queryWrapper.eq(WarehouseWarehousingDetailEntity::getIsDeleted, "0"); + List detailList = warehouseWarehousingDetailService.list(queryWrapper); + // 按照入库ID分组 + Map> detailMap = detailList.stream().collect(Collectors.groupingBy(WarehouseWarehousingDetailEntity::getWarehousingEntryId)); + + + if (Func.isNotEmpty(list)) { + + for (WarehouseWarehousingEntryEntity warehouseWarehousingEntryEntity : list) { + // 查询子表明细 + List warehouseWarehousingDetailEntities = detailMap.get(warehouseWarehousingEntryEntity.getId()); + + PrintPreviewVO printPreviewVO = buildPrintPreviewVO(warehouseWarehousingEntryEntity, warehouseWarehousingDetailEntities, printTemplate, html); + + + printPreviewVOList.add(printPreviewVO); + + + } + + } + + return printPreviewVOList; + } catch (Exception e) { + log.error("打印入库单异常", e); + throw new ServiceException("服务器异常,请联系管理员"); + } + + } + + /** + * 构建入库单信息 + * + * @param warehouseWarehousingEntryEntity + * @param warehouseWarehousingDetailEntities + * @param printTemplate + * @return + */ + private PrintPreviewVO buildPrintPreviewVO(WarehouseWarehousingEntryEntity warehouseWarehousingEntryEntity, List warehouseWarehousingDetailEntities, BasicPrintTemplateEntity printTemplate, String html) throws Exception { + + Map map = new HashMap<>(); + + map.put("入库时间", DateUtil.DATE_FORMAT.format(warehouseWarehousingEntryEntity.getReceiptDate())); + map.put("入库批次", warehouseWarehousingEntryEntity.getReceiptBatch()); + map.put("客户名称", warehouseWarehousingEntryEntity.getCustomerName()); + map.put("客户编码", warehouseWarehousingEntryEntity.getCustomerCode()); + map.put("门店名称", warehouseWarehousingEntryEntity.getStoreName()); + map.put("物流公司", warehouseWarehousingEntryEntity.getLogisticsCompany()); + map.put("物流运单号", warehouseWarehousingEntryEntity.getTrainNumber()); + map.put("入库车牌", warehouseWarehousingEntryEntity.getLicensePlate()); + map.put("订单号", warehouseWarehousingEntryEntity.getOrderNumber()); + map.put("所在仓库", warehouseWarehousingEntryEntity.getWarehouse()); + map.put("服务类型", DistributionTypeConstant.getName(warehouseWarehousingEntryEntity.getServiceType())); + map.put("备注", warehouseWarehousingEntryEntity.getRemark()); + R userR = userClient.userInfoById(warehouseWarehousingEntryEntity.getCreateUser()); + if (userR.isSuccess() && userR.getData() != null) { + map.put("制单人", userR.getData().getName()); } + map.put("制单时间", DateUtil.DATETIME_FORMAT.format(warehouseWarehousingEntryEntity.getCreateTime())); - return null; + List> dataList = new ArrayList<>(); + for (WarehouseWarehousingDetailEntity warehouseWarehousingDetailEntity : warehouseWarehousingDetailEntities) { + Map dataMap = buildDataMap(warehouseWarehousingDetailEntity); + dataList.add(dataMap); + } + map.put("入库明细", dataList); + + String popHtml = TemplateUtil.popTemplate("入库单打印", map, html); + PrintPreviewVO printPreviewVO = new PrintPreviewVO(); + printPreviewVO.setTemplateId(printTemplate.getId()); + printPreviewVO.setTemplateHtml(popHtml); + + return printPreviewVO; + + } + @NotNull + private static Map buildDataMap(WarehouseWarehousingDetailEntity warehouseWarehousingDetailEntity) { + Map dataMap = new HashMap<>(); + dataMap.put("SKU", warehouseWarehousingDetailEntity.getSku()); + dataMap.put("物料编码", warehouseWarehousingDetailEntity.getProductCode()); + dataMap.put("物科名称", warehouseWarehousingDetailEntity.getProductName()); + dataMap.put("物料单位", warehouseWarehousingDetailEntity.getProductUnit()); + dataMap.put("包装数据", warehouseWarehousingDetailEntity.getPackagingNumber()); + dataMap.put("品牌", warehouseWarehousingDetailEntity.getBrandName()); + dataMap.put("托盘名称", warehouseWarehousingDetailEntity.getTrayName()); + dataMap.put("预计入库件数", warehouseWarehousingDetailEntity.getCreateInventory()); + dataMap.put("实际入库件数", warehouseWarehousingDetailEntity.getActualReceipt()); + return dataMap; } }