fix:一人一档导出

This commit is contained in:
geh
2025-04-14 19:47:49 +08:00
parent 24390f1ea0
commit 4d7e4d1806
13 changed files with 1483 additions and 299 deletions
@@ -897,5 +897,74 @@ namespace BLL
} }
} }
#endregion #endregion
public static List<Model.TestRecordItem> getTrainingTestRecordListByDepartId( string unitId, string departId, string strPass, string strParam)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
var getDataLists = (from x in db.Training_TestRecord
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
join z in db.Sys_User on x.TestManId equals z.UserId
where x.ProjectId == null && x.TestStartTime.HasValue && x.TestEndTime.HasValue
orderby x.TestStartTime descending
select new Model.TestRecordItem
{
TestRecordId = x.TestRecordId,
ProjectId = x.ProjectId,
TestPlanId = x.TestPlanId,
TestPlanName = y.PlanName,
UnitId = z.UnitId,
UnitName = getUnitName(z.UnitId),
WorkPostId = z.WorkPostId,
WorkPostName = db.Base_WorkPost.FirstOrDefault(p => p.WorkPostId == z.WorkPostId).WorkPostName,
DepartId = z.DepartId,
TestManId = x.TestManId,
TestManName = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == x.TestManId).PersonName,
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
Duration = x.Duration,
TestPlanEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime.Value.AddMinutes(x.Duration)),
TotalScore = y.TotalScore ?? 0,
TestScores = x.TestScores ?? 0,
TestType = x.TestType,
TemporaryUser = x.TemporaryUser,
});
if (!string.IsNullOrEmpty(unitId))
{
getDataLists = getDataLists.Where(x => x.UnitId == unitId);
}
if (!string.IsNullOrEmpty(departId))
{
getDataLists = getDataLists.Where(x => x.DepartId == departId);
}
if (!string.IsNullOrEmpty(strParam))
{
getDataLists = getDataLists.Where(x => x.TestManName.Contains(strParam));
}
if (!string.IsNullOrEmpty(strPass))
{
int PassingScore = SysConstSetService.getPassScoreForApi();
if (strPass == "0")
{
getDataLists = getDataLists.Where(x => x.TestScores < PassingScore);
}
else
{
getDataLists = getDataLists.Where(x => x.TestScores >= PassingScore);
}
}
foreach(var item in getDataLists)
{
var depart = db.Base_Depart.FirstOrDefault(x => x.DepartId == item.DepartId);
if (depart != null)
{
item.DepartName = depart.DepartName;
}
}
return getDataLists.ToList();
}
}
} }
} }
+34 -2
View File
@@ -67,8 +67,11 @@
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL"> <Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath> <HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath> <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.9.0.0\lib\netstandard2.0\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.QualityTools.Testing.Fakes.16.11.230815\lib\net35\Microsoft.QualityTools.Testing.Fakes.dll</HintPath> <HintPath>..\packages\Microsoft.QualityTools.Testing.Fakes.16.11.230815\lib\net35\Microsoft.QualityTools.Testing.Fakes.dll</HintPath>
@@ -78,6 +81,7 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ManagedDTS\v4.0_16.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ManagedDTS.dll</HintPath> <HintPath>C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ManagedDTS\v4.0_16.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ManagedDTS.dll</HintPath>
</Reference> </Reference>
<Reference Include="mscorlib" />
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
@@ -97,12 +101,18 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\FineUIPro\Reference BLL\NPOI.OpenXmlFormats.dll</HintPath> <HintPath>..\FineUIPro\Reference BLL\NPOI.OpenXmlFormats.dll</HintPath>
</Reference> </Reference>
<Reference Include="Pipelines.Sockets.Unofficial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42ea0a778e13fbe2, processorArchitecture=MSIL">
<HintPath>..\packages\Pipelines.Sockets.Unofficial.2.2.8\lib\net461\Pipelines.Sockets.Unofficial.dll</HintPath>
</Reference>
<Reference Include="Quartz, Version=3.7.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL"> <Reference Include="Quartz, Version=3.7.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<HintPath>..\packages\Quartz.3.7.0\lib\netstandard2.0\Quartz.dll</HintPath> <HintPath>..\packages\Quartz.3.7.0\lib\netstandard2.0\Quartz.dll</HintPath>
</Reference> </Reference>
<Reference Include="RestSharp, Version=106.15.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL"> <Reference Include="RestSharp, Version=106.15.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll</HintPath> <HintPath>..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="StackExchange.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
<HintPath>..\packages\StackExchange.Redis.2.7.33\lib\net461\StackExchange.Redis.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath> <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
@@ -119,6 +129,12 @@
</Reference> </Reference>
<Reference Include="System.DirectoryServices" /> <Reference Include="System.DirectoryServices" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
</Reference>
<Reference Include="System.IO.Pipelines, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Pipelines.5.0.1\lib\net461\System.IO.Pipelines.dll</HintPath>
</Reference>
<Reference Include="System.Management" /> <Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath> <HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
@@ -129,6 +145,9 @@
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" /> <Reference Include="System.Security" />
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -142,6 +161,9 @@
</Reference> </Reference>
<Reference Include="System.ServiceModel" /> <Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceProcess" /> <Reference Include="System.ServiceProcess" />
<Reference Include="System.Threading.Channels, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Channels.5.0.0\lib\net461\System.Threading.Channels.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" /> <Reference Include="System.Transactions" />
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath> <HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
@@ -263,6 +285,9 @@
<Compile Include="Common\NPOIHelper.cs" /> <Compile Include="Common\NPOIHelper.cs" />
<Compile Include="Common\PrinterDocService.cs" /> <Compile Include="Common\PrinterDocService.cs" />
<Compile Include="Common\ProjectDataFlowSetService.cs" /> <Compile Include="Common\ProjectDataFlowSetService.cs" />
<Compile Include="Common\Redis\ICache.cs" />
<Compile Include="Common\Redis\Redis.cs" />
<Compile Include="Common\Redis\RedisHelper.cs" />
<Compile Include="Common\UploadFileService.cs" /> <Compile Include="Common\UploadFileService.cs" />
<Compile Include="Common\UpLoadImageService.cs" /> <Compile Include="Common\UpLoadImageService.cs" />
<Compile Include="Common\UserShowColumnsService.cs" /> <Compile Include="Common\UserShowColumnsService.cs" />
@@ -1504,6 +1529,13 @@
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.QualityTools.Testing.Fakes.16.11.230815\build\Microsoft.Qualitytools.Testing.Fakes.targets" Condition="Exists('..\packages\Microsoft.QualityTools.Testing.Fakes.16.11.230815\build\Microsoft.Qualitytools.Testing.Fakes.targets')" /> <Import Project="..\packages\Microsoft.QualityTools.Testing.Fakes.16.11.230815\build\Microsoft.Qualitytools.Testing.Fakes.targets" Condition="Exists('..\packages\Microsoft.QualityTools.Testing.Fakes.16.11.230815\build\Microsoft.Qualitytools.Testing.Fakes.targets')" />
<Import Project="..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets" Condition="Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
+37 -1
View File
@@ -8,6 +8,8 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Text; using System.Text;
using Aspose.Words.Drawing;
using Shape = Aspose.Words.Drawing.Shape;
namespace BLL namespace BLL
{ {
@@ -29,6 +31,40 @@ namespace BLL
{ {
wordDoc = new Document(path); wordDoc = new Document(path);
} }
/// <summary>
/// 添加图片
/// </summary>
/// <param name="filename">文件路径+文件名</param>
/// <param name="field">文本域名</param>
/// <param name="width">宽</param>
/// <param name="height">高</param>
public void AddImage(string filename, string field, double width, double height, double left, double top)
{
DocumentBuilder builder = new DocumentBuilder(wordDoc);
Shape shape = new Shape(wordDoc, ShapeType.Image);
if (!string.IsNullOrEmpty(filename))
{
shape.ImageData.SetImage(filename);
shape.Width = width;//设置宽和高
shape.Height = height;
shape.Left = left;
shape.Top = top;
shape.WrapType = WrapType.None;
shape.BehindText = true;
builder.MoveToMergeField(field);
builder.InsertNode(shape);
}
else
{
//没有图片用空替换占位域值
builder.MoveToMergeField(field);
builder.Write("");
}
}
/// <summary> /// <summary>
/// 书签赋值用法 /// 书签赋值用法
@@ -269,7 +305,7 @@ namespace BLL
/// </summary> /// </summary>
/// <param name="Html">html代码</param> /// <param name="Html">html代码</param>
/// <param name="path">保存路径</param> /// <param name="path">保存路径</param>
public static void HtmlIntoWord(string Html,string path) public void HtmlIntoWord(string Html,string path)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@@ -1304,5 +1304,29 @@ namespace BLL
return personId; return personId;
} }
public static string GetPersonIdByUserIdForApi(string userId)
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
string personId = userId;
var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == userId);
if (getPerson == null)
{
var getUser = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
if (getUser != null)
{
getPerson = db.SitePerson_Person.FirstOrDefault(e => e.IdentityCard == getUser.IdentityCard);
if (getPerson != null)
{
personId = getPerson.PersonId;
}
}
}
return personId;
}
}
} }
} }
@@ -394,5 +394,19 @@
} }
} }
#endregion #endregion
public static int getPassScoreForApi()
{
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
{
int passScore = 80;
var testRule = db.Sys_TestRule.FirstOrDefault();
if (testRule != null)
{
passScore = testRule.PassingScore;
}
return passScore;
}
}
} }
} }
@@ -149,6 +149,9 @@
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath> <HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Net" /> <Reference Include="System.Net" />
<Reference Include="System.Net.Http">
<HintPath>..\BLL\bin\Debug\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" /> <Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
@@ -194,6 +194,9 @@
<f:MenuButton ID="btnMenuEdit" OnClick="btnMenuEdit_Click" EnablePostBack="true" <f:MenuButton ID="btnMenuEdit" OnClick="btnMenuEdit_Click" EnablePostBack="true"
Hidden="true" runat="server" Text="修改" Icon="Pencil"> Hidden="true" runat="server" Text="修改" Icon="Pencil">
</f:MenuButton> </f:MenuButton>
<f:MenuButton ID="btnPrinter" EnablePostBack="true" runat="server"
Text="导出" Icon="Printer" OnClick="butExport_Click" EnableAjax="false" DisableControlBeforePostBack="false">
</f:MenuButton>
<f:MenuButton ID="btnMenuDelete" OnClick="btnMenuDelete_Click" EnablePostBack="true" <f:MenuButton ID="btnMenuDelete" OnClick="btnMenuDelete_Click" EnablePostBack="true"
Hidden="true" ConfirmText="删除选中行?" ConfirmTarget="Parent" runat="server" Icon="Delete" Text="删除"> Hidden="true" ConfirmText="删除选中行?" ConfirmTarget="Parent" runat="server" Icon="Delete" Text="删除">
</f:MenuButton> </f:MenuButton>
@@ -7,6 +7,10 @@ using System.Data.SqlClient;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using AspNet = System.Web.UI.WebControls; using AspNet = System.Web.UI.WebControls;
using Aspose.Words;
using System.IO;
using System.Threading;
using Model;
namespace FineUIPro.Web.HSSE.SitePerson namespace FineUIPro.Web.HSSE.SitePerson
{ {
@@ -763,5 +767,519 @@ namespace FineUIPro.Web.HSSE.SitePerson
} }
return age; return age;
} }
protected void butExport_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
var person = Funs.DB.View_SitePerson_Person.FirstOrDefault(x => x.PersonId == Grid1.SelectedRowID);
if (person != null)
{
string rootPath = Server.MapPath("~/");
string initTemplatePath = string.Empty;
string uploadfilepath = string.Empty;
string newUrl = string.Empty;
if (person.WorkPostName == "电工")
{
initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(电工).doc";
}
// else if (person.WorkPostName == "电焊工")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(电焊工).doc";
// }
// else if (person.WorkPostName == "防水普工")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(防水普工).doc";
// }
// else if (person.WorkPostName == "钢筋工")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(钢筋工).doc";
// }
// else if (person.WorkPostName == "管理人员")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(管理人员).doc";
// }
// else if (person.WorkPostName == "架子工")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(架子工).doc";
// }
// else if (person.WorkPostName == "木工")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(木工).doc";
// }
// else if (person.WorkPostName == "普工")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(普工).doc";
// }
// else if (person.WorkPostName == "施工电梯司机")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(施工电梯司机).doc";
// }
// else if (person.WorkPostName == "水电工")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(水电工).doc";
// }
// else if (person.WorkPostName == "司索信号工")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(司索信号工).doc";
// }
// else if (person.WorkPostName == "塔吊司机")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(塔吊司机).doc";
// }
// else if (person.WorkPostName == "挖机司机")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(挖机司机).doc";
// }
// else if (person.WorkPostName == "瓦工")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(瓦工).doc";
// }
// else if (person.WorkPostName == "渣土车司机")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(渣土车司机).doc";
// }
// else if (person.WorkPostName == "桩基")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(桩基).doc";
// }
// else if (person.WorkPostName == "装配、灌浆工")
// {
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(装配、灌浆工).doc";
// }
else
{
Alert.ShowInTop("当前岗位类型不可导出!", MessageBoxIcon.Warning);
return;
}
uploadfilepath = rootPath + initTemplatePath;
newUrl = uploadfilepath.Replace(".doc", person.PersonName + ".doc");
if (File.Exists(newUrl))
{
File.Delete(newUrl);
}
File.Copy(uploadfilepath, newUrl);
AsposeWordHelper helper = new AsposeWordHelper();
helper.OpenTempelte(newUrl); //打开模板文件
string projectName = Funs.DB.Base_Project.First(z => z.ProjectId == person.ProjectId).ProjectName;
string name = person.PersonName;
string time = DateTime.Now.ToString("yyyy-MM-dd");
string sex = string.IsNullOrEmpty(person.Sex) ? "" : person.Sex == "1" ? "男" : "女";
string InTime = person.InTime.HasValue ? string.Format("{0:yyyy-MM-dd}", person.InTime) : "";
string IdCardFront = AttachFileService.getFileUrl(person.PersonId + "#1");
string IdCardBack = AttachFileService.getFileUrl(person.PersonId + "#5");
if (!string.IsNullOrEmpty(IdCardFront))
{
helper.AddImage(rootPath + IdCardFront, "IdCardFront", 100, 100, 10, 20);
}
else
{
helper.AddImage(string.Empty, "IdCardFront", 100, 100, 10, 20);
}
if (!string.IsNullOrEmpty(IdCardBack))
{
helper.AddImage(rootPath + IdCardBack, "IdCardBack", 100, 100, 120, 20);
}
else
{
helper.AddImage(string.Empty, "IdCardBack", 100, 100, 10, 20);
}
var gTrainingTestRecord =
(from x in Funs.DB.Training_TestRecord
join TestPlan in Funs.DB.Training_TestPlan on x.TestPlanId equals TestPlan.TestPlanId into
gTestPlan
from TestPlan in gTestPlan.DefaultIfEmpty()
join user in Funs.DB.Sys_User on TestPlan.PlanManId equals user.UserId into gUser
from user in gUser.DefaultIfEmpty()
where x.TestManId == person.PersonId
// where x.TestManId == "d9f795a2-b8eb-4872-9e4c-4a3dba028b5c"
orderby x.TestEndTime descending
select new
{
TestRecordId = x.TestRecordId,
TestStartTime = x.TestStartTime,
TestEndTime = x.TestEndTime,
Signature = x.Signature,
TestScores = x.TestScores,
PlanManName = user == null ? "" : user.UserName
}).FirstOrDefault();
string date1 = "";
string sign = "";
string sign1 = "";
string TestRecordId = "";
decimal? TestScores = null;
DateTime? TestStartTime = null;
DateTime? dateTime1 = null;
string Signature = "";
string unitName = "";
string workPostName = "";
string testName = "";
string IdCard = "";
int SValue = 0;
int SValueCount = 0;
int MValue = 0;
int MValueCount = 0;
int JValue = 0;
int JValueCount = 0;
Sys_TestRule sysTestRule = null;
IQueryable<Training_TestRecordItem> getTestItems = null;
List<Training_TestRecordItem> getSingleItem = new List<Training_TestRecordItem>();
List<Training_TestRecordItem> getMultipleItem = new List<Training_TestRecordItem>();
List<Training_TestRecordItem> getIsTrueItem = new List<Training_TestRecordItem>();
if (gTrainingTestRecord != null)
{
testName = person.PersonName;
IdCard = person.IdentityCard;
Signature = gTrainingTestRecord.Signature;
TestScores = gTrainingTestRecord.TestScores;
TestStartTime = gTrainingTestRecord.TestStartTime;
TestRecordId = gTrainingTestRecord.TestRecordId;
sign = gTrainingTestRecord.PlanManName;
sign1 = AttachFileService.getFileUrl(person.PersonId + "_1");
dateTime1 = gTrainingTestRecord.TestStartTime.Value;
unitName = BLL.UnitService.GetUnitNameByUnitId(person.UnitId);
workPostName = WorkPostService.getWorkPostNamesWorkPostIds(person.WorkPostId);
sysTestRule = Funs.DB.Sys_TestRule.FirstOrDefault();
getTestItems = from x in Funs.DB.Training_TestRecordItem
where x.TestRecordId == TestRecordId
select x;
getSingleItem = getTestItems.Where(x => x.TestType == "1").ToList();
SValue = sysTestRule.SValue; //每题分数
SValueCount = sysTestRule.SValue * getSingleItem.Count; //总分
getMultipleItem = getTestItems.Where(x => x.TestType == "2").ToList();
MValue = sysTestRule.MValue; //每题分数
MValueCount = sysTestRule.MValue * getMultipleItem.Count; //总分
getIsTrueItem = getTestItems.Where(x => x.TestType == "3").ToList();
JValue = sysTestRule.JValue; //每题分数
JValueCount = sysTestRule.JValue * getIsTrueItem.Count; //总分
}
if (!string.IsNullOrEmpty(sign1))
{
helper.AddImage(rootPath + sign1, "sign1", 50, 25, 15, 30);
helper.AddImage(rootPath + sign1, "sign1_1", 50, 25, 15, 30);
helper.AddImage(rootPath + sign1, "sign1_2", 50, 25, 15, 30);
}
else
{
helper.AddImage(string.Empty, "sign1", 0, 0, 0, 0);
helper.AddImage(string.Empty, "sign1_1", 0, 0, 0, 0);
helper.AddImage(string.Empty, "sign1_2", 0, 0, 0, 0);
}
// 构建格式化的字符串
date1 = dateTime1.HasValue
? $" {dateTime1.Value.Year} 年 {dateTime1.Value.Month:D2} 月 {dateTime1.Value.Day:D2} 日"
: "";
string sign2 = AttachFileService.getFileUrl(person.PersonId + "_2");
if (!string.IsNullOrEmpty(sign2))
{
helper.AddImage(rootPath + sign2, "sign2", 50, 25, 130, 0);
}
else
{
helper.AddImage(string.Empty, "sign2", 0, 0, 0, 0);
}
DateTime dateTime2 = new DateTime(2024, 6, 25);
// 构建格式化的字符串
string date2 = $" {dateTime2.Year} 年 {dateTime2.Month:D2} 月 {dateTime2.Day:D2} 日";
string IdentityCard = person.IdentityCard;
string Telephone = person.Telephone;
// 假设我们有一个DateTime对象
DateTime dateTime = new DateTime(2024, 6, 25);
// 提取年、月、日
int year = dateTime.Year;
int month = dateTime.Month;
int day = dateTime.Day;
string sign3 = AttachFileService.getFileUrl(person.PersonId + "_3");
if (!string.IsNullOrEmpty(sign3))
{
helper.AddImage(rootPath + sign3, "sign3", 50, 25, 350, 5);
}
else
{
helper.AddImage(string.Empty, "sign3", 0, 0, 0, 0);
}
string sign4 = AttachFileService.getFileUrl(person.PersonId + "_4");
if (!string.IsNullOrEmpty(sign4))
{
helper.AddImage(rootPath + sign4, "sign4", 50, 25, 100, 5);
}
else
{
helper.AddImage(string.Empty, "sign4", 0, 0, 0, 0);
}
string sign5 = AttachFileService.getFileUrl(person.PersonId + "_5");
if (!string.IsNullOrEmpty(sign5))
{
helper.AddImage(rootPath + sign5, "sign5", 50, 25, 320, 5);
}
else
{
helper.AddImage(string.Empty, "sign5", 0, 0, 0, 0);
}
#region
#region
DataTable tableS = new DataTable("TableS");
tableS.Columns.Add("SProblem");
tableS.Columns.Add("SOption");
if (getSingleItem.Count > 0)
{
int num = 1;
foreach (var item in getSingleItem)
{
string Avstracts = item.Abstracts.Replace(" ", "").Replace(" ", "").Replace("", "(")
.Replace("", ")").Replace("()", "(" + item.SelectedItem + ")");
string SProblem = num + "、" + Avstracts + " 正确答案:" + item.AnswerItems;
string str = string.Empty;
if (!string.IsNullOrEmpty(item.AItem))
{
str += "A." + item.AItem;
}
if (!string.IsNullOrEmpty(item.BItem))
{
str += " B." + item.BItem;
}
if (!string.IsNullOrEmpty(item.CItem))
{
str += " C." + item.CItem;
}
if (!string.IsNullOrEmpty(item.DItem))
{
str += " D." + item.DItem;
}
if (!string.IsNullOrEmpty(item.EItem))
{
str += " E." + item.EItem;
}
string SOption = str;
tableS.Rows.Add(new object[] { SProblem, SOption });
num++;
}
}
else
{
tableS.Rows.Add(new object[] { "", "" });
}
#endregion
#region
DataTable tableM = new DataTable("TableM");
tableM.Columns.Add("MProblem");
tableM.Columns.Add("MOption");
if (getMultipleItem.Count > 0)
{
int num = 1;
foreach (var item in getMultipleItem)
{
string Avstracts = item.Abstracts.Replace(" ", "").Replace(" ", "").Replace("", "(")
.Replace("", ")").Replace("()", "(" + item.SelectedItem + ")");
string MProblem = num + "、" + Avstracts + " 正确答案:" + item.AnswerItems;
string str = string.Empty;
if (!string.IsNullOrEmpty(item.AItem))
{
str += "A." + item.AItem;
}
if (!string.IsNullOrEmpty(item.BItem))
{
str += " B." + item.BItem;
}
if (!string.IsNullOrEmpty(item.CItem))
{
str += " ;C." + item.CItem;
}
if (!string.IsNullOrEmpty(item.DItem))
{
str += " ;D." + item.DItem;
}
if (!string.IsNullOrEmpty(item.EItem))
{
str += " ;E." + item.EItem;
}
string MOption = str;
tableM.Rows.Add(new object[] { MProblem, MOption });
num++;
}
}
else
{
tableM.Rows.Add(new object[] { "", "" });
}
#endregion
#region
DataTable tableJ = new DataTable("TableJ");
tableJ.Columns.Add("data");
if (getIsTrueItem.Count > 0)
{
int num = 1;
foreach (var item in getIsTrueItem)
{
var Avstracts = item.Abstracts;
if (Avstracts.IndexOf("(") > -1)
{
Avstracts = Avstracts.Replace("(", "" + item.SelectedItem == "A" ? "(√" : "(×");
}
else
{
if (Avstracts.IndexOf("") > -1)
Avstracts = Avstracts.Replace("", "" + item.SelectedItem == "A" ? "(√" : "(×");
}
string data = num + "、" + Avstracts + " 正确答案:" + (item.AnswerItems == "A" ? "√" : "×");
tableJ.Rows.Add(new object[] { data });
num++;
}
}
else
{
tableJ.Rows.Add(new object[] { "" });
}
#endregion
helper.WriteTable(tableS); //集合赋值遍历
helper.WriteTable(tableM); //集合赋值遍历
helper.WriteTable(tableJ); //集合赋值遍历
//考试抓拍照片
var attachFile = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == TestRecordId);
if (attachFile != null && !string.IsNullOrEmpty(attachFile.AttachUrl))
{
List<string> listUrl = Funs.GetStrListByStr(attachFile.AttachUrl, ',');
int count = listUrl.Count();
if (count > 0)
{
helper.AddImage(rootPath + listUrl[0], "imgStr1", 70, 70, 10, 10);
if (count >= 2)
{
int cout2 = count / 2;
helper.AddImage(rootPath + listUrl[cout2], "imgStr2", 70, 70, 10, 10);
}
else
{
helper.AddImage(string.Empty, "imgStr2", 0, 0, 0, 0);
}
helper.AddImage(rootPath + listUrl[count - 1], "imgStr3", 70, 70, 10, 10);
}
}
else
{
helper.AddImage(string.Empty, "imgStr1", 0, 0, 0, 0);
helper.AddImage(string.Empty, "imgStr2", 0, 0, 0, 0);
helper.AddImage(string.Empty, "imgStr3", 0, 0, 0, 0);
}
#endregion
string[] fieldNames = { };
object[] fieldValues = { };
if (!string.IsNullOrEmpty(Signature))
{
helper.AddImage(rootPath + Signature, "testName", 50, 25, 10, 5);
fieldNames = new[]
{
"projectName", "name", "time", "sex", "InTime", "sign",
"date1", "date2", "IdentityCard", "Telephone", "year", "month", "day",
"unitName", "workPostName", "TestStartTime","IdCard", "TestScores", "SValue", "SValueCount", "MValue",
"MValueCount", "JValue", "JValueCount"
};
fieldValues = new object[]
{
projectName, name, time, sex, InTime, sign, date1, date2,
IdentityCard, Telephone, year, month, day,
unitName, workPostName, TestStartTime,IdCard, TestScores, SValue, SValueCount, MValue, MValueCount,
JValue, JValueCount
};
}
else
{
fieldNames = new[]
{
"projectName", "name", "time", "sex", "InTime", "sign",
"date1", "date2", "IdentityCard", "Telephone", "year", "month", "day",
"unitName", "workPostName", "TestStartTime", "testName", "IdCard", "TestScores", "SValue", "SValueCount",
"MValue", "MValueCount", "JValue", "JValueCount"
};
fieldValues = new object[]
{
projectName, name, time, sex, InTime, sign, date1, date2,
IdentityCard, Telephone, year, month, day,
unitName, workPostName, TestStartTime, testName, IdCard, TestScores, SValue, SValueCount,
MValue, MValueCount, JValue, JValueCount
};
}
helper.Executefield(fieldNames, fieldValues); //域赋值
helper.SaveDoc(newUrl); //文件保存,保存为doc
// 验证文件是否存在
if (!File.Exists(newUrl))
{
throw new Exception("文件不存在: " + newUrl);
}
string fileName = Path.GetFileName(newUrl);
FileInfo info = new FileInfo(newUrl);
long fileSize = info.Length;
Response.Clear();
Response.ContentType = "application/x-zip-compressed";
Response.AddHeader("Content-Disposition",
"attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length", fileSize.ToString());
Response.TransmitFile(newUrl, 0, fileSize);
Response.Flush();
Response.Close();
File.Delete(newUrl);
}
}
} }
} }
@@ -374,6 +374,15 @@ namespace FineUIPro.Web.HSSE.SitePerson
/// </remarks> /// </remarks>
protected global::FineUIPro.MenuButton btnMenuEdit; protected global::FineUIPro.MenuButton btnMenuEdit;
/// <summary>
/// btnPrinter 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.MenuButton btnPrinter;
/// <summary> /// <summary>
/// btnMenuDelete 控件。 /// btnMenuDelete 控件。
/// </summary> /// </summary>
@@ -247,5 +247,19 @@ namespace Model
get; get;
set; set;
} }
/// <summary>
/// 签名
/// </summary>
public string Signature
{
get;
set;
}
public string Fingerprint
{
get;
set;
}
} }
} }
+454 -107
View File
@@ -2927,6 +2927,9 @@ namespace Model
partial void InsertZJ_Energy(ZJ_Energy instance); partial void InsertZJ_Energy(ZJ_Energy instance);
partial void UpdateZJ_Energy(ZJ_Energy instance); partial void UpdateZJ_Energy(ZJ_Energy instance);
partial void DeleteZJ_Energy(ZJ_Energy instance); partial void DeleteZJ_Energy(ZJ_Energy instance);
partial void InsertZJ_EnvironmentalCheck(ZJ_EnvironmentalCheck instance);
partial void UpdateZJ_EnvironmentalCheck(ZJ_EnvironmentalCheck instance);
partial void DeleteZJ_EnvironmentalCheck(ZJ_EnvironmentalCheck instance);
partial void InsertZJ_SuperviseCheck(ZJ_SuperviseCheck instance); partial void InsertZJ_SuperviseCheck(ZJ_SuperviseCheck instance);
partial void UpdateZJ_SuperviseCheck(ZJ_SuperviseCheck instance); partial void UpdateZJ_SuperviseCheck(ZJ_SuperviseCheck instance);
partial void DeleteZJ_SuperviseCheck(ZJ_SuperviseCheck instance); partial void DeleteZJ_SuperviseCheck(ZJ_SuperviseCheck instance);
@@ -10290,14 +10293,6 @@ namespace Model
} }
} }
public System.Data.Linq.Table<UnitWorkTemp1> UnitWorkTemp1
{
get
{
return this.GetTable<UnitWorkTemp1>();
}
}
public System.Data.Linq.Table<Unqualified_WorkContact> Unqualified_WorkContact public System.Data.Linq.Table<Unqualified_WorkContact> Unqualified_WorkContact
{ {
get get
@@ -11858,6 +11853,14 @@ namespace Model
} }
} }
public System.Data.Linq.Table<ZJ_EnvironmentalCheck> ZJ_EnvironmentalCheck
{
get
{
return this.GetTable<ZJ_EnvironmentalCheck>();
}
}
public System.Data.Linq.Table<ZJ_SuperviseCheck> ZJ_SuperviseCheck public System.Data.Linq.Table<ZJ_SuperviseCheck> ZJ_SuperviseCheck
{ {
get get
@@ -291346,6 +291349,8 @@ namespace Model
private EntityRef<ProjectData_TeamGroup> _ProjectData_TeamGroup; private EntityRef<ProjectData_TeamGroup> _ProjectData_TeamGroup;
private EntityRef<SitePerson_Person> _SitePerson_Person;
private EntityRef<Sys_User> _Sys_User; private EntityRef<Sys_User> _Sys_User;
#region #region
@@ -291437,6 +291442,7 @@ namespace Model
this._Base_Project = default(EntityRef<Base_Project>); this._Base_Project = default(EntityRef<Base_Project>);
this._Base_Unit = default(EntityRef<Base_Unit>); this._Base_Unit = default(EntityRef<Base_Unit>);
this._ProjectData_TeamGroup = default(EntityRef<ProjectData_TeamGroup>); this._ProjectData_TeamGroup = default(EntityRef<ProjectData_TeamGroup>);
this._SitePerson_Person = default(EntityRef<SitePerson_Person>);
this._Sys_User = default(EntityRef<Sys_User>); this._Sys_User = default(EntityRef<Sys_User>);
OnCreated(); OnCreated();
} }
@@ -291564,6 +291570,10 @@ namespace Model
{ {
if ((this._PersonId != value)) if ((this._PersonId != value))
{ {
if (this._SitePerson_Person.HasLoadedOrAssignedValue)
{
throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
}
this.OnPersonIdChanging(value); this.OnPersonIdChanging(value);
this.SendPropertyChanging(); this.SendPropertyChanging();
this._PersonId = value; this._PersonId = value;
@@ -292339,6 +292349,40 @@ namespace Model
} }
} }
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_Perfomance_PersonPerfomance_SitePerson_Person", Storage="_SitePerson_Person", ThisKey="PersonId", OtherKey="PersonId", IsForeignKey=true)]
public SitePerson_Person SitePerson_Person
{
get
{
return this._SitePerson_Person.Entity;
}
set
{
SitePerson_Person previousValue = this._SitePerson_Person.Entity;
if (((previousValue != value)
|| (this._SitePerson_Person.HasLoadedOrAssignedValue == false)))
{
this.SendPropertyChanging();
if ((previousValue != null))
{
this._SitePerson_Person.Entity = null;
previousValue.Perfomance_PersonPerfomance.Remove(this);
}
this._SitePerson_Person.Entity = value;
if ((value != null))
{
value.Perfomance_PersonPerfomance.Add(this);
this._PersonId = value.PersonId;
}
else
{
this._PersonId = default(string);
}
this.SendPropertyChanged("SitePerson_Person");
}
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_Perfomance_PersonPerfomance_Sys_User", Storage="_Sys_User", ThisKey="CompileMan", OtherKey="UserId", IsForeignKey=true)] [global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_Perfomance_PersonPerfomance_Sys_User", Storage="_Sys_User", ThisKey="CompileMan", OtherKey="UserId", IsForeignKey=true)]
public Sys_User Sys_User public Sys_User Sys_User
{ {
@@ -363368,6 +363412,8 @@ namespace Model
private EntitySet<HJGL_WeldJoint> _HJGL_WeldJoint_SitePerson_Person_CoverWelder; private EntitySet<HJGL_WeldJoint> _HJGL_WeldJoint_SitePerson_Person_CoverWelder;
private EntitySet<Perfomance_PersonPerfomance> _Perfomance_PersonPerfomance;
private EntitySet<QualityAudit_EquipmentPersonQuality> _QualityAudit_EquipmentPersonQuality; private EntitySet<QualityAudit_EquipmentPersonQuality> _QualityAudit_EquipmentPersonQuality;
private EntitySet<QualityAudit_PersonQuality> _QualityAudit_PersonQuality; private EntitySet<QualityAudit_PersonQuality> _QualityAudit_PersonQuality;
@@ -363561,6 +363607,7 @@ namespace Model
this._HJGL_RepairRecord = new EntitySet<HJGL_RepairRecord>(new Action<HJGL_RepairRecord>(this.attach_HJGL_RepairRecord), new Action<HJGL_RepairRecord>(this.detach_HJGL_RepairRecord)); this._HJGL_RepairRecord = new EntitySet<HJGL_RepairRecord>(new Action<HJGL_RepairRecord>(this.attach_HJGL_RepairRecord), new Action<HJGL_RepairRecord>(this.detach_HJGL_RepairRecord));
this._HJGL_WeldJoint = new EntitySet<HJGL_WeldJoint>(new Action<HJGL_WeldJoint>(this.attach_HJGL_WeldJoint), new Action<HJGL_WeldJoint>(this.detach_HJGL_WeldJoint)); this._HJGL_WeldJoint = new EntitySet<HJGL_WeldJoint>(new Action<HJGL_WeldJoint>(this.attach_HJGL_WeldJoint), new Action<HJGL_WeldJoint>(this.detach_HJGL_WeldJoint));
this._HJGL_WeldJoint_SitePerson_Person_CoverWelder = new EntitySet<HJGL_WeldJoint>(new Action<HJGL_WeldJoint>(this.attach_HJGL_WeldJoint_SitePerson_Person_CoverWelder), new Action<HJGL_WeldJoint>(this.detach_HJGL_WeldJoint_SitePerson_Person_CoverWelder)); this._HJGL_WeldJoint_SitePerson_Person_CoverWelder = new EntitySet<HJGL_WeldJoint>(new Action<HJGL_WeldJoint>(this.attach_HJGL_WeldJoint_SitePerson_Person_CoverWelder), new Action<HJGL_WeldJoint>(this.detach_HJGL_WeldJoint_SitePerson_Person_CoverWelder));
this._Perfomance_PersonPerfomance = new EntitySet<Perfomance_PersonPerfomance>(new Action<Perfomance_PersonPerfomance>(this.attach_Perfomance_PersonPerfomance), new Action<Perfomance_PersonPerfomance>(this.detach_Perfomance_PersonPerfomance));
this._QualityAudit_EquipmentPersonQuality = new EntitySet<QualityAudit_EquipmentPersonQuality>(new Action<QualityAudit_EquipmentPersonQuality>(this.attach_QualityAudit_EquipmentPersonQuality), new Action<QualityAudit_EquipmentPersonQuality>(this.detach_QualityAudit_EquipmentPersonQuality)); this._QualityAudit_EquipmentPersonQuality = new EntitySet<QualityAudit_EquipmentPersonQuality>(new Action<QualityAudit_EquipmentPersonQuality>(this.attach_QualityAudit_EquipmentPersonQuality), new Action<QualityAudit_EquipmentPersonQuality>(this.detach_QualityAudit_EquipmentPersonQuality));
this._QualityAudit_PersonQuality = new EntitySet<QualityAudit_PersonQuality>(new Action<QualityAudit_PersonQuality>(this.attach_QualityAudit_PersonQuality), new Action<QualityAudit_PersonQuality>(this.detach_QualityAudit_PersonQuality)); this._QualityAudit_PersonQuality = new EntitySet<QualityAudit_PersonQuality>(new Action<QualityAudit_PersonQuality>(this.attach_QualityAudit_PersonQuality), new Action<QualityAudit_PersonQuality>(this.detach_QualityAudit_PersonQuality));
this._QualityAudit_SafePersonQuality = new EntitySet<QualityAudit_SafePersonQuality>(new Action<QualityAudit_SafePersonQuality>(this.attach_QualityAudit_SafePersonQuality), new Action<QualityAudit_SafePersonQuality>(this.detach_QualityAudit_SafePersonQuality)); this._QualityAudit_SafePersonQuality = new EntitySet<QualityAudit_SafePersonQuality>(new Action<QualityAudit_SafePersonQuality>(this.attach_QualityAudit_SafePersonQuality), new Action<QualityAudit_SafePersonQuality>(this.detach_QualityAudit_SafePersonQuality));
@@ -365118,6 +365165,19 @@ namespace Model
} }
} }
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_Perfomance_PersonPerfomance_SitePerson_Person", Storage="_Perfomance_PersonPerfomance", ThisKey="PersonId", OtherKey="PersonId", DeleteRule="NO ACTION")]
public EntitySet<Perfomance_PersonPerfomance> Perfomance_PersonPerfomance
{
get
{
return this._Perfomance_PersonPerfomance;
}
set
{
this._Perfomance_PersonPerfomance.Assign(value);
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_QualityAudit_EquipmentPersonQuality_SitePerson_Person", Storage="_QualityAudit_EquipmentPersonQuality", ThisKey="PersonId", OtherKey="PersonId", DeleteRule="NO ACTION")] [global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_QualityAudit_EquipmentPersonQuality_SitePerson_Person", Storage="_QualityAudit_EquipmentPersonQuality", ThisKey="PersonId", OtherKey="PersonId", DeleteRule="NO ACTION")]
public EntitySet<QualityAudit_EquipmentPersonQuality> QualityAudit_EquipmentPersonQuality public EntitySet<QualityAudit_EquipmentPersonQuality> QualityAudit_EquipmentPersonQuality
{ {
@@ -365685,6 +365745,18 @@ namespace Model
entity.CoverWelder = null; entity.CoverWelder = null;
} }
private void attach_Perfomance_PersonPerfomance(Perfomance_PersonPerfomance entity)
{
this.SendPropertyChanging();
entity.SitePerson_Person = this;
}
private void detach_Perfomance_PersonPerfomance(Perfomance_PersonPerfomance entity)
{
this.SendPropertyChanging();
entity.SitePerson_Person = null;
}
private void attach_QualityAudit_EquipmentPersonQuality(QualityAudit_EquipmentPersonQuality entity) private void attach_QualityAudit_EquipmentPersonQuality(QualityAudit_EquipmentPersonQuality entity)
{ {
this.SendPropertyChanging(); this.SendPropertyChanging();
@@ -437275,6 +437347,12 @@ namespace Model
private string _UnitId; private string _UnitId;
private string _Signature;
private string _Fingerprint;
private string _CompanyTrainingItemId;
private EntityRef<Base_Project> _Base_Project; private EntityRef<Base_Project> _Base_Project;
private EntityRef<SitePerson_Person> _SitePerson_Person; private EntityRef<SitePerson_Person> _SitePerson_Person;
@@ -437311,6 +437389,12 @@ namespace Model
partial void OnDurationChanged(); partial void OnDurationChanged();
partial void OnUnitIdChanging(string value); partial void OnUnitIdChanging(string value);
partial void OnUnitIdChanged(); partial void OnUnitIdChanged();
partial void OnSignatureChanging(string value);
partial void OnSignatureChanged();
partial void OnFingerprintChanging(string value);
partial void OnFingerprintChanged();
partial void OnCompanyTrainingItemIdChanging(string value);
partial void OnCompanyTrainingItemIdChanged();
#endregion #endregion
public Training_TestRecord() public Training_TestRecord()
@@ -437574,6 +437658,66 @@ namespace Model
} }
} }
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Signature", DbType="NVarChar(1000)")]
public string Signature
{
get
{
return this._Signature;
}
set
{
if ((this._Signature != value))
{
this.OnSignatureChanging(value);
this.SendPropertyChanging();
this._Signature = value;
this.SendPropertyChanged("Signature");
this.OnSignatureChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Fingerprint", DbType="NVarChar(1000)")]
public string Fingerprint
{
get
{
return this._Fingerprint;
}
set
{
if ((this._Fingerprint != value))
{
this.OnFingerprintChanging(value);
this.SendPropertyChanging();
this._Fingerprint = value;
this.SendPropertyChanged("Fingerprint");
this.OnFingerprintChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CompanyTrainingItemId", DbType="NVarChar(50)")]
public string CompanyTrainingItemId
{
get
{
return this._CompanyTrainingItemId;
}
set
{
if ((this._CompanyTrainingItemId != value))
{
this.OnCompanyTrainingItemIdChanging(value);
this.SendPropertyChanging();
this._CompanyTrainingItemId = value;
this.SendPropertyChanged("CompanyTrainingItemId");
this.OnCompanyTrainingItemIdChanged();
}
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_Training_TestRecord_Base_Project", Storage="_Base_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true)] [global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_Training_TestRecord_Base_Project", Storage="_Base_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true)]
public Base_Project Base_Project public Base_Project Base_Project
{ {
@@ -441126,105 +441270,6 @@ namespace Model
} }
} }
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.UnitWorkTemp1")]
public partial class UnitWorkTemp1
{
private string _UnitId;
private string _UnitName;
private string _WorkPostId;
private string _WorkPostName;
private System.Nullable<int> _PNum;
public UnitWorkTemp1()
{
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UnitId", DbType="NVarChar(50)")]
public string UnitId
{
get
{
return this._UnitId;
}
set
{
if ((this._UnitId != value))
{
this._UnitId = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UnitName", DbType="NVarChar(200)")]
public string UnitName
{
get
{
return this._UnitName;
}
set
{
if ((this._UnitName != value))
{
this._UnitName = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkPostId", DbType="NVarChar(50)")]
public string WorkPostId
{
get
{
return this._WorkPostId;
}
set
{
if ((this._WorkPostId != value))
{
this._WorkPostId = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkPostName", DbType="VarChar(10) NOT NULL", CanBeNull=false)]
public string WorkPostName
{
get
{
return this._WorkPostName;
}
set
{
if ((this._WorkPostName != value))
{
this._WorkPostName = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Name="pNum", Storage="_PNum", DbType="Int")]
public System.Nullable<int> PNum
{
get
{
return this._PNum;
}
set
{
if ((this._PNum != value))
{
this._PNum = value;
}
}
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Unqualified_WorkContact")] [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Unqualified_WorkContact")]
public partial class Unqualified_WorkContact : INotifyPropertyChanging, INotifyPropertyChanged public partial class Unqualified_WorkContact : INotifyPropertyChanging, INotifyPropertyChanged
{ {
@@ -516660,6 +516705,308 @@ namespace Model
} }
} }
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.ZJ_EnvironmentalCheck")]
public partial class ZJ_EnvironmentalCheck : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private string _Id;
private string _ProjectId;
private System.Nullable<double> _Tsp;
private System.Nullable<double> _Temp;
private System.Nullable<double> _Noise;
private System.Nullable<double> _Humid;
private System.Nullable<double> _PmTwoPointFive;
private System.Nullable<double> _WindSpeed;
private System.Nullable<double> _PmTen;
private System.Nullable<System.DateTime> _Time;
private System.Nullable<System.DateTime> _CreateTime;
#region
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnIdChanging(string value);
partial void OnIdChanged();
partial void OnProjectIdChanging(string value);
partial void OnProjectIdChanged();
partial void OnTspChanging(System.Nullable<double> value);
partial void OnTspChanged();
partial void OnTempChanging(System.Nullable<double> value);
partial void OnTempChanged();
partial void OnNoiseChanging(System.Nullable<double> value);
partial void OnNoiseChanged();
partial void OnHumidChanging(System.Nullable<double> value);
partial void OnHumidChanged();
partial void OnPmTwoPointFiveChanging(System.Nullable<double> value);
partial void OnPmTwoPointFiveChanged();
partial void OnWindSpeedChanging(System.Nullable<double> value);
partial void OnWindSpeedChanged();
partial void OnPmTenChanging(System.Nullable<double> value);
partial void OnPmTenChanged();
partial void OnTimeChanging(System.Nullable<System.DateTime> value);
partial void OnTimeChanged();
partial void OnCreateTimeChanging(System.Nullable<System.DateTime> value);
partial void OnCreateTimeChanged();
#endregion
public ZJ_EnvironmentalCheck()
{
OnCreated();
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Id", DbType="NVarChar(50) NOT NULL", CanBeNull=false, IsPrimaryKey=true)]
public string Id
{
get
{
return this._Id;
}
set
{
if ((this._Id != value))
{
this.OnIdChanging(value);
this.SendPropertyChanging();
this._Id = value;
this.SendPropertyChanged("Id");
this.OnIdChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ProjectId", DbType="NVarChar(50)")]
public string ProjectId
{
get
{
return this._ProjectId;
}
set
{
if ((this._ProjectId != value))
{
this.OnProjectIdChanging(value);
this.SendPropertyChanging();
this._ProjectId = value;
this.SendPropertyChanged("ProjectId");
this.OnProjectIdChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Tsp", DbType="Float")]
public System.Nullable<double> Tsp
{
get
{
return this._Tsp;
}
set
{
if ((this._Tsp != value))
{
this.OnTspChanging(value);
this.SendPropertyChanging();
this._Tsp = value;
this.SendPropertyChanged("Tsp");
this.OnTspChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Temp", DbType="Float")]
public System.Nullable<double> Temp
{
get
{
return this._Temp;
}
set
{
if ((this._Temp != value))
{
this.OnTempChanging(value);
this.SendPropertyChanging();
this._Temp = value;
this.SendPropertyChanged("Temp");
this.OnTempChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Noise", DbType="Float")]
public System.Nullable<double> Noise
{
get
{
return this._Noise;
}
set
{
if ((this._Noise != value))
{
this.OnNoiseChanging(value);
this.SendPropertyChanging();
this._Noise = value;
this.SendPropertyChanged("Noise");
this.OnNoiseChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Humid", DbType="Float")]
public System.Nullable<double> Humid
{
get
{
return this._Humid;
}
set
{
if ((this._Humid != value))
{
this.OnHumidChanging(value);
this.SendPropertyChanging();
this._Humid = value;
this.SendPropertyChanged("Humid");
this.OnHumidChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PmTwoPointFive", DbType="Float")]
public System.Nullable<double> PmTwoPointFive
{
get
{
return this._PmTwoPointFive;
}
set
{
if ((this._PmTwoPointFive != value))
{
this.OnPmTwoPointFiveChanging(value);
this.SendPropertyChanging();
this._PmTwoPointFive = value;
this.SendPropertyChanged("PmTwoPointFive");
this.OnPmTwoPointFiveChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WindSpeed", DbType="Float")]
public System.Nullable<double> WindSpeed
{
get
{
return this._WindSpeed;
}
set
{
if ((this._WindSpeed != value))
{
this.OnWindSpeedChanging(value);
this.SendPropertyChanging();
this._WindSpeed = value;
this.SendPropertyChanged("WindSpeed");
this.OnWindSpeedChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PmTen", DbType="Float")]
public System.Nullable<double> PmTen
{
get
{
return this._PmTen;
}
set
{
if ((this._PmTen != value))
{
this.OnPmTenChanging(value);
this.SendPropertyChanging();
this._PmTen = value;
this.SendPropertyChanged("PmTen");
this.OnPmTenChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Time", DbType="DateTime")]
public System.Nullable<System.DateTime> Time
{
get
{
return this._Time;
}
set
{
if ((this._Time != value))
{
this.OnTimeChanging(value);
this.SendPropertyChanging();
this._Time = value;
this.SendPropertyChanged("Time");
this.OnTimeChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CreateTime", DbType="DateTime")]
public System.Nullable<System.DateTime> CreateTime
{
get
{
return this._CreateTime;
}
set
{
if ((this._CreateTime != value))
{
this.OnCreateTimeChanging(value);
this.SendPropertyChanging();
this._CreateTime = value;
this.SendPropertyChanged("CreateTime");
this.OnCreateTimeChanged();
}
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void SendPropertyChanging()
{
if ((this.PropertyChanging != null))
{
this.PropertyChanging(this, emptyChangingEventArgs);
}
}
protected virtual void SendPropertyChanged(String propertyName)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.ZJ_SuperviseCheck")] [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.ZJ_SuperviseCheck")]
public partial class ZJ_SuperviseCheck : INotifyPropertyChanging, INotifyPropertyChanged public partial class ZJ_SuperviseCheck : INotifyPropertyChanging, INotifyPropertyChanged
{ {
@@ -1,10 +1,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Web.Http; using System.Web.Http;
using BLL; using BLL;
using Model;
namespace WebAPI.Controllers namespace WebAPI.Controllers
{ {
/// <summary> /// <summary>
@@ -155,52 +159,20 @@ namespace WebAPI.Controllers
/// <param name="projectId">项目ID</param> /// <param name="projectId">项目ID</param>
/// <param name="personId">人员ID(null查全部)</param> /// <param name="personId">人员ID(null查全部)</param>
/// <param name="pageIndex">页码</param> /// <param name="pageIndex">页码</param>
/// <param name="unitId">单位id</param>
/// <returns>考试记录列表</returns> /// <returns>考试记录列表</returns>
public Model.ResponeData getTrainingTestRecordListByProjectIdPersonId(string projectId, string personId, int pageIndex=0,string unitId="") public Model.ResponeData getTrainingTestRecordListByProjectIdPersonId(string projectId, string personId, int pageIndex)
{ {
var responeData = new Model.ResponeData(); var responeData = new Model.ResponeData();
try try
{ {
if (string.IsNullOrEmpty(unitId)) personId = PersonService.GetPersonIdByUserIdForApi(personId);
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectIdPersonId(projectId, personId);
int pageCount = getDataLists.Count;
if (pageCount > 0 && pageIndex > 0)
{ {
//项目级 getDataLists = getDataLists.OrderByDescending(x => x.TestStartTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
if (pageIndex == 0)
{
personId = PersonService.GetPersonIdByUserId(personId);
responeData.data = APITestRecordService.getTrainingTestRecordListByProjectIdPersonId(projectId, personId);
}
else {
personId = PersonService.GetPersonIdByUserId(personId);
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectIdPersonId(projectId, personId);
int pageCount = getDataLists.Count;
if (pageCount > 0 && pageIndex > 0)
{
getDataLists = getDataLists.OrderByDescending(x => x.TestStartTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
}
responeData.data = new { pageCount, getDataLists };
}
} }
else { responeData.data = new { pageCount, getDataLists };
//公司级
if (pageIndex == 0)
{
personId = PersonService.GetPersonIdByUserId(personId);
responeData.data = APITestRecordService.getTrainingTestRecordListByUnitIdPersonId(unitId, personId);
}
else
{
personId = PersonService.GetPersonIdByUserId(personId);
var getDataLists = APITestRecordService.getTrainingTestRecordListByUnitIdPersonId(unitId, personId);
int pageCount = getDataLists.Count;
if (pageCount > 0 && pageIndex > 0)
{
getDataLists = getDataLists.OrderByDescending(x => x.TestStartTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
}
responeData.data = new { pageCount, getDataLists };
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -250,17 +222,14 @@ namespace WebAPI.Controllers
/// <param name="strPass">0-未通过;1通过;空所有</param> /// <param name="strPass">0-未通过;1通过;空所有</param>
/// <param name="pageIndex">页码</param> /// <param name="pageIndex">页码</param>
/// <returns>考试记录列表</returns> /// <returns>考试记录列表</returns>
public Model.ResponeData getTrainingTestRecordListQuery(string projectId, string unitId, string workPostId, string strPass, int pageIndex=0) public Model.ResponeData getTrainingTestRecordListQuery(string projectId, string unitId, string workPostId, string departId, string strPass, int pageIndex)
{ {
var responeData = new Model.ResponeData(); var responeData = new Model.ResponeData();
try try
{ {
if (pageIndex == 0) if (!string.IsNullOrEmpty(departId))
{ {
responeData.data = APITestRecordService.getTrainingTestRecordListByProjectId(projectId, unitId, workPostId, strPass, string.Empty); var getDataLists = APITestRecordService.getTrainingTestRecordListByDepartId(unitId,departId,strPass,string.Empty);
}
else {
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectId(projectId, unitId, workPostId, strPass, string.Empty);
int pageCount = getDataLists.Count; int pageCount = getDataLists.Count;
if (pageCount > 0 && pageIndex > 0) if (pageCount > 0 && pageIndex > 0)
{ {
@@ -268,6 +237,19 @@ namespace WebAPI.Controllers
} }
responeData.data = new { pageCount, getDataLists }; responeData.data = new { pageCount, getDataLists };
} }
else
{
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectId(projectId, unitId, workPostId, strPass, string.Empty);
int pageCount = getDataLists.Count;
if (pageCount > 0 && pageIndex > 0)
{
getDataLists = getDataLists.OrderByDescending(x => x.TestStartTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
}
responeData.data = new { pageCount, getDataLists };
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -289,32 +271,7 @@ namespace WebAPI.Controllers
/// <param name="strParam">参数</param> /// <param name="strParam">参数</param>
/// <param name="pageIndex">页码</param> /// <param name="pageIndex">页码</param>
/// <returns>考试记录列表</returns> /// <returns>考试记录列表</returns>
public Model.ResponeData getTrainingTestRecordListQuery(string projectId, string unitId, string workPostId, string strPass,string strParam, int pageIndex=0)
{
var responeData = new Model.ResponeData();
try
{
if (pageIndex == 0)
{
responeData.data = APITestRecordService.getTrainingTestRecordListByProjectId(projectId, unitId, workPostId, strPass, strParam);
}
else {
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectId(projectId, unitId, workPostId, strPass, strParam);
int pageCount = getDataLists.Count;
if (pageCount > 0 && pageIndex > 0)
{
getDataLists = getDataLists.OrderByDescending(x => x.TestStartTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
}
responeData.data = new { pageCount, getDataLists };
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion #endregion
#region TestRecordItemIdselectedItem #region TestRecordItemIdselectedItem
@@ -328,25 +285,129 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData(); var responeData = new Model.ResponeData();
try try
{ {
var getItem = TestRecordItemService.GetTestRecordItemTestRecordItemId(testRecordItemId); if (!string.IsNullOrEmpty(testRecordItemId) && !string.IsNullOrEmpty(selectedItem))
if (getItem != null)
{ {
//更新没有结束时间且超时的考试记录 using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
int closeCount = TestRecordService.UpdateTestEndTimeNull(getItem.TestRecordId);
if (closeCount > 0)
{ {
responeData.code = 2; var getTItem = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordItemId == testRecordItemId);
responeData.message = "本次考试已结束,系统自动交卷!"; if (getTItem != null)
} {
else getTItem.SubjectScore = 0;
{ getTItem.SelectedItem = selectedItem;
APITestRecordService.getTestRecordItemAnswerBySelectedItem(getItem, selectedItem); if (!string.IsNullOrEmpty(selectedItem))
{
if (getTItem.AnswerItems == selectedItem)
{
getTItem.SubjectScore = getTItem.Score ?? 0;
}
else
{
var listA = Funs.GetStrListByStr(getTItem.AnswerItems.ToUpper(), ',');
var listS = Funs.GetStrListByStr(selectedItem.ToUpper(), ',');
if (getTItem.TestType == "2" && listA.Count >= listS.Count)
{
int i = 0;
foreach (var item in listS)
{
if (!listA.Contains(item))
{
i++;
break;
}
}
if (i == 0)
{
if (listA.Count == listS.Count)
{
getTItem.SubjectScore = getTItem.Score ?? 0;
}
else
{
getTItem.SubjectScore = Convert.ToDecimal((getTItem.Score ?? 0) * 1.0 / 2);
}
}
}
}
}
db.SubmitChanges();
}
} }
} }
else else
{ {
responeData.code = 0; responeData.code = 0;
responeData.message = "试题有问题"; responeData.message = "答题为空选项";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
public Model.ResponeData getTestRecordItemAnswerBySelectedItem(string testRecordId,string testRecordItemId, string selectedItem)
{
var responeData = new Model.ResponeData();
try
{
if (!string.IsNullOrEmpty(testRecordId) && !string.IsNullOrEmpty(testRecordItemId) && !string.IsNullOrEmpty(selectedItem))
{
BLL.RedisHelper redis = new RedisHelper();
var trainingTestRecordItems = redis.GetObjString<List<Training_TestRecordItem>>(testRecordId); //根据试卷ID获取试卷题目列表
var getTItem= trainingTestRecordItems?.FirstOrDefault(x => x.TestRecordItemId== testRecordItemId); //获取试题
if (getTItem==null)
{
responeData.code = 0;
responeData.message = "答题为空选项!";
return responeData;
}
getTItem.SubjectScore = 0;
getTItem.SelectedItem = selectedItem;
if (!string.IsNullOrEmpty(selectedItem))
{
if (getTItem.AnswerItems == selectedItem)
{
getTItem.SubjectScore = getTItem.Score ?? 0;
}
else
{
var listA = Funs.GetStrListByStr(getTItem.AnswerItems.ToUpper(), ',');
var listS = Funs.GetStrListByStr(selectedItem.ToUpper(), ',');
if (getTItem.TestType == "2" && listA.Count >= listS.Count)
{
int i = 0;
foreach (var item in listS)
{
if (!listA.Contains(item))
{
i++;
break;
}
}
if (i == 0)
{
if (listA.Count == listS.Count)
{
getTItem.SubjectScore = getTItem.Score ?? 0;
}
else
{
getTItem.SubjectScore = Convert.ToDecimal((getTItem.Score ?? 0) * 1.0 / 2);
}
}
}
}
}
redis.SetObjString(testRecordId, getTItem);
}
else
{
responeData.code = 0;
responeData.message = "参数不足!";
return responeData;
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -364,62 +425,75 @@ namespace WebAPI.Controllers
/// 交卷 /// 交卷
/// </summary> /// </summary>
/// <param name="testRecordId">试卷ID</param> /// <param name="testRecordId">试卷ID</param>
public Model.ResponeData getSubmitTestRecordByTestRecordId(string testRecordId) public Model.ResponeData getSubmitTestRecordByTestRecordId(string testRecordId,string Signature)
{ {
var responeData = new Model.ResponeData(); var responeData = new Model.ResponeData();
try try
{ {
var getTestRecord = Funs.DB.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId); using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
if (getTestRecord != null)
{ {
string returnTestRecordId = string.Empty; #region
////考试分数 RedisHelper redis = new RedisHelper();
decimal getTestScores = APITestRecordService.getSubmitTestRecord(getTestRecord); var trainingTestRecordItems = redis.GetObjString<List<Training_TestRecordItem>>(testRecordId);
////及格分数
//int getPassScores = SysConstSetService.getPassScore(); if (trainingTestRecordItems!=null)
int getPassScores = SysConstSetService.getPassScore(getTestRecord.TestPlanId);
if (getTestScores >= getPassScores)
{ {
APITestRecordService.updateAll(getTestRecord.TestPlanId); var testRecordItem = from x in db.Training_TestRecordItem
responeData.message = "恭喜考试通过!您的成绩为:【" + getTestScores.ToString() + "】。"; where x.TestRecordId == testRecordId
} select x;
else if (testRecordItem.Any())
{
int testCount = Funs.DB.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
if (testCount < 2)
{ {
////重新生成一条考试记录 以及考试试卷 db.Training_TestRecordItem.DeleteAllOnSubmit(testRecordItem);
returnTestRecordId = APITestRecordService.getResitTestRecord(getTestRecord); db.SubmitChanges();
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,您将进入补考。"; }
db.Training_TestRecordItem.InsertAllOnSubmit(trainingTestRecordItems);
}
#endregion
string returnTestRecordId = string.Empty;
decimal getTestScores = 0;
var getTestRecord = db.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
if (getTestRecord != null)
{
if (getTestRecord.TestStartTime.HasValue)
{
getTestRecord.Signature = Signature;
getTestRecord.TestEndTime = DateTime.Now;
// var getRItem = db.Training_TestRecordItem.Where(x => x.TestRecordId == testRecordId);
// if (getRItem.Count() > 0)
// {
getTestRecord.TestScores = db.Training_TestRecordItem.Where(x => x.TestRecordId == testRecordId).Sum(x => x.SubjectScore ?? 0);
// }
db.SubmitChanges();
getTestScores = getTestRecord.TestScores ?? 0;
}
////考试分数
int getPassScores = SysConstSetService.getPassScoreForApi();
if (getTestScores <= getPassScores)
{
int testCount = db.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
if (testCount < 2)
{
////重新生成一条考试记录 以及考试试卷
returnTestRecordId = APITestRecordService.getResitTestRecord(getTestRecord);
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,您将进入补考。";
}
else
{
// APITestRecordService.updateAll(getTestRecord.TestPlanId);
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,请再次参加培训后补考。";
}
} }
else else
{ {
APITestRecordService.updateAll(getTestRecord.TestPlanId); // APITestRecordService.updateAll(getTestRecord.TestPlanId);
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,请再次参加培训后补考。"; responeData.message = "恭喜考试通过!您的成绩为:【" + getTestScores.ToString() + "】。";
} }
}
//if (getTestScores <= getPassScores)
//{
// int testCount = Funs.DB.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
// if (testCount < 2)
// {
// ////重新生成一条考试记录 以及考试试卷
// returnTestRecordId = APITestRecordService.getResitTestRecord(getTestRecord);
// responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,您将进入补考。";
// }
// else
// {
// APITestRecordService.updateAll(getTestRecord.TestPlanId);
// responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,请再次参加培训后补考。";
// }
//}
//else
//{
// APITestRecordService.updateAll(getTestRecord.TestPlanId);
// responeData.message = "恭喜考试通过!您的成绩为:【" + getTestScores.ToString() + "】。";
//}
responeData.data = new { getTestScores, getPassScores, returnTestRecordId }; responeData.data = new { getTestScores, getPassScores, returnTestRecordId };
}
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -432,80 +506,121 @@ namespace WebAPI.Controllers
} }
#endregion #endregion
#region #region
/// <summary> /// <summary>
/// 根据TestRecordItemId、selectedItem 考生答题 /// 交卷
/// </summary> /// </summary>
/// <param name="testRecordItemId">题目ID</param> public Model.ResponeData SaveSubmitTestRecordByTestRecordId(Model.TestRecordItem testRecordItem)
/// <param name="selectedItem">选项</param>
public Model.ResponeData getTestRecordItemAnswerBySelectedItemNew(string testRecordItemId, string selectedItem)
{ {
string testRecordId = testRecordItem.TestRecordId;
string Signature = testRecordItem.Signature;
string Fingerprint = testRecordItem.Fingerprint;
var responeData = new Model.ResponeData(); var responeData = new Model.ResponeData();
try try
{ {
var getItem = TestRecordItemService.GetTestRecordItemTestRecordItemId(testRecordItemId); using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
if (getItem != null)
{ {
APITestRecordService.getTestRecordItemAnswerBySelectedItem(getItem, selectedItem); #region
} RedisHelper redis = new RedisHelper();
else var trainingTestRecordItems = redis.GetObjString<List<Training_TestRecordItem>>(testRecordId);
{
responeData.code = 0;
responeData.message = "试题有问题!";
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData; if (trainingTestRecordItems!=null)
}
/// <summary>
/// 交卷
/// </summary>
/// <param name="testRecordId"></param>
/// <returns></returns>
public Model.ResponeData getSubmitTestRecordByTestRecordIdNew(string testRecordId)
{
var responeData = new Model.ResponeData();
try
{
var getTestRecord = Funs.DB.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
if (getTestRecord != null)
{
string returnTestRecordId = string.Empty;
////考试分数
decimal getTestScores = APITestRecordService.getSubmitTestRecord(getTestRecord);
////及格分数
//int getPassScores = SysConstSetService.getPassScore();
int getPassScores = SysConstSetService.getPassScore(getTestRecord.TestPlanId);
if (getTestScores >= getPassScores)
{ {
//APITestRecordService.updateAll(getTestRecord.TestPlanId); var modeltestRecordItem = from x in db.Training_TestRecordItem
responeData.message = "恭喜考试通过!您的成绩为:【" + getTestScores.ToString() + "】。"; where x.TestRecordId == testRecordId
select x;
if (modeltestRecordItem.Any())
{
db.Training_TestRecordItem.DeleteAllOnSubmit(modeltestRecordItem);
db.SubmitChanges();
}
db.Training_TestRecordItem.InsertAllOnSubmit(trainingTestRecordItems);
} }
else #endregion
{
//APITestRecordService.updateAll(getTestRecord.TestPlanId);
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,请再次重新扫码进行考试。"; var getTestRecord = db.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
if (getTestRecord != null)
{
string rootUrl = ConfigurationManager.AppSettings["localRoot"];
string SignatureUrl = @"FileUpload\TestRecord\" + getTestRecord.TestRecordId + "~签名" + ".png";
string FingerprintUrl = @"FileUpload\TestRecord\" + getTestRecord.TestRecordId + "~指纹" + ".png";
string Signaturefilename = rootUrl + SignatureUrl;
string Fingerprintfilename = rootUrl + FingerprintUrl;
if (!string.IsNullOrEmpty(Signature))
{
Signature = Signature.Replace("data:image/svg+xml;base64,", "").Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换
byte[] bytes = Convert.FromBase64String(Signature);
MemoryStream memStream = new MemoryStream(bytes);
Image mImage = Image.FromStream(memStream);
Bitmap bp = new Bitmap(mImage);
MemoryStream ms = new MemoryStream();
bp.Save(Signaturefilename, System.Drawing.Imaging.ImageFormat.Png);
// System.IO.File.WriteAllBytes(Signaturefilename, Convert.FromBase64String(Signature));
getTestRecord.Signature = Signaturefilename.Replace(rootUrl, "");
}
if (!string.IsNullOrEmpty(Fingerprint))
{
Fingerprint = Fingerprint.Replace("data:image/svg+xml;base64,", "").Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换
byte[] bytes = Convert.FromBase64String(Fingerprint);
MemoryStream memStream = new MemoryStream(bytes);
Image mImage = Image.FromStream(memStream);
Bitmap bp = new Bitmap(mImage);
MemoryStream ms = new MemoryStream();
bp.Save(Fingerprintfilename, System.Drawing.Imaging.ImageFormat.Png);
getTestRecord.Fingerprint = Fingerprintfilename.Replace(rootUrl, "");
}
db.SubmitChanges();
// APITestRecordService.updateTestRecord(getTestRecord);
string returnTestRecordId = string.Empty;
////考试分数
decimal getTestScores = APITestRecordService.getSubmitTestRecord(getTestRecord);
if (!string.IsNullOrEmpty(getTestRecord.TestPlanId))
{ ////及格分数
int getPassScores = 80;
var testRule = db.Sys_TestRule.FirstOrDefault();
if (testRule != null)
{
getPassScores = testRule.PassingScore;
}
if (getTestScores <= getPassScores)
{
int testCount = db.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
if (testCount < 2)
{
////重新生成一条考试记录 以及考试试卷
returnTestRecordId = APITestRecordService.getResitTestRecord(getTestRecord);
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,您将进入补考。";
}
else
{
APITestRecordService.updateAll(getTestRecord.TestPlanId);
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,请再次参加培训后补考。";
}
}
else
{
APITestRecordService.updateAll(getTestRecord.TestPlanId);
responeData.message = "恭喜考试通过!您的成绩为:【" + getTestScores.ToString() + "】。";
} responeData.data = new { getTestScores, getPassScores, returnTestRecordId };
}
else
{
responeData.data = new { getTestScores };
}
//int testCount = Funs.DB.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
//if (testCount < 2)
//{
// ////重新生成一条考试记录 以及考试试卷
// returnTestRecordId = APITestRecordService.getResitTestRecord(getTestRecord);
// responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,您将进入补考。";
//}
//else
//{
// APITestRecordService.updateAll(getTestRecord.TestPlanId);
// responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,请再次参加培训后补考。";
//}
} }
responeData.data = new { getTestScores, getPassScores, returnTestRecordId };
} }
} }
catch (Exception ex) catch (Exception ex)