176 lines
4.8 KiB
C#
176 lines
4.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Xml;
|
|
using UnityEngine;
|
|
using System.Linq;
|
|
using DataModel.Model;
|
|
using LitJson;
|
|
|
|
public class ScoreBase : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 评估序号
|
|
/// </summary>
|
|
public int code;
|
|
/// <summary>
|
|
/// 评估点
|
|
/// </summary>
|
|
[DisplayOnly]
|
|
public string scoreName;
|
|
/// <summary>
|
|
/// 岗位名
|
|
/// </summary>
|
|
[DisplayOnly]
|
|
public string seatName;
|
|
/// <summary>
|
|
/// 步骤序号
|
|
/// </summary>
|
|
[DisplayOnly]
|
|
public int stepOrder;
|
|
/// <summary>
|
|
/// 分值
|
|
/// </summary>
|
|
[DisplayOnly]
|
|
public int scoreValue;
|
|
|
|
[Header("如果有前置打分点,则配置有效")]
|
|
/// <summary>
|
|
/// 是否有前置打分点
|
|
/// </summary>
|
|
public bool hasFrontPoint;
|
|
/// <summary>
|
|
/// 前置评估点编号
|
|
/// </summary>
|
|
public int frontScorePointCode;
|
|
/// <summary>
|
|
/// 前置打分点
|
|
/// </summary>
|
|
[HideInInspector]
|
|
public ScoreBase frontScorePoint;
|
|
|
|
[Header("==============")]
|
|
|
|
/// <summary>
|
|
/// 评分点是否正确
|
|
/// </summary>
|
|
[DisplayOnly]
|
|
public bool IsRight;
|
|
|
|
/// <summary>
|
|
/// 是否激活
|
|
/// </summary>
|
|
[DisplayOnly]
|
|
public bool IsActive = false;
|
|
|
|
/// <summary>
|
|
/// 判断点完成顺序
|
|
/// </summary>
|
|
[HideInInspector]
|
|
public int Completed = 0;
|
|
|
|
|
|
public virtual void Init(string subjectName,int code)
|
|
{
|
|
this.code = code;
|
|
XmlNode node = ScoreManage.scoreXML.SelectSingleNode("root/Sub_" + subjectName);
|
|
foreach (XmlNode item in node.ChildNodes)
|
|
{
|
|
if(item.Attributes["code"].Value==code.ToString())
|
|
{
|
|
scoreName = item.Attributes["Text"].Value;
|
|
seatName= item.Attributes["seatName"].Value;
|
|
scoreValue = int.Parse(item.Attributes["scoreValue"].Value);
|
|
stepOrder = int.Parse(item.Attributes["stepOrder"].Value);
|
|
break;
|
|
}
|
|
}
|
|
|
|
//获取前置
|
|
if (hasFrontPoint)
|
|
{
|
|
ScoreBase sb= transform.parent.GetComponentsInChildren<ScoreBase>(true).ToList().Find(a => a.code == frontScorePointCode);
|
|
if(sb!=null)
|
|
{
|
|
frontScorePoint = sb;
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("前置条件错误:" + subjectName + " " + code);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 激活(按科目激活)
|
|
/// </summary>
|
|
public virtual void SetActive(bool isActive)
|
|
{
|
|
IsActive = isActive;
|
|
if(isActive)
|
|
{
|
|
transform.GetComponentsInChildren<ScoreJudge_FixedValue>(true).ToList().ForEach(a =>
|
|
{
|
|
a.AddAction();
|
|
});
|
|
}
|
|
else
|
|
{
|
|
transform.GetComponentsInChildren<ScoreJudge_FixedValue>(true).ToList().ForEach(a =>
|
|
{
|
|
a.RemoveAction();
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
public virtual void SetIsRight()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提交分表分数 (暂定点击步骤结束提交)
|
|
/// </summary>
|
|
public virtual void Submit()
|
|
{
|
|
if (IsActive)
|
|
{
|
|
SetActive(false);
|
|
appraisedetail appraisedetail = new appraisedetail
|
|
{
|
|
Id = System.Guid.NewGuid().ToString(),
|
|
PracticeId = LoadManage.Instance.currentPractice.Id,
|
|
AppraiseId = LoadManage.Instance.currentPractice.Id,
|
|
SubjectId = LoadManage.Instance.psubjects.Find(a => a.Name == transform.parent.name).SubjectId,
|
|
PracticeSubjectId= LoadManage.Instance.psubjects.Find(a => a.Name == transform.parent.name).Id,
|
|
UserAccount = LoadManage.Instance.me.user.user_name,
|
|
RoleName = seatName,
|
|
Idx = code,
|
|
Notice = scoreName,
|
|
Score = (IsRight ? 0 : -scoreValue),
|
|
Completed=(IsRight ? 1:0)
|
|
};
|
|
|
|
|
|
//提交数据库
|
|
string url = "http://"+MyNetMQClient.CallIP+ "/Handler/Api_Appraise.ashx";
|
|
var tmp= new KeyValuePair<string, string>[2];
|
|
tmp[0] = new KeyValuePair<string, string>("action", "setScore");
|
|
tmp[1] = new KeyValuePair<string, string>("appraiseDetail", JsonMapper.ToJson(appraisedetail));
|
|
StartCoroutine(MyNetMQClient.CallPost(url, tmp, result =>
|
|
{
|
|
var json = JsonMapper.ToObject<CallResultObject>(result);
|
|
if (json.state)
|
|
{
|
|
Debug.Log("上传分数:++++++++++++++++++++++++++++++" + JsonMapper.ToJson(appraisedetail));
|
|
}
|
|
else
|
|
{
|
|
Debug.Log(json.message);
|
|
}
|
|
}));
|
|
}
|
|
}
|
|
}
|