inisialisasi

This commit is contained in:
tias
2024-06-15 16:59:12 +07:00
commit 3e97011f66
90 changed files with 5620 additions and 0 deletions

View File

@@ -0,0 +1,294 @@
// package org.sadigit.scheduling.Maximo;
// import com.google.gson.Gson;
// import com.google.gson.GsonBuilder;
// import
// com.iconpln.schedulerintegmaximoupdate.Interceptor.AuthenticationInterceptor;
// import com.iconpln.schedulerintegmaximoupdate.dao.AssetDao;
// import com.iconpln.schedulerintegmaximoupdate.model.dto.DataGardu;
// import com.iconpln.schedulerintegmaximoupdate.model.dto.DataPenyulang;
// import com.iconpln.schedulerintegmaximoupdate.model.dto.DataTrafo;
// import com.iconpln.schedulerintegmaximoupdate.model.payload.ResponseGardu;
// import
// com.iconpln.schedulerintegmaximoupdate.model.payload.ResponsePenyulang;
// import com.iconpln.schedulerintegmaximoupdate.model.payload.ResponseTrafo;
// import lombok.extern.slf4j.Slf4j;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.beans.factory.annotation.Value;
// import org.springframework.http.HttpEntity;
// import org.springframework.http.HttpMethod;
// import org.springframework.http.ResponseEntity;
// import org.springframework.http.client.ClientHttpRequestInterceptor;
// import org.springframework.http.converter.StringHttpMessageConverter;
// import
// org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
// import org.springframework.stereotype.Component;
// import org.springframework.web.client.RestTemplate;
// import java.io.IOException;
// import java.text.SimpleDateFormat;
// import java.util.*;
// @Slf4j
// @Component("jobGetAsset")
// public class JobGetAsset {
// @Value("${url.api.maximo1}")
// private String URL;
// @Value("${auth.api.maximo}")
// private String AUTH;
// // @Value("${content.api.maximo}")
// // private String CONTENT;
// @Autowired
// private AssetDao assetDao;
// public void executeGetAsset() throws IOException {
// log.info("--- JOB GET ASSET ---");
// List<Map<String, String>> lstMap = getDataSiapAmbil();
// log.info("JML DATA CXUNIT : {}", lstMap.size());
// if (!lstMap.isEmpty()) {
// for (Map<String, String> map : lstMap) {
// if (map.get("tipe").toString().equals("GARDU") ) {
// ResponseGardu response = getGarduUpdateEndPoint(map);
// log.info("JML DATA GARDU : {}", response.getMember().size());
// log.info("CXUNIT : {}", map.get("unitid").toString());
// log.info("TIPE : {}", map.get("tipe").toString());
// if (response.getMember() != null) {
// Map<String, String> mapSimpanDataGarduKolektif =
// SimpanDataGarduKolektif(map.get("unitid").toString(), response.getMember());
// if (mapSimpanDataGarduKolektif.get("return").equals("1")) {
// log.info("SIMPAN DATA GARDU : {}", mapSimpanDataGarduKolektif);
// }
// }
// }
// if (map.get("tipe").toString().equals("FEEDER") ) {
// ResponsePenyulang response = getPenyulangUpdateEndPoint(map);
// log.info("JML DATA PENYULANG : {}", response.getMember().size());
// log.info("CXUNIT : {}", map.get("unitid").toString());
// log.info("TIPE : {}", map.get("tipe").toString());
// if (response.getMember() != null) {
// Map<String, String> mapSimpanDataPenyulangKolektif =
// SimpanDataPenyulangKolektif(map.get("unitid").toString(),
// response.getMember());
// if (mapSimpanDataPenyulangKolektif.get("return").equals("1")) {
// log.info("SIMPAN DATA PENYULANG : {}", mapSimpanDataPenyulangKolektif);
// }
// }
// }
// if (map.get("tipe").toString().equals("TRAFO") ) {
// ResponseTrafo response = getTrafoUpdateEndPoint(map);
// log.info("JML DATA TRAFO : {}", response.getMember().size());
// log.info("CXUNIT : {}", map.get("unitid").toString());
// log.info("TIPE : {}", map.get("tipe").toString());
// if (response.getMember() != null) {
// Map<String, String> mapSimpanDataTrafoKolektif =
// SimpanDataTrafoKolektif(map.get("unitid").toString(), response.getMember());
// if (mapSimpanDataTrafoKolektif.get("return").equals("1")) {
// log.info("SIMPAN DATA TRAFO : {}", mapSimpanDataTrafoKolektif);
// }
// }
// }
// }
// }
// }
// private List<Map<String, String>> getDataSiapAmbil() {
// List<Map<String, String>> lstMap = assetDao.getAmbilDataGardu();
// return lstMap;
// }
// private ResponseGardu getGarduUpdateEndPoint (Map<String, String> map) {
// RestTemplate restTemplate = new RestTemplate();
// Map<String, Object> mapParams = new HashMap<>();
// ResponseGardu response = new ResponseGardu();
// ResponseEntity<ResponseGardu> res = null;
// try {
// ClientHttpRequestInterceptor authenticationInterceptor = new
// AuthenticationInterceptor(AUTH);
// restTemplate.setInterceptors(Collections.singletonList(authenticationInterceptor));
// restTemplate.getMessageConverters().add(new
// MappingJackson2HttpMessageConverter());
// restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
// Date date = new Date();
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// // String url = URL +
// "os/MXLOCATION_TEST?oslc.select=location,description,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,locationspec,serviceaddress{longitudex,latitudey,formattedaddress}&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Bangunan Sipil Gardu\" and
// cxunit=\"{unitid}\"&ignorecollectionref=1&lean=1&collectioncount=1";
// String url = URL +
// "os/MXLOCATION_TEST?oslc.select=location,description,tujdnumber,cxunit,apkt_numbers,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,locationspec,serviceaddress{longitudex,latitudey,formattedaddress}&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Bangunan Sipil Gardu\" and cxunit=\"{unitid}\" and
// changedate>\"{currentdate}\"&ignorecollectionref=1&lean=1&collectioncount=1";
// // String url = URL +
// "os/MXLOCATION_TEST?oslc.select=location,description,tujdnumber,cxunit,apkt_numbers,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,locationspec,serviceaddress{longitudex,latitudey,formattedaddress}&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Bangunan Sipil Gardu\" and cxunit=\"{unitid}\" and
// changedate>\"2021-08-05\"&ignorecollectionref=1&lean=1&collectioncount=1";
// Object mapValue = "{longitudex,latitudey,formattedaddress}";
// mapParams.put("longitudex,latitudey,formattedaddress", mapValue);
// mapParams.put("unitid", map.get("unitid").toString());
// mapParams.put("currentdate", formatter.format(date));
// // Map mapParam = new HashMap();
// // res = restTemplate.getForEntity(url, null, ResponseGardu.class, mapParam);
// res = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY,
// ResponseGardu.class, mapParams);
// // log.info("res : {}", res);
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// String jsonifyresponse = gson.toJson(res.getBody());
// log.info("RESPONSE : {}", jsonifyresponse);
// } catch (Exception ex) {
// ex.printStackTrace();
// log.error("ERROR GET GARDU : {}", ex);
// // response.setRc("01");
// response.setMessage("Error, "+ex.getMessage());
// response.setMember(null);
// return response;
// }
// return res.getBody();
// }
// private ResponsePenyulang getPenyulangUpdateEndPoint (Map<String, String>
// map) {
// RestTemplate restTemplate = new RestTemplate();
// Map<String, Object> mapParams = new HashMap<>();
// ResponsePenyulang response = new ResponsePenyulang();
// ResponseEntity<ResponsePenyulang> res = null;
// try {
// ClientHttpRequestInterceptor authenticationInterceptor = new
// AuthenticationInterceptor(AUTH);
// restTemplate.setInterceptors(Collections.singletonList(authenticationInterceptor));
// restTemplate.getMessageConverters().add(new
// MappingJackson2HttpMessageConverter());
// restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
// Date date = new Date();
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// // String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,
// location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec{assetattrid,alnvalue,numvalue,measureunitid},location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy{parent}&oslc.where=status="OPERATING"
// and cxclassificationdesc="MVCable 20 kV" and
// apkt_number!="NULL"&ignorecollectionref=1&oslc.pageSize=10&lean=1&collectioncount=1";
// String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec,location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy,endmeasure&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"MVCable 20 kV\" and cxunit=\"{unitid}\" and
// changedate>\"{currentdate}\"&ignorecollectionref=1&lean=1&collectioncount=1";
// // String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec,location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy,endmeasure&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"MVCable 20 kV\" and cxunit=\"{unitid}\" and
// changedate>\"2021-08-05\"&ignorecollectionref=1&lean=1&collectioncount=1";
// Object mapValue =
// "{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit}";
// mapParams.put("serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit",
// mapValue);
// mapParams.put("unitid", map.get("unitid").toString());
// mapParams.put("currentdate", formatter.format(date));
// // Map mapParam = new HashMap();
// // res = restTemplate.getForEntity(url, null, ResponseTrafo.class, mapParam);
// res = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY,
// ResponsePenyulang.class, mapParams);
// // log.info("res : {}", res);
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// String jsonifyresponse = gson.toJson(res.getBody());
// log.info("RESPONSE : {}", jsonifyresponse);
// } catch (Exception ex) {
// ex.printStackTrace();
// log.error("ERROR GET PENYULANG : {}", ex);
// // response.setRc("01");
// response.setMessage("Error, "+ex.getMessage());
// response.setMember(null);
// return response;
// }
// return res.getBody();
// }
// private ResponseTrafo getTrafoUpdateEndPoint (Map<String, String> map) {
// RestTemplate restTemplate = new RestTemplate();
// Map<String, Object> mapParams = new HashMap<>();
// ResponseTrafo response = new ResponseTrafo();
// ResponseEntity<ResponseTrafo> res = null;
// try {
// ClientHttpRequestInterceptor authenticationInterceptor = new
// AuthenticationInterceptor(AUTH);
// restTemplate.setInterceptors(Collections.singletonList(authenticationInterceptor));
// restTemplate.getMessageConverters().add(new
// MappingJackson2HttpMessageConverter());
// restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
// Date date = new Date();
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// // String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec,location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy,manufacturer&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Trafo\" and
// cxunit=\"{unitid}\"&ignorecollectionref=1&lean=1&collectioncount=1";
// String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec,location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy,manufacturer&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Trafo\" and cxunit=\"{unitid}\" and
// changedate>\"{currentdate}\"&ignorecollectionref=1&lean=1&collectioncount=1";
// // String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec,location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy,manufacturer&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Trafo\" and cxunit=\"{unitid}\" and
// changedate>\"2021-08-05\"&ignorecollectionref=1&lean=1&collectioncount=1";
// Object mapValue =
// "{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit}";
// mapParams.put("serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit",
// mapValue);
// mapParams.put("unitid", map.get("unitid").toString());
// mapParams.put("currentdate", formatter.format(date));
// // Map mapParam = new HashMap();
// // res = restTemplate.getForEntity(url, null, ResponseTrafo.class, mapParam);
// res = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY,
// ResponseTrafo.class, mapParams);
// // log.info("res : {}", res);
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// String jsonifyresponse = gson.toJson(res.getBody());
// log.info("RESPONSE : {}", jsonifyresponse);
// } catch (Exception ex) {
// ex.printStackTrace();
// log.error("ERROR GET TRAFO : {}", ex);
// // response.setRc("01");
// response.setMessage("Error, "+ex.getMessage());
// response.setMember(null);
// return response;
// }
// return res.getBody();
// }
// private Map<String, String> SimpanDataGarduKolektif(String unitid,
// List<DataGardu> lstGardu){
// Map<String, String> mapResult = new HashMap<>();
// mapResult = assetDao.SimpanDataGarduKolektif(unitid, lstGardu);
// return mapResult;
// }
// private Map<String, String> SimpanDataPenyulangKolektif(String unitid,
// List<DataPenyulang> lstPenyulang){
// Map<String, String> mapResult = new HashMap<>();
// mapResult = assetDao.SimpanDataPenyulangKolektif(unitid, lstPenyulang);
// return mapResult;
// }
// private Map<String, String> SimpanDataTrafoKolektif(String unitid,
// List<DataTrafo> lstTrafo){
// Map<String, String> mapResult = new HashMap<>();
// mapResult = assetDao.SimpanDataTrafoKolektif(unitid, lstTrafo);
// return mapResult;
// }
// }

