|
|
@ -13,10 +13,13 @@ import com.ruoyi.common.annotation.Log; |
|
|
|
import com.ruoyi.common.core.controller.BaseController; |
|
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
|
import com.ruoyi.common.core.page.TableDataInfo; |
|
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
|
import com.ruoyi.common.enums.BusinessType; |
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil; |
|
|
|
import com.ruoyi.purchase.domain.PurchaseMaterial; |
|
|
|
import com.ruoyi.purchase.domain.PurchaseOrder; |
|
|
|
import com.ruoyi.purchase.domain.PurchaseOrderChild; |
|
|
|
import com.ruoyi.purchase.domain.PurchaseQuoteChild; |
|
|
|
import com.ruoyi.purchase.domain.exportDto.PurchaseMaterialDto; |
|
|
|
import com.ruoyi.purchase.domain.exportDto.PurchaseOrderDto; |
|
|
|
import com.ruoyi.purchase.service.IPurchaseMaterialService; |
|
|
@ -32,6 +35,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import static com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder.log; |
|
|
@ -53,6 +57,9 @@ public class PurchaseOrderController extends BaseController |
|
|
|
@Autowired |
|
|
|
private IPurchaseMaterialService purchaseMaterialService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisCache redisCache; |
|
|
|
|
|
|
|
@RequiresPermissions("purchase:purchaseOrder:view") |
|
|
|
@GetMapping() |
|
|
|
public String purchaseOrder() |
|
|
@ -103,8 +110,40 @@ public class PurchaseOrderController extends BaseController |
|
|
|
@Log(title = "采购订单", businessType = BusinessType.INSERT) |
|
|
|
@PostMapping("/add") |
|
|
|
@ResponseBody |
|
|
|
public AjaxResult addSave(PurchaseOrder purchaseOrder) |
|
|
|
{ |
|
|
|
public AjaxResult addSave(@RequestBody PurchaseOrder purchaseOrder) throws Exception{ |
|
|
|
//获取采购订单子表中的供应商,核算供应商数量和采购物料合计以及采购数量合计,采购不含税报价合计,采购含税报价合计
|
|
|
|
List<PurchaseOrderChild> purchaseMaterials = purchaseOrder.getPurchaseOrderChildList(); |
|
|
|
purchaseOrder.setPurchaseOrderCode(redisCache.generateBillNo("CG")); |
|
|
|
BigDecimal materialNoRmb = BigDecimal.valueOf(0.0); |
|
|
|
BigDecimal materialRmb = BigDecimal.valueOf(0.0); |
|
|
|
BigDecimal materialNoRmbSum = BigDecimal.valueOf(0.0); |
|
|
|
BigDecimal materialRmbSum = BigDecimal.valueOf(0.0); |
|
|
|
BigDecimal materialSum = BigDecimal.valueOf(0.0); |
|
|
|
Long materialNum = 0L; |
|
|
|
Long supplierNum = 0L; |
|
|
|
for (PurchaseOrderChild purchaseOrderChild : purchaseMaterials) { |
|
|
|
purchaseOrderChild.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
for (PurchaseQuoteChild purchaseSupplierQuote : purchaseOrderChild.getPurchaseQuoteChildList()){ |
|
|
|
BigDecimal suplierMaterialNoRmb = purchaseSupplierQuote.getMaterialNoRmb(); |
|
|
|
BigDecimal suplierMaterialRmb = purchaseSupplierQuote.getMaterialRmb(); |
|
|
|
Long suplierMaterialNum = purchaseSupplierQuote.getMaterialNum(); |
|
|
|
BigDecimal suplierMaterialNoRmbSum = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); |
|
|
|
BigDecimal suplierMaterialRmbSum = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); |
|
|
|
materialNum = materialNum + suplierMaterialNum; |
|
|
|
materialNoRmb = materialNoRmb.add(purchaseSupplierQuote.getMaterialNoRmb()); |
|
|
|
materialRmb = materialRmb.add(purchaseSupplierQuote.getMaterialRmb()); |
|
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSum); |
|
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSum); |
|
|
|
purchaseSupplierQuote.setPurchaseQuoteCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
if (purchaseSupplierQuote.getSupplierCode() != null){ |
|
|
|
supplierNum ++; |
|
|
|
} |
|
|
|
} |
|
|
|
purchaseOrderChild.setMaterialNormb(materialNoRmb); |
|
|
|
purchaseOrderChild.setMaterialRmb(materialRmb); |
|
|
|
purchaseOrderChild.setMaterialNum(materialNum); |
|
|
|
} |
|
|
|
purchaseOrder.setSupplierNum(Math.toIntExact(supplierNum)); |
|
|
|
return toAjax(purchaseOrderService.insertPurchaseOrder(purchaseOrder)); |
|
|
|
} |
|
|
|
|
|
|
|