:feat: 合同变更合规推送增加同步状态回写闭环,仅原合同已推送合规的变更单参与推送
This commit is contained in:
+5
-9
@@ -33,6 +33,7 @@ import org.springblade.core.mp.support.Condition;
|
|||||||
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.mp.support.Query;
|
||||||
import org.springblade.core.secure.annotation.PreAuth;
|
import org.springblade.core.secure.annotation.PreAuth;
|
||||||
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.api.R;
|
||||||
|
import org.springblade.transport.constant.HcsSyncConstant;
|
||||||
import org.springblade.transport.pojo.entity.ContractChange;
|
import org.springblade.transport.pojo.entity.ContractChange;
|
||||||
import org.springblade.transport.pojo.vo.ContractChangeVO;
|
import org.springblade.transport.pojo.vo.ContractChangeVO;
|
||||||
import org.springblade.transport.service.IContractChangeService;
|
import org.springblade.transport.service.IContractChangeService;
|
||||||
@@ -110,17 +111,12 @@ public class ContractChangeController extends BladeController {
|
|||||||
hcsImmediatePushSupport.pushContractAndWait(contractId);
|
hcsImmediatePushSupport.pushContractAndWait(contractId);
|
||||||
String syncFailure = HcsImmediatePushSupport.pollSyncFailure();
|
String syncFailure = HcsImmediatePushSupport.pollSyncFailure();
|
||||||
if (syncFailure != null) {
|
if (syncFailure != null) {
|
||||||
ContractChange contractChange = contractChangeService.getById(id);
|
contractChangeService.writeBackSyncStatus(contractId, HcsSyncConstant.HCS_STATUS_FAILED);
|
||||||
if (contractChange != null) {
|
|
||||||
contractChange.setSyncStatus("failed");
|
|
||||||
contractChangeService.updateById(contractChange);
|
|
||||||
}
|
|
||||||
return R.data(Boolean.FALSE, "审批通过,但合规推送失败:" + syncFailure);
|
return R.data(Boolean.FALSE, "审批通过,但合规推送失败:" + syncFailure);
|
||||||
}
|
}
|
||||||
ContractChange contractChange = contractChangeService.getById(id);
|
// 即时推送未开启时(开关关闭不触发推送)不标记已推送,待推送状态由定时扫描任务推送后闭环
|
||||||
if (contractChange != null) {
|
if (hcsImmediatePushSupport.isImmediateEnabled()) {
|
||||||
contractChange.setSyncStatus("synced");
|
contractChangeService.writeBackSyncStatus(contractId, HcsSyncConstant.HCS_STATUS_SYNCED);
|
||||||
contractChangeService.updateById(contractChange);
|
|
||||||
}
|
}
|
||||||
return R.success("审批通过");
|
return R.success("审批通过");
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -72,4 +72,13 @@ public interface IContractChangeService extends BaseService<ContractChange> {
|
|||||||
*/
|
*/
|
||||||
boolean markSyncStatus(String ids, String syncStatus);
|
boolean markSyncStatus(String ids, String syncStatus);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按原合同回写最近一条待同步变更单的同步状态(审批即时推送/定时任务推送后调用)
|
||||||
|
*
|
||||||
|
* @param contractId 原合同ID
|
||||||
|
* @param syncStatus 同步状态(synced/failed)
|
||||||
|
* @return 是否回写成功(无待同步变更单时返回 false)
|
||||||
|
*/
|
||||||
|
boolean writeBackSyncStatus(Long contractId, String syncStatus);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-1
@@ -190,7 +190,11 @@ public class ContractChangeServiceImpl extends BaseServiceImpl<ContractChangeMap
|
|||||||
String processor = TransportBusinessSupport.trimToNull(AuthUtil.getUserName());
|
String processor = TransportBusinessSupport.trimToNull(AuthUtil.getUserName());
|
||||||
contractChange.setCurrentProcessor(processor == null ? "系统" : processor);
|
contractChange.setCurrentProcessor(processor == null ? "系统" : processor);
|
||||||
contractChange.setApprovedTime(LocalDateTime.now());
|
contractChange.setApprovedTime(LocalDateTime.now());
|
||||||
contractChange.setSyncStatus(HcsSyncConstant.HCS_STATUS_UNSYNCED);
|
// 仅原合同已推送合规(有合规单据ID标识 hcs_fd_id)的变更单参与合规推送(C103-11),存量未推送合同不置同步状态
|
||||||
|
ContractManage contractManage = contractManageService.getById(contractChange.getContractId());
|
||||||
|
if (contractManage != null && Func.isNotBlank(contractManage.getHcsFdId())) {
|
||||||
|
contractChange.setSyncStatus(HcsSyncConstant.HCS_STATUS_UNSYNCED);
|
||||||
|
}
|
||||||
updateById(contractChange);
|
updateById(contractChange);
|
||||||
contractManageService.applyChangeFromRecord(contractChange);
|
contractManageService.applyChangeFromRecord(contractChange);
|
||||||
return contractChange.getContractId();
|
return contractChange.getContractId();
|
||||||
@@ -253,6 +257,20 @@ public class ContractChangeServiceImpl extends BaseServiceImpl<ContractChangeMap
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean writeBackSyncStatus(Long contractId, String syncStatus) {
|
||||||
|
if (contractId == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 仅回写该合同最近一条审批通过且未同步/失败的变更单,历史已闭环单据不翻动
|
||||||
|
return update(Wrappers.<ContractChange>lambdaUpdate()
|
||||||
|
.eq(ContractChange::getContractId, contractId)
|
||||||
|
.eq(ContractChange::getApprovalStatus, STATUS_APPROVED)
|
||||||
|
.in(ContractChange::getSyncStatus, List.of(HcsSyncConstant.HCS_STATUS_UNSYNCED, HcsSyncConstant.HCS_STATUS_FAILED))
|
||||||
|
.set(ContractChange::getSyncStatus, syncStatus)
|
||||||
|
.last("order by approved_time desc limit 1"));
|
||||||
|
}
|
||||||
|
|
||||||
private LambdaQueryWrapper<ContractChange> buildQuery(ContractChangeVO contractChange) {
|
private LambdaQueryWrapper<ContractChange> buildQuery(ContractChangeVO contractChange) {
|
||||||
TransportBusinessSupport.validateAllDept(contractChange.getAllDept(), "合同变更");
|
TransportBusinessSupport.validateAllDept(contractChange.getAllDept(), "合同变更");
|
||||||
LambdaQueryWrapper<ContractChange> queryWrapper = Wrappers.<ContractChange>lambdaQuery().eq(ContractChange::getIsDeleted, 0);
|
LambdaQueryWrapper<ContractChange> queryWrapper = Wrappers.<ContractChange>lambdaQuery().eq(ContractChange::getIsDeleted, 0);
|
||||||
|
|||||||
+7
@@ -153,6 +153,13 @@ public class HcsImmediatePushSupport {
|
|||||||
this.pushWithLock(HcsSyncConstant.BIZ_TYPE_CONTRACT, id, () -> this.pushContractNow(id));
|
this.pushWithLock(HcsSyncConstant.BIZ_TYPE_CONTRACT, id, () -> this.pushContractNow(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 即时推送开关(thirdParty.hcs.push.immediate-enabled)状态,供 Controller 判断审批响应是否实际等待过推送结果
|
||||||
|
*/
|
||||||
|
public boolean isImmediateEnabled() {
|
||||||
|
return hcsProperties.getPush().isImmediateEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目立项"通过"按钮路径:在审批事务提交返回后由 Controller 同步调用,失败原因留在当前线程供其取走
|
* 项目立项"通过"按钮路径:在审批事务提交返回后由 Controller 同步调用,失败原因留在当前线程供其取走
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user