using System; using System.Collections.Generic; using System.Configuration; using System.Threading.Tasks; using System.Web.Http; using System.Web.Http.Description; using SuperMap.RealEstate.ServiceModel; using ESCG = EShang.Common.GeneralMethod; using ESCM = EShang.Common.Model; using HZQR.Common; namespace OpenApi.Controllers.BigData { /// /// 大数据分析相关接口【卡口数据传输】 /// public class BigDataController : BaseController { /// /// 涉疫车辆推送 /// protected string WarningPlate = ConfigurationManager.AppSettings["WarningPlate"]; #region 添加实时卡口流水 /// /// 添加实时卡口流水 /// /// 卡口流水集合 /// [Route("BigData/AddBayonet")] [AcceptVerbs("POST")] [ResponseType(typeof(Models.JsonMsg))] public IHttpActionResult AddBayonet(List BayonetList) { try { //新增卡口流水表 ESCG.BAYONETHelper.AddBayonet(transaction, BayonetList); //开启异步线程 Task task = Task.Factory.StartNew(() => { Transaction _Transaction = new Transaction(); try { foreach (ESCM.BAYONETModel bayonetModel in BayonetList) { if (!string.IsNullOrWhiteSpace(bayonetModel.LICENSE_PLATE) && !string.IsNullOrWhiteSpace(WarningPlate) && bayonetModel.INOUT_TYPE == 1) { foreach (string Plate in WarningPlate.Split(',')) { if (bayonetModel.LICENSE_PLATE.StartsWith(Plate)) { Method.WeChatPush.WeChat_SendMessage(_Transaction, bayonetModel); break; } } } } } catch (Exception _Exception) { LogUtil.WriteLog(null, "消息推送错误:" + _Exception.Message, DateTime.Now.ToString("yyyyMMdd") + "_SafetyWarning"); } finally { _Transaction.Release(); _Transaction.Dispose(); } }); return Ok(Method.Common.ReturnJson(100, "添加成功")); } catch (Exception ex) { //事务回滚 transaction.Rollback(); LogUtil.WriteLog(null, "添加失败!失败原因:" + ex.Message, DateTime.Now.ToString("yyyyMMdd") + "_AddBayonet"); return Ok(Method.Common.ReturnJson(999, "添加失败" + ex.Message)); } } #endregion #region 添加断面流量数据 /// /// 添加断面流量数据 /// /// 断面流量数据集合 /// [Route("BigData/AddSectionFlow")] [AcceptVerbs("POST")] [ResponseType(typeof(Models.JsonMsg))] public IHttpActionResult AddSectionFlow(List SectionFlowList) { try { //新增卡口流水表 ESCG.SECTIONFLOWHelper.AddSectionFlow(transaction, SectionFlowList); return Ok(Method.Common.ReturnJson(100, "添加成功")); } catch (Exception ex) { //事务回滚 transaction.Rollback(); LogUtil.WriteLog(null, "添加失败!失败原因:" + ex.Message, DateTime.Now.ToString("yyyyMMdd") + "_AddSectionFlow"); return Ok(Method.Common.ReturnJson(999, "添加失败" + ex.Message)); } } #endregion } }