单方协议
This commit is contained in:
+46
-3
@@ -344,6 +344,9 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ContractLaunchDto handleLawApproveCallback(ContractLaunchLawCallbackDto callbackData) {
|
||||
ContractLaunchDto contract = getContractByLawCallback(callbackData);
|
||||
if (isSingleAgreement(contract)) {
|
||||
throw new ServiceException("单方协议不接收法务审批回调");
|
||||
}
|
||||
SysUserEntity currentUser = adminSecurityManage.getUser();
|
||||
|
||||
boolean approved = isLawCallbackApproved(callbackData);
|
||||
@@ -394,6 +397,9 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ContractLaunchDto saveSealInfo(Long id, ContractLaunchSealDto sealDto) {
|
||||
ContractLaunchDto contract = getDetail(id);
|
||||
if (isSingleAgreement(contract)) {
|
||||
throw new ServiceException("单方协议无需发起在线签章");
|
||||
}
|
||||
SysUserEntity currentUser = adminSecurityManage.getUser();
|
||||
contract.setSealContractId(sealDto.getSealContractId());
|
||||
contract.setSealContractStatus(sealDto.getSealContractStatus());
|
||||
@@ -425,6 +431,7 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
ContractLaunchDto contract = getDetail(id);
|
||||
SysUserEntity currentUser = adminSecurityManage.getUser();
|
||||
LocalDateTime completedTime = LocalDateTime.now();
|
||||
boolean singleAgreement = isSingleAgreement(contract);
|
||||
contract.setSealContractId(sealDto.getSealContractId() == null || sealDto.getSealContractId().isBlank() ? contract.getSealContractId() : sealDto.getSealContractId());
|
||||
contract.setSealContractStatus(sealDto.getSealContractStatus());
|
||||
contract.setSignedFileName(sealDto.getSignedFileName());
|
||||
@@ -439,12 +446,20 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
contract.setSealDate(firstNonNull(sealDto.getSealDate(), contract.getSealDate(), contract.getSignDate()));
|
||||
contract.setActiveDate(firstNonNull(sealDto.getActiveDate(), contract.getActiveDate()));
|
||||
validateSignCompletion(contract);
|
||||
contract.setStatus(ContractLaunchConstants.STATUS_PENDING_COLLECT);
|
||||
contract.setStatus(singleAgreement ? ContractLaunchConstants.STATUS_COMPLETED : ContractLaunchConstants.STATUS_PENDING_COLLECT);
|
||||
contract.setUpdateBy(currentUser.getUsername());
|
||||
contract.setUpdateTime(completedTime);
|
||||
contractLaunchMapper.updateContract(contract);
|
||||
saveSignedFile(id, sealDto, currentUser.getUsername());
|
||||
insertLog(id, ContractLaunchConstants.ACTION_SEAL_FINISH, "签署完成", ContractLaunchConstants.ACTION_STATUS_SUCCESS, "合同签署已完成,待采集", sealDto, currentUser);
|
||||
insertLog(
|
||||
id,
|
||||
ContractLaunchConstants.ACTION_SEAL_FINISH,
|
||||
singleAgreement ? "盖章完成" : "签署完成",
|
||||
ContractLaunchConstants.ACTION_STATUS_SUCCESS,
|
||||
singleAgreement ? "单方协议已盖章生效,流程完成" : "合同签署已完成,待采集",
|
||||
sealDto,
|
||||
currentUser
|
||||
);
|
||||
return getDetail(id);
|
||||
}
|
||||
|
||||
@@ -471,6 +486,9 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ContractLaunchDto mockCollect(Long id) {
|
||||
ContractLaunchDto contract = getDetail(id);
|
||||
if (isSingleAgreement(contract)) {
|
||||
throw new ServiceException("单方协议无需执行法务采集");
|
||||
}
|
||||
if (!ContractLaunchConstants.STATUS_PENDING_COLLECT.equals(contract.getStatus())) {
|
||||
throw new ServiceException("当前状态不允许执行采集");
|
||||
}
|
||||
@@ -513,6 +531,9 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ContractLaunchDto archive(Long id, ContractLaunchArchiveDto archiveDto) {
|
||||
ContractLaunchDto contract = getDetail(id);
|
||||
if (isSingleAgreement(contract)) {
|
||||
throw new ServiceException("单方协议无需执行法务归档");
|
||||
}
|
||||
if (!ContractLaunchConstants.STATUS_PENDING_ARCHIVE.equals(contract.getStatus())) {
|
||||
throw new ServiceException("当前状态不允许归档");
|
||||
}
|
||||
@@ -839,7 +860,9 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
item.setArchiveEles(archiveEles);
|
||||
item.setLogList(new ArrayList<>(logMap.getOrDefault(item.getId(), Collections.emptyList())));
|
||||
item.setCounterpartySummary(
|
||||
item.getPartyList().stream()
|
||||
isSingleAgreement(item)
|
||||
? "单方协议"
|
||||
: item.getPartyList().stream()
|
||||
.filter(this::isOppositeParty)
|
||||
.map(ContractLaunchPartyDto::getCompanyName)
|
||||
.filter(name -> name != null && !name.isBlank())
|
||||
@@ -962,6 +985,7 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
if (contract == null) {
|
||||
throw new ServiceException("合同数据不能为空");
|
||||
}
|
||||
boolean singleAgreement = isSingleAgreement(contract);
|
||||
contract.setContractName(trim(contract.getContractName()));
|
||||
contract.setContractCode(trim(contract.getContractCode()));
|
||||
contract.setContractType(trim(contract.getContractType()));
|
||||
@@ -999,6 +1023,12 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
if (contract.getPushUrl() == null || contract.getPushUrl().isBlank()) {
|
||||
contract.setPushUrl("/contract/launch/callback/law/approve");
|
||||
}
|
||||
if (singleAgreement) {
|
||||
contract.setIsElectron("0");
|
||||
if (contract.getSealType() == null || contract.getSealType().isBlank()) {
|
||||
contract.setSealType("YWZ");
|
||||
}
|
||||
}
|
||||
if (contract.getSealQuantity() == null) {
|
||||
contract.setSealQuantity(1);
|
||||
}
|
||||
@@ -1019,9 +1049,11 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
if (contract == null || contract.getPartyList() == null) {
|
||||
return;
|
||||
}
|
||||
boolean singleAgreement = isSingleAgreement(contract);
|
||||
List<ContractLaunchPartyDto> normalized = contract.getPartyList().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item -> item.getCompanyName() != null && !item.getCompanyName().isBlank())
|
||||
.filter(item -> !singleAgreement || !isOppositeParty(item))
|
||||
.peek(item -> {
|
||||
String roleCode = trim(item.getRoleCode());
|
||||
if (roleCode == null || roleCode.isBlank()) {
|
||||
@@ -1146,6 +1178,17 @@ public class ContractLaunchServiceImpl implements ContractLaunchService {
|
||||
if (!containsCurrentOrg) {
|
||||
throw new ServiceException("我方主体中必须包含当前登录主体");
|
||||
}
|
||||
if (isSingleAgreement(contract)) {
|
||||
boolean onlyCurrentOrg = contract.getPartyList().stream()
|
||||
.filter(this::isOurParty)
|
||||
.map(ContractLaunchPartyDto::getSubjectCode)
|
||||
.filter(Objects::nonNull)
|
||||
.map(String::trim)
|
||||
.allMatch(currentOrgId::equals);
|
||||
if (!onlyCurrentOrg) {
|
||||
throw new ServiceException("单方协议仅允许使用当前登录主体");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isSingleAgreement(contract) && !hasCounterparty) {
|
||||
throw new ServiceException("至少维护一个相对方");
|
||||
|
||||
Reference in New Issue
Block a user