Compare commits
8 Commits
94030a5a39
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 643338f4b0 | |||
| 880671a5a9 | |||
| 4e738bea3c | |||
| 3cf3a717be | |||
| e8c8305f40 | |||
| be63ff62a4 | |||
| 18057a657e | |||
| db07befffe |
@@ -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("\\.");
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import com.ecep.contract.MessageHolder;
|
|||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
import com.ecep.contract.cloud.CloudInfo;
|
import com.ecep.contract.cloud.CloudInfo;
|
||||||
import com.ecep.contract.ds.MyRepository;
|
|
||||||
import com.ecep.contract.ds.company.model.Company;
|
import com.ecep.contract.ds.company.model.Company;
|
||||||
import com.ecep.contract.ds.company.model.CompanyBlackReason;
|
import com.ecep.contract.ds.company.model.CompanyBlackReason;
|
||||||
import com.ecep.contract.ds.company.service.CompanyService;
|
import com.ecep.contract.ds.company.service.CompanyService;
|
||||||
@@ -103,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) {
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class ContractGroupSyncTask extends Tasker<Object> implements WebSocketSe
|
|||||||
ContractGroupService service = getContractGroupService();
|
ContractGroupService service = getContractGroupService();
|
||||||
var contractGroup = service.findByCode(groupCode);
|
var contractGroup = service.findByCode(groupCode);
|
||||||
if (contractGroup == null) {
|
if (contractGroup == null) {
|
||||||
var newGroup = service.newContractGroup();
|
var newGroup = service.createNewEntity();
|
||||||
newGroup.setCode(groupCode);
|
newGroup.setCode(groupCode);
|
||||||
newGroup.setName(groupName);
|
newGroup.setName(groupName);
|
||||||
newGroup.setTitle(groupTitle);
|
newGroup.setTitle(groupTitle);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.springframework.context.annotation.Lazy;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.CustomerFileType;
|
import com.ecep.contract.CustomerFileType;
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.VendorFileType;
|
import com.ecep.contract.VendorFileType;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
import com.ecep.contract.ds.company.CompanyFileUtils;
|
||||||
@@ -26,8 +27,9 @@ import com.ecep.contract.model.CompanyBasicFile;
|
|||||||
import com.ecep.contract.ds.customer.model.CompanyCustomerFile;
|
import com.ecep.contract.ds.customer.model.CompanyCustomerFile;
|
||||||
import com.ecep.contract.ds.vendor.model.VendorFile;
|
import com.ecep.contract.ds.vendor.model.VendorFile;
|
||||||
import com.ecep.contract.model.HolidayTable;
|
import com.ecep.contract.model.HolidayTable;
|
||||||
|
import com.ecep.contract.model.Voable;
|
||||||
|
|
||||||
public abstract class CompanyBasicService {
|
public abstract class CompanyBasicService<T extends Voable<VO>, VO> extends EntityService<T, VO, Integer> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CompanyBasicService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CompanyBasicService.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -458,4 +460,6 @@ public abstract class CompanyBasicService {
|
|||||||
*/
|
*/
|
||||||
protected abstract boolean isEvaluationFile(String fileName);
|
protected abstract boolean isEvaluationFile(String fileName);
|
||||||
|
|
||||||
|
public abstract File getBasePath();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -8,12 +8,9 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import com.ecep.contract.constant.ParamConstant;
|
import com.ecep.contract.constant.ParamConstant;
|
||||||
import com.ecep.contract.ds.company.service.HolidayService;
|
import com.ecep.contract.ds.company.service.HolidayService;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
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.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -23,6 +20,7 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.ecep.contract.CustomerFileType;
|
import com.ecep.contract.CustomerFileType;
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.MessageHolder;
|
import com.ecep.contract.MessageHolder;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
@@ -47,10 +45,9 @@ import jakarta.persistence.criteria.Path;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "company-customer-file")
|
@CacheConfig(cacheNames = "company-customer-file")
|
||||||
public class CompanyCustomerFileService
|
public class CompanyCustomerFileService extends EntityService<CompanyCustomerFile, CustomerFileVo, Integer>
|
||||||
implements IEntityService<CompanyCustomerFile>, QueryService<CompanyCustomerFile>,
|
implements IEntityService<CompanyCustomerFile>, QueryService<CustomerFileVo>,
|
||||||
VoableService<CompanyCustomerFile, CustomerFileVo> {
|
VoableService<CompanyCustomerFile, CustomerFileVo> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerFileService.class);
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysConfService confService;
|
private SysConfService confService;
|
||||||
@@ -61,18 +58,32 @@ public class CompanyCustomerFileService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CompanyCustomerEvaluationFormFileRepository companyCustomerEvaluationFormFileRepository;
|
private CompanyCustomerEvaluationFormFileRepository companyCustomerEvaluationFormFileRepository;
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Override
|
||||||
public CompanyCustomerFile findById(Integer id) {
|
protected CompanyCustomerFileRepository getRepository() {
|
||||||
return getById(id);
|
return companyCustomerFileRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompanyCustomerFile getById(Integer id) {
|
public CustomerFileVo findById(Integer id) {
|
||||||
return companyCustomerFileRepository.findById(id).orElse(null);
|
return getRepository().findById(id).map(CompanyCustomerFile::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<CompanyCustomerFile> getSearchSpecification(String searchText) {
|
public CompanyCustomerFile createNewEntity() {
|
||||||
|
return new CompanyCustomerFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<CompanyCustomerFile> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<CompanyCustomerFile> spec = null;
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "customer");
|
||||||
|
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<CompanyCustomerFile> buildSearchSpecification(String searchText) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
|
return builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
|
||||||
};
|
};
|
||||||
@@ -99,23 +110,6 @@ public class CompanyCustomerFileService
|
|||||||
return companyCustomerEvaluationFormFileRepository.save(formFile);
|
return companyCustomerEvaluationFormFileRepository.save(formFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<CompanyCustomerFile> findAll(Specification<CompanyCustomerFile> spec, Pageable pageable) {
|
|
||||||
return companyCustomerFileRepository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<CompanyCustomerFile> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<CompanyCustomerFile> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "customer");
|
|
||||||
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
|
||||||
return findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CompanyCustomerFile> findAllByCustomer(CompanyCustomer customer) {
|
public List<CompanyCustomerFile> findAllByCustomer(CompanyCustomer customer) {
|
||||||
return companyCustomerFileRepository.findAllByCustomer(customer);
|
return companyCustomerFileRepository.findAllByCustomer(customer);
|
||||||
}
|
}
|
||||||
@@ -183,7 +177,8 @@ public class CompanyCustomerFileService
|
|||||||
LocalDate miniContractDate = LocalDate.of(2022, 1, 1);
|
LocalDate miniContractDate = LocalDate.of(2022, 1, 1);
|
||||||
// 检索全部合同
|
// 检索全部合同
|
||||||
ContractService contractService = SpringApp.getBean(ContractService.class);
|
ContractService contractService = SpringApp.getBean(ContractService.class);
|
||||||
List<Contract> contractList = contractService.findAllByCompanyCustomer(companyCustomer, miniContractDate, LocalDate.now());
|
List<Contract> contractList = contractService.findAllByCompanyCustomer(companyCustomer, miniContractDate,
|
||||||
|
LocalDate.now());
|
||||||
if (contractList.isEmpty()) {
|
if (contractList.isEmpty()) {
|
||||||
holder.error("未发现已登记的合同");
|
holder.error("未发现已登记的合同");
|
||||||
return null;
|
return null;
|
||||||
@@ -299,6 +294,4 @@ public class CompanyCustomerFileService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.CustomerFileType;
|
import com.ecep.contract.CustomerFileType;
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerFileTypeLocalRepository;
|
import com.ecep.contract.ds.customer.repository.CompanyCustomerFileTypeLocalRepository;
|
||||||
@@ -31,33 +32,37 @@ import jakarta.annotation.Resource;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "customer-file-type")
|
@CacheConfig(cacheNames = "customer-file-type")
|
||||||
public class CompanyCustomerFileTypeService implements IEntityService<CompanyCustomerFileTypeLocal>, QueryService<CompanyCustomerFileTypeLocalVo>,
|
public class CompanyCustomerFileTypeService
|
||||||
|
extends EntityService<CompanyCustomerFileTypeLocal, CompanyCustomerFileTypeLocalVo, Integer>
|
||||||
|
implements IEntityService<CompanyCustomerFileTypeLocal>, QueryService<CompanyCustomerFileTypeLocalVo>,
|
||||||
VoableService<CompanyCustomerFileTypeLocal, CompanyCustomerFileTypeLocalVo> {
|
VoableService<CompanyCustomerFileTypeLocal, CompanyCustomerFileTypeLocalVo> {
|
||||||
@Resource
|
@Resource
|
||||||
private CompanyCustomerFileTypeLocalRepository repository;
|
private CompanyCustomerFileTypeLocalRepository repository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CompanyCustomerFileTypeLocalRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompanyCustomerFileTypeLocal createNewEntity() {
|
||||||
|
return new CompanyCustomerFileTypeLocal();
|
||||||
|
}
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public CompanyCustomerFileTypeLocalVo findById(Integer id) {
|
public CompanyCustomerFileTypeLocalVo findById(Integer id) {
|
||||||
return repository.findById(id).map(CompanyCustomerFileTypeLocal::toVo).orElse(null);
|
return repository.findById(id).map(CompanyCustomerFileTypeLocal::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompanyCustomerFileTypeLocal getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<CompanyCustomerFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
protected Specification<CompanyCustomerFileTypeLocal> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
Specification<CompanyCustomerFileTypeLocal> spec = null;
|
Specification<CompanyCustomerFileTypeLocal> spec = null;
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paramsNode.has("type")) {
|
if (paramsNode.has("type")) {
|
||||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), CustomerFileType.valueOf(paramsNode.get("type").asText())));
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"),
|
||||||
|
CustomerFileType.valueOf(paramsNode.get("type").asText())));
|
||||||
}
|
}
|
||||||
// field
|
return spec;
|
||||||
return findAll(spec, pageable).map(CompanyCustomerFileTypeLocal::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||||
@@ -65,26 +70,13 @@ public class CompanyCustomerFileTypeService implements IEntityService<CompanyCus
|
|||||||
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
||||||
.collect(java.util.stream.Collectors.toMap(
|
.collect(java.util.stream.Collectors.toMap(
|
||||||
java.util.Map.Entry::getKey,
|
java.util.Map.Entry::getKey,
|
||||||
entry -> entry.getValue().toVo()
|
entry -> entry.getValue().toVo()));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<CompanyCustomerFileTypeLocal> findAll(Specification<CompanyCustomerFileTypeLocal> spec, Pageable pageable) {
|
protected Specification<CompanyCustomerFileTypeLocal> buildSearchSpecification(String searchText) {
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<CompanyCustomerFileTypeLocal> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return
|
return builder.like(root.get("type"), "%" + searchText + "%");
|
||||||
// builder.or(
|
|
||||||
builder.like(root.get("type"), "%" + searchText + "%")
|
|
||||||
// )
|
|
||||||
;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,20 @@
|
|||||||
package com.ecep.contract.ds.customer.service;
|
package com.ecep.contract.ds.customer.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.cache.annotation.Caching;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.EntityService;
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.constant.ParamConstant;
|
|
||||||
import com.ecep.contract.ds.customer.repository.CustomerCatalogRepository;
|
import com.ecep.contract.ds.customer.repository.CustomerCatalogRepository;
|
||||||
import com.ecep.contract.model.CustomerCatalog;
|
import com.ecep.contract.model.CustomerCatalog;
|
||||||
import com.ecep.contract.service.ServiceException;
|
import com.ecep.contract.service.ServiceException;
|
||||||
@@ -11,20 +22,6 @@ import com.ecep.contract.service.VoableService;
|
|||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.CustomerCatalogVo;
|
import com.ecep.contract.vo.CustomerCatalogVo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.cache.annotation.Caching;
|
|
||||||
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;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户分类服务
|
* 客户分类服务
|
||||||
@@ -32,7 +29,8 @@ import java.util.List;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "customer-catalog")
|
@CacheConfig(cacheNames = "customer-catalog")
|
||||||
public class CustomerCatalogService extends EntityService<CustomerCatalog, CustomerCatalogVo, Integer> implements IEntityService<CustomerCatalog>, QueryService<CustomerCatalogVo>,
|
public class CustomerCatalogService extends EntityService<CustomerCatalog, CustomerCatalogVo, Integer>
|
||||||
|
implements IEntityService<CustomerCatalog>, QueryService<CustomerCatalogVo>,
|
||||||
VoableService<CustomerCatalog, CustomerCatalogVo> {
|
VoableService<CustomerCatalog, CustomerCatalogVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -49,23 +47,22 @@ public class CustomerCatalogService extends EntityService<CustomerCatalog, Custo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected org.springframework.data.jpa.domain.Specification<CustomerCatalog> buildParameterSpecification(JsonNode paramsNode) {
|
protected org.springframework.data.jpa.domain.Specification<CustomerCatalog> buildParameterSpecification(
|
||||||
|
JsonNode paramsNode) {
|
||||||
org.springframework.data.jpa.domain.Specification<CustomerCatalog> spec = null;
|
org.springframework.data.jpa.domain.Specification<CustomerCatalog> spec = null;
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code", "name", "description");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code", "name", "description");
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected org.springframework.data.jpa.domain.Specification<CustomerCatalog> buildSearchSpecification(String searchText) {
|
protected Specification<CustomerCatalog> buildSearchSpecification(String searchText) {
|
||||||
return getSearchSpecification(searchText);
|
String likeText = "%" + searchText + "%";
|
||||||
}
|
return (root, query, builder) -> {
|
||||||
|
return builder.or(
|
||||||
/**
|
builder.like(root.get("code"), likeText),
|
||||||
* 根据 id 查找 CustomerCatalog
|
builder.like(root.get("name"), likeText),
|
||||||
*/
|
builder.like(root.get("description"), likeText));
|
||||||
@Override
|
};
|
||||||
public CustomerCatalog getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@@ -132,49 +129,6 @@ public class CustomerCatalogService extends EntityService<CustomerCatalog, Custo
|
|||||||
repository.delete(catalog);
|
repository.delete(catalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询 CustomerCatalog
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Page<CustomerCatalogVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<CustomerCatalog> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 字段等值查询
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code", "name", "description");
|
|
||||||
return repository.findAll(spec, pageable).map(CustomerCatalog::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据搜索文本创建查询条件
|
|
||||||
*/
|
|
||||||
public Specification<CustomerCatalog> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String likeText = "%" + searchText + "%";
|
|
||||||
return (root, query, builder) -> {
|
|
||||||
return builder.or(
|
|
||||||
builder.like(root.get("code"), likeText),
|
|
||||||
builder.like(root.get("name"), likeText),
|
|
||||||
builder.like(root.get("description"), likeText));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搜索 CustomerCatalog
|
|
||||||
*/
|
|
||||||
public List<CustomerCatalog> search(String searchText) {
|
|
||||||
return repository.findAll(getSearchSpecification(searchText), Pageable.ofSize(10)).getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<CustomerCatalog> findAll(Specification<CustomerCatalog> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateByVo(CustomerCatalog model, CustomerCatalogVo vo) {
|
public void updateByVo(CustomerCatalog model, CustomerCatalogVo vo) {
|
||||||
// 参数校验
|
// 参数校验
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.CustomerFileType;
|
import com.ecep.contract.CustomerFileType;
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.customer.repository.CustomerFileTypeLocalRepository;
|
import com.ecep.contract.ds.customer.repository.CustomerFileTypeLocalRepository;
|
||||||
@@ -31,26 +32,30 @@ import com.ecep.contract.vo.CustomerFileTypeLocalVo;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "customer-file-type")
|
@CacheConfig(cacheNames = "customer-file-type")
|
||||||
public class CustomerFileTypeService implements IEntityService<CustomerFileTypeLocal>, QueryService<CustomerFileTypeLocalVo>,
|
public class CustomerFileTypeService extends EntityService<CustomerFileTypeLocal, CustomerFileTypeLocalVo, Integer>
|
||||||
|
implements IEntityService<CustomerFileTypeLocal>, QueryService<CustomerFileTypeLocalVo>,
|
||||||
VoableService<CustomerFileTypeLocal, CustomerFileTypeLocalVo> {
|
VoableService<CustomerFileTypeLocal, CustomerFileTypeLocalVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private CustomerFileTypeLocalRepository repository;
|
private CustomerFileTypeLocalRepository repository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<CustomerFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
protected Specification<CustomerFileTypeLocal> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.like(root.get("type"), "%" + searchText + "%");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<CustomerFileTypeLocal> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
Specification<CustomerFileTypeLocal> spec = null;
|
Specification<CustomerFileTypeLocal> spec = null;
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paramsNode.has("type")) {
|
if (paramsNode.has("type")) {
|
||||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), CustomerFileType.valueOf(paramsNode.get("type").asText())));
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"),
|
||||||
|
CustomerFileType.valueOf(paramsNode.get("type").asText())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// field
|
// field
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
||||||
return findAll(spec, pageable).map(CustomerFileTypeLocal::toVo);
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@@ -59,36 +64,22 @@ public class CustomerFileTypeService implements IEntityService<CustomerFileTypeL
|
|||||||
return repository.findById(id).map(CustomerFileTypeLocal::toVo).orElse(null);
|
return repository.findById(id).map(CustomerFileTypeLocal::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomerFileTypeLocal getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<CustomerFileTypeLocal> findAll(Specification<CustomerFileTypeLocal> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||||
public Map<CustomerFileType, CustomerFileTypeLocalVo> findAll(Locale locale) {
|
public Map<CustomerFileType, CustomerFileTypeLocalVo> findAll(Locale locale) {
|
||||||
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
||||||
.collect(java.util.stream.Collectors.toMap(
|
.collect(java.util.stream.Collectors.toMap(
|
||||||
java.util.Map.Entry::getKey,
|
java.util.Map.Entry::getKey,
|
||||||
entry -> entry.getValue().toVo()
|
entry -> entry.getValue().toVo()));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<CustomerFileTypeLocal> getSearchSpecification(String searchText) {
|
protected CustomerFileTypeLocalRepository getRepository() {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
return repository;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
@Override
|
||||||
return
|
public CustomerFileTypeLocal createNewEntity() {
|
||||||
// builder.or(
|
return new CustomerFileTypeLocal();
|
||||||
builder.like(root.get("type"), "%" + searchText + "%")
|
|
||||||
// )
|
|
||||||
;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.CustomerFileType;
|
import com.ecep.contract.CustomerFileType;
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.MessageHolder;
|
import com.ecep.contract.MessageHolder;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
@@ -59,7 +60,8 @@ import jakarta.persistence.criteria.Path;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "company-customer")
|
@CacheConfig(cacheNames = "company-customer")
|
||||||
public class CustomerService extends CompanyBasicService
|
public class CustomerService extends CompanyBasicService<CompanyCustomer, CustomerVo> // EntityService<CompanyCustomer,
|
||||||
|
// CustomerVo, Integer>
|
||||||
implements IEntityService<CompanyCustomer>, QueryService<CustomerVo>,
|
implements IEntityService<CompanyCustomer>, QueryService<CustomerVo>,
|
||||||
VoableService<CompanyCustomer, CustomerVo> {
|
VoableService<CompanyCustomer, CustomerVo> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CustomerService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CustomerService.class);
|
||||||
@@ -77,49 +79,21 @@ public class CustomerService extends CompanyBasicService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CompanyCustomerEntityService companyCustomerEntityService;
|
private CompanyCustomerEntityService companyCustomerEntityService;
|
||||||
|
|
||||||
public CompanyCustomer findByCompany(Company company) {
|
|
||||||
return repository.findByCompany(company).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CustomerVo findByCompany(CompanyVo company) {
|
|
||||||
return repository.findByCompanyId(company.getId()).map(CompanyCustomer::toVo).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompanyCustomer getById(Integer id) {
|
protected CompanyCustomerRepository getRepository() {
|
||||||
return repository.findById(id).orElse(null);
|
return repository;
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
|
||||||
public CustomerVo findById(Integer id) {
|
|
||||||
return repository.findById(id).map(CompanyCustomer::toVo).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
|
||||||
@CacheEvict(key = "#p0.id")
|
|
||||||
})
|
|
||||||
public CompanyCustomer save(CompanyCustomer companyCustomer) {
|
|
||||||
return repository.save(companyCustomer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
|
||||||
@CacheEvict(key = "#p0")
|
|
||||||
})
|
|
||||||
@Override
|
|
||||||
public void delete(CompanyCustomer entity) {
|
|
||||||
repository.delete(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<CompanyCustomer> getSearchSpecification(String searchText) {
|
public CompanyCustomer createNewEntity() {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
return new CompanyCustomer();
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<CompanyCustomer> buildSearchSpecification(String searchText) {
|
||||||
Specification<CompanyCustomer> nameSpec = (root, query, builder) -> {
|
Specification<CompanyCustomer> nameSpec = (root, query, builder) -> {
|
||||||
Path<Company> company = root.get("company");
|
Path<Company> company = root.get("company");
|
||||||
return companyService.buildSearchPredicate(searchText, company, query, builder);
|
return SpringApp.getBean(CompanyService.class).buildSearchPredicate(searchText, company, query, builder);
|
||||||
};
|
};
|
||||||
// 判断是否全是数字
|
// 判断是否全是数字
|
||||||
if (MyStringUtils.isAllDigit(searchText)) {
|
if (MyStringUtils.isAllDigit(searchText)) {
|
||||||
@@ -147,9 +121,40 @@ public class CustomerService extends CompanyBasicService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CompanyCustomer> search(String searchText) {
|
protected Specification<CompanyCustomer> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
Specification<CompanyCustomer> spec = getSearchSpecification(searchText);
|
Specification<CompanyCustomer> spec = null;
|
||||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
// field
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompanyCustomer findByCompany(Company company) {
|
||||||
|
return repository.findByCompany(company).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomerVo findByCompany(CompanyVo company) {
|
||||||
|
return repository.findByCompanyId(company.getId()).map(CompanyCustomer::toVo).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "#p0")
|
||||||
|
public CustomerVo findById(Integer id) {
|
||||||
|
return repository.findById(id).map(CompanyCustomer::toVo).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id")
|
||||||
|
})
|
||||||
|
@Override
|
||||||
|
public CompanyCustomer save(CompanyCustomer companyCustomer) {
|
||||||
|
return repository.save(companyCustomer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0")
|
||||||
|
})
|
||||||
|
@Override
|
||||||
|
public void delete(CompanyCustomer entity) {
|
||||||
|
repository.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -158,6 +163,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
companyCustomerFileService.delete(customerFile);
|
companyCustomerFileService.delete(customerFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public File getBasePath() {
|
public File getBasePath() {
|
||||||
return new File(confService.getString(CompanyCustomerConstant.KEY_BASE_PATH));
|
return new File(confService.getString(CompanyCustomerConstant.KEY_BASE_PATH));
|
||||||
}
|
}
|
||||||
@@ -199,7 +205,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file,
|
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file,
|
||||||
Consumer<String> status) {
|
Consumer<String> status) {
|
||||||
dbFile.setType((T) CustomerFileType.General);
|
dbFile.setType((T) CustomerFileType.General);
|
||||||
fillFile(dbFile, file, null, status);
|
fillFile(dbFile, file, null, status);
|
||||||
companyCustomerFileService.save((CompanyCustomerFile) dbFile);
|
companyCustomerFileService.save((CompanyCustomerFile) dbFile);
|
||||||
@@ -208,7 +214,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsEvaluationFile(F customerFile, File file,
|
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsEvaluationFile(F customerFile, File file,
|
||||||
List<File> fileList, Consumer<String> status) {
|
List<File> fileList, Consumer<String> status) {
|
||||||
boolean modified = super.fillFileAsEvaluationFile(customerFile, file, fileList, status);
|
boolean modified = super.fillFileAsEvaluationFile(customerFile, file, fileList, status);
|
||||||
|
|
||||||
if (fileList != null) {
|
if (fileList != null) {
|
||||||
@@ -242,7 +248,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <T, F extends CompanyBasicFile<T>> void updateEvaluationFileByJsonFile(F customerFile, File jsonFile,
|
private <T, F extends CompanyBasicFile<T>> void updateEvaluationFileByJsonFile(F customerFile, File jsonFile,
|
||||||
Consumer<String> status) throws IOException {
|
Consumer<String> status) throws IOException {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
JsonNode root = objectMapper.readTree(jsonFile);
|
JsonNode root = objectMapper.readTree(jsonFile);
|
||||||
if (!root.isObject()) {
|
if (!root.isObject()) {
|
||||||
@@ -268,7 +274,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
|
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
|
||||||
Consumer<String> status) {
|
Consumer<String> status) {
|
||||||
CompanyCustomerFile customerFile = new CompanyCustomerFile();
|
CompanyCustomerFile customerFile = new CompanyCustomerFile();
|
||||||
customerFile.setType(CustomerFileType.General);
|
customerFile.setType(CustomerFileType.General);
|
||||||
if (fillFile(customerFile, file, fileList, status)) {
|
if (fillFile(customerFile, file, fileList, status)) {
|
||||||
@@ -292,7 +298,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
return (fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME1)
|
return (fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME1)
|
||||||
|| fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME2))
|
|| fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME2))
|
||||||
&& (FileUtils.withExtensions(fileName, FileUtils.JPG, FileUtils.JPEG,
|
&& (FileUtils.withExtensions(fileName, FileUtils.JPG, FileUtils.JPEG,
|
||||||
FileUtils.PDF));
|
FileUtils.PDF));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean makePathAbsent(CompanyCustomer companyCustomer) {
|
public boolean makePathAbsent(CompanyCustomer companyCustomer) {
|
||||||
@@ -335,21 +341,6 @@ public class CustomerService extends CompanyBasicService
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<CompanyCustomer> findAll(Specification<CompanyCustomer> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<CustomerVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<CompanyCustomer> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
|
||||||
return findAll(spec, pageable).map(CompanyCustomer::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将一个公司的客户信息转移到另一个公司,并保存在数据库中
|
* 将一个公司的客户信息转移到另一个公司,并保存在数据库中
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,14 +2,13 @@ package com.ecep.contract.ds.other.repository;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.model.InventoryCatalog;
|
import com.ecep.contract.model.InventoryCatalog;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface InventoryCatalogRepository extends JpaRepository<InventoryCatalog, Integer>, JpaSpecificationExecutor<InventoryCatalog> {
|
public interface InventoryCatalogRepository extends MyRepository<InventoryCatalog, Integer> {
|
||||||
Optional<InventoryCatalog> findByCode(String code);
|
Optional<InventoryCatalog> findByCode(String code);
|
||||||
|
|
||||||
Optional<InventoryCatalog> findByName(String name);
|
Optional<InventoryCatalog> findByName(String name);
|
||||||
|
|||||||
@@ -3,24 +3,15 @@ package com.ecep.contract.ds.other.repository;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
|
||||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.model.Permission;
|
import com.ecep.contract.model.Permission;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Repository
|
@Repository
|
||||||
public interface PermissionRepository extends
|
public interface PermissionRepository extends MyRepository<Permission, Integer> {
|
||||||
// JDBC interfaces
|
|
||||||
CrudRepository<Permission, Integer>, PagingAndSortingRepository<Permission, Integer>,
|
|
||||||
// JPA interfaces
|
|
||||||
JpaRepository<Permission, Integer>, JpaSpecificationExecutor<Permission> {
|
|
||||||
|
|
||||||
|
|
||||||
List<Permission> findAllByFunctionId(Integer functionId);
|
List<Permission> findAllByFunctionId(Integer functionId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,12 @@
|
|||||||
package com.ecep.contract.ds.other.service;
|
package com.ecep.contract.ds.other.service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
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.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import com.ecep.contract.EntityService;
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
@@ -21,14 +14,15 @@ import com.ecep.contract.QueryService;
|
|||||||
import com.ecep.contract.ds.other.repository.BankRepository;
|
import com.ecep.contract.ds.other.repository.BankRepository;
|
||||||
import com.ecep.contract.model.Bank;
|
import com.ecep.contract.model.Bank;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.BankVo;
|
import com.ecep.contract.vo.BankVo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "bank")
|
@CacheConfig(cacheNames = "bank")
|
||||||
public class BankService extends EntityService<Bank, BankVo, Integer> implements IEntityService<Bank>, QueryService<BankVo>, VoableService<Bank, BankVo> {
|
public class BankService extends EntityService<Bank, BankVo, Integer>
|
||||||
|
implements IEntityService<Bank>, QueryService<BankVo>, VoableService<Bank, BankVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private BankRepository bankRepository;
|
private BankRepository bankRepository;
|
||||||
@@ -52,44 +46,6 @@ public class BankService extends EntityService<Bank, BankVo, Integer> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected org.springframework.data.jpa.domain.Specification<Bank> buildSearchSpecification(String searchText) {
|
protected org.springframework.data.jpa.domain.Specification<Bank> buildSearchSpecification(String searchText) {
|
||||||
return getSearchSpecification(searchText);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#id")
|
|
||||||
public BankVo findById(Integer id) {
|
|
||||||
return bankRepository.findById(id).map(Bank::toVo).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bank getById(Integer id) {
|
|
||||||
return bankRepository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Page<Bank> findAll(Specification<Bank> spec, Pageable pageable) {
|
|
||||||
return bankRepository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<BankVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<Bank> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 可以根据需要添加更多参数处理
|
|
||||||
return findAll(spec, pageable).map(Bank::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count(JsonNode paramsNode) {
|
|
||||||
return bankRepository.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<Bank> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
@@ -97,9 +53,9 @@ public class BankService extends EntityService<Bank, BankVo, Integer> implements
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Bank> search(String searchText) {
|
@Cacheable(key = "#id")
|
||||||
Specification<Bank> spec = getSearchSpecification(searchText);
|
public BankVo findById(Integer id) {
|
||||||
return bankRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
return bankRepository.findById(id).map(Bank::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bank findByName(String name) {
|
public Bank findByName(String name) {
|
||||||
|
|||||||
@@ -73,25 +73,11 @@ public class DepartmentService extends EntityService<Department, DepartmentVo, I
|
|||||||
return repository.findById(id).map(Department::toVo).orElse(null);
|
return repository.findById(id).map(Department::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Department getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "'code-'+#p0")
|
@Cacheable(key = "'code-'+#p0")
|
||||||
public DepartmentVo findByCode(String code) {
|
public DepartmentVo findByCode(String code) {
|
||||||
return repository.findByCode(code).map(Department::toVo).orElse(null);
|
return repository.findByCode(code).map(Department::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<Department> findAll(Specification<Department> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Department> search(String searchText) {
|
|
||||||
Specification<Department> spec = getSearchSpecification(searchText);
|
|
||||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'code-'+#p0.code")
|
@CacheEvict(key = "'code-'+#p0.code")
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
@@ -28,26 +29,25 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "employee-auth-bind")
|
@CacheConfig(cacheNames = "employee-auth-bind")
|
||||||
public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>, QueryService<EmployeeAuthBindVo>,
|
public class EmployeeAuthBindService extends EntityService<EmployeeAuthBind, EmployeeAuthBindVo, Integer>
|
||||||
|
implements IEntityService<EmployeeAuthBind>, QueryService<EmployeeAuthBindVo>,
|
||||||
VoableService<EmployeeAuthBind, EmployeeAuthBindVo> {
|
VoableService<EmployeeAuthBind, EmployeeAuthBindVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmployeeAuthBindRepository repository;
|
private EmployeeAuthBindRepository repository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EmployeeAuthBindVo findById(Integer id) {
|
protected EmployeeAuthBindRepository getRepository() {
|
||||||
return repository.findById(id).map(EmployeeAuthBind::toVo).orElse(null);
|
return repository;
|
||||||
}
|
|
||||||
|
|
||||||
public EmployeeAuthBind getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<EmployeeAuthBind> getSearchSpecification(String searchText) {
|
public EmployeeAuthBind createNewEntity() {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
return new EmployeeAuthBind();
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
protected Specification<EmployeeAuthBind> buildSearchSpecification(String searchText) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("ip"), "%" + searchText + "%"),
|
builder.like(root.get("ip"), "%" + searchText + "%"),
|
||||||
@@ -57,19 +57,16 @@ public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<EmployeeAuthBind> findAll(Specification<EmployeeAuthBind> spec, Pageable pageable) {
|
protected Specification<EmployeeAuthBind> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
return repository.findAll(spec, pageable);
|
Specification<EmployeeAuthBind> spec = null;
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<EmployeeAuthBindVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
public EmployeeAuthBindVo findById(Integer id) {
|
||||||
Specification<EmployeeAuthBind> spec = null;
|
return repository.findById(id).map(EmployeeAuthBind::toVo).orElse(null);
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 可以根据需要添加更多参数处理
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");
|
|
||||||
return findAll(spec, pageable).map(EmployeeAuthBind::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
package com.ecep.contract.ds.other.service;
|
package com.ecep.contract.ds.other.service;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
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.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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
@@ -25,7 +22,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "employee-login-history")
|
@CacheConfig(cacheNames = "employee-login-history")
|
||||||
public class EmployeeLoginHistoryService
|
public class EmployeeLoginHistoryService extends EntityService<EmployeeLoginHistory, EmployeeLoginHistoryVo, Integer>
|
||||||
implements IEntityService<EmployeeLoginHistory>, QueryService<EmployeeLoginHistoryVo>,
|
implements IEntityService<EmployeeLoginHistory>, QueryService<EmployeeLoginHistoryVo>,
|
||||||
VoableService<EmployeeLoginHistory, EmployeeLoginHistoryVo> {
|
VoableService<EmployeeLoginHistory, EmployeeLoginHistoryVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@@ -33,19 +30,17 @@ public class EmployeeLoginHistoryService
|
|||||||
private EmployeeLoginHistoryRepository repository;
|
private EmployeeLoginHistoryRepository repository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EmployeeLoginHistoryVo findById(Integer id) {
|
protected EmployeeLoginHistoryRepository getRepository() {
|
||||||
return repository.findById(id).map(EmployeeLoginHistory::toVo).orElse(null);
|
return repository;
|
||||||
}
|
|
||||||
|
|
||||||
public EmployeeLoginHistory getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<EmployeeLoginHistory> getSearchSpecification(String searchText) {
|
public EmployeeLoginHistory createNewEntity() {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
return new EmployeeLoginHistory();
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
protected Specification<EmployeeLoginHistory> buildSearchSpecification(String searchText) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("ip"), "%" + searchText + "%"),
|
builder.like(root.get("ip"), "%" + searchText + "%"),
|
||||||
@@ -54,28 +49,22 @@ public class EmployeeLoginHistoryService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<EmployeeLoginHistory> findAll(Specification<EmployeeLoginHistory> spec, Pageable pageable) {
|
protected Specification<EmployeeLoginHistory> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<EmployeeLoginHistoryVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<EmployeeLoginHistory> spec = null;
|
Specification<EmployeeLoginHistory> spec = null;
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 可以根据需要添加更多参数处理
|
// 可以根据需要添加更多参数处理
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");
|
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "ip", "mac");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "ip", "mac");
|
||||||
return findAll(spec, pageable).map(EmployeeLoginHistory::toVo);
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(EmployeeLoginHistory entity) {
|
public EmployeeLoginHistoryVo findById(Integer id) {
|
||||||
repository.delete(entity);
|
return repository.findById(id).map(EmployeeLoginHistory::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@CacheEvict(key = "#p0.id")
|
||||||
public EmployeeLoginHistory save(EmployeeLoginHistory entity) {
|
public EmployeeLoginHistory save(EmployeeLoginHistory entity) {
|
||||||
return repository.save(entity);
|
return repository.save(entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,27 +3,25 @@ package com.ecep.contract.ds.other.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.ecep.contract.vo.FunctionVo;
|
|
||||||
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.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.service.VoableService;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.ecep.contract.ds.other.repository.EmployeeRoleRepository;
|
import com.ecep.contract.ds.other.repository.EmployeeRoleRepository;
|
||||||
import com.ecep.contract.model.EmployeeRole;
|
import com.ecep.contract.model.EmployeeRole;
|
||||||
import com.ecep.contract.model.Function;
|
import com.ecep.contract.model.Function;
|
||||||
|
import com.ecep.contract.service.VoableService;
|
||||||
import com.ecep.contract.vo.EmployeeRoleVo;
|
import com.ecep.contract.vo.EmployeeRoleVo;
|
||||||
|
import com.ecep.contract.vo.FunctionVo;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
|
||||||
@@ -32,7 +30,8 @@ import jakarta.transaction.Transactional;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "employee-role")
|
@CacheConfig(cacheNames = "employee-role")
|
||||||
public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryService<EmployeeRoleVo>,
|
public class EmployeeRoleService extends EntityService<EmployeeRole, EmployeeRoleVo, Integer>
|
||||||
|
implements IEntityService<EmployeeRole>, QueryService<EmployeeRoleVo>,
|
||||||
VoableService<EmployeeRole, EmployeeRoleVo> {
|
VoableService<EmployeeRole, EmployeeRoleVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -41,20 +40,18 @@ public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryS
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FunctionService functionService;
|
private FunctionService functionService;
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Override
|
||||||
public EmployeeRoleVo findById(Integer id) {
|
protected EmployeeRoleRepository getRepository() {
|
||||||
return roleRepository.findById(id).map(EmployeeRole::toVo).orElse(null);
|
return roleRepository;
|
||||||
}
|
|
||||||
|
|
||||||
public EmployeeRole getById(Integer id) {
|
|
||||||
return roleRepository.findById(id).orElse(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<EmployeeRole> getSearchSpecification(String searchText) {
|
public EmployeeRole createNewEntity() {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
return new EmployeeRole();
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
protected Specification<EmployeeRole> buildSearchSpecification(String searchText) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
@@ -62,6 +59,11 @@ public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryS
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "#p0")
|
||||||
|
public EmployeeRoleVo findById(Integer id) {
|
||||||
|
return roleRepository.findById(id).map(EmployeeRole::toVo).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'code-'+#p0")
|
@Cacheable(key = "'code-'+#p0")
|
||||||
public EmployeeRoleVo findByCode(String code) {
|
public EmployeeRoleVo findByCode(String code) {
|
||||||
return roleRepository.findByCode(code).map(EmployeeRole::toVo).orElse(null);
|
return roleRepository.findByCode(code).map(EmployeeRole::toVo).orElse(null);
|
||||||
@@ -84,18 +86,8 @@ public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<EmployeeRole> findAll(Specification<EmployeeRole> spec, Pageable pageable) {
|
protected Specification<EmployeeRole> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
return roleRepository.findAll(spec, pageable);
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<EmployeeRoleVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<EmployeeRole> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 可以根据需要添加更多参数处理
|
|
||||||
return findAll(spec, pageable).map(EmployeeRole::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import com.ecep.contract.service.VoableService;
|
|||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.EmployeeVo;
|
import com.ecep.contract.vo.EmployeeVo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
|
||||||
@@ -58,7 +57,8 @@ public class EmployeeService extends EntityService<Employee, EmployeeVo, Integer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected org.springframework.data.jpa.domain.Specification<Employee> buildParameterSpecification(JsonNode paramsNode) {
|
protected org.springframework.data.jpa.domain.Specification<Employee> buildParameterSpecification(
|
||||||
|
JsonNode paramsNode) {
|
||||||
org.springframework.data.jpa.domain.Specification<Employee> spec = null;
|
org.springframework.data.jpa.domain.Specification<Employee> spec = null;
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "department");
|
spec = SpecificationUtils.andParam(spec, paramsNode, "department");
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "isActive");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "isActive");
|
||||||
@@ -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 + "%"));
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,10 +94,6 @@ public class EmployeeService extends EntityService<Employee, EmployeeVo, Integer
|
|||||||
return employeeRepository.findById(id).map(Employee::toVo).orElse(null);
|
return employeeRepository.findById(id).map(Employee::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Employee getById(Integer id) {
|
|
||||||
return employeeRepository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "'ac-'+#p0")
|
@Cacheable(key = "'ac-'+#p0")
|
||||||
public EmployeeVo findByAccount(String username) {
|
public EmployeeVo findByAccount(String username) {
|
||||||
return employeeRepository.findByAccount(username).map(Employee::toVo).orElse(null);
|
return employeeRepository.findByAccount(username).map(Employee::toVo).orElse(null);
|
||||||
@@ -142,39 +147,6 @@ public class EmployeeService extends EntityService<Employee, EmployeeVo, Integer
|
|||||||
employeeRepository.delete(employee);
|
employeeRepository.delete(employee);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<Employee> findAll(Specification<Employee> spec, Pageable pageable) {
|
|
||||||
return employeeRepository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 + "%"));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据搜索文本查询员工列表
|
* 根据搜索文本查询员工列表
|
||||||
@@ -185,11 +157,6 @@ public class EmployeeService extends EntityService<Employee, EmployeeVo, Integer
|
|||||||
* @param searchText 要搜索的文本,用于在员工代码和名称中进行模糊匹配
|
* @param searchText 要搜索的文本,用于在员工代码和名称中进行模糊匹配
|
||||||
* @return 包含搜索结果的员工列表,最多10条记录
|
* @return 包含搜索结果的员工列表,最多10条记录
|
||||||
*/
|
*/
|
||||||
public List<Employee> search(String searchText) {
|
|
||||||
// 创建一个Specification对象,用于定义复杂的查询条件
|
|
||||||
Specification<Employee> spec = getSearchSpecification(searchText);
|
|
||||||
return employeeRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<EmployeeRole> getRolesByEmployeeId(Integer employeeId) {
|
public List<EmployeeRole> getRolesByEmployeeId(Integer employeeId) {
|
||||||
@@ -209,7 +176,7 @@ public class EmployeeService extends EntityService<Employee, EmployeeVo, Integer
|
|||||||
entity.setAlias(vo.getAlias());
|
entity.setAlias(vo.getAlias());
|
||||||
entity.setCode(vo.getCode());
|
entity.setCode(vo.getCode());
|
||||||
if (vo.getDepartmentId() != null) {
|
if (vo.getDepartmentId() != null) {
|
||||||
if(entity.getDepartment()==null || !entity.getDepartment().getId().equals(vo.getDepartmentId())){
|
if (entity.getDepartment() == null || !entity.getDepartment().getId().equals(vo.getDepartmentId())) {
|
||||||
Department department = SpringApp.getBean(DepartmentService.class).getById(vo.getDepartmentId());
|
Department department = SpringApp.getBean(DepartmentService.class).getById(vo.getDepartmentId());
|
||||||
entity.setDepartment(department);
|
entity.setDepartment(department);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.ecep.contract.ds.other.service;
|
package com.ecep.contract.ds.other.service;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
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.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
@@ -12,20 +10,21 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.service.VoableService;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.ecep.contract.ds.other.repository.FunctionRepository;
|
import com.ecep.contract.ds.other.repository.FunctionRepository;
|
||||||
import com.ecep.contract.model.Function;
|
import com.ecep.contract.model.Function;
|
||||||
|
import com.ecep.contract.service.VoableService;
|
||||||
import com.ecep.contract.vo.FunctionVo;
|
import com.ecep.contract.vo.FunctionVo;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "function")
|
@CacheConfig(cacheNames = "function")
|
||||||
public class FunctionService implements IEntityService<Function>, QueryService<FunctionVo>, VoableService<Function, FunctionVo> {
|
public class FunctionService extends EntityService<Function, FunctionVo, Integer>
|
||||||
|
implements IEntityService<Function>, QueryService<FunctionVo>, VoableService<Function, FunctionVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private FunctionRepository repository;
|
private FunctionRepository repository;
|
||||||
@@ -34,14 +33,11 @@ public class FunctionService implements IEntityService<Function>, QueryService<F
|
|||||||
public FunctionVo findById(Integer id) {
|
public FunctionVo findById(Integer id) {
|
||||||
return repository.findById(id).map(Function::toVo).orElse(null);
|
return repository.findById(id).map(Function::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Function getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id")
|
@CacheEvict(key = "#p0.id")
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public Function save(Function role) {
|
public Function save(Function role) {
|
||||||
return repository.save(role);
|
return repository.save(role);
|
||||||
}
|
}
|
||||||
@@ -49,37 +45,29 @@ public class FunctionService implements IEntityService<Function>, QueryService<F
|
|||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id")
|
@CacheEvict(key = "#p0.id")
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public void delete(Function entity) {
|
public void delete(Function entity) {
|
||||||
repository.delete(entity);
|
repository.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Function> findAll(Specification<Function> spec, Pageable pageable) {
|
protected FunctionRepository getRepository() {
|
||||||
return repository.findAll(spec, pageable);
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<FunctionVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
public Function createNewEntity() {
|
||||||
Specification<Function> spec = null;
|
return new Function();
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 可以根据需要添加更多参数处理
|
|
||||||
return findAll(spec, pageable).map(Function::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<Function> getSearchSpecification(String searchText) {
|
protected Specification<Function> buildSearchSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("key"), "%" + searchText + "%"),
|
builder.like(root.get("key"), "%" + searchText + "%"),
|
||||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||||
builder.like(root.get("controller"), "%" + searchText + "%"),
|
builder.like(root.get("controller"), "%" + searchText + "%"),
|
||||||
builder.like(root.get("icon"), "%" + searchText + "%")
|
builder.like(root.get("icon"), "%" + searchText + "%"));
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,4 +81,9 @@ public class FunctionService implements IEntityService<Function>, QueryService<F
|
|||||||
function.setDescription(vo.getDescription());
|
function.setDescription(vo.getDescription());
|
||||||
// parentId和order字段在实体类中不存在,暂不处理
|
// parentId和order字段在实体类中不存在,暂不处理
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
protected Specification<Function> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.ecep.contract.ds.other.service;
|
package com.ecep.contract.ds.other.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
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;
|
||||||
@@ -17,6 +16,7 @@ import org.springframework.util.StringUtils;
|
|||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.ds.other.repository.InventoryCatalogRepository;
|
import com.ecep.contract.ds.other.repository.InventoryCatalogRepository;
|
||||||
import com.ecep.contract.model.InventoryCatalog;
|
import com.ecep.contract.model.InventoryCatalog;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
@@ -26,7 +26,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "inventory-catalog")
|
@CacheConfig(cacheNames = "inventory-catalog")
|
||||||
public class InventoryCatalogService implements IEntityService<InventoryCatalog>, QueryService<InventoryCatalogVo>,
|
public class InventoryCatalogService extends EntityService<InventoryCatalog, InventoryCatalogVo, Integer>
|
||||||
|
implements IEntityService<InventoryCatalog>, QueryService<InventoryCatalogVo>,
|
||||||
VoableService<InventoryCatalog, InventoryCatalogVo> {
|
VoableService<InventoryCatalog, InventoryCatalogVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -36,10 +37,6 @@ public class InventoryCatalogService implements IEntityService<InventoryCatalog>
|
|||||||
public InventoryCatalogVo findById(Integer id) {
|
public InventoryCatalogVo findById(Integer id) {
|
||||||
return repository.findById(id).map(InventoryCatalog::toVo).orElse(null);
|
return repository.findById(id).map(InventoryCatalog::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryCatalog getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "'code-'+#p0")
|
@Cacheable(key = "'code-'+#p0")
|
||||||
public InventoryCatalogVo findByCode(String code) {
|
public InventoryCatalogVo findByCode(String code) {
|
||||||
@@ -51,50 +48,35 @@ public class InventoryCatalogService implements IEntityService<InventoryCatalog>
|
|||||||
return repository.findByName(name).map(InventoryCatalog::toVo).orElse(null);
|
return repository.findByName(name).map(InventoryCatalog::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<InventoryCatalog> findAll(Specification<InventoryCatalog> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<InventoryCatalogVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<InventoryCatalog> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 可以根据需要添加更多参数处理
|
|
||||||
return findAll(spec, pageable).map(InventoryCatalog::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<InventoryCatalog> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
|
||||||
return builder.or(
|
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
|
||||||
builder.like(root.get("name"), "%" + searchText + "%"));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryCatalog> search(String searchText) {
|
|
||||||
Specification<InventoryCatalog> spec = (root, query, builder) -> {
|
|
||||||
return builder.or(builder.like(root.get("code"), "%" + searchText + "%"),
|
|
||||||
builder.like(root.get("name"), "%" + searchText + "%"));
|
|
||||||
};
|
|
||||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'code-'+#p0.code"),
|
@CacheEvict(key = "'code-'+#p0.code"),
|
||||||
@CacheEvict(key = "'name-'+#p0.code")
|
@CacheEvict(key = "'name-'+#p0.code")
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public InventoryCatalog save(InventoryCatalog entity) {
|
public InventoryCatalog save(InventoryCatalog entity) {
|
||||||
return repository.save(entity);
|
return repository.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected InventoryCatalogRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InventoryCatalog createNewEntity() {
|
||||||
|
return new InventoryCatalog();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<InventoryCatalog> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.or(
|
||||||
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("name"), "%" + searchText + "%"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'code-'+#p0.code"),
|
@CacheEvict(key = "'code-'+#p0.code"),
|
||||||
@@ -111,4 +93,9 @@ public class InventoryCatalogService implements IEntityService<InventoryCatalog>
|
|||||||
model.setName(vo.getName());
|
model.setName(vo.getName());
|
||||||
// 其他属性根据实际需要添加
|
// 其他属性根据实际需要添加
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<InventoryCatalog> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import java.util.Optional;
|
|||||||
|
|
||||||
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.CacheEvict;
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -26,7 +28,7 @@ import jakarta.persistence.criteria.Path;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "inventory-history-price")
|
@CacheConfig(cacheNames = "inventory-history-price")
|
||||||
public class InventoryHistoryPriceService
|
public class InventoryHistoryPriceService extends EntityService<InventoryHistoryPrice, InventoryHistoryPriceVo, Integer>
|
||||||
implements IEntityService<InventoryHistoryPrice>, QueryService<InventoryHistoryPriceVo>,
|
implements IEntityService<InventoryHistoryPrice>, QueryService<InventoryHistoryPriceVo>,
|
||||||
VoableService<InventoryHistoryPrice, InventoryHistoryPriceVo> {
|
VoableService<InventoryHistoryPrice, InventoryHistoryPriceVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@@ -41,16 +43,35 @@ public class InventoryHistoryPriceService
|
|||||||
public InventoryHistoryPriceVo findById(Integer id) {
|
public InventoryHistoryPriceVo findById(Integer id) {
|
||||||
return repository.findById(id).map(InventoryHistoryPrice::toVo).orElse(null);
|
return repository.findById(id).map(InventoryHistoryPrice::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryHistoryPrice getById(Integer id) {
|
public List<InventoryHistoryPrice> findAllByInventory(Inventory inventory) {
|
||||||
return repository.findById(id).orElse(null);
|
return repository.findAllByInventory(inventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@CacheEvict(key = "#p0.id")
|
||||||
|
@Override
|
||||||
|
public void delete(InventoryHistoryPrice entity) {
|
||||||
|
repository.delete(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@CacheEvict(key = "#p0.id")
|
||||||
|
@Override
|
||||||
|
public InventoryHistoryPrice save(InventoryHistoryPrice entity) {
|
||||||
|
return repository.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<InventoryHistoryPrice> getSearchSpecification(String searchText) {
|
protected InventoryHistoryPriceRepository getRepository() {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
return repository;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public InventoryHistoryPrice createNewEntity() {
|
||||||
|
return new InventoryHistoryPrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<InventoryHistoryPrice> buildSearchSpecification(String searchText) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
Path<Inventory> inventory = root.get("inventory");
|
Path<Inventory> inventory = root.get("inventory");
|
||||||
return builder.or(
|
return builder.or(
|
||||||
@@ -59,35 +80,6 @@ public class InventoryHistoryPriceService
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<InventoryHistoryPrice> findAll(Specification<InventoryHistoryPrice> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<InventoryHistoryPriceVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<InventoryHistoryPrice> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 可以根据需要添加更多参数处理
|
|
||||||
return findAll(spec, pageable).map(InventoryHistoryPrice::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryHistoryPrice> findAllByInventory(Inventory inventory) {
|
|
||||||
return repository.findAllByInventory(inventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(InventoryHistoryPrice entity) {
|
|
||||||
repository.delete(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InventoryHistoryPrice save(InventoryHistoryPrice entity) {
|
|
||||||
return repository.save(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateByVo(InventoryHistoryPrice entity, InventoryHistoryPriceVo vo) {
|
public void updateByVo(InventoryHistoryPrice entity, InventoryHistoryPriceVo vo) {
|
||||||
if (entity == null || vo == null) {
|
if (entity == null || vo == null) {
|
||||||
@@ -151,4 +143,9 @@ public class InventoryHistoryPriceService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<InventoryHistoryPrice> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -8,12 +8,10 @@ import org.springframework.cache.annotation.CacheEvict;
|
|||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
@@ -28,7 +26,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "permission")
|
@CacheConfig(cacheNames = "permission")
|
||||||
public class PermissionService
|
public class PermissionService extends EntityService<Permission, PermissionVo, Integer>
|
||||||
implements IEntityService<Permission>, QueryService<PermissionVo>, VoableService<Permission, PermissionVo> {
|
implements IEntityService<Permission>, QueryService<PermissionVo>, VoableService<Permission, PermissionVo> {
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@@ -42,21 +40,6 @@ public class PermissionService
|
|||||||
return permissionRepository.findById(id).map(Permission::toVo).orElse(null);
|
return permissionRepository.findById(id).map(Permission::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Permission getById(Integer id) {
|
|
||||||
return permissionRepository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<Permission> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
|
||||||
return builder.or(
|
|
||||||
builder.like(root.get("name"), "%" + searchText + "%"));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "'permission-code-'+#p0")
|
@Cacheable(key = "'permission-code-'+#p0")
|
||||||
public Permission findByCode(String code) {
|
public Permission findByCode(String code) {
|
||||||
// return permissionRepository.findByCode(code).orElse(null);
|
// return permissionRepository.findByCode(code).orElse(null);
|
||||||
@@ -67,25 +50,12 @@ public class PermissionService
|
|||||||
@CacheEvict(key = "'permission-'+#p0.id"),
|
@CacheEvict(key = "'permission-'+#p0.id"),
|
||||||
// @CacheEvict(key = "'permission-code-'+#p0.code")
|
// @CacheEvict(key = "'permission-code-'+#p0.code")
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public Permission save(Permission role) {
|
public Permission save(Permission role) {
|
||||||
return permissionRepository.save(role);
|
return permissionRepository.save(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@CacheEvict(key = "'permission-'+#p0.id")
|
||||||
public Page<Permission> findAll(Specification<Permission> spec, Pageable pageable) {
|
|
||||||
return permissionRepository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<PermissionVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<Permission> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 可以根据需要添加更多参数处理
|
|
||||||
return findAll(spec, pageable).map(Permission::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Permission entity) {
|
public void delete(Permission entity) {
|
||||||
permissionRepository.delete(entity);
|
permissionRepository.delete(entity);
|
||||||
@@ -95,6 +65,24 @@ public class PermissionService
|
|||||||
return permissionRepository.findAllByFunctionId(functionId);
|
return permissionRepository.findAllByFunctionId(functionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PermissionRepository getRepository() {
|
||||||
|
return permissionRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission createNewEntity() {
|
||||||
|
return new Permission();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<Permission> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.or(
|
||||||
|
builder.like(root.get("name"), "%" + searchText + "%"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateByVo(Permission permission, PermissionVo vo) {
|
public void updateByVo(Permission permission, PermissionVo vo) {
|
||||||
// 映射基本属性
|
// 映射基本属性
|
||||||
@@ -121,4 +109,9 @@ public class PermissionService
|
|||||||
// 如果需要处理,可以添加日志记录或者其他逻辑
|
// 如果需要处理,可以添加日志记录或者其他逻辑
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<Permission> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
package com.ecep.contract.ds.project.repository;
|
package com.ecep.contract.ds.project.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.customer.model.CustomerSatisfactionSurvey;
|
import com.ecep.contract.ds.customer.model.CustomerSatisfactionSurvey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目客户满意度调查数据访问层
|
* 项目客户满意度调查数据访问层
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface CustomerSatisfactionSurveyRepository
|
public interface CustomerSatisfactionSurveyRepository
|
||||||
extends JpaRepository<CustomerSatisfactionSurvey, Integer>,
|
extends MyRepository<CustomerSatisfactionSurvey, Integer> {
|
||||||
JpaSpecificationExecutor<CustomerSatisfactionSurvey> {
|
|
||||||
|
// 可以在这里添加自定义查询方法
|
||||||
// 可以在这里添加自定义查询方法
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ package com.ecep.contract.ds.project.repository;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.project.model.ProjectCost;
|
import com.ecep.contract.ds.project.model.ProjectCost;
|
||||||
import com.ecep.contract.ds.project.model.ProjectCostItem;
|
import com.ecep.contract.ds.project.model.ProjectCostItem;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ProjectCostItemRepository extends JpaRepository<ProjectCostItem, Integer>, JpaSpecificationExecutor<ProjectCostItem> {
|
public interface ProjectCostItemRepository extends MyRepository<ProjectCostItem, Integer> {
|
||||||
/**
|
/**
|
||||||
* 根据项目成本查询项目成本条目
|
* 根据项目成本查询项目成本条目
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,16 +3,15 @@ package com.ecep.contract.ds.project.repository;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.contract.model.Contract;
|
import com.ecep.contract.ds.contract.model.Contract;
|
||||||
import com.ecep.contract.ds.project.model.Project;
|
import com.ecep.contract.ds.project.model.Project;
|
||||||
import com.ecep.contract.ds.project.model.ProjectCost;
|
import com.ecep.contract.ds.project.model.ProjectCost;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ProjectCostRepository extends JpaRepository<ProjectCost, Integer>, JpaSpecificationExecutor<ProjectCost> {
|
public interface ProjectCostRepository extends MyRepository<ProjectCost, Integer> {
|
||||||
/**
|
/**
|
||||||
* 根据合同查询
|
* 根据合同查询
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,18 +2,16 @@ package com.ecep.contract.ds.project.repository;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.model.ProjectSaleType;
|
import com.ecep.contract.model.ProjectSaleType;
|
||||||
import com.ecep.contract.model.ProjectSaleTypeRequireFileType;
|
import com.ecep.contract.model.ProjectSaleTypeRequireFileType;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ProjectSaleTypeRequireFileTypeRepository extends
|
public interface ProjectSaleTypeRequireFileTypeRepository extends
|
||||||
JpaRepository<ProjectSaleTypeRequireFileType, Integer>,
|
MyRepository<ProjectSaleTypeRequireFileType, Integer> {
|
||||||
JpaSpecificationExecutor<ProjectSaleTypeRequireFileType> {
|
|
||||||
|
|
||||||
List<ProjectSaleTypeRequireFileType> findBySaleTypeId(int saleTypeId);
|
List<ProjectSaleTypeRequireFileType> findBySaleTypeId(int saleTypeId);
|
||||||
|
|
||||||
List<ProjectSaleTypeRequireFileType> findBySaleType(ProjectSaleType saleType);
|
List<ProjectSaleTypeRequireFileType> findBySaleType(ProjectSaleType saleType);
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package com.ecep.contract.ds.project.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ecep.contract.constant.ParamConstant;
|
|
||||||
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.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -13,14 +13,17 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
import com.ecep.contract.constant.ParamConstant;
|
||||||
import com.ecep.contract.ds.project.repository.CustomerSatisfactionSurveyRepository;
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.customer.model.CustomerSatisfactionSurvey;
|
import com.ecep.contract.ds.customer.model.CustomerSatisfactionSurvey;
|
||||||
import com.ecep.contract.model.Employee;
|
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||||
import com.ecep.contract.ds.project.model.Project;
|
import com.ecep.contract.ds.project.model.Project;
|
||||||
|
import com.ecep.contract.ds.project.repository.CustomerSatisfactionSurveyRepository;
|
||||||
|
import com.ecep.contract.model.Employee;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
|
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
|
||||||
@@ -33,6 +36,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "customer-satisfaction-survey")
|
@CacheConfig(cacheNames = "customer-satisfaction-survey")
|
||||||
public class CustomerSatisfactionSurveyService
|
public class CustomerSatisfactionSurveyService
|
||||||
|
extends EntityService<CustomerSatisfactionSurvey, CustomerSatisfactionSurveyVo, Integer>
|
||||||
implements IEntityService<CustomerSatisfactionSurvey>, QueryService<CustomerSatisfactionSurveyVo>,
|
implements IEntityService<CustomerSatisfactionSurvey>, QueryService<CustomerSatisfactionSurveyVo>,
|
||||||
VoableService<CustomerSatisfactionSurvey, CustomerSatisfactionSurveyVo> {
|
VoableService<CustomerSatisfactionSurvey, CustomerSatisfactionSurveyVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@@ -40,8 +44,13 @@ public class CustomerSatisfactionSurveyService
|
|||||||
private CustomerSatisfactionSurveyRepository repository;
|
private CustomerSatisfactionSurveyRepository repository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomerSatisfactionSurvey getById(Integer id) {
|
protected MyRepository<CustomerSatisfactionSurvey, Integer> getRepository() {
|
||||||
return repository.findById(id).orElse(null);
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomerSatisfactionSurvey createNewEntity() {
|
||||||
|
return new CustomerSatisfactionSurvey();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,16 +70,25 @@ public class CustomerSatisfactionSurveyService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<CustomerSatisfactionSurvey> getSearchSpecification(String searchText) {
|
protected Specification<CustomerSatisfactionSurvey> buildSearchSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.like(root.get("code"), "%" + searchText + "%");
|
return builder.like(root.get("code"), "%" + searchText + "%");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
@Override
|
||||||
|
protected Specification<CustomerSatisfactionSurvey> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<CustomerSatisfactionSurvey> spec = null;
|
||||||
|
if (paramsNode.has("project.customer")) {
|
||||||
|
int customerId = paramsNode.get("project.customer").asInt();
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||||
|
return builder.equal(root.get("project").get("customer").get("id"), customerId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "project", "applicant");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存客户满意度调查
|
* 保存客户满意度调查
|
||||||
@@ -78,6 +96,8 @@ public class CustomerSatisfactionSurveyService
|
|||||||
* @param survey 客户满意度调查实体
|
* @param survey 客户满意度调查实体
|
||||||
* @return 保存后的实体
|
* @return 保存后的实体
|
||||||
*/
|
*/
|
||||||
|
@CacheEvict(key = "#p0.id")
|
||||||
|
@Override
|
||||||
public CustomerSatisfactionSurvey save(CustomerSatisfactionSurvey survey) {
|
public CustomerSatisfactionSurvey save(CustomerSatisfactionSurvey survey) {
|
||||||
return repository.save(survey);
|
return repository.save(survey);
|
||||||
}
|
}
|
||||||
@@ -87,6 +107,8 @@ public class CustomerSatisfactionSurveyService
|
|||||||
*
|
*
|
||||||
* @param survey 客户满意度调查实体
|
* @param survey 客户满意度调查实体
|
||||||
*/
|
*/
|
||||||
|
@CacheEvict(key = "#p0.id")
|
||||||
|
@Override
|
||||||
public void delete(CustomerSatisfactionSurvey survey) {
|
public void delete(CustomerSatisfactionSurvey survey) {
|
||||||
repository.delete(survey);
|
repository.delete(survey);
|
||||||
}
|
}
|
||||||
@@ -98,9 +120,6 @@ public class CustomerSatisfactionSurveyService
|
|||||||
* @param pageable 分页参数
|
* @param pageable 分页参数
|
||||||
* @return 客户满意度调查分页列表
|
* @return 客户满意度调查分页列表
|
||||||
*/
|
*/
|
||||||
public Page<CustomerSatisfactionSurvey> findAll(Specification<CustomerSatisfactionSurvey> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件查找所有客户满意度调查
|
* 根据条件查找所有客户满意度调查
|
||||||
@@ -113,25 +132,6 @@ public class CustomerSatisfactionSurveyService
|
|||||||
return entities.stream().map(CustomerSatisfactionSurvey::toVo).toList();
|
return entities.stream().map(CustomerSatisfactionSurvey::toVo).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<CustomerSatisfactionSurveyVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<CustomerSatisfactionSurvey> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paramsNode.has("project.customer")) {
|
|
||||||
int customerId = paramsNode.get("project.customer").asInt();
|
|
||||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
|
||||||
return builder.equal(root.get("project").get("customer").get("id"), customerId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project", "applicant");
|
|
||||||
Page<CustomerSatisfactionSurvey> page = findAll(spec, pageable);
|
|
||||||
return page.map(CustomerSatisfactionSurvey::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateByVo(CustomerSatisfactionSurvey model, CustomerSatisfactionSurveyVo vo) {
|
public void updateByVo(CustomerSatisfactionSurvey model, CustomerSatisfactionSurveyVo vo) {
|
||||||
model.setCode(vo.getCode());
|
model.setCode(vo.getCode());
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ import org.springframework.data.domain.Sort;
|
|||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.project.repository.ProductDeliverySignMethodRepository;
|
import com.ecep.contract.ds.project.repository.ProductDeliverySignMethodRepository;
|
||||||
import com.ecep.contract.model.DeliverySignMethod;
|
import com.ecep.contract.model.DeliverySignMethod;
|
||||||
import com.ecep.contract.model.ProjectSaleType;
|
import com.ecep.contract.model.ProjectSaleType;
|
||||||
@@ -30,18 +32,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-sign-method")
|
@CacheConfig(cacheNames = "project-sign-method")
|
||||||
public class DeliverySignMethodService
|
public class DeliverySignMethodService extends EntityService<DeliverySignMethod, DeliverySignMethodVo, Integer>
|
||||||
implements IEntityService<DeliverySignMethod>, QueryService<DeliverySignMethodVo>,
|
implements IEntityService<DeliverySignMethod>, QueryService<DeliverySignMethodVo>,
|
||||||
VoableService<DeliverySignMethod, DeliverySignMethodVo> {
|
VoableService<DeliverySignMethod, DeliverySignMethodVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductDeliverySignMethodRepository deliverySignMethodRepository;
|
private ProductDeliverySignMethodRepository deliverySignMethodRepository;
|
||||||
|
|
||||||
@Override
|
|
||||||
public DeliverySignMethod getById(Integer id) {
|
|
||||||
return deliverySignMethodRepository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public DeliverySignMethodVo findById(Integer id) {
|
public DeliverySignMethodVo findById(Integer id) {
|
||||||
@@ -52,39 +49,20 @@ public class DeliverySignMethodService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<DeliverySignMethod> findAll(Specification<DeliverySignMethod> spec, Pageable pageable) {
|
|
||||||
return deliverySignMethodRepository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<DeliverySignMethodVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<DeliverySignMethod> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "saleType");
|
|
||||||
Page<DeliverySignMethod> page = findAll(spec, pageable);
|
|
||||||
return page.map(DeliverySignMethod::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeliverySignMethod findBySaleTypeAndName(ProjectSaleType saleType, String name) {
|
public DeliverySignMethod findBySaleTypeAndName(ProjectSaleType saleType, String name) {
|
||||||
return deliverySignMethodRepository.findBySaleTypeAndName(saleType, name).orElse(null);
|
return deliverySignMethodRepository.findBySaleTypeAndName(saleType, name).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'type-'+#p0.id+'_code-'+#p1")
|
@Cacheable(key = "'type-'+#p0.id+'_code-'+#p1")
|
||||||
public DeliverySignMethodVo findBySaleTypeAndCode(ProjectSaleType saleType, String code) {
|
public DeliverySignMethodVo findBySaleTypeAndCode(ProjectSaleType saleType, String code) {
|
||||||
return deliverySignMethodRepository.findBySaleTypeAndCode(saleType, code).map(DeliverySignMethod::toVo).orElse(null);
|
return deliverySignMethodRepository.findBySaleTypeAndCode(saleType, code).map(DeliverySignMethod::toVo)
|
||||||
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'type-'+#p0.id+'_code-'+#p1")
|
@Cacheable(key = "'type-'+#p0.id+'_code-'+#p1")
|
||||||
public DeliverySignMethodVo findBySaleTypeAndCode(ProjectSaleTypeVo saleType, String code) {
|
public DeliverySignMethodVo findBySaleTypeAndCode(ProjectSaleTypeVo saleType, String code) {
|
||||||
return deliverySignMethodRepository.findBySaleTypeIdAndCode(saleType.getId(), code).map(DeliverySignMethod::toVo).orElse(null);
|
return deliverySignMethodRepository.findBySaleTypeIdAndCode(saleType.getId(), code)
|
||||||
}
|
.map(DeliverySignMethod::toVo).orElse(null);
|
||||||
|
|
||||||
public List<DeliverySignMethod> findAll(Specification<DeliverySignMethod> spec, Sort sort) {
|
|
||||||
return deliverySignMethodRepository.findAll(spec, sort);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'all'")
|
@Cacheable(key = "'all'")
|
||||||
@@ -116,9 +94,29 @@ public class DeliverySignMethodService
|
|||||||
deliverySignMethodRepository.delete(method);
|
deliverySignMethodRepository.delete(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MyRepository<DeliverySignMethod, Integer> getRepository() {
|
||||||
|
return deliverySignMethodRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeliverySignMethod createNewEntity() {
|
||||||
|
return new DeliverySignMethod();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<DeliverySignMethod> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.or(
|
||||||
|
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<DeliverySignMethod> getSearchSpecification(String searchText) {
|
public Specification<DeliverySignMethod> getSearchSpecification(String searchText) {
|
||||||
return null;
|
return super.getSearchSpecification(searchText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -142,4 +140,11 @@ public class DeliverySignMethodService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<DeliverySignMethod> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<DeliverySignMethod> spec = null;
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "saleType");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,16 +8,15 @@ import org.springframework.cache.annotation.CacheEvict;
|
|||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.project.repository.ProductTypeRepository;
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.project.model.ProductType;
|
import com.ecep.contract.ds.project.model.ProductType;
|
||||||
|
import com.ecep.contract.ds.project.repository.ProductTypeRepository;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
import com.ecep.contract.vo.ProductTypeVo;
|
import com.ecep.contract.vo.ProductTypeVo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
@@ -25,17 +24,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "product-type")
|
@CacheConfig(cacheNames = "product-type")
|
||||||
public class ProductTypeService implements IEntityService<ProductType>, QueryService<ProductTypeVo>,
|
public class ProductTypeService extends EntityService<ProductType, ProductTypeVo, Integer>
|
||||||
|
implements IEntityService<ProductType>, QueryService<ProductTypeVo>,
|
||||||
VoableService<ProductType, ProductTypeVo> {
|
VoableService<ProductType, ProductTypeVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductTypeRepository productTypeRepository;
|
private ProductTypeRepository productTypeRepository;
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProductType getById(Integer id) {
|
|
||||||
return productTypeRepository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public ProductTypeVo findById(Integer id) {
|
public ProductTypeVo findById(Integer id) {
|
||||||
@@ -58,26 +53,17 @@ public class ProductTypeService implements IEntityService<ProductType>, QuerySer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProductType> findAll(Specification<ProductType> spec, Pageable pageable) {
|
protected MyRepository<ProductType, Integer> getRepository() {
|
||||||
return productTypeRepository.findAll(spec, pageable);
|
return productTypeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProductTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
public ProductType createNewEntity() {
|
||||||
Specification<ProductType> spec = null;
|
return new ProductType();
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
|
||||||
return findAll(spec, pageable).map(ProductType::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<ProductType> getSearchSpecification(String searchText) {
|
protected Specification<ProductType> buildSearchSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
@@ -115,4 +101,9 @@ public class ProductTypeService implements IEntityService<ProductType>, QuerySer
|
|||||||
model.setName(vo.getName());
|
model.setName(vo.getName());
|
||||||
model.setCode(vo.getCode());
|
model.setCode(vo.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProductType> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.project.repository.ProductUsageRepository;
|
import com.ecep.contract.ds.project.repository.ProductUsageRepository;
|
||||||
import com.ecep.contract.ds.project.model.ProductUsage;
|
import com.ecep.contract.ds.project.model.ProductUsage;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
@@ -25,17 +27,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "product-usage")
|
@CacheConfig(cacheNames = "product-usage")
|
||||||
public class ProductUsageService implements IEntityService<ProductUsage>, QueryService<ProductUsageVo>,
|
public class ProductUsageService extends EntityService<ProductUsage, ProductUsageVo, Integer>
|
||||||
|
implements IEntityService<ProductUsage>, QueryService<ProductUsageVo>,
|
||||||
VoableService<ProductUsage, ProductUsageVo> {
|
VoableService<ProductUsage, ProductUsageVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductUsageRepository productUsageRepository;
|
private ProductUsageRepository productUsageRepository;
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProductUsage getById(Integer id) {
|
|
||||||
return productUsageRepository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public ProductUsageVo findById(Integer id) {
|
public ProductUsageVo findById(Integer id) {
|
||||||
@@ -70,27 +68,17 @@ public class ProductUsageService implements IEntityService<ProductUsage>, QueryS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProductUsage> findAll(Specification<ProductUsage> spec, Pageable pageable) {
|
protected MyRepository<ProductUsage, Integer> getRepository() {
|
||||||
return productUsageRepository.findAll(spec, pageable);
|
return productUsageRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProductUsageVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
public ProductUsage createNewEntity() {
|
||||||
Specification<ProductUsage> spec = null;
|
return new ProductUsage();
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
|
||||||
Page<ProductUsage> page = findAll(spec, pageable);
|
|
||||||
return page.map(ProductUsage::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<ProductUsage> getSearchSpecification(String searchText) {
|
protected Specification<ProductUsage> buildSearchSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.like(root.get("name"), "%" + searchText + "%");
|
return builder.like(root.get("name"), "%" + searchText + "%");
|
||||||
};
|
};
|
||||||
@@ -124,4 +112,9 @@ public class ProductUsageService implements IEntityService<ProductUsage>, QueryS
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProductUsage> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEvaluationFormFileService;
|
import com.ecep.contract.ds.customer.service.CompanyCustomerEvaluationFormFileService;
|
||||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||||
import com.ecep.contract.ds.project.repository.ProjectBidRepository;
|
import com.ecep.contract.ds.project.repository.ProjectBidRepository;
|
||||||
@@ -31,17 +33,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-bid")
|
@CacheConfig(cacheNames = "project-bid")
|
||||||
public class ProjectBidService implements IEntityService<ProjectBid>, QueryService<ProjectBidVo>,
|
public class ProjectBidService extends EntityService<ProjectBid, ProjectBidVo, Integer>
|
||||||
|
implements IEntityService<ProjectBid>, QueryService<ProjectBidVo>,
|
||||||
VoableService<ProjectBid, ProjectBidVo> {
|
VoableService<ProjectBid, ProjectBidVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectBidRepository repository;
|
private ProjectBidRepository repository;
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProjectBid getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public ProjectBidVo findById(Integer id) {
|
public ProjectBidVo findById(Integer id) {
|
||||||
@@ -53,35 +51,17 @@ public class ProjectBidService implements IEntityService<ProjectBid>, QueryServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectBid> findAll(Specification<ProjectBid> spec, Pageable pageable) {
|
protected MyRepository<ProjectBid, Integer> getRepository() {
|
||||||
return repository.findAll(spec, pageable);
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectBidVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
public ProjectBid createNewEntity() {
|
||||||
Specification<ProjectBid> spec = null;
|
return new ProjectBid();
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project");
|
|
||||||
|
|
||||||
if (paramsNode.has("project.customer")) {
|
|
||||||
Integer customerId = paramsNode.get("project.customer").asInt();
|
|
||||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
|
||||||
return builder.equal(root.get("project").get("customer").get("id"), customerId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Page<ProjectBid> page = findAll(spec, pageable);
|
|
||||||
return page.map(ProjectBid::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<ProjectBid> getSearchSpecification(String searchText) {
|
protected Specification<ProjectBid> buildSearchSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
@@ -135,7 +115,7 @@ public class ProjectBidService implements IEntityService<ProjectBid>, QueryServi
|
|||||||
if (vo.getEvaluationFileId() != null) {
|
if (vo.getEvaluationFileId() != null) {
|
||||||
CompanyCustomerEvaluationFormFileService evaluationFileService = SpringApp
|
CompanyCustomerEvaluationFormFileService evaluationFileService = SpringApp
|
||||||
.getBean(CompanyCustomerEvaluationFormFileService.class);
|
.getBean(CompanyCustomerEvaluationFormFileService.class);
|
||||||
model.setEvaluationFile(evaluationFileService.findById(vo.getEvaluationFileId()));
|
model.setEvaluationFile(evaluationFileService.getById(vo.getEvaluationFileId()));
|
||||||
} else {
|
} else {
|
||||||
model.setEvaluationFile(null);
|
model.setEvaluationFile(null);
|
||||||
}
|
}
|
||||||
@@ -164,4 +144,23 @@ public class ProjectBidService implements IEntityService<ProjectBid>, QueryServi
|
|||||||
public List<ProjectBid> findAllByProject(Project project) {
|
public List<ProjectBid> findAllByProject(Project project) {
|
||||||
return repository.findAllByProject(project);
|
return repository.findAllByProject(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectBid> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<ProjectBid> spec = null;
|
||||||
|
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||||
|
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "project");
|
||||||
|
|
||||||
|
if (paramsNode.has("project.customer")) {
|
||||||
|
Integer customerId = paramsNode.get("project.customer").asInt();
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||||
|
return builder.equal(root.get("project").get("customer").get("id"), customerId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.other.service.InventoryService;
|
import com.ecep.contract.ds.other.service.InventoryService;
|
||||||
import com.ecep.contract.ds.project.repository.ProjectCostItemRepository;
|
import com.ecep.contract.ds.project.repository.ProjectCostItemRepository;
|
||||||
import com.ecep.contract.ds.project.model.ProjectCost;
|
import com.ecep.contract.ds.project.model.ProjectCost;
|
||||||
@@ -30,17 +32,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-cost-item")
|
@CacheConfig(cacheNames = "project-cost-item")
|
||||||
public class ProjectCostItemService implements IEntityService<ProjectCostItem>, QueryService<ProjectCostItemVo>,
|
public class ProjectCostItemService extends EntityService<ProjectCostItem, ProjectCostItemVo, Integer>
|
||||||
|
implements IEntityService<ProjectCostItem>, QueryService<ProjectCostItemVo>,
|
||||||
VoableService<ProjectCostItem, ProjectCostItemVo> {
|
VoableService<ProjectCostItem, ProjectCostItemVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectCostItemRepository repository;
|
private ProjectCostItemRepository repository;
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProjectCostItem getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public ProjectCostItemVo findById(Integer id) {
|
public ProjectCostItemVo findById(Integer id) {
|
||||||
@@ -52,49 +50,38 @@ public class ProjectCostItemService implements IEntityService<ProjectCostItem>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectCostItem> findAll(Specification<ProjectCostItem> spec, Pageable pageable) {
|
protected MyRepository<ProjectCostItem, Integer> getRepository() {
|
||||||
return repository.findAll(spec, pageable);
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectCostItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
public ProjectCostItem createNewEntity() {
|
||||||
Specification<ProjectCostItem> spec = null;
|
return new ProjectCostItem();
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "cost");
|
|
||||||
|
|
||||||
Page<ProjectCostItem> page = findAll(spec, pageable);
|
|
||||||
return page.map(ProjectCostItem::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<ProjectCostItem> getSearchSpecification(String searchText) {
|
protected Specification<ProjectCostItem> buildSearchSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
builder.like(root.get("name"), "%" + searchText + "%")
|
builder.like(root.get("name"), "%" + searchText + "%"));
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public ProjectCostItem save(ProjectCostItem item) {
|
public ProjectCostItem save(ProjectCostItem item) {
|
||||||
return repository.save(item);
|
return super.save(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public void delete(ProjectCostItem item) {
|
public void delete(ProjectCostItem item) {
|
||||||
repository.delete(item);
|
super.delete(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProjectCostItem> findByCostId(Integer costId) {
|
public List<ProjectCostItem> findByCostId(Integer costId) {
|
||||||
@@ -131,4 +118,12 @@ public class ProjectCostItemService implements IEntityService<ProjectCostItem>,
|
|||||||
model.setInventory(null);
|
model.setInventory(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectCostItem> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<ProjectCostItem> spec = null;
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "cost");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,11 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.project.repository.ProjectCostRepository;
|
import com.ecep.contract.ds.project.repository.ProjectCostRepository;
|
||||||
import com.ecep.contract.ds.project.model.Project;
|
import com.ecep.contract.ds.project.model.Project;
|
||||||
import com.ecep.contract.ds.project.model.ProjectCost;
|
import com.ecep.contract.ds.project.model.ProjectCost;
|
||||||
@@ -32,17 +34,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-cost")
|
@CacheConfig(cacheNames = "project-cost")
|
||||||
public class ProjectCostService implements IEntityService<ProjectCost>, QueryService<ProjectCostVo>,
|
public class ProjectCostService extends EntityService<ProjectCost, ProjectCostVo, Integer>
|
||||||
|
implements IEntityService<ProjectCost>, QueryService<ProjectCostVo>,
|
||||||
VoableService<ProjectCost, ProjectCostVo> {
|
VoableService<ProjectCost, ProjectCostVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectCostRepository repository;
|
private ProjectCostRepository repository;
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProjectCost getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public ProjectCostVo findById(Integer id) {
|
public ProjectCostVo findById(Integer id) {
|
||||||
@@ -54,35 +52,17 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectCost> findAll(Specification<ProjectCost> spec, Pageable pageable) {
|
protected MyRepository<ProjectCost, Integer> getRepository() {
|
||||||
return repository.findAll(spec, pageable);
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectCostVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
public ProjectCost createNewEntity() {
|
||||||
Specification<ProjectCost> spec = null;
|
return new ProjectCost();
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project");
|
|
||||||
|
|
||||||
if (paramsNode.has("project.customer")) {
|
|
||||||
Integer customerId = paramsNode.get("project.customer").asInt();
|
|
||||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
|
||||||
return builder.equal(root.get("project").get("customer").get("id"), customerId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Page<ProjectCost> page = findAll(spec, pageable);
|
|
||||||
return page.map(ProjectCost::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<ProjectCost> getSearchSpecification(String searchText) {
|
protected Specification<ProjectCost> buildSearchSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
@@ -93,15 +73,17 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
|
|||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public ProjectCost save(ProjectCost cost) {
|
public ProjectCost save(ProjectCost cost) {
|
||||||
return repository.save(cost);
|
return super.save(cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public void delete(ProjectCost cost) {
|
public void delete(ProjectCost cost) {
|
||||||
repository.delete(cost);
|
super.delete(cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProjectCost> findByProject(Project project) {
|
public List<ProjectCost> findByProject(Project project) {
|
||||||
@@ -151,7 +133,6 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
|
|||||||
model.setOutExclusiveTaxAmount(vo.getOutExclusiveTaxAmount());
|
model.setOutExclusiveTaxAmount(vo.getOutExclusiveTaxAmount());
|
||||||
model.setGrossProfitMargin(vo.getGrossProfitMargin());
|
model.setGrossProfitMargin(vo.getGrossProfitMargin());
|
||||||
|
|
||||||
|
|
||||||
if (vo.getProject() == null) {
|
if (vo.getProject() == null) {
|
||||||
model.setProject(null);
|
model.setProject(null);
|
||||||
} else {
|
} else {
|
||||||
@@ -181,4 +162,23 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
|
|||||||
model.setAuthorizationTime(vo.getAuthorizationTime());
|
model.setAuthorizationTime(vo.getAuthorizationTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectCost> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<ProjectCost> spec = null;
|
||||||
|
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||||
|
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "project");
|
||||||
|
|
||||||
|
if (paramsNode.has("project.customer")) {
|
||||||
|
Integer customerId = paramsNode.get("project.customer").asInt();
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||||
|
return builder.equal(root.get("project").get("customer").get("id"), customerId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,18 +9,17 @@ import org.springframework.cache.annotation.CacheEvict;
|
|||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.ProjectFileType;
|
import com.ecep.contract.ProjectFileType;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.project.repository.ProjectFileRepository;
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.project.model.Project;
|
import com.ecep.contract.ds.project.model.Project;
|
||||||
import com.ecep.contract.ds.project.model.ProjectFile;
|
import com.ecep.contract.ds.project.model.ProjectFile;
|
||||||
|
import com.ecep.contract.ds.project.repository.ProjectFileRepository;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.ProjectFileVo;
|
import com.ecep.contract.vo.ProjectFileVo;
|
||||||
@@ -29,20 +28,16 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-file")
|
@CacheConfig(cacheNames = "project-file")
|
||||||
public class ProjectFileService implements IEntityService<ProjectFile>, QueryService<ProjectFileVo>, VoableService<ProjectFile, ProjectFileVo> {
|
public class ProjectFileService extends EntityService<ProjectFile, ProjectFileVo, Integer>
|
||||||
|
implements IEntityService<ProjectFile>, QueryService<ProjectFileVo>, VoableService<ProjectFile, ProjectFileVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectFileRepository repository;
|
private ProjectFileRepository repository;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectService projectService;
|
private ProjectService projectService;
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProjectFile getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public ProjectFileVo findById(Integer id) {
|
public ProjectFileVo findById(Integer id) {
|
||||||
@@ -54,58 +49,36 @@ public class ProjectFileService implements IEntityService<ProjectFile>, QuerySer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectFileVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
protected MyRepository<ProjectFile, Integer> getRepository() {
|
||||||
// 构建查询规范
|
return repository;
|
||||||
Specification<ProjectFile> spec = getSpecification(paramsNode);
|
|
||||||
// 查询实体列表
|
|
||||||
Page<ProjectFile> entityPage = findAll(spec, pageable);
|
|
||||||
// 转换为VO列表
|
|
||||||
return entityPage.map(ProjectFile::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectFile> findAll(Specification<ProjectFile> spec, Pageable pageable) {
|
public ProjectFile createNewEntity() {
|
||||||
return repository.findAll(spec, pageable);
|
return new ProjectFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<ProjectFile> getSearchSpecification(String searchText) {
|
protected Specification<ProjectFile> buildSearchSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.like(root.get("filePath"), "%" + searchText + "%");
|
return builder.like(root.get("filePath"), "%" + searchText + "%");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Caching(evict = {
|
||||||
public List<ProjectFile> search(String searchText) {
|
@CacheEvict(key = "#p0.id"),
|
||||||
Specification<ProjectFile> spec = getSearchSpecification(searchText);
|
})
|
||||||
return repository.findAll(spec);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(ProjectFile entity) {
|
|
||||||
repository.delete(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectFile save(ProjectFile entity) {
|
public ProjectFile save(ProjectFile entity) {
|
||||||
return repository.save(entity);
|
return super.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
})
|
})
|
||||||
public ProjectFile saveFile(ProjectFile file) {
|
@Override
|
||||||
return repository.save(file);
|
public void delete(ProjectFile entity) {
|
||||||
}
|
super.delete(entity);
|
||||||
|
|
||||||
@Caching(evict = {
|
|
||||||
@CacheEvict(key = "#p0.id"),
|
|
||||||
})
|
|
||||||
public void deleteFile(ProjectFile file) {
|
|
||||||
repository.delete(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据项目查询文件列表
|
// 根据项目查询文件列表
|
||||||
@@ -121,27 +94,18 @@ public class ProjectFileService implements IEntityService<ProjectFile>, QuerySer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 构建查询规范
|
// 构建查询规范
|
||||||
private Specification<ProjectFile> getSpecification(JsonNode paramsNode) {
|
@Override
|
||||||
|
protected Specification<ProjectFile> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
Specification<ProjectFile> spec = null;
|
Specification<ProjectFile> spec = null;
|
||||||
|
|
||||||
// 根据参数构建查询条件
|
// 根据参数构建查询条件
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "id");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "id");
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "projectId");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "projectId");
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "type");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "type");
|
||||||
|
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计数方法实现
|
|
||||||
@Override
|
|
||||||
public long count(JsonNode paramsNode) {
|
|
||||||
Specification<ProjectFile> spec = getSpecification(paramsNode);
|
|
||||||
if (spec != null) {
|
|
||||||
return repository.count(spec);
|
|
||||||
}
|
|
||||||
return repository.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateByVo(ProjectFile model, ProjectFileVo vo) {
|
public void updateByVo(ProjectFile model, ProjectFileVo vo) {
|
||||||
// 更新文件类型
|
// 更新文件类型
|
||||||
@@ -150,7 +114,7 @@ public class ProjectFileService implements IEntityService<ProjectFile>, QuerySer
|
|||||||
model.setFilePath(vo.getFilePath());
|
model.setFilePath(vo.getFilePath());
|
||||||
// 更新项目关联
|
// 更新项目关联
|
||||||
if (vo.getProjectId() != null) {
|
if (vo.getProjectId() != null) {
|
||||||
|
|
||||||
model.setProject(projectService.getById(vo.getProjectId()));
|
model.setProject(projectService.getById(vo.getProjectId()));
|
||||||
} else {
|
} else {
|
||||||
model.setProject(null);
|
model.setProject(null);
|
||||||
|
|||||||
@@ -3,22 +3,20 @@ package com.ecep.contract.ds.project.service;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ecep.contract.constant.ParamConstant;
|
|
||||||
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.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.ProjectFileType;
|
import com.ecep.contract.ProjectFileType;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.project.repository.ProjectFileTypeLocalRepository;
|
import com.ecep.contract.ds.project.repository.ProjectFileTypeLocalRepository;
|
||||||
import com.ecep.contract.model.ProjectFileTypeLocal;
|
import com.ecep.contract.model.ProjectFileTypeLocal;
|
||||||
import com.ecep.contract.service.ServiceException;
|
import com.ecep.contract.service.ServiceException;
|
||||||
@@ -30,7 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-file-type")
|
@CacheConfig(cacheNames = "project-file-type")
|
||||||
public class ProjectFileTypeService
|
public class ProjectFileTypeService extends EntityService<ProjectFileTypeLocal, ProjectFileTypeLocalVo, Integer>
|
||||||
implements IEntityService<ProjectFileTypeLocal>, QueryService<ProjectFileTypeLocalVo>,
|
implements IEntityService<ProjectFileTypeLocal>, QueryService<ProjectFileTypeLocalVo>,
|
||||||
VoableService<ProjectFileTypeLocal, ProjectFileTypeLocalVo> {
|
VoableService<ProjectFileTypeLocal, ProjectFileTypeLocalVo> {
|
||||||
|
|
||||||
@@ -38,37 +36,11 @@ public class ProjectFileTypeService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ProjectFileTypeLocalRepository repository;
|
private ProjectFileTypeLocalRepository repository;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ProjectFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<ProjectFileTypeLocal> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paramsNode.has("type")) {
|
|
||||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"),
|
|
||||||
ProjectFileType.valueOf(paramsNode.get("type").asText())));
|
|
||||||
}
|
|
||||||
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
|
||||||
return findAll(spec, pageable).map(ProjectFileTypeLocal::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectFileTypeLocalVo findById(Integer id) {
|
public ProjectFileTypeLocalVo findById(Integer id) {
|
||||||
return repository.findById(id).map(ProjectFileTypeLocal::toVo).orElse(null);
|
return repository.findById(id).map(ProjectFileTypeLocal::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectFileTypeLocal getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ProjectFileTypeLocal> findAll(Specification<ProjectFileTypeLocal> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||||
public Map<ProjectFileType, ProjectFileTypeLocalVo> findAll(Locale locale) {
|
public Map<ProjectFileType, ProjectFileTypeLocalVo> findAll(Locale locale) {
|
||||||
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
||||||
@@ -77,20 +49,6 @@ public class ProjectFileTypeService
|
|||||||
entry -> entry.getValue().toVo()));
|
entry -> entry.getValue().toVo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<ProjectFileTypeLocal> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
|
||||||
return
|
|
||||||
// builder.or(
|
|
||||||
builder.like(root.get("type"), "%" + searchText + "%")
|
|
||||||
// )
|
|
||||||
;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'all-'+#p0.getLang()")
|
@CacheEvict(key = "'all-'+#p0.getLang()")
|
||||||
@@ -122,4 +80,37 @@ public class ProjectFileTypeService
|
|||||||
entity.setLang(vo.getLang());
|
entity.setLang(vo.getLang());
|
||||||
entity.setValue(vo.getValue());
|
entity.setValue(vo.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MyRepository<ProjectFileTypeLocal, Integer> getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProjectFileTypeLocal createNewEntity() {
|
||||||
|
return new ProjectFileTypeLocal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectFileTypeLocal> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<ProjectFileTypeLocal> spec = null;
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"),
|
||||||
|
ProjectFileType.valueOf(paramsNode.get("type").asText())));
|
||||||
|
}
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectFileTypeLocal> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return
|
||||||
|
// builder.or(
|
||||||
|
builder.like(root.get("type"), "%" + searchText + "%")
|
||||||
|
// )
|
||||||
|
;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -13,16 +13,16 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
import com.ecep.contract.ds.contract.service.ContractPayPlanService;
|
|
||||||
import com.ecep.contract.ds.project.repository.ProjectFundPlanRepository;
|
|
||||||
import com.ecep.contract.ds.contract.model.ContractPayPlan;
|
import com.ecep.contract.ds.contract.model.ContractPayPlan;
|
||||||
|
import com.ecep.contract.ds.contract.service.ContractPayPlanService;
|
||||||
import com.ecep.contract.ds.project.model.Project;
|
import com.ecep.contract.ds.project.model.Project;
|
||||||
import com.ecep.contract.ds.project.model.ProjectFundPlan;
|
import com.ecep.contract.ds.project.model.ProjectFundPlan;
|
||||||
|
import com.ecep.contract.ds.project.repository.ProjectFundPlanRepository;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.ProjectFundPlanVo;
|
import com.ecep.contract.vo.ProjectFundPlanVo;
|
||||||
@@ -31,17 +31,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-fund-plan")
|
@CacheConfig(cacheNames = "project-fund-plan")
|
||||||
public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>, QueryService<ProjectFundPlanVo>,
|
public class ProjectFundPlanService extends EntityService<ProjectFundPlan, ProjectFundPlanVo, Integer>
|
||||||
|
implements IEntityService<ProjectFundPlan>, QueryService<ProjectFundPlanVo>,
|
||||||
VoableService<ProjectFundPlan, ProjectFundPlanVo> {
|
VoableService<ProjectFundPlan, ProjectFundPlanVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectFundPlanRepository repository;
|
private ProjectFundPlanRepository repository;
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProjectFundPlan getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public ProjectFundPlanVo findById(Integer id) {
|
public ProjectFundPlanVo findById(Integer id) {
|
||||||
@@ -52,36 +48,10 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ProjectFundPlan> findAll(Specification<ProjectFundPlan> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ProjectFundPlanVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<ProjectFundPlan> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project");
|
|
||||||
Page<ProjectFundPlan> page = findAll(spec, pageable);
|
|
||||||
return page.map(ProjectFundPlan::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<ProjectFundPlan> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
|
||||||
return builder.like(root.get("description"), "%" + searchText + "%");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public ProjectFundPlan save(ProjectFundPlan fundPlan) {
|
public ProjectFundPlan save(ProjectFundPlan fundPlan) {
|
||||||
return repository.save(fundPlan);
|
return repository.save(fundPlan);
|
||||||
}
|
}
|
||||||
@@ -89,10 +59,35 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
|
|||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public void delete(ProjectFundPlan fundPlan) {
|
public void delete(ProjectFundPlan fundPlan) {
|
||||||
repository.delete(fundPlan);
|
repository.delete(fundPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ProjectFundPlanRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProjectFundPlan createNewEntity() {
|
||||||
|
return new ProjectFundPlan();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectFundPlan> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<ProjectFundPlan> spec = null;
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "project");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectFundPlan> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.like(root.get("description"), "%" + searchText + "%");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public List<ProjectFundPlan> findByProject(Project project) {
|
public List<ProjectFundPlan> findByProject(Project project) {
|
||||||
return repository.findAllByProject(project);
|
return repository.findAllByProject(project);
|
||||||
}
|
}
|
||||||
@@ -105,10 +100,10 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
|
|||||||
// 转换为BigDecimal
|
// 转换为BigDecimal
|
||||||
return BigDecimal.valueOf(plans.stream().mapToDouble(ProjectFundPlan::getPayCurrency).sum());
|
return BigDecimal.valueOf(plans.stream().mapToDouble(ProjectFundPlan::getPayCurrency).sum());
|
||||||
// return plans.stream()
|
// return plans.stream()
|
||||||
// .map(ProjectFundPlan::getAmount)
|
// .map(ProjectFundPlan::getAmount)
|
||||||
// .filter(Optional::isPresent)
|
// .filter(Optional::isPresent)
|
||||||
// .map(Optional::get)
|
// .map(Optional::get)
|
||||||
// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -124,15 +119,16 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
|
|||||||
|
|
||||||
// 处理关联实体
|
// 处理关联实体
|
||||||
if (vo.getContractPayPlanId() != null) {
|
if (vo.getContractPayPlanId() != null) {
|
||||||
ContractPayPlan contractPayPlan = SpringApp.getBean(ContractPayPlanService.class).getById(vo.getContractPayPlanId());
|
ContractPayPlan contractPayPlan = SpringApp.getBean(ContractPayPlanService.class)
|
||||||
|
.getById(vo.getContractPayPlanId());
|
||||||
model.setContractPayPlan(contractPayPlan);
|
model.setContractPayPlan(contractPayPlan);
|
||||||
}else{
|
} else {
|
||||||
model.setContractPayPlan(null);
|
model.setContractPayPlan(null);
|
||||||
}
|
}
|
||||||
if (vo.getProjectId() != null) {
|
if (vo.getProjectId() != null) {
|
||||||
Project project = SpringApp.getBean(ProjectService.class).getById(vo.getProjectId());
|
Project project = SpringApp.getBean(ProjectService.class).getById(vo.getProjectId());
|
||||||
model.setProject(project);
|
model.setProject(project);
|
||||||
}else{
|
} else {
|
||||||
model.setProject(null);
|
model.setProject(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,40 +2,38 @@ package com.ecep.contract.ds.project.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ecep.contract.QueryService;
|
|
||||||
import com.ecep.contract.constant.ParamConstant;
|
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
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.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.ds.project.repository.ProjectIndustryRepository;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.project.model.ProjectIndustry;
|
import com.ecep.contract.ds.project.model.ProjectIndustry;
|
||||||
|
import com.ecep.contract.ds.project.repository.ProjectIndustryRepository;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.ProjectIndustryVo;
|
import com.ecep.contract.vo.ProjectIndustryVo;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-industry")
|
@CacheConfig(cacheNames = "project-industry")
|
||||||
public class ProjectIndustryService implements IEntityService<ProjectIndustry>, QueryService<ProjectIndustryVo>,
|
public class ProjectIndustryService extends EntityService<ProjectIndustry, ProjectIndustryVo, Integer>
|
||||||
|
implements IEntityService<ProjectIndustry>, QueryService<ProjectIndustryVo>,
|
||||||
VoableService<ProjectIndustry, ProjectIndustryVo> {
|
VoableService<ProjectIndustry, ProjectIndustryVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectIndustryRepository repository;
|
private ProjectIndustryRepository repository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectIndustry getById(Integer id) {
|
protected ProjectIndustryRepository getRepository() {
|
||||||
return repository.findById(id).orElse(null);
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@@ -72,34 +70,6 @@ public class ProjectIndustryService implements IEntityService<ProjectIndustry>,
|
|||||||
return industries.stream().map(ProjectIndustry::toVo).toList();
|
return industries.stream().map(ProjectIndustry::toVo).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<ProjectIndustry> findAll(Specification<ProjectIndustry> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ProjectIndustryVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<ProjectIndustry> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code", "name");
|
|
||||||
Page<ProjectIndustry> page = findAll(spec, pageable);
|
|
||||||
return page.map(ProjectIndustry::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<ProjectIndustry> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
|
||||||
return builder.or(
|
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
|
||||||
builder.like(root.get("name"), "%" + searchText + "%"));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'code-'+#p0.code"),
|
@CacheEvict(key = "'code-'+#p0.code"),
|
||||||
@@ -126,4 +96,25 @@ public class ProjectIndustryService implements IEntityService<ProjectIndustry>,
|
|||||||
model.setCode(vo.getCode());
|
model.setCode(vo.getCode());
|
||||||
model.setDescription(vo.getDescription());
|
model.setDescription(vo.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProjectIndustry createNewEntity() {
|
||||||
|
return new ProjectIndustry();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectIndustry> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<ProjectIndustry> spec = null;
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code", "name");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectIndustry> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.or(
|
||||||
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("name"), "%" + searchText + "%"));
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -16,15 +17,17 @@ import org.springframework.data.domain.Sort;
|
|||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEvaluationFormFileService;
|
import com.ecep.contract.ds.customer.service.CompanyCustomerEvaluationFormFileService;
|
||||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||||
import com.ecep.contract.ds.project.repository.ProjectQuotationRepository;
|
|
||||||
import com.ecep.contract.model.Employee;
|
|
||||||
import com.ecep.contract.ds.project.model.Project;
|
import com.ecep.contract.ds.project.model.Project;
|
||||||
import com.ecep.contract.ds.project.model.ProjectQuotation;
|
import com.ecep.contract.ds.project.model.ProjectQuotation;
|
||||||
|
import com.ecep.contract.ds.project.repository.ProjectQuotationRepository;
|
||||||
|
import com.ecep.contract.model.Employee;
|
||||||
import com.ecep.contract.service.ServiceException;
|
import com.ecep.contract.service.ServiceException;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
@@ -34,7 +37,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-quotation")
|
@CacheConfig(cacheNames = "project-quotation")
|
||||||
public class ProjectQuotationService implements IEntityService<ProjectQuotation>, QueryService<ProjectQuotationVo>,
|
public class ProjectQuotationService extends EntityService<ProjectQuotation, ProjectQuotationVo, Integer>
|
||||||
|
implements IEntityService<ProjectQuotation>, QueryService<ProjectQuotationVo>,
|
||||||
VoableService<ProjectQuotation, ProjectQuotationVo> {
|
VoableService<ProjectQuotation, ProjectQuotationVo> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ProjectQuotationService.class);
|
private static final Logger logger = LoggerFactory.getLogger(ProjectQuotationService.class);
|
||||||
|
|
||||||
@@ -43,8 +47,8 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
|||||||
private ProjectQuotationRepository repository;
|
private ProjectQuotationRepository repository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectQuotation getById(Integer id) {
|
protected ProjectQuotationRepository getRepository() {
|
||||||
return repository.findById(id).orElse(null);
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@@ -56,39 +60,36 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 实现QueryService接口的findAll方法
|
|
||||||
@Override
|
|
||||||
public Page<ProjectQuotationVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<ProjectQuotation> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project", "applicant", "authorizer");
|
|
||||||
return findAll(spec, pageable).map(ProjectQuotation::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 实现IEntityService接口的findAll方法
|
|
||||||
@Override
|
|
||||||
public Page<ProjectQuotation> findAll(Specification<ProjectQuotation> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ProjectQuotation> findAllByProject(Project project) {
|
public List<ProjectQuotation> findAllByProject(Project project) {
|
||||||
return repository.findAllByProject(project);
|
return repository.findAllByProject(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectQuotation save(ProjectQuotation approval) {
|
@Override
|
||||||
return repository.save(approval);
|
public ProjectQuotation createNewEntity() {
|
||||||
|
return new ProjectQuotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<ProjectQuotation> getSearchSpecification(String searchText) {
|
protected Specification<ProjectQuotation> buildSearchSpecification(String searchText) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(ProjectQuotation approval) {
|
@Override
|
||||||
repository.delete(approval);
|
protected Specification<ProjectQuotation> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@CacheEvict(key = "#p0.id")
|
||||||
|
@Override
|
||||||
|
public ProjectQuotation save(ProjectQuotation entity) {
|
||||||
|
return repository.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@CacheEvict(key = "#p0.id")
|
||||||
|
@Override
|
||||||
|
public void delete(ProjectQuotation entity) {
|
||||||
|
repository.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectQuotation newInstanceByProject(Project project) {
|
public ProjectQuotation newInstanceByProject(Project project) {
|
||||||
@@ -100,10 +101,6 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
|||||||
return approval;
|
return approval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProjectQuotation> findAll(Specification<ProjectQuotation> spec, Sort sort) {
|
|
||||||
return repository.findAll(spec, sort);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateByVo(ProjectQuotation entity, ProjectQuotationVo vo) {
|
public void updateByVo(ProjectQuotation entity, ProjectQuotationVo vo) {
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
@@ -160,4 +157,5 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
|||||||
entity.setEvaluationFile(null);
|
entity.setEvaluationFile(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,35 +2,33 @@ package com.ecep.contract.ds.project.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
|
||||||
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.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
|
|
||||||
import com.ecep.contract.ContractFileType;
|
import com.ecep.contract.ContractFileType;
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
import com.ecep.contract.ds.project.repository.ProjectSaleTypeRequireFileTypeRepository;
|
import com.ecep.contract.ds.project.repository.ProjectSaleTypeRequireFileTypeRepository;
|
||||||
import com.ecep.contract.ds.project.service.ProjectSaleTypeService;
|
|
||||||
import com.ecep.contract.model.ProjectSaleType;
|
import com.ecep.contract.model.ProjectSaleType;
|
||||||
import com.ecep.contract.model.ProjectSaleTypeRequireFileType;
|
import com.ecep.contract.model.ProjectSaleTypeRequireFileType;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
|
||||||
import com.ecep.contract.vo.ProjectSaleTypeRequireFileTypeVo;
|
import com.ecep.contract.vo.ProjectSaleTypeRequireFileTypeVo;
|
||||||
|
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-sale-type-require-file-type")
|
@CacheConfig(cacheNames = "project-sale-type-require-file-type")
|
||||||
public class ProjectSaleTypeRequireFileTypeService
|
public class ProjectSaleTypeRequireFileTypeService
|
||||||
|
extends EntityService<ProjectSaleTypeRequireFileType, ProjectSaleTypeRequireFileTypeVo, Integer>
|
||||||
implements IEntityService<ProjectSaleTypeRequireFileType>, QueryService<ProjectSaleTypeRequireFileTypeVo>,
|
implements IEntityService<ProjectSaleTypeRequireFileType>, QueryService<ProjectSaleTypeRequireFileTypeVo>,
|
||||||
VoableService<ProjectSaleTypeRequireFileType, ProjectSaleTypeRequireFileTypeVo> {
|
VoableService<ProjectSaleTypeRequireFileType, ProjectSaleTypeRequireFileTypeVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@@ -38,8 +36,8 @@ public class ProjectSaleTypeRequireFileTypeService
|
|||||||
private ProjectSaleTypeRequireFileTypeRepository repository;
|
private ProjectSaleTypeRequireFileTypeRepository repository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectSaleTypeRequireFileType getById(Integer id) {
|
protected ProjectSaleTypeRequireFileTypeRepository getRepository() {
|
||||||
return repository.findById(id).orElse(null);
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@@ -47,15 +45,10 @@ public class ProjectSaleTypeRequireFileTypeService
|
|||||||
return repository.findById(id).map(ProjectSaleTypeRequireFileType::toVo).orElse(null);
|
return repository.findById(id).map(ProjectSaleTypeRequireFileType::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ProjectSaleTypeRequireFileType> findAll(Specification<ProjectSaleTypeRequireFileType> spec,
|
|
||||||
Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "'bySaleType-'+#p0")
|
@Cacheable(key = "'bySaleType-'+#p0")
|
||||||
public List<ProjectSaleTypeRequireFileTypeVo> findBySaleType(ProjectSaleTypeVo saleType) {
|
public List<ProjectSaleTypeRequireFileTypeVo> findBySaleType(ProjectSaleTypeVo saleType) {
|
||||||
return repository.findBySaleTypeId(saleType.getId()).stream().map(ProjectSaleTypeRequireFileType::toVo).toList();
|
return repository.findBySaleTypeId(saleType.getId()).stream().map(ProjectSaleTypeRequireFileType::toVo)
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'by-sale-type-'+#p0.id")
|
@Cacheable(key = "'by-sale-type-'+#p0.id")
|
||||||
@@ -70,21 +63,20 @@ public class ProjectSaleTypeRequireFileTypeService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectSaleTypeRequireFileTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
public ProjectSaleTypeRequireFileType createNewEntity() {
|
||||||
Specification<ProjectSaleTypeRequireFileType> spec = null;
|
return new ProjectSaleTypeRequireFileType();
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "saleType");
|
|
||||||
return findAll(spec, pageable).map(ProjectSaleTypeRequireFileType::toVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<ProjectSaleTypeRequireFileType> getSearchSpecification(String searchText) {
|
protected Specification<ProjectSaleTypeRequireFileType> buildSearchSpecification(String searchText) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectSaleTypeRequireFileType> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||||
|
}
|
||||||
|
|
||||||
// save
|
// save
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@@ -92,6 +84,7 @@ public class ProjectSaleTypeRequireFileTypeService
|
|||||||
@CacheEvict(key = "'by-sale-type-'+#p0.saleType.id"),
|
@CacheEvict(key = "'by-sale-type-'+#p0.saleType.id"),
|
||||||
@CacheEvict(key = "'all'")
|
@CacheEvict(key = "'all'")
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public ProjectSaleTypeRequireFileType save(ProjectSaleTypeRequireFileType type) {
|
public ProjectSaleTypeRequireFileType save(ProjectSaleTypeRequireFileType type) {
|
||||||
return repository.save(type);
|
return repository.save(type);
|
||||||
}
|
}
|
||||||
@@ -103,6 +96,7 @@ public class ProjectSaleTypeRequireFileTypeService
|
|||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'all'")
|
@CacheEvict(key = "'all'")
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public void delete(ProjectSaleTypeRequireFileType type) {
|
public void delete(ProjectSaleTypeRequireFileType type) {
|
||||||
repository.delete(type);
|
repository.delete(type);
|
||||||
}
|
}
|
||||||
@@ -135,4 +129,5 @@ public class ProjectSaleTypeRequireFileTypeService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.project.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
@@ -15,7 +16,6 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.ds.project.repository.ProjectSaleTypeRepository;
|
import com.ecep.contract.ds.project.repository.ProjectSaleTypeRepository;
|
||||||
@@ -26,14 +26,21 @@ import com.ecep.contract.vo.ProjectSaleTypeVo;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-sale-type")
|
@CacheConfig(cacheNames = "project-sale-type")
|
||||||
public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>, QueryService<ProjectSaleTypeVo>,
|
public class ProjectSaleTypeService extends EntityService<ProjectSaleType, ProjectSaleTypeVo, Integer>
|
||||||
|
implements IEntityService<ProjectSaleType>, QueryService<ProjectSaleTypeVo>,
|
||||||
VoableService<ProjectSaleType, ProjectSaleTypeVo> {
|
VoableService<ProjectSaleType, ProjectSaleTypeVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectSaleTypeRepository saleTypeRepository;
|
private ProjectSaleTypeRepository saleTypeRepository;
|
||||||
|
|
||||||
public ProjectSaleType getById(Integer id) {
|
@Override
|
||||||
return saleTypeRepository.findById(id).orElse(null);
|
protected ProjectSaleTypeRepository getRepository() {
|
||||||
|
return saleTypeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProjectSaleType createNewEntity() {
|
||||||
|
return new ProjectSaleType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@@ -64,26 +71,16 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
|||||||
return entities.stream().map(ProjectSaleType::toVo).toList();
|
return entities.stream().map(ProjectSaleType::toVo).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<ProjectSaleType> findAll(Specification<ProjectSaleType> spec, Pageable pageable) {
|
|
||||||
return saleTypeRepository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ProjectSaleTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
protected Specification<ProjectSaleType> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
Specification<ProjectSaleType> spec = null;
|
Specification<ProjectSaleType> spec = null;
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// field
|
// field
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active");
|
||||||
return findAll(spec, pageable).map(ProjectSaleType::toVo);
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<ProjectSaleType> getSearchSpecification(String searchText) {
|
protected Specification<ProjectSaleType> buildSearchSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
@@ -96,6 +93,7 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
|||||||
@CacheEvict(key = "'code-'+#p0.name"),
|
@CacheEvict(key = "'code-'+#p0.name"),
|
||||||
@CacheEvict(key = "'all'"),
|
@CacheEvict(key = "'all'"),
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public ProjectSaleType save(ProjectSaleType type) {
|
public ProjectSaleType save(ProjectSaleType type) {
|
||||||
return saleTypeRepository.save(type);
|
return saleTypeRepository.save(type);
|
||||||
}
|
}
|
||||||
@@ -105,6 +103,7 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
|||||||
@CacheEvict(key = "'code-'+#p0.name"),
|
@CacheEvict(key = "'code-'+#p0.name"),
|
||||||
@CacheEvict(key = "'all'"),
|
@CacheEvict(key = "'all'"),
|
||||||
})
|
})
|
||||||
|
@Override
|
||||||
public void delete(ProjectSaleType type) {
|
public void delete(ProjectSaleType type) {
|
||||||
saleTypeRepository.delete(type);
|
saleTypeRepository.delete(type);
|
||||||
}
|
}
|
||||||
@@ -132,4 +131,5 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
|||||||
// ProjectSaleTypeVo中的created和version字段在ProjectSaleType实体中不存在,这里不做处理
|
// ProjectSaleTypeVo中的created和version字段在ProjectSaleType实体中不存在,这里不做处理
|
||||||
// 如果需要处理,可以添加日志记录或者其他逻辑
|
// 如果需要处理,可以添加日志记录或者其他逻辑
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.project.repository.ProjectTypeRepository;
|
import com.ecep.contract.ds.project.repository.ProjectTypeRepository;
|
||||||
@@ -27,14 +28,20 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "project-type")
|
@CacheConfig(cacheNames = "project-type")
|
||||||
public class ProjectTypeService
|
public class ProjectTypeService extends EntityService<ProjectType, ProjectTypeVo, Integer>
|
||||||
implements IEntityService<ProjectType>, QueryService<ProjectTypeVo>, VoableService<ProjectType, ProjectTypeVo> {
|
implements IEntityService<ProjectType>, QueryService<ProjectTypeVo>, VoableService<ProjectType, ProjectTypeVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectTypeRepository repository;
|
private ProjectTypeRepository repository;
|
||||||
|
|
||||||
public ProjectType getById(Integer id) {
|
@Override
|
||||||
return repository.findById(id).orElse(null);
|
protected ProjectTypeRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProjectType createNewEntity() {
|
||||||
|
return new ProjectType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@@ -71,33 +78,6 @@ public class ProjectTypeService
|
|||||||
return entities.stream().map(ProjectType::toVo).toList();
|
return entities.stream().map(ProjectType::toVo).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<ProjectType> findAll(Specification<ProjectType> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<ProjectTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<ProjectType> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "code");
|
|
||||||
return findAll(spec, pageable).map(ProjectType::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<ProjectType> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
|
||||||
return builder.or(
|
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
|
||||||
builder.like(root.get("name"), "%" + searchText + "%"));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'all'"),
|
@CacheEvict(key = "'all'"),
|
||||||
@@ -125,6 +105,21 @@ public class ProjectTypeService
|
|||||||
model.setDescription(vo.getDescription());
|
model.setDescription(vo.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectType> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<ProjectType> spec = null;
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "code");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<ProjectType> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.or(
|
||||||
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("name"), "%" + searchText + "%"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ package com.ecep.contract.ds.vendor.repository;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.vendor.model.Vendor;
|
import com.ecep.contract.ds.vendor.model.Vendor;
|
||||||
import com.ecep.contract.ds.vendor.model.VendorApprovedItem;
|
import com.ecep.contract.ds.vendor.model.VendorApprovedItem;
|
||||||
import com.ecep.contract.model.VendorApproved;
|
import com.ecep.contract.model.VendorApproved;
|
||||||
@@ -14,8 +13,7 @@ import com.ecep.contract.model.VendorApproved;
|
|||||||
* 合格供方名录
|
* 合格供方名录
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface VendorApprovedItemRepository extends
|
public interface VendorApprovedItemRepository extends MyRepository<VendorApprovedItem, Integer> {
|
||||||
JpaRepository<VendorApprovedItem, Integer>, JpaSpecificationExecutor<VendorApprovedItem> {
|
|
||||||
|
|
||||||
List<VendorApprovedItem> findAllByList(VendorApproved list);
|
List<VendorApprovedItem> findAllByList(VendorApproved list);
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ package com.ecep.contract.ds.vendor.repository;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.model.VendorGroup;
|
import com.ecep.contract.model.VendorGroup;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface VendorGroupRepository extends
|
public interface VendorGroupRepository extends
|
||||||
JpaRepository<VendorGroup, Integer>, JpaSpecificationExecutor<VendorGroup> {
|
MyRepository<VendorGroup, Integer> {
|
||||||
|
|
||||||
Optional<VendorGroup> findByName(String name);
|
Optional<VendorGroup> findByName(String name);
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,14 @@ package com.ecep.contract.ds.vendor.repository;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.model.VendorGroupRequireFileType;
|
import com.ecep.contract.model.VendorGroupRequireFileType;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface VendorGroupRequireFileTypeRepository extends
|
public interface VendorGroupRequireFileTypeRepository extends
|
||||||
JpaRepository<VendorGroupRequireFileType, Integer>, JpaSpecificationExecutor<VendorGroupRequireFileType> {
|
MyRepository<VendorGroupRequireFileType, Integer> {
|
||||||
|
|
||||||
|
|
||||||
List<VendorGroupRequireFileType> findByGroupId(int groupId);
|
List<VendorGroupRequireFileType> findByGroupId(int groupId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
package com.ecep.contract.ds.vendor.service;
|
package com.ecep.contract.ds.vendor.service;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.cache.annotation.Caching;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.ecep.contract.EntityService;
|
import com.ecep.contract.EntityService;
|
||||||
|
import com.ecep.contract.IEntityService;
|
||||||
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.ParamConstant;
|
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorApprovedFileRepository;
|
import com.ecep.contract.ds.vendor.repository.VendorApprovedFileRepository;
|
||||||
import com.ecep.contract.model.VendorApproved;
|
import com.ecep.contract.model.VendorApproved;
|
||||||
import com.ecep.contract.model.VendorApprovedFile;
|
import com.ecep.contract.model.VendorApprovedFile;
|
||||||
@@ -13,16 +22,6 @@ import com.ecep.contract.service.VoableService;
|
|||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.VendorApprovedFileVo;
|
import com.ecep.contract.vo.VendorApprovedFileVo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
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;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@@ -72,30 +71,15 @@ public class VendorApprovedFileService extends EntityService<VendorApprovedFile,
|
|||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VendorApprovedFile getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据查询规格和分页参数获取供应商已批准文件列表
|
|
||||||
*
|
|
||||||
* @param spec 查询规格
|
|
||||||
* @param pageable 分页参数
|
|
||||||
* @return 分页的文件列表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Page<VendorApprovedFile> findAll(Specification<VendorApprovedFile> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除供应商已批准文件
|
* 删除供应商已批准文件
|
||||||
*
|
*
|
||||||
* @param entity 要删除的文件实体
|
* @param entity 要删除的文件实体
|
||||||
*/
|
*/
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'byList-'+#p0.list.id")
|
||||||
|
})
|
||||||
@Override
|
@Override
|
||||||
public void delete(VendorApprovedFile entity) {
|
public void delete(VendorApprovedFile entity) {
|
||||||
repository.delete(entity);
|
repository.delete(entity);
|
||||||
@@ -107,6 +91,10 @@ public class VendorApprovedFileService extends EntityService<VendorApprovedFile,
|
|||||||
* @param entity 要保存的文件实体
|
* @param entity 要保存的文件实体
|
||||||
* @return 保存后的文件实体
|
* @return 保存后的文件实体
|
||||||
*/
|
*/
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'byList-'+#p0.list.id")
|
||||||
|
})
|
||||||
@Override
|
@Override
|
||||||
public VendorApprovedFile save(VendorApprovedFile entity) {
|
public VendorApprovedFile save(VendorApprovedFile entity) {
|
||||||
return repository.save(entity);
|
return repository.save(entity);
|
||||||
@@ -158,4 +146,4 @@ public class VendorApprovedFileService extends EntityService<VendorApprovedFile,
|
|||||||
entity.setList(null);
|
entity.setList(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,13 +3,13 @@ package com.ecep.contract.ds.vendor.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.VendorType;
|
import com.ecep.contract.VendorType;
|
||||||
import com.ecep.contract.constant.ParamConstant;
|
import com.ecep.contract.constant.ParamConstant;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
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.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ import jakarta.persistence.criteria.Predicate;
|
|||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
public class VendorApprovedItemService
|
public class VendorApprovedItemService extends EntityService<VendorApprovedItem, VendorApprovedItemVo, Integer>
|
||||||
implements IEntityService<VendorApprovedItem>, QueryService<VendorApprovedItemVo>,
|
implements IEntityService<VendorApprovedItem>, QueryService<VendorApprovedItemVo>,
|
||||||
VoableService<VendorApprovedItem, VendorApprovedItemVo> {
|
VoableService<VendorApprovedItem, VendorApprovedItemVo> {
|
||||||
|
|
||||||
@@ -45,7 +45,14 @@ public class VendorApprovedItemService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CompanyOldNameService companyOldNameService;
|
private CompanyOldNameService companyOldNameService;
|
||||||
|
|
||||||
public VendorApprovedItemService() {
|
@Override
|
||||||
|
protected VendorApprovedItemRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VendorApprovedItem createNewEntity() {
|
||||||
|
return new VendorApprovedItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -54,12 +61,7 @@ public class VendorApprovedItemService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VendorApprovedItem getById(Integer id) {
|
protected Specification<VendorApprovedItem> buildSearchSpecification(String searchText) {
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<VendorApprovedItem> getSearchSpecification(String searchText) {
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
Path<Vendor> vendor = root.get("vendor");
|
Path<Vendor> vendor = root.get("vendor");
|
||||||
Path<Company> company = vendor.get("company");
|
Path<Company> company = vendor.get("company");
|
||||||
@@ -82,30 +84,8 @@ public class VendorApprovedItemService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<VendorApprovedItem> findAll(Specification<VendorApprovedItem> spec, Pageable pageable) {
|
protected Specification<VendorApprovedItem> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(VendorApprovedItem entity) {
|
|
||||||
repository.delete(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VendorApprovedItem save(VendorApprovedItem entity) {
|
|
||||||
return repository.save(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VendorApprovedItem> findAll(Specification<VendorApprovedItem> spec, Sort sort) {
|
|
||||||
return repository.findAll(spec, sort);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<VendorApprovedItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<VendorApprovedItem> spec = null;
|
Specification<VendorApprovedItem> spec = null;
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
// 添加额外的参数过滤
|
// 添加额外的参数过滤
|
||||||
if (paramsNode.has("type")) {
|
if (paramsNode.has("type")) {
|
||||||
String typeText = paramsNode.get("type").asText();
|
String typeText = paramsNode.get("type").asText();
|
||||||
@@ -115,7 +95,7 @@ public class VendorApprovedItemService
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor", "list");
|
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor", "list");
|
||||||
return findAll(spec, pageable).map(VendorApprovedItem::toVo);
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<VendorApprovedItem> findAllByListAndVendor(VendorApproved approvedList, Vendor vendor) {
|
public List<VendorApprovedItem> findAllByListAndVendor(VendorApproved approvedList, Vendor vendor) {
|
||||||
@@ -153,4 +133,4 @@ public class VendorApprovedItemService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,36 +8,32 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.ecep.contract.SpringApp;
|
|
||||||
import com.ecep.contract.constant.ParamConstant;
|
|
||||||
import com.ecep.contract.service.SmbFileService;
|
|
||||||
import com.hierynomus.smbj.common.SmbPath;
|
|
||||||
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;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
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;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
|
||||||
import com.ecep.contract.EntityService;
|
import com.ecep.contract.EntityService;
|
||||||
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.MyDateTimeUtils;
|
import com.ecep.contract.MyDateTimeUtils;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.SpringApp;
|
||||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||||
import com.ecep.contract.ds.other.service.SysConfService;
|
import com.ecep.contract.ds.other.service.SysConfService;
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorApprovedRepository;
|
import com.ecep.contract.ds.vendor.repository.VendorApprovedRepository;
|
||||||
import com.ecep.contract.model.VendorApproved;
|
import com.ecep.contract.model.VendorApproved;
|
||||||
import com.ecep.contract.model.VendorApprovedFile;
|
import com.ecep.contract.model.VendorApprovedFile;
|
||||||
import com.ecep.contract.service.ServiceException;
|
import com.ecep.contract.service.ServiceException;
|
||||||
|
import com.ecep.contract.service.SmbFileService;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
import com.ecep.contract.util.FileUtils;
|
import com.ecep.contract.util.FileUtils;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.VendorApprovedVo;
|
import com.ecep.contract.vo.VendorApprovedVo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.hierynomus.smbj.common.SmbPath;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@@ -78,11 +74,6 @@ public class VendorApprovedService extends EntityService<VendorApproved, VendorA
|
|||||||
return repository.findById(id).map(VendorApproved::toVo).orElse(null);
|
return repository.findById(id).map(VendorApproved::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VendorApproved getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected org.springframework.data.jpa.domain.Specification<VendorApproved> buildParameterSpecification(
|
protected org.springframework.data.jpa.domain.Specification<VendorApproved> buildParameterSpecification(
|
||||||
JsonNode paramsNode) {
|
JsonNode paramsNode) {
|
||||||
@@ -108,10 +99,6 @@ public class VendorApprovedService extends EntityService<VendorApproved, VendorA
|
|||||||
repository.delete(entity);
|
repository.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<VendorApproved> findAll(Specification<VendorApproved> spec, PageRequest pageRequest) {
|
|
||||||
return repository.findAll(spec, pageRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean makePathAbsent(VendorApproved list) {
|
public boolean makePathAbsent(VendorApproved list) {
|
||||||
String path = list.getPath();
|
String path = list.getPath();
|
||||||
if (StringUtils.hasText(path)) {
|
if (StringUtils.hasText(path)) {
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
package com.ecep.contract.ds.vendor.service;
|
package com.ecep.contract.ds.vendor.service;
|
||||||
|
|
||||||
import com.ecep.contract.constant.ParamConstant;
|
|
||||||
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.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
|
||||||
import com.ecep.contract.EntityService;
|
import com.ecep.contract.EntityService;
|
||||||
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorClassRepository;
|
import com.ecep.contract.ds.vendor.repository.VendorClassRepository;
|
||||||
import com.ecep.contract.model.VendorCatalog;
|
import com.ecep.contract.model.VendorCatalog;
|
||||||
@@ -48,34 +44,12 @@ public class VendorCatalogService extends EntityService<VendorCatalog, VendorCat
|
|||||||
return new VendorCatalog();
|
return new VendorCatalog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<VendorCatalogVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<VendorCatalog> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "code", "parentId");
|
|
||||||
return findAll(spec, pageable).map(VendorCatalog::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VendorCatalog getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public VendorCatalogVo findById(Integer id) {
|
public VendorCatalogVo findById(Integer id) {
|
||||||
return repository.findById(id).map(VendorCatalog::toVo).orElse(null);
|
return repository.findById(id).map(VendorCatalog::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<VendorCatalog> findAll(Specification<VendorCatalog> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected org.springframework.data.jpa.domain.Specification<VendorCatalog> buildParameterSpecification(
|
protected org.springframework.data.jpa.domain.Specification<VendorCatalog> buildParameterSpecification(
|
||||||
JsonNode paramsNode) {
|
JsonNode paramsNode) {
|
||||||
@@ -121,4 +95,4 @@ public class VendorCatalogService extends EntityService<VendorCatalog, VendorCat
|
|||||||
model.setCode(vo.getCode());
|
model.setCode(vo.getCode());
|
||||||
model.setType(vo.getType());
|
model.setType(vo.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,20 +8,17 @@ import org.springframework.cache.annotation.CacheEvict;
|
|||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
|
||||||
import com.ecep.contract.EntityService;
|
import com.ecep.contract.EntityService;
|
||||||
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorEntityRepository;
|
|
||||||
import com.ecep.contract.ds.vendor.model.Vendor;
|
import com.ecep.contract.ds.vendor.model.Vendor;
|
||||||
import com.ecep.contract.ds.vendor.model.VendorEntity;
|
import com.ecep.contract.ds.vendor.model.VendorEntity;
|
||||||
|
import com.ecep.contract.ds.vendor.repository.VendorEntityRepository;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.VendorEntityVo;
|
import com.ecep.contract.vo.VendorEntityVo;
|
||||||
@@ -30,7 +27,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "company-vendor-entity")
|
@CacheConfig(cacheNames = "company-vendor-entity")
|
||||||
public class VendorEntityService extends EntityService<VendorEntity, VendorEntityVo, Integer> implements IEntityService<VendorEntity>, QueryService<VendorEntityVo>,
|
public class VendorEntityService extends EntityService<VendorEntity, VendorEntityVo, Integer>
|
||||||
|
implements IEntityService<VendorEntity>, QueryService<VendorEntityVo>,
|
||||||
VoableService<VendorEntity, VendorEntityVo> {
|
VoableService<VendorEntity, VendorEntityVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -46,11 +44,6 @@ public class VendorEntityService extends EntityService<VendorEntity, VendorEntit
|
|||||||
return new VendorEntity();
|
return new VendorEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VendorEntity getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public VendorEntityVo findById(Integer id) {
|
public VendorEntityVo findById(Integer id) {
|
||||||
@@ -69,13 +62,6 @@ public class VendorEntityService extends EntityService<VendorEntity, VendorEntit
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<VendorEntity> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Specification<VendorEntity> buildSearchSpecification(String searchText) {
|
protected Specification<VendorEntity> buildSearchSpecification(String searchText) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
@@ -86,35 +72,14 @@ public class VendorEntityService extends EntityService<VendorEntity, VendorEntit
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected org.springframework.data.jpa.domain.Specification<VendorEntity> buildParameterSpecification(JsonNode paramsNode) {
|
protected org.springframework.data.jpa.domain.Specification<VendorEntity> buildParameterSpecification(
|
||||||
|
JsonNode paramsNode) {
|
||||||
org.springframework.data.jpa.domain.Specification<VendorEntity> spec = null;
|
org.springframework.data.jpa.domain.Specification<VendorEntity> spec = null;
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");
|
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "abbName", "code");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "abbName", "code");
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<VendorEntity> search(String searchText) {
|
|
||||||
Specification<VendorEntity> spec = getSearchSpecification(searchText);
|
|
||||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<VendorEntity> findAll(Specification<VendorEntity> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<VendorEntityVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<VendorEntity> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 添加额外的参数过滤s
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");
|
|
||||||
return findAll(spec, pageable).map(VendorEntity::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'code-'+#p0.code")
|
@CacheEvict(key = "'code-'+#p0.code")
|
||||||
@@ -173,4 +138,4 @@ public class VendorEntityService extends EntityService<VendorEntity, VendorEntit
|
|||||||
model.setModifier(employeeService.getById(vo.getModifierId()));
|
model.setModifier(employeeService.getById(vo.getModifierId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,11 +12,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
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.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.ecep.contract.ContractPayWay;
|
import com.ecep.contract.ContractPayWay;
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.MessageHolder;
|
import com.ecep.contract.MessageHolder;
|
||||||
import com.ecep.contract.MyDateTimeUtils;
|
import com.ecep.contract.MyDateTimeUtils;
|
||||||
@@ -42,8 +41,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
public class VendorFileService
|
public class VendorFileService extends EntityService<VendorFile, VendorFileVo, Integer>
|
||||||
implements IEntityService<VendorFile>, QueryService<VendorFile>, VoableService<VendorFile, VendorFileVo> {
|
implements IEntityService<VendorFile>, QueryService<VendorFileVo>, VoableService<VendorFile, VendorFileVo> {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(VendorFileService.class);
|
private static final Logger logger = LoggerFactory.getLogger(VendorFileService.class);
|
||||||
|
|
||||||
@@ -59,42 +58,8 @@ public class VendorFileService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private VendorFileRepository repository;
|
private VendorFileRepository repository;
|
||||||
|
|
||||||
@Override
|
public VendorFileVo findById(Integer id) {
|
||||||
public VendorFile getById(Integer id) {
|
return repository.findById(id).map(VendorFile::toVo).orElse(null);
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VendorFile findById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<VendorFile> getSearchSpecification(String searchText) {
|
|
||||||
return (root, query, builder) -> {
|
|
||||||
return builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<VendorFile> findAll(Specification<VendorFile> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<VendorFile> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<VendorFile> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
// 添加额外的参数过滤
|
|
||||||
if (paramsNode.has("type")) {
|
|
||||||
VendorFileType type = VendorFileType.valueOf(paramsNode.get("type").asText());
|
|
||||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), type));
|
|
||||||
}
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "valid");
|
|
||||||
spec = SpecificationUtils.andFieldBetweenParam(spec, paramsNode, "signDate", LocalDate.class);
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");
|
|
||||||
return findAll(spec, pageable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<VendorFile> findAllByVendor(Vendor vendor) {
|
public List<VendorFile> findAllByVendor(Vendor vendor) {
|
||||||
@@ -105,10 +70,6 @@ public class VendorFileService
|
|||||||
return repository.findAllByVendorId(vendor.getId()).stream().map(VendorFile::toVo).toList();
|
return repository.findAllByVendorId(vendor.getId()).stream().map(VendorFile::toVo).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(VendorFile file) {
|
|
||||||
repository.delete(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteById(int id) {
|
public void deleteById(int id) {
|
||||||
repository.deleteById(id);
|
repository.deleteById(id);
|
||||||
}
|
}
|
||||||
@@ -117,14 +78,6 @@ public class VendorFileService
|
|||||||
repository.saveAll(files);
|
repository.saveAll(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VendorFile save(VendorFile file) {
|
|
||||||
return repository.save(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VendorFile> findAll(Specification<VendorFile> spec, Sort sort) {
|
|
||||||
return repository.findAll(spec, sort);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VendorFile> findAllByVendorAndType(Vendor vendor, VendorFileType type) {
|
public List<VendorFile> findAllByVendorAndType(Vendor vendor, VendorFileType type) {
|
||||||
return repository.findAllByVendorAndType(vendor, type);
|
return repository.findAllByVendorAndType(vendor, type);
|
||||||
}
|
}
|
||||||
@@ -133,6 +86,40 @@ public class VendorFileService
|
|||||||
return repository.findAllByVendorIdAndType(vendor.getId(), type);
|
return repository.findAllByVendorIdAndType(vendor.getId(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected VendorFileRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VendorFile createNewEntity() {
|
||||||
|
return new VendorFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<VendorFile> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<VendorFile> buildParameterSpecification(JsonNode node) {
|
||||||
|
Specification<VendorFile> spec = null;
|
||||||
|
if (node.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||||
|
spec = getSearchSpecification(node.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||||
|
}
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
if (node.has("type")) {
|
||||||
|
VendorFileType type = VendorFileType.valueOf(node.get("type").asText());
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), type));
|
||||||
|
}
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, node, "valid");
|
||||||
|
spec = SpecificationUtils.andFieldBetweenParam(spec, node, "signDate", LocalDate.class);
|
||||||
|
spec = SpecificationUtils.andParam(spec, node, "vendor");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证供应商文件
|
* 验证供应商文件
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,23 +3,21 @@ package com.ecep.contract.ds.vendor.service;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ecep.contract.constant.ParamConstant;
|
|
||||||
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.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.VendorFileType;
|
import com.ecep.contract.VendorFileType;
|
||||||
import com.ecep.contract.VendorType;
|
import com.ecep.contract.VendorType;
|
||||||
|
import com.ecep.contract.constant.ParamConstant;
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorFileTypeLocalRepository;
|
import com.ecep.contract.ds.vendor.repository.VendorFileTypeLocalRepository;
|
||||||
import com.ecep.contract.model.VendorFileTypeLocal;
|
import com.ecep.contract.model.VendorFileTypeLocal;
|
||||||
import com.ecep.contract.service.ServiceException;
|
import com.ecep.contract.service.ServiceException;
|
||||||
@@ -35,44 +33,19 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "vendor-file-type")
|
@CacheConfig(cacheNames = "vendor-file-type")
|
||||||
public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal>, QueryService<VendorFileTypeLocalVo>,
|
public class VendorFileTypeService extends EntityService<VendorFileTypeLocal, VendorFileTypeLocalVo, Integer>
|
||||||
|
implements IEntityService<VendorFileTypeLocal>, QueryService<VendorFileTypeLocalVo>,
|
||||||
VoableService<VendorFileTypeLocal, VendorFileTypeLocalVo> {
|
VoableService<VendorFileTypeLocal, VendorFileTypeLocalVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private VendorFileTypeLocalRepository repository;
|
private VendorFileTypeLocalRepository repository;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<VendorFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<VendorFileTypeLocal> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paramsNode.has("type")) {
|
|
||||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"),
|
|
||||||
VendorType.valueOf(paramsNode.get("type").asText())));
|
|
||||||
}
|
|
||||||
|
|
||||||
// field
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
|
||||||
return findAll(spec, pageable).map(VendorFileTypeLocal::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public VendorFileTypeLocalVo findById(Integer id) {
|
public VendorFileTypeLocalVo findById(Integer id) {
|
||||||
return repository.findById(id).map(VendorFileTypeLocal::toVo).orElse(null);
|
return repository.findById(id).map(VendorFileTypeLocal::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VendorFileTypeLocal getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<VendorFileTypeLocal> findAll(Specification<VendorFileTypeLocal> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||||
public Map<VendorFileType, VendorFileTypeLocalVo> findAll(Locale locale) {
|
public Map<VendorFileType, VendorFileTypeLocalVo> findAll(Locale locale) {
|
||||||
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
||||||
@@ -81,20 +54,6 @@ public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal
|
|||||||
entry -> entry.getValue().toVo()));
|
entry -> entry.getValue().toVo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<VendorFileTypeLocal> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
|
||||||
return
|
|
||||||
// builder.or(
|
|
||||||
builder.like(root.get("type"), "%" + searchText + "%")
|
|
||||||
// )
|
|
||||||
;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'all-'+#p0.getLang()")
|
@CacheEvict(key = "'all-'+#p0.getLang()")
|
||||||
@@ -113,6 +72,40 @@ public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal
|
|||||||
return repository.save(entity);
|
return repository.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected VendorFileTypeLocalRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VendorFileTypeLocal createNewEntity() {
|
||||||
|
return new VendorFileTypeLocal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<VendorFileTypeLocal> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.like(root.get("type"), "%" + searchText + "%");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<VendorFileTypeLocal> buildParameterSpecification(JsonNode node) {
|
||||||
|
Specification<VendorFileTypeLocal> spec = null;
|
||||||
|
if (node.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||||
|
spec = getSearchSpecification(node.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.has("type")) {
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"),
|
||||||
|
VendorType.valueOf(node.get("type").asText())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, node, "lang", "value");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateByVo(VendorFileTypeLocal entity, VendorFileTypeLocalVo vo) throws ServiceException {
|
public void updateByVo(VendorFileTypeLocal entity, VendorFileTypeLocalVo vo) throws ServiceException {
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
|
|||||||
@@ -2,18 +2,16 @@ package com.ecep.contract.ds.vendor.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
|
||||||
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.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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;
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
@@ -22,6 +20,7 @@ import com.ecep.contract.model.VendorGroup;
|
|||||||
import com.ecep.contract.model.VendorGroupRequireFileType;
|
import com.ecep.contract.model.VendorGroupRequireFileType;
|
||||||
import com.ecep.contract.service.ServiceException;
|
import com.ecep.contract.service.ServiceException;
|
||||||
import com.ecep.contract.service.VoableService;
|
import com.ecep.contract.service.VoableService;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.ecep.contract.vo.VendorGroupRequireFileTypeVo;
|
import com.ecep.contract.vo.VendorGroupRequireFileTypeVo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
@@ -29,55 +28,47 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "vendor-group-require-file-type")
|
@CacheConfig(cacheNames = "vendor-group-require-file-type")
|
||||||
public class VendorGroupRequireFileTypeService
|
public class VendorGroupRequireFileTypeService
|
||||||
implements IEntityService<VendorGroupRequireFileType>, QueryService<VendorGroupRequireFileType>,
|
extends EntityService<VendorGroupRequireFileType, VendorGroupRequireFileTypeVo, Integer>
|
||||||
|
implements IEntityService<VendorGroupRequireFileType>, QueryService<VendorGroupRequireFileTypeVo>,
|
||||||
VoableService<VendorGroupRequireFileType, VendorGroupRequireFileTypeVo> {
|
VoableService<VendorGroupRequireFileType, VendorGroupRequireFileTypeVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private VendorGroupRequireFileTypeRepository repository;
|
private VendorGroupRequireFileTypeRepository repository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VendorGroupRequireFileType getById(Integer id) {
|
protected VendorGroupRequireFileTypeRepository getRepository() {
|
||||||
return repository.findById(id).orElse(null);
|
return repository;
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
|
||||||
public VendorGroupRequireFileType findById(Integer id) {
|
|
||||||
return getById(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<VendorGroupRequireFileType> findAll(Specification<VendorGroupRequireFileType> spec, Pageable pageable) {
|
public VendorGroupRequireFileType createNewEntity() {
|
||||||
return repository.findAll(spec, pageable);
|
return new VendorGroupRequireFileType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<VendorGroupRequireFileType> findAll(JsonNode paramsNode, Pageable pageable) {
|
public VendorGroupRequireFileTypeVo findById(Integer id) {
|
||||||
Specification<VendorGroupRequireFileType> spec = null;
|
return repository.findById(id).map(VendorGroupRequireFileType::toVo).orElse(null);
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "group");
|
|
||||||
// 添加额外的参数过滤
|
|
||||||
return findAll(spec, pageable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<VendorGroupRequireFileType> getSearchSpecification(String searchText) {
|
protected Specification<VendorGroupRequireFileType> buildSearchSpecification(String searchText) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<VendorGroupRequireFileType> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<VendorGroupRequireFileType> spec = null;
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "group");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'byGroup-'+#p0")
|
@Cacheable(key = "'byGroup-'+#p0")
|
||||||
public List<VendorGroupRequireFileTypeVo> findByGroupId(int groupId) {
|
public List<VendorGroupRequireFileTypeVo> findByGroupId(int groupId) {
|
||||||
return repository.findByGroupId(groupId).stream().map(VendorGroupRequireFileType::toVo).toList();
|
return repository.findByGroupId(groupId).stream().map(VendorGroupRequireFileType::toVo).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// findAll
|
|
||||||
@Cacheable(key = "'all'")
|
|
||||||
public List<VendorGroupRequireFileType> findAll() {
|
|
||||||
return repository.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
// save
|
// save
|
||||||
|
@Override
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'byGroup-'+#p0.group.id"),
|
@CacheEvict(key = "'byGroup-'+#p0.group.id"),
|
||||||
@@ -90,6 +81,7 @@ public class VendorGroupRequireFileTypeService
|
|||||||
/**
|
/**
|
||||||
* delete and evict cache
|
* delete and evict cache
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'byGroup-'+#p0.group.id"),
|
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'byGroup-'+#p0.group.id"),
|
||||||
@CacheEvict(key = "'all'")
|
@CacheEvict(key = "'all'")
|
||||||
@@ -121,4 +113,5 @@ public class VendorGroupRequireFileTypeService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,11 @@ import org.springframework.cache.annotation.CacheEvict;
|
|||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
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.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;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.EntityService;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorGroupRepository;
|
import com.ecep.contract.ds.vendor.repository.VendorGroupRepository;
|
||||||
@@ -27,22 +26,36 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "vendor-group")
|
@CacheConfig(cacheNames = "vendor-group")
|
||||||
public class VendorGroupService
|
public class VendorGroupService extends EntityService<VendorGroup, VendorGroupVo, Integer>
|
||||||
implements IEntityService<VendorGroup>, QueryService<VendorGroupVo>, VoableService<VendorGroup, VendorGroupVo> {
|
implements IEntityService<VendorGroup>, QueryService<VendorGroupVo>, VoableService<VendorGroup, VendorGroupVo> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private VendorGroupRepository vendorGroupRepository;
|
private VendorGroupRepository vendorGroupRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected VendorGroupRepository getRepository() {
|
||||||
|
return vendorGroupRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VendorGroup createNewEntity() {
|
||||||
|
VendorGroup group = new VendorGroup();
|
||||||
|
group.setCode("");
|
||||||
|
group.setName("");
|
||||||
|
group.setDescription("");
|
||||||
|
group.setActive(true);
|
||||||
|
group.setPriceComparison(true);
|
||||||
|
group.setRequireQuotationSheetForBid(true);
|
||||||
|
group.setCanPrePurchase(false);
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public VendorGroupVo findById(Integer id) {
|
public VendorGroupVo findById(Integer id) {
|
||||||
return vendorGroupRepository.findById(id).map(VendorGroup::toVo).orElse(null);
|
return vendorGroupRepository.findById(id).map(VendorGroup::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VendorGroup getById(Integer id) {
|
|
||||||
return vendorGroupRepository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VendorGroup findByName(String name) {
|
public VendorGroup findByName(String name) {
|
||||||
return vendorGroupRepository.findByName(name).orElse(null);
|
return vendorGroupRepository.findByName(name).orElse(null);
|
||||||
}
|
}
|
||||||
@@ -57,63 +70,21 @@ public class VendorGroupService
|
|||||||
return vendorGroupRepository.findAll();
|
return vendorGroupRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<VendorGroup> findAll(Specification<VendorGroup> spec, Pageable pageable) {
|
|
||||||
return vendorGroupRepository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<VendorGroupVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
protected Specification<VendorGroup> buildSearchSpecification(String searchText) {
|
||||||
Specification<VendorGroup> spec = null;
|
|
||||||
if (paramsNode.has("searchText")) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
|
||||||
}
|
|
||||||
// 添加额外的参数过滤
|
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active", "name", "code");
|
|
||||||
return findAll(spec, pageable).map(entity -> entity.toVo());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<VendorGroup> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
builder.like(root.get("description"), "%" + searchText + "%")
|
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Override
|
||||||
@CacheEvict(key = "#p0.id"),
|
protected Specification<VendorGroup> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
@CacheEvict(key = "'code-'+#p0.name"),
|
Specification<VendorGroup> spec = null;
|
||||||
@CacheEvict(key = "'all'"),
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active", "name", "code");
|
||||||
})
|
return spec;
|
||||||
public VendorGroup saveEntity(VendorGroup group) {
|
|
||||||
return vendorGroupRepository.save(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
|
||||||
@CacheEvict(key = "#p0.id"),
|
|
||||||
@CacheEvict(key = "'code-'+#p0.name"),
|
|
||||||
@CacheEvict(key = "'all'"),
|
|
||||||
})
|
|
||||||
public void deleteEntity(VendorGroup entity) {
|
|
||||||
vendorGroupRepository.delete(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VendorGroup newInstance() {
|
|
||||||
VendorGroup group = new VendorGroup();
|
|
||||||
group.setCode("");
|
|
||||||
group.setName("");
|
|
||||||
group.setDescription("");
|
|
||||||
group.setActive(true);
|
|
||||||
group.setPriceComparison(true);
|
|
||||||
group.setRequireQuotationSheetForBid(true);
|
|
||||||
group.setCanPrePurchase(false);
|
|
||||||
return group;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -134,14 +105,23 @@ public class VendorGroupService
|
|||||||
model.setCanPrePurchase(vo.isCanPrePurchase());
|
model.setCanPrePurchase(vo.isCanPrePurchase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'code-'+#p0.name"),
|
||||||
|
@CacheEvict(key = "'all'"),
|
||||||
|
})
|
||||||
public VendorGroup save(VendorGroup entity) {
|
public VendorGroup save(VendorGroup entity) {
|
||||||
return saveEntity(entity);
|
return vendorGroupRepository.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'code-'+#p0.name"),
|
||||||
|
@CacheEvict(key = "'all'"),
|
||||||
|
})
|
||||||
public void delete(VendorGroup entity) {
|
public void delete(VendorGroup entity) {
|
||||||
deleteEntity(entity);
|
vendorGroupRepository.delete(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,6 +42,7 @@ import com.ecep.contract.ds.other.service.SysConfService;
|
|||||||
import com.ecep.contract.ds.vendor.repository.VendorClassRepository;
|
import com.ecep.contract.ds.vendor.repository.VendorClassRepository;
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorRepository;
|
import com.ecep.contract.ds.vendor.repository.VendorRepository;
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorTypeLocalRepository;
|
import com.ecep.contract.ds.vendor.repository.VendorTypeLocalRepository;
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.company.model.Company;
|
import com.ecep.contract.ds.company.model.Company;
|
||||||
import com.ecep.contract.model.CompanyBasicFile;
|
import com.ecep.contract.model.CompanyBasicFile;
|
||||||
import com.ecep.contract.ds.contract.model.Contract;
|
import com.ecep.contract.ds.contract.model.Contract;
|
||||||
@@ -65,7 +66,7 @@ import jakarta.persistence.criteria.Path;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = CompanyVendorConstant.CACHE_NAME)
|
@CacheConfig(cacheNames = CompanyVendorConstant.CACHE_NAME)
|
||||||
public class VendorService extends CompanyBasicService
|
public class VendorService extends CompanyBasicService<Vendor, VendorVo>
|
||||||
implements IEntityService<Vendor>, QueryService<VendorVo>, VoableService<Vendor, VendorVo> {
|
implements IEntityService<Vendor>, QueryService<VendorVo>, VoableService<Vendor, VendorVo> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private VendorCatalogService vendorCatalogService;
|
private VendorCatalogService vendorCatalogService;
|
||||||
@@ -92,6 +93,16 @@ public class VendorService extends CompanyBasicService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private VendorClassRepository vendorClassRepository;
|
private VendorClassRepository vendorClassRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected VendorRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vendor createNewEntity() {
|
||||||
|
return new Vendor();
|
||||||
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
SpringApp.getBean(org.springframework.core.convert.converter.ConverterRegistry.class)
|
SpringApp.getBean(org.springframework.core.convert.converter.ConverterRegistry.class)
|
||||||
@@ -103,30 +114,6 @@ public class VendorService extends CompanyBasicService
|
|||||||
return repository.findById(id).map(Vendor::toVo).orElse(null);
|
return repository.findById(id).map(Vendor::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vendor getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Page<Vendor> findAll(Specification<Vendor> spec, Pageable pageable) {
|
|
||||||
return repository.findAll(spec, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<VendorVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
|
||||||
Specification<Vendor> spec = null;
|
|
||||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
|
||||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
|
||||||
}
|
|
||||||
// 添加额外的参数过滤
|
|
||||||
if (paramsNode.has("type")) {
|
|
||||||
VendorType type = VendorType.valueOf(paramsNode.get("type").asText());
|
|
||||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), type));
|
|
||||||
}
|
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company", "catalog");
|
|
||||||
return findAll(spec, pageable).map(Vendor::toVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vendor findByCompany(Company company) {
|
public Vendor findByCompany(Company company) {
|
||||||
return repository.findByCompany(company).orElse(null);
|
return repository.findByCompany(company).orElse(null);
|
||||||
}
|
}
|
||||||
@@ -150,45 +137,6 @@ public class VendorService extends CompanyBasicService
|
|||||||
repository.delete(entity);
|
repository.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Specification<Vendor> getSearchSpecification(String searchText) {
|
|
||||||
if (!StringUtils.hasText(searchText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Specification<Vendor> nameSpec = (root, query, builder) -> {
|
|
||||||
Path<Company> company = root.get("company");
|
|
||||||
return companyService.buildSearchPredicate(searchText, company, query, builder);
|
|
||||||
};
|
|
||||||
// 判断是否全是数字
|
|
||||||
if (MyStringUtils.isAllDigit(searchText)) {
|
|
||||||
// 全数字就按 Id 查询
|
|
||||||
try {
|
|
||||||
int id = Integer.parseInt(searchText);
|
|
||||||
nameSpec = SpecificationUtils.or(nameSpec, (root, query, builder) -> {
|
|
||||||
return builder.equal(root.get("id"), id);
|
|
||||||
});
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<VendorEntity> searched = vendorEntityService.search(searchText);
|
|
||||||
if (!searched.isEmpty()) {
|
|
||||||
nameSpec = SpecificationUtils.or(nameSpec, (root, query, builder) -> {
|
|
||||||
return builder.in(root.get("id")).value(searched.stream()
|
|
||||||
.map(VendorEntity::getVendor)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.map(Vendor::getId)
|
|
||||||
.collect(Collectors.toSet()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return nameSpec;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Vendor> search(String searchText) {
|
|
||||||
Specification<Vendor> spec = getSearchSpecification(searchText);
|
|
||||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T, F extends CompanyBasicFile<T>, ID> void deleteFile(F file) {
|
public <T, F extends CompanyBasicFile<T>, ID> void deleteFile(F file) {
|
||||||
vendorFileService.delete((VendorFile) file);
|
vendorFileService.delete((VendorFile) file);
|
||||||
@@ -521,4 +469,46 @@ public class VendorService extends CompanyBasicService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<Vendor> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<Vendor> spec = null;
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
VendorType type = VendorType.valueOf(paramsNode.get("type").asText());
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), type));
|
||||||
|
}
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "company", "catalog");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<Vendor> buildSearchSpecification(String searchText) {
|
||||||
|
Specification<Vendor> nameSpec = (root, query, builder) -> {
|
||||||
|
Path<Company> company = root.get("company");
|
||||||
|
return companyService.buildSearchPredicate(searchText, company, query, builder);
|
||||||
|
};
|
||||||
|
// 判断是否全是数字
|
||||||
|
if (MyStringUtils.isAllDigit(searchText)) {
|
||||||
|
// 全数字就按 Id 查询
|
||||||
|
try {
|
||||||
|
int id = Integer.parseInt(searchText);
|
||||||
|
nameSpec = SpecificationUtils.or(nameSpec, (root, query, builder) -> {
|
||||||
|
return builder.equal(root.get("id"), id);
|
||||||
|
});
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<VendorEntity> searched = vendorEntityService.search(searchText);
|
||||||
|
if (!searched.isEmpty()) {
|
||||||
|
nameSpec = SpecificationUtils.or(nameSpec, (root, query, builder) -> {
|
||||||
|
return builder.in(root.get("id")).value(searched.stream()
|
||||||
|
.map(VendorEntity::getVendor)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(Vendor::getId)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return nameSpec;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,10 +77,7 @@ public class VendorTypeService extends EntityService<VendorTypeLocal, VendorType
|
|||||||
return repository.findById(id).map(VendorTypeLocal::toVo).orElse(null);
|
return repository.findById(id).map(VendorTypeLocal::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VendorTypeLocal getById(Integer id) {
|
|
||||||
return repository.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||||
public Map<VendorType, VendorTypeLocal> findAll(Locale locale) {
|
public Map<VendorType, VendorTypeLocal> findAll(Locale locale) {
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> impl
|
|||||||
baseRow++;
|
baseRow++;
|
||||||
CompanyCustomerFile customerFile = form.getCustomerFile();
|
CompanyCustomerFile customerFile = form.getCustomerFile();
|
||||||
if (!Hibernate.isInitialized(customerFile)) {
|
if (!Hibernate.isInitialized(customerFile)) {
|
||||||
customerFile = getCompanyCustomerFileService().findById(customerFile.getId());
|
customerFile = getCompanyCustomerFileService().getById(customerFile.getId());
|
||||||
holder.debug("延迟加载评价表文件信息,文件ID:" + customerFile.getId());
|
holder.debug("延迟加载评价表文件信息,文件ID:" + customerFile.getId());
|
||||||
}
|
}
|
||||||
setCellValue(sheet, baseRow, 2, String.valueOf(customerFile.getSignDate()));
|
setCellValue(sheet, baseRow, 2, String.valueOf(customerFile.getSignDate()));
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class CustomerFileMoveTasker extends Tasker<Object> implements WebSocketS
|
|||||||
@Override
|
@Override
|
||||||
public void init(JsonNode argsNode) {
|
public void init(JsonNode argsNode) {
|
||||||
if (argsNode != null && argsNode.size() > 0) {
|
if (argsNode != null && argsNode.size() > 0) {
|
||||||
this.file = getCompanyCustomerFileService().findById(argsNode.get(0).asInt());
|
this.file = getCompanyCustomerFileService().getById(argsNode.get(0).asInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,94 @@
|
|||||||
# 服务器端继承IEntityService接口的Service列表
|
# 服务器端 Service 继承IEntityService接口任务
|
||||||
|
|
||||||
|
`IEntityService` 接口定义了若干基本 CRUD 操作(相对项目路径:src/main/java/com/contract/service/IEntityService.java),包括保存、删除、查询等方法。
|
||||||
|
|
||||||
|
## Service 继承 EntityService 类的任务
|
||||||
|
|
||||||
|
参考 `server\src\main\java\com\ecep\contract\cloud\rk\CloudRkService.java` 类
|
||||||
|
|
||||||
|
1. 实现 `server\src\main\java\com\ecep\contract\EntityService.java` 类的方法
|
||||||
|
1.1 实现 `getRepository` 方法,用于获取实体的Repository
|
||||||
|
1.1.1 确认的Repository是否为`server\src\main\java\com\ecep\contract\ds\MyRepository.java`的子接口
|
||||||
|
1.2 实现 `createNewEntity` 方法,用于创建新实体
|
||||||
|
1.3 实现 `buildSearchSpecification` 方法,根据搜索参数构建查询规范
|
||||||
|
1.3.1 方法内容如下
|
||||||
|
|
||||||
|
```java
|
||||||
|
@Override
|
||||||
|
protected org.springframework.data.jpa.domain.Specification<VendorApprovedFile> buildSearchSpecification(String searchText) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.or(
|
||||||
|
builder.like(root.get("fileName"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
1.4 实现 `buildParameterSpecification` 方法,根据参数构建查询规范
|
||||||
|
1.4.1 方法内容从 `findAll(JsonNode paramsNode, Pageable pageable)` 中提取,然后删除 findAll 方法
|
||||||
|
比如 findAll 方法中定义如下
|
||||||
|
```java
|
||||||
|
@Override
|
||||||
|
public Page<VendorApprovedItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<VendorApprovedItem> spec = null;
|
||||||
|
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||||
|
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||||
|
}
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
String typeText = paramsNode.get("type").asText();
|
||||||
|
VendorType type = VendorType.valueOf(typeText);
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||||
|
return builder.equal(root.get("type"), type);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor", "list");
|
||||||
|
return findAll(spec, pageable).map(VendorApprovedItem::toVo);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
则 `buildParameterSpecification` 方法的实现如下(删除 searchText 部分以及直接返回spec,不调用findAll方法)
|
||||||
|
```java
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Specification<VendorApprovedItem> buildParameterSpecification(JsonNode paramsNode) {
|
||||||
|
Specification<VendorApprovedItem> spec = null;
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
String typeText = paramsNode.get("type").asText();
|
||||||
|
VendorType type = VendorType.valueOf(typeText);
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||||
|
return builder.equal(root.get("type"), type);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor", "list");
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
1.5 检查`count`方法的功能实现是否与父类相同,相同则移除
|
||||||
|
1.6 检查`findAll`方法的功能实现是否与父类相同,相同则移除
|
||||||
|
1.7 检查`getById`方法的功能实现是否与父类相同,相同则移除
|
||||||
|
1.8 检查`findById`f方法的返回值类型,须 Vo 类型,如未实现,则添加如下代码
|
||||||
|
|
||||||
|
```java
|
||||||
|
@Override
|
||||||
|
public VendorGroupRequireFileTypeVo findById(Integer id) {
|
||||||
|
return repository.findById(id).map(VendorGroupRequireFileType::toVo).orElse(null);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 缓存相关任务
|
||||||
|
2.1 确认Service类是否有 @CacheConfig 注解,没有注解,则没有应用缓存功能,跳过后续缓存检查
|
||||||
|
2.2 检查 `findById` 方法,注解 @Cacheable(key = "#p0")
|
||||||
|
2.3 检查 `save` 方法,注解 @CacheEvict(key = "#p0.id") 或者 @Caching(evict = @CacheEvict(key = "#p0.id"))
|
||||||
|
2.4 检查 `delete` 方法,注解 @CacheEvict(key = "#p0.id") 或者 @Caching(evict = @CacheEvict(key = "#p0.id"))
|
||||||
|
|
||||||
|
|
||||||
|
3. 处理异常情况
|
||||||
|
|
||||||
|
|
||||||
|
## Service 继承 IEntityService 接口的列表
|
||||||
|
|
||||||
| 类名 | 是否继承EntityService |
|
| 类名 | 是否继承EntityService |
|
||||||
|------|----------------------|
|
|------|----------------------|
|
||||||
@@ -39,65 +129,47 @@
|
|||||||
| SalesOrderItemService | 是 |
|
| SalesOrderItemService | 是 |
|
||||||
| CompanyCustomerEntityService | 是 |
|
| CompanyCustomerEntityService | 是 |
|
||||||
| CompanyCustomerEvaluationFormFileService | 是 |
|
| CompanyCustomerEvaluationFormFileService | 是 |
|
||||||
| CompanyCustomerFileService | 否 |
|
| CompanyCustomerFileService | 是 |
|
||||||
| CompanyCustomerFileTypeService | 否 |
|
| CompanyCustomerFileTypeService | 是 |
|
||||||
| CustomerCatalogService | 否 |
|
| CustomerCatalogService | 是 |
|
||||||
| CustomerFileTypeService | 否 |
|
| CustomerFileTypeService | 是 |
|
||||||
| CustomerService | 否 |
|
| CustomerService | 是 |
|
||||||
| BankService | 否 |
|
| BankService | 是 |
|
||||||
| DepartmentService | 否 |
|
| DepartmentService | 是 |
|
||||||
| EmployeeAuthBindService | 否 |
|
| EmployeeAuthBindService | 是 |
|
||||||
| EmployeeLoginHistoryService | 否 |
|
| EmployeeLoginHistoryService | 是 |
|
||||||
| EmployeeRoleService | 否 |
|
| EmployeeRoleService | 是 |
|
||||||
| EmployeeService | 否 |
|
| EmployeeService | 是 |
|
||||||
| FunctionService | 否 |
|
| FunctionService | 是 |
|
||||||
| InventoryCatalogService | 否 |
|
| InventoryCatalogService | 是 |
|
||||||
| InventoryHistoryPriceService | 否 |
|
| InventoryHistoryPriceService | 是 |
|
||||||
| InventoryService | 否 |
|
| InventoryService | 是 |
|
||||||
| PermissionService | 否 |
|
| PermissionService | 是 |
|
||||||
| CustomerSatisfactionSurveyService | 否 |
|
| CustomerSatisfactionSurveyService | 是 |
|
||||||
| DeliverySignMethodService | 否 |
|
| DeliverySignMethodService | 是 |
|
||||||
| ProductTypeService | 否 |
|
| ProductTypeService | 是 |
|
||||||
| ProductUsageService | 否 |
|
| ProductUsageService | 是 |
|
||||||
| ProjectBidService | 否 |
|
| ProjectBidService | 是 |
|
||||||
| ProjectCostItemService | 否 |
|
| ProjectCostItemService | 是 |
|
||||||
| ProjectCostService | 否 |
|
| ProjectCostService | 是 |
|
||||||
| ProjectFileService | 否 |
|
| ProjectFileService | 是 |
|
||||||
| ProjectFileTypeService | 否 |
|
| ProjectFileTypeService | 是 |
|
||||||
| ProjectFundPlanService | 否 |
|
| ProjectFundPlanService | 是 |
|
||||||
| ProjectIndustryService | 否 |
|
| ProjectIndustryService | 是 |
|
||||||
| ProjectQuotationService | 否 |
|
| ProjectQuotationService | 是 |
|
||||||
| ProjectSaleTypeRequireFileTypeService | 否 |
|
| ProjectSaleTypeRequireFileTypeService | 是 |
|
||||||
| ProjectSaleTypeService | 否 |
|
| ProjectSaleTypeService | 是 |
|
||||||
| ProjectService | 是 |
|
| ProjectService | 是 |
|
||||||
| ProjectTypeService | 否 |
|
| ProjectTypeService | 是 |
|
||||||
| VendorApprovedFileService | 否 |
|
| VendorApprovedFileService | 是 |
|
||||||
| VendorApprovedItemService | 否 |
|
| VendorApprovedItemService | 是 |
|
||||||
| VendorApprovedService | 否 |
|
| VendorApprovedService | 是 |
|
||||||
| VendorCatalogService | 否 |
|
| VendorCatalogService | 是 |
|
||||||
| VendorEntityService | 否 |
|
| VendorEntityService | 是 |
|
||||||
| VendorFileService | 否 |
|
| VendorFileService | 是 |
|
||||||
| VendorFileTypeService | 否 |
|
| VendorFileTypeService | 是 |
|
||||||
| VendorGroupRequireFileTypeService | 否 |
|
| VendorGroupRequireFileTypeService | 是 |
|
||||||
| VendorGroupService | 否 |
|
| VendorGroupService | 是 |
|
||||||
| VendorService | 否 |
|
| VendorService | 是 |
|
||||||
| VendorTypeService | 否 |
|
| VendorTypeService | 是 |
|
||||||
|
|
||||||
## 分析结果
|
|
||||||
|
|
||||||
- 共找到81个实现了IEntityService接口的服务类
|
|
||||||
- 其中有12个类同时继承了EntityService类
|
|
||||||
- 大多数服务类(69个)仅实现了IEntityService接口,没有继承EntityService类
|
|
||||||
|
|
||||||
继承EntityService类的服务类包括:
|
|
||||||
- CloudRkService
|
|
||||||
- CloudTycService
|
|
||||||
- YongYouU8Service
|
|
||||||
- CompanyBankAccountService
|
|
||||||
- CompanyService
|
|
||||||
- ContractService
|
|
||||||
- SaleOrdersService
|
|
||||||
- SalesBillVoucherService
|
|
||||||
- SalesOrderItemService
|
|
||||||
- ProjectService
|
|
||||||
- 以及其他几个核心业务服务类
|
|
||||||
Reference in New Issue
Block a user