Browse Source

[feat] 采购管理:采购单计划添加采购单,采购报价信息可按照prd上显示,对应prd显示的内容为物料下有供应商列表循环成卡片类显示,显示内容供应商报价。添加计划添加采购单方法。

dev
zhangsiqi 5 months ago
parent
commit
0e8f69c05a
  1. 43
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  2. 18
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchasePlanController.java
  3. 12
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java
  4. 58
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchasePlanChild.java
  5. 2
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  6. 21
      ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanChildMapper.xml
  7. 5
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html

43
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java

@ -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));
}

18
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchasePlanController.java

@ -2,6 +2,7 @@ package com.ruoyi.purchase.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.purchase.domain.PurchasePlan;
@ -114,22 +115,21 @@ public class PurchasePlanController extends BaseController
@GetMapping("/addPurchaseOrder/{purchasePlanCodes}")
public String purChaseOrder(@PathVariable("purchasePlanCodes") String purchasePlanCodes,ModelMap mmap){
//purchasePlanCodes去除重复数据,purchasePlanCodeArray作为数组类型去除
String purchasePlanCode = purchasePlanCodes;
// 直接使用String的split方法分割字符串,然后转为Stream去重,最后再拼接回字符串
String[] purchasePlanCodeArray = purchasePlanCodes.split(",");
purchasePlanCodes = Arrays.toString(Arrays.stream(purchasePlanCodeArray).distinct().toArray());
String uniquePurchasePlanCodes = String.join(",", Arrays.stream(purchasePlanCodeArray).distinct().toArray(String[]::new));
//查询相关采购计划数据
List<PurchasePlan> purchasePlanList = purchasePlanService.selectPurchasePlanByPlanCode(purchasePlanCode);
List<PurchasePlan> purchasePlanList = purchasePlanService.selectPurchasePlanByPlanCode(uniquePurchasePlanCodes);
//根据采购计划编号查询对应的采购报价数据
List<PurchasePlanChild> purchasePlanChildList = purchasePlanChildService.getPurchasePlanChildByPlanCodes(purchasePlanCode);
List<PurchasePlanChild> purchasePlanChildList = purchasePlanChildService.getPurchasePlanChildByPlanCodes(uniquePurchasePlanCodes);
//再根据采购计划编号分组查询对应的采购报价数据分组
for(PurchasePlanChild purchasePlanChild : purchasePlanChildList){
List<PurchaseQuoteChild> purchaseQuoteChildList = purchasePlanChild.getPurchaseQuoteChildList();
purchasePlanChild.setPurchaseSupplierList(purchasePlanChild.parseSupplierMaterialCombinations(purchasePlanChild.getSupplierCodes()));
}
//再根据采购计划编号分组查询对应的采购报价数据分组
purchasePlanCodes = purchasePlanCodes.replace("[","").replace("]","");
//查询物料报价中供应商
mmap.put("purchasePlanList", purchasePlanList);
mmap.put("purchasePlanCodes", purchasePlanCodes);
mmap.put("purchasePlanCodes", uniquePurchasePlanCodes);
mmap.put("purchasePlanChildList", purchasePlanChildList);
return prefix + "/addPurchaseOrder";
}

12
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java

@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.List;
/**
* 采购订单对象 purchase_order
*
@ -177,6 +179,16 @@ public class PurchaseOrder extends BaseEntity
/** 备用二 */
private String standbyTwo;
private List<PurchaseOrderChild> purchaseOrderChildList;
public List<PurchaseOrderChild> getPurchaseOrderChildList() {
return purchaseOrderChildList;
}
public void setPurchaseOrderChildList(List<PurchaseOrderChild> purchaseOrderChildList) {
this.purchaseOrderChildList = purchaseOrderChildList;
}
public Long getPurchaseOrderId() {
return purchaseOrderId;
}

58
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchasePlanChild.java

