提交 ced97711 编写于 作者: yujiaming's avatar yujiaming

action_in_progress, action_cancel, action_done更新

上级 302c2267
......@@ -2,8 +2,12 @@ package cn.ibizlab.businesscentral.core.extensions.service;
import cn.ibizlab.businesscentral.core.odoo_ir.domain.Ir_sequence;
import cn.ibizlab.businesscentral.core.odoo_ir.service.IIr_sequenceService;
import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_product;
import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_supplierinfo;
import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_template;
import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Purchase_order;
import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Purchase_requisition_line;
import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Purchase_requisition_type;
import cn.ibizlab.businesscentral.core.odoo_purchase.service.impl.Purchase_requisitionServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
......@@ -27,6 +31,12 @@ public class Purchase_requisitionExService extends Purchase_requisitionServiceIm
@Autowired
IIr_sequenceService sequenceService;
@Autowired
protected cn.ibizlab.businesscentral.core.odoo_product.service.IProduct_productService productService;
@Autowired
protected cn.ibizlab.businesscentral.core.odoo_product.service.IProduct_supplierinfoService supplierinfoService;
@Override
protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
......@@ -41,7 +51,22 @@ public class Purchase_requisitionExService extends Purchase_requisitionServiceIm
@Override
@Transactional
public Purchase_requisition action_cancel(Purchase_requisition et) {
//purchase_order cancel
//purchase_requisition cancel
List<Purchase_requisition_line> lines = purchaseRequisitionLineService.selectByRequisitionId(et.getId());
if(lines.size() != 0){
for(Purchase_requisition_line line : lines){
//移除 line 关联 supplierinfo,从Product_supplierinfo中删除相关的记录
// 调用的时models.py中的unlink()方法,从Product_supplierinfo表中将采购申请所对应的供应商价格记录删除
// unlink() 作用是删除当前表中的采购申请行对应的供应商价格记录
}
}
// 取消采购申请所对应的采购订单
List<Purchase_order> orders = purchaseOrderService.selectByRequisitionId(et.getId());
for(Purchase_order order : orders){
purchaseOrderService.button_cancel(order);
// 本采购申请单相关的采购询价单已取消
}
log.warn("purchase_order");
et.setState("cancel");
......@@ -66,7 +91,13 @@ public class Purchase_requisitionExService extends Purchase_requisitionServiceIm
}
List<Purchase_requisition_line> lines = purchaseRequisitionLineService.selectByRequisitionId(et.getId());
//移除 line 关联 supplierinfo
//移除 line 关联 supplierinfo,从Product_supplierinfo中删除相关的记录
if(lines.size() != 0){
for(Purchase_requisition_line line : lines){
// 需要调用product.supplierinfo模型中的unlink()方法,未处理
// unlink() 作用是删除当前表中的采购申请行对应的供应商价格记录
}
}
log.warn("移除 line 关联 supplierinfo");
et.setState("done");
......@@ -111,7 +142,25 @@ public class Purchase_requisitionExService extends Purchase_requisitionServiceIm
if (line.getProductQty() <= 0) {
throw new RuntimeException("你无法确认没有数量的单一供应商采购申请单");
}
//关联 create_supplier_info
// 关联 create_supplier_info,调用的是purchase_resquisition_line的_create_supplier_info()方法
// 向product_supplierinfo表中添加供应商价格记录,在action_done行为时将这些记录删除
Purchase_requisition purchaseRequisition = this.baseMapper.selectById(line.getRequisitionId());
Purchase_requisition_type requisitionType = purchaseRequisitionTypeService.get(purchaseRequisition.getTypeId());
if(StringUtils.compare(requisitionType.getQuantityCopy(), "none") == 0 && purchaseRequisition.getVendorId() != null){
Product_supplierinfo supplierinfo = new Product_supplierinfo();
supplierinfo.setName(purchaseRequisition.getVendorId());
supplierinfo.setProductId(line.getProductId());
Product_product product = productService.get(line.getProductId());
supplierinfo.setProductTmplId(product.getProductTmplId());
supplierinfo.setPrice(line.getPriceUnit());
supplierinfo.setCurrencyId(purchaseRequisition.getCurrencyId());
supplierinfo.setPurchaseRequisitionLineId(line.getId());
// 设置不能为空的值为默认值,sequence,minqty,
supplierinfo.setSequence(1);
supplierinfo.setMinQty(0.0);
supplierinfoService.create(supplierinfo);
}
log.warn("关联 create_supplier_info");
}
et.setState("ongoing");
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册