/// <summary> /// 获取护林员离线 在线 出围 /// </summary> /// <returns></returns> public JsonResult showHLYLineInOrOut() { Message ms = null; string str = Request.Params["obj"]; string curUserOrg = SystemCls.getCurUserOrgNo(); //获取当前登录用户的机构编码 var dataResult = new List <T_IPSFR_USER_Model>(); //护林员结果 if (string.IsNullOrEmpty(str)) { ms = new Message(false, "护林员离在出线参数传参错误", ""); return(Json(ms)); } string hidstr = string.Empty; var sw = new T_IPSFR_USER_SW(); if (str == "0")//护林员在线 { hidstr = T_IPSFR_USERCls.GetHids(curUserOrg, "0"); } else if (str == "1")//护林员离线 { hidstr = T_IPSFR_USERCls.GetHids(curUserOrg, "1"); } else if (str == "2")//护林员出围 { hidstr = T_IPSFR_USERCls.GetHids(curUserOrg, "2"); } sw.HID = hidstr; if (!string.IsNullOrEmpty(hidstr)) { dataResult = T_IPSFR_USERCls.getListModel(sw).ToList(); } StringBuilder sb = new StringBuilder(); int i = 0; sb.AppendFormat("<div class=\"divTable\">"); sb.AppendFormat("<table cellpadding=\"0\" cellspacing=\"0\">"); sb.AppendFormat("<thead>"); sb.AppendFormat("<tr>"); sb.AppendFormat("<th>序号</th>"); sb.AppendFormat("<th>单位</th>"); sb.AppendFormat("<th>姓名</th>"); sb.AppendFormat("<th>电话</th>"); sb.AppendFormat("</tr>"); sb.AppendFormat("</thead>"); sb.AppendFormat("<tbody role=\"alert\" aria-live=\"polite\" aria-relevant=\"all\">"); if (dataResult.Any()) { foreach (var person in dataResult) { if (i % 2 == 0) { sb.AppendFormat("<tr>"); } else { sb.AppendFormat("<tr class='row1'>"); } sb.AppendFormat("<td class=\"center\">{0}</td>", ++i); sb.AppendFormat("<td class=\"center\">{0}</td>", person.ORGNAME); sb.AppendFormat("<td class=\"center\">{0}</td>", person.HNAME); sb.AppendFormat("<td class=\"center\">{0}</td>", person.PHONE); sb.AppendFormat("</tr>"); } } else { sb.AppendFormat("<td colspan=\"4\"><em>暂无信息</em></td>"); } sb.AppendFormat("</tbody>"); sb.AppendFormat("</table>"); sb.AppendFormat("</div>"); ms = new Message(true, sb.ToString(), ""); return(Json(ms)); }
/// <summary> /// 自动发送短信 /// </summary> /// <returns></returns> public JsonResult AutoSendMsg() { Message ms = null; var st = ConfigCls.getIsAutoSendFireLevelMsg(); //读取配置 if (st == "1") //自动 { var smsmodel = YJ_DCSMS_TMPCls.GetListModel(new YJ_DCSMS_TMP_SW { ISENABLE = "1" }); //获取短信模板 if (smsmodel.Any()) { int levelnum = 0; foreach (var sms in smsmodel) { var FireLevellist = YJ_DANGERCLASSCls.getListModelTop(new YJ_DANGERCLASS_SW() { }).Where(p => p.DANGERCLASS == sms.DANGERCLASS); //获取最新的火险等级 if (FireLevellist.Any()) { var _cityorg = ""; //市机构中间变量 var _contyorg = ""; //县机构中间变量 int i = 0; levelnum = FireLevellist.Count(); //当前火险等级个数 foreach (var level in FireLevellist) { var info = new YJ_DCSMS_SEND_SW(); info.opMethod = "Add"; info.SMSSENDUSERLIST = sms.SMSSENDUSERLIST; info.DCDATE = level.DCDATE; info.BYORGNO = level.BYORGNO; info.YJ_DCSMS_TMPID = sms.YJ_DCSMS_TMPID; //info.TMPCONTENT = sms.TMPCONTENT; #region 通讯录接收人员 if (!string.IsNullOrEmpty(info.SMSSENDUSERLIST)) { var arrperson = info.SMSSENDUSERLIST.Split(','); info.TMPCONTENT = sms.TMPCONTENT.Replace("[num]", levelnum.ToString());//短信内容replace if (!string.IsNullOrEmpty(info.TMPCONTENT)) { foreach (var p in arrperson) { var txlmodel = T_SYS_ADDREDDBOOKCls.getModel(new T_SYS_ADDREDDBOOK_SW { ADID = p }); //通讯录 if (txlmodel != null && !string.IsNullOrEmpty(txlmodel.PHONE)) { try { ////TODO Send Message //add redis //队列 var msg = txlmodel.PHONE.Trim() + "|" + info.TMPCONTENT; redisclient.EnqueueItemOnList("SendMsg", msg);//入队。 logs.Info("==入队列号码信息==" + msg); // client.SendMsg(info.TMPCONTENT, txlmodel.PHONE); Thread.Sleep(200); } catch (Exception ex) { logs.Error(ex.Message); } } } info.SMSSENDSTATUS = "1";//0 未发送 1 已发送 -1 发送失败 } } #endregion #region 发送值班员与护林员 if (string.IsNullOrEmpty(sms.SMSSENDUSERLIST))//接收人为空 发送值班员与护林员 { #region 值班员 与护林员 if (sms.SMSGROUPTYPE == "1") //值班员 { var cityorg = level.BYORGNO.Substring(0, 4) + "00000"; //市机构码 var contyorg = level.BYORGNO.Substring(0, 6) + "000"; //县机构码 if (i == 0) //初次 { _cityorg = cityorg; _contyorg = contyorg; } else { if (_cityorg == cityorg)//循环相同的市级单位 跳出循环 { continue; } if (_contyorg == contyorg)//循环相同的县级单位 跳出循环 { continue; } } info.TMPCONTENT = sms.TMPCONTENT.Replace("[cityconty]", level.TOPTOWNNAME).Replace("[num]", levelnum.ToString()); //短信内容replace string str = cityorg + "," + contyorg; var zbylist = OD_USERCls.GetOndutyUserid(level.DCDATE, str); //获取值班员useridlist if (zbylist.Any()) { var zbystr = ""; foreach (var zby in zbylist) { var m = T_SYSSEC_IPSUSERCls.getModel(new T_SYSSEC_IPSUSER_SW { USERID = zby.ToString() }); if (!string.IsNullOrEmpty(m.PHONE)) { if (zbylist.Count() == 1) { zbystr = zby; } else { zbystr += zby + ","; } try { ////TODO Send Message //add redis //队列 var msg = m.PHONE.Trim() + "|" + info.TMPCONTENT; redisclient.EnqueueItemOnList("SendMsg", msg);//入队。 logs.Info("==入队列号码信息==" + msg); //client.SendMsg(info.TMPCONTENT, m.PHONE); Thread.Sleep(200); } catch (Exception ex) { logs.Error(ex.Message); } } } info.SMSSENDUSERLIST = zbystr; //值班员人员 info.SMSSENDSTATUS = "1"; //0 未发送 1 已发送 -1 发送失败 // ms = YJ_DCSMS_SENDCls.Manager(info); } ++i; } else if (sms.SMSGROUPTYPE == "2") //护林员 { info.TMPCONTENT = sms.TMPCONTENT.Replace("[cityconty]", level.TOWNNAME); //短信内容replace var hlylist = T_IPSFR_USERCls.getListModel(new T_IPSFR_USER_SW { BYORGNO = info.BYORGNO }); //护林员 if (hlylist.Any()) { var hlystr = "";//护林员人员 逗号分隔 foreach (var hly in hlylist) { if (!string.IsNullOrEmpty(hly.PHONE)) { if (hlylist.Count() == 1) { hlystr = hly.HID; } else { hlystr += hly.HID + ","; } try { //TODO Send Message //add redis //队列 var msg = hly.PHONE.Trim() + "|" + info.TMPCONTENT; redisclient.EnqueueItemOnList("SendMsg", msg);//入队。 logs.Info("==入队列号码信息==" + msg); //client.SendMsg(info.TMPCONTENT, hly.PHONE); Thread.Sleep(200); } catch (Exception ex) { logs.Error(ex.Message); } } } info.SMSSENDUSERLIST = hlystr; //护林员人员 info.SMSSENDSTATUS = "1"; //0 未发送 1 已发送 -1 发送失败 //ms = YJ_DCSMS_SENDCls.Manager(info); } } #endregion } #endregion } } } } else { ms = new Message(true, "短信未设置模板!", ""); } } else { ms = new Message(true, "短信发送已设置为手动发送,请手动发送短信!", ""); } return(Json(ms)); }
/// <summary> /// 转换为护林员巡检线和责任区 /// </summary> /// <returns></returns> public JsonResult ConvertHlyLineArea() { Message msg = new Message(false, "转化失败!", ""); string cid = Request.Params["cid"]; //采集id string hid = Request.Params["hid"]; //护林员id string htype = Request.Params["htype"]; //护林员转换类型 0 表是线 1 表示面 var sw = new T_IPSCOL_COLLECT_SW(); sw.COLLECTID = cid; var list = T_IPSCOL_COLLECTCls.getDetailModelList(sw); if (list.Any()) { string pointstr = string.Empty; int j = 0; string str = string.Empty; foreach (var item in list) { if (htype == "1")//面 特殊处理 { if (j == 0) { str = item.LONGITUDE + "," + item.LATITUDE + "|"; } } //pointstr += item.ORILONGITUDE + "," + item.ORILATITUDE + ",,|"; pointstr += item.LONGITUDE + "," + item.LATITUDE + "|"; j++; } pointstr += str; var m = new T_IPSFR_ROUTERAIL_Model();//巡检线和责任区 m.HID = hid; m.longitLatitList = pointstr; m.longitLatitList = m.longitLatitList.Replace("|", ", , |"); m.longitLatitList = m.longitLatitList + ";"; m.opMethod = "AddBatch"; m.ROADTYPE = htype; var ms = T_IPSFR_ROUTERAILCls.Manager(m); if (ms.Success) { string jd = ""; string wd = ""; string line = ""; string polygon = ""; //入三维空间库 #region 责任线 if (htype == "0") { m.longitLatitList = m.longitLatitList.Substring(0, m.longitLatitList.LastIndexOf(";")); m.longitLatitList = m.longitLatitList.Replace(",,", ""); if (!string.IsNullOrEmpty(m.longitLatitList)) { var result = T_IPSFR_USERCls.getListModel(new T_IPSFR_USER_SW { HID = hid }).FirstOrDefault(); //获取护林员信息 var m1 = new TD_DUTYROUTE_Model(); //三维责任路线模型 m1.opMethod = m.opMethod; m1.NAME = result.HNAME; m1.OBJECTID = result.HID; m1.ORGNAME = result.ORGNAME; m1.TELEPHONE = result.PHONE; string[] arr = m.longitLatitList.Split('|'); for (int i = 0; i < arr.Length; i++) { if (!string.IsNullOrEmpty(arr[i])) { string[] brr = arr[i].Split(','); double[] drr = ClsPositionTrans.GpsTransform(double.Parse(brr[1]), double.Parse(brr[0]), ConfigCls.getSDELonLatTransform());//坐标系转换 wd = drr[0].ToString(); jd = drr[1].ToString(); } if (i == arr.Length - 1)//最后一条记录 { line += jd + " " + wd; } else { line += jd + " " + wd + ","; } } #region 中心点获取 if (arr.Length % 2 == 0) { string[] crr = arr[arr.Length / 2].Split(','); double[] drr = ClsPositionTrans.GpsTransform(double.Parse(crr[1]), double.Parse(crr[0]), ConfigCls.getSDELonLatTransform()); m1.DISPLAY_X = drr[1].ToString(); m1.DISPLAY_Y = drr[0].ToString(); } else { string[] crr = arr[(arr.Length + 1) / 2].Split(','); double[] drr = ClsPositionTrans.GpsTransform(double.Parse(crr[1]), double.Parse(crr[0]), ConfigCls.getSDELonLatTransform());//中心点偏移 m1.DISPLAY_X = drr[1].ToString(); m1.DISPLAY_Y = drr[0].ToString(); } #endregion m1.Shape = "geometry::STGeomFromText('LINESTRING(" + line + ")',4326).MakeValid()"; DC_DUTYROUTECls.Manager(m1); } } #endregion #region 责任面 else { m.longitLatitList = m.longitLatitList.Substring(0, m.longitLatitList.LastIndexOf(";")); m.longitLatitList = m.longitLatitList.Replace(",,", ""); if (!string.IsNullOrEmpty(m.longitLatitList)) { var result = T_IPSFR_USERCls.getListModel(new T_IPSFR_USER_SW { HID = hid }).FirstOrDefault(); //获取护林员信息 var m2 = new TD_DUTYAREA_Model(); //三维责任区模型 m2.opMethod = m.opMethod; m2.NAME = result.HNAME; m2.OBJECTID = result.HID; m2.ORGNAME = result.ORGNAME; m2.TELEPHONE = result.PHONE; string[] arr = m.longitLatitList.Split('|'); for (int i = 0; i < arr.Length; i++) { if (!string.IsNullOrEmpty(arr[i])) { string[] brr = arr[i].Split(','); double[] drr = ClsPositionTrans.GpsTransform(double.Parse(brr[1]), double.Parse(brr[0]), ConfigCls.getSDELonLatTransform());//坐标系转换 wd = drr[0].ToString(); jd = drr[1].ToString(); } if (i == arr.Length - 1)//最后一条记录 { polygon += jd + " " + wd; } else { polygon += jd + " " + wd + ","; } } #region 中心点获取 if (arr.Length % 2 == 0) { string[] crr = arr[arr.Length / 2].Split(','); double[] drr = ClsPositionTrans.GpsTransform(double.Parse(crr[1]), double.Parse(crr[0]), ConfigCls.getSDELonLatTransform()); m2.DISPLAY_X = drr[1].ToString(); m2.DISPLAY_Y = drr[0].ToString(); } else { string[] crr = arr[(arr.Length + 1) / 2].Split(','); double[] drr = ClsPositionTrans.GpsTransform(double.Parse(crr[1]), double.Parse(crr[0]), ConfigCls.getSDELonLatTransform());//中心点偏移 m2.DISPLAY_X = drr[1].ToString(); m2.DISPLAY_Y = drr[0].ToString(); } #endregion m2.Shape = "geometry::STGeomFromText('Polygon((" + polygon + "))',4326).MakeValid()"; DC_DUTYAREACls.Manager(m2); } } msg = new Message(true, "转换成功!", ""); #endregion } } return(Json(msg)); }
/// <summary> /// 手动发送短信 /// </summary> /// <returns></returns> public JsonResult SendMsg() { Message ms = new Message(false, "错误信息初始化!", ""); string SubjectPerson = Request.Params["SubjectPerson"]; var paraArry1 = SubjectPerson.Split('|');//获取主题+;+人员+;+短信内容| if (paraArry1.Length > 0) { foreach (var item in paraArry1) { if (string.IsNullOrEmpty(item)) { continue; } var subject = item.Split(';');//获取主题+;+人员+;+短信内容 var model = YJ_DCSMS_TMPCls.GetListModel(new YJ_DCSMS_TMP_SW { YJ_DCSMS_TMPID = subject[0], ISENABLE = "1" }).FirstOrDefault(); if (model != null && !string.IsNullOrEmpty(model.TMPCONTENT)) { var info = new YJ_DCSMS_SEND_SW(); info.opMethod = "Add"; //增加 info.YJ_DCSMS_TMPID = subject[0]; info.SMSSENDUSERLIST = subject[1]; //接收人员 info.TMPCONTENT = subject[2]; //获取界面的短信内容 info.DCDATE = DateTime.Now.ToString(); //火险等级时间 info.BYORGNO = ""; //所属机构 适用于值班员与护林员 int levelnum = 0; var FireLevellist = YJ_DANGERCLASSCls.getListModelTop(new YJ_DANGERCLASS_SW() { }).Where(p => p.DANGERCLASS == model.DANGERCLASS); //获取最新的火险等级 if (FireLevellist.Any()) { levelnum = FireLevellist.Count();//当前火险等级个数 #region 通讯录接收人员 if (!string.IsNullOrEmpty(info.SMSSENDUSERLIST)) { info.DCDATE = FireLevellist.FirstOrDefault().DCDATE; info.TMPCONTENT = subject[2].Replace("[num]", levelnum.ToString());//短信内容replace if (!string.IsNullOrEmpty(info.TMPCONTENT)) { var arrpersonlist = info.SMSSENDUSERLIST.Split(',').Where(p => p != "" && p != null); string arrperson = string.Join(",", arrpersonlist); string txlMobile = arrperson; //通讯录电话列表 string txlContent = ""; // 通讯录模板 #region 注释 // foreach (var p in arrperson) // { // var txlmodel = T_SYS_ADDREDDBOOKCls.getModel(new T_SYS_ADDREDDBOOK_SW { ADID = p });//通讯录 // if (txlmodel != null && !string.IsNullOrEmpty(txlmodel.PHONE)) // { ////TODO Send Message //add redis //队列 //try //{ // var msg = txlmodel.PHONE.Trim() + "|" + info.TMPCONTENT; // redisclient.EnqueueItemOnList("SendMsg", msg);//入队。 // logs.Info("==入队列号码信息==" + msg); // Thread.Sleep(100); // // client.SendMsg(info.TMPCONTENT, txlmodel.PHONE); // // Thread.Sleep(200); //} //catch (Exception ex) //{ // logs.Error(ex.Message); //} // txlMobile += txlmodel.PHONE.Trim() + ","; // } //} #endregion txlContent = info.TMPCONTENT; var mm = SmsCom.SendMsg(txlContent, txlMobile.TrimEnd(','));//发送短信 if (mm.Success) { ms.Msg = mm.Msg; ms.Success = mm.Success; ms.Url = ""; } //ms // var mm = Smsclient.SendMsg(txlContent, txlMobile); // ms = SmsMsgCom.SendMsg(txlContent, txlMobile);//发送短信 // info.SMSSENDSTATUS = "1";//0 未发送 1 已发送 -1 发送失败 // ms = YJ_DCSMS_SENDCls.Manager(info); } } #endregion #region 值班员 、护林员 if (string.IsNullOrEmpty(info.SMSSENDUSERLIST)) //值班员 、护林员 { var _cityorg = ""; //市机构中间变量 var _contyorg = ""; //县机构中间变量 int i = 0; if (model.SMSGROUPTYPE == "2" || model.SMSGROUPTYPE == "1") //护林员接收人员 或者 值班员接收人员 { foreach (var level in FireLevellist) { info.DCDATE = level.DCDATE; //火险等级时间 info.BYORGNO = level.BYORGNO; //火险等级所属机构 #region 护林员接收人员 if (model.SMSGROUPTYPE == "2") { info.TMPCONTENT = subject[2].Replace("[cityconty]", level.TOWNNAME);//短信内容replace var hlylist = T_IPSFR_USERCls.getListModel(new T_IPSFR_USER_SW { BYORGNO = level.BYORGNO }); //护林员 if (hlylist.Any()) { // var hlystr = "";//护林员人员 逗号分隔 string hlyMobile = ""; //护林员电话 string hlyContent = ""; //护林员模板 foreach (var hly in hlylist.MyDistinct(s => s.PHONE)) { if (!string.IsNullOrEmpty(hly.PHONE)) { hlyMobile += hly.PHONE.Trim() + ","; //if (hlylist.Count() == 1) //{ // hlystr = hly.HID; //} //else //{ // hlystr += hly.HID + ","; //} //try //{ // //TODO Send Message // //add redis // //队列 // var msg = hly.PHONE.Trim() + "|" + info.TMPCONTENT; // redisclient.EnqueueItemOnList("SendMsg", msg);//入队。 // logs.Info("==入队列号码信息==" + msg); // //client.SendMsg(info.TMPCONTENT, hly.PHONE); // Thread.Sleep(200); //} //catch (Exception ex) //{ // logs.Error(ex.Message); //} } } hlyContent = info.TMPCONTENT; var mm = SmsCom.SendMsg(hlyContent, hlyMobile.TrimEnd(','));//发送短信 if (mm.Success) { ms.Msg = mm.Msg; ms.Success = mm.Success; ms.Url = ""; } //info.SMSSENDUSERLIST = hlystr;//护林员人员 //info.SMSSENDSTATUS = "1";//0 未发送 1 已发送 -1 发送失败 // ms = YJ_DCSMS_SENDCls.Manager(info); } } #endregion #region 值班员接收人员 if (model.SMSGROUPTYPE == "1") { var cityorg = level.BYORGNO.Substring(0, 4) + "00000"; //市机构码 var contyorg = level.BYORGNO.Substring(0, 6) + "000"; //县机构码 if (i == 0) //初次 { _cityorg = cityorg; _contyorg = contyorg; } else { if (_cityorg == cityorg)//循环相同的市级单位 跳出循环 { continue; } if (_contyorg == contyorg)//循环相同的县级单位 跳出循环 { continue; } } info.TMPCONTENT = subject[2].Replace("[cityconty]", level.TOPTOWNNAME).Replace("[num]", levelnum.ToString()); //短信内容replace string str = cityorg + "," + contyorg; var zbylist = OD_USERCls.GetOndutyUserid(level.DCDATE, str); //获取值班员useridlist if (zbylist.Any()) { //var zbystr = ""; string zbyMobile = ""; //值班员电话 string zbyContent = info.TMPCONTENT; //值班员模板 foreach (var zby in zbylist) { var m = T_SYSSEC_IPSUSERCls.getModel(new T_SYSSEC_IPSUSER_SW { USERID = zby.ToString() }); if (!string.IsNullOrEmpty(m.PHONE)) { zbyMobile += m.PHONE.Trim() + ","; //if (zbylist.Count() == 1) //{ // zbystr = zby; //} //else //{ // zbystr += zby + ","; //} //try //{ // ////TODO Send Message // //add redis // //队列 // var msg = m.PHONE.Trim() + "|" + info.TMPCONTENT; // redisclient.EnqueueItemOnList("SendMsg", msg);//入队。 // logs.Info("==入队列号码信息==" + msg); // // client.SendMsg(info.TMPCONTENT, m.PHONE); // Thread.Sleep(200); //} //catch (Exception ex) //{ // logs.Error(ex.Message); //} } } var mm = SmsCom.SendMsg(zbyContent, zbyMobile.TrimEnd(','));//发送短信 if (mm.Success) { ms.Msg = mm.Msg; ms.Success = mm.Success; ms.Url = ""; } // info.SMSSENDUSERLIST = zbystr;//值班员人员 //info.SMSSENDSTATUS = "1";//0 未发送 1 已发送 -1 发送失败 //ms = YJ_DCSMS_SENDCls.Manager(info); } ++i; } #endregion } } } #endregion } else { ms = new Message(false, "当前火险等级未达到预警,无需发短信!", ""); } } else { ms = new Message(false, "没有短信模板,不发短信!", ""); } } } else { ms = new Message(false, "传递短信模板主题与人员id参数错误!", ""); } return(Json(ms)); }