Commit aa65d1c4 by 高晓磊

场站中的生产线新增和修改

parent 85e673dc
......@@ -5,7 +5,9 @@ import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.core.context.AminoContextHolder;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.support.KernelArray;
import com.beecode.inz.basis.internal.dao.AbstractBaseDao;
import com.xyst.dinas.biz.constant.ProductionLineConstant;
import com.xyst.dinas.biz.constant.StationConstant;
import com.xyst.dinas.biz.dao.DinasTypeDao;
import com.xyst.dinas.biz.dao.StationDao;
......@@ -15,6 +17,7 @@ import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import java.lang.reflect.Array;
import java.util.Date;
import java.util.List;
import java.util.UUID;
......@@ -78,6 +81,19 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat
kobject.set("modifyTime",new Date());
kobject.set("modifier",staff);
kobject.set("del",false);
template.deleteAll(id.get("productionLines").toList());
KObject productions = kobject.get("productionLines");
if(null!=productions){
List<KObject> kObjects = productions.toList();
for (KObject object : kObjects) {
if(null==object.getUuid("id")){
object.set("id",UUID.randomUUID());
}
object.set("station",kobject);
template.save(ProductionLineConstant.ENTITY,object);
}
}
template.merge(kobject);
}
......@@ -93,7 +109,19 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat
kObject.set("creator",staff);
kObject.set("createTime", new Date());
kObject.set("del",false);
return ((UUID)template.save(kObject));
UUID save = (UUID) template.save(kObject);
KObject productions = kObject.get("productionLines");
if(null!=productions){
List<KObject> kObjects = productions.toList();
for (KObject object : kObjects) {
if(null==object.getUuid("id")){
object.set("id",UUID.randomUUID());
}
object.set("station",kObject);
template.save(ProductionLineConstant.ENTITY,object);
}
}
return save;
}
@Override
......
......@@ -60,10 +60,6 @@
<comment>场站状态,0已停业1经营中</comment>
</column>
</property>
<bag name="productionLines" lazy="true" fetch="select" inverse="true">
<key column="station_id" not-null="true" />
<one-to-many entity-name="com.xyst.dinas.biz.datamodel.ProductionLine" />
</bag>
<property name="stationCoordinate" type="nstring" not-null="false">
<column name="station_coordinate">
<comment>场站的坐标按照逗号分隔</comment>
......@@ -94,14 +90,18 @@
<comment >排序</comment>
</column>
</property>
<bag name="productionLines" lazy="true" fetch="select" inverse="true">
<key column="station_id" not-null="true" />
<one-to-many entity-name="com.xyst.dinas.biz.datamodel.ProductionLine" />
</bag>
</class>
<class entity-name="com.xyst.dinas.biz.datamodel.ProductionLine" table="xyst_dinas_biz_production_Line" optimistic-lock="version">
<class entity-name="com.xyst.dinas.biz.datamodel.ProductionLine" table="xyst_dinas_biz_production_Line">
<tuplizer entity-mode="dynamic-map" class="com.beecode.bcp.store.hibernate.KObjectEntityTuplizer"/>
<id name="id" type="uuid-binary" column="id" length="16">
<generator class="assigned" />
</id>
<many-to-one name="station" entity-name="com.xyst.dinas.biz.datamodel.ProductionLine" fetch="select">
<column name="station_id" not-null="false">
<many-to-one name="station" entity-name="com.xyst.dinas.biz.datamodel.Station" fetch="select" >
<column name="station_id" not-null="false" >
<comment>所属场站</comment>
</column>
</many-to-one>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment