From e5a404eff8557bb0debb10b6d4f6da602323a5a9 Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Tue, 26 Sep 2023 07:24:21 +0530 Subject: [PATCH 01/22] PFM-4640 --- frontend/mgramseva/lib/screeens/common/payment_success.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/mgramseva/lib/screeens/common/payment_success.dart b/frontend/mgramseva/lib/screeens/common/payment_success.dart index 9d4cb6ea8..e25ef5411 100644 --- a/frontend/mgramseva/lib/screeens/common/payment_success.dart +++ b/frontend/mgramseva/lib/screeens/common/payment_success.dart @@ -142,7 +142,7 @@ class _PaymentSuccessState extends State { backButton: false, isWithoutLogin: true, isConsumer: true, - amount: '${transactionObject.transaction!.first.currencyCode! ?? ''} ${transactionObject.transaction!.first.txnAmount! ?? '0'}', + amount: '${transactionObject.transaction!.first.txnAmount! ?? '0'}', ) : NoLoginFailurePage(i18.payment.PAYMENT_FAILED); } From f36c3ee6c18d566f5329beca9cafe82511f3ed00 Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Tue, 26 Sep 2023 07:51:30 +0530 Subject: [PATCH 02/22] PFM-4592 --- frontend/mgramseva/lib/model/connection/water_connection.g.dart | 2 +- .../mgramseva/lib/screeens/add_expense/expense_details.dart | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/mgramseva/lib/model/connection/water_connection.g.dart b/frontend/mgramseva/lib/model/connection/water_connection.g.dart index 598c971f8..f7abbfd0b 100644 --- a/frontend/mgramseva/lib/model/connection/water_connection.g.dart +++ b/frontend/mgramseva/lib/model/connection/water_connection.g.dart @@ -42,7 +42,7 @@ WaterConnection _$WaterConnectionFromJson(Map json) => json['processInstance'] as Map) ..paymentType = json['paymentType'] as String? ..penalty = (json['penalty'] as num?)?.toDouble() - ..advance = (json['advance'] as num?)?.toDouble(); + ..advance = (json['advance'] as num?)?.toDouble().abs(); Map _$WaterConnectionToJson(WaterConnection instance) => { diff --git a/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart b/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart index b77a86929..a546796fc 100644 --- a/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart +++ b/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart @@ -276,6 +276,7 @@ class _ExpenseDetailsState extends State { FilteringTextInputFormatter.allow( RegExp(r"^[1-9][0-9]{0,5}$")) ], + hint: '${i18.expense.AMOUNT} (₹)', labelSuffix: '(₹)', isDisabled: (expenseDetails.allowEdit ?? true) ? false From a0dc6aaa68b5be124a03605b054669e0e8c3b1e9 Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Wed, 27 Sep 2023 10:14:09 +0530 Subject: [PATCH 03/22] PFM-4589 --- .../mgramseva/lib/screeens/add_expense/expense_details.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart b/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart index a546796fc..cc1bb3026 100644 --- a/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart +++ b/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart @@ -276,7 +276,7 @@ class _ExpenseDetailsState extends State { FilteringTextInputFormatter.allow( RegExp(r"^[1-9][0-9]{0,5}$")) ], - hint: '${i18.expense.AMOUNT} (₹)', + placeHolder: '${i18.expense.AMOUNT} (₹)', labelSuffix: '(₹)', isDisabled: (expenseDetails.allowEdit ?? true) ? false From f2a408a1b1203ec981fcb882a3af387fa586271c Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Wed, 27 Sep 2023 10:47:32 +0530 Subject: [PATCH 04/22] PFM-4592 --- .../lib/providers/household_register_provider.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/mgramseva/lib/providers/household_register_provider.dart b/frontend/mgramseva/lib/providers/household_register_provider.dart index 1581a9a69..414d6ce01 100644 --- a/frontend/mgramseva/lib/providers/household_register_provider.dart +++ b/frontend/mgramseva/lib/providers/household_register_provider.dart @@ -278,9 +278,9 @@ class HouseholdRegisterProvider with ChangeNotifier { TableData('${name ?? ''}'), TableData('${fatherName ?? ''}'), TableData( - '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '${connection.additionalDetails?.collectionPendingAmount}' : '-'}'), + '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}'), TableData( - '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '').abs()}' : '-' : '-'}'), + '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}'), TableData( '${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}', style: TextStyle( @@ -405,8 +405,8 @@ class HouseholdRegisterProvider with ChangeNotifier { '${connection.connectionNo ?? ''} ${connection.connectionType == 'Metered' ? '- M' : ''}', '${connection.connectionHolders?.first.name ?? ''}', '${connection.connectionHolders?.first.fatherOrHusbandName ?? ''}', - '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '${connection.additionalDetails?.collectionPendingAmount}' : '-'}', - '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '- ₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '').abs()}' : '₹ 0' : '₹ 0'}', + '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}', + '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}', '${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}', '${connection.additionalDetails?.lastDemandGeneratedDate != null && connection.additionalDetails?.lastDemandGeneratedDate != '' ? DateFormats.timeStampToDate(int.parse(connection.additionalDetails?.lastDemandGeneratedDate ?? '')) : '-'}' ]) @@ -418,8 +418,8 @@ class HouseholdRegisterProvider with ChangeNotifier { '${connection.oldConnectionNo ?? ''}', '${connection.connectionHolders?.first.name ?? ''}', '${connection.connectionHolders?.first.fatherOrHusbandName ?? ''}', - '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '${connection.additionalDetails?.collectionPendingAmount}' : '-'}', - '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '- ₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '').abs()}' : '₹ 0' : '₹ 0'}', + '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}', + '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}', '${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}', '${connection.additionalDetails?.lastDemandGeneratedDate != null && connection.additionalDetails?.lastDemandGeneratedDate != '' ? DateFormats.timeStampToDate(int.parse(connection.additionalDetails?.lastDemandGeneratedDate ?? '')) : '-'}' ]) From 3f6927c53c175f31094b90809519a46c5dddcbc5 Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Wed, 27 Sep 2023 21:28:37 +0530 Subject: [PATCH 05/22] PFM-4793 --- .../lib/providers/household_register_provider.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/mgramseva/lib/providers/household_register_provider.dart b/frontend/mgramseva/lib/providers/household_register_provider.dart index 414d6ce01..5b3c3c285 100644 --- a/frontend/mgramseva/lib/providers/household_register_provider.dart +++ b/frontend/mgramseva/lib/providers/household_register_provider.dart @@ -278,9 +278,9 @@ class HouseholdRegisterProvider with ChangeNotifier { TableData('${name ?? ''}'), TableData('${fatherName ?? ''}'), TableData( - '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}'), + '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-'}'), TableData( - '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}'), + '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-' : '-'}'), TableData( '${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}', style: TextStyle( @@ -405,8 +405,8 @@ class HouseholdRegisterProvider with ChangeNotifier { '${connection.connectionNo ?? ''} ${connection.connectionType == 'Metered' ? '- M' : ''}', '${connection.connectionHolders?.first.name ?? ''}', '${connection.connectionHolders?.first.fatherOrHusbandName ?? ''}', - '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}', - '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}', + '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-'}', + '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '₹ 0' : '₹ 0'}', '${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}', '${connection.additionalDetails?.lastDemandGeneratedDate != null && connection.additionalDetails?.lastDemandGeneratedDate != '' ? DateFormats.timeStampToDate(int.parse(connection.additionalDetails?.lastDemandGeneratedDate ?? '')) : '-'}' ]) @@ -418,8 +418,8 @@ class HouseholdRegisterProvider with ChangeNotifier { '${connection.oldConnectionNo ?? ''}', '${connection.connectionHolders?.first.name ?? ''}', '${connection.connectionHolders?.first.fatherOrHusbandName ?? ''}', - '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}', - '${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}', + '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-'}', + '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '₹ 0' : '₹ 0'}', '${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}', '${connection.additionalDetails?.lastDemandGeneratedDate != null && connection.additionalDetails?.lastDemandGeneratedDate != '' ? DateFormats.timeStampToDate(int.parse(connection.additionalDetails?.lastDemandGeneratedDate ?? '')) : '-'}' ]) From 1740e16363366269abdcceddec18bdef2ff7a6bc Mon Sep 17 00:00:00 2001 From: Saloni-eGov Date: Wed, 4 Oct 2023 16:33:19 +0530 Subject: [PATCH 06/22] PFM-4408 Payment date is not reflecting --- .../lib/model/expenses_details/expenses_details.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart b/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart index 4a30d571b..95c46ecc5 100644 --- a/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart +++ b/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart @@ -167,10 +167,10 @@ class ExpensesDetailsModel { expensesAmount?.first.amount ?? totalAmount?.toInt().toString() ?? ''; billDateCtrl.text = DateFormats.timeStampToDate(billDate); paidDateCtrl.text = - paidDate == 0 ? '' : DateFormats.timeStampToDate(paidDate); + paidDate == null || paidDate == 0 ? '' : DateFormats.timeStampToDate(paidDate); billIssuedDateCtrl.text = billIssuedDate == 0 ? '' : DateFormats.timeStampToDate(billIssuedDate); - isBillPaid ??= false; + isBillPaid = paidDate != null && paidDate != 0 ? isBillPaid : false; challanNumberCtrl.text = challanNo?.toString() ?? ''; fromDateCtrl.text = DateFormats.timeStampToDate(taxPeriodFrom); toDateCtrl.text = DateFormats.timeStampToDate(taxPeriodTo); @@ -179,7 +179,7 @@ class ExpensesDetailsModel { selectedVendor = Vendor(vendorName ?? '', vendorId ?? ''); } - if (isBillPaid!) { + if (isBillPaid! && paidDate != null && paidDate != 0) { allowEdit = false; } else { paidDateCtrl.text = ''; From 56e19d1fcdf333f302c6ea9861977a2b87d106db Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 5 Oct 2023 13:45:30 +0530 Subject: [PATCH 07/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- .../web/notification/sms/consumer/contract/SMSRequest.java | 6 +++--- .../main/java/org/egov/web/notification/sms/models/Sms.java | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/consumer/contract/SMSRequest.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/consumer/contract/SMSRequest.java index 26bf91620..78d8805fe 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/consumer/contract/SMSRequest.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/consumer/contract/SMSRequest.java @@ -34,10 +34,10 @@ public class SMSRequest { private String templateId; public Sms toDomain() { - if (category == null) { - return new Sms(mobileNumber, message, Category.OTHERS, expiryTime,templateId); + if (category == null || tenantId == null) { + return new Sms(mobileNumber, message, Category.OTHERS, expiryTime,templateId,"pb"); } else { - return new Sms(mobileNumber, message, category, expiryTime, templateId); + return new Sms(mobileNumber, message, category, expiryTime, templateId,tenantId); } } } diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/Sms.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/Sms.java index 0a6cf022d..2dd3b7f6a 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/Sms.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/Sms.java @@ -18,6 +18,7 @@ public class Sms { private Category category; private Long expiryTime; private String templateId; + private String tenantId; public boolean isValid() { return isNotEmpty(mobileNumber) && isNotEmpty(message); From 2eeec6c7d89161bb1dd0a72fdaaf4a5cedae0955 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 5 Oct 2023 14:04:52 +0530 Subject: [PATCH 08/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- .../sms/config/SMSProperties.java | 3 +++ .../sms/controller/TestController.java | 2 +- .../sms/models/SmsSaveRequest.java | 25 +++++++++++++++++++ .../notification/sms/producer/Producer.java | 18 +++++++++++++ .../sms/service/BaseSMSService.java | 10 +++++++- .../src/main/resources/application.properties | 5 +++- 6 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java create mode 100644 core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/producer/Producer.java diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java index 3df4e7541..6355de06a 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java @@ -87,6 +87,9 @@ public class SMSProperties { @Value("${sms.enabled:false}") private boolean smsEnabled; + @Value("${save.sms.entity.topic}") + private String saveSmsTopic; + @Setter(AccessLevel.PROTECTED) private List whitelistPatterns; @Setter(AccessLevel.PROTECTED) private List blacklistPatterns; diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/controller/TestController.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/controller/TestController.java index e666a254d..467baa93a 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/controller/TestController.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/controller/TestController.java @@ -25,7 +25,7 @@ public ResponseEntity test(@RequestParam(value="number", required = true) Str //Sms sms = new Sms(number, sms, Category.OTP, expirytime); - Sms sms = new Sms(number, msg, category, expirytime, "123"); + Sms sms = new Sms(number, msg, category, expirytime, "123","pb"); smsService.sendSMS(sms); diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java new file mode 100644 index 000000000..a22346cb2 --- /dev/null +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java @@ -0,0 +1,25 @@ +package org.egov.web.notification.sms.models; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import static org.apache.commons.lang3.StringUtils.isNotEmpty; + +@AllArgsConstructor +@NoArgsConstructor +@Builder +@ToString +public class SmsSaveRequest { + private String mobileNumber; + private String message; + private Category category; + private Long createdtime; + private String templateId; + private String tenantId; + public boolean isValid() { + + return isNotEmpty(mobileNumber) && isNotEmpty(message); + } +} diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/producer/Producer.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/producer/Producer.java new file mode 100644 index 000000000..48190b21b --- /dev/null +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/producer/Producer.java @@ -0,0 +1,18 @@ +package org.egov.web.notification.sms.producer; + +import lombok.extern.slf4j.Slf4j; +import org.egov.tracer.kafka.CustomKafkaTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +public class Producer { + + @Autowired + private CustomKafkaTemplate kafkaTemplate; + + public void push(String topic, Object value) { + kafkaTemplate.send(topic, value); + } +} diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java index fdf107534..7f221c2e0 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java @@ -7,6 +7,7 @@ import org.apache.http.impl.client.*; import org.egov.web.notification.sms.config.*; import org.egov.web.notification.sms.models.*; +import org.egov.web.notification.sms.producer.Producer; import org.springframework.asm.*; import org.springframework.beans.factory.annotation.*; import org.springframework.core.*; @@ -41,6 +42,9 @@ abstract public class BaseSMSService implements SMSService, SMSBodyBuilder { @Autowired protected Environment env; + @Autowired + private Producer producer; + @PostConstruct public void init() { List> converters = restTemplate.getMessageConverters(); @@ -75,6 +79,10 @@ public void sendSMS(Sms sms) { return; } log.info("calling submitToExternalSmsService() method"); + SmsSaveRequest smsSaveRequest = SmsSaveRequest.builder().mobileNumber(sms.getMobileNumber()).message(sms.getMessage()) + .category(sms.getCategory()).templateId(sms.getTemplateId()).tenantId(sms.getTenantId()).createdtime(System.currentTimeMillis()).build(); + log.info("SMS request to save sms topic" +smsSaveRequest ); + producer.push(smsProperties.getSaveSmsTopic(), smsSaveRequest); submitToExternalSmsService(sms); } @@ -128,7 +136,7 @@ protected ResponseEntity executeAPI(URI uri, HttpMethod method, HttpEntit log.error("error response from third party api: info:"+responseMap.get("info")); throw new RuntimeException(responseMap.get("info")); } - + log.info("executeAPI() end"); return res; } diff --git a/core-services/egov-notification-sms/src/main/resources/application.properties b/core-services/egov-notification-sms/src/main/resources/application.properties index 27b4b4605..a02de326c 100644 --- a/core-services/egov-notification-sms/src/main/resources/application.properties +++ b/core-services/egov-notification-sms/src/main/resources/application.properties @@ -87,4 +87,7 @@ spring.kafka.consumer.properties.spring.deserializer.value.delegate.class=org.eg #spring.kafka.consumer.properties.spring.deserializer.value.delegate.class=org.springframework.kafka.support.serializer.JsonDeserializer spring.kafka.consumer.properties.spring.json.trusted.packages=org.egov spring.kafka.consumer.properties.spring.json.type.mapping=smsRequest:org.egov.web.notification.sms.consumer.contract.SMSRequest -spring.kafka.listener.missing-topics-fatal=false \ No newline at end of file +spring.kafka.listener.missing-topics-fatal=false + +#persister topic of sms +save.sms.entity.topic = save-sms-entity-application \ No newline at end of file From d471c7d625e66b2f1ac27133760fb653fe92b91e Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 5 Oct 2023 14:44:32 +0530 Subject: [PATCH 09/22] PFM-4871: added chnnages for concerened service that are sending SMS to notification service to add tenantid in SMS request --- .../demand/consumer/notification/NotificationConsumer.java | 1 + .../src/main/java/org/egov/echallan/model/SMSRequest.java | 1 + .../java/org/egov/echallan/service/SchedulerService.java | 3 +++ .../wscalculation/consumer/DemandGenerationConsumer.java | 1 + .../wscalculation/service/DemandNotificationService.java | 2 +- .../java/org/egov/wscalculation/service/DemandService.java | 6 +++--- .../java/org/egov/wscalculation/web/models/SMSRequest.java | 1 + .../waterconnection/service/EditNotificationService.java | 2 +- .../egov/waterconnection/service/PaymentUpdateService.java | 2 +- .../org/egov/waterconnection/service/SchedulerService.java | 4 ++-- .../service/WorkflowNotificationService.java | 2 +- .../org/egov/waterconnection/web/models/SMSRequest.java | 3 ++- 12 files changed, 18 insertions(+), 10 deletions(-) diff --git a/business-services/billing-service/src/main/java/org/egov/demand/consumer/notification/NotificationConsumer.java b/business-services/billing-service/src/main/java/org/egov/demand/consumer/notification/NotificationConsumer.java index 65cc1f4f7..179672d76 100644 --- a/business-services/billing-service/src/main/java/org/egov/demand/consumer/notification/NotificationConsumer.java +++ b/business-services/billing-service/src/main/java/org/egov/demand/consumer/notification/NotificationConsumer.java @@ -114,6 +114,7 @@ private void sendNotification(BillRequest billReq) { Map request = new HashMap<>(); request.put("mobileNumber", phNo); request.put("message", message); + request.put("tenantId", bill.getTenantId()); log.info("Msg sent to user : " + message); if(isSmsForBillNotificationEnabled) { producer.send(smsTopic, smsTopickey, request); diff --git a/municipal-services/echallan-services/src/main/java/org/egov/echallan/model/SMSRequest.java b/municipal-services/echallan-services/src/main/java/org/egov/echallan/model/SMSRequest.java index 42c1c5afc..22820ec15 100644 --- a/municipal-services/echallan-services/src/main/java/org/egov/echallan/model/SMSRequest.java +++ b/municipal-services/echallan-services/src/main/java/org/egov/echallan/model/SMSRequest.java @@ -12,6 +12,7 @@ public class SMSRequest { private String mobileNumber; private String message; private String templateId; + private String tenantid; private String[] users; } diff --git a/municipal-services/echallan-services/src/main/java/org/egov/echallan/service/SchedulerService.java b/municipal-services/echallan-services/src/main/java/org/egov/echallan/service/SchedulerService.java index f9d21456d..22ef7a5f0 100644 --- a/municipal-services/echallan-services/src/main/java/org/egov/echallan/service/SchedulerService.java +++ b/municipal-services/echallan-services/src/main/java/org/egov/echallan/service/SchedulerService.java @@ -256,6 +256,7 @@ public void sendNewExpenditureEvent(RequestInfo requestInfo) { System.out.println("New Expenditure SMS :: " + message); SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(message) + .tenantid(tenantId) .templateId(messageMap.get(NotificationUtil.TEMPLATE_KEY)) .users(new String[] { map.getValue() }).build(); if(config.isSmsForExpenditureEnabled()) { @@ -452,6 +453,7 @@ public void sendMarkExpensebillEvent(RequestInfo requestInfo) { // value. System.out.println("Mark expense bills SMS::" + message); SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(message) + .tenantid(tenantId) .templateId(messageMap.get(NotificationUtil.TEMPLATE_KEY)) .users(new String[] { map.getValue() }).build(); if(config.isSmsForMarkBillEnabled()) { @@ -583,6 +585,7 @@ public void sendMonthSummaryEvent(RequestInfo requestInfo) { message = message.replace("{user}", uuidUsername); System.out.println("SMS Notification::" + message); SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(message) + .tenantid(tenantId) .templateId(messageMap.get(NotificationUtil.TEMPLATE_KEY)) .users(new String[] { uuidUsername }).build(); if(config.isSmsForMonthlySummaryEnabled()) { diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 840576f72..393cfe5e3 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -483,6 +483,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t System.out.println("Demand GP USER SMS1::" + msg); if(!map.getKey().equals(config.getPspclVendorNumber())) { SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(msg) + .tenantid(tenantId) .category(Category.TRANSACTION).build(); if(config.isSmsForDemandEnable()) { producer.push(config.getSmsNotifTopic(), smsRequest); diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandNotificationService.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandNotificationService.java index 60f839196..8c5b3dd5d 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandNotificationService.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandNotificationService.java @@ -61,7 +61,7 @@ private void enrichSMSRequest(DemandNotificationObj notificationObj, List { String message = util.getAppliedMsg(receiver, messageTemplate, notificationObj); - SMSRequest sms = SMSRequest.builder().mobileNumber(receiver.getMobileNumber()).message(message).category(Category.TRANSACTION).build(); + SMSRequest sms = SMSRequest.builder().mobileNumber(receiver.getMobileNumber()).message(message).category(Category.TRANSACTION).tenantid(tenantId).build(); smsRequest.add(sms); }); } diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java index c2cb6276d..6292bcfc4 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java @@ -341,7 +341,7 @@ private void sendPaymentSMSNotification(RequestInfo requestInfo, String tenantId System.out.println("payment genaration Message1::" + messageString); - SMSRequest sms = SMSRequest.builder().mobileNumber(owner.getMobileNumber()).message(messageString) + SMSRequest sms = SMSRequest.builder().mobileNumber(owner.getMobileNumber()).message(messageString).tenantid(tenantId) .category(Category.TRANSACTION).build(); if(config.isSmsForPaymentLinkEnable()) { producer.push(config.getSmsNotifTopic(), sms); @@ -381,7 +381,7 @@ private void sendDownloadBillSMSNotification(RequestInfo requestInfo, String ten System.out.println("Demand genaration Message get bill::" + messageString); - SMSRequest sms = SMSRequest.builder().mobileNumber(owner.getMobileNumber()).message(messageString) + SMSRequest sms = SMSRequest.builder().mobileNumber(owner.getMobileNumber()).message(messageString).tenantid(tenantId) .category(Category.TRANSACTION).build(); if(config.isSmsForBillDownloadEnabled()) { producer.push(config.getSmsNotifTopic(), sms); @@ -432,7 +432,7 @@ private void sendPaymentAndBillSMSNotification(RequestInfo requestInfo, String t System.out.println("Denmand and Payment genaration Message::" + messageString); SMSRequest sms = SMSRequest.builder().mobileNumber(owner.getMobileNumber()).message(messageString) - .category(Category.TRANSACTION).build(); + .category(Category.TRANSACTION).tenantid(tenantId).build(); if(config.isSmsForBillDownloadEnabled() && config.isSmsForPaymentLinkEnable()) { producer.push(config.getSmsNotifTopic(), sms); } diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/web/models/SMSRequest.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/web/models/SMSRequest.java index e7d578125..cb859eb08 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/web/models/SMSRequest.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/web/models/SMSRequest.java @@ -17,4 +17,5 @@ public class SMSRequest { private String message; private Category category; private Long expiryTime; + private String tenantid; } diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/EditNotificationService.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/EditNotificationService.java index 3fdc5ddd0..2d11fe080 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/EditNotificationService.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/EditNotificationService.java @@ -181,7 +181,7 @@ private List getSmsRequest(WaterConnectionRequest waterConnectionReq .getMessageForMobileNumber(mobileNumbersAndNames, waterConnectionRequest, message, property, new HashMap<>()); List smsRequest = new ArrayList<>(); mobileNumberAndMessage.forEach((mobileNumber, msg) -> { - SMSRequest req = SMSRequest.builder().mobileNumber(mobileNumber).message(msg).category(Category.TRANSACTION).build(); + SMSRequest req = SMSRequest.builder().mobileNumber(mobileNumber).message(msg).category(Category.TRANSACTION).tenantId(waterConnectionRequest.getWaterConnection().getTenantId()).build(); smsRequest.add(req); }); return smsRequest; diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/PaymentUpdateService.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/PaymentUpdateService.java index 1f35c9494..5a4c9c7b4 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/PaymentUpdateService.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/PaymentUpdateService.java @@ -358,7 +358,7 @@ private List getSmsRequest(WaterConnectionRequest waterConnectionReq List smsRequest = new ArrayList<>(); mobileNumberAndMessage.forEach((mobileNumber, msg) -> { - SMSRequest req = SMSRequest.builder().mobileNumber(mobileNumber).message(msg).category(Category.TRANSACTION).build(); + SMSRequest req = SMSRequest.builder().mobileNumber(mobileNumber).message(msg).category(Category.TRANSACTION).tenantId(waterConnectionRequest.getWaterConnection().getTenantId()).build(); smsRequest.add(req); }); return smsRequest; diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/SchedulerService.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/SchedulerService.java index fd4194403..bfe7174b6 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/SchedulerService.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/SchedulerService.java @@ -166,7 +166,7 @@ public void sendPendingCollectionEvent(RequestInfo requestInfo) { message = message.replace("{Date}", LocalDate.now().toString()); System.out.println("PENDING Coll SMS::" + message); SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(message) - .templateId(messageMap.get(NotificationUtil.TEMPLATE_KEY)) + .templateId(messageMap.get(NotificationUtil.TEMPLATE_KEY)).tenantId(tenantId) .users(new String[] { uuidUsername }).build(); if(config.isSMSForPendingCollectionEnabled()) { producer.push(config.getSmsNotifTopic(), smsRequest); @@ -467,7 +467,7 @@ public void sendTodaysCollection(RequestInfo requestInfo) { msg = msg.replace("{date}", formattedDate); System.out.println("TODAY Coll SMS::" + msg); SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()) - .message(msg).templateId(messageMap.get(NotificationUtil.TEMPLATE_KEY)) + .message(msg).templateId(messageMap.get(NotificationUtil.TEMPLATE_KEY)).tenantId(tenantId) .users(new String[] { uuidUsername }).build(); if(config.isSMSForTodaysCollectionEnabled()) { producer.push(config.getSmsNotifTopic(), smsRequest); diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WorkflowNotificationService.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WorkflowNotificationService.java index e33b41bb8..253956a81 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WorkflowNotificationService.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WorkflowNotificationService.java @@ -304,7 +304,7 @@ private List getSmsRequest(WaterConnectionRequest waterConnectionReq mobileNumberAndMessage = setRecepitDownloadLink(mobileNumberAndMessage, waterConnectionRequest, message, property); List smsRequest = new ArrayList<>(); mobileNumberAndMessage.forEach((mobileNumber, msg) -> { - SMSRequest req = SMSRequest.builder().mobileNumber(mobileNumber).message(msg).category(Category.TRANSACTION).build(); + SMSRequest req = SMSRequest.builder().mobileNumber(mobileNumber).message(msg).category(Category.TRANSACTION).tenantId(waterConnectionRequest.getWaterConnection().getTenantId()).build(); smsRequest.add(req); }); return smsRequest; diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/SMSRequest.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/SMSRequest.java index 407b29aad..10a06df16 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/SMSRequest.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/SMSRequest.java @@ -18,6 +18,7 @@ public class SMSRequest { private Category category; private Long expiryTime; private String templateId; - private String[] users; + private String[] users; + private String tenantId; } From 4fe1ac92285870778069187c9b0b1b08ed8cee97 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 5 Oct 2023 16:01:29 +0530 Subject: [PATCH 10/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- .../notification/sms/consumer/contract/SMSRequest.java | 5 +++-- .../src/main/resources/db/Dockerfile | 9 +++++++++ .../src/main/resources/db/migrate.sh | 3 +++ .../V20231005150835_notification_sms_ddl.sql | 9 +++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 core-services/egov-notification-sms/src/main/resources/db/Dockerfile create mode 100644 core-services/egov-notification-sms/src/main/resources/db/migrate.sh create mode 100644 core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/consumer/contract/SMSRequest.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/consumer/contract/SMSRequest.java index 78d8805fe..cf9a9b422 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/consumer/contract/SMSRequest.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/consumer/contract/SMSRequest.java @@ -34,8 +34,9 @@ public class SMSRequest { private String templateId; public Sms toDomain() { - if (category == null || tenantId == null) { - return new Sms(mobileNumber, message, Category.OTHERS, expiryTime,templateId,"pb"); + if (category == null) { + return new Sms(mobileNumber, message, Category.OTHERS, expiryTime,templateId,null); + } else { return new Sms(mobileNumber, message, category, expiryTime, templateId,tenantId); } diff --git a/core-services/egov-notification-sms/src/main/resources/db/Dockerfile b/core-services/egov-notification-sms/src/main/resources/db/Dockerfile new file mode 100644 index 000000000..60fc07ce6 --- /dev/null +++ b/core-services/egov-notification-sms/src/main/resources/db/Dockerfile @@ -0,0 +1,9 @@ +FROM egovio/flyway:4.1.2 + +COPY ./migration/main /flyway/sql + +COPY migrate.sh /usr/bin/migrate.sh + +RUN chmod +x /usr/bin/migrate.sh + +CMD ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/core-services/egov-notification-sms/src/main/resources/db/migrate.sh b/core-services/egov-notification-sms/src/main/resources/db/migrate.sh new file mode 100644 index 000000000..54d07c094 --- /dev/null +++ b/core-services/egov-notification-sms/src/main/resources/db/migrate.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate diff --git a/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql b/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql new file mode 100644 index 000000000..a5cc0b613 --- /dev/null +++ b/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS eg_notification_sms ( + id CHARACTER VARYING (128) NOT NULL, + mobile_no VARCHAR(20) NOT NULL, + message TEXT, + category VARCHAR(50), + template_id VARCHAR(50), + createdtime TIMESTAMP, + tenant_id VARCHAR(50) +); From ead650dbb9509de8f7dcea3a41252264264bd8c1 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 5 Oct 2023 16:02:17 +0530 Subject: [PATCH 11/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- .../org/egov/web/notification/sms/models/SmsSaveRequest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java index a22346cb2..a1e84d7ea 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java @@ -12,6 +12,7 @@ @Builder @ToString public class SmsSaveRequest { + private String id; private String mobileNumber; private String message; private Category category; From 1ccdb4ee911915c0763e8958b56895e478cb1f47 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 5 Oct 2023 16:49:40 +0530 Subject: [PATCH 12/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- .../db/migration.main/V20231005150835_notification_sms_ddl.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql b/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql index a5cc0b613..e5344c243 100644 --- a/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql +++ b/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql @@ -1,5 +1,5 @@ CREATE TABLE IF NOT EXISTS eg_notification_sms ( - id CHARACTER VARYING (128) NOT NULL, + id SERIAL PRIMARY KEY, mobile_no VARCHAR(20) NOT NULL, message TEXT, category VARCHAR(50), From f9818bc1adfd9abef2bc7487cf0b8371e5540735 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 6 Oct 2023 10:18:54 +0530 Subject: [PATCH 13/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- .../web/notification/sms/config/SMSProperties.java | 3 +++ .../web/notification/sms/service/BaseSMSService.java | 10 ++++++---- .../src/main/resources/application.properties | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java index 6355de06a..223b9e1a3 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java @@ -90,6 +90,9 @@ public class SMSProperties { @Value("${save.sms.entity.topic}") private String saveSmsTopic; + @Value("${save.sms.entity.enabled}") + private boolean isSaveSmsEnable; + @Setter(AccessLevel.PROTECTED) private List whitelistPatterns; @Setter(AccessLevel.PROTECTED) private List blacklistPatterns; diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java index 7f221c2e0..efdafab22 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java @@ -79,10 +79,12 @@ public void sendSMS(Sms sms) { return; } log.info("calling submitToExternalSmsService() method"); - SmsSaveRequest smsSaveRequest = SmsSaveRequest.builder().mobileNumber(sms.getMobileNumber()).message(sms.getMessage()) - .category(sms.getCategory()).templateId(sms.getTemplateId()).tenantId(sms.getTenantId()).createdtime(System.currentTimeMillis()).build(); - log.info("SMS request to save sms topic" +smsSaveRequest ); - producer.push(smsProperties.getSaveSmsTopic(), smsSaveRequest); + if(smsProperties.isSaveSmsEnable()) { + SmsSaveRequest smsSaveRequest = SmsSaveRequest.builder().mobileNumber(sms.getMobileNumber()).message(sms.getMessage()) + .category(sms.getCategory()).templateId(sms.getTemplateId()).tenantId(sms.getTenantId()).createdtime(System.currentTimeMillis()).build(); + log.info("SMS request to save sms topic" + smsSaveRequest); + producer.push(smsProperties.getSaveSmsTopic(), smsSaveRequest); + } submitToExternalSmsService(sms); } diff --git a/core-services/egov-notification-sms/src/main/resources/application.properties b/core-services/egov-notification-sms/src/main/resources/application.properties index a02de326c..b2a4544e7 100644 --- a/core-services/egov-notification-sms/src/main/resources/application.properties +++ b/core-services/egov-notification-sms/src/main/resources/application.properties @@ -90,4 +90,5 @@ spring.kafka.consumer.properties.spring.json.type.mapping=smsRequest:org.egov.we spring.kafka.listener.missing-topics-fatal=false #persister topic of sms -save.sms.entity.topic = save-sms-entity-application \ No newline at end of file +save.sms.entity.topic = save-sms-entity-application +save.sms.entity.enabled = true \ No newline at end of file From 21531898e046e4e6a941a70612c13bcf3d6d567a Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 6 Oct 2023 11:22:30 +0530 Subject: [PATCH 14/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- core-services/egov-notification-sms/pom.xml | 5 +++++ .../sms/models/SmsSaveRequest.java | 2 +- .../builder/SmsNotificationRepository.java | 22 +++++++++++++++++++ .../sms/service/BaseSMSService.java | 7 +++++- .../V20231005150835_notification_sms_ddl.sql | 10 ++++++++- 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java diff --git a/core-services/egov-notification-sms/pom.xml b/core-services/egov-notification-sms/pom.xml index 4268b706a..0b85ef8d8 100644 --- a/core-services/egov-notification-sms/pom.xml +++ b/core-services/egov-notification-sms/pom.xml @@ -71,6 +71,11 @@ spring-boot-starter-test test + + org.springframework + spring-jdbc + 5.3.23 + diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java index a1e84d7ea..8b3c660c4 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java @@ -12,7 +12,7 @@ @Builder @ToString public class SmsSaveRequest { - private String id; + private Long id; private String mobileNumber; private String message; private Category category; diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java new file mode 100644 index 000000000..505990986 --- /dev/null +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java @@ -0,0 +1,22 @@ +package org.egov.web.notification.sms.repository.builder; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Repository; +import org.springframework.jdbc.core.JdbcTemplate; + +@Component +@Slf4j +@Repository +public class SmsNotificationRepository { + + private JdbcTemplate jdbcTemplate; + + public static final String SELECT_NEXT_SEQUENCE_USER = "select nextval('seq_eg_notification_sms')"; + + public Long getNextSequence() { + return jdbcTemplate.queryForObject(SELECT_NEXT_SEQUENCE_USER, Long.class); + } + + +} diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java index efdafab22..4c257ada6 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java @@ -8,6 +8,7 @@ import org.egov.web.notification.sms.config.*; import org.egov.web.notification.sms.models.*; import org.egov.web.notification.sms.producer.Producer; +import org.egov.web.notification.sms.repository.builder.SmsNotificationRepository; import org.springframework.asm.*; import org.springframework.beans.factory.annotation.*; import org.springframework.core.*; @@ -45,6 +46,9 @@ abstract public class BaseSMSService implements SMSService, SMSBodyBuilder { @Autowired private Producer producer; + @Autowired + private SmsNotificationRepository smsNotificationRepository; + @PostConstruct public void init() { List> converters = restTemplate.getMessageConverters(); @@ -80,7 +84,8 @@ public void sendSMS(Sms sms) { } log.info("calling submitToExternalSmsService() method"); if(smsProperties.isSaveSmsEnable()) { - SmsSaveRequest smsSaveRequest = SmsSaveRequest.builder().mobileNumber(sms.getMobileNumber()).message(sms.getMessage()) + Long id = smsNotificationRepository.getNextSequence(); + SmsSaveRequest smsSaveRequest = SmsSaveRequest.builder().id(id).mobileNumber(sms.getMobileNumber()).message(sms.getMessage()) .category(sms.getCategory()).templateId(sms.getTemplateId()).tenantId(sms.getTenantId()).createdtime(System.currentTimeMillis()).build(); log.info("SMS request to save sms topic" + smsSaveRequest); producer.push(smsProperties.getSaveSmsTopic(), smsSaveRequest); diff --git a/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql b/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql index e5344c243..04ae434f5 100644 --- a/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql +++ b/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql @@ -1,5 +1,5 @@ CREATE TABLE IF NOT EXISTS eg_notification_sms ( - id SERIAL PRIMARY KEY, + id bigint NOT NULL, mobile_no VARCHAR(20) NOT NULL, message TEXT, category VARCHAR(50), @@ -7,3 +7,11 @@ CREATE TABLE IF NOT EXISTS eg_notification_sms ( createdtime TIMESTAMP, tenant_id VARCHAR(50) ); +CREATE SEQUENCE seq_eg_notification_sms + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER TABLE eg_notification_sms ADD CONSTRAINT eg_notification_sms_pkey PRIMARY KEY (id); + From 16a1b539dc0d903304d9ee5a25f1b67931f40b45 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 6 Oct 2023 13:03:53 +0530 Subject: [PATCH 15/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- .../src/main/resources/application.properties | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core-services/egov-notification-sms/src/main/resources/application.properties b/core-services/egov-notification-sms/src/main/resources/application.properties index b2a4544e7..81a4929d5 100644 --- a/core-services/egov-notification-sms/src/main/resources/application.properties +++ b/core-services/egov-notification-sms/src/main/resources/application.properties @@ -32,6 +32,23 @@ sms.extra.config.map={'extraParam': 'abc'} # this should be the name of class with first letter in small sms.url.dont_encode_url = true + +# DB CONNECTION CONFIGURATIONS +spring.datasource.driver-class-name=org.postgresql.Driver +spring.datasource.url=jdbc:postgresql://localhost:5432/ifixdb +spring.datasource.username=postgres +spring.datasource.password=postgres + +# FLYWAY CONFIGURATIONS +spring.flyway.url=jdbc:postgresql://localhost:5432/ifixdb +spring.flyway.user=postgres +spring.flyway.password=postgres +spring.flyway.baseline-on-migrate=true +spring.flyway.outOfOrder=true +spring.flyway.locations=classpath:/db/migration/main +spring.flyway.enabled=true +spring.flyway.table=ifix_migration_toolkit_schema + # KAFKA CONSUMER CONFIGURATIONS spring.kafka.consumer.auto_commit=true spring.kafka.consumer.auto_commit_interval=100 From 2f244bd8c8bacb0d987293ceff0c51b62742e31d Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 6 Oct 2023 13:46:15 +0530 Subject: [PATCH 16/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- .../src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core-services/egov-notification-sms/src/main/resources/application.properties b/core-services/egov-notification-sms/src/main/resources/application.properties index 81a4929d5..32189dee2 100644 --- a/core-services/egov-notification-sms/src/main/resources/application.properties +++ b/core-services/egov-notification-sms/src/main/resources/application.properties @@ -35,19 +35,19 @@ sms.url.dont_encode_url = true # DB CONNECTION CONFIGURATIONS spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=jdbc:postgresql://localhost:5432/ifixdb +spring.datasource.url=jdbc:postgresql://localhost:5432/devdb spring.datasource.username=postgres spring.datasource.password=postgres # FLYWAY CONFIGURATIONS -spring.flyway.url=jdbc:postgresql://localhost:5432/ifixdb +spring.flyway.url=jdbc:postgresql://localhost:5432/devdb spring.flyway.user=postgres spring.flyway.password=postgres spring.flyway.baseline-on-migrate=true spring.flyway.outOfOrder=true spring.flyway.locations=classpath:/db/migration/main spring.flyway.enabled=true -spring.flyway.table=ifix_migration_toolkit_schema +spring.flyway.table=eg_notification_sms_schema # KAFKA CONSUMER CONFIGURATIONS spring.kafka.consumer.auto_commit=true From 0a5ea72265c99ce25087f6fc1a15286b350cdee4 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 6 Oct 2023 14:28:51 +0530 Subject: [PATCH 17/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- core-services/egov-notification-sms/pom.xml | 18 +++++++++++++----- .../builder/SmsNotificationRepository.java | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core-services/egov-notification-sms/pom.xml b/core-services/egov-notification-sms/pom.xml index 0b85ef8d8..53a6fd996 100644 --- a/core-services/egov-notification-sms/pom.xml +++ b/core-services/egov-notification-sms/pom.xml @@ -35,6 +35,10 @@ spring-kafka 2.4.5.RELEASE + + org.springframework.boot + spring-boot-starter-jdbc + org.springframework.boot spring-boot-starter-web @@ -66,16 +70,20 @@ httpclient 4.5.3 + + org.flywaydb + flyway-core + + + org.postgresql + postgresql + 42.3.3 + org.springframework.boot spring-boot-starter-test test - - org.springframework - spring-jdbc - 5.3.23 - diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java index 505990986..4d3776372 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java @@ -1,6 +1,7 @@ package org.egov.web.notification.sms.repository.builder; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.stereotype.Repository; import org.springframework.jdbc.core.JdbcTemplate; @@ -10,6 +11,7 @@ @Repository public class SmsNotificationRepository { + @Autowired private JdbcTemplate jdbcTemplate; public static final String SELECT_NEXT_SEQUENCE_USER = "select nextval('seq_eg_notification_sms')"; From a2b31fda7ee67eeb85a24416281993e75bea9945 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 6 Oct 2023 15:01:07 +0530 Subject: [PATCH 18/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- core-services/egov-notification-sms/pom.xml | 4 +++- .../main/V20231006150836__notification_sms_ddl.sql} | 0 2 files changed, 3 insertions(+), 1 deletion(-) rename core-services/egov-notification-sms/src/main/resources/db/{migration.main/V20231005150835_notification_sms_ddl.sql => migration/main/V20231006150836__notification_sms_ddl.sql} (100%) diff --git a/core-services/egov-notification-sms/pom.xml b/core-services/egov-notification-sms/pom.xml index 53a6fd996..f001c6b98 100644 --- a/core-services/egov-notification-sms/pom.xml +++ b/core-services/egov-notification-sms/pom.xml @@ -73,11 +73,13 @@ org.flywaydb flyway-core + 6.4.3 org.postgresql postgresql - 42.3.3 + 9.4.1212 + runtime org.springframework.boot diff --git a/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql b/core-services/egov-notification-sms/src/main/resources/db/migration/main/V20231006150836__notification_sms_ddl.sql similarity index 100% rename from core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql rename to core-services/egov-notification-sms/src/main/resources/db/migration/main/V20231006150836__notification_sms_ddl.sql From 6bae8daa62b5568fb7d805f4b30333ff9cef3c61 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 6 Oct 2023 16:22:17 +0530 Subject: [PATCH 19/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- core-services/egov-notification-sms/pom.xml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/core-services/egov-notification-sms/pom.xml b/core-services/egov-notification-sms/pom.xml index f001c6b98..fa000fa4a 100644 --- a/core-services/egov-notification-sms/pom.xml +++ b/core-services/egov-notification-sms/pom.xml @@ -35,10 +35,6 @@ spring-kafka 2.4.5.RELEASE - - org.springframework.boot - spring-boot-starter-jdbc - org.springframework.boot spring-boot-starter-web @@ -70,16 +66,17 @@ httpclient 4.5.3 + + org.postgresql + postgresql + org.flywaydb flyway-core - 6.4.3 - org.postgresql - postgresql - 9.4.1212 - runtime + org.springframework.boot + spring-boot-starter-jdbc org.springframework.boot From d73b95d753afa1b904c78e7589a3774852239eb2 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 6 Oct 2023 17:07:23 +0530 Subject: [PATCH 20/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- .../src/main/resources/application.properties | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core-services/egov-notification-sms/src/main/resources/application.properties b/core-services/egov-notification-sms/src/main/resources/application.properties index 32189dee2..25849120a 100644 --- a/core-services/egov-notification-sms/src/main/resources/application.properties +++ b/core-services/egov-notification-sms/src/main/resources/application.properties @@ -40,14 +40,14 @@ spring.datasource.username=postgres spring.datasource.password=postgres # FLYWAY CONFIGURATIONS -spring.flyway.url=jdbc:postgresql://localhost:5432/devdb -spring.flyway.user=postgres -spring.flyway.password=postgres -spring.flyway.baseline-on-migrate=true -spring.flyway.outOfOrder=true -spring.flyway.locations=classpath:/db/migration/main -spring.flyway.enabled=true -spring.flyway.table=eg_notification_sms_schema +flyway.url=jdbc:postgresql://localhost:5432/devdb +flyway.user=postgres +flyway.password=postgres +flyway.baseline-on-migrate=true +flyway.outOfOrder=true +flyway.locations=classpath:/db/migration/main +flyway.enabled=true +flyway.table=eg_notification_sms_schema # KAFKA CONSUMER CONFIGURATIONS spring.kafka.consumer.auto_commit=true From 86585493cb08d0617975e16f33c91844f924a9f4 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Mon, 9 Oct 2023 11:22:21 +0530 Subject: [PATCH 21/22] PFM-4871: added the changes to persist sms in a table in mgramseva --- .../egov/web/notification/sms/service/BaseSMSService.java | 5 +++-- .../migration/main/V20231006150836__notification_sms_ddl.sql | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java index 4c257ada6..6a5d68310 100644 --- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java +++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java @@ -85,9 +85,10 @@ public void sendSMS(Sms sms) { log.info("calling submitToExternalSmsService() method"); if(smsProperties.isSaveSmsEnable()) { Long id = smsNotificationRepository.getNextSequence(); - SmsSaveRequest smsSaveRequest = SmsSaveRequest.builder().id(id).mobileNumber(sms.getMobileNumber()).message(sms.getMessage()) + String mobileNumber = sms.getMobileNumber(); + mobileNumber = mobileNumber.substring(0, 2) + mobileNumber.substring(6); + SmsSaveRequest smsSaveRequest = SmsSaveRequest.builder().id(id).mobileNumber(mobileNumber).message(sms.getMessage()) .category(sms.getCategory()).templateId(sms.getTemplateId()).tenantId(sms.getTenantId()).createdtime(System.currentTimeMillis()).build(); - log.info("SMS request to save sms topic" + smsSaveRequest); producer.push(smsProperties.getSaveSmsTopic(), smsSaveRequest); } submitToExternalSmsService(sms); diff --git a/core-services/egov-notification-sms/src/main/resources/db/migration/main/V20231006150836__notification_sms_ddl.sql b/core-services/egov-notification-sms/src/main/resources/db/migration/main/V20231006150836__notification_sms_ddl.sql index 04ae434f5..8c775e011 100644 --- a/core-services/egov-notification-sms/src/main/resources/db/migration/main/V20231006150836__notification_sms_ddl.sql +++ b/core-services/egov-notification-sms/src/main/resources/db/migration/main/V20231006150836__notification_sms_ddl.sql @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS eg_notification_sms ( message TEXT, category VARCHAR(50), template_id VARCHAR(50), - createdtime TIMESTAMP, + createdtime bigint, tenant_id VARCHAR(50) ); CREATE SEQUENCE seq_eg_notification_sms From 9abdb9d990136d3c0c1413450598781587a4355c Mon Sep 17 00:00:00 2001 From: Debasish Chakraborty <117706910+debasishchakraborty-egovt@users.noreply.github.com> Date: Mon, 9 Oct 2023 12:33:56 +0530 Subject: [PATCH 22/22] Update build-config.yml --- build/build-config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/build-config.yml b/build/build-config.yml index 54f341c8c..f2eedc178 100644 --- a/build/build-config.yml +++ b/build/build-config.yml @@ -94,6 +94,8 @@ config: - work-dir: "core-services/egov-notification-sms" image-name: "egov-notification-sms" dockerfile: "build/maven/Dockerfile" + - work-dir: "core-services/egov-notification-sms/src/main/resources/db" + image-name: "egov-notification-sms-db" - name: "builds/mGramSeva/utilities/mdms-read-cronjob" build: - work-dir: "utilities/mdms-read-cronjob"