采购合同更新API
parent
12160d8fbc
commit
d8e2dc63dc
|
@ -473,10 +473,14 @@ public class ProcessController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PutMapping
|
@PutMapping("/{id}")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(@RequestBody @Valid ProcessUpdateForm form) throws Exception {
|
public void update(@PathVariable int id, @RequestBody @Valid ProcessUpdateForm form) throws Exception {
|
||||||
ProjectProcess entity = processService.getById(form.getId());
|
ProjectProcess entity = processService.getById(id);
|
||||||
|
if (entity == null) {
|
||||||
|
throw ErrorMessageException.failed("流程不存在");
|
||||||
|
}
|
||||||
|
|
||||||
Integer processId = entity.getId();
|
Integer processId = entity.getId();
|
||||||
ProcessType processType = entity.getProcessType();
|
ProcessType processType = entity.getProcessType();
|
||||||
|
|
||||||
|
@ -491,7 +495,7 @@ public class ProcessController {
|
||||||
entityManager.merge(entity);
|
entityManager.merge(entity);
|
||||||
|
|
||||||
if (processType == ProcessType.sale_contract) {
|
if (processType == ProcessType.sale_contract) {
|
||||||
SaleContract contract = processService.findSaleContract(form.getId());
|
SaleContract contract = processService.findSaleContract(id);
|
||||||
contract.setClientName(form.getClientName());
|
contract.setClientName(form.getClientName());
|
||||||
contract.setPaymentTerms(form.getPaymentTerms());
|
contract.setPaymentTerms(form.getPaymentTerms());
|
||||||
contract.setApplyPersonPhone(form.getApplyPersonPhone());
|
contract.setApplyPersonPhone(form.getApplyPersonPhone());
|
||||||
|
@ -500,7 +504,7 @@ public class ProcessController {
|
||||||
processService.updateIncomeDetails(form.getIncomeDetails());
|
processService.updateIncomeDetails(form.getIncomeDetails());
|
||||||
}
|
}
|
||||||
else if (processType == ProcessType.procurement_contract) {
|
else if (processType == ProcessType.procurement_contract) {
|
||||||
ProcurementContract contract = processService.findProcurementContract(form.getId());
|
ProcurementContract contract = processService.findProcurementContract(id);
|
||||||
contract.setProcurementMode(form.getProcurementMode());
|
contract.setProcurementMode(form.getProcurementMode());
|
||||||
contract.setPaymentTerms(form.getPaymentTerms());
|
contract.setPaymentTerms(form.getPaymentTerms());
|
||||||
contract.setSupplierName(form.getSupplierName());
|
contract.setSupplierName(form.getSupplierName());
|
||||||
|
@ -512,14 +516,20 @@ public class ProcessController {
|
||||||
for (SupplierMaterial material : form.supplierMaterials) {
|
for (SupplierMaterial material : form.supplierMaterials) {
|
||||||
material.setProcessId(processId);
|
material.setProcessId(processId);
|
||||||
material.setContractId(contractId);
|
material.setContractId(contractId);
|
||||||
|
// 更新或者新增
|
||||||
entityManager.merge(material);
|
if (material.getId() != null) {
|
||||||
|
entityManager.merge(material);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entityManager.persist(material);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(form.purchaseAmount)) {
|
if (!CollectionUtils.isEmpty(form.purchaseAmount)) {
|
||||||
for (BudgetPurchaseAmountModel amountForm : form.purchaseAmount) {
|
for (BudgetPurchaseAmountModel amountForm : form.purchaseAmount) {
|
||||||
// 草稿模式也不允许为空 (基础数据)
|
// 草稿模式也不允许为空 (基础数据), 更新ID不能为空
|
||||||
|
Assert.notNull(amountForm.amountId, "合同明细填写不完整");
|
||||||
Assert.notNull(amountForm.amount, "合同明细填写不完整");
|
Assert.notNull(amountForm.amount, "合同明细填写不完整");
|
||||||
Assert.notNull(amountForm.budgetCostId, "合同明细填写不完整");
|
Assert.notNull(amountForm.budgetCostId, "合同明细填写不完整");
|
||||||
|
|
||||||
|
@ -528,7 +538,7 @@ public class ProcessController {
|
||||||
|
|
||||||
// 新建
|
// 新建
|
||||||
BudgetPurchaseAmount purchaseAmount = new BudgetPurchaseAmount();
|
BudgetPurchaseAmount purchaseAmount = new BudgetPurchaseAmount();
|
||||||
purchaseAmount.setId(amountForm.id);
|
purchaseAmount.setId(amountForm.amountId);
|
||||||
purchaseAmount.setProcessId(processId);
|
purchaseAmount.setProcessId(processId);
|
||||||
purchaseAmount.setContractId(contractId);
|
purchaseAmount.setContractId(contractId);
|
||||||
purchaseAmount.setAmount(amountForm.amount);
|
purchaseAmount.setAmount(amountForm.amount);
|
||||||
|
|
|
@ -18,7 +18,7 @@ import lombok.ToString;
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
public class BudgetPurchaseAmountModel {
|
public class BudgetPurchaseAmountModel {
|
||||||
|
|
||||||
public Integer id;
|
public Integer amountId;
|
||||||
|
|
||||||
// 所有的
|
// 所有的
|
||||||
public BigDecimal amount;
|
public BigDecimal amount;
|
||||||
|
|
|
@ -58,6 +58,8 @@ public class ProcurementDetail {
|
||||||
|
|
||||||
private List<BudgetPurchaseDetail> purchaseDetails;
|
private List<BudgetPurchaseDetail> purchaseDetails;
|
||||||
|
|
||||||
|
private Integer amountId;
|
||||||
|
|
||||||
public void setIsUnderwritten(int isUnderwritten) {
|
public void setIsUnderwritten(int isUnderwritten) {
|
||||||
this.isUnderwritten = isUnderwritten;
|
this.isUnderwritten = isUnderwritten;
|
||||||
this.isUnderwrittenDesc = isUnderwritten == 1 ? "是" : "否";
|
this.isUnderwrittenDesc = isUnderwritten == 1 ? "是" : "否";
|
||||||
|
|
|
@ -20,9 +20,6 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class ProcessUpdateForm {
|
public class ProcessUpdateForm {
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
// 申请部门 部门1,部门2,部门3 (逗号分割)
|
// 申请部门 部门1,部门2,部门3 (逗号分割)
|
||||||
private String applyDept;
|
private String applyDept;
|
||||||
|
|
||||||
|
|
|
@ -225,6 +225,7 @@ public class ProjectProcessService {
|
||||||
if (amountAlready == null) {
|
if (amountAlready == null) {
|
||||||
amountAlready = getAmountAlready(amount.getBudgetCostId());
|
amountAlready = getAmountAlready(amount.getBudgetCostId());
|
||||||
}
|
}
|
||||||
|
detail.setAmountId(amountId);
|
||||||
detail.setAmountAlready(amountAlready);
|
detail.setAmountAlready(amountAlready);
|
||||||
detail.setAmountCurrent(amount.getAmountCurrent());
|
detail.setAmountCurrent(amount.getAmountCurrent());
|
||||||
ret.add(detail);
|
ret.add(detail);
|
||||||
|
@ -322,6 +323,7 @@ public class ProjectProcessService {
|
||||||
public BigDecimal getAmountAlready(int budgetCostId) {
|
public BigDecimal getAmountAlready(int budgetCostId) {
|
||||||
return getPurchaseAmountList(budgetCostId).stream()
|
return getPurchaseAmountList(budgetCostId).stream()
|
||||||
.map(BudgetPurchaseAmount::getAmountAlready)
|
.map(BudgetPurchaseAmount::getAmountAlready)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue