`

FE1

阅读更多
/**
 * 添加预案关联
 * @author ecy
 */	
	@Override
	public void addPlanGroupMap(Connection conn,PlanInfo planInfo) throws Exception {
		PreparedStatement pst = null;
		
		String addPlanGroupMapByPersonSQL = "insert into SNOW_PLAN_PERSON_MAP (GROUP_ID,PERSON_ID) VALUES(?,?)";
		pst = DBCommon.getPsm(conn, addPlanGroupMapByPersonSQL);
		if(planInfo.getPlanGroupList()!=null && planInfo.getPlanGroupList().size()>0){
			for(int i=0;i<planInfo.getPlanGroupList().size();i++){
				pst.setString(1, planInfo.getPlanGroupList().get(i).getGroupID());
				if(planInfo.getPlanGroupList().get(i).getPersonList()!=null && planInfo.getPlanGroupList().get(i).getPersonList().size()>0){
					for(int j=0;j<planInfo.getPlanGroupList().get(i).getPersonList().size();j++){
						pst.setString(2, planInfo.getPlanGroupList().get(i).getPersonList().get(j).getPersonID());
						pst.addBatch();
					}
				}
			}
			pst.executeBatch();
		}
		
		String addPlanGroupMapByCarSQL = "insert into SNOW_PLAN_CAR_MAP (GROUP_ID,CAR_ID) VALUES (?,?)";
		pst = DBCommon.getPsm(conn, addPlanGroupMapByCarSQL);
		if(planInfo.getPlanGroupList()!=null && planInfo.getPlanGroupList().size()>0){
			for(int i=0;i<planInfo.getPlanGroupList().size();i++){
				pst.setString(1, planInfo.getPlanGroupList().get(i).getGroupID());
				if(planInfo.getPlanGroupList().get(i).getCarList()!=null && planInfo.getPlanGroupList().get(i).getCarList().size()>0){
					for(int j=0;j<planInfo.getPlanGroupList().get(i).getCarList().size();j++){
						pst.setString(2, planInfo.getPlanGroupList().get(i).getCarList().get(j).getCarID());
						pst.addBatch();
					}
				}
			}
			pst.executeBatch();
		}
		
		String addPlanGroupMapByCommandCarSQL = "insert into SNOW_PLAN_COMMAND_CAR_MAP (GROUP_ID,COMMAND_CAR_ID) VALUES (?,?)";
		pst = DBCommon.getPsm(conn, addPlanGroupMapByCommandCarSQL);
		if(planInfo.getPlanGroupList()!=null && planInfo.getPlanGroupList().size()>0){
			for(int i=0;i<planInfo.getPlanGroupList().size();i++){
				pst.setString(1, planInfo.getPlanGroupList().get(i).getGroupID());
				if(planInfo.getPlanGroupList().get(i).getCommandCarList()!=null && planInfo.getPlanGroupList().get(i).getCommandCarList().size()>0){
					for(int j=0;j<planInfo.getPlanGroupList().get(i).getCommandCarList().size();j++){
						pst.setString(2, planInfo.getPlanGroupList().get(i).getCommandCarList().get(j).getCommandCarID());
						pst.addBatch();
					}
				}
			}
			pst.executeBatch();
		}
		
		String addPlanGroupMapByStockSQL = "insert into SNOW_PLAN_STOCK_MAP (GROUP_ID,STOCKID) VALUES (?,?)";
		pst = DBCommon.getPsm(conn, addPlanGroupMapByStockSQL);
		if(planInfo.getPlanGroupList()!=null && planInfo.getPlanGroupList().size()>0){
			for(int i=0;i<planInfo.getPlanGroupList().size();i++){
				pst.setString(1, planInfo.getPlanGroupList().get(i).getGroupID());
				if(planInfo.getPlanGroupList().get(i).getStockList()!=null && planInfo.getPlanGroupList().get(i).getStockList().size()>0){
					for(int j=0;j<planInfo.getPlanGroupList().get(i).getStockList().size();j++){
						pst.setString(2, planInfo.getPlanGroupList().get(i).getStockList().get(j).getStockID());
						pst.addBatch();
					}
				}
			}
			pst.executeBatch();
		}
		
		String addPlanGroupMapByAreaSQL = "insert into SNOW_PLAN_GROUP_AREA (ROAD_CODE,ROAD_NAME,direction,STAKE_START,STAKE_END,REMARKS,group_id,group_area_id) VALUES (?,?,?,?,?,?,?,?)";
		pst = DBCommon.getPsm(conn, addPlanGroupMapByAreaSQL);
		if(planInfo.getPlanGroupList()!=null && planInfo.getPlanGroupList().size()>0){
			for(int i=0;i<planInfo.getPlanGroupList().size();i++){
				if(planInfo.getPlanGroupList().get(i).getGroupAreaList()!=null && planInfo.getPlanGroupList().get(i).getGroupAreaList().size()>0){
					for(int j=0;j<planInfo.getPlanGroupList().get(i).getGroupAreaList().size();j++){
						String id = IDGenerator.generateUID();
						pst.setString(1, planInfo.getPlanGroupList().get(i).getGroupAreaList().get(j).getRoadCode());
						pst.setString(2, planInfo.getPlanGroupList().get(i).getGroupAreaList().get(j).getRoadName());
						pst.setString(3, planInfo.getPlanGroupList().get(i).getGroupAreaList().get(j).getDirection());
						pst.setString(4, planInfo.getPlanGroupList().get(i).getGroupAreaList().get(j).getStartStake());
						pst.setString(5, planInfo.getPlanGroupList().get(i).getGroupAreaList().get(j).getEndStake());
						pst.setString(6, planInfo.getPlanGroupList().get(i).getGroupAreaList().get(j).getRemarks());
						pst.setString(7, planInfo.getPlanGroupList().get(i).getGroupID());
						pst.setString(8, id);
						pst.addBatch();
					}
				}
			}
			pst.executeBatch();
		}
		
		if(pst!=null){
			pst.close();
		}
		
	}
	
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics