Browse Source

[feat]

采购管理的采购订单:新增采购报价根据提供的采购计划个采购计划关联单号,传入采购单子表数据中。
dev
zhangsiqi 5 months ago
parent
commit
d083eb4c2d
  1. 6
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderChildController.java
  2. 161
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  3. 77
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java
  4. 23
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java
  5. 2
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderChildMapper.java
  6. 2
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderMapper.java
  7. 2
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderChildService.java
  8. 2
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java
  9. 7
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderChildServiceImpl.java
  10. 12
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  11. 10
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml
  12. 31
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml
  13. 80
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html

6
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderChildController.java

@ -9,11 +9,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.purchase.domain.PurchaseOrderChild; import com.ruoyi.purchase.domain.PurchaseOrderChild;

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

@ -15,16 +15,17 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.purchase.domain.PurchaseMaterial; import com.ruoyi.purchase.domain.*;
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.PurchaseMaterialDto;
import com.ruoyi.purchase.domain.exportDto.PurchaseOrderDto; import com.ruoyi.purchase.domain.exportDto.PurchaseOrderDto;
import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper; import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper;
import com.ruoyi.purchase.service.IPurchaseMaterialService; import com.ruoyi.purchase.service.IPurchaseMaterialService;
import com.ruoyi.purchase.service.IPurchaseOrderChildService;
import com.ruoyi.purchase.service.IPurchaseOrderService; import com.ruoyi.purchase.service.IPurchaseOrderService;
import com.ruoyi.purchase.service.IPurchasePlanService;
import com.ruoyi.quality.domain.QualityOrderDetail; import com.ruoyi.quality.domain.QualityOrderDetail;
import com.ruoyi.storehouse.utils.CustomRowWriteCellHandler; import com.ruoyi.storehouse.utils.CustomRowWriteCellHandler;
import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.HorizontalAlignment;
@ -62,7 +63,10 @@ public class PurchaseOrderController extends BaseController
@Autowired @Autowired
private IPurchaseMaterialService purchaseMaterialService; private IPurchaseMaterialService purchaseMaterialService;
@Autowired @Autowired
private PurchaseOrderChildMapper purchaseOrderChildService;; private IPurchaseOrderChildService purchaseOrderChildService;;
@Autowired
private IPurchasePlanService purchasePlanService;
@Autowired @Autowired
private RedisCache redisCache; private RedisCache redisCache;
@ -116,9 +120,18 @@ public class PurchaseOrderController extends BaseController
@Log(title = "采购订单", businessType = BusinessType.INSERT) @Log(title = "采购订单", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@Valid @RequestBody PurchaseOrder purchaseOrder) { public AjaxResult addSave( @RequestBody PurchaseOrder purchaseOrder) {
// 数据校验,确保前端传入数据格式正确
// 生成采购订单编号
// 执行主表插入操作
return toAjax(purchaseOrderService.insertPurchaseOrder(purchaseOrder)); // 假设toAjax方法处理成功逻辑
}
@RequiresPermissions("purchase:purchaseOrder:add")
@Log(title = "采购订单", businessType = BusinessType.INSERT)
@PostMapping("/addPurchaseOrder")
@ResponseBody
public AjaxResult addPurchasePlantoPuserchaseOrder(@RequestBody PurchaseOrder purchaseOrder) {
// 数据校验,确保前端传入数据格式正确 // 数据校验,确保前端传入数据格式正确
validatePurchaseOrder(purchaseOrder);
// 生成采购订单编号 // 生成采购订单编号
purchaseOrder.setPurchaseOrderCode(redisCache.generateBillNo("CG")); purchaseOrder.setPurchaseOrderCode(redisCache.generateBillNo("CG"));
// 初始化累加变量 // 初始化累加变量
@ -128,73 +141,82 @@ public class PurchaseOrderController extends BaseController
BigDecimal materialRmbSum = BigDecimal.ZERO; BigDecimal materialRmbSum = BigDecimal.ZERO;
Long materialNum = 0L; Long materialNum = 0L;
int supplierNum = 0; int supplierNum = 0;
// 遍历处理采购订单子表 if (!CollectionUtils.isEmpty(purchaseOrder.getPurchaseOrderChildList())) {
for (PurchaseOrderChild child : purchaseOrder.getPurchaseOrderChildList()) { supplierNum = purchaseOrder.getPurchaseOrderChildList().size();
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); }
// 累加物料数量和金额 if (purchaseOrder.getPurchaseOrderChildList() != null) {
for (PurchaseQuoteChild quote : child.getPurchaseQuoteChildList()) { for (PurchaseOrderChild child : purchaseOrder.getPurchaseOrderChildList()) {
//获取物料供应商采购价格 if (child.getCorrelationCode().contains(",")) {
BigDecimal suplierMaterialNoRmb = quote.getMaterialNoRmb(); String[] correlationCodes = child.getCorrelationCode().split(",");
// 获取物料供应商采购价格 for (int i = 0; i < correlationCodes.length; i++) {
BigDecimal suplierMaterialRmb = quote.getMaterialRmb(); String correlationCode = correlationCodes[i];
// 获取物料数量 String planCode = child.getPurchasePlanCode().split(",")[i];
Long suplierMaterialNum = quote.getMaterialNum(); if (correlationCode != null) {
// 累加物料数量 PurchaseOrderChild material = new PurchaseOrderChild();
materialNum += suplierMaterialNum; child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
// 累加不含税物料价格 // 累加物料数量和金额
materialNoRmb = materialNoRmb.add(suplierMaterialNoRmb); //获取物料供应商采购价格
// 累加含税物料价格 BigDecimal suplierMaterialNoRmb = child.getMaterialNoRmb();
materialRmb = materialRmb.add(suplierMaterialRmb); // 获取物料供应商采购价格
BigDecimal suplierMaterialRmb = child.getMaterialRmb();
child.setPurchasePlanCode(quote.getPurchasePlanCode()); // 获取物料数量
// 计算不含税物料总价 Long suplierMaterialNum = child.getMaterialNum();
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); // 累加物料数量
// 计算物料含税总价 materialNum += suplierMaterialNum;
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); // 累加不含税物料价格
// 累加物料总价 materialNoRmb = materialNoRmb.add(suplierMaterialNoRmb);
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); // 累加含税物料价格
// 累加物料含税总价 materialRmb = materialRmb.add(suplierMaterialRmb);
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); // 计算不含税物料总价
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum));
// 设置采购报价单编号和供应商信息到QuoteChild // 计算物料含税总价
quote.setPurchaseQuoteCode(purchaseOrder.getPurchaseOrderCode()); BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum));
child.setSupplierCode(quote.getSupplierCode()); // 累加物料总价
child.setSupplierName(quote.getSupplierName()); materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseQuoteCode(purchaseOrder.getPurchaseOrderCode());
material.setSupplierCode(child.getSupplierCode());
material.setSupplierName(child.getSupplierName());
material.setMaterialNoRmb(child.getMaterialNoRmb());
material.setMaterialRmb(child.getMaterialRmb());
material.setMaterialNum(child.getMaterialNum());
material.setMaterialName(child.getMaterialName());
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum());
material.setMaterialRmbSum(child.getMaterialRmbSum());
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum());
material.setCorrelationCode(correlationCode);
material.setPurchasePlanCode(planCode);
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(child);
PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(child.getPurchasePlanCode());
plan.setPurchasePlanStatus("1");
int result = purchasePlanService.updatePurchasePlan(plan);
}
}
child.setMaterialNoRmb(BigDecimal.ZERO);
}
// 确保供应商数量统计准确 // 确保供应商数量统计准确
if (quote.getSupplierCode() != null) { if (child.getSupplierCode() != null) {
supplierNum++; supplierNum++;
} }
}
// 设置累加的物料信息到子表
child.setMaterialNoRmb(materialNoRmb);
child.setMaterialRmb(materialRmb);
child.setMaterialNum(materialNum);
// 执行子表插入操作 }
purchaseOrderChildService.insertPurchaseOrderChild(child);
} }
// 遍历处理采购订单子表
// 设置累加的物料信息到子表
purchaseOrder.setMaterialSum(Math.toIntExact(materialNum));
purchaseOrder.setNoRmbSum(materialNoRmbSum);
purchaseOrder.setRmbSum(materialRmbSum);
// 设置主表的供应商数量 // 设置主表的供应商数量
purchaseOrder.setSupplierNum(supplierNum); purchaseOrder.setSupplierNum(supplierNum);
// 执行主表插入操作 // 执行主表插入操作
return toAjax(purchaseOrderService.insertPurchaseOrder(purchaseOrder)); // 假设toAjax方法处理成功逻辑 return toAjax(purchaseOrderService.insertPurchaseOrder(purchaseOrder)); // 假设toAjax方法处理成功逻辑
} }
// 数据校验逻辑
private void validatePurchaseOrder(PurchaseOrder purchaseOrder) {
if (CollectionUtils.isEmpty(purchaseOrder.getPurchaseOrderChildList())) {
try {
throw new Exception("采购订单子项不能为空");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// 可以添加更多校验逻辑
}
/** /**
* 修改采购订单 * 修改采购订单
*/ */
@ -213,6 +235,18 @@ public class PurchaseOrderController extends BaseController
mmap.put("purchaseOrderChild", purchaseOrderChild); mmap.put("purchaseOrderChild", purchaseOrderChild);
return prefix + "/detail"; return prefix + "/detail";
} }
@GetMapping("/addPurchaseOrderStorage/{purchaseOrderCode}")
public String addPurchaseOrderStorage(@PathVariable("purchaseOrderCode") String purchaseOrderCode,ModelMap mmap){
//purchasePlanCodes去除重复数据,purchasePlanCodeArray作为数组类型去除
//查询相关采购计划数据
PurchaseOrder purchaseOrderList = purchaseOrderService.selectPurchaseOrderByOrderCode(purchaseOrderCode);
//根据采购计划编号查询对应的采购报价数据
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrderChildService.selectPurchaseOrderChildByOrderCode(purchaseOrderCode);
//再根据采购计划编号分组查询对应的采购报价数据分组
mmap.put("purchaseOrderList", purchaseOrderList);
mmap.put("purchaseOrderChildList", purchaseOrderChildList);
return prefix + "/addPurchaseOrderStorage";
}
@ResponseBody @ResponseBody
@RequestMapping("/detailListGroupedBySupplier") @RequestMapping("/detailListGroupedBySupplier")
public Map<String, List<PurchaseOrderChild>> detailListGroupedBySupplier(String qualityOrderCode) { public Map<String, List<PurchaseOrderChild>> detailListGroupedBySupplier(String qualityOrderCode) {
@ -288,7 +322,6 @@ public class PurchaseOrderController extends BaseController
// 创建列合并工具类对象 // 创建列合并工具类对象
// ExcelFillCellMergePrevColUtils mergePrevColUtils = new ExcelFillCellMergePrevColUtils(); // ExcelFillCellMergePrevColUtils mergePrevColUtils = new ExcelFillCellMergePrevColUtils();
List<PurchaseMaterial> purchaseMaterialList = purchaseMaterialService.selectPurchaseMaterialList(purchaseMaterial); List<PurchaseMaterial> purchaseMaterialList = purchaseMaterialService.selectPurchaseMaterialList(purchaseMaterial);
List<PurchaseMaterialDto> purchaseMaterialDtoList = new ArrayList<>(); List<PurchaseMaterialDto> purchaseMaterialDtoList = new ArrayList<>();
double total = 0.00; double total = 0.00;

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

@ -5,6 +5,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
@ -41,9 +42,9 @@ public class PurchaseOrder extends BaseEntity
@Excel(name="数量合计") @Excel(name="数量合计")
private Integer materialSum; private Integer materialSum;
@Excel(name="不含税总价(RMB)") @Excel(name="不含税总价(RMB)")
private Double noRmbSum; private BigDecimal noRmbSum;
@Excel(name="含税总价") @Excel(name="含税总价")
private Double rmbSum; private BigDecimal rmbSum;
/** 供应商代码 */ /** 供应商代码 */
@Excel(name = "供应商代码") @Excel(name = "供应商代码")
private String supplierCode; private String supplierCode;
@ -173,14 +174,76 @@ public class PurchaseOrder extends BaseEntity
@Excel(name = "修改时间") @Excel(name = "修改时间")
private String updateInfoTime; private String updateInfoTime;
/** 删除标志(0代表存在 2代表删除) */
private String delFlag;
/*仓库ID*/
private String stockNo;
/*仓库名称*/
private String stockName;
/*仓库收货地址*/
private String stockAddress;
/*仓库收货电话*/
private String stockPhone;
/*仓库收货人*/
private String stockContact;
/** 备用一 */ /** 备用一 */
private String standbyOne; private String standbyOne;
/** 备用二 */ /** 备用二 */
private String standbyTwo; private String standbyTwo;
private List<PurchaseOrderChild> purchaseOrderChildList; private List<PurchaseOrderChild> purchaseOrderChildList;
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getStockNo() {
return stockNo;
}
public void setStockNo(String stockNo) {
this.stockNo = stockNo;
}
public String getStockName() {
return stockName;
}
public void setStockName(String stockName) {
this.stockName = stockName;
}
public String getStockAddress() {
return stockAddress;
}
public void setStockAddress(String stockAddress) {
this.stockAddress = stockAddress;
}
public String getStockPhone() {
return stockPhone;
}
public void setStockPhone(String stockPhone) {
this.stockPhone = stockPhone;
}
public String getStockContact() {
return stockContact;
}
public void setStockContact(String stockContact) {
this.stockContact = stockContact;
}
public List<PurchaseOrderChild> getPurchaseOrderChildList() { public List<PurchaseOrderChild> getPurchaseOrderChildList() {
return purchaseOrderChildList; return purchaseOrderChildList;
} }
@ -269,19 +332,19 @@ public class PurchaseOrder extends BaseEntity
this.materialSum = materialSum; this.materialSum = materialSum;
} }
public Double getNoRmbSum() { public BigDecimal getNoRmbSum() {
return noRmbSum; return noRmbSum;
} }
public void setNoRmbSum(Double noRmbSum) { public void setNoRmbSum(BigDecimal noRmbSum) {
this.noRmbSum = noRmbSum; this.noRmbSum = noRmbSum;
} }
public Double getRmbSum() { public BigDecimal getRmbSum() {
return rmbSum; return rmbSum;
} }
public void setRmbSum(Double rmbSum) { public void setRmbSum(BigDecimal rmbSum) {
this.rmbSum = rmbSum; this.rmbSum = rmbSum;
} }

