You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
7.1 KiB
156 lines
7.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
public class EPModel
|
|
{
|
|
public string Id { set; get; }
|
|
|
|
public string Uid { set; get; }
|
|
}
|
|
/// <summary>
|
|
/// ZYCameraHandler 的摘要说明
|
|
/// </summary>
|
|
public class FacerecTask : IHttpHandler
|
|
{
|
|
|
|
private FangYar.BLL.TBL_CAMERA bll = new FangYar.BLL.TBL_CAMERA();
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "人脸出操数据操作请求", "");
|
|
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
switch (action)
|
|
{
|
|
// 点名统计页数据获取
|
|
case "Exercise":
|
|
returnstr = Exercise(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 执行出操任务
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string Exercise(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
//string org_id = "021933cc9b11441c920a431eeffe60c2";
|
|
string org_id = context.Request.Params["org_id"]; //地区顶级机构ID
|
|
if (string.IsNullOrEmpty(org_id))
|
|
{
|
|
return "{\"code\":-1,\"msg\":\"传输机构ID为空!\",\"count\":0,\"data\":[]}";
|
|
}
|
|
try
|
|
{
|
|
FangYar.BLL.FIRE.FIRE_ORG orgbll = new BLL.FIRE.FIRE_ORG();
|
|
FangYar.BLL.TBL_CAMERA cambll = new BLL.TBL_CAMERA();
|
|
FangYar.BLL.OA.OA_EXERCISE_TASK etbll = new BLL.OA.OA_EXERCISE_TASK();
|
|
FangYar.BLL.OA.OA_EXERCISE_RECORD erbll = new BLL.OA.OA_EXERCISE_RECORD();
|
|
FangYar.BLL.OA.OA_FACERECOGNITION facebll = new BLL.OA.OA_FACERECOGNITION();
|
|
|
|
//获取下级所有单位
|
|
DataTable dtorg = orgbll.GetList(" org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + org_id + "') cids ) s where find_in_set(org_id,cids)) and type = '0'").Tables[0];
|
|
for (int n = 0; n < dtorg.Rows.Count; n++)
|
|
{
|
|
//获取营区中具有出操功能的摄像头
|
|
DataTable dtcam = cambll.GetList(" instr(C_FUN,'0')>0 and ORG_ID='" + dtorg.Rows[n]["ORG_ID"].ToString() + "'").Tables[0];
|
|
if (dtcam.Rows.Count > 0)
|
|
{
|
|
string cams = "";
|
|
for (int m = 0; m < dtcam.Rows.Count; m++)
|
|
{
|
|
if (m == 0)
|
|
{
|
|
cams += "'" + dtcam.Rows[m]["EXTEND3"].ToString() + "'";
|
|
}
|
|
else
|
|
{
|
|
cams += " ,'" + dtcam.Rows[m]["EXTEND3"].ToString() + "'";
|
|
}
|
|
}
|
|
|
|
//获取今天的出操任务
|
|
DataTable dttask = etbll.GetList(" DATE_FORMAT( report_time,'%Y-%m-%d') = DATE_FORMAT(now(), '%Y-%m-%d') and ORG_ID='" + dtorg.Rows[n]["ORG_ID"].ToString() + "'").Tables[0];
|
|
|
|
//遍历出操任务
|
|
for (int i = 0; i < dttask.Rows.Count; i++)
|
|
{
|
|
string stime = dttask.Rows[i]["EXTEND2"].ToString();
|
|
string mtime = dttask.Rows[i]["EXTEND3"].ToString();
|
|
string etime = dttask.Rows[i]["EXTEND4"].ToString();
|
|
|
|
//获取未打卡人员信息
|
|
DataTable dtrecord = erbll.GetList("task_id = '" + dttask.Rows[i]["ID"].ToString() + "' and state = '0'").Tables[0];
|
|
List<EPModel> plist = new List<EPModel>(); //将任务中未打卡的人存入一个列表
|
|
for (int j = 0; j < dtrecord.Rows.Count; j++)
|
|
{
|
|
plist.Add(new EPModel() { Id = dtrecord.Rows[j]["ID"].ToString(), Uid = dtrecord.Rows[j]["USERS_UID"].ToString() });
|
|
}
|
|
|
|
//获取人脸识别
|
|
DataTable dtface = facebll.GetList(@"date_format('" + dttask.Rows[i]["EXTEND2"].ToString() + @"','%Y-%m-%d %H:%i:%s')<=datetime
|
|
and date_format('" + dttask.Rows[i]["EXTEND4"].ToString() + @"', '%Y-%m-%d %H:%i:%s') >= datetime and DEVICEIDENTIFY
|
|
in (" + cams + ") order by DATETIME asc ").Tables[0];
|
|
|
|
for (int k = 0; k < dtface.Rows.Count; k++)
|
|
{
|
|
string facetime = dtface.Rows[k]["DATETIME"].ToString().Replace("/", "-");
|
|
string facename = dtface.Rows[k]["NAME"].ToString();
|
|
string faceuid = dtface.Rows[k]["EMPUID"].ToString();
|
|
string faceid = dtface.Rows[k]["ID"].ToString();
|
|
string facepicurl = dtface.Rows[k]["PICURL"].ToString();
|
|
|
|
//判断列表中是否存在该人员
|
|
int listindex = plist.FindIndex(t => t.Uid == faceuid); //根据姓名匹配
|
|
if (listindex > -1)
|
|
{
|
|
EPModel epmodel = plist[listindex];
|
|
bool flag = erbll.UpdateFace(faceid, facepicurl, facetime, "1", epmodel.Id);
|
|
if (flag)
|
|
{
|
|
plist.Remove(epmodel);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"本次任务执行完毕!\",\"count\":0,\"data\":[]}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人脸出操数据操作请求", "执行出操任务查询异常:" + e);
|
|
}
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人脸出操数据操作请求", "执行出操任务");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|