Commit f78a1f1e by 陶然

init

parent 4191e570
......@@ -3,3 +3,4 @@
################################################################################
/Src/bin/Debug
/Src/obj/Debug
using Kivii;
using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jst.HumanResources.Oa.Entities
{
[Alias("ERPNWorkToDo")]
public class OaWorkToDo:IEntityInAnyDb
{
[PrimaryKey]
public int ID { get; set; }
public string WorkName { get; set; }
public int FormID { get; set; }
public int WorkFlowID { get; set; }
public string UserName { get; set; }
public DateTime TimeStr { get; set; }
public string FormContent { get; set; }
public string FuJianList { get; set; }
public string ShenPiYiJian { get; set; }
public int JieDianID { get; set; }
public string JieDianName { get; set; }
public string ShenPiUserList { get; set; }
public string OKUserList { get; set; }
public string StateNow { get; set; }
public DateTime LateTime { get; set; }
public string ChaoSongUserList { get; set; }
public int PreviousNode { get; set; }
public string PreShenPiUser { get; set; }
public int Status { get; set; }
[Ignore]
public bool IsSuccess { get; set; }
}
}
using Jst.HumanResources.Oa.Entities;
using Kivii;
using Kivii.HumanResources.Entities;
using Kivii.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jst.HumanResources.Oa.Jobs
{
public class OaWorkToDoJob : IJob
{
public string Name => "OA请假同步任务";
public string Description => "获取OA请假同步至考勤任务";
public IJobContext TaskContext { get; set; }
public void Dispose()
{
}
public bool Execution()
{
return OaSync();
}
private bool OaSync()
{
var connHr = KiviiContext.GetOpenedDbConnection<Attendance>();
var queryNotSigned = connHr.From<Attendance>();
//只查三个月以内的
queryNotSigned.Where(o => o.TimeResult == "NotSigned" & o.BaseCheckTime >= DateTime.Now.AddMonths(-3));
//查出未打卡的人清单
var notSigneds = connHr.Select(queryNotSigned);
if (notSigneds.IsNullOrEmpty())
{
TaskContext.Message = $"暂无请假申请同步!";
return true;
}
int total = notSigneds.Count, success = 0;
var names = notSigneds.ConvertAll(o => o.UserName).Distinct().ToList();
var connOa = KiviiContext.GetOpenedDbConnection<OaWorkToDo>();
var queryOa = connOa.From<OaWorkToDo>();
queryOa.Where(o => o.StateNow == "正常结束" & Sql.In(o.UserName, names) & o.WorkName.Contains("请假"));
var oaWorkToDos = connOa.Select(queryOa);
foreach (var oa in oaWorkToDos)
{
var beginStr = "alt=开始时间 value=\"";
var endStr = "alt=结束时间 value=\"";
int beginIndex = oa.FormContent.IndexOf(beginStr);
int endIndex = oa.FormContent.IndexOf(endStr);
if (beginIndex == -1) continue;
if (endIndex == -1) continue;
if (!DateTime.TryParse(oa.FormContent.Substring(beginIndex + beginStr.Length, 10), out var beginTime)) continue;
if (!DateTime.TryParse(oa.FormContent.Substring(endIndex + endStr.Length, 10), out var endtTime)) continue;
oa.IsSuccess = true;
oa.TimeStr = beginTime;
oa.LateTime = endtTime.AddDays(1);
}
foreach (var notSigned in notSigneds)
{
var oas = oaWorkToDos.Where(o => o.UserName == notSigned.UserName).ToList();
if (oas.IsNullOrEmpty()) continue;
var oa = oas.FirstOrDefault(o => o.IsSuccess == true & o.TimeStr >= notSigned.BaseCheckTime & notSigned.BaseCheckTime < o.LateTime);
if (oa == null) continue;
notSigned.SourceType = "OA";
notSigned.AddOnlyProperties(o => o.SourceType);
notSigned.TimeResult = "Leave";
notSigned.AddOnlyProperties(o => o.TimeResult);
notSigned.Summary = $"已匹配到OA请假申请,时间为:{oa.TimeStr:G}{oa.LateTime:G}";
notSigned.AddOnlyProperties(o => o.Summary);
connHr.UpdateOnly(notSigned);
success++;
}
TaskContext.Message = $"查询到{total}条未打卡记录,成功同步OA请假申请{success}条!";
return true;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5BAF2428-8C5A-492E-AB82-DC995FB36410}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Jst.HumanResources.Oa</RootNamespace>
<AssemblyName>Jst.HumanResources.Oa</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kivii.Common.V4.5, Version=5.6.2021.3190, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\Kivii.K5\packages\Kivii.Common.5.6.2021.3190\lib\net45\Kivii.Common.V4.5.dll</HintPath>
</Reference>
<Reference Include="Kivii.Core.V4.5, Version=5.6.2021.4000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\Kivii.K5\packages\Kivii.Core.5.6.2021.4000\lib\net45\Kivii.Core.V4.5.dll</HintPath>
</Reference>
<Reference Include="Kivii.Linq.V4.5, Version=5.6.2021.3030, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\Kivii.K5\packages\Kivii.Linq.5.6.2021.3030\lib\net45\Kivii.Linq.V4.5.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Entities\OaWorkToDo.cs" />
<Compile Include="Jobs\OaWorkToDoJob.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Kivii.K5\Kivii.Biz.HumanResources\Src\Kivii.Biz.HumanResources.V4.5.csproj">
<Project>{8f97c7de-a962-4c58-8e8e-2f3213bb5a24}</Project>
<Name>Kivii.Biz.HumanResources.V4.5</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Jst.HumanResources.Oa.V4.5")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Jst.HumanResources.Oa.V4.5")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("5baf2428-8c5a-492e-ab82-dc995fb36410")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Kivii.Common" version="5.6.2021.3190" targetFramework="net45" />
<package id="Kivii.Core" version="5.6.2021.4000" targetFramework="net45" />
<package id="Kivii.Linq" version="5.6.2021.3030" targetFramework="net45" />
</packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment