|
|
|
@ -4,6 +4,7 @@ import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
|
|
import com.op.common.core.context.SecurityContextHolder;
|
|
|
|
|
import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
@ -187,4 +188,63 @@ public class BpRawMaterialInDetailServiceImpl implements IBpRawMaterialInDetailS
|
|
|
|
|
public int deleteBpRawMaterialInDetailById(String id) {
|
|
|
|
|
return bpRawMaterialInDetailMapper.deleteBpRawMaterialInDetailById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int insertBpRawMaterialInDetailSC(BpRawMaterialInDetail bpRawMaterialInDetail) {
|
|
|
|
|
int reselt=1;
|
|
|
|
|
//获取当前所选工厂
|
|
|
|
|
String factoryCode = bpRawMaterialInDetail.getFactoryCode();
|
|
|
|
|
DynamicDataSourceContextHolder.push("ds_" + factoryCode);
|
|
|
|
|
if (bpRawMaterialInDetail.getMaterialName().isEmpty() || bpRawMaterialInDetail.getAmountReal()==null){
|
|
|
|
|
}else {
|
|
|
|
|
bpRawMaterialInDetail.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
bpRawMaterialInDetail.setFactoryCode(factoryCode);
|
|
|
|
|
bpRawMaterialInDetail.setWaCode("白坯原料库");
|
|
|
|
|
BaseProduct baseProduct = baseProductMapper.selectBaseProductByProductName(bpRawMaterialInDetail.getMaterialName());
|
|
|
|
|
bpRawMaterialInDetail.setMaterialCode(baseProduct.getProductCode());
|
|
|
|
|
bpRawMaterialInDetail.setUnit("吨");
|
|
|
|
|
bpRawMaterialInDetail.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
bpRawMaterialInDetail.setGmtCreate(new Date());
|
|
|
|
|
bpRawMaterialInDetail.setUserDefined1(bpRawMaterialInDetail.getUserDefined1());//采购单号
|
|
|
|
|
bpRawMaterialInDetailMapper.insertBpRawMaterialInDetail(bpRawMaterialInDetail);
|
|
|
|
|
}
|
|
|
|
|
//判断库存中物料是否存在
|
|
|
|
|
BpRawMaterialIn bpRawMaterialIn = bpRawMaterialInMapper.selectBpRawMaterialInBymateriaName(bpRawMaterialInDetail.getMaterialName());
|
|
|
|
|
if (bpRawMaterialIn==null){
|
|
|
|
|
//不存在,添加库存
|
|
|
|
|
BpRawMaterialIn bpRawMaterialIn1 = new BpRawMaterialIn();
|
|
|
|
|
bpRawMaterialIn1.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
bpRawMaterialIn1.setFactoryCode(factoryCode);
|
|
|
|
|
bpRawMaterialIn1.setWaCode("白坯原料库");
|
|
|
|
|
bpRawMaterialIn1.setMaterialName(bpRawMaterialInDetail.getMaterialName());
|
|
|
|
|
BaseProduct baseProduct = baseProductMapper.selectBaseProductByProductName(bpRawMaterialInDetail.getMaterialName());
|
|
|
|
|
bpRawMaterialIn1.setMaterialCode(baseProduct.getProductCode());
|
|
|
|
|
bpRawMaterialIn1.setUnit(bpRawMaterialInDetail.getUnit());
|
|
|
|
|
bpRawMaterialIn1.setAmountReal(bpRawMaterialInDetail.getAmountReal());
|
|
|
|
|
reselt=bpRawMaterialInMapper.insertBpRawMaterialIn(bpRawMaterialIn1);
|
|
|
|
|
}else {
|
|
|
|
|
//物料存在,加库存
|
|
|
|
|
bpRawMaterialIn.getAmountReal();//原有
|
|
|
|
|
bpRawMaterialInDetail.getAmountReal();//新增
|
|
|
|
|
bpRawMaterialIn.setAmountReal(bpRawMaterialIn.getAmountReal()+bpRawMaterialInDetail.getAmountReal());
|
|
|
|
|
bpRawMaterialInMapper.updateBpRawMaterialIn(bpRawMaterialIn);
|
|
|
|
|
}
|
|
|
|
|
//采购单减库存
|
|
|
|
|
// TODO: 2024-11-11 根据采购单号查询
|
|
|
|
|
BpProcureOrder bpProcureOrder = bpProcureOrderMapper.selectBpProcureOrderByProcureCode(bpRawMaterialInDetail.getUserDefined1());
|
|
|
|
|
if (bpProcureOrder==null){
|
|
|
|
|
reselt=2;
|
|
|
|
|
return reselt;
|
|
|
|
|
}else {
|
|
|
|
|
//采购单减数量
|
|
|
|
|
// BpProcureOrder bpProcureOrder1 = new BpProcureOrder();
|
|
|
|
|
// bpProcureOrder1.setProcureCode(bpRawMaterialInDetail.getUserDefined1());
|
|
|
|
|
// bpProcureOrder1.setMaterialName(bpRawMaterialInDetail.getMaterialName());
|
|
|
|
|
// BaseProduct baseProduct = baseProductMapper.selectBaseProductByProductName(bpRawMaterialInDetail.getMaterialName());
|
|
|
|
|
// bpProcureOrder1.setMaterialCode(baseProduct.getProductCode());
|
|
|
|
|
bpProcureOrder.setRealityNumber(bpRawMaterialInDetail.getAmountReal());
|
|
|
|
|
bpProcureOrderMapper.updateBpProcureOrder(bpProcureOrder);
|
|
|
|
|
}
|
|
|
|
|
return reselt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|