feat: 添加按ID查询的仓库方法并优化合同同步逻辑
添加了多个仓库的按ID查询方法,如findByCompanyId和findAllByContractId 优化了合同同步任务,使用ContractVo替代Contract减少数据库访问 重构了部分服务方法,支持通过ID直接操作,提升性能 修复了ProjectCostService中字段映射错误的问题
This commit is contained in:
@@ -38,17 +38,13 @@ public class ProjectCostTabSkinBase
|
|||||||
implements TabSkin {
|
implements TabSkin {
|
||||||
@Setter
|
@Setter
|
||||||
LocalDateTimeStringConverter localDateTimeStringConverter;
|
LocalDateTimeStringConverter localDateTimeStringConverter;
|
||||||
ProjectService projectService;
|
|
||||||
|
|
||||||
public ProjectCostTabSkinBase(ProjectCostWindowController controller) {
|
public ProjectCostTabSkinBase(ProjectCostWindowController controller) {
|
||||||
super(controller);
|
super(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectService getProjectService() {
|
ProjectService getProjectService() {
|
||||||
if (projectService == null) {
|
return getCachedBean(ProjectService.class);
|
||||||
projectService = getBean(ProjectService.class);
|
|
||||||
}
|
|
||||||
return projectService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalDateTimeStringConverter getLocalDateTimeStringConverter() {
|
private LocalDateTimeStringConverter getLocalDateTimeStringConverter() {
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.ecep.contract.converter;
|
||||||
|
|
||||||
|
import com.ecep.contract.service.InventoryService;
|
||||||
|
import com.ecep.contract.vo.InventoryVo;
|
||||||
|
import javafx.util.StringConverter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存货字符串转换器
|
||||||
|
* 用于在UI组件中显示存货信息并支持从字符串还原存货对象
|
||||||
|
*/
|
||||||
|
public class InventoryStringConverter extends StringConverter<InventoryVo> {
|
||||||
|
|
||||||
|
/** 存货服务,用于从字符串查找对应的存货对象 */
|
||||||
|
private final InventoryService service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
*
|
||||||
|
* @param service 存货服务实例
|
||||||
|
*/
|
||||||
|
public InventoryStringConverter(InventoryService service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将存货对象转换为字符串表示
|
||||||
|
*
|
||||||
|
* @param object 存货对象
|
||||||
|
* @return 存货的名称,如果对象为null则返回空字符串
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString(InventoryVo object) {
|
||||||
|
return object == null ? "" : (object.getName()+"-"+ object.getSpecification());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从字符串还原存货对象
|
||||||
|
*
|
||||||
|
* @param string 存货名称
|
||||||
|
* @return 对应的存货对象,如果未找到则返回null
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public InventoryVo fromString(String string) {
|
||||||
|
return service.findByName(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,10 @@ package com.ecep.contract.service;
|
|||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import com.ecep.contract.converter.CustomerFileTypeStringConverter;
|
||||||
|
import com.ecep.contract.converter.InventoryStringConverter;
|
||||||
|
import com.ecep.contract.vo.CustomerFileTypeLocalVo;
|
||||||
|
import javafx.util.StringConverter;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -13,7 +17,7 @@ import com.ecep.contract.vo.InventoryVo;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class InventoryService extends QueryService<InventoryVo, InventoryViewModel> {
|
public class InventoryService extends QueryService<InventoryVo, InventoryViewModel> {
|
||||||
|
private final StringConverter<InventoryVo> stringConverter = new InventoryStringConverter(this);
|
||||||
@Override
|
@Override
|
||||||
public InventoryVo createNewEntity() {
|
public InventoryVo createNewEntity() {
|
||||||
InventoryVo inventory = new InventoryVo();
|
InventoryVo inventory = new InventoryVo();
|
||||||
@@ -44,4 +48,8 @@ public class InventoryService extends QueryService<InventoryVo, InventoryViewMod
|
|||||||
return page.getContent().getFirst();
|
return page.getContent().getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StringConverter<InventoryVo> getStringConverter() {
|
||||||
|
return stringConverter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,14 @@ import com.ecep.contract.SpringApp;
|
|||||||
import com.ecep.contract.ds.company.service.CompanyService;
|
import com.ecep.contract.ds.company.service.CompanyService;
|
||||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||||
import com.ecep.contract.ds.other.service.SysConfService;
|
import com.ecep.contract.ds.other.service.SysConfService;
|
||||||
|
import com.ecep.contract.util.ContextUtils;
|
||||||
import com.ecep.contract.util.MyStringUtils;
|
import com.ecep.contract.util.MyStringUtils;
|
||||||
import com.ecep.contract.util.NumberUtils;
|
import com.ecep.contract.util.NumberUtils;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
public class AbstractCtx {
|
public class AbstractCtx implements ContextUtils {
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
Locale locale = Locale.getDefault();
|
Locale locale = Locale.getDefault();
|
||||||
@@ -60,7 +61,7 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateText(Supplier<String> getter, Consumer<String> setter, String text, MessageHolder holder,
|
public boolean updateText(Supplier<String> getter, Consumer<String> setter, String text, MessageHolder holder,
|
||||||
String topic) {
|
String topic) {
|
||||||
if (!Objects.equals(getter.get(), text)) {
|
if (!Objects.equals(getter.get(), text)) {
|
||||||
setter.accept(text);
|
setter.accept(text);
|
||||||
holder.info(topic + "修改为: " + text);
|
holder.info(topic + "修改为: " + text);
|
||||||
@@ -70,7 +71,7 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateAppendText(Supplier<String> getter, Consumer<String> setter, String text, MessageHolder holder,
|
public boolean updateAppendText(Supplier<String> getter, Consumer<String> setter, String text, MessageHolder holder,
|
||||||
String topic) {
|
String topic) {
|
||||||
if (StringUtils.hasText(text)) {
|
if (StringUtils.hasText(text)) {
|
||||||
String str = MyStringUtils.appendIfAbsent(getter.get(), text);
|
String str = MyStringUtils.appendIfAbsent(getter.get(), text);
|
||||||
if (!Objects.equals(getter.get(), str)) {
|
if (!Objects.equals(getter.get(), str)) {
|
||||||
@@ -83,7 +84,7 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateLocalDate(Supplier<LocalDate> getter, Consumer<LocalDate> setter, java.sql.Date date,
|
public boolean updateLocalDate(Supplier<LocalDate> getter, Consumer<LocalDate> setter, java.sql.Date date,
|
||||||
MessageHolder holder, String topic) {
|
MessageHolder holder, String topic) {
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
return updateLocalDate(getter, setter, date.toLocalDate(), holder, topic);
|
return updateLocalDate(getter, setter, date.toLocalDate(), holder, topic);
|
||||||
}
|
}
|
||||||
@@ -91,12 +92,12 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateLocalDate(Supplier<LocalDate> getter, Consumer<LocalDate> setter, LocalDate date,
|
public boolean updateLocalDate(Supplier<LocalDate> getter, Consumer<LocalDate> setter, LocalDate date,
|
||||||
MessageHolder holder, String topic) {
|
MessageHolder holder, String topic) {
|
||||||
return updateLocalDate(getter, setter, date, holder, topic, false);
|
return updateLocalDate(getter, setter, date, holder, topic, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateLocalDate(Supplier<LocalDate> getter, Consumer<LocalDate> setter, LocalDate date,
|
public boolean updateLocalDate(Supplier<LocalDate> getter, Consumer<LocalDate> setter, LocalDate date,
|
||||||
MessageHolder holder, String topic, boolean allowNull) {
|
MessageHolder holder, String topic, boolean allowNull) {
|
||||||
if (date == null && !allowNull) {
|
if (date == null && !allowNull) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -109,7 +110,7 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateLocalDate(Supplier<LocalDate> getter, Consumer<LocalDate> setter, String strDate,
|
public boolean updateLocalDate(Supplier<LocalDate> getter, Consumer<LocalDate> setter, String strDate,
|
||||||
MessageHolder holder, String topic) {
|
MessageHolder holder, String topic) {
|
||||||
LocalDate date = null;
|
LocalDate date = null;
|
||||||
if (StringUtils.hasText(strDate)) {
|
if (StringUtils.hasText(strDate)) {
|
||||||
try {
|
try {
|
||||||
@@ -122,7 +123,7 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateLocalDate(Supplier<LocalDate> getter, Consumer<LocalDate> setter, Timestamp timestamp,
|
public boolean updateLocalDate(Supplier<LocalDate> getter, Consumer<LocalDate> setter, Timestamp timestamp,
|
||||||
MessageHolder holder, String topic) {
|
MessageHolder holder, String topic) {
|
||||||
LocalDate date = null;
|
LocalDate date = null;
|
||||||
|
|
||||||
if (timestamp != null) {
|
if (timestamp != null) {
|
||||||
@@ -136,7 +137,7 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateLocalDateTime(Supplier<LocalDateTime> getter, Consumer<LocalDateTime> setter,
|
public boolean updateLocalDateTime(Supplier<LocalDateTime> getter, Consumer<LocalDateTime> setter,
|
||||||
Timestamp timestamp, MessageHolder holder, String topic) {
|
Timestamp timestamp, MessageHolder holder, String topic) {
|
||||||
LocalDateTime dateTime = null;
|
LocalDateTime dateTime = null;
|
||||||
|
|
||||||
if (timestamp != null) {
|
if (timestamp != null) {
|
||||||
@@ -152,7 +153,7 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateLocalDateTime(Supplier<LocalDateTime> getter, Consumer<LocalDateTime> setter,
|
public boolean updateLocalDateTime(Supplier<LocalDateTime> getter, Consumer<LocalDateTime> setter,
|
||||||
LocalDateTime dateTime, MessageHolder holder, String topic) {
|
LocalDateTime dateTime, MessageHolder holder, String topic) {
|
||||||
if (!Objects.equals(getter.get(), dateTime)) {
|
if (!Objects.equals(getter.get(), dateTime)) {
|
||||||
setter.accept(dateTime);
|
setter.accept(dateTime);
|
||||||
holder.info(topic + "修改为: " + dateTime);
|
holder.info(topic + "修改为: " + dateTime);
|
||||||
@@ -162,7 +163,7 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateInstant(Supplier<Instant> getter, Consumer<Instant> setter, Instant instant,
|
public boolean updateInstant(Supplier<Instant> getter, Consumer<Instant> setter, Instant instant,
|
||||||
MessageHolder holder, String topic) {
|
MessageHolder holder, String topic) {
|
||||||
if (!Objects.equals(getter.get(), instant)) {
|
if (!Objects.equals(getter.get(), instant)) {
|
||||||
setter.accept(instant);
|
setter.accept(instant);
|
||||||
holder.info(topic + "修改为: " + instant);
|
holder.info(topic + "修改为: " + instant);
|
||||||
@@ -172,13 +173,13 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateNumber(Supplier<Double> getter, Consumer<Double> setter, BigDecimal value,
|
public boolean updateNumber(Supplier<Double> getter, Consumer<Double> setter, BigDecimal value,
|
||||||
MessageHolder holder, String topic) {
|
MessageHolder holder, String topic) {
|
||||||
double val = value.doubleValue();
|
double val = value.doubleValue();
|
||||||
return updateNumber(getter, setter, val, holder, topic);
|
return updateNumber(getter, setter, val, holder, topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateNumber(Supplier<Double> getter, Consumer<Double> setter, double value, MessageHolder holder,
|
public boolean updateNumber(Supplier<Double> getter, Consumer<Double> setter, double value, MessageHolder holder,
|
||||||
String topic) {
|
String topic) {
|
||||||
if (getter.get() == null || !NumberUtils.equals(getter.get(), value)) {
|
if (getter.get() == null || !NumberUtils.equals(getter.get(), value)) {
|
||||||
setter.accept(value);
|
setter.accept(value);
|
||||||
holder.info(topic + "修改为: " + value);
|
holder.info(topic + "修改为: " + value);
|
||||||
@@ -188,7 +189,7 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateNumber(Supplier<Float> getter, Consumer<Float> setter, float value, MessageHolder holder,
|
public boolean updateNumber(Supplier<Float> getter, Consumer<Float> setter, float value, MessageHolder holder,
|
||||||
String topic) {
|
String topic) {
|
||||||
if (getter.get() == null || !NumberUtils.equals(getter.get(), value)) {
|
if (getter.get() == null || !NumberUtils.equals(getter.get(), value)) {
|
||||||
setter.accept(value);
|
setter.accept(value);
|
||||||
holder.info(topic + "修改为: " + value);
|
holder.info(topic + "修改为: " + value);
|
||||||
@@ -198,7 +199,7 @@ public class AbstractCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateNumber(Supplier<Integer> getter, Consumer<Integer> setter, Integer value, MessageHolder holder,
|
public boolean updateNumber(Supplier<Integer> getter, Consumer<Integer> setter, Integer value, MessageHolder holder,
|
||||||
String topic) {
|
String topic) {
|
||||||
if (getter.get() == null || !NumberUtils.equals(getter.get(), value)) {
|
if (getter.get() == null || !NumberUtils.equals(getter.get(), value)) {
|
||||||
setter.accept(value);
|
setter.accept(value);
|
||||||
holder.info(topic + "修改为: " + value);
|
holder.info(topic + "修改为: " + value);
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import com.ecep.contract.ds.vendor.service.VendorEntityService;
|
|||||||
import com.ecep.contract.ds.vendor.service.VendorService;
|
import com.ecep.contract.ds.vendor.service.VendorService;
|
||||||
import com.ecep.contract.ds.company.model.Company;
|
import com.ecep.contract.ds.company.model.Company;
|
||||||
import com.ecep.contract.model.Employee;
|
import com.ecep.contract.model.Employee;
|
||||||
import com.ecep.contract.ds.vendor.model.Vendor;
|
|
||||||
import com.ecep.contract.ds.vendor.model.VendorEntity;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -72,6 +70,36 @@ public class AbstractYongYouU8Ctx extends AbstractCtx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean updateEmployeeId(Supplier<Integer> getter, Consumer<Integer> setter, EmployeeVo employee,
|
||||||
|
MessageHolder holder, String topic) {
|
||||||
|
if (employee == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var v1 = getter.get();
|
||||||
|
if (v1 == null) {
|
||||||
|
setter.accept(employee.getId());
|
||||||
|
holder.info(topic + "更新为 " + employee.getName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(v1, employee.getId())) {
|
||||||
|
setter.accept(employee.getId());
|
||||||
|
holder.info(topic + "更新为 " + employee.getName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean updateEmployeeIdByCode(Supplier<Integer> getter, Consumer<Integer> setter, String code,
|
||||||
|
MessageHolder holder, String topic) {
|
||||||
|
if (StringUtils.hasText(code)) {
|
||||||
|
var employee = getEmployeeService().findByCode(code);
|
||||||
|
if (employee != null) {
|
||||||
|
return updateEmployeeId(getter, setter, employee, holder, topic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean updateEmployee(Supplier<Employee> getter, Consumer<Employee> setter, EmployeeVo employee,
|
boolean updateEmployee(Supplier<Employee> getter, Consumer<Employee> setter, EmployeeVo employee,
|
||||||
MessageHolder holder, String topic) {
|
MessageHolder holder, String topic) {
|
||||||
if (employee == null) {
|
if (employee == null) {
|
||||||
@@ -106,6 +134,17 @@ public class AbstractYongYouU8Ctx extends AbstractCtx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean updateEmployeeIdByName(Supplier<Integer> getter, Consumer<Integer> setter, String name,
|
||||||
|
MessageHolder holder, String topic) {
|
||||||
|
if (StringUtils.hasText(name)) {
|
||||||
|
EmployeeVo employee = getEmployeeService().findByName(name);
|
||||||
|
if (employee != null) {
|
||||||
|
return updateEmployeeId(getter, setter, employee, holder, topic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean updateCompanyByCustomerCode(Supplier<Company> getter, Consumer<Company> setter, String customerCode,
|
boolean updateCompanyByCustomerCode(Supplier<Company> getter, Consumer<Company> setter, String customerCode,
|
||||||
MessageHolder holder, String topic) {
|
MessageHolder holder, String topic) {
|
||||||
Company company = null;
|
Company company = null;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@@ -148,11 +150,11 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
List<Contract> list = getContractService().findAllByCompany(company);
|
List<Contract> list = getContractService().findAllByCompany(company);
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
Contract contract = list.get(i);
|
Contract contract = list.get(i);
|
||||||
syncContract(contract, holder);
|
syncContract(contract.toVo(), holder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void syncContract(Contract contract, MessageHolder holder) {
|
public void syncContract(ContractVo contract, MessageHolder holder) {
|
||||||
boolean modified = updateContractDetailByGuid(contract, contract.getGuid(), holder);
|
boolean modified = updateContractDetailByGuid(contract, contract.getGuid(), holder);
|
||||||
if (updateContractExec(contract, holder)) {
|
if (updateContractExec(contract, holder)) {
|
||||||
modified = true;
|
modified = true;
|
||||||
@@ -169,7 +171,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateContractDetailByGuid(Contract contract, String guid, MessageHolder holder) {
|
public boolean updateContractDetailByGuid(ContractVo contract, String guid, MessageHolder holder) {
|
||||||
if (repository == null) {
|
if (repository == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -185,7 +187,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
/**
|
/**
|
||||||
* 应用合同数据
|
* 应用合同数据
|
||||||
*/
|
*/
|
||||||
public boolean applyContractDetail(Contract contract, Map<String, Object> rs, MessageHolder holder) {
|
public boolean applyContractDetail(ContractVo contract, Map<String, Object> rs, MessageHolder holder) {
|
||||||
if (rs == null || rs.isEmpty()) {
|
if (rs == null || rs.isEmpty()) {
|
||||||
holder.warn("CM_Contract_B 中未检索到合同数据");
|
holder.warn("CM_Contract_B 中未检索到合同数据");
|
||||||
return false;
|
return false;
|
||||||
@@ -259,15 +261,15 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
"变更日期")) {
|
"变更日期")) {
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
if (updateEmployeeByName(contract::getSetupPerson, contract::setSetupPerson, (String) rs.get("strSetupPerson"),
|
if (updateEmployeeIdByName(contract::getSetupPersonId, contract::setSetupPersonId, (String) rs.get("strSetupPerson"),
|
||||||
holder, "提交人")) {
|
holder, "提交人")) {
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
if (updateEmployeeByName(contract::getInurePerson, contract::setInurePerson, (String) rs.get("strInurePerson"),
|
if (updateEmployeeIdByName(contract::getInurePersonId, contract::setInurePersonId, (String) rs.get("strInurePerson"),
|
||||||
holder, "生效人")) {
|
holder, "生效人")) {
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
if (updateEmployeeByName(contract::getVaryPerson, contract::setVaryPerson, (String) rs.get("strVaryPerson"),
|
if (updateEmployeeIdByName(contract::getVaryPersonId, contract::setVaryPersonId, (String) rs.get("strVaryPerson"),
|
||||||
holder, "修改人")) {
|
holder, "修改人")) {
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
@@ -301,28 +303,19 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contract.getType() != null && contract.getPayWay() != null) {
|
if (contract.getTypeId() != null && contract.getPayWay() != null) {
|
||||||
ContractType type = contract.getType();
|
var typeId = contract.getTypeId();
|
||||||
if (!Hibernate.isInitialized(type)) {
|
var type = getCachedBean(ContractTypeService.class).findById(typeId);
|
||||||
type = getCachedBean(ContractTypeService.class).getById(type.getId());
|
|
||||||
contract.setType(type);
|
|
||||||
}
|
|
||||||
if (!type.getDirection().equals(contract.getPayWay().getText())) {
|
if (!type.getDirection().equals(contract.getPayWay().getText())) {
|
||||||
holder.warn("合同类型:" + type.getName() + "的付款方向与付款方式不一致:" + contract.getPayWay().getText());
|
holder.warn("合同类型:" + type.getName() + "的付款方向与付款方式不一致:" + contract.getPayWay().getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contract.getKind() != null && contract.getType() != null) {
|
if (contract.getKindId() != null && contract.getTypeId() != null) {
|
||||||
ContractKind kind = contract.getKind();
|
var kindId = contract.getKindId();
|
||||||
if (!Hibernate.isInitialized(kind)) {
|
var kind = getCachedBean(ContractKindService.class).findById(kindId);
|
||||||
kind = getCachedBean(ContractKindService.class).getById(kind.getId());
|
var typeId = contract.getTypeId();
|
||||||
contract.setKind(kind);
|
var type = getCachedBean(ContractTypeService.class).findById(typeId);
|
||||||
}
|
|
||||||
ContractType type = contract.getType();
|
|
||||||
if (!Hibernate.isInitialized(type)) {
|
|
||||||
type = getCachedBean(ContractTypeService.class).getById(type.getId());
|
|
||||||
contract.setType(type);
|
|
||||||
}
|
|
||||||
if (!kind.getName().equals(type.getTitle())) {
|
if (!kind.getName().equals(type.getTitle())) {
|
||||||
holder.warn("合同分类的名称:" + kind.getName() + "与合同类型的标题:" + type.getName() + "不一致");
|
holder.warn("合同分类的名称:" + kind.getName() + "与合同类型的标题:" + type.getName() + "不一致");
|
||||||
}
|
}
|
||||||
@@ -337,8 +330,8 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
* @param unit 合同对应的单位代码
|
* @param unit 合同对应的单位代码
|
||||||
* @param holder 消息处理对象
|
* @param holder 消息处理对象
|
||||||
*/
|
*/
|
||||||
private boolean updateCompanyByVendorUnitCode(Contract contract, String unit, MessageHolder holder) {
|
private boolean updateCompanyByVendorUnitCode(ContractVo contract, String unit, MessageHolder holder) {
|
||||||
Company company = contract.getCompany();
|
var companyId = contract.getCompanyId();
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
boolean vendorModified = false;
|
boolean vendorModified = false;
|
||||||
VendorService vendorService = getCompanyVendorService();
|
VendorService vendorService = getCompanyVendorService();
|
||||||
@@ -353,31 +346,33 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
|
|
||||||
entity = save(entity);
|
entity = save(entity);
|
||||||
|
|
||||||
Vendor vendor = getCompanyVendorService().getById(entity.getVendorId());
|
var vendor = getCompanyVendorService().findById(entity.getVendorId());
|
||||||
if (vendor == null) {
|
if (vendor == null) {
|
||||||
if (company != null) {
|
if (companyId != null) {
|
||||||
|
var company = getCompanyService().findById(companyId);
|
||||||
vendor = vendorService.findByCompany(company);
|
vendor = vendorService.findByCompany(company);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!Hibernate.isInitialized(vendor)) {
|
if (vendor.getCompanyId() == null) {
|
||||||
vendor = vendorService.getById(vendor.getId());
|
vendor.setCompanyId(companyId);
|
||||||
}
|
|
||||||
if (vendor.getCompany() == null) {
|
|
||||||
vendor.setCompany(company);
|
|
||||||
vendorModified = true;
|
vendorModified = true;
|
||||||
} else {
|
} else {
|
||||||
if (company == null) {
|
if (companyId == null) {
|
||||||
company = vendor.getCompany();
|
companyId = vendor.getCompanyId();
|
||||||
} else if (!Objects.equals(company, vendor.getCompany())) {
|
} else if (!Objects.equals(companyId, vendor.getCompanyId())) {
|
||||||
|
var contractCompany = getCompanyService().findById(companyId);
|
||||||
|
var vendorCompany = getCompanyService().findById(vendor.getCompanyId());
|
||||||
holder.error(
|
holder.error(
|
||||||
"供应商的企业和合同的企业不一致, 供应商的企业:" + vendor.getCompany().getId() + ",合同的企业:" + company.getId());
|
"供应商的企业和合同的企业不一致, 供应商的企业:" + vendorCompany.getName() + ",合同的企业:" + contractCompany.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vendor == null) {
|
if (vendor == null) {
|
||||||
vendor = new Vendor();
|
var v0 = new Vendor();
|
||||||
vendor.setCompany(company);
|
v0.setCompany(getCompanyService().getById(companyId));
|
||||||
vendorModified = true;
|
v0.setCreated(LocalDateTime.now());
|
||||||
|
v0.setVersion(0);
|
||||||
|
vendor = getCompanyVendorService().save(v0).toVo();
|
||||||
}
|
}
|
||||||
if (vendor.getDevelopDate() == null
|
if (vendor.getDevelopDate() == null
|
||||||
|| (entity.getDevelopDate() != null && vendor.getDevelopDate().isAfter(entity.getDevelopDate()))) {
|
|| (entity.getDevelopDate() != null && vendor.getDevelopDate().isAfter(entity.getDevelopDate()))) {
|
||||||
@@ -386,16 +381,17 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
holder.info("供应商的开发日期修改为:" + entity.getDevelopDate());
|
holder.info("供应商的开发日期修改为:" + entity.getDevelopDate());
|
||||||
}
|
}
|
||||||
if (vendorModified) {
|
if (vendorModified) {
|
||||||
vendor = vendorService.save(vendor);
|
vendor = getVendorCtx().save(vendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确定 company
|
// 确定 company
|
||||||
if (company == null) {
|
if (companyId == null) {
|
||||||
company = getCompanyCtx().findOrCreateByNameOrAbbName(entity.getName(), entity.getAbbName(),
|
var company = getCompanyCtx().findOrCreateByNameOrAbbName(entity.getName(), entity.getAbbName(),
|
||||||
entity.getDevelopDate(), holder);
|
entity.getDevelopDate(), holder);
|
||||||
|
companyId = company.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateCompany(contract, company, holder)) {
|
if (updateCompanyId(contract, companyId, holder)) {
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,6 +420,19 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean updateCompanyId(ContractVo contract, Integer companyId, MessageHolder holder) {
|
||||||
|
if (companyId == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Objects.equals(contract.getCompanyId(), companyId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
contract.setCompanyId(companyId);
|
||||||
|
var company = getCompanyService().getById(companyId);
|
||||||
|
holder.info("关联至 " + company.getName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private VendorEntityVo updateVendorEntityDetailByCode(VendorEntityVo entity, String unitCode,
|
private VendorEntityVo updateVendorEntityDetailByCode(VendorEntityVo entity, String unitCode,
|
||||||
MessageHolder holder) {
|
MessageHolder holder) {
|
||||||
if (vendorEntityUpdateDelayDays > 0) {
|
if (vendorEntityUpdateDelayDays > 0) {
|
||||||
@@ -458,8 +467,8 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return getCustomerCtx().updateCustomerEntityDetailByCode(entity, unitCode, holder);
|
return getCustomerCtx().updateCustomerEntityDetailByCode(entity, unitCode, holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateCompanyByCustomerUnitCode(Contract contract, String unit, MessageHolder holder) {
|
private boolean updateCompanyByCustomerUnitCode(ContractVo contract, String unit, MessageHolder holder) {
|
||||||
Company company = contract.getCompany();
|
var companyId = contract.getCompanyId();
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
boolean customerModified = false;
|
boolean customerModified = false;
|
||||||
CompanyCustomerEntityService customerEntityService = getCompanyCustomerEntityService();
|
CompanyCustomerEntityService customerEntityService = getCompanyCustomerEntityService();
|
||||||
@@ -474,28 +483,27 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
|
|
||||||
CustomerVo customer = customerService.findById(entity.getCustomerId());
|
CustomerVo customer = customerService.findById(entity.getCustomerId());
|
||||||
if (customer == null) {
|
if (customer == null) {
|
||||||
if (company != null) {
|
if (companyId != null) {
|
||||||
customer = customerService.findByCompany(company).toVo();
|
customer = customerService.findByCompany(getCompanyService().findById(companyId));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (customer.getCompanyId() == null) {
|
if (customer.getCompanyId() == null) {
|
||||||
customer.setCompanyId(company.getId());
|
customer.setCompanyId(companyId);
|
||||||
customerModified = true;
|
customerModified = true;
|
||||||
} else {
|
} else {
|
||||||
if (company == null) {
|
if (companyId == null) {
|
||||||
customer.setCompanyId(company.getId());
|
customer.setCompanyId(null);
|
||||||
} else if (!Objects.equals(company.getId(), customer.getCompanyId())) {
|
} else if (!Objects.equals(companyId, customer.getCompanyId())) {
|
||||||
holder.error(
|
holder.error(
|
||||||
"客户的企业和合同的企业不一致, 客户的企业:" + customer.getCompanyId() + ",合同的企业:" + company.getId());
|
"客户的企业和合同的企业不一致, 客户的企业:#" + customer.getCompanyId() + ",合同的企业:#" + companyId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (customer == null) {
|
if (customer == null) {
|
||||||
CompanyCustomer v1 = new CompanyCustomer();
|
CompanyCustomer v1 = new CompanyCustomer();
|
||||||
if (company != null && !Hibernate.isInitialized(company)) {
|
var company = getCompanyService().getById(companyId);
|
||||||
company = getCompanyService().getById(company.getId());
|
v1.setId(getCachedBean(OldVersionService.class)
|
||||||
}
|
.newCompanyCustomer(companyId == null ? unit : company.getName()));
|
||||||
v1.setId(getCachedBean(OldVersionService.class).newCompanyCustomer(company == null ? unit : company.getName()));
|
|
||||||
v1.setCompany(company);
|
v1.setCompany(company);
|
||||||
|
|
||||||
customer = customerService.save(v1).toVo();
|
customer = customerService.save(v1).toVo();
|
||||||
@@ -512,19 +520,20 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
customer = customerService.save(v0).toVo();
|
customer = customerService.save(v0).toVo();
|
||||||
}
|
}
|
||||||
// 确定 company
|
// 确定 company
|
||||||
if (company == null) {
|
if (companyId == null) {
|
||||||
company = getCompanyCtx().findOrCreateByNameOrAbbName(entity.getName(), entity.getAbbName(),
|
var company = getCompanyCtx().findOrCreateByNameOrAbbName(entity.getName(), entity.getAbbName(),
|
||||||
entity.getDevelopDate(), holder);
|
entity.getDevelopDate(), holder);
|
||||||
|
companyId = company.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateCompany(contract, company, holder)) {
|
if (updateCompanyId(contract, companyId, holder)) {
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updatePayWay(Contract contract, String way, MessageHolder holder) {
|
private boolean updatePayWay(ContractVo contract, String way, MessageHolder holder) {
|
||||||
if (!StringUtils.hasText(way)) {
|
if (!StringUtils.hasText(way)) {
|
||||||
holder.warn("无付款方向");
|
holder.warn("无付款方向");
|
||||||
return false;
|
return false;
|
||||||
@@ -542,69 +551,85 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateTypeByCode(Contract contract, String typeCode, MessageHolder holder) {
|
private boolean updateTypeByCode(ContractVo contract, String typeCode, MessageHolder holder) {
|
||||||
var service = getCachedBean(ContractTypeService.class);
|
var service = getCachedBean(ContractTypeService.class);
|
||||||
var type = service.findByCode(typeCode);
|
var type = service.findByCode(typeCode);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
contract.setType(null);
|
contract.setTypeId(null);
|
||||||
} else {
|
} else {
|
||||||
if (contract.getType() == null || !Objects.equals(contract.getType().getId(), type.getId())) {
|
if (contract.getTypeId() == null) {
|
||||||
contract.setType(service.getById(type.getId()));
|
contract.setTypeId(type.getId());
|
||||||
holder.info("合同类型修改为: " + type.getName());
|
holder.info("合同类型修改为: " + type.getName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(contract.getTypeId(), type.getId())) {
|
||||||
|
contract.setTypeId(type.getId());
|
||||||
|
holder.info("合同类型修改为: " + type.getName());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateGroupByCode(Contract contract, String groupCode, MessageHolder holder) {
|
private boolean updateGroupByCode(ContractVo contract, String groupCode, MessageHolder holder) {
|
||||||
var service = getCachedBean(ContractGroupService.class);
|
var service = getCachedBean(ContractGroupService.class);
|
||||||
var group = service.findByCode(groupCode);
|
var group = service.findByCode(groupCode);
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
contract.setGroup(null);
|
contract.setGroupId(null);
|
||||||
} else {
|
} else {
|
||||||
if (contract.getGroup() == null || !Objects.equals(contract.getGroup().getId(), group.getId())) {
|
if (contract.getGroupId() == null) {
|
||||||
contract.setGroup(service.getById(group.getId()));
|
contract.setGroupId(group.getId());
|
||||||
holder.info("合同分组修改为: " + group.getName());
|
holder.info("合同分组修改为: " + group.getName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(contract.getGroupId(), group.getId())) {
|
||||||
|
contract.setGroupId(group.getId());
|
||||||
|
holder.info("合同分组修改为: " + group.getName());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateKindByCode(Contract contract, String kindName, MessageHolder holder) {
|
private boolean updateKindByCode(ContractVo contract, String kindName, MessageHolder holder) {
|
||||||
var service = getCachedBean(ContractKindService.class);
|
var service = getCachedBean(ContractKindService.class);
|
||||||
var kind = service.findByName(kindName);
|
var kind = service.findByName(kindName);
|
||||||
if (!Objects.equals(contract.getKind(), kind)) {
|
if (kind == null) {
|
||||||
contract.setKind(kind);
|
contract.setKindId(null);
|
||||||
holder.info("合同分类修改为: " + kind.getName());
|
} else {
|
||||||
return true;
|
if (contract.getKindId() == null) {
|
||||||
|
contract.setKindId(kind.getId());
|
||||||
|
holder.info("合同分类修改为: " + kind.getName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(contract.getKindId(), kind.getId())) {
|
||||||
|
contract.setKindId(kind.getId());
|
||||||
|
holder.info("合同分类修改为: " + kind.getName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateEmployeeByCode(Contract contract, String personId, MessageHolder holder) {
|
private boolean updateEmployeeByCode(ContractVo contract, String personId, MessageHolder holder) {
|
||||||
boolean updated = updateEmployeeByCode(contract::getEmployee, contract::setEmployee, personId, holder, "业务员");
|
boolean updated = updateEmployeeIdByCode(contract::getEmployeeId, contract::setEmployeeId, personId, holder,
|
||||||
Employee employee = contract.getEmployee();
|
"业务员");
|
||||||
if (employee == null) {
|
Integer employeeId = contract.getEmployeeId();
|
||||||
|
if (employeeId == null) {
|
||||||
holder.warn("* 合同业务员:" + personId + " 未导入");
|
holder.warn("* 合同业务员:" + personId + " 未导入");
|
||||||
} else {
|
} else {
|
||||||
if (!Hibernate.isInitialized(employee)) {
|
var v1 = getEmployeeService().findById(employeeId);
|
||||||
employee = getEmployeeService().getById(employee.getId());
|
if (!v1.isActive()) {
|
||||||
}
|
holder.warn("业务员 " + v1.getName() + " 已经不可用,其离职日期:" + v1.getLeaveDate());
|
||||||
if (!employee.isActive()) {
|
|
||||||
holder.warn("业务员 " + employee.getName() + " 已经不可用,其离职日期:" + employee.getLeaveDate());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Contract findContractByCode(String contractCode) {
|
|
||||||
|
public ContractVo findContractByCode(String contractCode) {
|
||||||
var service = getContractService();
|
var service = getContractService();
|
||||||
var vo = service.findByCode(contractCode);
|
return service.findByCode(contractCode);
|
||||||
if (vo == null) {
|
|
||||||
// holder.warn("合同 " + contractCode + " 未导入");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return service.getById(vo.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean syncByVendorEntity(Vendor vendor, VendorEntity entity, MessageHolder holder) {
|
public boolean syncByVendorEntity(Vendor vendor, VendorEntity entity, MessageHolder holder) {
|
||||||
@@ -654,17 +679,17 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateContract(String contractID, String guid, MessageHolder holder) {
|
public boolean updateContract(String contractID, String guid, MessageHolder holder) {
|
||||||
Contract contract = findOrCreatByGuidOrContractId(guid, contractID, holder);
|
ContractVo contract = findOrCreatByGuidOrContractId(guid, contractID, holder);
|
||||||
boolean updated = false;
|
boolean updated = false;
|
||||||
boolean modified = applyContractDetail(contract, repository.queryContractDetail(guid), holder);
|
boolean modified = applyContractDetail(contract, repository.queryContractDetail(guid), holder);
|
||||||
if (modified) {
|
if (modified) {
|
||||||
contract = getContractService().save(contract);
|
contract = save(contract);
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Contract findOrCreatByGuidOrContractId(String guid, String contractId, MessageHolder holder) {
|
public ContractVo findOrCreatByGuidOrContractId(String guid, String contractId, MessageHolder holder) {
|
||||||
ContractService service = getContractService();
|
ContractService service = getContractService();
|
||||||
UUID.fromString(guid);
|
UUID.fromString(guid);
|
||||||
ContractVo contract = service.findByGuid(guid);
|
ContractVo contract = service.findByGuid(guid);
|
||||||
@@ -678,29 +703,26 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
v0.setCode(contractId);
|
v0.setCode(contractId);
|
||||||
v0 = service.save(v0);
|
v0 = service.save(v0);
|
||||||
holder.info("新建合同:" + contractId + ", GUID: " + guid);
|
holder.info("新建合同:" + contractId + ", GUID: " + guid);
|
||||||
return v0;
|
return v0.toVo();
|
||||||
} else {
|
|
||||||
return service.getById(contract.getId());
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return service.getById(contract.getId());
|
|
||||||
}
|
}
|
||||||
|
return contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateContract(Map<String, Object> rs, MessageHolder holder) {
|
private boolean updateContract(Map<String, Object> rs, MessageHolder holder) {
|
||||||
String contractID = (String) rs.get("strContractID");
|
String contractID = (String) rs.get("strContractID");
|
||||||
String guid = (String) rs.get("GUID");
|
String guid = (String) rs.get("GUID");
|
||||||
boolean updated = false;
|
boolean updated = false;
|
||||||
Contract contract = findOrCreatByGuidOrContractId(guid, contractID, holder);
|
ContractVo contract = findOrCreatByGuidOrContractId(guid, contractID, holder);
|
||||||
boolean modified = applyContractDetail(contract, rs, holder);
|
boolean modified = applyContractDetail(contract, rs, holder);
|
||||||
if (modified) {
|
if (modified) {
|
||||||
contract = getContractService().save(contract);
|
contract = save(contract);
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateParentContract(Contract contract, MessageHolder holder) {
|
public boolean updateParentContract(ContractVo contract, MessageHolder holder) {
|
||||||
// 如果已经由父合同编号,跳过
|
// 如果已经由父合同编号,跳过
|
||||||
if (StringUtils.hasText(contract.getParentCode())) {
|
if (StringUtils.hasText(contract.getParentCode())) {
|
||||||
return false;
|
return false;
|
||||||
@@ -715,7 +737,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String parentCode = getContractService().getParentCode(contract);
|
String parentCode = getContractService().getParentCode(contract.getCode());
|
||||||
holder.info("尝试查找主合同:" + parentCode);
|
holder.info("尝试查找主合同:" + parentCode);
|
||||||
List<Contract> list = getContractService().findByCodeStartsWith(ContractPayWay.RECEIVE, parentCode);
|
List<Contract> list = getContractService().findByCodeStartsWith(ContractPayWay.RECEIVE, parentCode);
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
@@ -732,7 +754,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return updateText(contract::getCode, contract::setParentCode, parent.getCode(), holder, "主合同");
|
return updateText(contract::getCode, contract::setParentCode, parent.getCode(), holder, "主合同");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateContractExec(Contract contract, MessageHolder holder) {
|
public boolean updateContractExec(ContractVo contract, MessageHolder holder) {
|
||||||
if (repository == null) {
|
if (repository == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -764,7 +786,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
* @param contract 合同
|
* @param contract 合同
|
||||||
* @param holder 消息
|
* @param holder 消息
|
||||||
*/
|
*/
|
||||||
public boolean syncContractItems(Contract contract, MessageHolder holder) {
|
public boolean syncContractItems(ContractVo contract, MessageHolder holder) {
|
||||||
if (repository == null) {
|
if (repository == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -788,7 +810,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
if (contractItem == null) {
|
if (contractItem == null) {
|
||||||
contractItem = new ContractItem();
|
contractItem = new ContractItem();
|
||||||
contractItem.setContract(contract);
|
contractItem.setContract(getContractService().getById(contract.getId()));
|
||||||
contractItem.setRefId(refId);
|
contractItem.setRefId(refId);
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
||||||
@@ -928,7 +950,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean sumItems(Contract contract, Collection<ContractItem> items, MessageHolder holder) {
|
private boolean sumItems(ContractVo contract, Collection<ContractItem> items, MessageHolder holder) {
|
||||||
if (items == null || items.isEmpty()) {
|
if (items == null || items.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -952,7 +974,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateContractPath(Contract contract, MessageHolder holder) {
|
public boolean updateContractPath(ContractVo contract, MessageHolder holder) {
|
||||||
// 如果合同路径存在
|
// 如果合同路径存在
|
||||||
if (CompanyFileUtils.exists(contract.getPath())) {
|
if (CompanyFileUtils.exists(contract.getPath())) {
|
||||||
File dir = new File(contract.getPath());
|
File dir = new File(contract.getPath());
|
||||||
@@ -998,17 +1020,15 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
} else if (contract.getPayWay() == ContractPayWay.RECEIVE) {
|
} else if (contract.getPayWay() == ContractPayWay.RECEIVE) {
|
||||||
// 销售合同
|
// 销售合同
|
||||||
File contractPath = null;
|
File contractPath = null;
|
||||||
Project project = contract.getProject();
|
Integer projectId = contract.getProject();
|
||||||
if (project != null) {
|
if (projectId != null) {
|
||||||
project = getProjectCtx().initialize(project);
|
var projectVo = getProjectCtx().getProjectService().findById(projectId);
|
||||||
ProjectSaleType saleType = project.getSaleType();
|
var saleTypeId = projectVo.getSaleTypeId();
|
||||||
if (saleType != null) {
|
if (saleTypeId != null) {
|
||||||
if (!Hibernate.isInitialized(saleType)) {
|
ProjectSaleTypeVo saleType = getSaleTypeService().findById(saleTypeId);
|
||||||
saleType = getSaleTypeService().getById(saleType.getId());
|
|
||||||
}
|
|
||||||
File dir = new File(saleType.getPath());
|
File dir = new File(saleType.getPath());
|
||||||
if (saleType.isStoreByYear()) {
|
if (saleType.isStoreByYear()) {
|
||||||
dir = new File(dir, "20" + project.getCodeYear());
|
dir = new File(dir, "20" + projectVo.getCodeYear());
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
if (dir.mkdir()) {
|
if (dir.mkdir()) {
|
||||||
holder.info("新建目录 " + dir.getAbsolutePath());
|
holder.info("新建目录 " + dir.getAbsolutePath());
|
||||||
@@ -1021,7 +1041,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
|
|
||||||
// 从关联项目上未取得合同目录,尝试根据合同编码来确定合同目录
|
// 从关联项目上未取得合同目录,尝试根据合同编码来确定合同目录
|
||||||
if (contractPath == null) {
|
if (contractPath == null) {
|
||||||
ContractCatalog catalog = getContractService().findContractCatalogByContract(contract.getCode());
|
ContractCatalogVo catalog = getContractService().findContractCatalogByContract(contract.getCode());
|
||||||
if (catalog != null) {
|
if (catalog != null) {
|
||||||
contractPath = getContractService().getContractCatalogPath(catalog, contract);
|
contractPath = getContractService().getContractCatalogPath(catalog, contract);
|
||||||
}
|
}
|
||||||
@@ -1048,7 +1068,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateContractAmount(Contract contract, MessageHolder holder) {
|
public boolean updateContractAmount(ContractVo contract, MessageHolder holder) {
|
||||||
if (contract.getAmount() == null || contract.getAmount() == 0.0d) {
|
if (contract.getAmount() == null || contract.getAmount() == 0.0d) {
|
||||||
if (contract.getTotalAmount() > 0) {
|
if (contract.getTotalAmount() > 0) {
|
||||||
contract.setAmount(contract.getTotalAmount());
|
contract.setAmount(contract.getTotalAmount());
|
||||||
@@ -1059,17 +1079,22 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateContractProject(Contract contract, Project project, MessageHolder holder) {
|
public boolean updateContractProject(ContractVo contract, ProjectVo project, MessageHolder holder) {
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
|
holder.warn("合同所属项目更新失败,项目不存在");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Objects.equals(contract.getProject(), project)) {
|
if (contract.getProject() == null) {
|
||||||
return false;
|
contract.setProject(project.getId());
|
||||||
|
holder.info("合同所属项目更新为:" + project.getName());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
project = getProjectCtx().initialize(project);
|
if (!Objects.equals(contract.getProject(), project.getId())) {
|
||||||
holder.info("合同所属项目更新为:" + project.getName());
|
holder.info("合同所属项目更新为:" + project.getName());
|
||||||
contract.setProject(project);
|
contract.setProject(project.getId());
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1079,14 +1104,15 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
* @param holder
|
* @param holder
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean updateContractProject(Contract contract, Contract parent, MessageHolder holder) {
|
public boolean updateContractProject(ContractVo contract, ContractVo parent, MessageHolder holder) {
|
||||||
Project project = contract.getProject();
|
Integer projectId = contract.getProject();
|
||||||
if (project == null && parent != null) {
|
if (projectId == null && parent != null) {
|
||||||
// 尝试从父合同中获取项目对象
|
// 尝试从父合同中获取项目对象
|
||||||
project = parent.getProject();
|
projectId = parent.getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project == null) {
|
if (projectId == null) {
|
||||||
|
holder.debug("合同没有关联项目");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1095,41 +1121,43 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
|
|
||||||
ProjectCtx ctx = getProjectCtx();
|
ProjectCtx ctx = getProjectCtx();
|
||||||
|
|
||||||
project = ctx.initialize(project);
|
var projectVo = getProjectCtx().getProjectService().findById(projectId);
|
||||||
if (project.getAmount() == null || project.getAmount() == 0) {
|
if (projectVo.getAmount() == null || projectVo.getAmount() == 0) {
|
||||||
if (ctx.updateNumber(project::getAmount, project::setAmount, contract.getAmount().intValue(), holder,
|
if (ctx.updateNumber(projectVo::getAmount, projectVo::setAmount, contract.getAmount().intValue(), holder,
|
||||||
"项目金额")) {
|
"项目金额")) {
|
||||||
projectModified = true;
|
projectModified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查项目的客户
|
// 检查项目的客户
|
||||||
Company customer = project.getCustomer();
|
Integer customerId = projectVo.getCustomerId();
|
||||||
if (customer == null) {
|
if (customerId == null) {
|
||||||
// 查询合同关联的客户(主合同上的是客户)
|
// 查询合同关联的客户(主合同上的是客户)
|
||||||
if (parent == null) { // 主合同时,parent 为 null
|
if (parent == null) { // 主合同时,parent 为 null
|
||||||
if (contract.getPayWay() == ContractPayWay.RECEIVE) {
|
if (contract.getPayWay() == ContractPayWay.RECEIVE) {
|
||||||
customer = contract.getCompany();
|
customerId = contract.getCompanyId();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
customer = parent.getCompany();
|
customerId = parent.getCompanyId();
|
||||||
if (customer == null) {
|
if (customerId == null) {
|
||||||
holder.warn("合同:" + parent.getCode() + " 没有关联的客户");
|
holder.warn("合同:" + parent.getCode() + " 没有关联的客户");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (customer != null) {
|
if (customerId != null) {
|
||||||
if (ctx.updateCustomer(project, customer, holder)) {
|
if (ctx.updateCustomerId(projectVo, customerId, holder)) {
|
||||||
projectModified = true;
|
projectModified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectModified) {
|
if (projectModified) {
|
||||||
project = ctx.save(project);
|
projectVo = ctx.save(projectVo);
|
||||||
contract.setProject(project);
|
|
||||||
}
|
}
|
||||||
|
if (!Objects.equals(contract.getProject(), projectId)) {
|
||||||
if (updateContractProject(contract, project, holder)) {
|
contract.setProject(projectId);
|
||||||
|
contractModified = true;
|
||||||
|
}
|
||||||
|
if (updateContractProject(contract, projectVo, holder)) {
|
||||||
// 更新项目客户
|
// 更新项目客户
|
||||||
contractModified = true;
|
contractModified = true;
|
||||||
}
|
}
|
||||||
@@ -1137,7 +1165,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return contractModified;
|
return contractModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean syncContractFiles(Contract contract, MessageHolder holder) {
|
public boolean syncContractFiles(ContractVo contract, MessageHolder holder) {
|
||||||
String contractPath = contract.getPath();
|
String contractPath = contract.getPath();
|
||||||
if (!StringUtils.hasText(contractPath)) {
|
if (!StringUtils.hasText(contractPath)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1193,7 +1221,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
}
|
}
|
||||||
// 未记录的文件,存储到 retrieveFiles
|
// 未记录的文件,存储到 retrieveFiles
|
||||||
ContractFile contractFile = new ContractFile();
|
ContractFile contractFile = new ContractFile();
|
||||||
contractFile.setContract(contract);
|
contractFile.setContract(getContractService().getById(contract.getId()));
|
||||||
contractFile.setType(ContractFileType.General);
|
contractFile.setType(ContractFileType.General);
|
||||||
contractFile.setFileName(file.getName());
|
contractFile.setFileName(file.getName());
|
||||||
syncContractFile(contractFile, file, holder);
|
syncContractFile(contractFile, file, holder);
|
||||||
@@ -1279,11 +1307,8 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return Math.max(suggestFileName.length(), value.length());
|
return Math.max(suggestFileName.length(), value.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Contract save(Contract contract) {
|
|
||||||
return getContractService().save(contract);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean syncContractPayPlan(Contract contract, MessageHolder holder) {
|
public boolean syncContractPayPlan(ContractVo contract, MessageHolder holder) {
|
||||||
if (repository == null) {
|
if (repository == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1307,7 +1332,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
if (plan == null) {
|
if (plan == null) {
|
||||||
plan = new ContractPayPlan();
|
plan = new ContractPayPlan();
|
||||||
plan.setContract(contract);
|
plan.setContract(getContractService().getById(contract.getId()));
|
||||||
plan.setRefId(refId);
|
plan.setRefId(refId);
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
||||||
@@ -1367,4 +1392,15 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
}
|
}
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Contract save(Contract contract) {
|
||||||
|
return getContractService().save(contract);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContractVo save(ContractVo contract) {
|
||||||
|
ContractService service = getContractService();
|
||||||
|
Contract v0 = service.getById(contract.getId());
|
||||||
|
service.updateByVo(v0, contract);
|
||||||
|
return service.save(v0).toVo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import java.util.Objects;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.InventoryCatalogVo;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.dao.EmptyResultDataAccessException;
|
import org.springframework.dao.EmptyResultDataAccessException;
|
||||||
@@ -158,8 +159,8 @@ public class InventoryCtx extends AbstractYongYouU8Ctx {
|
|||||||
* @return 是否更新
|
* @return 是否更新
|
||||||
*/
|
*/
|
||||||
private boolean updateInventoryCatalog(Supplier<InventoryCatalog> getter, Consumer<InventoryCatalog> setter,
|
private boolean updateInventoryCatalog(Supplier<InventoryCatalog> getter, Consumer<InventoryCatalog> setter,
|
||||||
String catalogCode, MessageHolder holder, String topic) {
|
String catalogCode, MessageHolder holder, String topic) {
|
||||||
InventoryCatalog catalog = null;
|
InventoryCatalogVo catalog = null;
|
||||||
if (StringUtils.hasText(catalogCode)) {
|
if (StringUtils.hasText(catalogCode)) {
|
||||||
catalog = getInventoryCatalogService().findByCode(catalogCode);
|
catalog = getInventoryCatalogService().findByCode(catalogCode);
|
||||||
}
|
}
|
||||||
@@ -168,11 +169,14 @@ public class InventoryCtx extends AbstractYongYouU8Ctx {
|
|||||||
holder.warn("无效" + topic + ":" + catalogCode);
|
holder.warn("无效" + topic + ":" + catalogCode);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (!Objects.equals(getter.get(), catalog)) {
|
InventoryCatalog v1 = getter.get();
|
||||||
if (!Hibernate.isInitialized(catalog)) {
|
if (v1 == null) {
|
||||||
catalog = getInventoryCatalogService().findByCode(catalogCode);
|
setter.accept(getInventoryCatalogService().getById(catalog.getId()));
|
||||||
}
|
holder.info(topic + "修改为: " + catalog.getName());
|
||||||
setter.accept(catalog);
|
return true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(v1.getId(), catalog.getId())) {
|
||||||
|
setter.accept(getInventoryCatalogService().getById(catalog.getId()));
|
||||||
holder.info(topic + "修改为: " + catalog.getName());
|
holder.info(topic + "修改为: " + catalog.getName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -191,7 +195,7 @@ public class InventoryCtx extends AbstractYongYouU8Ctx {
|
|||||||
* @return 是否更新
|
* @return 是否更新
|
||||||
*/
|
*/
|
||||||
public boolean syncInventoryDetailByCode(Supplier<Inventory> getter, Consumer<Inventory> setter,
|
public boolean syncInventoryDetailByCode(Supplier<Inventory> getter, Consumer<Inventory> setter,
|
||||||
String inventoryCode, MessageHolder holder, String topic) {
|
String inventoryCode, MessageHolder holder, String topic) {
|
||||||
if (!StringUtils.hasText(inventoryCode)) {
|
if (!StringUtils.hasText(inventoryCode)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import com.ecep.contract.vo.PurchaseOrderItemVo;
|
import com.ecep.contract.vo.PurchaseOrderItemVo;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
|||||||
import com.ecep.contract.ds.vendor.model.PurchaseOrderItem;
|
import com.ecep.contract.ds.vendor.model.PurchaseOrderItem;
|
||||||
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||||
@Setter
|
@Setter
|
||||||
@@ -197,12 +199,10 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void syncByContract(Contract contract, MessageHolder holder) {
|
public void syncByContract(ContractVo contract, MessageHolder holder) {
|
||||||
PurchaseBillVoucherService voucherService = getPurchaseBillVoucherService();
|
PurchaseBillVoucherService voucherService = getPurchaseBillVoucherService();
|
||||||
PurchaseBillVoucherItemService voucherItemService = getPurchaseBillVoucherItemService();
|
PurchaseBillVoucherItemService voucherItemService = getPurchaseBillVoucherItemService();
|
||||||
List<PurchaseBillVoucherItem> items = voucherItemService.findAll((root, q, cb) -> {
|
List<PurchaseBillVoucherItem> items = voucherItemService.findAllByContract(contract);
|
||||||
return cb.equal(root.get("contract"), contract);
|
|
||||||
}, Sort.unsorted());
|
|
||||||
|
|
||||||
Map<Integer, PurchaseBillVoucherItem> itemMap = items.stream()
|
Map<Integer, PurchaseBillVoucherItem> itemMap = items.stream()
|
||||||
.collect(Collectors.toMap(PurchaseBillVoucherItem::getRefId, item -> item));
|
.collect(Collectors.toMap(PurchaseBillVoucherItem::getRefId, item -> item));
|
||||||
@@ -408,20 +408,27 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
|||||||
|
|
||||||
boolean updateContractByContractCode(Supplier<Contract> getter, Consumer<Contract> setter, String contractCode,
|
boolean updateContractByContractCode(Supplier<Contract> getter, Consumer<Contract> setter, String contractCode,
|
||||||
MessageHolder holder, String topic) {
|
MessageHolder holder, String topic) {
|
||||||
Contract contract = null;
|
ContractVo contract = null;
|
||||||
if (contractCode != null) {
|
if (StringUtils.hasText(contractCode)) {
|
||||||
contract = getContractCtx().findContractByCode(contractCode);
|
contract = getContractCtx().findContractByCode(contractCode);
|
||||||
}
|
if (contract == null) {
|
||||||
if (contract == null) {
|
holder.warn("无相关记录, " + topic + ":" + contractCode);
|
||||||
setter.accept(null);
|
return false;
|
||||||
holder.warn("无效" + topic + ":" + contractCode);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (!Objects.equals(getter.get(), contract)) {
|
|
||||||
setter.accept(contract);
|
|
||||||
holder.info(topic + "修改为: " + contract.getCode());
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
holder.warn("无效 " + topic + ":" + contractCode);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Contract v1 = getter.get();
|
||||||
|
if (v1 == null) {
|
||||||
|
setter.accept(getContractCtx().getContractService().getById(contract.getId()));
|
||||||
|
holder.info(topic + "修改为: " + contract.getCode());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(v1.getId(), contract.getId())) {
|
||||||
|
setter.accept(getContractCtx().getContractService().getById(contract.getId()));
|
||||||
|
holder.info(topic + "修改为: " + contract.getCode());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
@@ -77,25 +79,21 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
|||||||
return purchaseOrderItemService;
|
return purchaseOrderItemService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PurchaseOrder> syncByContract(Contract contract, MessageHolder holder) {
|
public List<PurchaseOrder> syncByContract(ContractVo contract, MessageHolder holder) {
|
||||||
PurchaseOrdersService ordersService = getPurchaseOrdersService();
|
PurchaseOrdersService ordersService = getPurchaseOrdersService();
|
||||||
PurchaseOrderItemService itemService = getPurchaseOrderItemService();
|
PurchaseOrderItemService itemService = getPurchaseOrderItemService();
|
||||||
|
|
||||||
List<PurchaseOrder> orders = ordersService.findAll((root, q, cb) -> {
|
List<PurchaseOrder> orders = ordersService.findAllByContract(contract);
|
||||||
return cb.equal(root.get("contract"), contract);
|
|
||||||
}, Sort.unsorted());
|
|
||||||
holder.debug("查找到 " + orders.size() + " 条采购订单记录在数据库中");
|
holder.debug("查找到 " + orders.size() + " 条采购订单记录在数据库中");
|
||||||
Map<Integer, PurchaseOrder> ordersMap = orders.stream()
|
Map<Integer, PurchaseOrder> ordersMap = orders.stream()
|
||||||
.collect(Collectors.toMap(PurchaseOrder::getRefId, item -> item));
|
.collect(Collectors.toMap(PurchaseOrder::getRefId, item -> item));
|
||||||
|
|
||||||
List<PurchaseOrderItem> items = itemService.findAll((root, q, cb) -> {
|
|
||||||
return cb.equal(root.get("order").get("contract"), contract);
|
|
||||||
}, Sort.unsorted());
|
|
||||||
|
|
||||||
// 按 order 分组
|
// 按 order 分组
|
||||||
Map<PurchaseOrder, Map<Integer, PurchaseOrderItem>> itemMap = items.stream()
|
Map<PurchaseOrder, Map<Integer, PurchaseOrderItem>> itemMap = orders.stream()
|
||||||
.collect(Collectors.groupingBy(PurchaseOrderItem::getOrder,
|
.collect(Collectors.toMap(Function.identity(), order -> itemService.findAllByOrder(order).stream().collect(
|
||||||
Collectors.toMap(PurchaseOrderItem::getRefId, item -> item)));
|
Collectors.toMap(PurchaseOrderItem::getRefId, item -> item)
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
// 查询 U8 数据库
|
// 查询 U8 数据库
|
||||||
List<Map<String, Object>> ds = repository.findAllPurchaseOrderItemByContractCode(contract.getCode());
|
List<Map<String, Object>> ds = repository.findAllPurchaseOrderItemByContractCode(contract.getCode());
|
||||||
@@ -111,7 +109,7 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
|||||||
PurchaseOrder order = ordersMap.get(poId);
|
PurchaseOrder order = ordersMap.get(poId);
|
||||||
if (order == null) {
|
if (order == null) {
|
||||||
order = new PurchaseOrder();
|
order = new PurchaseOrder();
|
||||||
order.setContract(contract);
|
order.setContract(getCachedBean(ContractService.class).getById(contract.getId()));
|
||||||
order.setRefId(poId);
|
order.setRefId(poId);
|
||||||
|
|
||||||
order = ordersService.save(order);
|
order = ordersService.save(order);
|
||||||
@@ -263,7 +261,7 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean applyPurchaseOrderItemDetail(PurchaseOrderItem item, Map<String, Object> map,
|
private boolean applyPurchaseOrderItemDetail(PurchaseOrderItem item, Map<String, Object> map,
|
||||||
MessageHolder holder) {
|
MessageHolder holder) {
|
||||||
Integer refId = (Integer) map.get("ID");
|
Integer refId = (Integer) map.get("ID");
|
||||||
String inventoryCode = (String) map.get("cInvCode");
|
String inventoryCode = (String) map.get("cInvCode");
|
||||||
String contractCode = (String) map.get("ContractCode");
|
String contractCode = (String) map.get("ContractCode");
|
||||||
@@ -326,7 +324,7 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean updateInventory(Supplier<Inventory> getter, Consumer<Inventory> setter, String inventoryCode,
|
boolean updateInventory(Supplier<Inventory> getter, Consumer<Inventory> setter, String inventoryCode,
|
||||||
MessageHolder holder, String topic) {
|
MessageHolder holder, String topic) {
|
||||||
return getInventoryCtx().syncInventoryDetailByCode(getter, setter, inventoryCode, holder, topic);
|
return getInventoryCtx().syncInventoryDetailByCode(getter, setter, inventoryCode, holder, topic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.contract.service.ContractService;
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
import com.ecep.contract.MessageHolder;
|
import com.ecep.contract.MessageHolder;
|
||||||
@@ -47,23 +50,21 @@ public class SalesOrderCtx extends AbstractYongYouU8Ctx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<SalesOrder> syncByContract(Contract contract, MessageHolder holder) {
|
public List<SalesOrder> syncByContract(ContractVo contract, MessageHolder holder) {
|
||||||
SaleOrdersService saleOrdersService = getSaleOrdersService();
|
SaleOrdersService saleOrdersService = getSaleOrdersService();
|
||||||
SalesOrderItemService orderItemService = getOrderItemService();
|
SalesOrderItemService orderItemService = getOrderItemService();
|
||||||
|
|
||||||
List<SalesOrder> orders = saleOrdersService.findAll((root, q, cb) -> {
|
List<SalesOrder> orders = saleOrdersService.findAllByContract(contract);
|
||||||
return cb.equal(root.get("contract"), contract);
|
|
||||||
}, Sort.unsorted());
|
|
||||||
holder.debug("查找到 " + orders.size() + " 条销售订单记录在数据库中");
|
holder.debug("查找到 " + orders.size() + " 条销售订单记录在数据库中");
|
||||||
Map<String, SalesOrder> ordersMap = orders.stream().collect(Collectors.toMap(SalesOrder::getCode, item -> item));
|
Map<String, SalesOrder> ordersMap = orders.stream().collect(Collectors.toMap(SalesOrder::getCode, item -> item));
|
||||||
|
|
||||||
List<SalesOrderItem> items = orderItemService.findAll((root, q, cb) -> {
|
|
||||||
return cb.equal(root.get("order").get("contract"), contract);
|
|
||||||
}, Sort.unsorted());
|
|
||||||
|
|
||||||
// 按 order 分组
|
// 按 order 分组
|
||||||
Map<SalesOrder, Map<String, SalesOrderItem>> itemMap = items.stream().collect(Collectors.groupingBy(SalesOrderItem::getOrder,
|
Map<SalesOrder, Map<String, SalesOrderItem>> itemMap = orders.stream()
|
||||||
Collectors.toMap(SalesOrderItem::getCode, item -> item)));
|
.collect(
|
||||||
|
Collectors.toMap(Function.identity(), order -> orderItemService.findAllBySaleOrder(order).stream().collect(
|
||||||
|
Collectors.toMap(SalesOrderItem::getCode, item -> item)
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// 查询 U8 数据库
|
// 查询 U8 数据库
|
||||||
List<Map<String, Object>> ds = repository.findAllSalesOrderItemByContractCode(contract.getCode());
|
List<Map<String, Object>> ds = repository.findAllSalesOrderItemByContractCode(contract.getCode());
|
||||||
@@ -79,7 +80,7 @@ public class SalesOrderCtx extends AbstractYongYouU8Ctx {
|
|||||||
SalesOrder order = ordersMap.get(orderCode);
|
SalesOrder order = ordersMap.get(orderCode);
|
||||||
if (order == null) {
|
if (order == null) {
|
||||||
order = new SalesOrder();
|
order = new SalesOrder();
|
||||||
order.setContract(contract);
|
order.setContract(getCachedBean(ContractService.class).getById(contract.getId()));
|
||||||
order.setCode(orderCode);
|
order.setCode(orderCode);
|
||||||
|
|
||||||
order = saleOrdersService.save(order);
|
order = saleOrdersService.save(order);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.util.function.Supplier;
|
|||||||
import com.ecep.contract.ds.vendor.service.VendorCatalogService;
|
import com.ecep.contract.ds.vendor.service.VendorCatalogService;
|
||||||
import com.ecep.contract.vo.VendorCatalogVo;
|
import com.ecep.contract.vo.VendorCatalogVo;
|
||||||
import com.ecep.contract.vo.VendorEntityVo;
|
import com.ecep.contract.vo.VendorEntityVo;
|
||||||
|
import com.ecep.contract.vo.VendorVo;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@@ -332,4 +333,10 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public VendorVo save(VendorVo vendor) {
|
||||||
|
VendorService service = getCompanyVendorService();
|
||||||
|
Vendor v0 = service.getById(vendor.getId());
|
||||||
|
service.updateByVo(v0, vendor);
|
||||||
|
return service.save(v0).toVo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,7 @@ public interface ContractFileRepository extends JpaRepository<ContractFile, Inte
|
|||||||
|
|
||||||
List<ContractFile> findAllByContract(Contract contract);
|
List<ContractFile> findAllByContract(Contract contract);
|
||||||
|
|
||||||
|
List<ContractFile> findAllByContractId(Integer contractId);
|
||||||
|
|
||||||
List<ContractFile> findAllByContractAndType(Contract contract, ContractFileType type);
|
List<ContractFile> findAllByContractAndType(Contract contract, ContractFileType type);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ecep.contract.ds.contract.repository;
|
package com.ecep.contract.ds.contract.repository;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
@@ -8,12 +9,11 @@ import org.springframework.stereotype.Repository;
|
|||||||
|
|
||||||
import com.ecep.contract.ds.vendor.model.PurchaseBillVoucherItem;
|
import com.ecep.contract.ds.vendor.model.PurchaseBillVoucherItem;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface PurchaseBillVoucherItemRepository extends
|
public interface PurchaseBillVoucherItemRepository extends
|
||||||
// JDBC interfaces
|
MyRepository<PurchaseBillVoucherItem, Integer> {
|
||||||
CrudRepository<PurchaseBillVoucherItem, Integer>,
|
|
||||||
PagingAndSortingRepository<PurchaseBillVoucherItem, Integer>,
|
|
||||||
// JPA interfaces
|
|
||||||
JpaRepository<PurchaseBillVoucherItem, Integer>, JpaSpecificationExecutor<PurchaseBillVoucherItem> {
|
|
||||||
|
|
||||||
|
List<PurchaseBillVoucherItem> findAllByContractId(Integer contractId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public interface PurchaseOrderRepository extends
|
|||||||
Optional<PurchaseOrder> findByRefId(Integer refId);
|
Optional<PurchaseOrder> findByRefId(Integer refId);
|
||||||
|
|
||||||
List<PurchaseOrder> findAllByContract(Contract contract);
|
List<PurchaseOrder> findAllByContract(Contract contract);
|
||||||
|
List<PurchaseOrder> findAllByContractId(Integer contractId);
|
||||||
|
|
||||||
List<PurchaseOrder> findByCodeStartsWith(String code);
|
List<PurchaseOrder> findByCodeStartsWith(String code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public interface SalesOrderRepository extends MyRepository<SalesOrder, Integer>
|
|||||||
Optional<SalesOrder> findByCode(String code);
|
Optional<SalesOrder> findByCode(String code);
|
||||||
|
|
||||||
List<SalesOrder> findAllByContract(Contract contract);
|
List<SalesOrder> findAllByContract(Contract contract);
|
||||||
|
List<SalesOrder> findAllByContractId(Integer contractId);
|
||||||
|
|
||||||
List<SalesOrder> findByCodeStartsWith(String code);
|
List<SalesOrder> findByCodeStartsWith(String code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ public class ContractCatalogService implements IEntityService<ContractCatalog>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'code-'+#p0")
|
@Cacheable(key = "'code-'+#p0")
|
||||||
public ContractCatalog findByCode(String code) {
|
public ContractCatalogVo findByCode(String code) {
|
||||||
return repository.findByCode(code).orElse(null);
|
return repository.findByCode(code).map(ContractCatalog::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'catalogs'")
|
@Cacheable(key = "'catalogs'")
|
||||||
public List<ContractCatalog> findAll() {
|
public List<ContractCatalogVo> findAll() {
|
||||||
return repository.findAll();
|
return repository.findAll().stream().map(ContractCatalog::toVo).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.ecep.contract.ds.contract.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -166,6 +167,11 @@ public class ContractFileService implements IEntityService<ContractFile>, QueryS
|
|||||||
return contractFileRepository.findAllByContract(contract).stream().map(ContractFile::toVo).toList();
|
return contractFileRepository.findAllByContract(contract).stream().map(ContractFile::toVo).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "'allbycontract-'+#p0.id")
|
||||||
|
public List<ContractFileVo> findAllByContract(ContractVo contract) {
|
||||||
|
return contractFileRepository.findAllByContractId(contract.getId()).stream().map(ContractFile::toVo).toList();
|
||||||
|
}
|
||||||
|
|
||||||
public List<ContractFile> searchByContract(Contract contract, String userText) {
|
public List<ContractFile> searchByContract(Contract contract, String userText) {
|
||||||
Specification<ContractFile> spec = (root, query, builder) -> {
|
Specification<ContractFile> spec = (root, query, builder) -> {
|
||||||
return builder.and(
|
return builder.and(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.contract.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -98,6 +99,10 @@ public class ContractItemService implements IEntityService<ContractItem>, QueryS
|
|||||||
return itemRepository.findByContractId(contract.getId());
|
return itemRepository.findByContractId(contract.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ContractItem> findAllByContract(ContractVo contract) {
|
||||||
|
return itemRepository.findByContractId(contract.getId());
|
||||||
|
}
|
||||||
|
|
||||||
public List<ContractItem> findAllByInventory(Inventory inventory) {
|
public List<ContractItem> findAllByInventory(Inventory inventory) {
|
||||||
return itemRepository.findByInventoryId(inventory.getId());
|
return itemRepository.findByInventoryId(inventory.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.contract.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
@@ -74,8 +75,8 @@ public class ContractPayPlanService implements IEntityService<ContractPayPlan>,
|
|||||||
return findAll(spec, pageable).map(ContractPayPlan::toVo);
|
return findAll(spec, pageable).map(ContractPayPlan::toVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ContractPayPlan> findAllByContract(Contract contract) {
|
public List<ContractPayPlan> findAllByContract(ContractVo contract) {
|
||||||
return repository.findAllByContract(contract);
|
return repository.findAllByContractId(contract.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.util.Objects;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractCatalogVo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -149,7 +150,7 @@ public class ContractService extends EntityService<Contract, ContractVo, Integer
|
|||||||
/**
|
/**
|
||||||
* 返回合同的分类目录
|
* 返回合同的分类目录
|
||||||
*/
|
*/
|
||||||
public File getContractCatalogPath(ContractCatalog catalog, Contract contract) {
|
public File getContractCatalogPath(ContractCatalogVo catalog, ContractVo contract) {
|
||||||
String parent = catalog.getParent();
|
String parent = catalog.getParent();
|
||||||
File dir = getBasePath();
|
File dir = getBasePath();
|
||||||
if (StringUtils.hasText(parent)) {
|
if (StringUtils.hasText(parent)) {
|
||||||
@@ -186,7 +187,7 @@ public class ContractService extends EntityService<Contract, ContractVo, Integer
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getContractCatalogPath(ContractCatalog catalog, ContractVo contract) {
|
public File getContractCatalogPath(ContractCatalogVo catalog, Contract contract) {
|
||||||
String parent = catalog.getParent();
|
String parent = catalog.getParent();
|
||||||
File dir = getBasePath();
|
File dir = getBasePath();
|
||||||
if (StringUtils.hasText(parent)) {
|
if (StringUtils.hasText(parent)) {
|
||||||
@@ -226,7 +227,7 @@ public class ContractService extends EntityService<Contract, ContractVo, Integer
|
|||||||
/**
|
/**
|
||||||
* 查找合同的分类
|
* 查找合同的分类
|
||||||
*/
|
*/
|
||||||
public ContractCatalog findContractCatalogByContract(String contractCode) {
|
public ContractCatalogVo findContractCatalogByContract(String contractCode) {
|
||||||
if (!StringUtils.hasText(contractCode)) {
|
if (!StringUtils.hasText(contractCode)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -341,16 +342,18 @@ public class ContractService extends EntityService<Contract, ContractVo, Integer
|
|||||||
return code.contains("-");
|
return code.contains("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSubContract(ContractVo contract) {
|
||||||
|
return isSubContractCode(contract.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSubContract(Contract contract) {
|
public boolean isSubContract(Contract contract) {
|
||||||
return isSubContractCode(contract.getCode());
|
return isSubContractCode(contract.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParentCode(Contract contract) {
|
public String getParentCode(String contractCode) {
|
||||||
String code = contract.getCode();
|
int index = contractCode.indexOf("-");
|
||||||
|
|
||||||
int index = code.indexOf("-");
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
return code.substring(0, index);
|
return contractCode.substring(0, index);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -362,7 +365,7 @@ public class ContractService extends EntityService<Contract, ContractVo, Integer
|
|||||||
if (!isSubContract(contract)) {
|
if (!isSubContract(contract)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String parentCode = getParentCode(contract);
|
String parentCode = getParentCode(contract.getCode());
|
||||||
// fixed
|
// fixed
|
||||||
if (Objects.equals(contract.getParentCode(), parentCode)) {
|
if (Objects.equals(contract.getParentCode(), parentCode)) {
|
||||||
// 已经相同,跳过
|
// 已经相同,跳过
|
||||||
@@ -422,6 +425,10 @@ public class ContractService extends EntityService<Contract, ContractVo, Integer
|
|||||||
return contractRepository.findAllByParentCode(contract.getCode());
|
return contractRepository.findAllByParentCode(contract.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Contract> findAllByParent(ContractVo contract) {
|
||||||
|
return contractRepository.findAllByParentCode(contract.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
public List<Contract> findByCodeStartsWith(ContractPayWay payWay, String parentCode) {
|
public List<Contract> findByCodeStartsWith(ContractPayWay payWay, String parentCode) {
|
||||||
return contractRepository.findByPayWayAndCodeStartsWith(payWay, parentCode);
|
return contractRepository.findByPayWayAndCodeStartsWith(payWay, parentCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.contract.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
@@ -100,4 +101,8 @@ public class PurchaseBillVoucherItemService
|
|||||||
model.setPrice(vo.getPrice());
|
model.setPrice(vo.getPrice());
|
||||||
model.setDescription(vo.getDescription());
|
model.setDescription(vo.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PurchaseBillVoucherItem> findAllByContract(ContractVo contract) {
|
||||||
|
return repository.findAllByContractId(contract.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.contract.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -142,4 +143,8 @@ public class PurchaseOrderItemService implements IEntityService<PurchaseOrderIte
|
|||||||
model.setInventory(SpringApp.getBean(InventoryService.class).getById(vo.getInventoryId()));
|
model.setInventory(SpringApp.getBean(InventoryService.class).getById(vo.getInventoryId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PurchaseOrderItem> findAllByOrder(PurchaseOrder order) {
|
||||||
|
return repository.findAllByOrder(order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.contract.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -137,6 +138,10 @@ public class PurchaseOrdersService implements IEntityService<PurchaseOrder>, Que
|
|||||||
return repository.findAllByContract(contract);
|
return repository.findAllByContract(contract);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PurchaseOrder> findAllByContract(ContractVo contract) {
|
||||||
|
return repository.findAllByContractId(contract.getId());
|
||||||
|
}
|
||||||
|
|
||||||
public List<PurchaseOrder> search(String searchText) {
|
public List<PurchaseOrder> search(String searchText) {
|
||||||
Specification<PurchaseOrder> spec = (root, query, builder) -> {
|
Specification<PurchaseOrder> spec = (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.contract.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -143,4 +144,8 @@ public class SaleOrdersService extends EntityService<SalesOrder, SalesOrderVo, I
|
|||||||
public List<SalesOrder> findAllByContract(Contract contract) {
|
public List<SalesOrder> findAllByContract(Contract contract) {
|
||||||
return repository.findAllByContract(contract);
|
return repository.findAllByContract(contract);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SalesOrder> findAllByContract(ContractVo contract) {
|
||||||
|
return repository.findAllByContractId(contract.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
package com.ecep.contract.ds.contract.service;
|
package com.ecep.contract.ds.contract.service;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.customer.model.SalesOrder;
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -21,6 +24,8 @@ import com.ecep.contract.util.SpecificationUtils;
|
|||||||
import com.ecep.contract.vo.SalesOrderItemVo;
|
import com.ecep.contract.vo.SalesOrderItemVo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "contract-sale-order-item")
|
@CacheConfig(cacheNames = "contract-sale-order-item")
|
||||||
@@ -108,4 +113,14 @@ public class SalesOrderItemService extends EntityService<SalesOrderItem, SalesOr
|
|||||||
model.setOrder(SpringApp.getBean(SaleOrdersService.class).getById(vo.getOrderId()));
|
model.setOrder(SpringApp.getBean(SaleOrdersService.class).getById(vo.getOrderId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SalesOrderItem> findAllByContract(ContractVo contract) {
|
||||||
|
return repository.findAll((root, q, cb) -> {
|
||||||
|
return cb.equal(root.get("order").get("contract").get("id"), contract.getId());
|
||||||
|
}, Sort.unsorted());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SalesOrderItem> findAllBySaleOrder(SalesOrder order) {
|
||||||
|
return repository.findAllByOrder(order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import java.util.Objects;
|
|||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.ecep.contract.ds.project.service.ProjectService;
|
||||||
|
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.jdbc.CannotGetJdbcConnectionException;
|
import org.springframework.jdbc.CannotGetJdbcConnectionException;
|
||||||
@@ -106,7 +108,7 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
|||||||
String state = (String) rs.get("strState");
|
String state = (String) rs.get("strState");
|
||||||
|
|
||||||
holder.info("同步合同 " + contractID + " " + contractName);
|
holder.info("同步合同 " + contractID + " " + contractName);
|
||||||
Contract contract = contractCtx.findOrCreatByGuidOrContractId(guid, contractID, holder);
|
ContractVo contract = contractCtx.findOrCreatByGuidOrContractId(guid, contractID, holder);
|
||||||
if (contract == null) {
|
if (contract == null) {
|
||||||
holder.warn("未知合同" + contractID + ", " + rs.get("strContractName"));
|
holder.warn("未知合同" + contractID + ", " + rs.get("strContractName"));
|
||||||
return false;
|
return false;
|
||||||
@@ -143,17 +145,17 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (modified) {
|
if (modified) {
|
||||||
contract = contractCtx.save(contract);
|
contract = save(contract);
|
||||||
}
|
}
|
||||||
|
|
||||||
Contract parent = null;
|
ContractVo parent = null;
|
||||||
|
|
||||||
if (contract.getPayWay() == ContractPayWay.PAY) {
|
if (contract.getPayWay() == ContractPayWay.PAY) {
|
||||||
if (StringUtils.hasText(contract.getParentCode())) {
|
if (StringUtils.hasText(contract.getParentCode())) {
|
||||||
parent = contractCtx.findContractByCode(contract.getParentCode());
|
parent = contractCtx.findContractByCode(contract.getParentCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AtomicReference<Contract> refer = new AtomicReference<>(contract);
|
AtomicReference<ContractVo> refer = new AtomicReference<>(contract);
|
||||||
try {
|
try {
|
||||||
return repair(refer, parent, holder, progress -> {
|
return repair(refer, parent, holder, progress -> {
|
||||||
});
|
});
|
||||||
@@ -163,6 +165,10 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ContractVo save(ContractVo contract) {
|
||||||
|
return contractCtx.save(contract);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param contractProperty
|
* @param contractProperty
|
||||||
* @param holder
|
* @param holder
|
||||||
@@ -170,11 +176,11 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean repair(
|
public boolean repair(
|
||||||
AtomicReference<Contract> contractProperty,
|
AtomicReference<ContractVo> contractProperty,
|
||||||
Contract parent, MessageHolder holder, Consumer<Double> progress) {
|
ContractVo parent, MessageHolder holder, Consumer<Double> progress) {
|
||||||
boolean repaired = false;
|
boolean repaired = false;
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
Contract contract = contractProperty.get();
|
ContractVo contract = contractProperty.get();
|
||||||
|
|
||||||
progress.accept(0.1);
|
progress.accept(0.1);
|
||||||
if (contractCtx.updateContractDetailByGuid(contract, contract.getGuid(), holder)) {
|
if (contractCtx.updateContractDetailByGuid(contract, contract.getGuid(), holder)) {
|
||||||
@@ -197,7 +203,7 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
|||||||
}
|
}
|
||||||
progress.accept(0.5);
|
progress.accept(0.5);
|
||||||
if (modified) {
|
if (modified) {
|
||||||
contract = contractCtx.save(contract);
|
contract = save(contract);
|
||||||
contractProperty.set(contract);
|
contractProperty.set(contract);
|
||||||
modified = false;
|
modified = false;
|
||||||
repaired = true;
|
repaired = true;
|
||||||
@@ -216,7 +222,7 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
|||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
if (modified) {
|
if (modified) {
|
||||||
contract = contractCtx.save(contract);
|
contract = save(contract);
|
||||||
contractProperty.set(contract);
|
contractProperty.set(contract);
|
||||||
modified = false;
|
modified = false;
|
||||||
repaired = true;
|
repaired = true;
|
||||||
@@ -239,38 +245,38 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
|||||||
return repaired;
|
return repaired;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncChildrenContract(Contract parent, MessageHolder holder, Consumer<Double> progress) {
|
private void syncChildrenContract(ContractVo parent, MessageHolder holder, Consumer<Double> progress) {
|
||||||
ContractService contractService = contractCtx.getContractService();
|
ContractService contractService = contractCtx.getContractService();
|
||||||
|
ProjectService projectService = getCachedBean(ProjectService.class);
|
||||||
List<Contract> list = contractService.findAllByParent(parent);
|
List<Contract> list = contractService.findAllByParent(parent);
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
Contract v = list.get(i);
|
Contract v0 = list.get(i);
|
||||||
holder.info("子合同 : " + v.getCode() + " " + v.getName());
|
ContractVo v1 = v0.toVo();
|
||||||
|
holder.info("子合同 : " + v1.getCode() + " " + v1.getName());
|
||||||
MessageHolder subHolder = holder.sub(" -- ");
|
MessageHolder subHolder = holder.sub(" -- ");
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
Project project = parent.getProject();
|
Integer projectId = parent.getProject();
|
||||||
if (project == null) {
|
if (projectId == null) {
|
||||||
project = v.getProject();
|
projectId = v1.getProject();
|
||||||
}
|
}
|
||||||
AtomicReference<Contract> contractProperty = new AtomicReference<>(v);
|
AtomicReference<ContractVo> contractProperty = new AtomicReference<>(v1);
|
||||||
try {
|
try {
|
||||||
repair(contractProperty, parent, subHolder, p -> {
|
repair(contractProperty, parent, subHolder, p -> {
|
||||||
});
|
});
|
||||||
|
v1 = contractProperty.get();
|
||||||
|
|
||||||
v = contractProperty.get();
|
var projectVo = projectService.findById(projectId);
|
||||||
if (contractCtx.updateContractProject(v, project, subHolder)) {
|
if (contractCtx.updateContractProject(v1, projectVo, subHolder)) {
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (!Hibernate.isInitialized(v)) {
|
throw new RuntimeException("同步子合同失败, 合同b编号:" + v1.getCode(), e);
|
||||||
v = contractService.getById(v.getId());
|
|
||||||
}
|
|
||||||
throw new RuntimeException("同步子合同失败, contract=" + v.toPrettyString(), e);
|
|
||||||
}
|
}
|
||||||
if (modified) {
|
if (modified) {
|
||||||
try {
|
try {
|
||||||
v = contractCtx.save(v);
|
v1 = save(v1);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("#" + v.getId() + ", v=" + v.getVersion(), e);
|
throw new RuntimeException("#" + v1.getId() + ", ver=" + v1.getVersion(), e);
|
||||||
}
|
}
|
||||||
modified = false;
|
modified = false;
|
||||||
}
|
}
|
||||||
@@ -284,7 +290,7 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
|||||||
* @param contract 合同
|
* @param contract 合同
|
||||||
* @param holder 消息
|
* @param holder 消息
|
||||||
*/
|
*/
|
||||||
private void syncSaleOrder(Contract contract, MessageHolder holder) {
|
private void syncSaleOrder(ContractVo contract, MessageHolder holder) {
|
||||||
SalesOrderCtx ctx = getSalesOrderCtx();
|
SalesOrderCtx ctx = getSalesOrderCtx();
|
||||||
if (ctx.getRepository() == null) {
|
if (ctx.getRepository() == null) {
|
||||||
return;
|
return;
|
||||||
@@ -305,10 +311,13 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
|||||||
* @param contract 合同
|
* @param contract 合同
|
||||||
* @param holder 消息
|
* @param holder 消息
|
||||||
*/
|
*/
|
||||||
private void syncPurchaseOrder(Contract contract, MessageHolder holder) {
|
private void syncPurchaseOrder(ContractVo contract, MessageHolder holder) {
|
||||||
PurchaseOrderCtx ctx1 = getPurchaseOrderCtx();
|
PurchaseOrderCtx ctx1 = getPurchaseOrderCtx();
|
||||||
if (ctx1.getRepository() != null) {
|
if (ctx1.getRepository() != null) {
|
||||||
ctx1.syncByContract(contract, holder);
|
List<PurchaseOrder> orders = ctx1.syncByContract(contract, holder);
|
||||||
|
if (orders == null) {
|
||||||
|
holder.warn("没有采购订单异常");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PurchaseBillVoucherCtx ctx2 = getPurchaseBillVoucherCtx();
|
PurchaseBillVoucherCtx ctx2 = getPurchaseBillVoucherCtx();
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class ContractFilesRebuildAllTasker extends Tasker<Object> {
|
|||||||
}
|
}
|
||||||
MessageHolder subHolder = holder.sub(
|
MessageHolder subHolder = holder.sub(
|
||||||
counter.get() + " / " + total + "> " + contract.getCode() + " #" + contract.getId() + "> ");
|
counter.get() + " / " + total + "> " + contract.getCode() + " #" + contract.getId() + "> ");
|
||||||
getContractCtx().syncContractFiles(contract, subHolder);
|
getContractCtx().syncContractFiles(contract.toVo(), subHolder);
|
||||||
updateProgress(counter.incrementAndGet(), total);
|
updateProgress(counter.incrementAndGet(), total);
|
||||||
}
|
}
|
||||||
if (!page.hasNext()) {
|
if (!page.hasNext()) {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class ContractFilesRebuildTasker extends Tasker<Object> {
|
|||||||
updateTitle("遍历合同的文件进行“重置”操作");
|
updateTitle("遍历合同的文件进行“重置”操作");
|
||||||
|
|
||||||
ContractCtx contractCtx = new ContractCtx();
|
ContractCtx contractCtx = new ContractCtx();
|
||||||
if (contractCtx.syncContractFiles(contract, holder)) {
|
if (contractCtx.syncContractFiles(contract.toVo(), holder)) {
|
||||||
repaired = true;
|
repaired = true;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -70,21 +71,22 @@ public class ContractRepairAllTasker extends AbstContractRepairTasker {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Contract contract : page) {
|
for (Contract c : page) {
|
||||||
if (isCancelled()) {
|
if (isCancelled()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
var contract = c.toVo();
|
||||||
MessageHolder subHolder = holder.sub(
|
MessageHolder subHolder = holder.sub(
|
||||||
counter.get() + " / " + total + "> " + contract.getCode() + " #" + contract.getId() + "> ");
|
counter.get() + " / " + total + "> " + contract.getCode() + " #" + contract.getId() + "> ");
|
||||||
MessageHolderImpl messageHolder = new MessageHolderImpl();
|
MessageHolderImpl messageHolder = new MessageHolderImpl();
|
||||||
try {
|
try {
|
||||||
Contract parent = null;
|
ContractVo parent = null;
|
||||||
if (contract.getPayWay() == ContractPayWay.PAY) {
|
if (contract.getPayWay() == ContractPayWay.PAY) {
|
||||||
if (StringUtils.hasText(contract.getParentCode())) {
|
if (StringUtils.hasText(contract.getParentCode())) {
|
||||||
parent = contractCtx.findContractByCode(contract.getParentCode());
|
parent = contractCtx.findContractByCode(contract.getParentCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AtomicReference<Contract> contractProperty = new AtomicReference<>(contract);
|
AtomicReference<ContractVo> contractProperty = new AtomicReference<>(contract);
|
||||||
boolean repaired = repair(contractProperty, parent, messageHolder, progress -> {
|
boolean repaired = repair(contractProperty, parent, messageHolder, progress -> {
|
||||||
});
|
});
|
||||||
String msg = messageHolder.messages.stream()
|
String msg = messageHolder.messages.stream()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import static com.ecep.contract.SpringApp.getBean;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ContractCatalogVo;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.MessageHolder;
|
import com.ecep.contract.MessageHolder;
|
||||||
@@ -119,7 +120,7 @@ public class ContractRepairComm {
|
|||||||
parentDir = new File(parentPath);
|
parentDir = new File(parentPath);
|
||||||
} else {
|
} else {
|
||||||
// 主合同
|
// 主合同
|
||||||
ContractCatalog catalog = getContractService().findContractCatalogByContract(contract.getCode());
|
ContractCatalogVo catalog = getContractService().findContractCatalogByContract(contract.getCode());
|
||||||
if (catalog == null) {
|
if (catalog == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
package com.ecep.contract.ds.customer.repository;
|
package com.ecep.contract.ds.customer.repository;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import com.ecep.contract.ds.MyRepository;
|
import com.ecep.contract.ds.MyRepository;
|
||||||
import com.ecep.contract.ds.company.model.Company;
|
import com.ecep.contract.ds.company.model.Company;
|
||||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||||
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface CompanyCustomerRepository extends MyRepository<CompanyCustomer, Integer> {
|
public interface CompanyCustomerRepository extends MyRepository<CompanyCustomer, Integer> {
|
||||||
|
|
||||||
Optional<CompanyCustomer> findByCompany(Company company);
|
Optional<CompanyCustomer> findByCompany(Company company);
|
||||||
|
|
||||||
|
Optional<CompanyCustomer> findByCompanyId(Integer companyId);
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
int deleteAllByCompany(Company company);
|
int deleteAllByCompany(Company company);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.util.Optional;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.CompanyVo;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -80,6 +81,11 @@ public class CustomerService extends CompanyBasicService
|
|||||||
return repository.findByCompany(company).orElse(null);
|
return repository.findByCompany(company).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CustomerVo findByCompany(CompanyVo company) {
|
||||||
|
return repository.findByCompanyId(company.getId()).map(CompanyCustomer::toVo).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompanyCustomer getById(Integer id) {
|
public CompanyCustomer getById(Integer id) {
|
||||||
return repository.findById(id).orElse(null);
|
return repository.findById(id).orElse(null);
|
||||||
@@ -193,7 +199,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file,
|
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file,
|
||||||
Consumer<String> status) {
|
Consumer<String> status) {
|
||||||
dbFile.setType((T) CustomerFileType.General);
|
dbFile.setType((T) CustomerFileType.General);
|
||||||
fillFile(dbFile, file, null, status);
|
fillFile(dbFile, file, null, status);
|
||||||
companyCustomerFileService.save((CompanyCustomerFile) dbFile);
|
companyCustomerFileService.save((CompanyCustomerFile) dbFile);
|
||||||
@@ -202,7 +208,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsEvaluationFile(F customerFile, File file,
|
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsEvaluationFile(F customerFile, File file,
|
||||||
List<File> fileList, Consumer<String> status) {
|
List<File> fileList, Consumer<String> status) {
|
||||||
boolean modified = super.fillFileAsEvaluationFile(customerFile, file, fileList, status);
|
boolean modified = super.fillFileAsEvaluationFile(customerFile, file, fileList, status);
|
||||||
|
|
||||||
if (fileList != null) {
|
if (fileList != null) {
|
||||||
@@ -236,7 +242,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <T, F extends CompanyBasicFile<T>> void updateEvaluationFileByJsonFile(F customerFile, File jsonFile,
|
private <T, F extends CompanyBasicFile<T>> void updateEvaluationFileByJsonFile(F customerFile, File jsonFile,
|
||||||
Consumer<String> status) throws IOException {
|
Consumer<String> status) throws IOException {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
JsonNode root = objectMapper.readTree(jsonFile);
|
JsonNode root = objectMapper.readTree(jsonFile);
|
||||||
if (!root.isObject()) {
|
if (!root.isObject()) {
|
||||||
@@ -262,7 +268,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
|
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
|
||||||
Consumer<String> status) {
|
Consumer<String> status) {
|
||||||
CompanyCustomerFile customerFile = new CompanyCustomerFile();
|
CompanyCustomerFile customerFile = new CompanyCustomerFile();
|
||||||
customerFile.setType(CustomerFileType.General);
|
customerFile.setType(CustomerFileType.General);
|
||||||
if (fillFile(customerFile, file, fileList, status)) {
|
if (fillFile(customerFile, file, fileList, status)) {
|
||||||
@@ -286,7 +292,7 @@ public class CustomerService extends CompanyBasicService
|
|||||||
return (fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME1)
|
return (fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME1)
|
||||||
|| fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME2))
|
|| fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME2))
|
||||||
&& (FileUtils.withExtensions(fileName, FileUtils.JPG, FileUtils.JPEG,
|
&& (FileUtils.withExtensions(fileName, FileUtils.JPG, FileUtils.JPEG,
|
||||||
FileUtils.PDF));
|
FileUtils.PDF));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean makePathAbsent(CompanyCustomer companyCustomer) {
|
public boolean makePathAbsent(CompanyCustomer companyCustomer) {
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ public class InventoryCatalogService implements IEntityService<InventoryCatalog>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'code-'+#p0")
|
@Cacheable(key = "'code-'+#p0")
|
||||||
public InventoryCatalog findByCode(String code) {
|
public InventoryCatalogVo findByCode(String code) {
|
||||||
return repository.findByCode(code).orElse(null);
|
return repository.findByCode(code).map(InventoryCatalog::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'name-'+#p0")
|
@Cacheable(key = "'name-'+#p0")
|
||||||
public InventoryCatalog findByName(String name) {
|
public InventoryCatalogVo findByName(String name) {
|
||||||
return repository.findByName(name).orElse(null);
|
return repository.findByName(name).map(InventoryCatalog::toVo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.project;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.ProjectVo;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
|
|
||||||
import com.ecep.contract.MessageHolder;
|
import com.ecep.contract.MessageHolder;
|
||||||
@@ -13,15 +14,9 @@ import com.ecep.contract.ds.project.model.Project;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
public class ProjectCtx extends AbstractCtx {
|
public class ProjectCtx extends AbstractCtx {
|
||||||
@Setter
|
|
||||||
private ProjectService projectService;
|
|
||||||
|
|
||||||
|
public ProjectService getProjectService() {
|
||||||
ProjectService getProjectService() {
|
return getCachedBean(ProjectService.class);
|
||||||
if (projectService == null) {
|
|
||||||
projectService = getBean(ProjectService.class);
|
|
||||||
}
|
|
||||||
return projectService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateCustomer(Project project, Company customer, MessageHolder holder) {
|
public boolean updateCustomer(Project project, Company customer, MessageHolder holder) {
|
||||||
@@ -38,14 +33,27 @@ public class ProjectCtx extends AbstractCtx {
|
|||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project initialize(Project project) {
|
public boolean updateCustomerId(ProjectVo project, Integer customerId, MessageHolder holder) {
|
||||||
if (Hibernate.isInitialized(project)) {
|
boolean modified = false;
|
||||||
return project;
|
if (!Objects.equals(project.getCustomerId(), customerId)) {
|
||||||
|
project.setCustomerId(customerId);
|
||||||
|
var customer = getCompanyService().findById(customerId);
|
||||||
|
holder.info("同步合同所属项目客户为:" + customer.getName());
|
||||||
|
modified = true;
|
||||||
}
|
}
|
||||||
return getProjectService().getById(project.getId());
|
|
||||||
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Project save(Project project) {
|
public Project save(Project project) {
|
||||||
return getProjectService().save(project);
|
return getProjectService().save(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProjectVo save(ProjectVo project) {
|
||||||
|
ProjectService service = getProjectService();
|
||||||
|
var v0 = service.getById(project.getId());
|
||||||
|
service.updateByVo(v0, project);
|
||||||
|
return service.save(v0).toVo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,15 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
|
|||||||
model.setDescription(vo.getDescription());
|
model.setDescription(vo.getDescription());
|
||||||
model.setImportLock(vo.isImportLock());
|
model.setImportLock(vo.isImportLock());
|
||||||
|
|
||||||
|
model.setInTaxAmount(vo.getInTaxAmount());
|
||||||
|
model.setInQuantities(vo.getInQuantities());
|
||||||
|
model.setInExclusiveTaxAmount(vo.getInExclusiveTaxAmount());
|
||||||
|
model.setOutTaxAmount(vo.getOutTaxAmount());
|
||||||
|
model.setOutQuantities(vo.getOutQuantities());
|
||||||
|
model.setOutExclusiveTaxAmount(vo.getOutExclusiveTaxAmount());
|
||||||
|
model.setGrossProfitMargin(vo.getGrossProfitMargin());
|
||||||
|
|
||||||
|
|
||||||
if (vo.getProject() == null) {
|
if (vo.getProject() == null) {
|
||||||
model.setProject(null);
|
model.setProject(null);
|
||||||
} else {
|
} else {
|
||||||
@@ -156,10 +165,10 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
|
|||||||
model.setContract(SpringApp.getBean(ContractService.class).getById(vo.getContractId()));
|
model.setContract(SpringApp.getBean(ContractService.class).getById(vo.getContractId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vo.getApplicantId() == null) {
|
if (vo.getAuthorizerId() == null) {
|
||||||
model.setAuthorizer(null);
|
model.setAuthorizer(null);
|
||||||
} else {
|
} else {
|
||||||
model.setApplicant(SpringApp.getBean(EmployeeService.class).getById(vo.getApplicantId()));
|
model.setAuthorizer(SpringApp.getBean(EmployeeService.class).getById(vo.getAuthorizerId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vo.getApplicantId() == null) {
|
if (vo.getApplicantId() == null) {
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public interface VendorRepository extends MyRepository<Vendor, Integer> {
|
|||||||
|
|
||||||
Optional<Vendor> findByCompany(Company company);
|
Optional<Vendor> findByCompany(Company company);
|
||||||
|
|
||||||
|
Optional<Vendor> findByCompanyId(Integer companyId);
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
int deleteAllByCompany(Company company);
|
int deleteAllByCompany(Company company);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.util.Optional;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.CompanyVo;
|
||||||
import com.ecep.contract.vo.VendorCatalogVo;
|
import com.ecep.contract.vo.VendorCatalogVo;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -121,6 +122,10 @@ public class VendorService extends CompanyBasicService
|
|||||||
return repository.findByCompany(company).orElse(null);
|
return repository.findByCompany(company).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VendorVo findByCompany(CompanyVo company) {
|
||||||
|
return repository.findByCompanyId(company.getId()).map(Vendor::toVo).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id")
|
@CacheEvict(key = "#p0.id")
|
||||||
})
|
})
|
||||||
@@ -221,7 +226,7 @@ public class VendorService extends CompanyBasicService
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file,
|
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file,
|
||||||
Consumer<String> status) {
|
Consumer<String> status) {
|
||||||
dbFile.setType((T) VendorFileType.General);
|
dbFile.setType((T) VendorFileType.General);
|
||||||
fillFile(dbFile, file, null, status);
|
fillFile(dbFile, file, null, status);
|
||||||
vendorFileService.save((VendorFile) dbFile);
|
vendorFileService.save((VendorFile) dbFile);
|
||||||
@@ -231,7 +236,7 @@ public class VendorService extends CompanyBasicService
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
|
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
|
||||||
Consumer<String> status) {
|
Consumer<String> status) {
|
||||||
VendorFile vendorFile = new VendorFile();
|
VendorFile vendorFile = new VendorFile();
|
||||||
vendorFile.setType(VendorFileType.General);
|
vendorFile.setType(VendorFileType.General);
|
||||||
vendorFile.setFilePath(file.getAbsolutePath());
|
vendorFile.setFilePath(file.getAbsolutePath());
|
||||||
@@ -252,7 +257,7 @@ public class VendorService extends CompanyBasicService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsEvaluationFile(F customerFile, File file,
|
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsEvaluationFile(F customerFile, File file,
|
||||||
List<File> fileList, Consumer<String> status) {
|
List<File> fileList, Consumer<String> status) {
|
||||||
boolean modified = super.fillFileAsEvaluationFile(customerFile, file, fileList, status);
|
boolean modified = super.fillFileAsEvaluationFile(customerFile, file, fileList, status);
|
||||||
// 当评价表有日期,并且未设审核时
|
// 当评价表有日期,并且未设审核时
|
||||||
boolean valid = FileUtils.isArchiveFile(customerFile.getFilePath()) && customerFile.getSignDate() != null;
|
boolean valid = FileUtils.isArchiveFile(customerFile.getFilePath()) && customerFile.getSignDate() != null;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
import com.ecep.contract.ds.contract.service.ContractService;
|
import com.ecep.contract.ds.contract.service.ContractService;
|
||||||
import com.ecep.contract.ds.contract.tasker.AbstContractRepairTasker;
|
import com.ecep.contract.ds.contract.tasker.AbstContractRepairTasker;
|
||||||
import com.ecep.contract.ds.contract.tasker.ContractRepairComm;
|
import com.ecep.contract.ds.contract.tasker.ContractRepairComm;
|
||||||
|
import com.ecep.contract.vo.ContractVo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ import lombok.Getter;
|
|||||||
*/
|
*/
|
||||||
public class ContractRepairTasker extends AbstContractRepairTasker implements WebSocketServerTasker {
|
public class ContractRepairTasker extends AbstContractRepairTasker implements WebSocketServerTasker {
|
||||||
@Getter
|
@Getter
|
||||||
private Contract contract;
|
private ContractVo contract;
|
||||||
@Getter
|
@Getter
|
||||||
boolean repaired = false;
|
boolean repaired = false;
|
||||||
|
|
||||||
@@ -31,13 +32,13 @@ public class ContractRepairTasker extends AbstContractRepairTasker implements We
|
|||||||
|
|
||||||
public void init(JsonNode argsNode) {
|
public void init(JsonNode argsNode) {
|
||||||
int contractId = argsNode.get(0).asInt();
|
int contractId = argsNode.get(0).asInt();
|
||||||
contract = getCachedBean(ContractService.class).getById(contractId);
|
contract = getCachedBean(ContractService.class).findById(contractId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void repair(MessageHolder holder) {
|
protected void repair(MessageHolder holder) {
|
||||||
updateTitle("修复合同 " + contract.toPrettyString());
|
updateTitle("修复合同 " + contract.getCode() + " - " + contract.getName());
|
||||||
Contract parent = null;
|
ContractVo parent = null;
|
||||||
|
|
||||||
if (contract.getPayWay() == ContractPayWay.PAY) {
|
if (contract.getPayWay() == ContractPayWay.PAY) {
|
||||||
if (StringUtils.hasText(contract.getParentCode())) {
|
if (StringUtils.hasText(contract.getParentCode())) {
|
||||||
@@ -45,7 +46,7 @@ public class ContractRepairTasker extends AbstContractRepairTasker implements We
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomicReference<Contract> contractProperty = new AtomicReference<>(contract);
|
AtomicReference<ContractVo> contractProperty = new AtomicReference<>(contract);
|
||||||
if (repair(contractProperty, parent, holder, progress -> updateProgress(progress, 1))) {
|
if (repair(contractProperty, parent, holder, progress -> updateProgress(progress, 1))) {
|
||||||
repaired = true;
|
repaired = true;
|
||||||
updateProperty("repaired", true);
|
updateProperty("repaired", true);
|
||||||
@@ -56,7 +57,7 @@ public class ContractRepairTasker extends AbstContractRepairTasker implements We
|
|||||||
updateProgress(1, 1);
|
updateProgress(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContract(Contract contract) {
|
public void setContract(ContractVo contract) {
|
||||||
this.contract = contract;
|
this.contract = contract;
|
||||||
updateProperty("contract", contract);
|
updateProperty("contract", contract);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user