feat: 实现客户端与服务器端Tasker通信机制及文件管理功能

refactor: 重构Tasker基类与服务获取逻辑
fix: 修复文件路径显示问题及任务注册加载机制
docs: 添加客户端与服务器端Tasker通信规则文档
style: 优化代码格式与日志输出
build: 添加tasker_mapper.json配置文件
chore: 清理无用代码与文件
This commit is contained in:
2025-09-25 00:14:34 +08:00
parent dc764e6ed8
commit 2057c3ca67
28 changed files with 1014 additions and 446 deletions

View File

@@ -41,7 +41,6 @@ public class WebSocketClientSession {
webSocketService.send(arguments);
}
public void onMessage(JsonNode node) {
if (node.has("type")) {
String type = node.get("type").asText();
@@ -66,15 +65,15 @@ public class WebSocketClientSession {
}
}
private void handleAsStart(JsonNode args) {
tasker.updateMessage(java.util.logging.Level.INFO, "任务开始");
}
private void handleAsDone(JsonNode args) {
tasker.updateMessage(java.util.logging.Level.INFO, "任务完成");
close();
}
private void handleAsStart(JsonNode args) {
tasker.updateMessage(java.util.logging.Level.INFO, "任务开始");
}
private void handleAsProgress(JsonNode args) {
long current = args.get(0).asLong();
long total = args.get(1).asLong();
@@ -91,7 +90,8 @@ public class WebSocketClientSession {
Object object = webSocketService.getObjectMapper().convertValue(value, descriptor.getPropertyType());
System.out.println("object = " + object);
System.out.println("descriptor.getWriteMethod() = " + descriptor.getWriteMethod());
System.out.println("descriptor.getWriteMethod().getParameterTypes() = " + descriptor.getWriteMethod().getParameterTypes());
System.out.println("descriptor.getWriteMethod().getParameterTypes() = "
+ descriptor.getWriteMethod().getParameterTypes());
descriptor.getWriteMethod().invoke(tasker, object);
} catch (Exception e) {
tasker.updateMessage(java.util.logging.Level.SEVERE, "属性设置失败: " + name + " = " + value);

View File

@@ -264,7 +264,6 @@ public class CompanyWindowController
public void onCompanyVerifyAction(ActionEvent event) {
CompanyVo company = getEntity();
CompanyVerifyTasker task = new CompanyVerifyTasker();
task.setCompanyService(companyService);
task.setCompany(company);
UITools.showTaskDialogAndWait("企业合规性验证", task, null);
}

View File

@@ -1,4 +1,4 @@
package com.ecep.contract.controller.customer;
package com.ecep.contract.controller.contract.sale_order;
import com.ecep.contract.vo.SalesOrderVo;
import org.slf4j.Logger;

View File

@@ -1,240 +1,34 @@
package com.ecep.contract.controller.customer;
import static com.ecep.contract.util.ExcelUtils.setCellValue;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.time.LocalDate;
import java.util.Comparator;
import java.util.List;
import com.ecep.contract.service.*;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.WebSocketClientTasker;
import com.ecep.contract.task.Tasker;
import com.ecep.contract.util.CompanyUtils;
import com.ecep.contract.vo.CompanyCustomerFileVo;
import com.ecep.contract.vo.CompanyCustomerVo;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.CellRangeAddress;
import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.ecep.contract.CustomerFileType;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.SpringApp;
import com.ecep.contract.vo.CloudTycVo;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
import lombok.Setter;
public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> {
public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> implements WebSocketClientTasker {
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerEvaluationFormUpdateTask.class);
@Setter
private CompanyCustomerVo customer;
@Setter
private CompanyService companyService;
private CompanyContactService companyContactService;
private CompanyCustomerService companyCustomerService;
@Setter
private CompanyCustomerFileService companyCustomerFileService;
private CompanyCustomerService getCompanyCustomerService() {
if (companyCustomerService == null) {
companyCustomerService = SpringApp.getBean(CompanyCustomerService.class);
}
return companyCustomerService;
@Override
public String getTaskName() {
return getClass().getSimpleName();
}
private CompanyContactService getCompanyContactService() {
if (companyContactService == null) {
companyContactService = SpringApp.getBean(CompanyContactService.class);
}
return companyContactService;
}
private CompanyCustomerFileService getCompanyCustomerFileService() {
if (companyCustomerFileService == null) {
companyCustomerFileService = SpringApp.getBean(CompanyCustomerFileService.class);
}
return companyCustomerFileService;
}
private CompanyCustomerEvaluationFormFileService getCompanyCustomerEvaluationFormFileService() {
return getBean(CompanyCustomerEvaluationFormFileService.class);
}
private File getEvaluationFormTemplate() {
return getCompanyCustomerFileService().getEvaluationFormTemplate();
@Override
public void updateProgress(long current, long total) {
super.updateProgress(current, total);
}
@Override
protected Object execute(MessageHolder holder) throws Exception {
try {
updateEvaluationForm(holder);
} catch (Exception ex) {
updateMessage(ex.getMessage());
}
return null;
updateTitle("客户评估表更新任务");
return callRemoteTask(holder, getLocale(), customer.getId());
}
public void updateEvaluationForm(MessageHolder holder) {
if (!StringUtils.hasText(customer.getPath())) {
holder.error("供应商目录未设置,请先设置供应商目录");
return;
}
File template = getEvaluationFormTemplate();
if (template == null) {
holder.error("评价表模板文件未设置,请先设置评价表模板文件");
return;
}
if (!template.exists()) {
holder.error("评价表模板文件 " + template.getAbsolutePath() + " 不存在,请检查");
return;
}
File dir = new File(customer.getPath());
String template_file_name = template.getName();
File destFile = new File(dir, template_file_name);
if (destFile.exists()) {
holder.info("表单文件已经存在," + destFile.getName());
try (
InputStream inp = new FileInputStream(destFile);
Workbook wb = WorkbookFactory.create(inp)) {
updateEvaluationForm(wb, destFile, holder);
holder.info("评价表已更新");
} catch (Exception e) {
holder.error(e.getMessage());
logger.error(e.getMessage(), e);
}
} else {
holder.info("根据模板 " + template_file_name + " 创建表单 " + destFile.getName());
try (
InputStream inp = new FileInputStream(template);
Workbook wb = WorkbookFactory.create(inp)) {
updateEvaluationForm(wb, destFile, holder);
holder.info("评价表已创建");
CompanyCustomerFileVo customerFile = new CompanyCustomerFileVo();
customerFile.setCustomer(customer.getId());
customerFile.setFilePath(destFile.getAbsolutePath());
customerFile.setType(CustomerFileType.General);
save(customerFile);
} catch (Exception e) {
holder.error(e.getMessage());
logger.error(e.getMessage(), e);
}
}
updateProgress(1, 1);
}
private void save(CompanyCustomerFileVo customerFile) {
getCompanyCustomerFileService().save(customerFile);
}
/**
* 更新客户评估表,依据模板创建,如果已经存在生成的文件,则更新评估表
*
* @param wb work book
* @param destFile 目标文件
*/
public void updateEvaluationForm(Workbook wb, File destFile, MessageHolder holder) throws IOException {
Integer companyId = customer.getCompanyId();
CompanyVo company = getCompanyService().findById(companyId);
Sheet sheet = wb.getSheetAt(0);
updateSheet(company, sheet, holder.sub(" - "));
updateProgress(900, 1000);
// 输出到文件
try (OutputStream fileOut = new FileOutputStream(destFile)) {
wb.write(fileOut);
} catch (FileNotFoundException e) {
holder.error("写评估表时发生文件错误,请检查评估表是否被打开中:" + e.getMessage());
logger.error(e.getMessage(), e);
}
}
private void updateSheet(CompanyVo company, Sheet sheet, MessageHolder holder) {
setCellValue(sheet, "B3", "客户编号:" + CompanyUtils.formatCompanyVendorId(customer.getId()));
setCellValue(sheet, "B4", "客户名称:" + company.getName());
LocalDate suggestDate = getCompanyCustomerFileService().getNextSignDate(customer, holder);
if (suggestDate == null) {
suggestDate = LocalDate.now();
}
setCellValue(sheet, "H3", "评定时间:" + suggestDate);
setCellValue(sheet, "H4", "统一社会信用代码:");
setCellValue(sheet, "H5", company.getUniscid());
// 注册所属地
setCellValue(sheet, "B5", "注册所属地:" + company.getDistrict());
// 经营状态
setCellValue(sheet, "D6", "经营状态:" + company.getEntStatus());
// 成立日期
setCellValue(sheet, "H6", "成立日期:" + company.getSetupDate());
// 所属行业
setCellValue(sheet, "D7", "所属行业:" + company.getIndustry());
setCellValue(sheet, "D8",
"注册资金:" + company.getRegisteredCapital() + " " + company.getRegisteredCapitalCurrency());
// 企业类型
setCellValue(sheet, "H10", "企业类型:" + company.getEntType());
// 天眼评分
CloudTycService cloudTycService = SpringApp.getBean(CloudTycService.class);
CloudTycVo cloudTyc = cloudTycService.getOrCreateCloudTyc(company);
setCellValue(sheet, "D10", "天眼评分:" + (cloudTyc.getScore() > 0 ? cloudTyc.getScore() : ""));
// 检索评估表
List<CompanyCustomerFileVo> customerFiles = getCompanyCustomerFileService().findAllByCustomerAndType(customer,
CustomerFileType.EvaluationForm);
List<CompanyCustomerEvaluationFormFileVo> filteredList = customerFiles.stream().filter(file -> {
return file.getSignDate() != null && file.isValid();
})
.sorted(Comparator.comparing(CompanyCustomerFileVo::getSignDate))
.map(getCompanyCustomerEvaluationFormFileService()::findByCustomerFile)
.toList();
if (filteredList.isEmpty()) {
setCellValue(sheet, "C40", "首次评价");
try {
sheet.addMergedRegion(CellRangeAddress.valueOf("C40:K40"));
} catch (Exception ignored) {
}
} else {
setCellValue(sheet, "C40", "评价日期");
try {
sheet.addMergedRegion(CellRangeAddress.valueOf("C40:D40"));
} catch (Exception ignored) {
}
setCellValue(sheet, "E40", "经济指标");
setCellValue(sheet, "F40", "综合指标");
setCellValue(sheet, "G40", "资信等级");
String[] CreditLevelTitles = new String[] { "-", "差★", " 一般★★", " 较好★★★", " 好★★★★", " " };
int baseRow = 40;
for (CompanyCustomerEvaluationFormFileVo form : filteredList) {
CompanyCustomerFileVo customerFile = getCompanyCustomerFileService().findById(form.getCustomerFile());
setCellValue(sheet, baseRow, 2, String.valueOf(customerFile.getSignDate()));
setCellValue(sheet, baseRow, 4, form.getCatalog());
setCellValue(sheet, baseRow, 5, form.getLevel());
if (form.getCreditLevel() == null) {
setCellValue(sheet, baseRow, 6, "-");
} else {
setCellValue(sheet, baseRow, 6, CreditLevelTitles[form.getCreditLevel()]);
}
try {
sheet.addMergedRegion(new CellRangeAddress(baseRow, baseRow, 2, 3));
} catch (Exception ignored) {
}
baseRow++;
}
}
}
}

View File

@@ -63,7 +63,6 @@ public class CompanyCustomerManagerWindowController
return getCachedBean(CompanyCustomerService.class);
}
@Autowired
private CompanyService getCompanyService() {
return getCachedBean(CompanyService.class);
}

View File

@@ -0,0 +1,34 @@
package com.ecep.contract.controller.customer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
public class CompanyCustomerNextSignDateTask extends Tasker<Object> implements WebSocketClientTasker {
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerNextSignDateTask.class);
@Setter
private CompanyCustomerVo customer;
@Override
public String getTaskName() {
return getClass().getSimpleName();
}
@Override
public void updateProgress(long current, long total) {
super.updateProgress(current, total);
}
@Override
protected Object execute(MessageHolder holder) throws Exception {
updateTitle("计算客户下一个评价日期");
return callRemoteTask(holder, getLocale(), customer.getId());
}
}

View File

@@ -4,24 +4,20 @@ 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 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.model.BaseEnumEntity;
import com.ecep.contract.controller.table.cell.CompanyCustomerFileTableTypeTableCell;
import com.ecep.contract.controller.table.cell.FilePathTableCell;
import com.ecep.contract.service.CompanyCustomerEvaluationFormFileService;
import com.ecep.contract.service.CompanyCustomerFileService;
import com.ecep.contract.service.CompanyCustomerFileTypeService;
import com.ecep.contract.service.CompanyCustomerService;
import com.ecep.contract.task.CompanyCustomerRebuildFilesTasker;
import com.ecep.contract.util.FileUtils;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.ParamUtils;
@@ -31,34 +27,24 @@ 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;
@@ -91,6 +77,14 @@ public class CustomerTabSkinFile
return getCompanyCustomerFileService();
}
public CompanyCustomerFileService getCompanyCustomerFileService() {
return getCachedBean(CompanyCustomerFileService.class);
}
public CompanyCustomerEvaluationFormFileService getEvaluationFormFileService() {
return getCachedBean(CompanyCustomerEvaluationFormFileService.class);
}
@Override
public ParamUtils.Builder getSpecification(CompanyCustomerVo parent) {
ParamUtils.Builder params = getSpecification();
@@ -105,16 +99,18 @@ 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());
fileTable_typeColumn.setCellFactory(CompanyCustomerFileTableTypeTableCell.forTableColumn(fileTypeService));
fileTable_filePathColumn.setCellValueFactory(param -> param.getValue().getFilePath());
fileTable_filePathColumn.setCellFactory(param -> new FileTableFilePathTableCell());
fileTable_filePathColumn.setCellFactory(FilePathTableCell.forTableColumn(viewModel.getPath()));
fileTable_editFilePathColumn.setCellValueFactory(param -> param.getValue().getEditFilePath());
fileTable_editFilePathColumn.setCellFactory(param -> new FileTableFilePathTableCell());
fileTable_editFilePathColumn.setCellFactory(FilePathTableCell.forTableColumn(viewModel.getPath()));
fileTable_signDateColumn.setCellValueFactory(param -> param.getValue().getSignDate());
fileTable_validColumn.setEditable(true);
@@ -159,11 +155,12 @@ public class CustomerTabSkinFile
protected void onTableRowDoubleClickedAction(CompanyCustomerFileViewModel item) {
CustomerFileType fileType = item.getType().get();
if (fileType == CustomerFileType.EvaluationForm) {
CompanyCustomerEvaluationFormFileVo evaluationFormFile = getCachedBean(
CompanyCustomerEvaluationFormFileService.class).findByCustomerFile(item.getId().get());
// 文件不是 Excel 文件时打开编辑UI
if (!FileUtils.withExtensions(item.getFilePath().get(), FileUtils.XLS,
FileUtils.XLSX)) {
CompanyCustomerEvaluationFormFileVo evaluationFormFile = getEvaluationFormFileService()
.findByCustomerFile(item.getId().get());
CompanyCustomerEvaluationFormFileWindowController.show(evaluationFormFile,
controller.root.getScene().getWindow());
return;
@@ -239,17 +236,13 @@ public class CustomerTabSkinFile
}
public void onFileReBuildingAction(ActionEvent event) {
CompletableFuture.runAsync(() -> {
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();
}
});
CompanyCustomerRebuildFilesTasker task = new CompanyCustomerRebuildFilesTasker();
CompanyCustomerVo customer = getEntity();
task.setCompanyCustomer(customer);
UITools.showTaskDialogAndWait("重建客户文件", task, null);
if (task.isFilesUpdated()) {
loadTableDataSet();
}
}
@Override
@@ -320,74 +313,19 @@ 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();
task.setCompanyService(getCompanyService());
task.setCompanyCustomerFileService(getCompanyCustomerFileService());
task.setCustomer(getCompanyCustomerService().findById(viewModel.getId().get()));
UITools.showTaskDialogAndWait("更新评价表", task, consumer -> {
initializeTask(task, "更新评价表", msg -> consumer.accept(Message.info(msg)));
});
CompanyCustomerVo customer = getEntity();
task.setCustomer(customer);
UITools.showTaskDialogAndWait("更新评价表", task, null);
loadTableDataSet();
}
public void onCalcNextSignDateAction(ActionEvent event) {
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);
});
}
});
}
class FileTableFilePathTableCell extends TableCell<CompanyCustomerFileViewModel, String> {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty || !StringUtils.hasText(item)) {
setText("");
return;
}
String path = viewModel.getPath().get();
if (StringUtils.hasText(path)) {
if (item.startsWith(path)) {
item = "~" + item.substring(path.length());
}
}
setText(item);
}
}
private CompanyCustomerFileService getCompanyCustomerFileService() {
if (companyCustomerFileService == null) {
companyCustomerFileService = SpringApp.getBean(CompanyCustomerFileService.class);
}
return companyCustomerFileService;
CompanyCustomerNextSignDateTask task = new CompanyCustomerNextSignDateTask();
CompanyCustomerVo customer = getEntity();
task.setCustomer(customer);
UITools.showTaskDialogAndWait("计算客户下一个评价日期", task, null);
}
}

