|
|
|
@ -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<Wareho
|
|
|
|
|
private final IWarehouseUpdownTypeService warehouseUpdownTypeService; |
|
|
|
|
private final IWarehouseTrayTypeService warehouseTrayTypeService; |
|
|
|
|
private final IBasicPrintTemplateClient basicPrintTemplateClient; |
|
|
|
|
private final IUserClient userClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -209,10 +217,10 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
detailEntity.setId(i.getId()); |
|
|
|
|
detailEntity.setActualReceipt(next.getActualReceipt()); //实际
|
|
|
|
|
int i2 = next.getCreateInventory() - i.getCreateInventory(); |
|
|
|
|
if ( next.getCreateInventory() < i.getActualReceipt()){ |
|
|
|
|
if (next.getCreateInventory() < i.getActualReceipt()) { |
|
|
|
|
//入库单预计数量无法进行减少
|
|
|
|
|
log.info("入库单进行预计数量修改,原计划录入:{},目标修改:{}",i.getCreateInventory(),next.getCreateInventory()); |
|
|
|
|
log.info("入库单进行预计数量修改,已入库数量:{}",i.getActualReceipt()); |
|
|
|
|
log.info("入库单进行预计数量修改,原计划录入:{},目标修改:{}", i.getCreateInventory(), next.getCreateInventory()); |
|
|
|
|
log.info("入库单进行预计数量修改,已入库数量:{}", i.getActualReceipt()); |
|
|
|
|
throw new RuntimeException("入库单预计数量不能小于已入库数量"); |
|
|
|
|
} |
|
|
|
|
detailEntity.setCreateInventory(next.getCreateInventory()); |
|
|
|
@ -227,8 +235,8 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
warehouseWarehousingDetailService.updateById(detailEntity);//修改数据
|
|
|
|
|
//当前入库数量
|
|
|
|
|
int i1 = next.getActualReceipt() - i.getActualReceipt(); |
|
|
|
|
if (i1< 0){ |
|
|
|
|
log.info("入库单进行预计数量修改,已入库数量:{},目标修改数量:{}",i.getActualReceipt(),next.getActualReceipt()); |
|
|
|
|
if (i1 < 0) { |
|
|
|
|
log.info("入库单进行预计数量修改,已入库数量:{},目标修改数量:{}", i.getActualReceipt(), next.getActualReceipt()); |
|
|
|
|
throw new RuntimeException("请输入正确的入库数量"); |
|
|
|
|
} |
|
|
|
|
//添加库存品
|
|
|
|
@ -380,10 +388,10 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Integer loadingType = warehousingDetail.getLoadingType(); |
|
|
|
|
if (Func.isNotEmpty(loadingType)){ |
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>入库单录入》》》》》》》》》》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<UpShelfStockDTO> list = new ArrayList<>(); |
|
|
|
|
UpShelfStockDTO upShelfStockDTO = new UpShelfStockDTO(); |
|
|
|
@ -395,8 +403,8 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
upShelfStockDTO.setEnterNum(num); |
|
|
|
|
upShelfStockDTO.setWarehouseId(entity.getWarehouseId()); |
|
|
|
|
list.add(upShelfStockDTO); |
|
|
|
|
warehouseUpdownTypeService.upShelfStockList(list,warehousingDetail.getAllocationId(),entity.getWarehouseId(),"入库单录入数量上架至"+warehousingDetail.getAllocationName()+num+"件"); |
|
|
|
|
}else { |
|
|
|
|
warehouseUpdownTypeService.upShelfStockList(list, warehousingDetail.getAllocationId(), entity.getWarehouseId(), "入库单录入数量上架至" + warehousingDetail.getAllocationName() + num + "件"); |
|
|
|
|
} else { |
|
|
|
|
//进行打托操作
|
|
|
|
|
BasicdataTrayEntity basicdataTray = basicdataTrayClient.findByTrayName(warehousingDetail.getTrayName()); |
|
|
|
|
|
|
|
|
@ -408,7 +416,7 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
noDataStockListDTO.setNum(num); |
|
|
|
|
noDataStockListDTOS.add(noDataStockListDTO); |
|
|
|
|
|
|
|
|
|
warehouseTrayTypeService.enterStockNoDataMaterialCode(basicdataTray.getPalletCode(),"100",noDataStockListDTOS,entity.getWarehouseId(),"入库单录入数量,打托至"+warehousingDetail.getTrayName()+num+"件"); |
|
|
|
|
warehouseTrayTypeService.enterStockNoDataMaterialCode(basicdataTray.getPalletCode(), "100", noDataStockListDTOS, entity.getWarehouseId(), "入库单录入数量,打托至" + warehousingDetail.getTrayName() + num + "件"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -419,7 +427,7 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
BeanUtil.copyProperties(entity, distributionStockListInfo); |
|
|
|
|
distributionStockListInfo.setSourceType("2");//导入
|
|
|
|
|
distributionStockListInfo.setQuantityStock(num); |
|
|
|
|
distributionStockListInfo.setStorageLocation(warehousingDetail.getAllocationName() == null|| Func.isEmpty(warehousingDetail.getAllocationName())?warehousingDetail.getTrayName():warehousingDetail.getAllocationName()); |
|
|
|
|
distributionStockListInfo.setStorageLocation(warehousingDetail.getAllocationName() == null || Func.isEmpty(warehousingDetail.getAllocationName()) ? warehousingDetail.getTrayName() : warehousingDetail.getAllocationName()); |
|
|
|
|
distributionStockListInfo.setId(null); |
|
|
|
|
return distributionStockListInfoClient.addStockListInfoEntity(distributionStockListInfo); |
|
|
|
|
} |
|
|
|
@ -549,27 +557,27 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
detail.setCreateInventory(i.getCreateInventory()); |
|
|
|
|
detail.setWarehousingEntryId(entryEntity.getId()); |
|
|
|
|
detail.setActualReceipt(0); |
|
|
|
|
if (!ObjectUtils.isNull(i.getPositions()) && Func.isNotEmpty(i.getLoadingType())){ |
|
|
|
|
if (!ObjectUtils.isNull(i.getPositions()) && Func.isNotEmpty(i.getLoadingType())) { |
|
|
|
|
String positions = i.getPositions(); |
|
|
|
|
positions =positions.trim().replaceAll("\n","").replaceAll("\r",""); |
|
|
|
|
positions = positions.trim().replaceAll("\n", "").replaceAll("\r", ""); |
|
|
|
|
//查询库位
|
|
|
|
|
if (i.getLoadingType().equals("1")){ |
|
|
|
|
//库位
|
|
|
|
|
WarehouseGoodsAllocationEntity warehouseGoodsAllocationEntity = warehouseGoodsAllocationClient.findByAllocationQrCode(positions); |
|
|
|
|
if (Func.isNotEmpty(warehouseGoodsAllocationEntity)){ |
|
|
|
|
detail.setLoadingType(1); |
|
|
|
|
detail.setAllocationId(warehouseGoodsAllocationEntity.getId()); |
|
|
|
|
detail.setAllocationName(warehouseGoodsAllocationEntity.getQrCode()); |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
//托盘
|
|
|
|
|
BasicdataTrayEntity basicdataTrayEntity = basicdataTrayClient.findByTrayName(positions); |
|
|
|
|
if (Func.isNotEmpty(basicdataTrayEntity)){ |
|
|
|
|
detail.setLoadingType(2); |
|
|
|
|
detail.setTrayId(basicdataTrayEntity.getId()); |
|
|
|
|
detail.setTrayName(basicdataTrayEntity.getPalletName()); |
|
|
|
|
} |
|
|
|
|
if (i.getLoadingType().equals("1")) { |
|
|
|
|
//库位
|
|
|
|
|
WarehouseGoodsAllocationEntity warehouseGoodsAllocationEntity = warehouseGoodsAllocationClient.findByAllocationQrCode(positions); |
|
|
|
|
if (Func.isNotEmpty(warehouseGoodsAllocationEntity)) { |
|
|
|
|
detail.setLoadingType(1); |
|
|
|
|
detail.setAllocationId(warehouseGoodsAllocationEntity.getId()); |
|
|
|
|
detail.setAllocationName(warehouseGoodsAllocationEntity.getQrCode()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
//托盘
|
|
|
|
|
BasicdataTrayEntity basicdataTrayEntity = basicdataTrayClient.findByTrayName(positions); |
|
|
|
|
if (Func.isNotEmpty(basicdataTrayEntity)) { |
|
|
|
|
detail.setLoadingType(2); |
|
|
|
|
detail.setTrayId(basicdataTrayEntity.getId()); |
|
|
|
|
detail.setTrayName(basicdataTrayEntity.getPalletName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//品牌
|
|
|
|
|
BasicdataStoreBrandEntity brandList = basicdataStoreBrandClient.getBrandList(entryEntity.getClientId(), i.getBrandName()); |
|
|
|
@ -642,13 +650,111 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<PrintPreviewVO> printBatch(String ids, Integer type) { |
|
|
|
|
BasicPrintTemplateEntity printTemplate = basicPrintTemplateClient.getPrintTemplate(PrintTemplateStatusConstant.stock_import_1.getValue()); |
|
|
|
|
if (ObjectUtils.isNull(printTemplate)){ |
|
|
|
|
throw new ServiceException("打印模板不存在!"); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
List<PrintPreviewVO> 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<WarehouseWarehousingEntryEntity> list = baseMapper.selectBatchIds(Arrays.asList(idsArr)); |
|
|
|
|
|
|
|
|
|
// 根据入库ID查询 库存品详情
|
|
|
|
|
LambdaQueryWrapper<WarehouseWarehousingDetailEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
queryWrapper.in(WarehouseWarehousingDetailEntity::getWarehousingEntryId, Arrays.asList(idsArr)); |
|
|
|
|
queryWrapper.eq(WarehouseWarehousingDetailEntity::getIsDeleted, "0"); |
|
|
|
|
List<WarehouseWarehousingDetailEntity> detailList = warehouseWarehousingDetailService.list(queryWrapper); |
|
|
|
|
// 按照入库ID分组
|
|
|
|
|
Map<Long, List<WarehouseWarehousingDetailEntity>> detailMap = detailList.stream().collect(Collectors.groupingBy(WarehouseWarehousingDetailEntity::getWarehousingEntryId)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(list)) { |
|
|
|
|
|
|
|
|
|
for (WarehouseWarehousingEntryEntity warehouseWarehousingEntryEntity : list) { |
|
|
|
|
// 查询子表明细
|
|
|
|
|
List<WarehouseWarehousingDetailEntity> 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<WarehouseWarehousingDetailEntity> warehouseWarehousingDetailEntities, BasicPrintTemplateEntity printTemplate, String html) throws Exception { |
|
|
|
|
|
|
|
|
|
Map<String, Object> 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<User> 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<Map<String, Object>> dataList = new ArrayList<>(); |
|
|
|
|
for (WarehouseWarehousingDetailEntity warehouseWarehousingDetailEntity : warehouseWarehousingDetailEntities) { |
|
|
|
|
Map<String, Object> 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<String, Object> buildDataMap(WarehouseWarehousingDetailEntity warehouseWarehousingDetailEntity) { |
|
|
|
|
Map<String, Object> 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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|