采购合同流程 采购成本明细 数据结构
parent
ab47c53214
commit
f76fae0a85
|
@ -14,6 +14,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -46,6 +47,7 @@ import cn.palmte.work.config.activiti.ActProjectTypeEnum;
|
|||
import cn.palmte.work.model.Admin;
|
||||
import cn.palmte.work.model.DeptRepository;
|
||||
import cn.palmte.work.model.Project;
|
||||
import cn.palmte.work.model.ProjectBudgetCostDetail;
|
||||
import cn.palmte.work.model.ProjectBudgetIncomeDetail;
|
||||
import cn.palmte.work.model.ProjectRepository;
|
||||
import cn.palmte.work.model.ProjectTaskRecord;
|
||||
|
@ -56,6 +58,8 @@ import cn.palmte.work.model.enums.ProcessType;
|
|||
import cn.palmte.work.model.enums.ProcurementMode;
|
||||
import cn.palmte.work.model.enums.ProjectType;
|
||||
import cn.palmte.work.model.enums.SealType;
|
||||
import cn.palmte.work.model.process.BudgetPurchaseAmount;
|
||||
import cn.palmte.work.model.process.BudgetPurchaseDetail;
|
||||
import cn.palmte.work.model.process.ProcessAttachment;
|
||||
import cn.palmte.work.model.process.ProcurementContract;
|
||||
import cn.palmte.work.model.process.ProjectProcess;
|
||||
|
@ -63,9 +67,11 @@ import cn.palmte.work.model.process.ProjectProcessRepository;
|
|||
import cn.palmte.work.model.process.SaleContract;
|
||||
import cn.palmte.work.model.process.SealTypeArray;
|
||||
import cn.palmte.work.model.process.SupplierMaterial;
|
||||
import cn.palmte.work.model.process.form.BudgetPurchaseAmountForm;
|
||||
import cn.palmte.work.model.process.form.BudgetPurchaseDetailForm;
|
||||
import cn.palmte.work.model.process.form.ProcessCreationForm;
|
||||
import cn.palmte.work.model.process.form.ProcessQueryForm;
|
||||
import cn.palmte.work.model.process.form.ProcessUpdateForm;
|
||||
import cn.palmte.work.model.process.form.ProcessCreationForm;
|
||||
import cn.palmte.work.service.ProjectBudgetService;
|
||||
import cn.palmte.work.service.ProjectInstanceService;
|
||||
import cn.palmte.work.service.ProjectProcessService;
|
||||
|
@ -245,6 +251,7 @@ public class ProcessController {
|
|||
public String terminalCustomer;
|
||||
|
||||
public List<ProjectBudgetIncomeDetail> incomeDetails;
|
||||
public List<ProjectBudgetCostDetail> procurementDetails;
|
||||
|
||||
// FIXME 垫资
|
||||
// 是否垫资
|
||||
|
@ -263,9 +270,14 @@ public class ProcessController {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取调谐表单的初始数据
|
||||
*
|
||||
* @param id 项目ID
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping("/projects/{id}")
|
||||
public ProjectReturnValue query(@PathVariable int id) {
|
||||
public ProjectReturnValue getProject(@PathVariable int id) {
|
||||
Project project = projectRepository.findById(id);
|
||||
Admin admin = InterfaceUtil.getAdmin();
|
||||
|
||||
|
@ -274,10 +286,12 @@ public class ProcessController {
|
|||
BigDecimal repaidAmount = getRepaidAmount(id);
|
||||
// 可以在对应表数据查询 是否存在再启用
|
||||
List<ProjectBudgetIncomeDetail> incomeDetails = projectBudgetService.getBudgetIncomeDetail(project);
|
||||
List<ProjectBudgetCostDetail> procurementDetails = projectBudgetService.getBudgetCostDetail(project);
|
||||
return ProjectReturnValue.builder()
|
||||
.isPrepaid(isPrepaid(project))
|
||||
.projectId(project.getId())
|
||||
.incomeDetails(incomeDetails)
|
||||
.procurementDetails(procurementDetails)
|
||||
.projectName(project.getName())
|
||||
.repaidAmount(repaidAmount + "元")
|
||||
.budgetGrossMargin(project.getGrossProfitMargin())
|
||||
|
@ -345,7 +359,11 @@ public class ProcessController {
|
|||
@ResponseBody
|
||||
@PostMapping
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void post(@RequestBody @Valid ProcessCreationForm form) throws Exception {
|
||||
public void post(@RequestBody ProcessCreationForm form) throws Exception {
|
||||
Assert.notNull(form.getProjectId(), "未选择项目");
|
||||
ProcessType processType = form.getProcessType();
|
||||
Assert.notNull(processType, "流程类型不能为空");
|
||||
|
||||
ProjectProcess entity = new ProjectProcess();
|
||||
BeanUtils.copyProperties(form, entity, "sealTypes", "applyDate", "attachments");
|
||||
entity.setApplyDate(LocalDate.parse(form.getApplyDate(), formatter));
|
||||
|
@ -356,29 +374,61 @@ public class ProcessController {
|
|||
|
||||
entityManager.persist(entity);
|
||||
|
||||
if (entity.getProcessType() != null) {
|
||||
switch (entity.getProcessType()) {
|
||||
case sale_contract:
|
||||
SaleContract saleContract = SaleContract.from(form);
|
||||
saleContract.setProcessId(entity.getId());
|
||||
entityManager.persist(saleContract);
|
||||
break;
|
||||
case procurement_contract:
|
||||
ProcurementContract procurementContract = ProcurementContract.from(form);
|
||||
procurementContract.setProcessId(entity.getId());
|
||||
entityManager.persist(procurementContract);
|
||||
// 保存后流程ID可以获取
|
||||
Integer processId = entity.getId();
|
||||
|
||||
List<SupplierMaterial> supplierMaterials = form.getSupplierMaterials();
|
||||
if (!CollectionUtils.isEmpty(supplierMaterials)) {
|
||||
supplierMaterials.forEach(entityManager::persist);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("还不支持");
|
||||
}
|
||||
if (processType == ProcessType.sale_contract) {
|
||||
SaleContract contract = SaleContract.from(form);
|
||||
contract.setProcessId(processId);
|
||||
entityManager.persist(contract);
|
||||
|
||||
processService.updateIncomeDetails(form.getIncomeDetails());
|
||||
}
|
||||
else if (processType == ProcessType.procurement_contract) {
|
||||
ProcurementContract contract = ProcurementContract.from(form);
|
||||
contract.setProcessId(processId);
|
||||
entityManager.persist(contract);
|
||||
|
||||
processService.updateIncomeDetails(form.getIncomeDetails());
|
||||
Integer contractId = contract.getId();
|
||||
|
||||
if (!CollectionUtils.isEmpty(form.getSupplierMaterials())) {
|
||||
for (SupplierMaterial material : form.getSupplierMaterials()) {
|
||||
material.setProcessId(processId);
|
||||
material.setContractId(contractId);
|
||||
|
||||
entityManager.persist(material);
|
||||
}
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(form.getPurchaseAmount())) {
|
||||
for (BudgetPurchaseAmountForm amountForm : form.getPurchaseAmount()) {
|
||||
// 保存 成本明细数量
|
||||
BudgetPurchaseAmount amountEntity = new BudgetPurchaseAmount();
|
||||
BeanUtils.copyProperties(amountForm, amountEntity, "details");
|
||||
amountEntity.setProcessId(processId);
|
||||
amountEntity.setContractId(contractId);
|
||||
|
||||
entityManager.persist(amountEntity);
|
||||
|
||||
Integer amountId = amountEntity.getId();
|
||||
// 保存成本对应的 明细
|
||||
|
||||
if (!CollectionUtils.isEmpty(amountForm.getDetails())) {
|
||||
for (BudgetPurchaseDetailForm detail : amountForm.getDetails()) {
|
||||
BudgetPurchaseDetail purchaseDetail = new BudgetPurchaseDetail();
|
||||
BeanUtils.copyProperties(detail, purchaseDetail, "details");
|
||||
|
||||
// 关联主键
|
||||
purchaseDetail.setAmountId(amountId);
|
||||
purchaseDetail.setProcessId(processId);
|
||||
purchaseDetail.setContractId(contractId);
|
||||
entityManager.persist(purchaseDetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (form.getStatus() == ProcessStatus.to_be_audit) {
|
||||
// 发起流程
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package cn.palmte.work.model.process;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 采购合同流程预算采购明细的数量记录
|
||||
* <p>
|
||||
* 一个 BudgetPurchaseAmount 对应 多个 BudgetPurchaseDetail
|
||||
*
|
||||
* @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
|
||||
* @since 2.0 2022/12/28 14:15
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "procurement_contract_budget_purchase_amount")
|
||||
public class BudgetPurchaseAmount implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GenericGenerator(name = "persistenceGenerator", strategy = "increment")
|
||||
private Integer id;
|
||||
|
||||
// 已采购数量
|
||||
private Integer amountAlready;
|
||||
|
||||
// '本次采购数量'
|
||||
private Integer amountCurrent;
|
||||
|
||||
// 未采购数量
|
||||
private Integer amountLeft;
|
||||
|
||||
// 流程ID
|
||||
private Integer processId;
|
||||
|
||||
// 采购合同ID
|
||||
private Integer contractId;
|
||||
|
||||
// 成本ID
|
||||
private Integer budgetCostId;
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
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;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 采购合同流程预算采购明细的详情
|
||||
* <p>
|
||||
* 一个 BudgetPurchaseAmount 对应 多个 BudgetPurchaseDetail
|
||||
*
|
||||
* @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
|
||||
* @since 2.0 2022/12/28 11:41
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "procurement_contract_budget_purchase_detail")
|
||||
public class BudgetPurchaseDetail implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GenericGenerator(name = "persistenceGenerator", strategy = "increment")
|
||||
private Integer id;
|
||||
|
||||
// 供应商名称
|
||||
private String supplierName;
|
||||
|
||||
// 设备厂商名称
|
||||
private String manufacturerName;
|
||||
|
||||
// 对应采购清单
|
||||
private String purchaseList;
|
||||
|
||||
// 规格型号
|
||||
private String spec;
|
||||
|
||||
// 对应采购数目
|
||||
private Integer procurementAmount;
|
||||
|
||||
// 采购单价
|
||||
private BigDecimal procurementPrice;
|
||||
|
||||
// 含税总金额(元)
|
||||
private String totalTaxInclude;
|
||||
|
||||
private Integer processId;
|
||||
|
||||
// 对应的 procurement_contract 的ID
|
||||
private Integer contractId;
|
||||
|
||||
private Integer amountId;
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@ import lombok.ToString;
|
|||
|
||||
/**
|
||||
* 供应商比选材料
|
||||
*
|
||||
* @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
|
||||
* @since 2.0 2022/12/26 17:34
|
||||
*/
|
||||
|
@ -43,6 +44,8 @@ public class SupplierMaterial {
|
|||
|
||||
private Integer processId;
|
||||
|
||||
private Integer contractId;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package cn.palmte.work.model.process.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 采购合同流程预算采购明细的数量记录
|
||||
*
|
||||
* @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
|
||||
* @since 2.0 2022/12/28 15:00
|
||||
*/
|
||||
@Data
|
||||
public class BudgetPurchaseAmountForm {
|
||||
|
||||
// 已采购数量
|
||||
private Integer amountAlready;
|
||||
|
||||
// 本次采购数量
|
||||
private Integer amountCurrent;
|
||||
|
||||
// 未采购数量
|
||||
private Integer amountLeft;
|
||||
|
||||
// 项目的成本明细ID
|
||||
private Integer budgetCostId;
|
||||
|
||||
private List<BudgetPurchaseDetailForm> details;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package cn.palmte.work.model.process.form;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 采购合同流程预算采购明细的详情
|
||||
*
|
||||
* @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
|
||||
* @since 2.0 2022/12/28 15:01
|
||||
*/
|
||||
@Data
|
||||
public class BudgetPurchaseDetailForm {
|
||||
|
||||
// 供应商名称
|
||||
private String supplierName;
|
||||
|
||||
// 设备厂商名称
|
||||
private String manufacturerName;
|
||||
|
||||
// 对应采购清单
|
||||
private String purchaseList;
|
||||
|
||||
// 规格型号
|
||||
private String spec;
|
||||
|
||||
// 对应采购数目
|
||||
private Integer procurementAmount;
|
||||
|
||||
// 采购单价
|
||||
private BigDecimal procurementPrice;
|
||||
|
||||
// 含税总金额(元)
|
||||
private String totalTaxInclude;
|
||||
|
||||
}
|
|
@ -2,8 +2,6 @@ package cn.palmte.work.model.process.form;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import cn.palmte.work.model.enums.ProcessStatus;
|
||||
import cn.palmte.work.model.enums.ProcessType;
|
||||
import cn.palmte.work.model.enums.ProcurementMode;
|
||||
|
@ -20,7 +18,6 @@ import lombok.Data;
|
|||
@Data
|
||||
public class ProcessCreationForm {
|
||||
|
||||
@NotNull
|
||||
private Integer projectId;
|
||||
|
||||
// 项目编号
|
||||
|
@ -78,7 +75,6 @@ public class ProcessCreationForm {
|
|||
|
||||
private ProcessStatus status;
|
||||
|
||||
@NotNull(message = "流程类型不能为空")
|
||||
private ProcessType processType;
|
||||
|
||||
private List<SaleContractDetailForm> incomeDetails;
|
||||
|
@ -91,4 +87,7 @@ public class ProcessCreationForm {
|
|||
|
||||
private List<SupplierMaterial> supplierMaterials;
|
||||
|
||||
// 采购详情
|
||||
private List<BudgetPurchaseAmountForm> purchaseAmount;
|
||||
|
||||
}
|
||||
|
|
|
@ -55,4 +55,7 @@ public class ProcessUpdateForm {
|
|||
private List<ProcessAttachment> attachments;
|
||||
|
||||
private List<SaleContractDetailForm> incomeDetails;
|
||||
|
||||
// 采购详情
|
||||
private List<BudgetPurchaseAmountForm> purchaseAmount;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ create table project_process
|
|||
create_at datetime default CURRENT_TIMESTAMP comment '创建时间',
|
||||
last_update_at datetime default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '最后更新时间'
|
||||
|
||||
);
|
||||
) comment '项目对应的流程';
|
||||
|
||||
alter table project_process
|
||||
add apply_dept_leader_id int null comment '申请部门领导ID';
|
||||
|
@ -40,9 +40,9 @@ create table procurement_contract
|
|||
id int auto_increment primary key comment 'ID',
|
||||
procurement_mode varchar(255) null comment '采购模式',
|
||||
payment_terms text null comment '付款条件',
|
||||
process_id int null comment '流程ID',
|
||||
supplier_name varchar(255) null comment '供应商名称'
|
||||
);
|
||||
supplier_name varchar(255) null comment '供应商名称',
|
||||
process_id int comment '流程ID'
|
||||
) comment '采购合同流程';
|
||||
|
||||
# 销售合同
|
||||
create table sale_contract
|
||||
|
@ -51,8 +51,9 @@ create table sale_contract
|
|||
apply_person_phone varchar(255) null comment '申请人电话',
|
||||
client_name varchar(255) null comment '客户名称',
|
||||
payment_terms text null comment '收款条件',
|
||||
process_id int null comment '流程ID'
|
||||
);
|
||||
process_id int comment '流程ID'
|
||||
) comment '销售合同流程';
|
||||
|
||||
create table procurement_contract_supplier_material
|
||||
(
|
||||
id int auto_increment primary key comment 'ID',
|
||||
|
@ -63,5 +64,36 @@ create table procurement_contract_supplier_material
|
|||
tax_rate varchar(255) null comment '税率',
|
||||
remark varchar(255) null comment '备注',
|
||||
attachment varchar(1000) null comment '附件',
|
||||
process_id int null comment '流程ID'
|
||||
);
|
||||
|
||||
process_id int comment '流程ID',
|
||||
contract_id int comment '采购合同ID'
|
||||
) comment '采购合同流程的供应商材料';
|
||||
|
||||
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 '未采购数量',
|
||||
|
||||
process_id int comment '流程ID',
|
||||
contract_id int comment '采购合同ID',
|
||||
budget_cost_id int comment '成本ID'
|
||||
) comment '采购合同流程预算采购明细的数量记录';
|
||||
|
||||
create table procurement_contract_budget_purchase_detail
|
||||
(
|
||||
id int auto_increment primary key comment 'ID',
|
||||
supplier_name varchar(255) null comment '供应商名称',
|
||||
manufacturer_name varchar(255) null comment '设备厂商名称',
|
||||
purchase_list varchar(255) null comment '对应采购清单',
|
||||
spec varchar(255) null comment '规格型号',
|
||||
procurement_amount int null comment '对应采购数目',
|
||||
procurement_price decimal(19, 5) null comment '采购单价',
|
||||
total_tax_include decimal(19, 5) null comment '含税总金额(元)',
|
||||
|
||||
process_id int comment '流程ID',
|
||||
contract_id int comment '采购合同ID',
|
||||
amount_id int comment '成本ID'
|
||||
|
||||
) comment '采购合同流程预算采购明细的详情';
|
Loading…
Reference in New Issue