Compare commits
16 Commits
72edb07798
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 643338f4b0 | |||
| 880671a5a9 | |||
| 4e738bea3c | |||
| 3cf3a717be | |||
| e8c8305f40 | |||
| be63ff62a4 | |||
| 18057a657e | |||
| db07befffe | |||
| 94030a5a39 | |||
| 7e59f2c17e | |||
| c8b0d57f22 | |||
| 6eebdb1744 | |||
| 9dc90507cb | |||
| 0c26d329c6 | |||
| e3661630fe | |||
| 5d6fb961b6 |
@@ -12,6 +12,9 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import org.controlsfx.control.PopOver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -50,13 +53,6 @@ import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckMenuItem;
|
||||
import javafx.scene.control.DatePicker;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Modality;
|
||||
@@ -79,6 +75,7 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
return super.show(loader, owner, modality);
|
||||
}
|
||||
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class MessageExt extends Message {
|
||||
@@ -90,12 +87,16 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Model implements MessageHolder {
|
||||
public static class Model {
|
||||
private SimpleStringProperty code = new SimpleStringProperty();
|
||||
private SimpleStringProperty name = new SimpleStringProperty();
|
||||
private SimpleObjectProperty<Integer> employee = new SimpleObjectProperty<>();
|
||||
private SimpleObjectProperty<LocalDate> setupDate = new SimpleObjectProperty<>();
|
||||
private SimpleListProperty<MessageExt> messages = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||
}
|
||||
|
||||
static class MessageHolderImpl implements MessageHolder {
|
||||
List<MessageExt> messages = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void addMessage(Level level, String message) {
|
||||
@@ -261,6 +262,8 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
long total = contractService.count(params);
|
||||
setStatus("合同:" + total + " 条");
|
||||
|
||||
MessageHolderImpl messageHolder = new MessageHolderImpl();
|
||||
|
||||
while (true) {
|
||||
if (isCloseRequested()) {
|
||||
break;
|
||||
@@ -268,6 +271,7 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
|
||||
Page<ContractVo> page = contractService.findAll(params, pageRequest);
|
||||
for (ContractVo contract : page) {
|
||||
messageHolder.messages.clear();
|
||||
if (isCloseRequested()) {
|
||||
break;
|
||||
}
|
||||
@@ -285,11 +289,11 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
model.getName().set(contract.getName());
|
||||
model.getSetupDate().set(contract.getSetupDate());
|
||||
|
||||
comm.verify(contract, model);
|
||||
comm.verify(contract, messageHolder);
|
||||
setStatus("合同验证进度:" + counter.get() + " / " + total);
|
||||
// 移除中间消息
|
||||
if (!model.getMessages().isEmpty()) {
|
||||
model.getMessages().removeIf(msg -> msg.getLevel().intValue() <= Level.INFO.intValue());
|
||||
if (!messageHolder.messages.isEmpty()) {
|
||||
model.getMessages().setAll(messageHolder.messages.stream().filter(msg -> msg.getLevel().intValue() > Level.INFO.intValue()).limit(50).toList());
|
||||
}
|
||||
if (model.getMessages().isEmpty()) {
|
||||
if (onlyShowVerifiedChecker.isSelected()) {
|
||||
@@ -325,6 +329,7 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
}
|
||||
runAsync(() -> {
|
||||
ContractVo contract = null;
|
||||
MessageHolderImpl messageHolder = new MessageHolderImpl();
|
||||
try {
|
||||
contract = contractService.findByCode(contractCode);
|
||||
} catch (Exception e) {
|
||||
@@ -336,17 +341,18 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
}
|
||||
model.getMessages().clear();
|
||||
try {
|
||||
comm.verify(contract, model);
|
||||
// 移除中间消息
|
||||
if (!model.getMessages().isEmpty()) {
|
||||
model.getMessages().removeIf(msg -> msg.getLevel().intValue() <= Level.INFO.intValue());
|
||||
}
|
||||
comm.verify(contract, messageHolder);
|
||||
} catch (Exception e) {
|
||||
logger.error(model.getCode().get(), e);
|
||||
model.error(e.getMessage());
|
||||
messageHolder.error(e.getMessage());
|
||||
}
|
||||
|
||||
if (model.getMessages().isEmpty()) {
|
||||
// 移除中间消息
|
||||
if (!messageHolder.messages.isEmpty()) {
|
||||
model.getMessages().setAll(messageHolder.messages.stream().filter(msg -> msg.getLevel().intValue() > Level.INFO.intValue()).limit(50).toList());
|
||||
}
|
||||
|
||||
if (messageHolder.messages.isEmpty()) {
|
||||
Platform.runLater(() -> {
|
||||
viewTableDataSet.remove(model);
|
||||
});
|
||||
@@ -380,6 +386,38 @@ public class ContractVerifyWindowController extends BaseController {
|
||||
ContractWindowController.show(contract, viewTable.getScene().getWindow());
|
||||
}
|
||||
|
||||
|
||||
public void onShowVerifyStatusAction(ActionEvent event) {
|
||||
|
||||
// 在新新窗口中显示 状态消息 Model# messages
|
||||
|
||||
Model selectedItem = viewTable.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ListView<MessageExt> listView = new ListView<>();
|
||||
listView.setItems(selectedItem.messages);
|
||||
listView.setCellFactory(v -> new ListCell<>() {
|
||||
@Override
|
||||
protected void updateItem(MessageExt item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item == null || empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
setText(item.getMessage());
|
||||
setGraphic(new Label(item.getPrefix()));
|
||||
}
|
||||
}
|
||||
});
|
||||
PopOver popOver = new PopOver(listView);
|
||||
popOver.setArrowLocation(PopOver.ArrowLocation.TOP_LEFT);
|
||||
MenuItem menuItem = (MenuItem) event.getSource();
|
||||
Node node = viewTable.lookup(".table-row-cell:selected");
|
||||
popOver.show(node);
|
||||
}
|
||||
|
||||
public void onExportVerifyResultAsFileAction(ActionEvent e) {
|
||||
FileChooser chooser = new FileChooser();
|
||||
chooser.setTitle("导出核验结果");
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.ecep.contract.controller.employee;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.ecep.contract.controller.tab.TabSkin;
|
||||
@@ -48,7 +50,7 @@ public class EmployeeTabSkinRole
|
||||
|
||||
private void initializeListView() {
|
||||
// 非系统内置账户
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
Map<String, Object> params = ParamUtils.builder().build();
|
||||
List<EmployeeRoleVo> roles = getEmployeeRoleService().findAll(params, Pageable.ofSize(500)).getContent();
|
||||
|
||||
controller.rolesField.getSourceItems().setAll(roles);
|
||||
|
||||
@@ -39,13 +39,13 @@ public class CompanyCustomerFileTypeService
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Caching(put = { @CachePut(key = "#p0.id"), @CachePut(key = "'all'") })
|
||||
@Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'all'")})
|
||||
@Override
|
||||
public CustomerFileTypeLocalVo save(CustomerFileTypeLocalVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(put = { @CachePut(key = "#p0.id"), @CachePut(key = "'all'") })
|
||||
@Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'all'")})
|
||||
@Override
|
||||
public void delete(CustomerFileTypeLocalVo entity) {
|
||||
super.delete(entity);
|
||||
@@ -53,8 +53,7 @@ public class CompanyCustomerFileTypeService
|
||||
|
||||
@Cacheable
|
||||
public Map<CustomerFileType, CustomerFileTypeLocalVo> findAll(Locale locale) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("lang", locale.toLanguageTag());
|
||||
Map<String, Object> params = ParamUtils.builder().equals("lang", locale.toLanguageTag()).build();
|
||||
return findAll(params, Pageable.unpaged()).stream()
|
||||
.collect(Collectors.toMap(CustomerFileTypeLocalVo::getType, Function.identity()));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyInvoiceInfoViewModel;
|
||||
import com.ecep.contract.vo.CompanyInvoiceInfoVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
@@ -15,9 +16,8 @@ import java.util.Map;
|
||||
public class CompanyInvoiceInfoService extends QueryService<CompanyInvoiceInfoVo, CompanyInvoiceInfoViewModel> {
|
||||
|
||||
public List<CompanyInvoiceInfoVo> searchByCompany(CompanyVo company, String searchText) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("company", company);
|
||||
params.put("searchText", searchText);
|
||||
Map<String, Object> params = ParamUtils.builder().equals("company", company.getId())
|
||||
.search(searchText).build();
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -58,8 +59,7 @@ public class CompanyService extends QueryService<CompanyVo, CompanyViewModel> {
|
||||
}
|
||||
|
||||
public List<CompanyVo> findAllByName(String name) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("name", name);
|
||||
Map<String, Object> params = ParamUtils.builder().equals("name", name).build();
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@ import com.ecep.contract.vo.ContractVo;
|
||||
|
||||
@Service
|
||||
public class ContractFileService extends QueryService<ContractFileVo, ContractFileViewModel> {
|
||||
|
||||
@Override
|
||||
public ContractFileVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public List<ContractFileVo> findAllByContract(ContractVo contract) {
|
||||
return findAll(ParamUtils.equal("contract", contract.getId()), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ public class ProjectSaleTypeService extends QueryService<ProjectSaleTypeVo, Proj
|
||||
}
|
||||
|
||||
public ProjectSaleTypeVo findByCode(String code) {
|
||||
return findAll(ParamUtils.builder().equals("code", code).build(), Pageable.ofSize(1)).getContent().getFirst();
|
||||
return findOneByProperty("code", code);
|
||||
}
|
||||
|
||||
public ProjectSaleTypeVo findByName(String name) {
|
||||
return findAll(ParamUtils.builder().equals("name", name).build(), Pageable.ofSize(1)).getContent().getFirst();
|
||||
return findOneByProperty("name", name);
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(key = "#p0.id")})
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ecep.contract.service;
|
||||
import com.ecep.contract.PageArgument;
|
||||
import com.ecep.contract.PageContent;
|
||||
import com.ecep.contract.WebSocketClientService;
|
||||
import com.ecep.contract.constant.ServiceConstant;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.model.NamedEntity;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
@@ -67,7 +68,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
@Override
|
||||
public T save(T entity) {
|
||||
try {
|
||||
return async("save", entity, entity.getClass().getName()).handle((response, ex) -> {
|
||||
return async(ServiceConstant.SAVE_METHOD_NAME, entity, entity.getClass().getName()).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("保存实体失败", ex);
|
||||
}
|
||||
@@ -88,7 +89,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
@Override
|
||||
public void delete(T entity) {
|
||||
try {
|
||||
async("delete", entity, entity.getClass().getName()).handle((response, ex) -> {
|
||||
async(ServiceConstant.DELETE_METHOD_NAME, entity, entity.getClass().getName()).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("删除实体失败", ex);
|
||||
}
|
||||
@@ -117,7 +118,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
}
|
||||
|
||||
public CompletableFuture<T> asyncFindById(Integer id) {
|
||||
return async("findById", id, Integer.class).handle((response, ex) -> {
|
||||
return async(ServiceConstant.FIND_BY_ID_METHOD_NAME, id, Integer.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("查询实体失败", ex);
|
||||
}
|
||||
@@ -149,7 +150,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
*/
|
||||
public CompletableFuture<Page<T>> asyncFindAll(Map<String, Object> params, Pageable pageable) {
|
||||
// 调用async方法发送WebSocket请求,获取异步响应结果
|
||||
return async("findAll", params, PageArgument.of(pageable)).handle((response, ex) -> {
|
||||
return async(ServiceConstant.FIND_ALL_METHOD_NAME, params, PageArgument.of(pageable)).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findAll+调用失败", ex);
|
||||
}
|
||||
@@ -188,8 +189,9 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
}
|
||||
|
||||
public T findOneByProperty(String propertyName, Object propertyValue) {
|
||||
return findAll(ParamUtils.builder().equals(propertyName, propertyValue).build(), Pageable.ofSize(1)).stream()
|
||||
.findFirst().orElse(null);
|
||||
ParamUtils.Builder paramBuilder = ParamUtils.builder().equals(propertyName, propertyValue);
|
||||
Page<T> page = findAll(paramBuilder.build(), Pageable.ofSize(1));
|
||||
return page.stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +203,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
public CompletableFuture<Long> asyncCount(Map<String, Object> params) {
|
||||
// 调用async方法执行名为"count"的异步操作,传入参数params
|
||||
// 使用handle方法处理异步操作的结果或异常
|
||||
return async("count", params).handle((response, ex) -> {
|
||||
return async(ServiceConstant.COUNT_METHOD_NAME, params).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+count+调用失败", ex);
|
||||
}
|
||||
|
||||
@@ -373,7 +373,10 @@ public class ContractVerifyComm implements BeanContext {
|
||||
}
|
||||
|
||||
CompanyVo company = getCompanyService().findById(bidVendor.getCompanyId());
|
||||
ContractFileVo contractFile = fileService.findById(bidVendor.getQuotationSheetFileId());
|
||||
ContractFileVo contractFile = null;
|
||||
if (bidVendor.getQuotationSheetFileId() != null) {
|
||||
contractFile = fileService.findById(bidVendor.getQuotationSheetFileId());
|
||||
}
|
||||
// 报价表文件不存在
|
||||
if (contractFile == null) {
|
||||
if (requireQuotation && bidVendor.getCompanyId().equals(contract.getCompanyId())) {
|
||||
|
||||
@@ -4,7 +4,8 @@ import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
|
||||
@@ -16,64 +17,65 @@ public class ParamUtils {
|
||||
/**
|
||||
* 创建日期范围查询参数
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param field 查询字段名
|
||||
* @param begin 开始日期
|
||||
* @param end 结束日期
|
||||
* @return 包含日期范围的查询参数Map
|
||||
*/
|
||||
public static Map<String, Object> between(String key, LocalDate begin, LocalDate end) {
|
||||
return Map.of(key, Map.of(
|
||||
"begin", begin,
|
||||
"end", end));
|
||||
public static Map<String, Object> between(String field, LocalDate begin, LocalDate end) {
|
||||
Builder builder = builder();
|
||||
builder.between(field, begin, end);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建等于条件查询参数
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param field 查询字段名
|
||||
* @param value 查询值
|
||||
* @return 包含等于条件的查询参数Map
|
||||
*/
|
||||
public static Map<String, Object> equal(String key, Object value) {
|
||||
return Map.of(key, value);
|
||||
public static Map<String, Object> equal(String field, Object value) {
|
||||
Builder builder = builder();
|
||||
builder.equals(field, value);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建字符串模糊查询参数
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param field 查询字段名
|
||||
* @param value 模糊查询的字符串值
|
||||
* @return 包含模糊查询条件的查询参数Map
|
||||
*/
|
||||
public static Map<String, Object> like(String key, String value) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(key, "%" + value + "%");
|
||||
return params;
|
||||
public static Map<String, Object> contains(String field, String value, boolean caseSensitive) {
|
||||
Builder builder = builder();
|
||||
builder.and().like(field, value, ParamConstant.Mode.CONTAINS, caseSensitive, false);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建日期模糊查询参数
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param value 模糊查询的日期值
|
||||
* @return 包含日期模糊查询条件的查询参数Map
|
||||
*/
|
||||
public static Map<String, Object> like(String key, LocalDate value) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(key, "%" + value + "%");
|
||||
return params;
|
||||
public static Map<String, Object> startsWith(String field, String value, boolean caseSensitive) {
|
||||
Builder builder = builder();
|
||||
builder.and().like(field, value, ParamConstant.Mode.STARTS_WITH, caseSensitive, false);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static Map<String, Object> endsWith(String field, String value, boolean caseSensitive) {
|
||||
Builder builder = builder();
|
||||
builder.and().like(field, value, ParamConstant.Mode.ENDS_WITH, caseSensitive, false);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建非空条件查询参数
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param field 查询字段名
|
||||
* @return 包含非空条件的查询参数Map
|
||||
*/
|
||||
public static Map<String, Object> isNotNull(String key) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(key, Map.of("isNotNull", true));
|
||||
return params;
|
||||
public static Map<String, Object> isNotNull(String field) {
|
||||
Builder builder = builder();
|
||||
builder.isNotNull(field);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,9 +86,22 @@ public class ParamUtils {
|
||||
* @return 包含小于条件的查询参数Map
|
||||
*/
|
||||
public static Map<String, Object> lessThan(String key, LocalDate value) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(key, Map.of("lessThan", value));
|
||||
return params;
|
||||
Builder builder = builder();
|
||||
builder.lessThan(key, value);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建大于条件的日期查询参数
|
||||
*
|
||||
* @param key 查询字段名
|
||||
* @param value 比较的日期值
|
||||
* @return 包含大于条件的查询参数Map
|
||||
*/
|
||||
public static Map<String, Object> greaterThan(String key, LocalDate value) {
|
||||
Builder builder = builder();
|
||||
builder.greaterThan(key, value);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +120,7 @@ public class ParamUtils {
|
||||
public static class Builder {
|
||||
// 存储构建的查询参数
|
||||
private String searchText;
|
||||
private Map<String, Object> params = new HashMap<>();
|
||||
private FilterGroup group;
|
||||
|
||||
/**
|
||||
* 私有构造方法,防止外部直接实例化
|
||||
@@ -114,18 +129,6 @@ public class ParamUtils {
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
private void addParam(String field, String action, Object value) {
|
||||
Object map = params.computeIfAbsent(field, k -> new HashMap<>());
|
||||
if (map instanceof Map) {
|
||||
((Map) map).put(action, value);
|
||||
return;
|
||||
}
|
||||
HashMap<String, Object> m = new HashMap<>();
|
||||
m.put(action, value);
|
||||
m.put(ParamConstant.KEY_equal, map);
|
||||
params.put(field, m);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加非空条件到构建器
|
||||
*
|
||||
@@ -133,7 +136,7 @@ public class ParamUtils {
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
*/
|
||||
public Builder isNotNull(String key) {
|
||||
addParam(key, ParamConstant.KEY_isNotNull, true);
|
||||
getDefaultGroup().isNotNull(key);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -145,7 +148,7 @@ public class ParamUtils {
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
*/
|
||||
public Builder lessThan(String key, LocalDate value) {
|
||||
addParam(key, ParamConstant.KEY_lessThan, value);
|
||||
getDefaultGroup().lessThan(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -157,7 +160,7 @@ public class ParamUtils {
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
*/
|
||||
public Builder greaterThan(String key, LocalDate value) {
|
||||
addParam(key, ParamConstant.KEY_greaterThan, value);
|
||||
getDefaultGroup().greaterThan(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -169,7 +172,7 @@ public class ParamUtils {
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
*/
|
||||
public Builder equals(String key, Object value) {
|
||||
addParam(key, ParamConstant.KEY_equal, value);
|
||||
getDefaultGroup().equals(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -182,10 +185,16 @@ public class ParamUtils {
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
*/
|
||||
public Builder between(String key, LocalDate begin, LocalDate end) {
|
||||
addParam(key, ParamConstant.KEY_between, new Object[]{begin, end});
|
||||
getDefaultGroup().between(key, begin, end);
|
||||
return this;
|
||||
}
|
||||
|
||||
private FilterGroup getDefaultGroup() {
|
||||
if (group != null) {
|
||||
return group;
|
||||
}
|
||||
return and();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加全文搜索条件到构建器
|
||||
@@ -200,56 +209,337 @@ public class ParamUtils {
|
||||
|
||||
/**
|
||||
* 构建并返回查询参数Map
|
||||
* 推荐的结构(仅为契约示例,服务端需配套解析):
|
||||
*
|
||||
* <pre>
|
||||
* {
|
||||
* searchText: "搜索文本",
|
||||
* and: [
|
||||
* {field: "字段名", action: "equal", value: "值"},
|
||||
* {field: "字段名", action: "between", value: [begin, end]}
|
||||
* {field: "字段名", action: "or", value: [
|
||||
* {field: "字段名", action: "equal", value: "值"},
|
||||
* ]}
|
||||
* ],
|
||||
* or: [
|
||||
* {field: "字段名", action: "操作符", value: "值"}
|
||||
* ]
|
||||
* "searchText": "关键词",
|
||||
* "filter": {
|
||||
* "op": "and",
|
||||
* "conditions": [
|
||||
* { "field": "code", "op": "equal", "value": "V-0001" },
|
||||
* {
|
||||
* "field": "createdDate",
|
||||
* "op": "between",
|
||||
* "value": {
|
||||
* "begin": "2024-01-01",
|
||||
* "end": "2024-12-31",
|
||||
* "includeBegin": true,
|
||||
* "includeEnd": false
|
||||
* }
|
||||
* },
|
||||
* {
|
||||
* "field": "name",
|
||||
* "op": "like",
|
||||
* "value": "元素",
|
||||
* "mode": "contains",
|
||||
* "caseSensitive": false
|
||||
* },
|
||||
* {
|
||||
* "op": "or",
|
||||
* "conditions": [
|
||||
* { "field": "name", "op": "like", "value": "元素", "mode": "contains", "caseSensitive": false },
|
||||
* { "field": "abbName", "op": "like", "value": "元素", "mode": "contains", "caseSensitive": false }
|
||||
* ]
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* 约定说明:
|
||||
* - 分组节点:{ op: "and"|"or", conditions: [...] }
|
||||
* - 叶子条件:{ field: "路径", op: "equal"|"between"|..., value: ... }
|
||||
* - like 扩展:支持 mode("contains"|"startsWith"|"endsWith") 和
|
||||
* caseSensitive(boolean)
|
||||
* - between 扩展:value 为对象,支持包含边界 includeBegin/includeEnd
|
||||
*
|
||||
* @return 包含所有添加条件的查询参数Map
|
||||
*/
|
||||
public Map<String, Object> build() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ParamConstant.KEY_SEARCH_TEXT, searchText);
|
||||
if (StringUtils.hasText(searchText)) {
|
||||
map.put(ParamConstant.KEY_SEARCH_TEXT, searchText);
|
||||
}
|
||||
if (group != null) {
|
||||
Map<String, Object> filter = new HashMap<>();
|
||||
filter.put(ParamConstant.KEY_OPERATOR, group.operator.name().toLowerCase());
|
||||
filter.put(ParamConstant.KEY_CONDITIONS, group.conditions);
|
||||
map.put(ParamConstant.KEY_FILTER, filter);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加AND逻辑条件组到构建器
|
||||
*
|
||||
* @param consumer Builder消费者,用于构建子条件
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
* @return 新建的分组实例,支持链式调用添加子条件
|
||||
*/
|
||||
public Builder and(Consumer<Builder> consumer) {
|
||||
Builder builder = new Builder();
|
||||
consumer.accept(builder);
|
||||
params.put(ParamConstant.KEY_AND, builder);
|
||||
return this;
|
||||
public FilterGroup and() {
|
||||
if (group == null) {
|
||||
group = new FilterGroup(ParamConstant.Operator.AND);
|
||||
} else {
|
||||
if (group.operator != ParamConstant.Operator.AND) {
|
||||
throw new IllegalArgumentException(" 当前是 " + group.operator + " 条件组不允许修改为 AND 条件");
|
||||
}
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加OR逻辑条件组到构建器
|
||||
*
|
||||
* @param consumer Builder消费者,用于构建子条件
|
||||
* @return 当前Builder实例,支持链式调用
|
||||
* @return 新建的分组实例,支持链式调用添加子条件
|
||||
*/
|
||||
public Builder or(Consumer<Builder> consumer) {
|
||||
Builder builder = new Builder();
|
||||
consumer.accept(builder);
|
||||
params.put(ParamConstant.KEY_OR, builder);
|
||||
return this;
|
||||
public FilterGroup or() {
|
||||
if (group == null) {
|
||||
group = new FilterGroup(ParamConstant.Operator.OR);
|
||||
} else {
|
||||
if (group.operator != ParamConstant.Operator.OR) {
|
||||
throw new IllegalArgumentException(" 当前是 " + group.operator + " 条件组不允许修改为 OR 条件");
|
||||
}
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤条件组,支持 AND/OR 逻辑组合
|
||||
*/
|
||||
public static class FilterGroup {
|
||||
private ParamConstant.Operator operator = ParamConstant.Operator.AND;
|
||||
List<Map<String, Object>> conditions = new java.util.ArrayList<>();
|
||||
|
||||
public FilterGroup(ParamConstant.Operator operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
// 添加叶子条件:equal(支持 ignoreNull)
|
||||
public FilterGroup equals(String field, Object value) {
|
||||
return equals(field, value, false);
|
||||
}
|
||||
|
||||
public FilterGroup equals(String field, Object value, boolean ignoreNull) {
|
||||
if (ignoreNull && isNullOrEmpty(value)) {
|
||||
return this;
|
||||
}
|
||||
Map<String, Object> leaf = new HashMap<>();
|
||||
leaf.put(ParamConstant.KEY_FIELD, field);
|
||||
leaf.put(ParamConstant.KEY_OPERATOR, ParamConstant.KEY_equal);
|
||||
leaf.put(ParamConstant.KEY_VALUE, value);
|
||||
if (ignoreNull) {
|
||||
leaf.put(ParamConstant.KEY_IGNORE_NULL, true);
|
||||
}
|
||||
conditions.add(leaf);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 添加叶子条件:between(对象形式 + 边界 + ignoreNull)
|
||||
public FilterGroup between(String field, LocalDate begin, LocalDate end) {
|
||||
return between(field, begin, end, true, true, false);
|
||||
}
|
||||
|
||||
public FilterGroup between(String field, LocalDate begin, LocalDate end,
|
||||
boolean includeBegin, boolean includeEnd, boolean ignoreNull) {
|
||||
boolean noBegin = begin == null;
|
||||
boolean noEnd = end == null;
|
||||
if (ignoreNull && noBegin && noEnd) {
|
||||
return this;
|
||||
}
|
||||
Map<String, Object> value = new HashMap<>();
|
||||
if (!noBegin) {
|
||||
value.put(ParamConstant.KEY_between_begin, begin);
|
||||
}
|
||||
if (!noEnd) {
|
||||
value.put(ParamConstant.KEY_between_end, end);
|
||||
}
|
||||
value.put(ParamConstant.KEY_INCLUDE_BEGIN, includeBegin);
|
||||
value.put(ParamConstant.KEY_INCLUDE_END, includeEnd);
|
||||
|
||||
Map<String, Object> leaf = new HashMap<>();
|
||||
leaf.put(ParamConstant.KEY_FIELD, field);
|
||||
leaf.put(ParamConstant.KEY_OPERATOR, ParamConstant.KEY_BETWEEN);
|
||||
leaf.put(ParamConstant.KEY_VALUE, value);
|
||||
if (ignoreNull) {
|
||||
leaf.put(ParamConstant.KEY_IGNORE_NULL, true);
|
||||
}
|
||||
conditions.add(leaf);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 添加叶子条件:lessThan(支持 ignoreNull)
|
||||
public FilterGroup lessThan(String field, LocalDate value) {
|
||||
return lessThan(field, value, false);
|
||||
}
|
||||
|
||||
public FilterGroup lessThan(String field, LocalDate value, boolean ignoreNull) {
|
||||
if (ignoreNull && value == null) {
|
||||
return this;
|
||||
}
|
||||
Map<String, Object> leaf = new HashMap<>();
|
||||
leaf.put(ParamConstant.KEY_FIELD, field);
|
||||
leaf.put(ParamConstant.KEY_OPERATOR, ParamConstant.KEY_lessThan);
|
||||
leaf.put(ParamConstant.KEY_VALUE, value);
|
||||
if (ignoreNull) {
|
||||
leaf.put(ParamConstant.KEY_IGNORE_NULL, true);
|
||||
}
|
||||
conditions.add(leaf);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 添加叶子条件:greaterThan(支持 ignoreNull)
|
||||
public FilterGroup greaterThan(String field, LocalDate value) {
|
||||
return greaterThan(field, value, false);
|
||||
}
|
||||
|
||||
public FilterGroup greaterThan(String field, LocalDate value, boolean ignoreNull) {
|
||||
if (ignoreNull && value == null) {
|
||||
return this;
|
||||
}
|
||||
Map<String, Object> leaf = new HashMap<>();
|
||||
leaf.put(ParamConstant.KEY_FIELD, field);
|
||||
leaf.put(ParamConstant.KEY_OPERATOR, ParamConstant.KEY_greaterThan);
|
||||
leaf.put(ParamConstant.KEY_VALUE, value);
|
||||
if (ignoreNull) {
|
||||
leaf.put(ParamConstant.KEY_IGNORE_NULL, true);
|
||||
}
|
||||
conditions.add(leaf);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 添加叶子条件:isNotNull
|
||||
public FilterGroup isNotNull(String field) {
|
||||
Map<String, Object> leaf = new HashMap<>();
|
||||
leaf.put(ParamConstant.KEY_FIELD, field);
|
||||
leaf.put(ParamConstant.KEY_OPERATOR, ParamConstant.KEY_isNotNull);
|
||||
leaf.put(ParamConstant.KEY_VALUE, true);
|
||||
conditions.add(leaf);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 添加叶子条件:like(支持 mode/caseSensitive/ignoreNull)
|
||||
public FilterGroup like(String field, String value) {
|
||||
return like(field, value, ParamConstant.Mode.CONTAINS, false, false);
|
||||
}
|
||||
|
||||
public FilterGroup like(String field, String value, ParamConstant.Mode mode, boolean caseSensitive,
|
||||
boolean ignoreNull) {
|
||||
if (ignoreNull && isNullOrEmpty(value)) {
|
||||
return this;
|
||||
}
|
||||
Map<String, Object> leaf = new HashMap<>();
|
||||
leaf.put(ParamConstant.KEY_FIELD, field);
|
||||
leaf.put(ParamConstant.KEY_OPERATOR, ParamConstant.KEY_like);
|
||||
leaf.put(ParamConstant.KEY_VALUE, value);
|
||||
// 使用枚举值作为模式输出
|
||||
leaf.put(ParamConstant.KEY_MODE, mode.name());
|
||||
leaf.put(ParamConstant.KEY_CASE_SENSITIVE, caseSensitive);
|
||||
if (ignoreNull) {
|
||||
leaf.put(ParamConstant.KEY_IGNORE_NULL, true);
|
||||
}
|
||||
conditions.add(leaf);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 添加叶子条件:notLike(支持 mode/caseSensitive/ignoreNull)
|
||||
public FilterGroup notLike(String field, String value) {
|
||||
return notLike(field, value, ParamConstant.Mode.CONTAINS, false, false);
|
||||
}
|
||||
|
||||
public FilterGroup notLike(String field, String value, ParamConstant.Mode mode, boolean caseSensitive,
|
||||
boolean ignoreNull) {
|
||||
if (ignoreNull && isNullOrEmpty(value)) {
|
||||
return this;
|
||||
}
|
||||
Map<String, Object> leaf = new HashMap<>();
|
||||
leaf.put(ParamConstant.KEY_FIELD, field);
|
||||
leaf.put(ParamConstant.KEY_OPERATOR, ParamConstant.KEY_notLike);
|
||||
leaf.put(ParamConstant.KEY_VALUE, value);
|
||||
// 使用枚举值作为模式输出
|
||||
leaf.put(ParamConstant.KEY_MODE, mode.name());
|
||||
leaf.put(ParamConstant.KEY_CASE_SENSITIVE, caseSensitive);
|
||||
if (ignoreNull) {
|
||||
leaf.put(ParamConstant.KEY_IGNORE_NULL, true);
|
||||
}
|
||||
conditions.add(leaf);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 添加叶子条件:in(空集合防护 + ignoreNull)
|
||||
public FilterGroup in(String field, java.util.Collection<?> values) {
|
||||
return in(field, values, false);
|
||||
}
|
||||
|
||||
public FilterGroup in(String field, java.util.Collection<?> values, boolean ignoreNull) {
|
||||
if (ignoreNull && (values == null || values.isEmpty())) {
|
||||
return this;
|
||||
}
|
||||
Map<String, Object> leaf = new HashMap<>();
|
||||
leaf.put(ParamConstant.KEY_FIELD, field);
|
||||
leaf.put(ParamConstant.KEY_OPERATOR, ParamConstant.KEY_in);
|
||||
leaf.put(ParamConstant.KEY_VALUE, values);
|
||||
if (ignoreNull) {
|
||||
leaf.put(ParamConstant.KEY_IGNORE_NULL, true);
|
||||
}
|
||||
conditions.add(leaf);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 添加叶子条件:notIn(空集合防护 + ignoreNull)
|
||||
public FilterGroup notIn(String field, java.util.Collection<?> values) {
|
||||
return notIn(field, values, false);
|
||||
}
|
||||
|
||||
public FilterGroup notIn(String field, java.util.Collection<?> values, boolean ignoreNull) {
|
||||
if (ignoreNull && (values == null || values.isEmpty())) {
|
||||
return this;
|
||||
}
|
||||
Map<String, Object> leaf = new HashMap<>();
|
||||
leaf.put(ParamConstant.KEY_FIELD, field);
|
||||
leaf.put(ParamConstant.KEY_OPERATOR, ParamConstant.KEY_notIn);
|
||||
leaf.put(ParamConstant.KEY_VALUE, values);
|
||||
if (ignoreNull) {
|
||||
leaf.put(ParamConstant.KEY_IGNORE_NULL, true);
|
||||
}
|
||||
conditions.add(leaf);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 嵌套分组:and / or(保持原有行为)
|
||||
public FilterGroup and() {
|
||||
FilterGroup group = new FilterGroup(ParamConstant.Operator.AND);
|
||||
Map<String, Object> child = new HashMap<>();
|
||||
child.put(ParamConstant.KEY_OPERATOR, ParamConstant.Operator.AND.name().toLowerCase());
|
||||
child.put(ParamConstant.KEY_CONDITIONS, group.conditions);
|
||||
conditions.add(child);
|
||||
return group;
|
||||
}
|
||||
|
||||
public FilterGroup or() {
|
||||
FilterGroup group = new FilterGroup(ParamConstant.Operator.OR);
|
||||
Map<String, Object> child = new HashMap<>();
|
||||
child.put(ParamConstant.KEY_OPERATOR, ParamConstant.Operator.OR.name().toLowerCase());
|
||||
child.put(ParamConstant.KEY_CONDITIONS, group.conditions);
|
||||
conditions.add(child);
|
||||
return group;
|
||||
}
|
||||
|
||||
// 辅助:空值判断(String/Collection/Array/null)
|
||||
private boolean isNullOrEmpty(Object value) {
|
||||
if (value == null) {
|
||||
return true;
|
||||
}
|
||||
if (value instanceof String s) {
|
||||
return !org.springframework.util.StringUtils.hasText(s);
|
||||
}
|
||||
if (value instanceof java.util.Collection<?> c) {
|
||||
return c.isEmpty();
|
||||
}
|
||||
if (value.getClass().isArray()) {
|
||||
return java.lang.reflect.Array.getLength(value) == 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,9 +105,9 @@
|
||||
<contextMenu>
|
||||
<ContextMenu>
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onShowContractDetailAction"
|
||||
text="合同详情"/>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onShowContractDetailAction" text="合同详情"/>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onContractReVerifyAction" text="重新验证"/>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onShowVerifyStatusAction" text="查看状态"/>
|
||||
</items>
|
||||
</ContextMenu>
|
||||
</contextMenu>
|
||||
|
||||
@@ -1,14 +1,43 @@
|
||||
package com.ecep.contract.constant;
|
||||
|
||||
public class ParamConstant {
|
||||
// 操作符常量
|
||||
public static final String KEY_like = "like";
|
||||
public static final String KEY_notLike = "notLike";
|
||||
public static final String KEY_in = "in";
|
||||
public static final String KEY_notIn = "notIn";
|
||||
public static final String KEY_isNotNull = "isNotNull";
|
||||
public static final String KEY_lessThan = "lessThan";
|
||||
public static final String KEY_greaterThan = "greaterThan";
|
||||
public static final String KEY_between = "between";
|
||||
|
||||
public static final String KEY_BETWEEN = "between";
|
||||
public static final String KEY_between_begin = "begin";
|
||||
public static final String KEY_between_end = "end";
|
||||
public static final String KEY_INCLUDE_BEGIN = "includeBegin";
|
||||
public static final String KEY_INCLUDE_END = "includeEnd";
|
||||
public static final String KEY_equal = "equal";
|
||||
|
||||
public static final String KEY_OR = "or";
|
||||
public static final String KEY_AND = "and";
|
||||
public static final String KEY_SEARCH_TEXT = "searchText";
|
||||
public static final String KEY_FILTER = "filter";
|
||||
public static final String KEY_OPERATOR = "op";
|
||||
public static final String KEY_CONDITIONS = "conditions";
|
||||
// 新增:统一字段与值的键名、like 配置、between 边界、忽略空值
|
||||
public static final String KEY_FIELD = "field";
|
||||
public static final String KEY_VALUE = "value";
|
||||
// 新增:like 的模式键名
|
||||
public static final String KEY_MODE = "mode";
|
||||
public static final String KEY_CASE_SENSITIVE = "caseSensitive";
|
||||
|
||||
public static final String KEY_IGNORE_NULL = "ignoreNull";
|
||||
|
||||
|
||||
|
||||
public enum Operator {
|
||||
OR, AND
|
||||
}
|
||||
// 新增:like 模式枚举
|
||||
public enum Mode {
|
||||
CONTAINS,
|
||||
STARTS_WITH,
|
||||
ENDS_WITH
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
package com.ecep.contract.constant;
|
||||
|
||||
public class ServiceConstant {
|
||||
public static final String COUNT_METHOD_NAME = "count";
|
||||
public static final String FIND_ALL_METHOD_NAME = "findAll";
|
||||
public static final String FIND_BY_ID_METHOD_NAME = "findById";
|
||||
public static final String DELETE_METHOD_NAME = "delete";
|
||||
public static final String SAVE_METHOD_NAME = "save";
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ecep.contract;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -10,9 +11,14 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.model.Voable;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import jakarta.persistence.criteria.Path;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 实体服务基类
|
||||
@@ -22,6 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
* @param <VO> VO类型
|
||||
* @param <ID> 主键类型
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
||||
/**
|
||||
* 获取实体数据访问层接口
|
||||
@@ -35,50 +42,408 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
|
||||
return getRepository().findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新实体实例
|
||||
* 设置默认值或必要的属性
|
||||
* 实例是游离态的,未存储到数据库
|
||||
*
|
||||
* @return 新实体实例
|
||||
*/
|
||||
public abstract T createNewEntity();
|
||||
|
||||
/**
|
||||
* 统计所有实体数量
|
||||
*
|
||||
* @return 实体数量
|
||||
*/
|
||||
public long count() {
|
||||
return getRepository().count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据查询规范统计实体数量
|
||||
*
|
||||
* @param spec 查询规范
|
||||
* @return 符合规范的实体数量
|
||||
*/
|
||||
public long count(Specification<T> spec) {
|
||||
return getRepository().count(spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据JSON参数节点统计实体数量
|
||||
*
|
||||
* @param paramsNode JSON参数节点
|
||||
* @return 符合参数节点规范的实体数量
|
||||
*/
|
||||
public long count(JsonNode paramsNode) {
|
||||
return getRepository().count(buildParameterSpecification(paramsNode));
|
||||
return count(applyJsonParameter(paramsNode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存实体到数据库
|
||||
*
|
||||
* @param entity 要保存的实体
|
||||
* @return 保存后的实体
|
||||
*/
|
||||
public T save(T entity) {
|
||||
return getRepository().save(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除实体
|
||||
*
|
||||
* @param entity 要删除的实体
|
||||
*/
|
||||
public void delete(T entity) {
|
||||
getRepository().delete(entity);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected abstract Specification<T> buildParameterSpecification(JsonNode paramsNode);
|
||||
|
||||
public Page<VO> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<T> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
/**
|
||||
* 应用JSON参数节点到查询规范
|
||||
*
|
||||
* @param node JSON参数节点
|
||||
* @return 应用参数节点后的查询规范
|
||||
*/
|
||||
protected Specification<T> applyJsonParameter(JsonNode node) {
|
||||
Specification<T> spec = SpecificationUtils.applySearchText(node, this::getSearchSpecification);
|
||||
JsonNode filterNode = node.get(ParamConstant.KEY_FILTER);
|
||||
if (filterNode != null) {
|
||||
Specification<T> childSpec = buildFilterCondition(filterNode);
|
||||
if (childSpec != null) {
|
||||
spec = SpecificationUtils.and(spec, childSpec);
|
||||
}
|
||||
}
|
||||
spec = SpecificationUtils.and(spec, buildParameterSpecification(paramsNode));
|
||||
return findAll(spec, pageable).map(T::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据JSON参数节点查询所有实体
|
||||
*
|
||||
* @param paramsNode JSON参数节点
|
||||
* @param pageable 分页信息
|
||||
* @return 符合参数节点规范的实体分页结果
|
||||
*/
|
||||
public Page<VO> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
return findAll(applyJsonParameter(paramsNode), pageable).map(T::toVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据查询规范查询所有实体
|
||||
*
|
||||
* @param spec 查询规范
|
||||
* @param pageable 分页信息
|
||||
* @return 符合规范的实体分页结果
|
||||
*/
|
||||
public Page<T> findAll(Specification<T> spec, Pageable pageable) {
|
||||
return getRepository().findAll(spec, pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据查询规范查询所有实体
|
||||
*
|
||||
* @param spec 查询规范
|
||||
* @param sort 排序信息
|
||||
* @return 符合规范的实体列表
|
||||
*/
|
||||
public List<T> findAll(Specification<T> spec, Sort sort) {
|
||||
return getRepository().findAll(spec, sort);
|
||||
}
|
||||
|
||||
protected abstract Specification<T> buildSearchSpecification(String searchText);
|
||||
/**
|
||||
* 根据搜索文本查询所有实体
|
||||
*
|
||||
* @param searchText 搜索文本
|
||||
* @return 符合搜索文本规范的实体列表
|
||||
*/
|
||||
public List<T> search(String searchText) {
|
||||
Specification<T> spec = getSearchSpecification(searchText);
|
||||
return getRepository().findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
public Specification<T> getSpecification(String searchText) {
|
||||
/**
|
||||
* 根据搜索文本构建查询规范
|
||||
*
|
||||
* @param searchText 搜索文本
|
||||
* @return 符合搜索文本规范的查询规范
|
||||
*/
|
||||
public Specification<T> getSearchSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
|
||||
}
|
||||
|
||||
public List<T> search(String searchText) {
|
||||
Specification<T> spec = getSpecification(searchText);
|
||||
return getRepository().findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
/**
|
||||
* 构建搜索规范
|
||||
*
|
||||
* @param searchText 搜索文本,非空
|
||||
* @return 符合搜索文本规范的查询规范
|
||||
*/
|
||||
protected abstract Specification<T> buildSearchSpecification(String searchText);
|
||||
|
||||
/**
|
||||
* 构建过滤条件规范
|
||||
*
|
||||
* @param filterNode 过滤条件节点
|
||||
* @return 过滤条件规范
|
||||
*/
|
||||
private Specification<T> buildFilterCondition(JsonNode filterNode) {
|
||||
String operatorStr = filterNode.get(ParamConstant.KEY_OPERATOR).asText();
|
||||
|
||||
if (isAndOrOperator(operatorStr)) {
|
||||
if (filterNode.has(ParamConstant.KEY_CONDITIONS)) {
|
||||
JsonNode conditionsNode = filterNode.get(ParamConstant.KEY_CONDITIONS);
|
||||
if (conditionsNode.isArray()) {
|
||||
List<Specification<T>> specs = new java.util.ArrayList<>();
|
||||
|
||||
for (JsonNode conditionNode : conditionsNode) {
|
||||
Specification<T> childSpec = buildFilterCondition(conditionNode);
|
||||
if (childSpec != null) {
|
||||
specs.add(childSpec);
|
||||
}
|
||||
}
|
||||
if (!specs.isEmpty()) {
|
||||
ParamConstant.Operator op = ParamConstant.Operator.AND;
|
||||
if (ParamConstant.Operator.OR.name().equalsIgnoreCase(operatorStr)) {
|
||||
op = ParamConstant.Operator.OR;
|
||||
}
|
||||
return (op == ParamConstant.Operator.AND) ? Specification.allOf(specs)
|
||||
: Specification.anyOf(specs);
|
||||
}
|
||||
} else {
|
||||
log.debug("filterNode 中没有 conditions 数组");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String field = filterNode.get(ParamConstant.KEY_FIELD).asText();
|
||||
if (!StringUtils.hasText(field)) {
|
||||
log.debug("filterNode 中没有 field 字段");
|
||||
return null;
|
||||
}
|
||||
|
||||
field = aliasFor(field, filterNode);
|
||||
|
||||
if (ParamConstant.KEY_equal.equals(operatorStr)) {
|
||||
return buildEqualSpecification(field, filterNode);
|
||||
}
|
||||
if (ParamConstant.KEY_BETWEEN.equals(operatorStr)) {
|
||||
return buildBetweenSpecification(field, filterNode);
|
||||
}
|
||||
if (ParamConstant.KEY_like.equals(operatorStr)) {
|
||||
return buildLikeSpecification(field, filterNode);
|
||||
}
|
||||
if (ParamConstant.KEY_in.equals(operatorStr)) {
|
||||
return buildInSpecification(field, filterNode);
|
||||
}
|
||||
if (ParamConstant.KEY_notIn.equals(operatorStr)) {
|
||||
return buildNotInSpecification(field, filterNode);
|
||||
}
|
||||
if (ParamConstant.KEY_greaterThan.equals(operatorStr)) {
|
||||
return buildGreaterThanSpecification(field, filterNode);
|
||||
}
|
||||
if (ParamConstant.KEY_lessThan.equals(operatorStr)) {
|
||||
return buildLessThanSpecification(field, filterNode);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为查询字段添加别名
|
||||
*
|
||||
* @param field
|
||||
* @param filterNode
|
||||
* @return
|
||||
*/
|
||||
protected String aliasFor(String field, JsonNode filterNode) {
|
||||
return field;
|
||||
}
|
||||
|
||||
private <X extends Comparable<? super X>> Specification<T> buildLessThanSpecification(String field,
|
||||
JsonNode filterNode) {
|
||||
JsonNode valueNode = filterNode.get(ParamConstant.KEY_VALUE);
|
||||
if (valueNode == null || valueNode.isNull()) {
|
||||
log.debug("lessThan 操作符需要 value 字段");
|
||||
return null;
|
||||
}
|
||||
return (root, query, cb) -> {
|
||||
// 支持嵌套属性路径,如 company.id
|
||||
String[] fieldPath = field.split("\\.");
|
||||
Path<?> path = root;
|
||||
for (String segment : fieldPath) {
|
||||
path = path.get(segment);
|
||||
}
|
||||
Class<X> clz = (Class<X>) path.getJavaType();
|
||||
ObjectMapper objectMapper = SpringApp.getBean(ObjectMapper.class);
|
||||
X value = objectMapper.convertValue(valueNode, clz);
|
||||
return cb.lessThan(path.as(clz), value);
|
||||
};
|
||||
}
|
||||
|
||||
private Specification<T> buildGreaterThanSpecification(String field, JsonNode filterNode) {
|
||||
// TODO 实现大于操作符的逻辑
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildGreaterThanSpecification'");
|
||||
}
|
||||
|
||||
private Specification<T> buildNotInSpecification(String field, JsonNode filterNode) {
|
||||
// TODO 实现 NOT IN 操作符的逻辑
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildNotInSpecification'");
|
||||
}
|
||||
|
||||
private Specification<T> buildInSpecification(String field, JsonNode filterNode) {
|
||||
// TODO 实现 IN 操作符的逻辑
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildInSpecification'");
|
||||
}
|
||||
|
||||
private Specification<T> buildLikeSpecification(String field, JsonNode filterNode) {
|
||||
JsonNode valueNode = filterNode.get(ParamConstant.KEY_VALUE);
|
||||
if (valueNode == null || !valueNode.isTextual()) {
|
||||
log.debug("LIKE 操作符需要 value 为字符串");
|
||||
return null;
|
||||
}
|
||||
|
||||
ParamConstant.Mode mode = ParamConstant.Mode.CONTAINS;
|
||||
if (filterNode.has(ParamConstant.KEY_MODE)) {
|
||||
mode = ParamConstant.Mode.valueOf(filterNode.get(ParamConstant.KEY_MODE).asText());
|
||||
}
|
||||
|
||||
String likeValue;
|
||||
switch (mode) {
|
||||
case STARTS_WITH:
|
||||
likeValue = valueNode.asText() + "%";
|
||||
break;
|
||||
case ENDS_WITH:
|
||||
likeValue = "%" + valueNode.asText();
|
||||
break;
|
||||
default:
|
||||
likeValue = "%" + valueNode.asText() + "%";
|
||||
break;
|
||||
}
|
||||
return (root, query, cb) -> {
|
||||
// 支持 company.name 这种嵌套属性路径
|
||||
String[] fieldPath = field.split("\\.");
|
||||
Path<?> path = root;
|
||||
for (String segment : fieldPath) {
|
||||
path = path.get(segment);
|
||||
}
|
||||
return cb.like(path.as(String.class), likeValue);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 等于操作符的逻辑
|
||||
*
|
||||
* @param field
|
||||
* @param filterNode
|
||||
* @return
|
||||
*/
|
||||
private Specification<T> buildEqualSpecification(String field, JsonNode filterNode) {
|
||||
// 等于操作符的逻辑
|
||||
JsonNode valueNode = filterNode.get(ParamConstant.KEY_VALUE);
|
||||
if (valueNode == null || valueNode.isNull()) {
|
||||
return (root, query, cb) -> cb.isNull(root.get(field));
|
||||
}
|
||||
return (root, query, cb) -> {
|
||||
// 支持 company.id 这种嵌套属性路径
|
||||
String[] fieldPath = field.split("\\.");
|
||||
Path<?> path = root;
|
||||
for (String segment : fieldPath) {
|
||||
path = path.get(segment);
|
||||
}
|
||||
Class<?> clz = path.getJavaType();
|
||||
if (IdentityEntity.class.isAssignableFrom(clz)) {
|
||||
if (valueNode.isNumber()) {
|
||||
return cb.equal(path.get("id"), valueNode.asInt());
|
||||
}
|
||||
|
||||
if (valueNode.isObject() && valueNode.has("id")) {
|
||||
JsonNode identity = valueNode.get("id");
|
||||
if (identity.isNumber()) {
|
||||
return cb.equal(path.get("id"), identity.asInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (clz == java.lang.Enum.class) {
|
||||
// 将字符串转换为对应的枚举值
|
||||
clz = ((SqmBasicValuedSimplePath) path).getExpressibleJavaType().getJavaTypeClass();
|
||||
}
|
||||
ObjectMapper objectMapper = SpringApp.getBean(ObjectMapper.class);
|
||||
Object value = null;
|
||||
try {
|
||||
value = objectMapper.convertValue(valueNode, clz);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("field=" + field + ", clz=" + clz.getName() + ", value=" + valueNode, e);
|
||||
}
|
||||
// Object value = valueNode.isTextual() ? valueNode.asText()
|
||||
// : valueNode.isNumber() ? valueNode.numberValue()
|
||||
// : valueNode.isBoolean() ? valueNode.asBoolean() : valueNode;
|
||||
return cb.equal(path, value);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* BETWEEN 操作符的逻辑
|
||||
*
|
||||
* @param field
|
||||
* @param filterNode
|
||||
* @return
|
||||
*/
|
||||
private <X extends Comparable<? super X>> Specification<T> buildBetweenSpecification(String field,
|
||||
JsonNode filterNode) {
|
||||
// BETWEEN 操作符:要求 value 为数组,且长度=2
|
||||
JsonNode valueNode = filterNode.get(ParamConstant.KEY_VALUE);
|
||||
JsonNode lowNode, highNode;
|
||||
boolean includeBegin = false, includeEnd = false;
|
||||
if (valueNode == null || valueNode.isNull()) {
|
||||
throw new IllegalArgumentException(field + " 的 BETWEEN 操作符需要参数");
|
||||
}
|
||||
if (valueNode.isArray()) {
|
||||
if (valueNode.size() != 2) {
|
||||
throw new IllegalArgumentException(field + " 的 BETWEEN 操作符的 value 数组长度必须为 2");
|
||||
}
|
||||
lowNode = valueNode.get(0);
|
||||
highNode = valueNode.get(1);
|
||||
} else if (valueNode.isObject()) {
|
||||
lowNode = valueNode.get(ParamConstant.KEY_between_begin);
|
||||
highNode = valueNode.get(ParamConstant.KEY_between_end);
|
||||
|
||||
if (valueNode.has(ParamConstant.KEY_INCLUDE_BEGIN)) {
|
||||
includeBegin = valueNode.get(ParamConstant.KEY_INCLUDE_BEGIN).asBoolean();
|
||||
}
|
||||
if (valueNode.has(ParamConstant.KEY_INCLUDE_END)) {
|
||||
includeEnd = valueNode.get(ParamConstant.KEY_INCLUDE_END).asBoolean();
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException(field + " 的 BETWEEN 操作符的 value 必须为数组或对象");
|
||||
}
|
||||
|
||||
if (lowNode == null || highNode == null || lowNode.isNull() || highNode.isNull()) {
|
||||
throw new IllegalArgumentException(field + " 的 BETWEEN 操作符的 value 数组元素不能为空");
|
||||
}
|
||||
|
||||
return (root, query, cb) -> {
|
||||
// 支持嵌套属性路径,如 company.id
|
||||
String[] fieldPath = field.split("\\.");
|
||||
Path<?> path = root;
|
||||
for (String segment : fieldPath) {
|
||||
path = path.get(segment);
|
||||
}
|
||||
Class<X> clz = (Class<X>) path.getJavaType();
|
||||
ObjectMapper objectMapper = SpringApp.getBean(ObjectMapper.class);
|
||||
X lowVal = objectMapper.convertValue(lowNode, clz);
|
||||
X highVal = objectMapper.convertValue(highNode, clz);
|
||||
return cb.between(path.as(clz), lowVal, highVal);
|
||||
};
|
||||
}
|
||||
|
||||
private boolean isAndOrOperator(String str) {
|
||||
return ParamConstant.Operator.AND.name().equalsIgnoreCase(str)
|
||||
|| ParamConstant.Operator.OR.name().equalsIgnoreCase(str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public interface IEntityService<T> {
|
||||
* @param searchText 要搜索的文本
|
||||
* @return 规格化查询
|
||||
*/
|
||||
Specification<T> getSpecification(String searchText);
|
||||
Specification<T> getSearchSpecification(String searchText);
|
||||
|
||||
/**
|
||||
* 根据搜索文本查询列表
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
package com.ecep.contract.cloud.rk;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -26,17 +20,19 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.BlackReasonType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.cloud.CloudInfo;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.model.CompanyBlackReason;
|
||||
import com.ecep.contract.ds.company.repository.CompanyBlackReasonRepository;
|
||||
import com.ecep.contract.ds.company.repository.CompanyOldNameRepository;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.other.model.CloudRk;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.HttpJsonUtils;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CloudRkVo;
|
||||
@@ -53,7 +49,8 @@ import lombok.Data;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "cloud-rk")
|
||||
public class CloudRkService implements IEntityService<CloudRk>, QueryService<CloudRkVo>, VoableService<CloudRk, CloudRkVo> {
|
||||
public class CloudRkService extends EntityService<CloudRk, CloudRkVo, Integer>
|
||||
implements IEntityService<CloudRk>, QueryService<CloudRkVo>, VoableService<CloudRk, CloudRkVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CloudRkService.class);
|
||||
|
||||
public static final String KEY_PROXY = "cloud.rk.proxy";
|
||||
@@ -93,46 +90,41 @@ public class CloudRkService implements IEntityService<CloudRk>, QueryService<Clo
|
||||
private boolean nowName;
|
||||
}
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SysConfService confService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CloudRkRepository cloudRKRepository;
|
||||
@Autowired
|
||||
private CompanyOldNameRepository companyOldNameRepository;
|
||||
@Autowired
|
||||
private CompanyBlackReasonRepository companyBlackReasonRepository;
|
||||
|
||||
@Override
|
||||
public CloudRk getById(Integer id) {
|
||||
return cloudRKRepository.findById(id).orElse(null);
|
||||
protected CloudRkRepository getRepository() {
|
||||
return cloudRKRepository;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public CloudRkVo findById(Integer id) {
|
||||
return cloudRKRepository.findById(id).map(CloudRk::toVo).orElse(null);
|
||||
return getRepository().findById(id).map(CloudRk::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CloudRkVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
public CloudRk createNewEntity() {
|
||||
return new CloudRk();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<CloudRk> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CloudRk> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "cloudId", "customerGrade", "customerScore", "vendorGrade", "vendorScore", "active", "version", "rank", "description");
|
||||
// 可以根据需要添加更多参数处理
|
||||
return findAll(spec, pageable).map(CloudRk::toVo);
|
||||
}
|
||||
|
||||
public Page<CloudRk> findAll(Specification<CloudRk> spec, Pageable pageable) {
|
||||
return cloudRKRepository.findAll(spec, pageable);
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "cloudId", "customerGrade", "customerScore",
|
||||
"vendorGrade", "vendorScore", "active", "version", "rank", "description");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CloudRk> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<CloudRk> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
Path<Object> company = root.get("company");
|
||||
return builder.or(
|
||||
@@ -143,6 +135,10 @@ public class CloudRkService implements IEntityService<CloudRk>, QueryService<Clo
|
||||
};
|
||||
}
|
||||
|
||||
public Page<CloudRk> findAll(Specification<CloudRk> spec, Pageable pageable) {
|
||||
return cloudRKRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
private void toCompanyBlackReasonList(
|
||||
Company company, BlackReasonType type,
|
||||
JsonNode reason, List<CompanyBlackReason> dbReasons,
|
||||
@@ -386,4 +382,5 @@ public class CloudRkService implements IEntityService<CloudRk>, QueryService<Clo
|
||||
|
||||
cloudRk.setVersion(vo.getVersion());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -27,6 +28,7 @@ import com.ecep.contract.cloud.CloudInfo;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.other.model.CloudTyc;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
@@ -35,7 +37,8 @@ import com.ecep.contract.vo.CloudTycVo;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "cloud-tyc")
|
||||
public class CloudTycService implements IEntityService<CloudTyc>, QueryService<CloudTycVo>, VoableService<CloudTyc, CloudTycVo> {
|
||||
public class CloudTycService extends EntityService<CloudTyc, CloudTycVo, Integer>
|
||||
implements IEntityService<CloudTyc>, QueryService<CloudTycVo>, VoableService<CloudTyc, CloudTycVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CloudTycService.class);
|
||||
|
||||
/**
|
||||
@@ -49,12 +52,18 @@ public class CloudTycService implements IEntityService<CloudTyc>, QueryService<C
|
||||
return fileName.contains(CloudServiceConstant.TYC_NAME);
|
||||
}
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CloudTycRepository cloudTycRepository;
|
||||
|
||||
@Override
|
||||
public CloudTyc getById(Integer id) {
|
||||
return cloudTycRepository.findById(id).orElse(null);
|
||||
protected CloudTycRepository getRepository() {
|
||||
return cloudTycRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudTyc createNewEntity() {
|
||||
return new CloudTyc();
|
||||
}
|
||||
|
||||
public CloudTyc getOrCreateCloudTyc(CloudInfo info) {
|
||||
@@ -163,30 +172,15 @@ public class CloudTycService implements IEntityService<CloudTyc>, QueryService<C
|
||||
return cloudTycRepository.findById(id).map(CloudTyc::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public Page<CloudTyc> findAll(Specification<CloudTyc> spec, PageRequest pageable) {
|
||||
return cloudTycRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public Page<CloudTyc> findAll(Specification<CloudTyc> spec, Pageable pageable) {
|
||||
return cloudTycRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CloudTycVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<CloudTyc> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CloudTyc> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
// 可以根据需要添加更多参数处理
|
||||
return findAll(spec, pageable).map(CloudTyc::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CloudTyc> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<CloudTyc> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.like(root.get("cloudId"), "%" + searchText + "%");
|
||||
};
|
||||
@@ -227,4 +221,5 @@ public class CloudTycService implements IEntityService<CloudTyc>, QueryService<C
|
||||
}
|
||||
cloudTyc.setVersion(vo.getVersion());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ContractGroupSyncTask extends Tasker<Object> implements WebSocketSe
|
||||
ContractGroupService service = getContractGroupService();
|
||||
var contractGroup = service.findByCode(groupCode);
|
||||
if (contractGroup == null) {
|
||||
var newGroup = service.newContractGroup();
|
||||
var newGroup = service.createNewEntity();
|
||||
newGroup.setCode(groupCode);
|
||||
newGroup.setName(groupName);
|
||||
newGroup.setTitle(groupTitle);
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package com.ecep.contract.cloud.u8;
|
||||
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
@@ -11,13 +18,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||
|
||||
@Lazy
|
||||
@Repository
|
||||
@@ -36,7 +37,6 @@ public class YongYouU8Repository {
|
||||
return jdbcTemplate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回 U8 系统中 供应商总数
|
||||
*
|
||||
@@ -57,11 +57,9 @@ public class YongYouU8Repository {
|
||||
"cVCCode,cVenAddress,cast(dVenDevDate as DATE) as venDevDate," +
|
||||
"cVenBank, cVenAccount, cCreatePerson,cModifyPerson,dModifyDate " +
|
||||
"from Vendor",
|
||||
new ColumnMapRowMapper()
|
||||
);
|
||||
new ColumnMapRowMapper());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 以 U8 供应商 的代码查询 供应商
|
||||
*
|
||||
@@ -102,8 +100,7 @@ public class YongYouU8Repository {
|
||||
"cCCCode,cCusAddress,cast(dCusDevDate as DATE) as cusDevDate," +
|
||||
"cCusBank,cCusAccount, cCreatePerson,cModifyPerson,dModifyDate " +
|
||||
"from Customer",
|
||||
new ColumnMapRowMapper()
|
||||
);
|
||||
new ColumnMapRowMapper());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,30 +143,27 @@ public class YongYouU8Repository {
|
||||
return getJdbcTemplate().queryForObject(
|
||||
"select count(*) " +
|
||||
"from CM_Contract_B " +
|
||||
"where strSetupDate>=? or (dtVaryDate is not null and dtVaryDate>=?)"
|
||||
, Long.class, latestDate, latestDate);
|
||||
"where strSetupDate>=? or (dtVaryDate is not null and dtVaryDate>=?)",
|
||||
Long.class, latestDate, latestDate);
|
||||
}
|
||||
|
||||
public Stream<Map<String, Object>> queryAllContractForStream() {
|
||||
return getJdbcTemplate().queryForStream(
|
||||
"select * from CM_List", new ColumnMapRowMapper()
|
||||
);
|
||||
"select * from CM_List", new ColumnMapRowMapper());
|
||||
}
|
||||
|
||||
public Stream<Map<String, Object>> queryAllContractForStream(int latestId) {
|
||||
return getJdbcTemplate().queryForStream(
|
||||
"select * from CM_List where ID > ?",
|
||||
new ColumnMapRowMapper(),
|
||||
latestId
|
||||
);
|
||||
latestId);
|
||||
}
|
||||
|
||||
public Stream<Map<String, Object>> queryAllContractForStream(LocalDateTime dateTime) {
|
||||
return getJdbcTemplate().queryForStream(
|
||||
"select * from CM_List where dtDate > ?",
|
||||
new ColumnMapRowMapper(),
|
||||
dateTime
|
||||
);
|
||||
dateTime);
|
||||
}
|
||||
|
||||
public Stream<Map<String, Object>> queryAllContractBForStream() {
|
||||
@@ -188,8 +182,7 @@ public class YongYouU8Repository {
|
||||
"strPersonID, " +
|
||||
"dblTotalCurrency,dblExecCurrency,dblTotalQuantity,dblExecQuqantity " +
|
||||
"from CM_Contract_B ",
|
||||
new ColumnMapRowMapper()
|
||||
);
|
||||
new ColumnMapRowMapper());
|
||||
}
|
||||
|
||||
public Stream<Map<String, Object>> queryAllContractBForStream(LocalDate latestDate) {
|
||||
@@ -208,8 +201,7 @@ public class YongYouU8Repository {
|
||||
"strPersonID, " +
|
||||
"dblTotalCurrency,dblExecCurrency,dblTotalQuantity,dblExecQuqantity " +
|
||||
"from CM_Contract_B where strSetupDate>=? or (dtVaryDate is not null and dtVaryDate>=?)",
|
||||
new ColumnMapRowMapper(), latestDate, latestDate
|
||||
);
|
||||
new ColumnMapRowMapper(), latestDate, latestDate);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,25 +226,26 @@ public class YongYouU8Repository {
|
||||
"strPersonID, " +
|
||||
"dblTotalCurrency,dblExecCurrency,dblTotalQuantity,dblExecQuqantity " +
|
||||
"from CM_Contract_B where strBisectionUnit=? and strWay=?",
|
||||
new ColumnMapRowMapper(), unit, payWay.getText()
|
||||
);
|
||||
new ColumnMapRowMapper(), unit, payWay.getText());
|
||||
}
|
||||
|
||||
public Map<String, Object> queryContractDetail(String guid) {
|
||||
return getJdbcTemplate().queryForObject("select GUID,strContractID,strContractName,strContractType,strParentID,strContractKind,strWay," +
|
||||
"strContractGrp, strContractDesc,strBisectionUnit," +
|
||||
// 时间
|
||||
"strContractOrderDate,strContractStartDate,strContractEndDate," +
|
||||
// 创建人和时间
|
||||
"strSetupPerson,strSetupDate," +
|
||||
// 生效人和时间
|
||||
"strInurePerson,strInureDate," +
|
||||
// 修改人和时间
|
||||
"strVaryPerson,dtVaryDate," +
|
||||
// 业务员
|
||||
"strPersonID, " +
|
||||
"dblTotalCurrency,dblExecCurrency,dblTotalQuantity,dblExecQuqantity " +
|
||||
" from CM_Contract_B where GUID = ?", new ColumnMapRowMapper(), guid);
|
||||
return getJdbcTemplate().queryForObject(
|
||||
"select GUID,strContractID,strContractName,strContractType,strParentID,strContractKind,strWay," +
|
||||
"strContractGrp, strContractDesc,strBisectionUnit," +
|
||||
// 时间
|
||||
"strContractOrderDate,strContractStartDate,strContractEndDate," +
|
||||
// 创建人和时间
|
||||
"strSetupPerson,strSetupDate," +
|
||||
// 生效人和时间
|
||||
"strInurePerson,strInureDate," +
|
||||
// 修改人和时间
|
||||
"strVaryPerson,dtVaryDate," +
|
||||
// 业务员
|
||||
"strPersonID, " +
|
||||
"dblTotalCurrency,dblExecCurrency,dblTotalQuantity,dblExecQuqantity " +
|
||||
" from CM_Contract_B where GUID = ?",
|
||||
new ColumnMapRowMapper(), guid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,9 +255,12 @@ public class YongYouU8Repository {
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
public Map<String, Object> sumContractExec(String code) {
|
||||
return getJdbcTemplate().queryForObject("select sum(decCount) as execQuantity, sum(decRateMoney) as execAmount, sum(decNoRateMoney) as execUnTaxAmount " +
|
||||
"from CM_ExecInterface " +
|
||||
"where cContractID = ?;", new ColumnMapRowMapper(), code);
|
||||
return getJdbcTemplate().queryForObject(
|
||||
"select sum(decCount) as execQuantity, sum(decRateMoney) as execAmount, sum(decNoRateMoney) as execUnTaxAmount "
|
||||
+
|
||||
"from CM_ExecInterface " +
|
||||
"where cContractID = ?;",
|
||||
new ColumnMapRowMapper(), code);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> findAllContractExecByContractCode(String code) {
|
||||
@@ -293,7 +289,6 @@ public class YongYouU8Repository {
|
||||
" from PO_Pomain where POID = ?", new ColumnMapRowMapper(), code);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 采购合同项
|
||||
*
|
||||
@@ -321,7 +316,9 @@ public class YongYouU8Repository {
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
public Map<String, Object> queryInventoryDetail(String code) {
|
||||
return getJdbcTemplate().queryForObject("select I.*, U.cComUnitName from Inventory as I left join ComputationUnit as U on I.cComUnitCode=U.cComunitCode where cInvCode = ?", new ColumnMapRowMapper(), code);
|
||||
return getJdbcTemplate().queryForObject(
|
||||
"select I.*, U.cComUnitName from Inventory as I left join ComputationUnit as U on I.cComUnitCode=U.cComunitCode where cInvCode = ?",
|
||||
new ColumnMapRowMapper(), code);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> queryAllPerson() {
|
||||
@@ -350,13 +347,13 @@ public class YongYouU8Repository {
|
||||
return getJdbcTemplate().queryForList("select cCCCode, cCCName, iCCGrade from CustomerClass;");
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String, Object>> findAllPurchaseBillVoucherByVendorCode(String code) {
|
||||
return getJdbcTemplate().queryForList("select * from PurBillVouch where cVenCode=?", code);
|
||||
}
|
||||
|
||||
public Map<String, Object> findPurchaseBillVoucherById(Integer pbvId) {
|
||||
return getJdbcTemplate().queryForObject("select * from PurBillVouch where PBVID = ?", new ColumnMapRowMapper(), pbvId);
|
||||
return getJdbcTemplate().queryForObject("select * from PurBillVouch where PBVID = ?", new ColumnMapRowMapper(),
|
||||
pbvId);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> findAllPurchaseBillVoucherItemByPbvId(int pbvId) {
|
||||
|
||||
@@ -22,6 +22,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -38,7 +39,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "cloud-yu")
|
||||
public class YongYouU8Service
|
||||
public class YongYouU8Service extends EntityService<CloudYu, CloudYuVo, Integer>
|
||||
implements IEntityService<CloudYu>, QueryService<CloudYuVo>, VoableService<CloudYu, CloudYuVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(YongYouU8Service.class);
|
||||
|
||||
@@ -61,6 +62,11 @@ public class YongYouU8Service
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudYuRepository getRepository() {
|
||||
return cloudYuRepository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#id")
|
||||
public CloudYuVo findById(Integer id) {
|
||||
Optional<CloudYu> optional = cloudYuRepository.findById(id);
|
||||
@@ -68,8 +74,8 @@ public class YongYouU8Service
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudYu getById(Integer id) {
|
||||
return cloudYuRepository.findById(id).orElse(null);
|
||||
public CloudYu createNewEntity() {
|
||||
return new CloudYu();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,13 +126,13 @@ public class YongYouU8Service
|
||||
* @param cloudYu Cloud Yu 对象
|
||||
* @return 更新的 Cloud Yu
|
||||
*/
|
||||
@Caching(evict = {@CacheEvict(key = "#cloudYu.id")})
|
||||
@Caching(evict = { @CacheEvict(key = "#cloudYu.id") })
|
||||
@Override
|
||||
public CloudYu save(CloudYu cloudYu) {
|
||||
return cloudYuRepository.save(cloudYu);
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(key = "#cloudYu.id")})
|
||||
@Caching(evict = { @CacheEvict(key = "#cloudYu.id") })
|
||||
@Override
|
||||
public void delete(CloudYu vo) {
|
||||
CloudYu entity = cloudYuRepository.findById(vo.getId()).orElse(null);
|
||||
@@ -157,26 +163,15 @@ public class YongYouU8Service
|
||||
cloudYuRepository.saveAll(list);
|
||||
}
|
||||
|
||||
public Page<CloudYu> findAll(Specification<CloudYu> spec, Pageable pageable) {
|
||||
return cloudYuRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CloudYuVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<CloudYu> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CloudYu> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
String searchText = paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText();
|
||||
spec = getSpecification(searchText);
|
||||
}
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable).map(CloudYu::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CloudYu> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<CloudYu> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.like(root.get("cloudId"), "%" + searchText + "%");
|
||||
};
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
package com.ecep.contract.ds.company.repository;
|
||||
|
||||
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 com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.company.model.CompanyInvoiceInfo;
|
||||
|
||||
/**
|
||||
* 公司发票信息 Repository
|
||||
*/
|
||||
@Repository
|
||||
public interface CompanyInvoiceInfoRepository extends
|
||||
// JDBC interfaces
|
||||
CrudRepository<CompanyInvoiceInfo, Integer>, PagingAndSortingRepository<CompanyInvoiceInfo, Integer>,
|
||||
// JPA interfaces
|
||||
JpaRepository<CompanyInvoiceInfo, Integer>, JpaSpecificationExecutor<CompanyInvoiceInfo> {
|
||||
public interface CompanyInvoiceInfoRepository extends MyRepository<CompanyInvoiceInfo, Integer> {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,22 +2,15 @@ package com.ecep.contract.ds.company.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.company.model.CompanyOldName;
|
||||
|
||||
@Repository
|
||||
public interface CompanyOldNameRepository extends
|
||||
// JDBC interfaces
|
||||
CrudRepository<CompanyOldName, Integer>, PagingAndSortingRepository<CompanyOldName, Integer>,
|
||||
// JPA interfaces
|
||||
JpaRepository<CompanyOldName, Integer>, JpaSpecificationExecutor<CompanyOldName> {
|
||||
public interface CompanyOldNameRepository extends MyRepository<CompanyOldName, Integer> {
|
||||
|
||||
List<CompanyOldName> findAllByCompanyId(Integer companyId);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -17,14 +18,15 @@ 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.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.company.repository.CompanyBankAccountRepository;
|
||||
import com.ecep.contract.ds.other.service.BankService;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.model.CompanyBankAccount;
|
||||
import com.ecep.contract.ds.company.repository.CompanyBankAccountRepository;
|
||||
import com.ecep.contract.ds.other.service.BankService;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
@@ -34,13 +36,46 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-bank-account")
|
||||
public class CompanyBankAccountService implements IEntityService<CompanyBankAccount>, QueryService<CompanyBankAccountVo>,
|
||||
public class CompanyBankAccountService
|
||||
extends EntityService<CompanyBankAccount, CompanyBankAccountVo, Integer>
|
||||
implements IEntityService<CompanyBankAccount>, QueryService<CompanyBankAccountVo>,
|
||||
VoableService<CompanyBankAccount, CompanyBankAccountVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyBankAccountService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyBankAccountRepository repository;
|
||||
|
||||
@Override
|
||||
protected CompanyBankAccountRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyBankAccount createNewEntity() {
|
||||
return new CompanyBankAccount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyBankAccount> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CompanyBankAccount> spec = null;
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyBankAccount> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.and(
|
||||
builder.isNotNull(root.get("bank")),
|
||||
builder.or(
|
||||
builder.like(root.get("bank").get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("bank").get("code"), "%" + searchText + "%"))),
|
||||
builder.like(root.get("openingBank"), "%" + searchText + "%"),
|
||||
builder.like(root.get("account"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
public CompanyBankAccount findByAccount(Company company, String account) {
|
||||
return repository.findByCompanyAndAccount(company, account).orElse(null);
|
||||
}
|
||||
@@ -76,53 +111,26 @@ public class CompanyBankAccountService implements IEntityService<CompanyBankAcco
|
||||
}
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#p0.id")
|
||||
public CompanyBankAccount save(CompanyBankAccount account) {
|
||||
return repository.save(account);
|
||||
return super.save(account);
|
||||
}
|
||||
|
||||
public List<CompanyBankAccount> findAll(Specification<CompanyBankAccount> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
@CacheEvict(key = "#p0.id")
|
||||
public void delete(CompanyBankAccount entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public CompanyBankAccountVo findById(Integer id) {
|
||||
return repository.findById(id).map(CompanyBankAccount::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyBankAccount getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyBankAccount> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.and(
|
||||
builder.isNotNull(root.get("bank")),
|
||||
builder.or(
|
||||
builder.like(root.get("bank").get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("bank").get("code"), "%" + searchText + "%"))),
|
||||
builder.like(root.get("openingBank"), "%" + searchText + "%"),
|
||||
builder.like(root.get("account"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyBankAccount> findAll(Specification<CompanyBankAccount> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public void delete(CompanyBankAccount entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
public List<CompanyBankAccount> searchByCompany(Company company, String searchText) {
|
||||
Specification<CompanyBankAccount> spec = getSpecification(searchText);
|
||||
Specification<CompanyBankAccount> spec = getSearchSpecification(searchText);
|
||||
if (company != null) {
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
return builder.equal(root.get("company"), company);
|
||||
@@ -131,17 +139,6 @@ public class CompanyBankAccountService implements IEntityService<CompanyBankAcco
|
||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyBankAccountVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<CompanyBankAccount> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable).map(CompanyBankAccount::toVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CompanyBankAccount model, CompanyBankAccountVo vo) {
|
||||
if (model == null) {
|
||||
@@ -173,4 +170,5 @@ public class CompanyBankAccountService implements IEntityService<CompanyBankAcco
|
||||
model.setCreated(vo.getCreated());
|
||||
model.setActive(vo.isActive());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CustomerFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.SpringApp;
|
||||
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.vendor.model.VendorFile;
|
||||
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);
|
||||
|
||||
/**
|
||||
@@ -458,4 +460,6 @@ public abstract class CompanyBasicService {
|
||||
*/
|
||||
protected abstract boolean isEvaluationFile(String fileName);
|
||||
|
||||
public abstract File getBasePath();
|
||||
|
||||
}
|
||||
|
||||
@@ -5,31 +5,28 @@ import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.company.repository.CompanyBlackReasonRepository;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.model.CompanyBlackReason;
|
||||
import com.ecep.contract.ds.company.repository.CompanyBlackReasonRepository;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyBlackReasonVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-black-reason")
|
||||
public class CompanyBlackReasonService
|
||||
public class CompanyBlackReasonService extends EntityService<CompanyBlackReason, CompanyBlackReasonVo, Integer>
|
||||
implements IEntityService<CompanyBlackReason>, QueryService<CompanyBlackReasonVo>,
|
||||
VoableService<CompanyBlackReason, CompanyBlackReasonVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyContactService.class);
|
||||
@@ -37,16 +34,28 @@ public class CompanyBlackReasonService
|
||||
@Autowired
|
||||
private CompanyBlackReasonRepository repository;
|
||||
|
||||
@Override
|
||||
protected CompanyBlackReasonRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyBlackReason createNewEntity() {
|
||||
return new CompanyBlackReason();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public CompanyBlackReasonVo findById(Integer id) {
|
||||
return repository.findById(id).map(CompanyBlackReason::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyBlackReason> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<CompanyBlackReason> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<CompanyBlackReason> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("applyName"), "%" + searchText + "%"),
|
||||
@@ -55,41 +64,20 @@ public class CompanyBlackReasonService
|
||||
};
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#p0.id")
|
||||
@Override
|
||||
public Page<CompanyBlackReason> findAll(Specification<CompanyBlackReason> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyBlackReason getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public void delete(CompanyBlackReason entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
public List<CompanyBlackReason> findAll(Specification<CompanyBlackReason> spec, Sort by) {
|
||||
return repository.findAll(spec, by);
|
||||
}
|
||||
|
||||
public List<CompanyBlackReason> findAllByCompany(Company company) {
|
||||
return repository.findAllByCompany(company);
|
||||
}
|
||||
|
||||
public CompanyBlackReason save(CompanyBlackReason companyBlackReason) {
|
||||
return repository.save(companyBlackReason);
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#p0.id")
|
||||
@Override
|
||||
public Page<CompanyBlackReasonVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<CompanyBlackReason> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable).map(CompanyBlackReason::toVo);
|
||||
public void delete(CompanyBlackReason entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
public List<CompanyBlackReason> findAllByCompany(Company company) {
|
||||
return repository.findAllByCompany(company);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,25 +2,23 @@ package com.ecep.contract.ds.company.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
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.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.company.repository.CompanyContactRepository;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.model.CompanyContact;
|
||||
import com.ecep.contract.ds.company.repository.CompanyContactRepository;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
@@ -35,7 +33,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-contact")
|
||||
public class CompanyContactService implements IEntityService<CompanyContact>, QueryService<CompanyContactVo>,
|
||||
public class CompanyContactService extends EntityService<CompanyContact, CompanyContactVo, Integer>
|
||||
implements IEntityService<CompanyContact>, QueryService<CompanyContactVo>,
|
||||
VoableService<CompanyContact, CompanyContactVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyContactService.class);
|
||||
|
||||
@@ -43,10 +42,11 @@ public class CompanyContactService implements IEntityService<CompanyContact>, Qu
|
||||
private CompanyContactRepository repository;
|
||||
|
||||
@Override
|
||||
public CompanyContact getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected CompanyContactRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#p0.id")
|
||||
@Override
|
||||
public CompanyContact save(CompanyContact contact) {
|
||||
return repository.save(contact);
|
||||
@@ -76,6 +76,7 @@ public class CompanyContactService implements IEntityService<CompanyContact>, Qu
|
||||
}
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#p0.id")
|
||||
@Override
|
||||
public void delete(CompanyContact entity) {
|
||||
repository.delete(entity);
|
||||
@@ -95,10 +96,7 @@ public class CompanyContactService implements IEntityService<CompanyContact>, Qu
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyContact> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<CompanyContact> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
@@ -110,36 +108,28 @@ public class CompanyContactService implements IEntityService<CompanyContact>, Qu
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyContact> findAll(Specification<CompanyContact> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
protected Specification<CompanyContact> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CompanyContact> spec = null;
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyContact createNewEntity() {
|
||||
return new CompanyContact();
|
||||
}
|
||||
|
||||
public List<CompanyContact> searchByCompany(Company company, String userText) {
|
||||
Specification<CompanyContact> spec = SpecificationUtils.and((root, query, builder) -> {
|
||||
return builder.equal(root.get("company"), company);
|
||||
}, getSpecification(userText));
|
||||
}, getSearchSpecification(userText));
|
||||
return repository.findAll(spec);
|
||||
}
|
||||
|
||||
public List<CompanyContact> findAll(Specification<CompanyContact> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
public List<CompanyContact> findAllByCompanyAndName(Company company, String contactName) {
|
||||
return repository.findAllByCompanyAndName(company, contactName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyContactVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<CompanyContact> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable).map(CompanyContact::toVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CompanyContact model, CompanyContactVo vo) {
|
||||
if (model == null) {
|
||||
|
||||
@@ -2,9 +2,6 @@ package com.ecep.contract.ds.company.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -15,20 +12,21 @@ 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.domain.Sort;
|
||||
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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.company.repository.CompanyExtendInfoRepository;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.model.CompanyExtendInfo;
|
||||
import com.ecep.contract.ds.company.repository.CompanyExtendInfoRepository;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyExtendInfoVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
/**
|
||||
@@ -37,25 +35,33 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-extend-info")
|
||||
public class CompanyExtendInfoService implements IEntityService<CompanyExtendInfo>, QueryService<CompanyExtendInfoVo>, VoableService<CompanyExtendInfo, CompanyExtendInfoVo> {
|
||||
public class CompanyExtendInfoService extends EntityService<CompanyExtendInfo, CompanyExtendInfoVo, Integer>
|
||||
implements IEntityService<CompanyExtendInfo>, QueryService<CompanyExtendInfoVo>,
|
||||
VoableService<CompanyExtendInfo, CompanyExtendInfoVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyExtendInfoService.class);
|
||||
@Autowired
|
||||
private CompanyExtendInfoRepository repository;
|
||||
|
||||
@Override
|
||||
protected CompanyExtendInfoRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public CompanyExtendInfoVo findById(Integer id) {
|
||||
return repository.findById(id).map(CompanyExtendInfo::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public List<CompanyExtendInfo> findAll(Specification<CompanyExtendInfo> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
@Override
|
||||
protected Specification<CompanyExtendInfo> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CompanyExtendInfo> spec = null;
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return spec;
|
||||
}
|
||||
|
||||
public Specification<CompanyExtendInfo> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected Specification<CompanyExtendInfo> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("businessScope"), "%" + searchText + "%"),
|
||||
@@ -64,21 +70,12 @@ public class CompanyExtendInfoService implements IEntityService<CompanyExtendInf
|
||||
};
|
||||
}
|
||||
|
||||
public Page<CompanyExtendInfo> findAll(Specification<CompanyExtendInfo> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
@Override
|
||||
public CompanyExtendInfo createNewEntity() {
|
||||
return new CompanyExtendInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyExtendInfoVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<CompanyExtendInfo> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable).map(CompanyExtendInfo::toVo);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'byCompany-'+#p0.company.id")
|
||||
@@ -144,8 +141,5 @@ public class CompanyExtendInfoService implements IEntityService<CompanyExtendInf
|
||||
model.setDisableVerify(vo.isDisableVerify());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyExtendInfo getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CompanyFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
@@ -52,7 +53,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-file")
|
||||
public class CompanyFileService
|
||||
public class CompanyFileService extends EntityService<CompanyFile, CompanyFileVo, Integer>
|
||||
implements IEntityService<CompanyFile>, QueryService<CompanyFileVo>, VoableService<CompanyFile, CompanyFileVo> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyFileService.class);
|
||||
@@ -60,11 +61,12 @@ public class CompanyFileService
|
||||
@Autowired
|
||||
private CompanyFileRepository repository;
|
||||
|
||||
public CompanyFileService() {
|
||||
@Override
|
||||
protected CompanyFileRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public CompanyFile getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
public CompanyFileService() {
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -202,9 +204,15 @@ public class CompanyFileService
|
||||
* @param companyFile 企业文件
|
||||
* @return 保存后的企业文件
|
||||
*/
|
||||
@Override
|
||||
public CompanyFile createNewEntity() {
|
||||
return new CompanyFile();
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
@Override
|
||||
public CompanyFile save(CompanyFile companyFile) {
|
||||
return repository.save(companyFile);
|
||||
}
|
||||
@@ -219,6 +227,7 @@ public class CompanyFileService
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
@Override
|
||||
public void delete(CompanyFile file) {
|
||||
repository.delete(file);
|
||||
}
|
||||
@@ -433,27 +442,6 @@ public class CompanyFileService
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyFileVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<CompanyFile> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(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> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
|
||||
}
|
||||
|
||||
protected Specification<CompanyFile> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
|
||||
@@ -1,37 +1,34 @@
|
||||
package com.ecep.contract.ds.company.service;
|
||||
|
||||
import com.ecep.contract.CompanyFileType;
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
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 com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.company.repository.CompanyFileTypeLocalRepository;
|
||||
import com.ecep.contract.model.CompanyFileTypeLocal;
|
||||
import com.ecep.contract.vo.CompanyFileTypeLocalVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
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 com.ecep.contract.CompanyFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.company.repository.CompanyFileTypeLocalRepository;
|
||||
import com.ecep.contract.model.CompanyFileTypeLocal;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyFileTypeLocalVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-file-type")
|
||||
public class CompanyFileTypeService
|
||||
public class CompanyFileTypeService extends EntityService<CompanyFileTypeLocal, CompanyFileTypeLocalVo, Integer>
|
||||
implements IEntityService<CompanyFileTypeLocal>, QueryService<CompanyFileTypeLocalVo>,
|
||||
VoableService<CompanyFileTypeLocal, CompanyFileTypeLocalVo> {
|
||||
|
||||
@@ -39,8 +36,13 @@ public class CompanyFileTypeService
|
||||
private CompanyFileTypeLocalRepository repository;
|
||||
|
||||
@Override
|
||||
public CompanyFileTypeLocal getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected CompanyFileTypeLocalRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyFileTypeLocal createNewEntity() {
|
||||
return new CompanyFileTypeLocal();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#id")
|
||||
@@ -51,18 +53,13 @@ public class CompanyFileTypeService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<CompanyFileTypeLocal> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CompanyFileTypeLocal> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
|
||||
if (paramsNode.has("type")) {
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"),
|
||||
CompanyFileType.valueOf(paramsNode.get("type").asText())));
|
||||
}
|
||||
// field
|
||||
return findAll(spec, pageable).map(CompanyFileTypeLocal::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Cacheable(key = "'all-'+#locale.toLanguageTag()")
|
||||
@@ -74,21 +71,9 @@ public class CompanyFileTypeService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyFileTypeLocal> findAll(Specification<CompanyFileTypeLocal> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyFileTypeLocal> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<CompanyFileTypeLocal> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return
|
||||
// builder.or(
|
||||
builder.like(root.get("type"), "%" + searchText + "%")
|
||||
// )
|
||||
;
|
||||
return builder.like(root.get("type"), "%" + searchText + "%");
|
||||
};
|
||||
}
|
||||
|
||||
@@ -98,7 +83,7 @@ public class CompanyFileTypeService
|
||||
})
|
||||
@Override
|
||||
public void delete(CompanyFileTypeLocal entity) {
|
||||
repository.delete(entity);
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@@ -107,7 +92,7 @@ public class CompanyFileTypeService
|
||||
})
|
||||
@Override
|
||||
public CompanyFileTypeLocal save(CompanyFileTypeLocal entity) {
|
||||
return repository.save(entity);
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.company.repository.CompanyInvoiceInfoRepository;
|
||||
@@ -33,12 +34,24 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-invoice-info")
|
||||
public class CompanyInvoiceInfoService implements IEntityService<CompanyInvoiceInfo>, QueryService<CompanyInvoiceInfoVo>, VoableService<CompanyInvoiceInfo, CompanyInvoiceInfoVo> {
|
||||
public class CompanyInvoiceInfoService extends EntityService<CompanyInvoiceInfo, CompanyInvoiceInfoVo, Integer>
|
||||
implements IEntityService<CompanyInvoiceInfo>, QueryService<CompanyInvoiceInfoVo>,
|
||||
VoableService<CompanyInvoiceInfo, CompanyInvoiceInfoVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyInvoiceInfoService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyInvoiceInfoRepository repository;
|
||||
|
||||
@Override
|
||||
protected CompanyInvoiceInfoRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyInvoiceInfo createNewEntity() {
|
||||
return new CompanyInvoiceInfo();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public CompanyInvoiceInfoVo findById(Integer id) {
|
||||
@@ -46,16 +59,7 @@ public class CompanyInvoiceInfoService implements IEntityService<CompanyInvoiceI
|
||||
}
|
||||
|
||||
public List<CompanyInvoiceInfo> searchByCompany(Company company, String searchText) {
|
||||
Specification<CompanyInvoiceInfo> spec = (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("taxId"), "%" + searchText + "%"),
|
||||
builder.like(root.get("address"), "%" + searchText + "%"),
|
||||
builder.like(root.get("phone"), "%" + searchText + "%"),
|
||||
builder.like(root.get("bankName"), "%" + searchText + "%"),
|
||||
builder.like(root.get("bankAccount"), "%" + searchText + "%"));
|
||||
};
|
||||
|
||||
Specification<CompanyInvoiceInfo> spec = buildSearchSpecification(searchText);
|
||||
if (company != null) {
|
||||
spec = spec.and((root, query, builder) -> {
|
||||
return builder.equal(root.get("company"), company);
|
||||
@@ -64,10 +68,7 @@ public class CompanyInvoiceInfoService implements IEntityService<CompanyInvoiceI
|
||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
public Specification<CompanyInvoiceInfo> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<CompanyInvoiceInfo> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
@@ -79,19 +80,11 @@ public class CompanyInvoiceInfoService implements IEntityService<CompanyInvoiceI
|
||||
};
|
||||
}
|
||||
|
||||
public Page<CompanyInvoiceInfo> findAll(Specification<CompanyInvoiceInfo> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyInvoiceInfoVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<CompanyInvoiceInfo> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CompanyInvoiceInfo> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable).map(CompanyInvoiceInfo::toVo);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@@ -107,6 +100,7 @@ public class CompanyInvoiceInfoService implements IEntityService<CompanyInvoiceI
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'byCompany-'+#p0.company.id")
|
||||
})
|
||||
@Override
|
||||
public void delete(CompanyInvoiceInfo model) {
|
||||
repository.delete(model);
|
||||
}
|
||||
@@ -125,9 +119,4 @@ public class CompanyInvoiceInfoService implements IEntityService<CompanyInvoiceI
|
||||
model.setBankName(vo.getBankName());
|
||||
model.setBankAccount(vo.getBankAccount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyInvoiceInfo getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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;
|
||||
@@ -19,6 +21,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.company.repository.CompanyOldNameRepository;
|
||||
@@ -35,7 +38,9 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-old-name")
|
||||
public class CompanyOldNameService implements IEntityService<CompanyOldName>, QueryService<CompanyOldNameVo>, VoableService<CompanyOldName, CompanyOldNameVo> {
|
||||
public class CompanyOldNameService extends EntityService<CompanyOldName, CompanyOldNameVo, Integer>
|
||||
implements IEntityService<CompanyOldName>, QueryService<CompanyOldNameVo>,
|
||||
VoableService<CompanyOldName, CompanyOldNameVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyOldNameService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -44,17 +49,20 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public CompanyOldNameVo findById(Integer id) {
|
||||
return companyOldNameRepository.findById(id).map(CompanyOldName::toVo).orElse(null);
|
||||
@Override
|
||||
protected CompanyOldNameRepository getRepository() {
|
||||
return companyOldNameRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyOldName> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
|
||||
public CompanyOldName createNewEntity() {
|
||||
return new CompanyOldName();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public CompanyOldNameVo findById(Integer id) {
|
||||
return companyOldNameRepository.findById(id).map(CompanyOldName::toVo).orElse(null);
|
||||
}
|
||||
|
||||
protected Specification<CompanyOldName> buildSearchSpecification(String searchText) {
|
||||
@@ -65,6 +73,15 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<CompanyOldName> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
public CompanyOldName save(CompanyOldName companyOldName) {
|
||||
return companyOldNameRepository.save(companyOldName);
|
||||
}
|
||||
@@ -120,10 +137,6 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
||||
return companyOldNameRepository.findAllByName(name);
|
||||
}
|
||||
|
||||
public List<CompanyOldName> findAll(Specification<CompanyOldName> spec, Sort sort) {
|
||||
return companyOldNameRepository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
public List<CompanyOldName> findAllByCompany(Company company) {
|
||||
return companyOldNameRepository.findAllByCompanyId(company.getId());
|
||||
}
|
||||
@@ -151,6 +164,10 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
||||
companyOldNameRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
public void delete(CompanyOldName entity) {
|
||||
companyOldNameRepository.delete(entity);
|
||||
}
|
||||
@@ -179,7 +196,6 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
||||
}
|
||||
companyOldNameRepository.saveAll(list);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void deleteByCompany(Company company) {
|
||||
@@ -191,52 +207,12 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据提供的搜索文本查询公司旧名称列表。
|
||||
* <p>
|
||||
* 该函数使用JPA的Specification接口构建查询条件,查找公司旧名称中包含指定文本的记录。
|
||||
* 查询结果最多返回10条记录。
|
||||
*
|
||||
* @param searchText 用于搜索的文本,将匹配公司旧名称中包含该文本的记录。
|
||||
* @return 包含匹配的公司旧名称的列表,列表中的每个元素都是一个CompanyOldName对象。
|
||||
*/
|
||||
public List<CompanyOldName> search(String searchText) {
|
||||
return companyOldNameRepository.findAll(getSpecification(searchText), Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyOldName> findAll(Specification<CompanyOldName> spec, Pageable pageable) {
|
||||
return companyOldNameRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyOldName getById(Integer id) {
|
||||
return companyOldNameRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyOldNameVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<CompanyOldName> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
protected String aliasFor(String field, JsonNode filterNode) {
|
||||
if ("company".equals(field)) {
|
||||
return "companyId";
|
||||
}
|
||||
if (paramsNode.has("company")) {
|
||||
JsonNode param = paramsNode.get("company");
|
||||
Integer companyId = null;
|
||||
if (param.isInt()) {
|
||||
companyId = param.asInt();
|
||||
} else if (param.isObject()) {
|
||||
companyId = param.get("id").asInt();
|
||||
}
|
||||
if (companyId != null) {
|
||||
final int id = companyId;
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
return builder.equal(root.get("companyId"), id);
|
||||
});
|
||||
}
|
||||
}
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "ambiguity", "beginDate", "endDate");
|
||||
return findAll(spec, pageable).map(CompanyOldName::toVo);
|
||||
return super.aliasFor(field, filterNode);
|
||||
}
|
||||
|
||||
public CompanyOldName createNew(Company company, String name, boolean ambiguity) {
|
||||
@@ -262,4 +238,5 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
||||
model.getId(), model.getVersion(), vo.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ public class CompanyService extends EntityService<Company, CompanyVo, Integer>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<Company> getSpecification(String searchText) {
|
||||
public Specification<Company> getSearchSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,15 @@ 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.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.other.repository.HolidayTableRepository;
|
||||
@@ -36,11 +39,17 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "HolidayTable")
|
||||
@Slf4j
|
||||
public class HolidayService implements IEntityService<HolidayTable>, QueryService<HolidayTableVo>, VoableService<HolidayTable, HolidayTableVo> {
|
||||
public class HolidayService extends EntityService<HolidayTable, HolidayTableVo, LocalDate> implements
|
||||
IEntityService<HolidayTable>, QueryService<HolidayTableVo>, VoableService<HolidayTable, HolidayTableVo> {
|
||||
|
||||
@Autowired
|
||||
private HolidayTableRepository holidayTableRepository;
|
||||
|
||||
@Override
|
||||
protected HolidayTableRepository getRepository() {
|
||||
return holidayTableRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整日期到工作日
|
||||
*
|
||||
@@ -52,7 +61,8 @@ public class HolidayService implements IEntityService<HolidayTable>, QueryServic
|
||||
return null;
|
||||
}
|
||||
|
||||
while (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY || isHoliday(date)) {
|
||||
while (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY
|
||||
|| isHoliday(date)) {
|
||||
date = date.plusDays(1);
|
||||
}
|
||||
return date;
|
||||
@@ -75,11 +85,13 @@ public class HolidayService implements IEntityService<HolidayTable>, QueryServic
|
||||
|
||||
@Override
|
||||
public HolidayTable getById(Integer id) {
|
||||
throw new UnsupportedOperationException("HolidayTable uses LocalDate as ID, please use getById(LocalDate id) method instead");
|
||||
throw new UnsupportedOperationException(
|
||||
"HolidayTable uses LocalDate as ID, please use getById(LocalDate id) method instead");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据LocalDate类型的ID查询实体
|
||||
*
|
||||
* @param id 实体ID
|
||||
* @return 实体对象
|
||||
*/
|
||||
@@ -87,26 +99,29 @@ public class HolidayService implements IEntityService<HolidayTable>, QueryServic
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return holidayTableRepository.findById(id).orElse(null);
|
||||
return super.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = { @CacheEvict(key = "#p0.id") })
|
||||
public HolidayTable save(HolidayTable entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
return holidayTableRepository.save(entity);
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = { @CacheEvict(key = "#p0.id") })
|
||||
public void delete(HolidayTable entity) {
|
||||
if (entity != null && entity.getId() != null) {
|
||||
holidayTableRepository.deleteById(entity.getId());
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据LocalDate类型的ID删除实体
|
||||
*
|
||||
* @param id 实体ID
|
||||
*/
|
||||
public void deleteById(LocalDate id) {
|
||||
@@ -115,46 +130,32 @@ public class HolidayService implements IEntityService<HolidayTable>, QueryServic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有节假日
|
||||
* @param pageable 分页参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
public Page<HolidayTable> findAll(Pageable pageable) {
|
||||
return holidayTableRepository.findAll(pageable);
|
||||
@Override
|
||||
public HolidayTable createNewEntity() {
|
||||
return new HolidayTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<HolidayTable> findAll(Specification<HolidayTable> spec, Pageable pageable) {
|
||||
// 由于HolidayTableRepository不支持Specification查询,返回所有节假日
|
||||
return findAll(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<HolidayTable> getSpecification(String searchText) {
|
||||
// 实现根据搜索文本构建规格化查询
|
||||
protected Specification<HolidayTable> buildSearchSpecification(String searchText) {
|
||||
return (Root<HolidayTable> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) -> {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
if (searchText != null && !searchText.trim().isEmpty()) {
|
||||
try {
|
||||
// 尝试将搜索文本解析为日期
|
||||
LocalDate date = LocalDate.parse(searchText.trim());
|
||||
predicates.add(criteriaBuilder.equal(root.get("id"), date));
|
||||
} catch (DateTimeParseException e) {
|
||||
// 如果不是日期格式,尝试其他搜索方式
|
||||
// 由于HolidayTable只有id和holiday字段,这里无法进行其他字段的模糊搜索
|
||||
log.warn("Search text '{}' is not a valid date format", searchText);
|
||||
}
|
||||
try {
|
||||
// 尝试将搜索文本解析为日期
|
||||
LocalDate date = LocalDate.parse(searchText.trim());
|
||||
predicates.add(criteriaBuilder.equal(root.get("id"), date));
|
||||
} catch (DateTimeParseException e) {
|
||||
// 如果不是日期格式,尝试其他搜索方式
|
||||
// 由于HolidayTable只有id和holiday字段,这里无法进行其他字段的模糊搜索
|
||||
log.warn("Search text '{}' is not a valid date format", searchText);
|
||||
}
|
||||
|
||||
return criteriaBuilder.and(predicates.toArray(new Predicate[0]));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public HolidayTableVo findById(Integer id) {
|
||||
throw new UnsupportedOperationException("HolidayTable uses LocalDate as ID, please use findById(Object id) instead");
|
||||
throw new UnsupportedOperationException(
|
||||
"HolidayTable uses LocalDate as ID, please use findById(Object id) instead");
|
||||
}
|
||||
|
||||
@Cacheable(key = "#id", unless = "#result == null")
|
||||
@@ -163,6 +164,21 @@ public class HolidayService implements IEntityService<HolidayTable>, QueryServic
|
||||
return entity != null ? entity.toVo() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<HolidayTable> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有节假日
|
||||
*
|
||||
* @param pageable 分页参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
public Page<HolidayTable> findAll(Pageable pageable) {
|
||||
return holidayTableRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<HolidayTableVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
// 实现根据JSON参数过滤节假日
|
||||
@@ -216,12 +232,6 @@ public class HolidayService implements IEntityService<HolidayTable>, QueryServic
|
||||
return entityPage.map(HolidayTable::toVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count(JsonNode paramsNode) {
|
||||
// 简单实现,返回所有节假日数量
|
||||
return holidayTableRepository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(HolidayTable model, HolidayTableVo vo) {
|
||||
if (model == null || vo == null) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.ecep.contract.ds.company.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -9,28 +7,25 @@ import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
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.domain.Sort;
|
||||
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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.company.repository.InvoiceRepository;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.repository.InvoiceRepository;
|
||||
import com.ecep.contract.ds.other.model.Invoice;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.InvoiceVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "invoice")
|
||||
public class InvoiceService implements IEntityService<Invoice>, QueryService<InvoiceVo>,
|
||||
public class InvoiceService extends EntityService<Invoice, InvoiceVo, Integer>
|
||||
implements IEntityService<Invoice>, QueryService<InvoiceVo>,
|
||||
VoableService<Invoice, InvoiceVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(InvoiceService.class);
|
||||
|
||||
@@ -38,8 +33,8 @@ public class InvoiceService implements IEntityService<Invoice>, QueryService<Inv
|
||||
private InvoiceRepository repository;
|
||||
|
||||
@Override
|
||||
public Invoice getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected InvoiceRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -49,34 +44,30 @@ public class InvoiceService implements IEntityService<Invoice>, QueryService<Inv
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<Invoice> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
public Invoice createNewEntity() {
|
||||
return new Invoice();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<Invoice> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<Invoice> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Invoice> findAll(Specification<Invoice> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#p0.id")
|
||||
@Override
|
||||
public void delete(Invoice entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
public List<Invoice> findAll(Specification<Invoice> spec, Sort by) {
|
||||
return repository.findAll(spec, by);
|
||||
}
|
||||
|
||||
public Invoice findByCode(String invoiceNumber) {
|
||||
return repository.findByCode(invoiceNumber);
|
||||
}
|
||||
@@ -87,18 +78,6 @@ public class InvoiceService implements IEntityService<Invoice>, QueryService<Inv
|
||||
return repository.save(invoice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<InvoiceVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<Invoice> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable).map(Invoice::toVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Invoice model, InvoiceVo vo) {
|
||||
if (model == null || vo == null) {
|
||||
@@ -115,4 +94,5 @@ public class InvoiceService implements IEntityService<Invoice>, QueryService<Inv
|
||||
model.setDescription(vo.getDescription());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,20 +2,13 @@ package com.ecep.contract.ds.contract.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.contract.model.ContractBidVendor;
|
||||
|
||||
@Repository
|
||||
public interface ContractBidVendorRepository extends
|
||||
// JDBC interfaces
|
||||
CrudRepository<ContractBidVendor, Integer>, PagingAndSortingRepository<ContractBidVendor, Integer>,
|
||||
// JPA interfaces
|
||||
JpaRepository<ContractBidVendor, Integer>, JpaSpecificationExecutor<ContractBidVendor> {
|
||||
public interface ContractBidVendorRepository extends MyRepository<ContractBidVendor, Integer> {
|
||||
|
||||
List<ContractBidVendor> findByContractId(Integer contractId);
|
||||
|
||||
|
||||
@@ -2,16 +2,13 @@ package com.ecep.contract.ds.contract.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.vendor.model.ExtendVendorInfo;
|
||||
|
||||
@Repository
|
||||
public interface ExtendVendorInfoRepository extends
|
||||
// JPA interfaces
|
||||
JpaRepository<ExtendVendorInfo, Integer>, JpaSpecificationExecutor<ExtendVendorInfo> {
|
||||
public interface ExtendVendorInfoRepository extends MyRepository<ExtendVendorInfo, Integer> {
|
||||
|
||||
Optional<ExtendVendorInfo> findByContractId(Integer contractId);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -25,7 +26,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-balance")
|
||||
public class ContractBalanceService implements IEntityService<ContractBalance>, QueryService<ContractBalanceVo>,
|
||||
public class ContractBalanceService extends EntityService<ContractBalance, ContractBalanceVo, Integer>
|
||||
implements IEntityService<ContractBalance>, QueryService<ContractBalanceVo>,
|
||||
VoableService<ContractBalance, ContractBalanceVo> {
|
||||
|
||||
@Lazy
|
||||
@@ -33,8 +35,8 @@ public class ContractBalanceService implements IEntityService<ContractBalance>,
|
||||
private ContractBalanceRepository repository;
|
||||
|
||||
@Override
|
||||
public ContractBalance getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected ContractBalanceRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -48,10 +50,12 @@ public class ContractBalanceService implements IEntityService<ContractBalance>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractBalance> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
public ContractBalance createNewEntity() {
|
||||
return new ContractBalance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ContractBalance> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("refId"), "%" + searchText + "%"),
|
||||
@@ -83,16 +87,11 @@ public class ContractBalanceService implements IEntityService<ContractBalance>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractBalanceVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<ContractBalance> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<ContractBalance> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
|
||||
// 字段等值查询 - 只包含ContractBalanceVo中存在的字段
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "contract", "employee");
|
||||
|
||||
return findAll(spec, pageable).map(ContractBalance::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -32,14 +33,16 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-ven-bid")
|
||||
public class ContractBidVendorService implements IEntityService<ContractBidVendor>, QueryService<ContractBidVendorVo>, VoableService<ContractBidVendor, ContractBidVendorVo> {
|
||||
public class ContractBidVendorService extends EntityService<ContractBidVendor, ContractBidVendorVo, Integer>
|
||||
implements IEntityService<ContractBidVendor>, QueryService<ContractBidVendorVo>,
|
||||
VoableService<ContractBidVendor, ContractBidVendorVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractBidVendorRepository repository;
|
||||
|
||||
@Override
|
||||
public ContractBidVendor getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected ContractBidVendorRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -53,21 +56,19 @@ public class ContractBidVendorService implements IEntityService<ContractBidVendo
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractBidVendor> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ContractBidVendor> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("bidName"), "%" + searchText + "%"),
|
||||
builder.like(root.get("memo"), "%" + searchText + "%")
|
||||
);
|
||||
builder.like(root.get("memo"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractBidVendor> findAll(Specification<ContractBidVendor> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
protected Specification<ContractBidVendor> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<ContractBidVendor> spec = null;
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "company");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Cacheable(key = "'allbycontract-'+#p0.id")
|
||||
@@ -75,6 +76,7 @@ public class ContractBidVendorService implements IEntityService<ContractBidVendo
|
||||
return repository.findByContractId(contract.getId()).stream().map(ContractBidVendor::toVo).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'allbycontract-'+#p0.contract.id")
|
||||
@@ -92,10 +94,6 @@ public class ContractBidVendorService implements IEntityService<ContractBidVendo
|
||||
repository.delete(bidVendor);
|
||||
}
|
||||
|
||||
public List<ContractBidVendor> findAll(Specification<ContractBidVendor> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
@@ -108,14 +106,8 @@ public class ContractBidVendorService implements IEntityService<ContractBidVendo
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractBidVendorVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ContractBidVendor> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "company");
|
||||
return findAll(spec, pageable).map(ContractBidVendor::toVo);
|
||||
public ContractBidVendor createNewEntity() {
|
||||
return new ContractBidVendor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,8 +134,10 @@ public class ContractBidVendorService implements IEntityService<ContractBidVendo
|
||||
if (vo.getQuotationSheetFileId() == null) {
|
||||
model.setQuotationSheet(null);
|
||||
} else {
|
||||
if (model.getQuotationSheet() == null || !model.getQuotationSheet().getId().equals(vo.getQuotationSheetFileId())) {
|
||||
model.setQuotationSheet(SpringApp.getBean(ContractFileRepository.class).findById(vo.getQuotationSheetFileId()).orElse(null));
|
||||
if (model.getQuotationSheet() == null
|
||||
|| !model.getQuotationSheet().getId().equals(vo.getQuotationSheetFileId())) {
|
||||
model.setQuotationSheet(SpringApp.getBean(ContractFileRepository.class)
|
||||
.findById(vo.getQuotationSheetFileId()).orElse(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,10 @@ 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 com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.contract.repository.ContractCatalogRepository;
|
||||
@@ -28,12 +26,18 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-catalog")
|
||||
public class ContractCatalogService implements IEntityService<ContractCatalog>, QueryService<ContractCatalogVo>,
|
||||
public class ContractCatalogService extends EntityService<ContractCatalog, ContractCatalogVo, Integer>
|
||||
implements IEntityService<ContractCatalog>, QueryService<ContractCatalogVo>,
|
||||
VoableService<ContractCatalog, ContractCatalogVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractCatalogRepository repository;
|
||||
|
||||
@Override
|
||||
protected ContractCatalogRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 id 查找 ContractCatalog
|
||||
*/
|
||||
@@ -43,9 +47,7 @@ public class ContractCatalogService implements IEntityService<ContractCatalog>,
|
||||
return repository.findById(id).map(ContractCatalog::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public ContractCatalog getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
public ContractCatalog findByName(String name) {
|
||||
return repository.findByName(name).orElse(null);
|
||||
@@ -61,6 +63,7 @@ public class ContractCatalogService implements IEntityService<ContractCatalog>,
|
||||
return repository.findAll().stream().map(ContractCatalog::toVo).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code"),
|
||||
@@ -81,10 +84,7 @@ public class ContractCatalogService implements IEntityService<ContractCatalog>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractCatalog> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ContractCatalog> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
@@ -94,17 +94,8 @@ public class ContractCatalogService implements IEntityService<ContractCatalog>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractCatalog> findAll(Specification<ContractCatalog> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractCatalogVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ContractCatalog> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
return findAll(spec, pageable).map(ContractCatalog::toVo);
|
||||
protected Specification<ContractCatalog> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,4 +109,9 @@ public class ContractCatalogService implements IEntityService<ContractCatalog>,
|
||||
model.setParent(vo.getParent());
|
||||
model.setUseYear(vo.isUseYear());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractCatalog createNewEntity() {
|
||||
return new ContractCatalog();
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.ContractFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -34,18 +35,14 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-file")
|
||||
public class ContractFileService implements IEntityService<ContractFile>, QueryService<ContractFileVo>,
|
||||
public class ContractFileService extends EntityService<ContractFile, ContractFileVo, Integer>
|
||||
implements IEntityService<ContractFile>, QueryService<ContractFileVo>,
|
||||
VoableService<ContractFile, ContractFileVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContractFileService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractFileRepository contractFileRepository;
|
||||
|
||||
@Override
|
||||
public ContractFile getById(Integer id) {
|
||||
return contractFileRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public ContractFileVo findById(Integer id) {
|
||||
@@ -53,10 +50,7 @@ public class ContractFileService implements IEntityService<ContractFile>, QueryS
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractFile> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
public Specification<ContractFile> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("fileName"), "%" + searchText + "%"),
|
||||
@@ -65,25 +59,20 @@ public class ContractFileService implements IEntityService<ContractFile>, QueryS
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractFile> findAll(Specification<ContractFile> spec, Pageable pageable) {
|
||||
return contractFileRepository.findAll(spec, pageable);
|
||||
protected ContractFileRepository getRepository() {
|
||||
return contractFileRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractFileVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ContractFile> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "type");
|
||||
|
||||
return findAll(spec, pageable).map(ContractFile::toVo);
|
||||
public ContractFile createNewEntity() {
|
||||
return new ContractFile();
|
||||
}
|
||||
|
||||
public List<ContractFile> findAll(Specification<ContractFile> spec, Sort by) {
|
||||
return contractFileRepository.findAll(spec, by);
|
||||
@Override
|
||||
protected Specification<ContractFile> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<ContractFile> spec = null;
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "type");
|
||||
return spec;
|
||||
}
|
||||
|
||||
public List<ContractFile> findAllByContractAndFileType(Contract contract, ContractFileType contractFileType) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.ContractFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.contract.repository.ContractFileTypeLocalRepository;
|
||||
@@ -31,7 +32,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-file-type")
|
||||
public class ContractFileTypeService
|
||||
public class ContractFileTypeService extends EntityService<ContractFileTypeLocal, ContractFileTypeLocalVo, Integer>
|
||||
implements IEntityService<ContractFileTypeLocal>, QueryService<ContractFileTypeLocalVo>,
|
||||
VoableService<ContractFileTypeLocal, ContractFileTypeLocalVo> {
|
||||
@Lazy
|
||||
@@ -39,20 +40,25 @@ public class ContractFileTypeService
|
||||
private ContractFileTypeLocalRepository repository;
|
||||
|
||||
@Override
|
||||
public Page<ContractFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ContractFileTypeLocal> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
protected ContractFileTypeLocalRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractFileTypeLocal createNewEntity() {
|
||||
return new ContractFileTypeLocal();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ContractFileTypeLocal> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<ContractFileTypeLocal> spec = null;
|
||||
if (paramsNode.has("type")) {
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"),
|
||||
ContractFileType.valueOf(paramsNode.get("type").asText())));
|
||||
}
|
||||
|
||||
// field
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value", "suggestFileName");
|
||||
return findAll(spec, pageable).map(ContractFileTypeLocal::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||
@@ -69,20 +75,8 @@ public class ContractFileTypeService
|
||||
return repository.findById(id).map(ContractFileTypeLocal::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public ContractFileTypeLocal getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractFileTypeLocal> findAll(Specification<ContractFileTypeLocal> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractFileTypeLocal> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ContractFileTypeLocal> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("type"), "%" + searchText + "%"),
|
||||
|
||||
@@ -16,8 +16,10 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.contract.repository.ContractGroupRepository;
|
||||
import com.ecep.contract.model.ContractGroup;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
@@ -30,7 +32,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-group")
|
||||
public class ContractGroupService implements IEntityService<ContractGroup>, QueryService<ContractGroupVo>,
|
||||
public class ContractGroupService extends EntityService<ContractGroup, ContractGroupVo, Integer>
|
||||
implements IEntityService<ContractGroup>, QueryService<ContractGroupVo>,
|
||||
VoableService<ContractGroup, ContractGroupVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContractGroupService.class);
|
||||
|
||||
@@ -39,8 +42,8 @@ public class ContractGroupService implements IEntityService<ContractGroup>, Quer
|
||||
private ContractGroupRepository repository;
|
||||
|
||||
@Override
|
||||
public ContractGroup getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected ContractGroupRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,21 +53,7 @@ public class ContractGroupService implements IEntityService<ContractGroup>, Quer
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractGroup> findAll(Specification<ContractGroup> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractGroupVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ContractGroup> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
return findAll(spec, pageable).map(ContractGroup::toVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractGroup> getSpecification(String searchText) {
|
||||
protected Specification<ContractGroup> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
@@ -73,6 +62,11 @@ public class ContractGroupService implements IEntityService<ContractGroup>, Quer
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ContractGroup> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ContractGroup findByName(String name) {
|
||||
return repository.findByName(name).orElse(null);
|
||||
}
|
||||
@@ -115,7 +109,8 @@ public class ContractGroupService implements IEntityService<ContractGroup>, Quer
|
||||
repository.delete(group);
|
||||
}
|
||||
|
||||
public ContractGroup newContractGroup() {
|
||||
@Override
|
||||
public ContractGroup createNewEntity() {
|
||||
ContractGroup group = new ContractGroup();
|
||||
group.setCode("");
|
||||
group.setName("");
|
||||
|
||||
@@ -4,12 +4,14 @@ 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.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -27,7 +29,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-invoice")
|
||||
public class ContractInvoiceService implements IEntityService<ContractInvoice>, QueryService<ContractInvoiceVo>,
|
||||
public class ContractInvoiceService extends EntityService<ContractInvoice, ContractInvoiceVo, Integer>
|
||||
implements IEntityService<ContractInvoice>, QueryService<ContractInvoiceVo>,
|
||||
VoableService<ContractInvoice, ContractInvoiceVo> {
|
||||
|
||||
@Autowired
|
||||
@@ -75,6 +78,7 @@ public class ContractInvoiceService implements IEntityService<ContractInvoice>,
|
||||
* @return 保存后的发票VO
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(key = "#p0.id")
|
||||
public ContractInvoice save(ContractInvoice invoice) {
|
||||
try {
|
||||
ContractInvoice saved = repository.save(invoice);
|
||||
@@ -85,6 +89,11 @@ public class ContractInvoiceService implements IEntityService<ContractInvoice>,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractInvoice createNewEntity() {
|
||||
return new ContractInvoice();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ContractInvoice entity, ContractInvoiceVo vo) {
|
||||
if (entity == null || vo == null) {
|
||||
@@ -135,13 +144,6 @@ public class ContractInvoiceService implements IEntityService<ContractInvoice>,
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractInvoiceVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ContractInvoice> spec = buildParameterSpecification(paramsNode);
|
||||
Page<ContractInvoice> page = repository.findAll(spec, pageable);
|
||||
return page.map(ContractInvoice::toVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建参数规范
|
||||
*
|
||||
@@ -161,7 +163,7 @@ public class ContractInvoiceService implements IEntityService<ContractInvoice>,
|
||||
if (paramsNode.has("searchText")) {
|
||||
String searchText = paramsNode.get("searchText").asText();
|
||||
if (searchText != null && !searchText.isEmpty()) {
|
||||
spec = SpecificationUtils.and(spec, getSpecification(searchText));
|
||||
spec = SpecificationUtils.and(spec, getSearchSpecification(searchText));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,17 +171,12 @@ public class ContractInvoiceService implements IEntityService<ContractInvoice>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractInvoice getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected ContractInvoiceRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractInvoice> findAll(Specification<ContractInvoice> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractInvoice> getSpecification(String searchText) {
|
||||
protected Specification<ContractInvoice> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
@@ -189,6 +186,7 @@ public class ContractInvoiceService implements IEntityService<ContractInvoice>,
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "#p0.id")
|
||||
public void delete(ContractInvoice entity) {
|
||||
try {
|
||||
repository.delete(entity);
|
||||
|
||||
@@ -2,23 +2,19 @@ package com.ecep.contract.ds.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.domain.Sort;
|
||||
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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -31,6 +27,7 @@ import com.ecep.contract.model.Inventory;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ContractItemVo;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.persistence.criteria.Path;
|
||||
@@ -38,26 +35,20 @@ import jakarta.persistence.criteria.Path;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-item")
|
||||
public class ContractItemService implements IEntityService<ContractItem>, QueryService<ContractItemVo>,
|
||||
public class ContractItemService extends EntityService<ContractItem, ContractItemVo, Integer>
|
||||
implements IEntityService<ContractItem>, QueryService<ContractItemVo>,
|
||||
VoableService<ContractItem, ContractItemVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContractItemService.class);
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractItemRepository itemRepository;
|
||||
|
||||
@Override
|
||||
public ContractItem getById(Integer id) {
|
||||
return itemRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public ContractItemVo findById(Integer id) {
|
||||
return itemRepository.findById(id).map(ContractItem::toVo).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
public List<ContractItem> findAllByItemCode(String itemCode) {
|
||||
return itemRepository.findAllByItemCode(itemCode);
|
||||
}
|
||||
@@ -66,44 +57,6 @@ public class ContractItemService implements IEntityService<ContractItem>, QueryS
|
||||
return itemRepository.findByRowId(rowId).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractItem> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return (root, query, builder) -> {
|
||||
Path<Inventory> inventory = root.get("inventory");
|
||||
return builder.or(
|
||||
builder.like(root.get("itemCode"), "%" + searchText + "%"),
|
||||
builder.like(root.get("title"), "%" + searchText + "%"),
|
||||
builder.like(root.get("specification"), "%" + searchText + "%"),
|
||||
builder.like(root.get("unit"), "%" + searchText + "%"),
|
||||
builder.like(root.get("remark"), "%" + searchText + "%"),
|
||||
builder.and(
|
||||
inventory.isNotNull(), builder.or(
|
||||
builder.like(inventory.get("name"), "%" + searchText + "%"),
|
||||
builder.like(inventory.get("code"), "%" + searchText + "%"),
|
||||
builder.like(inventory.get("specification"), "%" + searchText + "%"))));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractItem> findAll(Specification<ContractItem> spec, Pageable pageable) {
|
||||
return itemRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ContractItem> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "inventory", "creator", "updater");
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "itemCode", "refId", "title", "specification");
|
||||
return findAll(spec, pageable).map(ContractItem::toVo);
|
||||
}
|
||||
|
||||
public List<ContractItem> findAllByContract(Contract contract) {
|
||||
return itemRepository.findByContractId(contract.getId());
|
||||
}
|
||||
@@ -116,14 +69,6 @@ public class ContractItemService implements IEntityService<ContractItem>, QueryS
|
||||
return itemRepository.findByInventoryId(inventory.getId());
|
||||
}
|
||||
|
||||
public List<ContractItem> findAll(Specification<ContractItem> spec, Sort sort) {
|
||||
return itemRepository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
|
||||
@Override
|
||||
public void updateByVo(ContractItem model, ContractItemVo vo) {
|
||||
// 更新基本属性
|
||||
@@ -181,16 +126,47 @@ public class ContractItemService implements IEntityService<ContractItem>, QueryS
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "#p0.id")
|
||||
public ContractItem save(ContractItem item) {
|
||||
return itemRepository.save(item);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
@Override
|
||||
@CacheEvict(key = "#p0.id")
|
||||
public void delete(ContractItem item) {
|
||||
itemRepository.delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ContractItemRepository getRepository() {
|
||||
return itemRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractItem createNewEntity() {
|
||||
return new ContractItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ContractItem> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
Path<Inventory> inventory = root.get("inventory");
|
||||
return builder.or(
|
||||
builder.like(root.get("itemCode"), "%" + searchText + "%"),
|
||||
builder.like(root.get("title"), "%" + searchText + "%"),
|
||||
builder.like(root.get("specification"), "%" + searchText + "%"),
|
||||
builder.like(root.get("unit"), "%" + searchText + "%"),
|
||||
builder.like(root.get("remark"), "%" + searchText + "%"),
|
||||
builder.and(
|
||||
inventory.isNotNull(), builder.or(
|
||||
builder.like(inventory.get("name"), "%" + searchText + "%"),
|
||||
builder.like(inventory.get("code"), "%" + searchText + "%"),
|
||||
builder.like(inventory.get("specification"), "%" + searchText + "%"))));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ContractItem> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.contract.repository.ContractKindRepository;
|
||||
@@ -29,7 +30,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-kind")
|
||||
public class ContractKindService implements IEntityService<ContractKind>, QueryService<ContractKindVo>,
|
||||
public class ContractKindService extends EntityService<ContractKind, ContractKindVo, Integer>
|
||||
implements IEntityService<ContractKind>, QueryService<ContractKindVo>,
|
||||
VoableService<ContractKind, ContractKindVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContractKindService.class);
|
||||
|
||||
@@ -43,26 +45,13 @@ public class ContractKindService implements IEntityService<ContractKind>, QueryS
|
||||
return repository.findById(id).map(ContractKind::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public ContractKind getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
@Override
|
||||
protected Specification<ContractKind> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractKind> findAll(Specification<ContractKind> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractKindVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ContractKind> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
return findAll(spec, pageable).map(ContractKind::toVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractKind> getSpecification(String searchText) {
|
||||
protected Specification<ContractKind> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
@@ -72,6 +61,10 @@ public class ContractKindService implements IEntityService<ContractKind>, QueryS
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "'kinds'"),
|
||||
@CacheEvict(key = "'kind-'+#p0.id"),
|
||||
})
|
||||
public void delete(ContractKind entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
@@ -117,4 +110,15 @@ public class ContractKindService implements IEntityService<ContractKind>, QueryS
|
||||
model.setTitle(vo.getTitle());
|
||||
// model.setActive(vo.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ContractKindRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractKind createNewEntity() {
|
||||
return new ContractKind();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -22,7 +23,7 @@ import com.ecep.contract.ds.contract.repository.ContractPayPlanRepository;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.contract.model.ContractPayPlan;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
|
||||
import com.ecep.contract.vo.ContractPayPlanVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@@ -32,17 +33,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-pay-plan")
|
||||
public class ContractPayPlanService implements IEntityService<ContractPayPlan>, QueryService<ContractPayPlanVo>,
|
||||
public class ContractPayPlanService extends EntityService<ContractPayPlan, ContractPayPlanVo, Integer>
|
||||
implements IEntityService<ContractPayPlan>, QueryService<ContractPayPlanVo>,
|
||||
VoableService<ContractPayPlan, ContractPayPlanVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractPayPlanRepository repository;
|
||||
|
||||
@Override
|
||||
public ContractPayPlan getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ContractPayPlanVo findById(Integer id) {
|
||||
@@ -50,29 +47,13 @@ public class ContractPayPlanService implements IEntityService<ContractPayPlan>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractPayPlan> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return (root, query, cb) -> {
|
||||
return cb.or(cb.like(root.get("payTerm"), "%" + searchText + "%"));
|
||||
};
|
||||
protected ContractPayPlanRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractPayPlan> findAll(Specification<ContractPayPlan> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractPayPlanVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ContractPayPlan> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract");
|
||||
return findAll(spec, pageable).map(ContractPayPlan::toVo);
|
||||
public ContractPayPlan createNewEntity() {
|
||||
return new ContractPayPlan();
|
||||
}
|
||||
|
||||
public List<ContractPayPlan> findAllByContract(ContractVo contract) {
|
||||
@@ -117,4 +98,17 @@ public class ContractPayPlanService implements IEntityService<ContractPayPlan>,
|
||||
model.setUpdateDate(vo.getUpdateDate());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ContractPayPlan> buildParameterSpecification(JsonNode paramsNode) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ContractPayPlan> buildSearchSpecification(String searchText) {
|
||||
return (root, query, cb) -> {
|
||||
return cb.or(cb.like(root.get("payTerm"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.ecep.contract.ds.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -15,6 +13,7 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.contract.repository.ContractTypeRepository;
|
||||
@@ -29,9 +28,9 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-type")
|
||||
public class ContractTypeService implements IEntityService<ContractType>, QueryService<ContractTypeVo>,
|
||||
public class ContractTypeService extends EntityService<ContractType, ContractTypeVo, Integer>
|
||||
implements IEntityService<ContractType>, QueryService<ContractTypeVo>,
|
||||
VoableService<ContractType, ContractTypeVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContractTypeService.class);
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -43,22 +42,29 @@ public class ContractTypeService implements IEntityService<ContractType>, QueryS
|
||||
return repository.findById(id).map(ContractType::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public ContractType getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
@Override
|
||||
protected ContractTypeRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractType> findAll(Specification<ContractType> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
public ContractType createNewEntity() {
|
||||
return new ContractType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ContractType> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
return findAll(spec, pageable).map(ContractType::toVo);
|
||||
protected Specification<ContractType> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("title"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ContractType> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ContractType findByName(String name) {
|
||||
@@ -75,16 +81,6 @@ public class ContractTypeService implements IEntityService<ContractType>, QueryS
|
||||
return repository.findAll().stream().map(ContractType::toVo).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractType> getSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("title"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code"),
|
||||
|
||||
@@ -18,6 +18,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.contract.repository.ExtendVendorInfoRepository;
|
||||
@@ -25,14 +26,15 @@ import com.ecep.contract.ds.vendor.service.VendorGroupService;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.vendor.model.ExtendVendorInfo;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
|
||||
import com.ecep.contract.vo.ExtendVendorInfoVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-ext-ven-info")
|
||||
public class ExtendVendorInfoService implements IEntityService<ExtendVendorInfo>, QueryService<ExtendVendorInfoVo>,
|
||||
public class ExtendVendorInfoService extends EntityService<ExtendVendorInfo, ExtendVendorInfoVo, Integer>
|
||||
implements IEntityService<ExtendVendorInfo>, QueryService<ExtendVendorInfoVo>,
|
||||
VoableService<ExtendVendorInfo, ExtendVendorInfoVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -45,8 +47,23 @@ public class ExtendVendorInfoService implements IEntityService<ExtendVendorInfo>
|
||||
private ContractService contractService;
|
||||
|
||||
@Override
|
||||
public ExtendVendorInfo getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected ExtendVendorInfoRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtendVendorInfo createNewEntity() {
|
||||
return new ExtendVendorInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ExtendVendorInfo> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("contract").get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("contract").get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("codeSequenceNumber").as(String.class), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,35 +98,6 @@ public class ExtendVendorInfoService implements IEntityService<ExtendVendorInfo>
|
||||
repository.delete(bidVendor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ExtendVendorInfo> findAll(Specification<ExtendVendorInfo> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ExtendVendorInfo> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("contract").get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("contract").get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("codeSequenceNumber").as(String.class), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ExtendVendorInfoVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ExtendVendorInfo> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract");
|
||||
return findAll(spec, pageable).map(ExtendVendorInfo::toVo);
|
||||
}
|
||||
|
||||
public List<ExtendVendorInfo> findAll(Specification<ExtendVendorInfo> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
@@ -167,4 +155,9 @@ public class ExtendVendorInfoService implements IEntityService<ExtendVendorInfo>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ExtendVendorInfo> buildParameterSpecification(JsonNode paramsNode) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,25 +2,22 @@ package com.ecep.contract.ds.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
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.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.contract.repository.PurchaseBillVoucherItemRepository;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseBillVoucherItem;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import com.ecep.contract.vo.PurchaseBillVoucherItemVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@@ -28,25 +25,31 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "purchase-bill-voucher-item")
|
||||
public class PurchaseBillVoucherItemService
|
||||
implements IEntityService<PurchaseBillVoucherItem>, QueryService<PurchaseBillVoucherItem>,
|
||||
extends EntityService<PurchaseBillVoucherItem, PurchaseBillVoucherItemVo, Integer>
|
||||
implements IEntityService<PurchaseBillVoucherItem>, QueryService<PurchaseBillVoucherItemVo>,
|
||||
VoableService<PurchaseBillVoucherItem, PurchaseBillVoucherItemVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private PurchaseBillVoucherItemRepository repository;
|
||||
|
||||
@Override
|
||||
public PurchaseBillVoucherItem getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public PurchaseBillVoucherItem findById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
public PurchaseBillVoucherItemVo findById(Integer id) {
|
||||
return repository.findById(id).map(PurchaseBillVoucherItem::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<PurchaseBillVoucherItem> getSpecification(String searchText) {
|
||||
protected PurchaseBillVoucherItemRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PurchaseBillVoucherItem createNewEntity() {
|
||||
return new PurchaseBillVoucherItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<PurchaseBillVoucherItem> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||
@@ -54,19 +57,8 @@ public class PurchaseBillVoucherItemService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PurchaseBillVoucherItem> findAll(Specification<PurchaseBillVoucherItem> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PurchaseBillVoucherItem> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<PurchaseBillVoucherItem> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "voucher");
|
||||
return findAll(spec, pageable);
|
||||
protected Specification<PurchaseBillVoucherItem> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@@ -87,10 +79,6 @@ public class PurchaseBillVoucherItemService
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
public List<PurchaseBillVoucherItem> findAll(Specification<PurchaseBillVoucherItem> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(PurchaseBillVoucherItem model, PurchaseBillVoucherItemVo vo) {
|
||||
model.setId(vo.getId());
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package com.ecep.contract.ds.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseBillVoucherItem;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrderItem;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -18,11 +13,12 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.company.service.InvoiceService;
|
||||
import com.ecep.contract.ds.contract.repository.PurchaseBillVoucherRepository;
|
||||
@@ -39,40 +35,21 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "purchase-bill-voucher")
|
||||
public class PurchaseBillVoucherService
|
||||
public class PurchaseBillVoucherService extends EntityService<PurchaseBillVoucher, PurchaseBillVoucherVo, Integer>
|
||||
implements IEntityService<PurchaseBillVoucher>, QueryService<PurchaseBillVoucherVo>,
|
||||
VoableService<PurchaseBillVoucher, PurchaseBillVoucherVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PurchaseBillVoucherService.class);
|
||||
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private PurchaseBillVoucherRepository repository;
|
||||
|
||||
@Override
|
||||
public PurchaseBillVoucher getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public PurchaseBillVoucherVo findById(Integer id) {
|
||||
return repository.findById(id).map(PurchaseBillVoucher::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<PurchaseBillVoucher> getSpecification(String searchText) {
|
||||
// if null
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Cacheable(key = "'code-'+#p0")
|
||||
public PurchaseBillVoucherVo findByCode(String code) {
|
||||
return repository.findByCode(code).map(PurchaseBillVoucher::toVo).orElse(null);
|
||||
@@ -88,16 +65,17 @@ public class PurchaseBillVoucherService
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存实体对象,异步方法
|
||||
* 保存实体对象
|
||||
*
|
||||
* @param voucher 要保存的实体对象
|
||||
* @return 返回异步调用
|
||||
* @return 返回保存后的实体
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code"),
|
||||
@CacheEvict(key = "'refId-'+#p0.refId")
|
||||
})
|
||||
@Override
|
||||
public PurchaseBillVoucher save(PurchaseBillVoucher voucher) {
|
||||
return repository.save(voucher);
|
||||
}
|
||||
@@ -112,47 +90,30 @@ public class PurchaseBillVoucherService
|
||||
repository.delete(order);
|
||||
}
|
||||
|
||||
public long count() {
|
||||
return repository.count();
|
||||
}
|
||||
|
||||
public long count(Specification<PurchaseBillVoucher> spec) {
|
||||
return repository.count(spec);
|
||||
@Override
|
||||
protected Specification<PurchaseBillVoucher> buildParameterSpecification(JsonNode paramsNode) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PurchaseBillVoucher> findAll(Specification<PurchaseBillVoucher> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
protected PurchaseBillVoucherRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PurchaseBillVoucherVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<PurchaseBillVoucher> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company", "inventory");
|
||||
if (paramsNode.has("purchaseOrder")) {
|
||||
spec = SpecificationUtils.and(spec, (root, query, cb) -> {
|
||||
Root<PurchaseBillVoucherItem> voucherItemRoot = query.from(PurchaseBillVoucherItem.class);
|
||||
Root<PurchaseOrderItem> orderItemRoot = query.from(PurchaseOrderItem.class);
|
||||
return cb.and(
|
||||
cb.equal(voucherItemRoot.get("orderItem"), orderItemRoot),
|
||||
cb.equal(orderItemRoot.get("order").get("id"), paramsNode.get("purchaseOrder").asInt()),
|
||||
cb.equal(root, voucherItemRoot.get("voucher"))
|
||||
);
|
||||
});
|
||||
}
|
||||
return findAll(spec, pageable).map(PurchaseBillVoucher::toVo);
|
||||
public PurchaseBillVoucher createNewEntity() {
|
||||
return new PurchaseBillVoucher();
|
||||
}
|
||||
|
||||
public List<PurchaseBillVoucher> findAll(Specification<PurchaseBillVoucher> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
public List<PurchaseBillVoucher> search(String searchText) {
|
||||
return repository.findAll(getSpecification(searchText), Pageable.ofSize(10)).getContent();
|
||||
@Override
|
||||
protected Specification<PurchaseBillVoucher> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,4 +161,5 @@ public class PurchaseBillVoucherService
|
||||
model.setVerifier(employeeService.getById(vo.getVerifierId()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,6 @@ package com.ecep.contract.ds.contract.service;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||
import com.ecep.contract.vo.ContractItemVo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -15,38 +11,31 @@ 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.domain.Sort;
|
||||
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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.contract.repository.PurchaseOrderItemRepository;
|
||||
import com.ecep.contract.ds.other.service.InventoryService;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrderItem;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.PurchaseOrderItemVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-purchase-order-item")
|
||||
public class PurchaseOrderItemService implements IEntityService<PurchaseOrderItem>, QueryService<PurchaseOrderItemVo>,
|
||||
public class PurchaseOrderItemService extends EntityService<PurchaseOrderItem, PurchaseOrderItemVo, Integer> implements IEntityService<PurchaseOrderItem>, QueryService<PurchaseOrderItemVo>,
|
||||
VoableService<PurchaseOrderItem, PurchaseOrderItemVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PurchaseOrderItemService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
private PurchaseOrderItemRepository repository;
|
||||
|
||||
@Override
|
||||
public PurchaseOrderItem getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public PurchaseOrderItemVo findById(Integer id) {
|
||||
@@ -62,61 +51,10 @@ public class PurchaseOrderItemService implements IEntityService<PurchaseOrderIte
|
||||
while (list.size() > 1) {
|
||||
PurchaseOrderItem item = list.removeLast();
|
||||
repository.delete(item);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Duplicate PurchaseOrderItem, Delete {}", item);
|
||||
}
|
||||
}
|
||||
return list.getFirst().toVo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<PurchaseOrderItem> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(builder.like(root.get("description"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PurchaseOrderItem> findAll(Specification<PurchaseOrderItem> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PurchaseOrderItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<PurchaseOrderItem> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "order", "inventory", "contractItem");
|
||||
|
||||
// if (paramsNode.has("contractItem")) {
|
||||
// ContractItemService itemService = SpringApp.getBean(ContractItemService.class);
|
||||
// var contractItem = itemService.findById(paramsNode.get("contractItem").asInt());
|
||||
//
|
||||
// if (contractItem.getInventoryId() == null) {
|
||||
// spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
// return builder.and(
|
||||
// builder.equal(root.get("order").get("contract").get("id"), contractItem.getContractId()),
|
||||
// builder.equal(root.get("inventory").get("id"), null)
|
||||
// );
|
||||
// });
|
||||
// } else {
|
||||
// spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
// return builder.and(
|
||||
// builder.equal(root.get("order").get("contract").get("id"), contractItem.getContractId()),
|
||||
// builder.equal(root.get("inventory").get("id"), contractItem.getInventoryId())
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
return findAll(spec, pageable).map(PurchaseOrderItem::toVo);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'refId-'+#p0.refId")
|
||||
@@ -134,10 +72,6 @@ public class PurchaseOrderItemService implements IEntityService<PurchaseOrderIte
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
public List<PurchaseOrderItem> findAll(Specification<PurchaseOrderItem> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(PurchaseOrderItem model, PurchaseOrderItemVo vo) {
|
||||
if (model == null) {
|
||||
@@ -183,4 +117,26 @@ public class PurchaseOrderItemService implements IEntityService<PurchaseOrderIte
|
||||
public List<PurchaseOrderItem> findAllByOrder(PurchaseOrder order) {
|
||||
return repository.findAllByOrder(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PurchaseOrderItemRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PurchaseOrderItem createNewEntity() {
|
||||
return new PurchaseOrderItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<PurchaseOrderItem> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(builder.like(root.get("description"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<PurchaseOrderItem> buildParameterSpecification(JsonNode paramsNode) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package com.ecep.contract.ds.contract.service;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -13,10 +11,10 @@ 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.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -26,7 +24,6 @@ import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.PurchaseOrderVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@@ -36,31 +33,32 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-purchase-order")
|
||||
public class PurchaseOrdersService implements IEntityService<PurchaseOrder>, QueryService<PurchaseOrderVo>,
|
||||
public class PurchaseOrdersService extends EntityService<PurchaseOrder, PurchaseOrderVo, Integer>
|
||||
implements IEntityService<PurchaseOrder>, QueryService<PurchaseOrderVo>,
|
||||
VoableService<PurchaseOrder, PurchaseOrderVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PurchaseOrdersService.class);
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private PurchaseOrderRepository repository;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
|
||||
@Override
|
||||
public PurchaseOrder getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected PurchaseOrderRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public PurchaseOrderVo findById(Integer id) {
|
||||
return repository.findById(id).map(PurchaseOrder::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<PurchaseOrder> getSpecification(String searchText) {
|
||||
public PurchaseOrder createNewEntity() {
|
||||
return new PurchaseOrder();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<PurchaseOrder> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
@@ -108,31 +106,9 @@ public class PurchaseOrdersService implements IEntityService<PurchaseOrder>, Que
|
||||
repository.delete(order);
|
||||
}
|
||||
|
||||
public long count() {
|
||||
return repository.count();
|
||||
}
|
||||
|
||||
public long count(Specification<PurchaseOrder> spec) {
|
||||
return repository.count(spec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PurchaseOrder> findAll(Specification<PurchaseOrder> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PurchaseOrderVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<PurchaseOrder> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract");
|
||||
return findAll(spec, pageable).map(PurchaseOrder::toVo);
|
||||
}
|
||||
|
||||
public List<PurchaseOrder> findAll(Specification<PurchaseOrder> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
protected Specification<PurchaseOrder> buildParameterSpecification(JsonNode paramsNode) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||
}
|
||||
|
||||
public List<PurchaseOrder> findAllByContract(Contract contract) {
|
||||
@@ -143,15 +119,6 @@ public class PurchaseOrdersService implements IEntityService<PurchaseOrder>, Que
|
||||
return repository.findAllByContractId(contract.getId());
|
||||
}
|
||||
|
||||
public List<PurchaseOrder> search(String searchText) {
|
||||
Specification<PurchaseOrder> spec = (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("code"), "%" + searchText + "%"));
|
||||
};
|
||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(PurchaseOrder model, PurchaseOrderVo vo) {
|
||||
if (model == null || vo == null) {
|
||||
|
||||
@@ -52,10 +52,7 @@ public class SaleOrdersService extends EntityService<SalesOrder, SalesOrderVo, I
|
||||
return new SalesOrder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SalesOrder getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public SalesOrderVo findById(Integer id) {
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package com.ecep.contract.ds.contract.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.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.contract.repository.SalesBillVoucherItemRepository;
|
||||
@@ -25,50 +21,19 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "sales-bill-voucher-item")
|
||||
public class SalesBillVoucherItemService
|
||||
public class SalesBillVoucherItemService extends EntityService<SalesBillVoucherItem, SalesBillVoucherItemVo, Integer>
|
||||
implements IEntityService<SalesBillVoucherItem>, QueryService<SalesBillVoucherItemVo>,
|
||||
VoableService<SalesBillVoucherItem, SalesBillVoucherItemVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SalesBillVoucherItemRepository repository;
|
||||
|
||||
@Override
|
||||
public SalesBillVoucherItem getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public SalesBillVoucherItemVo findById(Integer id) {
|
||||
return repository.findById(id).map(SalesBillVoucherItem::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<SalesBillVoucherItem> getSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SalesBillVoucherItem> findAll(Specification<SalesBillVoucherItem> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<SalesBillVoucherItem> findAll(Specification<SalesBillVoucherItem> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SalesBillVoucherItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<SalesBillVoucherItem> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
return findAll(spec, pageable).map(SalesBillVoucherItem::toVo);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "'item-'+#p0.id")
|
||||
})
|
||||
@@ -85,12 +50,26 @@ public class SalesBillVoucherItemService
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
public long countItems() {
|
||||
return repository.count();
|
||||
@Override
|
||||
protected SalesBillVoucherItemRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public long countItems(Specification<SalesBillVoucherItem> spec) {
|
||||
return repository.count(spec);
|
||||
@Override
|
||||
public SalesBillVoucherItem createNewEntity() {
|
||||
return new SalesBillVoucherItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<SalesBillVoucherItem> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(builder.like(root.get("description"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<SalesBillVoucherItem> buildParameterSpecification(JsonNode paramsNode) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,4 +82,5 @@ public class SalesBillVoucherItemService
|
||||
model.setPrice(vo.getPrice());
|
||||
model.setDescription(vo.getDescription());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,24 +2,26 @@ package com.ecep.contract.ds.customer.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerEvaluationFormFile;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerFile;
|
||||
|
||||
@Repository
|
||||
public interface CompanyCustomerEvaluationFormFileRepository extends JpaRepository<CompanyCustomerEvaluationFormFile, Integer>, JpaSpecificationExecutor<CompanyCustomerEvaluationFormFile> {
|
||||
public interface CompanyCustomerEvaluationFormFileRepository
|
||||
extends MyRepository<CompanyCustomerEvaluationFormFile, Integer> {
|
||||
|
||||
List<CompanyCustomerEvaluationFormFile> findAllByCustomerFileCustomer(@Param("customer") CompanyCustomer customer);
|
||||
|
||||
@Query(value = "SELECT * FROM COMPANY_CUSTOMER_FILE ccf left join COMPANY_CUSTOMER_EVALUATION_FORM_FILE CCEFF on ccf.ID = CCEFF.ID " +
|
||||
@Query(value = "SELECT * FROM COMPANY_CUSTOMER_FILE ccf left join COMPANY_CUSTOMER_EVALUATION_FORM_FILE CCEFF on ccf.ID = CCEFF.ID "
|
||||
+
|
||||
"where ccf.CUSTOMER_ID=:customer and ccf.TYPE=:fileType", nativeQuery = true)
|
||||
List<CompanyCustomerEvaluationFormFile> findAllByCustomerAndType(@Param("customer") int companyCustomerId, @Param("fileType") String type);
|
||||
List<CompanyCustomerEvaluationFormFile> findAllByCustomerAndType(@Param("customer") int companyCustomerId,
|
||||
@Param("fileType") String type);
|
||||
|
||||
CompanyCustomerEvaluationFormFile findByCustomerFile(CompanyCustomerFile customerFile);
|
||||
}
|
||||
|
||||
@@ -12,23 +12,25 @@ 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 com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerEntityRepository;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyCustomerEntityVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-customer-entity")
|
||||
public class CompanyCustomerEntityService implements IEntityService<CompanyCustomerEntity>, QueryService<CompanyCustomerEntityVo>, VoableService<CompanyCustomerEntity, CompanyCustomerEntityVo> {
|
||||
public class CompanyCustomerEntityService extends EntityService<CompanyCustomerEntity, CompanyCustomerEntityVo, Integer>
|
||||
implements IEntityService<CompanyCustomerEntity>, QueryService<CompanyCustomerEntityVo>,
|
||||
VoableService<CompanyCustomerEntity, CompanyCustomerEntityVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyCustomerEntityRepository repository;
|
||||
@@ -42,11 +44,6 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
|
||||
@Override
|
||||
public CompanyCustomerEntity getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public CompanyCustomerEntityVo findById(Integer id) {
|
||||
@@ -54,13 +51,6 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyCustomerEntity> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
|
||||
}
|
||||
|
||||
protected Specification<CompanyCustomerEntity> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
@@ -70,25 +60,9 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
|
||||
};
|
||||
}
|
||||
|
||||
public List<CompanyCustomerEntity> search(String searchText) {
|
||||
Specification<CompanyCustomerEntity> spec = getSpecification(searchText);
|
||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyCustomerEntity> findAll(Specification<CompanyCustomerEntity> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyCustomerEntityVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<CompanyCustomerEntity> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "customer");
|
||||
return findAll(spec, pageable).map(CompanyCustomerEntity::toVo);
|
||||
protected Specification<CompanyCustomerEntity> buildParameterSpecification(JsonNode paramsNode) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@@ -126,6 +100,16 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
|
||||
repository.saveAll(entities);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MyRepository<CompanyCustomerEntity, Integer> getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyCustomerEntity createNewEntity() {
|
||||
return new CompanyCustomerEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CompanyCustomerEntity entity, CompanyCustomerEntityVo vo) {
|
||||
// 优化关联实体处理逻辑 - 客户关联
|
||||
|
||||
@@ -3,12 +3,9 @@ package com.ecep.contract.ds.customer.service;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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;
|
||||
@@ -16,9 +13,11 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerEvaluationFormFileRepository;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerEvaluationFormFile;
|
||||
@@ -33,30 +32,31 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-customer-evaluation-form-file")
|
||||
public class CompanyCustomerEvaluationFormFileService
|
||||
implements IEntityService<CompanyCustomerEvaluationFormFile>, QueryService<CompanyCustomerEvaluationFormFile>,
|
||||
extends EntityService<CompanyCustomerEvaluationFormFile, CompanyCustomerEvaluationFormFileVo, Integer>
|
||||
implements IEntityService<CompanyCustomerEvaluationFormFile>, QueryService<CompanyCustomerEvaluationFormFileVo>,
|
||||
VoableService<CompanyCustomerEvaluationFormFile, CompanyCustomerEvaluationFormFileVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerEvaluationFormFileService.class);
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyCustomerEvaluationFormFileRepository repository;
|
||||
|
||||
@Override
|
||||
public CompanyCustomerEvaluationFormFile getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public CompanyCustomerEvaluationFormFile findById(Integer id) {
|
||||
return getById(id);
|
||||
protected CompanyCustomerEvaluationFormFileRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyCustomerEvaluationFormFile> getSpecification(String searchText) {
|
||||
if (!org.springframework.util.StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
public CompanyCustomerEvaluationFormFileVo findById(Integer id) {
|
||||
return repository.findById(id).map(CompanyCustomerEvaluationFormFile::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyCustomerEvaluationFormFile createNewEntity() {
|
||||
return new CompanyCustomerEvaluationFormFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<CompanyCustomerEvaluationFormFile> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
var customerFile = root.get("customerFile");
|
||||
return builder.or(
|
||||
@@ -64,8 +64,7 @@ public class CompanyCustomerEvaluationFormFileService
|
||||
builder.like(root.get("level"), "%" + searchText + "%"),
|
||||
builder.and(
|
||||
customerFile.isNotNull(),
|
||||
builder.like(customerFile.get("filePath"), "%" + searchText + "%")
|
||||
));
|
||||
builder.like(customerFile.get("filePath"), "%" + searchText + "%")));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -86,31 +85,23 @@ public class CompanyCustomerEvaluationFormFileService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyCustomerEvaluationFormFile> findAll(Specification<CompanyCustomerEvaluationFormFile> spec,
|
||||
Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyCustomerEvaluationFormFile> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<CompanyCustomerEvaluationFormFile> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CompanyCustomerEvaluationFormFile> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
|
||||
if (paramsNode.has("customer")) {
|
||||
spec = SpecificationUtils.and(spec,
|
||||
(root, query, builder) -> builder.equal(root.get("customerFile").get("customer").get("id"), paramsNode.get("customer").asInt()));
|
||||
(root, query, builder) -> builder.equal(root.get("customerFile").get("customer").get("id"),
|
||||
paramsNode.get("customer").asInt()));
|
||||
}
|
||||
if (paramsNode.has("company")) {
|
||||
spec = SpecificationUtils.and(spec,
|
||||
(root, query, builder) -> builder.equal(root.get("customerFile").get("customer").get("company").get("id"), paramsNode.get("company").asInt()));
|
||||
(root, query, builder) -> builder.equal(
|
||||
root.get("customerFile").get("customer").get("company").get("id"),
|
||||
paramsNode.get("company").asInt()));
|
||||
}
|
||||
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "customerFile");
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "catalog", "level");
|
||||
|
||||
return findAll(spec, pageable);
|
||||
return spec;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,4 +169,5 @@ public class CompanyCustomerEvaluationFormFileService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,12 +8,9 @@ import java.util.Optional;
|
||||
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
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.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;
|
||||
@@ -23,6 +20,7 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.CustomerFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.QueryService;
|
||||
@@ -47,10 +45,9 @@ import jakarta.persistence.criteria.Path;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-customer-file")
|
||||
public class CompanyCustomerFileService
|
||||
implements IEntityService<CompanyCustomerFile>, QueryService<CompanyCustomerFile>,
|
||||
public class CompanyCustomerFileService extends EntityService<CompanyCustomerFile, CustomerFileVo, Integer>
|
||||
implements IEntityService<CompanyCustomerFile>, QueryService<CustomerFileVo>,
|
||||
VoableService<CompanyCustomerFile, CustomerFileVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerFileService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SysConfService confService;
|
||||
@@ -61,18 +58,32 @@ public class CompanyCustomerFileService
|
||||
@Autowired
|
||||
private CompanyCustomerEvaluationFormFileRepository companyCustomerEvaluationFormFileRepository;
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public CompanyCustomerFile findById(Integer id) {
|
||||
return getById(id);
|
||||
@Override
|
||||
protected CompanyCustomerFileRepository getRepository() {
|
||||
return companyCustomerFileRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyCustomerFile getById(Integer id) {
|
||||
return companyCustomerFileRepository.findById(id).orElse(null);
|
||||
public CustomerFileVo findById(Integer id) {
|
||||
return getRepository().findById(id).map(CompanyCustomerFile::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyCustomerFile> getSpecification(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 builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
|
||||
};
|
||||
@@ -99,23 +110,6 @@ public class CompanyCustomerFileService
|
||||
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 = getSpecification(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) {
|
||||
return companyCustomerFileRepository.findAllByCustomer(customer);
|
||||
}
|
||||
@@ -183,7 +177,8 @@ public class CompanyCustomerFileService
|
||||
LocalDate miniContractDate = LocalDate.of(2022, 1, 1);
|
||||
// 检索全部合同
|
||||
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()) {
|
||||
holder.error("未发现已登记的合同");
|
||||
return null;
|
||||
@@ -299,6 +294,4 @@ public class CompanyCustomerFileService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CustomerFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerFileTypeLocalRepository;
|
||||
@@ -31,33 +32,37 @@ import jakarta.annotation.Resource;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Resource
|
||||
private CompanyCustomerFileTypeLocalRepository repository;
|
||||
|
||||
@Override
|
||||
protected CompanyCustomerFileTypeLocalRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyCustomerFileTypeLocal createNewEntity() {
|
||||
return new CompanyCustomerFileTypeLocal();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public CompanyCustomerFileTypeLocalVo findById(Integer id) {
|
||||
return repository.findById(id).map(CompanyCustomerFileTypeLocal::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public CompanyCustomerFileTypeLocal getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyCustomerFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<CompanyCustomerFileTypeLocal> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CompanyCustomerFileTypeLocal> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
|
||||
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 findAll(spec, pageable).map(CompanyCustomerFileTypeLocal::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||
@@ -65,26 +70,13 @@ public class CompanyCustomerFileTypeService implements IEntityService<CompanyCus
|
||||
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
||||
.collect(java.util.stream.Collectors.toMap(
|
||||
java.util.Map.Entry::getKey,
|
||||
entry -> entry.getValue().toVo()
|
||||
));
|
||||
entry -> entry.getValue().toVo()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyCustomerFileTypeLocal> findAll(Specification<CompanyCustomerFileTypeLocal> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyCustomerFileTypeLocal> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<CompanyCustomerFileTypeLocal> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return
|
||||
// builder.or(
|
||||
builder.like(root.get("type"), "%" + searchText + "%")
|
||||
// )
|
||||
;
|
||||
return builder.like(root.get("type"), "%" + searchText + "%");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import com.ecep.contract.ds.customer.repository.CustomerCatalogRepository;
|
||||
import com.ecep.contract.model.CustomerCatalog;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
@@ -10,19 +22,6 @@ import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CustomerCatalogVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 客户分类服务
|
||||
@@ -30,18 +29,40 @@ import java.util.List;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "customer-catalog")
|
||||
public class CustomerCatalogService implements IEntityService<CustomerCatalog>, QueryService<CustomerCatalogVo>,
|
||||
public class CustomerCatalogService extends EntityService<CustomerCatalog, CustomerCatalogVo, Integer>
|
||||
implements IEntityService<CustomerCatalog>, QueryService<CustomerCatalogVo>,
|
||||
VoableService<CustomerCatalog, CustomerCatalogVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CustomerCatalogRepository repository;
|
||||
|
||||
/**
|
||||
* 根据 id 查找 CustomerCatalog
|
||||
*/
|
||||
@Override
|
||||
public CustomerCatalog getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected CustomerCatalogRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomerCatalog createNewEntity() {
|
||||
return new CustomerCatalog();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected org.springframework.data.jpa.domain.Specification<CustomerCatalog> buildParameterSpecification(
|
||||
JsonNode paramsNode) {
|
||||
org.springframework.data.jpa.domain.Specification<CustomerCatalog> spec = null;
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code", "name", "description");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<CustomerCatalog> buildSearchSpecification(String searchText) {
|
||||
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));
|
||||
};
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -108,49 +129,6 @@ public class CustomerCatalogService implements IEntityService<CustomerCatalog>,
|
||||
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 = getSpecification(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> getSpecification(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(getSpecification(searchText), Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CustomerCatalog> findAll(Specification<CustomerCatalog> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CustomerCatalog model, CustomerCatalogVo vo) {
|
||||
// 参数校验
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CustomerFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.customer.repository.CustomerFileTypeLocalRepository;
|
||||
@@ -31,26 +32,30 @@ import com.ecep.contract.vo.CustomerFileTypeLocalVo;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CustomerFileTypeLocalRepository repository;
|
||||
|
||||
@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;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
|
||||
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
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
||||
return findAll(spec, pageable).map(CustomerFileTypeLocal::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -59,36 +64,22 @@ public class CustomerFileTypeService implements IEntityService<CustomerFileTypeL
|
||||
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()")
|
||||
public Map<CustomerFileType, CustomerFileTypeLocalVo> findAll(Locale locale) {
|
||||
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
||||
.collect(java.util.stream.Collectors.toMap(
|
||||
java.util.Map.Entry::getKey,
|
||||
entry -> entry.getValue().toVo()
|
||||
));
|
||||
entry -> entry.getValue().toVo()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CustomerFileTypeLocal> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return (root, query, builder) -> {
|
||||
return
|
||||
// builder.or(
|
||||
builder.like(root.get("type"), "%" + searchText + "%")
|
||||
// )
|
||||
;
|
||||
};
|
||||
protected CustomerFileTypeLocalRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomerFileTypeLocal createNewEntity() {
|
||||
return new CustomerFileTypeLocal();
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CustomerFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.QueryService;
|
||||
@@ -59,7 +60,8 @@ import jakarta.persistence.criteria.Path;
|
||||
@Lazy
|
||||
@Service
|
||||
@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>,
|
||||
VoableService<CompanyCustomer, CustomerVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CustomerService.class);
|
||||
@@ -77,49 +79,21 @@ public class CustomerService extends CompanyBasicService
|
||||
@Autowired
|
||||
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
|
||||
public CompanyCustomer getById(Integer id) {
|
||||
return repository.findById(id).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")
|
||||
})
|
||||
public CompanyCustomer save(CompanyCustomer companyCustomer) {
|
||||
return repository.save(companyCustomer);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0")
|
||||
})
|
||||
@Override
|
||||
public void delete(CompanyCustomer entity) {
|
||||
repository.delete(entity);
|
||||
protected CompanyCustomerRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CompanyCustomer> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
public CompanyCustomer createNewEntity() {
|
||||
return new CompanyCustomer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<CompanyCustomer> buildSearchSpecification(String searchText) {
|
||||
Specification<CompanyCustomer> nameSpec = (root, query, builder) -> {
|
||||
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)) {
|
||||
@@ -147,9 +121,40 @@ public class CustomerService extends CompanyBasicService
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyCustomer> search(String searchText) {
|
||||
Specification<CompanyCustomer> spec = getSpecification(searchText);
|
||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
protected Specification<CompanyCustomer> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CompanyCustomer> spec = null;
|
||||
// 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
|
||||
@@ -158,6 +163,7 @@ public class CustomerService extends CompanyBasicService
|
||||
companyCustomerFileService.delete(customerFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getBasePath() {
|
||||
return new File(confService.getString(CompanyCustomerConstant.KEY_BASE_PATH));
|
||||
}
|
||||
@@ -199,7 +205,7 @@ public class CustomerService extends CompanyBasicService
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file,
|
||||
Consumer<String> status) {
|
||||
Consumer<String> status) {
|
||||
dbFile.setType((T) CustomerFileType.General);
|
||||
fillFile(dbFile, file, null, status);
|
||||
companyCustomerFileService.save((CompanyCustomerFile) dbFile);
|
||||
@@ -208,7 +214,7 @@ public class CustomerService extends CompanyBasicService
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
if (fileList != null) {
|
||||
@@ -242,7 +248,7 @@ public class CustomerService extends CompanyBasicService
|
||||
}
|
||||
|
||||
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();
|
||||
JsonNode root = objectMapper.readTree(jsonFile);
|
||||
if (!root.isObject()) {
|
||||
@@ -268,7 +274,7 @@ public class CustomerService extends CompanyBasicService
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
|
||||
Consumer<String> status) {
|
||||
Consumer<String> status) {
|
||||
CompanyCustomerFile customerFile = new CompanyCustomerFile();
|
||||
customerFile.setType(CustomerFileType.General);
|
||||
if (fillFile(customerFile, file, fileList, status)) {
|
||||
@@ -292,7 +298,7 @@ public class CustomerService extends CompanyBasicService
|
||||
return (fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME1)
|
||||
|| fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME2))
|
||||
&& (FileUtils.withExtensions(fileName, FileUtils.JPG, FileUtils.JPEG,
|
||||
FileUtils.PDF));
|
||||
FileUtils.PDF));
|
||||
}
|
||||
|
||||
public boolean makePathAbsent(CompanyCustomer companyCustomer) {
|
||||
@@ -335,21 +341,6 @@ public class CustomerService extends CompanyBasicService
|
||||
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 = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable).map(CompanyCustomer::toVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个公司的客户信息转移到另一个公司,并保存在数据库中
|
||||
*
|
||||
|
||||
@@ -43,7 +43,7 @@ public class EmployeeRoleController {
|
||||
|
||||
String searchText = (String) params.get("searchText");
|
||||
if (StringUtils.hasText(searchText)) {
|
||||
spec = SpecificationUtils.and(spec, employeeRoleService.getSpecification(searchText));
|
||||
spec = SpecificationUtils.and(spec, employeeRoleService.getSearchSpecification(searchText));
|
||||
}
|
||||
|
||||
Sort sort = Sort.by(Sort.Order.desc("id"));
|
||||
|
||||
@@ -4,15 +4,13 @@ import java.time.LocalDate;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.model.HolidayTable;
|
||||
|
||||
@Repository
|
||||
public interface HolidayTableRepository // curd
|
||||
extends CrudRepository<HolidayTable, LocalDate>, PagingAndSortingRepository<HolidayTable, LocalDate> {
|
||||
public interface HolidayTableRepository extends MyRepository<HolidayTable, LocalDate> {
|
||||
|
||||
/**
|
||||
* 根据是否为节假日过滤
|
||||
|
||||
@@ -2,14 +2,13 @@ package com.ecep.contract.ds.other.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.model.InventoryCatalog;
|
||||
|
||||
@Repository
|
||||
public interface InventoryCatalogRepository extends JpaRepository<InventoryCatalog, Integer>, JpaSpecificationExecutor<InventoryCatalog> {
|
||||
public interface InventoryCatalogRepository extends MyRepository<InventoryCatalog, Integer> {
|
||||
Optional<InventoryCatalog> findByCode(String code);
|
||||
|
||||
Optional<InventoryCatalog> findByName(String name);
|
||||
|
||||
@@ -2,13 +2,12 @@ package com.ecep.contract.ds.other.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.model.Inventory;
|
||||
|
||||
@Repository
|
||||
public interface InventoryRepository extends JpaRepository<Inventory, Integer>, JpaSpecificationExecutor<Inventory> {
|
||||
public interface InventoryRepository extends MyRepository<Inventory, Integer> {
|
||||
Optional<Inventory> findByCode(String code);
|
||||
}
|
||||
@@ -3,24 +3,15 @@ package com.ecep.contract.ds.other.repository;
|
||||
import java.util.List;
|
||||
|
||||
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 com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.model.Permission;
|
||||
|
||||
@Lazy
|
||||
@Repository
|
||||
public interface PermissionRepository extends
|
||||
// JDBC interfaces
|
||||
CrudRepository<Permission, Integer>, PagingAndSortingRepository<Permission, Integer>,
|
||||
// JPA interfaces
|
||||
JpaRepository<Permission, Integer>, JpaSpecificationExecutor<Permission> {
|
||||
|
||||
public interface PermissionRepository extends MyRepository<Permission, Integer> {
|
||||
|
||||
List<Permission> findAllByFunctionId(Integer functionId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,71 +1,51 @@
|
||||
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.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.other.repository.BankRepository;
|
||||
import com.ecep.contract.model.Bank;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.BankVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "bank")
|
||||
public class BankService 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
|
||||
@Autowired
|
||||
private BankRepository bankRepository;
|
||||
|
||||
@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
|
||||
protected BankRepository getRepository() {
|
||||
return bankRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<BankVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<Bank> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
return findAll(spec, pageable).map(Bank::toVo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public long count(JsonNode paramsNode) {
|
||||
return bankRepository.count();
|
||||
public Bank createNewEntity() {
|
||||
return new Bank();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<Bank> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected org.springframework.data.jpa.domain.Specification<Bank> buildParameterSpecification(JsonNode paramsNode) {
|
||||
org.springframework.data.jpa.domain.Specification<Bank> spec = null;
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code", "name");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected org.springframework.data.jpa.domain.Specification<Bank> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
@@ -73,9 +53,9 @@ public class BankService implements IEntityService<Bank>, QueryService<BankVo>,
|
||||
};
|
||||
}
|
||||
|
||||
public List<Bank> search(String searchText) {
|
||||
Specification<Bank> spec = getSpecification(searchText);
|
||||
return bankRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
@Cacheable(key = "#id")
|
||||
public BankVo findById(Integer id) {
|
||||
return bankRepository.findById(id).map(Bank::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public Bank findByName(String name) {
|
||||
|
||||
@@ -14,6 +14,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -23,6 +24,7 @@ import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.DepartmentVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
|
||||
/**
|
||||
* 部门
|
||||
@@ -30,46 +32,33 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "department")
|
||||
public class DepartmentService implements IEntityService<Department>, QueryService<DepartmentVo>, VoableService<Department, DepartmentVo> {
|
||||
public class DepartmentService extends EntityService<Department, DepartmentVo, Integer>
|
||||
implements IEntityService<Department>, QueryService<DepartmentVo>, VoableService<Department, DepartmentVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private DepartmentRepository repository;
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public DepartmentVo findById(Integer id) {
|
||||
return repository.findById(id).map(Department::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public Department getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'code-'+#p0")
|
||||
public DepartmentVo findByCode(String code) {
|
||||
return repository.findByCode(code).map(Department::toVo).orElse(null);
|
||||
protected DepartmentRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Department> findAll(Specification<Department> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
public Department createNewEntity() {
|
||||
return new Department();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DepartmentVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<Department> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
return findAll(spec, pageable).map(Department::toVo);
|
||||
protected org.springframework.data.jpa.domain.Specification<Department> buildParameterSpecification(
|
||||
JsonNode paramsNode) {
|
||||
org.springframework.data.jpa.domain.Specification<Department> spec = null;
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code", "name");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<Department> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected org.springframework.data.jpa.domain.Specification<Department> buildSearchSpecification(
|
||||
String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
// 使用或条件组合查询,以实现对员工代码或名称的模糊搜索
|
||||
return builder.or(
|
||||
@@ -78,9 +67,15 @@ public class DepartmentService implements IEntityService<Department>, QueryServi
|
||||
};
|
||||
}
|
||||
|
||||
public List<Department> search(String searchText) {
|
||||
Specification<Department> spec = getSpecification(searchText);
|
||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public DepartmentVo findById(Integer id) {
|
||||
return repository.findById(id).map(Department::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'code-'+#p0")
|
||||
public DepartmentVo findByCode(String code) {
|
||||
return repository.findByCode(code).map(Department::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
|
||||
@@ -13,6 +13,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -28,26 +29,25 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EmployeeAuthBindRepository repository;
|
||||
|
||||
@Override
|
||||
public EmployeeAuthBindVo findById(Integer id) {
|
||||
return repository.findById(id).map(EmployeeAuthBind::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public EmployeeAuthBind getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected EmployeeAuthBindRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<EmployeeAuthBind> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
public EmployeeAuthBind createNewEntity() {
|
||||
return new EmployeeAuthBind();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<EmployeeAuthBind> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("ip"), "%" + searchText + "%"),
|
||||
@@ -57,19 +57,16 @@ public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<EmployeeAuthBind> findAll(Specification<EmployeeAuthBind> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
protected Specification<EmployeeAuthBind> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<EmployeeAuthBind> spec = null;
|
||||
// 可以根据需要添加更多参数处理
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<EmployeeAuthBindVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<EmployeeAuthBind> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");
|
||||
return findAll(spec, pageable).map(EmployeeAuthBind::toVo);
|
||||
public EmployeeAuthBindVo findById(Integer id) {
|
||||
return repository.findById(id).map(EmployeeAuthBind::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package com.ecep.contract.ds.other.service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -25,7 +22,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "employee-login-history")
|
||||
public class EmployeeLoginHistoryService
|
||||
public class EmployeeLoginHistoryService extends EntityService<EmployeeLoginHistory, EmployeeLoginHistoryVo, Integer>
|
||||
implements IEntityService<EmployeeLoginHistory>, QueryService<EmployeeLoginHistoryVo>,
|
||||
VoableService<EmployeeLoginHistory, EmployeeLoginHistoryVo> {
|
||||
@Lazy
|
||||
@@ -33,19 +30,17 @@ public class EmployeeLoginHistoryService
|
||||
private EmployeeLoginHistoryRepository repository;
|
||||
|
||||
@Override
|
||||
public EmployeeLoginHistoryVo findById(Integer id) {
|
||||
return repository.findById(id).map(EmployeeLoginHistory::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public EmployeeLoginHistory getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected EmployeeLoginHistoryRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<EmployeeLoginHistory> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
public EmployeeLoginHistory createNewEntity() {
|
||||
return new EmployeeLoginHistory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<EmployeeLoginHistory> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("ip"), "%" + searchText + "%"),
|
||||
@@ -54,28 +49,22 @@ public class EmployeeLoginHistoryService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<EmployeeLoginHistory> findAll(Specification<EmployeeLoginHistory> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<EmployeeLoginHistoryVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<EmployeeLoginHistory> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<EmployeeLoginHistory> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "ip", "mac");
|
||||
return findAll(spec, pageable).map(EmployeeLoginHistory::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(EmployeeLoginHistory entity) {
|
||||
repository.delete(entity);
|
||||
public EmployeeLoginHistoryVo findById(Integer id) {
|
||||
return repository.findById(id).map(EmployeeLoginHistory::toVo).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "#p0.id")
|
||||
public EmployeeLoginHistory save(EmployeeLoginHistory entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@@ -3,27 +3,25 @@ package com.ecep.contract.ds.other.service;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.ecep.contract.vo.FunctionVo;
|
||||
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 com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
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.model.EmployeeRole;
|
||||
import com.ecep.contract.model.Function;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.EmployeeRoleVo;
|
||||
import com.ecep.contract.vo.FunctionVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
@@ -32,7 +30,8 @@ import jakarta.transaction.Transactional;
|
||||
*/
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -41,20 +40,18 @@ public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryS
|
||||
@Autowired
|
||||
private FunctionService functionService;
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public EmployeeRoleVo findById(Integer id) {
|
||||
return roleRepository.findById(id).map(EmployeeRole::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public EmployeeRole getById(Integer id) {
|
||||
return roleRepository.findById(id).orElse(null);
|
||||
@Override
|
||||
protected EmployeeRoleRepository getRepository() {
|
||||
return roleRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<EmployeeRole> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
public EmployeeRole createNewEntity() {
|
||||
return new EmployeeRole();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<EmployeeRole> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
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")
|
||||
public EmployeeRoleVo findByCode(String code) {
|
||||
return roleRepository.findByCode(code).map(EmployeeRole::toVo).orElse(null);
|
||||
@@ -84,18 +86,8 @@ public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryS
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<EmployeeRole> findAll(Specification<EmployeeRole> spec, Pageable pageable) {
|
||||
return roleRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<EmployeeRoleVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<EmployeeRole> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
return findAll(spec, pageable).map(EmployeeRole::toVo);
|
||||
protected Specification<EmployeeRole> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@@ -17,6 +17,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -37,7 +38,7 @@ import jakarta.transaction.Transactional;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "employee")
|
||||
public class EmployeeService
|
||||
public class EmployeeService extends EntityService<Employee, EmployeeVo, Integer>
|
||||
implements IEntityService<Employee>, QueryService<EmployeeVo>, VoableService<Employee, EmployeeVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EmployeeService.class);
|
||||
public static final int DEFAULT_SYSTEM_EMPLOYEE_ID = 26;
|
||||
@@ -45,6 +46,39 @@ public class EmployeeService
|
||||
@Autowired
|
||||
private EmployeeRepository employeeRepository;
|
||||
|
||||
@Override
|
||||
protected EmployeeRepository getRepository() {
|
||||
return employeeRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Employee createNewEntity() {
|
||||
return new Employee();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected org.springframework.data.jpa.domain.Specification<Employee> buildParameterSpecification(
|
||||
JsonNode paramsNode) {
|
||||
org.springframework.data.jpa.domain.Specification<Employee> spec = null;
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "department");
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "isActive");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected org.springframework.data.jpa.domain.Specification<Employee> buildSearchSpecification(String 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 + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据员工ID查找员工信息,并使用缓存机制提高查询效率。
|
||||
* <p>
|
||||
@@ -60,10 +94,6 @@ public class EmployeeService
|
||||
return employeeRepository.findById(id).map(Employee::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public Employee getById(Integer id) {
|
||||
return employeeRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'ac-'+#p0")
|
||||
public EmployeeVo findByAccount(String username) {
|
||||
return employeeRepository.findByAccount(username).map(Employee::toVo).orElse(null);
|
||||
@@ -117,39 +147,6 @@ public class EmployeeService
|
||||
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 = getSpecification(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> getSpecification(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 + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据搜索文本查询员工列表
|
||||
@@ -160,11 +157,6 @@ public class EmployeeService
|
||||
* @param searchText 要搜索的文本,用于在员工代码和名称中进行模糊匹配
|
||||
* @return 包含搜索结果的员工列表,最多10条记录
|
||||
*/
|
||||
public List<Employee> search(String searchText) {
|
||||
// 创建一个Specification对象,用于定义复杂的查询条件
|
||||
Specification<Employee> spec = getSpecification(searchText);
|
||||
return employeeRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<EmployeeRole> getRolesByEmployeeId(Integer employeeId) {
|
||||
@@ -184,7 +176,7 @@ public class EmployeeService
|
||||
entity.setAlias(vo.getAlias());
|
||||
entity.setCode(vo.getCode());
|
||||
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());
|
||||
entity.setDepartment(department);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.ecep.contract.ds.other.service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
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.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
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.model.Function;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.FunctionVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@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
|
||||
@Autowired
|
||||
private FunctionRepository repository;
|
||||
@@ -35,13 +34,10 @@ public class FunctionService implements IEntityService<Function>, QueryService<F
|
||||
return repository.findById(id).map(Function::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public Function getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
@Override
|
||||
public Function save(Function role) {
|
||||
return repository.save(role);
|
||||
}
|
||||
@@ -49,37 +45,29 @@ public class FunctionService implements IEntityService<Function>, QueryService<F
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
@Override
|
||||
public void delete(Function entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Function> findAll(Specification<Function> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
protected FunctionRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<FunctionVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<Function> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
return findAll(spec, pageable).map(Function::toVo);
|
||||
public Function createNewEntity() {
|
||||
return new Function();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<Function> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<Function> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("key"), "%" + searchText + "%"),
|
||||
builder.like(root.get("name"), "%" + 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());
|
||||
// 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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
@@ -17,6 +16,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.ds.other.repository.InventoryCatalogRepository;
|
||||
import com.ecep.contract.model.InventoryCatalog;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
@@ -26,7 +26,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -37,10 +38,6 @@ public class InventoryCatalogService implements IEntityService<InventoryCatalog>
|
||||
return repository.findById(id).map(InventoryCatalog::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public InventoryCatalog getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'code-'+#p0")
|
||||
public InventoryCatalogVo findByCode(String code) {
|
||||
return repository.findByCode(code).map(InventoryCatalog::toVo).orElse(null);
|
||||
@@ -51,50 +48,35 @@ public class InventoryCatalogService implements IEntityService<InventoryCatalog>
|
||||
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 = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
return findAll(spec, pageable).map(InventoryCatalog::toVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<InventoryCatalog> getSpecification(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 = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code"),
|
||||
@CacheEvict(key = "'name-'+#p0.code")
|
||||
})
|
||||
@Override
|
||||
public InventoryCatalog save(InventoryCatalog 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 = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code"),
|
||||
@@ -111,4 +93,9 @@ public class InventoryCatalogService implements IEntityService<InventoryCatalog>
|
||||
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.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import com.ecep.contract.EntityService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -26,7 +28,7 @@ import jakarta.persistence.criteria.Path;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "inventory-history-price")
|
||||
public class InventoryHistoryPriceService
|
||||
public class InventoryHistoryPriceService extends EntityService<InventoryHistoryPrice, InventoryHistoryPriceVo, Integer>
|
||||
implements IEntityService<InventoryHistoryPrice>, QueryService<InventoryHistoryPriceVo>,
|
||||
VoableService<InventoryHistoryPrice, InventoryHistoryPriceVo> {
|
||||
@Lazy
|
||||
@@ -42,15 +44,34 @@ public class InventoryHistoryPriceService
|
||||
return repository.findById(id).map(InventoryHistoryPrice::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public InventoryHistoryPrice getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
public List<InventoryHistoryPrice> findAllByInventory(Inventory inventory) {
|
||||
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
|
||||
public Specification<InventoryHistoryPrice> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected InventoryHistoryPriceRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryHistoryPrice createNewEntity() {
|
||||
return new InventoryHistoryPrice();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<InventoryHistoryPrice> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
Path<Inventory> inventory = root.get("inventory");
|
||||
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 = getSpecification(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
|
||||
public void updateByVo(InventoryHistoryPrice entity, InventoryHistoryPriceVo vo) {
|
||||
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'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -36,7 +37,7 @@ import lombok.Setter;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "inventory")
|
||||
public class InventoryService
|
||||
public class InventoryService extends EntityService<Inventory, InventoryVo, Integer>
|
||||
implements IEntityService<Inventory>, QueryService<InventoryVo>, VoableService<Inventory, InventoryVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -45,38 +46,37 @@ public class InventoryService
|
||||
@Setter
|
||||
private int searchPageSize = 10;
|
||||
|
||||
@Override
|
||||
protected InventoryRepository getRepository() {
|
||||
return inventoryRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory createNewEntity() {
|
||||
return createNewInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected org.springframework.data.jpa.domain.Specification<Inventory> buildParameterSpecification(
|
||||
JsonNode paramsNode) {
|
||||
org.springframework.data.jpa.domain.Specification<Inventory> spec = null;
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "catalog", "creator", "updater");
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code", "name", "specification");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public InventoryVo findById(Integer id) {
|
||||
return inventoryRepository.findById(id).map(Inventory::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public Inventory getById(Integer id) {
|
||||
return inventoryRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<Inventory> findAll(Specification<Inventory> spec, Pageable pageable) {
|
||||
return inventoryRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<InventoryVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<Inventory> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
return findAll(spec, pageable).map(Inventory::toVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<Inventory> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
|
||||
}
|
||||
|
||||
protected Specification<Inventory> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
Join<Object, Object> catalog = root.join("catalog", JoinType.LEFT);
|
||||
@@ -96,7 +96,7 @@ public class InventoryService
|
||||
public List<Inventory> search(String searchText) {
|
||||
Pageable pageable = Pageable.ofSize(getSearchPageSize());
|
||||
pageable.getSort().and(Sort.by(Sort.Direction.DESC, "id"));
|
||||
Specification<Inventory> specification = getSpecification(searchText);
|
||||
Specification<Inventory> specification = getSearchSpecification(searchText);
|
||||
return inventoryRepository.findAll(specification, pageable).getContent();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,10 @@ 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 com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -28,7 +26,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "permission")
|
||||
public class PermissionService
|
||||
public class PermissionService extends EntityService<Permission, PermissionVo, Integer>
|
||||
implements IEntityService<Permission>, QueryService<PermissionVo>, VoableService<Permission, PermissionVo> {
|
||||
|
||||
@Lazy
|
||||
@@ -42,21 +40,6 @@ public class PermissionService
|
||||
return permissionRepository.findById(id).map(Permission::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public Permission getById(Integer id) {
|
||||
return permissionRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<Permission> getSpecification(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")
|
||||
public Permission findByCode(String code) {
|
||||
// return permissionRepository.findByCode(code).orElse(null);
|
||||
@@ -67,25 +50,12 @@ public class PermissionService
|
||||
@CacheEvict(key = "'permission-'+#p0.id"),
|
||||
// @CacheEvict(key = "'permission-code-'+#p0.code")
|
||||
})
|
||||
@Override
|
||||
public Permission save(Permission role) {
|
||||
return permissionRepository.save(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
return findAll(spec, pageable).map(Permission::toVo);
|
||||
}
|
||||
|
||||
@CacheEvict(key = "'permission-'+#p0.id")
|
||||
@Override
|
||||
public void delete(Permission entity) {
|
||||
permissionRepository.delete(entity);
|
||||
@@ -95,6 +65,24 @@ public class PermissionService
|
||||
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
|
||||
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,9 +1,8 @@
|
||||
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 com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.customer.model.CustomerSatisfactionSurvey;
|
||||
|
||||
/**
|
||||
@@ -11,8 +10,7 @@ import com.ecep.contract.ds.customer.model.CustomerSatisfactionSurvey;
|
||||
*/
|
||||
@Repository
|
||||
public interface CustomerSatisfactionSurveyRepository
|
||||
extends JpaRepository<CustomerSatisfactionSurvey, Integer>,
|
||||
JpaSpecificationExecutor<CustomerSatisfactionSurvey> {
|
||||
extends MyRepository<CustomerSatisfactionSurvey, Integer> {
|
||||
|
||||
// 可以在这里添加自定义查询方法
|
||||
// 可以在这里添加自定义查询方法
|
||||
}
|
||||
|
||||
@@ -2,15 +2,14 @@ package com.ecep.contract.ds.project.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
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.ProjectCostItem;
|
||||
|
||||
@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.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.project.model.Project;
|
||||
import com.ecep.contract.ds.project.model.ProjectCost;
|
||||
|
||||
@Repository
|
||||
public interface ProjectCostRepository extends JpaRepository<ProjectCost, Integer>, JpaSpecificationExecutor<ProjectCost> {
|
||||
public interface ProjectCostRepository extends MyRepository<ProjectCost, Integer> {
|
||||
/**
|
||||
* 根据合同查询
|
||||
*
|
||||
|
||||
@@ -2,17 +2,15 @@ package com.ecep.contract.ds.project.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.model.ProjectSaleTypeRequireFileType;
|
||||
|
||||
@Repository
|
||||
public interface ProjectSaleTypeRequireFileTypeRepository extends
|
||||
JpaRepository<ProjectSaleTypeRequireFileType, Integer>,
|
||||
JpaSpecificationExecutor<ProjectSaleTypeRequireFileType> {
|
||||
MyRepository<ProjectSaleTypeRequireFileType, Integer> {
|
||||
|
||||
List<ProjectSaleTypeRequireFileType> findBySaleTypeId(int saleTypeId);
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
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.context.annotation.Lazy;
|
||||
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.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.project.repository.CustomerSatisfactionSurveyRepository;
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
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.repository.CustomerSatisfactionSurveyRepository;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
|
||||
@@ -33,6 +36,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "customer-satisfaction-survey")
|
||||
public class CustomerSatisfactionSurveyService
|
||||
extends EntityService<CustomerSatisfactionSurvey, CustomerSatisfactionSurveyVo, Integer>
|
||||
implements IEntityService<CustomerSatisfactionSurvey>, QueryService<CustomerSatisfactionSurveyVo>,
|
||||
VoableService<CustomerSatisfactionSurvey, CustomerSatisfactionSurveyVo> {
|
||||
@Lazy
|
||||
@@ -40,8 +44,13 @@ public class CustomerSatisfactionSurveyService
|
||||
private CustomerSatisfactionSurveyRepository repository;
|
||||
|
||||
@Override
|
||||
public CustomerSatisfactionSurvey getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected MyRepository<CustomerSatisfactionSurvey, Integer> getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomerSatisfactionSurvey createNewEntity() {
|
||||
return new CustomerSatisfactionSurvey();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,16 +70,25 @@ public class CustomerSatisfactionSurveyService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<CustomerSatisfactionSurvey> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<CustomerSatisfactionSurvey> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
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 客户满意度调查实体
|
||||
* @return 保存后的实体
|
||||
*/
|
||||
@CacheEvict(key = "#p0.id")
|
||||
@Override
|
||||
public CustomerSatisfactionSurvey save(CustomerSatisfactionSurvey survey) {
|
||||
return repository.save(survey);
|
||||
}
|
||||
@@ -87,6 +107,8 @@ public class CustomerSatisfactionSurveyService
|
||||
*
|
||||
* @param survey 客户满意度调查实体
|
||||
*/
|
||||
@CacheEvict(key = "#p0.id")
|
||||
@Override
|
||||
public void delete(CustomerSatisfactionSurvey survey) {
|
||||
repository.delete(survey);
|
||||
}
|
||||
@@ -98,9 +120,6 @@ public class CustomerSatisfactionSurveyService
|
||||
* @param pageable 分页参数
|
||||
* @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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CustomerSatisfactionSurveyVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<CustomerSatisfactionSurvey> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(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
|
||||
public void updateByVo(CustomerSatisfactionSurvey model, CustomerSatisfactionSurveyVo vo) {
|
||||
model.setCode(vo.getCode());
|
||||
|
||||
@@ -15,9 +15,11 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.project.repository.ProductDeliverySignMethodRepository;
|
||||
import com.ecep.contract.model.DeliverySignMethod;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
@@ -30,18 +32,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-sign-method")
|
||||
public class DeliverySignMethodService
|
||||
public class DeliverySignMethodService extends EntityService<DeliverySignMethod, DeliverySignMethodVo, Integer>
|
||||
implements IEntityService<DeliverySignMethod>, QueryService<DeliverySignMethodVo>,
|
||||
VoableService<DeliverySignMethod, DeliverySignMethodVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProductDeliverySignMethodRepository deliverySignMethodRepository;
|
||||
|
||||
@Override
|
||||
public DeliverySignMethod getById(Integer id) {
|
||||
return deliverySignMethodRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public DeliverySignMethodVo findById(Integer id) {
|
||||
@@ -52,39 +49,20 @@ public class DeliverySignMethodService
|
||||
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 = getSpecification(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) {
|
||||
return deliverySignMethodRepository.findBySaleTypeAndName(saleType, name).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'type-'+#p0.id+'_code-'+#p1")
|
||||
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")
|
||||
public DeliverySignMethodVo findBySaleTypeAndCode(ProjectSaleTypeVo saleType, String code) {
|
||||
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);
|
||||
return deliverySignMethodRepository.findBySaleTypeIdAndCode(saleType.getId(), code)
|
||||
.map(DeliverySignMethod::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'all'")
|
||||
@@ -117,8 +95,28 @@ public class DeliverySignMethodService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<DeliverySignMethod> getSpecification(String searchText) {
|
||||
return null;
|
||||
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
|
||||
public Specification<DeliverySignMethod> getSearchSpecification(String searchText) {
|
||||
return super.getSearchSpecification(searchText);
|
||||
}
|
||||
|
||||
@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.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 com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
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.repository.ProductTypeRepository;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.ProductTypeVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -25,17 +24,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProductTypeRepository productTypeRepository;
|
||||
|
||||
@Override
|
||||
public ProductType getById(Integer id) {
|
||||
return productTypeRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ProductTypeVo findById(Integer id) {
|
||||
@@ -58,26 +53,17 @@ public class ProductTypeService implements IEntityService<ProductType>, QuerySer
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProductType> findAll(Specification<ProductType> spec, Pageable pageable) {
|
||||
return productTypeRepository.findAll(spec, pageable);
|
||||
protected MyRepository<ProductType, Integer> getRepository() {
|
||||
return productTypeRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProductTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProductType> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable).map(ProductType::toVo);
|
||||
public ProductType createNewEntity() {
|
||||
return new ProductType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProductType> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ProductType> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
@@ -115,4 +101,9 @@ public class ProductTypeService implements IEntityService<ProductType>, QuerySer
|
||||
model.setName(vo.getName());
|
||||
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.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
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.model.ProductUsage;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
@@ -25,17 +27,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProductUsageRepository productUsageRepository;
|
||||
|
||||
@Override
|
||||
public ProductUsage getById(Integer id) {
|
||||
return productUsageRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ProductUsageVo findById(Integer id) {
|
||||
@@ -70,27 +68,17 @@ public class ProductUsageService implements IEntityService<ProductUsage>, QueryS
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProductUsage> findAll(Specification<ProductUsage> spec, Pageable pageable) {
|
||||
return productUsageRepository.findAll(spec, pageable);
|
||||
protected MyRepository<ProductUsage, Integer> getRepository() {
|
||||
return productUsageRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProductUsageVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProductUsage> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
Page<ProductUsage> page = findAll(spec, pageable);
|
||||
return page.map(ProductUsage::toVo);
|
||||
public ProductUsage createNewEntity() {
|
||||
return new ProductUsage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProductUsage> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ProductUsage> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
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.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEvaluationFormFileService;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectBidRepository;
|
||||
@@ -31,17 +33,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectBidRepository repository;
|
||||
|
||||
@Override
|
||||
public ProjectBid getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ProjectBidVo findById(Integer id) {
|
||||
@@ -53,35 +51,17 @@ public class ProjectBidService implements IEntityService<ProjectBid>, QueryServi
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectBid> findAll(Specification<ProjectBid> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
protected MyRepository<ProjectBid, Integer> getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectBidVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectBid> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(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);
|
||||
public ProjectBid createNewEntity() {
|
||||
return new ProjectBid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectBid> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ProjectBid> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
@@ -135,7 +115,7 @@ public class ProjectBidService implements IEntityService<ProjectBid>, QueryServi
|
||||
if (vo.getEvaluationFileId() != null) {
|
||||
CompanyCustomerEvaluationFormFileService evaluationFileService = SpringApp
|
||||
.getBean(CompanyCustomerEvaluationFormFileService.class);
|
||||
model.setEvaluationFile(evaluationFileService.findById(vo.getEvaluationFileId()));
|
||||
model.setEvaluationFile(evaluationFileService.getById(vo.getEvaluationFileId()));
|
||||
} else {
|
||||
model.setEvaluationFile(null);
|
||||
}
|
||||
@@ -164,4 +144,23 @@ public class ProjectBidService implements IEntityService<ProjectBid>, QueryServi
|
||||
public List<ProjectBid> findAllByProject(Project 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.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.other.service.InventoryService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectCostItemRepository;
|
||||
import com.ecep.contract.ds.project.model.ProjectCost;
|
||||
@@ -30,17 +32,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectCostItemRepository repository;
|
||||
|
||||
@Override
|
||||
public ProjectCostItem getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ProjectCostItemVo findById(Integer id) {
|
||||
@@ -52,49 +50,38 @@ public class ProjectCostItemService implements IEntityService<ProjectCostItem>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectCostItem> findAll(Specification<ProjectCostItem> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
protected MyRepository<ProjectCostItem, Integer> getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectCostItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectCostItem> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(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);
|
||||
public ProjectCostItem createNewEntity() {
|
||||
return new ProjectCostItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectCostItem> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ProjectCostItem> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("name"), "%" + searchText + "%")
|
||||
);
|
||||
builder.like(root.get("name"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public ProjectCostItem save(ProjectCostItem item) {
|
||||
return repository.save(item);
|
||||
return super.save(item);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ProjectCostItem item) {
|
||||
repository.delete(item);
|
||||
super.delete(item);
|
||||
}
|
||||
|
||||
public List<ProjectCostItem> findByCostId(Integer costId) {
|
||||
@@ -131,4 +118,12 @@ public class ProjectCostItemService implements IEntityService<ProjectCostItem>,
|
||||
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.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
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.model.Project;
|
||||
import com.ecep.contract.ds.project.model.ProjectCost;
|
||||
@@ -32,17 +34,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectCostRepository repository;
|
||||
|
||||
@Override
|
||||
public ProjectCost getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ProjectCostVo findById(Integer id) {
|
||||
@@ -54,35 +52,17 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectCost> findAll(Specification<ProjectCost> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
protected MyRepository<ProjectCost, Integer> getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectCostVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectCost> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(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);
|
||||
public ProjectCost createNewEntity() {
|
||||
return new ProjectCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectCost> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ProjectCost> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
@@ -93,15 +73,17 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public ProjectCost save(ProjectCost cost) {
|
||||
return repository.save(cost);
|
||||
return super.save(cost);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ProjectCost cost) {
|
||||
repository.delete(cost);
|
||||
super.delete(cost);
|
||||
}
|
||||
|
||||
public List<ProjectCost> findByProject(Project project) {
|
||||
@@ -151,7 +133,6 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
|
||||
model.setOutExclusiveTaxAmount(vo.getOutExclusiveTaxAmount());
|
||||
model.setGrossProfitMargin(vo.getGrossProfitMargin());
|
||||
|
||||
|
||||
if (vo.getProject() == null) {
|
||||
model.setProject(null);
|
||||
} else {
|
||||
@@ -181,4 +162,23 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
|
||||
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.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 com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.ProjectFileType;
|
||||
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.ProjectFile;
|
||||
import com.ecep.contract.ds.project.repository.ProjectFileRepository;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ProjectFileVo;
|
||||
@@ -29,7 +28,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@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
|
||||
@Autowired
|
||||
private ProjectFileRepository repository;
|
||||
@@ -38,11 +38,6 @@ public class ProjectFileService implements IEntityService<ProjectFile>, QuerySer
|
||||
@Autowired
|
||||
private ProjectService projectService;
|
||||
|
||||
@Override
|
||||
public ProjectFile getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ProjectFileVo findById(Integer id) {
|
||||
@@ -54,58 +49,36 @@ public class ProjectFileService implements IEntityService<ProjectFile>, QuerySer
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectFileVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
// 构建查询规范
|
||||
Specification<ProjectFile> spec = getSpecification(paramsNode);
|
||||
// 查询实体列表
|
||||
Page<ProjectFile> entityPage = findAll(spec, pageable);
|
||||
// 转换为VO列表
|
||||
return entityPage.map(ProjectFile::toVo);
|
||||
protected MyRepository<ProjectFile, Integer> getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectFile> findAll(Specification<ProjectFile> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
public ProjectFile createNewEntity() {
|
||||
return new ProjectFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectFile> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ProjectFile> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.like(root.get("filePath"), "%" + searchText + "%");
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProjectFile> search(String searchText) {
|
||||
Specification<ProjectFile> spec = getSpecification(searchText);
|
||||
return repository.findAll(spec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ProjectFile entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public ProjectFile save(ProjectFile entity) {
|
||||
return repository.save(entity);
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
public ProjectFile saveFile(ProjectFile file) {
|
||||
return repository.save(file);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
public void deleteFile(ProjectFile file) {
|
||||
repository.delete(file);
|
||||
@Override
|
||||
public void delete(ProjectFile entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
// 根据项目查询文件列表
|
||||
@@ -121,7 +94,8 @@ public class ProjectFileService implements IEntityService<ProjectFile>, QuerySer
|
||||
}
|
||||
|
||||
// 构建查询规范
|
||||
private Specification<ProjectFile> getSpecification(JsonNode paramsNode) {
|
||||
@Override
|
||||
protected Specification<ProjectFile> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<ProjectFile> spec = null;
|
||||
|
||||
// 根据参数构建查询条件
|
||||
@@ -132,16 +106,6 @@ public class ProjectFileService implements IEntityService<ProjectFile>, QuerySer
|
||||
return spec;
|
||||
}
|
||||
|
||||
// 计数方法实现
|
||||
@Override
|
||||
public long count(JsonNode paramsNode) {
|
||||
Specification<ProjectFile> spec = getSpecification(paramsNode);
|
||||
if (spec != null) {
|
||||
return repository.count(spec);
|
||||
}
|
||||
return repository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ProjectFile model, ProjectFileVo vo) {
|
||||
// 更新文件类型
|
||||
|
||||
@@ -3,22 +3,20 @@ package com.ecep.contract.ds.project.service;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
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 com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.ProjectFileType;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.project.repository.ProjectFileTypeLocalRepository;
|
||||
import com.ecep.contract.model.ProjectFileTypeLocal;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
@@ -30,7 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-file-type")
|
||||
public class ProjectFileTypeService
|
||||
public class ProjectFileTypeService extends EntityService<ProjectFileTypeLocal, ProjectFileTypeLocalVo, Integer>
|
||||
implements IEntityService<ProjectFileTypeLocal>, QueryService<ProjectFileTypeLocalVo>,
|
||||
VoableService<ProjectFileTypeLocal, ProjectFileTypeLocalVo> {
|
||||
|
||||
@@ -38,37 +36,11 @@ public class ProjectFileTypeService
|
||||
@Autowired
|
||||
private ProjectFileTypeLocalRepository repository;
|
||||
|
||||
@Override
|
||||
public Page<ProjectFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectFileTypeLocal> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSpecification(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
|
||||
public ProjectFileTypeLocalVo findById(Integer id) {
|
||||
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()")
|
||||
public Map<ProjectFileType, ProjectFileTypeLocalVo> findAll(Locale locale) {
|
||||
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
||||
@@ -77,20 +49,6 @@ public class ProjectFileTypeService
|
||||
entry -> entry.getValue().toVo()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectFileTypeLocal> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return (root, query, builder) -> {
|
||||
return
|
||||
// builder.or(
|
||||
builder.like(root.get("type"), "%" + searchText + "%")
|
||||
// )
|
||||
;
|
||||
};
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'all-'+#p0.getLang()")
|
||||
@@ -122,4 +80,37 @@ public class ProjectFileTypeService
|
||||
entity.setLang(vo.getLang());
|
||||
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.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
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.service.ContractPayPlanService;
|
||||
import com.ecep.contract.ds.project.model.Project;
|
||||
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.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ProjectFundPlanVo;
|
||||
@@ -31,17 +31,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectFundPlanRepository repository;
|
||||
|
||||
@Override
|
||||
public ProjectFundPlan getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ProjectFundPlanVo findById(Integer id) {
|
||||
@@ -52,36 +48,10 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
|
||||
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 = getSpecification(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> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return (root, query, builder) -> {
|
||||
return builder.like(root.get("description"), "%" + searchText + "%");
|
||||
};
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public ProjectFundPlan save(ProjectFundPlan fundPlan) {
|
||||
return repository.save(fundPlan);
|
||||
}
|
||||
@@ -89,10 +59,35 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ProjectFundPlan 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) {
|
||||
return repository.findAllByProject(project);
|
||||
}
|
||||
@@ -105,10 +100,10 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
|
||||
// 转换为BigDecimal
|
||||
return BigDecimal.valueOf(plans.stream().mapToDouble(ProjectFundPlan::getPayCurrency).sum());
|
||||
// return plans.stream()
|
||||
// .map(ProjectFundPlan::getAmount)
|
||||
// .filter(Optional::isPresent)
|
||||
// .map(Optional::get)
|
||||
// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// .map(ProjectFundPlan::getAmount)
|
||||
// .filter(Optional::isPresent)
|
||||
// .map(Optional::get)
|
||||
// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,15 +119,16 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
|
||||
|
||||
// 处理关联实体
|
||||
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);
|
||||
}else{
|
||||
} else {
|
||||
model.setContractPayPlan(null);
|
||||
}
|
||||
if (vo.getProjectId() != null) {
|
||||
Project project = SpringApp.getBean(ProjectService.class).getById(vo.getProjectId());
|
||||
model.setProject(project);
|
||||
}else{
|
||||
} else {
|
||||
model.setProject(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,40 +2,38 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
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.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 com.ecep.contract.EntityService;
|
||||
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.repository.ProjectIndustryRepository;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ProjectIndustryVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectIndustryRepository repository;
|
||||
|
||||
@Override
|
||||
public ProjectIndustry getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected ProjectIndustryRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -72,34 +70,6 @@ public class ProjectIndustryService implements IEntityService<ProjectIndustry>,
|
||||
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 = getSpecification(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> getSpecification(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 = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code"),
|
||||
@@ -126,4 +96,25 @@ public class ProjectIndustryService implements IEntityService<ProjectIndustry>,
|
||||
model.setCode(vo.getCode());
|
||||
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.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.context.annotation.Lazy;
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEvaluationFormFileService;
|
||||
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.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.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
@@ -34,7 +37,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectQuotationService.class);
|
||||
|
||||
@@ -43,8 +47,8 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
||||
private ProjectQuotationRepository repository;
|
||||
|
||||
@Override
|
||||
public ProjectQuotation getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected ProjectQuotationRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -56,39 +60,36 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
||||
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 = getSpecification(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) {
|
||||
return repository.findAllByProject(project);
|
||||
}
|
||||
|
||||
public ProjectQuotation save(ProjectQuotation approval) {
|
||||
return repository.save(approval);
|
||||
@Override
|
||||
public ProjectQuotation createNewEntity() {
|
||||
return new ProjectQuotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectQuotation> getSpecification(String searchText) {
|
||||
protected Specification<ProjectQuotation> buildSearchSpecification(String searchText) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void delete(ProjectQuotation approval) {
|
||||
repository.delete(approval);
|
||||
@Override
|
||||
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) {
|
||||
@@ -100,10 +101,6 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
||||
return approval;
|
||||
}
|
||||
|
||||
public List<ProjectQuotation> findAll(Specification<ProjectQuotation> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ProjectQuotation entity, ProjectQuotationVo vo) {
|
||||
if (entity == null) {
|
||||
@@ -160,4 +157,5 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
||||
entity.setEvaluationFile(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,35 +2,33 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
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 com.ecep.contract.ContractFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
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.ProjectSaleTypeRequireFileType;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeRequireFileTypeVo;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-sale-type-require-file-type")
|
||||
public class ProjectSaleTypeRequireFileTypeService
|
||||
extends EntityService<ProjectSaleTypeRequireFileType, ProjectSaleTypeRequireFileTypeVo, Integer>
|
||||
implements IEntityService<ProjectSaleTypeRequireFileType>, QueryService<ProjectSaleTypeRequireFileTypeVo>,
|
||||
VoableService<ProjectSaleTypeRequireFileType, ProjectSaleTypeRequireFileTypeVo> {
|
||||
@Lazy
|
||||
@@ -38,8 +36,8 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
private ProjectSaleTypeRequireFileTypeRepository repository;
|
||||
|
||||
@Override
|
||||
public ProjectSaleTypeRequireFileType getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected ProjectSaleTypeRequireFileTypeRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -47,15 +45,10 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
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")
|
||||
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")
|
||||
@@ -70,21 +63,20 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectSaleTypeRequireFileTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectSaleTypeRequireFileType> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "saleType");
|
||||
return findAll(spec, pageable).map(ProjectSaleTypeRequireFileType::toVo);
|
||||
public ProjectSaleTypeRequireFileType createNewEntity() {
|
||||
return new ProjectSaleTypeRequireFileType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectSaleTypeRequireFileType> getSpecification(String searchText) {
|
||||
protected Specification<ProjectSaleTypeRequireFileType> buildSearchSpecification(String searchText) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ProjectSaleTypeRequireFileType> buildParameterSpecification(JsonNode paramsNode) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||
}
|
||||
|
||||
// save
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@@ -92,6 +84,7 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
@CacheEvict(key = "'by-sale-type-'+#p0.saleType.id"),
|
||||
@CacheEvict(key = "'all'")
|
||||
})
|
||||
@Override
|
||||
public ProjectSaleTypeRequireFileType save(ProjectSaleTypeRequireFileType type) {
|
||||
return repository.save(type);
|
||||
}
|
||||
@@ -103,6 +96,7 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'all'")
|
||||
})
|
||||
@Override
|
||||
public void delete(ProjectSaleTypeRequireFileType 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 com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
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.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectSaleTypeRepository;
|
||||
@@ -26,14 +26,21 @@ import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
@Lazy
|
||||
@Service
|
||||
@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> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectSaleTypeRepository saleTypeRepository;
|
||||
|
||||
public ProjectSaleType getById(Integer id) {
|
||||
return saleTypeRepository.findById(id).orElse(null);
|
||||
@Override
|
||||
protected ProjectSaleTypeRepository getRepository() {
|
||||
return saleTypeRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectSaleType createNewEntity() {
|
||||
return new ProjectSaleType();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -64,26 +71,16 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
||||
return entities.stream().map(ProjectSaleType::toVo).toList();
|
||||
}
|
||||
|
||||
public Page<ProjectSaleType> findAll(Specification<ProjectSaleType> spec, Pageable pageable) {
|
||||
return saleTypeRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectSaleTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<ProjectSaleType> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<ProjectSaleType> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active");
|
||||
return findAll(spec, pageable).map(ProjectSaleType::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectSaleType> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ProjectSaleType> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
@@ -96,6 +93,7 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
||||
@CacheEvict(key = "'code-'+#p0.name"),
|
||||
@CacheEvict(key = "'all'"),
|
||||
})
|
||||
@Override
|
||||
public ProjectSaleType save(ProjectSaleType type) {
|
||||
return saleTypeRepository.save(type);
|
||||
}
|
||||
@@ -105,6 +103,7 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
||||
@CacheEvict(key = "'code-'+#p0.name"),
|
||||
@CacheEvict(key = "'all'"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ProjectSaleType type) {
|
||||
saleTypeRepository.delete(type);
|
||||
}
|
||||
@@ -132,4 +131,5 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
||||
// ProjectSaleTypeVo中的created和version字段在ProjectSaleType实体中不存在,这里不做处理
|
||||
// 如果需要处理,可以添加日志记录或者其他逻辑
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,6 @@ import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.vo.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -24,20 +21,31 @@ 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.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.ProjectConstant;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.ds.project.model.Project;
|
||||
import com.ecep.contract.ds.project.repository.ProductDeliverySignMethodRepository;
|
||||
import com.ecep.contract.ds.project.repository.ProjectRepository;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.project.model.Project;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.DeliverySignMethodVo;
|
||||
import com.ecep.contract.vo.ProductTypeVo;
|
||||
import com.ecep.contract.vo.ProductUsageVo;
|
||||
import com.ecep.contract.vo.ProjectIndustryVo;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
import com.ecep.contract.vo.ProjectTypeVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
/**
|
||||
@@ -46,7 +54,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project")
|
||||
public class ProjectService
|
||||
public class ProjectService extends EntityService<Project, ProjectVo, Integer>
|
||||
implements IEntityService<Project>, QueryService<ProjectVo>, VoableService<Project, ProjectVo> {
|
||||
|
||||
private final ProductDeliverySignMethodRepository productDeliverySignMethodRepository;
|
||||
@@ -84,10 +92,20 @@ public class ProjectService
|
||||
this.productDeliverySignMethodRepository = productDeliverySignMethodRepository;
|
||||
}
|
||||
|
||||
public Project getById(Integer id) {
|
||||
return projectRepository.findById(id).orElse(null);
|
||||
@Override
|
||||
protected ProjectRepository getRepository() {
|
||||
return projectRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project createNewEntity() {
|
||||
Project project = new Project();
|
||||
project.setCodeYear(LocalDate.now().getYear());
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public ProjectVo findById(Integer id) {
|
||||
Project entity = getById(id);
|
||||
@@ -149,20 +167,15 @@ public class ProjectService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<Project> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<Project> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "customer", "industry", "saleType", "projectType",
|
||||
"productType", "deliverySignMethod", "productUsage");
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "applicant", "authorizer");
|
||||
|
||||
//
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code");
|
||||
|
||||
return findAll(spec, pageable).map(Project::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#p0.id")
|
||||
@@ -180,14 +193,6 @@ public class ProjectService
|
||||
return project.getCodeSequenceNumber() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<Project> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
|
||||
}
|
||||
|
||||
protected Specification<Project> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
@@ -198,7 +203,7 @@ public class ProjectService
|
||||
}
|
||||
|
||||
public List<Project> search(String userText) {
|
||||
Specification<Project> spec = getSpecification(userText);
|
||||
Specification<Project> spec = getSearchSpecification(userText);
|
||||
return projectRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ 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.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectTypeRepository;
|
||||
@@ -27,14 +28,20 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-type")
|
||||
public class ProjectTypeService
|
||||
public class ProjectTypeService extends EntityService<ProjectType, ProjectTypeVo, Integer>
|
||||
implements IEntityService<ProjectType>, QueryService<ProjectTypeVo>, VoableService<ProjectType, ProjectTypeVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectTypeRepository repository;
|
||||
|
||||
public ProjectType getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
@Override
|
||||
protected ProjectTypeRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectType createNewEntity() {
|
||||
return new ProjectType();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -71,33 +78,6 @@ public class ProjectTypeService
|
||||
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 = getSpecification(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> getSpecification(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 = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'all'"),
|
||||
@@ -125,6 +105,21 @@ public class ProjectTypeService
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
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.VendorApprovedItem;
|
||||
import com.ecep.contract.model.VendorApproved;
|
||||
@@ -14,8 +13,7 @@ import com.ecep.contract.model.VendorApproved;
|
||||
* 合格供方名录
|
||||
*/
|
||||
@Repository
|
||||
public interface VendorApprovedItemRepository extends
|
||||
JpaRepository<VendorApprovedItem, Integer>, JpaSpecificationExecutor<VendorApprovedItem> {
|
||||
public interface VendorApprovedItemRepository extends MyRepository<VendorApprovedItem, Integer> {
|
||||
|
||||
List<VendorApprovedItem> findAllByList(VendorApproved list);
|
||||
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
package com.ecep.contract.ds.vendor.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.model.VendorApproved;
|
||||
|
||||
/**
|
||||
* 合格供方名录
|
||||
*/
|
||||
@Repository
|
||||
public interface VendorApprovedRepository extends
|
||||
JpaRepository<VendorApproved, Integer>, JpaSpecificationExecutor<VendorApproved>
|
||||
|
||||
|
||||
|
||||
{
|
||||
public interface VendorApprovedRepository extends MyRepository<VendorApproved, Integer> {
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user