View File

@@ -0,0 +1,133 @@
// package org.sadigit.scheduling.Maximo;
// import com.google.gson.Gson;
// import com.google.gson.GsonBuilder;
// import
// com.iconpln.schedulerintegmaximoupdate.Interceptor.AuthenticationInterceptor;
// import com.iconpln.schedulerintegmaximoupdate.dao.GarduDao;
// import com.iconpln.schedulerintegmaximoupdate.model.dto.DataGardu;
// import com.iconpln.schedulerintegmaximoupdate.model.payload.ResponseGardu;
// import lombok.extern.slf4j.Slf4j;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.beans.factory.annotation.Value;
// import org.springframework.http.HttpEntity;
// import org.springframework.http.HttpMethod;
// import org.springframework.http.ResponseEntity;
// import org.springframework.http.client.ClientHttpRequestInterceptor;
// import org.springframework.http.converter.StringHttpMessageConverter;
// import
// org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
// import org.springframework.stereotype.Component;
// import org.springframework.web.client.RestTemplate;
// import java.io.IOException;
// import java.text.SimpleDateFormat;
// import java.util.*;
// @Slf4j
// @Component("jobGetGarduUpdate")
// public class JobGetGarduUpdate {
// @Value("${url.api.maximo1}")
// private String URL;
// @Value("${auth.api.maximo}")
// private String AUTH;
// // @Value("${content.api.maximo}")
// // private String CONTENT;
// @Autowired
// private GarduDao garduDao;
// public void executeGetGarduUpdate() throws IOException {
// log.info("--- JOB GET GARDU ---");
// List<Map<String, String>> lstMap = getDataSiapAmbil();
// // log.info("JML DATA CXUNIT : {}", lstMap.size());
// if (!lstMap.isEmpty()) {
// for (Map<String, String> map : lstMap) {
// if (map.get("tipe").toString().equals("GARDU") ) {
// ResponseGardu response = getGarduUpdateEndPoint(map);
// log.info("JML DATA GARDU : {}", response.getMember().size());
// log.info("CXUNIT : {}", map.get("unitid").toString());
// log.info("TIPE : {}", map.get("tipe").toString());
// if (response.getMember() != null) {
// Map<String, String> mapSimpanDataGarduKolektif =
// SimpanDataGarduKolektif(map.get("unitid").toString(), response.getMember());
// if (mapSimpanDataGarduKolektif.get("return").equals("1")) {
// log.info("SIMPAN DATA GARDU : {}", mapSimpanDataGarduKolektif);
// }
// }
// }
// }
// }
// }
// private List<Map<String, String>> getDataSiapAmbil() {
// List<Map<String, String>> lstMap = garduDao.getAmbilDataGardu();
// return lstMap;
// }
// private ResponseGardu getGarduUpdateEndPoint (Map<String, String> map) {
// RestTemplate restTemplate = new RestTemplate();
// Map<String, Object> mapParams = new HashMap<>();
// ResponseGardu response = new ResponseGardu();
// ResponseEntity<ResponseGardu> res = null;
// try {
// ClientHttpRequestInterceptor authenticationInterceptor = new
// AuthenticationInterceptor(AUTH);
// restTemplate.setInterceptors(Collections.singletonList(authenticationInterceptor));
// restTemplate.getMessageConverters().add(new
// MappingJackson2HttpMessageConverter());
// restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
// Date date = new Date();
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// // String url = URL +
// "os/MXLOCATION_TEST?oslc.select=location,description,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,locationspec,serviceaddress{longitudex,latitudey,formattedaddress}&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Bangunan Sipil Gardu\" and
// cxunit=\"{unitid}\"&ignorecollectionref=1&lean=1&collectioncount=1";
// // String url = URL +
// "os/MXLOCATION_TEST?oslc.select=location,description,tujdnumber,cxunit,apkt_numbers,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,locationspec,serviceaddress{longitudex,latitudey,formattedaddress}&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Bangunan Sipil Gardu\" and cxunit=\"{unitid}\" and
// changedate>\"{currentdate}\"&ignorecollectionref=1&lean=1&collectioncount=1";
// String url = URL +
// "os/MXLOCATION_TEST?oslc.select=location,description,tujdnumber,cxunit,apkt_numbers,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,locationspec,serviceaddress{longitudex,latitudey,formattedaddress}&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Bangunan Sipil Gardu\" and cxunit=\"{unitid}\" and
// changedate>\"2021-08-05\"&ignorecollectionref=1&lean=1&collectioncount=1";
// Object mapValue = "{longitudex,latitudey,formattedaddress}";
// mapParams.put("longitudex,latitudey,formattedaddress", mapValue);
// mapParams.put("unitid", map.get("unitid").toString());
// mapParams.put("currentdate", formatter.format(date));
// // Map mapParam = new HashMap();
// // res = restTemplate.getForEntity(url, null, ResponseGardu.class, mapParam);
// res = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY,
// ResponseGardu.class, mapParams);
// // log.info("res : {}", res);
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// String jsonifyresponse = gson.toJson(res.getBody());
// log.info("RESPONSE : {}", jsonifyresponse);
// } catch (Exception ex) {
// ex.printStackTrace();
// log.error("ERROR GET GARDU : {}", ex);
// // response.setRc("01");
// response.setMessage("Error, "+ex.getMessage());
// response.setMember(null);
// return response;
// }
// return res.getBody();
// }
// private Map<String, String> SimpanDataGarduKolektif(String unitid,
// List<DataGardu> lstGardu){
// Map<String, String> mapResult = new HashMap<>();
// mapResult = garduDao.SimpanDataGarduKolektif(unitid, lstGardu);
// return mapResult;
// }
// }

