UP
This commit is contained in:
@@ -60,7 +60,7 @@
|
||||
- `customer/`: 客户相关业务
|
||||
- `project/`: 项目相关业务
|
||||
- `vendor/`: 供应商相关业务
|
||||
- 每个业务领域包含:`model/`(实体类)、`repository/`(数据访问接口)、`service/`(业务逻辑, 详细规范见 `.trae\rules\server_service_rules.md`)、`tasker/`(任务处理器)、`controller/`(控制器)
|
||||
- 每个业务领域包含:`model/`(实体类)、`repository/`(数据访问接口)、`service/`(业务逻辑, 详细规范见 `.trae\rules\server_service_rules.md`)、`tasker/`(任务处理器, 详细规范见 `.trae\rules\server_tasker_rules.md`)、`controller/`(控制器, 详细规范见 `.trae\rules\server_controller_rules.md`)
|
||||
- `handler/`: WebSocket处理器
|
||||
- `service/`: 服务层,包含一些通用服务和任务处理器
|
||||
- `ui/`: UI相关组件
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>com.ecep.contract</groupId>
|
||||
<artifactId>Contract-Manager</artifactId>
|
||||
<version>0.0.101-SNAPSHOT</version>
|
||||
<version>0.0.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.ecep.contract</groupId>
|
||||
<artifactId>client</artifactId>
|
||||
<version>0.0.101-SNAPSHOT</version>
|
||||
<version>0.0.102-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
@@ -22,7 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>com.ecep.contract</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>0.0.101-SNAPSHOT</version>
|
||||
<version>0.0.102-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Locale;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.ecep.contract.util.ContextUtils;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.util.FxmlUtils;
|
||||
import com.ecep.contract.vo.EmployeeVo;
|
||||
@@ -41,7 +42,7 @@ import javafx.stage.Window;
|
||||
import javafx.stage.WindowEvent;
|
||||
import lombok.Getter;
|
||||
|
||||
public class BaseController {
|
||||
public class BaseController implements ContextUtils {
|
||||
private static final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
||||
public static HashMap<String, Stage> stages = new HashMap<>();
|
||||
|
||||
@@ -50,7 +51,7 @@ public class BaseController {
|
||||
}
|
||||
|
||||
public static <T extends BaseController> CompletableFuture<Void> show(Class<T> clz, Window owner,
|
||||
Consumer<T> consumer) {
|
||||
Consumer<T> consumer) {
|
||||
String key = clz.getName();
|
||||
if (toFront(key)) {
|
||||
return null;
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.ecep.contract.controller.tab.CompanyTabSkinOldName;
|
||||
import com.ecep.contract.controller.tab.CompanyTabSkinOther;
|
||||
import com.ecep.contract.controller.tab.CompanyTabSkinPurchaseBillVoucher;
|
||||
import com.ecep.contract.controller.vendor.VendorWindowController;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.service.VendorService;
|
||||
import com.ecep.contract.task.CompanyCompositeUpdateTasker;
|
||||
@@ -34,7 +34,7 @@ import com.ecep.contract.task.CompanyVerifyTasker;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.CompanyViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
@@ -124,7 +124,7 @@ public class CompanyWindowController
|
||||
// private final CompanyVendorViewModel companyVendorViewModel = new
|
||||
// CompanyVendorViewModel();
|
||||
|
||||
private final SimpleObjectProperty<CompanyCustomerVo> companyCustomerProperty = new SimpleObjectProperty<>();
|
||||
private final SimpleObjectProperty<CustomerVo> companyCustomerProperty = new SimpleObjectProperty<>();
|
||||
private final SimpleObjectProperty<VendorVo> companyVendorProperty = new SimpleObjectProperty<>();
|
||||
|
||||
public Pane customerTab_pane1;
|
||||
@@ -202,7 +202,7 @@ public class CompanyWindowController
|
||||
logger.debug("onCustomerTabShown");
|
||||
}
|
||||
getLoadedFuture().thenAcceptAsync(company -> {
|
||||
CompanyCustomerVo customerVo = getCachedBean(CompanyCustomerService.class).findByCompany(company);
|
||||
CustomerVo customerVo = getCachedBean(CustomerService.class).findByCompany(company);
|
||||
companyCustomerProperty.set(customerVo);
|
||||
}).exceptionally(ex -> {
|
||||
UITools.showExceptionAndWait(ex.getMessage(), ex);
|
||||
|
||||
@@ -158,16 +158,10 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
ContractVerifyComm comm = new ContractVerifyComm();
|
||||
ContractVerifyComm comm = new ContractVerifyComm(this);
|
||||
|
||||
@Autowired
|
||||
private ProjectSaleTypeService saleTypeService;
|
||||
@Autowired
|
||||
private VendorGroupService vendorGroupService;
|
||||
@Autowired
|
||||
private ContractService contractService;
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
|
||||
@FXML
|
||||
public DatePicker setupDateBeginSelector;
|
||||
@@ -218,7 +212,6 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
|
||||
public void onShown(WindowEvent windowEvent) {
|
||||
super.onShown(windowEvent);
|
||||
comm.setContractService(contractService);
|
||||
viewTable.getScene().getStylesheets().add("/ui/contract/contract-verify.css");
|
||||
|
||||
LocalDate now = LocalDate.now();
|
||||
@@ -230,11 +223,7 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
viewTable_employeeColumn.setCellValueFactory(param -> param.getValue().getEmployee());
|
||||
viewTable_employeeColumn.setCellFactory(param -> new EmployeeTableCell<>(getEmployeeService()));
|
||||
viewTable_setupDateColumn.setCellValueFactory(param -> param.getValue().getSetupDate());
|
||||
// viewTable_stateColumn.setCellValueFactory(param ->
|
||||
// param.getValue().getMessages().map(messages -> {
|
||||
// return
|
||||
// messages.stream().map(Message::getMessage).collect(Collectors.joining(", "));
|
||||
// }));
|
||||
|
||||
viewTable_stateColumn.setCellValueFactory(param -> param.getValue().getMessages());
|
||||
viewTable_stateColumn.setCellFactory(param -> new StateTableCell());
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ package com.ecep.contract.controller.customer;
|
||||
import com.ecep.contract.controller.tab.TabSkin;
|
||||
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.vm.CompanyCustomerViewModel;
|
||||
import com.ecep.contract.vm.IdentityViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
public abstract class AbstCompanyCustomerTableTabSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>>
|
||||
extends
|
||||
AbstEntityTableTabSkin<CompanyCustomerWindowController, CompanyCustomerVo, CompanyCustomerViewModel, T, TV>
|
||||
AbstEntityTableTabSkin<CompanyCustomerWindowController, CustomerVo, CompanyCustomerViewModel, T, TV>
|
||||
implements TabSkin {
|
||||
|
||||
public AbstCompanyCustomerTableTabSkin(CompanyCustomerWindowController controller) {
|
||||
@@ -22,8 +22,8 @@ public abstract class AbstCompanyCustomerTableTabSkin<T extends IdentityEntity,
|
||||
return controller.getCompanyService();
|
||||
}
|
||||
|
||||
protected CompanyCustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CompanyCustomerService.class);
|
||||
protected CustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CustomerService.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.controller.BaseController;
|
||||
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CustomerFileVo;
|
||||
import com.ecep.contract.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerEvaluationFormFileService;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.FxmlUtils;
|
||||
import com.ecep.contract.vm.CompanyCustomerEvaluationFormFileViewModel;
|
||||
import com.ecep.contract.vm.CompanyCustomerFileViewModel;
|
||||
import com.ecep.contract.vm.CustomerFileViewModel;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.Bindings;
|
||||
@@ -142,7 +142,7 @@ public class CompanyCustomerEvaluationFormFileWindowController extends BaseContr
|
||||
|
||||
loadedFuture = CompletableFuture.supplyAsync(() -> {
|
||||
int id = viewModel.getId().get();
|
||||
CompanyCustomerFileVo customerFile = companyCustomerFileService.findById(id);
|
||||
CustomerFileVo customerFile = companyCustomerFileService.findById(id);
|
||||
CompanyCustomerEvaluationFormFileVo formFile = evaluationFormFileService.findByCustomerFile(customerFile);
|
||||
Platform.runLater(() -> update(formFile));
|
||||
return formFile;
|
||||
|
||||
@@ -34,14 +34,14 @@ import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.service.CompanyCustomerEntityService;
|
||||
import com.ecep.contract.service.CompanyCustomerEvaluationFormFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.task.Tasker;
|
||||
import com.ecep.contract.util.ExcelUtils;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vo.CompanyCustomerEntityVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerFileVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
import lombok.Setter;
|
||||
@@ -52,14 +52,14 @@ public class CompanyCustomerExportExcelTasker extends Tasker<Object> {
|
||||
@Setter
|
||||
File destFile;
|
||||
|
||||
CompanyCustomerService customerService;
|
||||
CustomerService customerService;
|
||||
CompanyCustomerEntityService customerEntityService;
|
||||
CompanyCustomerFileService customerFileService;
|
||||
CompanyCustomerEvaluationFormFileService customerEvaluationFormFileService;
|
||||
|
||||
CompanyCustomerService getCustomerService() {
|
||||
CustomerService getCustomerService() {
|
||||
if (customerService == null)
|
||||
customerService = getBean(CompanyCustomerService.class);
|
||||
customerService = getBean(CustomerService.class);
|
||||
return customerService;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class CompanyCustomerExportExcelTasker extends Tasker<Object> {
|
||||
setCellValue(sheet, "A19", "Build by CMS @ " + MyDateTimeUtils.format(LocalDateTime.now()));
|
||||
|
||||
int rowIndex = 0;
|
||||
for (CompanyCustomerVo customer : getCustomerService().findAll(null, Pageable.unpaged())) {
|
||||
for (CustomerVo customer : getCustomerService().findAll(null, Pageable.unpaged())) {
|
||||
Integer companyId = customer.getCompanyId();
|
||||
;
|
||||
CompanyVo company = getCompanyService().findById(companyId);
|
||||
@@ -136,7 +136,7 @@ public class CompanyCustomerExportExcelTasker extends Tasker<Object> {
|
||||
}
|
||||
}
|
||||
|
||||
CompanyCustomerFileVo customerFile = getCustomerFileService()
|
||||
CustomerFileVo customerFile = getCustomerFileService()
|
||||
.findAllByCustomer(customer).stream().filter(v -> v.isValid())
|
||||
.max(Comparator.comparing(v -> v.getSignDate())).orElse(null);
|
||||
|
||||
|
||||
@@ -4,18 +4,18 @@ import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.controller.AbstEntityManagerSkin;
|
||||
import com.ecep.contract.controller.table.cell.CompanyTableCell;
|
||||
import com.ecep.contract.controller.table.cell.CustomerCatalogTableCell;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.service.CustomerCatalogService;
|
||||
import com.ecep.contract.vm.CompanyCustomerViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
import javafx.application.Platform;
|
||||
|
||||
public class CompanyCustomerManagerSkin
|
||||
extends
|
||||
AbstEntityManagerSkin<CompanyCustomerVo, CompanyCustomerViewModel, CompanyCustomerManagerSkin, CompanyCustomerManagerWindowController> {
|
||||
AbstEntityManagerSkin<CustomerVo, CompanyCustomerViewModel, CompanyCustomerManagerSkin, CompanyCustomerManagerWindowController> {
|
||||
|
||||
public CompanyCustomerManagerSkin(CompanyCustomerManagerWindowController controller) {
|
||||
super(controller);
|
||||
@@ -25,7 +25,7 @@ public class CompanyCustomerManagerSkin
|
||||
return getBean(CompanyService.class);
|
||||
}
|
||||
|
||||
public CompanyCustomerService getCompanyCustomerService() {
|
||||
public CustomerService getCompanyCustomerService() {
|
||||
return controller.getViewModelService();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.time.LocalDate;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.controller.AbstManagerWindowController;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.util.UITools;
|
||||
@@ -44,7 +44,7 @@ import javafx.stage.Stage;
|
||||
@Component
|
||||
@FxmlPath("/ui/company/customer/customer_manager.fxml")
|
||||
public class CompanyCustomerManagerWindowController
|
||||
extends AbstManagerWindowController<CompanyCustomerVo, CompanyCustomerViewModel, CompanyCustomerManagerSkin> {
|
||||
extends AbstManagerWindowController<CustomerVo, CompanyCustomerViewModel, CompanyCustomerManagerSkin> {
|
||||
|
||||
// columns
|
||||
public TableColumn<CompanyCustomerViewModel, Number> idColumn;
|
||||
@@ -59,8 +59,8 @@ public class CompanyCustomerManagerWindowController
|
||||
|
||||
|
||||
@Override
|
||||
public CompanyCustomerService getViewModelService() {
|
||||
return getCachedBean(CompanyCustomerService.class);
|
||||
public CustomerService getViewModelService() {
|
||||
return getCachedBean(CustomerService.class);
|
||||
}
|
||||
|
||||
private CompanyService getCompanyService() {
|
||||
@@ -117,11 +117,11 @@ public class CompanyCustomerManagerWindowController
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Pageable pageRequest = PageRequest.ofSize(50);
|
||||
while (!canceled.get()) {
|
||||
Page<CompanyCustomerVo> page = getViewModelService().findAll(null, pageRequest);
|
||||
Page<CustomerVo> page = getViewModelService().findAll(null, pageRequest);
|
||||
int index = page.getNumber() * page.getSize();
|
||||
|
||||
int i = 1;
|
||||
for (CompanyCustomerVo companyCustomer : page) {
|
||||
for (CustomerVo companyCustomer : page) {
|
||||
if (canceled.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ import org.springframework.util.StringUtils;
|
||||
import com.ecep.contract.DesktopUtils;
|
||||
import com.ecep.contract.controller.AbstEntityController;
|
||||
import com.ecep.contract.service.CompanyContactService;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.vm.CompanyCustomerViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
@@ -36,13 +36,13 @@ import javafx.stage.WindowEvent;
|
||||
@Scope("prototype")
|
||||
@Component
|
||||
@FxmlPath("/ui/company/customer/customer.fxml")
|
||||
public class CompanyCustomerWindowController extends AbstEntityController<CompanyCustomerVo, CompanyCustomerViewModel> {
|
||||
public class CompanyCustomerWindowController extends AbstEntityController<CustomerVo, CompanyCustomerViewModel> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerWindowController.class);
|
||||
|
||||
/**
|
||||
* 显示界面
|
||||
*/
|
||||
public static void show(CompanyCustomerVo customer, Window window) {
|
||||
public static void show(CustomerVo customer, Window window) {
|
||||
show(CompanyCustomerWindowController.class, CompanyCustomerViewModel.from(customer), window);
|
||||
}
|
||||
|
||||
@@ -80,15 +80,15 @@ public class CompanyCustomerWindowController extends AbstEntityController<Compan
|
||||
|
||||
@Override
|
||||
protected void registerTabSkins() {
|
||||
registerTabSkin(baseInfoTab, tab -> new CompanyCustomerTabSkinBase(this));
|
||||
registerTabSkin(baseInfoTab, tab -> new CustomerTabSkinBase(this));
|
||||
registerTabSkin(fileTab, tab -> new CustomerTabSkinFile(this));
|
||||
registerTabSkin(entityTab, tab -> new CustomerTabSkinEntity(this));
|
||||
registerTabSkin(satisfactionTab, tab -> new CustomerTabSkinSatisfactionSurvey(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyCustomerService getViewModelService() {
|
||||
return getCachedBean(CompanyCustomerService.class);
|
||||
public CustomerService getViewModelService() {
|
||||
return getCachedBean(CustomerService.class);
|
||||
}
|
||||
|
||||
public CompanyService getCompanyService() {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ecep.contract.controller.customer;
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -11,12 +12,16 @@ import com.ecep.contract.controller.company.CompanyWindowController;
|
||||
import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
|
||||
import com.ecep.contract.controller.tab.TabSkin;
|
||||
import com.ecep.contract.service.CompanyContactService;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.service.QueryService;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.CompanyContactViewModel;
|
||||
import com.ecep.contract.vm.CompanyCustomerViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CompanyContactVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
@@ -24,13 +29,14 @@ import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.util.StringConverter;
|
||||
import javafx.util.converter.LocalDateStringConverter;
|
||||
|
||||
public class CompanyCustomerTabSkinBase
|
||||
extends AbstEntityBasedTabSkin<CompanyCustomerWindowController, CompanyCustomerVo, CompanyCustomerViewModel>
|
||||
public class CustomerTabSkinBase
|
||||
extends AbstEntityBasedTabSkin<CompanyCustomerWindowController, CustomerVo, CompanyCustomerViewModel>
|
||||
implements TabSkin {
|
||||
|
||||
public CompanyCustomerTabSkinBase(CompanyCustomerWindowController controller) {
|
||||
public CustomerTabSkinBase(CompanyCustomerWindowController controller) {
|
||||
super(controller);
|
||||
}
|
||||
|
||||
@@ -44,7 +50,25 @@ public class CompanyCustomerTabSkinBase
|
||||
initializeCompanyFieldAutoCompletion(controller.companyField);
|
||||
initializeContactFieldAutoCompletion(controller.contactField);
|
||||
|
||||
UITools.autoCompletion(controller.contactField, viewModel.getContact(), getCompanyContactService());
|
||||
UITools.autoCompletion(controller.contactField, viewModel.getContact(),
|
||||
new QueryService<CompanyContactVo, CompanyContactViewModel>() {
|
||||
@Override
|
||||
public CompanyContactVo findById(Integer id) {
|
||||
return getCompanyContactService().findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyContactVo> search(String searchText) {
|
||||
CustomerVo vendor = getEntity();
|
||||
CompanyVo company = controller.getCompanyService().findById(vendor.getCompanyId());
|
||||
return getCompanyContactService().searchByCompany(company, searchText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringConverter<CompanyContactVo> getStringConverter() {
|
||||
return getCompanyContactService().getStringConverter();
|
||||
}
|
||||
});
|
||||
|
||||
LocalDateStringConverter converter = new LocalDateStringConverter(DateTimeFormatter.ISO_LOCAL_DATE, null);
|
||||
|
||||
@@ -92,7 +116,7 @@ public class CompanyCustomerTabSkinBase
|
||||
}
|
||||
|
||||
public void onCompanyCustomerCreatePathAction(ActionEvent event) {
|
||||
CompanyCustomerVo companyCustomer = getCompanyCustomerService().findById(viewModel.getId().get());
|
||||
CustomerVo companyCustomer = getCompanyCustomerService().findById(viewModel.getId().get());
|
||||
if (getCompanyCustomerService().makePathAbsent(companyCustomer)) {
|
||||
companyCustomer = getCompanyCustomerService().save(companyCustomer);
|
||||
viewModel.update(companyCustomer);
|
||||
@@ -103,10 +127,10 @@ public class CompanyCustomerTabSkinBase
|
||||
|
||||
public void onCompanyCustomerChangePathAction(ActionEvent event) {
|
||||
DirectoryChooser chooser = new DirectoryChooser();
|
||||
CompanyCustomerVo entity = getEntity();
|
||||
CustomerVo entity = getEntity();
|
||||
String path = entity.getPath();
|
||||
File initialDirectory = null;
|
||||
|
||||
|
||||
// 如果当前已经设置了目录并且路径有效,则设置初始目录为该目录
|
||||
if (StringUtils.hasText(path)) {
|
||||
File dir = new File(path);
|
||||
@@ -114,16 +138,16 @@ public class CompanyCustomerTabSkinBase
|
||||
initialDirectory = dir;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 如果没有有效的初始目录,则使用基础路径
|
||||
if (initialDirectory == null) {
|
||||
initialDirectory = getCompanyCustomerService().getBasePath();
|
||||
}
|
||||
|
||||
|
||||
if (initialDirectory != null) {
|
||||
chooser.setInitialDirectory(initialDirectory);
|
||||
}
|
||||
|
||||
|
||||
File newDirectory = chooser.showDialog(getTab().getContent().getScene().getWindow());
|
||||
if (newDirectory != null) {
|
||||
entity.setPath(newDirectory.getAbsolutePath());
|
||||
@@ -135,8 +159,8 @@ public class CompanyCustomerTabSkinBase
|
||||
setStatus("未实现");
|
||||
}
|
||||
|
||||
public CompanyCustomerService getCompanyCustomerService() {
|
||||
return controller.getCachedBean(CompanyCustomerService.class);
|
||||
public CustomerService getCompanyCustomerService() {
|
||||
return controller.getCachedBean(CustomerService.class);
|
||||
}
|
||||
|
||||
public CompanyContactService getCompanyContactService() {
|
||||
@@ -12,7 +12,7 @@ import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CustomerEntityViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerEntityVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.Tab;
|
||||
@@ -89,7 +89,7 @@ public class CustomerTabSkinEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParamUtils.Builder getSpecification(CompanyCustomerVo parent) {
|
||||
public ParamUtils.Builder getSpecification(CustomerVo parent) {
|
||||
ParamUtils.Builder params = getSpecification();
|
||||
params.equals("customer", parent.getId());
|
||||
return params;
|
||||
|
||||
@@ -4,49 +4,40 @@ 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.customer.tasker.CustomerEvaluationFormUpdateTask;
|
||||
import com.ecep.contract.controller.customer.tasker.CustomerNextSignDateTask;
|
||||
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.service.CompanyService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.task.CustomerFileMoveTasker;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.CompanyCustomerFileViewModel;
|
||||
import com.ecep.contract.vm.CustomerFileViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerFileVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.CustomerFileTypeLocalVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
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;
|
||||
@@ -56,19 +47,19 @@ import lombok.Setter;
|
||||
|
||||
@FxmlPath("/ui/company/customer/customer-tab-file.fxml")
|
||||
public class CustomerTabSkinFile
|
||||
extends AbstCompanyCustomerTableTabSkin<CompanyCustomerFileVo, CompanyCustomerFileViewModel>
|
||||
implements EditableEntityTableTabSkin<CompanyCustomerFileVo, CompanyCustomerFileViewModel> {
|
||||
extends AbstCompanyCustomerTableTabSkin<CustomerFileVo, CustomerFileViewModel>
|
||||
implements EditableEntityTableTabSkin<CustomerFileVo, CustomerFileViewModel> {
|
||||
|
||||
@Setter
|
||||
private CompanyCustomerFileService companyCustomerFileService;
|
||||
|
||||
public TableColumn<CompanyCustomerFileViewModel, Number> fileTable_idColumn;
|
||||
public TableColumn<CompanyCustomerFileViewModel, CustomerFileType> fileTable_typeColumn;
|
||||
public TableColumn<CompanyCustomerFileViewModel, String> fileTable_filePathColumn;
|
||||
public TableColumn<CompanyCustomerFileViewModel, String> fileTable_editFilePathColumn;
|
||||
public TableColumn<CompanyCustomerFileViewModel, LocalDate> fileTable_signDateColumn;
|
||||
public TableColumn<CompanyCustomerFileViewModel, Boolean> fileTable_validColumn;
|
||||
public TableColumn<CompanyCustomerFileViewModel, String> fileTable_descriptionColumn;
|
||||
public TableColumn<CustomerFileViewModel, Number> fileTable_idColumn;
|
||||
public TableColumn<CustomerFileViewModel, CustomerFileType> fileTable_typeColumn;
|
||||
public TableColumn<CustomerFileViewModel, String> fileTable_filePathColumn;
|
||||
public TableColumn<CustomerFileViewModel, String> fileTable_editFilePathColumn;
|
||||
public TableColumn<CustomerFileViewModel, LocalDate> fileTable_signDateColumn;
|
||||
public TableColumn<CustomerFileViewModel, Boolean> fileTable_validColumn;
|
||||
public TableColumn<CustomerFileViewModel, String> fileTable_descriptionColumn;
|
||||
|
||||
public Button fileTable_reBuildBtn;
|
||||
public Button fileTable_updateEvaluationFormBuildBtn;
|
||||
@@ -99,7 +90,7 @@ public class CustomerTabSkinFile
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParamUtils.Builder getSpecification(CompanyCustomerVo parent) {
|
||||
public ParamUtils.Builder getSpecification(CustomerVo parent) {
|
||||
ParamUtils.Builder params = getSpecification();
|
||||
params.equals("customer", parent.getId());
|
||||
return params;
|
||||
@@ -109,7 +100,7 @@ public class CustomerTabSkinFile
|
||||
public void initializeTable() {
|
||||
super.initializeTable();
|
||||
|
||||
TableView<CompanyCustomerFileViewModel> table = getTableView();
|
||||
TableView<CustomerFileViewModel> table = getTableView();
|
||||
|
||||
table.disableProperty().bind(viewModel.getPath().isEmpty());
|
||||
fileTable_idColumn.setCellValueFactory(param -> param.getValue().getId());
|
||||
@@ -163,7 +154,7 @@ public class CustomerTabSkinFile
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTableRowDoubleClickedAction(CompanyCustomerFileViewModel item) {
|
||||
protected void onTableRowDoubleClickedAction(CustomerFileViewModel item) {
|
||||
CustomerFileType fileType = item.getType().get();
|
||||
if (fileType == CustomerFileType.EvaluationForm) {
|
||||
|
||||
@@ -196,7 +187,7 @@ public class CustomerTabSkinFile
|
||||
setStatus("目录错误,不存在");
|
||||
return;
|
||||
}
|
||||
CompanyCustomerVo companyCustomer = getParent();
|
||||
CustomerVo companyCustomer = getParent();
|
||||
LocalDate nextSignDate = getCompanyCustomerFileService().getNextSignDate(companyCustomer,
|
||||
((level, message) -> setStatus(message)));
|
||||
if (nextSignDate != null && files.size() == 1) {
|
||||
@@ -208,15 +199,15 @@ public class CustomerTabSkinFile
|
||||
+ "." + StringUtils.getFilenameExtension(fileName);
|
||||
File dest = new File(dir, destFileName);
|
||||
if (file.renameTo(dest)) {
|
||||
CompanyCustomerFileVo ccf = new CompanyCustomerFileVo();
|
||||
CustomerFileVo ccf = new CustomerFileVo();
|
||||
ccf.setCustomer(companyCustomer.getId());
|
||||
ccf.setType(CustomerFileType.EvaluationForm);
|
||||
ccf.setFilePath(dest.getAbsolutePath());
|
||||
ccf.setSignDate(nextSignDate);
|
||||
ccf.setValid(false);
|
||||
CompanyCustomerFileVo saved = getCompanyCustomerFileService().save(ccf);
|
||||
CustomerFileVo saved = getCompanyCustomerFileService().save(ccf);
|
||||
Platform.runLater(() -> {
|
||||
CompanyCustomerFileViewModel model = new CompanyCustomerFileViewModel();
|
||||
CustomerFileViewModel model = new CustomerFileViewModel();
|
||||
model.update(saved);
|
||||
dataSet.add(model);
|
||||
|
||||
@@ -235,7 +226,7 @@ public class CustomerTabSkinFile
|
||||
for (File file : files) {
|
||||
File dest = new File(dir, file.getName());
|
||||
if (file.renameTo(dest)) {
|
||||
CompanyCustomerFileVo ccf = new CompanyCustomerFileVo();
|
||||
CustomerFileVo ccf = new CustomerFileVo();
|
||||
ccf.setCustomer(companyCustomer.getId());
|
||||
ccf.setType(CustomerFileType.General);
|
||||
ccf.setFilePath(dest.getAbsolutePath());
|
||||
@@ -248,9 +239,9 @@ public class CustomerTabSkinFile
|
||||
|
||||
public void onFileReBuildingAction(ActionEvent event) {
|
||||
|
||||
CompanyCustomerService customerService = getCompanyCustomerService();
|
||||
CustomerService customerService = getCompanyCustomerService();
|
||||
try {
|
||||
CompanyCustomerVo companyCustomer = customerService.findById(viewModel.getId().get());
|
||||
CustomerVo companyCustomer = customerService.findById(viewModel.getId().get());
|
||||
if (customerService.reBuildingFiles(companyCustomer, (level, message) -> setStatus(message))) {
|
||||
loadTableDataSet();
|
||||
}
|
||||
@@ -260,7 +251,7 @@ public class CustomerTabSkinFile
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean deleteRow(CompanyCustomerFileViewModel row) {
|
||||
protected boolean deleteRow(CustomerFileViewModel row) {
|
||||
String path = row.getFilePath().get();
|
||||
if (super.deleteRow(row)) {
|
||||
File file = new File(path);
|
||||
@@ -280,7 +271,7 @@ public class CustomerTabSkinFile
|
||||
}
|
||||
|
||||
public void onFileTableMoveToCompanyPathAction(ActionEvent event) {
|
||||
CompanyCustomerFileViewModel selectedItem = getSelectedItem();
|
||||
CustomerFileViewModel selectedItem = getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
return;
|
||||
}
|
||||
@@ -309,46 +300,17 @@ public class CustomerTabSkinFile
|
||||
loadTableDataSet();
|
||||
}
|
||||
|
||||
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();
|
||||
CustomerEvaluationFormUpdateTask task = new CustomerEvaluationFormUpdateTask();
|
||||
task.setCustomer(getCompanyCustomerService().findById(viewModel.getId().get()));
|
||||
UITools.showTaskDialogAndWait("更新评价表", task, consumer -> {
|
||||
initializeTask(task, "更新评价表", msg -> consumer.accept(Message.info(msg)));
|
||||
});
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
CustomerNextSignDateTask task = new CustomerNextSignDateTask();
|
||||
task.setCustomer(getEntity());
|
||||
UITools.showTaskDialogAndWait("计算客户的下一个评价日期", task, null);
|
||||
}
|
||||
|
||||
private CompanyCustomerFileService getCompanyCustomerFileService() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.ecep.contract.controller.project.satisfaction_survey.CustomerSatisfac
|
||||
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
|
||||
import com.ecep.contract.controller.table.cell.ProjectTableCell;
|
||||
import com.ecep.contract.converter.EntityStringConverter;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.CustomerCatalogVo;
|
||||
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
|
||||
import com.ecep.contract.vo.EmployeeVo;
|
||||
@@ -96,7 +96,7 @@ public class CustomerTabSkinSatisfactionSurvey
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParamUtils.Builder getSpecification(CompanyCustomerVo parent) {
|
||||
public ParamUtils.Builder getSpecification(CustomerVo parent) {
|
||||
ParamUtils.Builder params = getSpecification();
|
||||
params.equals("project.customer", parent.getId());
|
||||
return params;
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
package com.ecep.contract.controller.customer;
|
||||
package com.ecep.contract.controller.customer.tasker;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.WebSocketClientTasker;
|
||||
import com.ecep.contract.task.Tasker;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 客户评估表更新任务
|
||||
*/
|
||||
public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> implements WebSocketClientTasker {
|
||||
public class CustomerEvaluationFormUpdateTask extends Tasker<Object> implements WebSocketClientTasker {
|
||||
@Setter
|
||||
private CompanyCustomerVo customer;
|
||||
private CustomerVo customer;
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return getClass().getSimpleName();
|
||||
return "CustomerEvaluationFormUpdateTask";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ecep.contract.controller.customer;
|
||||
package com.ecep.contract.controller.customer.tasker;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -6,19 +6,19 @@ 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 com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
public class CompanyCustomerNextSignDateTask extends Tasker<Object> implements WebSocketClientTasker {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerNextSignDateTask.class);
|
||||
public class CustomerNextSignDateTask extends Tasker<Object> implements WebSocketClientTasker {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CustomerNextSignDateTask.class);
|
||||
|
||||
@Setter
|
||||
private CompanyCustomerVo customer;
|
||||
private CustomerVo customer;
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return getClass().getSimpleName();
|
||||
return "CustomerNextSignDateTask";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.ecep.contract.task;
|
||||
package com.ecep.contract.controller.customer.tasker;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.WebSocketClientTasker;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.task.Tasker;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -11,10 +12,10 @@ import lombok.Setter;
|
||||
* 客户文件重建任务类
|
||||
* 用于通过WebSocket与服务器通信,重建客户相关文件
|
||||
*/
|
||||
public class CompanyCustomerRebuildFilesTasker extends Tasker<Object> implements WebSocketClientTasker {
|
||||
public class CustomerRebuildFilesTasker extends Tasker<Object> implements WebSocketClientTasker {
|
||||
@Getter
|
||||
@Setter
|
||||
private CompanyCustomerVo companyCustomer;
|
||||
private CustomerVo companyCustomer;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -22,7 +23,7 @@ public class CompanyCustomerRebuildFilesTasker extends Tasker<Object> implements
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return "CompanyCustomerRebuildFilesTasker";
|
||||
return "CustomerRebuildFilesTasker";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -13,7 +13,7 @@ import com.ecep.contract.controller.table.cell.EmployeeTableCell;
|
||||
import com.ecep.contract.converter.CompanyStringConverter;
|
||||
import com.ecep.contract.converter.EmployeeStringConverter;
|
||||
import com.ecep.contract.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.service.ProjectBidService;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
@@ -56,7 +56,7 @@ public class ProjectTabSkinBid
|
||||
@Setter
|
||||
private CompanyService companyService;
|
||||
@Setter
|
||||
private CompanyCustomerService customerService;
|
||||
private CustomerService customerService;
|
||||
@Setter
|
||||
private CompanyCustomerFileService customerFileService;
|
||||
|
||||
@@ -163,9 +163,9 @@ public class ProjectTabSkinBid
|
||||
return companyStringConverter;
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCompanyCustomerService() {
|
||||
private CustomerService getCompanyCustomerService() {
|
||||
if (customerService == null) {
|
||||
customerService = getBean(CompanyCustomerService.class);
|
||||
customerService = getBean(CustomerService.class);
|
||||
}
|
||||
return customerService;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.ecep.contract.controller.table.cell.EmployeeTableCell;
|
||||
import com.ecep.contract.converter.CompanyStringConverter;
|
||||
import com.ecep.contract.converter.EmployeeStringConverter;
|
||||
import com.ecep.contract.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.service.CustomerSatisfactionSurveyService;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
@@ -52,7 +52,7 @@ public class ProjectTabSkinCustomerSatisfactionSurvey
|
||||
@Setter
|
||||
private CompanyService companyService;
|
||||
@Setter
|
||||
private CompanyCustomerService customerService;
|
||||
private CustomerService customerService;
|
||||
@Setter
|
||||
private CompanyCustomerFileService customerFileService;
|
||||
|
||||
@@ -141,9 +141,9 @@ public class ProjectTabSkinCustomerSatisfactionSurvey
|
||||
return companyStringConverter;
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCompanyCustomerService() {
|
||||
private CustomerService getCompanyCustomerService() {
|
||||
if (customerService == null) {
|
||||
customerService = getBean(CompanyCustomerService.class);
|
||||
customerService = getBean(CustomerService.class);
|
||||
}
|
||||
return customerService;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
|
||||
import com.ecep.contract.converter.CompanyStringConverter;
|
||||
import com.ecep.contract.converter.EmployeeStringConverter;
|
||||
import com.ecep.contract.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.service.ProjectQuotationService;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
@@ -69,7 +69,7 @@ public class ProjectTabSkinQuotation
|
||||
@Setter
|
||||
private CompanyService companyService;
|
||||
@Setter
|
||||
private CompanyCustomerService customerService;
|
||||
private CustomerService customerService;
|
||||
@Setter
|
||||
private CompanyCustomerFileService customerFileService;
|
||||
|
||||
@@ -174,9 +174,9 @@ public class ProjectTabSkinQuotation
|
||||
return companyStringConverter;
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCompanyCustomerService() {
|
||||
private CustomerService getCompanyCustomerService() {
|
||||
if (customerService == null) {
|
||||
customerService = getBean(CompanyCustomerService.class);
|
||||
customerService = getBean(CustomerService.class);
|
||||
}
|
||||
return customerService;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ProjectBidTabSkinBase
|
||||
@Setter
|
||||
private CompanyService companyService;
|
||||
@Setter
|
||||
private CompanyCustomerService customerService;
|
||||
private CustomerService customerService;
|
||||
@Setter
|
||||
private CompanyCustomerFileService customerFileService;
|
||||
@Setter
|
||||
@@ -266,7 +266,7 @@ public class ProjectBidTabSkinBase
|
||||
}
|
||||
Integer companyId = project.getCustomerId();
|
||||
CompanyVo company = getCompanyService().findById(companyId);
|
||||
CompanyCustomerVo customer = getCompanyCustomerService().findByCompany(company);
|
||||
CustomerVo customer = getCompanyCustomerService().findByCompany(company);
|
||||
if (customer == null) {
|
||||
// 没有对应的客户
|
||||
return;
|
||||
@@ -275,7 +275,7 @@ public class ProjectBidTabSkinBase
|
||||
CompanyCustomerFileService fileService = getBean(CompanyCustomerFileService.class);
|
||||
|
||||
// 获取客户资信评估表
|
||||
List<CompanyCustomerFileVo> list = fileService.findAllByCustomerAndType(customer,
|
||||
List<CustomerFileVo> list = fileService.findAllByCustomerAndType(customer,
|
||||
CustomerFileType.EvaluationForm);
|
||||
if (list.isEmpty()) {
|
||||
// 没有评估表
|
||||
@@ -285,7 +285,7 @@ public class ProjectBidTabSkinBase
|
||||
// 在时间范围内是否有评估表
|
||||
LocalDateTime applyTime = getViewModel().getApplyTime().get();
|
||||
LocalDate verifyDate = applyTime.toLocalDate();
|
||||
CompanyCustomerFileVo file = list.stream()
|
||||
CustomerFileVo file = list.stream()
|
||||
.filter(v -> v.getSignDate() != null && v.isValid())
|
||||
.filter(v -> v.getType() == CustomerFileType.EvaluationForm)
|
||||
.filter(v -> MyDateTimeUtils.dateValidFilter(verifyDate, v.getSignDate(), v.getSignDate().plusYears(1),
|
||||
@@ -423,9 +423,9 @@ public class ProjectBidTabSkinBase
|
||||
return companyStringConverter;
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCompanyCustomerService() {
|
||||
private CustomerService getCompanyCustomerService() {
|
||||
if (customerService == null) {
|
||||
customerService = getBean(CompanyCustomerService.class);
|
||||
customerService = getBean(CustomerService.class);
|
||||
}
|
||||
return customerService;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.ecep.contract.converter.EmployeeStringConverter;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.service.CompanyCustomerEvaluationFormFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.service.ProjectQuotationService;
|
||||
import com.ecep.contract.service.ProjectService;
|
||||
@@ -54,7 +54,7 @@ public class ProjectQuotationTabSkinBase
|
||||
@Setter
|
||||
private CompanyService companyService;
|
||||
@Setter
|
||||
private CompanyCustomerService customerService;
|
||||
private CustomerService customerService;
|
||||
@Setter
|
||||
private CompanyCustomerFileService customerFileService;
|
||||
@Setter
|
||||
@@ -244,8 +244,8 @@ public class ProjectQuotationTabSkinBase
|
||||
return getBean(CompanyStringConverter.class);
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCompanyCustomerService() {
|
||||
return getBean(CompanyCustomerService.class);
|
||||
private CustomerService getCompanyCustomerService() {
|
||||
return getBean(CustomerService.class);
|
||||
}
|
||||
|
||||
private CompanyCustomerFileService getCompanyCustomerFileService() {
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.ecep.contract.converter.CompanyStringConverter;
|
||||
import com.ecep.contract.converter.EmployeeStringConverter;
|
||||
import com.ecep.contract.service.CompanyCustomerEvaluationFormFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.service.ProjectCostService;
|
||||
import com.ecep.contract.service.ProjectQuotationService;
|
||||
@@ -27,8 +27,8 @@ import com.ecep.contract.util.ProxyUtils;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.CustomerSatisfactionSurveyViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerFileVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
@@ -64,7 +64,7 @@ public class CustomerSatisfactionSurveyTabSkinBase
|
||||
@Setter
|
||||
private CompanyService companyService;
|
||||
@Setter
|
||||
private CompanyCustomerService customerService;
|
||||
private CustomerService customerService;
|
||||
@Setter
|
||||
private CompanyCustomerFileService customerFileService;
|
||||
@Setter
|
||||
@@ -228,13 +228,13 @@ public class CustomerSatisfactionSurveyTabSkinBase
|
||||
}
|
||||
Integer companyId = project.getCustomerId();
|
||||
CompanyVo company = getCompanyService().findById(companyId);
|
||||
CompanyCustomerVo customer = getCompanyCustomerService().findByCompany(company);
|
||||
CustomerVo customer = getCompanyCustomerService().findByCompany(company);
|
||||
if (customer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CompanyCustomerFileService companyCustomerFileService = getBean(CompanyCustomerFileService.class);
|
||||
List<CompanyCustomerFileVo> list = companyCustomerFileService.findAllByCustomerAndType(customer,
|
||||
List<CustomerFileVo> list = companyCustomerFileService.findAllByCustomerAndType(customer,
|
||||
CustomerFileType.EvaluationForm);
|
||||
if (list.isEmpty()) {
|
||||
return;
|
||||
@@ -242,7 +242,7 @@ public class CustomerSatisfactionSurveyTabSkinBase
|
||||
|
||||
LocalDateTime applyTime = getViewModel().getApplyTime().get();
|
||||
LocalDate verifyDate = applyTime.toLocalDate();
|
||||
CompanyCustomerFileVo file = list.stream()
|
||||
CustomerFileVo file = list.stream()
|
||||
.filter(v -> v.getSignDate() != null && v.isValid())
|
||||
.filter(v -> v.getType() == CustomerFileType.EvaluationForm)
|
||||
.filter(v -> MyDateTimeUtils.dateValidFilter(verifyDate, v.getSignDate(), v.getSignDate().plusYears(1),
|
||||
@@ -314,9 +314,9 @@ public class CustomerSatisfactionSurveyTabSkinBase
|
||||
return companyStringConverter;
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCompanyCustomerService() {
|
||||
private CustomerService getCompanyCustomerService() {
|
||||
if (customerService == null) {
|
||||
customerService = getBean(CompanyCustomerService.class);
|
||||
customerService = getBean(CustomerService.class);
|
||||
}
|
||||
return customerService;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.controller.company.AbstCompanyTableTabSkin;
|
||||
import com.ecep.contract.controller.company.CompanyWindowController;
|
||||
import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
|
||||
import com.ecep.contract.controller.table.cell.CompanyFilePathTableCell;
|
||||
import com.ecep.contract.controller.table.cell.CompanyFileTypeTableCell;
|
||||
import com.ecep.contract.controller.table.cell.FilePathTableCell;
|
||||
import com.ecep.contract.service.CloudTycService;
|
||||
import com.ecep.contract.service.CompanyFileService;
|
||||
import com.ecep.contract.service.CompanyFileTypeService;
|
||||
@@ -92,7 +92,7 @@ public class CompanyTabSkinFile
|
||||
typeColumn.setCellFactory(CompanyFileTypeTableCell.forTableColumn(getCachedBean(CompanyFileTypeService.class)));
|
||||
|
||||
filePathColumn.setCellValueFactory(param -> param.getValue().getFilePath());
|
||||
filePathColumn.setCellFactory(param -> new CompanyFilePathTableCell<>(viewModel.getPath()));
|
||||
filePathColumn.setCellFactory(FilePathTableCell.forTableColumn(viewModel.getPath()));
|
||||
|
||||
applyDateColumn.setCellValueFactory(param -> param.getValue().getApplyDate());
|
||||
expiringDateColumn.setCellValueFactory(param -> param.getValue().getExpiringDate());
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.ecep.contract.controller.vendor.VendorWindowController;
|
||||
import com.ecep.contract.converter.ContractStringConverter;
|
||||
import com.ecep.contract.service.VendorService;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.ContractTypeVo;
|
||||
@@ -445,7 +445,7 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin {
|
||||
public void onContractOpenRelativeCompanyCustomerAction(ActionEvent event) {
|
||||
ContractVo contract = getEntity();
|
||||
CompanyVo company = controller.getCompanyService().findById(contract.getCompanyId());
|
||||
CompanyCustomerVo companyCustomer = getCompanyCustomerService().findByCompany(company);
|
||||
CustomerVo companyCustomer = getCompanyCustomerService().findByCompany(company);
|
||||
CompanyCustomerWindowController.show(companyCustomer, null);
|
||||
}
|
||||
|
||||
@@ -465,8 +465,8 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin {
|
||||
UITools.autoCompletion(textField, viewModel.getProject(), getProjectService());
|
||||
}
|
||||
|
||||
public CompanyCustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CompanyCustomerService.class);
|
||||
public CustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CustomerService.class);
|
||||
}
|
||||
|
||||
public ProjectService getProjectService() {
|
||||
|
||||
@@ -150,8 +150,8 @@ public class ContractUpdater implements MessageHolder {
|
||||
return getBean(VendorService.class);
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCustomerService() {
|
||||
return getBean(CompanyCustomerService.class);
|
||||
private CustomerService getCustomerService() {
|
||||
return getBean(CustomerService.class);
|
||||
}
|
||||
|
||||
private CompanyService getCompanyService() {
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.ecep.contract.controller.table.cell;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.scene.control.TableCell;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CompanyFilePathTableCell<T> extends TableCell<T, String> {
|
||||
private SimpleStringProperty companyPathProperty;
|
||||
|
||||
public void setCompanyPathProperty(SimpleStringProperty property) {
|
||||
this.companyPathProperty = property;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText("");
|
||||
return;
|
||||
}
|
||||
if (companyPathProperty != null) {
|
||||
String path = companyPathProperty.get();
|
||||
if (StringUtils.hasText(path)) {
|
||||
if (item.startsWith(path)) {
|
||||
item = "~" + item.substring(path.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
setText(item);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.service.CompanyCustomerEvaluationFormFileService;
|
||||
import com.ecep.contract.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CustomerFileVo;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class EvaluationFileTableCell<V> extends AsyncUpdateTableCell<V, Integer,
|
||||
if (vo == null || vo.getCustomerFile() == null) {
|
||||
return super.format(vo);
|
||||
}
|
||||
CompanyCustomerFileVo customerFile = getFileService().findById(vo.getCustomerFile());
|
||||
CustomerFileVo customerFile = getFileService().findById(vo.getCustomerFile());
|
||||
String path = customerFile.getFilePath();
|
||||
if (StringUtils.hasText(path)) {
|
||||
File file = new File(path);
|
||||
|
||||
@@ -6,20 +6,26 @@ 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;
|
||||
private StringProperty rootPathProperty;
|
||||
|
||||
/**
|
||||
* 创建一个用于表格列的单元格工厂
|
||||
*/
|
||||
public static <T> Callback<TableColumn<T, String>, TableCell<T, String>> forTableColumn(
|
||||
StringProperty parentPath) {
|
||||
return param -> new FilePathTableCell<>(parentPath);
|
||||
StringProperty rootPath) {
|
||||
return param -> new FilePathTableCell<>(rootPath);
|
||||
}
|
||||
|
||||
public FilePathTableCell(StringProperty parentPath) {
|
||||
this.path = parentPath;
|
||||
this.rootPathProperty = parentPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,7 +36,7 @@ public class FilePathTableCell<V> extends TableCell<V, String> {
|
||||
return;
|
||||
}
|
||||
|
||||
String path = this.path.get();
|
||||
String path = this.rootPathProperty.get();
|
||||
if (StringUtils.hasText(path)) {
|
||||
if (item.startsWith(path)) {
|
||||
item = "~" + item.substring(path.length());
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.time.LocalDate;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.ecep.contract.service.VendorService;
|
||||
import com.ecep.contract.task.VendorReBuildFilesTasker;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -73,13 +74,14 @@ public class VendorManagerWindowController
|
||||
MessageHolder messageHolder = (level, msg) -> {
|
||||
System.out.println(level + ">" + msg);
|
||||
};
|
||||
|
||||
VendorReBuildFilesTasker tasker = new VendorReBuildFilesTasker();
|
||||
while (true) {
|
||||
Page<VendorVo> page = vendorService.findAll(null, pageRequest);
|
||||
for (VendorVo companyVendor : page) {
|
||||
MessageHolder sub = messageHolder
|
||||
.sub(page.getNumber() + "/" + page.getTotalPages() + " #" + companyVendor.getId() + ">");
|
||||
vendorService.reBuildingFiles(companyVendor, sub);
|
||||
tasker.setVendor(companyVendor);
|
||||
tasker.callRemoteTask(sub, getLocale(), companyVendor.getId());
|
||||
}
|
||||
if (!page.hasNext()) {
|
||||
break;
|
||||
|
||||
34
client/src/main/java/com/ecep/contract/controller/vendor/VendorNextSignDateTask.java
vendored
Normal file
34
client/src/main/java/com/ecep/contract/controller/vendor/VendorNextSignDateTask.java
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.ecep.contract.controller.vendor;
|
||||
|
||||
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.VendorVo;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
public class VendorNextSignDateTask extends Tasker<Object> implements WebSocketClientTasker {
|
||||
private static final Logger logger = LoggerFactory.getLogger(VendorNextSignDateTask.class);
|
||||
|
||||
@Setter
|
||||
private VendorVo vendor;
|
||||
|
||||
@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(), vendor.getId());
|
||||
}
|
||||
}
|
||||
@@ -2,24 +2,28 @@ package com.ecep.contract.controller.vendor;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.VendorType;
|
||||
import com.ecep.contract.util.ComboBoxUtils;
|
||||
import com.ecep.contract.controller.company.CompanyWindowController;
|
||||
import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
|
||||
import com.ecep.contract.service.CompanyContactService;
|
||||
import com.ecep.contract.service.VendorService;
|
||||
import com.ecep.contract.service.QueryService;
|
||||
import com.ecep.contract.service.VendorCatalogService;
|
||||
import com.ecep.contract.service.VendorService;
|
||||
import com.ecep.contract.service.VendorTypeService;
|
||||
import com.ecep.contract.util.ComboBoxUtils;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.CompanyContactViewModel;
|
||||
import com.ecep.contract.vm.CompanyVendorViewModel;
|
||||
import com.ecep.contract.vm.CompanyViewModel;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
import com.ecep.contract.vo.CompanyContactVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
@@ -27,6 +31,7 @@ import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.util.StringConverter;
|
||||
import javafx.util.converter.LocalDateStringConverter;
|
||||
import javafx.util.converter.LocalDateTimeStringConverter;
|
||||
|
||||
@@ -59,12 +64,31 @@ public class VendorTabSkinBase
|
||||
controller.developDateField.setConverter(converter);
|
||||
controller.developDateField.valueProperty().bindBidirectional(viewModel.getDevelopDate());
|
||||
|
||||
ComboBoxUtils.initialComboBox(controller.catalogField, viewModel.getCatalog(), getCachedBean(VendorCatalogService.class), true);
|
||||
ComboBoxUtils.initialComboBox(controller.catalogField, viewModel.getCatalog(),
|
||||
getCachedBean(VendorCatalogService.class), true);
|
||||
|
||||
initialTypeComboBox();
|
||||
|
||||
controller.protocolProviderField.selectedProperty().bindBidirectional(viewModel.getProtocolProvider());
|
||||
UITools.autoCompletion(controller.contactField, viewModel.getContact(), getCompanyContactService());
|
||||
UITools.autoCompletion(controller.contactField, viewModel.getContact(),
|
||||
new QueryService<CompanyContactVo, CompanyContactViewModel>() {
|
||||
@Override
|
||||
public CompanyContactVo findById(Integer id) {
|
||||
return getCompanyContactService().findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyContactVo> search(String searchText) {
|
||||
VendorVo vendor = getEntity();
|
||||
CompanyVo company = controller.getCompanyService().findById(vendor.getCompanyId());
|
||||
return getCompanyContactService().searchByCompany(company, searchText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringConverter<CompanyContactVo> getStringConverter() {
|
||||
return getCompanyContactService().getStringConverter();
|
||||
}
|
||||
});
|
||||
controller.purchaseField.textProperty().bindBidirectional(viewModel.getPurchase());
|
||||
|
||||
controller.pathField.textProperty().bind(viewModel.getPath());
|
||||
@@ -115,7 +139,7 @@ public class VendorTabSkinBase
|
||||
VendorVo entity = getEntity();
|
||||
String path = entity.getPath();
|
||||
File initialDirectory = null;
|
||||
|
||||
|
||||
// 如果当前已经设置了目录并且路径有效,则设置初始目录为该目录
|
||||
if (StringUtils.hasText(path)) {
|
||||
File dir = new File(path);
|
||||
@@ -123,16 +147,16 @@ public class VendorTabSkinBase
|
||||
initialDirectory = dir;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 如果没有有效的初始目录,则使用基础路径
|
||||
if (initialDirectory == null) {
|
||||
initialDirectory = getCompanyVendorService().getBasePath();
|
||||
}
|
||||
|
||||
|
||||
if (initialDirectory != null) {
|
||||
chooser.setInitialDirectory(initialDirectory);
|
||||
}
|
||||
|
||||
|
||||
File newDirectory = chooser.showDialog(getTab().getContent().getScene().getWindow());
|
||||
if (newDirectory != null) {
|
||||
entity.setPath(newDirectory.getAbsolutePath());
|
||||
|
||||
@@ -3,40 +3,34 @@ package com.ecep.contract.controller.vendor;
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.ecep.contract.service.VendorFileTypeService;
|
||||
import com.ecep.contract.vo.VendorFileVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.VendorFileTypeLocalVo;
|
||||
import javafx.scene.control.*;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.DesktopUtils;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.controller.tab.TabSkin;
|
||||
import com.ecep.contract.model.BaseEnumEntity;
|
||||
import com.ecep.contract.controller.table.cell.FilePathTableCell;
|
||||
import com.ecep.contract.service.VendorFileService;
|
||||
import com.ecep.contract.service.VendorFileTypeService;
|
||||
import com.ecep.contract.task.CompanyVendorEvaluationFormUpdateTask;
|
||||
import com.ecep.contract.task.VendorReBuildFilesTasker;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.CompanyVendorFileViewModel;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.VendorFileTypeLocalVo;
|
||||
import com.ecep.contract.vo.VendorFileVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableMap;
|
||||
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 lombok.Setter;
|
||||
|
||||
@@ -59,6 +53,9 @@ public class VendorTabSkinFile
|
||||
public MenuItem fileTable_menu_refresh;
|
||||
public MenuItem fileTable_menu_del;
|
||||
public MenuItem fileTable_menu_move_to_company_path;
|
||||
public Menu fileTable_menu_set_valid;
|
||||
public MenuItem fileTable_menu_set_valid_true;
|
||||
public MenuItem fileTable_menu_set_valid_false;
|
||||
|
||||
public Button fileTable_reBuildBtn;
|
||||
public Button fileTable_updateEvaluationFormBuildBtn;
|
||||
@@ -97,10 +94,13 @@ public class VendorTabSkinFile
|
||||
param.getValue().getType()).map(VendorFileTypeLocalVo::getValue));
|
||||
|
||||
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);
|
||||
fileTable_validColumn.setCellValueFactory(param -> param.getValue().getValid());
|
||||
fileTable_validColumn.setCellFactory(param -> new CheckBoxTableCell<>());
|
||||
@@ -113,6 +113,14 @@ public class VendorTabSkinFile
|
||||
fileTable_menu_del.setOnAction(this::onTableDeleteAction);
|
||||
fileTable_menu_move_to_company_path.setOnAction(this::onFileTableMoveToCompanyPathAction);
|
||||
|
||||
// 设置有效性菜单项事件处理
|
||||
fileTable_menu_set_valid_true.setOnAction(e -> setValidValue(true));
|
||||
fileTable_menu_set_valid_false.setOnAction(e -> setValidValue(false));
|
||||
|
||||
// 当表格中没有选中项时,菜单项不显示
|
||||
fileTable_menu_set_valid.visibleProperty()
|
||||
.bind(Bindings.isNotEmpty(table.getSelectionModel().getSelectedItems()));
|
||||
|
||||
super.initializeTab();
|
||||
}
|
||||
|
||||
@@ -174,23 +182,19 @@ public class VendorTabSkinFile
|
||||
ccf.setType(VendorFileType.General);
|
||||
ccf.setFilePath(dest.getAbsolutePath());
|
||||
ccf.setValid(false);
|
||||
VendorFileVo saved = getVendorFileService().save(ccf);
|
||||
getVendorFileService().save(ccf);
|
||||
}
|
||||
}
|
||||
loadTableDataSet();
|
||||
}
|
||||
|
||||
public void onFileReBuildingAction(ActionEvent event) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
VendorVo companyVendor = getParent();
|
||||
if (getCompanyVendorService().reBuildingFiles(companyVendor, (level, msg) -> setStatus(msg))) {
|
||||
loadTableDataSet();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
VendorReBuildFilesTasker tasker = new VendorReBuildFilesTasker();
|
||||
tasker.setVendor(getEntity());
|
||||
UITools.showTaskDialogAndWait("重建文件", tasker, null);
|
||||
if (tasker.isModified()) {
|
||||
loadTableDataSet();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -278,43 +282,15 @@ public class VendorTabSkinFile
|
||||
|
||||
public void onUpdateEvaluationFormAction(ActionEvent event) {
|
||||
CompanyVendorEvaluationFormUpdateTask task = new CompanyVendorEvaluationFormUpdateTask();
|
||||
task.setVendor(getEntity());
|
||||
UITools.showTaskDialogAndWait("更新评价表", task, null);
|
||||
loadTableDataSet();
|
||||
}
|
||||
|
||||
public void onCalcNextSignDateAction(ActionEvent event) {
|
||||
UITools.showDialogAndWait("计算供应商下一个评价日期", "依据已有的供应商评价表和登记采购的合同计算下一个评价日期", ds -> {
|
||||
VendorVo companyVendor = getCompanyVendorService().findById(viewModel.getId().get());
|
||||
LocalDate nextSignDate = getVendorFileService().getNextSignDate(companyVendor, msg -> {
|
||||
Platform.runLater(() -> {
|
||||
ds.add(msg);
|
||||
});
|
||||
});
|
||||
if (nextSignDate != null) {
|
||||
Platform.runLater(() -> {
|
||||
ds.add("下一个评价日期:" + nextSignDate);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class FileTableFilePathTableCell extends TableCell<CompanyVendorFileViewModel, 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);
|
||||
}
|
||||
VendorNextSignDateTask task = new VendorNextSignDateTask();
|
||||
task.setVendor(getEntity());
|
||||
UITools.showTaskDialogAndWait("计算供应商的下一个评价日期", task, null);
|
||||
}
|
||||
|
||||
public VendorFileService getVendorFileService() {
|
||||
@@ -324,4 +300,28 @@ public class VendorTabSkinFile
|
||||
return vendorFileService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置选中行的valid值
|
||||
*
|
||||
* @param valid 有效性值
|
||||
*/
|
||||
private void setValidValue(boolean valid) {
|
||||
List<CompanyVendorFileViewModel> selectedItems = getTableView().getSelectionModel().getSelectedItems();
|
||||
if (selectedItems.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (CompanyVendorFileViewModel item : selectedItems) {
|
||||
// 更新视图模型的值
|
||||
item.getValid().set(valid);
|
||||
|
||||
// 保存到后端
|
||||
VendorFileVo entity = loadRowData(item);
|
||||
entity.setValid(valid);
|
||||
saveRowData(entity);
|
||||
}
|
||||
|
||||
setStatus("已更新" + selectedItems.size() + "条记录的有效性状态");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,17 +4,17 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ecep.contract.service.CompanyCustomerService;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.service.CustomerService;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
public class CompanyCustomerStringConverter extends EntityStringConverter<CompanyCustomerVo> {
|
||||
public class CompanyCustomerStringConverter extends EntityStringConverter<CustomerVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyCustomerService service;
|
||||
private CustomerService service;
|
||||
|
||||
public CompanyCustomerStringConverter() {
|
||||
|
||||
|
||||
@@ -63,6 +63,8 @@ public class CloudTycService extends QueryService<CloudTycVo, CloudTycInfoViewMo
|
||||
if (cloudTyc == null) {
|
||||
cloudTyc = new CloudTycVo();
|
||||
cloudTyc.setCompanyId(company.getId());
|
||||
cloudTyc.setCloudId("");
|
||||
cloudTyc.setScore(0);
|
||||
cloudTyc.setActive(false);
|
||||
cloudTyc.setVersion(1);
|
||||
cloudTyc = save(cloudTyc);
|
||||
|
||||
@@ -8,11 +8,11 @@ import org.springframework.stereotype.Service;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CustomerEntityViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerEntityVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
@Service
|
||||
public class CompanyCustomerEntityService extends QueryService<CompanyCustomerEntityVo, CustomerEntityViewModel> {
|
||||
public List<CompanyCustomerEntityVo> findAllByCustomer(CompanyCustomerVo customer) {
|
||||
public List<CompanyCustomerEntityVo> findAllByCustomer(CustomerVo customer) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("customer", customer.getId()).build(), Pageable.unpaged())
|
||||
.getContent();
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Service;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyCustomerEvaluationFormFileViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CustomerFileVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class CompanyCustomerEvaluationFormFileService
|
||||
/**
|
||||
* 根据客户文件查找评估表文件
|
||||
*/
|
||||
public CompanyCustomerEvaluationFormFileVo findByCustomerFile(CompanyCustomerFileVo customerFile) {
|
||||
public CompanyCustomerEvaluationFormFileVo findByCustomerFile(CustomerFileVo customerFile) {
|
||||
return findByCustomerFile(customerFile.getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -17,15 +17,15 @@ import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyCustomerFileViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vm.CustomerFileViewModel;
|
||||
import com.ecep.contract.vo.CustomerFileVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "customer-file")
|
||||
public class CompanyCustomerFileService extends QueryService<CompanyCustomerFileVo, CompanyCustomerFileViewModel> {
|
||||
public class CompanyCustomerFileService extends QueryService<CustomerFileVo, CustomerFileViewModel> {
|
||||
|
||||
public File getEvaluationFormTemplate() {
|
||||
SysConfService confService = SpringApp.getBean(SysConfService.class);
|
||||
@@ -38,11 +38,11 @@ public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile
|
||||
|
||||
@Cacheable
|
||||
@Override
|
||||
public CompanyCustomerFileVo findById(Integer id) {
|
||||
public CustomerFileVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public LocalDate getNextSignDate(CompanyCustomerVo companyCustomer, MessageHolder holder) {
|
||||
public LocalDate getNextSignDate(CustomerVo companyCustomer, MessageHolder holder) {
|
||||
LocalDate miniContractDate = LocalDate.of(2022, 1, 1);
|
||||
Integer companyId = companyCustomer.getCompanyId();
|
||||
|
||||
@@ -57,11 +57,11 @@ public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile
|
||||
}
|
||||
|
||||
// 检索评估表
|
||||
List<CompanyCustomerFileVo> files = findAllByCustomerAndType(companyCustomer,
|
||||
List<CustomerFileVo> files = findAllByCustomerAndType(companyCustomer,
|
||||
CustomerFileType.EvaluationForm);
|
||||
CompanyCustomerFileVo latestFile = files.stream()
|
||||
CustomerFileVo latestFile = files.stream()
|
||||
.filter(v -> v.getSignDate() != null && v.isValid())
|
||||
.max(Comparator.comparing(CompanyCustomerFileVo::getSignDate))
|
||||
.max(Comparator.comparing(CustomerFileVo::getSignDate))
|
||||
.orElse(null);
|
||||
if (latestFile == null) {
|
||||
// 没有有效的评估表的评价日期
|
||||
@@ -104,12 +104,12 @@ public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile
|
||||
return SpringApp.getBean(HolidayService.class).adjustToWorkDay(setupDate.plusDays(-7));
|
||||
}
|
||||
|
||||
public List<CompanyCustomerFileVo> findAllByCustomer(CompanyCustomerVo companyCustomer) {
|
||||
public List<CustomerFileVo> findAllByCustomer(CustomerVo companyCustomer) {
|
||||
return findAll(ParamUtils.builder().equals("customer", companyCustomer).build(), Pageable.unpaged())
|
||||
.getContent();
|
||||
}
|
||||
|
||||
public List<CompanyCustomerFileVo> findAllByCustomerAndType(CompanyCustomerVo customer, CustomerFileType type) {
|
||||
public List<CustomerFileVo> findAllByCustomerAndType(CustomerVo customer, CustomerFileType type) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("customer", customer.getId())
|
||||
.equals("type", type.name())
|
||||
@@ -118,7 +118,7 @@ public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile
|
||||
|
||||
@CacheEvict(allEntries = true)
|
||||
@Override
|
||||
public CompanyCustomerFileVo save(CompanyCustomerFileVo entity) {
|
||||
public CustomerFileVo save(CustomerFileVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,24 +2,23 @@ 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;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.task.CompanyCustomerRebuildFilesTasker;
|
||||
import com.ecep.contract.controller.customer.tasker.CustomerRebuildFilesTasker;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.CompanyCustomerViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import org.springframework.util.StringUtils;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
@Service
|
||||
public class CompanyCustomerService extends QueryService<CompanyCustomerVo, CompanyCustomerViewModel> {
|
||||
public class CustomerService extends QueryService<CustomerVo, CompanyCustomerViewModel> {
|
||||
private File basePath;
|
||||
|
||||
public File getBasePath() {
|
||||
@@ -30,8 +29,8 @@ public class CompanyCustomerService extends QueryService<CompanyCustomerVo, Comp
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public CompanyCustomerVo findByCompany(CompanyVo company) {
|
||||
Page<CompanyCustomerVo> page = findAll(ParamUtils.equal("company", company.getId()), Pageable.ofSize(1));
|
||||
public CustomerVo findByCompany(CompanyVo company) {
|
||||
Page<CustomerVo> page = findAll(ParamUtils.equal("company", company.getId()), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -45,14 +44,14 @@ public class CompanyCustomerService extends QueryService<CompanyCustomerVo, Comp
|
||||
* @param holder 消息持有者,用于显示任务执行过程中的消息
|
||||
* @return 如果文件重建成功则返回true,否则返回false
|
||||
*/
|
||||
public boolean reBuildingFiles(CompanyCustomerVo companyCustomer, MessageHolder holder) {
|
||||
public boolean reBuildingFiles(CustomerVo companyCustomer, MessageHolder holder) {
|
||||
// 首先确保客户有有效的路径
|
||||
if (!makePathAbsent(companyCustomer)) {
|
||||
holder.warn("无法创建或确认客户路径,文件重建可能失败");
|
||||
}
|
||||
|
||||
// 创建并配置文件重建任务
|
||||
CompanyCustomerRebuildFilesTasker tasker = new CompanyCustomerRebuildFilesTasker();
|
||||
CustomerRebuildFilesTasker tasker = new CustomerRebuildFilesTasker();
|
||||
tasker.setCompanyCustomer(companyCustomer);
|
||||
|
||||
// 显示任务对话框并等待任务完成
|
||||
@@ -68,7 +67,7 @@ public class CompanyCustomerService extends QueryService<CompanyCustomerVo, Comp
|
||||
* @param companyCustomer 客户对象
|
||||
* @return 如果成功创建路径并设置则返回true,否则返回false
|
||||
*/
|
||||
public boolean makePathAbsent(CompanyCustomerVo companyCustomer) {
|
||||
public boolean makePathAbsent(CustomerVo companyCustomer) {
|
||||
String path = companyCustomer.getPath();
|
||||
if (StringUtils.hasText(path)) {
|
||||
File file = new File(path);
|
||||
@@ -94,7 +93,7 @@ public class CompanyCustomerService extends QueryService<CompanyCustomerVo, Comp
|
||||
* @param companyCustomer 客户对象
|
||||
* @return 创建的目录对象,如果创建失败则返回null
|
||||
*/
|
||||
private File makePath(CompanyCustomerVo companyCustomer) {
|
||||
private File makePath(CustomerVo companyCustomer) {
|
||||
File basePath = getBasePath();
|
||||
Integer companyId = companyCustomer.getCompanyId();
|
||||
CompanyVo company = SpringApp.getBean(CompanyService.class).findById(companyId);
|
||||
@@ -1,36 +1,49 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyVendorFileViewModel;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import com.ecep.contract.vo.VendorFileVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.model.VendorFileTypeLocal;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyVendorFileViewModel;
|
||||
import com.ecep.contract.vo.VendorFileVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
|
||||
@Service
|
||||
public class VendorFileService extends QueryService<VendorFileVo, CompanyVendorFileViewModel> {
|
||||
public File getEvaluationFormTemplate() {
|
||||
SysConfService confService = SpringApp.getBean(SysConfService.class);
|
||||
String path = confService.getString(CompanyVendorConstant.KEY_EVALUATION_FORM_TEMPLATE);
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
return new File(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取供应商下一个评价表的日期
|
||||
*
|
||||
* @param vendor 供应商
|
||||
* @param state 状态消费者
|
||||
* @return 下一个评价表的日期
|
||||
*/
|
||||
public LocalDate getNextSignDate(VendorVo vendor, Consumer<String> state) {
|
||||
LocalDate miniContractDate = LocalDate.of(2022, 1, 1);
|
||||
|
||||
// 检索全部合同
|
||||
ContractService contractService = SpringApp.getBean(ContractService.class);
|
||||
List<ContractVo> contractList = contractService.findAllByCompanyVendor(vendor, null, null);
|
||||
List<ContractVo> contractList = contractService.findAllByCompanyVendor(vendor, miniContractDate, LocalDate.now());
|
||||
if (contractList.isEmpty()) {
|
||||
state.accept("未发现已登记的合同");
|
||||
return null;
|
||||
|
||||
@@ -65,11 +65,6 @@ public class VendorService extends QueryService<VendorVo, CompanyVendorViewModel
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public boolean reBuildingFiles(VendorVo companyVendor, MessageHolder messageHolder) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'reBuildingFiles'");
|
||||
}
|
||||
|
||||
public void verify(ContractVo contract, MessageHolder holder) {
|
||||
CompanyVo company = companyService.findById(contract.getCompanyId());
|
||||
if (company == null) {
|
||||
|
||||
@@ -19,13 +19,11 @@ import lombok.Setter;
|
||||
public class CloudRkSyncTask extends Tasker<Object> implements WebSocketClientTasker {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CloudRkSyncTask.class);
|
||||
|
||||
@Setter
|
||||
private CompanyVo company;
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
updateTitle(String.format("集团相关方平台同步任务[%s]", company.getName()));
|
||||
return callRemoteTask(holder, getLocale(), company.getId());
|
||||
updateTitle("集团相关方平台同步任务");
|
||||
return callRemoteTask(holder, getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ecep.contract.task;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.WebSocketClientTasker;
|
||||
import com.ecep.contract.service.CloudRkService;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
import lombok.Setter;
|
||||
@@ -23,7 +24,7 @@ public class CompanyRkUpdateTasker extends Tasker<Object> implements WebSocketCl
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
updateTitle("合并更新 " + company.getName());
|
||||
updateTitle("从 集团相关方平台 拉取数据更新 " + company.getName() + " 企业信息");
|
||||
return callRemoteTask(holder, getLocale(), company.getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -4,16 +4,32 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.WebSocketClientTasker;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 更新供应商评价表
|
||||
*/
|
||||
public class CompanyVendorEvaluationFormUpdateTask extends Tasker<Object> {
|
||||
public class CompanyVendorEvaluationFormUpdateTask extends Tasker<Object> implements WebSocketClientTasker {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorEvaluationFormUpdateTask.class);
|
||||
@Setter
|
||||
private VendorVo vendor;
|
||||
|
||||
@Override
|
||||
public void updateProgress(long current, long total) {
|
||||
super.updateProgress(current, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return "CompanyVendorEvaluationFormUpdateTask";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
updateTitle("更新供应商评价表");
|
||||
return null;
|
||||
return callRemoteTask(holder, getLocale(), vendor.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@ import com.ecep.contract.*;
|
||||
import com.ecep.contract.controller.project.cost.ProjectCostImportItemsFromContractsTasker;
|
||||
import com.ecep.contract.model.ContractFileTypeLocal;
|
||||
import com.ecep.contract.service.*;
|
||||
import com.ecep.contract.util.ContextUtils;
|
||||
import com.ecep.contract.vo.*;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.collections.ObservableMap;
|
||||
import javafx.util.converter.NumberStringConverter;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -20,173 +22,101 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
public class ContractVerifyComm {
|
||||
// Project
|
||||
private ProjectService projectService;
|
||||
private ProjectSaleTypeRequireFileTypeService saleTypeRequireFileTypeService;
|
||||
private ProjectSaleTypeService saleTypeService;
|
||||
private ProjectCostService projectCostService;
|
||||
private ProjectQuotationService projectQuotationService;
|
||||
private ProjectBidService projectBidService;
|
||||
// Contract
|
||||
private ContractService contractService;
|
||||
private ContractFileService contractFileService;
|
||||
private ContractFileTypeService contractFileTypeService;
|
||||
private ContractBidVendorService contractBidVendorService;
|
||||
public class ContractVerifyComm implements ContextUtils {
|
||||
ContextUtils parent;
|
||||
|
||||
// Company
|
||||
private CompanyService companyService;
|
||||
private CompanyFileService companyFileService;
|
||||
// Vendor
|
||||
private VendorService vendorService;
|
||||
private VendorGroupService vendorGroupService;
|
||||
private VendorGroupRequireFileTypeService vendorGroupRequireFileTypeService;
|
||||
private ExtendVendorInfoService extendVendorInfoService;
|
||||
// Customer
|
||||
private CompanyCustomerService companyCustomerService;
|
||||
private CompanyCustomerFileService companyCustomerFileService;
|
||||
private CompanyExtendInfoService companyExtendInfoService;
|
||||
// Employee
|
||||
private EmployeeService employeeService;
|
||||
public ContractVerifyComm(ContextUtils parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getBean(Class<T> requiredType) throws BeansException {
|
||||
return parent.getBean(requiredType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCachedBean(Class<T> requiredType) throws BeansException {
|
||||
return parent.getCachedBean(requiredType);
|
||||
}
|
||||
|
||||
private ProjectService getProjectService() {
|
||||
if (projectService == null) {
|
||||
projectService = SpringApp.getBean(ProjectService.class);
|
||||
}
|
||||
return projectService;
|
||||
return getCachedBean(ProjectService.class);
|
||||
}
|
||||
|
||||
private ProjectSaleTypeService getSaleTypeService() {
|
||||
if (saleTypeService == null) {
|
||||
saleTypeService = SpringApp.getBean(ProjectSaleTypeService.class);
|
||||
}
|
||||
return saleTypeService;
|
||||
return getCachedBean(ProjectSaleTypeService.class);
|
||||
}
|
||||
|
||||
ProjectCostService getProjectCostService() {
|
||||
if (projectCostService == null) {
|
||||
projectCostService = SpringApp.getBean(ProjectCostService.class);
|
||||
}
|
||||
return projectCostService;
|
||||
private ProjectCostService getProjectCostService() {
|
||||
return getCachedBean(ProjectCostService.class);
|
||||
}
|
||||
|
||||
ProjectQuotationService getProjectQuotationService() {
|
||||
if (projectQuotationService == null) {
|
||||
projectQuotationService = SpringApp.getBean(ProjectQuotationService.class);
|
||||
}
|
||||
return projectQuotationService;
|
||||
private ProjectQuotationService getProjectQuotationService() {
|
||||
return getCachedBean(ProjectQuotationService.class);
|
||||
}
|
||||
|
||||
ProjectBidService getProjectBidService() {
|
||||
if (projectBidService == null) {
|
||||
projectBidService = SpringApp.getBean(ProjectBidService.class);
|
||||
}
|
||||
return projectBidService;
|
||||
private ProjectBidService getProjectBidService() {
|
||||
return getCachedBean(ProjectBidService.class);
|
||||
}
|
||||
|
||||
private ProjectSaleTypeRequireFileTypeService getSaleTypeRequireFileTypeService() {
|
||||
if (saleTypeRequireFileTypeService == null) {
|
||||
saleTypeRequireFileTypeService = SpringApp.getBean(ProjectSaleTypeRequireFileTypeService.class);
|
||||
}
|
||||
return saleTypeRequireFileTypeService;
|
||||
return getCachedBean(ProjectSaleTypeRequireFileTypeService.class);
|
||||
}
|
||||
|
||||
public ContractService getContractService() {
|
||||
if (contractService == null) {
|
||||
contractService = SpringApp.getBean(ContractService.class);
|
||||
}
|
||||
return contractService;
|
||||
return getCachedBean(ContractService.class);
|
||||
}
|
||||
|
||||
private ContractFileService getContractFileService() {
|
||||
if (contractFileService == null) {
|
||||
contractFileService = SpringApp.getBean(ContractFileService.class);
|
||||
}
|
||||
return contractFileService;
|
||||
return getCachedBean(ContractFileService.class);
|
||||
}
|
||||
|
||||
private ContractFileTypeService getContractFileTypeService() {
|
||||
if (contractFileTypeService == null) {
|
||||
contractFileTypeService = SpringApp.getBean(ContractFileTypeService.class);
|
||||
}
|
||||
return contractFileTypeService;
|
||||
return getCachedBean(ContractFileTypeService.class);
|
||||
}
|
||||
|
||||
private ContractBidVendorService getContractBidVendorService() {
|
||||
if (contractBidVendorService == null) {
|
||||
contractBidVendorService = SpringApp.getBean(ContractBidVendorService.class);
|
||||
}
|
||||
return contractBidVendorService;
|
||||
return getCachedBean(ContractBidVendorService.class);
|
||||
}
|
||||
|
||||
private CompanyService getCompanyService() {
|
||||
if (companyService == null) {
|
||||
companyService = SpringApp.getBean(CompanyService.class);
|
||||
}
|
||||
return companyService;
|
||||
return getBean(CompanyService.class);
|
||||
}
|
||||
|
||||
private CompanyFileService getCompanyFileService() {
|
||||
if (companyFileService == null) {
|
||||
companyFileService = SpringApp.getBean(CompanyFileService.class);
|
||||
}
|
||||
return companyFileService;
|
||||
return getCachedBean(CompanyFileService.class);
|
||||
}
|
||||
|
||||
private VendorGroupService getVendorGroupService() {
|
||||
if (vendorGroupService == null) {
|
||||
vendorGroupService = SpringApp.getBean(VendorGroupService.class);
|
||||
}
|
||||
return vendorGroupService;
|
||||
return getCachedBean(VendorGroupService.class);
|
||||
}
|
||||
|
||||
private VendorGroupRequireFileTypeService getVendorGroupRequireFileTypeService() {
|
||||
if (vendorGroupRequireFileTypeService == null) {
|
||||
vendorGroupRequireFileTypeService = SpringApp.getBean(VendorGroupRequireFileTypeService.class);
|
||||
}
|
||||
return vendorGroupRequireFileTypeService;
|
||||
return getCachedBean(VendorGroupRequireFileTypeService.class);
|
||||
}
|
||||
|
||||
private ExtendVendorInfoService getExtendVendorInfoService() {
|
||||
if (extendVendorInfoService == null) {
|
||||
extendVendorInfoService = SpringApp.getBean(ExtendVendorInfoService.class);
|
||||
}
|
||||
return extendVendorInfoService;
|
||||
return getCachedBean(ExtendVendorInfoService.class);
|
||||
}
|
||||
|
||||
private VendorService getVendorService() {
|
||||
if (vendorService == null) {
|
||||
vendorService = SpringApp.getBean(VendorService.class);
|
||||
}
|
||||
return vendorService;
|
||||
return getCachedBean(VendorService.class);
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCompanyCustomerService() {
|
||||
if (companyCustomerService == null) {
|
||||
companyCustomerService = SpringApp.getBean(CompanyCustomerService.class);
|
||||
}
|
||||
return companyCustomerService;
|
||||
private CustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CustomerService.class);
|
||||
}
|
||||
|
||||
private CompanyCustomerFileService getCompanyCustomerFileService() {
|
||||
if (companyCustomerFileService == null) {
|
||||
companyCustomerFileService = SpringApp.getBean(CompanyCustomerFileService.class);
|
||||
}
|
||||
return companyCustomerFileService;
|
||||
return getCachedBean(CompanyCustomerFileService.class);
|
||||
}
|
||||
|
||||
private CompanyExtendInfoService getCompanyExtendInfoService() {
|
||||
if (companyExtendInfoService == null) {
|
||||
companyExtendInfoService = SpringApp.getBean(CompanyExtendInfoService.class);
|
||||
}
|
||||
return companyExtendInfoService;
|
||||
return getCachedBean(CompanyExtendInfoService.class);
|
||||
}
|
||||
|
||||
private EmployeeService getEmployeeService() {
|
||||
if (employeeService == null) {
|
||||
employeeService = SpringApp.getBean(EmployeeService.class);
|
||||
}
|
||||
return employeeService;
|
||||
return getCachedBean(EmployeeService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,6 +319,7 @@ public class ContractVerifyComm {
|
||||
}
|
||||
}
|
||||
if (verifyVendor.get()) {
|
||||
|
||||
getVendorService().verify(contract, holder);
|
||||
}
|
||||
|
||||
@@ -581,7 +512,7 @@ public class ContractVerifyComm {
|
||||
valid = false;
|
||||
}
|
||||
|
||||
CompanyCustomerVo companyCustomer = getCompanyCustomerService().findByCompany(company);
|
||||
CustomerVo companyCustomer = getCompanyCustomerService().findByCompany(company);
|
||||
if (companyCustomer == null) {
|
||||
holder.warn("合同未关联客户");
|
||||
valid = false;
|
||||
@@ -602,7 +533,7 @@ public class ContractVerifyComm {
|
||||
return valid;
|
||||
}
|
||||
|
||||
private boolean verifyCustomerFileByContract(CompanyCustomerVo companyCustomer, ContractVo contract,
|
||||
private boolean verifyCustomerFileByContract(CustomerVo companyCustomer, ContractVo contract,
|
||||
MessageHolder holder) {
|
||||
List<LocalDate> verifyDates = new ArrayList<>();
|
||||
LocalDate minDate = LocalDate.of(2022, 1, 1);
|
||||
@@ -655,14 +586,14 @@ public class ContractVerifyComm {
|
||||
}
|
||||
|
||||
// 客户
|
||||
List<CompanyCustomerFileVo> files = getCompanyCustomerFileService().findAllByCustomer(companyCustomer);
|
||||
List<CustomerFileVo> files = getCompanyCustomerFileService().findAllByCustomer(companyCustomer);
|
||||
if (files == null || files.isEmpty()) {
|
||||
holder.warn("未见客户评估表");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (LocalDate verifyDate : verifyDates) {
|
||||
CompanyCustomerFileVo customerFile = files.stream()
|
||||
CustomerFileVo customerFile = files.stream()
|
||||
.filter(v -> v.getSignDate() != null && v.isValid())
|
||||
.filter(v -> v.getType() == CustomerFileType.EvaluationForm)
|
||||
.filter(v -> MyDateTimeUtils.dateValidFilter(verifyDate, v.getSignDate(),
|
||||
@@ -673,10 +604,10 @@ public class ContractVerifyComm {
|
||||
}
|
||||
}
|
||||
|
||||
CompanyCustomerFileVo latestFile = files.stream()
|
||||
CustomerFileVo latestFile = files.stream()
|
||||
.filter(v -> v.getSignDate() != null && v.isValid())
|
||||
.filter(v -> v.getType() == CustomerFileType.EvaluationForm)
|
||||
.max(Comparator.comparing(CompanyCustomerFileVo::getSignDate))
|
||||
.max(Comparator.comparing(CustomerFileVo::getSignDate))
|
||||
.orElse(null);
|
||||
|
||||
if (latestFile == null) {
|
||||
|
||||
@@ -1,4 +1,55 @@
|
||||
package com.ecep.contract.task;
|
||||
|
||||
public class VendorReBuildFilesTasker {
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.WebSocketClientTasker;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 供应商文件重建任务器客户端实现
|
||||
* 用于通过WebSocket与服务器通信,重建供应商相关文件
|
||||
*/
|
||||
public class VendorReBuildFilesTasker extends Tasker<Object> implements WebSocketClientTasker {
|
||||
private static final Logger logger = LoggerFactory.getLogger(VendorReBuildFilesTasker.class);
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VendorVo vendor;
|
||||
|
||||
@Getter
|
||||
protected boolean modified = false;
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return "VendorReBuildFilesTasker";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(long current, long total) {
|
||||
super.updateProgress(current, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
updateTitle("重建供应商文件");
|
||||
if (vendor == null) {
|
||||
holder.addMessage(java.util.logging.Level.SEVERE, "供应商信息不能为空");
|
||||
return null;
|
||||
}
|
||||
return callRemoteTask(holder, getLocale(), vendor.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理从服务器返回的修改状态
|
||||
* 当服务器端更新此属性时,客户端会接收到更新
|
||||
*
|
||||
* @param modified 文件是否被修改
|
||||
*/
|
||||
public void setModified(boolean modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.ecep.contract.constant.ServiceConstant;
|
||||
public class ParamUtils {
|
||||
/**
|
||||
* 创建日期范围查询参数
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param begin 开始日期
|
||||
* @param end 结束日期
|
||||
@@ -28,7 +28,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 创建等于条件查询参数
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param value 查询值
|
||||
* @return 包含等于条件的查询参数Map
|
||||
@@ -39,7 +39,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 创建字符串模糊查询参数
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param value 模糊查询的字符串值
|
||||
* @return 包含模糊查询条件的查询参数Map
|
||||
@@ -52,7 +52,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 创建日期模糊查询参数
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param value 模糊查询的日期值
|
||||
* @return 包含日期模糊查询条件的查询参数Map
|
||||
@@ -65,7 +65,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 创建非空条件查询参数
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @return 包含非空条件的查询参数Map
|
||||
*/
|
||||
@@ -77,7 +77,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 创建小于条件的日期查询参数
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param value 比较的日期值
|
||||
* @return 包含小于条件的查询参数Map
|
||||
@@ -90,7 +90,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 创建参数构建器实例
|
||||
*
|
||||
*
|
||||
* @return Builder实例,用于链式构建复杂查询条件
|
||||
*/
|
||||
public static Builder builder() {
|
||||
@@ -114,7 +114,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 添加非空条件到构建器
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
*/
|
||||
@@ -125,7 +125,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 添加小于条件到构建器(针对日期类型)
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param value 比较的日期值
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
@@ -137,7 +137,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 添加大于条件到构建器(针对日期类型)
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param value 比较的日期值
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
@@ -149,7 +149,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 添加等于条件到构建器
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param value 查询值
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
@@ -161,20 +161,24 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 添加日期范围条件到构建器
|
||||
*
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param begin 开始日期
|
||||
* @param end 结束日期
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
*/
|
||||
public Builder between(String key, LocalDate begin, LocalDate end) {
|
||||
params.put(key, Map.of("begin", begin, "end", end));
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("begin", begin);
|
||||
params.put("end", end);
|
||||
this.params.put(key, params);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加全文搜索条件到构建器
|
||||
*
|
||||
*
|
||||
* @param searchText 搜索文本
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
*/
|
||||
@@ -185,7 +189,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 构建并返回查询参数Map
|
||||
*
|
||||
*
|
||||
* @return 包含所有添加条件的查询参数Map
|
||||
*/
|
||||
public Map<String, Object> build() {
|
||||
@@ -194,7 +198,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 添加AND逻辑条件组到构建器
|
||||
*
|
||||
*
|
||||
* @param consumer Builder消费者,用于构建子条件
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
*/
|
||||
@@ -207,7 +211,7 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 添加OR逻辑条件组到构建器
|
||||
*
|
||||
*
|
||||
* @param consumer Builder消费者,用于构建子条件
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class CompanyCustomerViewModel extends IdentityViewModel<CompanyCustomerVo> {
|
||||
public class CompanyCustomerViewModel extends IdentityViewModel<CustomerVo> {
|
||||
private SimpleStringProperty state = new SimpleStringProperty();
|
||||
/**
|
||||
* 关联的企业,Company
|
||||
@@ -39,13 +39,13 @@ public class CompanyCustomerViewModel extends IdentityViewModel<CompanyCustomerV
|
||||
private SimpleObjectProperty<LocalDateTime> created = new SimpleObjectProperty<>();
|
||||
private SimpleIntegerProperty version = new SimpleIntegerProperty();
|
||||
|
||||
public static CompanyCustomerViewModel from(CompanyCustomerVo cc) {
|
||||
public static CompanyCustomerViewModel from(CustomerVo cc) {
|
||||
CompanyCustomerViewModel model = new CompanyCustomerViewModel();
|
||||
model.update(cc);
|
||||
return model;
|
||||
}
|
||||
|
||||
public void updateFrom(CompanyCustomerVo c) {
|
||||
public void updateFrom(CustomerVo c) {
|
||||
super.updateFrom(c);
|
||||
getCompany().set(c.getCompanyId());
|
||||
getCatalog().set(c.getCatalogId());
|
||||
@@ -57,7 +57,7 @@ public class CompanyCustomerViewModel extends IdentityViewModel<CompanyCustomerV
|
||||
version.set(c.getVersion());
|
||||
}
|
||||
|
||||
public boolean copyTo(CompanyCustomerVo v) {
|
||||
public boolean copyTo(CustomerVo v) {
|
||||
boolean modified = super.copyTo(v);
|
||||
if (!Objects.equals(company.get(), v.getCompanyId())) {
|
||||
v.setCompanyId(company.get());
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.CustomerFileType;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CustomerFileVo;
|
||||
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
@@ -16,10 +16,10 @@ import lombok.ToString;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ToString
|
||||
public class CompanyCustomerFileViewModel extends IdentityViewModel<CompanyCustomerFileVo> {
|
||||
public class CustomerFileViewModel extends IdentityViewModel<CustomerFileVo> {
|
||||
|
||||
public static CompanyCustomerFileViewModel from(CompanyCustomerFileVo companyCustomerFile) {
|
||||
CompanyCustomerFileViewModel model = new CompanyCustomerFileViewModel();
|
||||
public static CustomerFileViewModel from(CustomerFileVo companyCustomerFile) {
|
||||
CustomerFileViewModel model = new CustomerFileViewModel();
|
||||
model.update(companyCustomerFile);
|
||||
return model;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class CompanyCustomerFileViewModel extends IdentityViewModel<CompanyCusto
|
||||
private SimpleBooleanProperty valid = new SimpleBooleanProperty(this, "valid", false);
|
||||
|
||||
@Override
|
||||
protected void updateFrom(CompanyCustomerFileVo v) {
|
||||
protected void updateFrom(CustomerFileVo v) {
|
||||
super.updateFrom(v);
|
||||
getCustomer().set(v.getCustomer());
|
||||
getType().set(v.getType());
|
||||
@@ -56,7 +56,7 @@ public class CompanyCustomerFileViewModel extends IdentityViewModel<CompanyCusto
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean copyTo(CompanyCustomerFileVo v) {
|
||||
public boolean copyTo(CustomerFileVo v) {
|
||||
boolean modified = super.copyTo(v);
|
||||
if (!Objects.equals(customer.get(), v.getCustomer())) {
|
||||
v.setCustomer(customer.get());
|
||||
@@ -40,6 +40,12 @@
|
||||
<MenuItem fx:id="fileTable_menu_del" mnemonicParsing="false" text="删除"/>
|
||||
<MenuItem fx:id="fileTable_menu_move_to_company_path" mnemonicParsing="false"
|
||||
text="移动到公司目录"/>
|
||||
<Menu fx:id="fileTable_menu_set_valid" mnemonicParsing="false" text="设置有效性">
|
||||
<items>
|
||||
<MenuItem fx:id="fileTable_menu_set_valid_true" mnemonicParsing="false" text="是"/>
|
||||
<MenuItem fx:id="fileTable_menu_set_valid_false" mnemonicParsing="false" text="否"/>
|
||||
</items>
|
||||
</Menu>
|
||||
</items>
|
||||
</ContextMenu>
|
||||
</contextMenu>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.contract.sale_order.SalesOrderTabSkinBillVoucher">
|
||||
fx:controller="com.ecep.contract.controller.tab.SalesOrderTabSkinBillVoucher">
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.contract.sale_order.SalesOrderTabSkinItems">
|
||||
fx:controller="com.ecep.contract.controller.tab.SalesOrderTabSkinItems">
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>com.ecep.contract</groupId>
|
||||
<artifactId>Contract-Manager</artifactId>
|
||||
<version>0.0.101-SNAPSHOT</version>
|
||||
<version>0.0.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.ecep.contract</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>0.0.101-SNAPSHOT</version>
|
||||
<version>0.0.102-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
package com.ecep.contract.util;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
|
||||
public interface ContextUtils {
|
||||
<T> T getBean(Class<T> requiredType) throws BeansException;
|
||||
|
||||
<T> T getCachedBean(Class<T> requiredType) throws BeansException;
|
||||
}
|
||||
|
||||
@@ -72,4 +72,28 @@ public class FileUtils {
|
||||
}
|
||||
return fileName.startsWith("~$");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查文件是否为可编辑文件
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @return 是否为可编辑文件
|
||||
*/
|
||||
public static boolean isEditableFile(String fileName) {
|
||||
return withExtensions(fileName,
|
||||
XLS, XLSX,
|
||||
DOC, DOCX);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查文件是否为归档文件
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @return 是否为归档文件
|
||||
*/
|
||||
public static boolean isArchiveFile(String fileName) {
|
||||
return withExtensions(fileName,
|
||||
PNG, PDF,
|
||||
JPG, JPEG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.time.LocalDate;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CompanyCustomerFileVo implements IdentityEntity, Serializable {
|
||||
public class CustomerFileVo implements IdentityEntity, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Integer id;
|
||||
private Integer customer;
|
||||
@@ -9,7 +9,7 @@ import com.ecep.contract.model.IdentityEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CompanyCustomerVo implements IdentityEntity, CompanyBasedVo, Serializable {
|
||||
public class CustomerVo implements IdentityEntity, CompanyBasedVo, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Integer id;
|
||||
/**
|
||||
@@ -15,7 +15,6 @@ public class SalesBillVoucherVo implements IdentityEntity, CompanyBasedVo, java.
|
||||
private String code;
|
||||
private Integer companyId;
|
||||
private Integer orderId;
|
||||
private String orderCode;
|
||||
private Integer employeeId;
|
||||
private Integer makerId;
|
||||
private LocalDateTime makerDate;
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>com.ecep.contract</groupId>
|
||||
<artifactId>Contract-Manager</artifactId>
|
||||
<version>0.0.101-SNAPSHOT</version>
|
||||
<version>0.0.102-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>server</module>
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>com.ecep.contract</groupId>
|
||||
<artifactId>Contract-Manager</artifactId>
|
||||
<version>0.0.101-SNAPSHOT</version>
|
||||
<version>0.0.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.ecep.contract</groupId>
|
||||
<artifactId>server</artifactId>
|
||||
<version>0.0.101-SNAPSHOT</version>
|
||||
<version>0.0.102-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
@@ -22,7 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>com.ecep.contract</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>0.0.101-SNAPSHOT</version>
|
||||
<version>0.0.102-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.ecep.contract.cloud.old;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
@@ -37,7 +37,7 @@ public class OldVersionSyncCustomerTask extends Tasker<Object> {
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
updateTitle("老版本-同步客户数据");
|
||||
basePath = getCachedBean(CompanyCustomerService.class).getBasePath();
|
||||
basePath = getCachedBean(CustomerService.class).getBasePath();
|
||||
List<Runnable> runnable = Arrays.asList(this::loadOldNames, this::loadContacts, this::syncCustomers,
|
||||
this::syncContracts);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ecep.contract.cloud.rk;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
@@ -38,13 +39,13 @@ public interface CloudRkRepository extends MyRepository<CloudRk, Integer> {
|
||||
|
||||
List<CloudRk> findAllByCompanyId(int companyId);
|
||||
|
||||
long countByLatestUpdateBefore(Instant instant);
|
||||
long countByLatestUpdateBefore(LocalDateTime instant);
|
||||
|
||||
long countByAutoUpdateIsTrueAndLatestUpdateBefore(Instant instant);
|
||||
long countByAutoUpdateIsTrueAndLatestUpdateBefore(LocalDateTime instant);
|
||||
|
||||
List<CloudRk> findTop100ByLatestUpdateBeforeOrderByLatestUpdateDesc(Instant instant);
|
||||
List<CloudRk> findTop100ByLatestUpdateBeforeOrderByLatestUpdateDesc(LocalDateTime instant);
|
||||
|
||||
List<CloudRk> findTop100ByAutoUpdateIsTrueAndLatestUpdateBeforeOrderByLatestUpdateDesc(Instant instant);
|
||||
List<CloudRk> findTop100ByAutoUpdateIsTrueAndLatestUpdateBeforeOrderByLatestUpdateDesc(LocalDateTime instant);
|
||||
|
||||
@Modifying
|
||||
@Transactional
|
||||
|
||||
@@ -354,9 +354,9 @@ public class CloudRkService implements IEntityService<CloudRk>, QueryService<Clo
|
||||
* @return 记录条数
|
||||
*/
|
||||
public long countNeedUpdate() {
|
||||
Instant now = Instant.now();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
long elapse = getSyncElapse();
|
||||
Instant instant = now.minusSeconds(elapse);
|
||||
LocalDateTime instant = now.minusSeconds(elapse);
|
||||
return cloudRKRepository.countByAutoUpdateIsTrueAndLatestUpdateBefore(instant);
|
||||
}
|
||||
|
||||
@@ -365,9 +365,9 @@ public class CloudRkService implements IEntityService<CloudRk>, QueryService<Clo
|
||||
*/
|
||||
// @Transactional
|
||||
public List<CloudRk> findNeedUpdate() {
|
||||
Instant now = Instant.now();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
long elapse = getSyncElapse();
|
||||
Instant instant = now.minusSeconds(elapse);
|
||||
LocalDateTime instant = now.minusSeconds(elapse);
|
||||
return cloudRKRepository.findTop100ByAutoUpdateIsTrueAndLatestUpdateBeforeOrderByLatestUpdateDesc(instant);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public class CloudRkCtx extends AbstractCtx implements CloudRkContext {
|
||||
*/
|
||||
public boolean syncCompany(Company company, CloudRk cloudRk, MessageHolder holder) {
|
||||
if (!StringUtils.hasText(cloudRk.getCloudId())) {
|
||||
holder.warn("未定义平台编号, 尝试从平台上自动获取");
|
||||
holder.warn("未定义平台编号, 尝试获取平台编号");
|
||||
// 当未定义平台编号时,尝试自动获取
|
||||
if (!queryCloudIdAndSelectOne(company, cloudRk, holder)) {
|
||||
// 自动获取到平台编号失败,立即返回
|
||||
@@ -468,6 +468,7 @@ public class CloudRkCtx extends AbstractCtx implements CloudRkContext {
|
||||
List<CloudRkService.EntInfo> results = new ArrayList<>();
|
||||
ObjectMapper objectMapper = getObjectMapper();
|
||||
try {
|
||||
holder.debug("POST " + url);
|
||||
HttpJsonUtils.post(url, data -> {
|
||||
data.put("theKey", company.getName());
|
||||
data.put("get", true);
|
||||
@@ -819,13 +820,13 @@ public class CloudRkCtx extends AbstractCtx implements CloudRkContext {
|
||||
private void saveJsonToFile(Company company, JsonNode json, String fileName, MessageHolder holder) {
|
||||
String companyPath = company.getPath();
|
||||
if (!StringUtils.hasText(companyPath)) {
|
||||
holder.warn("公司路径为空");
|
||||
holder.warn("公司路径为空, 无法保存 " + fileName);
|
||||
return;
|
||||
}
|
||||
|
||||
File dir = new File(companyPath);
|
||||
if (!dir.exists()) {
|
||||
holder.warn("公司路径不存在");
|
||||
holder.warn("公司路径" + dir.getName() + "不存在, 无法保存 " + fileName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.springframework.beans.BeansException;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.model.CustomerCatalog;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
import com.ecep.contract.vo.CustomerCatalogVo;
|
||||
@@ -25,15 +25,15 @@ import lombok.Setter;
|
||||
public class CustomerClassSyncTask extends Tasker<Object> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CustomerClassSyncTask.class);
|
||||
@Setter
|
||||
private CompanyCustomerService companyCustomerService;
|
||||
private CustomerService companyCustomerService;
|
||||
|
||||
public CustomerClassSyncTask() {
|
||||
updateTitle("用友U8系统-同步客户分类信息");
|
||||
}
|
||||
|
||||
CompanyCustomerService getCompanyCustomerService() {
|
||||
CustomerService getCompanyCustomerService() {
|
||||
if (companyCustomerService == null) {
|
||||
companyCustomerService = SpringApp.getBean(CompanyCustomerService.class);
|
||||
companyCustomerService = SpringApp.getBean(CustomerService.class);
|
||||
}
|
||||
return companyCustomerService;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.ecep.contract.cloud.u8.ctx.CustomerCtx;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.contract.tasker.AbstContractRepairTasker;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.other.model.CloudYu;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
@@ -42,7 +42,7 @@ public class CustomerSyncTask extends AbstContractRepairTasker {
|
||||
updateTitle("用友U8系统-同步客户");
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCompanyCustomerService() {
|
||||
private CustomerService getCompanyCustomerService() {
|
||||
return customerCtx.getCompanyCustomerService();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.ecep.contract.cloud.AbstractCtx;
|
||||
import com.ecep.contract.cloud.u8.YongYouU8Repository;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEntityService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorEntityService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorService;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
@@ -45,8 +45,8 @@ public class AbstractYongYouU8Ctx extends AbstractCtx {
|
||||
}
|
||||
}
|
||||
|
||||
public CompanyCustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CompanyCustomerService.class);
|
||||
public CustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CustomerService.class);
|
||||
}
|
||||
|
||||
public CompanyCustomerEntityService getCompanyCustomerEntityService() {
|
||||
@@ -111,12 +111,12 @@ public class AbstractYongYouU8Ctx extends AbstractCtx {
|
||||
Company company = null;
|
||||
if (StringUtils.hasText(customerCode)) {
|
||||
CompanyCustomerEntityService customerEntityService = getCompanyCustomerEntityService();
|
||||
CompanyCustomerService customerService = getCompanyCustomerService();
|
||||
CustomerService customerService = getCompanyCustomerService();
|
||||
CompanyCustomerEntityVo entity = customerEntityService.findByCustomerCode(customerCode);
|
||||
if (entity == null) {
|
||||
holder.warn("无效" + topic + ":" + customerCode);
|
||||
} else {
|
||||
CompanyCustomerVo customer = customerService.findById(entity.getCustomerId());
|
||||
CustomerVo customer = customerService.findById(entity.getCustomerId());
|
||||
if (customer == null) {
|
||||
holder.warn("无效" + topic + ":" + customerCode);
|
||||
} else {
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.ecep.contract.ds.contract.service.ContractPayPlanService;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.contract.service.ContractTypeService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEntityService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.project.ProjectCtx;
|
||||
import com.ecep.contract.ds.project.service.ProjectSaleTypeService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorEntityService;
|
||||
@@ -463,7 +463,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
boolean modified = false;
|
||||
boolean customerModified = false;
|
||||
CompanyCustomerEntityService customerEntityService = getCompanyCustomerEntityService();
|
||||
CompanyCustomerService customerService = getCompanyCustomerService();
|
||||
CustomerService customerService = getCompanyCustomerService();
|
||||
CompanyCustomerEntityVo entity = customerEntityService.findByCustomerCode(unit);
|
||||
if (entity == null) {
|
||||
CompanyCustomerEntity v1 = new CompanyCustomerEntity();
|
||||
@@ -472,7 +472,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
entity = updateCustomerEntityDetailByCode(entity, unit, holder);
|
||||
|
||||
CompanyCustomerVo customer = customerService.findById(entity.getCustomerId());
|
||||
CustomerVo customer = customerService.findById(entity.getCustomerId());
|
||||
if (customer == null) {
|
||||
if (company != null) {
|
||||
customer = customerService.findByCompany(company).toVo();
|
||||
|
||||
@@ -14,6 +14,8 @@ public interface CompanyContactRepository extends MyRepository<CompanyContact, I
|
||||
|
||||
Optional<CompanyContact> findFirstByCompany(Company company);
|
||||
|
||||
Optional<CompanyContact> findFirstByCompanyId(Integer companyId);
|
||||
|
||||
List<CompanyContact> findAllByCompany(Company company);
|
||||
|
||||
List<CompanyContact> findAllByCompanyAndName(Company company, String name);
|
||||
|
||||
@@ -77,18 +77,6 @@ public abstract class CompanyBasicService {
|
||||
@Autowired
|
||||
protected CompanyService companyService;
|
||||
|
||||
protected boolean isEditableFile(String fileName) {
|
||||
return FileUtils.withExtensions(fileName,
|
||||
FileUtils.XLS, FileUtils.XLSX,
|
||||
FileUtils.DOC, FileUtils.DOCX);
|
||||
}
|
||||
|
||||
protected boolean isArchiveFile(String fileName) {
|
||||
return FileUtils.withExtensions(fileName,
|
||||
FileUtils.PNG, FileUtils.PDF,
|
||||
FileUtils.JPG, FileUtils.JPEG);
|
||||
}
|
||||
|
||||
public abstract <T, F extends CompanyBasicFile<T>, ID> void deleteFile(F file);
|
||||
|
||||
protected <T, F extends CompanyBasicFile<T>, ID> boolean fetchDbFiles(List<F> dbFiles, Map<String, F> map,
|
||||
@@ -328,7 +316,7 @@ public abstract class CompanyBasicService {
|
||||
// 文件全路径
|
||||
String fileAbsolutePath = file.getAbsolutePath();
|
||||
|
||||
if (isEditableFile(fileName)) {
|
||||
if (FileUtils.isEditableFile(fileName)) {
|
||||
// 是可编辑文件时
|
||||
if (!Objects.equals(fileAbsolutePath, customerFile.getEditFilePath())) {
|
||||
customerFile.setEditFilePath(fileAbsolutePath);
|
||||
@@ -338,7 +326,7 @@ public abstract class CompanyBasicService {
|
||||
if (useAsEditableFile(customerFile, file, fileList, status)) {
|
||||
modified = true;
|
||||
}
|
||||
} else if (isArchiveFile(fileName)) {
|
||||
} else if (FileUtils.isArchiveFile(fileName)) {
|
||||
// 存档文件时
|
||||
if (!Objects.equals(fileAbsolutePath, customerFile.getFilePath())) {
|
||||
customerFile.setFilePath(fileAbsolutePath);
|
||||
@@ -387,7 +375,7 @@ public abstract class CompanyBasicService {
|
||||
String name = StringUtils.stripFilenameExtension(fileName);
|
||||
for (File f : fileList) {
|
||||
// 查找存档文件
|
||||
if (f.getName().startsWith(name) && isArchiveFile(f.getName())) {
|
||||
if (f.getName().startsWith(name) && FileUtils.isArchiveFile(f.getName())) {
|
||||
archiveFile = f;
|
||||
break;
|
||||
}
|
||||
@@ -431,7 +419,7 @@ public abstract class CompanyBasicService {
|
||||
String name = StringUtils.stripFilenameExtension(fileName);
|
||||
for (File f : fileList) {
|
||||
// 查找存档文件
|
||||
if (f.getName().startsWith(name) && isEditableFile(f.getName())) {
|
||||
if (f.getName().startsWith(name) && FileUtils.isEditableFile(f.getName())) {
|
||||
editFile = f;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyContactVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
/**
|
||||
@@ -81,6 +82,10 @@ public class CompanyContactService implements IEntityService<CompanyContact>, Qu
|
||||
return repository.findFirstByCompany(company).orElse(null);
|
||||
}
|
||||
|
||||
public CompanyContactVo findFirstByCompany(CompanyVo company) {
|
||||
return repository.findFirstByCompanyId(company.getId()).map(CompanyContact::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyContactVo findById(Integer id) {
|
||||
return repository.findById(id).map(CompanyContact::toVo).orElse(null);
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.ecep.contract.cloud.u8.YongYouU8Service;
|
||||
import com.ecep.contract.constant.CompanyConstant;
|
||||
import com.ecep.contract.ds.company.repository.CompanyRepository;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorService;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
@@ -76,7 +76,7 @@ public class CompanyService extends EntityService<Company, CompanyVo, Integer>
|
||||
private VendorService vendorService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyCustomerService companyCustomerService;
|
||||
private CustomerService companyCustomerService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyOldNameService companyOldNameService;
|
||||
@@ -267,7 +267,7 @@ public class CompanyService extends EntityService<Company, CompanyVo, Integer>
|
||||
* 删除前需要把关联数据解除
|
||||
* <ul>
|
||||
* <li>{@link VendorService#deleteByCompany(Company)}</li>
|
||||
* <li>{@link CompanyCustomerService#deleteByCompany(Company)}</li>
|
||||
* <li>{@link CustomerService#deleteByCompany(Company)}</li>
|
||||
* <li>{@link CompanyOldNameService#deleteByCompany(Company)}</li>
|
||||
* <li>{@link CompanyContactService#deleteByCompany(Company)}</li>
|
||||
* <li>{@link ContractService#deleteByCompany(Company)}</li>
|
||||
@@ -276,7 +276,7 @@ public class CompanyService extends EntityService<Company, CompanyVo, Integer>
|
||||
* 或者 把关联数据转移到其他公司
|
||||
* <ul>
|
||||
* <li>{@link VendorService#resetTo(Company, Company)}</li>
|
||||
* <li>{@link CompanyCustomerService#resetTo(Company, Company)}</li>
|
||||
* <li>{@link CustomerService#resetTo(Company, Company)}</li>
|
||||
* <li>{@link CompanyOldNameService#resetTo(Company, Company)}</li>
|
||||
* <li>{@link CompanyContactService#resetTo(Company, Company)}</li>
|
||||
* <li>{@link ContractService#resetTo(Company, Company)}</li>
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.ecep.contract.ds.vendor.model.Vendor;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@@ -119,6 +120,16 @@ public class ContractService extends EntityService<Contract, ContractVo, Integer
|
||||
return contractRepository.findAllByCompanyId(company.getId());
|
||||
}
|
||||
|
||||
public List<Contract> findAllByCompany(CompanyVo company, ContractPayWay payWay, LocalDate beginDate,
|
||||
LocalDate endDate) {
|
||||
return contractRepository.findAll((root, query, cb) -> {
|
||||
Predicate p = cb.and(
|
||||
cb.equal(root.get("company").get("id"), company.getId()),
|
||||
cb.equal(root.get("payWay"), payWay));
|
||||
return applyPredicate(root, cb, p, beginDate, endDate);
|
||||
}, Sort.unsorted());
|
||||
}
|
||||
|
||||
public List<Contract> findAllByProject(Project project) {
|
||||
return contractRepository.findAllByProjectId(project.getId());
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.ecep.contract.model.Voable;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -34,7 +34,7 @@ import lombok.ToString;
|
||||
|
||||
})
|
||||
@ToString
|
||||
public class CompanyCustomer implements IdentityEntity, CompanyBasedEntity, Voable<CompanyCustomerVo> {
|
||||
public class CompanyCustomer implements IdentityEntity, CompanyBasedEntity, Voable<CustomerVo> {
|
||||
@Id
|
||||
@Column(name = "ID", nullable = false)
|
||||
private Integer id;
|
||||
@@ -105,8 +105,8 @@ public class CompanyCustomer implements IdentityEntity, CompanyBasedEntity, Voab
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyCustomerVo toVo() {
|
||||
CompanyCustomerVo vo = new CompanyCustomerVo();
|
||||
public CustomerVo toVo() {
|
||||
CustomerVo vo = new CustomerVo();
|
||||
vo.setId(id);
|
||||
vo.setCompanyId(company != null ? company.getId() : null);
|
||||
vo.setCatalogId(catalog != null ? catalog.getId() : null);
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.ecep.contract.CustomerFileType;
|
||||
import com.ecep.contract.model.CompanyBasicFile;
|
||||
import com.ecep.contract.model.Voable;
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CustomerFileVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -29,7 +29,7 @@ import lombok.ToString;
|
||||
@Entity
|
||||
@Table(name = "COMPANY_CUSTOMER_FILE")
|
||||
@ToString
|
||||
public class CompanyCustomerFile implements CompanyBasicFile<CustomerFileType>, Voable<CompanyCustomerFileVo> {
|
||||
public class CompanyCustomerFile implements CompanyBasicFile<CustomerFileType>, Voable<CustomerFileVo> {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "ID", nullable = false)
|
||||
@@ -81,8 +81,8 @@ public class CompanyCustomerFile implements CompanyBasicFile<CustomerFileType>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyCustomerFileVo toVo() {
|
||||
CompanyCustomerFileVo vo = new CompanyCustomerFileVo();
|
||||
public CustomerFileVo toVo() {
|
||||
CustomerFileVo vo = new CustomerFileVo();
|
||||
vo.setId(getId());
|
||||
vo.setCustomer(getCustomer() != null ? getCustomer().getId() : null);
|
||||
vo.setType(getType());
|
||||
|
||||
@@ -143,7 +143,6 @@ public class SalesBillVoucher implements IdentityEntity, BasedEntity, Voable<Sal
|
||||
}
|
||||
if (order != null) {
|
||||
vo.setOrderId(order.getId());
|
||||
vo.setOrderCode(order.getCode());
|
||||
}
|
||||
if (employee != null) {
|
||||
vo.setEmployeeId(employee.getId());
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
|
||||
private CompanyCustomerEntityRepository repository;
|
||||
|
||||
@Autowired
|
||||
private CompanyCustomerService companyCustomerService;
|
||||
private CustomerService companyCustomerService;
|
||||
|
||||
@Autowired
|
||||
private CustomerCatalogService customerCatalogService;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.ecep.contract.ds.company.service.HolidayService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -39,7 +40,7 @@ import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CustomerFileVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.persistence.criteria.Path;
|
||||
@@ -49,7 +50,7 @@ import jakarta.persistence.criteria.Path;
|
||||
@CacheConfig(cacheNames = "company-customer-file")
|
||||
public class CompanyCustomerFileService
|
||||
implements IEntityService<CompanyCustomerFile>, QueryService<CompanyCustomerFile>,
|
||||
VoableService<CompanyCustomerFile, CompanyCustomerFileVo> {
|
||||
VoableService<CompanyCustomerFile, CustomerFileVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerFileService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -183,7 +184,7 @@ public class CompanyCustomerFileService
|
||||
LocalDate miniContractDate = LocalDate.of(2022, 1, 1);
|
||||
// 检索全部合同
|
||||
ContractService contractService = SpringApp.getBean(ContractService.class);
|
||||
List<Contract> contractList = contractService.findAllByCompanyCustomer(companyCustomer, null, null);
|
||||
List<Contract> contractList = contractService.findAllByCompanyCustomer(companyCustomer, miniContractDate, LocalDate.now());
|
||||
if (contractList.isEmpty()) {
|
||||
holder.error("未发现已登记的合同");
|
||||
return null;
|
||||
@@ -210,7 +211,7 @@ public class CompanyCustomerFileService
|
||||
|
||||
LocalDate setupDate = firstContract.getSetupDate();
|
||||
holder.info("依据合同 " + firstContract.getCode() + " 的日期 " + setupDate + " 推算");
|
||||
return CompanyBasicService.adjustToWorkDay(setupDate.plusDays(-7));
|
||||
return SpringApp.getBean(HolidayService.class).adjustToWorkDay(setupDate.plusDays(-7));
|
||||
}
|
||||
|
||||
// 检查失效日期起的第一个合同
|
||||
@@ -233,7 +234,7 @@ public class CompanyCustomerFileService
|
||||
LocalDate setupDate = firstContract.getSetupDate();
|
||||
holder.info("匹配失效期 " + nextInValidDate + " 后的第一个合同 " + firstContract.getCode());
|
||||
holder.info("依据合同 " + firstContract.getCode() + " 的日期 " + setupDate + " 推算");
|
||||
return CompanyBasicService.adjustToWorkDay(setupDate.plusDays(-7));
|
||||
return SpringApp.getBean(HolidayService.class).adjustToWorkDay(setupDate.plusDays(-7));
|
||||
}
|
||||
|
||||
public File getEvaluationFormTemplate() {
|
||||
@@ -271,7 +272,7 @@ public class CompanyCustomerFileService
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CompanyCustomerFile model, CompanyCustomerFileVo vo) {
|
||||
public void updateByVo(CompanyCustomerFile model, CustomerFileVo vo) {
|
||||
if (model == null) {
|
||||
throw new ServiceException("companyCustomerFile is null");
|
||||
}
|
||||
@@ -290,7 +291,7 @@ public class CompanyCustomerFileService
|
||||
if (vo.getCustomer() == null) {
|
||||
model.setCustomer(null);
|
||||
} else {
|
||||
CompanyCustomerService service = SpringApp.getBean(CompanyCustomerService.class);
|
||||
CustomerService service = SpringApp.getBean(CustomerService.class);
|
||||
// 添加实体匹配检查
|
||||
if (model.getCustomer() == null || !model.getCustomer().getId().equals(vo.getCustomer())) {
|
||||
// 使用getById方法替代findById
|
||||
|
||||
@@ -48,7 +48,7 @@ import com.ecep.contract.util.CompanyUtils;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -58,10 +58,10 @@ import jakarta.persistence.criteria.Path;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-customer")
|
||||
public class CompanyCustomerService extends CompanyBasicService
|
||||
implements IEntityService<CompanyCustomer>, QueryService<CompanyCustomerVo>,
|
||||
VoableService<CompanyCustomer, CompanyCustomerVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerService.class);
|
||||
public class CustomerService extends CompanyBasicService
|
||||
implements IEntityService<CompanyCustomer>, QueryService<CustomerVo>,
|
||||
VoableService<CompanyCustomer, CustomerVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CustomerService.class);
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -86,7 +86,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public CompanyCustomerVo findById(Integer id) {
|
||||
public CustomerVo findById(Integer id) {
|
||||
return repository.findById(id).map(CompanyCustomer::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyCustomerVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
public Page<CustomerVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<CompanyCustomer> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
@@ -399,7 +399,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CompanyCustomer customer, CompanyCustomerVo vo) {
|
||||
public void updateByVo(CompanyCustomer customer, CustomerVo vo) {
|
||||
// 优化关联实体处理逻辑 - 公司关联
|
||||
if (vo.getCompanyId() == null) {
|
||||
customer.setCompany(null);
|
||||
@@ -18,5 +18,7 @@ public interface VendorFileRepository
|
||||
|
||||
List<VendorFile> findAllByVendorAndType(Vendor vendor, VendorFileType type);
|
||||
|
||||
List<VendorFile> findAllByVendorIdAndType(Integer vendorId, VendorFileType type);
|
||||
|
||||
List<VendorFile> findByVendorId(int vendorId);
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -16,22 +15,28 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorFileRepository;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.company.service.HolidayService;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.ds.vendor.model.Vendor;
|
||||
import com.ecep.contract.ds.vendor.model.VendorFile;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorFileRepository;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.VendorFileVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@@ -41,6 +46,15 @@ public class VendorFileService
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(VendorFileService.class);
|
||||
|
||||
public File getEvaluationFormTemplate() {
|
||||
SysConfService confService = SpringApp.getBean(SysConfService.class);
|
||||
String path = confService.getString(CompanyVendorConstant.KEY_EVALUATION_FORM_TEMPLATE);
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
return new File(path);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private VendorFileRepository repository;
|
||||
|
||||
@@ -85,6 +99,10 @@ public class VendorFileService
|
||||
return repository.findAllByVendorId(vendor.getId());
|
||||
}
|
||||
|
||||
public List<VendorFileVo> findAllByVendor(VendorVo vendor) {
|
||||
return repository.findAllByVendorId(vendor.getId()).stream().map(VendorFile::toVo).toList();
|
||||
}
|
||||
|
||||
public void delete(VendorFile file) {
|
||||
repository.delete(file);
|
||||
}
|
||||
@@ -109,6 +127,10 @@ public class VendorFileService
|
||||
return repository.findAllByVendorAndType(vendor, type);
|
||||
}
|
||||
|
||||
public List<VendorFile> findAllByVendorAndType(VendorVo vendor, VendorFileType type) {
|
||||
return repository.findAllByVendorIdAndType(vendor.getId(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证供应商文件
|
||||
*
|
||||
@@ -158,14 +180,17 @@ public class VendorFileService
|
||||
* @param vendor 供应商
|
||||
* @return 下一个评价日期
|
||||
*/
|
||||
public LocalDate getNextSignDate(Vendor vendor, Consumer<String> state) {
|
||||
public LocalDate getNextSignDate(VendorVo vendor, MessageHolder holder) {
|
||||
LocalDate miniContractDate = LocalDate.of(2022, 1, 1);
|
||||
|
||||
// 检索全部合同
|
||||
ContractService contractService = SpringApp.getBean(ContractService.class);
|
||||
List<Contract> contractList = contractService.findAllByCompanyVendor(vendor, null, null);
|
||||
CompanyService companyService = SpringApp.getBean(CompanyService.class);
|
||||
CompanyVo company = companyService.findById(vendor.getCompanyId());
|
||||
List<Contract> contractList = contractService.findAllByCompany(company, ContractPayWay.PAY, miniContractDate,
|
||||
LocalDate.now());
|
||||
if (contractList.isEmpty()) {
|
||||
state.accept("未发现已登记的合同");
|
||||
holder.error("未发现已登记的合同");
|
||||
return null;
|
||||
}
|
||||
// 检索评价表
|
||||
@@ -177,43 +202,43 @@ public class VendorFileService
|
||||
|
||||
// 没有有效的评价表的评价日期
|
||||
if (latestFile == null) {
|
||||
state.accept("未发现有效的评价表");
|
||||
holder.warn("未发现有效的评价表");
|
||||
// 返回最早的合同日期
|
||||
Contract firstContract = contractList.stream()
|
||||
.filter(v -> v.getSetupDate() != null && !v.getSetupDate().isBefore(miniContractDate))
|
||||
.min(Comparator.comparing(Contract::getSetupDate))
|
||||
.orElse(null);
|
||||
if (firstContract == null) {
|
||||
state.accept("最早的合同不存在?");
|
||||
holder.error("最早的合同不存在?");
|
||||
return null;
|
||||
}
|
||||
|
||||
LocalDate setupDate = firstContract.getSetupDate();
|
||||
state.accept("依据合同 " + firstContract.getCode() + " 的日期 " + setupDate + " 推算");
|
||||
return CompanyBasicService.adjustToWorkDay(setupDate.plusDays(-7));
|
||||
holder.info("依据合同 " + firstContract.getCode() + " 的日期 " + setupDate + " 推算");
|
||||
return SpringApp.getBean(HolidayService.class).adjustToWorkDay(setupDate.plusDays(-7));
|
||||
}
|
||||
|
||||
// 检查失效日期起的第一个合同
|
||||
LocalDate nextInValidDate = latestFile.getSignDate().plusYears(1);
|
||||
File file = new File(latestFile.getFilePath());
|
||||
state.accept("依据 " + file.getName() + " 的失效期 " + nextInValidDate + " 检索合同");
|
||||
holder.info("依据 " + file.getName() + " 的失效期 " + nextInValidDate + " 检索合同");
|
||||
List<Contract> matchedContracts = contractList.stream()
|
||||
.filter(v -> v.getSetupDate().isAfter(nextInValidDate)).toList();
|
||||
// 没有在失效日期后的合同时,使用失效日期
|
||||
if (matchedContracts.isEmpty()) {
|
||||
state.accept("未发现失效期 " + nextInValidDate + " 后的合同");
|
||||
holder.warn("未发现失效期 " + nextInValidDate + " 后的合同");
|
||||
return null;
|
||||
}
|
||||
state.accept("发现匹配合同 " + matchedContracts.size() + " 个");
|
||||
holder.info("发现匹配合同 " + matchedContracts.size() + " 个");
|
||||
|
||||
// 按时间取最早一个
|
||||
Contract firstContract = matchedContracts.stream()
|
||||
.min(Comparator.comparing(Contract::getSetupDate))
|
||||
.orElse(null);
|
||||
LocalDate setupDate = firstContract.getSetupDate();
|
||||
state.accept("匹配失效期 " + nextInValidDate + " 后的第一个合同 " + firstContract.getCode());
|
||||
state.accept("依据合同 " + firstContract.getCode() + " 的日期 " + setupDate + " 推算");
|
||||
return CompanyBasicService.adjustToWorkDay(setupDate.plusDays(-7));
|
||||
holder.info("匹配失效期 " + nextInValidDate + " 后的第一个合同 " + firstContract.getCode());
|
||||
holder.info("依据合同 " + firstContract.getCode() + " 的日期 " + setupDate + " 推算");
|
||||
return SpringApp.getBean(HolidayService.class).adjustToWorkDay(setupDate.plusDays(-7));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -255,7 +255,7 @@ public class VendorService extends CompanyBasicService
|
||||
List<File> fileList, Consumer<String> status) {
|
||||
boolean modified = super.fillFileAsEvaluationFile(customerFile, file, fileList, status);
|
||||
// 当评价表有日期,并且未设审核时
|
||||
boolean valid = isArchiveFile(customerFile.getFilePath()) && customerFile.getSignDate() != null;
|
||||
boolean valid = FileUtils.isArchiveFile(customerFile.getFilePath()) && customerFile.getSignDate() != null;
|
||||
if (valid != customerFile.isValid()) {
|
||||
customerFile.setValid(valid);
|
||||
modified = true;
|
||||
@@ -263,7 +263,7 @@ public class VendorService extends CompanyBasicService
|
||||
return modified;
|
||||
}
|
||||
|
||||
protected boolean isEvaluationFile(String fileName) {
|
||||
public boolean isEvaluationFile(String fileName) {
|
||||
return fileName.contains(CompanyVendorConstant.EVALUATION_FORM_NAME1)
|
||||
|| fileName.contains(CompanyVendorConstant.EVALUATION_FORM_NAME2)
|
||||
|| fileName.contains(CompanyVendorConstant.EVALUATION_FORM_NAME3);
|
||||
@@ -375,14 +375,6 @@ public class VendorService extends CompanyBasicService
|
||||
return modified;
|
||||
}
|
||||
|
||||
public File getEvaluationFormTemplate() {
|
||||
String path = confService.getString(CompanyVendorConstant.KEY_EVALUATION_FORM_TEMPLATE);
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
return new File(path);
|
||||
}
|
||||
|
||||
public File getVendorApprovedListTemplate() {
|
||||
String path = confService.getString(CompanyVendorConstant.KEY_APPROVED_LIST_TEMPLATE);
|
||||
if (path == null) {
|
||||
|
||||
489
server/src/main/java/com/ecep/contract/ds/vendor/task/VendorReBuildFilesTasker.java
vendored
Normal file
489
server/src/main/java/com/ecep/contract/ds/vendor/task/VendorReBuildFilesTasker.java
vendored
Normal file
@@ -0,0 +1,489 @@
|
||||
package com.ecep.contract.ds.vendor.task;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.vendor.model.VendorFile;
|
||||
import com.ecep.contract.ds.vendor.service.VendorFileService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorService;
|
||||
import com.ecep.contract.service.tasker.WebSocketServerTasker;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.VendorFileVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
/**
|
||||
* 供应商文件重建任务
|
||||
* 1. 从供应商目录下递归遍历所有文件
|
||||
* 2. 检查数据库中是否存在该文件
|
||||
* 3. 如果不存在,则添加到数据库中
|
||||
* 4. 如果存在,则检查文件是否被修改
|
||||
* 5. 如果被修改,则更新数据库中的文件信息
|
||||
* 6. 如果文件不存在于供应商目录下,则从数据库中删除该文件
|
||||
*/
|
||||
public class VendorReBuildFilesTasker extends Tasker<Object> implements WebSocketServerTasker {
|
||||
private final Logger logger = LoggerFactory.getLogger(VendorReBuildFilesTasker.class);
|
||||
private VendorService vendorService;
|
||||
private VendorFileService vendorFileService;
|
||||
private VendorVo vendor;
|
||||
|
||||
@Override
|
||||
public void init(JsonNode argsNode) {
|
||||
int vendorId = argsNode.get(0).asInt();
|
||||
vendorService = getCachedBean(VendorService.class);
|
||||
vendorFileService = getCachedBean(VendorFileService.class);
|
||||
vendor = vendorService.findById(vendorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
CompanyVo company = getCachedBean(CompanyService.class).findById(vendor.getCompanyId());
|
||||
|
||||
holder.info("开始重建供应商[" + company.getName() + "]的文件信息...");
|
||||
updateProgress(0, 100);
|
||||
|
||||
holder.info("正在读取数据库中的文件记录...");
|
||||
List<VendorFileVo> dbFiles = vendorFileService.findAllByVendor(vendor);
|
||||
holder.info("共找到 " + dbFiles.size() + " 条数据库记录,正在进行数据清理...");
|
||||
|
||||
Map<String, VendorFileVo> map = new HashMap<>();
|
||||
boolean modified = fetchDbFiles(dbFiles, map, holder);
|
||||
updateProgress(30, 100);
|
||||
|
||||
// 供应商目录下,准备用于移动到公司目录
|
||||
List<File> needMoveToCompanyPath = new ArrayList<>();
|
||||
// 有修改和新导入的文件
|
||||
List<VendorFileVo> retrieveFiles = new ArrayList<>();
|
||||
|
||||
holder.info("正在扫描供应商目录[" + vendor.getPath() + "]中的文件...");
|
||||
fetchFiles(vendor.getPath(), needMoveToCompanyPath, retrieveFiles, map, holder);
|
||||
updateProgress(60, 100);
|
||||
|
||||
// 移动文件到公司目录下 to company path
|
||||
if (!needMoveToCompanyPath.isEmpty()) {
|
||||
holder.info("发现 " + needMoveToCompanyPath.size() + " 个文件需要移动到公司目录,正在处理...");
|
||||
moveFileToCompany(needMoveToCompanyPath, holder);
|
||||
holder.info("文件移动完成");
|
||||
}
|
||||
|
||||
holder.info("导入 " + retrieveFiles.size() + " 个文件");
|
||||
if (!retrieveFiles.isEmpty()) {
|
||||
holder.info("正在更新数据库记录...");
|
||||
int totalFiles = retrieveFiles.size();
|
||||
int processed = 0;
|
||||
// update db
|
||||
for (VendorFileVo v0 : retrieveFiles) {
|
||||
v0.setVendorId(vendor.getId());
|
||||
save(v0);
|
||||
processed++;
|
||||
updateProgress(60 + (processed * 40) / totalFiles, 100);
|
||||
}
|
||||
modified = true;
|
||||
holder.info("数据库更新完成");
|
||||
}
|
||||
updateProperty("modified", modified);
|
||||
|
||||
updateProgress(100, 100);
|
||||
holder.info("文件重建任务完成");
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
protected void moveFileToCompany(List<File> needMoveToCompanyPath, MessageHolder holder) {
|
||||
CompanyService companyService = getCachedBean(CompanyService.class);
|
||||
CompanyVo company = companyService.findById(vendor.getCompanyId());
|
||||
String companyPath = company.getPath();
|
||||
if (!StringUtils.hasText(companyPath)) {
|
||||
holder.warn("公司路径未设置,无法移动文件");
|
||||
return;
|
||||
}
|
||||
|
||||
int movedCount = 0;
|
||||
int totalCount = needMoveToCompanyPath.size();
|
||||
for (File file : needMoveToCompanyPath) {
|
||||
File dest = new File(companyPath, file.getName());
|
||||
if (file.renameTo(dest)) {
|
||||
holder.info("移动文件: " + file.getAbsolutePath() + " -> " + dest.getAbsolutePath());
|
||||
movedCount++;
|
||||
} else {
|
||||
if (dest.exists()) {
|
||||
if (file.delete()) {
|
||||
holder.info("删除重复文件: " + file.getAbsolutePath());
|
||||
} else {
|
||||
holder.warn("无法删除重复文件: " + file.getAbsolutePath());
|
||||
}
|
||||
} else {
|
||||
holder.warn("无法移动文件: " + file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
holder.info("文件移动完成: 共 " + totalCount + " 个文件,成功移动 " + movedCount + " 个");
|
||||
}
|
||||
|
||||
/**
|
||||
* 从数据库中获取所有文件信息
|
||||
*
|
||||
* @param dbFiles
|
||||
* @param map
|
||||
* @param holder
|
||||
* @return
|
||||
*/
|
||||
protected boolean fetchDbFiles(List<VendorFileVo> dbFiles, Map<String, VendorFileVo> map, MessageHolder holder) {
|
||||
boolean modified = false;
|
||||
List<File> editFiles = new ArrayList<>();
|
||||
int deletedCount = 0;
|
||||
int updatedCount = 0;
|
||||
int totalCount = dbFiles.size();
|
||||
|
||||
// 排除掉数据库中重复的
|
||||
for (int i = 0; i < dbFiles.size(); i++) {
|
||||
VendorFileVo dbFile = dbFiles.get(i);
|
||||
String filePath = dbFile.getFilePath();
|
||||
|
||||
// 更新进度
|
||||
if (i % 10 == 0 || i == totalCount - 1) {
|
||||
updateProgress(10 + (i * 20) / totalCount, 100);
|
||||
}
|
||||
|
||||
// 没有文件信息,无效记录,删除
|
||||
if (!StringUtils.hasText(filePath)) {
|
||||
deleteFile(dbFile);
|
||||
deletedCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 文件不存在或者隐藏文件,删除记录
|
||||
File file = new File(filePath);
|
||||
if (!file.exists() || FileUtils.isHiddenFile(file)) {
|
||||
deleteFile(dbFile);
|
||||
deletedCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// old 是冲突的,按dbFiles顺序,旧的(list前面的)
|
||||
VendorFileVo old = map.put(filePath, dbFile);
|
||||
// 目录有重复删除
|
||||
if (old != null) {
|
||||
deleteFile(old);
|
||||
deletedCount++;
|
||||
}
|
||||
|
||||
String editFilePath = dbFile.getEditFilePath();
|
||||
if (!Objects.equals(filePath, editFilePath)) {
|
||||
// 没有文件信息,无效记录,删除
|
||||
if (StringUtils.hasText(editFilePath)) {
|
||||
File editFile = new File(editFilePath);
|
||||
if (editFile.exists()) {
|
||||
editFiles.add(editFile);
|
||||
} else {
|
||||
dbFile.setEditFilePath("");
|
||||
updatedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 类型未设置,补充类型
|
||||
if (dbFile.getType() == null) {
|
||||
if (fillFileAsDefaultType(dbFile, file, holder)) {
|
||||
modified = true;
|
||||
updatedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理编辑文件
|
||||
int editDeletedCount = 0;
|
||||
for (File editFile : editFiles) {
|
||||
String editFilePath = editFile.getAbsolutePath();
|
||||
VendorFileVo dup = map.remove(editFilePath);
|
||||
// 目录有重复删除
|
||||
if (dup != null) {
|
||||
deleteFile(dup);
|
||||
editDeletedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
holder.info("数据库清理完成: 删除 " + (deletedCount + editDeletedCount) + " 条无效记录,更新 " + updatedCount + " 条记录");
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历扫描 path 目录下的文件, 并根据文件类型,填充到 retrieveFiles 中
|
||||
*
|
||||
* @param path
|
||||
* @param needMoveToCompanyPath 符合 CompanyFileUtils.isCompanyFile(file)
|
||||
* 规则的文件,会加到此集合中
|
||||
* @param retrieveFiles
|
||||
* @param map
|
||||
* @param status
|
||||
* @param <T>
|
||||
* @param <F>
|
||||
*/
|
||||
protected void fetchFiles(
|
||||
String path,
|
||||
List<File> needMoveToCompanyPath,
|
||||
List<VendorFileVo> retrieveFiles,
|
||||
Map<String, VendorFileVo> map,
|
||||
MessageHolder holder) {
|
||||
if (!StringUtils.hasText(path)) {
|
||||
return;
|
||||
}
|
||||
File dir = new File(path);
|
||||
if (!dir.exists()) {
|
||||
return;
|
||||
}
|
||||
File[] files = dir.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
List<File> step1 = new ArrayList<>();
|
||||
for (File file : files) {
|
||||
// 只处理文件
|
||||
if (!file.isFile() || FileUtils.isHiddenFile(file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CompanyFileUtils.isCompanyFile(file)) {
|
||||
needMoveToCompanyPath.add(file);
|
||||
continue;
|
||||
}
|
||||
// 先把所有文件加到列表中
|
||||
step1.add(file);
|
||||
}
|
||||
|
||||
if (!step1.isEmpty()) {
|
||||
// 第一步,处理已经存在的
|
||||
for (File file : new ArrayList<>(step1)) {
|
||||
String filePath = file.getAbsolutePath();
|
||||
if (map.containsKey(filePath)) {
|
||||
// 已记录
|
||||
VendorFileVo customerFile = map.get(filePath);
|
||||
if (fillFile(customerFile, file, step1, holder)) {
|
||||
retrieveFiles.add(customerFile);
|
||||
}
|
||||
step1.remove(file);
|
||||
}
|
||||
}
|
||||
|
||||
// 第二步骤,再处理
|
||||
while (!step1.isEmpty()) {
|
||||
File file = step1.removeLast();
|
||||
VendorFileVo vendorFile = new VendorFileVo();
|
||||
vendorFile.setType(VendorFileType.General);
|
||||
vendorFile.setFilePath(file.getAbsolutePath());
|
||||
fillFile(vendorFile, file, step1, holder);
|
||||
if (vendorFile != null) {
|
||||
retrieveFiles.add(vendorFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean fillFile(VendorFileVo customerFile, File file, List<File> fileList,
|
||||
MessageHolder holder) {
|
||||
String fileName = file.getName();
|
||||
boolean modified = CompanyFileUtils.fillApplyDateAbsent(file, customerFile, VendorFileVo::getSignDate,
|
||||
VendorFileVo::setSignDate);
|
||||
// 评估表
|
||||
if (getCachedBean(VendorService.class).isEvaluationFile(fileName)) {
|
||||
if (fillFileAsEvaluationFile(customerFile, file, fileList, holder)) {
|
||||
modified = true;
|
||||
}
|
||||
} else {
|
||||
if (!Objects.equals(file.getAbsolutePath(), customerFile.getFilePath())) {
|
||||
customerFile.setFilePath(file.getAbsolutePath());
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以评价表单模板。填充文件信息
|
||||
*
|
||||
* @param customerFile 文件对象
|
||||
* @param file 相关文件
|
||||
* @param fileList 待处理文件列表
|
||||
* @param status 状态输出
|
||||
* @param <T> 类型类
|
||||
* @param <F> 文件类
|
||||
* @return true:文件对象有修改,否则返回false
|
||||
*/
|
||||
protected boolean fillFileAsEvaluationFile(VendorFileVo customerFile, File file,
|
||||
List<File> fileList, MessageHolder holder) {
|
||||
boolean modified = setFileTypeAsEvaluationForm(customerFile);
|
||||
String fileName = file.getName();
|
||||
|
||||
// 文件全路径
|
||||
String fileAbsolutePath = file.getAbsolutePath();
|
||||
|
||||
if (FileUtils.isEditableFile(fileName)) {
|
||||
// 是可编辑文件时
|
||||
if (!Objects.equals(fileAbsolutePath, customerFile.getEditFilePath())) {
|
||||
customerFile.setEditFilePath(fileAbsolutePath);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (useAsEditableFile(customerFile, file, fileList, holder)) {
|
||||
modified = true;
|
||||
}
|
||||
} else if (FileUtils.isArchiveFile(fileName)) {
|
||||
// 存档文件时
|
||||
if (!Objects.equals(fileAbsolutePath, customerFile.getFilePath())) {
|
||||
customerFile.setFilePath(fileAbsolutePath);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (useAsArchiveFile(customerFile, file, fileList, holder)) {
|
||||
modified = true;
|
||||
}
|
||||
} else {
|
||||
customerFile.setFilePath(file.getAbsolutePath());
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
protected boolean setFileTypeAsEvaluationForm(VendorFileVo file) {
|
||||
VendorFileType type = file.getType();
|
||||
if (type != VendorFileType.EvaluationForm) {
|
||||
file.setType(VendorFileType.EvaluationForm);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean useAsEditableFile(VendorFileVo customerFile, File file, List<File> fileList,
|
||||
MessageHolder holder) {
|
||||
if (fileList == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查存档文件
|
||||
if (StringUtils.hasText(customerFile.getFilePath())) {
|
||||
// 移除 存档文件
|
||||
File archiveFile = new File(customerFile.getFilePath());
|
||||
fileList.remove(archiveFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 未关联存档文件,去找 fileList 查
|
||||
if (fileList.isEmpty()) {
|
||||
// 文件全路径
|
||||
String fileAbsolutePath = file.getAbsolutePath();
|
||||
// 当没有其他文件时,与 EditFile 相同
|
||||
if (!Objects.equals(fileAbsolutePath, customerFile.getFilePath())) {
|
||||
customerFile.setFilePath(fileAbsolutePath);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
File archiveFile = null;
|
||||
// 文件名
|
||||
String fileName = file.getName();
|
||||
// 文件名,不含后缀
|
||||
String name = StringUtils.stripFilenameExtension(fileName);
|
||||
for (File f : fileList) {
|
||||
// 查找存档文件
|
||||
if (f.getName().startsWith(name) && FileUtils.isArchiveFile(f.getName())) {
|
||||
archiveFile = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 没有匹配到文件
|
||||
if (archiveFile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileList.remove(archiveFile)) {
|
||||
customerFile.setFilePath(archiveFile.getAbsolutePath());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean useAsArchiveFile(VendorFileVo customerFile, File file, List<File> fileList,
|
||||
MessageHolder holder) {
|
||||
if (fileList == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 未关联存档文件,去找 fileList 查
|
||||
if (fileList.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查可编辑文件
|
||||
if (StringUtils.hasText(customerFile.getEditFilePath())) {
|
||||
// 移除 可编辑文件
|
||||
File editFile = new File(customerFile.getEditFilePath());
|
||||
fileList.remove(editFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
File editFile = null;
|
||||
// 文件名
|
||||
String fileName = file.getName();
|
||||
// 文件名,不含后缀
|
||||
String name = StringUtils.stripFilenameExtension(fileName);
|
||||
for (File f : fileList) {
|
||||
// 查找存档文件
|
||||
if (f.getName().startsWith(name) && FileUtils.isEditableFile(f.getName())) {
|
||||
editFile = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 没有匹配到文件
|
||||
if (editFile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileList.remove(editFile)) {
|
||||
String editFilePath = editFile.getAbsolutePath();
|
||||
if (!Objects.equals(editFilePath, customerFile.getEditFilePath())) {
|
||||
customerFile.setEditFilePath(editFilePath);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean fillFileAsDefaultType(VendorFileVo dbFile, File file,
|
||||
MessageHolder holder) {
|
||||
dbFile.setType(VendorFileType.General);
|
||||
fillFile(dbFile, file, null, holder);
|
||||
save(dbFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void save(VendorFileVo dbFile) {
|
||||
VendorFile v1 = vendorFileService.getById(dbFile.getId());
|
||||
vendorFileService.updateByVo(v1, dbFile);
|
||||
vendorFileService.save(v1);
|
||||
}
|
||||
|
||||
private void deleteFile(VendorFileVo dbFile) {
|
||||
VendorFile v1 = vendorFileService.getById(dbFile.getId());
|
||||
vendorFileService.delete(v1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ecep.contract.service.tasker;
|
||||
|
||||
import static com.ecep.contract.util.ExcelUtils.setCellValue;
|
||||
import static com.ecep.contract.util.ExcelUtils.getCellValue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -12,6 +13,7 @@ import java.io.OutputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
@@ -26,7 +28,7 @@ import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.cloud.tyc.CloudTycService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEvaluationFormFileService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.other.model.CloudTyc;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
@@ -34,6 +36,7 @@ import com.ecep.contract.ds.customer.model.CompanyCustomerEvaluationFormFile;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerFile;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
import com.ecep.contract.util.CompanyUtils;
|
||||
import com.ecep.contract.util.ExcelUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> implements WebSocketServerTasker {
|
||||
@@ -42,7 +45,7 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> impl
|
||||
@Override
|
||||
public void init(JsonNode argsNode) {
|
||||
int customerId = argsNode.get(0).asInt();
|
||||
customer = getCachedBean(CompanyCustomerService.class).getById(customerId);
|
||||
customer = getCachedBean(CustomerService.class).getById(customerId);
|
||||
}
|
||||
|
||||
CompanyCustomerFileService getCompanyCustomerFileService() {
|
||||
@@ -131,36 +134,100 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> impl
|
||||
}
|
||||
|
||||
private void updateSheet(Company company, Sheet sheet, MessageHolder holder) {
|
||||
setCellValue(sheet, "B3", "客户编号:" + CompanyUtils.formatCompanyVendorId(customer.getId()));
|
||||
setCellValue(sheet, "B4", "客户名称:" + company.getName());
|
||||
String customerId = "客户编号:" + CompanyUtils.formatCompanyVendorId(customer.getId());
|
||||
String currentCustomerId = ExcelUtils.getCellValue(sheet, "B3");
|
||||
if (!Objects.equals(customerId, currentCustomerId)) {
|
||||
setCellValue(sheet, "B3", customerId);
|
||||
holder.info("更新客户编号为:" + CompanyUtils.formatCompanyVendorId(customer.getId()));
|
||||
}
|
||||
|
||||
String customerName = "客户名称:" + company.getName();
|
||||
String currentCustomerName = ExcelUtils.getCellValue(sheet, "B4");
|
||||
if (!Objects.equals(customerName, currentCustomerName)) {
|
||||
setCellValue(sheet, "B4", customerName);
|
||||
holder.info("更新客户名称为:" + company.getName());
|
||||
}
|
||||
|
||||
LocalDate suggestDate = getCompanyCustomerFileService().getNextSignDate(customer, holder);
|
||||
if (suggestDate == null) {
|
||||
suggestDate = LocalDate.now();
|
||||
holder.debug("未获取到推荐评定日期,使用当前日期:" + suggestDate);
|
||||
} else {
|
||||
holder.debug("获取到推荐评定日期:" + suggestDate);
|
||||
}
|
||||
setCellValue(sheet, "H3", "评定时间:" + suggestDate);
|
||||
String evalDate = "评定时间:" + suggestDate;
|
||||
String currentEvalDate = ExcelUtils.getCellValue(sheet, "H3");
|
||||
if (!Objects.equals(evalDate, currentEvalDate)) {
|
||||
setCellValue(sheet, "H3", evalDate);
|
||||
holder.info("更新评定时间为:" + suggestDate);
|
||||
}
|
||||
|
||||
setCellValue(sheet, "H4", "统一社会信用代码:");
|
||||
setCellValue(sheet, "H5", company.getUniscid());
|
||||
|
||||
if (!Objects.equals(company.getUniscid(), ExcelUtils.getCellValue(sheet, "H5"))) {
|
||||
setCellValue(sheet, "H5", company.getUniscid());
|
||||
holder.info("更新统一社会信用代码为:" + company.getUniscid());
|
||||
}
|
||||
|
||||
// 注册所属地
|
||||
setCellValue(sheet, "B5", "注册所属地:" + company.getDistrict());
|
||||
String district = "注册所属地:" + company.getDistrict();
|
||||
if (!Objects.equals(district, ExcelUtils.getCellValue(sheet, "B5"))) {
|
||||
setCellValue(sheet, "B5", district);
|
||||
holder.info("更新注册所属地为:" + company.getDistrict());
|
||||
}
|
||||
|
||||
// 经营状态
|
||||
setCellValue(sheet, "D6", "经营状态:" + company.getEntStatus());
|
||||
String entStatus = "经营状态:" + company.getEntStatus();
|
||||
if (!Objects.equals(entStatus, ExcelUtils.getCellValue(sheet, "D6"))) {
|
||||
setCellValue(sheet, "D6", entStatus);
|
||||
holder.info("更新经营状态为:" + company.getEntStatus());
|
||||
}
|
||||
|
||||
// 成立日期
|
||||
setCellValue(sheet, "H6", "成立日期:" + company.getSetupDate());
|
||||
String setupDate = "成立日期:" + company.getSetupDate();
|
||||
if (!Objects.equals(setupDate, ExcelUtils.getCellValue(sheet, "H6"))) {
|
||||
setCellValue(sheet, "H6", setupDate);
|
||||
holder.info("更新成立日期为:" + company.getSetupDate());
|
||||
}
|
||||
|
||||
// 所属行业
|
||||
setCellValue(sheet, "D7", "所属行业:" + company.getIndustry());
|
||||
setCellValue(sheet, "D8",
|
||||
"注册资金:" + company.getRegisteredCapital() + " " + company.getRegisteredCapitalCurrency());
|
||||
String industry = "所属行业:" + company.getIndustry();
|
||||
if (!Objects.equals(industry, ExcelUtils.getCellValue(sheet, "D7"))) {
|
||||
setCellValue(sheet, "D7", industry);
|
||||
holder.info("更新所属行业为:" + company.getIndustry());
|
||||
}
|
||||
|
||||
String registeredCapital = "注册资金:" + company.getRegisteredCapital() + " " + company.getRegisteredCapitalCurrency();
|
||||
if (!Objects.equals(registeredCapital, ExcelUtils.getCellValue(sheet, "D8"))) {
|
||||
setCellValue(sheet, "D8", registeredCapital);
|
||||
holder.info("更新注册资金为:" + registeredCapital);
|
||||
}
|
||||
|
||||
// 企业类型
|
||||
setCellValue(sheet, "H10", "企业类型:" + company.getEntType());
|
||||
String entType = "企业类型:" + company.getEntType();
|
||||
if (!Objects.equals(entType, ExcelUtils.getCellValue(sheet, "H10"))) {
|
||||
setCellValue(sheet, "H10", entType);
|
||||
holder.info("更新企业类型为:" + company.getEntType());
|
||||
}
|
||||
|
||||
// 天眼评分
|
||||
CloudTycService cloudTycService = SpringApp.getBean(CloudTycService.class);
|
||||
CloudTyc cloudTyc = cloudTycService.getOrCreateCloudTyc(company);
|
||||
setCellValue(sheet, "D10", "天眼评分:" + (cloudTyc.getScore() > 0 ? cloudTyc.getScore() : ""));
|
||||
String tycScore = "天眼评分:" + (cloudTyc.getScore() > 0 ? cloudTyc.getScore() : "");
|
||||
if (!Objects.equals(tycScore, ExcelUtils.getCellValue(sheet, "D10"))) {
|
||||
setCellValue(sheet, "D10", tycScore);
|
||||
if (cloudTyc.getScore() > 0) {
|
||||
holder.info("更新天眼评分为:" + cloudTyc.getScore());
|
||||
} else {
|
||||
holder.debug("天眼评分未设置或为0");
|
||||
}
|
||||
}
|
||||
|
||||
// 检索评估表
|
||||
holder.debug("开始检索客户评价表文件");
|
||||
List<CompanyCustomerFile> customerFiles = getCompanyCustomerFileService().findAllByCustomerAndType(customer,
|
||||
CustomerFileType.EvaluationForm);
|
||||
holder.debug("共检索到 " + customerFiles.size() + " 个客户评价表文件");
|
||||
|
||||
List<CompanyCustomerEvaluationFormFile> filteredList = customerFiles.stream().filter(file -> {
|
||||
return file.getSignDate() != null && file.isValid();
|
||||
@@ -168,29 +235,45 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> impl
|
||||
.sorted(Comparator.comparing(CompanyCustomerFile::getSignDate))
|
||||
.map(getCompanyCustomerEvaluationFormFileService()::findByCustomerFile)
|
||||
.toList();
|
||||
holder.debug("有效评价表数量:" + filteredList.size());
|
||||
|
||||
if (filteredList.isEmpty()) {
|
||||
setCellValue(sheet, "C40", "首次评价");
|
||||
if (!Objects.equals("首次评价", ExcelUtils.getCellValue(sheet, "C40"))) {
|
||||
setCellValue(sheet, "C40", "首次评价");
|
||||
holder.info("设置客户为首次评价状态");
|
||||
}
|
||||
try {
|
||||
sheet.addMergedRegion(CellRangeAddress.valueOf("C40:K40"));
|
||||
} catch (Exception ignored) {
|
||||
holder.debug("合并单元格C40:K40失败,可能已合并");
|
||||
}
|
||||
} else {
|
||||
holder.info("客户有 " + filteredList.size() + " 条评价表");
|
||||
setCellValue(sheet, "C40", "评价日期");
|
||||
try {
|
||||
sheet.addMergedRegion(CellRangeAddress.valueOf("C40:D40"));
|
||||
} catch (Exception ignored) {
|
||||
holder.info("客户有 " + filteredList.size() + " 条有效评价表记录");
|
||||
if (!Objects.equals("评价日期", ExcelUtils.getCellValue(sheet, "C40"))) {
|
||||
setCellValue(sheet, "C40", "评价日期");
|
||||
try {
|
||||
sheet.addMergedRegion(CellRangeAddress.valueOf("C40:D40"));
|
||||
} catch (Exception ignored) {
|
||||
holder.debug("合并单元格C40:D40失败,可能已合并");
|
||||
}
|
||||
}
|
||||
if (!Objects.equals("经济指标", ExcelUtils.getCellValue(sheet, "E40"))) {
|
||||
setCellValue(sheet, "E40", "经济指标");
|
||||
}
|
||||
if (!Objects.equals("综合指标", ExcelUtils.getCellValue(sheet, "F40"))) {
|
||||
setCellValue(sheet, "F40", "综合指标");
|
||||
}
|
||||
if (!Objects.equals("资信等级", ExcelUtils.getCellValue(sheet, "G40"))) {
|
||||
setCellValue(sheet, "G40", "资信等级");
|
||||
}
|
||||
setCellValue(sheet, "E40", "经济指标");
|
||||
setCellValue(sheet, "F40", "综合指标");
|
||||
setCellValue(sheet, "G40", "资信等级");
|
||||
String[] CreditLevelTitles = new String[] { "-", "差★", " 一般★★", " 较好★★★", " 好★★★★", " " };
|
||||
int baseRow = 40;
|
||||
for (CompanyCustomerEvaluationFormFile form : filteredList) {
|
||||
baseRow++;
|
||||
CompanyCustomerFile customerFile = form.getCustomerFile();
|
||||
if (!Hibernate.isInitialized(customerFile)) {
|
||||
customerFile = getCompanyCustomerFileService().findById(customerFile.getId());
|
||||
holder.debug("延迟加载评价表文件信息,文件ID:" + customerFile.getId());
|
||||
}
|
||||
setCellValue(sheet, baseRow, 2, String.valueOf(customerFile.getSignDate()));
|
||||
setCellValue(sheet, baseRow, 4, form.getCatalog());
|
||||
@@ -203,9 +286,10 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> impl
|
||||
try {
|
||||
sheet.addMergedRegion(new CellRangeAddress(baseRow, baseRow, 2, 3));
|
||||
} catch (Exception ignored) {
|
||||
holder.debug("合并单元格第" + baseRow + "行的2-3列失败,可能已合并");
|
||||
}
|
||||
baseRow++;
|
||||
}
|
||||
holder.info("已成功更新所有评价表记录到Excel中");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.ecep.contract.CustomerFileType;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerFile;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
@@ -22,15 +22,15 @@ public class CompanyCustomerNextSignDateTask extends Tasker<Object> implements W
|
||||
@Override
|
||||
public void init(JsonNode argsNode) {
|
||||
int customerId = argsNode.get(0).asInt();
|
||||
customer = getCachedBean(CompanyCustomerService.class).getById(customerId);
|
||||
customer = getCachedBean(CustomerService.class).getById(customerId);
|
||||
}
|
||||
|
||||
CompanyCustomerFileService getCompanyCustomerFileService() {
|
||||
return getCachedBean(CompanyCustomerFileService.class);
|
||||
}
|
||||
|
||||
CompanyCustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CompanyCustomerService.class);
|
||||
CustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CustomerService.class);
|
||||
}
|
||||
|
||||
ContractService getContractService() {
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
@@ -19,8 +19,8 @@ public class CompanyCustomerRebuildFilesTasker extends Tasker<Object> implements
|
||||
|
||||
private CompanyCustomer customer;
|
||||
|
||||
CompanyCustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CompanyCustomerService.class);
|
||||
CustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CustomerService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ecep.contract.service.tasker;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.cloud.rk.CloudRkService;
|
||||
import com.ecep.contract.cloud.rk.ctx.CloudRkCtx;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
@@ -34,16 +35,18 @@ public class CompanyRkUpdateTasker extends Tasker<Object> implements WebSocketSe
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
holder.debug("1. 从 " + CloudServiceConstant.RK_NAME + " 更新...");
|
||||
try {
|
||||
cloudRkService = getCachedBean(CloudRkService.class);
|
||||
} catch (BeansException e) {
|
||||
throw new RuntimeException("服务未启用");
|
||||
throw new RuntimeException("服务未启用,请联系管理员");
|
||||
}
|
||||
CloudRk cloudRk = cloudRkService.getOrCreateCloudRk(company);
|
||||
if (cloudRk == null) {
|
||||
throw new RuntimeException("无法创建或获取 CloudRk 对象");
|
||||
}
|
||||
if (cloudRk.getLatestUpdate() != null) {
|
||||
holder.info("上次更新:" + MyDateTimeUtils.format(cloudRk.getLatestUpdate()));
|
||||
}
|
||||
|
||||
try {
|
||||
CloudRkCtx cloudRkCtx = new CloudRkCtx();
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
package com.ecep.contract.service.tasker;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.ds.company.service.CompanyContactService;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.vendor.model.Vendor;
|
||||
import com.ecep.contract.ds.vendor.model.VendorFile;
|
||||
import com.ecep.contract.ds.vendor.service.VendorFileService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorService;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
import com.ecep.contract.util.ExcelUtils;
|
||||
import com.ecep.contract.vo.CompanyContactVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.ecep.contract.util.ExcelUtils.getCellValue;
|
||||
import static com.ecep.contract.util.ExcelUtils.setCellValue;
|
||||
|
||||
/**
|
||||
* 更新供应商评价表
|
||||
*/
|
||||
@Component
|
||||
public class CompanyVendorEvaluationFormUpdateTask extends Tasker<Object> implements WebSocketServerTasker {
|
||||
private VendorVo vendor;
|
||||
private CompanyVo company;
|
||||
private File template;
|
||||
|
||||
@Override
|
||||
public void init(JsonNode argsNode) {
|
||||
int vendorId = argsNode.get(0).asInt();
|
||||
vendor = getVendorService().findById(vendorId);
|
||||
}
|
||||
|
||||
private VendorService getVendorService() {
|
||||
return getCachedBean(VendorService.class);
|
||||
}
|
||||
|
||||
VendorFileService getVendorFileService() {
|
||||
return getCachedBean(VendorFileService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
if (vendor == null) {
|
||||
holder.error("未找到供应商信息");
|
||||
return null;
|
||||
}
|
||||
if (!StringUtils.hasText(vendor.getPath())) {
|
||||
holder.error("供应商目录未设置,请先设置供应商目录");
|
||||
return null;
|
||||
}
|
||||
updateEvaluationForm(holder);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateEvaluationForm(MessageHolder holder) {
|
||||
company = getCachedBean(CompanyService.class).findById(vendor.getCompanyId());
|
||||
|
||||
template = getVendorFileService().getEvaluationFormTemplate();
|
||||
if (template == null) {
|
||||
holder.error("评价表模板文件未设置,请先设置评价表模板文件");
|
||||
return;
|
||||
}
|
||||
if (!template.exists()) {
|
||||
holder.error("评价表模板文件 " + template.getAbsolutePath() + " 不存在,请检查");
|
||||
return;
|
||||
}
|
||||
|
||||
updateProgress(1, 10);
|
||||
File dir = new File(vendor.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());
|
||||
}
|
||||
} 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("评价表已创建");
|
||||
// 创建 VendorFile 对象
|
||||
VendorFile vendorFile = new VendorFile();
|
||||
Vendor vendorEntity = getCachedBean(VendorService.class).getById(vendor.getId());
|
||||
vendorFile.setVendor(vendorEntity);
|
||||
vendorFile.setFilePath(destFile.getAbsolutePath());
|
||||
vendorFile.setType(VendorFileType.EvaluationForm);
|
||||
vendorFile.setSignDate(LocalDate.now());
|
||||
vendorFile.setValid(false);
|
||||
getVendorFileService().save(vendorFile);
|
||||
} catch (Exception e) {
|
||||
holder.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
updateProgress(10, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新供应商评估表,依据模板创建,如果已经存在生成的文件,则更新评估表
|
||||
*
|
||||
* @param wb work book
|
||||
* @param destFile 目标文件
|
||||
*/
|
||||
public void updateEvaluationForm(Workbook wb, File destFile, MessageHolder holder) throws IOException {
|
||||
updateProgress(2, 10);
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
holder.info("更新 " + sheet.getSheetName() + " Sheet");
|
||||
updateSheet(sheet, holder.sub(" - "));
|
||||
updateProgress(8, 10);
|
||||
// 输出到文件
|
||||
try (OutputStream fileOut = new FileOutputStream(destFile)) {
|
||||
wb.write(fileOut);
|
||||
} catch (FileNotFoundException e) {
|
||||
holder.error("写评估表时发生文件错误,请检查评估表是否被打开中:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSheet(Sheet sheet, MessageHolder holder) {
|
||||
String vendor_id = "" + vendor.getId();
|
||||
if (!Objects.equals(vendor_id, getCellValue(sheet, "G1"))) {
|
||||
setCellValue(sheet, "G1", vendor_id);
|
||||
holder.info("供应商编号更新为:" + vendor_id);
|
||||
}
|
||||
|
||||
String companyName = company.getName();
|
||||
if (!Objects.equals(companyName, getCellValue(sheet, "B2"))) {
|
||||
setCellValue(sheet, "B2", companyName);
|
||||
holder.info("供应商名称更新为:" + companyName);
|
||||
}
|
||||
|
||||
String address = null;
|
||||
// 联系人
|
||||
CompanyContactVo contact = null;
|
||||
if (vendor.getContactId() != null) {
|
||||
contact = getCompanyContactService().findById(vendor.getContactId());
|
||||
if (contact != null) {
|
||||
holder.debug("供应商指定联系人:" + contact.getName());
|
||||
}
|
||||
}
|
||||
if (contact == null) {
|
||||
contact = getCompanyContactService().findFirstByCompany(company);
|
||||
if (contact != null) {
|
||||
holder.debug("从公司联系人列表中获取联系人:" + contact.getName());
|
||||
}
|
||||
}
|
||||
if (contact != null) {
|
||||
String contactName = contact.getName();
|
||||
if (!Objects.equals(contactName, getCellValue(sheet, "F2"))) {
|
||||
setCellValue(sheet, "F2", contactName);
|
||||
holder.info("联系人姓名更新为:" + contactName);
|
||||
}
|
||||
String contactPhone = contact.getPhone();
|
||||
if (StringUtils.hasText(contactPhone)) {
|
||||
if (!Objects.equals(contactPhone, getCellValue(sheet, "F3"))) {
|
||||
setCellValue(sheet, "F3", contactPhone);
|
||||
holder.info("联系人电话更新为:" + contactPhone);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(contact.getAddress())) {
|
||||
address = contact.getAddress();
|
||||
}
|
||||
}
|
||||
|
||||
if (!StringUtils.hasText(address)) {
|
||||
address = company.getAddress();
|
||||
if (StringUtils.hasText(address)) {
|
||||
holder.debug("使用公司地址:" + address);
|
||||
}
|
||||
}
|
||||
if (!StringUtils.hasText(address)) {
|
||||
address = company.getRegAddr();
|
||||
if (StringUtils.hasText(address)) {
|
||||
holder.debug("使用公司注册地址:" + address);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(address)) {
|
||||
if (!Objects.equals(address, getCellValue(sheet, "B3"))) {
|
||||
setCellValue(sheet, "B3", address);
|
||||
holder.info("更新供应商地址为:" + address);
|
||||
}
|
||||
} else {
|
||||
holder.warn("没有获取到供应商地址,请检查供应商信息");
|
||||
}
|
||||
|
||||
|
||||
String companyUniscid = company.getUniscid();
|
||||
if (!Objects.equals(companyUniscid, getCellValue(sheet, "B8"))) {
|
||||
setCellValue(sheet, "B8", companyUniscid);
|
||||
holder.info("更新供应商统一社会信用代码为:" + companyUniscid);
|
||||
}
|
||||
|
||||
String regCap = company.getRegisteredCapital() + " " + company.getRegisteredCapitalCurrency();
|
||||
if (!Objects.equals(regCap, getCellValue(sheet, "E8"))) {
|
||||
setCellValue(sheet, "E8", regCap);
|
||||
holder.info("更新供应商注册资金为:" + regCap);
|
||||
}
|
||||
|
||||
setCellValue(sheet, "H8", company.getOperationPeriodBegin());
|
||||
if (company.getOperationPeriodEnd() == null) {
|
||||
if (company.getOperationPeriodBegin() != null) {
|
||||
setCellValue(sheet, "H9", "无固定期限");
|
||||
}
|
||||
} else {
|
||||
setCellValue(sheet, "H9", company.getOperationPeriodEnd());
|
||||
}
|
||||
|
||||
String vendorPurchase = vendor.getPurchase();
|
||||
if (!Objects.equals(vendorPurchase, getCellValue(sheet, "C4"))) {
|
||||
setCellValue(sheet, "C4", vendorPurchase);
|
||||
holder.info("更新供应商采购内容为:" + vendorPurchase);
|
||||
}
|
||||
|
||||
Cell a6 = ExcelUtils.getCell(sheet, "A6");
|
||||
if (a6 != null) {
|
||||
if (!Objects.equals(a6.getStringCellValue(), vendor.getDescription())) {
|
||||
a6.setCellValue(vendor.getDescription());
|
||||
holder.info("更新供应商描述为:" + StringUtils.truncate(a6.getStringCellValue(), 30));
|
||||
}
|
||||
if (a6.getCellStyle().getAlignment() != HorizontalAlignment.LEFT) {
|
||||
a6.getCellStyle().setAlignment(HorizontalAlignment.LEFT);
|
||||
holder.info("更新供应商描述对齐方式为左对齐");
|
||||
}
|
||||
}
|
||||
|
||||
// 第一个评价日期
|
||||
Cell g16 = ExcelUtils.getCell(sheet, "G16");
|
||||
if (g16 == null) {
|
||||
holder.error("模板异常, 第一个评价日期单元格(G16)未找到!");
|
||||
} else {
|
||||
CellType cellType = g16.getCellType();
|
||||
// 未设置, 尝试更新
|
||||
if (cellType == CellType.BLANK || cellType == CellType.NUMERIC) {
|
||||
holder.debug("推算下一个评价日期...");
|
||||
LocalDate nextSignDate = getVendorFileService().getNextSignDate(vendor, holder.sub(" -| "));
|
||||
// 当没有推荐日期时,说明不需要评价,更新为空
|
||||
if (nextSignDate == null) {
|
||||
g16.setBlank();
|
||||
holder.info("!未推算出下一个评价日期,单元格设空!");
|
||||
} else {
|
||||
holder.debug("推算出下一个评价日期:" + nextSignDate);
|
||||
LocalDateTime value = g16.getLocalDateTimeCellValue();
|
||||
if (value == null) {
|
||||
g16.setCellValue(nextSignDate);
|
||||
holder.info("评价日期更新为:" + nextSignDate);
|
||||
} else {
|
||||
if (!Objects.equals(value.toLocalDate(), nextSignDate)) {
|
||||
g16.setCellValue(nextSignDate);
|
||||
holder.info("评价日期更新为:" + nextSignDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
holder.warn("第一个评价日期所在单元格 " + g16.getAddress().formatAsR1C1String() + " 的单元格类型未知:" + cellType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CompanyContactService getCompanyContactService() {
|
||||
return getCachedBean(CompanyContactService.class);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.ecep.contract.service.tasker;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerFile;
|
||||
@@ -104,7 +104,7 @@ public class CustomerFileMoveTasker extends Tasker<Object> implements WebSocketS
|
||||
return getCachedBean(CompanyCustomerFileService.class);
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CompanyCustomerService.class);
|
||||
private CustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CustomerService.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.ecep.contract.service.tasker;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.vendor.model.Vendor;
|
||||
import com.ecep.contract.ds.vendor.model.VendorFile;
|
||||
import com.ecep.contract.ds.vendor.service.VendorFileService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorService;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
public class VendorNextSignDateTask extends Tasker<Object> implements WebSocketServerTasker {
|
||||
|
||||
private Vendor vendor;
|
||||
|
||||
@Override
|
||||
public void init(JsonNode argsNode) {
|
||||
int vendorId = argsNode.get(0).asInt();
|
||||
vendor = getCachedBean(VendorService.class).getById(vendorId);
|
||||
}
|
||||
|
||||
VendorFileService getVendorFileService() {
|
||||
return getCachedBean(VendorFileService.class);
|
||||
}
|
||||
|
||||
VendorService getVendorService() {
|
||||
return getCachedBean(VendorService.class);
|
||||
}
|
||||
|
||||
ContractService getContractService() {
|
||||
return getCachedBean(ContractService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
if (vendor == null) {
|
||||
holder.error("未找到供应商信息");
|
||||
return null;
|
||||
}
|
||||
|
||||
holder.info("开始计算供应商下一个评价日期");
|
||||
|
||||
LocalDate nextSignDate = calculateNextSignDate(holder);
|
||||
|
||||
if (nextSignDate != null) {
|
||||
holder.info("下一个评价日期:" + nextSignDate);
|
||||
} else {
|
||||
holder.warn("无法计算下一个评价日期");
|
||||
}
|
||||
|
||||
return nextSignDate;
|
||||
}
|
||||
|
||||
private LocalDate calculateNextSignDate(MessageHolder holder) {
|
||||
LocalDate miniContractDate = LocalDate.of(2022, 1, 1);
|
||||
|
||||
// 检索全部合同
|
||||
ContractService contractService = getContractService();
|
||||
List<Contract> contractList = contractService.findAllByCompanyVendor(vendor, null, null);
|
||||
if (contractList.isEmpty()) {
|
||||
holder.error("未发现已登记的合同");
|
||||
return null;
|
||||
}
|
||||
|
||||
holder.info("发现" + contractList.size() + "份合同");
|
||||
|
||||
// 检索评价表
|
||||
List<VendorFile> files = getVendorFileService().findAllByVendorAndType(vendor,
|
||||
VendorFileType.EvaluationForm);
|
||||
VendorFile latestFile = files.stream()
|
||||
.filter(v -> v.getSignDate() != null && v.isValid())
|
||||
.max(Comparator.comparing(VendorFile::getSignDate))
|
||||
.orElse(null);
|
||||
|
||||
// 没有有效的评价表的评价日期
|
||||
if (latestFile == null) {
|
||||
holder.warn("未发现有效的评价表");
|
||||
// 返回最早的合同日期
|
||||
Contract firstContract = contractList.stream()
|
||||
.filter(v -> v.getSetupDate() != null && !v.getSetupDate().isBefore(miniContractDate))
|
||||
.min(Comparator.comparing(Contract::getSetupDate))
|
||||
.orElse(null);
|
||||
|
||||
if (firstContract == null) {
|
||||
holder.error("最早的合同不存在");
|
||||
return null;
|
||||
}
|
||||
|
||||
LocalDate setupDate = firstContract.getSetupDate();
|
||||
holder.info("选择最早的合同:" + firstContract.getCode() + ",日期:" + setupDate);
|
||||
return setupDate.plusDays(-7);
|
||||
}
|
||||
|
||||
// 有有效的评价表,计算下一个日期
|
||||
LocalDate lastSignDate = latestFile.getSignDate();
|
||||
holder.info("最近一次有效的评价表日期:" + lastSignDate);
|
||||
|
||||
// 查找最近一次评价日期之后的合同
|
||||
Contract firstContractAfter = contractList.stream()
|
||||
.filter(v -> v.getSetupDate() != null && v.getSetupDate().isAfter(lastSignDate))
|
||||
.min(Comparator.comparing(Contract::getSetupDate))
|
||||
.orElse(null);
|
||||
|
||||
if (firstContractAfter == null) {
|
||||
holder.warn("没有找到在" + lastSignDate + "之后的合同");
|
||||
// 返回当前日期作为建议
|
||||
return LocalDate.now();
|
||||
}
|
||||
|
||||
LocalDate setupDate = firstContractAfter.getSetupDate();
|
||||
holder.info("找到最近一次评价日期后的第一个合同:" + firstContractAfter.getCode() + ",日期:" + setupDate);
|
||||
|
||||
return setupDate.plusDays(-7);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import com.ecep.contract.ds.contract.service.ContractFileTypeService;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerFileTypeService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.project.service.ProjectFileService;
|
||||
import com.ecep.contract.ds.project.service.ProjectFileTypeService;
|
||||
@@ -109,8 +109,8 @@ public class VerifyContext {
|
||||
|
||||
// Customer
|
||||
|
||||
protected CompanyCustomerService getCompanyCustomerService() {
|
||||
return getBean(CompanyCustomerService.class);
|
||||
protected CustomerService getCompanyCustomerService() {
|
||||
return getBean(CustomerService.class);
|
||||
}
|
||||
|
||||
protected CompanyCustomerFileTypeService getCompanyCustomerFileTypeService() {
|
||||
|
||||
@@ -4,14 +4,17 @@
|
||||
"ContractRepairTask": "com.ecep.contract.service.tasker.ContractRepairTasker",
|
||||
"ContractVerifyTasker": "com.ecep.contract.service.tasker.ContractVerifyTasker",
|
||||
"ProjectCostImportItemsFromContractsTasker": "com.ecep.contract.service.tasker.ProjectCostImportItemsFromContractsTasker",
|
||||
"CompanyCustomerEvaluationFormUpdateTask": "com.ecep.contract.service.tasker.CompanyCustomerEvaluationFormUpdateTask",
|
||||
"CompanyCustomerNextSignDateTask": "com.ecep.contract.service.tasker.CompanyCustomerNextSignDateTask",
|
||||
"CompanyCustomerRebuildFilesTasker": "com.ecep.contract.service.tasker.CompanyCustomerRebuildFilesTasker",
|
||||
"CustomerEvaluationFormUpdateTask": "com.ecep.contract.service.tasker.CompanyCustomerEvaluationFormUpdateTask",
|
||||
"CustomerNextSignDateTask": "com.ecep.contract.service.tasker.CompanyCustomerNextSignDateTask",
|
||||
"CustomerRebuildFilesTasker": "com.ecep.contract.service.tasker.CompanyCustomerRebuildFilesTasker",
|
||||
"CustomerFileMoveTasker": "com.ecep.contract.service.tasker.CustomerFileMoveTasker",
|
||||
"CompanyCompositeUpdateTasker": "com.ecep.contract.service.tasker.CompanyCompositeUpdateTasker",
|
||||
"CompanyVerifyTasker": "com.ecep.contract.service.tasker.CompanyVerifyTasker",
|
||||
"CompanyRkUpdateTasker": "com.ecep.contract.service.tasker.CompanyRkUpdateTasker",
|
||||
"CloudRkSyncTask": "com.ecep.contract.cloud.rk.CloudRkSyncTask"
|
||||
"CloudRkSyncTask": "com.ecep.contract.cloud.rk.CloudRkSyncTask",
|
||||
"VendorReBuildFilesTasker": "com.ecep.contract.ds.vendor.task.VendorReBuildFilesTasker",
|
||||
"CompanyVendorEvaluationFormUpdateTask": "com.ecep.contract.service.tasker.CompanyVendorEvaluationFormUpdateTask",
|
||||
"VendorNextSignDateTask": "com.ecep.contract.service.tasker.VendorNextSignDateTask"
|
||||
},
|
||||
"descriptions": "任务注册信息"
|
||||
"descriptions": "任务注册信息, 客户端的任务可以通过 WebSocket 调用"
|
||||
}
|
||||
Reference in New Issue
Block a user