fix: 原卷生成

This commit is contained in:
lyndonliu 2024-03-25 17:46:44 +08:00
parent 0043320cd4
commit 1c7a87122f
4 changed files with 44 additions and 10 deletions

View File

@ -83,10 +83,10 @@ public class ExamManager : DomainService, IExamManager
}).ToListAsync(); }).ToListAsync();
var DbBiz = await GetTenantDb(eto.SchoolId); var DbBiz = await GetTenantDb(eto.SchoolId);
await DbBiz.Updateable<ExamSubjectSchoolStudent>().SetColumns(s => s.CollectStatus == 2).Where(w => w.ExamSubjectSchoolId == eto.ExamSubjectSchoolId && w.StudentExamNum == penSerial).ExecuteCommandAsync();
if (lattices.Count == 0) if (lattices.Count == 0)
{ {
await DbBiz.Updateable<ExamSubjectSchoolStudent>().SetColumns(s => s.CollectStatus == 2).Where(w => w.ExamSubjectSchoolId == eto.ExamSubjectSchoolId && w.StudentExamNum == penSerial).ExecuteCommandAsync();
Logger.LogInformation("{ExamSubjectId} {penSerial} 无点阵数据", eto.ExamSubjectId, penSerial); Logger.LogInformation("{ExamSubjectId} {penSerial} 无点阵数据", eto.ExamSubjectId, penSerial);
return; return;
} }
@ -228,12 +228,44 @@ public class ExamManager : DomainService, IExamManager
IsExcess = s.IsExcess, IsExcess = s.IsExcess,
}).ToList(); }).ToList();
var paperAnswers = new List<string>();
var kgt = new List<Tuple<string, string>>(); var kgt = new List<Tuple<string, string>>();
var zgt = new List<Tuple<string, string, bool>>(); // 纸张Id, 题号, 是否跨页 var zgt = new List<Tuple<string, string, bool>>(); // 纸张Id, 题号, 是否跨页
var pageSerials = new List<string>(); // 需要计算的页 var pageSerials = new List<string>(); // 需要计算的页
foreach (var paper in paperInfo) foreach (var paper in paperInfo)
{ {
var paperLatts = lattices.Where(w => w.PageSerial == paper.PaperId).ToList(); var paperLatts = lattices.Where(w => w.PageSerial == paper.PaperId).ToList();
// 原卷生成
var imgBytes = await paper.ImgUrl.GetBytesAsync();
var bitmap = SKBitmap.Decode(imgBytes);
var pxLatts = paperLatts.Select(s => new SubjectiveLatt()
{
Stroke = s.strokeIndex,
X = s.CX.AUToPX(),
Y = s.CY.AUToPX(),
Time = s.Time,
}).ToList();
using (var canvas = new SKCanvas(bitmap))
{
// 一笔一笔的画上去
var strokeIndexs = pxLatts.GroupBy(g => g.Stroke).Select(s => s.Key).ToList();
foreach (var stroke in strokeIndexs)
{
var points = pxLatts.Where(w => w.Stroke == stroke).OrderBy(s => s.Time).Select(s => new SKPoint(s.X, s.Y)).ToArray();
var skPointMode = SKPointMode.Polygon;
if (points.Length == 1)
skPointMode = SKPointMode.Points;
else if (points.Length == 2)
skPointMode = SKPointMode.Lines;
canvas.DrawPoints(skPointMode, points, skPaint);
}
var paperAnswer = $"origin-paper/{eto.ExamSubjectId}/{penSerial}/{paper.PageIndex}.jpg";
await _blobContainer.SaveAsync(paperAnswer, bitmap.Encode(SKEncodedImageFormat.Jpeg, 100).ToArray(), true);
paperAnswers.Add($"\"{_aliyunOption.Host}/{paperAnswer}\"");
}
foreach (var que in paper.QueData) foreach (var que in paper.QueData)
{ {
if (que.type == "1") // 客观题 if (que.type == "1") // 客观题
@ -268,10 +300,6 @@ public class ExamManager : DomainService, IExamManager
} }
} }
foreach (var _kgtDtl in kgtDtls)
{
_kgtDtl.Id = YitIdHelper.NextId();
}
var kgtPapers = kgt.GroupBy(s => s.Item1).Select(s => s.Key).ToList(); // 客观题处理 var kgtPapers = kgt.GroupBy(s => s.Item1).Select(s => s.Key).ToList(); // 客观题处理
foreach (var paperId in kgtPapers) foreach (var paperId in kgtPapers)
{ {
@ -394,6 +422,9 @@ public class ExamManager : DomainService, IExamManager
await DbBiz.Insertable(kgtDtls).ExecuteCommandAsync(); await DbBiz.Insertable(kgtDtls).ExecuteCommandAsync();
await DbBiz.Insertable(zgtDtls).ExecuteCommandAsync(); await DbBiz.Insertable(zgtDtls).ExecuteCommandAsync();
var paperAnswersStr = $"[{string.Join(",", paperAnswers)}]";
await DbBiz.Updateable<ExamSubjectSchoolStudent>().SetColumns(s => new ExamSubjectSchoolStudent { CollectStatus = 2, DotPenOriginalImg = paperAnswersStr }).Where(w => w.ExamSubjectSchoolId == eto.ExamSubjectSchoolId && w.StudentExamNum == penSerial).ExecuteCommandAsync();
await DbBiz.CommitTranAsync(); await DbBiz.CommitTranAsync();
Logger.LogInformation("{ExamSubjectId} {penSerial} 收集成功", eto.ExamSubjectId, penSerial); Logger.LogInformation("{ExamSubjectId} {penSerial} 收集成功", eto.ExamSubjectId, penSerial);
} }

