对接莱医特平台

This commit is contained in:
shenjianxing 2025-04-11 15:22:47 +08:00
parent a374f5a488
commit 6bd36e8e80
21 changed files with 439 additions and 20 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6dcc6d8ed48376e478d9a91d0846f80d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -5,11 +5,14 @@ PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
'': Any
: Any
second:
enabled: 0
settings:
@ -19,17 +22,17 @@ PluginImporter:
Exclude Linux64: 0
Exclude LinuxUniversal: 0
Exclude OSXUniversal: 0
Exclude WebGL: 0
Exclude WebGL: 1
Exclude Win: 0
Exclude Win64: 1
- first:
'': OSXIntel
: OSXIntel
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
'': OSXIntel64
: OSXIntel64
second:
enabled: 0
settings:
@ -50,7 +53,7 @@ PluginImporter:
second:
enabled: 1
settings:
CPU: x86
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
@ -104,7 +107,7 @@ PluginImporter:
- first:
WebGL: WebGL
second:
enabled: 1
enabled: 0
settings: {}
userData:
assetBundleName:

View File

@ -5,11 +5,14 @@ PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
'': Any
: Any
second:
enabled: 0
settings:
@ -19,17 +22,17 @@ PluginImporter:
Exclude Linux64: 0
Exclude LinuxUniversal: 0
Exclude OSXUniversal: 0
Exclude WebGL: 0
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 0
- first:
'': OSXIntel
: OSXIntel
second:
enabled: 0
settings:
CPU: None
- first:
'': OSXIntel64
: OSXIntel64
second:
enabled: 1
settings:
@ -76,7 +79,7 @@ PluginImporter:
second:
enabled: 1
settings:
CPU: x86_64
CPU: AnyCPU
- first:
Standalone: LinuxUniversal
second:
@ -104,7 +107,7 @@ PluginImporter:
- first:
WebGL: WebGL
second:
enabled: 1
enabled: 0
settings: {}
userData:
assetBundleName:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e2f1f4b08170f7e4d885e9154afbd7a1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
<RSAKeyValue>
<Modulus>vsWZ0Eu/pLeJblZfeAQ7p+KWQHqiJnp9UNwfHLW8Ev2EI9Kg2aPiB/DGmhPab8yCfuQuZIqJSwcCX1XzVvtIOoeeKy53VHOity0oxADtoY+TZSbJraG0+kEwE+S8HZ8u8xAoVg1xcI1a/wnS2CmZSvoqwpOFKufcosyZZeWTyQXhTipLIudmmA+KFWxRjXzcigE/46fA76MzSoH9WUaIq+d8DPJMQwURZcxmMRwIkSmzz6rss10uSdTGqM7VmewDkqeWugIjS0wzSMBKQYgv1rxbMO38hd58J0mygKtjMRdm38MUaPfm2fYCFhqRBuUXnLZ992NHpUNsXesSzlLlyw==</Modulus>
<Exponent>AQAB</Exponent>
<P>+JTwTuuxi9suxLj+qVfpWwYQ7VIpG5EubZoZrFeHNynysgTbJuSvuujN7rgpT3uejxBbUMjxaOlikECKpTdGs6gyNaAKce6SA+4xobbWmFUS4uE7RBbIXefq/jof0V/etBW4eXwG2IiB2IKhVbPyq3lVmbZcQr3Matm9oEu+H6E=</P>
<Q>xHcEu0QIDKgxNYLgsmq7i+P+vLGCTXs+8EVNkBKMoyRpLpP+TPCcKnHRK7+j0Od4tD1yYNk/IGPOojjdwzouSDGpIpHNNHOwUOr/n0DVwTWIs8kTRDDVa8al+ptaD8cfssbfbdgs8QkvloX09YLZpZ5dfeKrBH3ZpEtqtjwyves=</Q>
<DP>buhEr3GJLZUFMNA5DuUiQHJcawYVQS9tP4lZmwMSWRJmLfbssFWn8gScnL2d8NB+1eW+WDTPQLegOiwRr9URvmZ0wGg/QMXob8h+bGBfLmgGnSNQhfiEPSGUPwk/2PKlMkPeopUrmMCO7kKaKNq4krj38DTkxQJZifLMIBCrKwE=</DP>
<DQ>gSyIDeCTMk8726Uru+N1YGsNyF8l/2+zWCMY9ktb8MA18AwaPdhNtZKUJyGfwfEPaeKk24y7dr5o1DxzgrM0Tv9n53TZ6UzPdsSsQbdNU/Ww5hSk+EbrbCt2YinWs10HOHKN4Rkro2eYxG1bPDlGhSB09Boeu5tLiDyV8y/tZPU=</DQ>
<InverseQ>FZzsXZ8ReLoBF9hYAaxP4/41uvReXoYVi3AcJrTwtC3a3fBKGAfXB+6oMbVtU9iPOWD1C7I0ZZh3A8xhQp730bLvbbdZWrpR4eY2RnefAW9EJESHfdDCxnsAIiH7+V/gAieF7bN0G5uifx/OxQl5pogovrLWLmZ+cw3QnMLX1kY=</InverseQ>
<D>trGx7eK881e5S2t4Hg2fu9WpIrLOmp7vaAKF4Q7BwEX8x/mshQEHM6eH6oJczHhD+JU5QJvTg4CA6x/63C/lKfg6pwvmx3++MkITKjHhYLmI5HPS7G9SS98l1cdVx+BsK+YrWs2g97LHlDqqKs0busv9Kz3vZ/mIOHhL52OGthk7SBSL0Nbq5rCCyErQEKPk3HmVmF2nJTam3d1PK0OT7I4IH5Szn9CXt1R3kk1Y2NZb3GIrcPUaQ7+75/DlVL05Leabc/eMi/ghhyCqOotHnLw8uNf3kK6QvD/bv3C4Ikdy1ZYBpENz74OMeINWAEXZyARLgs4EryA+6F7Fw3magQ==</D>
</RSAKeyValue>

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fa05fa85bd33f6c4ca626c1e0317d53d
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/WebPlatform.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1313d4092ca8d554bb23e331d88db6d1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8f4e4f808ac25d946affe317d1b81545
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,223 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
public class LYTWebGLHelper : MonoBehaviour
{
public class LabData
{
public string GUID;
public string ExpID;
public string HOST = string.Empty;
public string PARA1;
public string PARA;
public string PARA2;
}
#if UNITY_WEBGL
[DllImport("__Internal")]
private static extern IntPtr GetURLParameter(string name);
#endif
string token = string.Empty;
LabData labData = new LabData();
[SerializeField]
private TextAsset RSA;
private const int RsaKeySize = 2048;
public string uploadUrl;
public static LYTWebGLHelper Instance;
private void Awake()
{
#if UNITY_WEBGL
Instance = this;
DontDestroyOnLoad(this);
#endif
}
public void Init()
{
#if UNITY_WEBGL && !UNITY_EDITOR
var paramPtr = GetURLParameter("token");
if (paramPtr != IntPtr.Zero)
{
string value = Marshal.PtrToStringUTF8(paramPtr);
//token = value.Replace("%2B", "+");
token = value.Replace(" ", "+");
Marshal.FreeHGlobal(paramPtr); // 释放分配的内存
}
Debug.LogError("获取的:" + token);
#endif
RSA = Resources.Load<TextAsset>("LYTWebGL/RSA");
if (string.IsNullOrEmpty(token) == false)
{
string urlData = Decrypt(token);
var datas = urlData.Split("&");
labData.GUID = datas[0];
labData.ExpID = datas[1];
labData.HOST = datas[2];
labData.PARA1 = datas[3];
labData.PARA = datas[4];
labData.PARA2 = datas[5];
}
uploadUrl = Path.Combine(labData.HOST, "host/public/Exp/AddScore/");
}
/// <summary>
/// Decrypts encrypted text given a RSA private key file path.给定路径的 RSA 私钥文件解
/// </summary>
/// <param name="encryptedText">加密的密文</param>
/// <param name="pathToPrivateKey">用于加密的私钥路径.</param>
/// <returns>未加密数据的字符串</returns>
public string Decrypt(string encryptedText)
{
using (var rsa = new RSACryptoServiceProvider(RsaKeySize))
{
try
{
string privateXmlKey = RSA.text;
rsa.FromXmlString(privateXmlKey);
Debug.Log("encryptedText " + encryptedText);
var bytesEncrypted = Convert.FromBase64String(encryptedText);
string b = Encoding.UTF8.GetString(bytesEncrypted);
Debug.Log("byte " + b);
//var bytesPlainText = rsa.Decrypt(bytesEncrypted, false);
var bytesPlainText = rsa.Decrypt(bytesEncrypted, false);
Debug.Log("bytesPlainText " + bytesPlainText);
return System.Text.Encoding.UTF8.GetString(bytesPlainText);
}
finally
{
rsa.PersistKeyInCsp = false;
}
}
}
public void UpLoadData(int totalScore, List<string> stepNames, List<int> maxScore, List<int> score)
{
if (string.IsNullOrEmpty(token))
{
Init();
}
var data = new UploadData();
data.GUID = labData.GUID;
int expId = 0;
int.TryParse(labData.ExpID, out expId);
data.ExpID = expId;
data.score = totalScore;
data.flag = true;
var list = new List<Expstepvtwolist>();
for (int i = 0; i < stepNames.Count; i++)
{
var step = new Expstepvtwolist();
step.ExpStepName = stepNames[i];
step.maxScore = maxScore[i];
step.score = score[i];
list.Add(step);
}
data.ExpStepVTwoList = list.ToArray();
StartCoroutine(SendScore(JsonConvert.SerializeObject(data)));
}
IEnumerator SendScore(string json, UnityAction<string> action = null)
{
if (string.IsNullOrEmpty(uploadUrl))
{
Debug.LogError("上传接口地址错误:" + uploadUrl);
yield break;
}
Debug.LogError("上传的数据:" + json);
using (UnityWebRequest request = new UnityWebRequest(uploadUrl, "POST"))
{
request.SetRequestHeader("Content-Type", "application/json");
request.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(json));
request.downloadHandler = new DownloadHandlerBuffer();
yield return request.SendWebRequest();
// 处理响应
if (request.result == UnityWebRequest.Result.ConnectionError ||
request.result == UnityWebRequest.Result.ProtocolError)
{
Debug.LogError($"Upload failed: {request.uri}");
Debug.LogError($"Upload failed: {request.error}");
Debug.LogError($"Response Code: {request.responseCode}");
}
else
{
Debug.Log("Upload complete!");
Debug.Log($"Response Code: {request.responseCode}");
Debug.Log($"Server Response: {request.downloadHandler.text}");
Response response = JsonConvert.DeserializeObject<Response>(request.downloadHandler.text);
Debug.LogError(response.msg);
action?.Invoke(response.msg);
}
}
}
public class UploadData
{
public string GUID { get; set; }
// 实验 ID
public int ExpID { get; set; }
// 成绩
public int score { get; set; }
// 标志位:默认值 true
public bool flag { get; set; }
// 实验步骤列表
public Expstepvtwolist[] ExpStepVTwoList { get; set; }
}
public class Expstepvtwolist
{
// 实验步骤序号
public int seq { get; set; }
// 实验步骤名称
public string ExpStepName = "";
// 实验步骤状态
public string StepState = "";
// 实验步骤开始时间
public DateTime startTime = default;
// 实验步骤结束时间
public DateTime endTime = default;
// 实验步骤合理用时:单位秒
public int expectTime = 0;
// 实验步骤满分0 ~100百分制
public int maxScore = 100;
// 实验步骤得分0 ~100百分制
public int score = 0;
// 实验步骤操作次数
public int repeatCount = 1;
// 步骤评价200 字以内
public string evaluation = "";
// 赋分模型200 字以内
public string scoringModel = "";
// 备注
public string remarks { get; set; }
}
public class Response
{
public string msg;
public bool success;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c1b108973e2a6cd43bf6b1943d979a23
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5da36794a84f2e24aa0626b1466f6360
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4a5ff23952c587c48ab012049e07df51
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 23a14a5f29ce27c4dab61a5fe698a2e9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,17 @@
mergeInto(LibraryManager.library, {
GetURLParameter: function (name) {
const paramName = UTF8ToString(name);
const search = window.location.search.substring(1);
const params = new URLSearchParams(search);
const value = params.get(paramName);
console.log('GetURLParameter:', value);
if (value) {
var buffer = _malloc((value.length + 1) * 2);
stringToUTF8(value, buffer, (value.length + 1) * 2);
return buffer;
} else {
return 0;
}
}
});

View File

@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: af1b30451ed743d4f81b3f9c8c15baeb
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2435,7 +2435,52 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: add14a4156b366340bb4a76d1dad5cb1, type: 3}
m_Name:
m_EditorClassIdentifier:
targetParent: {fileID: 0}
--- !u!1 &1619907665
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1619907666}
- component: {fileID: 1619907667}
m_Layer: 0
m_Name: WebGL
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1619907666
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1619907665}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 960, y: 540, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1619907667
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1619907665}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c1b108973e2a6cd43bf6b1943d979a23, type: 3}
m_Name:
m_EditorClassIdentifier:
RSA: {fileID: 0}
uploadUrl:
--- !u!1 &1623041755
GameObject:
m_ObjectHideFlags: 0
@ -3506,3 +3551,4 @@ SceneRoots:
- {fileID: 2223146455129701296}
- {fileID: 2058174970}
- {fileID: 1116630619}
- {fileID: 1619907666}

