|
@@ -15,6 +15,7 @@ using StackExchange.Redis;
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
using TEAMModelOS.Models;
|
|
using TEAMModelOS.Models;
|
|
using TEAMModelOS.SDK;
|
|
using TEAMModelOS.SDK;
|
|
|
|
+using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
|
|
|
namespace TEAMModelOS.SDK.Services
|
|
namespace TEAMModelOS.SDK.Services
|
|
{
|
|
{
|
|
@@ -618,29 +619,31 @@ namespace TEAMModelOS.SDK.Services
|
|
{
|
|
{
|
|
recs[index].ForEach(x =>
|
|
recs[index].ForEach(x =>
|
|
{
|
|
{
|
|
- if (survey.answers[index].Contains(x))
|
|
|
|
- {
|
|
|
|
- if (dict.ContainsKey(x))
|
|
|
|
- {
|
|
|
|
- dict[x] = dict[x] + 1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(x)) {
|
|
|
|
+ if (survey.answers[index].Contains(x))
|
|
{
|
|
{
|
|
- dict[x] = 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (dict.ContainsKey("other"))
|
|
|
|
- {
|
|
|
|
- dict["other"] = dict["other"] + 1;
|
|
|
|
|
|
+ if (dict.ContainsKey(x))
|
|
|
|
+ {
|
|
|
|
+ dict[x] = dict[x] + 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ dict[x] = 1;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- dict["other"] = 1;
|
|
|
|
|
|
+ if (dict.ContainsKey("other"))
|
|
|
|
+ {
|
|
|
|
+ dict["other"] = dict["other"] + 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ dict["other"] = 1;
|
|
|
|
+ }
|
|
|
|
+ //这里暂不处理, 结算再处理other
|
|
|
|
+ // tasks.Add(_azureStorage.UploadFileByContainer(survey.owner,new { other=x, userid, time =curr }.ToJsonString(), "survey", $"{survey.id}/other/{index}/{userid}.json", false));
|
|
}
|
|
}
|
|
- //这里暂不处理, 结算再处理other
|
|
|
|
- // tasks.Add(_azureStorage.UploadFileByContainer(survey.owner,new { other=x, userid, time =curr }.ToJsonString(), "survey", $"{survey.id}/other/{index}/{userid}.json", false));
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -748,13 +751,51 @@ namespace TEAMModelOS.SDK.Services
|
|
}
|
|
}
|
|
var records = await azureRedis.GetRedisClient(8).HashGetAllAsync($"Survey:Record:{survey.id}");
|
|
var records = await azureRedis.GetRedisClient(8).HashGetAllAsync($"Survey:Record:{survey.id}");
|
|
List<dynamic> recds = new List<dynamic>();
|
|
List<dynamic> recds = new List<dynamic>();
|
|
- foreach (var rcd in records)
|
|
|
|
- {
|
|
|
|
- var value = rcd.Value.ToString().ToObject<JsonElement>();
|
|
|
|
- recds.Add(new { index = rcd.Name.ToString(), ans = value });
|
|
|
|
|
|
+
|
|
|
|
+ List<srecord> srecords = new List<srecord>();
|
|
|
|
+ int len = survey.answers.Count;
|
|
|
|
+ for (int i = 0; i < len; i++) {
|
|
|
|
+ var anses= surveyRecords.Select(z => z.ans).ToList();
|
|
|
|
+ srecord srecord= new srecord() { index=$"{i}"};
|
|
|
|
+ Dictionary<string, int> dict = new Dictionary<string, int>();
|
|
|
|
+ srecord.ans = dict;
|
|
|
|
+ foreach (var asd in anses) {
|
|
|
|
+ asd[i].ForEach(z => {
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(z)) {
|
|
|
|
+ if (survey.answers[i].Contains(z))
|
|
|
|
+ {
|
|
|
|
+ if (dict.ContainsKey(z))
|
|
|
|
+ {
|
|
|
|
+ dict[z] = dict[z] + 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ dict.Add(z, 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (dict.ContainsKey("other"))
|
|
|
|
+ {
|
|
|
|
+ dict["other"] = dict["other"] + 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ dict.Add("other", 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ srecords.Add(srecord);
|
|
}
|
|
}
|
|
|
|
+ //foreach (var rcd in records)
|
|
|
|
+ //{
|
|
|
|
+ // var value = rcd.Value.ToString().ToObject<JsonElement>();
|
|
|
|
+ // recds.Add(new { index = rcd.Name.ToString(), ans = value });
|
|
|
|
+ //}
|
|
await Task.WhenAll(tasks);
|
|
await Task.WhenAll(tasks);
|
|
- var cods = new { records = recds, userids, question = questionRecords, urecord = surveyRecords };
|
|
|
|
|
|
+ var cods = new { records = srecords, userids, question = questionRecords, urecord = surveyRecords };
|
|
//问卷整体情况
|
|
//问卷整体情况
|
|
await _azureStorage.GetBlobContainerClient(blobcntr).UploadFileByContainer(cods.ToJsonString(), "survey", $"{survey.id}/record.json");
|
|
await _azureStorage.GetBlobContainerClient(blobcntr).UploadFileByContainer(cods.ToJsonString(), "survey", $"{survey.id}/record.json");
|
|
///end 20210805 huanghb 实时结算
|
|
///end 20210805 huanghb 实时结算
|
|
@@ -843,5 +884,11 @@ namespace TEAMModelOS.SDK.Services
|
|
public Dictionary<string, int> srecord { get; set; } = new Dictionary<string, int>();
|
|
public Dictionary<string, int> srecord { get; set; } = new Dictionary<string, int>();
|
|
public Dictionary<string, string[]> urecord { get; set; } = new Dictionary<string, string[]>();
|
|
public Dictionary<string, string[]> urecord { get; set; } = new Dictionary<string, string[]>();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public class srecord
|
|
|
|
+ {
|
|
|
|
+ public string index { get; set;}
|
|
|
|
+ public Dictionary<string, int> ans { get; set; } = new Dictionary<string, int>();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|