This commit is contained in:
2025-11-26 16:10:17 +08:00
parent f0e85c5a18
commit c10bd369c0
83 changed files with 1755 additions and 541 deletions

View File

@@ -4,6 +4,7 @@ import java.io.File;
import java.time.LocalDate;
import java.util.List;
import com.ecep.contract.util.MyStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -70,16 +71,7 @@ public class CompanyOldNameService extends QueryService<CompanyOldNameVo, Compan
}
public CompanyOldNameVo findMatchByDate(CompanyVo company, LocalDate localDate) {
Page<CompanyOldNameVo> page = findAll(ParamUtils.builder()
.equals("ambiguity", false)
.equals("company", company.getId())
.and(b -> b.isNotNull("beginDate").greaterThan("beginDate", localDate))
.and(b -> b.isNotNull("endDate").lessThan("endDate", localDate))
.build(), Pageable.ofSize(1));
if (page.isEmpty()) {
return null;
}
return page.getContent().getFirst();
return null;
}
public List<CompanyOldNameVo> findAllByCompanyAndName(CompanyVo company, String oldName) {
@@ -90,4 +82,13 @@ public class CompanyOldNameService extends QueryService<CompanyOldNameVo, Compan
public List<CompanyOldNameVo> findAllByCompany(IdentityEntity company) {
return findAll(ParamUtils.equal("company", company.getId()), Pageable.unpaged()).getContent();
}
public void mergeTo(CompanyVo from, CompanyVo to) {
List<CompanyOldNameVo> fromOldNames = findAllByCompany(from);
for (CompanyOldNameVo fromOldName : fromOldNames) {
fromOldName.setMemo(MyStringUtils.appendIfAbsent(fromOldName.getMemo(), "转自 " + from.getId()));
fromOldName.setCompanyId(to.getId());
save(fromOldName);
}
}
}