View File

@@ -0,0 +1,139 @@
// package org.sadigit.scheduling.Maximo;
// import com.google.gson.Gson;
// import com.google.gson.GsonBuilder;
// import
// com.iconpln.schedulerintegmaximoupdate.Interceptor.AuthenticationInterceptor;
// import com.iconpln.schedulerintegmaximoupdate.dao.PenyulangDao;
// import com.iconpln.schedulerintegmaximoupdate.model.dto.DataPenyulang;
// import
// com.iconpln.schedulerintegmaximoupdate.model.payload.ResponsePenyulang;
// import lombok.extern.slf4j.Slf4j;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.beans.factory.annotation.Value;
// import org.springframework.http.HttpEntity;
// import org.springframework.http.HttpMethod;
// import org.springframework.http.ResponseEntity;
// import org.springframework.http.client.ClientHttpRequestInterceptor;
// import org.springframework.http.converter.StringHttpMessageConverter;
// import
// org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
// import org.springframework.stereotype.Component;
// import org.springframework.web.client.RestTemplate;
// import java.io.IOException;
// import java.text.SimpleDateFormat;
// import java.util.*;
// @Slf4j
// @Component("jobGetPenyulangUpdate")
// public class JobGetPenyulangUpdate {
// @Value("${url.api.maximo1}")
// private String URL;
// @Value("${auth.api.maximo}")
// private String AUTH;
// // @Value("${content.api.maximo}")
// // private String CONTENT;
// @Autowired
// private PenyulangDao penyulangDao;
// public void executeGetPenyulangUpdate() throws IOException {
// log.info("--- JOB GET PENYULANG ---");
// List<Map<String, String>> lstMap = getDataSiapAmbil();
// // log.info("JML DATA CXUNIT : {}", lstMap.size());
// if (!lstMap.isEmpty()) {
// for (Map<String, String> map : lstMap) {
// if (map.get("tipe").toString().equals("FEEDER") ) {
// ResponsePenyulang response = getPenyulangUpdateEndPoint(map);
// log.info("JML DATA PENYULANG : {}", response.getMember().size());
// log.info("CXUNIT : {}", map.get("unitid").toString());
// log.info("TIPE : {}", map.get("tipe").toString());
// if (response.getMember() != null) {
// Map<String, String> mapSimpanDataPenyulangKolektif =
// SimpanDataPenyulangKolektif(map.get("unitid").toString(),
// response.getMember());
// if (mapSimpanDataPenyulangKolektif.get("return").equals("1")) {
// log.info("SIMPAN DATA PENYULANG : {}", mapSimpanDataPenyulangKolektif);
// }
// }
// }
// }
// }
// }
// private List<Map<String, String>> getDataSiapAmbil() {
// List<Map<String, String>> lstMap = penyulangDao.getAmbilDataPenyulang();
// return lstMap;
// }
// private ResponsePenyulang getPenyulangUpdateEndPoint (Map<String, String>
// map) {
// RestTemplate restTemplate = new RestTemplate();
// Map<String, Object> mapParams = new HashMap<>();
// ResponsePenyulang response = new ResponsePenyulang();
// ResponseEntity<ResponsePenyulang> res = null;
// try {
// ClientHttpRequestInterceptor authenticationInterceptor = new
// AuthenticationInterceptor(AUTH);
// restTemplate.setInterceptors(Collections.singletonList(authenticationInterceptor));
// restTemplate.getMessageConverters().add(new
// MappingJackson2HttpMessageConverter());
// restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
// Date date = new Date();
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// // String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,
// location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec{assetattrid,alnvalue,numvalue,measureunitid},location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy{parent}&oslc.where=status="OPERATING"
// and cxclassificationdesc="MVCable 20 kV" and
// apkt_number!="NULL"&ignorecollectionref=1&oslc.pageSize=10&lean=1&collectioncount=1";
// // String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec,location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy,endmeasure&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"MVCable 20 kV\" and cxunit=\"{unitid}\" and
// changedate>\"{currentdate}\"&ignorecollectionref=1&lean=1&collectioncount=1";
// String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec,location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy,endmeasure&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"MVCable 20 kV\" and cxunit=\"{unitid}\" and
// changedate>\"2021-08-05\"&ignorecollectionref=1&lean=1&collectioncount=1";
// Object mapValue =
// "{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit}";
// mapParams.put("serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit",
// mapValue);
// mapParams.put("unitid", map.get("unitid").toString());
// mapParams.put("currentdate", formatter.format(date));
// // Map mapParam = new HashMap();
// // res = restTemplate.getForEntity(url, null, ResponseTrafo.class, mapParam);
// res = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY,
// ResponsePenyulang.class, mapParams);
// // log.info("res : {}", res);
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// String jsonifyresponse = gson.toJson(res.getBody());
// log.info("RESPONSE : {}", jsonifyresponse);
// } catch (Exception ex) {
// ex.printStackTrace();
// log.error("ERROR GET PENYULANG : {}", ex);
// // response.setRc("01");
// response.setMessage("Error, "+ex.getMessage());
// response.setMember(null);
// return response;
// }
// return res.getBody();
// }
// private Map<String, String> SimpanDataPenyulangKolektif(String unitid,
// List<DataPenyulang> lstPenyulang){
// Map<String, String> mapResult = new HashMap<>();
// mapResult = penyulangDao.SimpanDataPenyulangKolektif(unitid, lstPenyulang);
// return mapResult;
// }
// }

