|
@@ -69,6 +69,8 @@ public class VppDrServiceImpl implements VppDrService {
|
|
|
private static final int EVENT_STATUS_SPLITTING = VppDrEventStatus.LAST_PLACE_SPLITTING;
|
|
private static final int EVENT_STATUS_SPLITTING = VppDrEventStatus.LAST_PLACE_SPLITTING;
|
|
|
|
|
|
|
|
private static final int PARTICIPATE_STATUS_ACCEPT = 1;
|
|
private static final int PARTICIPATE_STATUS_ACCEPT = 1;
|
|
|
|
|
+ private static final int REPLY_ACCEPT = 1;
|
|
|
|
|
+ private static final int REPLY_REJECT = 2;
|
|
|
|
|
|
|
|
private static final int EXECUTE_STATUS_PENDING = 0;
|
|
private static final int EXECUTE_STATUS_PENDING = 0;
|
|
|
private static final int EXECUTE_STATUS_RUNNING = 1;
|
|
private static final int EXECUTE_STATUS_RUNNING = 1;
|
|
@@ -232,6 +234,14 @@ public class VppDrServiceImpl implements VppDrService {
|
|
|
event.setEventStatus(EVENT_STATUS_DECLARED);
|
|
event.setEventStatus(EVENT_STATUS_DECLARED);
|
|
|
VppAuditHelper.fillUpdate(event);
|
|
VppAuditHelper.fillUpdate(event);
|
|
|
eventMapper.updateById(event);
|
|
eventMapper.updateById(event);
|
|
|
|
|
+ for (VppDrInvitation invitation : loadEventInvitations(event.getId())) {
|
|
|
|
|
+ invitation.setResponseStatus(EVENT_STATUS_DECLARED);
|
|
|
|
|
+ if (invitation.getTenantId() == null) {
|
|
|
|
|
+ invitation.setTenantId(event.getTenantId() != null ? event.getTenantId() : tenantId);
|
|
|
|
|
+ }
|
|
|
|
|
+ VppAuditHelper.fillUpdate(invitation);
|
|
|
|
|
+ invitationMapper.updateById(invitation);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -342,6 +352,7 @@ public class VppDrServiceImpl implements VppDrService {
|
|
|
.filter(inv -> inv.getSiteId() != null)
|
|
.filter(inv -> inv.getSiteId() != null)
|
|
|
.collect(Collectors.toMap(VppDrInvitation::getSiteId, inv -> inv, (a, b) -> a));
|
|
.collect(Collectors.toMap(VppDrInvitation::getSiteId, inv -> inv, (a, b) -> a));
|
|
|
|
|
|
|
|
|
|
+ Map<Long, VppDrInvitation> matchedInvitations = new LinkedHashMap<>();
|
|
|
Map<Long, BigDecimal> declaredByResourceId = new HashMap<>();
|
|
Map<Long, BigDecimal> declaredByResourceId = new HashMap<>();
|
|
|
for (DrParticipateRequest.DrResourceDeclare resource : request.getResources()) {
|
|
for (DrParticipateRequest.DrResourceDeclare resource : request.getResources()) {
|
|
|
if (resource.getResourceId() == null) {
|
|
if (resource.getResourceId() == null) {
|
|
@@ -368,8 +379,10 @@ public class VppDrServiceImpl implements VppDrService {
|
|
|
throw new BusinessException("邀约申报出清容量必须大于0");
|
|
throw new BusinessException("邀约申报出清容量必须大于0");
|
|
|
}
|
|
}
|
|
|
declaredByResourceId.put(resource.getResourceId(), declaredCapacityKw);
|
|
declaredByResourceId.put(resource.getResourceId(), declaredCapacityKw);
|
|
|
|
|
+ matchedInvitations.put(invitation.getId(), invitation);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ List<VppDrParticipation> createdParticipations = new ArrayList<>();
|
|
|
for (DrParticipateRequest.DrResourceDeclare resource : request.getResources()) {
|
|
for (DrParticipateRequest.DrResourceDeclare resource : request.getResources()) {
|
|
|
VppResourcePoint rp = resourcePointMapper.selectById(resource.getResourceId());
|
|
VppResourcePoint rp = resourcePointMapper.selectById(resource.getResourceId());
|
|
|
VppDrParticipation participation = new VppDrParticipation();
|
|
VppDrParticipation participation = new VppDrParticipation();
|
|
@@ -381,16 +394,22 @@ public class VppDrServiceImpl implements VppDrService {
|
|
|
participation.setDeclaredAt(LocalDateTime.now());
|
|
participation.setDeclaredAt(LocalDateTime.now());
|
|
|
VppDrParticipationHelper.refreshCompletionRate(participation);
|
|
VppDrParticipationHelper.refreshCompletionRate(participation);
|
|
|
VppAuditHelper.fillCreate(participation);
|
|
VppAuditHelper.fillCreate(participation);
|
|
|
|
|
+ if (participation.getTenantId() == null && event.getTenantId() != null) {
|
|
|
|
|
+ participation.setTenantId(event.getTenantId());
|
|
|
|
|
+ }
|
|
|
participationMapper.insert(participation);
|
|
participationMapper.insert(participation);
|
|
|
|
|
+ createdParticipations.add(participation);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
event.setEventStatus(EVENT_STATUS_DECLARED);
|
|
event.setEventStatus(EVENT_STATUS_DECLARED);
|
|
|
VppAuditHelper.fillUpdate(event);
|
|
VppAuditHelper.fillUpdate(event);
|
|
|
eventMapper.updateById(event);
|
|
eventMapper.updateById(event);
|
|
|
|
|
+ syncInvitationStatus(event, true, matchedInvitations.values(), createdParticipations);
|
|
|
} else {
|
|
} else {
|
|
|
event.setEventStatus(EVENT_STATUS_CANCELLED);
|
|
event.setEventStatus(EVENT_STATUS_CANCELLED);
|
|
|
VppAuditHelper.fillUpdate(event);
|
|
VppAuditHelper.fillUpdate(event);
|
|
|
eventMapper.updateById(event);
|
|
eventMapper.updateById(event);
|
|
|
|
|
+ syncInvitationStatus(event, false, loadEventInvitations(eventId), Collections.emptyList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
syncParticipationToUn(eventId, request.getParticipate());
|
|
syncParticipationToUn(eventId, request.getParticipate());
|
|
@@ -404,6 +423,48 @@ public class VppDrServiceImpl implements VppDrService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private List<VppDrInvitation> loadEventInvitations(Long eventId) {
|
|
|
|
|
+ return invitationMapper.selectList(new LambdaQueryWrapper<VppDrInvitation>()
|
|
|
|
|
+ .eq(VppDrInvitation::getDrEventId, eventId)
|
|
|
|
|
+ .eq(VppDrInvitation::getDeleteFlag, VppAuditHelper.NOT_DELETED));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void syncInvitationStatus(VppDrEvent event, boolean participate,
|
|
|
|
|
+ Collection<VppDrInvitation> invitations,
|
|
|
|
|
+ List<VppDrParticipation> createdParticipations) {
|
|
|
|
|
+ if (invitations == null || invitations.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<Long, Long> participationIdByCustomer = createdParticipations == null
|
|
|
|
|
+ ? Collections.emptyMap()
|
|
|
|
|
+ : createdParticipations.stream()
|
|
|
|
|
+ .filter(p -> p.getCustomerId() != null && p.getId() != null)
|
|
|
|
|
+ .collect(Collectors.toMap(VppDrParticipation::getCustomerId, VppDrParticipation::getId, (a, b) -> a));
|
|
|
|
|
+ for (VppDrInvitation invitation : invitations) {
|
|
|
|
|
+ if (invitation == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (participate) {
|
|
|
|
|
+ invitation.setReplyStatus(REPLY_ACCEPT);
|
|
|
|
|
+ invitation.setResponseStatus(EVENT_STATUS_DECLARED);
|
|
|
|
|
+ if (invitation.getParticipationId() == null && invitation.getCustomerId() != null) {
|
|
|
|
|
+ Long participationId = participationIdByCustomer.get(invitation.getCustomerId());
|
|
|
|
|
+ if (participationId != null) {
|
|
|
|
|
+ invitation.setParticipationId(participationId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ invitation.setReplyStatus(REPLY_REJECT);
|
|
|
|
|
+ invitation.setResponseStatus(EVENT_STATUS_CANCELLED);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (invitation.getTenantId() == null) {
|
|
|
|
|
+ invitation.setTenantId(event.getTenantId() != null ? event.getTenantId() : SecurityUtils.getTenantId());
|
|
|
|
|
+ }
|
|
|
|
|
+ VppAuditHelper.fillUpdate(invitation);
|
|
|
|
|
+ invitationMapper.updateById(invitation);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private VppDrInvitation resolveInvitationForResource(Long customerId, Long siteId,
|
|
private VppDrInvitation resolveInvitationForResource(Long customerId, Long siteId,
|
|
|
Map<Long, VppDrInvitation> invitationByCustomerId,
|
|
Map<Long, VppDrInvitation> invitationByCustomerId,
|
|
|
Map<Long, VppDrInvitation> invitationBySiteId) {
|
|
Map<Long, VppDrInvitation> invitationBySiteId) {
|