|
@@ -11,11 +11,13 @@ import com.usky.vpp.domain.VppCustomerContact;
|
|
|
import com.usky.vpp.domain.VppDrEvent;
|
|
import com.usky.vpp.domain.VppDrEvent;
|
|
|
import com.usky.vpp.domain.VppDrInvitation;
|
|
import com.usky.vpp.domain.VppDrInvitation;
|
|
|
import com.usky.vpp.domain.VppDrParticipation;
|
|
import com.usky.vpp.domain.VppDrParticipation;
|
|
|
|
|
+import com.usky.vpp.domain.VppResourcePoint;
|
|
|
import com.usky.vpp.mapper.VppCustomerContactMapper;
|
|
import com.usky.vpp.mapper.VppCustomerContactMapper;
|
|
|
import com.usky.vpp.mapper.VppCustomerMapper;
|
|
import com.usky.vpp.mapper.VppCustomerMapper;
|
|
|
import com.usky.vpp.mapper.VppDrEventMapper;
|
|
import com.usky.vpp.mapper.VppDrEventMapper;
|
|
|
import com.usky.vpp.mapper.VppDrInvitationMapper;
|
|
import com.usky.vpp.mapper.VppDrInvitationMapper;
|
|
|
import com.usky.vpp.mapper.VppDrParticipationMapper;
|
|
import com.usky.vpp.mapper.VppDrParticipationMapper;
|
|
|
|
|
+import com.usky.vpp.mapper.VppResourcePointMapper;
|
|
|
import com.usky.vpp.service.VppAliyunSmsService;
|
|
import com.usky.vpp.service.VppAliyunSmsService;
|
|
|
import com.usky.vpp.service.VppDrInvitationService;
|
|
import com.usky.vpp.service.VppDrInvitationService;
|
|
|
import com.usky.vpp.service.VppUnIntegrationService;
|
|
import com.usky.vpp.service.VppUnIntegrationService;
|
|
@@ -79,6 +81,8 @@ public class VppDrInvitationServiceImpl implements VppDrInvitationService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private VppDrParticipationMapper participationMapper;
|
|
private VppDrParticipationMapper participationMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ private VppResourcePointMapper resourcePointMapper;
|
|
|
|
|
+ @Autowired
|
|
|
private VppUnIntegrationService unIntegrationService;
|
|
private VppUnIntegrationService unIntegrationService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private VppAliyunSmsService aliyunSmsService;
|
|
private VppAliyunSmsService aliyunSmsService;
|
|
@@ -111,7 +115,7 @@ public class VppDrInvitationServiceImpl implements VppDrInvitationService {
|
|
|
|
|
|
|
|
VppDrEvent event = requireEvent(request.getDrEventId());
|
|
VppDrEvent event = requireEvent(request.getDrEventId());
|
|
|
VppCustomer customer = requireCustomer(request.getCustomerId());
|
|
VppCustomer customer = requireCustomer(request.getCustomerId());
|
|
|
- ensureInvitationUnique(request.getDrEventId(), request.getCustomerId(), null);
|
|
|
|
|
|
|
+ ensureInvitationUnique(request, null);
|
|
|
|
|
|
|
|
VppDrInvitation invitation = new VppDrInvitation();
|
|
VppDrInvitation invitation = new VppDrInvitation();
|
|
|
invitation.setInvitationNo(VppAuditHelper.nextInvitationNo());
|
|
invitation.setInvitationNo(VppAuditHelper.nextInvitationNo());
|
|
@@ -368,13 +372,19 @@ public class VppDrInvitationServiceImpl implements VppDrInvitationService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private VppDrParticipation findOrCreateParticipation(VppDrInvitation invitation, BigDecimal declaredCapacityKw) {
|
|
private VppDrParticipation findOrCreateParticipation(VppDrInvitation invitation, BigDecimal declaredCapacityKw) {
|
|
|
- VppDrParticipation existing = participationMapper.selectOne(new LambdaQueryWrapper<VppDrParticipation>()
|
|
|
|
|
|
|
+ Long resourceId = resolveResourceIdBySiteId(invitation.getSiteId());
|
|
|
|
|
+ LambdaQueryWrapper<VppDrParticipation> wrapper = new LambdaQueryWrapper<VppDrParticipation>()
|
|
|
.eq(VppDrParticipation::getEventId, invitation.getDrEventId())
|
|
.eq(VppDrParticipation::getEventId, invitation.getDrEventId())
|
|
|
.eq(VppDrParticipation::getCustomerId, invitation.getCustomerId())
|
|
.eq(VppDrParticipation::getCustomerId, invitation.getCustomerId())
|
|
|
- .isNull(VppDrParticipation::getResourceId)
|
|
|
|
|
- .eq(VppDrParticipation::getDeleteFlag, VppAuditHelper.NOT_DELETED)
|
|
|
|
|
- .last("LIMIT 1"));
|
|
|
|
|
|
|
+ .eq(VppDrParticipation::getDeleteFlag, VppAuditHelper.NOT_DELETED);
|
|
|
|
|
+ if (resourceId != null) {
|
|
|
|
|
+ wrapper.eq(VppDrParticipation::getResourceId, resourceId);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wrapper.isNull(VppDrParticipation::getResourceId);
|
|
|
|
|
+ }
|
|
|
|
|
+ VppDrParticipation existing = participationMapper.selectOne(wrapper.last("LIMIT 1"));
|
|
|
if (existing != null) {
|
|
if (existing != null) {
|
|
|
|
|
+ existing.setResourceId(resourceId);
|
|
|
existing.setParticipateStatus(PARTICIPATE_ACCEPT);
|
|
existing.setParticipateStatus(PARTICIPATE_ACCEPT);
|
|
|
existing.setDeclaredCapacityKw(declaredCapacityKw);
|
|
existing.setDeclaredCapacityKw(declaredCapacityKw);
|
|
|
existing.setDeclaredAt(LocalDateTime.now());
|
|
existing.setDeclaredAt(LocalDateTime.now());
|
|
@@ -387,6 +397,7 @@ public class VppDrInvitationServiceImpl implements VppDrInvitationService {
|
|
|
VppDrParticipation participation = new VppDrParticipation();
|
|
VppDrParticipation participation = new VppDrParticipation();
|
|
|
participation.setEventId(invitation.getDrEventId());
|
|
participation.setEventId(invitation.getDrEventId());
|
|
|
participation.setCustomerId(invitation.getCustomerId());
|
|
participation.setCustomerId(invitation.getCustomerId());
|
|
|
|
|
+ participation.setResourceId(resourceId);
|
|
|
participation.setParticipateStatus(PARTICIPATE_ACCEPT);
|
|
participation.setParticipateStatus(PARTICIPATE_ACCEPT);
|
|
|
participation.setDeclaredCapacityKw(declaredCapacityKw);
|
|
participation.setDeclaredCapacityKw(declaredCapacityKw);
|
|
|
participation.setDeclaredAt(LocalDateTime.now());
|
|
participation.setDeclaredAt(LocalDateTime.now());
|
|
@@ -399,6 +410,20 @@ public class VppDrInvitationServiceImpl implements VppDrInvitationService {
|
|
|
return participation;
|
|
return participation;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private Long resolveResourceIdBySiteId(Long siteId) {
|
|
|
|
|
+ if (siteId == null) {
|
|
|
|
|
+ throw new BusinessException("邀约未关联站点,无法创建参与记录");
|
|
|
|
|
+ }
|
|
|
|
|
+ VppResourcePoint resourcePoint = resourcePointMapper.selectOne(new LambdaQueryWrapper<VppResourcePoint>()
|
|
|
|
|
+ .eq(VppResourcePoint::getSiteId, siteId)
|
|
|
|
|
+ .eq(VppResourcePoint::getDeleteFlag, VppAuditHelper.NOT_DELETED)
|
|
|
|
|
+ .last("LIMIT 1"));
|
|
|
|
|
+ if (resourcePoint == null) {
|
|
|
|
|
+ throw new BusinessException("站点未配置资源点,无法参与");
|
|
|
|
|
+ }
|
|
|
|
|
+ return resourcePoint.getId();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void syncParticipationToUn(Long eventId, boolean participate, List<VppDrParticipation> participations) {
|
|
private void syncParticipationToUn(Long eventId, boolean participate, List<VppDrParticipation> participations) {
|
|
|
try {
|
|
try {
|
|
|
unIntegrationService.submitParticipation(eventId, participate, participations);
|
|
unIntegrationService.submitParticipation(eventId, participate, participations);
|
|
@@ -461,16 +486,25 @@ public class VppDrInvitationServiceImpl implements VppDrInvitationService {
|
|
|
return any != null ? any.getId() : null;
|
|
return any != null ? any.getId() : null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void ensureInvitationUnique(Long drEventId, Long customerId, Long excludeId) {
|
|
|
|
|
|
|
+ private void ensureInvitationUnique(DrInvitationRequest request, Long excludeId) {
|
|
|
|
|
+ if (request == null || request.getDrEventId() == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
LambdaQueryWrapper<VppDrInvitation> wrapper = new LambdaQueryWrapper<VppDrInvitation>()
|
|
LambdaQueryWrapper<VppDrInvitation> wrapper = new LambdaQueryWrapper<VppDrInvitation>()
|
|
|
- .eq(VppDrInvitation::getDrEventId, drEventId)
|
|
|
|
|
- .eq(VppDrInvitation::getCustomerId, customerId)
|
|
|
|
|
|
|
+ .eq(VppDrInvitation::getDrEventId, request.getDrEventId())
|
|
|
.eq(VppDrInvitation::getDeleteFlag, VppAuditHelper.NOT_DELETED);
|
|
.eq(VppDrInvitation::getDeleteFlag, VppAuditHelper.NOT_DELETED);
|
|
|
|
|
+ if (request.getSiteId() != null) {
|
|
|
|
|
+ wrapper.eq(VppDrInvitation::getSiteId, request.getSiteId());
|
|
|
|
|
+ } else if (request.getCustomerId() != null) {
|
|
|
|
|
+ wrapper.eq(VppDrInvitation::getCustomerId, request.getCustomerId());
|
|
|
|
|
+ }
|
|
|
if (excludeId != null) {
|
|
if (excludeId != null) {
|
|
|
wrapper.ne(VppDrInvitation::getId, excludeId);
|
|
wrapper.ne(VppDrInvitation::getId, excludeId);
|
|
|
}
|
|
}
|
|
|
if (invitationMapper.selectCount(wrapper) > 0) {
|
|
if (invitationMapper.selectCount(wrapper) > 0) {
|
|
|
- throw new BusinessException("该事件已存在该企业的邀约记录");
|
|
|
|
|
|
|
+ throw new BusinessException(request.getSiteId() != null
|
|
|
|
|
+ ? "该事件已存在该站点的邀约记录"
|
|
|
|
|
+ : "该事件已存在该企业的邀约记录");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|