View File

@@ -0,0 +1,135 @@
// package org.sadigit.scheduling.Maximo;
// import com.google.gson.Gson;
// import com.google.gson.GsonBuilder;
// import
// com.iconpln.schedulerintegmaximoupdate.Interceptor.AuthenticationInterceptor;
// import com.iconpln.schedulerintegmaximoupdate.dao.TrafoDao;
// import com.iconpln.schedulerintegmaximoupdate.model.dto.DataTrafo;
// import com.iconpln.schedulerintegmaximoupdate.model.payload.ResponseTrafo;
// import lombok.extern.slf4j.Slf4j;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.beans.factory.annotation.Value;
// import org.springframework.http.HttpEntity;
// import org.springframework.http.HttpMethod;
// import org.springframework.http.ResponseEntity;
// import org.springframework.http.client.ClientHttpRequestInterceptor;
// import org.springframework.http.converter.StringHttpMessageConverter;
// import
// org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
// import org.springframework.stereotype.Component;
// import org.springframework.web.client.RestTemplate;
// import java.io.IOException;
// import java.text.SimpleDateFormat;
// import java.util.*;
// @Slf4j
// @Component("jobGetTrafoUpdate")
// public class JobGetTrafoUpdate {
// @Value("${url.api.maximo1}")
// private String URL;
// @Value("${auth.api.maximo}")
// private String AUTH;
// // @Value("${content.api.maximo}")
// // private String CONTENT;
// @Autowired
// private TrafoDao trafoDao;
// public void executeGetTrafoUpdate() throws IOException {
// log.info("--- JOB GET TRAFO ---");
// List<Map<String, String>> lstMap = getDataSiapAmbil();
// // log.info("JML DATA CXUNIT : {}", lstMap.size());
// if (!lstMap.isEmpty()) {
// for (Map<String, String> map : lstMap) {
// if (map.get("tipe").toString().equals("TRAFO") ) {
// ResponseTrafo response = getTrafoUpdateEndPoint(map);
// log.info("JML DATA TRAFO : {}", response.getMember().size());
// log.info("CXUNIT : {}", map.get("unitid").toString());
// log.info("TIPE : {}", map.get("tipe").toString());
// if (response.getMember() != null) {
// Map<String, String> mapSimpanDataTrafoKolektif =
// SimpanDataTrafoKolektif(map.get("unitid").toString(), response.getMember());
// if (mapSimpanDataTrafoKolektif.get("return").equals("1")) {
// log.info("SIMPAN DATA TRAFO : {}", mapSimpanDataTrafoKolektif);
// }
// }
// }
// }
// }
// }
// private List<Map<String, String>> getDataSiapAmbil() {
// List<Map<String, String>> lstMap = trafoDao.getAmbilDataTrafo();
// return lstMap;
// }
// private ResponseTrafo getTrafoUpdateEndPoint (Map<String, String> map) {
// RestTemplate restTemplate = new RestTemplate();
// Map<String, Object> mapParams = new HashMap<>();
// ResponseTrafo response = new ResponseTrafo();
// ResponseEntity<ResponseTrafo> res = null;
// try {
// ClientHttpRequestInterceptor authenticationInterceptor = new
// AuthenticationInterceptor(AUTH);
// restTemplate.setInterceptors(Collections.singletonList(authenticationInterceptor));
// restTemplate.getMessageConverters().add(new
// MappingJackson2HttpMessageConverter());
// restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
// Date date = new Date();
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// // String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec,location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy,manufacturer&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Trafo\" and
// cxunit=\"{unitid}\"&ignorecollectionref=1&lean=1&collectioncount=1";
// // String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec,location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy,manufacturer&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Trafo\" and cxunit=\"{unitid}\" and
// changedate>\"{currentdate}\"&ignorecollectionref=1&lean=1&collectioncount=1";
// String url = URL +
// "os/mxasset_test?oslc.select=assetnum,apkt_numbers,description,location--assetlocation,tujdnumber,cxunit,cxclassificationdesc,installvendor,installdate,actualoprdate,changedate,assetspec,location.saddresscode,locations{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit},lochierarchy,manufacturer&oslc.where=status=\"OPERATING\"
// and cxclassificationdesc=\"Trafo\" and cxunit=\"{unitid}\" and
// changedate>\"2021-08-05\"&ignorecollectionref=1&lean=1&collectioncount=1";
// Object mapValue =
// "{serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit}";
// mapParams.put("serviceaddress.longitudex,serviceaddress.latitudey,serviceaddress.FORMATTEDADDRESS,cxunit",
// mapValue);
// mapParams.put("unitid", map.get("unitid").toString());
// mapParams.put("currentdate", formatter.format(date));
// // Map mapParam = new HashMap();
// // res = restTemplate.getForEntity(url, null, ResponseTrafo.class, mapParam);
// res = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY,
// ResponseTrafo.class, mapParams);
// // log.info("res : {}", res);
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// String jsonifyresponse = gson.toJson(res.getBody());
// log.info("RESPONSE : {}", jsonifyresponse);
// } catch (Exception ex) {
// ex.printStackTrace();
// log.error("ERROR GET TRAFO : {}", ex);
// // response.setRc("01");
// response.setMessage("Error, "+ex.getMessage());
// response.setMember(null);
// return response;
// }
// return res.getBody();
// }
// private Map<String, String> SimpanDataTrafoKolektif(String unitid,
// List<DataTrafo> lstTrafo){
// Map<String, String> mapResult = new HashMap<>();
// mapResult = trafoDao.SimpanDataTrafoKolektif(unitid, lstTrafo);
// return mapResult;
// }
// }