import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
public abstract class WizardPageUtil extends VBox{
Button priorButton = new Button("上一步");
Button nextButton = new Button("下一步");
Button cancelButton = new Button("取消");
Button finishButton = new Button("完成");
public WizardPageUtil() {
super();
}
public WizardPageUtil(double arg0, Node... arg1) {
super(arg0, arg1);
}
public WizardPageUtil(double arg0) {
super(arg0);
}
public WizardPageUtil(Node... arg0) {
super(arg0);
}
protected WizardPageUtil(String title) {
setSpacing(5);
Region spring = new Region();
VBox.setVgrow(spring, Priority.ALWAYS);
getChildren().addAll(new Text(title),getContent(), spring, getButtons());
priorButton.setOnAction(event -> priorPage());
nextButton.setOnAction(event -> nextPage());
cancelButton.setOnAction(event -> getWizard().cancel());
finishButton.setOnAction(event -> getWizard().finish());
}
HBox getButtons() {
Region spring = new Region();
HBox.setHgrow(spring, Priority.ALWAYS);
HBox buttonBar = new HBox(5);
cancelButton.setCancelButton(true);
finishButton.setDefaultButton(true);
buttonBar.getChildren().addAll(spring, priorButton, nextButton, cancelButton, finishButton);
return buttonBar;
}
public abstract Parent getContent();
boolean hasNextPage() {
return getWizard().hasNextPage();
}
boolean hasPriorPage() {
return getWizard().hasPriorPage();
}
void nextPage() {
getWizard().nextPage();
}
void priorPage() {
getWizard().priorPage();
}
void navTo(String id) {
getWizard().navTo(id);
}
WizardUtil getWizard() {
return (WizardUtil) getParent();
}
public void manageButtons() {
if (!hasPriorPage()) {
priorButton.setDisable(true);
}
if (!hasNextPage()) {
nextButton.setDisable(true);
}
if(nextButton.isDisable()){
finishButton.setDisable(false);
}else{
finishButton.setDisable(true);
}
}
}
import java.util.Stack;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.layout.StackPane;
public class WizardUtil extends StackPane{
private static final int UNDEFINED = -1;
private ObservableList<WizardPageUtil> pages = FXCollections.observableArrayList();
private Stack<Integer> history = new Stack<>();
protected int curPageIdx = UNDEFINED;
protected WizardUtil(WizardPageUtil... nodes) {
pages.addAll(nodes);
navTo(0);
}
public void nextPage() {
if (hasNextPage()) {
navTo(curPageIdx + 1);
}
}
void priorPage() {
if (hasPriorPage()) {
navTo(history.pop(), false);
}
}
protected boolean hasNextPage() {
return (curPageIdx < pages.size() - 1);
}
boolean hasPriorPage() {
return !history.isEmpty();
}
void navTo(int nextPageIdx, boolean pushHistory) {
if (nextPageIdx < 0 || nextPageIdx >= pages.size()) return;
if (curPageIdx != UNDEFINED) {
if (pushHistory) {
history.push(curPageIdx);
}
}
WizardPageUtil nextPage = pages.get(nextPageIdx);
curPageIdx = nextPageIdx;
getChildren().clear();
getChildren().add(nextPage);
nextPage.manageButtons();
}
protected void navTo(int nextPageIdx) {
navTo(nextPageIdx, true);
}
void navTo(String id) {
if (id == null) {
return;
}
pages.stream()
.filter(page -> id.equals(page.getId()))
.findFirst()
.ifPresent(page ->
navTo(pages.indexOf(page))
);
}
public void finish() {
}
public void cancel() {
}
}
public class HandleInterfaceDataWizardUtil extends WizardUtil {
Stage owner;
String rst="";
static Date planDate;
Long schPlanId;
String ifIdStr;
private IFimsPlanService planService = FimsServiceFactory.getService(IFimsPlanService.class);
static HandleInterfaceDataFront nhidf=new HandleInterfaceDataFront(FPcontroller.date);
static HandleInterfaceDataBack nhidb;
public HandleInterfaceDataWizardUtil(Stage owner,Date date) {
super(nhidf,nhidb);
nhidf.datePicker.setValue(LocalDateConvert.DateToDateTimePickerValue(date));
nhidf.cb_hx.setSelected(false);
nhidf.cb_kg.setSelected(false);
this.owner = owner;
}
public void nextPage(){
super.pages.remove(1);
nhidb=new HandleInterfaceDataBack();
super.pages.add(nhidb);
if(nhidf.datePicker.getValue()==null){
MessageDialogInfo.openWarning("提示", "请填入航班计划日期", null, ButtonType.OK);
}else if(nhidf.datePicker.getValue().isBefore(LocalDate.now())){
MessageDialogInfo.openWarning("提示", "计划日期应该大于当前日期", null, ButtonType.OK);
}
else if(!nhidf.cb_hx.isSelected()&&!nhidf.cb_kg.isSelected()){
MessageDialogInfo.openWarning("提示", "请选择数据接口类型", null, ButtonType.OK);
}
else if (hasNextPage()) {
nhidb=new HandleInterfaceDataBack();
navTo(curPageIdx + 1);
}
}
public void finish() {
submitInfo();
owner.close();
}
public void cancel() {
owner.close();
}
private void submitInfo(){
Alert a=MessageDialogInfo.openInformation("提示", "接口数据处理...", null, ButtonType.OK);
final Button b_ok=(Button)a.getDialogPane().lookupButton(ButtonType.OK);
b_ok.setText("转入后台");
a.show();
b_ok.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
HandleInterfaceDataDialog.stage.hide();
a.close();
}
});
rst=planService.handleInterfaceDataForTao(nhidb.flightDate,nhidb.getIfIdStr());
a.close();
if(!(rst==null||rst.trim().equals(""))){
MessageDialogInfo.openInformation("提示", rst, null, ButtonType.OK);
}
}
}
import java.util.Date;
import controller.FPcontroller;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.Parent;
import javafx.scene.control.CheckBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Separator;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import util.LocalDateConvert;
public class HandleInterfaceDataFront extends WizardPageUtil{
VBox root;
Text t1;
Text t2;
Text t3;
Text t4;
/**
* 航信数据
*/
CheckBox cb_hx;
/**
* 空管计划报
*/
CheckBox cb_kg;
static DatePicker datePicker;
static Boolean hx=false;
static Boolean kg=false;
private Date date;
public HandleInterfaceDataFront(Date date) {
super("");
this.date=date;
}
@Override
public Parent getContent() {
root=new VBox();
createCheckBox();
createText();
createDatePicker();
HBox h1=new HBox();
h1.getChildren().addAll(t2,datePicker);
HBox h2=new HBox();
h2.getChildren().addAll(t3,cb_hx);
HBox h3=new HBox();
h3.getChildren().add(cb_kg);
Separator s=new Separator();
s.setOrientation(Orientation.HORIZONTAL);
s.setPrefWidth(600);
s.setMinWidth(600);
root.getChildren().addAll(t1,h1,h2,h3,s,t4);
root.setPadding(new Insets(10, 0, 0, 10));
root.setSpacing(20);
t1.setFont(Font.font(13));
h3.setPadding(new Insets(0, 0, 0, 83));
init();
return root;
}
public void createText(){
t1=new Text("欢迎使用\"接口数据处理向导\",帮助您完成数据接口校正航班工作。");
t2=new Text("航班计划日期:");
t3=new Text("数据接口类型:");
t4=new Text("要继续执行请点击\"下一步\"。");
}
public void createDatePicker(){
datePicker=new DatePicker(LocalDateConvert.UDateToLocalDate(HandleInterfaceDataDialog.date));
}
public void createCheckBox(){
cb_hx=new CheckBox("航信数据(提供订单系统中的航班信息)");
cb_kg=new CheckBox("空管计划报(提供计划航班信息)");
}
public void init(){
cb_hx.setSelected(false);
cb_kg.setSelected(false);
hx=true;
cb_hx.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) {
if(arg2){
hx=true;
}else{
hx=false;
}
}
});
cb_kg.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if(newValue){
kg=true;
}else{
kg=false;
}
}
});
}
}
import java.util.Date;
import java.util.List;
import com.taocares.naoms.fims.client.remote.service.FimsServiceFactory;
import com.taocares.naoms.fims.dto.config.InterfaceDto;
import com.taocares.naoms.fims.dto.flight.IfParsedDataDto;
import com.taocares.naoms.service.IFimsConfigQueryService;
import com.taocares.naoms.service.IFimsPlanQueryService;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Orientation;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.control.Separator;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import naoms.client.model.plan.vo.InterfaceDataVo;
import util.FimsConst;
import util.LocalDateConvert;
public class HandleInterfaceDataBack extends WizardPageUtil{
Text t;
int inCount =0;
int outCount =0;
int sumCount = 0;
private TableView<InterfaceDataVo> table;
public static ObservableList<IfParsedDataDto> ifParsedDataDtos=FXCollections.observableArrayList();
public static ObservableList<InterfaceDataVo> interfaceDataVos=FXCollections.observableArrayList();
private TableColumn<InterfaceDataVo, String> tc_1;
private TableColumn<InterfaceDataVo, String> tc_2;
private TableColumn<InterfaceDataVo, String> tc_3;
private TableColumn<InterfaceDataVo, String> tc_4;
private TableColumn<InterfaceDataVo, String> tc_5;
private TableColumn<InterfaceDataVo, String> tc_6;
public Date flightDate=LocalDateConvert.LocalDateToUdate(HandleInterfaceDataFront.datePicker.getValue());
private String ifIdStr;
private ObservableList<InterfaceDto> interfaceDtos=FXCollections.observableArrayList();
private ObservableList<IfParsedDataDto> list=FXCollections.observableArrayList();
VBox vbox;
HBox hbox;
public HandleInterfaceDataBack() {
super("");
}
@Override
public Parent getContent() {
createRoot();
return vbox;
}
public void createRoot(){
vbox=new VBox();
vbox.setId("vbox");
creatTableView();
init();
loadtable(flightDate);
createText();
Separator s=new Separator();
s.setId("separator");
s.setOrientation(Orientation.HORIZONTAL);
vbox.getChildren().addAll(hbox,table,s);
vbox.getStylesheets().add(getClass().getResource("/naoms/client/ui/plan/view/css/NewHandleInterfaceDataBack.css").toString());
}
public void createText(){
Text t1=new Text("进港航班:");
Text t2=new Text(""+inCount);
Text t3=new Text(" 出港航班:");
Text t4=new Text(""+outCount);
Text t5=new Text(" 航班总数为:");
Text t6=new Text(""+sumCount);
hbox=new HBox();
hbox.getChildren().addAll(t1,t2,t3,t4,t5,t6);
hbox.setSpacing(15);
t2.setId("t");
t4.setId("t");
t6.setId("t");
}
public void creatTableView(){
table=new TableView<InterfaceDataVo>();
table.setId("table");
tc_1=new TableColumn<InterfaceDataVo, String>("接口类型");
tc_2=new TableColumn<InterfaceDataVo, String>("进出港");
tc_3=new TableColumn<InterfaceDataVo, String>("航班名称");
tc_4=new TableColumn<InterfaceDataVo, String>("机型");
tc_5=new TableColumn<InterfaceDataVo, String>("机号");
tc_6=new TableColumn<InterfaceDataVo, String>("航线信息");
tc_1.setSortable(false);
tc_2.setSortable(false);
tc_3.setSortable(false);
tc_4.setSortable(false);
tc_5.setSortable(false);
tc_6.setSortable(false);
tc_1.setCellValueFactory(new PropertyValueFactory<InterfaceDataVo, String>("interfacetype"));
tc_2.setCellValueFactory(new PropertyValueFactory<InterfaceDataVo, String>("come_go"));
tc_3.setCellValueFactory(new PropertyValueFactory<InterfaceDataVo, String>("flightName"));
tc_4.setCellValueFactory(new PropertyValueFactory<InterfaceDataVo, String>("carftType"));
tc_5.setCellValueFactory(new PropertyValueFactory<InterfaceDataVo, String>("carftNo"));
tc_6.setCellValueFactory(new PropertyValueFactory<InterfaceDataVo, String>("route"));
table.getColumns().addAll(tc_1,tc_2,tc_3,tc_4,tc_5,tc_6);
}
public void init(){
flightDate=LocalDateConvert.LocalDateToUdate(HandleInterfaceDataFront.datePicker.getValue());
interfaceDtos=FXCollections.observableArrayList(FimsServiceFactory.getService(IFimsConfigQueryService.class).loadInterfaceAll());
if (interfaceDtos == null) {
interfaceDtos =FXCollections.observableArrayList();
}else{
for(InterfaceDto interfaceDto : interfaceDtos){
if(FimsConst.INTERFACE_DYNTELEX.equals(interfaceDto.getName())){
interfaceDtos.remove(interfaceDto);
break;
}
}
}
StringBuffer ifDataIdStr = new StringBuffer();
if(HandleInterfaceDataFront.hx){
ifDataIdStr.append(interfaceDtos.get(0).getId()).append(",");
}
if(HandleInterfaceDataFront.kg){
ifDataIdStr.append(interfaceDtos.get(1).getId()).append(",");
}
ifIdStr=ifDataIdStr.toString();
}
public void loadtable(Date flightDate) {
if("".equals(ifIdStr)||ifIdStr==null){
return ;
}else{
String[] ifIds = ifIdStr.split(",");
ifParsedDataDtos=FXCollections.observableArrayList();
interfaceDataVos=FXCollections.observableArrayList();
ifParsedDataDtos.clear();
interfaceDataVos.clear();
if(table.getItems()!=null&&table.getItems().size()!=0){
table.getItems().clear();
}
for(String interfaceId : ifIds){
List<IfParsedDataDto> temp = FimsServiceFactory.getService(IFimsPlanQueryService.class).loadIfParsedData(flightDate,Long.parseLong(interfaceId));
if( temp!= null&&!temp.isEmpty()){
ifParsedDataDtos.addAll(temp);
}
}
if (ifParsedDataDtos.isEmpty()) {
ifParsedDataDtos = FXCollections.observableArrayList();
}
if(interfaceDataVos.isEmpty()){
interfaceDataVos=FXCollections.observableArrayList();
}
for (IfParsedDataDto idd : ifParsedDataDtos) {
InterfaceDataVo idv=new InterfaceDataVo();
idv.setCarftNo(idd.getCraftNo());
idv.setCarftType(idd.getCraftType());
idv.setFlightName(idd.getFlightName());
idv.setInterfacetype(idd.getInterfaceName());
idv.setRoute(idd.getRoute());
if(idd!=null&&idd.isArrFlight()!=null){
idv.setCome_go(idd.isArrFlight()?"进":"出");
}
interfaceDataVos.add(idv);
}
table.setItems(interfaceDataVos);
for (IfParsedDataDto ifParsedDataDto : ifParsedDataDtos) {
if(ifParsedDataDto.isArrFlight()==null){
continue;
}else if(ifParsedDataDto.isArrFlight()){
inCount++;
}else{
outCount++;
}
}
sumCount = inCount + outCount;
}
}
public String getIfIdStr() {
return ifIdStr;
}
public void setIfIdStr(String ifIdStr) {
this.ifIdStr = ifIdStr;
}
}
import java.util.Date;
import com.sun.glass.ui.Window;
import controller.FPcontroller;
import javafx.scene.Scene;
import javafx.scene.control.ButtonType;
import javafx.stage.Modality;
import javafx.stage.Stage;
import util.MessageDialogInfo;
/**
* 接口数据处理
* @author 赵乔石
*
*/
public class HandleInterfaceDataDialog {
static Stage stage;
static Date date;
public HandleInterfaceDataDialog() {
super();
date=FPcontroller.date;
if(date.before(new Date())){
MessageDialogInfo.openWarning("提示", "计划日期应该大于当前日期", null, ButtonType.OK);
return;
}
stage=new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.setTitle("接口数据处理");
stage.setResizable(false);
stage.setScene(new Scene(new HandleInterfaceDataWizardUtil(stage,date), 600, 400));
stage.show();
}
}