编辑采购合同流程 获取采购清单 重构
parent
b4e5d5cad7
commit
c45ba9346f
|
@ -29,6 +29,7 @@ public class ProcurementDetail {
|
||||||
private String contractParty;
|
private String contractParty;
|
||||||
|
|
||||||
private int isUnderwritten;
|
private int isUnderwritten;
|
||||||
|
private String isUnderwrittenDesc;
|
||||||
|
|
||||||
private BigDecimal underwrittenAmount;
|
private BigDecimal underwrittenAmount;
|
||||||
|
|
||||||
|
@ -53,4 +54,8 @@ public class ProcurementDetail {
|
||||||
|
|
||||||
private List<BudgetPurchaseDetail> purchaseDetails;
|
private List<BudgetPurchaseDetail> purchaseDetails;
|
||||||
|
|
||||||
|
public void setIsUnderwritten(int isUnderwritten) {
|
||||||
|
this.isUnderwritten = isUnderwritten;
|
||||||
|
this.isUnderwrittenDesc = isUnderwritten == 1 ? "是" : "否";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,32 +205,40 @@ public class ProjectProcessService {
|
||||||
* @param processId 流程ID 一般用于获取详情
|
* @param processId 流程ID 一般用于获取详情
|
||||||
*/
|
*/
|
||||||
public List<ProcurementDetail> getProcurementDetails(int projectId, Integer processId) {
|
public List<ProcurementDetail> getProcurementDetails(int projectId, Integer processId) {
|
||||||
List<ProcurementDetail> ret = new ArrayList<>();
|
ArrayList<ProcurementDetail> ret = new ArrayList<>();
|
||||||
|
if (processId != null) {
|
||||||
|
// 根据流程获取
|
||||||
|
List<BudgetPurchaseAmount> purchaseAmount = getProcessPurchaseAmount(processId);
|
||||||
|
for (BudgetPurchaseAmount amount : purchaseAmount) {
|
||||||
|
ProjectBudgetCostDetail costDetail = getCostDetailById(amount.getBudgetCostId());
|
||||||
|
ProcurementDetail detail = new ProcurementDetail();
|
||||||
|
BeanUtils.copyProperties(costDetail, detail);
|
||||||
|
|
||||||
List<ProjectBudgetCostDetail> costDetails = getCostDetails(projectId);
|
Integer amountId = amount.getId();
|
||||||
for (ProjectBudgetCostDetail costDetail : costDetails) {
|
// 找对应 预算采购明细的数量记录 的采购详情
|
||||||
ProcurementDetail detail = new ProcurementDetail();
|
List<BudgetPurchaseDetail> purchaseDetails = getBudgetPurchaseDetails(amountId);
|
||||||
BeanUtils.copyProperties(costDetail, detail);
|
detail.setPurchaseDetails(purchaseDetails);
|
||||||
// 可能为 0
|
detail.setBudgetCostId(costDetail.getId());
|
||||||
BigDecimal amountAlready = getAmountAlready(costDetail.getId());
|
detail.setCategory(getCategory(costDetail));
|
||||||
detail.setAmountAlready(amountAlready);
|
detail.setAmountAlready(amount.getAmountAlready());
|
||||||
|
|
||||||
if (processId != null) {
|
|
||||||
// 根据 processId 确定唯一的 BudgetPurchaseAmount 用作获取详情 , 可能还未创建
|
|
||||||
BudgetPurchaseAmount purchaseAmount = getPurchaseAmount(costDetail.getId(), processId);
|
|
||||||
if (purchaseAmount != null) {
|
|
||||||
Integer amountId = purchaseAmount.getId();
|
|
||||||
List<BudgetPurchaseDetail> purchaseDetails = getBudgetPurchaseDetails(amountId);
|
|
||||||
detail.setPurchaseDetails(purchaseDetails);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// TODO 查询太频繁
|
|
||||||
detail.setCategory(getCategory(costDetail));
|
|
||||||
|
|
||||||
detail.setBudgetCostId(costDetail.getId());
|
|
||||||
ret.add(detail);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
List<ProjectBudgetCostDetail> costDetails = getCostDetails(projectId);
|
||||||
|
for (ProjectBudgetCostDetail costDetail : costDetails) {
|
||||||
|
ProcurementDetail detail = new ProcurementDetail();
|
||||||
|
BeanUtils.copyProperties(costDetail, detail);
|
||||||
|
// 可能为 0
|
||||||
|
BigDecimal amountAlready = getAmountAlready(costDetail.getId());
|
||||||
|
detail.setAmountAlready(amountAlready);
|
||||||
|
|
||||||
|
// TODO 查询太频繁
|
||||||
|
detail.setCategory(getCategory(costDetail));
|
||||||
|
|
||||||
|
detail.setBudgetCostId(costDetail.getId());
|
||||||
|
ret.add(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,6 +263,10 @@ public class ProjectProcessService {
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ProjectBudgetCostDetail getCostDetailById(int budgetCostId) {
|
||||||
|
return entityManager.find(ProjectBudgetCostDetail.class, budgetCostId);
|
||||||
|
}
|
||||||
|
|
||||||
private List<ProjectBudgetCostDetail> getCostDetails(int projectId) {
|
private List<ProjectBudgetCostDetail> getCostDetails(int projectId) {
|
||||||
TypedQuery<ProjectBudgetCostDetail> query = entityManager.createQuery(
|
TypedQuery<ProjectBudgetCostDetail> query = entityManager.createQuery(
|
||||||
"from ProjectBudgetCostDetail where projectId=:projectId", ProjectBudgetCostDetail.class);
|
"from ProjectBudgetCostDetail where projectId=:projectId", ProjectBudgetCostDetail.class);
|
||||||
|
@ -262,6 +274,24 @@ public class ProjectProcessService {
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取采购合同流程所有的 预算采购明细的数量记录
|
||||||
|
*
|
||||||
|
* @param processId 合同流程
|
||||||
|
* @return 采购合同流程预算采购明细的数量记录 列表
|
||||||
|
*/
|
||||||
|
public List<BudgetPurchaseAmount> getProcessPurchaseAmount(Integer processId) {
|
||||||
|
TypedQuery<BudgetPurchaseAmount> amountQuery = entityManager.createQuery(
|
||||||
|
"from BudgetPurchaseAmount where processId=:processId", BudgetPurchaseAmount.class);
|
||||||
|
amountQuery.setParameter("processId", processId);
|
||||||
|
try {
|
||||||
|
return amountQuery.getResultList();
|
||||||
|
}
|
||||||
|
catch (NoResultException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BudgetPurchaseAmount getPurchaseAmount(int budgetCostId, Integer processId) {
|
public BudgetPurchaseAmount getPurchaseAmount(int budgetCostId, Integer processId) {
|
||||||
TypedQuery<BudgetPurchaseAmount> amountQuery = entityManager.createQuery(
|
TypedQuery<BudgetPurchaseAmount> amountQuery = entityManager.createQuery(
|
||||||
"from BudgetPurchaseAmount where budgetCostId=:budgetCostId and processId=:processId", BudgetPurchaseAmount.class);
|
"from BudgetPurchaseAmount where budgetCostId=:budgetCostId and processId=:processId", BudgetPurchaseAmount.class);
|
||||||
|
|
|
@ -370,7 +370,7 @@
|
||||||
<el-table-column prop="totalTaxInclude_" label="含税总金额(元)" width="120"></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="totalTaxExclude" label="不含税金额(元)" width="120"></el-table-column>
|
||||||
<el-table-column prop="totalTax" 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="isUnderwrittenDesc" label="是否垫资"></el-table-column>
|
||||||
<el-table-column prop="payTime" label="支出时间" width="160"></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="payAmount" label="支出金额(元)" width="120"></el-table-column>
|
||||||
<el-table-column prop="amountAlready" label="已采购数量" width="100"></el-table-column>
|
<el-table-column prop="amountAlready" label="已采购数量" width="100"></el-table-column>
|
||||||
|
@ -468,6 +468,19 @@
|
||||||
const saleContractDetail = "saleContractDetail"
|
const saleContractDetail = "saleContractDetail"
|
||||||
const BUTTON = "btn"
|
const BUTTON = "btn"
|
||||||
|
|
||||||
|
const procurementDetailProperties = [
|
||||||
|
"spec",
|
||||||
|
"amount",
|
||||||
|
"purchaseList",
|
||||||
|
"amountAlready",
|
||||||
|
"amountCurrent",
|
||||||
|
"supplierName",
|
||||||
|
"totalTaxInclude",
|
||||||
|
"manufacturerName",
|
||||||
|
"procurementPrice",
|
||||||
|
"procurementAmount"
|
||||||
|
]
|
||||||
|
|
||||||
const isEmpty = (obj) => {
|
const isEmpty = (obj) => {
|
||||||
return !obj || (obj.length && obj.length === 0)
|
return !obj || (obj.length && obj.length === 0)
|
||||||
}
|
}
|
||||||
|
@ -618,22 +631,40 @@
|
||||||
|
|
||||||
let rowKey = 0
|
let rowKey = 0
|
||||||
|
|
||||||
function mapChildren(detail) {
|
const convertCommon = detail => {
|
||||||
const { purchaseDetails } = detail
|
return {
|
||||||
return (purchaseDetails || []).map(purchase => ({
|
rowKey: rowKey++, feeType: computeFeeType(detail.type),
|
||||||
...purchase, ...detail, rowKey: rowKey++, feeType: computeFeeType(detail.type),
|
|
||||||
totalTaxInclude_: detail.totalTaxInclude, totalTaxInclude: undefined, // 存在相同字段转换一下
|
totalTaxInclude_: detail.totalTaxInclude, totalTaxInclude: undefined, // 存在相同字段转换一下
|
||||||
isUnderwritten: detail.isUnderwritten === 1 ? "是" : "否",
|
}
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.procurementDetails = procurementDetails && procurementDetails.map(detail => ({
|
const computeProcurementDetails = procurementDetails => {
|
||||||
...detail, feeType: computeFeeType(detail.type),
|
const ret = []
|
||||||
totalTaxInclude_: detail.totalTaxInclude, totalTaxInclude: undefined, // 存在相同字段转换一下
|
for (let detail of procurementDetails || []) {
|
||||||
isUnderwritten: detail.isUnderwritten === 1 ? "是" : "否",
|
const newDetail = {
|
||||||
rowKey: rowKey++, children: mapChildren(detail)
|
...detail, ...convertCommon(detail),
|
||||||
}))
|
}
|
||||||
|
// mapChildren
|
||||||
|
let { purchaseDetails } = newDetail
|
||||||
|
if (isNotEmpty(purchaseDetails)) {
|
||||||
|
purchaseDetails = purchaseDetails.map(purchase => ({
|
||||||
|
...purchase, ...detail, parent: newDetail
|
||||||
|
}))
|
||||||
|
|
||||||
|
// 合并第一行到父级
|
||||||
|
const first = purchaseDetails.shift();
|
||||||
|
Object.assign(newDetail, first)
|
||||||
|
delete newDetail['parent']
|
||||||
|
delete newDetail['purchaseDetails']
|
||||||
|
|
||||||
|
newDetail['children'] = purchaseDetails
|
||||||
|
}
|
||||||
|
ret.push(newDetail)
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
this.procurementDetails = computeProcurementDetails(procurementDetails)
|
||||||
this.procurementDetailsRowKey = rowKey
|
this.procurementDetailsRowKey = rowKey
|
||||||
|
|
||||||
if (process.processType === 'sale_contract') {
|
if (process.processType === 'sale_contract') {
|
||||||
|
|
Loading…
Reference in New Issue