采购合同流程 创建时保存供应商比选材料

master
Harry Yang 2022-12-27 16:47:57 +08:00
parent 62f3574609
commit b87cc40094
2 changed files with 36 additions and 3 deletions

View File

@ -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.CollectionUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -61,6 +62,7 @@ import cn.palmte.work.model.process.ProjectProcess;
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.ProcessQueryForm;
import cn.palmte.work.model.process.form.ProcessUpdateForm;
import cn.palmte.work.model.process.form.ProcessCreationForm;
@ -289,6 +291,9 @@ public class ProcessController {
return processService.isProjectPrepaid(project) ? "是" : "否";
}
/**
*
*/
@ResponseBody
@GetMapping("/{id}")
public ProjectReturnValue get(@PathVariable int id) {
@ -329,7 +334,7 @@ public class ProcessController {
.build();
}
// 销售合同流程
// 合同流程
@ResponseBody
@PostMapping
@ -356,6 +361,11 @@ public class ProcessController {
ProcurementContract procurementContract = ProcurementContract.from(form);
procurementContract.setProcessId(entity.getId());
entityManager.persist(procurementContract);
List<SupplierMaterial> supplierMaterials = form.getSupplierMaterials();
if (!CollectionUtils.isEmpty(supplierMaterials)) {
supplierMaterials.forEach(entityManager::persist);
}
break;
default:
throw new UnsupportedOperationException("还不支持");

View File

@ -1,20 +1,28 @@
package cn.palmte.work.model.process;
import org.hibernate.Hibernate;
import org.hibernate.annotations.GenericGenerator;
import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
*
* @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
* @since 2.0 2022/12/26 17:34
*/
@Data
@Getter
@Setter
@ToString
@Entity
@Table(name = "procurement_contract_supplier_material")
public class SupplierMaterial {
@ -33,4 +41,19 @@ public class SupplierMaterial {
private String attachment;
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o))
return false;
SupplierMaterial that = (SupplierMaterial) o;
return id != null && Objects.equals(id, that.id);
}
@Override
public int hashCode() {
return getClass().hashCode();
}
}