|
|
|
@ -16,9 +16,17 @@
|
|
|
|
|
*/ |
|
|
|
|
package com.logpm.warehouse.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.google.common.eventbus.AllowConcurrentEvents; |
|
|
|
|
import com.logpm.basic.entity.BasicMaterialEntity; |
|
|
|
|
import com.logpm.basic.feign.IBasicMaterialClient; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataClientEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
|
|
import com.logpm.basicdata.feign.IBasicdataClientClient; |
|
|
|
|
import com.logpm.basicdata.feign.IBasicdataWarehouseClient; |
|
|
|
|
import com.logpm.distribution.entity.DistributionStockListEntity; |
|
|
|
|
import com.logpm.distribution.feign.IDistributionStockListClient; |
|
|
|
|
import com.logpm.distribution.vo.DistributionStockListVO; |
|
|
|
@ -32,9 +40,13 @@ import com.logpm.warehouse.excel.WarehouseWarehousingEntryExcel;
|
|
|
|
|
import com.logpm.warehouse.mapper.WarehouseWarehousingEntryMapper; |
|
|
|
|
import com.logpm.warehouse.service.IWarehouseWarehousingEntryService; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
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.Func; |
|
|
|
|
import org.springblade.system.entity.DictBiz; |
|
|
|
|
import org.springblade.system.feign.IDictBizClient; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
@ -42,9 +54,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Iterator; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 仓库入库单 服务实现类 |
|
|
|
@ -57,6 +69,10 @@ import java.util.List;
|
|
|
|
|
public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<WarehouseWarehousingEntryMapper, WarehouseWarehousingEntryEntity> implements IWarehouseWarehousingEntryService { |
|
|
|
|
private final IWarehouseWarehousingDetailService warehouseWarehousingDetailService; |
|
|
|
|
private final IDistributionStockListClient distributionStockListClient; |
|
|
|
|
private final IDictBizClient dictBizClient; |
|
|
|
|
private final IBasicMaterialClient basicMaterialClient; |
|
|
|
|
private final IBasicdataClientClient basicdataClientClient; |
|
|
|
|
private final IBasicdataWarehouseClient basicdataWarehouseClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -84,17 +100,19 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
BeanUtil.copyProperties(warehouseWarehousingEntryDTO,warehouseWarehousingEntry); |
|
|
|
|
if(ObjectUtils.isNotNull(warehouseWarehousingEntryDTO.getId())){ |
|
|
|
|
List<Long> detailEntityList = new ArrayList<>(); |
|
|
|
|
//修改
|
|
|
|
|
this.updateById(warehouseWarehousingEntry); |
|
|
|
|
List<WarehouseWarehousingDetailEntity> list1 = warehouseWarehousingDetailService.list(Wrappers.<WarehouseWarehousingDetailEntity>query().lambda() |
|
|
|
|
.eq(WarehouseWarehousingDetailEntity::getWarehousingEntryId, warehouseWarehousingEntry.getId()) |
|
|
|
|
); |
|
|
|
|
AtomicBoolean ba = new AtomicBoolean(false); |
|
|
|
|
list1.forEach( i ->{ |
|
|
|
|
boolean b = list.stream().anyMatch(w -> w.getMaterialId().equals(i.getMaterialId())); |
|
|
|
|
if(b){ |
|
|
|
|
Iterator<WarehouseWarehousingDetailEntity> iterator = list.iterator(); |
|
|
|
|
while (iterator.hasNext()){ |
|
|
|
|
WarehouseWarehousingDetailEntity next = iterator.next(); |
|
|
|
|
if(!i.getActualReceipt().equals(i.getCreateInventory())){ |
|
|
|
|
ba.set(true); |
|
|
|
|
} |
|
|
|
|
if(next.getMaterialId().equals(i.getMaterialId())){ |
|
|
|
|
//修改
|
|
|
|
|
WarehouseWarehousingDetailEntity detailEntity = new WarehouseWarehousingDetailEntity(); |
|
|
|
@ -104,6 +122,7 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
detailEntity.setConditions("3"); |
|
|
|
|
}else{ |
|
|
|
|
detailEntity.setConditions("2"); |
|
|
|
|
warehouseWarehousingEntry.setConditions("2"); |
|
|
|
|
} |
|
|
|
|
warehouseWarehousingDetailService.updateById(detailEntity);//修改数据
|
|
|
|
|
//当前入库数量
|
|
|
|
@ -119,6 +138,11 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
detailEntityList.add(i.getId()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if(!ba.get()){ |
|
|
|
|
warehouseWarehousingEntry.setConditions("3"); |
|
|
|
|
} |
|
|
|
|
//修改
|
|
|
|
|
this.updateById(warehouseWarehousingEntry); |
|
|
|
|
if(detailEntityList.size() > 0){ |
|
|
|
|
//删除多余的
|
|
|
|
|
warehouseWarehousingDetailService.deleteLogic(detailEntityList); |
|
|
|
@ -243,9 +267,96 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
|
|
|
|
|
* @param isCovered |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public void importUser(List<WarehousingEntryDetailExcel> data, Boolean isCovered) { |
|
|
|
|
data.forEach( i ->{ |
|
|
|
|
System.out.println("smsmmsmsmsmsmsmmsmsmsmmsmsms"+i); |
|
|
|
|
//分组
|
|
|
|
|
Map<String, List<WarehousingEntryDetailExcel>> collect = data.stream().map(x -> { |
|
|
|
|
return x; |
|
|
|
|
}).collect(Collectors.groupingBy(o ->{ |
|
|
|
|
// System.out.println("====<<<<<<<<"+o);
|
|
|
|
|
WarehouseWarehousingEntryEntity entryEntity = new WarehouseWarehousingEntryEntity(); |
|
|
|
|
entryEntity.setReceiptBatch(o.getReceiptBatch()); |
|
|
|
|
entryEntity.setReceiptDate(o.getReceiptDate()); |
|
|
|
|
entryEntity.setConditions("1"); |
|
|
|
|
BasicdataClientEntity customer = basicdataClientClient.getCustomer(o.getCustomerName(), o.getCustomerCode()); |
|
|
|
|
if(Func.isNotEmpty(customer)){ |
|
|
|
|
if(StringUtils.isNotBlank(o.getStoreName())){ |
|
|
|
|
BasicdataClientEntity customer1 = basicdataClientClient.findByName(o.getStoreName()); |
|
|
|
|
if(Func.isNotEmpty(customer1)){ |
|
|
|
|
entryEntity.setStoreId(customer1.getId()); |
|
|
|
|
entryEntity.setStoreName(o.getStoreName()); |
|
|
|
|
}else{ |
|
|
|
|
throw new ServiceException(o.getCustomerName()+o.getCustomerCode()+"门店信息不存在!!请维护门店数据!!!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
entryEntity.setClientId(customer.getId());//客户id
|
|
|
|
|
entryEntity.setCustomerName(o.getCustomerName()); |
|
|
|
|
entryEntity.setCustomerCode(o.getCustomerCode()); |
|
|
|
|
}else{ |
|
|
|
|
throw new ServiceException(o.getCustomerName()+o.getCustomerCode()+"客户信息不存在!!请维护客户数据!!!"); |
|
|
|
|
} |
|
|
|
|
BasicdataWarehouseEntity warehouse = basicdataWarehouseClient.getWarehouse(o.getWarehouse(), o.getWarehouseCode()); |
|
|
|
|
if(Func.isNotEmpty(warehouse)){ |
|
|
|
|
entryEntity.setWarehouseId(warehouse.getId());//仓库id
|
|
|
|
|
entryEntity.setWarehouse(o.getWarehouse());//仓库名称
|
|
|
|
|
}else{ |
|
|
|
|
throw new ServiceException(o.getCustomerName()+o.getCustomerCode()+"仓库信息不存在!!请维护仓库数据!!!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
entryEntity.setTrainNumber(o.getTrainNumber()); //仓库名称
|
|
|
|
|
entryEntity.setLicensePlate(o.getLicensePlate()); //仓库名称
|
|
|
|
|
entryEntity.setSource("导入"); |
|
|
|
|
R<List<DictBiz>> distriType = dictBizClient.getList("distribution_type"); |
|
|
|
|
if(ObjectUtils.isNotNull(distriType)){ |
|
|
|
|
List<DictBiz> data1 = distriType.getData(); |
|
|
|
|
DictBiz dictBiz = data1.stream().filter(da -> { |
|
|
|
|
return o.getServiceType().equals(da.getDictValue()); |
|
|
|
|
}).findAny().get(); |
|
|
|
|
entryEntity.setServiceType(dictBiz.getDictKey());//仓库名称
|
|
|
|
|
} |
|
|
|
|
entryEntity.setPositions(o.getPositions() ); |
|
|
|
|
String s = JSONObject.toJSONString(entryEntity); |
|
|
|
|
return s; |
|
|
|
|
} , Collectors.toList())); |
|
|
|
|
|
|
|
|
|
collect.forEach((k,v) ->{ |
|
|
|
|
// System.out.println(">>>>>>>>>>>+++++"+k+v);
|
|
|
|
|
WarehouseWarehousingEntryEntity entryEntity = JSON.parseObject(k, WarehouseWarehousingEntryEntity.class); |
|
|
|
|
// WarehouseWarehousingEntryEntity entryEntity = JSONObject.parseObject(JSONObject.toJSONString(k), WarehouseWarehousingEntryEntity.class);
|
|
|
|
|
this.save(entryEntity); |
|
|
|
|
List<WarehouseWarehousingDetailEntity> detailEntityList = new ArrayList<>(); |
|
|
|
|
v.forEach( i ->{ |
|
|
|
|
WarehouseWarehousingDetailEntity detail = new WarehouseWarehousingDetailEntity(); |
|
|
|
|
detail.setConditions("1"); |
|
|
|
|
detail.setSku(i.getSku()); |
|
|
|
|
detail.setProductCode(i.getProductCode()); |
|
|
|
|
detail.setProductName(i.getProductName()); |
|
|
|
|
detail.setProductCode(i.getProductCode()); |
|
|
|
|
detail.setProductUnit(i.getProductUnit()); |
|
|
|
|
detail.setPackagingNumber(i.getPackagingNumber()); |
|
|
|
|
detail.setPackagingSpecifications(i.getPackagingSpecifications()); |
|
|
|
|
detail.setCreateInventory(i.getCreateInventory()); |
|
|
|
|
detail.setWarehousingEntryId(entryEntity.getId()); |
|
|
|
|
detail.setActualReceipt(0); |
|
|
|
|
BasicMaterialEntity materialOwn = basicMaterialClient.getMaterialOwn(i.getProductCode(), i.getProductName(), i.getSku()); |
|
|
|
|
if(Func.isNotEmpty(materialOwn)){ |
|
|
|
|
detail.setMaterialId(materialOwn.getId());//物料ID
|
|
|
|
|
}else{ |
|
|
|
|
throw new ServiceException(i.getProductName()+i.getProductCode()+i.getSku()+"物料信息不存在!!请维护基础数据!!!"); |
|
|
|
|
} |
|
|
|
|
if(detailEntityList.size() > 0){ |
|
|
|
|
boolean b = detailEntityList.stream().anyMatch(a -> a.getProductCode().equals(detail.getProductCode()) && a.getProductName().equals(detail.getProductName()) && a.getSku().equals(detail.getSku())); |
|
|
|
|
if(b){ |
|
|
|
|
detailEntityList.stream().filter(a -> a.getProductCode().equals(detail.getProductCode()) && a.getProductName().equals(detail.getProductName()) && a.getSku().equals(detail.getSku())).forEach( f->f.setCreateInventory(f.getCreateInventory()+detail.getCreateInventory())); |
|
|
|
|
}else{ |
|
|
|
|
detailEntityList.add(detail); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
detailEntityList.add(detail); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
warehouseWarehousingDetailService.saveBatch(detailEntityList); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|