1:新增工作计划资源位置插入逻辑

yun-zuoyi
钮海涛 6 years ago
parent ba7c713b6f
commit 921be6b0f2

@ -1,6 +1,8 @@
package cn.estsh.i3plus.pojo.aps.bean;
import cn.estsh.i3plus.pojo.aps.common.BaseAPS;
import cn.estsh.i3plus.pojo.aps.common.BeanRelation;
import cn.estsh.i3plus.pojo.aps.holders.EShippingTime;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
@ -21,27 +23,55 @@ import javax.persistence.Table;
@Table(name = "APS_SHIPPING_TIME")
@Api("运输时间")
public class ShippingTime extends BaseAPS {
@Column(name="TIME")
@ApiParam(value ="运输时间")
private String time;
@Column(name="PRIORITY")
@ApiParam(value ="优先级")
private Integer priority;
@Column(name="PREV_RES_CODE")
@ApiParam(value ="前资源编码")
private String prevResCode;
@ApiParam(value ="前资源对象Id")
private Long prevResId;
@Column(name="POST_RES_CODE")
@ApiParam(value ="后资源编码")
private String postResCode;
@ApiParam(value ="后资源对象Id")
private Long postResId;
@Column(name="PREV_STAND_CODE")
@ApiParam(value ="前标准工序编码")
private String prevStandCode;
@ApiParam(value ="前标准工序对象Id")
private Long prevStandId;
@Column(name="POST_STAND_CODE")
@ApiParam(value ="后标准工序编码")
private String postStandCode;
@ApiParam(value ="后标准工序对象Id")
private Long postStandId;
@Column(name="TIME")
@ApiParam(value ="运输时间")
private String time;
public Resource getPrevRes() {return BeanRelation.get(this, EShippingTime.PrevRes); }
@Column(name="PRIORITY")
@ApiParam(value ="优先级")
private Integer priority;
public void setPrevRes(Resource res) {
this.prevResId = res != null ? res.getId() : 0l;
BeanRelation.set(this, EShippingTime.PrevRes, res);
}
public Resource getPostRes() { return BeanRelation.get(this, EShippingTime.PostRes); }
public void setPostRes(Resource res) {
this.postResId = res != null ? res.getId() : 0l;
BeanRelation.set(this, EShippingTime.PostRes, res);
}
public StandOperation getPrevStand() { return BeanRelation.get(this, EShippingTime.PrevStand);}
public void setPrevStand(StandOperation stand) {
this.prevStandId = stand != null ? stand.getId() : 0l;
BeanRelation.set(this, EShippingTime.PrevStand, stand);
}
public StandOperation getPostStand() { return BeanRelation.get(this, EShippingTime.PostStand); }
public void setPostStand(StandOperation stand) {
this.postStandId = stand != null ? stand.getId() : 0l;
BeanRelation.set(this, EShippingTime.PostStand, stand);
}
}

@ -202,30 +202,26 @@ public class BeanRelation {
}
}
public static <T extends BaseBean> List<T> lastList(BaseBean entity, Enum<?>... args) {
List<T> result = new ArrayList<T>();
lastListImpl(result, entity, null, args, 0);
return result;
}
public static <T extends BaseBean> List<T> lastList(BaseBean entity, Predicate<T> filter, Enum<?>... args) {
List<T> result = new ArrayList<T>();
lastListImpl(result, entity, filter, args, 0);
public static <T extends BaseBean> List<T> lastList(BaseBean bean, Enum<?>... holders) {
List<T> result = new ArrayList<>();
lastListImpl(result, bean, bean, holders, 0);
return result;
}
@SuppressWarnings("unchecked")
private final static <T extends BaseBean> boolean lastListImpl(List<T> result, BaseBean entity, Predicate<T> filter,
Enum<?>[] args, int index) {
if (index >= args.length) {
private final static <T extends BaseBean> boolean lastListImpl(List<T> result, BaseBean bean, BaseBean self,
Enum<?>[] holders, int index) {
if (index >= holders.length) {
if (self == bean) {
return false;
}
index = 0;
self = bean;
}
boolean bNotLast = true;
List<BaseBean> relaEntities = list(entity, args[index]);
for (BaseBean relaEntity : relaEntities) {
if (lastListImpl(result, relaEntity, filter, args, index + 1)) {
result.add((T)relaEntity);
List<BaseBean> nextBeans = list(bean, holders[index]);
for (BaseBean nextBean : nextBeans) {
if (lastListImpl(result, nextBean, self, holders, index + 1)) {
result.add((T)nextBean);
bNotLast = false;
}
}

@ -0,0 +1,8 @@
package cn.estsh.i3plus.pojo.aps.holders;
public enum EShippingTime {
PrevRes, // 前资源
PostRes, // 后资源
PrevStand, // 前标准工序
PostStand // 后标准工序
}

@ -2,6 +2,7 @@ package cn.estsh.i3plus.pojo.aps.model;
import cn.estsh.i3plus.pojo.aps.bean.WorkResource;
import java.util.ArrayList;
import java.util.List;
/**
@ -14,5 +15,5 @@ import java.util.List;
**/
public class ResourceCompose {
public WorkResource resource;
public List<WorkResource> assResource;
public List<WorkResource> assResource = new ArrayList<>();
}

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Class name="WorkPlan">
<Relation field="PrevRes" name="Resource" type="MULTI_TO_ONE" owner="false">
</Relation>
<Relation field="PostRes" name="Resource" type="MULTI_TO_ONE" owner="false">
</Relation>
<Relation field="PrevStand" name="StandOperation" type="MULTI_TO_ONE" owner="false">
</Relation>
<Relation field="PostStand" name="StandOperation" type="MULTI_TO_ONE" owner="false">
</Relation>
</Class>
Loading…
Cancel
Save