View File

@@ -7,7 +7,7 @@ import com.ecep.contract.controller.table.cell.EmployeeTableCell;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.controller.contract.AbstContractTableTabSkin;
import com.ecep.contract.controller.contract.ContractWindowController;
import com.ecep.contract.controller.customer.SalesOrderWindowController;
import com.ecep.contract.controller.contract.sale_order.SalesOrderWindowController;
import com.ecep.contract.controller.table.cell.LocalDateFieldTableCell;
import com.ecep.contract.converter.EmployeeStringConverter;
import com.ecep.contract.service.SaleOrdersService;

View File

@@ -4,7 +4,7 @@ import java.time.LocalDateTime;
import com.ecep.contract.MyDateTimeUtils;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.customer.SalesOrderWindowController;
import com.ecep.contract.controller.contract.sale_order.SalesOrderWindowController;
import com.ecep.contract.converter.EmployeeStringConverter;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.SalesOrder;

View File

@@ -1,7 +1,7 @@
package com.ecep.contract.controller.tab;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.customer.SalesOrderWindowController;
import com.ecep.contract.controller.contract.sale_order.SalesOrderWindowController;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
import com.ecep.contract.converter.EmployeeStringConverter;

View File

@@ -9,7 +9,7 @@ import java.util.stream.Collectors;
import org.springframework.util.StringUtils;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.customer.SalesOrderWindowController;
import com.ecep.contract.controller.contract.sale_order.SalesOrderWindowController;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.model.Contract;
import com.ecep.contract.service.ContractService;

