Commit 6b11008f authored by hanbing's avatar hanbing

[update] 态势监测,问题路口排序

parent c6f5b6a5
...@@ -74,9 +74,7 @@ public class TrendController { ...@@ -74,9 +74,7 @@ public class TrendController {
}) })
public JsonViewObject abnormalCrossList(@RequestBody AbnormalCrossListDTO abnormalCrossListDTO) { public JsonViewObject abnormalCrossList(@RequestBody AbnormalCrossListDTO abnormalCrossListDTO) {
AbnormalCrossVO abnormalCrossVO = trendService.abnormalCrossList(abnormalCrossListDTO); AbnormalCrossVO abnormalCrossVO = trendService.abnormalCrossList(abnormalCrossListDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); return JsonViewObject.newInstance().success(abnormalCrossVO);
return jsonViewObject.success(abnormalCrossVO);
} }
@ApiOperation(value = "问题路口详情", notes = "问题路口详情", response = JsonViewObject.class, @ApiOperation(value = "问题路口详情", notes = "问题路口详情", response = JsonViewObject.class,
......
...@@ -12,6 +12,7 @@ import net.wanji.opt.dto.strategy.QueryIdeaDTO; ...@@ -12,6 +12,7 @@ import net.wanji.opt.dto.strategy.QueryIdeaDTO;
import net.wanji.opt.po.strategy.IdeaPO; import net.wanji.opt.po.strategy.IdeaPO;
import net.wanji.opt.service.strategy.IdeaService; import net.wanji.opt.service.strategy.IdeaService;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -47,6 +48,7 @@ public class IdeaController { ...@@ -47,6 +48,7 @@ public class IdeaController {
try { try {
ideaService.addOrUpdateIdea(addOrUpdateIdeaDTO); ideaService.addOrUpdateIdea(addOrUpdateIdeaDTO);
} catch (DuplicateKeyException e) { } catch (DuplicateKeyException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new DuplicateKeyException("方法编号或方法名称不可重复"); throw new DuplicateKeyException("方法编号或方法名称不可重复");
} }
return JsonViewObject.newInstance().success(); return JsonViewObject.newInstance().success();
......
...@@ -12,6 +12,7 @@ import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO; ...@@ -12,6 +12,7 @@ import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO;
import net.wanji.opt.dto.strategy.QuerySceneDTO; import net.wanji.opt.dto.strategy.QuerySceneDTO;
import net.wanji.opt.service.strategy.SceneService; import net.wanji.opt.service.strategy.SceneService;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -47,8 +48,10 @@ public class SceneController { ...@@ -47,8 +48,10 @@ public class SceneController {
try { try {
sceneService.addOrUpdateScene(addOrUpdateSceneDTO); sceneService.addOrUpdateScene(addOrUpdateSceneDTO);
} catch (DuplicateKeyException e) { } catch (DuplicateKeyException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new DuplicateKeyException("场景编号或场景名称不可重复"); throw new DuplicateKeyException("场景编号或场景名称不可重复");
} catch (UniqueException e) { } catch (UniqueException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new UniqueException("应用策略或优化方法不可重复"); throw new UniqueException("应用策略或优化方法不可重复");
} }
return JsonViewObject.newInstance().success(); return JsonViewObject.newInstance().success();
......
...@@ -12,6 +12,7 @@ import net.wanji.opt.dto.strategy.QueryStrategyDTO; ...@@ -12,6 +12,7 @@ import net.wanji.opt.dto.strategy.QueryStrategyDTO;
import net.wanji.opt.po.strategy.StrategyPO; import net.wanji.opt.po.strategy.StrategyPO;
import net.wanji.opt.service.strategy.StrategyService; import net.wanji.opt.service.strategy.StrategyService;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -47,6 +48,7 @@ public class StrategyController { ...@@ -47,6 +48,7 @@ public class StrategyController {
try { try {
strategyService.addOrUpdateStrategy(addOrUpdateStrategyDTO); strategyService.addOrUpdateStrategy(addOrUpdateStrategyDTO);
} catch (DuplicateKeyException e) { } catch (DuplicateKeyException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new DuplicateKeyException("策略编号或策略名称不可重复"); throw new DuplicateKeyException("策略编号或策略名称不可重复");
} }
return JsonViewObject.newInstance().success(); return JsonViewObject.newInstance().success();
......
...@@ -37,6 +37,7 @@ import org.springframework.stereotype.Service; ...@@ -37,6 +37,7 @@ import org.springframework.stereotype.Service;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -154,6 +155,8 @@ public class TrendServiceImpl implements TrendService { ...@@ -154,6 +155,8 @@ public class TrendServiceImpl implements TrendService {
buildRidData(abnormalCrossListVO, endCrossId, inDirs); buildRidData(abnormalCrossListVO, endCrossId, inDirs);
} }
} }
CrossComparator crossComparator = new CrossComparator();
abnormalCrossListVOList.sort(crossComparator);
abnormalCrossVO.setAbnormalCrossList(abnormalCrossListVOList); abnormalCrossVO.setAbnormalCrossList(abnormalCrossListVOList);
// 构造统计信息 // 构造统计信息
List<AbnormalCrossListVO> listForStats = List<AbnormalCrossListVO> listForStats =
...@@ -163,6 +166,24 @@ public class TrendServiceImpl implements TrendService { ...@@ -163,6 +166,24 @@ public class TrendServiceImpl implements TrendService {
return abnormalCrossVO; return abnormalCrossVO;
} }
private static class CrossComparator implements Comparator<AbnormalCrossListVO> {
@Override
public int compare(AbnormalCrossListVO o1, AbnormalCrossListVO o2) {
// 先按路口状态排序
Integer o1status = o1.getRealtimeStatus();
Integer o2status = o2.getRealtimeStatus();
int flag = o2status - o1status;
if (flag == 0) {
// 再按拥堵时长排序
Long o1duration = o1.getDuration();
Long o2Duration = o2.getDuration();
long res = o2Duration - o1duration;
return (int) res;
}
return flag;
}
}
private void buildRidData(AbnormalCrossListVO abnormalCrossListVO, String endCrossId, private void buildRidData(AbnormalCrossListVO abnormalCrossListVO, String endCrossId,
List<Integer> spilloverDirList) { List<Integer> spilloverDirList) {
List<List<Double>> ridLocationList = new ArrayList<>(); List<List<Double>> ridLocationList = new ArrayList<>();
......
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