23
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java

@ -25,9 +25,14 @@ public class PurchaseOrderChild extends BaseEntity
/** 关联采购订单号 */ /** 关联采购订单号 */
@Excel(name = "关联采购订单号") @Excel(name = "关联采购订单号")
private String purchaseOrderCode; private String purchaseOrderCode;
/*关联计划单号*/
private String purchasePlanCode; private String purchasePlanCode;
/*采购计划关联单号*/
private String correlationCode;;
@Excel(name = "关联报价编号字段")
private String purchaseQuoteCode;
/** 供应商代码 */ /** 供应商代码 */
@Excel(name = "供应商代码") @Excel(name = "供应商代码")
private String supplierCode; private String supplierCode;
@ -297,6 +302,22 @@ public class PurchaseOrderChild extends BaseEntity
return standbyTwo; return standbyTwo;
} }
public String getCorrelationCode() {
return correlationCode;
}
public void setCorrelationCode(String correlationCode) {
this.correlationCode = correlationCode;
}
public String getPurchaseQuoteCode() {
return purchaseQuoteCode;
}
public void setPurchaseQuoteCode(String purchaseQuoteCode) {
this.purchaseQuoteCode = purchaseQuoteCode;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

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

@ -74,4 +74,6 @@ public interface PurchaseOrderChildMapper
* @return 结果 * @return 结果
*/ */
public int restorePurchaseOrderChildById(Long purchaseOrderChildId); public int restorePurchaseOrderChildById(Long purchaseOrderChildId);
List<PurchaseOrderChild> selectPurchaseOrderChildByOrderCode(String purchaseOrderCode);
} }

