added protocol in amendment request

This commit is contained in:
harish
2024-10-28 11:52:19 +05:30
23 changed files with 197 additions and 136 deletions

View File

@@ -44,7 +44,6 @@ import jakarta.servlet.http.HttpServletRequest;
import java.text.MessageFormat;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -91,9 +90,6 @@ public class ApplicationDao {
@Autowired
private CompanyService companyService;
@Autowired
private ProtocolRepository protocolRepository;
@Autowired
private SystemEmailTemplatesService systemEmailTemplatesService;
@@ -122,14 +118,14 @@ public class ApplicationDao {
@Value("${aws.s3.url.folder.signed.document}")
private String signedDocumentS3Folder;
@Value("${default.hub.uuid}")
private String defaultHubUuid;
@Autowired
private UserService userService;
@Autowired
S3PathConfig s3ConfigBean;
private S3PathConfig s3ConfigBean;
@Autowired
private ProtocolDao protocolDao;
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
@@ -606,8 +602,8 @@ public class ApplicationDao {
}
if (status.equals(ApplicationStatusTypeEnum.SUBMIT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) {
callService.validatePublishedCall(applicationEntity.getCall().getId(), userEntity.getHub().getId());
Long protocolNumber = getProtocolNumber(userEntity.getHub());
ProtocolEntity protocolEntity = createProtocolEntity(applicationEntity,protocolNumber, userEntity.getHub().getId());
Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub());
ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(applicationEntity,protocolNumber, userEntity.getHub().getId());
applicationEntity.setProtocol(protocolEntity);
applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue());
applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
@@ -622,14 +618,7 @@ public class ApplicationDao {
return getApplicationResponse(applicationEntity);
}
private Long getProtocolNumber(HubEntity hubEntity) {
Long maxProtocolNumber = protocolRepository.findMaxProtocolNumberAndHubId(hubEntity.getId());
Long startNumber = 10000001L;
if(Boolean.FALSE.equals(defaultHubUuid.equals(hubEntity.getUniqueUuid()))) {
startNumber = 20000001L;
}
return (maxProtocolNumber != null) ? maxProtocolNumber + 1 : startNumber;
}
public Integer calculateProgress(Long totalSteps, Long completedSteps) {
if (FieldValidator.isNullOrZero(totalSteps)) {
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.TOTAL_STEPS_NOT_BE_ZERO));
@@ -703,18 +692,6 @@ public class ApplicationDao {
}
}
public ProtocolEntity createProtocolEntity(ApplicationEntity applicationEntity,Long protocolNumber, Long hubId){
ProtocolEntity protocolEntity=new ProtocolEntity();
protocolEntity.setCall(applicationEntity.getCall().getId());
LocalDateTime utcDateTime = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
protocolEntity.setYear(utcDateTime.getYear());
protocolEntity.setProtocolNumber(protocolNumber);
protocolEntity.setTime(LocalTime.now());
protocolEntity.setApplicationId(applicationEntity.getId());
protocolEntity.setHubId(hubId);
protocolRepository.save(protocolEntity);
return protocolEntity;
}
private void sendMailToUserAndCompany(UserEntity userEntity, ApplicationEntity applicationEntity) {
CallEntity call =applicationEntity.getCall();
CompanyEntity company = applicationEntity.getCompany();