zoukankan      html  css  js  c++  java
  • 石家庄地铁查询

                       一、需求   :地铁(石家庄地铁)线路查询                                         

                    二、       学生:宋子健

                      合作对象:洪鼎淇

                      时间记录日志:  

    日期

    开始时间

    结束时间

    中断时间

    净时间

    活动

    2019/3/30

    10:00

    14:00

     13:00

    3.5小时

    web界面

    地铁地图绘制

    2019/4/2

    7:00

    13:00

     12:00

    4.5小时

    优化界面

    构建数据库

    实现基本线路查询

    2019/4/3

    18:00

    23:00

     20:40

    3小时

    优化查询功能

                  三、程序:

                  

    //数据处理层
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
      <%@ page language="java" import="java.util.*"%>
      <%@ page language="java" import="com.hdq.service.ClassService"%>
      <%@ page language="java" import="com.hdq.entity.LineInfo"%>
      <%@ page language="java" import="com.hdq.entity.Linenum" %>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>数据处理层</title>
    
    </head>
    <body>
    <%
    	request.setCharacterEncoding("utf-8");
    	//--------------------------------
    	String start=request.getParameter("start");
    	String end=request.getParameter("end");
    	ClassService service=new ClassService();
    	@SuppressWarnings("unchecked")
    	List<Linenum> ln=(List<Linenum>)service.list("linenum", new String[]{"linenum"},new Linenum().getClass());
    	int g_slinenum=-1,g_elinenum=-1;
    	int g_snum=-1,g_enum=-1;
    	List<LineInfo> pathInfo=new ArrayList<LineInfo>();
    	c:for(Linenum it:ln)
    	{
    		int g_count=0;
    		@SuppressWarnings("unchecked")
    		List<LineInfo> info=(List<LineInfo>)service.list("line"+it.getLinenum(), new String[]{"linenum","name"},new LineInfo().getClass());
    		
    		for(LineInfo it1:info)
    		{
    			
    			if(it1.getName().equals(start))
    			{
    				
    				//找到相应的节点
    				g_slinenum=it.getLinenum();
    				g_snum=g_count;
    			}
    			if(it1.getName().equals(end))
    			{
    				g_elinenum=it.getLinenum();
    				g_enum=g_count;
    			}
    			if(g_elinenum!=-1&&g_slinenum!=-1)
    				break c;
    			g_count++;
    		}
    		
    	}
    	if(g_slinenum!=-1&&g_elinenum!=-1)
    	{
    		if(g_elinenum!=g_slinenum)
    		{
    			@SuppressWarnings("unchecked")
    			List<LineInfo> einfo=(List<LineInfo>)service.list("line"+g_elinenum, new String[]{"linenum","name"},new LineInfo().getClass());
    			@SuppressWarnings("unchecked")
    			List<LineInfo> sinfo=(List<LineInfo>)service.list("line"+g_slinenum, new String[]{"linenum","name"},new LineInfo().getClass());
    			int g_center=-1,g_ecenter=-1;
    			boolean fOutside=false,feOutside=false;
    			for(int i=0;i<sinfo.size();i++)
    			{
    				if(i==g_snum)
    					fOutside=true;
    				if(sinfo.get(i).getLinenum()==g_elinenum)
    				{
    					g_center=i;
    				}
    				if(g_center!=-1&&fOutside)
    					break;
    			}
    			
    			if(g_center<g_snum)
    			{
    				pathInfo=sinfo.subList(g_center, g_snum+1);
    				Collections.reverse(pathInfo);
    			}
    			else
    			{
    				
    				pathInfo=sinfo.subList(g_snum, g_center+1);
    			}
    			List<LineInfo> subPathInfo=new ArrayList<LineInfo>();
    			for(int i=0;i<einfo.size();i++)
    			{
    				
    				if(i==g_enum)
    					feOutside=true;
    				if(g_center<g_snum)
    				{
    					if(einfo.get(i).getName().equals(sinfo.get(g_snum).getName()))
    					{
    						g_ecenter=i;
    					}
    				}
    				else
    				{
    					if(einfo.get(i).getName().equals(sinfo.get(g_center).getName()))
    					{
    						g_ecenter=i;
    					}
    				}
    				if(g_ecenter!=-1&&feOutside)
    					break;
    			}
    			
    			if(g_ecenter<g_enum)
    			{
    				subPathInfo=einfo.subList(g_ecenter, g_enum+1);
    			}
    			else
    			{
    				subPathInfo=einfo.subList(g_enum, g_ecenter+1);
    				Collections.reverse(subPathInfo);
    			}
    			LineInfo pointInfo=new LineInfo();
    			pointInfo.setName("换乘"+g_elinenum+"号线路");
    			pathInfo.add(pointInfo);
    			pathInfo.addAll(subPathInfo);
    			
    		}
    		else
    		{
    			@SuppressWarnings("unchecked")
    			List<LineInfo> sinfo=(List<LineInfo>)service.list("line"+g_slinenum, new String[]{"linenum","name"},new LineInfo().getClass());
    			
    			if(g_snum>g_enum)
    			{
    				pathInfo=sinfo.subList(g_enum,g_snum+1);
    				Collections.reverse(pathInfo);
    			}
    			else pathInfo=sinfo.subList(g_snum,g_enum+1);
    		}
    		String info=new String("查询的信息如下:");
    		for(LineInfo it:pathInfo)
    		{
    			info+=it.getName();
    			if(!it.getName().equals(pathInfo.get(pathInfo.size()-1).getName()))
    			{
    				info+="-";
    			}
    		}
    		request.setAttribute("message",info);
    	}
    	else
    	{
    		request.setAttribute("message","查无信息,请确定你输入的起点和终点的名称正确");
    	}
    	request.getRequestDispatcher("subway.jsp").forward(request,response);
    %>
    </body>
    </html>
    //具体代码省略
     

    运行结果: 

     

  • 相关阅读:
    Python socket 基础(Server)
    Python socket 基础(Client)
    DOM
    Software Testing Concepts
    coroutine
    这一周~&&html+css的学习感悟
    充实的几天~
    时间不够用的感觉
    论文真痛苦
    焦躁的一周……
  • 原文地址:https://www.cnblogs.com/janeszj/p/10652306.html
Copyright © 2011-2022 走看看