|
@@ -3,7 +3,9 @@ package com.usoftchina.smartschool.device.client.biometric.controller;
|
|
|
import com.usoftchina.smartschool.device.client.biometric.DeviceClient;
|
|
|
import com.usoftchina.smartschool.device.client.biometric.po.FaceGate;
|
|
|
import com.usoftchina.smartschool.device.client.biometric.po.Person;
|
|
|
+import com.usoftchina.smartschool.device.client.biometric.po.PersonGroup;
|
|
|
import com.usoftchina.smartschool.device.client.biometric.po.SexType;
|
|
|
+import com.usoftchina.smartschool.device.client.biometric.service.PersonGroupService;
|
|
|
import com.usoftchina.smartschool.device.client.biometric.service.PersonService;
|
|
|
import com.usoftchina.smartschool.device.client.biometric.util.AlertUtils;
|
|
|
import com.usoftchina.smartschool.device.client.biometric.util.NotifyUtils;
|
|
@@ -23,9 +25,10 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
|
|
import javafx.stage.Stage;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.net.URL;
|
|
|
-import java.util.ResourceBundle;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
* @author yingp
|
|
@@ -36,7 +39,7 @@ public class PersonController implements Initializable {
|
|
|
@FXML
|
|
|
public TableView<Person> tableView;
|
|
|
@FXML
|
|
|
- public TableColumn classCol;
|
|
|
+ public TableColumn groupCol;
|
|
|
@FXML
|
|
|
public TableColumn nameCol;
|
|
|
@FXML
|
|
@@ -53,20 +56,93 @@ public class PersonController implements Initializable {
|
|
|
public Button issueButton;
|
|
|
@FXML
|
|
|
public Button issueStatusButton;
|
|
|
+ @FXML
|
|
|
+ public ListView<PersonGroup> listView;
|
|
|
+ @FXML
|
|
|
+ public Button editGroupButton;
|
|
|
+ @FXML
|
|
|
+ public Button delGroupButton;
|
|
|
|
|
|
private PersonService personService;
|
|
|
+ private PersonGroupService personGroupService;
|
|
|
|
|
|
+ private ObservableList<PersonGroup> personGroupObservableList = FXCollections.observableArrayList();
|
|
|
private ObservableList<Person> personObservableList = FXCollections.observableArrayList();
|
|
|
+ private Map<Integer, String> personGroupMap = new HashMap<>(0);
|
|
|
|
|
|
@Override
|
|
|
public void initialize(URL location, ResourceBundle resources) {
|
|
|
personService = SpringContextHolder.getContext().getBean(PersonService.class);
|
|
|
- initTable();
|
|
|
+ personGroupService = SpringContextHolder.getContext().getBean(PersonGroupService.class);
|
|
|
+ initGroupList();
|
|
|
+ initPersonTable();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 用户组初始化
|
|
|
+ */
|
|
|
+ private void initGroupList() {
|
|
|
+ listView.setCellFactory((col) -> {
|
|
|
+ ListCell<PersonGroup> cell = new ListCell<PersonGroup>() {
|
|
|
+ @Override
|
|
|
+ protected void updateItem(PersonGroup item, boolean empty) {
|
|
|
+ super.updateItem(item, empty);
|
|
|
+ if (null != item) {
|
|
|
+ this.setText(item.getName());
|
|
|
+ this.getStyleClass().add("list-cell-text");
|
|
|
+ if (null == item.getId()) {
|
|
|
+ this.getStyleClass().add("list-cell-primary");
|
|
|
+ } else {
|
|
|
+ this.getStyleClass().remove("list-cell-primary");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.getStyleClass().remove("list-cell-primary");
|
|
|
+ this.getStyleClass().remove("list-cell-text");
|
|
|
+ this.setText(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return cell;
|
|
|
+ });
|
|
|
+ listView.setItems(personGroupObservableList);
|
|
|
+ listView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<PersonGroup>() {
|
|
|
+ @Override
|
|
|
+ public void changed(ObservableValue<? extends PersonGroup> observable, PersonGroup oldValue, PersonGroup newValue) {
|
|
|
+ loadData();
|
|
|
+ if (null != newValue && null != newValue.getId()) {
|
|
|
+ editGroupButton.setDisable(false);
|
|
|
+ delGroupButton.setDisable(false);
|
|
|
+ } else {
|
|
|
+ editGroupButton.setDisable(true);
|
|
|
+ delGroupButton.setDisable(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ loadGroups();
|
|
|
}
|
|
|
|
|
|
- private void initTable() {
|
|
|
+
|
|
|
+ * 用户列表初始化
|
|
|
+ */
|
|
|
+ private void initPersonTable() {
|
|
|
nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
|
|
|
- classCol.setCellValueFactory(new PropertyValueFactory<>("clazz"));
|
|
|
+ groupCol.setCellValueFactory(new PropertyValueFactory<>("groupId"));
|
|
|
+ groupCol.setCellFactory((col) -> {
|
|
|
+ TableCell<FaceGate, Integer> cell = new TableCell<FaceGate, Integer>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateItem(Integer item, boolean empty) {
|
|
|
+ super.updateItem(item, empty);
|
|
|
+ if (null != item) {
|
|
|
+ this.setText(personGroupMap.get(item));
|
|
|
+ } else {
|
|
|
+ this.setText(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ );
|
|
|
sexCol.setCellValueFactory(new PropertyValueFactory<>("sex"));
|
|
|
sexCol.setCellFactory((col) -> {
|
|
|
TableCell<FaceGate, SexType> cell = new TableCell<FaceGate, SexType>() {
|
|
@@ -89,7 +165,6 @@ public class PersonController implements Initializable {
|
|
|
|
|
|
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
|
|
tableView.setItems(personObservableList);
|
|
|
- loadData();
|
|
|
|
|
|
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() {
|
|
|
@Override
|
|
@@ -109,17 +184,43 @@ public class PersonController implements Initializable {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void loadGroups() {
|
|
|
+ Platform.runLater(() -> {
|
|
|
+ List<PersonGroup> groupList = personGroupService.findAll();
|
|
|
+ if (null == groupList) {
|
|
|
+ groupList = new ArrayList<>(1);
|
|
|
+ }
|
|
|
+ groupList.forEach(g -> personGroupMap.put(g.getId(), g.getName()));
|
|
|
+ groupList.add(0, new PersonGroup(null, "全部分组"));
|
|
|
+ personGroupObservableList.setAll(FXCollections.observableList(groupList));
|
|
|
+ listView.getSelectionModel().selectFirst();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
private void loadData() {
|
|
|
Platform.runLater(() -> {
|
|
|
- personObservableList.setAll(FXCollections.observableList(personService.findAll()));
|
|
|
+ PersonGroup personGroup = listView.getSelectionModel().getSelectedItem();
|
|
|
+ Integer groupId = null == personGroup ? null : personGroup.getId();
|
|
|
+ List<Person> personList = null == groupId ? personService.findAll() : personService.findByGroupId(groupId);
|
|
|
+ personObservableList.setAll(FXCollections.observableList(personList));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 新增人员
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
@FXML
|
|
|
public void handleAdd(ActionEvent event) {
|
|
|
createGateEditPane(null);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 修改人员
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
@FXML
|
|
|
public void handleEdit(ActionEvent event) {
|
|
|
Person person = tableView.getSelectionModel().getSelectedItem();
|
|
@@ -130,6 +231,11 @@ public class PersonController implements Initializable {
|
|
|
createGateEditPane(person);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 删除人员
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
@FXML
|
|
|
public void handleDelete(ActionEvent event) {
|
|
|
Person person = tableView.getSelectionModel().getSelectedItem();
|
|
@@ -150,6 +256,11 @@ public class PersonController implements Initializable {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 刷新
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
@FXML
|
|
|
public void handleRefresh(ActionEvent event) {
|
|
|
loadData();
|
|
@@ -180,10 +291,20 @@ public class PersonController implements Initializable {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 导入
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
@FXML
|
|
|
public void handleImport(ActionEvent event) {
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 批量下发
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
@FXML
|
|
|
public void handleIssue(ActionEvent event) {
|
|
|
Person person = tableView.getSelectionModel().getSelectedItem();
|
|
@@ -205,6 +326,11 @@ public class PersonController implements Initializable {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 查看下发状态
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
@FXML
|
|
|
public void handleIssueStatus(ActionEvent event) {
|
|
|
Person person = tableView.getSelectionModel().getSelectedItem();
|
|
@@ -225,4 +351,78 @@ public class PersonController implements Initializable {
|
|
|
logger.error("Issue Status Error", e);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 添加分组
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
+ @FXML
|
|
|
+ public void handleAddGroup(ActionEvent event) {
|
|
|
+ AlertUtils.input("输入分组名称").ifPresent(name -> {
|
|
|
+ if (!StringUtils.isEmpty(name)) {
|
|
|
+ Platform.runLater(() -> {
|
|
|
+ try {
|
|
|
+ PersonGroup personGroup = personGroupService.add(name);
|
|
|
+ personGroupObservableList.add(personGroup);
|
|
|
+ personGroupMap.put(personGroup.getId(), name);
|
|
|
+ } catch (Exception e) {
|
|
|
+ AlertUtils.error(e.getMessage());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 修改分组
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
+ @FXML
|
|
|
+ public void handleEditGroup(ActionEvent event) {
|
|
|
+ PersonGroup personGroup = listView.getSelectionModel().getSelectedItem();
|
|
|
+ if (null == personGroup || null == personGroup.getId()) {
|
|
|
+ AlertUtils.warn("请先选择分组");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ AlertUtils.input("输入分组名称", personGroup.getName()).ifPresent(name -> {
|
|
|
+ if (!StringUtils.isEmpty(name) && !name.equals(personGroup.getName())) {
|
|
|
+ Platform.runLater(() -> {
|
|
|
+ try {
|
|
|
+ personGroup.setName(name);
|
|
|
+ personGroupService.update(personGroup);
|
|
|
+ personGroupMap.put(personGroup.getId(), name);
|
|
|
+ listView.refresh();
|
|
|
+ tableView.refresh();
|
|
|
+ } catch (Exception e) {
|
|
|
+ AlertUtils.error(e.getMessage());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 删除分组
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ */
|
|
|
+ @FXML
|
|
|
+ public void handleDeleteGroup(ActionEvent event) {
|
|
|
+ PersonGroup personGroup = listView.getSelectionModel().getSelectedItem();
|
|
|
+ if (null == personGroup || null == personGroup.getId()) {
|
|
|
+ AlertUtils.warn("请先选择分组");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Platform.runLater(() -> {
|
|
|
+ try {
|
|
|
+ personGroupService.delete(personGroup);
|
|
|
+ personGroupObservableList.remove(personGroup);
|
|
|
+ personGroupMap.remove(personGroup.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ AlertUtils.error(e.getMessage());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|