MainPage.java
11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
package cn.csbr.app.gui.page;
import cn.csbr.app.Facerecognition.FaceWindow;
import cn.csbr.app.Long.HcgServer;
import cn.csbr.app.config.FxConfigure;
import cn.csbr.app.gui.GUIContext;
import cn.csbr.app.gui.component.common.ImageButton;
import cn.csbr.app.gui.handler.*;
import cn.csbr.app.gui.page.query.QueryPage;
import cn.csbr.app.gui.page.setting.SettingPage;
import cn.csbr.app.gui.util.DialogUtils;
import cn.csbr.app.model.RfidDataModel;
import cn.csbr.app.service.UseService;
import cn.csbr.app.service.ZjService;
import cn.csbr.springboot.dao.mapper.HcgOptionsMapper;
import cn.csbr.springboot.dao.mapper.MfcubestockdetailMapper;
import cn.hutool.core.date.DateUtil;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import static cn.csbr.app.gui.util.SystemUtils.getNavigationAreaMinHeight;
/**
* 登陆后首页
*/
@Component
public class MainPage extends AbstractPage {
private Label namelabel = new Label();
private Label timelabel = new Label();
private Label showCount=new Label();
private static Logger logger = LoggerFactory.getLogger(MainPage.class);
@Autowired
private FxConfigure fxConfigure;
@Autowired
private GUIContext guiContext;
@Autowired
private ToRejectMainPageHandler toRejectMainPageHandler;
@Autowired
private ToSettingPageHandler toSettingPageHandler;
@Autowired
private ToCheckMainHanlder toCheckMainHanlder;
@Autowired
private ToBanlanceHandler toBanlanceHandler;
@Autowired
private ToQueryHandler toQueryHandler;
@Autowired
private QueryPage queryPage;
@Autowired
private MfcubestockdetailMapper mfcubestockdetailMapper;
@Value("${jxqtitle}")
private String jxqtitle;
@Value("${youxqdays}")
private int youxqdays;
@Value("${jxqyellow}")
private int jxqyellow;
@Value("${timeOut}")
private String timeOut;
private Label lbjxqtxt=new Label("近效期(小于180天)");
private Label lbjxqdw=new Label("件");
private Label lbjxqsl=new Label("0");
private String returntimenum="0";//记录未归还的数量
//控制时间的变化
private boolean timeflag = false;
private RfidDataCallbackEventHandler rfidDataCallbackEventHandler = datas -> Platform.runLater(() -> ActionDoData(datas));
/**
* 第一排是用户名和密码 第二排是文字的名称 第三
* 批是按钮 第四排是公司名称版本号
*
* @return
*/
private Node createHeader() {
this.guiContext.setCurrentPage(this);
HBox headerBox = new HBox();
return headerBox;
}
private Node createActionArea() {
guiContext.setRfidDataCallbackEventHandler(this, this.rfidDataCallbackEventHandler);
GridPane grid = new GridPane();
grid.setId("");
//查询界面按钮,第一行
ImageButton toQueryBtn = new ImageButton(toQueryHandler, "toQueryBtn");
grid.add(toQueryBtn, 0, 0, 1, 1);
ImageButton toCheckBtn = new ImageButton(toCheckMainHanlder, "toCheckBtn");//toRejectBtn
grid.add(toCheckBtn, 1, 0, 1, 1);
ImageButton toBanlanceBtn = new ImageButton(toBanlanceHandler, "toBanlanceBtn");//toSettingBtn
grid.add(toBanlanceBtn, 0, 1, 1, 1);
ImageButton toRejectBtn = new ImageButton(toRejectMainPageHandler, "toRejectBtn");
grid.add(toRejectBtn, 1, 1, 1, 1);
toRejectBtn.setTranslateX(-112);
ImageButton toSettingBtn = new ImageButton(toSettingPageHandler, "toSettingBtn");
grid.add(toSettingBtn, 2, 1, 1, 1);
toSettingBtn.setTranslateX(-224);
grid.setGridLinesVisible(false);
//行距
grid.setHgap(5);
//列距
grid.setVgap(0);
grid.setMinHeight(400);
grid.setMaxHeight(400);
grid.setMaxWidth(700);
grid.setMinWidth(700);
grid.setStyle("-fx-text-alignment:center;-fx-alignment:center;");
grid.setTranslateX(130);
grid.setTranslateY(400);
if(isyc.equals("1")) {
hcgServer.start();
System.out.println("启动远程服务");
}
return grid;
}
@Value("${isyc}")
private String isyc;
@Value("${orgname}")
private String orgname;
@Autowired
private HcgServer hcgServer;
@Autowired
private CustomWindowNewDemo customWindowNewDemo;
//构建布局
@Override
protected Node constructNode() {
VBox root = new VBox();
root.setId("mainPage");
root.setPadding(new Insets(10, 10, 10, 10));
root.setMaxHeight(Double.MAX_VALUE);
ButtonBar buttonBar = new ButtonBar();
Region spacer = new Region();
VBox.setVgrow(spacer, Priority.ALWAYS);
Button button=new Button("测试弹框");
button.setOnAction((e)->{
root.getChildren().remove(button);
clearInbounduses();
getUseBackTabData("1");
customWindowNewDemo.start(guiContext.getPrimaryStage());
});
Button button2=new Button("测试人脸识别");
button2.setOnAction((e)->{
FaceWindow faceWindow=new FaceWindow();
faceWindow.start(guiContext.getPrimaryStage());
});
VBox vbjxqroot=new VBox();
HBox hbjxqhead=new HBox();
hbjxqhead.getChildren().addAll(lbjxqsl,lbjxqdw);
lbjxqsl.setStyle("-fx-text-fill: #00bea6;-fx-font-size: 3em");
lbjxqdw.setStyle("-fx-text-fill: black;-fx-font-size: 2em");
lbjxqdw.setTranslateY(8);
lbjxqdw.setTranslateX(8);
lbjxqtxt.setStyle("-fx-text-fill: black;-fx-font-size: 1.5em");
Label label=new Label();
label.setText(orgname);
label.setFont(Font.font("圆体",28));
label.setTranslateX(650);
label.setTranslateY(20);
label.setStyle("-fx-text-fill: white");
vbjxqroot.getChildren().add(hbjxqhead);
vbjxqroot.getChildren().add(lbjxqtxt);
vbjxqroot.setTranslateX(60);
vbjxqroot.setTranslateY(320);
label.setPickOnBounds(true);
//vbjxqroot.setPickOnBounds();
vbjxqroot.setOnMouseClicked(e->{
toQueryHandler.handle(e);
queryPage.GoExp();
});
root.getChildren().addAll(label);
button.setTranslateY(400);
button2.setTranslateY(400);
root.getChildren().addAll(button,button2,vbjxqroot);
// vbjxqroot.setStyle("-fx-background-color: black");
root.getChildren().addAll(createHeader());
root.getChildren().add(createActionArea());
root.setMinWidth(fxConfigure.getMinHeight());
root.setMinHeight(fxConfigure.getMinWidth());
root.setMaxHeight(fxConfigure.getMinWidth());
root.setMaxWidth(fxConfigure.getMinHeight());
root.getStylesheets().add("styles/mainpage.css");
//root.setStyle("-fx-background-color: red");
return root;
}
private synchronized void ActionDoData(String data)
{
logger.info("取货还货RFID获取数据");
List<RfidDataModel> datas = RfidDataModel.fromJson(data);
String rfidData="";
for (int i = 0; i < datas.size(); i++) {
rfidData= rfidData + "'" + datas.get(i).getRfidCd() + "'" + ",";
}
//清除原来的记录
clearInbounds();
//获取到取还弹窗的tab页数据
getUseBackTabData(datas.get(0), rfidData);
//弹出tab页
logger.info("开始进行弹出窗口");
popup(guiContext.getPrimaryStage());
Thread thread= new Thread(() -> {
saveInboundData();
});
thread.setDaemon(true);
thread.start();
}
//测试弹窗
//"[{"QUYUCD":"1","":"","RFIDCD":"E200001C110D01971730B176","CABINETCD":"A-01","USERCD":"USERCD","USERNAME":"USERCD"}]"
private synchronized void ActionDoData2(String data)
{ logger.info("取货还货RFID获取数据");
List<RfidDataModel> datas = RfidDataModel.fromJson(data);
String rfidData="";
for (int i = 0; i < datas.size(); i++) {
rfidData= rfidData + "'" + datas.get(i).getRfidCd() + "'" + ",";
}
//清除原来的记录
clearInbounds();
//获取到取还弹窗的tab页数据
getUseBackTabData(datas.get(0), rfidData);
//弹出tab页
logger.info("开始进行弹出窗口");
popup(guiContext.getPrimaryStage());
}
@Value("${iszj}")
private String iszj;
@Autowired
private ZjService zjService;
public void refjxq(){
int ts=jxqyellow;
if(iszj.equals("1")) {
zjService.Zj();
zjService.ReHcg();
}
int i=0;
if(guiContext.getLoginUser()!=null&& guiContext.getLoginUser().getOrgGuid()!=null) {
i = mfcubestockdetailMapper.selectExpiredGoods(guiContext.getLoginUser().getOrgGuid(), youxqdays);
lbjxqsl.setText(i+"");
}
}
Thread thread=null;
@Override
public void refresh() {
this.guiContext.setCurrentPage(this);
if(thread==null){
System.out.println("开启检测有效期线程");
thread=new Thread(()->{
try {
refjxq();
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
});
thread.start();
}
}
Stage primaryStage;
public void popProgressBar() {
ProgressIndicator progressIndicator = new ProgressIndicator(-1);
progressIndicator.setMinWidth(30);
progressIndicator.setMinHeight(30);
VBox box = new VBox();
box.getChildren().addAll(progressIndicator);
box.setStyle("-fx-background:transparent;");
final int width = 1000;
final int height = 200;
final Scene scene = new Scene(box, width, height);
scene.setFill(null);
primaryStage = new Stage();
primaryStage.setX(450);
primaryStage.setY(600);
primaryStage.initStyle(StageStyle.TRANSPARENT);
primaryStage.setScene(scene);
primaryStage.initOwner(guiContext.getPrimaryStage());
primaryStage.initModality(Modality.APPLICATION_MODAL);
primaryStage.initModality(Modality.APPLICATION_MODAL);
primaryStage.show();
}
public void closeProgressBar() {
primaryStage.close();
}
@Override
public String getTitle() {
return "main_page";
}
}