Commit bf31bfc1 authored by duanruiming's avatar duanruiming

[add] 策略优先级配置删除

parent 3de6c327
......@@ -115,12 +115,43 @@ public interface StrategyPriorityMapper extends BaseMapper<StrategyPriorityDaily
List<StrategyParameterConfig> getGreenParamConfigData(@Param("greenId") Integer greenId, @Param("type") Integer type, @Param("strategyNo") String strategyNo);
/**
* 通过路口编号,分组编号查询策略详情
* 通过路口编号或干线编号,分组编号查询策略库详情
* @param crossId
* @param greenId
* @param groupId
* @return
*/
List<StrategyFactoryEntity> selectCrossGroupStrategyList(@Param("crossId") String crossId, @Param("greenId") Integer greenId, @Param("groupId") Integer groupId);
/**
* 删除路口编号分组下策略编号
* @param crossId
* @param greenId
* @param groupId
* @param strategyNo
* @return
*/
void deleteGreenPriorityConfig(@Param("crossId") String crossId, @Param("greenId") Integer greenId,
@Param("groupId") Integer groupId, @Param("strategyNo") String strategyNo);
/**
* 通过路口编号或干线编号,分组编号,查询优先级配置日计划详情
* @param crossId
* @param greenId
* @param groupId
* @return
*/
List<StrategyPriorityDailyInfo> selectCrossGreenGroupDailyPlanList(@Param("crossId") String crossId, @Param("greenId") Integer greenId, @Param("groupId") Integer groupId);
/**
* 通过路口编号或干线编号,分组编号查询策略优先级配置详情
* @param crossId
* @param greenId
* @param groupId
* @return
*/
List<StrategyPriorityConfig> selectCrossGroupStrategyPriorityList(@Param("crossId") String crossId, @Param("greenId") Integer greenId, @Param("groupId") Integer groupId);
}
......@@ -29,6 +29,13 @@ public interface StrategyPriorityService extends IService<StrategyPriorityDailyI
void savePriority(List<StrategyPriorityGroupVO> dataList) throws Exception;
/**
* 删除优先级配置表中策略
* @param dataList
* @throws Exception
*/
void deletePriorityConfigList(List<StrategyPriorityGroupVO> dataList) throws Exception;
List<StrategyFactoryEntity> getPriorityData(String crossId,Integer greenId, Integer type) throws Exception;
void savePlanConfig(List<StrategyPriorityGroupVO> dailyPlanDetails) throws Exception;
......
......@@ -186,6 +186,46 @@ public class StrategyPriorityServiceImpl extends ServiceImpl<StrategyPriorityMap
}
}
@Override
@Transactional(rollbackFor = RuntimeException.class)
public void deletePriorityConfigList(List<StrategyPriorityGroupVO> dataList) throws Exception {
if (CollectionUtils.isNotEmpty(dataList)) {
Map<Integer, List<StrategyPriorityGroupVO>> groupMap = dataList.stream().collect(Collectors.groupingBy(StrategyPriorityGroupVO::getGroupId));
for (Map.Entry<Integer, List<StrategyPriorityGroupVO>> entry : groupMap.entrySet()) {
Integer groupId = entry.getKey();
List<StrategyPriorityGroupVO> value = entry.getValue();
StrategyPriorityGroupVO groupVO = value.get(0);
List<String> crossIds = groupVO.getCrossIds();
String crossId = null;
if (CollectionUtils.isNotEmpty(crossIds)) {
crossId = crossIds.get(0);
}
List<Integer> greenIds = groupVO.getGreenIds();
Integer greenId = null;
if (CollectionUtils.isNotEmpty(greenIds)) {
greenId = greenIds.get(0);
}
// 当全部删除时,1.校验日计划中是否有使用;2.并且删除数量=数据库中数量
List<StrategyPriorityConfig> data4DB = strategyPriorityMapper.selectCrossGroupStrategyPriorityList(crossId, greenId, groupId);
List<StrategyPriorityDailyInfo> dailyInfos = strategyPriorityMapper.selectCrossGreenGroupDailyPlanList(crossId, greenId, groupId);
if (CollectionUtils.isNotEmpty(dailyInfos) && data4DB.size() <= dataList.size()) {
throw new RuntimeException("日计划中已使用当前分组: " + groupId + " 不能清空!");
}
// 删除路口编号分组下策略编号
for (StrategyPriorityGroupVO strategyPriorityGroupVO : value) {
List<StrategyPriorityConfig> data = strategyPriorityGroupVO.getData();
if (CollectionUtils.isNotEmpty(data)) {
for (StrategyPriorityConfig datum : data) {
strategyPriorityMapper.deleteGreenPriorityConfig(crossId, greenId, groupId, datum.getStrategyNo());
}
}
}
}
}
}
/*
* 策略优先级路口跟干线数据回显
* */
......
......@@ -436,6 +436,7 @@
WHERE green_id =#{greenId}
</delete>
<!-- 通过路口或者绿波编号,分组编号查询分组中策略信息详情 -->
<select id="selectCrossGroupStrategyList" resultType="net.wanji.opt.synthesis.pojo.StrategyFactoryEntity">
select t2.type, t2.scene, t2.strategy_name, t2.strategy_no, t2.method, t2.company,
t2.mark, t2.status, t2.opt_type, t2.create_time, t2.modify_time
......@@ -453,7 +454,60 @@
</if>
order by t1.priority
</where>
</select>
<delete id="deleteGreenPriorityConfig">
DELETE
FROM t_strategy_priority_config
<where>
<if test="crossId != null and crossId != ''">
and cross_id = #{crossId}
</if>
<if test="greenId!=null and greenId!=''">
and green_id = #{greenId}
</if>
<if test="groupId != null and groupId != ''">
and group_id = #{groupId}
</if>
<if test="strategyNo != null and strategyNo != ''">
and strategy_no = #{strategyNo}
</if>
</where>
</delete>
<!-- 通过路口或者绿波编号,分组编号查询日计划详情 -->
<select id="selectCrossGreenGroupDailyPlanList" resultType="net.wanji.opt.entity.strategy.StrategyPriorityDailyInfo">
select daily_plan_id, week_execute, daily_plan_details, cross_id, type, green_id, gmt_create
from t_strategy_priority_daily_info
<where>
<if test="crossId != null and crossId != ''">
and cross_id = #{crossId}
</if>
<if test="greenId!=null and greenId!=''">
and green_id = #{greenId}
</if>
<if test="groupId != null and groupId != ''">
and JSON_CONTAINS(JSON_EXTRACT(daily_plan_details, '$'), JSON_OBJECT('groupId', #{groupId}))
</if>
</where>
</select>
<!-- 通过路口或者绿波编号,分组编号查询策略优先级配置详情 -->
<select id="selectCrossGroupStrategyPriorityList" resultType="net.wanji.opt.entity.strategy.StrategyPriorityDailyInfo">
select group_id, group_name, priority, strategy_no, cross_id, green_id, type, gmt_create
from t_strategy_priority_config
<where>
<if test="crossId != null and crossId != ''">
and cross_id = #{crossId}
</if>
<if test="greenId!=null and greenId!=''">
and green_id = #{greenId}
</if>
<if test="groupId != null and groupId != ''">
and group_id = #{groupId}
</if>
</where>
</select>
</mapper>
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