2
ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderMapper.java

@ -61,4 +61,6 @@ public interface PurchaseOrderMapper
public int deletePurchaseOrderByIds(String[] purchaseOrderIds); public int deletePurchaseOrderByIds(String[] purchaseOrderIds);
public List<PurchaseOrder> selectOrderByIdDesc(); public List<PurchaseOrder> selectOrderByIdDesc();
PurchaseOrder selectPurchaseOrderByOrderCode(String purchaseOrderCode);
} }

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

@ -72,4 +72,6 @@ public interface IPurchaseOrderChildService
* @return * @return
*/ */
int restorePurchaseOrderChildById(Long purchaseOrderChildId); int restorePurchaseOrderChildById(Long purchaseOrderChildId);
List<PurchaseOrderChild> selectPurchaseOrderChildByOrderCode(String purchaseOrderCode);
} }

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

@ -61,4 +61,6 @@ public interface IPurchaseOrderService
public int deletePurchaseOrderById(Long purchaseOrderId); public int deletePurchaseOrderById(Long purchaseOrderId);
public String getId(); public String getId();
PurchaseOrder selectPurchaseOrderByOrderCode(String purchaseOrderCode);
} }

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

@ -9,6 +9,7 @@ import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper;
import com.ruoyi.purchase.domain.PurchaseOrderChild; import com.ruoyi.purchase.domain.PurchaseOrderChild;
import com.ruoyi.purchase.service.IPurchaseOrderChildService; import com.ruoyi.purchase.service.IPurchaseOrderChildService;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 采购订单子表Service业务层处理 * 采购订单子表Service业务层处理
@ -53,6 +54,7 @@ public class PurchaseOrderChildServiceImpl implements IPurchaseOrderChildService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public int insertPurchaseOrderChild(PurchaseOrderChild purchaseOrderChild) public int insertPurchaseOrderChild(PurchaseOrderChild purchaseOrderChild)
{ {
String loginName = ShiroUtils.getLoginName(); String loginName = ShiroUtils.getLoginName();
@ -123,4 +125,9 @@ public class PurchaseOrderChildServiceImpl implements IPurchaseOrderChildService
{ {
return purchaseOrderChildMapper.restorePurchaseOrderChildById(purchaseOrderChildId); return purchaseOrderChildMapper.restorePurchaseOrderChildById(purchaseOrderChildId);
} }
@Override
public List<PurchaseOrderChild> selectPurchaseOrderChildByOrderCode(String purchaseOrderCode){
return purchaseOrderChildMapper.selectPurchaseOrderChildByOrderCode(purchaseOrderCode);
}
} }

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

