Commit aa65d1c4 by 高晓磊

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

parent 85e673dc
...@@ -5,7 +5,9 @@ import com.beecode.bap.attachment.common.Page; ...@@ -5,7 +5,9 @@ import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.core.context.AminoContextHolder; import com.beecode.bcp.core.context.AminoContextHolder;
import com.beecode.bcp.type.KClass; import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.support.KernelArray;
import com.beecode.inz.basis.internal.dao.AbstractBaseDao; 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.constant.StationConstant;
import com.xyst.dinas.biz.dao.DinasTypeDao; import com.xyst.dinas.biz.dao.DinasTypeDao;
import com.xyst.dinas.biz.dao.StationDao; import com.xyst.dinas.biz.dao.StationDao;
...@@ -15,6 +17,7 @@ import org.hibernate.criterion.Restrictions; ...@@ -15,6 +17,7 @@ import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate; import org.springframework.orm.hibernate5.HibernateTemplate;
import java.lang.reflect.Array;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
...@@ -78,6 +81,19 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat ...@@ -78,6 +81,19 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat
kobject.set("modifyTime",new Date()); kobject.set("modifyTime",new Date());
kobject.set("modifier",staff); kobject.set("modifier",staff);
kobject.set("del",false); 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); template.merge(kobject);
} }
...@@ -93,7 +109,19 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat ...@@ -93,7 +109,19 @@ public class StationDaoImpl extends AbstractBaseDao implements StationDao, Stat
kObject.set("creator",staff); kObject.set("creator",staff);
kObject.set("createTime", new Date()); kObject.set("createTime", new Date());
kObject.set("del",false); 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 @Override
......
...@@ -60,10 +60,6 @@ ...@@ -60,10 +60,6 @@
<comment>场站状态,0已停业1经营中</comment> <comment>场站状态,0已停业1经营中</comment>
</column> </column>
</property> </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"> <property name="stationCoordinate" type="nstring" not-null="false">
<column name="station_coordinate"> <column name="station_coordinate">
<comment>场站的坐标按照逗号分隔</comment> <comment>场站的坐标按照逗号分隔</comment>
...@@ -94,14 +90,18 @@ ...@@ -94,14 +90,18 @@
<comment >排序</comment> <comment >排序</comment>
</column> </column>
</property> </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>
<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"/> <tuplizer entity-mode="dynamic-map" class="com.beecode.bcp.store.hibernate.KObjectEntityTuplizer"/>
<id name="id" type="uuid-binary" column="id" length="16"> <id name="id" type="uuid-binary" column="id" length="16">
<generator class="assigned" /> <generator class="assigned" />
</id> </id>
<many-to-one name="station" entity-name="com.xyst.dinas.biz.datamodel.ProductionLine" fetch="select"> <many-to-one name="station" entity-name="com.xyst.dinas.biz.datamodel.Station" fetch="select" >
<column name="station_id" not-null="false"> <column name="station_id" not-null="false" >
<comment>所属场站</comment> <comment>所属场站</comment>
</column> </column>
</many-to-one> </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