【退料】计算入库

dev
siontion 3 months ago
parent 6db86aa07c
commit 651abfd31b

@ -43,7 +43,9 @@ public interface TplusStorageOutMapper extends BaseMapperX<TplusStorageOutDO> {
.disableSubLogicDel() .disableSubLogicDel()
.orderByDesc(TplusStorageOutDO::getId); .orderByDesc(TplusStorageOutDO::getId);
query.between(!StringUtils.isEmpty(reqVO.getSDate()) && !StringUtils.isEmpty(reqVO.getEDate()),TplusStorageOutDO::getCreateTime,reqVO.getSDate(),reqVO.getEDate()); query.between(!StringUtils.isEmpty(reqVO.getSDate()) && !StringUtils.isEmpty(reqVO.getEDate()),TplusStorageOutDO::getCreateTime,reqVO.getSDate(),reqVO.getEDate())
.apply(true,"exists(select id from wms_storage where id=t.stock_id and stock_type=2)")
;
return selectPage(reqVO,query); return selectPage(reqVO,query);
} }

@ -37,6 +37,7 @@ import com.chanko.yunxi.mes.module.biz.manager.CrossOrderManager;
import com.chanko.yunxi.mes.module.biz.service.serialnumber.SerialNumberService; import com.chanko.yunxi.mes.module.biz.service.serialnumber.SerialNumberService;
import com.chanko.yunxi.mes.module.biz.service.storagemat.StorageMatService; import com.chanko.yunxi.mes.module.biz.service.storagemat.StorageMatService;
import com.chanko.yunxi.mes.module.system.dal.mysql.dept.DeptMapper; import com.chanko.yunxi.mes.module.system.dal.mysql.dept.DeptMapper;
import lombok.val;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -303,7 +304,7 @@ public class StorageServiceImpl implements StorageService {
reqOutVO.setSDate(firstDay); reqOutVO.setSDate(firstDay);
reqOutVO.setEDate(lastDay); reqOutVO.setEDate(lastDay);
PageResult<TplusStorageOutDO> storageOutList = tplusStorageOutMapper.selectPage(reqOutVO); PageResult<TplusStorageOutDO> storageOutList = tplusStorageOutMapper.selectPageByDate(reqOutVO);
saveTplusStockInDate(updateObj,storageMatList,storageOutList.getList()); saveTplusStockInDate(updateObj,storageMatList,storageOutList.getList());
} }
@ -343,9 +344,10 @@ public class StorageServiceImpl implements StorageService {
} }
private void saveTplusStockInDate(StorageDO storageDO,List<StorageMatDO> storageMatDOS,List<TplusStorageOutDO> tplusStorageOutDOS){ private void saveTplusStockInDate(StorageDO storageDO,List<StorageMatDO> storageMatDOS,List<TplusStorageOutDO> tplusStorageOutDOS){
List<TplusStorageOutDO> sameWhAndMats;
if(CollUtil.isNotEmpty(tplusStorageOutDOS)){ if(CollUtil.isNotEmpty(tplusStorageOutDOS)){
List<TplusStorageOutDO> sameWhAndMats = tplusStorageOutDOS.stream().filter(ot->{ sameWhAndMats = tplusStorageOutDOS.stream().filter(ot -> {
return storageMatDOS.stream().anyMatch(mo ->mo.getProjectNo()!=null && mo.getWhId().equals(ot.getWhId()) && mo.getMatId().equals(ot.getMatId())); return storageMatDOS.stream().filter(mo -> mo.getWhId().longValue() == ot.getWhId().longValue() && mo.getMatId().longValue() == ot.getMatId().longValue()).count() > 0;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if(CollUtil.isNotEmpty(sameWhAndMats)){ if(CollUtil.isNotEmpty(sameWhAndMats)){
@ -360,8 +362,12 @@ public class StorageServiceImpl implements StorageService {
}); });
if(fixRatioAll[0].doubleValue()==0){ if(fixRatioAll[0].doubleValue()==0){
fixRatioAll[0] = ko.getFixRatio(); fixRatioAll[0] = ko.getFixRatio();
ko.setStorageOkQty(storageOkQtyIn.multiply(BigDecimal.valueOf(-1)));
}else{
val divideData = ko.getFixRatio().doubleValue() / fixRatioAll[0].doubleValue();
ko.setStorageOkQty(storageOkQtyIn.multiply(BigDecimal.valueOf(divideData)).multiply(BigDecimal.valueOf(-1)));
} }
ko.setStorageOkQty(storageOkQtyIn.multiply(ko.getFixRatio().divide(fixRatioAll[0])).multiply(BigDecimal.valueOf(-1)));
}); });
} }
@ -382,11 +388,8 @@ public class StorageServiceImpl implements StorageService {
} }
}); });
tplusStorageOutMapper.delete(TplusStorageOutDO::getStockId,storageDO.getId());
tplusStorageOutMapper.insertBatch(sameWhAndMats);
}else{ }else{
List<TplusStorageOutDO> insertWhAndMats = new ArrayList<>(); sameWhAndMats = new ArrayList<>();
storageMatDOS.forEach(sm->{ storageMatDOS.forEach(sm->{
TplusStorageOutDO tplusStorageOutDO = new TplusStorageOutDO(); TplusStorageOutDO tplusStorageOutDO = new TplusStorageOutDO();
tplusStorageOutDO.setStockId(storageDO.getId()); tplusStorageOutDO.setStockId(storageDO.getId());
@ -399,11 +402,11 @@ public class StorageServiceImpl implements StorageService {
tplusStorageOutDO.setMatId(materialMapper.selectOne(MaterialDO::getCode,sm.getProjectSubCode()).getId()); tplusStorageOutDO.setMatId(materialMapper.selectOne(MaterialDO::getCode,sm.getProjectSubCode()).getId());
tplusStorageOutDO.setStorageOkQty(sm.getStorageOkQty().multiply(new BigDecimal(-1))); tplusStorageOutDO.setStorageOkQty(sm.getStorageOkQty().multiply(new BigDecimal(-1)));
tplusStorageOutDO.setIsSend(0); tplusStorageOutDO.setIsSend(0);
insertWhAndMats.add(tplusStorageOutDO); sameWhAndMats.add(tplusStorageOutDO);
}); });
tplusStorageOutMapper.delete(TplusStorageOutDO::getStockId,storageDO.getId());
tplusStorageOutMapper.insertBatch(insertWhAndMats);
} }
tplusStorageOutMapper.delete(TplusStorageOutDO::getStockId,storageDO.getId());
tplusStorageOutMapper.insertBatch(sameWhAndMats);
} }
private Date getLastDayOfMonth(Date date) { private Date getLastDayOfMonth(Date date) {

Loading…
Cancel
Save