Commit f18e2721 by sunxin

业务类型可用范围 关联修改 删除

parent f4520004
...@@ -20,5 +20,10 @@ public interface CtBbtcTypeAreaDao extends CrudDao<CtBbtcTypeArea> { ...@@ -20,5 +20,10 @@ public interface CtBbtcTypeAreaDao extends CrudDao<CtBbtcTypeArea> {
public List<CtBbtcTypeArea> getByAreaId(CtBbtcTypeArea area); public List<CtBbtcTypeArea> getByAreaId(CtBbtcTypeArea area);
public List<CtBbtcTypeArea> getByParentId(CtBbtcTypeArea area);
/*跟据parentId 删除*/
public int deleteByParentId(CtBbtcTypeArea area);
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ package com.ejweb.modules.report.service; ...@@ -6,6 +6,7 @@ package com.ejweb.modules.report.service;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.ejweb.core.utils.StringUtils;
import com.ejweb.modules.report.dao.CtBbtcRegionDao; import com.ejweb.modules.report.dao.CtBbtcRegionDao;
import com.ejweb.modules.report.dao.CtBbtcTypeAreaDao; import com.ejweb.modules.report.dao.CtBbtcTypeAreaDao;
import com.ejweb.modules.report.entity.CtBbtcRegion; import com.ejweb.modules.report.entity.CtBbtcRegion;
...@@ -51,12 +52,20 @@ public class CtBbtcBusTypeService extends CrudService<CtBbtcBusTypeDao, CtBbtcBu ...@@ -51,12 +52,20 @@ public class CtBbtcBusTypeService extends CrudService<CtBbtcBusTypeDao, CtBbtcBu
super.save(ctBbtcBusType); super.save(ctBbtcBusType);
/*将可用范围存到 typearea表中*/ /*将可用范围存到 typearea表中*/
System.out.println(ctBbtcBusType.getGroup()+"==========================");
System.out.println(ctBbtcBusType.getArea()+"=========================");
String[] groups = ctBbtcBusType.getGroup().split(","); String[] groups = ctBbtcBusType.getGroup().split(",");
String[] areas = ctBbtcBusType.getArea().split(","); String[] areas = ctBbtcBusType.getArea().split(",");
/*判断是新增还是修改*/
CtBbtcTypeArea ctBbtcTypeArea0 =new CtBbtcTypeArea();
ctBbtcTypeArea0.setParentId(ctBbtcBusType.getId());
List<CtBbtcTypeArea> listParentId = ctBbtcTypeAreaDao.getByParentId(ctBbtcTypeArea0);
//修改
if(listParentId.size()!=0 && listParentId != null){
//删除前面所有parentid的信息 重新存
ctBbtcTypeAreaDao.deleteByParentId(ctBbtcTypeArea0);
}
int i=0; int i=0;
for (String typeArea:groups) { for (String typeArea:groups) {
CtBbtcTypeArea ctBbtcTypeArea =new CtBbtcTypeArea(); CtBbtcTypeArea ctBbtcTypeArea =new CtBbtcTypeArea();
...@@ -80,6 +89,10 @@ public class CtBbtcBusTypeService extends CrudService<CtBbtcBusTypeDao, CtBbtcBu ...@@ -80,6 +89,10 @@ public class CtBbtcBusTypeService extends CrudService<CtBbtcBusTypeDao, CtBbtcBu
@Transactional(readOnly = false) @Transactional(readOnly = false)
public void delete(CtBbtcBusType ctBbtcBusType) { public void delete(CtBbtcBusType ctBbtcBusType) {
super.delete(ctBbtcBusType); super.delete(ctBbtcBusType);
//删除关联表中 parentid为id的数据
CtBbtcTypeArea ctBbtcTypeArea =new CtBbtcTypeArea();
ctBbtcTypeArea.setParentId(ctBbtcBusType.getId());
ctBbtcTypeAreaDao.deleteByParentId(ctBbtcTypeArea);
} }
} }
\ No newline at end of file
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<update id="update"> <update id="update">
UPDATE ct_bbtc_bus_type SET UPDATE ct_bbtc_bus_type SET
fnumber = #{number}, fnumber = #{number},
name = #{name}, name = #{name}
WHERE id = #{id} WHERE id = #{id}
</update> </update>
......
...@@ -24,6 +24,14 @@ ...@@ -24,6 +24,14 @@
WHERE a.id = #{id} WHERE a.id = #{id}
</select> </select>
<select id="getByParentId" resultType="com.ejweb.modules.report.entity.CtBbtcTypeArea">
SELECT
<include refid="ctBbtcTypeAreaColumns"/>
FROM CT_BBTC_TYPE_AREA a
<include refid="ctBbtcTypeAreaJoins"/>
WHERE a.parent_id = #{parentId}
</select>
<select id="getByAreaId" resultType="com.ejweb.modules.report.entity.CtBbtcTypeArea"> <select id="getByAreaId" resultType="com.ejweb.modules.report.entity.CtBbtcTypeArea">
SELECT SELECT
<include refid="ctBbtcTypeAreaColumns"/> <include refid="ctBbtcTypeAreaColumns"/>
...@@ -75,5 +83,10 @@ ...@@ -75,5 +83,10 @@
DELETE FROM CT_BBTC_TYPE_AREA DELETE FROM CT_BBTC_TYPE_AREA
WHERE id = #{id} WHERE id = #{id}
</update> </update>
<update id="deleteByParentId">
DELETE FROM CT_BBTC_TYPE_AREA
WHERE parent_id = #{parentId}
</update>
</mapper> </mapper>
\ No newline at end of file
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