diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java index 9ca7d1cc..cd80aad6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java @@ -360,7 +360,6 @@ public class PurchaseOrderController extends BaseController // 使用状态-是 purchaseOrderVo.setUseStatus("1"); purchaseOrderService.addPurchaseOrderPayable(purchaseOrderVo); - } // 作废 else if("cancel".equals(instanceType)){ @@ -376,7 +375,7 @@ public class PurchaseOrderController extends BaseController purchaseOrderService.updatePurchaseOrder(purchaseOrderVo); // 驳回申请后继续申请,可能修改表单 if (saveEntityBoolean) { - purchaseOrderService.updatePurchaseOrder(purchaseOrderVo); + purchaseOrderService.updatePurchaseOrderCode(purchaseOrderVo); } return success("任务已完成"); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java index 8bb18023..be767ec7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java @@ -51,6 +51,8 @@ public interface IPurchaseOrderService */ public int updatePurchaseOrder(PurchaseOrder purchaseOrder); + int updatePurchaseOrderCode(PurchaseOrder purchaseOrder); + /** * 批量删除采购订单 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java index 652f94d0..314ffce3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java @@ -26,7 +26,6 @@ import com.ruoyi.erp.domain.ErpDevelopModifyorder; import com.ruoyi.erp.mapper.ErpDevelopModifyorderMapper; import com.ruoyi.financial.domain.FinancialAccountsPayable; import com.ruoyi.financial.mapper.FinancialAccountsPayableMapper; -import com.ruoyi.financial.service.IFinancialAccountsPayableService; import com.ruoyi.process.general.service.IProcessService; import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; import com.ruoyi.purchase.domain.PurchaseOrder; @@ -40,7 +39,6 @@ import com.ruoyi.purchase.service.IPurchaseOrderService; import com.ruoyi.system.domain.SysAttachFile; import com.ruoyi.system.domain.SysCompanyInformation; import com.ruoyi.system.domain.SysSupplier; -import com.ruoyi.system.domain.Vo.SysSupplierVo; import com.ruoyi.system.mapper.SysCompanyInformationMapper; import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.service.ISysAttachFileService; @@ -57,7 +55,6 @@ import org.activiti.engine.impl.persistence.entity.TaskEntityImpl; import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.task.Task; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -67,10 +64,8 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.io.OutputStream; import java.math.BigDecimal; import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -513,14 +508,28 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService //获取物料供应商的信息,采购订单的供应商数量 return 0; } + /** * 修改采购订单 - * + * * @param purchaseOrder 采购订单 * @return 结果 */ @Override public int updatePurchaseOrder(PurchaseOrder purchaseOrder) + { + purchaseOrder.setCreateTime(DateUtils.getNowDate()); + purchaseOrder.setCreateBy(ShiroUtils.getLoginName()); + return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder); + } + /** + * 修改采购订单 + * + * @param purchaseOrder 采购订单 + * @return 结果 + */ + @Override + public int updatePurchaseOrderCode(PurchaseOrder purchaseOrder) { // 初始化累加变量 BigDecimal materialNoRmb = BigDecimal.ZERO; @@ -537,84 +546,167 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService List purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList(); //订单子表去除实际物料数量位null或者0的物料信息 purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(purchaseOrderChildList)) { + for (PurchaseOrderChild child : purchaseOrderChildList) { purchaseOrderChildService.deletePurchaseOrderChildByPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); - 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(","); + 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(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.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); + material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); + 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[] planCodes = child.getPurchasePlanCode().split(","); + String[] planCode2 = 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); + 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.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); + material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); + material.setCorrelationCode(child.getCorrelationCode()); + 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.getCorrelationCode().contains(",")) - && child.getPurchasePlanCode() != null) { - PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(child.getPurchasePlanCode()); + } + 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()); //获取物料供应商不含税采购价格 @@ -623,15 +715,21 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService 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);} + 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); + materialNum = materialNum.add(suplierMaterialNum); // 累加物料总价 materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); // 累加物料含税总价 @@ -681,7 +779,9 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService } } } - // 遍历处理采购订单子表// 设置累加的物料信息到子表// 设置主表的供应商数量 + // 遍历处理采购订单子表 + // 设置累加的物料信息到子表 + // 设置主表的供应商数量 purchaseOrder.setSupplierNum(supplierNum); purchaseOrder.setNoRmbSum(materialNoRmbSum); purchaseOrder.setRmbSum(materialRmbSum); @@ -694,8 +794,6 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService Set 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); } diff --git a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml index 9980e545..d88633c1 100644 --- a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml @@ -103,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and pur.purchase_order_code in ( select purchase_order_code from purchase_order_child where supplier_name = #{supplierName}) + and pur.audit_status = #{auditStatus} and pur.use_status = #{useStatus} and pur.eceipt_status = #{eceiptStatus} and pur.payment_status = #{paymentStatus} diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/edit.html b/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/edit.html index 6e6be4e5..d0296e5d 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/edit.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/edit.html @@ -69,19 +69,19 @@
- +
- +
- +
@@ -99,8 +99,8 @@ \ No newline at end of file