작업 시간 분석, 작업 조건 분석 데이터 조회 테스트 기능 추가
This commit is contained in:
@@ -63,34 +63,6 @@ namespace CHN
|
||||
[OptionKey]
|
||||
string kpiAPI = "/api/usp_ppmr020/list/facilityKpi";
|
||||
|
||||
|
||||
//string mpwod01tworker = "/api/mpwod01t/list/worker";
|
||||
|
||||
string mpwod01t = "/api/mpwod01t/list";
|
||||
string mkord01t = "/api/mkord01t/list";
|
||||
string insti02t = "/api/insti02t/list";
|
||||
string mpeqi02t = "/api/mpeqi02t/list";
|
||||
string bimch01t = "/api/bimch01t/list";
|
||||
string biitm01t = "/api/biitm01t/list";
|
||||
string bicod01t = "/api/bicod01t/list";
|
||||
string bilos01t = "/api/bilos01t/list";
|
||||
|
||||
//string usp_ppmr020_workOrder = "/api/usp_ppmr020/list/workOrder";
|
||||
//string usp_ppmr020_facilityDate = "/api/usp_ppmr020/list/facilityDate";
|
||||
//string usp_ppmr020_facilityItem = "/api/usp_ppmr020/list/facilityItem";
|
||||
//string usp_ppmr020_item = "/api/usp_ppmr020/list/item";
|
||||
//string usp_ppmr020_itemDate= "/api/usp_ppmr020/list/itemDate";
|
||||
//string usp_ppmr030_workOrder = "/api/usp_ppmr030/list/workOrder";
|
||||
//string usp_ppmr030_facilityDate = "/api/usp_ppmr030/list/facilityDate";
|
||||
//string usp_ppmr030_facilityItem = "/api/usp_ppmr030/list/facilityItem";
|
||||
//string usp_ppmr030_item = "/api/usp_ppmr030/list/item";
|
||||
//string usp_ppmr030_itemDate = "/api/usp_ppmr030/list/itemDate";
|
||||
//string usp_ppmr040_workOrder = "/api/usp_ppmr040/list/workOrder";
|
||||
//string usp_ppmr040_facilityDate = "/api/usp_ppmr040/list/facilityDate";
|
||||
//string usp_ppmr040_facilityItem = "/api/usp_ppmr040/list/facilityItem";
|
||||
//string usp_ppmr040_item = "/api/usp_ppmr040/list/item";
|
||||
//string usp_ppmr040_itemDate = "/api/usp_ppmr040/list/itemDate";
|
||||
|
||||
public void Start()
|
||||
{
|
||||
HTTPConnect();
|
||||
@@ -109,91 +81,7 @@ namespace CHN
|
||||
request.AddHeader("access-token", apiKey);
|
||||
|
||||
request.Send();
|
||||
|
||||
//Get();
|
||||
}
|
||||
|
||||
void Get()
|
||||
{
|
||||
List<string> apiList = new();
|
||||
apiList.Add(mpwod01t);
|
||||
//apiList.Add(mpwod01tworker);
|
||||
apiList.Add(mkord01t);
|
||||
apiList.Add(biitm01t);
|
||||
|
||||
apiList.Add(bimch01t);
|
||||
apiList.Add(mpeqi02t);
|
||||
apiList.Add(insti02t);
|
||||
apiList.Add(bicod01t);
|
||||
|
||||
apiList.Add(bilos01t);
|
||||
//apiList.Add(usp_ppmr020_workOrder);
|
||||
//apiList.Add(usp_ppmr020_facilityDate);
|
||||
//apiList.Add(usp_ppmr020_facilityItem);
|
||||
|
||||
//apiList.Add(usp_ppmr020_item);
|
||||
//apiList.Add(usp_ppmr020_itemDate);
|
||||
//apiList.Add(usp_ppmr030_workOrder);
|
||||
//apiList.Add(usp_ppmr030_facilityDate);
|
||||
|
||||
//apiList.Add(usp_ppmr030_facilityItem);
|
||||
//apiList.Add(usp_ppmr030_item);
|
||||
//apiList.Add(usp_ppmr030_itemDate);
|
||||
//apiList.Add(usp_ppmr040_workOrder);
|
||||
|
||||
//apiList.Add(usp_ppmr040_facilityDate);
|
||||
//apiList.Add(usp_ppmr040_facilityItem);
|
||||
//apiList.Add(usp_ppmr040_item);
|
||||
//apiList.Add(usp_ppmr040_itemDate);
|
||||
|
||||
foreach (var api in apiList)
|
||||
{
|
||||
var path = httpServer + api;
|
||||
var query = $"?&limit=1&page=1";
|
||||
var request = HTTPRequest.CreateGet(path+query, GetDataFormats);
|
||||
request.AddHeader("access-token", apiKey);
|
||||
|
||||
request.Send();
|
||||
}
|
||||
}
|
||||
|
||||
public class rawData
|
||||
{
|
||||
public string status;
|
||||
public string code;
|
||||
public string message;
|
||||
public raw data;
|
||||
public string remark;
|
||||
}
|
||||
|
||||
public class raw
|
||||
{
|
||||
public string count;
|
||||
public string rows;
|
||||
|
||||
}
|
||||
void GetDataFormats(HTTPRequest req, HTTPResponse resp)
|
||||
{
|
||||
switch (req.State)
|
||||
{
|
||||
case HTTPRequestStates.Finished:
|
||||
if (resp.IsSuccess)
|
||||
{
|
||||
var payload = Encoding.UTF8.GetString(resp.Data);
|
||||
Debug.Log($"{req.Uri.ToString()} = {payload.Split(',')[4]}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"Server sent an error: {resp.StatusCode}-{resp.Message}");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.LogError($"Request finished with error! Request state: {req.State}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void RequestFinishedCallback(HTTPRequest req, HTTPResponse resp)
|
||||
{
|
||||
switch (req.State)
|
||||
|
||||
171
Assets/WorkSpace/Personal/JYM/HTTPTest.cs
Normal file
171
Assets/WorkSpace/Personal/JYM/HTTPTest.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
public class WorkTimeRequesttBody
|
||||
{
|
||||
public string startDate;
|
||||
public string endDate;
|
||||
public string MCHCD;
|
||||
public string WO;
|
||||
}
|
||||
public class WorkConditionsRequestBody
|
||||
{
|
||||
public string startDate;
|
||||
public string endDate;
|
||||
public string MCHCD;
|
||||
public string WO;
|
||||
}
|
||||
public class HTTPTest : MonoBehaviour
|
||||
{
|
||||
public string apiKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiZW1haWwiOiJ1dmMiLCJncm91cElkIjoyLCJncm91cENvZGUiOiJjaHVuaWxlbmciLCJyb2xlIjoiVGVuYW50QWRtaW4iLCJuYW1lIjoi7Jyg67mE7JSoIiwibGljZW5zZSI6ImJ1c2luZXNzIiwicGhvbmUiOiIiLCJpYXQiOjE3NDA1MzY0NzUsImV4cCI6NDg5NDEzNjQ3NX0.hr4D0bOA4K09Vhp12itiJgd-nVDQ3VZO8D7MVP5Ltw0";
|
||||
public string httpServer = "http://220.90.135.112:3100";
|
||||
public string facilityAPI = "/api/workConditionAnalysis/facilityCode";
|
||||
public string workingConditionsAPI = "/api/workConditionAnalysis/analyze";
|
||||
public string workingTimeAPI = "/api/workTimeAnalysis/analyze";
|
||||
|
||||
public string startDate;
|
||||
public string endDate;
|
||||
|
||||
public WorkConditionsRequestBody testWorkConditionRequest;
|
||||
public WorkTimeRequesttBody testWorkTimeRequest;
|
||||
|
||||
public WorkConditionsData workConditionsData;
|
||||
public WorkTimeData workTimeData;
|
||||
void Start()
|
||||
{
|
||||
StartCoroutine(HTTPWebRequest());
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.K))
|
||||
{
|
||||
WorkConditionInQuiry();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.J))
|
||||
{
|
||||
WorkTimeInQuiry();
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator HTTPWebRequest()
|
||||
{
|
||||
var path = httpServer + facilityAPI;
|
||||
var query = $"?startDate={startDate}&endDate={endDate}";
|
||||
|
||||
string url = path + query;
|
||||
|
||||
UnityWebRequest www = UnityWebRequest.Get(url);
|
||||
www.SetRequestHeader("access-token", apiKey);
|
||||
|
||||
yield return www.SendWebRequest();
|
||||
|
||||
if (www.error == null)
|
||||
{
|
||||
Debug.Log(www.downloadHandler.text);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log(www.error);
|
||||
}
|
||||
}
|
||||
|
||||
private void WorkConditionInQuiry()
|
||||
{
|
||||
var path = httpServer + workingConditionsAPI;
|
||||
|
||||
testWorkConditionRequest = TestWorkConditionSetting();
|
||||
var json = JsonUtility.ToJson(testWorkConditionRequest);
|
||||
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(WorkConditionsPost(path, json));
|
||||
}
|
||||
IEnumerator WorkConditionsPost(string url, string jsonData)
|
||||
{
|
||||
var request = new UnityWebRequest(url, "POST");
|
||||
byte[] bodyRaw = new System.Text.UTF8Encoding().GetBytes(jsonData);
|
||||
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
|
||||
request.downloadHandler = new DownloadHandlerBuffer();
|
||||
request.SetRequestHeader("access-token", apiKey);
|
||||
request.SetRequestHeader("Content-Type", "application/json");
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.Log("Error: " + request.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
var payload = Encoding.UTF8.GetString(request.downloadHandler.data);
|
||||
var response = JsonConvert.DeserializeObject<WorkConditionsData>(payload);
|
||||
|
||||
workConditionsData = response;
|
||||
Debug.Log("Received: " + request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
|
||||
private void WorkTimeInQuiry()
|
||||
{
|
||||
var path = httpServer + workingTimeAPI;
|
||||
|
||||
testWorkTimeRequest = TestWorkTimeSetting();
|
||||
var json = JsonUtility.ToJson(testWorkTimeRequest);
|
||||
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(WorkTimePost(path, json));
|
||||
}
|
||||
IEnumerator WorkTimePost(string url, string jsonData)
|
||||
{
|
||||
var request = new UnityWebRequest(url, "POST");
|
||||
byte[] bodyRaw = new UTF8Encoding().GetBytes(jsonData);
|
||||
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
|
||||
request.downloadHandler = new DownloadHandlerBuffer();
|
||||
request.SetRequestHeader("access-token", apiKey);
|
||||
request.SetRequestHeader("Content-Type", "application/json");
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.Log("Error: " + request.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
var payload = Encoding.UTF8.GetString(request.downloadHandler.data);
|
||||
var response = JsonConvert.DeserializeObject<WorkTimeData>(payload);
|
||||
|
||||
workTimeData = response;
|
||||
|
||||
Debug.Log("Received: " + request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
#region TestJson
|
||||
WorkTimeRequesttBody TestWorkTimeSetting()
|
||||
{
|
||||
WorkTimeRequesttBody request = new WorkTimeRequesttBody
|
||||
{
|
||||
startDate = "2025-01-10T00:00:00Z",
|
||||
endDate = "2025-02-20T00:00:00Z",
|
||||
MCHCD = "IJ01",
|
||||
WO = "WO202502170014"
|
||||
};
|
||||
return request;
|
||||
}
|
||||
WorkConditionsRequestBody TestWorkConditionSetting()
|
||||
{
|
||||
WorkConditionsRequestBody request = new WorkConditionsRequestBody
|
||||
{
|
||||
startDate = "2025-01-10T00:00:00Z",
|
||||
endDate = "2025-02-20T00:00:00Z",
|
||||
MCHCD = "IJ01",
|
||||
WO = "WO202502170014"
|
||||
};
|
||||
return request;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
11
Assets/WorkSpace/Personal/JYM/HTTPTest.cs.meta
Normal file
11
Assets/WorkSpace/Personal/JYM/HTTPTest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80da20d3dc717bf4291ee9570be46601
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/WorkSpace/Personal/JYM/WorkConditionFacilityData.cs
Normal file
10
Assets/WorkSpace/Personal/JYM/WorkConditionFacilityData.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
[Serializable]
|
||||
public class WorkConditionFacilityData
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0aedb69ce4a26a4598eb5372deb6c61
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/WorkSpace/Personal/JYM/WorkConditionsData.cs
Normal file
40
Assets/WorkSpace/Personal/JYM/WorkConditionsData.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class WorkConditionsData
|
||||
{
|
||||
public string status;
|
||||
public string code;
|
||||
public string message;
|
||||
public ConditionsData data;
|
||||
public string remark;
|
||||
}
|
||||
[Serializable]
|
||||
public class ConditionsData
|
||||
{
|
||||
public string count;
|
||||
public WorkConditions[] rows;
|
||||
}
|
||||
[Serializable]
|
||||
public class WorkConditions
|
||||
{
|
||||
public string result;
|
||||
public string table;
|
||||
public string _start;
|
||||
public string _stop;
|
||||
public string _time;
|
||||
public string DAYNIGHT;
|
||||
public string ITEMCD;
|
||||
public string MCHCD;
|
||||
public string MOLDCD;
|
||||
public string MOLDSEQ;
|
||||
public string WO;
|
||||
public string _measurement;
|
||||
public string C027;
|
||||
public string C045;
|
||||
public string HUMI01;
|
||||
public string TEMP01;
|
||||
}
|
||||
11
Assets/WorkSpace/Personal/JYM/WorkConditionsData.cs.meta
Normal file
11
Assets/WorkSpace/Personal/JYM/WorkConditionsData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19bf12f50a431034a92a67f5dfe41688
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/WorkSpace/Personal/JYM/WorkTimeData.cs
Normal file
40
Assets/WorkSpace/Personal/JYM/WorkTimeData.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
[Serializable]
|
||||
public class WorkTimeData
|
||||
{
|
||||
public string status;
|
||||
public string code;
|
||||
public string message;
|
||||
public TimeData data;
|
||||
public string remark;
|
||||
}
|
||||
[Serializable]
|
||||
public class TimeData
|
||||
{
|
||||
public string count;
|
||||
public WorkTime[] rows;
|
||||
}
|
||||
[Serializable]
|
||||
public class WorkTime
|
||||
{
|
||||
public string result;
|
||||
public string table;
|
||||
public string _start;
|
||||
public string _stop;
|
||||
public string _time;
|
||||
public string DAYNIGHT;
|
||||
public string ITEMCD;
|
||||
public string MCHCD;
|
||||
public string MOLDCD;
|
||||
public string MOLDSEQ;
|
||||
public string WO;
|
||||
public string _measurement;
|
||||
public string C027;
|
||||
public string C045;
|
||||
public string HUMI01;
|
||||
public string TEMP01;
|
||||
}
|
||||
11
Assets/WorkSpace/Personal/JYM/WorkTimeData.cs.meta
Normal file
11
Assets/WorkSpace/Personal/JYM/WorkTimeData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f86d05b6900618448355c1a9f8ad5d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user