@ -1,6 +1,8 @@
package com.ruoyi.purchase.domain;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -17,6 +19,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
public class PurchasePlanChild extends BaseEntity
{
private static final long serialVersionUID = 1L;
public List<PurchaseQuoteChild> parseSupplierMaterialCombinations;
/** 采购计划物料清单索引 */
private Long purchasePlanChildId;
@ -83,8 +86,28 @@ public class PurchasePlanChild extends BaseEntity
/** 删除标志 */
private String delFlag;
/** 关联供应商编号 */
private String supplierCodes;
/** 关联采购报价单编号 */
private String correlationCodes;
private List<PurchaseQuoteChild> purchaseQuoteChildList;
private List<PurchaseQuoteChild> purchaseSupplierList;
public String getSupplierCodes() {
return supplierCodes;
}
public void setSupplierCodes(String supplierCodes) {
this.supplierCodes = supplierCodes;
}
public String getCorrelationCodes() {
return correlationCodes;
}
public void setCorrelationCodes(String correlationCodes) {
this.correlationCodes = correlationCodes;
}
public void setPurchasePlanChildId(Long purchasePlanChildId)
{
@ -233,12 +256,12 @@ public class PurchasePlanChild extends BaseEntity
this.supplierName = supplierName;
}
public List<PurchaseQuoteChild> getPurchaseQuoteChildList() {
return purchaseQuoteChildList;
public List<PurchaseQuoteChild> getPurchaseSupplierList() {
return purchaseSupplierList;
}
public void setPurchaseQuoteChildList(List<PurchaseQuoteChild> purchaseQuoteChildList) {
this.purchaseQuoteChildList = purchaseQuoteChildList;
public void setPurchaseSupplierList(List<PurchaseQuoteChild> purchaseSupplierList) {
this.purchaseSupplierList = purchaseSupplierList;
}
public String getUseStatus()
@ -264,6 +287,31 @@ public class PurchasePlanChild extends BaseEntity
return delFlag;
}
public List<PurchaseQuoteChild> parseSupplierMaterialCombinations(String combinations) {
if (combinations == null || combinations.isEmpty()) {
return Collections.emptyList();
}
//materialCode|purchaseQuoteCode|supplierCode|supplierName|materialName|materialNoRmb|materialRmb
/* 1. 料号 | 2. 供应商报价编号 | 3. 供应商编号 | 4.供应商名称 | 5. 物料名称 | 6. 物料含税单价(RMB) | 7. 物料不含税单价(RMB) */
List<PurchaseQuoteChild> purchaseSupplierList = new ArrayList<>();
String[] split = combinations.split(",");
for (int i = 0; i < split.length; i++) {
String[] split1 = split[i].split("\\|");
if (split1.length != 7) {
continue;
}
PurchaseQuoteChild purchaseQuoteChild = new PurchaseQuoteChild();
purchaseQuoteChild.setMaterialCode(split1[0]);
purchaseQuoteChild.setPurchaseQuoteCode(split1[1]);
purchaseQuoteChild.setSupplierCode(split1[2]);
purchaseQuoteChild.setSupplierName(split1[3]);
purchaseQuoteChild.setMaterialName(split1[4]);
purchaseQuoteChild.setMaterialNoRmb(BigDecimal.valueOf(Float.parseFloat(split1[5])));
purchaseQuoteChild.setMaterialRmb(BigDecimal.valueOf(Float.parseFloat(split1[6])));
purchaseSupplierList.add(purchaseQuoteChild);
}
return purchaseSupplierList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

2
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java

@ -59,6 +59,8 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
@Override
public int insertPurchaseOrder(PurchaseOrder purchaseOrder)
{
//根据上传的物料信息做采购订单子项
//
return purchaseOrderMapper.insertPurchaseOrder(purchaseOrder);
}

21
ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanChildMapper.xml

@ -19,6 +19,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="materialRmb" column="material_rmb" />
<result property="materialNoRmb" column="material_noRmb" />
<result property="supplierCode" column="supplier_code" />
<result property="supplierCodes" column="supplier_codes" />
<result property="correlationCodes" column="correlation_codes" />
<result property="supplierName" column="supplier_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@ -165,8 +167,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getPurchasePlanChildByPlanCodes" parameterType="String" resultMap="PurchasePlanChildResult">
SELECT
GROUP_CONCAT(DISTINCT planOrder.correlation_code ORDER BY planOrder.correlation_code) AS correlation_codes,
quote.supplier_code,
GROUP_CONCAT(DISTINCT quote.supplier_code ORDER BY quote.supplier_code) AS supplier_code,
GROUP_CONCAT(DISTINCT CONCAT(quote.material_code,'|',quote.purchase_quote_code , '|' ,quote.supplier_code,'|',
quote.supplier_name,'|',quote.material_name,'|',quote.material_noRmb,'|',quote.material_rmb)
ORDER BY quote.supplier_code) AS supplier_codes,
plan.material_code,
plan.material_name,
plan.material_type,
@ -176,18 +179,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
plan.material_num
FROM
purchase_plan_child AS plan
LEFT JOIN purchase_plan AS planOrder
ON plan.purchase_plan_code = planOrder.purchase_plan_code
AND planOrder.del_flag = '0'
LEFT JOIN purchase_quote_child AS quote
ON plan.material_code = quote.material_code
AND quote.del_flag = '0'
LEFT JOIN purchase_plan AS planOrder ON plan.purchase_plan_code = planOrder.purchase_plan_code AND planOrder.del_flag = '0'
LEFT JOIN purchase_quote_child AS quote ON plan.material_code = quote.material_code AND quote.del_flag = '0'
WHERE
plan.purchase_plan_code IN
<foreach item="purchasePlanCode" collection="array" open="(" separator="," close=")">
#{purchasePlanCode}
</foreach>
AND plan.del_flag = '0'
plan.purchase_plan_code IN ('CGJH20240415001', 'CGJH20240415002') AND plan.del_flag = '0'
GROUP BY
plan.material_code;
</select>

5
ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html

@ -171,14 +171,13 @@
//·拼接采购计划单号
for(var i=0;i<selections.length;i++){
purchasePlanCodes += selections[i].purchasePlanCode + ",";
if(i == selections.length-1){
if(i == selections.length - 1){
purchasePlanCodes += selections[i].purchasePlanCode ;
}
}
}else{
}else if(selections.length === 1){
purchasePlanCodes = selections[0].purchasePlanCode;
}
}
$.modal.open("新增采购订单", prefix + "/addPurchaseOrder/" + purchasePlanCodes);
}

Loading…
Cancel
Save