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