216 lines
7.1 KiB
C#
216 lines
7.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using WI;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using System;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Menu;
|
|
using System.Globalization;
|
|
|
|
namespace CHN
|
|
{
|
|
public enum DataColumn
|
|
{
|
|
보압,
|
|
주변온도,
|
|
주변습도,
|
|
}
|
|
public class Panel_WorkConditionAnalysis : PanelBase, ISingle
|
|
{
|
|
private Button Button_StartDay;
|
|
private Button Button_EndDay;
|
|
private TextMeshProUGUI Text_StartDay;
|
|
private TextMeshProUGUI Text_EndDay;
|
|
private TMP_Dropdown Dropdown_Facility;
|
|
private TMP_InputField InputField_WorkOrderNumber;
|
|
private Button Button_Search;
|
|
private Button Button_Close;
|
|
private TextMeshProUGUI ITEMCD;
|
|
private TMP_Dropdown Dropdown_DataColumn;
|
|
|
|
private UI_Calendar ui_Calendar;
|
|
public UI_GraphChart mainChart;
|
|
public UI_GraphChart[] subCharts;
|
|
private RectTransform ChartDatas;
|
|
private RectTransform SubCharts;
|
|
|
|
public Action<string, string, string, string> onSearchData;
|
|
public Action<string> onChangedDropdownValue;
|
|
public Dictionary<string, int> dropdownValues = new Dictionary<string, int>();
|
|
|
|
public WorkConditionsData data;
|
|
public Action<string> onClose;
|
|
public Panel_Effect effect;
|
|
|
|
public float fadeTime;
|
|
public override void AfterAwake()
|
|
{
|
|
ui_Calendar = transform.GetComponentInChildren<UI_Calendar>(true);
|
|
mainChart = transform.GetComponentInChildren<UI_GraphChart>();
|
|
subCharts = SubCharts.GetComponentsInChildren<UI_GraphChart>();
|
|
|
|
Button_Close.onClick.AddListener(OnClickCloseButton);
|
|
Button_StartDay.onClick.AddListener(OnClickStartDayBtn);
|
|
Button_EndDay.onClick.AddListener(OnClickEndDayBtn);
|
|
Button_Search.onClick.AddListener(OnClickSearchBtn);
|
|
|
|
ui_Calendar.Close();
|
|
|
|
Text_StartDay.text = DateTime.Now.ToString("yyyy-MM-dd");
|
|
Text_EndDay.text = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
|
ChartDatas.gameObject.SetActive(false);
|
|
gameObject.transform.localScale = Vector3.zero;
|
|
}
|
|
public void Open()
|
|
{
|
|
effect.ActivePanel(gameObject);
|
|
gameObject.SetActive(true);
|
|
gameObject.transform.SetAsLastSibling();
|
|
|
|
StopAllCoroutines();
|
|
StartCoroutine(ScaleUp());
|
|
}
|
|
public void Close()
|
|
{
|
|
effect.DeactivePanel(gameObject);
|
|
gameObject.SetActive(false);
|
|
gameObject.transform.localScale = Vector3.zero;
|
|
}
|
|
public void OnClickCloseButton()
|
|
{
|
|
onClose?.Invoke("작업 조건 분석");
|
|
}
|
|
private void OnClickStartDayBtn()
|
|
{
|
|
ui_Calendar.Open(Text_StartDay);
|
|
}
|
|
private void OnClickEndDayBtn()
|
|
{
|
|
ui_Calendar.Open(Text_EndDay);
|
|
}
|
|
|
|
public void SetFacilityDropDown(WorkConditionFacilityData facilityData)
|
|
{
|
|
Dropdown_Facility.ClearOptions();
|
|
string[] data = facilityData.data;
|
|
|
|
List<TMP_Dropdown.OptionData> optionList = new List<TMP_Dropdown.OptionData>();
|
|
|
|
foreach (string str in data)
|
|
{
|
|
optionList.Add(new TMP_Dropdown.OptionData(str));
|
|
}
|
|
|
|
Dropdown_Facility.AddOptions(optionList);
|
|
Dropdown_Facility.value = 0;
|
|
}
|
|
|
|
private void OnClickSearchBtn()
|
|
{
|
|
DateTime startDate = Convert.ToDateTime(Text_StartDay.text);
|
|
DateTime endDate = Convert.ToDateTime(Text_EndDay.text);
|
|
|
|
string startDateString = startDate.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
|
string endDateString = endDate.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
|
string MCHCD = Dropdown_Facility.options[Dropdown_Facility.value].text;
|
|
string WO = InputField_WorkOrderNumber.text;
|
|
|
|
onSearchData?.Invoke(startDateString, endDateString, MCHCD, WO);
|
|
}
|
|
|
|
//public void SetChartLabels(List<string> chartLabels)
|
|
//{
|
|
// mainChart.SetChartLabels(chartLabels);
|
|
//}
|
|
public void SetWorkConditionsData(WorkConditionsData workConditionsData)
|
|
{
|
|
ChartDatas.gameObject.SetActive(true);
|
|
|
|
data = workConditionsData;
|
|
|
|
if (data.data.rows.Length > 0)
|
|
{
|
|
ITEMCD.text = data.data.rows[0].ITEMCD;
|
|
}
|
|
|
|
SetDataColumnDropDown();
|
|
OnDropdownValueChanged(0);
|
|
}
|
|
public void SetChartData(Dictionary<string, GraphChartData> mainChart)
|
|
{
|
|
var value = Dropdown_DataColumn.value;
|
|
var optionName = Dropdown_DataColumn.options[value].text;
|
|
|
|
this.mainChart.SetChartData(optionName, mainChart[optionName]);
|
|
}
|
|
public void SetSubChartDatas(Dictionary<string, GraphChartData> subCharts)
|
|
{
|
|
var subChartNames = new List<string>();
|
|
var subChartValue = new List<int>();
|
|
|
|
foreach (var option in Dropdown_DataColumn.options)
|
|
{
|
|
var optionName = option.text;
|
|
|
|
if (mainChart.graphName != optionName)
|
|
{
|
|
subChartNames.Add(optionName);
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < subCharts.Count; i++)
|
|
{
|
|
this.subCharts[i].SetChartData(subChartNames[i], subCharts[subChartNames[i]]);
|
|
this.subCharts[i].onClickChart += OnClickChart;
|
|
}
|
|
}
|
|
private void SetDataColumnDropDown()
|
|
{
|
|
dropdownValues.Clear();
|
|
Dropdown_DataColumn.ClearOptions();
|
|
List<TMP_Dropdown.OptionData> optionList = new List<TMP_Dropdown.OptionData>();
|
|
optionList.Add(new TMP_Dropdown.OptionData("보압 (Peak)"));
|
|
optionList.Add(new TMP_Dropdown.OptionData("주변 습도"));
|
|
optionList.Add(new TMP_Dropdown.OptionData("주변 온도"));
|
|
optionList.Add(new TMP_Dropdown.OptionData("싸이클 타임"));
|
|
|
|
for (int i = 0; i < optionList.Count; i++)
|
|
{
|
|
dropdownValues.Add(optionList[i].text, i);
|
|
}
|
|
|
|
Dropdown_DataColumn.AddOptions(optionList);
|
|
Dropdown_DataColumn.onValueChanged.AddListener(OnDropdownValueChanged);
|
|
|
|
Dropdown_DataColumn.value = 0;
|
|
}
|
|
private void OnClickChart(string graphName)
|
|
{
|
|
Dropdown_DataColumn.value = dropdownValues[graphName];
|
|
}
|
|
private void OnDropdownValueChanged(int arg0)
|
|
{
|
|
var optionName = Dropdown_DataColumn.options[arg0].text;
|
|
onChangedDropdownValue?.Invoke(optionName);
|
|
}
|
|
IEnumerator ScaleUp()
|
|
{
|
|
float timer = 0f;
|
|
float percent = 0f;
|
|
|
|
while (percent < 1)
|
|
{
|
|
timer += Time.deltaTime;
|
|
percent = timer / fadeTime;
|
|
transform.localScale = Vector3.Lerp(transform.localScale, Vector3.one, percent);
|
|
|
|
yield return null;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|