refactor(客户文件): 重构客户文件相关任务处理逻辑
- 移除CompanyCustomerFileService中未实现的searchEvaluationFile方法 - 删除已不再使用的tasker_mapper.json配置文件 - 重构CompanyCustomerEvaluationFormUpdateTask,移除无用日志记录 - 更新客户端与服务端Tasker通信文档中的文件路径格式 - 重构CustomerTabSkinFile中的文件重建和日期计算逻辑,改为直接调用服务方法
This commit is contained in:
@@ -4,13 +4,13 @@ import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.WebSocketClientTasker;
|
||||
import com.ecep.contract.task.Tasker;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
|
||||
import lombok.Setter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 客户评估表更新任务
|
||||
*/
|
||||
public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> implements WebSocketClientTasker {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerEvaluationFormUpdateTask.class);
|
||||
|
||||
@Setter
|
||||
private CompanyCustomerVo customer;
|
||||
|
||||
@@ -30,5 +30,4 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> impl
|
||||
return callRemoteTask(holder, getLocale(), customer.getId());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,20 +4,25 @@ import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.ecep.contract.controller.table.cell.CompanyCustomerFileTableTypeTableCell;
|
||||
import com.ecep.contract.controller.table.cell.FilePathTableCell;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CustomerFileType;
|
||||
import com.ecep.contract.DesktopUtils;
|
||||
import com.ecep.contract.Message;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
|
||||
import com.ecep.contract.controller.table.cell.CompanyCustomerFileTableTypeTableCell;
|
||||
import com.ecep.contract.controller.table.cell.FilePathTableCell;
|
||||
import com.ecep.contract.model.BaseEnumEntity;
|
||||
import com.ecep.contract.service.CompanyCustomerEvaluationFormFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerFileTypeService;
|
||||
import com.ecep.contract.task.CompanyCustomerRebuildFilesTasker;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
@@ -27,24 +32,34 @@ import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.CustomerFileTypeLocalVo;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableMap;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.CheckBoxTableCell;
|
||||
import javafx.scene.input.Dragboard;
|
||||
import javafx.scene.input.TransferMode;
|
||||
import lombok.Setter;
|
||||
|
||||
@FxmlPath("/ui/company/customer/customer-tab-file.fxml")
|
||||
public class CustomerTabSkinFile
|
||||
extends AbstCompanyCustomerTableTabSkin<CompanyCustomerFileVo, CompanyCustomerFileViewModel>
|
||||
implements EditableEntityTableTabSkin<CompanyCustomerFileVo, CompanyCustomerFileViewModel> {
|
||||
|
||||
@Setter
|
||||
private CompanyCustomerFileService companyCustomerFileService;
|
||||
|
||||
public TableColumn<CompanyCustomerFileViewModel, Number> fileTable_idColumn;
|
||||
public TableColumn<CompanyCustomerFileViewModel, CustomerFileType> fileTable_typeColumn;
|
||||
public TableColumn<CompanyCustomerFileViewModel, String> fileTable_filePathColumn;
|
||||
@@ -77,10 +92,6 @@ public class CustomerTabSkinFile
|
||||
return getCompanyCustomerFileService();
|
||||
}
|
||||
|
||||
public CompanyCustomerFileService getCompanyCustomerFileService() {
|
||||
return getCachedBean(CompanyCustomerFileService.class);
|
||||
}
|
||||
|
||||
public CompanyCustomerEvaluationFormFileService getEvaluationFormFileService() {
|
||||
return getCachedBean(CompanyCustomerEvaluationFormFileService.class);
|
||||
}
|
||||
@@ -99,8 +110,6 @@ public class CustomerTabSkinFile
|
||||
TableView<CompanyCustomerFileViewModel> table = getTableView();
|
||||
|
||||
table.disableProperty().bind(viewModel.getPath().isEmpty());
|
||||
|
||||
//
|
||||
fileTable_idColumn.setCellValueFactory(param -> param.getValue().getId());
|
||||
CompanyCustomerFileTypeService fileTypeService = getCachedBean(CompanyCustomerFileTypeService.class);
|
||||
fileTable_typeColumn.setCellValueFactory(param -> param.getValue().getType());
|
||||
@@ -236,12 +245,16 @@ public class CustomerTabSkinFile
|
||||
}
|
||||
|
||||
public void onFileReBuildingAction(ActionEvent event) {
|
||||
CompanyCustomerRebuildFilesTasker task = new CompanyCustomerRebuildFilesTasker();
|
||||
CompanyCustomerVo customer = getEntity();
|
||||
task.setCompanyCustomer(customer);
|
||||
UITools.showTaskDialogAndWait("重建客户文件", task, null);
|
||||
if (task.isFilesUpdated()) {
|
||||
loadTableDataSet();
|
||||
|
||||
|
||||
CompanyCustomerService customerService = getCompanyCustomerService();
|
||||
try {
|
||||
CompanyCustomerVo companyCustomer = customerService.findById(viewModel.getId().get());
|
||||
if (customerService.reBuildingFiles(companyCustomer, (level, message) -> setStatus(message))) {
|
||||
loadTableDataSet();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,19 +326,54 @@ public class CustomerTabSkinFile
|
||||
// dataSet.remove(selectedItem);
|
||||
}
|
||||
|
||||
private void initializeTask(Task<Object> task, String prefix, Consumer<String> consumer) {
|
||||
task.setOnScheduled(e -> {
|
||||
consumer.accept("正在" + prefix + ",请稍后...");
|
||||
});
|
||||
task.setOnRunning(e -> {
|
||||
consumer.accept("开始" + prefix + "...");
|
||||
});
|
||||
task.setOnSucceeded(e -> {
|
||||
consumer.accept(prefix + "同步完成...");
|
||||
});
|
||||
task.exceptionProperty().addListener((observable, oldValue, newValue) -> {
|
||||
consumer.accept(newValue.getMessage());
|
||||
});
|
||||
SpringApp.getBean(ScheduledExecutorService.class).submit(task);
|
||||
consumer.accept("任务已创建...");
|
||||
}
|
||||
|
||||
public void onUpdateEvaluationFormAction(ActionEvent event) {
|
||||
CompanyCustomerEvaluationFormUpdateTask task = new CompanyCustomerEvaluationFormUpdateTask();
|
||||
CompanyCustomerVo customer = getEntity();
|
||||
task.setCustomer(customer);
|
||||
UITools.showTaskDialogAndWait("更新评价表", task, null);
|
||||
task.setCustomer(getCompanyCustomerService().findById(viewModel.getId().get()));
|
||||
UITools.showTaskDialogAndWait("更新评价表", task, consumer -> {
|
||||
initializeTask(task, "更新评价表", msg -> consumer.accept(Message.info(msg)));
|
||||
});
|
||||
loadTableDataSet();
|
||||
}
|
||||
|
||||
public void onCalcNextSignDateAction(ActionEvent event) {
|
||||
CompanyCustomerNextSignDateTask task = new CompanyCustomerNextSignDateTask();
|
||||
CompanyCustomerVo customer = getEntity();
|
||||
task.setCustomer(customer);
|
||||
UITools.showTaskDialogAndWait("计算客户下一个评价日期", task, null);
|
||||
UITools.showDialogAndWait("计算客户下一个评价日期", "依据已有的客户评估表和登记采购的合同计算下一个评估日期", ds -> {
|
||||
CompanyCustomerVo companyCustomer = getCompanyCustomerService().findById(viewModel.getId().get());
|
||||
LocalDate nextSignDate = getCompanyCustomerFileService().getNextSignDate(companyCustomer, (level, msg) -> {
|
||||
Platform.runLater(() -> {
|
||||
ds.add(msg);
|
||||
});
|
||||
});
|
||||
if (nextSignDate != null) {
|
||||
Platform.runLater(() -> {
|
||||
ds.add("下一个评价日期:" + nextSignDate);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private CompanyCustomerFileService getCompanyCustomerFileService() {
|
||||
if (companyCustomerFileService == null) {
|
||||
companyCustomerFileService = SpringApp.getBean(CompanyCustomerFileService.class);
|
||||
}
|
||||
return companyCustomerFileService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -118,11 +118,6 @@ public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public List<CompanyCustomerEvaluationFormFile> searchEvaluationFile(CompanyCustomer customer, String searchText) {
|
||||
// TODO need move to CompanyCustomerEvaluationFormFileService
|
||||
throw new UnsupportedOperationException("Unimplemented method 'searchEvaluationFile'");
|
||||
}
|
||||
|
||||
@CacheEvict(allEntries = true)
|
||||
@Override
|
||||
public CompanyCustomerFileVo save(CompanyCustomerFileVo entity) {
|
||||
|
||||
Reference in New Issue
Block a user