Merge branch 'master' into dev-deploy
This commit is contained in:
commit
afe9989b3f
@ -1,15 +1,21 @@
|
||||
package com.jasamedika.medifirst2000.converter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.jasamedika.medifirst2000.converter.base.BaseVoConverter;
|
||||
import com.jasamedika.medifirst2000.dao.custom.base.impl.FindConverterDao;
|
||||
import com.jasamedika.medifirst2000.entities.KelompokUser;
|
||||
import com.jasamedika.medifirst2000.entities.LoginUser;
|
||||
import com.jasamedika.medifirst2000.service.KelompokUserService;
|
||||
import com.jasamedika.medifirst2000.service.PegawaiService;
|
||||
import com.jasamedika.medifirst2000.util.ExtendedSpringBeanUtil;
|
||||
import com.jasamedika.medifirst2000.vo.KelompokUserVO;
|
||||
import com.jasamedika.medifirst2000.vo.LoginUserVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
||||
|
||||
/**
|
||||
* Converter class between LoginUser and LoginUserVO
|
||||
@ -18,9 +24,46 @@ import java.util.List;
|
||||
*/
|
||||
@Component
|
||||
public class LoginUserAuthConverter extends FindConverterDao implements BaseVoConverter<LoginUserVO, LoginUser> {
|
||||
/*
|
||||
* @Override public LoginUser transferVOToModel(LoginUserVO vo, LoginUser
|
||||
* model) { if (null == model) model = new LoginUser();
|
||||
*
|
||||
* try { String[] fieldsToInclude = null; Map<String, Object> serialized =
|
||||
* vo.serialize(fieldsToInclude,vo.getClass().getName()); Gson gson = new
|
||||
* Gson(); String json = gson.toJson(serialized); model =
|
||||
* gson.fromJson(json, LoginUser.class); } catch (Exception e) {
|
||||
* e.printStackTrace(); }
|
||||
*
|
||||
* return model; }
|
||||
*
|
||||
* @Override public List<LoginUserVO>
|
||||
* transferListOfModelToListOfVO(List<LoginUser> models, List<LoginUserVO>
|
||||
* vos) { if (null == vos) vos = new ArrayList<LoginUserVO>();
|
||||
*
|
||||
* if (null == models) return vos;
|
||||
*
|
||||
* for (LoginUser loginUser : models) { LoginUserVO vo = new LoginUserVO();
|
||||
* vo=transferModelToVO(loginUser, vo); vos.add(vo); }
|
||||
*
|
||||
* return vos; }
|
||||
*
|
||||
* @Override public LoginUserVO transferModelToVO(LoginUser model,
|
||||
* LoginUserVO vo) { if (null == vo) vo = new LoginUserVO(); try { String[]
|
||||
* fieldsToInclude = null; Map<String, Object> serialized =
|
||||
* model.serialize(fieldsToInclude,model.getClass().getSimpleName()); Gson
|
||||
* gson = new Gson();
|
||||
*
|
||||
* String json = gson.toJson(serialized); vo = gson.fromJson(json,
|
||||
* LoginUserVO.class); } catch (Exception e) { e.printStackTrace(); }
|
||||
*
|
||||
* return vo; }
|
||||
*/
|
||||
|
||||
public LoginUser transferVOToModel(LoginUserVO vo, LoginUser model) {
|
||||
if (null == model)
|
||||
model = new LoginUser();
|
||||
|
||||
// fix this
|
||||
ExtendedSpringBeanUtil.copySpecificProperties(vo, model, new String[] { "id", "kataSandi", "namaUser", },
|
||||
new String[] { "id", "kataSandi", "namaUser", });
|
||||
if (vo.getKelompokUser() != null) {
|
||||
@ -28,11 +71,13 @@ public class LoginUserAuthConverter extends FindConverterDao implements BaseVoCo
|
||||
model.setKelompokUser(kelompokUser);
|
||||
}
|
||||
return model;
|
||||
|
||||
}
|
||||
|
||||
public List<LoginUserVO> transferListOfModelToListOfVO(List<LoginUser> models, List<LoginUserVO> vos) {
|
||||
if (null == vos)
|
||||
vos = new ArrayList<>();
|
||||
vos = new ArrayList<LoginUserVO>();
|
||||
|
||||
if (null == models)
|
||||
return vos;
|
||||
|
||||
@ -41,14 +86,32 @@ public class LoginUserAuthConverter extends FindConverterDao implements BaseVoCo
|
||||
transferModelToVO(loginUser, loginUserVO);
|
||||
vos.add(loginUserVO);
|
||||
}
|
||||
|
||||
return vos;
|
||||
}
|
||||
|
||||
public LoginUserVO transferModelToVO(LoginUser model, LoginUserVO vo) {
|
||||
if (null == vo)
|
||||
|
||||
vo = new LoginUserVO();
|
||||
|
||||
// fix this
|
||||
ExtendedSpringBeanUtil.copySpecificProperties(model, vo, new String[] { "id", "kataSandi", "namaUser", },
|
||||
new String[] { "id", "kataSandi", "namaUser", });
|
||||
|
||||
if (model.getKelompokUser() != null) {
|
||||
KelompokUserVO kelompokUserVo = kelompokUserService.findById(model.getKelompokUser().getId());
|
||||
vo.setKelompokUser(kelompokUserVo);
|
||||
}
|
||||
if (model.getPegawai() != null) {
|
||||
PegawaiVO kelompokUserVo = pgawaiService.findById(model.getPegawai().getId());
|
||||
vo.setPegawai(kelompokUserVo);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private KelompokUserService kelompokUserService;
|
||||
@Autowired
|
||||
private PegawaiService pgawaiService;
|
||||
}
|
||||
|
||||
@ -32,14 +32,14 @@ public class PegawaiConverter implements BaseVoConverter<PegawaiVO, Pegawai> {
|
||||
|
||||
try {
|
||||
String[] fieldsToInclude = null;
|
||||
Map<String, Object> serialized = vo.serialize(fieldsToInclude,vo.getClass().getName());
|
||||
Map<String, Object> serialized = vo.serialize(fieldsToInclude, vo.getClass().getName());
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(serialized);
|
||||
model = gson.fromJson(json, Pegawai.class);
|
||||
String json = gson.toJson(serialized);
|
||||
model = gson.fromJson(json, Pegawai.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public class PegawaiConverter implements BaseVoConverter<PegawaiVO, Pegawai> {
|
||||
|
||||
for (Pegawai pegawai : models) {
|
||||
PegawaiVO vo = new PegawaiVO();
|
||||
vo=transferModelToVO(pegawai, vo);
|
||||
vo = transferModelToVO(pegawai, vo);
|
||||
vos.add(vo);
|
||||
}
|
||||
|
||||
@ -66,109 +66,113 @@ public class PegawaiConverter implements BaseVoConverter<PegawaiVO, Pegawai> {
|
||||
if (null == vo)
|
||||
vo = new PegawaiVO();
|
||||
try {
|
||||
|
||||
|
||||
List<String> fieldsToInclude = new ArrayList<String>();
|
||||
for (Field field : model.GetFields(model.getClass())) {
|
||||
String str = field.getName();
|
||||
String name = field.getName();
|
||||
if(name.equals("serialVersionUID"))continue;
|
||||
if (name.equals("serialVersionUID"))
|
||||
continue;
|
||||
Boolean valid = false;
|
||||
for (java.lang.annotation.Annotation annotation : field.getDeclaredAnnotations()) {
|
||||
if (annotation instanceof JoinColumn) {
|
||||
valid=true;
|
||||
valid = true;
|
||||
} else if (annotation instanceof Column) {
|
||||
Column column = (Column)annotation;
|
||||
if(column.name().endsWith("Fk"))
|
||||
if(field.getName().endsWith("Id")==false)
|
||||
valid=true;
|
||||
}else if (annotation instanceof OneToMany) {
|
||||
|
||||
valid=true;
|
||||
Column column = (Column) annotation;
|
||||
if (column.name().endsWith("Fk"))
|
||||
if (field.getName().endsWith("Id") == false)
|
||||
valid = true;
|
||||
} else if (annotation instanceof OneToMany) {
|
||||
|
||||
valid = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(valid ==false)
|
||||
if (valid == false)
|
||||
fieldsToInclude.add(str);
|
||||
|
||||
|
||||
}
|
||||
Map<String, Object> serialized =model.ToMap();
|
||||
Map<String, Object> serialized = model.ToMap();
|
||||
Gson gson = new Gson();
|
||||
serialized.put("jenisPegawai", model.getJenisPegawai());
|
||||
String json = gson.toJson(serialized);
|
||||
vo = gson.fromJson(json, PegawaiVO.class);
|
||||
// serialized.put("jenisPegawai", model.getJenisPegawai());
|
||||
String json = gson.toJson(serialized);
|
||||
vo = gson.fromJson(json, PegawaiVO.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
public PegawaiVO transferModelToVOCustom(Pegawai model, PegawaiVO vo,String[] fieldsToInclude) {
|
||||
|
||||
public PegawaiVO transferModelToVOCustom(Pegawai model, PegawaiVO vo, String[] fieldsToInclude) {
|
||||
if (null == vo)
|
||||
|
||||
vo = new PegawaiVO();
|
||||
vo = new PegawaiVO();
|
||||
|
||||
try {
|
||||
Map<String, Object> serialized = model.serialize(fieldsToInclude,model.getClass().getSimpleName());
|
||||
Map<String, Object> serialized = model.serialize(fieldsToInclude, model.getClass().getSimpleName());
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(serialized);
|
||||
vo = gson.fromJson(json, PegawaiVO.class);
|
||||
String json = gson.toJson(serialized);
|
||||
vo = gson.fromJson(json, PegawaiVO.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
public Pegawai transferVOToModel(RekamDataPegawaiVO vo, Pegawai model) {
|
||||
if (null == model)
|
||||
model = new Pegawai();
|
||||
|
||||
try {
|
||||
String[] fieldsToInclude = null;
|
||||
Map<String, Object> serialized = vo.serialize(fieldsToInclude,vo.getClass().getName());
|
||||
Map<String, Object> serialized = vo.serialize(fieldsToInclude, vo.getClass().getName());
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(serialized);
|
||||
model = gson.fromJson(json, Pegawai.class);
|
||||
String json = gson.toJson(serialized);
|
||||
model = gson.fromJson(json, Pegawai.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public RekamDataPegawaiVO transferModelToVO(Pegawai model, RekamDataPegawaiVO vo) {
|
||||
if (null == vo)
|
||||
vo = new RekamDataPegawaiVO();
|
||||
try {
|
||||
|
||||
|
||||
List<String> fieldsToInclude = new ArrayList<String>();
|
||||
for (Field field : model.GetFields(model.getClass())) {
|
||||
String str = field.getName();
|
||||
String name = field.getName();
|
||||
if(name.equals("serialVersionUID"))continue;
|
||||
if (name.equals("serialVersionUID"))
|
||||
continue;
|
||||
Boolean valid = false;
|
||||
for (java.lang.annotation.Annotation annotation : field.getDeclaredAnnotations()) {
|
||||
if (annotation instanceof JoinColumn) {
|
||||
valid=true;
|
||||
valid = true;
|
||||
} else if (annotation instanceof Column) {
|
||||
Column column = (Column)annotation;
|
||||
if(column.name().endsWith("Fk"))
|
||||
if(field.getName().endsWith("Id")==false)
|
||||
valid=true;
|
||||
}else if (annotation instanceof OneToMany) {
|
||||
|
||||
valid=true;
|
||||
Column column = (Column) annotation;
|
||||
if (column.name().endsWith("Fk"))
|
||||
if (field.getName().endsWith("Id") == false)
|
||||
valid = true;
|
||||
} else if (annotation instanceof OneToMany) {
|
||||
|
||||
valid = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(valid ==false)
|
||||
if (valid == false)
|
||||
fieldsToInclude.add(str);
|
||||
|
||||
|
||||
}
|
||||
Map<String, Object> serialized =model.ToMap();
|
||||
Map<String, Object> serialized = model.ToMap();
|
||||
Gson gson = new Gson();
|
||||
serialized.put("jenisPegawai", model.getJenisPegawai());
|
||||
// serialized.put("pangkat", model.getPangkat());
|
||||
String json = gson.toJson(serialized);
|
||||
vo = gson.fromJson(json, RekamDataPegawaiVO.class);
|
||||
// serialized.put("pangkat", model.getPangkat());
|
||||
String json = gson.toJson(serialized);
|
||||
vo = gson.fromJson(json, RekamDataPegawaiVO.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ public interface PasienDao extends JpaRepository<Pasien, Integer> {
|
||||
+ "and to_char(anak.tglLahir,'yyyy-MM-dd') between :tglAwal and :tglAkhir " + "order by ibu.namaPasien")
|
||||
List<Map<String, Object>> findIbuAnak(@Param("tglAwal") String tglAwal, @Param("tglAkhir") String tglAkhir);
|
||||
|
||||
@Query(value = "select ps.* " + "from pasien_m ps " + "where ps.statusenabled is true "
|
||||
@Query(value = "select ps.* " + "from pasien_m ps " + "where ps.statusenabled is true " + "and ps.kdProfile <> 1 "
|
||||
+ "and (ps.nobpjs is not null " + "and trim(ps.nobpjs) <> '' " + "and ps.nobpjs <> '-' "
|
||||
+ "and ps.nobpjs ~ '[0-9]+' " + "and length(ps.nobpjs) = 13) " + "and (ps.noidentitas is null "
|
||||
+ "or length(ps.noidentitas) <> 16) " + "order by ps.statusenabled, ps.tgldaftar desc", nativeQuery = true)
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
package com.jasamedika.medifirst2000.service.impl;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jasamedika.medifirst2000.dao.ActivityPegawaiDao;
|
||||
import com.jasamedika.medifirst2000.dao.PegawaiDao;
|
||||
import com.jasamedika.medifirst2000.entities.ActivityPegawai;
|
||||
import com.jasamedika.medifirst2000.entities.Pegawai;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.ActivityPegawaiService;
|
||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
||||
import io.socket.client.IO;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
@ -19,19 +19,27 @@ import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
import com.google.gson.Gson;
|
||||
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
|
||||
import com.jasamedika.medifirst2000.dao.ActivityPegawaiDao;
|
||||
import com.jasamedika.medifirst2000.dao.PegawaiDao;
|
||||
import com.jasamedika.medifirst2000.entities.ActivityPegawai;
|
||||
import com.jasamedika.medifirst2000.entities.Pegawai;
|
||||
import com.jasamedika.medifirst2000.service.ActivityPegawaiService;
|
||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
||||
|
||||
import io.socket.client.IO;
|
||||
|
||||
/**
|
||||
* Implement class for PelayananObatService
|
||||
*
|
||||
* @author Generator
|
||||
* @param <T>
|
||||
*/
|
||||
@Service("activityPegawaiServiceImpl")
|
||||
public class ActivityPegawaiServiceImpl implements ActivityPegawaiService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ActivityPegawaiService.class);
|
||||
|
||||
static io.socket.client.Socket socket = null;
|
||||
@ -39,35 +47,41 @@ public class ActivityPegawaiServiceImpl implements ActivityPegawaiService {
|
||||
@PersistenceContext
|
||||
protected EntityManager em;
|
||||
|
||||
@Autowired
|
||||
private ActivityPegawaiDao activityPegawaiDao;
|
||||
|
||||
@Autowired
|
||||
private PegawaiDao pegawaiDao;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(readOnly = false)
|
||||
public String GetSettingDataFixed(String prefix) {
|
||||
String buffer = "select model.nilaiField from SettingDataFixed " + " model where model.namaField ='" + prefix
|
||||
+ "' ";
|
||||
Query query = em.createQuery(buffer);
|
||||
return (String) query.getSingleResult();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("select model.nilaiField from SettingDataFixed ")
|
||||
.append(" model where model.namaField ='" + prefix + "' ");
|
||||
Query query = em.createQuery(buffer.toString());
|
||||
|
||||
String result = (String) query.getSingleResult();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void BroadcastMessage(final String to, final Map<String, Object> data) {
|
||||
protected void BroadcastMessage(final String to, final Map data) {
|
||||
try {
|
||||
if (socket == null) {
|
||||
socket = IO.socket(GetSettingDataFixed("UrlSocketMessaging"));
|
||||
socket.on(io.socket.client.Socket.EVENT_CONNECT, args -> {
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
JSONObject item = new JSONObject(
|
||||
"{\"to\":\"" + to + "\",\"message\":" + gson.toJson(data) + "}");
|
||||
LOGGER.info("{\"to\":\"" + to + "\",\"message\":" + gson.toJson(data) + "}");
|
||||
socket.emit("subscribe", item);
|
||||
} catch (JSONException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
|
||||
socket.on(io.socket.client.Socket.EVENT_CONNECT, new io.socket.emitter.Emitter.Listener() {
|
||||
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
JSONObject item = new JSONObject(
|
||||
"{\"to\":\"" + to + "\",\"message\":" + gson.toJson(data) + "}");
|
||||
LOGGER.info("{\"to\":\"" + to + "\",\"message\":" + gson.toJson(data) + "}");
|
||||
socket.emit("subscribe", item);
|
||||
// socket.disconnect();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
socket.connect();
|
||||
} else {
|
||||
@ -76,17 +90,27 @@ public class ActivityPegawaiServiceImpl implements ActivityPegawaiService {
|
||||
JSONObject item = new JSONObject("{\"to\":\"" + to + "\",\"message\":" + gson.toJson(data) + "}");
|
||||
LOGGER.info("{\"to\":\"" + to + "\",\"message\":" + gson.toJson(data) + "}");
|
||||
socket.emit("subscribe", item);
|
||||
// socket.disconnect();
|
||||
} catch (JSONException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (URISyntaxException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private BaseConverterImpl<PegawaiVO, Pegawai> pelayananObatConverter;
|
||||
@Autowired
|
||||
private ActivityPegawaiDao activityPegawaiDao;
|
||||
@Autowired
|
||||
private PegawaiDao pegawaiDao;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(readOnly = false)
|
||||
public Boolean record(PegawaiVO pegawai, Date tanggal, String keterangan) {
|
||||
Pegawai pegawaiSave = new Pegawai();
|
||||
pegawaiSave.setId(pegawai.getId());
|
||||
@ -94,18 +118,20 @@ public class ActivityPegawaiServiceImpl implements ActivityPegawaiService {
|
||||
act.setKeterangan(keterangan);
|
||||
act.setPegawai(pegawaiSave);
|
||||
act.setTanggalKejadian(new Date());
|
||||
|
||||
act = activityPegawaiDao.save(act);
|
||||
act = activityPegawaiDao.findOne(act.getNoRec());
|
||||
act.setPegawai(pegawaiDao.findById(pegawai.getId()));
|
||||
try {
|
||||
BroadcastMessage("IKI", act.ToMap());
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return !Objects.equals(act.getNoRec(), "");
|
||||
return act.getNoRec() != "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(readOnly = false)
|
||||
public Boolean record(PegawaiVO pegawai, Date tanggal, String keterangan, String group) {
|
||||
Pegawai pegawaiSave = new Pegawai();
|
||||
pegawaiSave.setId(pegawai.getId());
|
||||
@ -114,34 +140,40 @@ public class ActivityPegawaiServiceImpl implements ActivityPegawaiService {
|
||||
act.setGroup(group);
|
||||
act.setPegawai(pegawaiSave);
|
||||
act.setTanggalKejadian(new Date());
|
||||
|
||||
act = activityPegawaiDao.save(act);
|
||||
act = activityPegawaiDao.findOne(act.getNoRec());
|
||||
act.setPegawai(pegawaiDao.findById(pegawai.getId()));
|
||||
try {
|
||||
BroadcastMessage("IKI", act.ToMap());
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return !Objects.equals(act.getNoRec(), "");
|
||||
return act.getNoRec() != "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityPegawai> getData() {
|
||||
return activityPegawaiDao.findDescending();
|
||||
return (List<ActivityPegawai>) activityPegawaiDao.findDescending();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityPegawai> getData(Date start, Date until, Integer top) {
|
||||
return activityPegawaiDao.findDescending(start, until, new PageRequest(0, top));
|
||||
return (List<ActivityPegawai>) activityPegawaiDao.findDescending(start, until, new PageRequest(0, top));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getActivityData(String tanggal, Integer idPegawai) {
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
|
||||
if (CommonUtil.isNotNullOrEmpty(tanggal) && CommonUtil.isNotNullOrEmpty(idPegawai)) {
|
||||
return activityPegawaiDao.aktivitasByDatePegawai(tanggal, idPegawai);
|
||||
result = activityPegawaiDao.aktivitasByDatePegawai(tanggal, idPegawai);
|
||||
} else if (CommonUtil.isNotNullOrEmpty(tanggal) && CommonUtil.isNullOrEmpty(idPegawai)) {
|
||||
return activityPegawaiDao.aktivitasByDate(tanggal);
|
||||
result = activityPegawaiDao.aktivitasByDate(tanggal);
|
||||
} else {
|
||||
result = activityPegawaiDao.aktivitasHariIni();
|
||||
}
|
||||
return activityPegawaiDao.aktivitasHariIni();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,16 @@
|
||||
package com.jasamedika.medifirst2000.service.impl;
|
||||
|
||||
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
|
||||
import com.jasamedika.medifirst2000.converter.LoginUserAuthConverter;
|
||||
import com.jasamedika.medifirst2000.dao.HistoryLoginModulAplikasiDao;
|
||||
import com.jasamedika.medifirst2000.dao.LoginUserDao;
|
||||
import com.jasamedika.medifirst2000.dao.MapPegawaiToModulAplikasiDao;
|
||||
import com.jasamedika.medifirst2000.entities.*;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.LoginUserService;
|
||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||
import com.jasamedika.medifirst2000.util.PasswordUtil;
|
||||
import com.jasamedika.medifirst2000.vo.*;
|
||||
import com.jasamedika.medifirst2000.vo.custom.AuthVO;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.IteratorUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -22,13 +21,36 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
|
||||
import com.jasamedika.medifirst2000.converter.LoginUserAuthConverter;
|
||||
import com.jasamedika.medifirst2000.converter.LoginUserConverter;
|
||||
import com.jasamedika.medifirst2000.dao.HistoryLoginModulAplikasiDao;
|
||||
import com.jasamedika.medifirst2000.dao.LoginUserDao;
|
||||
import com.jasamedika.medifirst2000.dao.MapPegawaiToModulAplikasiDao;
|
||||
import com.jasamedika.medifirst2000.entities.HistoryLoginModulAplikasi;
|
||||
import com.jasamedika.medifirst2000.entities.KelompokUser;
|
||||
import com.jasamedika.medifirst2000.entities.LoginUser;
|
||||
import com.jasamedika.medifirst2000.entities.MapLoginUserToRuangan;
|
||||
import com.jasamedika.medifirst2000.entities.MapPegawaiToModulAplikasi;
|
||||
import com.jasamedika.medifirst2000.entities.ModulAplikasi;
|
||||
import com.jasamedika.medifirst2000.entities.Pegawai;
|
||||
import com.jasamedika.medifirst2000.entities.Ruangan;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
import com.jasamedika.medifirst2000.service.LoginUserService;
|
||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||
import com.jasamedika.medifirst2000.util.PasswordUtil;
|
||||
import com.jasamedika.medifirst2000.vo.KelompokUserVO;
|
||||
import com.jasamedika.medifirst2000.vo.LoginUserVO;
|
||||
import com.jasamedika.medifirst2000.vo.MapLoginUserToRuanganVO;
|
||||
import com.jasamedika.medifirst2000.vo.MapPegawaiToModulAplikasiVO;
|
||||
import com.jasamedika.medifirst2000.vo.ModulAplikasiVO;
|
||||
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
||||
import com.jasamedika.medifirst2000.vo.RuanganVO;
|
||||
import com.jasamedika.medifirst2000.vo.custom.AuthVO;
|
||||
|
||||
@Service("LoginUserService")
|
||||
public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUserService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoginUserServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
@ -41,7 +63,10 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
private LoginUserAuthConverter loginUserAuthConverter;
|
||||
|
||||
@Autowired
|
||||
private BaseConverterImpl<LoginUserVO, LoginUser> loginUserConverter;
|
||||
private LoginUserConverter loginUserConverter;
|
||||
|
||||
@Autowired
|
||||
private BaseConverterImpl<LoginUserVO, LoginUser> loginUserConverters;
|
||||
|
||||
@Autowired
|
||||
private BaseConverterImpl<PegawaiVO, Pegawai> pegawaiConverter;
|
||||
@ -98,7 +123,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(readOnly = false)
|
||||
public LoginUserVO add(LoginUserVO vo) throws JpaSystemException, ServiceVOException {
|
||||
// convert to model and call repository
|
||||
LoginUser loginUser = new LoginUser();
|
||||
@ -108,7 +133,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
try {
|
||||
loginUser.setKataSandi(passwordUtil.encryptPassword(loginUser.getKataSandi()));
|
||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
LoginUser resultModel = loginUserDao.save(loginUser);
|
||||
@ -121,7 +146,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(readOnly = false)
|
||||
public LoginUserVO update(LoginUserVO vo) throws JpaSystemException, ServiceVOException {
|
||||
|
||||
// Alter Syamsu
|
||||
@ -134,7 +159,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
try {
|
||||
loginUserLama.setKataSandi(passwordUtil.encryptPassword(loginUserLama.getKataSandi()));
|
||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
loginUserDao.save(loginUserLama);
|
||||
@ -147,7 +172,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(readOnly = false)
|
||||
public Boolean delete(Integer key) throws JpaSystemException {
|
||||
if (loginUserDao.exists(key)) {
|
||||
loginUserDao.delete(key);
|
||||
@ -175,7 +200,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
|
||||
List<LoginUser> loginUserList = IteratorUtils.toList(loginUserDao.findAll().iterator());
|
||||
|
||||
List<LoginUserVO> loginUserVOList = new ArrayList<>();
|
||||
List<LoginUserVO> loginUserVOList = new ArrayList<LoginUserVO>();
|
||||
loginUserConverter.transferListOfModelToListOfVO(loginUserList, loginUserVOList);
|
||||
|
||||
return loginUserVOList;
|
||||
@ -197,7 +222,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
|
||||
LoginUser loginUser = loginUsers.get(0);
|
||||
PasswordUtil passwordUtil = new PasswordUtil();
|
||||
boolean isValidPassword;
|
||||
Boolean isValidPassword = false;
|
||||
try {
|
||||
isValidPassword = passwordUtil.isPasswordEqual(authVO.getKataSandi(), loginUser.getKataSandi());
|
||||
} catch (IOException ioe) {
|
||||
@ -209,19 +234,11 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
return null;
|
||||
}
|
||||
// to do validasi yang advanced di sini
|
||||
|
||||
LoginUserVO vo = new LoginUserVO();
|
||||
vo = loginUserAuthConverter.transferModelToVO(loginUser, vo);
|
||||
if (CommonUtil.isNotNullOrEmpty(loginUser.getKelompokUser())) {
|
||||
KelompokUserVO kelompokUserVO = new KelompokUserVO();
|
||||
kelompokUserVO = kelompokUserConverter.transferModelToVO(loginUser.getKelompokUser(), kelompokUserVO);
|
||||
vo.setKelompokUser(kelompokUserVO);
|
||||
}
|
||||
if (CommonUtil.isNotNullOrEmpty(loginUser.getPegawai())) {
|
||||
PegawaiVO pegawaiVO = new PegawaiVO();
|
||||
pegawaiVO = pegawaiConverter.transferModelToVO(loginUser.getPegawai(), pegawaiVO);
|
||||
vo.setPegawai(pegawaiVO);
|
||||
}
|
||||
loginUserAuthConverter.transferModelToVO(loginUser, vo);
|
||||
return vo;
|
||||
|
||||
} else {
|
||||
throw new RuntimeException("User account is unauthorized : username : " + authVO.getNamaUser());
|
||||
}
|
||||
@ -229,20 +246,22 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
|
||||
@Override
|
||||
public LoginUser getLoginUser() {
|
||||
List<LoginUser> loginUser = null;
|
||||
try {
|
||||
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
String namaUser = principal.toString();
|
||||
List<LoginUser> loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||
return loginUser.get(0);
|
||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return loginUser.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAllUser() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<LoginUser> list = loginUserDao.findAllUser();
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
List<LoginUser> list = new ArrayList<LoginUser>();
|
||||
list = (List<LoginUser>) loginUserDao.findAllUser();
|
||||
if (CommonUtil.isNotNullOrEmpty(list)) {
|
||||
result.put("data", list);
|
||||
result.put("dataFound", true);
|
||||
@ -252,9 +271,12 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
return result;
|
||||
}
|
||||
|
||||
// Reza
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getLoadData() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
// --------------------------------------------------------------------------
|
||||
List<Map<String, Object>> listPegawai = loginUserDao.listPegawai();
|
||||
if (CommonUtil.isNotNullOrEmpty(listPegawai)) {
|
||||
@ -346,7 +368,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new ServiceVOException(ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return listSideMenu;
|
||||
}
|
||||
@ -364,7 +386,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
|
||||
LoginUser loginUser = new LoginUser();
|
||||
if (CommonUtil.isNotNullOrEmpty(vo)) {
|
||||
loginUser = loginUserConverter.transferVOToModel(vo, new LoginUser());
|
||||
loginUser = loginUserConverters.transferVOToModel(vo, new LoginUser());
|
||||
loginUser.setKdProfile((short) 0);
|
||||
loginUser.setStatusEnabled(true);
|
||||
loginUser.setKodeExternal("");
|
||||
@ -379,7 +401,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
try {
|
||||
loginUser.setKataSandi(new PasswordUtil().encryptPassword(vo.getKataSandi()));
|
||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (CommonUtil.isNotNullOrEmpty(vo.getPegawai())) {
|
||||
@ -439,8 +461,9 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
public Map<String, Object> getListRuangan(Integer loginUserId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<Map<String, Object>> listRuangan = loginUserDao.getListRuangan(loginUserId);
|
||||
if (CommonUtil.isNotNullOrEmpty(listRuangan))
|
||||
if (CommonUtil.isNotNullOrEmpty(listRuangan)) {
|
||||
result.put("listRuangan", listRuangan);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -448,22 +471,62 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
public Map<String, Object> getListModulAplikasi(Integer pegawaiId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<Map<String, Object>> listModulAplikasi = loginUserDao.getListModulAplikasi(pegawaiId);
|
||||
if (CommonUtil.isNotNullOrEmpty(listModulAplikasi))
|
||||
if (CommonUtil.isNotNullOrEmpty(listModulAplikasi)) {
|
||||
result.put("listModulAplikasi", listModulAplikasi);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getListObjectModulAplikasi(Integer modulAplikasiId) {
|
||||
return new ArrayList<>();
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
// for(Map<String, Object> objectModulHead :
|
||||
// loginUserDao.getObjectModulHeadByModul(modulAplikasiId)){
|
||||
// Map<String, Object> parent = new HashMap<>();
|
||||
//
|
||||
// if(CommonUtil.isNotNullOrEmpty(objectModulHead)){
|
||||
// parent.put("name", objectModulHead.get("objekModulAplikasi"));
|
||||
// parent.put("noUrut", objectModulHead.get("objekModulNoUrut"));
|
||||
//
|
||||
// List<Map<String, Object>> listObjectModul =
|
||||
// loginUserDao.getModulByModulHead((Integer)objectModulHead.get("id"));
|
||||
// if(CommonUtil.isNullOrEmpty(listObjectModul)){
|
||||
// parent.put("link", objectModulHead.get("alamatUrlForm"));
|
||||
// }
|
||||
//
|
||||
// List<Map<String, Object>> listChildren = new ArrayList<>();
|
||||
// for(Map<String, Object> objectModul: listObjectModul){
|
||||
// Map<String, Object> children = new HashMap<>();
|
||||
//
|
||||
// if(CommonUtil.isNotNullOrEmpty(objectModul)){
|
||||
// children.put("name", objectModul.get("objekModulAplikasi"));
|
||||
// children.put("link", objectModul.get("alamatUrlForm"));
|
||||
// children.put("noUrut", objectModul.get("objekModulNoUrut"));
|
||||
// }
|
||||
// if(CommonUtil.isNotNullOrEmpty(children)){
|
||||
// listChildren.add(children);
|
||||
// }
|
||||
// }
|
||||
// if(CommonUtil.isNotNullOrEmpty(listChildren)){
|
||||
// parent.put("children", listChildren);
|
||||
// }
|
||||
// }
|
||||
// if(CommonUtil.isNotNullOrEmpty(parent)){
|
||||
// result.add(parent);
|
||||
// }
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> saveUpdateLoginUser(LoginUserVO vo) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if (CommonUtil.isNotNullOrEmpty(vo)) {
|
||||
LoginUser loginUser = new LoginUser();
|
||||
|
||||
if (CommonUtil.isNotNullOrEmpty(vo.getId())) {
|
||||
LoginUser loginUser = setLoginUser(vo);
|
||||
loginUser = setLoginUser(vo);
|
||||
if (CommonUtil.isNotNullOrEmpty(loginUser)) {
|
||||
LoginUser loginUserResult = loginUserDao.save(loginUser);
|
||||
result.put("namaUser", loginUserResult.getNamaUser());
|
||||
@ -475,7 +538,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
if (CommonUtil.isNotNullOrEmpty(users)) {
|
||||
result.put("statusError", "Nama user sudah ada, silahkan input nama user lainya");
|
||||
} else {
|
||||
LoginUser loginUser = setLoginUser(vo);
|
||||
loginUser = setLoginUser(vo);
|
||||
if (CommonUtil.isNotNullOrEmpty(loginUser)) {
|
||||
LoginUser loginUserResult = loginUserDao.save(loginUser);
|
||||
result.put("namaUser", loginUserResult.getNamaUser());
|
||||
@ -514,7 +577,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
||||
try {
|
||||
loginUser.setKataSandi(new PasswordUtil().encryptPassword(vo.getKataSandi()));
|
||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (CommonUtil.isNotNullOrEmpty(vo.getPegawai())) {
|
||||
|
||||
@ -17,4 +17,5 @@ import lombok.NoArgsConstructor;
|
||||
public class PesertaBpjsDto {
|
||||
private String noKartu;
|
||||
private String nik;
|
||||
private Short kdProfile;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user