Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public interface AgentQualityAuditorMapRepo extends CrudRepository<AgentQualityA

List<AgentQualityAuditorMap> findByPsmId(Integer psmId);

boolean existsByPsmIdAndRoleIdAndAgentIdAndDeletedFalse(Integer psmId, Integer roleId, Integer agentId);

@Query(value = " CALL Pr_QualityAuditorWorklist(:fDate, :tDate,:psmId, :langId, :agentId, :roleId, :isValid, :cycleId, :prevCycleFromDate, :prevCycleToDate ) ", nativeQuery = true)
public List<String[]> getQualityAuditorWorklist(@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate,
@Param("psmId") Integer psmId, @Param("langId") Integer langId, @Param("agentId") Integer agentId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class RCHDataUploadServiceImpl {

Logger logger = LoggerFactory.getLogger(this.getClass().getName());

private static final long MAX_FILE_SIZE_BYTES = 5L * 1024 * 1024;

@Autowired
private MotherRecordRepo motherRecordRepo;
@Autowired
Expand All @@ -80,17 +82,17 @@ public String uploadRCDData(RCHFileUploadDto rchFileUploadDto) {

String base64File = rchFileUploadDto.getFileContent();
byte[] excelDataBytes = Base64.decodeBase64(base64File);

if (excelDataBytes.length > MAX_FILE_SIZE_BYTES)
throw new ECDException("File size exceeds the maximum allowed limit of 5MB");

workbook = this.getXSSFWorkbook(excelDataBytes);

if (workbook.getNumberOfSheets() > 0) {
Sheet sheet = workbook.getSheetAt(0);

if (sheet != null) {

if (sheet.getPhysicalNumberOfRows() > 1000)
throw new ECDException(
"File is having more then 1000 records,please upload max 1000 records at a time");

if (rchFileUploadDto.getFieldFor() != null
&& rchFileUploadDto.getFieldFor().equalsIgnoreCase("Mother Data")) {
responseMap.put("response", getMotherValidRecords(sheet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@
try {
AgentQualityAuditorMap mapObj;
List<AgentQualityAuditorMap> agentMapDetails = new ArrayList<>();
List<String> alreadyMappedAgentNames = new ArrayList<>();
if (agentQualityAuditorMap != null && agentQualityAuditorMap.getAgentIds() != null
&& agentQualityAuditorMap.getAgentIds().length > 0) {
int j = 0;
String[] agentNamesArr = agentQualityAuditorMap.getAgentNames();
for (Integer i : agentQualityAuditorMap.getAgentIds()) {
if (agentQualityAuditorMapRepo.existsByPsmIdAndRoleIdAndAgentIdAndDeletedFalse(
agentQualityAuditorMap.getPsmId(), agentQualityAuditorMap.getRoleId(), i)) {
alreadyMappedAgentNames.add(agentNamesArr[j]);
j++;
continue;
}
mapObj = new AgentQualityAuditorMap();
mapObj.setQualityAuditorId(agentQualityAuditorMap.getQualityAuditorId());
mapObj.setQualityAuditorName(agentQualityAuditorMap.getQualityAuditorName());
Expand All @@ -67,10 +74,16 @@
} else {
agentMapDetails.add(agentQualityAuditorMap);
}
agentQualityAuditorMapRepo.saveAll(agentMapDetails);
if (!agentMapDetails.isEmpty())
agentQualityAuditorMapRepo.saveAll(agentMapDetails);

Map<String, Object> responseMap = new HashMap<>();
responseMap.put("response", "Agent Quality Auditor Mapping Created Successfully");
if (!alreadyMappedAgentNames.isEmpty()) {
responseMap.put("response", "Agent Quality Auditor Mapping Created Successfully. Already mapped, skipped: "

Check failure on line 82 in src/main/java/com/iemr/ecd/service/quality/AgentQualityAuditorMappingImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "response" 3 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_ECD-API&issues=AZ_GEM72HkQ3baFehASC&open=AZ_GEM72HkQ3baFehASC&pullRequest=142
+ String.join(", ", alreadyMappedAgentNames));
} else {
responseMap.put("response", "Agent Quality Auditor Mapping Created Successfully");
}
return new Gson().toJson(responseMap);
} catch (Exception e) {
throw new ECDException(e);
Expand Down