View File

@ -9,4 +9,5 @@ public class ExamSubjectSchoolStudent
public long ExamSubjectSchoolId { get; set; } public long ExamSubjectSchoolId { get; set; }
public string StudentExamNum { get; set; } public string StudentExamNum { get; set; }
public int CollectStatus { get; set; } public int CollectStatus { get; set; }
public string DotPenOriginalImg { get; set; }
} }

View File

@ -1,17 +1,14 @@
using Dolphin.ExamPictureCut.Constants; using Dolphin.ExamPictureCut.Constants;
using Dolphin.ExamPictureCut.Domains; using Dolphin.ExamPictureCut.Domains;
using Dolphin.ExamPictureCut.Extensions; using Dolphin.ExamPictureCut.Extensions;
using Dolphin.ExamPictureCut.Options;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using NoFurion.SqlSugar; using NoFurion.SqlSugar;
using SqlSugar; using SqlSugar;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Reflection;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.AspNetCore.Authentication.JwtBearer; using Volo.Abp.AspNetCore.Authentication.JwtBearer;
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
@ -98,6 +95,11 @@ public class DolphinExamPictureCutHttpApiHostModule : AbpModule
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "Dolphin"; options.Audience = "Dolphin";
}); });
Configure<AbpAntiForgeryOptions>(options =>
{
options.AutoValidate = false;
});
} }
private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)

View File

@ -4,7 +4,7 @@
}, },
"ConnectionStrings": { "ConnectionStrings": {
"marking_basic": "Server=192.168.2.9;Port=3306;Database=marking_basic;Uid=root;Pwd=qwe123!@#;AllowLoadLocalInfile=true;", "marking_basic": "Server=192.168.2.9;Port=3306;Database=marking_basic;Uid=root;Pwd=qwe123!@#;AllowLoadLocalInfile=true;",
"penoffline": "host=192.168.2.7;port=8812;username=zhjs;password=zhjsniubi;database=qdb;ServerCompatibilityMode=NoTypeLoading;" "penoffline": "host=47.108.209.28;port=8812;username=zhjs;password=zhjsniubi;database=qdb;ServerCompatibilityMode=NoTypeLoading;"
}, },
"Redis": { "Redis": {
"Configuration": "192.168.2.7:6379,password=qwe123!@#,defaultDatabase=14,idleTimeout=3000,poolsize=5,prefix=marking" "Configuration": "192.168.2.7:6379,password=qwe123!@#,defaultDatabase=14,idleTimeout=3000,poolsize=5,prefix=marking"