|
|
@@ -1,13 +1,26 @@
|
|
|
package com.railway.web.controller.business.baseinfo;
|
|
|
|
|
|
+import com.railway.business.baseinfo.domain.BusLine;
|
|
|
+import com.railway.business.baseinfo.domain.BusStation;
|
|
|
+import com.railway.business.baseinfo.domain.enums.XingbieEnum;
|
|
|
+import com.railway.business.baseinfo.domain.vo.CascadeDeptVo;
|
|
|
+import com.railway.business.baseinfo.domain.vo.CascadeLineVo;
|
|
|
+import com.railway.business.baseinfo.domain.vo.CascadeStationVo;
|
|
|
+import com.railway.business.baseinfo.domain.vo.CascadeXingbieVo;
|
|
|
+import com.railway.business.baseinfo.service.IBusLineService;
|
|
|
+import com.railway.business.baseinfo.service.IBusStationService;
|
|
|
import com.railway.common.core.controller.BaseController;
|
|
|
import com.railway.common.core.domain.AjaxResult;
|
|
|
+import com.railway.common.core.domain.entity.SysDept;
|
|
|
import com.railway.common.core.page.TableDataInfo;
|
|
|
-import com.railway.business.baseinfo.domain.BusStation;
|
|
|
-import com.railway.business.baseinfo.service.IBusStationService;
|
|
|
+import com.railway.common.utils.StringUtils;
|
|
|
+import com.railway.system.service.ISysDeptService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import javax.validation.Valid;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
@@ -29,9 +42,15 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
public class BusStationController extends BaseController {
|
|
|
|
|
|
private final IBusStationService busStationService;
|
|
|
+ private final ISysDeptService deptService;
|
|
|
+ private final IBusLineService busLineService;
|
|
|
|
|
|
- public BusStationController(IBusStationService busStationService) {
|
|
|
+ public BusStationController(IBusStationService busStationService,
|
|
|
+ ISysDeptService deptService,
|
|
|
+ IBusLineService busLineService) {
|
|
|
this.busStationService = busStationService;
|
|
|
+ this.deptService = deptService;
|
|
|
+ this.busLineService = busLineService;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "新增")
|
|
|
@@ -69,4 +88,71 @@ public class BusStationController extends BaseController {
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "基础数据级联")
|
|
|
+ @GetMapping(value = "cascade")
|
|
|
+ public TableDataInfo cascade() {
|
|
|
+ // 构建机构树
|
|
|
+ List<SysDept> depts = deptService.selectDeptList();
|
|
|
+ List<SysDept> deptTrees = deptService.buildDeptTree(depts);
|
|
|
+ List<CascadeDeptVo> cascadeDeptList = busStationService.buildCascadeDept(deptTrees);
|
|
|
+ Map<Long, CascadeDeptVo> cascadeDeptVoMap = new LinkedHashMap<>();
|
|
|
+ busStationService.cascadeDeptMap(cascadeDeptList, cascadeDeptVoMap);
|
|
|
+ //
|
|
|
+ List<BusLine> lines = busLineService.getList();
|
|
|
+ Map<Long, CascadeLineVo> cascadeLineMap = new LinkedHashMap<>();
|
|
|
+ for(BusLine line : lines){
|
|
|
+ CascadeDeptVo cascadeDept = cascadeDeptVoMap.get(line.getDeptId());
|
|
|
+ if(null == cascadeDept){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<CascadeLineVo> lineList = cascadeDept.getLineList();
|
|
|
+ if(null == lineList){
|
|
|
+ lineList = new ArrayList<>();
|
|
|
+ cascadeDept.setLineList(lineList);
|
|
|
+ }
|
|
|
+ CascadeLineVo cascadeLine = new CascadeLineVo();
|
|
|
+ cascadeLine.setLineId(line.getLineId());
|
|
|
+ cascadeLine.setLabel(line.getLineName());
|
|
|
+ List<CascadeXingbieVo> xingbieList = new ArrayList<>();
|
|
|
+ for (XingbieEnum investor : XingbieEnum.values()) {
|
|
|
+ CascadeXingbieVo xingbieVo = new CascadeXingbieVo();
|
|
|
+ xingbieVo.setXingbie(investor.getCode());
|
|
|
+ xingbieVo.setLabel(investor.getInfo());
|
|
|
+ xingbieList.add(xingbieVo);
|
|
|
+ }
|
|
|
+ cascadeLine.setXingbieList(xingbieList);
|
|
|
+ lineList.add(cascadeLine);
|
|
|
+ cascadeLineMap.put(line.getLineId(), cascadeLine);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<BusStation> stations = busStationService.getList();
|
|
|
+ for(BusStation station : stations){
|
|
|
+ CascadeLineVo cascadeLine = cascadeLineMap.get(station.getLineId());
|
|
|
+ if(null == cascadeLine){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String xingbie = station.getXingbie();
|
|
|
+ if(StringUtils.isEmpty(xingbie)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<CascadeXingbieVo> xingbieList = cascadeLine.getXingbieList();
|
|
|
+ Map<String, CascadeXingbieVo> xingbieVoMap = new LinkedHashMap<>();
|
|
|
+ for(CascadeXingbieVo xingbieVo : xingbieList){
|
|
|
+ xingbieVoMap.put(xingbieVo.getXingbie(), xingbieVo);
|
|
|
+ }
|
|
|
+ CascadeXingbieVo cascadeXingbie = xingbieVoMap.get(xingbie);
|
|
|
+ List<CascadeStationVo> stationList = cascadeXingbie.getStationList();
|
|
|
+ if(null == stationList){
|
|
|
+ stationList = new ArrayList<>();
|
|
|
+ cascadeXingbie.setStationList(stationList);
|
|
|
+ }
|
|
|
+ CascadeStationVo stationVo = new CascadeStationVo();
|
|
|
+ stationVo.setStationId(station.getStationId());
|
|
|
+ stationVo.setLabel(station.getStationName());
|
|
|
+ stationList.add(stationVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return getDataTable(cascadeDeptList);
|
|
|
+ }
|
|
|
+
|
|
|
}
|