@ -2,11 +2,14 @@ package com.ruoyi.purchase.service.impl;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.purchase.domain.PurchaseOrder; import com.ruoyi.purchase.domain.PurchaseOrder;
import com.ruoyi.purchase.mapper.PurchaseOrderMapper; import com.ruoyi.purchase.mapper.PurchaseOrderMapper;
import com.ruoyi.purchase.service.IPurchaseOrderService; import com.ruoyi.purchase.service.IPurchaseOrderService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
@ -57,9 +60,12 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public int insertPurchaseOrder(PurchaseOrder purchaseOrder) public int insertPurchaseOrder(PurchaseOrder purchaseOrder)
{ {
//根据上传的物料信息做采购订单子项 //根据上传的物料信息做采购订单子项
purchaseOrder.setCreateTime(DateUtils.getNowDate());
purchaseOrder.setCreateBy(ShiroUtils.getLoginName());
// //
return purchaseOrderMapper.insertPurchaseOrder(purchaseOrder); return purchaseOrderMapper.insertPurchaseOrder(purchaseOrder);
} }
@ -73,6 +79,8 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
@Override @Override
public int updatePurchaseOrder(PurchaseOrder purchaseOrder) public int updatePurchaseOrder(PurchaseOrder purchaseOrder)
{ {
purchaseOrder.setCreateTime(DateUtils.getNowDate());
purchaseOrder.setCreateBy(ShiroUtils.getLoginName());
return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder); return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);
} }
@ -104,4 +112,8 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
public String getId() { public String getId() {
return redisCache.generateBillNo("CG"); return redisCache.generateBillNo("CG");
} }
@Override
public PurchaseOrder selectPurchaseOrderByOrderCode(String purchaseOrderCode){
return purchaseOrderMapper.selectPurchaseOrderByOrderCode(purchaseOrderCode);
}
} }

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

