|
@@ -5,12 +5,17 @@ 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 java.math.BigDecimal;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 邀约短信模板参数构建
|
|
* 邀约短信模板参数构建
|
|
|
* <p>
|
|
* <p>
|
|
|
- * 阿里云模板变量需与控制台一致,默认使用:meet、time、room(SMS_465362899)
|
|
|
|
|
|
|
+ * 阿里云模板变量需与控制台一致:name、responsetype、time、number、operationtype
|
|
|
|
|
+ * <pre>
|
|
|
|
|
+ * 尊敬的${name},您已通过电力需求响应审核。 响应类型:${responsetype} 响应时间:${time}
|
|
|
|
|
+ * 邀约规模: ${number}kW 请在规定时段内${operationtype}
|
|
|
|
|
+ * </pre>
|
|
|
*/
|
|
*/
|
|
|
public final class VppSmsTemplateHelper {
|
|
public final class VppSmsTemplateHelper {
|
|
|
|
|
|
|
@@ -23,21 +28,72 @@ public final class VppSmsTemplateHelper {
|
|
|
VppDrEvent event,
|
|
VppDrEvent event,
|
|
|
VppCustomer customer,
|
|
VppCustomer customer,
|
|
|
VppCustomerContact contact) {
|
|
VppCustomerContact contact) {
|
|
|
- String meet = event != null && event.getEventName() != null
|
|
|
|
|
- ? event.getEventName()
|
|
|
|
|
- : (event != null ? event.getEventId() : "");
|
|
|
|
|
- String time = "";
|
|
|
|
|
- if (event != null && event.getStartTime() != null) {
|
|
|
|
|
- time = TIME_FORMAT.format(event.getStartTime());
|
|
|
|
|
- } else if (invitation.getReplyDeadline() != null) {
|
|
|
|
|
- time = TIME_FORMAT.format(invitation.getReplyDeadline());
|
|
|
|
|
- }
|
|
|
|
|
- String room = customer != null && customer.getCustomerName() != null
|
|
|
|
|
|
|
+ String name = customer != null && customer.getCustomerName() != null
|
|
|
? customer.getCustomerName()
|
|
? customer.getCustomerName()
|
|
|
: "";
|
|
: "";
|
|
|
- return "{\"meet\":\"" + escapeJson(meet)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Integer responseType = invitation != null && invitation.getResponseType() != null
|
|
|
|
|
+ ? invitation.getResponseType()
|
|
|
|
|
+ : (event != null ? event.getResponseType() : null);
|
|
|
|
|
+ String responsetype = VppCapabilityEvalHelper.responseTypeLabel(responseType);
|
|
|
|
|
+
|
|
|
|
|
+ String time = buildResponseTime(invitation, event);
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal capacity = invitation != null && invitation.getDemandCapacityKw() != null
|
|
|
|
|
+ ? invitation.getDemandCapacityKw()
|
|
|
|
|
+ : (event != null ? event.getTargetCapacityKw() : null);
|
|
|
|
|
+ String number = formatNumber(capacity);
|
|
|
|
|
+
|
|
|
|
|
+ Integer eventType = invitation != null && invitation.getTransactionType() != null
|
|
|
|
|
+ ? invitation.getTransactionType()
|
|
|
|
|
+ : (event != null ? event.getEventType() : null);
|
|
|
|
|
+ String operationtype = buildOperationType(eventType);
|
|
|
|
|
+
|
|
|
|
|
+ return "{\"name\":\"" + escapeJson(name)
|
|
|
|
|
+ + "\",\"responsetype\":\"" + escapeJson(responsetype)
|
|
|
+ "\",\"time\":\"" + escapeJson(time)
|
|
+ "\",\"time\":\"" + escapeJson(time)
|
|
|
- + "\",\"room\":\"" + escapeJson(room) + "\"}";
|
|
|
|
|
|
|
+ + "\",\"number\":\"" + escapeJson(number)
|
|
|
|
|
+ + "\",\"operationtype\":\"" + escapeJson(operationtype) + "\"}";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static String buildResponseTime(VppDrInvitation invitation, VppDrEvent event) {
|
|
|
|
|
+ if (event != null && event.getStartTime() != null) {
|
|
|
|
|
+ if (event.getEndTime() != null) {
|
|
|
|
|
+ return TIME_FORMAT.format(event.getStartTime()) + "~" + TIME_FORMAT.format(event.getEndTime());
|
|
|
|
|
+ }
|
|
|
|
|
+ return TIME_FORMAT.format(event.getStartTime());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (invitation != null && invitation.getExecuteStartDate() != null) {
|
|
|
|
|
+ if (invitation.getExecuteEndDate() != null
|
|
|
|
|
+ && !invitation.getExecuteStartDate().equals(invitation.getExecuteEndDate())) {
|
|
|
|
|
+ return invitation.getExecuteStartDate() + "~" + invitation.getExecuteEndDate();
|
|
|
|
|
+ }
|
|
|
|
|
+ return invitation.getExecuteStartDate().toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (invitation != null && invitation.getReplyDeadline() != null) {
|
|
|
|
|
+ return TIME_FORMAT.format(invitation.getReplyDeadline());
|
|
|
|
|
+ }
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static String buildOperationType(Integer eventType) {
|
|
|
|
|
+ if (eventType == null) {
|
|
|
|
|
+ return "完成响应";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (eventType == 1) {
|
|
|
|
|
+ return "参与削峰";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (eventType == 2) {
|
|
|
|
|
+ return "参与填谷";
|
|
|
|
|
+ }
|
|
|
|
|
+ return "完成响应";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static String formatNumber(BigDecimal value) {
|
|
|
|
|
+ if (value == null) {
|
|
|
|
|
+ return "0";
|
|
|
|
|
+ }
|
|
|
|
|
+ return value.stripTrailingZeros().toPlainString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private static String escapeJson(String value) {
|
|
private static String escapeJson(String value) {
|