View File

@@ -1,4 +1,41 @@
package com.ecep.contract.controller.table.cell;
public class FilePathTableCell {
import javafx.beans.property.StringProperty;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.util.Callback;
import org.springframework.util.StringUtils;
public class FilePathTableCell<V> extends TableCell<V, String> {
private StringProperty path;
/**
* 创建一个用于表格列的单元格工厂
*/
public static <T> Callback<TableColumn<T, String>, TableCell<T, String>> forTableColumn(
StringProperty parentPath) {
return param -> new FilePathTableCell<>(parentPath);
}
public FilePathTableCell(StringProperty parentPath) {
this.path = parentPath;
}
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty || !StringUtils.hasText(item)) {
setText("");
return;
}
String path = this.path.get();
if (StringUtils.hasText(path)) {
if (item.startsWith(path)) {
item = "~" + item.substring(path.length());
}
}
setText(item);
}
}

View File

@@ -278,7 +278,6 @@ public class VendorTabSkinFile
public void onUpdateEvaluationFormAction(ActionEvent event) {
CompanyVendorEvaluationFormUpdateTask task = new CompanyVendorEvaluationFormUpdateTask();
task.setCompanyService(getCompanyService());
UITools.showTaskDialogAndWait("更新评价表", task, null);
loadTableDataSet();
}