@ -68,7 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="supplierName != null">supplier_name,</if> <if test="supplierName != null">supplier_name,</if>
<if test="materialCode != null">material_code,</if> <if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if> <if test="materialName != null">material_name,</if>
<if test="materialNormb != null">material_no_rmb,</if> <if test="materialNoRmb != null">material_no_rmb,</if>
<if test="materialRmb != null">material_rmb,</if> <if test="materialRmb != null">material_rmb,</if>
<if test="materialNum != null">material_num,</if> <if test="materialNum != null">material_num,</if>
<if test="materialAmount != null">material_amount,</if> <if test="materialAmount != null">material_amount,</if>
@ -93,7 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="supplierName != null">#{supplierName},</if> <if test="supplierName != null">#{supplierName},</if>
<if test="materialCode != null">#{materialCode},</if> <if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if> <if test="materialName != null">#{materialName},</if>
<if test="materialNoRmb != null">#{materialNormb},</if> <if test="materialNoRmb != null">#{materialNoRmb},</if>
<if test="materialRmb != null">#{materialRmb},</if> <if test="materialRmb != null">#{materialRmb},</if>
<if test="materialNum != null">#{materialNum},</if> <if test="materialNum != null">#{materialNum},</if>
<if test="materialAmount != null">#{materialAmount},</if> <if test="materialAmount != null">#{materialAmount},</if>
@ -163,4 +163,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update purchase_order_child set del_flag = '0' where purchase_order_child_id = #{purchaseOrderChildId} update purchase_order_child set del_flag = '0' where purchase_order_child_id = #{purchaseOrderChildId}
</update> </update>
<select id="selectPurchaseOrderChildByOrderCode" parameterType="String" resultMap="PurchaseOrderChildResult">
<include refid="selectPurchaseOrderChildVo"/>
where purchase_order_code = #{purchaseOrderCode}
</select>
</mapper> </mapper>

