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.logging.Level;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import org.controlsfx.control.PopOver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -50,13 +53,6 @@ import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
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.stage.FileChooser;
|
||||
import javafx.stage.Modality;
|
||||
@@ -79,6 +75,7 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
return super.show(loader, owner, modality);
|
||||
}
|
||||
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class MessageExt extends Message {
|
||||
@@ -90,12 +87,16 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Model implements MessageHolder {
|
||||
public static class Model {
|
||||
private SimpleStringProperty code = new SimpleStringProperty();
|
||||
private SimpleStringProperty name = new SimpleStringProperty();
|
||||
private SimpleObjectProperty<Integer> employee = new SimpleObjectProperty<>();
|
||||
private SimpleObjectProperty<LocalDate> setupDate = new SimpleObjectProperty<>();
|
||||
private SimpleListProperty<MessageExt> messages = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||
}
|
||||
|
||||
static class MessageHolderImpl implements MessageHolder {
|
||||
List<MessageExt> messages = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void addMessage(Level level, String message) {
|
||||
@@ -261,6 +262,8 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
long total = contractService.count(params);
|
||||
setStatus("合同:" + total + " 条");
|
||||
|
||||
MessageHolderImpl messageHolder = new MessageHolderImpl();
|
||||
|
||||
while (true) {
|
||||
if (isCloseRequested()) {
|
||||
break;
|
||||
@@ -268,6 +271,7 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
|
||||
Page<ContractVo> page = contractService.findAll(params, pageRequest);
|
||||
for (ContractVo contract : page) {
|
||||
messageHolder.messages.clear();
|
||||
if (isCloseRequested()) {
|
||||
break;
|
||||
}
|
||||
@@ -285,11 +289,11 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
model.getName().set(contract.getName());
|
||||
model.getSetupDate().set(contract.getSetupDate());
|
||||
|
||||
comm.verify(contract, model);
|
||||
comm.verify(contract, messageHolder);
|
||||
setStatus("合同验证进度:" + counter.get() + " / " + total);
|
||||
// 移除中间消息
|
||||
if (!model.getMessages().isEmpty()) {
|
||||
model.getMessages().removeIf(msg -> msg.getLevel().intValue() <= Level.INFO.intValue());
|
||||
if (!messageHolder.messages.isEmpty()) {
|
||||
model.getMessages().setAll(messageHolder.messages.stream().filter(msg -> msg.getLevel().intValue() > Level.INFO.intValue()).limit(50).toList());
|
||||
}
|
||||
if (model.getMessages().isEmpty()) {
|
||||
if (onlyShowVerifiedChecker.isSelected()) {
|
||||
@@ -325,6 +329,7 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
}
|
||||
runAsync(() -> {
|
||||
ContractVo contract = null;
|
||||
MessageHolderImpl messageHolder = new MessageHolderImpl();
|
||||
try {
|
||||
contract = contractService.findByCode(contractCode);
|
||||
} catch (Exception e) {
|
||||
@@ -336,17 +341,18 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
}
|
||||
model.getMessages().clear();
|
||||
try {
|
||||
comm.verify(contract, model);
|
||||
// 移除中间消息
|
||||
if (!model.getMessages().isEmpty()) {
|
||||
model.getMessages().removeIf(msg -> msg.getLevel().intValue() <= Level.INFO.intValue());
|
||||
}
|
||||
comm.verify(contract, messageHolder);
|
||||
} catch (Exception 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(() -> {
|
||||
viewTableDataSet.remove(model);
|
||||
});
|
||||
@@ -380,6 +386,38 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
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) {
|
||||
FileChooser chooser = new FileChooser();
|
||||
chooser.setTitle("导出核验结果");
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.ecep.contract.controller.employee;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.ecep.contract.controller.tab.TabSkin;
|
||||
@@ -48,7 +50,7 @@ public class EmployeeTabSkinRole
|
||||
|
||||
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();
|
||||
|
||||
controller.rolesField.getSourceItems().setAll(roles);
|
||||
|
||||
@@ -53,8 +53,7 @@ public class CompanyCustomerFileTypeService
|
||||
|
||||
@Cacheable
|
||||
public Map<CustomerFileType, CustomerFileTypeLocalVo> findAll(Locale locale) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("lang", locale.toLanguageTag());
|
||||
Map<String, Object> params = ParamUtils.builder().equals("lang", locale.toLanguageTag()).build();
|
||||
return findAll(params, Pageable.unpaged()).stream()
|
||||
.collect(Collectors.toMap(CustomerFileTypeLocalVo::getType, Function.identity()));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyInvoiceInfoViewModel;
|
||||
import com.ecep.contract.vo.CompanyInvoiceInfoVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
@@ -15,9 +16,8 @@ import java.util.Map;
|
||||
public class CompanyInvoiceInfoService extends QueryService<CompanyInvoiceInfoVo, CompanyInvoiceInfoViewModel> {
|
||||
|
||||
public List<CompanyInvoiceInfoVo> searchByCompany(CompanyVo company, String searchText) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("company", company);
|
||||
params.put("searchText", searchText);
|
||||
Map<String, Object> params = ParamUtils.builder().equals("company", company.getId())
|
||||
.search(searchText).build();
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -58,8 +59,7 @@ public class CompanyService extends QueryService<CompanyVo, CompanyViewModel> {
|
||||
}
|
||||
|
||||
public List<CompanyVo> findAllByName(String name) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("name", name);
|
||||
Map<String, Object> params = ParamUtils.builder().equals("name", name).build();
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@ import com.ecep.contract.vo.ContractVo;
|
||||
|
||||
@Service
|
||||
public class ContractFileService extends QueryService<ContractFileVo, ContractFileViewModel> {
|
||||
|
||||
@Override
|
||||
public ContractFileVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public List<ContractFileVo> findAllByContract(ContractVo contract) {
|
||||
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) {
|
||||
return findAll(ParamUtils.builder().equals("code", code).build(), Pageable.ofSize(1)).getContent().getFirst();
|
||||
return findOneByProperty("code", code);
|
||||
}
|
||||
|
||||
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")})
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ecep.contract.service;
|
||||
import com.ecep.contract.PageArgument;
|
||||
import com.ecep.contract.PageContent;
|
||||
import com.ecep.contract.WebSocketClientService;
|
||||
import com.ecep.contract.constant.ServiceConstant;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.model.NamedEntity;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
@@ -67,7 +68,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
@Override
|
||||
public T save(T entity) {
|
||||
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) {
|
||||
throw new RuntimeException("保存实体失败", ex);
|
||||
}
|
||||
@@ -88,7 +89,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
@Override
|
||||
public void delete(T entity) {
|
||||
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) {
|
||||
throw new RuntimeException("删除实体失败", ex);
|
||||
}
|
||||
@@ -117,7 +118,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
// 调用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) {
|
||||
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) {
|
||||
return findAll(ParamUtils.builder().equals(propertyName, propertyValue).build(), Pageable.ofSize(1)).stream()
|
||||
.findFirst().orElse(null);
|
||||
ParamUtils.Builder paramBuilder = ParamUtils.builder().equals(propertyName, propertyValue);
|
||||
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) {
|
||||
// 调用async方法执行名为"count"的异步操作,传入参数params
|
||||
// 使用handle方法处理异步操作的结果或异常
|
||||
return async("count", params).handle((response, ex) -> {
|
||||
return async(ServiceConstant.COUNT_METHOD_NAME, params).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+count+调用失败", ex);
|
||||
}
|
||||
|
||||
@@ -373,7 +373,10 @@ public class ContractVerifyComm implements BeanContext {
|
||||
}
|
||||
|
||||
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 (requireQuotation && bidVendor.getCompanyId().equals(contract.getCompanyId())) {
|
||||
|
||||
@@ -105,9 +105,9 @@
|
||||
<contextMenu>
|
||||
<ContextMenu>
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onShowContractDetailAction"
|
||||
text="合同详情"/>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onShowContractDetailAction" text="合同详情"/>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onContractReVerifyAction" text="重新验证"/>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onShowVerifyStatusAction" text="查看状态"/>
|
||||
</items>
|
||||
</ContextMenu>
|
||||
</contextMenu>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
package com.ecep.contract.constant;
|
||||
|
||||
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 com.ecep.contract.constant.ParamConstant;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -226,6 +227,8 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
||||
return null;
|
||||
}
|
||||
|
||||
field = aliasFor(field, filterNode);
|
||||
|
||||
if (ParamConstant.KEY_equal.equals(operatorStr)) {
|
||||
return buildEqualSpecification(field, filterNode);
|
||||
}
|
||||
@@ -251,6 +254,17 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
||||
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,
|
||||
JsonNode filterNode) {
|
||||
JsonNode valueNode = filterNode.get(ParamConstant.KEY_VALUE);
|
||||
@@ -343,11 +357,29 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
||||
path = path.get(segment);
|
||||
}
|
||||
Class<?> clz = path.getJavaType();
|
||||
if (IdentityEntity.class.isAssignableFrom(clz) && valueNode.isNumber()) {
|
||||
if (IdentityEntity.class.isAssignableFrom(clz)) {
|
||||
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);
|
||||
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()
|
||||
// : valueNode.isNumber() ? valueNode.numberValue()
|
||||
// : valueNode.isBoolean() ? valueNode.asBoolean() : valueNode;
|
||||
@@ -366,16 +398,35 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
||||
JsonNode filterNode) {
|
||||
// BETWEEN 操作符:要求 value 为数组,且长度=2
|
||||
JsonNode valueNode = filterNode.get(ParamConstant.KEY_VALUE);
|
||||
if (valueNode == null || !valueNode.isArray() || valueNode.size() != 2) {
|
||||
log.debug("BETWEEN 操作符需要 value 为包含两个元素的数组");
|
||||
return null;
|
||||
JsonNode lowNode, highNode;
|
||||
boolean includeBegin = false, includeEnd = false;
|
||||
if (valueNode == null || valueNode.isNull()) {
|
||||
throw new IllegalArgumentException(field + " 的 BETWEEN 操作符需要参数");
|
||||
}
|
||||
JsonNode lowNode = valueNode.get(0);
|
||||
JsonNode highNode = valueNode.get(1);
|
||||
if (valueNode.isArray()) {
|
||||
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()) {
|
||||
log.debug("BETWEEN 操作符的 value 数组元素不能为空");
|
||||
return null;
|
||||
throw new IllegalArgumentException(field + " 的 BETWEEN 操作符的 value 数组元素不能为空");
|
||||
}
|
||||
|
||||
return (root, query, cb) -> {
|
||||
// 支持嵌套属性路径,如 company.id
|
||||
String[] fieldPath = field.split("\\.");
|
||||
|
||||
@@ -102,10 +102,7 @@ public class CloudRkService extends EntityService<CloudRk, CloudRkVo, Integer>
|
||||
return cloudRKRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudRk getById(Integer id) {
|
||||
return super.getById(id);
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
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) {
|
||||
return (root, query, builder) -> {
|
||||
|
||||
@@ -137,10 +137,6 @@ public class CompanyOldNameService extends EntityService<CompanyOldName, Company
|
||||
return companyOldNameRepository.findAllByName(name);
|
||||
}
|
||||
|
||||
public List<CompanyOldName> findAll(Specification<CompanyOldName> spec, Sort sort) {
|
||||
return companyOldNameRepository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
public List<CompanyOldName> findAllByCompany(Company company) {
|
||||
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
|
||||
public Page<CompanyOldName> findAll(Specification<CompanyOldName> spec, Pageable pageable) {
|
||||
return companyOldNameRepository.findAll(spec, pageable);
|
||||
protected String aliasFor(String field, JsonNode filterNode) {
|
||||
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")) {
|
||||
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);
|
||||
return super.aliasFor(field, filterNode);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count(JsonNode paramsNode) {
|
||||
// 简单实现,返回所有节假日数量
|
||||
return holidayTableRepository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(HolidayTable model, HolidayTableVo vo) {
|
||||
if (model == null || vo == null) {
|
||||
|
||||
@@ -110,17 +110,6 @@ public class ContractBidVendorService extends EntityService<ContractBidVendor, C
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractCatalog getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
public ContractCatalog findByName(String name) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractKindVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
return super.findAll(paramsNode, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ContractKind> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
|
||||
@@ -98,11 +98,6 @@ public class ExtendVendorInfoService extends EntityService<ExtendVendorInfo, Ext
|
||||
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) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@@ -55,11 +55,6 @@ public class PurchaseOrderItemService extends EntityService<PurchaseOrderItem, P
|
||||
return list.getFirst().toVo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PurchaseOrderItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
return super.findAll(paramsNode, pageable);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'refId-'+#p0.refId")
|
||||
|
||||
@@ -52,10 +52,7 @@ public class SaleOrdersService extends EntityService<SalesOrder, SalesOrderVo, I
|
||||
return new SalesOrder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SalesOrder getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
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.CacheEvict;
|
||||
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.stereotype.Service;
|
||||
|
||||
@@ -64,17 +62,6 @@ public class EmployeeLoginHistoryService extends EntityService<EmployeeLoginHist
|
||||
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
|
||||
@CacheEvict(key = "#p0.id")
|
||||
|
||||
@@ -67,7 +67,16 @@ public class EmployeeService extends EntityService<Employee, EmployeeVo, Integer
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
public Inventory getById(Integer id) {
|
||||
return inventoryRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<Inventory> findAll(Specification<Inventory> spec, Pageable pageable) {
|
||||
|
||||
@@ -48,17 +48,6 @@ public class ProjectFundPlanService extends EntityService<ProjectFundPlan, Proje
|
||||
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 = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
|
||||
@@ -104,9 +104,7 @@ public class ProjectService extends EntityService<Project, ProjectVo, Integer>
|
||||
return project;
|
||||
}
|
||||
|
||||
public Project getById(Integer id) {
|
||||
return projectRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public ProjectVo findById(Integer id) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.ecep.contract.PageArgument;
|
||||
import com.ecep.contract.PageContent;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.ServiceConstant;
|
||||
import com.ecep.contract.constant.WebSocketConstant;
|
||||
import com.ecep.contract.handler.SessionInfo;
|
||||
import com.ecep.contract.model.Voable;
|
||||
@@ -95,15 +96,15 @@ public class WebSocketServerCallbackManager {
|
||||
JsonNode argumentsNode = jsonNode.get(WebSocketConstant.ARGUMENTS_FIELD_NAME);
|
||||
|
||||
Object result = null;
|
||||
if (methodName.equals("findAll")) {
|
||||
if (methodName.equals(ServiceConstant.FIND_ALL_METHOD_NAME)) {
|
||||
result = invokerFindAllMethod(service, argumentsNode);
|
||||
} else if (methodName.equals("findById")) {
|
||||
} else if (methodName.equals(ServiceConstant.FIND_BY_ID_METHOD_NAME)) {
|
||||
result = invokerFindByIdMethod(service, argumentsNode);
|
||||
} else if (methodName.equals("save")) {
|
||||
} else if (methodName.equals(ServiceConstant.SAVE_METHOD_NAME)) {
|
||||
result = invokerSaveMethod(service, argumentsNode);
|
||||
} else if (methodName.equals("delete")) {
|
||||
} else if (methodName.equals(ServiceConstant.DELETE_METHOD_NAME)) {
|
||||
result = invokerDeleteMethod(service, argumentsNode);
|
||||
} else if (methodName.equals("count")) {
|
||||
} else if (methodName.equals(ServiceConstant.COUNT_METHOD_NAME)) {
|
||||
result = invokerCountMethod(service, argumentsNode);
|
||||
} else {
|
||||
result = invokerOtherMethod(service, methodName, argumentsNode);
|
||||
|
||||
Reference in New Issue
Block a user