Compare commits
4 Commits
e8c8305f40
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 643338f4b0 | |||
| 880671a5a9 | |||
| 4e738bea3c | |||
| 3cf3a717be |
@@ -12,6 +12,9 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.control.*;
|
||||||
|
import org.controlsfx.control.PopOver;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -50,13 +53,6 @@ import javafx.collections.ObservableList;
|
|||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.CheckMenuItem;
|
|
||||||
import javafx.scene.control.DatePicker;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.control.TableCell;
|
|
||||||
import javafx.scene.control.TableColumn;
|
|
||||||
import javafx.scene.control.TableView;
|
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
@@ -79,6 +75,7 @@ public class ContractVerifyWindowController extends BaseController {
|
|||||||
return super.show(loader, owner, modality);
|
return super.show(loader, owner, modality);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
public static class MessageExt extends Message {
|
public static class MessageExt extends Message {
|
||||||
@@ -90,12 +87,16 @@ public class ContractVerifyWindowController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Model implements MessageHolder {
|
public static class Model {
|
||||||
private SimpleStringProperty code = new SimpleStringProperty();
|
private SimpleStringProperty code = new SimpleStringProperty();
|
||||||
private SimpleStringProperty name = new SimpleStringProperty();
|
private SimpleStringProperty name = new SimpleStringProperty();
|
||||||
private SimpleObjectProperty<Integer> employee = new SimpleObjectProperty<>();
|
private SimpleObjectProperty<Integer> employee = new SimpleObjectProperty<>();
|
||||||
private SimpleObjectProperty<LocalDate> setupDate = new SimpleObjectProperty<>();
|
private SimpleObjectProperty<LocalDate> setupDate = new SimpleObjectProperty<>();
|
||||||
private SimpleListProperty<MessageExt> messages = new SimpleListProperty<>(FXCollections.observableArrayList());
|
private SimpleListProperty<MessageExt> messages = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||||
|
}
|
||||||
|
|
||||||
|
static class MessageHolderImpl implements MessageHolder {
|
||||||
|
List<MessageExt> messages = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMessage(Level level, String message) {
|
public void addMessage(Level level, String message) {
|
||||||
@@ -261,6 +262,8 @@ public class ContractVerifyWindowController extends BaseController {
|
|||||||
long total = contractService.count(params);
|
long total = contractService.count(params);
|
||||||
setStatus("合同:" + total + " 条");
|
setStatus("合同:" + total + " 条");
|
||||||
|
|
||||||
|
MessageHolderImpl messageHolder = new MessageHolderImpl();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (isCloseRequested()) {
|
if (isCloseRequested()) {
|
||||||
break;
|
break;
|
||||||
@@ -268,6 +271,7 @@ public class ContractVerifyWindowController extends BaseController {
|
|||||||
|
|
||||||
Page<ContractVo> page = contractService.findAll(params, pageRequest);
|
Page<ContractVo> page = contractService.findAll(params, pageRequest);
|
||||||
for (ContractVo contract : page) {
|
for (ContractVo contract : page) {
|
||||||
|
messageHolder.messages.clear();
|
||||||
if (isCloseRequested()) {
|
if (isCloseRequested()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -285,11 +289,11 @@ public class ContractVerifyWindowController extends BaseController {
|
|||||||
model.getName().set(contract.getName());
|
model.getName().set(contract.getName());
|
||||||
model.getSetupDate().set(contract.getSetupDate());
|
model.getSetupDate().set(contract.getSetupDate());
|
||||||
|
|
||||||
comm.verify(contract, model);
|
comm.verify(contract, messageHolder);
|
||||||
setStatus("合同验证进度:" + counter.get() + " / " + total);
|
setStatus("合同验证进度:" + counter.get() + " / " + total);
|
||||||
// 移除中间消息
|
// 移除中间消息
|
||||||
if (!model.getMessages().isEmpty()) {
|
if (!messageHolder.messages.isEmpty()) {
|
||||||
model.getMessages().removeIf(msg -> msg.getLevel().intValue() <= Level.INFO.intValue());
|
model.getMessages().setAll(messageHolder.messages.stream().filter(msg -> msg.getLevel().intValue() > Level.INFO.intValue()).limit(50).toList());
|
||||||
}
|
}
|
||||||
if (model.getMessages().isEmpty()) {
|
if (model.getMessages().isEmpty()) {
|
||||||
if (onlyShowVerifiedChecker.isSelected()) {
|
if (onlyShowVerifiedChecker.isSelected()) {
|
||||||
@@ -325,6 +329,7 @@ public class ContractVerifyWindowController extends BaseController {
|
|||||||
}
|
}
|
||||||
runAsync(() -> {
|
runAsync(() -> {
|
||||||
ContractVo contract = null;
|
ContractVo contract = null;
|
||||||
|
MessageHolderImpl messageHolder = new MessageHolderImpl();
|
||||||
try {
|
try {
|
||||||
contract = contractService.findByCode(contractCode);
|
contract = contractService.findByCode(contractCode);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -336,17 +341,18 @@ public class ContractVerifyWindowController extends BaseController {
|
|||||||
}
|
}
|
||||||
model.getMessages().clear();
|
model.getMessages().clear();
|
||||||
try {
|
try {
|
||||||
comm.verify(contract, model);
|
comm.verify(contract, messageHolder);
|
||||||
// 移除中间消息
|
|
||||||
if (!model.getMessages().isEmpty()) {
|
|
||||||
model.getMessages().removeIf(msg -> msg.getLevel().intValue() <= Level.INFO.intValue());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(model.getCode().get(), e);
|
logger.error(model.getCode().get(), e);
|
||||||
model.error(e.getMessage());
|
messageHolder.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.getMessages().isEmpty()) {
|
// 移除中间消息
|
||||||
|
if (!messageHolder.messages.isEmpty()) {
|
||||||
|
model.getMessages().setAll(messageHolder.messages.stream().filter(msg -> msg.getLevel().intValue() > Level.INFO.intValue()).limit(50).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (messageHolder.messages.isEmpty()) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
viewTableDataSet.remove(model);
|
viewTableDataSet.remove(model);
|
||||||
});
|
});
|
||||||
@@ -380,6 +386,38 @@ public class ContractVerifyWindowController extends BaseController {
|
|||||||
ContractWindowController.show(contract, viewTable.getScene().getWindow());
|
ContractWindowController.show(contract, viewTable.getScene().getWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void onShowVerifyStatusAction(ActionEvent event) {
|
||||||
|
|
||||||
|
// 在新新窗口中显示 状态消息 Model# messages
|
||||||
|
|
||||||
|
Model selectedItem = viewTable.getSelectionModel().getSelectedItem();
|
||||||
|
if (selectedItem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView<MessageExt> listView = new ListView<>();
|
||||||
|
listView.setItems(selectedItem.messages);
|
||||||
|
listView.setCellFactory(v -> new ListCell<>() {
|
||||||
|
@Override
|
||||||
|
protected void updateItem(MessageExt item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (item == null || empty) {
|
||||||
|
setText(null);
|
||||||
|
setGraphic(null);
|
||||||
|
} else {
|
||||||
|
setText(item.getMessage());
|
||||||
|
setGraphic(new Label(item.getPrefix()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
PopOver popOver = new PopOver(listView);
|
||||||
|
popOver.setArrowLocation(PopOver.ArrowLocation.TOP_LEFT);
|
||||||
|
MenuItem menuItem = (MenuItem) event.getSource();
|
||||||
|
Node node = viewTable.lookup(".table-row-cell:selected");
|
||||||
|
popOver.show(node);
|
||||||
|
}
|
||||||
|
|
||||||
public void onExportVerifyResultAsFileAction(ActionEvent e) {
|
public void onExportVerifyResultAsFileAction(ActionEvent e) {
|
||||||
FileChooser chooser = new FileChooser();
|
FileChooser chooser = new FileChooser();
|
||||||
chooser.setTitle("导出核验结果");
|
chooser.setTitle("导出核验结果");
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.ecep.contract.controller.employee;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ecep.contract.util.ParamUtils;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
import com.ecep.contract.controller.tab.TabSkin;
|
import com.ecep.contract.controller.tab.TabSkin;
|
||||||
@@ -48,7 +50,7 @@ public class EmployeeTabSkinRole
|
|||||||
|
|
||||||
private void initializeListView() {
|
private void initializeListView() {
|
||||||
// 非系统内置账户
|
// 非系统内置账户
|
||||||
HashMap<String, Object> params = new HashMap<>();
|
Map<String, Object> params = ParamUtils.builder().build();
|
||||||
List<EmployeeRoleVo> roles = getEmployeeRoleService().findAll(params, Pageable.ofSize(500)).getContent();
|
List<EmployeeRoleVo> roles = getEmployeeRoleService().findAll(params, Pageable.ofSize(500)).getContent();
|
||||||
|
|
||||||
controller.rolesField.getSourceItems().setAll(roles);
|
controller.rolesField.getSourceItems().setAll(roles);
|
||||||
|
|||||||
@@ -39,13 +39,13 @@ public class CompanyCustomerFileTypeService
|
|||||||
return super.findAll();
|
return super.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(put = { @CachePut(key = "#p0.id"), @CachePut(key = "'all'") })
|
@Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'all'")})
|
||||||
@Override
|
@Override
|
||||||
public CustomerFileTypeLocalVo save(CustomerFileTypeLocalVo entity) {
|
public CustomerFileTypeLocalVo save(CustomerFileTypeLocalVo entity) {
|
||||||
return super.save(entity);
|
return super.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(put = { @CachePut(key = "#p0.id"), @CachePut(key = "'all'") })
|
@Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'all'")})
|
||||||
@Override
|
@Override
|
||||||
public void delete(CustomerFileTypeLocalVo entity) {
|
public void delete(CustomerFileTypeLocalVo entity) {
|
||||||
super.delete(entity);
|
super.delete(entity);
|
||||||
@@ -53,8 +53,7 @@ public class CompanyCustomerFileTypeService
|
|||||||
|
|
||||||
@Cacheable
|
@Cacheable
|
||||||
public Map<CustomerFileType, CustomerFileTypeLocalVo> findAll(Locale locale) {
|
public Map<CustomerFileType, CustomerFileTypeLocalVo> findAll(Locale locale) {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = ParamUtils.builder().equals("lang", locale.toLanguageTag()).build();
|
||||||
params.put("lang", locale.toLanguageTag());
|
|
||||||
return findAll(params, Pageable.unpaged()).stream()
|
return findAll(params, Pageable.unpaged()).stream()
|
||||||
.collect(Collectors.toMap(CustomerFileTypeLocalVo::getType, Function.identity()));
|
.collect(Collectors.toMap(CustomerFileTypeLocalVo::getType, Function.identity()));
|
||||||
}
|
}
|
||||||
@@ -66,7 +65,7 @@ public class CompanyCustomerFileTypeService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据语言标签和参数查找单个 CustomerFileTypeLocalVo 对象
|
* 根据语言标签和参数查找单个 CustomerFileTypeLocalVo 对象
|
||||||
*
|
*
|
||||||
* @param locale 语言区域
|
* @param locale 语言区域
|
||||||
* @param key 参数键
|
* @param key 参数键
|
||||||
* @param value 参数值
|
* @param value 参数值
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ecep.contract.service;
|
package com.ecep.contract.service;
|
||||||
|
|
||||||
|
import com.ecep.contract.util.ParamUtils;
|
||||||
import com.ecep.contract.vm.CompanyInvoiceInfoViewModel;
|
import com.ecep.contract.vm.CompanyInvoiceInfoViewModel;
|
||||||
import com.ecep.contract.vo.CompanyInvoiceInfoVo;
|
import com.ecep.contract.vo.CompanyInvoiceInfoVo;
|
||||||
import com.ecep.contract.vo.CompanyVo;
|
import com.ecep.contract.vo.CompanyVo;
|
||||||
@@ -15,9 +16,8 @@ import java.util.Map;
|
|||||||
public class CompanyInvoiceInfoService extends QueryService<CompanyInvoiceInfoVo, CompanyInvoiceInfoViewModel> {
|
public class CompanyInvoiceInfoService extends QueryService<CompanyInvoiceInfoVo, CompanyInvoiceInfoViewModel> {
|
||||||
|
|
||||||
public List<CompanyInvoiceInfoVo> searchByCompany(CompanyVo company, String searchText) {
|
public List<CompanyInvoiceInfoVo> searchByCompany(CompanyVo company, String searchText) {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = ParamUtils.builder().equals("company", company.getId())
|
||||||
params.put("company", company);
|
.search(searchText).build();
|
||||||
params.put("searchText", searchText);
|
|
||||||
return findAll(params, Pageable.unpaged()).getContent();
|
return findAll(params, Pageable.unpaged()).getContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
|
import com.ecep.contract.util.ParamUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
@@ -58,8 +59,7 @@ public class CompanyService extends QueryService<CompanyVo, CompanyViewModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<CompanyVo> findAllByName(String name) {
|
public List<CompanyVo> findAllByName(String name) {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = ParamUtils.builder().equals("name", name).build();
|
||||||
params.put("name", name);
|
|
||||||
return findAll(params, Pageable.unpaged()).getContent();
|
return findAll(params, Pageable.unpaged()).getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,12 @@ import com.ecep.contract.vo.ContractVo;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ContractFileService extends QueryService<ContractFileVo, ContractFileViewModel> {
|
public class ContractFileService extends QueryService<ContractFileVo, ContractFileViewModel> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContractFileVo findById(Integer id) {
|
||||||
|
return super.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
public List<ContractFileVo> findAllByContract(ContractVo contract) {
|
public List<ContractFileVo> findAllByContract(ContractVo contract) {
|
||||||
return findAll(ParamUtils.equal("contract", contract.getId()), Pageable.unpaged()).getContent();
|
return findAll(ParamUtils.equal("contract", contract.getId()), Pageable.unpaged()).getContent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ public class ProjectSaleTypeService extends QueryService<ProjectSaleTypeVo, Proj
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ProjectSaleTypeVo findByCode(String code) {
|
public ProjectSaleTypeVo findByCode(String code) {
|
||||||
return findAll(ParamUtils.builder().equals("code", code).build(), Pageable.ofSize(1)).getContent().getFirst();
|
return findOneByProperty("code", code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectSaleTypeVo findByName(String name) {
|
public ProjectSaleTypeVo findByName(String name) {
|
||||||
return findAll(ParamUtils.builder().equals("name", name).build(), Pageable.ofSize(1)).getContent().getFirst();
|
return findOneByProperty("name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(evict = {@CacheEvict(key = "#p0.id")})
|
@Caching(evict = {@CacheEvict(key = "#p0.id")})
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.ecep.contract.service;
|
|||||||
import com.ecep.contract.PageArgument;
|
import com.ecep.contract.PageArgument;
|
||||||
import com.ecep.contract.PageContent;
|
import com.ecep.contract.PageContent;
|
||||||
import com.ecep.contract.WebSocketClientService;
|
import com.ecep.contract.WebSocketClientService;
|
||||||
|
import com.ecep.contract.constant.ServiceConstant;
|
||||||
import com.ecep.contract.model.IdentityEntity;
|
import com.ecep.contract.model.IdentityEntity;
|
||||||
import com.ecep.contract.model.NamedEntity;
|
import com.ecep.contract.model.NamedEntity;
|
||||||
import com.ecep.contract.util.ParamUtils;
|
import com.ecep.contract.util.ParamUtils;
|
||||||
@@ -67,7 +68,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
@Override
|
@Override
|
||||||
public T save(T entity) {
|
public T save(T entity) {
|
||||||
try {
|
try {
|
||||||
return async("save", entity, entity.getClass().getName()).handle((response, ex) -> {
|
return async(ServiceConstant.SAVE_METHOD_NAME, entity, entity.getClass().getName()).handle((response, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
throw new RuntimeException("保存实体失败", ex);
|
throw new RuntimeException("保存实体失败", ex);
|
||||||
}
|
}
|
||||||
@@ -88,7 +89,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
@Override
|
@Override
|
||||||
public void delete(T entity) {
|
public void delete(T entity) {
|
||||||
try {
|
try {
|
||||||
async("delete", entity, entity.getClass().getName()).handle((response, ex) -> {
|
async(ServiceConstant.DELETE_METHOD_NAME, entity, entity.getClass().getName()).handle((response, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
throw new RuntimeException("删除实体失败", ex);
|
throw new RuntimeException("删除实体失败", ex);
|
||||||
}
|
}
|
||||||
@@ -117,7 +118,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<T> asyncFindById(Integer id) {
|
public CompletableFuture<T> asyncFindById(Integer id) {
|
||||||
return async("findById", id, Integer.class).handle((response, ex) -> {
|
return async(ServiceConstant.FIND_BY_ID_METHOD_NAME, id, Integer.class).handle((response, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
throw new RuntimeException("查询实体失败", ex);
|
throw new RuntimeException("查询实体失败", ex);
|
||||||
}
|
}
|
||||||
@@ -149,7 +150,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
*/
|
*/
|
||||||
public CompletableFuture<Page<T>> asyncFindAll(Map<String, Object> params, Pageable pageable) {
|
public CompletableFuture<Page<T>> asyncFindAll(Map<String, Object> params, Pageable pageable) {
|
||||||
// 调用async方法发送WebSocket请求,获取异步响应结果
|
// 调用async方法发送WebSocket请求,获取异步响应结果
|
||||||
return async("findAll", params, PageArgument.of(pageable)).handle((response, ex) -> {
|
return async(ServiceConstant.FIND_ALL_METHOD_NAME, params, PageArgument.of(pageable)).handle((response, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
throw new RuntimeException("远程方法+findAll+调用失败", ex);
|
throw new RuntimeException("远程方法+findAll+调用失败", ex);
|
||||||
}
|
}
|
||||||
@@ -188,8 +189,9 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public T findOneByProperty(String propertyName, Object propertyValue) {
|
public T findOneByProperty(String propertyName, Object propertyValue) {
|
||||||
return findAll(ParamUtils.builder().equals(propertyName, propertyValue).build(), Pageable.ofSize(1)).stream()
|
ParamUtils.Builder paramBuilder = ParamUtils.builder().equals(propertyName, propertyValue);
|
||||||
.findFirst().orElse(null);
|
Page<T> page = findAll(paramBuilder.build(), Pageable.ofSize(1));
|
||||||
|
return page.stream().findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,7 +203,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
public CompletableFuture<Long> asyncCount(Map<String, Object> params) {
|
public CompletableFuture<Long> asyncCount(Map<String, Object> params) {
|
||||||
// 调用async方法执行名为"count"的异步操作,传入参数params
|
// 调用async方法执行名为"count"的异步操作,传入参数params
|
||||||
// 使用handle方法处理异步操作的结果或异常
|
// 使用handle方法处理异步操作的结果或异常
|
||||||
return async("count", params).handle((response, ex) -> {
|
return async(ServiceConstant.COUNT_METHOD_NAME, params).handle((response, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
throw new RuntimeException("远程方法+count+调用失败", ex);
|
throw new RuntimeException("远程方法+count+调用失败", ex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -373,7 +373,10 @@ public class ContractVerifyComm implements BeanContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CompanyVo company = getCompanyService().findById(bidVendor.getCompanyId());
|
CompanyVo company = getCompanyService().findById(bidVendor.getCompanyId());
|
||||||
ContractFileVo contractFile = fileService.findById(bidVendor.getQuotationSheetFileId());
|
ContractFileVo contractFile = null;
|
||||||
|
if (bidVendor.getQuotationSheetFileId() != null) {
|
||||||
|
contractFile = fileService.findById(bidVendor.getQuotationSheetFileId());
|
||||||
|
}
|
||||||
// 报价表文件不存在
|
// 报价表文件不存在
|
||||||
if (contractFile == null) {
|
if (contractFile == null) {
|
||||||
if (requireQuotation && bidVendor.getCompanyId().equals(contract.getCompanyId())) {
|
if (requireQuotation && bidVendor.getCompanyId().equals(contract.getCompanyId())) {
|
||||||
|
|||||||
@@ -105,9 +105,9 @@
|
|||||||
<contextMenu>
|
<contextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onShowContractDetailAction"
|
<MenuItem mnemonicParsing="false" onAction="#onShowContractDetailAction" text="合同详情"/>
|
||||||
text="合同详情"/>
|
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onContractReVerifyAction" text="重新验证"/>
|
<MenuItem mnemonicParsing="false" onAction="#onContractReVerifyAction" text="重新验证"/>
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#onShowVerifyStatusAction" text="查看状态"/>
|
||||||
</items>
|
</items>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</contextMenu>
|
</contextMenu>
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
package com.ecep.contract.constant;
|
package com.ecep.contract.constant;
|
||||||
|
|
||||||
public class ServiceConstant {
|
public class ServiceConstant {
|
||||||
|
public static final String COUNT_METHOD_NAME = "count";
|
||||||
|
public static final String FIND_ALL_METHOD_NAME = "findAll";
|
||||||
|
public static final String FIND_BY_ID_METHOD_NAME = "findById";
|
||||||
|
public static final String DELETE_METHOD_NAME = "delete";
|
||||||
|
public static final String SAVE_METHOD_NAME = "save";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.ecep.contract;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ecep.contract.constant.ParamConstant;
|
import com.ecep.contract.constant.ParamConstant;
|
||||||
|
import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
@@ -22,7 +23,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
/**
|
/**
|
||||||
* 实体服务基类
|
* 实体服务基类
|
||||||
* 提供基础的CRUD操作和查询方法
|
* 提供基础的CRUD操作和查询方法
|
||||||
*
|
*
|
||||||
* @param <T> 实体类型
|
* @param <T> 实体类型
|
||||||
* @param <VO> VO类型
|
* @param <VO> VO类型
|
||||||
* @param <ID> 主键类型
|
* @param <ID> 主键类型
|
||||||
@@ -32,7 +33,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
/**
|
/**
|
||||||
* 获取实体数据访问层接口
|
* 获取实体数据访问层接口
|
||||||
* 子类必须实现此方法,提供具体的实体数据访问层实例
|
* 子类必须实现此方法,提供具体的实体数据访问层实例
|
||||||
*
|
*
|
||||||
* @return 实体数据访问层接口
|
* @return 实体数据访问层接口
|
||||||
*/
|
*/
|
||||||
protected abstract MyRepository<T, ID> getRepository();
|
protected abstract MyRepository<T, ID> getRepository();
|
||||||
@@ -45,14 +46,14 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
* 创建新实体实例
|
* 创建新实体实例
|
||||||
* 设置默认值或必要的属性
|
* 设置默认值或必要的属性
|
||||||
* 实例是游离态的,未存储到数据库
|
* 实例是游离态的,未存储到数据库
|
||||||
*
|
*
|
||||||
* @return 新实体实例
|
* @return 新实体实例
|
||||||
*/
|
*/
|
||||||
public abstract T createNewEntity();
|
public abstract T createNewEntity();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计所有实体数量
|
* 统计所有实体数量
|
||||||
*
|
*
|
||||||
* @return 实体数量
|
* @return 实体数量
|
||||||
*/
|
*/
|
||||||
public long count() {
|
public long count() {
|
||||||
@@ -61,7 +62,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据查询规范统计实体数量
|
* 根据查询规范统计实体数量
|
||||||
*
|
*
|
||||||
* @param spec 查询规范
|
* @param spec 查询规范
|
||||||
* @return 符合规范的实体数量
|
* @return 符合规范的实体数量
|
||||||
*/
|
*/
|
||||||
@@ -71,7 +72,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据JSON参数节点统计实体数量
|
* 根据JSON参数节点统计实体数量
|
||||||
*
|
*
|
||||||
* @param paramsNode JSON参数节点
|
* @param paramsNode JSON参数节点
|
||||||
* @return 符合参数节点规范的实体数量
|
* @return 符合参数节点规范的实体数量
|
||||||
*/
|
*/
|
||||||
@@ -81,7 +82,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存实体到数据库
|
* 保存实体到数据库
|
||||||
*
|
*
|
||||||
* @param entity 要保存的实体
|
* @param entity 要保存的实体
|
||||||
* @return 保存后的实体
|
* @return 保存后的实体
|
||||||
*/
|
*/
|
||||||
@@ -91,7 +92,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除实体
|
* 删除实体
|
||||||
*
|
*
|
||||||
* @param entity 要删除的实体
|
* @param entity 要删除的实体
|
||||||
*/
|
*/
|
||||||
public void delete(T entity) {
|
public void delete(T entity) {
|
||||||
@@ -103,7 +104,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用JSON参数节点到查询规范
|
* 应用JSON参数节点到查询规范
|
||||||
*
|
*
|
||||||
* @param node JSON参数节点
|
* @param node JSON参数节点
|
||||||
* @return 应用参数节点后的查询规范
|
* @return 应用参数节点后的查询规范
|
||||||
*/
|
*/
|
||||||
@@ -121,7 +122,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据JSON参数节点查询所有实体
|
* 根据JSON参数节点查询所有实体
|
||||||
*
|
*
|
||||||
* @param paramsNode JSON参数节点
|
* @param paramsNode JSON参数节点
|
||||||
* @param pageable 分页信息
|
* @param pageable 分页信息
|
||||||
* @return 符合参数节点规范的实体分页结果
|
* @return 符合参数节点规范的实体分页结果
|
||||||
@@ -132,7 +133,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据查询规范查询所有实体
|
* 根据查询规范查询所有实体
|
||||||
*
|
*
|
||||||
* @param spec 查询规范
|
* @param spec 查询规范
|
||||||
* @param pageable 分页信息
|
* @param pageable 分页信息
|
||||||
* @return 符合规范的实体分页结果
|
* @return 符合规范的实体分页结果
|
||||||
@@ -143,7 +144,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据查询规范查询所有实体
|
* 根据查询规范查询所有实体
|
||||||
*
|
*
|
||||||
* @param spec 查询规范
|
* @param spec 查询规范
|
||||||
* @param sort 排序信息
|
* @param sort 排序信息
|
||||||
* @return 符合规范的实体列表
|
* @return 符合规范的实体列表
|
||||||
@@ -154,7 +155,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据搜索文本查询所有实体
|
* 根据搜索文本查询所有实体
|
||||||
*
|
*
|
||||||
* @param searchText 搜索文本
|
* @param searchText 搜索文本
|
||||||
* @return 符合搜索文本规范的实体列表
|
* @return 符合搜索文本规范的实体列表
|
||||||
*/
|
*/
|
||||||
@@ -165,7 +166,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据搜索文本构建查询规范
|
* 根据搜索文本构建查询规范
|
||||||
*
|
*
|
||||||
* @param searchText 搜索文本
|
* @param searchText 搜索文本
|
||||||
* @return 符合搜索文本规范的查询规范
|
* @return 符合搜索文本规范的查询规范
|
||||||
*/
|
*/
|
||||||
@@ -178,7 +179,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建搜索规范
|
* 构建搜索规范
|
||||||
*
|
*
|
||||||
* @param searchText 搜索文本,非空
|
* @param searchText 搜索文本,非空
|
||||||
* @return 符合搜索文本规范的查询规范
|
* @return 符合搜索文本规范的查询规范
|
||||||
*/
|
*/
|
||||||
@@ -186,7 +187,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建过滤条件规范
|
* 构建过滤条件规范
|
||||||
*
|
*
|
||||||
* @param filterNode 过滤条件节点
|
* @param filterNode 过滤条件节点
|
||||||
* @return 过滤条件规范
|
* @return 过滤条件规范
|
||||||
*/
|
*/
|
||||||
@@ -226,6 +227,8 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
field = aliasFor(field, filterNode);
|
||||||
|
|
||||||
if (ParamConstant.KEY_equal.equals(operatorStr)) {
|
if (ParamConstant.KEY_equal.equals(operatorStr)) {
|
||||||
return buildEqualSpecification(field, filterNode);
|
return buildEqualSpecification(field, filterNode);
|
||||||
}
|
}
|
||||||
@@ -251,6 +254,17 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为查询字段添加别名
|
||||||
|
*
|
||||||
|
* @param field
|
||||||
|
* @param filterNode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected String aliasFor(String field, JsonNode filterNode) {
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
private <X extends Comparable<? super X>> Specification<T> buildLessThanSpecification(String field,
|
private <X extends Comparable<? super X>> Specification<T> buildLessThanSpecification(String field,
|
||||||
JsonNode filterNode) {
|
JsonNode filterNode) {
|
||||||
JsonNode valueNode = filterNode.get(ParamConstant.KEY_VALUE);
|
JsonNode valueNode = filterNode.get(ParamConstant.KEY_VALUE);
|
||||||
@@ -324,7 +338,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 等于操作符的逻辑
|
* 等于操作符的逻辑
|
||||||
*
|
*
|
||||||
* @param field
|
* @param field
|
||||||
* @param filterNode
|
* @param filterNode
|
||||||
* @return
|
* @return
|
||||||
@@ -343,11 +357,29 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
path = path.get(segment);
|
path = path.get(segment);
|
||||||
}
|
}
|
||||||
Class<?> clz = path.getJavaType();
|
Class<?> clz = path.getJavaType();
|
||||||
if (IdentityEntity.class.isAssignableFrom(clz) && valueNode.isNumber()) {
|
if (IdentityEntity.class.isAssignableFrom(clz)) {
|
||||||
return cb.equal(path.get("id"), valueNode.asInt());
|
if (valueNode.isNumber()) {
|
||||||
|
return cb.equal(path.get("id"), valueNode.asInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valueNode.isObject() && valueNode.has("id")) {
|
||||||
|
JsonNode identity = valueNode.get("id");
|
||||||
|
if (identity.isNumber()) {
|
||||||
|
return cb.equal(path.get("id"), identity.asInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (clz == java.lang.Enum.class) {
|
||||||
|
// 将字符串转换为对应的枚举值
|
||||||
|
clz = ((SqmBasicValuedSimplePath) path).getExpressibleJavaType().getJavaTypeClass();
|
||||||
}
|
}
|
||||||
ObjectMapper objectMapper = SpringApp.getBean(ObjectMapper.class);
|
ObjectMapper objectMapper = SpringApp.getBean(ObjectMapper.class);
|
||||||
Object value = objectMapper.convertValue(valueNode, clz);
|
Object value = null;
|
||||||
|
try {
|
||||||
|
value = objectMapper.convertValue(valueNode, clz);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("field=" + field + ", clz=" + clz.getName() + ", value=" + valueNode, e);
|
||||||
|
}
|
||||||
// Object value = valueNode.isTextual() ? valueNode.asText()
|
// Object value = valueNode.isTextual() ? valueNode.asText()
|
||||||
// : valueNode.isNumber() ? valueNode.numberValue()
|
// : valueNode.isNumber() ? valueNode.numberValue()
|
||||||
// : valueNode.isBoolean() ? valueNode.asBoolean() : valueNode;
|
// : valueNode.isBoolean() ? valueNode.asBoolean() : valueNode;
|
||||||
@@ -357,7 +389,7 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* BETWEEN 操作符的逻辑
|
* BETWEEN 操作符的逻辑
|
||||||
*
|
*
|
||||||
* @param field
|
* @param field
|
||||||
* @param filterNode
|
* @param filterNode
|
||||||
* @return
|
* @return
|
||||||
@@ -366,16 +398,35 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
|||||||
JsonNode filterNode) {
|
JsonNode filterNode) {
|
||||||
// BETWEEN 操作符:要求 value 为数组,且长度=2
|
// BETWEEN 操作符:要求 value 为数组,且长度=2
|
||||||
JsonNode valueNode = filterNode.get(ParamConstant.KEY_VALUE);
|
JsonNode valueNode = filterNode.get(ParamConstant.KEY_VALUE);
|
||||||
if (valueNode == null || !valueNode.isArray() || valueNode.size() != 2) {
|
JsonNode lowNode, highNode;
|
||||||
log.debug("BETWEEN 操作符需要 value 为包含两个元素的数组");
|
boolean includeBegin = false, includeEnd = false;
|
||||||
return null;
|
if (valueNode == null || valueNode.isNull()) {
|
||||||
|
throw new IllegalArgumentException(field + " 的 BETWEEN 操作符需要参数");
|
||||||
}
|
}
|
||||||
JsonNode lowNode = valueNode.get(0);
|
if (valueNode.isArray()) {
|
||||||
JsonNode highNode = valueNode.get(1);
|
if (valueNode.size() != 2) {
|
||||||
|
throw new IllegalArgumentException(field + " 的 BETWEEN 操作符的 value 数组长度必须为 2");
|
||||||
|
}
|
||||||
|
lowNode = valueNode.get(0);
|
||||||
|
highNode = valueNode.get(1);
|
||||||
|
} else if (valueNode.isObject()) {
|
||||||
|
lowNode = valueNode.get(ParamConstant.KEY_between_begin);
|
||||||
|
highNode = valueNode.get(ParamConstant.KEY_between_end);
|
||||||
|
|
||||||
|
if (valueNode.has(ParamConstant.KEY_INCLUDE_BEGIN)) {
|
||||||
|
includeBegin = valueNode.get(ParamConstant.KEY_INCLUDE_BEGIN).asBoolean();
|
||||||
|
}
|
||||||
|
if (valueNode.has(ParamConstant.KEY_INCLUDE_END)) {
|
||||||
|
includeEnd = valueNode.get(ParamConstant.KEY_INCLUDE_END).asBoolean();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException(field + " 的 BETWEEN 操作符的 value 必须为数组或对象");
|
||||||
|
}
|
||||||
|
|
||||||
if (lowNode == null || highNode == null || lowNode.isNull() || highNode.isNull()) {
|
if (lowNode == null || highNode == null || lowNode.isNull() || highNode.isNull()) {
|
||||||
log.debug("BETWEEN 操作符的 value 数组元素不能为空");
|
throw new IllegalArgumentException(field + " 的 BETWEEN 操作符的 value 数组元素不能为空");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (root, query, cb) -> {
|
return (root, query, cb) -> {
|
||||||
// 支持嵌套属性路径,如 company.id
|
// 支持嵌套属性路径,如 company.id
|
||||||
String[] fieldPath = field.split("\\.");
|
String[] fieldPath = field.split("\\.");
|
||||||
|
|||||||
@@ -102,10 +102,7 @@ public class CloudRkService extends EntityService<CloudRk, CloudRkVo, Integer>
|
|||||||
return cloudRKRepository;
|
return cloudRKRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CloudRk getById(Integer id) {
|
|
||||||
return super.getById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
public CloudRkVo findById(Integer id) {
|
public CloudRkVo findById(Integer id) {
|
||||||
|
|||||||
@@ -442,27 +442,6 @@ public class CompanyFileService extends EntityService<CompanyFile, CompanyFileVo
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<CompanyFileVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<CompanyFile> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
spec = SpecificationUtils.and(spec, buildParameterSpecification(paramsNode));
|
|
||||||
return findAll(spec, pageable).map(CompanyFile::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Page<CompanyFile> findAll(Specification<CompanyFile> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<CompanyFile> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Specification<CompanyFile> buildSearchSpecification(String searchText) {
|
protected Specification<CompanyFile> buildSearchSpecification(String searchText) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
|
|||||||
@@ -137,10 +137,6 @@ public class CompanyOldNameService extends EntityService<CompanyOldName, Company
|
|||||||
return companyOldNameRepository.findAllByName(name);
|
return companyOldNameRepository.findAllByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CompanyOldName> findAll(Specification<CompanyOldName> spec, Sort sort) {
|
|
||||||
return companyOldNameRepository.findAll(spec, sort);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CompanyOldName> findAllByCompany(Company company) {
|
public List<CompanyOldName> findAllByCompany(Company company) {
|
||||||
return companyOldNameRepository.findAllByCompanyId(company.getId());
|
return companyOldNameRepository.findAllByCompanyId(company.getId());
|
||||||
}
|
}
|
||||||
@@ -211,47 +207,12 @@ public class CompanyOldNameService extends EntityService<CompanyOldName, Company
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据提供的搜索文本查询公司旧名称列表。
|
|
||||||
* <p>
|
|
||||||
* 该函数使用JPA的Specification接口构建查询条件,查找公司旧名称中包含指定文本的记录。
|
|
||||||
* 查询结果最多返回10条记录。
|
|
||||||
*
|
|
||||||
* @param searchText 用于搜索的文本,将匹配公司旧名称中包含该文本的记录。
|
|
||||||
* @return 包含匹配的公司旧名称的列表,列表中的每个元素都是一个CompanyOldName对象。
|
|
||||||
*/
|
|
||||||
public List<CompanyOldName> search(String searchText) {
|
|
||||||
return companyOldNameRepository.findAll(getSearchSpecification(searchText), Pageable.ofSize(10)).getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<CompanyOldName> findAll(Specification<CompanyOldName> spec, Pageable pageable) {
|
protected String aliasFor(String field, JsonNode filterNode) {
|
||||||
return companyOldNameRepository.findAll(spec, pageable);
|
if ("company".equals(field)) {
|
||||||
}
|
return "companyId";
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<CompanyOldNameVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<CompanyOldName> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
}
|
||||||
if (paramsNode.has("company")) {
|
return super.aliasFor(field, filterNode);
|
||||||
JsonNode param = paramsNode.get("company");
|
|
||||||
Integer companyId = null;
|
|
||||||
if (param.isInt()) {
|
|
||||||
companyId = param.asInt();
|
|
||||||
} else if (param.isObject()) {
|
|
||||||
companyId = param.get("id").asInt();
|
|
||||||
}
|
|
||||||
if (companyId != null) {
|
|
||||||
final int id = companyId;
|
|
||||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
|
||||||
return builder.equal(root.get("companyId"), id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "ambiguity", "beginDate", "endDate");
|
|
||||||
return findAll(spec, pageable).map(CompanyOldName::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompanyOldName createNew(Company company, String name, boolean ambiguity) {
|
public CompanyOldName createNew(Company company, String name, boolean ambiguity) {
|
||||||
|
|||||||
@@ -232,12 +232,6 @@ public class HolidayService extends EntityService<HolidayTable, HolidayTableVo,
|
|||||||
return entityPage.map(HolidayTable::toVo);
|
return entityPage.map(HolidayTable::toVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count(JsonNode paramsNode) {
|
|
||||||
// 简单实现,返回所有节假日数量
|
|
||||||
return holidayTableRepository.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateByVo(HolidayTable model, HolidayTableVo vo) {
|
public void updateByVo(HolidayTable model, HolidayTableVo vo) {
|
||||||
if (model == null || vo == null) {
|
if (model == null || vo == null) {
|
||||||
|
|||||||
@@ -110,17 +110,6 @@ public class ContractBidVendorService extends EntityService<ContractBidVendor, C
|
|||||||
return new ContractBidVendor();
|
return new ContractBidVendor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ContractBidVendorVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<ContractBidVendor> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = buildSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "company");
|
|
||||||
return findAll(spec, pageable).map(ContractBidVendor::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateByVo(ContractBidVendor model, ContractBidVendorVo vo) {
|
public void updateByVo(ContractBidVendor model, ContractBidVendorVo vo) {
|
||||||
// 处理关联对象
|
// 处理关联对象
|
||||||
|
|||||||
@@ -47,10 +47,7 @@ public class ContractCatalogService extends EntityService<ContractCatalog, Contr
|
|||||||
return repository.findById(id).map(ContractCatalog::toVo).orElse(null);
|
return repository.findById(id).map(ContractCatalog::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ContractCatalog getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContractCatalog findByName(String name) {
|
public ContractCatalog findByName(String name) {
|
||||||
return repository.findByName(name).orElse(null);
|
return repository.findByName(name).orElse(null);
|
||||||
|
|||||||
@@ -144,11 +144,6 @@ public class ContractInvoiceService extends EntityService<ContractInvoice, Contr
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ContractInvoiceVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
return super.findAll(paramsNode, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建参数规范
|
* 构建参数规范
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -45,11 +45,6 @@ public class ContractKindService extends EntityService<ContractKind, ContractKin
|
|||||||
return repository.findById(id).map(ContractKind::toVo).orElse(null);
|
return repository.findById(id).map(ContractKind::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ContractKindVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
return super.findAll(paramsNode, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Specification<ContractKind> buildParameterSpecification(JsonNode paramsNode) {
|
protected Specification<ContractKind> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -98,11 +98,6 @@ public class ExtendVendorInfoService extends EntityService<ExtendVendorInfo, Ext
|
|||||||
repository.delete(bidVendor);
|
repository.delete(bidVendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ExtendVendorInfoVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
return super.findAll(paramsNode, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ExtendVendorInfo> findAll(Specification<ExtendVendorInfo> spec, Sort sort) {
|
public List<ExtendVendorInfo> findAll(Specification<ExtendVendorInfo> spec, Sort sort) {
|
||||||
return repository.findAll(spec, sort);
|
return repository.findAll(spec, sort);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,11 +55,6 @@ public class PurchaseOrderItemService extends EntityService<PurchaseOrderItem, P
|
|||||||
return list.getFirst().toVo();
|
return list.getFirst().toVo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<PurchaseOrderItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
return super.findAll(paramsNode, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'refId-'+#p0.refId")
|
@CacheEvict(key = "'refId-'+#p0.refId")
|
||||||
|
|||||||
@@ -52,10 +52,7 @@ public class SaleOrdersService extends EntityService<SalesOrder, SalesOrderVo, I
|
|||||||
return new SalesOrder();
|
return new SalesOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SalesOrder getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
public SalesOrderVo findById(Integer id) {
|
public SalesOrderVo findById(Integer id) {
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -64,17 +62,6 @@ public class EmployeeLoginHistoryService extends EntityService<EmployeeLoginHist
|
|||||||
return repository.findById(id).map(EmployeeLoginHistory::toVo).orElse(null);
|
return repository.findById(id).map(EmployeeLoginHistory::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<EmployeeLoginHistoryVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<EmployeeLoginHistory> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 可以根据需要添加更多参数处理
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "ip", "mac");
|
|
||||||
return findAll(spec, pageable).map(EmployeeLoginHistory::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(key = "#p0.id")
|
@CacheEvict(key = "#p0.id")
|
||||||
|
|||||||
@@ -67,7 +67,16 @@ public class EmployeeService extends EntityService<Employee, EmployeeVo, Integer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected org.springframework.data.jpa.domain.Specification<Employee> buildSearchSpecification(String searchText) {
|
protected org.springframework.data.jpa.domain.Specification<Employee> buildSearchSpecification(String searchText) {
|
||||||
return getSearchSpecification(searchText);
|
return (root, query, builder) -> {
|
||||||
|
// 使用或条件组合查询,以实现对员工代码或名称的模糊搜索
|
||||||
|
return builder.or(
|
||||||
|
builder.like(root.get("account"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("alias"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("email"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("phone"), "%" + searchText + "%"));
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,34 +147,6 @@ public class EmployeeService extends EntityService<Employee, EmployeeVo, Integer
|
|||||||
employeeRepository.delete(employee);
|
employeeRepository.delete(employee);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<EmployeeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<Employee> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 可以根据需要添加更多参数处理
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "department");
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "isActive");
|
|
||||||
return findAll(spec, pageable).map(Employee::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<Employee> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
|
||||||
// 使用或条件组合查询,以实现对员工代码或名称的模糊搜索
|
|
||||||
return builder.or(
|
|
||||||
builder.like(root.get("account"), "%" + searchText + "%"),
|
|
||||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
|
||||||
builder.like(root.get("alias"), "%" + searchText + "%"),
|
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
|
||||||
builder.like(root.get("email"), "%" + searchText + "%"),
|
|
||||||
builder.like(root.get("phone"), "%" + searchText + "%"));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据搜索文本查询员工列表
|
* 根据搜索文本查询员工列表
|
||||||
|
|||||||
@@ -70,9 +70,7 @@ public class InventoryService extends EntityService<Inventory, InventoryVo, Inte
|
|||||||
return inventoryRepository.findById(id).map(Inventory::toVo).orElse(null);
|
return inventoryRepository.findById(id).map(Inventory::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory getById(Integer id) {
|
|
||||||
return inventoryRepository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Inventory> findAll(Specification<Inventory> spec, Pageable pageable) {
|
public Page<Inventory> findAll(Specification<Inventory> spec, Pageable pageable) {
|
||||||
|
|||||||
@@ -48,17 +48,6 @@ public class ProjectFundPlanService extends EntityService<ProjectFundPlan, Proje
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ProjectFundPlanVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<ProjectFundPlan> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = buildSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project");
|
|
||||||
return findAll(spec, pageable).map(ProjectFundPlan::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -104,9 +104,7 @@ public class ProjectService extends EntityService<Project, ProjectVo, Integer>
|
|||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project getById(Integer id) {
|
|
||||||
return projectRepository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
public ProjectVo findById(Integer id) {
|
public ProjectVo findById(Integer id) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.ecep.contract.PageArgument;
|
|||||||
import com.ecep.contract.PageContent;
|
import com.ecep.contract.PageContent;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
|
import com.ecep.contract.constant.ServiceConstant;
|
||||||
import com.ecep.contract.constant.WebSocketConstant;
|
import com.ecep.contract.constant.WebSocketConstant;
|
||||||
import com.ecep.contract.handler.SessionInfo;
|
import com.ecep.contract.handler.SessionInfo;
|
||||||
import com.ecep.contract.model.Voable;
|
import com.ecep.contract.model.Voable;
|
||||||
@@ -95,15 +96,15 @@ public class WebSocketServerCallbackManager {
|
|||||||
JsonNode argumentsNode = jsonNode.get(WebSocketConstant.ARGUMENTS_FIELD_NAME);
|
JsonNode argumentsNode = jsonNode.get(WebSocketConstant.ARGUMENTS_FIELD_NAME);
|
||||||
|
|
||||||
Object result = null;
|
Object result = null;
|
||||||
if (methodName.equals("findAll")) {
|
if (methodName.equals(ServiceConstant.FIND_ALL_METHOD_NAME)) {
|
||||||
result = invokerFindAllMethod(service, argumentsNode);
|
result = invokerFindAllMethod(service, argumentsNode);
|
||||||
} else if (methodName.equals("findById")) {
|
} else if (methodName.equals(ServiceConstant.FIND_BY_ID_METHOD_NAME)) {
|
||||||
result = invokerFindByIdMethod(service, argumentsNode);
|
result = invokerFindByIdMethod(service, argumentsNode);
|
||||||
} else if (methodName.equals("save")) {
|
} else if (methodName.equals(ServiceConstant.SAVE_METHOD_NAME)) {
|
||||||
result = invokerSaveMethod(service, argumentsNode);
|
result = invokerSaveMethod(service, argumentsNode);
|
||||||
} else if (methodName.equals("delete")) {
|
} else if (methodName.equals(ServiceConstant.DELETE_METHOD_NAME)) {
|
||||||
result = invokerDeleteMethod(service, argumentsNode);
|
result = invokerDeleteMethod(service, argumentsNode);
|
||||||
} else if (methodName.equals("count")) {
|
} else if (methodName.equals(ServiceConstant.COUNT_METHOD_NAME)) {
|
||||||
result = invokerCountMethod(service, argumentsNode);
|
result = invokerCountMethod(service, argumentsNode);
|
||||||
} else {
|
} else {
|
||||||
result = invokerOtherMethod(service, methodName, argumentsNode);
|
result = invokerOtherMethod(service, methodName, argumentsNode);
|
||||||
|
|||||||
Reference in New Issue
Block a user