31
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml

@ -49,6 +49,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateInfoTime" column="update_info_time" /> <result property="updateInfoTime" column="update_info_time" />
<result property="standbyOne" column="standby_one" /> <result property="standbyOne" column="standby_one" />
<result property="standbyTwo" column="standby_two" /> <result property="standbyTwo" column="standby_two" />
<result property="delFlag" column="del_flag" />
<result property="stockNo" column="stock_no" />
<result property="stockName" column="stock_name" />
<result property="stockAddress" column="stock_address" />
<result property="stockContact" column="stock_contact" />
<result property="stockPhone" column="stock_phone" />
</resultMap> </resultMap>
<sql id="selectPurchaseOrderVo"> <sql id="selectPurchaseOrderVo">
@ -58,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
purchase_category, purchase_commander, customer_order_number, remark_content, purchase_category, purchase_commander, customer_order_number, remark_content,
close_case_no, close_case_name, close_case_time, confirm_no, confirm_name, close_case_no, close_case_name, close_case_time, confirm_no, confirm_name,
confirm_time, audit_no, audit_name, audit_time, approve_no, approve_name, confirm_time, audit_no, audit_name, audit_time, approve_no, approve_name,
del_flag, stock_no, stock_name, stock_address, stock_contact, stock_phone,
approve_time, standby_one, standby_two from purchase_order approve_time, standby_one, standby_two from purchase_order
</sql> </sql>
@ -69,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="supplierName != null and supplierName != ''"> and supplier_name like concat('%', #{supplierName}, '%')</if> <if test="supplierName != null and supplierName != ''"> and supplier_name like concat('%', #{supplierName}, '%')</if>
<if test="params.beginBillingDate != null and params.beginBillingDate != '' and params.endBillingDate != null and params.endBillingDate != ''"> and billing_date between #{params.beginBillingDate} and #{params.endBillingDate}</if> <if test="params.beginBillingDate != null and params.beginBillingDate != '' and params.endBillingDate != null and params.endBillingDate != ''"> and billing_date between #{params.beginBillingDate} and #{params.endBillingDate}</if>
</where> </where>
order by create_time desc
</select> </select>
<select id="selectPurchaseOrderById" parameterType="Long" resultMap="PurchaseOrderResult"> <select id="selectPurchaseOrderById" parameterType="Long" resultMap="PurchaseOrderResult">
@ -99,6 +107,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="standbyTwo != null">standby_two,</if> <if test="standbyTwo != null">standby_two,</if>
<if test="createTime != null" >create_time,</if> <if test="createTime != null" >create_time,</if>
<if test="createBy != null" >create_by,</if> <if test="createBy != null" >create_by,</if>
<if test="delFlag != null" >del_flag,</if>
<if test="stockNo!= null">stock_no,</if>
<if test="stockName!= null">stock_name,</if>
<if test="stockAddress!= null">stock_address,</if>
<if test="stockContact!= null">stock_contact,</if>
<if test="stockPhone!= null">stock_phone,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="purchaseOrderCode != null">#{purchaseOrderCode},</if> <if test="purchaseOrderCode != null">#{purchaseOrderCode},</if>
@ -122,6 +136,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="standbyTwo != null">#{standbyTwo},</if> <if test="standbyTwo != null">#{standbyTwo},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="stockNo!= null">#{stockNo},</if>
<if test="stockName!= null">#{stockName},</if>
<if test="stockAddress!= null">#{stockAddress},</if>
<if test="stockContact!= null">#{stockContact},</if>
<if test="stockPhone!= null">#{stockPhone},</if>
</trim> </trim>
</insert> </insert>
@ -159,6 +179,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="approveTime != null">approve_time = #{approveTime},</if> <if test="approveTime != null">approve_time = #{approveTime},</if>
<if test="standbyOne != null">standby_one = #{standbyOne},</if> <if test="standbyOne != null">standby_one = #{standbyOne},</if>
<if test="standbyTwo != null">standby_two = #{standbyTwo},</if> <if test="standbyTwo != null">standby_two = #{standbyTwo},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="stockNo!= null">stock_no = #{stockNo},</if>
<if test="stockName!= null">stock_name = #{stockName},</if>
<if test="stockAddress!= null">stock_address = #{stockAddress},</if>
<if test="stockContact!= null">stock_contact = #{stockContact},</if>
<if test="stockPhone!= null">stock_phone = #{stockPhone},</if>
</trim> </trim>
where purchase_order_id = #{purchaseOrderId} where purchase_order_id = #{purchaseOrderId}
</update> </update>
@ -181,4 +207,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectPurchaseOrderVo"/> <include refid="selectPurchaseOrderVo"/>
WHERE purchase_order_code like '%PO%' ORDER BY purchase_order_id DESC WHERE purchase_order_code like '%PO%' ORDER BY purchase_order_id DESC
</select> </select>
<select id="selectPurchaseOrderByOrderCode" parameterType="String" resultMap="PurchaseOrderResult">
<include refid="selectPurchaseOrderVo"/>
where purchase_order_code = #{purchaseOrderCode}
</select>
</mapper> </mapper>

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

@ -75,10 +75,10 @@
<div class="btn-group-sm" id="toolbar" role="group"> <div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="importPurchaseOrder()" shiro:hasPermission="purchase:purchaseOrder:add"> <a class="btn btn-success" onclick="importPurchaseOrder()" shiro:hasPermission="purchase:purchaseOrder:add">
<i class="fa fa-plus"></i> 导入 <i class="fa fa-plus"></i> 导入合同
</a> </a>
<a class="btn btn-warning" onclick="exportPurchaseOrder()" shiro:hasPermission="purchase:purchaseOrder:export"> <a class="btn btn-warning" onclick="exportPurchaseOrder()" shiro:hasPermission="purchase:purchaseOrder:export">
<i class="fa fa-download"></i> 导出 <i class="fa fa-download"></i> 导出合同
</a> </a>
<a class="btn btn-primary" onclick="reviewCloseCase()" shiro:hasPermission="purchase:purchaseOrder:close"> <a class="btn btn-primary" onclick="reviewCloseCase()" shiro:hasPermission="purchase:purchaseOrder:close">
<i class="fa fa-hand-grab-o"></i> 结案 <i class="fa fa-hand-grab-o"></i> 结案
@ -102,38 +102,23 @@
</div> </div>
<div class="modal-body" style="height: 180px"> <div class="modal-body" style="height: 180px">
<form id="form-closeCase-edit"> <form id="form-closeCase-edit">
<div class="form-group" style="display: none"> <div class="form-group" hidden = "hidden">
<label class="col-sm-3 control-label is-required">订单id</label> <label class="col-sm-3 control-label is-required">采购订单ID</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="purchaseOrderId" name="purchaseOrderId" class="form-control" type="text" required <input name="purchaseOrderId" class="form-control" type="text" required readonly>
readonly>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group" >
<label class="col-sm-3 control-label ">结案否</label> <label class="col-sm-3 control-label is-required">采购单号</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select id="closeCaseNo" name="closeCaseNo" class="form-control" <input name="purchaseOrderCode" class="form-control" type="text" required readonly>
th:with="type=${@dict.getType('sys_whether')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label ">结案时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<input id="closeCaseTime" name="closeCaseTime" class="form-control"
placeholder="yyyy-mm-dd hh:ii:ss" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div> </div>
</div> </div>
<div class="form-group"> <table id="closeCaseTable"> </table>
<label class="col-sm-3 control-label ">结案人:</label> <div class="form-row">
<label class="col-sm-3 control-label is-required">备注:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<!-- <input id="auditName" name="auditName" class="form-control" type="text" th:value="${@permission.getPrincipalProperty('userName')}">--> <textarea id="remark" name="remark" class="form-control" rows="6"></textarea>
<input id="closeCaseName" name="closeCaseName" class="form-control" type="text">
</div> </div>
</div> </div>
</form> </form>
@ -172,9 +157,10 @@
detailView: true, detailView: true,
fixedColumns: true, // 启用冻结列 fixedColumns: true, // 启用冻结列
fixedRightNumber: 1, // 冻结右列个数 fixedRightNumber: 1, // 冻结右列个数
onExpandRow:function(index, row, $detail){ onExpandRow : function(index,row,$detail){
$detail.html('<table class="table-container" id="purchase_order_'+row.id+'"></table>'); $detail.html('<table class="table-container" id="purchase_order_child_'+row.id+'"></table>').find('table');
initChildTable(row, index, $detail); // 一阶
initChildTable(index,row,$detail);
}, },
columns: [ columns: [
{checkbox: true}, {checkbox: true},
@ -215,6 +201,9 @@
formatter: function(value, row, index) { formatter: function(value, row, index) {
var actions = []; var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i>编辑</a> '); actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
if (row.auditStatus === '1' && row.useStatus === '1' && row.eceiptStatus === '1') {
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="addPurchaseOrderStorage(\'' + row.purchaseOrderCode + '\')"><i class="fa fa-edit"></i>入库通知</a> ');
}
return actions.join(''); return actions.join('');
} }
} }
@ -223,13 +212,12 @@
$.table.init(options); $.table.init(options);
}); });
initChildTable = function(index, row, $detail) { initChildTable = function(index, row, $detail) {
$("#"+"purchase_order_"+row.id).bootstrapTable({ $("#"+"purchase_order_child_"+row.id).bootstrapTable({
url: ctx + "purchase/purchaseOrderChild/list", url: ctx + "purchase/purchaseOrderChild/list",
method: 'post', method: 'post',
sidePagination: "server",
contentType: "application/x-www-form-urlencoded", contentType: "application/x-www-form-urlencoded",
queryParams : { queryParams : {
purchaseOrderCode: row.purchaseOrderCode purchaseOrderCode: row.purchaseOrderCode,
}, },
columns: [ columns: [
{title: '采购单子表编号',field: 'purchaseOrderChildId',visible: false}, {title: '采购单子表编号',field: 'purchaseOrderChildId',visible: false},
@ -326,6 +314,32 @@
} }
}); });
} }
function addPurchaseOrderStorage(purchaseOrderCode){
$.model.open(ctx + "purchase/purchaseOrder/"+purchaseOrderCode, "新增入库检验通知", 800, 500);
}
function tableSet(data) {
var options = {
id: "closeCaseTable",
modalName: "采购订单",
search: false,
showExport: false,
showSearch: false,
showRefresh: false,
showColumns: false,
showToggle: false,
showFooter: false,
columns: [
{title: '采购订单编号',field: 'purchaseOrderCode',align: 'center',visible: false,},
{title: '采购单子表ID',field: 'purchaseOrderChildId', align: 'center',},
{title: '供应商名称',field: 'supplierName', align: 'center',},
{title: '供应商名称',field: 'supplierName',align: 'center',},
{title: '打款结案状态',field: 'paymentStatus',align: 'center',
formatter: function (value, row, index) {return $.table.selectDictLabel(paymentStatusDatas, value);}
},
],
}
}
</script> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save