Update MapProdukKelompokKerjaService

Penambahan informasi unit kerja KSM di menu mapping produk - kelompok kerja
This commit is contained in:
Salman Manoe 2022-03-26 13:01:05 +07:00
parent c17c229e57
commit 456d2a8c82
2 changed files with 8 additions and 6 deletions

View File

@ -72,8 +72,10 @@ public interface SubUnitKerjaDao extends PagingAndSortingRepository<SubUnitKerja
+ "and subunit.unitKerjaId = :idUnitKerja " + "order by subunit.name")
List<Map<String, Object>> getSubUnitKerjaCustomByUnitKerja(@Param("idUnitKerja") Integer idUnitKerja);
@Query("select new Map(skj.id as id,skj.name as subunitKerja) " + "from SubUnitKerjaPegawai skj "
+ "where skj.statusEnabled is true " + "and lower(skj.name) like 'kk%' " + "order by skj.id")
@Query("select new Map(ukj.id as unitKerjaId,ukj.name as unitKerja,"
+ "skj.id as subunitKerjaId,skj.name as subunitKerja) " + "from SubUnitKerjaPegawai skj "
+ "inner join skj.unitKerja ukj " + "where skj.statusEnabled is true " + "and lower(skj.name) like 'kk%' "
+ "order by skj.id")
List<Map<String, Object>> findAllKelompokKerjaMedis();
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.JpaSystemException;
@ -184,10 +185,8 @@ public class MapProdukKelompokKerjaServiceImpl extends BaseVoServiceImpl impleme
List<Map<String, Object>> mapping = mapProdukKelompokKerjaDao.findMappingByProduk(idProduk);
for (Map<String, Object> mapRs : kelompokKerja) {
mapRs.put("noRec", null);
mapRs.put("statusMapping", false);
for (Map<String, Object> map : mapping) {
if (mapRs.get("id").equals(map.get("kelompokKerjaId"))
if (mapRs.get("subunitKerjaId").equals(map.get("kelompokKerjaId"))
&& CommonUtil.isNotNullOrEmpty(map.get("noRec"))) {
mapRs.put("noRec", map.get("noRec").toString());
mapRs.put("statusMapping", true);
@ -196,7 +195,8 @@ public class MapProdukKelompokKerjaServiceImpl extends BaseVoServiceImpl impleme
result.add(mapRs);
}
result.sort(Comparator.comparing(m -> (String) m.get("subunitKerja")));
result = result.stream().sorted(Comparator.comparing(o1 -> o1.get("subunitKerja").toString()))
.sorted(Comparator.comparing(o2 -> o2.get("unitKerja").toString())).collect(Collectors.toList());
return result;
}