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.
522 lines
24 KiB
522 lines
24 KiB
using FangYar.BLL;
|
|
using FangYar.BLL.TBL;
|
|
using FangYar.Model.TBL;
|
|
using RoadFlow.Data.Model.WorkFlowExecute;
|
|
using RoadFlow.Platform;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Web;
|
|
using HardWareInteface.Common;
|
|
using System.Text;
|
|
using FangYar.Common;
|
|
|
|
namespace HardWareInteface.Handle
|
|
{
|
|
/// <summary>
|
|
/// SHZCarRecQueueHandler 的摘要说明
|
|
/// </summary>
|
|
public class SHZCarRecQueueHandler : IHttpHandler
|
|
{
|
|
FangYar.BLL.TBL_CARACCESS bll = new FangYar.BLL.TBL_CARACCESS();
|
|
FangYar.BLL.TBL_SYS_CAR car_bll = new FangYar.BLL.TBL_SYS_CAR();
|
|
/// <summary>
|
|
/// 正常消息队列
|
|
/// </summary>
|
|
public static System.Collections.Concurrent.ConcurrentQueue<string> infoMsgQueue = new System.Collections.Concurrent.ConcurrentQueue<string>();
|
|
|
|
/// <summary>
|
|
/// 控制消息处理线程
|
|
/// </summary>
|
|
private static System.Threading.Tasks.Task task;
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
context.Response.ContentType = "text/plain";
|
|
string returnStr = "";
|
|
|
|
|
|
string action = context.Request.Params["Action"] + "";
|
|
switch (action)
|
|
{
|
|
|
|
case "QueryQueue":
|
|
returnStr = "当前队列信息数:" + QueueDeviceUtil.infoMsgQueue.Count();
|
|
break;
|
|
default:
|
|
|
|
FangYar.Common.QueueDeviceUtil.AddDeviceDataToQueue(new FangYar.Common.QueueDataMo()
|
|
{
|
|
dataStr = QueueDeviceUtil.GetHttpContextDataStr(context),
|
|
dataFun = ReceiveAlarmInfoPlate
|
|
});
|
|
|
|
returnStr = "true";
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnStr);
|
|
}
|
|
/// <summary>
|
|
/// 数据处理
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
private string ReceiveAlarmInfoPlate(string data)
|
|
{
|
|
//WriteLog("进入!");
|
|
string response = string.Empty;
|
|
bool isadd = false;
|
|
if (data.Length != 0)
|
|
{
|
|
try
|
|
{
|
|
|
|
|
|
string[] sArray = data.Split('&');
|
|
|
|
FangYar.Model.TBL_CARACCESS model = new FangYar.Model.TBL_CARACCESS();
|
|
|
|
try
|
|
{
|
|
for (int i = 0; i < sArray.Length; i++)
|
|
{
|
|
string[] keyValue = sArray[i].Split('=');
|
|
PropertyInfo[] propertys = model.GetType().GetProperties();
|
|
Hashtable ht = new Hashtable();
|
|
if (keyValue[0].ToUpper() == "TYPE" && keyValue[1] != "online")
|
|
{
|
|
isadd = false;
|
|
break;
|
|
}
|
|
else if (keyValue[0].ToUpper() == "TYPE")
|
|
{
|
|
model.TYPE = keyValue[1];
|
|
}
|
|
else if (keyValue[0].ToUpper() == "PLATE_NUM")
|
|
{
|
|
model.CAR_PLATE = keyValue[1];
|
|
}
|
|
else if (keyValue[0].ToUpper() == "PLATE_COLOR")
|
|
{
|
|
model.COLOR = keyValue[1];
|
|
}
|
|
else if (keyValue[0].ToUpper() == "CAR_COLOR")
|
|
{
|
|
model.CAR_COLOR = keyValue[1];
|
|
}
|
|
else if (keyValue[0].ToUpper() == "CAR_LOGO")
|
|
{
|
|
model.CAR_LOGO = keyValue[1];
|
|
}
|
|
else if (keyValue[0].ToUpper() == "PARK_ID")
|
|
{
|
|
model.PARK_ID = keyValue[1];
|
|
}
|
|
else if (keyValue[0].ToUpper() == "CAM_ID")
|
|
{
|
|
model.CAMERA_ID = keyValue[1];
|
|
if (keyValue[1] == "18030005aa75")//进
|
|
{
|
|
model.INOROUT = "0";
|
|
}
|
|
else
|
|
{
|
|
model.INOROUT = "1";
|
|
}
|
|
}
|
|
else if (keyValue[0].ToUpper() == "START_TIME")
|
|
{
|
|
string str = keyValue[1];
|
|
long unixTimeStamp = long.Parse(str);
|
|
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
|
|
DateTime dt = startTime.AddSeconds(unixTimeStamp);
|
|
model.START_TIME = dt;
|
|
}
|
|
else if (keyValue[0].ToUpper() == "PICTURE")
|
|
{
|
|
StringBuilder str = new StringBuilder(keyValue[1].Trim());
|
|
str = str.Replace('-', '+')
|
|
.Replace('_', '/')
|
|
.Replace('.', '=')
|
|
.Replace("%", "")
|
|
.Replace(",", "")
|
|
.Replace(" ", "+");
|
|
string dummyData = str.ToString();
|
|
if (dummyData.Length % 4 > 0)
|
|
{
|
|
dummyData = dummyData.PadRight(dummyData.Length + 4 - dummyData.Length % 4, '=');
|
|
}
|
|
byte[] byteArray = Convert.FromBase64String(dummyData);
|
|
//model.PICTURE = byteArray;
|
|
model.EXTEND2 = GetFilePath(byteArray, "0");
|
|
}
|
|
else if (keyValue[0].ToUpper() == "CLOSEUP_PIC")
|
|
{
|
|
|
|
StringBuilder str = new StringBuilder(keyValue[1].Trim());
|
|
str = str.Replace('-', '+')
|
|
.Replace('_', '/')
|
|
.Replace('.', '=')
|
|
.Replace("%", "")
|
|
.Replace(",", "")
|
|
.Replace(" ", "+");
|
|
string dummyData = str.ToString();
|
|
if (dummyData.Length % 4 > 0)
|
|
{
|
|
dummyData = dummyData.PadRight(dummyData.Length + 4 - dummyData.Length % 4, '=');
|
|
}
|
|
byte[] byteArray = Convert.FromBase64String(dummyData);
|
|
//model.CLOSEUP_PIC = byteArray;
|
|
model.EXTEND3 = GetFilePath(byteArray, "1");
|
|
}
|
|
isadd = true;
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = "for循环异常:" + e, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error,path="" });
|
|
}
|
|
try
|
|
{
|
|
model.ID = Guid.NewGuid().ToString("N");
|
|
model.ORG_ID = "fbbb44bb458c4336a84e009df74c8598";
|
|
FangYar.Model.TBL_SYS_CAR car_model = car_bll.CarNumGetModel(model.ORG_ID, model.CAR_PLATE);
|
|
if (isadd)
|
|
{
|
|
if (car_model != null)
|
|
{
|
|
model.CLASS = car_model.CLASS;
|
|
if (model.CLASS == "0")
|
|
{
|
|
if (model.INOROUT == "1")
|
|
{
|
|
System.Data.DataTable dt = bll.getProccar_access_alarm(model.CAR_PLATE, model.ORG_ID, model.EXTEND2);
|
|
model.APPLY_ID = dt.Rows[0]["applyId"].ToString();
|
|
model.USERMAN = dt.Rows[0]["userman"].ToString();
|
|
|
|
if (model.APPLY_ID == "null" || model.APPLY_ID == null)
|
|
{
|
|
model.APPLY_ID = "";
|
|
}
|
|
if (model.USERMAN == "null" || model.USERMAN == null)
|
|
{
|
|
model.USERMAN = "";
|
|
}
|
|
isadd = bll.Add(model);
|
|
|
|
car_model.ISAPPLY = "2";
|
|
car_bll.EditCarIsapply(car_model);
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
if (model.APPLY_ID == "null" || model.APPLY_ID == null)
|
|
{
|
|
model.APPLY_ID = "";
|
|
}
|
|
if (model.USERMAN == "null" || model.USERMAN == null)
|
|
{
|
|
model.USERMAN = "";
|
|
}
|
|
isadd = bll.Add(model);
|
|
|
|
car_model.ISAPPLY = "0";
|
|
car_bll.EditCarIsapply(car_model);
|
|
|
|
//车辆自动还车节点补齐
|
|
ReutrnResult result = new ReutrnResult();
|
|
result = CarApplyAutoReturn(model.CAR_PLATE, model.ORG_ID, model.START_TIME.ToString());
|
|
if (result.result)
|
|
{
|
|
return result.result + ":" + result.msg;
|
|
}
|
|
else
|
|
{
|
|
return result.result + ":" + result.msg;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = "自动还车报错:" + e, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error });
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (car_model.CLASS == "2") //地方车修改车辆出入状态
|
|
{
|
|
//0进,1出
|
|
if (model.INOROUT == "1") //出营区
|
|
{
|
|
car_model.ISAPPLY = "2"; //离岗
|
|
car_bll.EditCarIsapply(car_model);
|
|
}
|
|
else //进营区
|
|
{
|
|
car_model.ISAPPLY = "0"; //在岗
|
|
car_bll.EditCarIsapply(car_model);
|
|
}
|
|
|
|
}
|
|
isadd = bll.Add(model);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
model.CLASS = "2";
|
|
isadd = bll.Add(model);
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = "处理自动还车逻辑异常:" + e, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = "自动还车报错:" + e, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error });
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = "队列内无数据:", msgType = FangYar.Common.EnumLogMsgTypeEnum.Error });
|
|
}
|
|
|
|
if (isadd == true)
|
|
{
|
|
FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = "数据处理成功:", msgType = FangYar.Common.EnumLogMsgTypeEnum.Info });
|
|
return "true";
|
|
}
|
|
else
|
|
{
|
|
FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = "数据处理数据库更新失败:" + data, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error });
|
|
return "false";
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// base转图片保存到服务器
|
|
/// </summary>
|
|
/// <param name="msg"></param>
|
|
private string GetFilePath(byte[] bytes, string strType)
|
|
{
|
|
try
|
|
{
|
|
//图片保存地址
|
|
string imgSavePath = System.Configuration.ConfigurationManager.AppSettings["imgSavePath"] + "";
|
|
string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString();//年月
|
|
string ImageFilePath = "/Attachment" + "/Car/shz/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString();
|
|
string fireUrl = imgSavePath + "Attachment" + "\\Car\\shz\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.Month.ToString();
|
|
if (System.IO.Directory.Exists(fireUrl) == false)//如果不存在就创建文件夹
|
|
{
|
|
System.IO.Directory.CreateDirectory(fireUrl);
|
|
}
|
|
string ImagePath, DbImagePath;
|
|
string str = System.DateTime.Now.ToString("yyyyHHddHHmmssfff");
|
|
if (strType == "0")//全景图
|
|
{
|
|
DbImagePath = ImageFilePath + "/" + str;//定义图片名称
|
|
ImagePath = fireUrl + "\\" + str;//定义图片名称
|
|
}
|
|
else
|
|
{
|
|
DbImagePath = ImageFilePath + "/Plate" + str;//定义图片名称
|
|
ImagePath = fireUrl + "\\Plate" + str;//定义图片名称
|
|
}
|
|
File.WriteAllBytes(ImagePath + ".png", bytes); //保存图片到服务器,然后获取路径
|
|
return DbImagePath + ".png";//获取保存后的路径
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//WriteLog("图片保存:" + e.Message);
|
|
FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = "图片保存异常:" + e, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error });
|
|
return "";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ReutrnResult
|
|
{
|
|
public bool result { get; set; }
|
|
|
|
public string msg { get; set; }
|
|
}
|
|
|
|
#region 自动还车
|
|
/// <summary>
|
|
/// 车辆通过道闸识别车牌后自动还车
|
|
/// </summary>
|
|
/// <param name="license">车牌号</param>
|
|
/// <returns>具体操作信息</returns>
|
|
public ReutrnResult CarApplyAutoReturn(string license, string orgId, string returnDate)
|
|
{
|
|
TBL_SYS_CARAPPLY carApplyBLL = new TBL_SYS_CARAPPLY();
|
|
ReutrnResult result = new ReutrnResult();
|
|
if (!String.IsNullOrWhiteSpace(license))
|
|
{
|
|
string where = string.Format(@" 1=1 and CARNUM='{0}' and state=1
|
|
and (extendcode2 =1 or extendcode2 is null)
|
|
and ( TO_DATE ('{1}', 'yyyy-mm-dd hh24:mi:ss') between carapply.STARTTIME and carapply.FINISHTIME)
|
|
order by carapply.finishtime desc,task.sort desc", license, returnDate);
|
|
var carAppyTb = carApplyBLL.GetCarApplyAndTaskListByLicense(where).Tables[0];
|
|
Hashtable hashtable = new Hashtable();
|
|
for (int i = 0; i < carAppyTb.Rows.Count; i++)
|
|
{
|
|
string instanceId = carAppyTb.Rows[i]["taskinstanceid"].ToString();
|
|
if (!hashtable.Contains(instanceId))
|
|
{
|
|
hashtable.Add(instanceId, i);
|
|
}
|
|
|
|
}
|
|
|
|
if (hashtable.Count > 0)
|
|
{
|
|
SysUsersBLL sysUsersBLL = new SysUsersBLL();
|
|
string userId = System.Configuration.ConfigurationManager.AppSettings["AutoReturnCarAccount"];
|
|
TBL_SYS_USERS_Model userInfoModel = sysUsersBLL.GetModelByUID(userId);
|
|
var usersList = new List<TBL_SYS_USERS_Model>();
|
|
usersList.Add(userInfoModel);
|
|
|
|
TBL_SYS_USERS_Model senderUserModel = new TBL_SYS_USERS_Model()
|
|
{
|
|
USERS_UID = userInfoModel.USERS_UID,
|
|
USERS_PWD = userInfoModel.USERS_PWD,
|
|
USERS_WEEK = userInfoModel.USERS_WEEK,
|
|
USERS_TIME = userInfoModel.USERS_TIME,
|
|
USERS_STATE = userInfoModel.USERS_STATE,
|
|
USERS_EMAIL = userInfoModel.USERS_EMAIL,
|
|
USERS_MOBILE = userInfoModel.USERS_MOBILE,
|
|
ORG_ID = orgId,
|
|
EMP_ID = userInfoModel.EMP_ID,
|
|
IS_THIS = userInfoModel.IS_THIS,
|
|
IS_SUPER = userInfoModel.IS_SUPER
|
|
|
|
};
|
|
|
|
foreach (DictionaryEntry item in hashtable)
|
|
{
|
|
var index = int.Parse(item.Value.ToString());
|
|
senderUserModel.USERS_NAME = carAppyTb.Rows[index]["taskreceivename"].ToString();
|
|
result = ExecuteFlowStep(carAppyTb, usersList, senderUserModel, index, returnDate, license);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result.result = false;
|
|
result.msg = "查询不到该车的申请记录";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result.result = false;
|
|
result.msg = "车牌号不能为空";
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 自动补齐后续还车节点
|
|
/// </summary>
|
|
/// <param name="dataTable">流程节点数据</param>
|
|
/// <param name="usersList">节点处理人信息</param>
|
|
/// <param name="users">自动处理信息</param>
|
|
/// <param name="dataIndex">数据索引</param>
|
|
/// <returns></returns>
|
|
public ReutrnResult ExecuteFlowStep(DataTable dataTable, List<TBL_SYS_USERS_Model> usersList, TBL_SYS_USERS_Model users, int dataIndex, string returnDate, string license)
|
|
{
|
|
ReutrnResult result = new ReutrnResult();
|
|
Execute executeModel = new Execute();
|
|
WorkFlowTask workFlowTask = new WorkFlowTask();
|
|
|
|
WorkFlow flow = new WorkFlow();
|
|
try
|
|
{
|
|
var nextStep = flow.GetNextSteps(dataTable.Rows[dataIndex]["taskflowid"].ToString().ToGuid(), dataTable.Rows[dataIndex]["taskstepid"].ToString().ToGuid());
|
|
foreach (var step in nextStep)
|
|
{
|
|
executeModel.Steps.Add(step.ID, usersList);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
result.result = false;
|
|
result.msg = "查询下一处理节点时报错";
|
|
//WriteLogTask.LogQueueFun("查询下一处理节点时报错" + e.StackTrace.ToString(), path);
|
|
//WriteLog("查询下一处理节点时报错");
|
|
}
|
|
|
|
executeModel.ExecuteType = EnumType.ExecuteType.Submit;
|
|
executeModel.Comment = "自动还车";
|
|
executeModel.FlowID = dataTable.Rows[dataIndex]["taskflowid"].ToString().ToGuid();
|
|
executeModel.GroupID = dataTable.Rows[dataIndex]["taskgroupid"].ToString().ToGuid();
|
|
executeModel.InstanceID = dataTable.Rows[dataIndex]["taskinstanceid"].ToString();
|
|
executeModel.IsSign = false;
|
|
executeModel.Note = "车辆通过道闸进入营区,已完成自动还车";
|
|
executeModel.Sender = users;
|
|
executeModel.StepID = dataTable.Rows[dataIndex]["taskstepid"].ToString().ToGuid();
|
|
executeModel.TaskID = dataTable.Rows[dataIndex]["TaskId"].ToString().ToGuid();
|
|
try
|
|
{
|
|
var flowExecuteResult = workFlowTask.Execute(executeModel);
|
|
var nextTask = flowExecuteResult.NextTasks;
|
|
if (nextTask.Count() > 0)
|
|
{
|
|
//ExecuteFlowStep(dataTable, usersList, users, dataIndex);
|
|
result = CarApplyAutoReturn(license, users.ORG_ID, returnDate);
|
|
}
|
|
else
|
|
{
|
|
TBL_SYS_CARAPPLY carApply = new TBL_SYS_CARAPPLY();
|
|
try
|
|
{
|
|
var boolResult = carApply.EditReturnState(dataTable.Rows[dataIndex]["ID"].ToString(), "2");
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//WriteLogTask.LogQueueFun(String.Format("自动还车后修改申请表状态失败:ID:{0},报错信息:{1}", dataTable.Rows[dataIndex]["ID"].ToString(), e.InnerException.ToString()), path);
|
|
//WriteLog(String.Format("自动还车后修改申请表状态失败:ID:{0},报错信息:{1}", dataTable.Rows[dataIndex]["ID"].ToString(), e.InnerException.ToString()));
|
|
|
|
}
|
|
result.result = true;
|
|
result.msg = "已完成自动还车";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
result.result = false;
|
|
result.msg = "执行自动还车节点时报错";
|
|
//WriteLogTask.LogQueueFun("执行自动还车节点时报错" + e.StackTrace.ToString(), path);
|
|
//WriteLog("执行自动还车节点时报错");
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|