java 数据结构查询,与处理

作者:LoveEmperor-王子様

vo:

public class ReqParkingLotInfoDto extends BaseMobileDto{


    public ReqParkingLotInfoDto(int ret, String msg) {
        super(ret, msg);
        // TODO Auto-generated constructor stub
    }

    private Integer parkId;
    private String name;
    private Integer berths;
    private Integer tierLength;// 停车场层数
    private List<CarportInfoItem> carportInfo;// 车位信息
    
    public Integer getParkId() {
        return parkId;
    }

    public void setParkId(Integer parkId) {
        this.parkId = parkId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getBerths() {
        return berths;
    }

    public void setBerths(Integer berths) {
        this.berths = berths;
    }

    public Integer getTierLength() {
        return tierLength;
    }

    public void setTierLength(Integer tierLength) {
        this.tierLength = tierLength;
    }

    public List<CarportInfoItem> getCarportInfo() {
        return carportInfo;
    }

    public void setCarportInfo(List<CarportInfoItem> carportInfo) {
        this.carportInfo = carportInfo;
    }
    
}

controller:

@Controller
@RequestMapping(value="/mobileApi")

public class MobileParkingLotController {


    @ResponseBody
    @RequestMapping(value = "/getParkingLotInfo.fgl")   
    public ReqParkingLotInfoDto reqParkingLotInfo(MobileParkingLotVo vo){
        return mobileParkingLotService.getParkingLotInfo(vo);
    }
}

}

public interface IMobileParkingLotService {
    /**
     * 停车场实时信息查询
     * @param vo
     * @return
     */
    ReqParkingRealStatusDto dealParkingRealStatusReq(MobileSearchParkingVo vo);
    
    
    /**
     * 停车场车位地图
     * @param vo
     * @return
     */
    ReqParkingLotInfoDto getParkingLotInfo(MobileParkingLotVo vo);
}

service:

// 停车场车位地图   
    public ReqParkingLotInfoDto getParkingLotInfo(MobileParkingLotVo vo) {
        ReqParkingLotInfoDto dto=new ReqParkingLotInfoDto(0,"ok");
        
        JdbcMySql jdbc=new JdbcMySql();
        List<CarportInfoItem> carportInfos = new ArrayList<CarportInfoItem>();
        List<SubTierInfoItem> subTierInfos = new ArrayList<SubTierInfoItem>();
        SubTierInfoItem subTierInfo = new SubTierInfoItem();
        CarportInfoItem carportInfo = new CarportInfoItem();
                
        List<HashMap<String, Object>> parkingList = jdbc.query(String.format(
                "select ParkingId,ParkingNum,OccupiedFlag,StopType from urpcs_parkingrealtimestatus where ParkingAreaId=%d",
                vo.getParkId()));
        
//        List<HashMap<String, Object>> AppliedCar = jdbc.query(String.format(
//                "select ParkingId,OccupiedFlag,StopType from urpcs_parkingrealtimestatus where ParkingNum='%s'",
//                vo.getParkingNum()));
    
        if(parkingList!=null&&parkingList.size()>0){
            List<ParkingLotInfoItem> parkingLotInfos = new ArrayList<ParkingLotInfoItem>();
            
            for(int i = 0; i < parkingList.size(); i++) {
                ParkingLotInfoItem parkingLotInfo = new ParkingLotInfoItem();
                
                parkingLotInfo.setOccupied((int)parkingList.get(i).get("OccupiedFlag") );
                parkingLotInfo.setSpotId((String)parkingList.get(i).get("ParkingNum"));
                parkingLotInfo.setApplied(0);
//                if (AppliedCar.size() >0 && AppliedCar != null) {
////                    if ((int)AppliedCar.get(0).get("StopType") == 13 ) {
////                        parkingLotInfo.setApplied(1);
////                    }
//                }else {
                    parkingLotInfo.setApplied(0);
//                }
                if ((int)parkingList.get(i).get("StopType") == 13) {
                    parkingLotInfo.setReserved(1);
                }else{
                    parkingLotInfo.setReserved(0);
                }
//                parkingLotInfo.setReserved((int) parkingList.get(i).get("StopType"));
                parkingLotInfos.add(parkingLotInfo);
            }
            subTierInfo.setParkingLotInfo(parkingLotInfos);
            subTierInfos.add(subTierInfo);
            carportInfo.setSubTierInfo(subTierInfos);
            carportInfos.add(carportInfo);
            dto.setCarportInfo(carportInfos);

        }
        return dto;
    }

猜你喜欢

转载自blog.csdn.net/qq_31424825/article/details/79622526