mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善
This commit is contained in:
@@ -24,5 +24,6 @@ public class UpdateDeliveryInformationDto extends OrgCommonDto {
|
||||
|
||||
|
||||
|
||||
private String purchaseOrder;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ import jakarta.persistence.ManyToOne;
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
public class CreatePurchaseOrderDto extends OrgCommonDto {
|
||||
@@ -25,6 +28,20 @@ public class CreatePurchaseOrderDto extends OrgCommonDto {
|
||||
private Double price;
|
||||
|
||||
|
||||
@Comment("采购日期")
|
||||
private LocalDate purchaseDate;
|
||||
|
||||
@Comment("预计到货日期")
|
||||
private LocalDate estimateDeliveryDate;
|
||||
|
||||
|
||||
@Formula("(select min(d.delivery_date) from t_delivery_information d where d.purchase_order_id = id)")
|
||||
private LocalDate firstDeliveryDate;
|
||||
|
||||
@Formula("(select max(d.delivery_date) from t_delivery_information d where d.purchase_order_id = id)")
|
||||
private LocalDate lastDeliveryDate;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,12 +12,40 @@ import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PurchaseOrderDto extends OrgCommonDto {
|
||||
|
||||
|
||||
@Comment("采购日期")
|
||||
private LocalDate purchaseDate;
|
||||
|
||||
@Comment("预计到货日期")
|
||||
private LocalDate estimateDeliveryDate;
|
||||
|
||||
|
||||
@Formula("(select min(d.delivery_date) from t_delivery_information d where d.purchase_order_id = id)")
|
||||
private LocalDate firstDeliveryDate;
|
||||
|
||||
@Formula("(select max(d.delivery_date) from t_delivery_information d where d.purchase_order_id = id)")
|
||||
private LocalDate lastDeliveryDate;
|
||||
|
||||
|
||||
private Integer dayLeft;
|
||||
|
||||
|
||||
private Integer dayAmount;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@Comment("煤炭信息")
|
||||
private CoalInfoDto coalInfo;
|
||||
@@ -34,6 +62,10 @@ public class PurchaseOrderDto extends OrgCommonDto {
|
||||
private Double receivedAmount;
|
||||
|
||||
|
||||
@Formula("(select sum(d.car_count) from t_delivery_information d where d.purchase_order_id = id)")
|
||||
private Double totalCarCount;
|
||||
|
||||
|
||||
@Formula("(amount - (select sum(d.amount) from t_delivery_information d where d.purchase_order_id = id))")
|
||||
private Double leftAmount;
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
public class UpdatePurchaseOrderDto extends OrgCommonDto {
|
||||
|
||||
@@ -25,4 +27,12 @@ public class UpdatePurchaseOrderDto extends OrgCommonDto {
|
||||
@Comment("采购单价")
|
||||
private Double price;
|
||||
|
||||
|
||||
|
||||
@Comment("采购日期")
|
||||
private LocalDate purchaseDate;
|
||||
|
||||
@Comment("预计到货日期")
|
||||
private LocalDate estimateDeliveryDate;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,12 +13,39 @@ import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class PurchaseOrderEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
|
||||
|
||||
@Comment("采购日期")
|
||||
private LocalDate purchaseDate;
|
||||
|
||||
@Comment("预计到货日期")
|
||||
private LocalDate estimateDeliveryDate;
|
||||
|
||||
|
||||
@Formula("(select min(d.delivery_date) from t_delivery_information d where d.purchase_order_id = id)")
|
||||
private LocalDate firstDeliveryDate;
|
||||
|
||||
@Formula("(select max(d.delivery_date) from t_delivery_information d where d.purchase_order_id = id)")
|
||||
private LocalDate lastDeliveryDate;
|
||||
|
||||
|
||||
|
||||
@Formula("(estimate_delivery_date - now()::date)")
|
||||
private Integer dayLeft;
|
||||
|
||||
|
||||
@Formula("(estimate_delivery_date - purchase_date)")
|
||||
private Integer dayAmount;
|
||||
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@Comment("煤炭信息")
|
||||
private CoalInfoEntity coalInfo;
|
||||
@@ -57,6 +84,33 @@ public class PurchaseOrderEntity extends OrgCommonEntity {
|
||||
+ " and i.code = order_status)")
|
||||
private String orderStatusName;
|
||||
|
||||
@Override
|
||||
public void prePersist() {
|
||||
super.prePersist();
|
||||
this.updateStatus();
|
||||
}
|
||||
|
||||
private void updateStatus() {
|
||||
if (this.purchaseDate.isBefore(LocalDate.now())){
|
||||
this.orderStatus = "0";
|
||||
}else {
|
||||
|
||||
double total = this.deliveryInformationList == null ? 0: this.deliveryInformationList.stream().mapToDouble(DeliveryInformationEntity::getAmount).sum();
|
||||
|
||||
if (total >= this.amount){
|
||||
this.orderStatus = "2";
|
||||
}else {
|
||||
this.orderStatus = "1";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preUpdate() {
|
||||
super.preUpdate();
|
||||
this.updateStatus();
|
||||
}
|
||||
|
||||
public void setDeliveryInformationList(List<cn.lihongjie.coal.deliveryInformation.entity.DeliveryInformationEntity> deliveryInformationList) {
|
||||
if (deliveryInformationList == null) {
|
||||
|
||||
Reference in New Issue
Block a user