| | |
| | | import com.zy.acs.manager.core.service.astart.CodeNodeType; |
| | | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.entity.Route; |
| | | import com.zy.acs.manager.manager.service.CodeGapService; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | | import com.zy.acs.manager.manager.service.RouteService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | /** |
| | | * Created by vincent on 12/9/2024 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class RouteGenerator { |
| | | |
| | |
| | | @Autowired |
| | | private CodeGapService codeGapService; |
| | | |
| | | public List<Route> generateRoutes(String[][] codeMatrix) { |
| | | List<Route> routes = new ArrayList<>(); |
| | | public List<String> generateRoutes(String[][] codeMatrix) { |
| | | List<String> list = new ArrayList<>(); |
| | | |
| | | int rows = codeMatrix.length; |
| | | int cols = codeMatrix[0].length; |
| | |
| | | String rightCodeData = codeMatrix[i][j + 1]; |
| | | if (!Cools.isEmpty(rightCodeData) && !CodeNodeType.NONE.val.equals(rightCodeData)) { |
| | | Code rightCode = codeService.selectByData(rightCodeData); |
| | | list.add(currCode.getData() + "-" + rightCode.getData()); |
| | | routeService.createRouteByCode(currCode, rightCode, 0, null); |
| | | codeGapService.createCodeGapByCode(currCode, rightCode, null); |
| | | |
| | | log.info(currCode.getData() + "-" + rightCode.getData() + " [finished]"); |
| | | } |
| | | } |
| | | |
| | |
| | | String bottomCodeData = codeMatrix[i + 1][j]; |
| | | if (!Cools.isEmpty(bottomCodeData) && !CodeNodeType.NONE.val.equals(bottomCodeData)) { |
| | | Code bottomCode = codeService.selectByData(bottomCodeData); |
| | | list.add(currCode.getData() + "-" + bottomCode.getData()); |
| | | routeService.createRouteByCode(currCode, bottomCode, 0, null); |
| | | codeGapService.createCodeGapByCode(currCode, bottomCode, null); |
| | | |
| | | log.info(currCode.getData() + "-" + bottomCode.getData() + " [finished]"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return routes; |
| | | return list; |
| | | } |
| | | |
| | | |