refactor: 重构供应商文件类型枚举及相关服务
feat: 为多个服务添加缓存支持 fix: 修复WebSocket任务管理和远程调用异常处理 refactor: 重命名CompanyVendorFileType为VendorFileType refactor: 优化项目成本导入任务实现 fix: 修复ContractTabSkinBase中的空指针问题 refactor: 统一WebSocket客户端任务调用接口
This commit is contained in:
@@ -134,7 +134,7 @@ public class WebSocketClientService {
|
||||
|
||||
@Override
|
||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
logger.error("WebSocket连接失败: " + t.getMessage());
|
||||
logger.error("WebSocket连接失败: " + t.getMessage() + ", response=" + response, t);
|
||||
Platform.runLater(() -> {
|
||||
online.setValue(false);
|
||||
message.set("连接失败: " + t.getMessage());
|
||||
@@ -179,13 +179,19 @@ public class WebSocketClientService {
|
||||
if (webSocket == null) {
|
||||
throw new IllegalStateException("WebSocket is not initialized");
|
||||
}
|
||||
|
||||
if (!online.get()) {
|
||||
throw new IllegalStateException("WebSocket is not online");
|
||||
}
|
||||
String json = objectMapper.writeValueAsString(msg);
|
||||
callbacks.put(msg.getMessageId(), future);
|
||||
if (webSocket.send(json)) {
|
||||
logger.debug("send message success:{}", json);
|
||||
} else {
|
||||
future.completeExceptionally(new RuntimeException("Failed to send WebSocket message"));
|
||||
if (isActive) {
|
||||
future.completeExceptionally(new RuntimeException("Failed to send WebSocket message"));
|
||||
} else {
|
||||
future.completeExceptionally(new RuntimeException("WebSocket is not active"));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to send WebSocket message: {}", e.getMessage());
|
||||
@@ -321,14 +327,14 @@ public class WebSocketClientService {
|
||||
}
|
||||
}
|
||||
|
||||
private void closeSession(WebSocketClientSession session) {
|
||||
public void closeSession(WebSocketClientSession session) {
|
||||
if (session != null) {
|
||||
sessions.remove(session.getSessionId());
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
private WebSocketClientSession createSession() {
|
||||
public WebSocketClientSession createSession() {
|
||||
WebSocketClientSession session = new WebSocketClientSession(this);
|
||||
sessions.put(session.getSessionId(), session);
|
||||
return session;
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.Getter;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
@@ -24,15 +25,12 @@ public class WebSocketClientSession {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
webSocketService.closeSession(this);
|
||||
}
|
||||
|
||||
public void submitTask(WebSocketClientTasker tasker, Object... args) throws JsonProcessingException {
|
||||
public void submitTask(WebSocketClientTasker tasker, Locale locale, Object... args) throws JsonProcessingException {
|
||||
this.tasker = tasker;
|
||||
// 将 tasker.getTaskName() 和 args 合并到一个数组参数中
|
||||
Object[] mergedArgs = new Object[args.length + 1];
|
||||
mergedArgs[0] = tasker.getTaskName();
|
||||
System.arraycopy(args, 0, mergedArgs, 1, args.length);
|
||||
send("createTask", mergedArgs);
|
||||
send("createTask", tasker.getTaskName(), locale.toLanguageTag(), args);
|
||||
}
|
||||
|
||||
public void send(String type, Object... args) throws JsonProcessingException {
|
||||
@@ -49,31 +47,17 @@ public class WebSocketClientSession {
|
||||
String type = node.get("type").asText();
|
||||
JsonNode args = node.get(WebSocketConstant.ARGUMENTS_FIELD_NAME);
|
||||
if (type.equals("message")) {
|
||||
String message = args.get(1).asText();
|
||||
String level = args.get(0).asText();
|
||||
updateMessage(java.util.logging.Level.parse(level), message);
|
||||
handleAsMessage(args);
|
||||
} else if (type.equals("title")) {
|
||||
String message = args.get(0).asText();
|
||||
tasker.updateTitle(message);
|
||||
handleAsTitle(args);
|
||||
} else if (type.equals("property")) {
|
||||
String name = args.get(0).asText();
|
||||
Object value = args.get(1);
|
||||
try {
|
||||
PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(tasker.getClass(), name);
|
||||
System.out.println("descriptor = " + descriptor);
|
||||
System.out.println("descriptor.getPropertyType() = " + descriptor.getPropertyType());
|
||||
Object object = webSocketService.getObjectMapper().convertValue(value, descriptor.getPropertyType());
|
||||
System.out.println("object = " + object);
|
||||
System.out.println("descriptor.getWriteMethod() = " + descriptor.getWriteMethod());
|
||||
System.out.println("descriptor.getWriteMethod().getParameterTypes() = " + descriptor.getWriteMethod().getParameterTypes());
|
||||
descriptor.getWriteMethod().invoke(tasker, object);
|
||||
} catch (Exception e) {
|
||||
tasker.updateMessage(java.util.logging.Level.SEVERE, "属性设置失败: " + name + " = " + value);
|
||||
}
|
||||
handleAsProperty(args);
|
||||
} else if (type.equals("progress")) {
|
||||
long current = args.get(0).asLong();
|
||||
long total = args.get(1).asLong();
|
||||
tasker.updateProgress(current, total);
|
||||
handleAsProgress(args);
|
||||
} else if (type.equals("start")) {
|
||||
handleAsStart(args);
|
||||
} else if (type.equals("done")) {
|
||||
handleAsDone(args);
|
||||
} else {
|
||||
tasker.updateMessage(java.util.logging.Level.INFO, "未知的消息类型: " + node.toString());
|
||||
}
|
||||
@@ -82,6 +66,49 @@ public class WebSocketClientSession {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAsDone(JsonNode args) {
|
||||
tasker.updateMessage(java.util.logging.Level.INFO, "任务完成");
|
||||
close();
|
||||
}
|
||||
|
||||
private void handleAsStart(JsonNode args) {
|
||||
tasker.updateMessage(java.util.logging.Level.INFO, "任务开始");
|
||||
}
|
||||
|
||||
private void handleAsProgress(JsonNode args) {
|
||||
long current = args.get(0).asLong();
|
||||
long total = args.get(1).asLong();
|
||||
tasker.updateProgress(current, total);
|
||||
}
|
||||
|
||||
private void handleAsProperty(JsonNode args) {
|
||||
String name = args.get(0).asText();
|
||||
Object value = args.get(1);
|
||||
try {
|
||||
PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(tasker.getClass(), name);
|
||||
System.out.println("descriptor = " + descriptor);
|
||||
System.out.println("descriptor.getPropertyType() = " + descriptor.getPropertyType());
|
||||
Object object = webSocketService.getObjectMapper().convertValue(value, descriptor.getPropertyType());
|
||||
System.out.println("object = " + object);
|
||||
System.out.println("descriptor.getWriteMethod() = " + descriptor.getWriteMethod());
|
||||
System.out.println("descriptor.getWriteMethod().getParameterTypes() = " + descriptor.getWriteMethod().getParameterTypes());
|
||||
descriptor.getWriteMethod().invoke(tasker, object);
|
||||
} catch (Exception e) {
|
||||
tasker.updateMessage(java.util.logging.Level.SEVERE, "属性设置失败: " + name + " = " + value);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAsTitle(JsonNode args) {
|
||||
String message = args.get(0).asText();
|
||||
tasker.updateTitle(message);
|
||||
}
|
||||
|
||||
private void handleAsMessage(JsonNode args) {
|
||||
String level = args.get(0).asText();
|
||||
String message = args.get(1).asText();
|
||||
updateMessage(java.util.logging.Level.parse(level), message);
|
||||
}
|
||||
|
||||
public void updateMessage(Level level, String message) {
|
||||
tasker.updateMessage(level, message);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.ecep.contract;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public interface WebSocketClientTasker {
|
||||
@@ -10,4 +13,17 @@ public interface WebSocketClientTasker {
|
||||
void updateTitle(String title);
|
||||
|
||||
void updateProgress(long current, long total);
|
||||
|
||||
default Object callRemoteTask(MessageHolder holder, Locale locale, Object... args) {
|
||||
WebSocketClientService webSocketService = SpringApp.getBean(WebSocketClientService.class);
|
||||
webSocketService.withSession(session -> {
|
||||
try {
|
||||
session.submitTask(this, locale, args);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,31 @@
|
||||
package com.ecep.contract.controller.project.cost;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.WebSocketClientTasker;
|
||||
import com.ecep.contract.model.ProjectCost;
|
||||
import com.ecep.contract.task.Tasker;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
public class ProjectCostImportItemsFromContractsTasker extends Tasker<Object> {
|
||||
/**
|
||||
* 从相关合同中导入成本项
|
||||
*/
|
||||
public class ProjectCostImportItemsFromContractsTasker extends Tasker<Object> implements WebSocketClientTasker {
|
||||
@Setter
|
||||
private ProjectCost cost;
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'execute'");
|
||||
updateTitle("修复项目成本 " + cost.getId());
|
||||
return callRemoteTask(holder, getLocale(), cost.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return "ProjectCostImportItemsFromContractsTasker";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(long current, long total) {
|
||||
super.updateProgress(current, total);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,14 @@ import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import org.controlsfx.control.textfield.TextFields;
|
||||
import org.controlsfx.glyphfont.Glyph;
|
||||
import com.ecep.contract.util.ProxyUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
@@ -285,7 +289,7 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin {
|
||||
|
||||
// 设置项目的开始创建时间,从合同的创建时间、提交日期、开始日期中取最早的日期
|
||||
List<LocalDate> dates = new ArrayList<>();
|
||||
if (viewModel.getCreated().get() != null) {
|
||||
if (viewModel.getCreated().getValue() != null) {
|
||||
dates.add(viewModel.getCreated().get().toLocalDate());
|
||||
}
|
||||
if (viewModel.getSetupDate().get() != null) {
|
||||
|
||||
@@ -120,10 +120,11 @@ public class AsyncUpdateTableCell<V, T extends IdentityEntity> extends javafx.sc
|
||||
return;
|
||||
}
|
||||
|
||||
if (getService() instanceof QueryService<T, ?> queryService) {
|
||||
queryService.asyncFindById(getItem().getId()).thenAccept(this::_updateEntity);
|
||||
return;
|
||||
}
|
||||
// if (getService() instanceof QueryService<T, ?> queryService) {
|
||||
// queryService.findById(getItem().getId());
|
||||
// queryService.asyncFindById(getItem().getId()).thenAccept(this::_updateEntity);
|
||||
// return;
|
||||
// }
|
||||
T entity = initialize();
|
||||
_updateEntity(entity);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.service.VendorTypeService;
|
||||
import com.ecep.contract.util.ProxyUtils;
|
||||
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
@@ -61,6 +62,8 @@ public class CompanyVendorManagerSkin
|
||||
@Override
|
||||
public void initializeTable() {
|
||||
|
||||
getBean(VendorTypeService.class);
|
||||
|
||||
List<VendorTypeLocal> vendorTypeLocals = getCompanyVendorService()
|
||||
.findAllTypes(controller.getLocale());
|
||||
ComboBoxUtils.initialComboBox(controller.typeSelector, vendorTypeLocals, true);
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
import com.ecep.contract.util.ProxyUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CompanyVendorFileType;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.DesktopUtils;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -19,7 +19,7 @@ import com.ecep.contract.model.BaseEnumEntity;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.CompanyVendorFile;
|
||||
import com.ecep.contract.model.CompanyVendorFileTypeLocal;
|
||||
import com.ecep.contract.model.VendorFileTypeLocal;
|
||||
import com.ecep.contract.service.CompanyVendorFileService;
|
||||
import com.ecep.contract.task.CompanyVendorEvaluationFormUpdateTask;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
@@ -91,7 +91,7 @@ public class VendorTabSkinFile
|
||||
table.disableProperty().bind(viewModel.getPath().isEmpty());
|
||||
fileTable_idColumn.setCellValueFactory(param -> param.getValue().getId());
|
||||
|
||||
ObservableMap<CompanyVendorFileType, CompanyVendorFileTypeLocal> observableMapByLocal = FXCollections
|
||||
ObservableMap<VendorFileType, VendorFileTypeLocal> observableMapByLocal = FXCollections
|
||||
.observableMap(companyVendorFileService.getFileTypeLocalMap(getLocale()));
|
||||
fileTable_typeColumn.setCellValueFactory(param -> Bindings.valueAt(observableMapByLocal,
|
||||
param.getValue().getType()).map(BaseEnumEntity::getValue));
|
||||
@@ -151,7 +151,7 @@ public class VendorTabSkinFile
|
||||
if (file.renameTo(dest)) {
|
||||
CompanyVendorFile ccf = new CompanyVendorFile();
|
||||
ccf.setVendor(companyVendor);
|
||||
ccf.setType(CompanyVendorFileType.EvaluationForm);
|
||||
ccf.setType(VendorFileType.EvaluationForm);
|
||||
ccf.setFilePath(dest.getAbsolutePath());
|
||||
ccf.setSignDate(nextSignDate);
|
||||
ccf.setValid(true);
|
||||
@@ -172,7 +172,7 @@ public class VendorTabSkinFile
|
||||
if (file.renameTo(dest)) {
|
||||
CompanyVendorFile ccf = new CompanyVendorFile();
|
||||
ccf.setVendor(companyVendor);
|
||||
ccf.setType(CompanyVendorFileType.General);
|
||||
ccf.setType(VendorFileType.General);
|
||||
ccf.setFilePath(dest.getAbsolutePath());
|
||||
ccf.setValid(false);
|
||||
companyVendorFiles.add(ccf);
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CompanyVendorFileType;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.VendorType;
|
||||
import com.ecep.contract.model.Company;
|
||||
@@ -574,7 +574,7 @@ public class CompanyVendorApprovedListVendorImportTask extends Tasker<Object> {
|
||||
CompanyVendorFileService fileService = getCompanyVendorFileService();
|
||||
LocalDate miniDate = publishDate.minusYears(vendorFileMinusYear);
|
||||
return fileService.findAll(ParamUtils.builder().equals("vendor", vendor.getId()).equals("valid", true)
|
||||
.equals("type", CompanyVendorFileType.EvaluationForm).between("signDate", miniDate, publishDate)
|
||||
.equals("type", VendorFileType.EvaluationForm).between("signDate", miniDate, publishDate)
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ import com.ecep.contract.MyDateTimeUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.CompanyVendorFileType;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.CompanyVendorFile;
|
||||
import com.ecep.contract.model.CompanyVendorFileTypeLocal;
|
||||
import com.ecep.contract.model.VendorFileTypeLocal;
|
||||
import com.ecep.contract.vm.CompanyVendorFileViewModel;
|
||||
|
||||
@Service
|
||||
@@ -30,14 +30,14 @@ public class CompanyVendorFileService extends QueryService<CompanyVendorFile, Co
|
||||
throw new UnsupportedOperationException("Unimplemented method 'saveAll'");
|
||||
}
|
||||
|
||||
public Map<CompanyVendorFileType, CompanyVendorFileTypeLocal> getFileTypeLocalMap(Locale locale) {
|
||||
public Map<VendorFileType, VendorFileTypeLocal> getFileTypeLocalMap(Locale locale) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getFileTypeLocalMap'");
|
||||
}
|
||||
|
||||
public void verify(CompanyVendor companyVendor, LocalDate verifyDate, MessageHolder holder) {
|
||||
// 查询所有评价表
|
||||
List<CompanyVendorFile> files = findAllByVendorAndType(companyVendor, CompanyVendorFileType.EvaluationForm);
|
||||
List<CompanyVendorFile> files = findAllByVendorAndType(companyVendor, VendorFileType.EvaluationForm);
|
||||
if (files == null || files.isEmpty()) {
|
||||
holder.error("未见供应商评价");
|
||||
return;
|
||||
@@ -65,7 +65,7 @@ public class CompanyVendorFileService extends QueryService<CompanyVendorFile, Co
|
||||
}
|
||||
}
|
||||
|
||||
public List<CompanyVendorFile> findAllByVendorAndType(CompanyVendor vendor, CompanyVendorFileType type) {
|
||||
public List<CompanyVendorFile> findAllByVendorAndType(CompanyVendor vendor, VendorFileType type) {
|
||||
return findAll(Map.of("vendor", vendor.getId(), "type", type.name()), Pageable.unpaged()).getContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,60 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.ContractKind;
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ContractGroup;
|
||||
import com.ecep.contract.vm.ContractGroupViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-group")
|
||||
public class ContractGroupService extends QueryService<ContractGroup, ContractGroupViewModel> {
|
||||
|
||||
public ContractGroup findByCode(String groupCode) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCode'");
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public ContractGroup findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public ContractGroup findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
ContractGroup newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败" + code, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Cacheable(key = "'groups'")
|
||||
@Override
|
||||
public List<ContractGroup> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'groups'")
|
||||
})
|
||||
@Override
|
||||
public ContractGroup save(ContractGroup entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'groups'")
|
||||
})
|
||||
@Override
|
||||
public void delete(ContractGroup entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,73 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.ContractType;
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ContractKind;
|
||||
import com.ecep.contract.vm.ContractKindViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-kind")
|
||||
public class ContractKindService extends QueryService<ContractKind, ContractKindViewModel> {
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ContractKind findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public ContractKind findByName(String name) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByName'");
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
ContractKind newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败" + name, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ContractKind findByCode(String code) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCode'");
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
ContractKind newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败" + code, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Cacheable(key = "'kinds'")
|
||||
@Override
|
||||
public List<ContractKind> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'kinds'"),
|
||||
})
|
||||
@Override
|
||||
public ContractKind save(ContractKind entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'kinds'"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ContractKind entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -75,6 +75,9 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
public Contract findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
if (response != null) {
|
||||
return updateValue(new Contract(), response);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,69 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ContractType;
|
||||
import com.ecep.contract.vm.ContractTypeViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-type")
|
||||
public class ContractTypeService extends QueryService<ContractType, ContractTypeViewModel> {
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ContractType findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public ContractType findByName(String name) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByName'");
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
ContractType newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败" + name, e);
|
||||
}
|
||||
}
|
||||
|
||||
public ContractType findByCode(String typeCode) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCode'");
|
||||
public ContractType findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
ContractType newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败" + code, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Cacheable(key = "'types'")
|
||||
@Override
|
||||
public List<ContractType> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'types'"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ContractType entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'types'"),
|
||||
})
|
||||
@Override
|
||||
public ContractType save(ContractType entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
import com.ecep.contract.vm.EmployeeViewModel;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
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.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -12,15 +16,43 @@ import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "employee")
|
||||
public class EmployeeService extends QueryService<Employee, EmployeeViewModel> {
|
||||
|
||||
public static final int DEFAULT_SYSTEM_EMPLOYEE_ID = 26;
|
||||
|
||||
public Employee findByName(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByName'");
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public Employee findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public Employee findByName(String name) {
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
Employee newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败:" + name, e);
|
||||
}
|
||||
}
|
||||
|
||||
public Employee findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
Employee newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败:" + code, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<EmployeeRole> getRolesByEmployeeId(Integer id) {
|
||||
try {
|
||||
return async("getRolesByEmployeeId", List.of(id), List.of(Integer.class)).handle((response, ex) -> {
|
||||
@@ -44,15 +76,20 @@ public class EmployeeService extends QueryService<Employee, EmployeeViewModel> {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateActive(int sessionId) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateActive'");
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public Employee save(Employee entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
public Employee findByCode(String personCode) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCode'");
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public void delete(Employee entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,56 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.ContractType;
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ProductType;
|
||||
import com.ecep.contract.vm.ProductTypeViewModel;
|
||||
|
||||
@Service
|
||||
public class ProductTypeService extends QueryService<ProductType, ProductTypeViewModel> {
|
||||
import java.util.List;
|
||||
|
||||
public ProductType findByName(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByName'");
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "product-type")
|
||||
public class ProductTypeService extends QueryService<ProductType, ProductTypeViewModel> {
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ProductType findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public ProductType findByName(String name) {
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
ProductType newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败" + name, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Cacheable(key = "'types'")
|
||||
@Override
|
||||
public List<ProductType> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'types'"),
|
||||
})
|
||||
@Override
|
||||
public ProductType save(ProductType entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'types'"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ProductType entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Project;
|
||||
@@ -12,8 +14,7 @@ import com.ecep.contract.vm.ProjectBidViewModel;
|
||||
public class ProjectBidService extends QueryService<ProjectBid, ProjectBidViewModel> {
|
||||
|
||||
public List<ProjectBid> findAllByProject(Project project) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllByProject'");
|
||||
return findAll(ParamUtils.builder().equals("project", project.getId()).build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,11 +43,6 @@ public class ProjectCostService extends QueryService<ProjectCost, ProjectCostVie
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public void updateAutoCost(Project project, MessageHolder holder) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateAutoCost'");
|
||||
}
|
||||
|
||||
public List<ProjectCost> findAllByProject(Project project) {
|
||||
return findAll(ParamUtils.builder().equals("project", project.getId()).build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.util.ProxyUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.vm.ProjectViewModel;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@@ -15,11 +21,25 @@ public class ProjectService extends QueryService<Project, ProjectViewModel> {
|
||||
|
||||
|
||||
public Project findByName(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
Project newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败:" + name, e);
|
||||
}
|
||||
}
|
||||
|
||||
public Project findByCode(String code) {
|
||||
throw new UnsupportedOperationException();
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
Project newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败:" + code, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void applyCode(Project project, String code) {
|
||||
@@ -27,13 +47,63 @@ public class ProjectService extends QueryService<Project, ProjectViewModel> {
|
||||
}
|
||||
|
||||
public Project newInstanceByContract(Contract contract) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'newInstanceByContract'");
|
||||
Project project = new Project();
|
||||
project.setName(contract.getName());
|
||||
applyCode(project, contract.getCode());
|
||||
contract.setCreated(LocalDateTime.now());
|
||||
LocalDateTime created = contract.getCreated();
|
||||
if (created != null) {
|
||||
project.setCreated(created.toLocalDate());
|
||||
} else {
|
||||
project.setCreated(LocalDate.now());
|
||||
}
|
||||
project.setCustomer(contract.getCompany());
|
||||
project.setApplicant(contract.getEmployee());
|
||||
return project;
|
||||
}
|
||||
|
||||
public File searchPath(Project project) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'searchPath'");
|
||||
ProjectSaleType saleType = project.getSaleType();
|
||||
if (saleType == null) {
|
||||
return null;
|
||||
}
|
||||
if (!ProxyUtils.isInitialized(saleType)) {
|
||||
saleType = SpringApp.getBean(ProjectSaleTypeService.class).findById(saleType.getId());
|
||||
project.setSaleType(saleType);
|
||||
}
|
||||
if (!StringUtils.hasText(saleType.getPath())) {
|
||||
return null;
|
||||
}
|
||||
File path = new File(saleType.getPath());
|
||||
if (saleType.isStoreByYear()) {
|
||||
path = new File(path, "20" + project.getCodeYear());
|
||||
if (!path.exists()) {
|
||||
path.mkdir();// 创建目录
|
||||
}
|
||||
}
|
||||
|
||||
String projectCode = makeProjectCode(project);
|
||||
// 检索目录
|
||||
File[] files = path.listFiles(f -> f.isDirectory() && f.getName().contains(projectCode));
|
||||
if (files != null && files.length > 0) {
|
||||
path = files[0];
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
public String makeProjectCode(Project project) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(project.getSaleType().getCode());
|
||||
sb.append(project.getCodeYear());
|
||||
if (project.getCodeSequenceNumber() < 10) {
|
||||
sb.append("0");
|
||||
}
|
||||
if (project.getCodeSequenceNumber() < 100) {
|
||||
sb.append("0");
|
||||
}
|
||||
sb.append(project.getCodeSequenceNumber());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public int getNextCodeSequenceNumber(ProjectSaleType newValue, int i) {
|
||||
@@ -42,7 +112,7 @@ public class ProjectService extends QueryService<Project, ProjectViewModel> {
|
||||
}
|
||||
|
||||
public Project findBySaleTypeAndCodeYearAndCodeSequenceNumber(ProjectSaleType saleType, int codeYear,
|
||||
int codeSequenceNumber) {
|
||||
int codeSequenceNumber) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findBySaleTypeAndCodeYearAndCodeSequenceNumber'");
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
public T save(T entity) {
|
||||
try {
|
||||
return async("save", entity, entity.getClass().getName()).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("保存实体失败", ex);
|
||||
}
|
||||
if (response != null) {
|
||||
try {
|
||||
objectMapper.updateValue(entity, response);
|
||||
@@ -84,6 +87,9 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
public void delete(T entity) {
|
||||
try {
|
||||
async("delete", entity, entity.getClass().getName()).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("删除实体失败", ex);
|
||||
}
|
||||
if (response != null) {
|
||||
return updateValue(entity, response);
|
||||
}
|
||||
@@ -116,6 +122,9 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
|
||||
public CompletableFuture<T> asyncFindById(Integer id) {
|
||||
return async("findById", id, Integer.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("查询实体失败", ex);
|
||||
}
|
||||
T newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
});
|
||||
@@ -145,6 +154,9 @@ 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) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findAll+调用失败", ex);
|
||||
}
|
||||
try {
|
||||
// 将响应结果转换为PageContent对象,使用当前类的createNewEntity方法创建实体实例
|
||||
PageContent<T> pageContent = of(response, objectMapper, this::createNewEntity);
|
||||
@@ -186,6 +198,9 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
// 调用async方法执行名为"count"的异步操作,传入参数params
|
||||
// 使用handle方法处理异步操作的结果或异常
|
||||
return async("count", params).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+count+调用失败", ex);
|
||||
}
|
||||
// 将响应结果转换为Long类型并返回
|
||||
return response.asLong();
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.CompanyVendorFileTypeLocal;
|
||||
import com.ecep.contract.vm.CompanyVendorFileTypeLocalViewModel;
|
||||
import com.ecep.contract.model.VendorFileTypeLocal;
|
||||
import com.ecep.contract.vm.VendorFileTypeLocalViewModel;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -12,28 +12,28 @@ import java.util.List;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "vendor-file-type")
|
||||
public class CompanyVendorFileTypeService extends QueryService<CompanyVendorFileTypeLocal, CompanyVendorFileTypeLocalViewModel> {
|
||||
public class VendorFileTypeService extends QueryService<VendorFileTypeLocal, VendorFileTypeLocalViewModel> {
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public CompanyVendorFileTypeLocal findById(Integer id) {
|
||||
public VendorFileTypeLocal findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'all'")
|
||||
@Override
|
||||
public List<CompanyVendorFileTypeLocal> findAll() {
|
||||
public List<VendorFileTypeLocal> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'all'")})
|
||||
@Override
|
||||
public CompanyVendorFileTypeLocal save(CompanyVendorFileTypeLocal entity) {
|
||||
public VendorFileTypeLocal save(VendorFileTypeLocal entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'all'")})
|
||||
@Override
|
||||
public void delete(CompanyVendorFileTypeLocal entity) {
|
||||
public void delete(VendorFileTypeLocal entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ public class VendorGroupService extends QueryService<VendorGroup, VendorGroupVie
|
||||
public VendorGroup findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
VendorGroup newEntity = newInstance();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
|
||||
@@ -1,12 +1,39 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.CompanyVendorFileTypeLocal;
|
||||
import com.ecep.contract.vm.CompanyVendorFileTypeLocalViewModel;
|
||||
import com.ecep.contract.model.VendorTypeLocal;
|
||||
import com.ecep.contract.vm.VendorTypeLocalViewModel;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "vendor-file-type")
|
||||
public class CompanyVendorFileTypeService extends QueryService<CompanyVendorFileTypeLocal, CompanyVendorFileTypeLocalViewModel> {
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "vendor-type")
|
||||
public class VendorTypeService extends QueryService<VendorTypeLocal, VendorTypeLocalViewModel> {
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public VendorTypeLocal findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'all'")
|
||||
@Override
|
||||
public List<VendorTypeLocal> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'all'")})
|
||||
@Override
|
||||
public VendorTypeLocal save(VendorTypeLocal entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'all'")})
|
||||
@Override
|
||||
public void delete(VendorTypeLocal entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,21 +46,7 @@ public class ContractRepairTask extends Tasker<Object> implements WebSocketClien
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
updateTitle("修复合同 " + contract.toPrettyString());
|
||||
return callRemoteTask(holder);
|
||||
return callRemoteTask(holder, getLocale(), contract.getId());
|
||||
}
|
||||
|
||||
private Object callRemoteTask(MessageHolder holder) {
|
||||
WebSocketClientService webSocketService = SpringApp.getBean(WebSocketClientService.class);
|
||||
webSocketService.withSession(session -> {
|
||||
try {
|
||||
session.submitTask(this, contract.getId(), getLocale().toLanguageTag());
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -37,20 +37,7 @@ public class ContractSyncTask extends Tasker<Object> implements WebSocketClientT
|
||||
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
updateTitle("用友U8系统-同步合同");
|
||||
return callRemoteTask(holder);
|
||||
}
|
||||
|
||||
private Object callRemoteTask(MessageHolder holder) {
|
||||
WebSocketClientService webSocketService = SpringApp.getBean(WebSocketClientService.class);
|
||||
webSocketService.withSession(session -> {
|
||||
try {
|
||||
session.submitTask(this);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
return callRemoteTask(holder, getLocale());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.controller.project.cost.ProjectCostImportItemsFromContractsTasker;
|
||||
import com.ecep.contract.util.ProxyUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -731,15 +732,16 @@ public class ContractVerifyComm {
|
||||
//
|
||||
boolean needImport = false;
|
||||
|
||||
ProjectCost autoCost = getProjectCostService().findAutoCostByProject(project);
|
||||
ProjectCostService projectCostService = getProjectCostService();
|
||||
ProjectCost autoCost = projectCostService.findAutoCostByProject(project);
|
||||
if (autoCost == null) {
|
||||
// 创建 V0 项目成本
|
||||
ProjectCost cost = getProjectCostService().newInstanceByProject(project);
|
||||
ProjectCost cost = projectCostService.newInstanceByProject(project);
|
||||
cost.setVersion(0);
|
||||
cost.setApplicant(getEmployeeService().findById(EmployeeService.DEFAULT_SYSTEM_EMPLOYEE_ID));
|
||||
cost.setApplyTime(LocalDateTime.now());
|
||||
cost.setDescription("自动导入");
|
||||
autoCost = getProjectCostService().save(cost);
|
||||
autoCost = projectCostService.save(cost);
|
||||
needImport = true;
|
||||
} else {
|
||||
// 检查 V0 项目成本
|
||||
@@ -754,13 +756,21 @@ public class ContractVerifyComm {
|
||||
|
||||
if (needImport && !autoCost.isImportLock()) {
|
||||
holder.debug("更新V0项目成本");
|
||||
getProjectCostService().updateAutoCost(project, holder);
|
||||
ProjectCost cost = projectCostService.findAutoCostByProject(project);
|
||||
if (cost == null) {
|
||||
cost = projectCostService.newInstanceByProject(project);
|
||||
cost.setVersion(0);
|
||||
cost = projectCostService.save(cost);
|
||||
}
|
||||
ProjectCostImportItemsFromContractsTasker tasker = new ProjectCostImportItemsFromContractsTasker();
|
||||
tasker.setCost(cost);
|
||||
|
||||
}
|
||||
|
||||
// 检查最新的项目成本,默认 V1
|
||||
ProjectCost latestCost = getProjectCostService().findLatestByProject(project);
|
||||
ProjectCost latestCost = projectCostService.findLatestByProject(project);
|
||||
if (latestCost == null) {
|
||||
ProjectCost cost = getProjectCostService().newInstanceByProject(project);
|
||||
ProjectCost cost = projectCostService.newInstanceByProject(project);
|
||||
cost.setVersion(1);
|
||||
Employee applicant = project.getApplicant();
|
||||
if (applicant == null) {
|
||||
@@ -768,7 +778,7 @@ public class ContractVerifyComm {
|
||||
}
|
||||
cost.setApplicant(applicant);
|
||||
cost.setApplyTime(project.getCreated().atTime(LocalTime.now()));
|
||||
latestCost = getProjectCostService().save(cost);
|
||||
latestCost = projectCostService.save(cost);
|
||||
} else {
|
||||
//
|
||||
if (latestCost.getGrossProfitMargin() <= 0) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.ecep.contract.vm;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.CompanyVendorFileType;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.CompanyVendorFile;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CompanyVendorFileViewModel extends IdentityViewModel<CompanyVendorF
|
||||
@ToString.Exclude
|
||||
private SimpleObjectProperty<CompanyVendor> vendor = new SimpleObjectProperty<>();
|
||||
|
||||
private SimpleObjectProperty<CompanyVendorFileType> type = new SimpleObjectProperty<>();
|
||||
private SimpleObjectProperty<VendorFileType> type = new SimpleObjectProperty<>();
|
||||
|
||||
private SimpleStringProperty filePath = new SimpleStringProperty();
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.ecep.contract.vm;
|
||||
|
||||
import com.ecep.contract.CompanyVendorFileType;
|
||||
import com.ecep.contract.model.CompanyVendorFileTypeLocal;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.model.VendorFileTypeLocal;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CompanyVendorFileTypeLocalViewModel extends EnumViewModel<CompanyVendorFileType, CompanyVendorFileTypeLocal> {
|
||||
public class VendorFileTypeLocalViewModel extends EnumViewModel<VendorFileType, VendorFileTypeLocal> {
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.ecep.contract.vm;
|
||||
|
||||
import com.ecep.contract.CompanyVendorFileType;
|
||||
import com.ecep.contract.model.CompanyVendorFileTypeLocal;
|
||||
import com.ecep.contract.VendorType;
|
||||
import com.ecep.contract.model.VendorTypeLocal;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CompanyVendorFileTypeLocalViewModel extends EnumViewModel<CompanyVendorFileType, CompanyVendorFileTypeLocal> {
|
||||
public class VendorTypeLocalViewModel extends EnumViewModel<VendorType, VendorTypeLocal> {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user