View File

@ -10,15 +10,15 @@ using UnityEngine.UI;
*******************************************************************************/
namespace ZXK.LouDiXvMuNiu
{
public class ScoreDataPanel : UIBase
public class ScoreDataPanel : UIBase
{
private InputField _studentNameInF = null;
private InputField _studentNumberInF = null;
private Text _studentTotalTxt = null;
private Text _studentActualTxt = null;
private Text _studentActualTxt = null;
private Text _errorTipTxt = null;
private Transform _scoreItemContent = null;
private GameObject _scoreItemPrefab = null;
private GameObject _scoreItemPrefab = null;
private Button _closeBtn = null;
private string _nameTemp = null;
@ -29,10 +29,10 @@ namespace ZXK.LouDiXvMuNiu
_studentNameInF = GetWedage("NameTxt_N").GetComponent<InputField>();
_studentNumberInF = GetWedage("NumberTxt_N").GetComponent<InputField>();
_studentTotalTxt = GetWedage("TotalScoreText_N").GetComponent<Text>();
_studentActualTxt = GetWedage("ActualScoreTxt_N").GetComponent<Text>();
_studentActualTxt = GetWedage("ActualScoreTxt_N").GetComponent<Text>();
_errorTipTxt = GetWedage("ErroTipTxt_N").GetComponent<Text>();
_scoreItemContent = GetWedage("ScoreItemContent_N").transform;
_scoreItemPrefab = GetWedage("ScoreItemPrefab_N");
_scoreItemPrefab = GetWedage("ScoreItemPrefab_N");
_closeBtn = GetWedage("CloseBtn_N").GetComponent<Button>();
_closeBtn.onClick.AddListener(() =>
@ -101,6 +101,9 @@ namespace ZXK.LouDiXvMuNiu
{
float totalScore = 0.0f;//总得分
float actualScore = 0.0f;//实际得分
List<string> stepNames = new List<string>();
List<int> maxScore = new List<int>();
List<int> scores = new List<int>();
foreach (string[] item in scoreQueue)
{
//WDebug.Log(item[0] + "@@@" + item[1] + "$$$" + item[2] + "%%%" + item[3]);
@ -119,6 +122,10 @@ namespace ZXK.LouDiXvMuNiu
float _actualScore = float.Parse(item[3]);
actualScore += _actualScore;
totalScore += _totalScore;
stepNames.Add(item[0] + item[1]);
maxScore.Add((int)float.Parse(item[2]));
scores.Add((int)float.Parse(item[3]));
}
_studentNameInF.placeholder.GetComponent<Text>().text = "请输入姓名...";
@ -130,6 +137,10 @@ namespace ZXK.LouDiXvMuNiu
_studentNumberInF.text = GameManager.Instance._StudentNumber;
_studentTotalTxt.text = totalScore.ToString();
_studentActualTxt.text = actualScore.ToString();
#if !UNITY_EDITOR && UNITY_WEBGL
LYTWebGLHelper.Instance.UpLoadData((int)totalScore, stepNames, maxScore, scores);
#endif
}
/// <summary>
/// 检查填写信息是否正确

View File

@ -804,7 +804,7 @@ PlayerSettings:
webGLMemoryGeometricGrowthCap: 96
webGLPowerPreference: 2
scriptingDefineSymbols:
Standalone: VR
Standalone:
additionalCompilerArguments: {}
platformArchitecture: {}
scriptingBackend: {}
@ -922,4 +922,4 @@ PlayerSettings:
hmiLoadingImage: {fileID: 0}
platformRequiresReadableAssets: 0
virtualTexturingSupportEnabled: 0
insecureHttpOption: 0
insecureHttpOption: 2