208 lines
6.6 KiB
C#
208 lines
6.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using UnityEngine;
|
|
/// <summary>
|
|
/// 数据管理类
|
|
/// </summary>
|
|
public class DataManager : BaseManager<DataManager>
|
|
{
|
|
private DataManager() { }
|
|
|
|
/// <summary>
|
|
/// 方案
|
|
/// </summary>
|
|
private Dictionary<int, TB_Scheme> schemeDic = new Dictionary<int, TB_Scheme>();
|
|
|
|
/// <summary>
|
|
/// 流程
|
|
/// </summary>
|
|
private Dictionary<int, TB_Process> processDic = new Dictionary<int, TB_Process>();
|
|
|
|
/// <summary>
|
|
/// 子流程
|
|
/// </summary>
|
|
private Dictionary<int, TB_SubProcess> subProcessDic = new Dictionary<int, TB_SubProcess>();
|
|
|
|
/// <summary>
|
|
/// 子流程步骤
|
|
/// </summary>
|
|
private Dictionary<int, TB_SubProcessStep> subProcessStepDic = new Dictionary<int, TB_SubProcessStep>();
|
|
|
|
/// <summary>
|
|
/// 虚拟仿真系统
|
|
/// </summary>
|
|
private Dictionary<int, TB_System> systemDic = new Dictionary<int, TB_System>();
|
|
|
|
/// <summary>
|
|
/// 设备类型
|
|
/// </summary>
|
|
private Dictionary<int, TB_DeviceType> deviceTypeDic = new Dictionary<int, TB_DeviceType>();
|
|
|
|
/// <summary>
|
|
/// 工具材料
|
|
/// </summary>
|
|
private Dictionary<int, TB_ToolAndMaterial> toolAndMaterialDic = new Dictionary<int, TB_ToolAndMaterial>();
|
|
|
|
/// <summary>
|
|
/// 用户数据
|
|
/// </summary>
|
|
public UserData userData = new UserData();
|
|
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
public void Init()
|
|
{
|
|
schemeDic = GameManager.BinaryMgr.GetTable<TB_SchemeContainer>().dataDic;
|
|
processDic = GameManager.BinaryMgr.GetTable<TB_ProcessContainer>().dataDic;
|
|
subProcessDic = GameManager.BinaryMgr.GetTable<TB_SubProcessContainer>().dataDic;
|
|
subProcessStepDic = GameManager.BinaryMgr.GetTable<TB_SubProcessStepContainer>().dataDic;
|
|
systemDic = GameManager.BinaryMgr.GetTable<TB_SystemContainer>().dataDic;
|
|
deviceTypeDic = GameManager.BinaryMgr.GetTable<TB_DeviceTypeContainer>().dataDic;
|
|
toolAndMaterialDic = GameManager.BinaryMgr.GetTable<TB_ToolAndMaterialContainer>().dataDic;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取D_Scheme
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public D_Scheme GetSchemeData(int id)
|
|
{
|
|
D_Scheme d_Scheme = new D_Scheme();
|
|
//获取方案数据
|
|
if (schemeDic.ContainsKey(id))
|
|
{
|
|
d_Scheme.id = schemeDic[id].id;
|
|
d_Scheme.schemeName = schemeDic[id].schemeName;
|
|
}
|
|
d_Scheme.processes = GetD_Processes(d_Scheme.id);
|
|
return d_Scheme;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据方案Id 获取流程列表
|
|
/// </summary>
|
|
/// <param name="schemeId"></param>
|
|
/// <returns></returns>
|
|
private List<D_Process> GetD_Processes(int schemeId)
|
|
{
|
|
List<D_Process> d_Processes = new List<D_Process>();
|
|
//获取方案流程数据
|
|
foreach (var item in processDic.Values)
|
|
{
|
|
if (item.schemeId == schemeId)
|
|
{
|
|
D_Process d_Process = new D_Process();
|
|
d_Process.id = item.id;
|
|
d_Process.processName = item.processName;
|
|
int processId = item.id;
|
|
d_Process.subProcesses = GetD_SubProcesses(schemeId, processId);
|
|
d_Processes.Add(d_Process);
|
|
}
|
|
}
|
|
return d_Processes;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据方案Id,流程Id ,获取子流程列表
|
|
/// </summary>
|
|
/// <param name="schemeId"></param>
|
|
/// <param name="processId"></param>
|
|
/// <returns></returns>
|
|
public List<D_SubProcess> GetD_SubProcesses(int schemeId, int processId)
|
|
{
|
|
List<D_SubProcess> d_SubProcesses = new List<D_SubProcess>();
|
|
foreach (var item in subProcessDic.Values)
|
|
{
|
|
if (item.schemeId == schemeId && item.processId == processId)
|
|
{
|
|
D_SubProcess d_SubProcess = new D_SubProcess();
|
|
d_SubProcess.id = item.id;
|
|
d_SubProcess.schemeId = item.schemeId;
|
|
d_SubProcess.processId = item.processId;
|
|
d_SubProcess.isPrecondition = item.isPrecondition;
|
|
d_SubProcess.precondition = item.precondition;
|
|
d_SubProcess.tips = item.tips;
|
|
int subProcessId = item.id;
|
|
d_SubProcess.subProcessStepes = GetD_SubProcessSteps(schemeId, processId, subProcessId);
|
|
d_SubProcesses.Add(d_SubProcess);
|
|
}
|
|
}
|
|
return d_SubProcesses;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据方案Id,流程Id,子流程Id 获取子流程步骤列表
|
|
/// </summary>
|
|
/// <param name="schemeId"></param>
|
|
/// <param name="processId"></param>
|
|
/// <param name="subProcessStepId"></param>
|
|
/// <returns></returns>
|
|
private List<D_SubProcessStep> GetD_SubProcessSteps(int schemeId, int processId, int subProcessId)
|
|
{
|
|
List<D_SubProcessStep> d_SubProcessSteps = new List<D_SubProcessStep>();
|
|
foreach (var step in subProcessStepDic.Values)
|
|
{
|
|
if (step.schemeId == schemeId && step.processId == processId && step.subProcessId == subProcessId)
|
|
{
|
|
D_SubProcessStep d_SubProcessStep = new D_SubProcessStep();
|
|
d_SubProcessStep.id = step.id;
|
|
d_SubProcessStep.schemeId = step.schemeId;
|
|
d_SubProcessStep.processId = step.processId;
|
|
d_SubProcessStep.subProcessId = step.subProcessId;
|
|
d_SubProcessStep.subProcessStepName = step.subProcessStepName;
|
|
d_SubProcessStep.isPrecondition = step.isPrecondition;
|
|
d_SubProcessStep.precondition = step.precondition;
|
|
d_SubProcessStep.score = step.score;
|
|
d_SubProcessSteps.Add(d_SubProcessStep);
|
|
}
|
|
}
|
|
return d_SubProcessSteps;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据系统Id 获取系统信息
|
|
/// </summary>
|
|
/// <param name="systemId"></param>
|
|
/// <returns></returns>
|
|
public TB_System GetSystemInfo(int systemId)
|
|
{
|
|
if (systemDic.ContainsKey(systemId))
|
|
{
|
|
return systemDic[systemId];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取报告
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
public R_Scheme GetSchemeReport(int id)
|
|
{
|
|
R_Scheme r_Scheme = new R_Scheme();
|
|
|
|
|
|
return r_Scheme;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public TB_Scheme GetTitleSpriteName(int id)
|
|
{
|
|
if (schemeDic.ContainsKey(id))
|
|
{
|
|
return schemeDic[id];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
|
|
}
|