合并最新
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace WebAPI.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口
|
||||
/// </summary>
|
||||
public interface ICache
|
||||
{
|
||||
/// <summary>
|
||||
/// 缓存过期时间
|
||||
/// </summary>
|
||||
int TimeOut { set; get; }
|
||||
/// <summary>
|
||||
/// 获得指定键的缓存值
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <returns>缓存值</returns>
|
||||
object Get(string key);
|
||||
/// <summary>
|
||||
/// 获得指定键的缓存值
|
||||
/// </summary>
|
||||
T Get<T>(string key);
|
||||
/// <summary>
|
||||
/// 从缓存中移除指定键的缓存值
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
void Remove(string key);
|
||||
/// <summary>
|
||||
/// 清空所有缓存对象
|
||||
/// </summary>
|
||||
//void Clear();
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
void Insert(string key, object data);
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
void Insert<T>(string key, T data);
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
/// <param name="cacheTime">缓存过期时间(秒钟)</param>
|
||||
void Insert(string key, object data, int cacheTime);
|
||||
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
/// <param name="cacheTime">缓存过期时间(秒钟)</param>
|
||||
void Insert<T>(string key, T data, int cacheTime);
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
/// <param name="cacheTime">缓存过期时间</param>
|
||||
void Insert(string key, object data, DateTime cacheTime);
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
/// <param name="cacheTime">缓存过期时间</param>
|
||||
void Insert<T>(string key, T data, DateTime cacheTime);
|
||||
/// <summary>
|
||||
/// 判断key是否存在
|
||||
/// </summary>
|
||||
bool Exists(string key);
|
||||
/// <summary>
|
||||
/// 右侧入队
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <param name="redisValue"></param>
|
||||
/// <returns></returns>
|
||||
long EnqueueListRightPush(RedisKey queueName, RedisValue redisValue);
|
||||
/// <summary>
|
||||
/// 左侧入队
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <param name="redisvalue"></param>
|
||||
/// <returns></returns>
|
||||
long EnqueueListLeftPush(RedisKey queueName, RedisValue redisvalue);
|
||||
/// <summary>
|
||||
/// 获取队列长度
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <returns></returns>
|
||||
long EnqueueListLength(RedisKey queueName);
|
||||
/// <summary>
|
||||
/// 左侧出队
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <returns></returns>
|
||||
string DequeueListPopLeft(RedisKey queueName);
|
||||
/// <summary>
|
||||
/// 右侧出队
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <returns></returns>
|
||||
string DequeueListPopRight(RedisKey queueName);
|
||||
/// <summary>
|
||||
/// 分布式加锁
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="data">值</param>
|
||||
/// <param name="seconds">过期时间</param>
|
||||
/// <returns></returns>
|
||||
bool LockTake(string key, string data, TimeSpan seconds, int db = 0);
|
||||
/// <summary>
|
||||
/// 解锁
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="data">值</param>
|
||||
/// <returns></returns>
|
||||
bool LockRelease(string key, string data, int db = -1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
using Newtonsoft.Json;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace WebAPI.Common
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class Redis : ICache
|
||||
{
|
||||
int Default_Timeout = 600;//默认超时时间(单位秒)
|
||||
string address;
|
||||
JsonSerializerSettings jsonConfig = new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore };
|
||||
ConnectionMultiplexer connectionMultiplexer;
|
||||
IDatabase database;
|
||||
|
||||
class CacheObject<T>
|
||||
{
|
||||
public int ExpireTime { get; set; }
|
||||
public bool ForceOutofDate { get; set; }
|
||||
public T Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dbbase"></param>
|
||||
public Redis(int dbbase = 0)
|
||||
{
|
||||
this.address = this.address = ConfigurationManager.AppSettings["RedisHosts"];
|
||||
|
||||
if (this.address == null || string.IsNullOrWhiteSpace(this.address.ToString()))
|
||||
throw new ApplicationException("配置文件中未找到RedisServer的有效配置");
|
||||
connectionMultiplexer = ConnectionMultiplexer.Connect(address);
|
||||
database = connectionMultiplexer.GetDatabase(dbbase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 连接超时设置
|
||||
/// </summary>
|
||||
public int TimeOut
|
||||
{
|
||||
get
|
||||
{
|
||||
return Default_Timeout;
|
||||
}
|
||||
set
|
||||
{
|
||||
Default_Timeout = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public object Get(string key)
|
||||
{
|
||||
return Get<object>(key);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public T Get<T>(string key)
|
||||
{
|
||||
|
||||
DateTime begin = DateTime.Now;
|
||||
var cacheValue = database.StringGet(key);
|
||||
DateTime endCache = DateTime.Now;
|
||||
var value = default(T);
|
||||
if (!cacheValue.IsNull)
|
||||
{
|
||||
var cacheObject = JsonConvert.DeserializeObject<CacheObject<T>>(cacheValue, jsonConfig);
|
||||
if (!cacheObject.ForceOutofDate)
|
||||
database.KeyExpire(key, new TimeSpan(0, 0, cacheObject.ExpireTime));
|
||||
value = cacheObject.Value;
|
||||
}
|
||||
DateTime endJson = DateTime.Now;
|
||||
return value;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
public void Insert(string key, object data)
|
||||
{
|
||||
var jsonData = GetJsonData(data, TimeOut, false);
|
||||
database.StringSet(key, jsonData);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
public void Insert(string key, object data, int cacheTime)
|
||||
{
|
||||
var timeSpan = TimeSpan.FromSeconds(cacheTime);
|
||||
var jsonData = GetJsonData(data, TimeOut, true);
|
||||
database.StringSet(key, jsonData, timeSpan);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
public void Insert(string key, object data, DateTime cacheTime)
|
||||
{
|
||||
var timeSpan = cacheTime - DateTime.Now;
|
||||
var jsonData = GetJsonData(data, TimeOut, true);
|
||||
database.StringSet(key, jsonData, timeSpan);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
public void Insert<T>(string key, T data)
|
||||
{
|
||||
var jsonData = GetJsonData<T>(data, TimeOut, false);
|
||||
database.StringSet(key, jsonData);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
public void Insert<T>(string key, T data, int cacheTime)
|
||||
{
|
||||
var timeSpan = TimeSpan.FromSeconds(cacheTime);
|
||||
var jsonData = GetJsonData<T>(data, TimeOut, true);
|
||||
database.StringSet(key, jsonData, timeSpan);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
public void Insert<T>(string key, T data, DateTime cacheTime)
|
||||
{
|
||||
var timeSpan = cacheTime - DateTime.Now;
|
||||
var jsonData = GetJsonData<T>(data, TimeOut, true);
|
||||
database.StringSet(key, jsonData, timeSpan);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
/// <param name="forceOutOfDate"></param>
|
||||
/// <returns></returns>
|
||||
string GetJsonData(object data, int cacheTime, bool forceOutOfDate)
|
||||
{
|
||||
var cacheObject = new CacheObject<object>() { Value = data, ExpireTime = cacheTime, ForceOutofDate = forceOutOfDate };
|
||||
return JsonConvert.SerializeObject(cacheObject, jsonConfig);//序列化对象
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
/// <param name="forceOutOfDate"></param>
|
||||
/// <returns></returns>
|
||||
string GetJsonData<T>(T data, int cacheTime, bool forceOutOfDate)
|
||||
{
|
||||
var cacheObject = new CacheObject<T>() { Value = data, ExpireTime = cacheTime, ForceOutofDate = forceOutOfDate };
|
||||
return JsonConvert.SerializeObject(cacheObject, jsonConfig);//序列化对象
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
public void Remove(string key)
|
||||
{
|
||||
database.KeyDelete(key, CommandFlags.HighPriority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断key是否存在
|
||||
/// </summary>
|
||||
public bool Exists(string key)
|
||||
{
|
||||
return database.KeyExists(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右侧入队
|
||||
/// </summary>
|
||||
/// <param name="queueName">队列名称</param>
|
||||
/// <param name="redisValue">值</param>
|
||||
/// <returns></returns>
|
||||
public long EnqueueListRightPush(RedisKey queueName, RedisValue redisValue)
|
||||
{
|
||||
return database.ListRightPush(queueName, redisValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 左侧入队
|
||||
/// </summary>
|
||||
/// <param name="queueName">队列名称</param>
|
||||
/// <param name="redisvalue">队列值</param>
|
||||
/// <returns></returns>
|
||||
public long EnqueueListLeftPush(RedisKey queueName, RedisValue redisvalue)
|
||||
{
|
||||
return database.ListLeftPush(queueName, redisvalue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取队列长度
|
||||
/// </summary>
|
||||
/// <param name="queueName">队列名称</param>
|
||||
/// <returns></returns>
|
||||
public long EnqueueListLength(RedisKey queueName)
|
||||
{
|
||||
if (database.KeyExists(queueName))
|
||||
{
|
||||
return database.ListLength(queueName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 左侧出队
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <returns></returns>
|
||||
public string DequeueListPopLeft(RedisKey queueName)
|
||||
{
|
||||
int count = database.ListRange(queueName).Length;
|
||||
if (count > 0)
|
||||
{
|
||||
string redisValue = database.ListLeftPop(queueName);
|
||||
if (!string.IsNullOrEmpty(redisValue))
|
||||
return redisValue;
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "-1";
|
||||
throw new Exception($"队列{queueName}数据为零");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右侧出队
|
||||
/// </summary>
|
||||
public string DequeueListPopRight(RedisKey queueName)
|
||||
{
|
||||
int count = database.ListRange(queueName).Length;
|
||||
if (count > 0)
|
||||
{
|
||||
string redisValue = database.ListRightPop(queueName);
|
||||
if (!string.IsNullOrEmpty(redisValue))
|
||||
return redisValue;
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "-1";
|
||||
throw new Exception($"队列{queueName}数据为零");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分布式加锁
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="data">值</param>
|
||||
/// <param name="seconds">过期时间</param>
|
||||
/// <returns></returns>
|
||||
public bool LockTake(string key, string data, TimeSpan seconds, int db = 0)
|
||||
{
|
||||
return database.LockTake(key, data, seconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解锁
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="data">值</param>
|
||||
/// <returns></returns>
|
||||
public bool LockRelease(string key, string data, int db = -1)
|
||||
{
|
||||
return database.LockRelease(key, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -550,6 +550,30 @@ namespace WebAPI.Controllers
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#region 获取部门
|
||||
/// <summary>
|
||||
/// 获取部门
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData getBaseDepart()
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
responeData.data = APIBaseInfoService.getBaseDepart(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
ErrLogInfo.WriteLog(ex, "WX接口-获取岗位信息", "BaseInfoController.getWorkPost");
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取岗位信息
|
||||
/// </summary>
|
||||
|
||||
@@ -153,11 +153,15 @@ namespace Mvc.Controllers
|
||||
|
||||
if (approve.ApproveType != "1" && approve.ApproveType != "7")
|
||||
{
|
||||
|
||||
var userid = Request.Headers.TryGetValues("token", out IEnumerable<string> token);
|
||||
var user = BLL.APIUserService.getUserByUserId(token.FirstOrDefault());
|
||||
APICommonService.SendSubscribeMessage(approve.ApproveMan, "质量巡检问题待办理", user.UserName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
|
||||
|
||||
if (token != null)
|
||||
{
|
||||
var user = BLL.APIUserService.getUserByUserId(token.FirstOrDefault());
|
||||
if (user != null)
|
||||
{
|
||||
APICommonService.SendSubscribeMessage(approve.ApproveMan, "质量巡检问题待办理", user.UserName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
|
||||
}
|
||||
}
|
||||
}
|
||||
res.resultValue = BLL.CheckControlApproveService.AddCheckControlApproveForApi(approve);
|
||||
res.successful = true;
|
||||
|
||||
@@ -0,0 +1,402 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using BLL;
|
||||
using WebAPI.Filter;
|
||||
|
||||
namespace WebAPI.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class DoorServerController : ApiController
|
||||
{
|
||||
#region 获取部门、人员、出入记录最大ID
|
||||
/// <summary>
|
||||
/// 获取部门、人员、出入记录最大ID
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public string getMaxID(string projectId)
|
||||
{
|
||||
int DepartmentID = 0, ID=0;
|
||||
long EmployID = 0, ValidEventID=0;
|
||||
var getD = Funs.DB.T_d_department.Where(x=> x.ProjectId == projectId).Select(x => x.DepartmentID);
|
||||
if (getD.Count()>0)
|
||||
{
|
||||
DepartmentID = getD.Max();
|
||||
}
|
||||
var getE= Funs.DB.T_d_employinfo.Where(x => x.ProjectId == projectId).Select(x => x.EmployID);
|
||||
if (getE.Count() > 0)
|
||||
{
|
||||
EmployID = getE.Max();
|
||||
}
|
||||
var getI = Funs.DB.T_d_facerecord.Where(x => x.ProjectId == projectId).Select(x => x.ID);
|
||||
if (getI.Count() > 0)
|
||||
{
|
||||
ID = getI.Max();
|
||||
}
|
||||
var getV = Funs.DB.T_d_validcardevent.Where(x => x.ProjectId == projectId).Select(x => x.ValidEventID);
|
||||
if (getV.Count() > 0)
|
||||
{
|
||||
ValidEventID = getV.Max();
|
||||
}
|
||||
return ("$" + DepartmentID.ToString()+"$"+ EmployID.ToString()+"$"+ID.ToString() + "$" + ValidEventID.ToString() + "$");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存部门信息
|
||||
/// <summary>
|
||||
/// 保存部门信息
|
||||
/// </summary>
|
||||
/// <param name="department">部门信息</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public Model.ResponeData SaveDepartment([FromBody] Model.t_d_departmentItem department)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
if (department != null)
|
||||
{
|
||||
var getDep = db.T_d_department.FirstOrDefault(x => x.DepartmentID == department.DepartmentID && x.ProjectId ==department.ProjectId);
|
||||
if (getDep == null)
|
||||
{
|
||||
Model.T_d_department newDep = new Model.T_d_department()
|
||||
{
|
||||
NewID = SQLHelper.GetNewID(),
|
||||
ProjectId = department.ProjectId,
|
||||
DepartmentID = department.DepartmentID,
|
||||
DepartmentName = department.DepartmentName,
|
||||
ParentID = department.ParentID,
|
||||
IsDel = department.IsDel,
|
||||
IsDown = department.IsDown,
|
||||
ParentDepartmentName = department.ParentDepartmentName,
|
||||
IsEnable = department.IsEnable,
|
||||
};
|
||||
db.T_d_department.InsertOnSubmit(newDep);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 2;
|
||||
responeData.message = "信息有误!";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存人员信息
|
||||
/// <summary>
|
||||
/// 保存人员信息
|
||||
/// </summary>
|
||||
/// <param name="employinfo">人员信息</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public Model.ResponeData SaveEmployinfo([FromBody] Model.t_d_employinfoItem employinfo)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
if (employinfo != null)
|
||||
{
|
||||
var getEm = db.T_d_employinfo.FirstOrDefault(x => x.EmployID == employinfo.EmployID && x.ProjectId ==employinfo.ProjectId);
|
||||
if (getEm == null)
|
||||
{
|
||||
Model.T_d_employinfo newEmploy = new Model.T_d_employinfo()
|
||||
{
|
||||
NewID = SQLHelper.GetNewID(),
|
||||
ProjectId = employinfo.ProjectId,
|
||||
EmployID = employinfo.EmployID,
|
||||
WxEmployID = employinfo.WxEmployID,
|
||||
EmployNO = employinfo.EmployNO,
|
||||
EmployName = employinfo.EmployName,
|
||||
CardNO = employinfo.CardNO,
|
||||
GroupID = employinfo.GroupID,
|
||||
IsAttend = employinfo.IsAttend,
|
||||
IsDoor = employinfo.IsDoor,
|
||||
BeginDateTime = employinfo.BeginDateTime,
|
||||
EndDateTime = employinfo.EndDateTime,
|
||||
InPassWord = employinfo.InPassWord,
|
||||
DepartmentName = employinfo.DepartmentName,
|
||||
Mailbox = employinfo.Mailbox,
|
||||
Mobilephone = employinfo.Mobilephone,
|
||||
WeiXinNO = employinfo.WeiXinNO,
|
||||
PostName = employinfo.PostName,
|
||||
Gender = employinfo.Gender,
|
||||
IsDown = employinfo.IsDown,
|
||||
IsWxDown = employinfo.IsWxDown,
|
||||
IDCardNo = employinfo.IDCardNo,
|
||||
PlayCardNumber = employinfo.PlayCardNumber,
|
||||
PlayCardSum = employinfo.PlayCardSum,
|
||||
UpdataCloud = employinfo.UpdataCloud,
|
||||
Birthday = employinfo.Birthday,
|
||||
Police = employinfo.Police,
|
||||
Nation = employinfo.Nation,
|
||||
Address = employinfo.Address,
|
||||
UpdateState = employinfo.UpdateState,
|
||||
UpdateDateTime = employinfo.UpdateDateTime,
|
||||
IsSubmarineBack = employinfo.IsSubmarineBack,
|
||||
OnSiteState = employinfo.OnSiteState,
|
||||
TimeNumber = employinfo.TimeNumber,
|
||||
CardTimeRecord = employinfo.CardTimeRecord,
|
||||
ReservedFieldsOne = employinfo.ReservedFieldsOne,
|
||||
ReservedFieldsTwo = employinfo.ReservedFieldsTwo,
|
||||
ReservedFieldsThree = employinfo.ReservedFieldsThree,
|
||||
ReservedFieldsFour = employinfo.ReservedFieldsFour,
|
||||
ReservedFieldsFive = employinfo.ReservedFieldsFive,
|
||||
};
|
||||
|
||||
#region 获取部门
|
||||
var getDep = Funs.DB.T_d_department.FirstOrDefault(x => x.ProjectId == newEmploy.ProjectId && x.DepartmentID == newEmploy.GroupID);
|
||||
if (getDep != null)
|
||||
{
|
||||
if (getDep.ParentID == 0)
|
||||
{
|
||||
newEmploy.InstallationId = getDep.DepartmentID;
|
||||
}
|
||||
else
|
||||
{
|
||||
var getDep0 =BLL.DoorServerService.GetSupDep(newEmploy.ProjectId, getDep.ParentID, 0);
|
||||
if (getDep0 != null)
|
||||
{
|
||||
newEmploy.UnitId = newEmploy.GroupID;
|
||||
newEmploy.InstallationId = getDep0.DepartmentID;
|
||||
var getUnit = BLL.DoorServerService.GetSupDep(newEmploy.ProjectId, getDep.DepartmentID, newEmploy.InstallationId ?? 0);
|
||||
if (getUnit != null)
|
||||
{
|
||||
newEmploy.UnitId = getUnit.DepartmentID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
db.T_d_employinfo.InsertOnSubmit(newEmploy);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 2;
|
||||
responeData.message = "信息有误!";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存人脸识别出入记录信息
|
||||
/// <summary>
|
||||
/// 保存出入记录信息
|
||||
/// </summary>
|
||||
/// <param name="facerecord">出入记录信息</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public Model.ResponeData SaveFacerecord([FromBody] Model.t_d_facerecordItem facerecord)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
if (facerecord != null)
|
||||
{
|
||||
var getFacerecord = db.T_d_facerecord.FirstOrDefault(x => x.ID == facerecord.ID && x.ProjectId == facerecord.ProjectId);
|
||||
if (getFacerecord == null)
|
||||
{
|
||||
Model.T_d_facerecord newFacerecord = new Model.T_d_facerecord()
|
||||
{
|
||||
NewID = SQLHelper.GetNewID(),
|
||||
ProjectId = facerecord.ProjectId,
|
||||
ID = facerecord.ID,
|
||||
EmployName = facerecord.EmployName,
|
||||
DepartmentID = facerecord.DepartmentID,
|
||||
DepartName = facerecord.DepartName,
|
||||
AreaID = facerecord.AreaID,
|
||||
AreaName = facerecord.AreaName,
|
||||
EmployNO = facerecord.EmployNO,
|
||||
CardID = facerecord.CardID,
|
||||
RoleID = facerecord.RoleID,
|
||||
DateTimeRecord = facerecord.DateTimeRecord,
|
||||
RecordDes = facerecord.RecordDes,
|
||||
FaceIP = facerecord.FaceIP,
|
||||
InOrOut = facerecord.InOrOut,
|
||||
Des1 = facerecord.Des1,
|
||||
Des2 = facerecord.Des2,
|
||||
Des3 = facerecord.Des3,
|
||||
Des4 = facerecord.Des4,
|
||||
};
|
||||
|
||||
db.T_d_facerecord.InsertOnSubmit(newFacerecord);
|
||||
db.SubmitChanges();
|
||||
if (facerecord.DateTimeRecord.HasValue)
|
||||
{
|
||||
Model.SitePerson_PersonInOut newInOut = new Model.SitePerson_PersonInOut
|
||||
{
|
||||
ProjectId = facerecord.ProjectId,
|
||||
IdentityCard = facerecord.EmployNO,
|
||||
IsIn = facerecord.InOrOut == "进门" ? true : false,
|
||||
ChangeTime = facerecord.DateTimeRecord.Value,
|
||||
InOutWay = Const.InOutWay_1,
|
||||
};
|
||||
|
||||
PersonInOutService.AddPersonInOut(newInOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 2;
|
||||
responeData.message = "信息有误!";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存刷卡出入记录信息
|
||||
/// <summary>
|
||||
/// 保存出入记录信息
|
||||
/// </summary>
|
||||
/// <param name="validcardevent">出入记录信息</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public Model.ResponeData SaveValidcardevent([FromBody] Model.t_d_validcardeventItem validcardevent)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
if (validcardevent != null)
|
||||
{
|
||||
var getValidcardevent = db.T_d_facerecord.FirstOrDefault(x => x.ID == validcardevent.ValidEventID && x.ProjectId == validcardevent.ProjectId);
|
||||
if (getValidcardevent == null)
|
||||
{
|
||||
Model.T_d_validcardevent newValidcardevent = new Model.T_d_validcardevent()
|
||||
{
|
||||
NewID = SQLHelper.GetNewID(),
|
||||
ProjectId = validcardevent.ProjectId,
|
||||
ValidEventID = validcardevent.ValidEventID,
|
||||
RecordDateTime = validcardevent.RecordDateTime,
|
||||
CardNO = validcardevent.CardNO,
|
||||
ConsumerID = validcardevent.ConsumerID,
|
||||
InOrOut = validcardevent.InOrOut,
|
||||
ControllerID = validcardevent.ControllerID,
|
||||
ReaderNO = validcardevent.ReaderNO,
|
||||
RecordFlashLoc = validcardevent.RecordFlashLoc,
|
||||
RecordAll = validcardevent.RecordAll,
|
||||
JPGPath = validcardevent.JPGPath,
|
||||
IsDown = validcardevent.IsDown,
|
||||
EquipmentSN = validcardevent.EquipmentSN,
|
||||
ConsumerNO = validcardevent.ConsumerNO,
|
||||
EmployNO = validcardevent.EmployNO,
|
||||
EmployName = validcardevent.EmployName,
|
||||
CardType = validcardevent.CardType,
|
||||
Card = validcardevent.Card,
|
||||
DepartmentID = validcardevent.DepartmentID,
|
||||
DepartmentName = validcardevent.DepartmentName,
|
||||
ControllerSN = validcardevent.ControllerSN,
|
||||
DoorID = validcardevent.DoorID,
|
||||
DoorName = validcardevent.DoorName,
|
||||
ReaderName = validcardevent.ReaderName,
|
||||
AreaID = validcardevent.AreaID,
|
||||
AreaName = validcardevent.AreaName,
|
||||
WorkType = validcardevent.WorkType,
|
||||
Positions = validcardevent.Positions,
|
||||
IDCardNo = validcardevent.IDCardNo,
|
||||
};
|
||||
|
||||
db.T_d_validcardevent.InsertOnSubmit(newValidcardevent);
|
||||
db.SubmitChanges();
|
||||
|
||||
if (validcardevent.RecordDateTime.HasValue)
|
||||
{
|
||||
Model.SitePerson_PersonInOut newInOut = new Model.SitePerson_PersonInOut
|
||||
{
|
||||
ProjectId = validcardevent.ProjectId,
|
||||
IdentityCard = validcardevent.EmployNO,
|
||||
IsIn = validcardevent.InOrOut == 1 ? true : false,
|
||||
ChangeTime = validcardevent.RecordDateTime.Value,
|
||||
InOutWay = Const.InOutWay_1,
|
||||
};
|
||||
|
||||
PersonInOutService.AddPersonInOut(newInOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 2;
|
||||
responeData.message = "信息有误!";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取门禁人员考勤统计
|
||||
/// <summary>
|
||||
/// 获取人员信息出入场记录
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData getInOutstatistics(string projectId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
string unitId = null;
|
||||
string postId = null;
|
||||
responeData.data = Funs.DB.spInOutManHoursReport(projectId, unitId, postId, startDate, endDate).ToList(); ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,502 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using BLL;
|
||||
using WebAPI.Filter;
|
||||
|
||||
namespace WebAPI.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class DoorServiceController : ApiController
|
||||
{
|
||||
#region 项目出入记录接口
|
||||
/// <summary>
|
||||
/// 保存出入记录信息
|
||||
/// </summary>
|
||||
/// <param name="records">出入记录信息</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public Model.ResponeData postPersonInOuts([FromBody] Model.attendanceItems records)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
if (records != null && records.records.Count() > 0)
|
||||
{
|
||||
List<Model.attendanceItem> attendanceItems = records.records;
|
||||
var getprojectCode = attendanceItems.FirstOrDefault(x => x.ProjectCode != null || x.ProjectId != null);
|
||||
if (getprojectCode != null)
|
||||
{
|
||||
string projectId = getprojectCode.ProjectId;
|
||||
if (string.IsNullOrEmpty(projectId))
|
||||
{
|
||||
var getProject = ProjectService.GetProjectByProjectCode(getprojectCode.ProjectCode);
|
||||
if (getProject != null)
|
||||
{
|
||||
projectId = getProject.ProjectId;
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(projectId))
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
int maxId = 0;
|
||||
var getmax = db.T_d_facerecord.Where(x => x.ProjectId == projectId && x.RoleID == "白名单").Select(x => x.ID);
|
||||
if (getmax.Count() > 0)
|
||||
{
|
||||
maxId = getmax.Max();
|
||||
}
|
||||
foreach (var item in attendanceItems)
|
||||
{
|
||||
maxId = maxId + 1;
|
||||
string name = string.Empty;
|
||||
string cardNo = string.Empty;
|
||||
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == item.idCardNumber);
|
||||
if (getPerson != null)
|
||||
{
|
||||
name = getPerson.PersonName;
|
||||
cardNo = getPerson.CardNo;
|
||||
}
|
||||
|
||||
Model.T_d_facerecord newFacerecord = new Model.T_d_facerecord()
|
||||
{
|
||||
NewID = SQLHelper.GetNewID(),
|
||||
ProjectId = projectId,
|
||||
ID = maxId,
|
||||
EmployName = name,
|
||||
EmployNO = item.idCardNumber,
|
||||
RoleID = "白名单",
|
||||
DateTimeRecord = Funs.GetNewDateTime(item.attendanceTime),
|
||||
RecordDes = "白名单:允许通行",
|
||||
InOrOut = (item.attendanceType == 1 ? "进门" : "出门"),
|
||||
};
|
||||
|
||||
db.T_d_facerecord.InsertOnSubmit(newFacerecord);
|
||||
db.SubmitChanges();
|
||||
///// 根据出入记录 写入考勤记录
|
||||
Model.t_d_facerecordItem facerecord = new Model.t_d_facerecordItem
|
||||
{
|
||||
ID = maxId,
|
||||
EmployName = name,
|
||||
IDCardNo = item.idCardNumber,
|
||||
EmployNO = item.idCardNumber,
|
||||
ProjectId = projectId,
|
||||
RoleID = "白名单",
|
||||
DateTimeRecord = Funs.GetNewDateTime(item.attendanceTime),
|
||||
RecordDes = "白名单:允许通行",
|
||||
InOrOut = (item.attendanceType == 1 ? "进门" : "出门"),
|
||||
};
|
||||
|
||||
if (facerecord.DateTimeRecord.HasValue)
|
||||
{
|
||||
int isIn = 0;
|
||||
if (facerecord.InOrOut == "进门")
|
||||
{
|
||||
isIn = 1;
|
||||
}
|
||||
APIPersonService.getPersonInOut(facerecord.ProjectId, facerecord.EmployNO, isIn, facerecord.DateTimeRecord.Value);
|
||||
}
|
||||
}
|
||||
responeData.message = "插入成功!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "项目号异常!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "项目号为空!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "数据为空!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 项目出入人员信息
|
||||
/// <summary>
|
||||
/// 保存人员信息
|
||||
/// </summary>
|
||||
/// <param name="person">人员信息</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public Model.ResponeData postPersons([FromBody] Model.PersonItem person)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
if (person != null)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getProject = ProjectService.GetProjectByProjectCode(person.ProjectCode);
|
||||
if (getProject != null)
|
||||
{
|
||||
var getUnit = UnitService.getUnitByCollCropCodeUnitName(person.CollCropCode, person.UnitName);
|
||||
if (getUnit != null)
|
||||
{
|
||||
Model.SitePerson_Person newPerson = new Model.SitePerson_Person
|
||||
{
|
||||
PersonId = SQLHelper.GetNewID(),
|
||||
ProjectId = getProject.ProjectId,
|
||||
UnitId = getUnit.UnitId,
|
||||
PersonName = person.PersonName,
|
||||
IdentityCard = person.IdentityCard,
|
||||
IdcardType = "SHENFEN_ZHENGJIAN",
|
||||
IdcardAddress = person.IdcardAddress,
|
||||
IdcardForever = "N",
|
||||
IdcardStartDate = Funs.GetNewDateTime(person.IdcardStartDate),
|
||||
IdcardEndDate = Funs.GetNewDateTime(person.IdcardEndDate),
|
||||
Sex = (person.Sex == "女" || person.Sex == "2") ? "2" : "1",
|
||||
Address = person.Address,
|
||||
OutResult = person.OutResult,
|
||||
Birthday = person.Birthday,
|
||||
Telephone = person.Telephone,
|
||||
IsUsed = (person.IsUsed == false ? false : true),
|
||||
InTime = Funs.GetNewDateTimeOrNow(person.InTime),
|
||||
Password = BLL.PersonService.GetPersonPassWord(person.IdentityCard),
|
||||
Isprint = "0",
|
||||
};
|
||||
if (!string.IsNullOrEmpty(person.TeamGroupName) && !string.IsNullOrEmpty(newPerson.UnitId))
|
||||
{
|
||||
var getTeamGroup = TeamGroupService.getTeamGroupByTeamGroupName(getProject.ProjectId, newPerson.UnitId, person.TeamGroupName);
|
||||
if (getTeamGroup != null)
|
||||
{
|
||||
newPerson.TeamGroupId = getTeamGroup.TeamGroupId;
|
||||
}
|
||||
else
|
||||
{
|
||||
Model.ProjectData_TeamGroup newTeamGroup = new Model.ProjectData_TeamGroup
|
||||
{
|
||||
TeamGroupId = SQLHelper.GetNewID(),
|
||||
ProjectId = getProject.ProjectId,
|
||||
UnitId = newPerson.UnitId,
|
||||
TeamGroupName = person.TeamGroupName,
|
||||
Remark = "来源:门禁对接数据",
|
||||
TeamTypeId = "CANJIAN_TEAM",
|
||||
EntryTime = System.DateTime.Now,
|
||||
RealNamePushTime = null,
|
||||
};
|
||||
db.ProjectData_TeamGroup.InsertOnSubmit(newTeamGroup);
|
||||
db.SubmitChanges();
|
||||
newPerson.TeamGroupId = newTeamGroup.TeamGroupId;
|
||||
}
|
||||
}
|
||||
var getWorkArea = UnitWorkService.GetUnitWorkByUnitWorkName(getProject.ProjectId, person.WorkAreaName);
|
||||
if (getWorkArea != null)
|
||||
{
|
||||
newPerson.WorkAreaId = getWorkArea.UnitWorkId;
|
||||
}
|
||||
var getWorkPost = WorkPostService.GetWorkPostByName(person.WorkPostName);
|
||||
if (getWorkPost != null)
|
||||
{
|
||||
newPerson.WorkPostId = getWorkPost.WorkPostId;
|
||||
}
|
||||
var getHsseMan = ProjectService.getHSSEManager(getProject.ProjectId);
|
||||
if (getHsseMan != null)
|
||||
{
|
||||
newPerson.AuditorId = getHsseMan.UserId;
|
||||
newPerson.AuditorDate = DateTime.Now;
|
||||
}
|
||||
newPerson.OutTime = Funs.GetNewDateTime(person.OutTime);
|
||||
if (person.headImage != null)
|
||||
{
|
||||
var image = Convert.FromBase64String(person.headImage);
|
||||
newPerson.HeadImage = image;
|
||||
string rootPath = ConfigurationManager.AppSettings["localRoot"];
|
||||
string path = "FileUpLoad/PersonBaseInfo/" + DateTime.Now.ToString("yyyy-MM") + "/";
|
||||
string fileUrl = (rootPath + path).Replace('/', '\\');
|
||||
string flieName = Funs.GetNewFileName() + "~" + person.PersonName + ".jpg";
|
||||
if (!Directory.Exists(fileUrl))
|
||||
{
|
||||
Directory.CreateDirectory(fileUrl);
|
||||
}
|
||||
newPerson.PhotoUrl = path + flieName;
|
||||
File.WriteAllBytes((fileUrl + flieName), image);
|
||||
//AttachFileService.Base64ToImage(person.headImage, path, person.PersonName);
|
||||
}
|
||||
|
||||
var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.ProjectId == getProject.ProjectId && e.IdentityCard == person.IdentityCard);
|
||||
if (getPerson == null)
|
||||
{
|
||||
PersonService.AddPerson(newPerson);
|
||||
responeData.message = "新增人员成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(person.OutTime))
|
||||
{
|
||||
var outTime = Funs.GetNewDateTimeOrNow(person.OutTime);
|
||||
PersonService.PersonOut(getPerson.PersonId, outTime);
|
||||
responeData.message = "更新出场时间";
|
||||
}
|
||||
else
|
||||
{
|
||||
getPerson.PersonName = newPerson.PersonName;
|
||||
getPerson.IdcardAddress = newPerson.IdcardAddress;
|
||||
getPerson.IdcardStartDate = newPerson.IdcardStartDate;
|
||||
getPerson.IdcardEndDate = newPerson.IdcardEndDate;
|
||||
getPerson.Sex = newPerson.Sex;
|
||||
getPerson.Address = newPerson.Address;
|
||||
getPerson.OutResult = newPerson.OutResult;
|
||||
getPerson.Birthday = newPerson.Birthday;
|
||||
getPerson.Telephone = newPerson.Telephone;
|
||||
getPerson.IsUsed = true;
|
||||
getPerson.InTime = newPerson.InTime;
|
||||
if (!string.IsNullOrEmpty(newPerson.TeamGroupId))
|
||||
{
|
||||
getPerson.TeamGroupId = newPerson.TeamGroupId;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(newPerson.WorkPostId))
|
||||
{
|
||||
getPerson.WorkPostId = newPerson.WorkPostId;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(newPerson.PhotoUrl))
|
||||
{
|
||||
getPerson.PhotoUrl = newPerson.PhotoUrl;
|
||||
}
|
||||
db.SubmitChanges();
|
||||
responeData.message = getPerson.PersonName+ ":信息更新成功!";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "单位:" + person.UnitName + "施工平台不存在!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "项目号:" + person.ProjectCode + "施工平台不存在!";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "数据为空!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取在岗人员 -照片不空
|
||||
/// <summary>
|
||||
/// 获取在岗人员
|
||||
/// </summary>
|
||||
/// <param name="projectCode"></param>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData getPersons(string projectCode)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getProject = Funs.DB.Base_Project.FirstOrDefault(e => e.ProjectCode == projectCode);
|
||||
if (getProject != null)
|
||||
{
|
||||
responeData.data = from x in Funs.DB.SitePerson_Person
|
||||
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
||||
join T in Funs.DB.ProjectData_TeamGroup on x.TeamGroupId equals T.TeamGroupId
|
||||
join w in Funs.DB.Base_WorkPost on x.WorkPostId equals w.WorkPostId
|
||||
where x.ProjectId == getProject.ProjectId && !x.ExchangeTime.HasValue
|
||||
&& (!x.OutTime.HasValue || x.OutTime > DateTime.Now)
|
||||
&& x.InTime.HasValue && x.InTime < DateTime.Now
|
||||
&& x.IsUsed == true
|
||||
&& x.PhotoUrl != null
|
||||
select new
|
||||
{
|
||||
x.PersonId,
|
||||
x.PersonName,
|
||||
x.CardNo,
|
||||
x.IdentityCard,
|
||||
x.UnitId,
|
||||
y.UnitCode,
|
||||
y.UnitName,
|
||||
y.ShortUnitName,
|
||||
T.TeamGroupName,
|
||||
x.Sex,
|
||||
w.WorkPostName,
|
||||
x.Telephone,
|
||||
x.Address,
|
||||
x.InTime,
|
||||
x.AuditorDate,
|
||||
x.ExchangeTime,
|
||||
x.ExchangeTime2,
|
||||
x.PhotoUrl,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "数据为空!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
ErrLogInfo.WriteLog(ex, "WX接口-获取人员下发门禁", "DoorServiceController.getPersons");
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 更新人员数据交换时间
|
||||
/// <summary>
|
||||
/// 更新人员数据交换时间
|
||||
/// </summary>
|
||||
/// <param name="projectCode"></param>
|
||||
/// <param name="idCard"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData getUpdatePersonExchangeTime(string projectCode, string idCard, string type)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getProject = db.Base_Project.FirstOrDefault(e => e.ProjectCode == projectCode);
|
||||
if (getProject != null)
|
||||
{
|
||||
var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.ProjectId == getProject.ProjectId && e.IdentityCard == idCard);
|
||||
if (getPerson != null && !string.IsNullOrEmpty(type))
|
||||
{
|
||||
if (type == "1")
|
||||
{
|
||||
getPerson.ExchangeTime2 = DateTime.Now;
|
||||
if (!getPerson.ExchangeTime.HasValue)
|
||||
{
|
||||
getPerson.ExchangeTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
getPerson.ExchangeTime = DateTime.Now;
|
||||
}
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
ErrLogInfo.WriteLog(ex, "WX接口-更新人员数据交换时间", "PersonController.getUpdatePersonExchangeTime");
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取离场人员
|
||||
/// <summary>
|
||||
/// 获取离场人员
|
||||
/// </summary>
|
||||
/// <param name="projectCode"></param>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData getOutWorkPersons(string projectCode)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getProject = db.Base_Project.FirstOrDefault(e => e.ProjectCode == projectCode);
|
||||
if (getProject != null)
|
||||
{
|
||||
responeData.data = (from x in db.SitePerson_Person
|
||||
where x.ProjectId == getProject.ProjectId
|
||||
&& x.OutTime.HasValue
|
||||
&& !x.ExchangeTime2.HasValue && x.ExchangeTime.HasValue
|
||||
select new
|
||||
{
|
||||
x.PersonId,
|
||||
x.PersonName,
|
||||
x.CardNo,
|
||||
x.IdentityCard,
|
||||
OutTime = x.OutTime == null ? DateTime.Now.AddYears(10) : x.OutTime,
|
||||
}).Take(200).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 插入人员出入场记录
|
||||
/// <summary>
|
||||
/// 获取人员出入场记录
|
||||
/// </summary>
|
||||
/// <param name="projectCode"></param>
|
||||
/// <param name="idCard"></param>
|
||||
/// <param name="isIn"></param>
|
||||
/// <param name="changeTime"></param>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData getPersonInOut(string projectCode, string idCard, int isIn, DateTime changeTime)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getProject = ProjectService.GetProjectByProjectCode(projectCode);
|
||||
if (getProject != null)
|
||||
{
|
||||
Model.SitePerson_PersonInOut newInOut = new Model.SitePerson_PersonInOut
|
||||
{
|
||||
ProjectId = getProject.ProjectId,
|
||||
IdentityCard = idCard,
|
||||
IsIn = isIn == 1 ? true : false,
|
||||
ChangeTime = changeTime,
|
||||
InOutWay = Const.InOutWay_1,
|
||||
};
|
||||
|
||||
PersonInOutService.AddPersonInOut(newInOut);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
ErrLogInfo.WriteLog(ex, "WX接口-插入人员出入场记录", "PersonController.getPersonInOut");
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -192,45 +192,89 @@ namespace WebAPI.Controllers
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getTestPlan = new Model.SGGLDB(Funs.ConnString).Training_TestPlan.FirstOrDefault(e => e.TestPlanId == testPlanId && e.States != "3" && e.TestStartTime <= DateTime.Now && e.TestEndTime >= DateTime.Now);
|
||||
if (getTestPlan != null)
|
||||
using (var db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var person = PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||
if (person != null )
|
||||
var getTestPlan = db.Training_TestPlan.FirstOrDefault(e => e.TestPlanId == testPlanId && e.States != "3" && e.TestStartTime <= DateTime.Now && e.TestEndTime >= DateTime.Now);
|
||||
if (getTestPlan != null)
|
||||
{
|
||||
//2-考试中;生成考试试卷
|
||||
if (getTestPlan.States == "2" )
|
||||
var user = db.Sys_User.FirstOrDefault(x=>x.UserId==personId);
|
||||
Model.SitePerson_Person person;
|
||||
if (user != null)
|
||||
{
|
||||
var testRecord = new Model.SGGLDB(Funs.ConnString).Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == person.PersonId && !x.TestEndTime.HasValue);
|
||||
if (testRecord != null)
|
||||
{
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord.TestRecordId, person);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
person = Funs.DB.SitePerson_Person.FirstOrDefault(e => (e.PersonId == personId || e.IdentityCard == user.IdentityCard) && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(person.UnitId) && (getTestPlan.WorkPostIds == null || getTestPlan.WorkPostIds.Contains(person.WorkPostId)))
|
||||
person = Funs.DB.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||
|
||||
}
|
||||
if (person != null || user != null)
|
||||
{
|
||||
//2-考试中;生成考试试卷
|
||||
if (getTestPlan.States == "2")
|
||||
{
|
||||
//0-待提交;1-已发布未考试 将人员添加进考试记录
|
||||
var testTRecord = new Model.SGGLDB(Funs.ConnString).Training_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == personId);
|
||||
if ((getTestPlan.States == "0" || getTestPlan.States == "1") && testTRecord == null && !string.IsNullOrEmpty(personId))
|
||||
var testRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == personId && !x.TestEndTime.HasValue);
|
||||
if (testRecord != null)
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord.TestRecordId, person,user);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
else if(person !=null)
|
||||
{
|
||||
var testRecord2 = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == person.PersonId && !x.TestEndTime.HasValue);
|
||||
if (testRecord2 != null)
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TestPlanId = getTestPlan.TestPlanId,
|
||||
TestManId = personId,
|
||||
};
|
||||
TestRecordService.AddTestRecord(newTestRecord);
|
||||
responeData.code = 3;
|
||||
responeData.message = "您已加入考试计划!";
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord2.TestRecordId, person, user);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (person!=null&&string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(person.UnitId) && (getTestPlan.WorkPostIds == null || getTestPlan.WorkPostIds.Contains(person.WorkPostId)))
|
||||
{
|
||||
//0-待提交;1-已发布未考试 将人员添加进考试记录
|
||||
var testTRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == person.PersonId);
|
||||
if ((getTestPlan.States == "0" || getTestPlan.States == "1") && testTRecord == null && !string.IsNullOrEmpty(personId))
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TestPlanId = getTestPlan.TestPlanId,
|
||||
TestManId = personId,
|
||||
};
|
||||
TestRecordService.AddTestRecord(newTestRecord);
|
||||
responeData.code = 3;
|
||||
responeData.message = "您已加入考试计划!";
|
||||
}
|
||||
}
|
||||
|
||||
if (user != null && string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(user.UnitId) && (getTestPlan.DepartIds == null || getTestPlan.DepartIds.Contains(user.DepartId)))
|
||||
{
|
||||
//0-待提交;1-已发布未考试 将人员添加进考试记录
|
||||
var testTRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == personId);
|
||||
if ((getTestPlan.States == "0" || getTestPlan.States == "1") && testTRecord == null && !string.IsNullOrEmpty(personId))
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TestPlanId = getTestPlan.TestPlanId,
|
||||
TestManId = personId,
|
||||
};
|
||||
TestRecordService.AddTestRecord(newTestRecord);
|
||||
responeData.code = 3;
|
||||
responeData.message = "您已加入考试计划!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (responeData.code == 1)
|
||||
|
||||
@@ -218,18 +218,34 @@ namespace WebAPI.Controllers
|
||||
/// <param name="strPass">0-未通过;1通过;空所有</param>
|
||||
/// <param name="pageIndex">页码</param>
|
||||
/// <returns>考试记录列表</returns>
|
||||
public Model.ResponeData getTrainingTestRecordListQuery(string projectId, string unitId, string workPostId, string strPass, int pageIndex)
|
||||
public Model.ResponeData getTrainingTestRecordListQuery(string projectId, string unitId, string workPostId, string departId, string strPass, int pageIndex)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectId(projectId, unitId, workPostId, strPass, string.Empty);
|
||||
int pageCount = getDataLists.Count;
|
||||
if (pageCount > 0 && pageIndex > 0)
|
||||
if (!string.IsNullOrEmpty(departId))
|
||||
{
|
||||
getDataLists = getDataLists.OrderByDescending(x => x.TestStartTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||||
var getDataLists = APITestRecordService.getTrainingTestRecordListByDepartId(unitId,departId,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 };
|
||||
}
|
||||
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)
|
||||
{
|
||||
@@ -251,26 +267,7 @@ namespace WebAPI.Controllers
|
||||
/// <param name="strParam">参数</param>
|
||||
/// <param name="pageIndex">页码</param>
|
||||
/// <returns>考试记录列表</returns>
|
||||
public Model.ResponeData getTrainingTestRecordListQuery(string projectId, string unitId, string workPostId, string strPass,string strParam, int pageIndex)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
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
|
||||
|
||||
#region 根据TestRecordItemId、selectedItem 考生答题
|
||||
@@ -284,25 +281,58 @@ namespace WebAPI.Controllers
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getItem = TestRecordItemService.GetTestRecordItemTestRecordItemId(testRecordItemId);
|
||||
if (getItem != null)
|
||||
if (!string.IsNullOrEmpty(testRecordItemId) && !string.IsNullOrEmpty(selectedItem))
|
||||
{
|
||||
//更新没有结束时间且超时的考试记录
|
||||
int closeCount = TestRecordService.UpdateTestEndTimeNull(getItem.TestRecordId);
|
||||
if (closeCount > 0)
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
responeData.code = 2;
|
||||
responeData.message = "本次考试已结束,系统自动交卷!";
|
||||
}
|
||||
else
|
||||
{
|
||||
APITestRecordService.getTestRecordItemAnswerBySelectedItem(getItem, selectedItem);
|
||||
var getTItem = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordItemId == testRecordItemId);
|
||||
if (getTItem != null)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "试题有问题!";
|
||||
responeData.message = "答题为空选项!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -325,36 +355,50 @@ namespace WebAPI.Controllers
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getTestRecord = Funs.DB.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
|
||||
if (getTestRecord != null)
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
string returnTestRecordId = string.Empty;
|
||||
////考试分数
|
||||
decimal getTestScores = APITestRecordService.getSubmitTestRecord(getTestRecord);
|
||||
////及格分数
|
||||
int getPassScores = SysConstSetService.getPassScore();
|
||||
if (getTestScores <= getPassScores)
|
||||
decimal getTestScores = 0;
|
||||
var getTestRecord = db.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
|
||||
if (getTestRecord != null)
|
||||
{
|
||||
int testCount = Funs.DB.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
|
||||
if (testCount < 2)
|
||||
if (getTestRecord.TestStartTime.HasValue)
|
||||
{
|
||||
////重新生成一条考试记录 以及考试试卷
|
||||
returnTestRecordId = APITestRecordService.getResitTestRecord(getTestRecord);
|
||||
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,您将进入补考。";
|
||||
getTestRecord.TestEndTime = DateTime.Now;
|
||||
var getRItem = db.Training_TestRecordItem.Where(x => x.TestRecordId == testRecordId);
|
||||
if (getRItem.Count() > 0)
|
||||
{
|
||||
getTestRecord.TestScores = getRItem.Sum(x => x.SubjectScore ?? 0);
|
||||
}
|
||||
db.SubmitChanges();
|
||||
getTestScores = getTestRecord.TestScores ?? 0;
|
||||
}
|
||||
|
||||
////考试分数
|
||||
int getPassScores = SysConstSetService.getPassScore();
|
||||
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() + "】,请再次参加培训后补考。";
|
||||
// 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)
|
||||
|
||||
@@ -345,21 +345,37 @@ namespace WebAPI.Controllers
|
||||
/// <param name="projectId">项目ID</param>
|
||||
/// <param name="unitIds">培训单位ID</param>
|
||||
/// <param name="workPostIds">培训岗位ID(可为空)</param>
|
||||
/// <param name="departIds">培训岗位ID(可为空)</param>
|
||||
/// <param name="trainTypeId">培训类型ID(可为空)</param>
|
||||
/// <param name="pageIndex">分页</param>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData getTrainingPersonListByTrainTypeId(string projectId, string unitIds, string workPostIds, string trainTypeId, int pageIndex)
|
||||
public Model.ResponeData getTrainingPersonListByTrainTypeId(string projectId, string unitIds, string workPostIds, string departIds, string trainTypeId, int pageIndex)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getDataList = APIPersonService.getTrainingPersonListByTrainTypeId(projectId, unitIds, workPostIds, trainTypeId).OrderBy(x => x.UnitName).ThenBy(x => x.ProjectName).ToList();
|
||||
int pageCount = getDataList.Count;
|
||||
if (pageCount > 0 && pageIndex > 0)
|
||||
if (string.IsNullOrEmpty(projectId))
|
||||
{
|
||||
getDataList = getDataList.OrderBy(u => u.UnitName).ThenBy(u => u.PersonName).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); ////200 ->Funs.PageSize
|
||||
var getDataList = APIPersonService.getTrainingPersonListByDepartAndTrainTypeId( unitIds, departIds, trainTypeId).OrderBy(x => x.UnitName).ThenBy(x => x.ProjectName).ToList();
|
||||
int pageCount = getDataList.Count;
|
||||
if (pageCount > 0 && pageIndex > 0)
|
||||
{
|
||||
getDataList = getDataList.OrderBy(u => u.UnitName).ThenBy(u => u.PersonName).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); ////200 ->Funs.PageSize
|
||||
}
|
||||
responeData.data = new { pageCount, getDataList };
|
||||
}
|
||||
responeData.data = new { pageCount, getDataList };
|
||||
else
|
||||
{
|
||||
var getDataList = APIPersonService.getTrainingPersonListByTrainTypeId(projectId, unitIds, workPostIds, departIds, trainTypeId).OrderBy(x => x.UnitName).ThenBy(x => x.ProjectName).ToList();
|
||||
|
||||
int pageCount = getDataList.Count;
|
||||
if (pageCount > 0 && pageIndex > 0)
|
||||
{
|
||||
getDataList = getDataList.OrderBy(u => u.UnitName).ThenBy(u => u.PersonName).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); ////200 ->Funs.PageSize
|
||||
}
|
||||
responeData.data = new { pageCount, getDataList };
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
||||
<publishUrl>E:\Package\中化成达\SGGLAPI</publishUrl>
|
||||
<publishUrl>D:\SGGLAPI</publishUrl>
|
||||
<DeleteExistingFiles>True</DeleteExistingFiles>
|
||||
<PrecompileBeforePublish>True</PrecompileBeforePublish>
|
||||
<EnableUpdateable>True</EnableUpdateable>
|
||||
|
||||
@@ -54,21 +54,61 @@
|
||||
<HintPath>bin\Apache.NMS.Fakes.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Aspose.Words">
|
||||
<HintPath>bin\Aspose.Words.dll</HintPath>
|
||||
<HintPath>..\..\..\..\五环施工平台\SGGL_CWCEC\SGGL\WebAPI\bin\Aspose.Words.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FineUIPro, Version=6.3.0.0, Culture=neutral, PublicKeyToken=9cbe753c029f291a" />
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>bin\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Pipelines.Sockets.Unofficial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42ea0a778e13fbe2, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Pipelines.Sockets.Unofficial.2.2.2\lib\net461\Pipelines.Sockets.Unofficial.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="StackExchange.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\StackExchange.Redis.2.6.70\lib\net461\StackExchange.Redis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<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>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data.Linq" />
|
||||
<Reference Include="System.Diagnostics.PerformanceCounter, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.PerformanceCounter.5.0.0\lib\net461\System.Diagnostics.PerformanceCounter.dll</HintPath>
|
||||
</Reference>
|
||||
<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.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>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<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>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</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.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.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Cors, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.Cors.5.2.7\lib\net45\System.Web.Cors.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -175,12 +215,15 @@
|
||||
<Compile Include="Areas\HelpPage\SampleGeneration\SampleDirection.cs" />
|
||||
<Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" />
|
||||
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
|
||||
<Compile Include="Common\ICache.cs" />
|
||||
<Compile Include="Common\Redis.cs" />
|
||||
<Compile Include="Controllers\BaseInfoController.cs" />
|
||||
<Compile Include="Controllers\CommonController.cs" />
|
||||
<Compile Include="Controllers\CQMS\InspectionManagementController.cs" />
|
||||
<Compile Include="Controllers\CQMS\WBSController.cs" />
|
||||
<Compile Include="Controllers\DoorProject\DoorServiceController.cs" />
|
||||
<Compile Include="Controllers\FaceController.cs" />
|
||||
<Compile Include="Controllers\DoorServerController.cs" />
|
||||
<Compile Include="Controllers\DoorProject\DoorServerController.cs" />
|
||||
<Compile Include="Controllers\HJGL\ElectrodeRecoveryController.cs" />
|
||||
<Compile Include="Controllers\HJGL\PersonEntranceController.cs" />
|
||||
<Compile Include="Controllers\HSSE\TrainTestRecordController.cs" />
|
||||
|
||||
Reference in New Issue
Block a user