View File

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
import com.ecep.contract.CustomerFileType;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.SpringApp;
import com.ecep.contract.constant.CompanyCustomerConstant;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.model.CompanyCustomerEvaluationFormFile;
import com.ecep.contract.util.ParamUtils;
@@ -27,9 +28,14 @@ import com.ecep.contract.vo.ContractVo;
@Service
@CacheConfig(cacheNames = "customer-file")
public class CompanyCustomerFileService extends QueryService<CompanyCustomerFileVo, CompanyCustomerFileViewModel> {
public File getEvaluationFormTemplate() {
throw new UnsupportedOperationException();
SysConfService confService = SpringApp.getBean(SysConfService.class);
String path = confService.getString(CompanyCustomerConstant.KEY_EVALUATION_FORM_TEMPLATE);
if (path == null) {
return null;
}
return new File(path);
}
@Cacheable
@@ -100,7 +106,6 @@ public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile
return SpringApp.getBean(HolidayService.class).adjustToWorkDay(setupDate.plusDays(-7));
}
public List<CompanyCustomerFileVo> findAllByCustomer(CompanyCustomerVo companyCustomer) {
return findAll(ParamUtils.builder().equals("customer", companyCustomer).build(), Pageable.unpaged())
.getContent();

View File

@@ -2,6 +2,7 @@ package com.ecep.contract.service;
import java.io.File;
import javafx.application.Platform;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -39,9 +40,9 @@ public class CompanyCustomerService extends QueryService<CompanyCustomerVo, Comp
/**
* 重建客户相关文件
*
*
* @param companyCustomer 客户对象
* @param holder 消息持有者,用于显示任务执行过程中的消息
* @param holder 消息持有者,用于显示任务执行过程中的消息
* @return 如果文件重建成功则返回true否则返回false
*/
public boolean reBuildingFiles(CompanyCustomerVo companyCustomer, MessageHolder holder) {
@@ -49,21 +50,21 @@ public class CompanyCustomerService extends QueryService<CompanyCustomerVo, Comp
if (!makePathAbsent(companyCustomer)) {
holder.addMessage(java.util.logging.Level.WARNING, "无法创建或确认客户路径,文件重建可能失败");
}
// 创建并配置文件重建任务
CompanyCustomerRebuildFilesTasker tasker = new CompanyCustomerRebuildFilesTasker();
tasker.setCompanyCustomer(companyCustomer);
// 显示任务对话框并等待任务完成
UITools.showTaskDialogAndWait("重建客户文件", tasker, null);
// 返回任务执行结果
return tasker.isFilesUpdated();
}
/**
* 检查客户路径是否不存在,如果不存在则创建并设置路径
*
*
* @param companyCustomer 客户对象
* @return 如果成功创建路径并设置则返回true否则返回false
*/
@@ -89,7 +90,7 @@ public class CompanyCustomerService extends QueryService<CompanyCustomerVo, Comp
/**
* 为客户创建路径
*
*
* @param companyCustomer 客户对象
* @return 创建的目录对象如果创建失败则返回null
*/
@@ -113,7 +114,7 @@ public class CompanyCustomerService extends QueryService<CompanyCustomerVo, Comp
/**
* 格式化公司客户ID确保格式一致
*
*
* @param id 客户ID
* @return 格式化后的ID字符串
*/
@@ -124,7 +125,7 @@ public class CompanyCustomerService extends QueryService<CompanyCustomerVo, Comp
/**
* 转义文件名,确保合法
*
*
* @param fileName 原始文件名
* @return 转义后的文件名
*/

View File

@@ -1,5 +1,6 @@
package com.ecep.contract.task;
import java.util.HashMap;
import java.util.Locale;
import java.util.logging.Level;
@@ -27,36 +28,32 @@ public abstract class Tasker<T> extends Task<T> {
@Setter
protected java.util.function.Predicate<Message> messageHandler;
private EmployeeVo currentUser;
@Setter
private CompanyService companyService;
@Setter
private EmployeeService employeeService;
@Setter
private SysConfService confService;
private HashMap<Class<?>, Object> cachedMap = new HashMap<>();
public SysConfService getConfService() {
if (confService == null) {
confService = getBean(SysConfService.class);
}
return confService;
return getBean(SysConfService.class);
}
public CompanyService getCompanyService() {
if (companyService == null) {
companyService = getBean(CompanyService.class);
}
return companyService;
return getBean(CompanyService.class);
}
public EmployeeService getEmployeeService() {
if (employeeService == null) {
employeeService = getBean(EmployeeService.class);
}
return employeeService;
return getBean(EmployeeService.class);
}
protected <K> K getBean(Class<K> requiredType) throws BeansException {
return SpringApp.getBean(requiredType);
return getCachedBean(requiredType);
}
protected <K> K getCachedBean(Class<K> requiredType) {
@SuppressWarnings("unchecked")
K bean = (K) cachedMap.get(requiredType);
if (bean == null) {
bean = getBean(requiredType);
cachedMap.put(requiredType, bean);
}
return bean;
}
public EmployeeVo getCurrentUser() {
@@ -72,7 +69,6 @@ public abstract class Tasker<T> extends Task<T> {
try {
return execute(holder);
} catch (Exception e) {
holder.error(e.getMessage());
logger.error(e.getMessage(), e);
throw e;