Browse Source

[feat]: 修改采购订单切割采购计划字符。新增修改采购订单方法。

dev
zhangsiqi 3 months ago
parent
commit
c935c08617
  1. 52
      ruoyi-activiti/src/main/java/com/ruoyi/process/general/service/impl/ProcessServiceImpl.java
  2. 17
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderChildMapper.java
  3. 15
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderChildService.java
  4. 10
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderChildServiceImpl.java
  5. 404
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  6. 10
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml
  7. 10
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html

52
ruoyi-activiti/src/main/java/com/ruoyi/process/general/service/impl/ProcessServiceImpl.java

@ -2,6 +2,7 @@ package com.ruoyi.process.general.service.impl;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
@ -17,6 +18,7 @@ import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricActivityInstanceQuery;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Comment;
import org.activiti.engine.task.Task;
@ -28,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
@ -35,6 +38,7 @@ import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Transactional
@ -94,6 +98,54 @@ public class ProcessServiceImpl implements IProcessService {
return activityList;
}
@Override
public List<HistoricActivity> selectHistoryList(@RequestParam(required = false) String businessKey, String processInstanceId, HistoricActivity historicActivity) {
// 查询特定 businessKey 的完成过的所有流程实例
List<HistoricProcessInstance> historicProcessInstanceList = historyService.createHistoricProcessInstanceQuery()
.processInstanceBusinessKey(businessKey)
.list();
List<HistoricActivity> activityList = new ArrayList<>();
// 如果没有找到流程实例,可以抛出异常或采取其他措施
if (CollectionUtils.isEmpty(historicProcessInstanceList)) {
throw new BusinessException("没有找到与业务键 " + businessKey + " 相关的流程实例");
}
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId)
.activityType("userTask")
.finished()
.orderByHistoricActivityInstanceStartTime()
.desc();
if (StringUtils.isNotBlank(historicActivity.getAssignee())) {
query.taskAssignee(historicActivity.getAssignee());
}
if (StringUtils.isNotBlank(historicActivity.getActivityName())) {
query.activityName(historicActivity.getActivityName());
}
List<HistoricActivityInstance> list = query.list();
for (HistoricActivityInstance instance : list) {
HistoricActivity activity = new HistoricActivity();
BeanUtils.copyProperties(instance, activity);
String taskId = instance.getTaskId();
List<Comment> comment = taskService.getTaskComments(taskId, "comment");
if (!CollectionUtils.isEmpty(comment)) {
activity.setComment(comment.get(0).getFullMessage());
}
SysUser sysUser = userMapper.selectUserByLoginName(instance.getAssignee());
if (sysUser != null) {
activity.setAssigneeName(sysUser.getUserName());
}
activityList.add(activity);
}
return activityList;
}
@Override
public String selectLastActName(String processInstanceId) {
// TODO Auto-generated method stub

17
ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderChildMapper.java

@ -2,6 +2,7 @@ package com.ruoyi.purchase.mapper;
import java.util.List;
import com.ruoyi.purchase.domain.PurchaseOrderChild;
import org.apache.ibatis.annotations.Mapper;
/**
* 采购订单子表Mapper接口
@ -9,6 +10,7 @@ import com.ruoyi.purchase.domain.PurchaseOrderChild;
* @author zhang
* @date 2024-06-19
*/
@Mapper
public interface PurchaseOrderChildMapper
{
/**
@ -50,6 +52,14 @@ public interface PurchaseOrderChildMapper
* @return 结果
*/
public int deletePurchaseOrderChildById(Long purchaseOrderChildId);
/**
* 删除采购订单子表
*
* @param purchaseOrderCode 采购订单子表号
* @return 结果
*/
public int deletePurchaseOrderChildByPurchaseOrderCode(String purchaseOrderCode);
/**
* 批量删除采购订单子表
@ -58,6 +68,13 @@ public interface PurchaseOrderChildMapper
* @return 结果
*/
public int deletePurchaseOrderChildByIds(String[] purchaseOrderChildIds);
/**
* 批量删除采购订单子表
*
* @param purchaseOrderCodes 需要删除的数据单号列表
* @return 结果
*/
public int deletePurchaseOrderChildByPurchaseOrderCodes(String[] purchaseOrderCodes);
/**
* 作废采购订单子表

15
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderChildService.java

@ -52,6 +52,13 @@ public interface IPurchaseOrderChildService
* @return 结果
*/
public int deletePurchaseOrderChildByIds(String ids);
/**
* 批量删除采购订单子表
*
* @param purchaseOrderCodes 需要删除的数据单号
* @return 结果
*/
public int deletePurchaseOrderChildByPurchaseOrderCodes(String purchaseOrderCodes);
/**
* 删除采购订单子表信息
@ -61,6 +68,14 @@ public interface IPurchaseOrderChildService
*/
public int deletePurchaseOrderChildById(Long purchaseOrderChildId);
/**
* 删除采购订单子表信息
*
* @param purchaseOrderCode 采购订单子表单号
* @return 结果
*/
public int deletePurchaseOrderChildByPurchaseOrderCode(String purchaseOrderCode);
/**
* 作废采购订单子表
* @param purchaseOrderChildId 采购订单子表ID

10
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderChildServiceImpl.java

@ -90,6 +90,11 @@ public class PurchaseOrderChildServiceImpl implements IPurchaseOrderChildService
return purchaseOrderChildMapper.deletePurchaseOrderChildByIds(Convert.toStrArray(ids));
}
@Override
public int deletePurchaseOrderChildByPurchaseOrderCodes(String purchaseOrderCodes) {
return purchaseOrderChildMapper.deletePurchaseOrderChildByPurchaseOrderCodes(Convert.toStrArray(purchaseOrderCodes));
}
/**
* 删除采购订单子表信息
*
@ -102,6 +107,11 @@ public class PurchaseOrderChildServiceImpl implements IPurchaseOrderChildService
return purchaseOrderChildMapper.deletePurchaseOrderChildById(purchaseOrderChildId);
}
@Override
public int deletePurchaseOrderChildByPurchaseOrderCode(String purchaseOrderCode) {
return purchaseOrderChildMapper.deletePurchaseOrderChildByPurchaseOrderCode(purchaseOrderCode);
}
/**
* 作废采购订单子表
*

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

@ -255,7 +255,8 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
//订单子表去除实际物料数量位null或者0的物料信息
purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null).collect(Collectors.toList());
for (PurchaseOrderChild child : purchaseOrderChildList) {
if (child.getCorrelationCode().contains(",")) {
if (child.getCorrelationCode().contains(","))
{
String[] correlationCodes = child.getCorrelationCode().split(",");
String[] planCodes = child.getPurchasePlanCode().split(",");
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(",");
@ -286,7 +287,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setPurchasePlanCorrelationCode(child.getCorrelationCode());
material.setPurchasePlanCorrelationCode(correlationCodes[i]);
material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept());
@ -311,9 +312,91 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
//实际采购单价合计
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal);
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal);
material.setCorrelationCode(child.getCorrelationCode());
material.setCorrelationCode(correlationCodes[i]);
material.setDeliveryTime(child.getDeliveryTime());
material.setPurchasePlanCode(planCode);
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode());
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material.setEceiptStatus("0");
material.setPaymentStatus("0");
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(planCode);
plan.setPurchasePlanStatus("1");
int result = purchasePlanService.updatePurchasePlan(plan);
}
}
}
else if ((child.getPurchasePlanCode().contains(",") && !child.getCorrelationCode().contains(",")
&& child.getCorrelationCode()!= null))
{
String[] planCodes = child.getPurchasePlanCode().split(",");
for (int i = 0; i < planCodes.length - 1; i++) {
String[] correlationCodes = child.getCorrelationCode().split(",");
String[] planCode2 = child.getPurchasePlanCode().split(",");
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(",");
String planCode = planCode2[i];
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode);
if (planCode != null) {
PurchaseOrderChild material = new PurchaseOrderChild();
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
//获取物料供应商不含税采购价格
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb();
// 获取物料供应商含税采购价格
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb();
// 获取物料数量
BigDecimal suplierMaterialNum = child.getMaterialRealNum();
if (suplierMaterialNoRmb == null) {
suplierMaterialNoRmb = BigDecimal.ZERO;
}
if (suplierMaterialRmb == null) {
suplierMaterialRmb = BigDecimal.ZERO;
}
if (suplierMaterialNum == null) {
suplierMaterialNum = new BigDecimal(0);
}
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量
materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setCorrelationCode(purchasePlan.getCorrelationCode());
material.setPurchasePlanCorrelationCode(correlationCodes[i]);
material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept());
material.setSupplierName(child.getSupplierName());
material.setMaterialCode(child.getMaterialCode());
material.setMaterialName(child.getMaterialName());
material.setMaterialBrand(child.getMaterialBrand());
material.setMaterialDescribe(child.getMaterialDescribe());
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl());
material.setMaterialProcessMethod(child.getMaterialProcessMethod());
material.setWarehouseDept(child.getWarehouseDept());
//计划采购数
material.setMaterialNum(child.getMaterialNum());
material.setMaterialNoRmb(child.getMaterialNoRmb());
material.setMaterialRmb(child.getMaterialRmb());
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum());
material.setMaterialRmbSum(child.getMaterialRmbSum());
//实际采购数
material.setMaterialRealNum(child.getMaterialRealNum());
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb());
material.setMaterialRealRmb(child.getMaterialRealRmb());
material.setDeliveryTime(child.getDeliveryTime());
material.setPurchasePlanCode(child.getPurchasePlanCode());
//实际采购单价合计
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal);
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal);
material.setCorrelationCode(child.getCorrelationCode());
material.setPurchasePlanCode(planCode);
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode());
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material.setEceiptStatus("0");
@ -321,77 +404,86 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(child.getPurchasePlanCode());
plan.setPurchasePlanCode(planCode);
plan.setPurchasePlanStatus("1");
int result = purchasePlanService.updatePurchasePlan(plan);
}
}
}
else if ((!child.getCorrelationCode().contains(","))
&& child.getPurchasePlanCode() != null) {
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(child.getPurchasePlanCode());
PurchaseOrderChild material = new PurchaseOrderChild();
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
//获取物料供应商不含税采购价格
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb();
// 获取物料供应商含税采购价格
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb();
// 获取物料数量
BigDecimal suplierMaterialNum = child.getMaterialRealNum();
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;}
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;}
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);}
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量
materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setCorrelationCode(purchasePlan.getCorrelationCode());
material.setPurchasePlanCorrelationCode(child.getCorrelationCode());
material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept());
material.setSupplierName(child.getSupplierName());
material.setMaterialCode(child.getMaterialCode());
material.setMaterialName(child.getMaterialName());
material.setMaterialBrand(child.getMaterialBrand());
material.setMaterialDescribe(child.getMaterialDescribe());
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl());
material.setMaterialProcessMethod(child.getMaterialProcessMethod());
material.setWarehouseDept(child.getWarehouseDept());
//计划采购数
material.setMaterialNum(child.getMaterialNum());
material.setMaterialNoRmb(child.getMaterialNoRmb());
material.setMaterialRmb(child.getMaterialRmb());
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum());
material.setMaterialRmbSum(child.getMaterialRmbSum());
//实际采购数
material.setMaterialRealNum(child.getMaterialRealNum());
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb());
material.setMaterialRealRmb(child.getMaterialRealRmb());
material.setDeliveryTime(child.getDeliveryTime());
//实际采购单价合计
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal);
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal);
material.setCorrelationCode(child.getCorrelationCode());
material.setPurchasePlanCode(child.getPurchasePlanCode());
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode());
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material.setEceiptStatus("0");
material.setPaymentStatus("0");
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(child.getPurchasePlanCode());
plan.setPurchasePlanStatus("1");
int result = purchasePlanService.updatePurchasePlan(plan);
else if(child.getCorrelationCode().contains(",") && child.getCorrelationCode().contains(",") &&
child.getPurchasePlanCode()!=null && child.getCorrelationCode()!=null){
String planCode = child.getPurchasePlanCode();
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode);
if (planCode != null) {
PurchaseOrderChild material = new PurchaseOrderChild();
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
//获取物料供应商不含税采购价格
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb();
// 获取物料供应商含税采购价格
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb();
// 获取物料数量
BigDecimal suplierMaterialNum = child.getMaterialRealNum();
if (suplierMaterialNoRmb == null) {
suplierMaterialNoRmb = BigDecimal.ZERO;
}
if (suplierMaterialRmb == null) {
suplierMaterialRmb = BigDecimal.ZERO;
}
if (suplierMaterialNum == null) {
suplierMaterialNum = new BigDecimal(0);
}
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量
materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setCorrelationCode(purchasePlan.getCorrelationCode());
material.setPurchasePlanCorrelationCode(child.getCorrelationCode());
material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept());
material.setSupplierName(child.getSupplierName());
material.setMaterialCode(child.getMaterialCode());
material.setMaterialName(child.getMaterialName());
material.setMaterialBrand(child.getMaterialBrand());
material.setMaterialDescribe(child.getMaterialDescribe());
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl());
material.setMaterialProcessMethod(child.getMaterialProcessMethod());
material.setWarehouseDept(child.getWarehouseDept());
//计划采购数
material.setMaterialNum(child.getMaterialNum());
material.setMaterialNoRmb(child.getMaterialNoRmb());
material.setMaterialRmb(child.getMaterialRmb());
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum());
material.setMaterialRmbSum(child.getMaterialRmbSum());
//实际采购数
material.setMaterialRealNum(child.getMaterialRealNum());
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb());
material.setMaterialRealRmb(child.getMaterialRealRmb());
material.setDeliveryTime(child.getDeliveryTime());
//实际采购单价合计
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal);
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal);
material.setCorrelationCode(child.getCorrelationCode());
material.setPurchasePlanCode(child.getPurchasePlanCode());
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode());
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material.setEceiptStatus("0");
material.setPaymentStatus("0");
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(child.getPurchasePlanCode());
plan.setPurchasePlanStatus("1");
int result = purchasePlanService.updatePurchasePlan(plan);
}
}
}
}
@ -430,6 +522,178 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
@Override
public int updatePurchaseOrder(PurchaseOrder purchaseOrder)
{
// 初始化累加变量
BigDecimal materialNoRmb = BigDecimal.ZERO;
BigDecimal materialRmb = BigDecimal.ZERO;
BigDecimal materialNoRmbSum = BigDecimal.ZERO;
BigDecimal materialRmbSum = BigDecimal.ZERO;
BigDecimal materialNum = BigDecimal.ZERO;
int supplierNum = 0;
//根据上传的物料信息做采购订单子项
if (!CollectionUtils.isEmpty(purchaseOrder.getPurchaseOrderChildList())) {
supplierNum = purchaseOrder.getPurchaseOrderChildList().size();
}
if (purchaseOrder.getPurchaseOrderChildList() != null) {
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList();
//订单子表去除实际物料数量位null或者0的物料信息
purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(purchaseOrderChildList)) {
purchaseOrderChildService.deletePurchaseOrderChildByPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
for (PurchaseOrderChild child : purchaseOrderChildList) {
if (child.getCorrelationCode().contains(",")) {
String[] correlationCodes = child.getCorrelationCode().split(",");
String[] planCodes = child.getPurchasePlanCode().split(",");
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(",");
for (int i = 0; i < planCodes.length - 1; i++) {
String planCode = planCodes[i];
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode);
if (planCode != null) {
PurchaseOrderChild material = new PurchaseOrderChild();
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
//获取物料供应商不含税采购价格
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb();
// 获取物料供应商含税采购价格
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb();
// 获取物料数量
BigDecimal suplierMaterialNum = child.getMaterialRealNum();
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;}
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;}
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);}
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量
materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setPurchasePlanCorrelationCode(child.getCorrelationCode());
material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept());
material.setSupplierName(child.getSupplierName());
material.setMaterialCode(child.getMaterialCode());
material.setMaterialName(child.getMaterialName());
material.setMaterialBrand(child.getMaterialBrand());
material.setMaterialDescribe(child.getMaterialDescribe());
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl());
material.setMaterialProcessMethod(child.getMaterialProcessMethod());
material.setWarehouseDept(child.getWarehouseDept());
//计划采购数
material.setMaterialNum(child.getMaterialNum());
material.setMaterialNoRmb(child.getMaterialNoRmb());
material.setMaterialRmb(child.getMaterialRmb());
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum());
material.setMaterialRmbSum(child.getMaterialRmbSum());
//实际采购数
material.setMaterialRealNum(child.getMaterialRealNum());
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb());
material.setMaterialRealRmb(child.getMaterialRealRmb());
//实际采购单价合计
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal);
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal);
material.setCorrelationCode(child.getCorrelationCode());
material.setDeliveryTime(child.getDeliveryTime());
material.setPurchasePlanCode(child.getPurchasePlanCode());
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode());
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material.setEceiptStatus("0");
material.setPaymentStatus("0");
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(child.getPurchasePlanCode());
plan.setPurchasePlanStatus("1");
int result = purchasePlanService.updatePurchasePlan(plan);
}
}
}
else if ((!child.getCorrelationCode().contains(","))
&& child.getPurchasePlanCode() != null) {
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(child.getPurchasePlanCode());
PurchaseOrderChild material = new PurchaseOrderChild();
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
//获取物料供应商不含税采购价格
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb();
// 获取物料供应商含税采购价格
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb();
// 获取物料数量
BigDecimal suplierMaterialNum = child.getMaterialRealNum();
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;}
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;}
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);}
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量
materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setCorrelationCode(purchasePlan.getCorrelationCode());
material.setPurchasePlanCorrelationCode(child.getCorrelationCode());
material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept());
material.setSupplierName(child.getSupplierName());
material.setMaterialCode(child.getMaterialCode());
material.setMaterialName(child.getMaterialName());
material.setMaterialBrand(child.getMaterialBrand());
material.setMaterialDescribe(child.getMaterialDescribe());
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl());
material.setMaterialProcessMethod(child.getMaterialProcessMethod());
material.setWarehouseDept(child.getWarehouseDept());
//计划采购数
material.setMaterialNum(child.getMaterialNum());
material.setMaterialNoRmb(child.getMaterialNoRmb());
material.setMaterialRmb(child.getMaterialRmb());
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum());
material.setMaterialRmbSum(child.getMaterialRmbSum());
//实际采购数
material.setMaterialRealNum(child.getMaterialRealNum());
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb());
material.setMaterialRealRmb(child.getMaterialRealRmb());
material.setDeliveryTime(child.getDeliveryTime());
//实际采购单价合计
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal);
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal);
material.setCorrelationCode(child.getCorrelationCode());
material.setPurchasePlanCode(child.getPurchasePlanCode());
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode());
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material.setEceiptStatus("0");
material.setPaymentStatus("0");
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(child.getPurchasePlanCode());
plan.setPurchasePlanStatus("1");
int result = purchasePlanService.updatePurchasePlan(plan);
}
}
}
}
// 遍历处理采购订单子表// 设置累加的物料信息到子表// 设置主表的供应商数量
purchaseOrder.setSupplierNum(supplierNum);
purchaseOrder.setNoRmbSum(materialNoRmbSum);
purchaseOrder.setRmbSum(materialRmbSum);
purchaseOrder.setDelFlag("0");
purchaseOrder.setEceiptStatus("0");
purchaseOrder.setPaymentStatus("0");
purchaseOrder.setPurchaseBuyer(purchaseOrder.getPurchaseBuyer());
purchaseOrder.setCreateTime(DateUtils.getNowDate());
purchaseOrder.setCreateBy(ShiroUtils.getLoginName());
Set<String> amountSet = purchaseOrder.getPurchaseOrderChildList().stream().map(PurchaseOrderChild::getMaterialCode).collect(Collectors.toSet());
Integer amount = amountSet.size();
purchaseOrder.setMaterialAmount(amount);
purchaseOrder.setCreateTime(DateUtils.getNowDate());
purchaseOrder.setCreateBy(ShiroUtils.getLoginName());
return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);

10
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml

@ -240,7 +240,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deletePurchaseOrderChildById" parameterType="Long">
delete from purchase_order_child where purchase_order_child_id = #{purchaseOrderChildId}
</delete>
<delete id="deletePurchaseOrderChildByPurchaseOrderCode" parameterType="String">
delete from purchase_order_child where purchase_order_code = #{purchaseOrderCode}
</delete>
<delete id="deletePurchaseOrderChildByPurchaseOrderCodes" parameterType="String">
delete from purchase_order_child where purchase_order_code = in
<foreach collection="array" item="purchaseOrderCode" open="(" separator="," close=")">
#{purchaseOrderCode}
</foreach>
</delete>
<delete id="deletePurchaseOrderChildByIds" parameterType="String">
delete from purchase_order_child where purchase_order_child_id in
<foreach item="purchaseOrderChildId" collection="array" open="(" separator="," close=")">

10
ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html

@ -288,7 +288,15 @@
return actions.join('');
}
}
]
],
rowStyle: function (row, index) {
if (row.auditStatus=="0") {
// 如果审核状态为待审核,则设置为红色
return {css:{"color":"red"}};
}
// 否则使用默认样式
return {};
}
};
$.table.init(options);
});

Loading…
Cancel
Save