采购合同流程 获取预算采购明细

master
Harry Yang 2022-12-28 18:09:38 +08:00
parent 8dc605ff33
commit dbf5ff4f28
9 changed files with 151 additions and 16 deletions

View File

@ -3,6 +3,7 @@ package cn.palmte.work.model.process;
import org.hibernate.annotations.GenericGenerator;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@ -31,13 +32,13 @@ public class BudgetPurchaseAmount implements Serializable {
private Integer id;
// 已采购数量
private Integer amountAlready;
private BigDecimal amountAlready;
// '本次采购数量'
private Integer amountCurrent;
private BigDecimal amountCurrent;
// 未采购数量
private Integer amountLeft;
private BigDecimal amountLeft;
// 流程ID
private Integer processId;

View File

@ -1,4 +1,4 @@
package cn.palmte.work.model.process.form;
package cn.palmte.work.model.process;
import java.util.List;
@ -11,7 +11,7 @@ import lombok.Data;
* @since 2.0 2022/12/28 15:00
*/
@Data
public class BudgetPurchaseAmountForm {
public class BudgetPurchaseAmountModel {
// 已采购数量
private Integer amountAlready;
@ -25,5 +25,5 @@ public class BudgetPurchaseAmountForm {
// 项目的成本明细ID
private Integer budgetCostId;
private List<BudgetPurchaseDetailForm> details;
private List<BudgetPurchaseDetailModel> details;
}

View File

@ -1,4 +1,4 @@
package cn.palmte.work.model.process.form;
package cn.palmte.work.model.process;
import java.math.BigDecimal;
@ -11,7 +11,7 @@ import lombok.Data;
* @since 2.0 2022/12/28 15:01
*/
@Data
public class BudgetPurchaseDetailForm {
public class BudgetPurchaseDetailModel {
// 供应商名称
private String supplierName;

View File

@ -0,0 +1,53 @@
package cn.palmte.work.model.process;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import lombok.Data;
/**
*
*
* @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
* @since 2.0 2022/12/28 16:01
*/
@Data
public class ProcurementDetail {
private int type;
private String category;
private String name;
private String unit;
private BigDecimal price;
private BigDecimal taxRate;
private String contractParty;
private int isUnderwritten;
private BigDecimal underwrittenAmount;
private Date payTime;
private BigDecimal totalTax;
private BigDecimal totalTaxInclude;
private BigDecimal totalTaxExclude;
private BigDecimal payAmount;
private String payWay;
private String remark;
// 要采购的总量
private BigDecimal amount;
// 已采购数量
private BigDecimal amountAlready = BigDecimal.ZERO;
private List<BudgetPurchaseDetail> purchaseDetails;
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import cn.palmte.work.model.enums.ProcessStatus;
import cn.palmte.work.model.enums.ProcessType;
import cn.palmte.work.model.enums.ProcurementMode;
import cn.palmte.work.model.process.BudgetPurchaseAmountModel;
import cn.palmte.work.model.process.ProcessAttachment;
import cn.palmte.work.model.process.SupplierMaterial;
import lombok.Data;
@ -88,6 +89,6 @@ public class ProcessCreationForm {
private List<SupplierMaterial> supplierMaterials;
// 采购详情
private List<BudgetPurchaseAmountForm> purchaseAmount;
private List<BudgetPurchaseAmountModel> purchaseAmount;
}

View File

@ -6,6 +6,7 @@ import javax.validation.constraints.NotNull;
import cn.palmte.work.model.enums.ProcessStatus;
import cn.palmte.work.model.enums.ProcurementMode;
import cn.palmte.work.model.process.BudgetPurchaseAmountModel;
import cn.palmte.work.model.process.ProcessAttachment;
import lombok.Data;
@ -57,5 +58,5 @@ public class ProcessUpdateForm {
private List<SaleContractDetailForm> incomeDetails;
// 采购详情
private List<BudgetPurchaseAmountForm> purchaseAmount;
private List<BudgetPurchaseAmountModel> purchaseAmount;
}

View File

@ -2,6 +2,7 @@ package cn.palmte.work.service;
import cn.palmte.work.config.activiti.ActConstant;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -18,6 +19,7 @@ import java.util.Objects;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import cn.palmte.work.config.activiti.ActProjectTypeEnum;
@ -25,10 +27,17 @@ import cn.palmte.work.model.Admin;
import cn.palmte.work.model.AdminRepository;
import cn.palmte.work.model.Dept;
import cn.palmte.work.model.DeptRepository;
import cn.palmte.work.model.ProcurementType;
import cn.palmte.work.model.ProcurementTypeRepository;
import cn.palmte.work.model.Project;
import cn.palmte.work.model.ProjectBudgetCostDetail;
import cn.palmte.work.model.ProjectRepository;
import cn.palmte.work.model.enums.ProcessStatus;
import cn.palmte.work.model.process.BudgetPurchaseAmount;
import cn.palmte.work.model.process.BudgetPurchaseDetail;
import cn.palmte.work.model.process.BudgetPurchaseDetailModel;
import cn.palmte.work.model.process.ProcurementContract;
import cn.palmte.work.model.process.ProcurementDetail;
import cn.palmte.work.model.process.ProjectProcess;
import cn.palmte.work.model.process.SaleContract;
import cn.palmte.work.model.process.SupplierMaterial;
@ -52,6 +61,7 @@ public class ProjectProcessService {
private final DeptRepository deptRepository;
private final AdminRepository userRepository;
private final ProcurementTypeRepository procurementTypeRepository;
@Data
static class DeptReturnValue {
@ -190,6 +200,74 @@ public class ProjectProcessService {
return query.getResultList();
}
/**
*
*
* @param projectId ID
*/
public List<ProcurementDetail> getProcurementDetails(int projectId) {
List<ProcurementDetail> ret = new ArrayList<>();
List<ProjectBudgetCostDetail> costDetails = getCostDetails(projectId);
for (ProjectBudgetCostDetail costDetail : costDetails) {
ProcurementDetail detail = new ProcurementDetail();
BeanUtils.copyProperties(costDetail, detail);
BudgetPurchaseAmount purchaseAmount = getPurchaseAmount(costDetail);
if (purchaseAmount != null) {
detail.setAmountAlready(purchaseAmount.getAmountAlready());
Integer amountId = purchaseAmount.getId();
List<BudgetPurchaseDetail> purchaseDetails = getBudgetPurchaseDetails(amountId);
detail.setPurchaseDetails(purchaseDetails);
}
// TODO 查询太频繁
detail.setCategory(getCategory(costDetail));
ret.add(detail);
}
return ret;
}
private String getCategory(ProjectBudgetCostDetail costDetail) {
int category = costDetail.getCategory();
TypedQuery<ProcurementType> query = entityManager.createQuery(
"from ProcurementType where id=:category and isDeleted=0 and enabled=1", ProcurementType.class);
query.setParameter("category", category);
try {
ProcurementType procurementType = query.getSingleResult();
return procurementType.getName();
}
catch (NoResultException e) {
return String.valueOf(category);
}
}
private List<BudgetPurchaseDetail> getBudgetPurchaseDetails(int amountId) {
TypedQuery<BudgetPurchaseDetail> query = entityManager.createQuery(
"from BudgetPurchaseDetail where amountId=:amountId", BudgetPurchaseDetail.class);
query.setParameter("amountId", amountId);
return query.getResultList();
}
private List<ProjectBudgetCostDetail> getCostDetails(int projectId) {
TypedQuery<ProjectBudgetCostDetail> query = entityManager.createQuery(
"from ProjectBudgetCostDetail where projectId=:projectId", ProjectBudgetCostDetail.class);
query.setParameter("projectId", projectId);
return query.getResultList();
}
private BudgetPurchaseAmount getPurchaseAmount(ProjectBudgetCostDetail costDetail) {
TypedQuery<BudgetPurchaseAmount> amountQuery = entityManager.createQuery(
"from BudgetPurchaseAmount where budgetCostId=:budgetCostId", BudgetPurchaseAmount.class);
amountQuery.setParameter("budgetCostId", costDetail.getId());
try {
return amountQuery.getSingleResult();
}
catch (NoResultException e) {
return null;
}
}
public ProjectProcess getById(int id) {
return entityManager.find(ProjectProcess.class, id);
}

View File

@ -72,9 +72,9 @@ create table procurement_contract_supplier_material
create table procurement_contract_budget_purchase_amount
(
id int auto_increment primary key comment 'ID',
amount_current int comment '本次采购数量',
amount_already int comment '已采购数量',
amount_left int comment '未采购数量',
amount_current decimal(11, 2) comment '本次采购数量',
amount_already decimal(11, 2) comment '已采购数量',
amount_left decimal(11, 2) comment '未采购数量',
process_id int comment '流程ID',
contract_id int comment '采购合同ID',

View File

@ -91,7 +91,7 @@
<template slot="prepend">项目编号</template>
<#--显示项目名称,但是值是 projectNo 定义显示的列表样式-->
<template slot-scope="{ item }">
<span>{{ item.name }}</span>
<span>{{ item.name }}</span>
</template>
</el-autocomplete>
@ -114,14 +114,15 @@
<el-table-column prop="taxRate" label="税率(%"></el-table-column>
<el-table-column prop="totalTaxInclude" label="含税总金额(元)" width="120"></el-table-column>
<el-table-column prop="totalTaxExclude" label="不含税金额(元)" width="120"></el-table-column>
<el-table-column prop="taxFee" label="税金(元)" width="110"></el-table-column>
<el-table-column prop="totalTax" label="税金(元)" width="110"></el-table-column>
<el-table-column prop="isUnderwritten" label="是否垫资"></el-table-column>
<el-table-column prop="payTime" label="支出时间"></el-table-column>
<el-table-column prop="payTime" label="支出时间" width="160"></el-table-column>
<el-table-column prop="payAmount" label="支出金额(元)" width="120"></el-table-column>
<el-table-column prop="amountAlready" label="已采购数量" width="100"></el-table-column>
<el-table-column prop="amountCurrent" label="本次采购数量" width="180">
<template slot-scope="scope">
<el-input-number size="mini" :precision="2" :step="0.1" :min="0"
:max="scope.row.amount - scope.row.amountAlready"
v-model="scope.row.amountCurrent"></el-input-number>
</template>
</el-table-column>