/// <summary> /// 根据机构编码获取该机构下车辆数 /// </summary> /// <param name="dtCar"></param> /// <param name="orgNo"></param> /// <returns></returns> public static string GetCarCount(DataTable dtCar, string orgNo) { string count = "0"; StringBuilder sb = new StringBuilder(); sb.AppendFormat("("); if (PublicCls.OrgIsShi(orgNo)) { count = dtCar.Compute("count(BYORGNO)", "substring(BYORGNO,1,4)='" + orgNo.Substring(0, 4) + "'").ToString(); } else if (PublicCls.OrgIsXian(orgNo)) { count = dtCar.Compute("count(BYORGNO)", "substring(BYORGNO,1,6)='" + orgNo.Substring(0, 6) + "'").ToString(); } else if (PublicCls.OrgIsZhen(orgNo)) { count = dtCar.Compute("count(BYORGNO)", "substring(BYORGNO,1,9)='" + orgNo.Substring(0, 9) + "'").ToString(); } else if (PublicCls.OrgIsCun(orgNo)) { count = dtCar.Compute("count(BYORGNO)", "BYORGNO='" + orgNo + "'").ToString(); } sb.AppendFormat("{0}", count); sb.AppendFormat(")"); return(sb.ToString()); }
/// <summary> /// 护林员统计 /// </summary> /// <returns>参见HUReport_HUCount_Model</returns> public static IEnumerable <HUReport_HUCount_Model> getHUCountModel(T_IPSFR_USER_SW sw) { var result = new List <HUReport_HUCount_Model>(); T_SYS_ORGSW swOrg = new T_SYS_ORGSW(); swOrg.SYSFLAG = ConfigCls.getSystemFlag(); swOrg.TopORGNO = sw.TopORGNO; if (PublicCls.OrgIsShi(sw.TopORGNO)) { swOrg.GetContyORGNOByCity = sw.TopORGNO;//获取所有县 } if (PublicCls.OrgIsXian(sw.TopORGNO)) { swOrg.GetXZOrgNOByConty = sw.TopORGNO;//获取所有镇 } DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(swOrg); //DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { SYSFLAG = ConfigCls.getSystemFlag() }); DataTable dtHU = BaseDT.T_IPSFR_USER.getDT(new T_IPSFR_USER_SW { ISENABLE = "1" }); DataRow[] drOrg = dtOrg.Select("", "ORGNO");//取所有 if (1 == 1) { HUReport_HUCount_Model m = new HUReport_HUCount_Model(); m.ORGName = BaseDT.T_SYS_ORG.getName(sw.TopORGNO) + "合计"; m.ORGNo = ""; m.HUCount = getHUCountBySex(dtHU, sw.TopORGNO, ""); m.Sex0Count = getHUCountBySex(dtHU, sw.TopORGNO, "1"); m.Sex1Count = getHUCountBySex(dtHU, sw.TopORGNO, "0"); m.Onstate0Count = getHUCountByOnstate(dtHU, sw.TopORGNO, "1"); m.Onstate1Count = getHUCountByOnstate(dtHU, sw.TopORGNO, "2"); result.Add(m); } for (int i = 0; i < drOrg.Length; i++) { HUReport_HUCount_Model m = new HUReport_HUCount_Model(); string orgName = drOrg[i]["ORGNAME"].ToString(); m.ORGName = orgName; m.ORGNo = drOrg[i]["ORGNO"].ToString(); m.HUCount = getHUCountBySex(dtHU, drOrg[i]["ORGNO"].ToString(), ""); m.Sex0Count = getHUCountBySex(dtHU, drOrg[i]["ORGNO"].ToString(), "1"); m.Sex1Count = getHUCountBySex(dtHU, drOrg[i]["ORGNO"].ToString(), "0"); m.Onstate0Count = getHUCountByOnstate(dtHU, drOrg[i]["ORGNO"].ToString(), "1"); m.Onstate1Count = getHUCountByOnstate(dtHU, drOrg[i]["ORGNO"].ToString(), "2"); result.Add(m); } dtHU.Clear(); dtHU.Dispose(); dtOrg.Clear(); dtOrg.Dispose(); return(result); }
/// <summary> /// 获取组织机构渐进名称 /// </summary> /// <param name="topOrgNo">顶级单位编码</param> /// <param name="orgCode">当前单位编码</param> /// <returns>组织机构渐进名称</returns> public static string getOrgTDNameClass(string topOrgNo, string orgCode) { string str1 = "padding-left:0px;"; string str2 = "padding-left:20px;"; string str3 = "padding-left:40px;"; string str4 = "padding-left:60px;"; if (PublicCls.OrgIsShi(topOrgNo)) { str1 = "padding-left:0px;"; str2 = "padding-left:20px;"; str3 = "padding-left:40px;"; str4 = "padding-left:60px;"; } else if (PublicCls.OrgIsXian(topOrgNo)) { str1 = "padding-left:0px;"; str2 = "padding-left:0px;"; str3 = "padding-left:20px;"; str4 = "padding-left:40px;"; } else if (PublicCls.OrgIsZhen(topOrgNo)) { str1 = "padding-left:0px;"; str2 = "padding-left:0px;"; str3 = "padding-left:0px;"; str4 = "padding-left:20px;"; } else if (PublicCls.OrgIsCun(topOrgNo)) { str1 = "padding-left:0px;"; str2 = "padding-left:0px;"; str3 = "padding-left:0px;"; str4 = "padding-left:0px;"; } if (PublicCls.OrgIsShi(orgCode))//市 { return(str1); } else if (PublicCls.OrgIsXian(orgCode))//县 { return(str2); } else if (PublicCls.OrgIsZhen(orgCode)) { return(str3); } else { return(str4); } }
/// <summary> /// 获取组织机构渐进名称 /// </summary> /// <param name="topOrgNo">顶级单位编码</param> /// <param name="orgCode">当前单位编码</param> /// <param name="orgName">单位名称</param> /// <returns>格式化后的单位名称(缩进)</returns> public static string getOrgTDName1(string topOrgNo, string orgCode, string orgName) { string str2 = " "; string str3 = " "; string str4 = " "; if (PublicCls.OrgIsShi(topOrgNo)) { } else if (PublicCls.OrgIsXian(topOrgNo)) { str4 = str3; str3 = str2; str2 = ""; } else if (PublicCls.OrgIsZhen(topOrgNo)) { str4 = str3; str3 = ""; } else if (PublicCls.OrgIsCun(topOrgNo)) { str4 = ""; } if (PublicCls.OrgIsShi(orgCode))//市 { return(orgName); } else if (PublicCls.OrgIsXian(orgCode))//县 { return(str2 + orgName); } else if (PublicCls.OrgIsZhen(orgCode)) { return(str3 + orgName); } else { return(str4 + orgName); } }
/// <summary> /// 根据组织机构获取该行应用的样式名称 /// </summary> /// <param name="topOrgNo">顶级单位编码</param> /// <param name="orgCode">当前单位编码</param> /// <returns>样式名称</returns> public static string getOrgTrClass(string topOrgNo, string orgCode) { string str1 = "danger"; string str2 = "warning"; string str3 = ""; if (PublicCls.OrgIsShi(topOrgNo)) { str1 = "danger"; str2 = "warning"; str3 = ""; } else if (PublicCls.OrgIsXian(topOrgNo)) { str1 = ""; str2 = "danger"; str3 = "warning"; } else if (PublicCls.OrgIsZhen(topOrgNo)) { str1 = ""; str2 = ""; str3 = "danger"; } if (PublicCls.OrgIsShi(orgCode))//市 { return(str1); } else if (PublicCls.OrgIsXian(orgCode))//县 { return(str2); } else { return(str3); } }
/// <summary> /// 组织机构联系人TREE /// </summary> /// <param name="OrgNo">组织结构编码</param> /// <returns></returns> public static string GetOrgTree(string OrgNo) { JArray jObjects = new JArray(); string curUserOrg = SystemCls.getCurUserOrgNo();//获取当前登录用户的机构编码 if (string.IsNullOrEmpty(OrgNo) == false) { curUserOrg = OrgNo; } var dtOrg = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { TopORGNO = curUserOrg, SYSFLAG = ConfigCls.getSystemFlag() }); //获取当前登录用户有权限查看的单位 DataTable dtLink = BaseDT.T_SYS_ORG_LINK.getDT(new T_SYS_ORG_LINK_SW { }); DataTable dtVillagecommittee = BaseDT.T_SYS_ORG_CWH.getDT(new T_SYS_ORG_CWH_SW { }); //JObject root = new JObject // { // { "id", "1"+"|" + "1" }, // { "text", "组织机构成员" } // }; #region 市级用户 if (PublicCls.OrgIsShi(curUserOrg)) { DataRow[] drOrg = dtOrg.Select("", "ORGNO"); //JArray childArrayroot = new JArray(); JObject root1 = new JObject { { "id", drOrg[0]["ORGNO"].ToString() }, { "text", drOrg[0]["ORGNAME"].ToString() }, { "treeType", "1" }, { "flag", "" } }; //childArrayroot.Add(root1); //root.Add("children", childArrayroot); JArray childArray = new JArray(); DataRow[] drLink = dtLink.Select("BYORGNO = '" + curUserOrg + "'", ""); for (int i = 0; i < drLink.Length; i++) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("<font title={0}>", drLink[i]["PHONE"].ToString()); sb.AppendFormat("{0}[{1}] </font>", drLink[i]["NAME"].ToString(), drLink[i]["USERJOB"].ToString()); JObject roota = new JObject { { "id", drLink[i]["PHONE"].ToString() }, { "text", sb.ToString() }, { "flag", drLink[i]["NAME"].ToString() }, { "phone", drLink[i]["PHONE"].ToString() } }; childArray.Add(roota); } DataRow[] drOrgC = dtOrg.Select("SUBSTRING(ORGNO,1,4) = '" + curUserOrg.Substring(0, 4) + "' AND ORGNO<>'" + curUserOrg + "' and SUBSTRING(ORGNO,7,9)='000000000'", "");//获取所有县且〈〉市的 for (int i = 0; i < drOrgC.Length; i++) { JObject rootb = new JObject { { "id", drOrgC[i]["ORGNO"].ToString() },//ORGNO { "text", drOrgC[i]["ORGNAME"].ToString() }, { "flag", "" }, { "state", "closed" }, }; childArray.Add(rootb); } root1.Add("children", childArray); jObjects.Add(root1); } #endregion #region 县级用户 else if (PublicCls.OrgIsXian(curUserOrg)) { DataRow[] drOrg = dtOrg.Select("", "ORGNO"); //JArray childArrayroot = new JArray(); JObject root1 = new JObject { { "id", drOrg[0]["ORGNO"].ToString() }, { "text", drOrg[0]["ORGNAME"].ToString() }, { "flag", "" } }; //childArrayroot.Add(root1); //root.Add("children", childArrayroot); JArray jObjectsC = new JArray(); DataRow[] drLink = dtLink.Select("BYORGNO = '" + curUserOrg + "'", ""); for (int i = 0; i < drLink.Length; i++) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("<font title={0}>", drLink[i]["PHONE"].ToString()); sb.AppendFormat("{0}[{1}] </font>", drLink[i]["NAME"].ToString(), drLink[i]["USERJOB"].ToString()); JObject rootc = new JObject { { "id", drLink[i]["PHONE"].ToString() }, { "text", sb.ToString() }, { "flag", drLink[i]["NAME"].ToString() }, { "phone", drLink[i]["PHONE"].ToString() } }; jObjectsC.Add(rootc); if (string.IsNullOrEmpty(OrgNo) == false)//异步加载,不显示县名 { jObjects.Add(rootc); } } DataRow[] drOrgC = dtOrg.Select("SUBSTRING(ORGNO,1,6) = '" + curUserOrg.Substring(0, 6) + "' AND ORGNO<>'" + curUserOrg + "' and SUBSTRING(ORGNO,10,6)='000000'", ""); //获取所有镇且〈〉县的 for (int i = 0; i < drOrgC.Length; i++) { JObject rootd = new JObject { { "id", drOrgC[i]["ORGNO"].ToString() },//ORGNO { "text", drOrgC[i]["ORGNAME"].ToString() }, { "flag", "" }, { "state", "closed" }, }; jObjectsC.Add(rootd); if (string.IsNullOrEmpty(OrgNo) == false)//异步加载,不显示县名 { jObjects.Add(rootd); } } if (string.IsNullOrEmpty(OrgNo))//县级用户登录 { jObjects.Add(root1); root1.Add("children", jObjectsC); } } #endregion #region 乡镇级用户 else if (PublicCls.OrgIsZhen(curUserOrg)) { DataRow[] drOrg = dtOrg.Select("", "ORGNO"); //JArray childArrayroot = new JArray(); JObject root1 = new JObject { { "id", drOrg[0]["ORGNO"].ToString() }, { "text", drOrg[0]["ORGNAME"].ToString() }, { "flag", "" }, { "treeType", "1" }, }; //childArrayroot.Add(root1); //root.Add("children", childArrayroot); JArray childArray = new JArray(); DataRow[] drLink = dtLink.Select("BYORGNO = '" + curUserOrg + "'", ""); for (int i = 0; i < drLink.Length; i++) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("<font title={0}>", drLink[i]["PHONE"].ToString()); sb.AppendFormat("{0}[{1}] </font>", drLink[i]["NAME"].ToString(), drLink[i]["USERJOB"].ToString()); JObject rootf = new JObject { { "id", drLink[i]["PHONE"].ToString() }, { "text", sb.ToString() }, { "flag", drLink[i]["NAME"].ToString() }, { "phone", drLink[i]["PHONE"].ToString() } }; childArray.Add(rootf); if (string.IsNullOrEmpty(OrgNo) == false)//异步加载 { jObjects.Add(rootf); } } DataRow[] drVillagecommittee = dtVillagecommittee.Select("BYORGNO = '" + curUserOrg + "'", "");//获取乡下面的村委会 for (int i = 0; i < drVillagecommittee.Length; i++) { JObject rootg = new JObject { { "id", drVillagecommittee[i]["CWHID"].ToString() },//ORGNO { "text", drVillagecommittee[i]["CWHNAME"].ToString() }, { "state", "closed" } }; childArray.Add(rootg); if (string.IsNullOrEmpty(OrgNo) == false)//异步加载 { jObjects.Add(rootg); } } if (string.IsNullOrEmpty(OrgNo))//乡镇用户登录 { //jObjects.Add(root); root1.Add("children", childArray); } } else { JArray childArray = new JArray(); DataRow[] drLink = dtLink.Select("BYORGNO = '" + curUserOrg + "'", ""); for (int i = 0; i < drLink.Length; i++) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("<font title={0}>", drLink[i]["PHONE"].ToString()); if (string.IsNullOrEmpty(drLink[i]["UNITNAME"].ToString()) == false) { sb.AppendFormat("{0}[{1}][{2}] </font>", drLink[i]["NAME"].ToString(), drLink[i]["USERJOB"].ToString(), drLink[i]["UNITNAME"].ToString()); } else { sb.AppendFormat("{0}[{1}][{2}] </font>", drLink[i]["NAME"].ToString(), drLink[i]["USERJOB"].ToString(), "--"); } JObject rootf = new JObject { { "id", drLink[i]["PHONE"].ToString() }, { "text", sb.ToString() }, { "flag", drLink[i]["NAME"].ToString() }, { "phone", drLink[i]["PHONE"].ToString() } }; childArray.Add(rootf); if (string.IsNullOrEmpty(OrgNo) == false)//异步加载 { jObjects.Add(rootf); } } } #endregion dtOrg.Clear(); dtOrg.Dispose(); return(JsonConvert.SerializeObject(jObjects)); }
/// <summary> /// 考勤统计 Model /// </summary> /// <param name="sw">参见HUCheckINCount_SW</param> /// <returns>参见HUCheck_CheckInCount_Model</returns> public static IEnumerable <HUCheck_CheckInCount_Model> getCheckInModel(HUCheckINCount_SW sw) { var result = new List <HUCheck_CheckInCount_Model>(); if (string.IsNullOrEmpty(sw.DateBegin))//开始时间为空 { return(result); } if (string.IsNullOrEmpty(sw.DateEnd))//结束时间为空 { return(result); } if (string.IsNullOrEmpty(sw.ORGNO))//组织机构编码 { return(result); } DateTime dt1 = Convert.ToDateTime(sw.DateBegin); DateTime dt2 = Convert.ToDateTime(sw.DateEnd); int days = ClsStr.getDateDiff(sw.DateBegin, sw.DateEnd) + 1;//日期包含天数 //根据机构编码获取下属组织机构 注意:这个函数含本级及所有下级的 //DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { TopORGNO = sw.ORGNO }); DataTable dtHRRealData = BaseDT.T_IPS_REALDATATEMPORARY.getDTByOrgNoToDate(new PatrolRouteStat_SW { DateBegin = sw.DateBegin, DateEnd = sw.DateEnd, TopORGNO = sw.ORGNO }); DataTable dtHU = BaseDT.T_IPSFR_USER.getDTByOrgSum(new T_IPSFR_USER_SW { BYORGNO = sw.ORGNO, ISENABLE = "1" }); if (PublicCls.OrgIsZhen(sw.ORGNO) == false) //市、县处理 { //只获取该市下面的县 县下面的乡 T_SYS_ORGSW swOrg = new T_SYS_ORGSW(); swOrg.SYSFLAG = ConfigCls.getSystemFlag(); swOrg.TopORGNO = sw.ORGNO; if (PublicCls.OrgIsShi(sw.ORGNO)) { swOrg.GetContyORGNOByCity = sw.ORGNO;//获取所有县 } if (PublicCls.OrgIsXian(sw.ORGNO)) { swOrg.GetXZOrgNOByConty = sw.ORGNO;//获取所有镇 } DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(swOrg); DataRow[] drOrg = dtOrg.Select("", "ORGNO");//取所有 for (int i = 0; i < drOrg.Length; i++) { HUCheck_CheckInCount_Model m = new HUCheck_CheckInCount_Model(); m.ORGName = drOrg[i]["ORGNAME"].ToString(); m.ORGNo = drOrg[i]["ORGNO"].ToString(); string CHr = dtHU.Compute("sum(C)", "BYORGNO=" + m.ORGNo).ToString(); //计算该单位下总人数 CHr = (string.IsNullOrEmpty(CHr) ? "0" : CHr); m.HUCount = CHr; //考勤人数 string cList = ""; for (DateTime tm = dt1; tm <= dt2; tm = tm.AddDays(1)) { string tm1 = PublicClassLibrary.ClsSwitch.SwitDate(tm).ToString(); if (string.IsNullOrEmpty(cList) == false) { cList += ","; } string tmp = dtHRRealData.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "' and SBDATE='" + tm1 + "'").ToString(); //计算该日期下人数 cList += (string.IsNullOrEmpty(tmp) ? "0" : tmp); //各日期以逗号分隔 } m.DayCountList = cList; //日期考勤列表 if (CHr != "0") { CHr = (int.Parse(CHr) * days).ToString(); string Chr0 = dtHRRealData.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "'").ToString(); Chr0 = (string.IsNullOrEmpty(Chr0) ? "0" : Chr0);; // BaseDT.T_IPS_REALDATATEMPORARY.getCountByOrgNo(dtHRRealData, orgNo).ToString(); string Chr1 = ClsStr.getDiff(CHr, Chr0).ToString("F0"); Chr1 = (string.IsNullOrEmpty(Chr1) ? "0" : Chr1); string Chr2 = ClsStr.getPercent(Chr0, CHr).ToString("F0"); Chr2 = (string.IsNullOrEmpty(Chr2) ? "0" : Chr2); m.daysC = CHr; //总 m.daysOK = Chr0; //完成 m.daysPer = Chr2 + "%"; //完成率 } result.Add(m); } dtOrg.Clear(); dtOrg.Dispose(); } else//显示乡的,乡的列出各个护林员 { DataRow[] drOrg = dtHU.Select("", "");//取所有 for (int i = 0; i < drOrg.Length; i++) { HUCheck_CheckInCount_Model m = new HUCheck_CheckInCount_Model(); m.ORGName = drOrg[i]["hname"].ToString(); m.ORGNo = drOrg[i]["hid"].ToString(); string CHr = "1"; // dtHU.Compute("BYORGNO=" + m.ORGNo, "").ToString();//计算该单位下总人数 m.HUCount = (string.IsNullOrEmpty(CHr) ? "0" : CHr); //考勤人数 string cList = ""; for (DateTime tm = dt1; tm <= dt2; tm = tm.AddDays(1)) { if (string.IsNullOrEmpty(cList) == false) { cList += ","; } string tmp = dtHRRealData.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "' and SBDATE='" + PublicClassLibrary.ClsSwitch.SwitDate(tm).ToString() + "'").ToString(); //计算该日期下人数 cList += (string.IsNullOrEmpty(tmp) ? "0" : tmp); //各日期以逗号分隔 } m.DayCountList = cList; //日期考勤列表 if (CHr != "0") { CHr = (int.Parse(CHr) * days).ToString(); string Chr0 = dtHRRealData.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "'").ToString(); Chr0 = (string.IsNullOrEmpty(Chr0) ? "0" : Chr0);; // BaseDT.T_IPS_REALDATATEMPORARY.getCountByOrgNo(dtHRRealData, orgNo).ToString(); string Chr1 = ClsStr.getDiff(CHr, Chr0).ToString("F0"); Chr1 = (string.IsNullOrEmpty(Chr1) ? "0" : Chr1); string Chr2 = ClsStr.getPercent(Chr0, CHr).ToString("F0"); Chr2 = (string.IsNullOrEmpty(Chr2) ? "0" : Chr2); m.daysC = CHr; //总 m.daysOK = Chr0; //完成 m.daysPer = Chr2 + "%"; //完成率 } result.Add(m); } } dtHU.Clear(); dtHU.Dispose(); //根据机构编码获取所有护林员信息 // DataTable dtHU = BaseDT.T_IPSFR_USER.getDT(new T_IPSFR_USER_SW { BYORGNO = sw.ORGNO, ISENABLE = "1" }); dtHRRealData.Clear(); dtHRRealData.Dispose(); if (1 == 1) { HUCheck_CheckInCount_Model m = new HUCheck_CheckInCount_Model(); m.ORGName = "合计"; string HUCount = result.Sum(item => Convert.ToDecimal(item.HUCount)).ToString();//总数 string daysC = result.Sum(item => Convert.ToDecimal(item.daysC)).ToString(); string daysOK = result.Sum(item => Convert.ToDecimal(item.daysOK)).ToString(); HUCount = (string.IsNullOrEmpty(HUCount) ? "0" : HUCount); daysC = (string.IsNullOrEmpty(daysC) ? "0" : daysC); daysOK = (string.IsNullOrEmpty(daysOK) ? "0" : daysOK); //string PointCount0 = result.Sum(item => Convert.ToDecimal(item.PointCount0)).ToString(); m.HUCount = HUCount; m.daysC = daysC; //总天数 m.daysOK = daysOK; //已出勤 int[] arrI = new int[days]; foreach (var v in result) { string[] a = v.DayCountList.Split(',');//组合列表 for (int i = 0; i < days; i++) { if (string.IsNullOrEmpty(arrI[i].ToString())) { arrI[i] = 0; } arrI[i] += int.Parse(a[i]); } } string cList = ""; for (int i = 0; i < days; i++) { if (string.IsNullOrEmpty(cList) == false) { cList += ","; } cList += arrI[i]; } m.DayCountList = cList; //m.LineCount2 = ClsStr.getPercent(LineCount0, LineCount).ToString("F0") + "%"; //m.PointCount = PointCount; //m.PointCount0 = PointCount0; //m.PointCount1 = result.Sum(item => Convert.ToDecimal(item.PointCount1)).ToString(); m.daysPer = ClsStr.getPercent(m.daysOK, m.daysC).ToString("F0") + "%"; result.Insert(0, m); } return(result); }
/// <summary> ///异步获取json字符串(车辆) /// </summary> /// <param name="orgno">当前用户机构码</param> /// <param name="idorgno">选择机构码</param> /// <returns></returns> public static string GetJsonStrCar(string orgno, string idorgno) { DataTable dtCar = BaseDT.DC_CAR.getDT(new DC_CAR_SW()); JArray jObjects = new JArray(); if (string.IsNullOrEmpty(idorgno)) { List <T_SYS_ORGModel> orgList = T_SYS_ORGCls.getListModel(new T_SYS_ORGSW { ORGNO = orgno }).ToList(); //获取机构 if (orgList.Any()) { var bo = PublicCls.OrgIsShi(orgno); if (bo) { List <T_SYS_ORGModel> citylist = orgList.Where(p => p.ORGNO.EndsWith("00000")).ToList();//市级别 foreach (var city in citylist) { var root = getJobejctCar(dtCar, city); jObjects.Add(root); } } var bb = PublicCls.OrgIsXian(orgno); if (bb) { List <T_SYS_ORGModel> countylist = orgList.Where(p => p.ORGNO.EndsWith("000")).ToList();//县级别 foreach (var county in countylist) { var root = getJobejctCar(dtCar, county); jObjects.Add(root); } } var bx = PublicCls.OrgIsZhen(orgno); if (bx) { List <T_SYS_ORGModel> towerlist = orgList.Where(p => !p.ORGNO.EndsWith("000")).ToList();//乡镇级别 foreach (var tower in towerlist) { var root = getJobejctCar(dtCar, tower); jObjects.Add(root); } } } } else { List <T_SYS_ORGModel> orgList = T_SYS_ORGCls.getListModel(new T_SYS_ORGSW { TopORGNO = idorgno }).ToList(); //获取机构 var bo = PublicCls.OrgIsShi(idorgno); //如果选择市,则列出所有县 if (bo) { List <T_SYS_ORGModel> countylist = orgList.Where(p => p.ORGNO.EndsWith("000000000") && p.ORGNO != idorgno).ToList(); foreach (var county in countylist) { var root = getJobejctCar(dtCar, county); jObjects.Add(root); } List <DC_CAR_Model> citycarlist = DC_CARCls.getModelList(new DC_CAR_SW { BYORGNO = idorgno }).Where(p => p.BYORGNO == idorgno).ToList(); //市(车辆) if (citycarlist.Any()) { foreach (var car in citycarlist) { var obj = getLastJobjectCar(car); jObjects.Add(obj); } } } var bb = PublicCls.OrgIsXian(idorgno);//如果选择县,则列出所有乡镇 if (bb) { List <T_SYS_ORGModel> towerlist = orgList.Where(p => p.ORGNO.EndsWith("000000") && p.ORGNO != idorgno).ToList(); foreach (var tower in towerlist) { var root = getJobejctCar(dtCar, tower); jObjects.Add(root); } List <DC_CAR_Model> countycarlist = DC_CARCls.getModelList(new DC_CAR_SW { BYORGNO = idorgno }).Where(p => p.BYORGNO == idorgno).ToList(); //县(车辆) if (countycarlist.Any()) { foreach (var car in countycarlist) { var obj = getLastJobjectCar(car); jObjects.Add(obj); } } } var bx = PublicCls.OrgIsZhen(idorgno);//如果选择乡镇,则列出所有乡镇的车辆 if (bx) { List <DC_CAR_Model> towercarlist = DC_CARCls.getModelList(new DC_CAR_SW { BYORGNO = idorgno }).ToList(); //乡镇(车辆) if (towercarlist.Any()) { foreach (var car in towercarlist) { var obj = getLastJobjectCar(car); jObjects.Add(obj); } } } } return(JsonConvert.SerializeObject(jObjects)); }
/// <summary> /// 考勤统计 Model /// </summary> /// <param name="sw">参见HUCheckINCount_SW</param> /// <returns>参见HUCheck_CheckInCount_Model</returns>getOutRaiLCountModel public static IEnumerable <OutRaiLCount_Model> getOutRaiLCountModel(OutRaiLCount_SW sw) { var result = new List <OutRaiLCount_Model>(); if (string.IsNullOrEmpty(sw.DateBegin))//开始时间为空 { return(result); } if (string.IsNullOrEmpty(sw.DateEnd))//结束时间为空 { return(result); } if (string.IsNullOrEmpty(sw.TopORGNO))//组织机构编码 { return(result); } DateTime dt1 = Convert.ToDateTime(sw.DateBegin); DateTime dt2 = Convert.ToDateTime(sw.DateEnd); int days = ClsStr.getDateDiff(sw.DateBegin, sw.DateEnd) + 1;//日期包含天数 DataTable dt = BaseDT.T_IPSFR_ROUTERAIL_RAIL.getDTByOrgNoToDate(new OutRaiLCount_SW { DateBegin = sw.DateBegin, DateEnd = sw.DateEnd, TopORGNO = sw.TopORGNO }); DataTable dtHU = BaseDT.T_IPSFR_USER.getDTByOrgSum(new T_IPSFR_USER_SW { BYORGNO = sw.TopORGNO, ISENABLE = "1" }); if (PublicCls.OrgIsZhen(sw.TopORGNO) == false) //市、县处理 { //只获取该市下面的县 县下面的乡 T_SYS_ORGSW swOrg = new T_SYS_ORGSW(); swOrg.SYSFLAG = ConfigCls.getSystemFlag(); swOrg.TopORGNO = sw.TopORGNO; if (PublicCls.OrgIsShi(sw.TopORGNO)) { swOrg.GetContyORGNOByCity = sw.TopORGNO;//获取所有县 } if (PublicCls.OrgIsXian(sw.TopORGNO)) { swOrg.GetXZOrgNOByConty = sw.TopORGNO;//获取所有镇 } DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(swOrg); DataRow[] drOrg = dtOrg.Select("", "ORGNO");//取所有 for (int i = 0; i < drOrg.Length; i++) { OutRaiLCount_Model m = new OutRaiLCount_Model(); m.ORGName = drOrg[i]["ORGNAME"].ToString(); m.ORGNo = drOrg[i]["ORGNO"].ToString(); string CHr = dt.Compute("sum(C)", "BYORGNO=" + m.ORGNo).ToString();//计算该单位下总数 CHr = (string.IsNullOrEmpty(CHr) ? "0" : CHr); m.Count = CHr; string cList = ""; for (DateTime tm = dt1; tm <= dt2; tm = tm.AddDays(1)) { string tm1 = PublicClassLibrary.ClsSwitch.SwitDate(tm).ToString(); if (string.IsNullOrEmpty(cList) == false) { cList += ","; } string tmp = dt.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "' and SBDATE='" + tm1 + "'").ToString(); //计算该日期下数量 cList += (string.IsNullOrEmpty(tmp) ? "0" : tmp); //各日期以逗号分隔 } m.DayCountList = cList; //日期考勤列表 result.Add(m); } dtOrg.Clear(); dtOrg.Dispose(); } else//显示乡的,乡的列出各个护林员 { DataRow[] drOrg = dtHU.Select("", "");//取所有 for (int i = 0; i < drOrg.Length; i++) { OutRaiLCount_Model m = new OutRaiLCount_Model(); m.ORGName = drOrg[i]["hname"].ToString(); m.ORGNo = drOrg[i]["hid"].ToString(); string CHr = dt.Compute("sum(C)", "BYORGNO=" + m.ORGNo).ToString();//计算该单位下总数 CHr = (string.IsNullOrEmpty(CHr) ? "0" : CHr); m.Count = CHr; string cList = ""; for (DateTime tm = dt1; tm <= dt2; tm = tm.AddDays(1)) { if (string.IsNullOrEmpty(cList) == false) { cList += ","; } string tmp = dt.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "' and SBDATE='" + PublicClassLibrary.ClsSwitch.SwitDate(tm).ToString() + "'").ToString(); //计算该日期下人数 cList += (string.IsNullOrEmpty(tmp) ? "0" : tmp); //各日期以逗号分隔 } m.DayCountList = cList; //日期列表 result.Add(m); } } dtHU.Clear(); dtHU.Dispose(); dt.Clear(); dt.Dispose(); if (1 == 1) { OutRaiLCount_Model m = new OutRaiLCount_Model(); m.ORGName = "合计"; string CHr = result.Sum(item => Convert.ToDecimal(item.Count)).ToString();//总数//计算该单位下总数 CHr = (string.IsNullOrEmpty(CHr) ? "0" : CHr); m.Count = CHr; int[] arrI = new int[days]; foreach (var v in result) { string[] a = v.DayCountList.Split(',');//组合列表 for (int i = 0; i < days; i++) { if (string.IsNullOrEmpty(arrI[i].ToString())) { arrI[i] = 0; } arrI[i] += int.Parse(a[i]); } } string cList = ""; for (int i = 0; i < days; i++) { if (string.IsNullOrEmpty(cList) == false) { cList += ","; } cList += arrI[i]; } m.DayCountList = cList; result.Insert(0, m); } return(result); }
/// <summary> /// 查询怠工统计 /// </summary> /// <param name="sw">参见SabotageCount_SW</param> /// <returns>参见getSabotageCount_Model</returns> public static IEnumerable <getSabotageCount_Model> getSabotageCountModel(SabotageCount_SW sw) { var result = new List <getSabotageCount_Model>(); if (string.IsNullOrEmpty(sw.DateBegin))//开始时间为空 { return(result); } if (string.IsNullOrEmpty(sw.DateEnd))//结束时间为空 { return(result); } DateTime dt1 = Convert.ToDateTime(sw.DateBegin); DateTime dt2 = Convert.ToDateTime(sw.DateEnd); int days = ClsStr.getDateDiff(sw.DateBegin, sw.DateEnd) + 1;//日期包含天数 DataTable dtHU = new DataTable(); DataTable dt = BaseDT.T_IPS_REALDATATEMPORARY.getDTSabotageByOrgNo(sw); if (PublicCls.OrgIsShi(sw.TopORGNO)) { dtHU = BaseDT.T_IPSFR_USER.getDTShi(new T_IPSFR_USER_SW { }); } else if (PublicCls.OrgIsXian(sw.TopORGNO)) { dtHU = BaseDT.T_IPSFR_USER.getDTXain(new T_IPSFR_USER_SW { BYORGNO = sw.TopORGNO }); } else { dtHU = BaseDT.T_IPSFR_USER.getDT(new T_IPSFR_USER_SW { ISENABLE = "1", BYORGNO = sw.TopORGNO }); } if (PublicCls.OrgIsZhen(sw.TopORGNO)) { DataRow[] drOrg = dtHU.Select("", ""); for (int i = 0; i < drOrg.Length; i++) { getSabotageCount_Model m = new getSabotageCount_Model(); m.ORGName = drOrg[i]["HNAME"].ToString(); m.ORGNo = drOrg[i]["HID"].ToString(); string CHr = dt.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "'").ToString(); CHr = (string.IsNullOrEmpty(CHr) ? "0" : CHr); string cList = ""; for (DateTime tm = dt1; tm <= dt2; tm = tm.AddDays(1)) { string tm1 = PublicClassLibrary.ClsSwitch.SwitDate(tm).ToString(); if (string.IsNullOrEmpty(cList) == false) { cList += ","; } string tmp = dt.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "' and SBDATE='" + tm1 + "' and PatrolLenErro=1").ToString(); //计算该日期下人数 cList += (string.IsNullOrEmpty(tmp) ? "0" : tmp); //各日期以逗号分隔 } m.DayCountList = cList; //日期考勤列表 string Chr0 = dt.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "' and PatrolLenErro=0").ToString(); Chr0 = (string.IsNullOrEmpty(Chr0) ? "0" : Chr0); string Chr1 = ClsStr.getDiff(CHr, Chr0).ToString("F0"); string Chr2 = ClsStr.getPercent(Chr0, CHr).ToString("F0"); m.Count = CHr; //总 m.Count0 = Chr0; //完成 m.Count1 = Chr1; //未完成 m.CountPer = Chr2 + "%"; //完成率 result.Add(m); } dtHU.Clear(); dtHU.Dispose(); } else { T_SYS_ORGSW swOrg = new T_SYS_ORGSW(); swOrg.SYSFLAG = ConfigCls.getSystemFlag(); swOrg.TopORGNO = sw.TopORGNO; if (PublicCls.OrgIsShi(sw.TopORGNO)) { swOrg.GetContyORGNOByCity = sw.TopORGNO;//获取所有县 } if (PublicCls.OrgIsXian(sw.TopORGNO)) { swOrg.GetXZOrgNOByConty = sw.TopORGNO;//获取所有镇 } DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(swOrg); DataRow[] drOrg = dtOrg.Select("", "ORGNO");//取所有 for (int i = 0; i < drOrg.Length; i++) { // string orgName = drOrg[i]["ORGNAME"].ToString(); //string orgNo = drOrg[i]["ORGNO"].ToString(); getSabotageCount_Model m = new getSabotageCount_Model(); m.ORGName = drOrg[i]["ORGNAME"].ToString(); m.ORGNo = drOrg[i]["ORGNO"].ToString(); string CHr = dt.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "'").ToString(); CHr = (string.IsNullOrEmpty(CHr) ? "0" : CHr); string cList = ""; for (DateTime tm = dt1; tm <= dt2; tm = tm.AddDays(1)) { string tm1 = PublicClassLibrary.ClsSwitch.SwitDate(tm).ToString(); if (string.IsNullOrEmpty(cList) == false) { cList += ","; } string tmp = dt.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "' and SBDATE='" + tm1 + "' and PatrolLenErro=0").ToString(); //计算该日期下人数 cList += (string.IsNullOrEmpty(tmp) ? "0" : tmp); //各日期以逗号分隔 } m.DayCountList = cList; //日期考勤列表 string Chr0 = dt.Compute("sum(C)", "BYORGNO='" + m.ORGNo + "' and PatrolLenErro=1").ToString(); Chr0 = (string.IsNullOrEmpty(Chr0) ? "0" : Chr0); string Chr1 = ClsStr.getDiff(CHr, Chr0).ToString("F0"); string Chr2 = ClsStr.getPercent(Chr0, CHr).ToString("F0"); m.Count = CHr; //总 m.Count0 = Chr0; //完成 m.Count1 = Chr1; //未完成 m.CountPer = Chr2 + "%"; //完成率 result.Add(m); } dtOrg.Clear(); dtOrg.Dispose(); } dt.Clear(); dt.Dispose(); if (1 == 1) { getSabotageCount_Model m = new getSabotageCount_Model(); m.ORGName = "合计"; string LineCount = result.Sum(item => Convert.ToDecimal(item.Count)).ToString(); string Count0 = result.Sum(item => Convert.ToDecimal(item.Count0)).ToString(); string Count1 = result.Sum(item => Convert.ToDecimal(item.Count1)).ToString(); m.Count = LineCount; m.Count0 = Count0; m.Count1 = Count1; m.CountPer = ClsStr.getPercent(m.Count0, m.Count).ToString("F0") + "%"; int[] arrI = new int[days]; foreach (var v in result) { string[] a = v.DayCountList.Split(',');//组合列表 for (int i = 0; i < days; i++) { if (string.IsNullOrEmpty(arrI[i].ToString())) { arrI[i] = 0; } arrI[i] += int.Parse(a[i]); } } string cList = ""; for (int i = 0; i < days; i++) { if (string.IsNullOrEmpty(cList) == false) { cList += ","; } cList += arrI[i]; } m.DayCountList = cList; result.Insert(0, m); } return(result); }
/// <summary> /// 获取单条数据 /// </summary> /// <param name="sw">参见模型</param> /// <returns>参见模型</returns> public static PEST_MONITORINGSTATION_Model getModel(PEST_MONITORINGSTATION_SW sw) { DataTable dt = BaseDT.PEST_MONITORINGSTATION.getDT(sw);//列表 DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { SYSFLAG = ConfigCls.getSystemFlag() }); //获取单位 DataTable dt119 = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW { DICTTYPEID = "119" }); //无线电传输方式 DataTable dt120 = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW { DICTTYPEID = "120" }); //使用现状 DataTable dt121 = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW { DICTTYPEID = "121" }); //维护类型 PEST_MONITORINGSTATION_Model m = new PEST_MONITORINGSTATION_Model(); if (dt.Rows.Count > 0) { int i = 0; m.PEST_MONITORINGSTATIONID = dt.Rows[i]["PEST_MONITORINGSTATIONID"].ToString(); m.NUMBER = dt.Rows[i]["NUMBER"].ToString(); m.NAME = dt.Rows[i]["NAME"].ToString(); m.ADDRESS = dt.Rows[i]["ADDRESS"].ToString(); m.MODEL = dt.Rows[i]["MODEL"].ToString(); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); if (PublicCls.OrgIsShi(m.BYORGNO) || PublicCls.OrgIsXian(m.BYORGNO)) { m.ORGName = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO); m.ORGXSName = "--"; } else { m.ORGName = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO.Substring(0, 6) + "000"); m.ORGXSName = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO); } m.TRANSFERMODETYPE = dt.Rows[i]["TRANSFERMODETYPE"].ToString(); m.TRANSFERMODETYPEName = BaseDT.T_SYS_DICT.getName(dt119, m.TRANSFERMODETYPE); m.MONICONTENT = dt.Rows[i]["MONICONTENT"].ToString(); m.BUILDDATE = PublicClassLibrary.ClsSwitch.SwitDate(dt.Rows[i]["BUILDDATE"].ToString()); m.USESTATE = dt.Rows[i]["USESTATE"].ToString(); m.USESTATEName = BaseDT.T_SYS_DICT.getName(dt120, m.USESTATE); m.MANAGERSTATE = dt.Rows[i]["MANAGERSTATE"].ToString(); m.MANAGERSTATEName = BaseDT.T_SYS_DICT.getName(dt121, m.MANAGERSTATE); m.MARK = dt.Rows[i]["MARK"].ToString(); m.JD = dt.Rows[i]["JD"].ToString(); m.WD = dt.Rows[i]["WD"].ToString(); m.WORTH = dt.Rows[i]["WORTH"].ToString(); } dt.Clear(); dt.Dispose(); dtORG.Clear(); dtORG.Dispose(); dt119.Clear(); dt119.Dispose(); dt120.Clear(); dt120.Dispose(); dt121.Clear(); dt121.Dispose(); return(m); }
/// <summary> /// 采集数据统计 /// </summary> /// <param name="sw">参见模型 sw.TopORGNO 顶级单位编码 sw.DateBegin 开始日期 年月日 sw.DateEnd 结束日期 年月日</param> /// <param name="typeModel">参见模型</param> /// <returns>参见模型</returns> public static IEnumerable <T_IPSCOL_COLLECT_OrgCountModel> getModelCount(T_IPSCOL_COLLECT_SW sw, out IEnumerable <T_IPSCOL_COLLECT_TypeCountModel> typeModel) { var result = new List <T_IPSCOL_COLLECT_OrgCountModel>(); //获取采集信息 DataTable dt = BaseDT.T_IPSCOL_COLLECT.getDTByOrgHUse(sw); //获取单位 T_SYS_ORGSW swOrg = new T_SYS_ORGSW(); swOrg.SYSFLAG = ConfigCls.getSystemFlag(); swOrg.TopORGNO = sw.TopORGNO; if (PublicCls.OrgIsShi(sw.TopORGNO)) { swOrg.GetContyORGNOByCity = sw.TopORGNO;//获取所有县 } if (PublicCls.OrgIsXian(sw.TopORGNO)) { swOrg.GetXZOrgNOByConty = sw.TopORGNO;//获取所有镇 } DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(swOrg); //采集类别 DataTable dtReportType = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW { DICTTYPEID = "4" }); //采集类别 //out 类别 var resultReportType = new List <T_IPSCOL_COLLECT_TypeCountModel>(); for (int i = 0; i < dtReportType.Rows.Count; i++) { T_IPSCOL_COLLECT_TypeCountModel m = new T_IPSCOL_COLLECT_TypeCountModel(); m.typeName = dtReportType.Rows[i]["DICTNAME"].ToString(); resultReportType.Add(m); } typeModel = resultReportType; if (1 == 1) { T_IPSCOL_COLLECT_OrgCountModel m = new T_IPSCOL_COLLECT_OrgCountModel(); m.HName = BaseDT.T_SYS_ORG.getName(sw.TopORGNO) + "合计"; m.ORGName = m.HName; m.CollectCount = BaseDT.T_IPSRPT_REPORT.getCountByOrgHUse(dt, sw.TopORGNO, "");//总数 var typeResult = new List <T_IPSCOL_COLLECT_TypeCountModel>(); //循环类别 for (int k = 0; k < dtReportType.Rows.Count; k++) { T_IPSCOL_COLLECT_TypeCountModel mm = new T_IPSCOL_COLLECT_TypeCountModel(); mm.typeID = dtReportType.Rows[k]["DICTVALUE"].ToString(); mm.typeName = dtReportType.Rows[k]["DICTNAME"].ToString(); mm.typeCount = BaseDT.T_IPSRPT_REPORT.getCountByOrgHUse(dt, sw.TopORGNO, mm.typeID);//分类别统计 typeResult.Add(mm); } m.TypeCountModel = typeResult; result.Add(m); } if (PublicCls.OrgIsZhen(sw.TopORGNO) == false) { //循环单位 for (int i = 0; i < dtOrg.Rows.Count; i++) { T_IPSCOL_COLLECT_OrgCountModel m = new T_IPSCOL_COLLECT_OrgCountModel(); m.ORGName = dtOrg.Rows[i]["ORGNAME"].ToString(); m.ORGNo = dtOrg.Rows[i]["ORGNO"].ToString(); //m.HID = dt.Rows[i]["HID"].ToString(); m.CollectCount = BaseDT.T_IPSCOL_COLLECT.getCountByOrgHUse(dt, m.ORGNo, "");//总数 var typeResult = new List <T_IPSCOL_COLLECT_TypeCountModel>(); //循环类别 for (int k = 0; k < dtReportType.Rows.Count; k++) { T_IPSCOL_COLLECT_TypeCountModel mm = new T_IPSCOL_COLLECT_TypeCountModel(); mm.typeID = dtReportType.Rows[k]["DICTVALUE"].ToString(); mm.typeName = dtReportType.Rows[k]["DICTNAME"].ToString(); mm.typeCount = BaseDT.T_IPSCOL_COLLECT.getCountByOrgHUse(dt, m.ORGNo, mm.typeID);//分类别统计 typeResult.Add(mm); } m.TypeCountModel = typeResult; result.Add(m); } } else//if (PublicCls.OrgIsZhen(sw.TopORGNO))//如果查询的单位为镇,显示所有护林员的统计信息 { DataTable dtHUser = BaseDT.T_IPSFR_USER.getDT(new T_IPSFR_USER_SW { BYORGNO = sw.TopORGNO }); for (int i = 0; i < dtHUser.Rows.Count; i++) { T_IPSCOL_COLLECT_OrgCountModel m = new T_IPSCOL_COLLECT_OrgCountModel(); m.HID = dtHUser.Rows[i]["HID"].ToString(); m.HName = dtHUser.Rows[i]["HNAME"].ToString(); m.CollectCount = BaseDT.T_IPSCOL_COLLECT.getCountByHID(dt, m.HID, "");//总数 var typeResult = new List <T_IPSCOL_COLLECT_TypeCountModel>(); //循环类别 for (int k = 0; k < dtReportType.Rows.Count; k++) { T_IPSCOL_COLLECT_TypeCountModel mm = new T_IPSCOL_COLLECT_TypeCountModel(); mm.typeID = dtReportType.Rows[k]["DICTVALUE"].ToString(); mm.typeName = dtReportType.Rows[k]["DICTNAME"].ToString(); mm.typeCount = BaseDT.T_IPSCOL_COLLECT.getCountByHID(dt, m.HID, mm.typeID);//分类别统计 typeResult.Add(mm); } m.TypeCountModel = typeResult; result.Add(m); } dtHUser.Clear(); dtHUser.Dispose(); } dt.Clear(); dt.Dispose(); dtOrg.Clear(); dtOrg.Dispose(); dtReportType.Clear(); dtReportType.Dispose(); return(result); }
/// <summary> /// 巡检路线统计总表 /// </summary> /// <param name="sw">参见PatrolRouteStat_SW</param> /// <returns>参见HUReport_PatrolRouteStat_Model</returns> public static IEnumerable <HUReport_PatrolRouteStat_Model> getPatrolRouteStatModel(PatrolRouteStat_SW sw) { var result = new List <HUReport_PatrolRouteStat_Model>(); if (string.IsNullOrEmpty(sw.DateBegin))//开始时间为空 { return(result); } if (string.IsNullOrEmpty(sw.DateEnd))//结束时间为空 { return(result); } //DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { SYSFLAG = ConfigCls.getSystemFlag(), TopORGNO=sw.orgNo }); //获取护林员每日巡检信息 //DataTable dtHRRealData = BaseDT.T_IPS_REALDATATEMPORARY.getHRAndRealDataDT(new T_IPS_REALDATATEMPORARYSW { DateBegin = sw.DateBegin, DateEnd = sw.DateEnd }); //获取具体巡检情况 //DataTable dtPatrol = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getDT(new T_IPSFR_ROUTERAIL_PATROL_SW { DateBegin = sw.DateBegin, DateEnd = sw.DateEnd }); // DataTable dtHRRealData = new DataTable(); //DataTable dtPatrol = new DataTable(); DataTable dtHU = new DataTable(); DataTable dtHRRealData = BaseDT.T_IPS_REALDATATEMPORARY.getDTByOrgNo(sw); //DataTable dtPatrol = BaseDT.T_IPS_REALDATATEMPORARY.getPATROLCOUNTDTByOrgNo(sw);//获取巡检信息 含未检和已检 if (PublicCls.OrgIsShi(sw.TopORGNO)) { //dtHRRealData = BaseDT.T_IPS_REALDATATEMPORARY.getDTShi(sw); //dtPatrol = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getDTShi(sw);//获取巡检信息 含未检和已检 dtHU = BaseDT.T_IPSFR_USER.getDTShi(new T_IPSFR_USER_SW { }); } else if (PublicCls.OrgIsXian(sw.TopORGNO)) { //dtHRRealData = BaseDT.T_IPS_REALDATATEMPORARY.getDTXain(sw); //dtPatrol = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getDTXain(sw);//获取巡检信息 含未检和已检 dtHU = BaseDT.T_IPSFR_USER.getDTXain(new T_IPSFR_USER_SW { BYORGNO = sw.TopORGNO }); } else { //dtHRRealData = BaseDT.T_IPS_REALDATATEMPORARY.getDTZhen(sw); //dtPatrol = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getDTZhen(sw);//获取巡检信息 含未检和已检 dtHU = BaseDT.T_IPSFR_USER.getDT(new T_IPSFR_USER_SW { ISENABLE = "1", BYORGNO = sw.TopORGNO }); } int days = ClsStr.getDateDiff(sw.DateBegin, sw.DateEnd) + 1;//日期包含天数 if (PublicCls.OrgIsZhen(sw.TopORGNO)) { DataRow[] drOrg = dtHU.Select("", ""); for (int i = 0; i < drOrg.Length; i++) { HUReport_PatrolRouteStat_Model m = new HUReport_PatrolRouteStat_Model(); m.ORGName = drOrg[i]["HNAME"].ToString(); m.ORGNo = drOrg[i]["HID"].ToString(); string CHr = "";// BaseDT.T_IPSFR_USER.getCountByOrgNo(dtHU, m.ORGNo).ToString(); if (CHr != "0") { CHr = days.ToString(); string Chr0 = BaseDT.T_IPS_REALDATATEMPORARY.getDTByOrgNoSum(dtHRRealData, m.ORGNo).ToString(); string Chr1 = ClsStr.getDiff(CHr, Chr0).ToString("F0"); string Chr2 = ClsStr.getPercent(Chr0, CHr).ToString("F0"); m.LineCount = CHr; //总 m.LineCount0 = Chr0; //完成 m.LineCount1 = Chr1; //未完成 m.LineCount2 = Chr2 + "%"; //完成率 } //巡检与漏检 string CCHr = dtHRRealData.Compute("sum(C1)", "BYORGNO='" + m.ORGNo + "'").ToString(); CCHr = (string.IsNullOrEmpty(CCHr) ? "0" : CCHr); if (CCHr != "0") { string Chr0 = dtHRRealData.Compute("sum(C2)", "BYORGNO='" + m.ORGNo + "'").ToString(); // BaseDT.T_IPSFR_ROUTERAIL_PATROL.getSumByOrgNo(dtPatrol, m.ORGNo, "1"); Chr0 = (string.IsNullOrEmpty(Chr0) ? "0" : Chr0); string Chr1 = dtHRRealData.Compute("sum(C3)", "BYORGNO='" + m.ORGNo + "'").ToString(); // BaseDT.T_IPSFR_ROUTERAIL_PATROL.getSumByOrgNo(dtPatrol, m.ORGNo, "0"); Chr1 = (string.IsNullOrEmpty(Chr1) ? "0" : Chr1); string Chr2 = ClsStr.getPercent(Chr0, CCHr).ToString("F0"); m.PointCount = CCHr; m.PointCount0 = Chr0; m.PointCount1 = Chr1; m.PointCount2 = Chr2 + "%"; } result.Add(m); } dtHU.Clear(); dtHU.Dispose(); } else { T_SYS_ORGSW swOrg = new T_SYS_ORGSW(); swOrg.SYSFLAG = ConfigCls.getSystemFlag(); swOrg.TopORGNO = sw.TopORGNO; if (PublicCls.OrgIsShi(sw.TopORGNO)) { swOrg.GetContyORGNOByCity = sw.TopORGNO;//获取所有县 } if (PublicCls.OrgIsXian(sw.TopORGNO)) { swOrg.GetXZOrgNOByConty = sw.TopORGNO;//获取所有镇 } DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(swOrg); DataRow[] drOrg = dtOrg.Select("", "ORGNO");//取所有 for (int i = 0; i < drOrg.Length; i++) { // string orgName = drOrg[i]["ORGNAME"].ToString(); //string orgNo = drOrg[i]["ORGNO"].ToString(); HUReport_PatrolRouteStat_Model m = new HUReport_PatrolRouteStat_Model(); m.ORGName = drOrg[i]["ORGNAME"].ToString(); m.ORGNo = drOrg[i]["ORGNO"].ToString(); string CHr = BaseDT.T_IPSFR_USER.getSumByOrgNo(dtHU, m.ORGNo);//各单位护林员个数 if (CHr != "0") { CHr = (int.Parse(CHr) * days).ToString(); string Chr0 = BaseDT.T_IPS_REALDATATEMPORARY.getDTByOrgNoSum(dtHRRealData, m.ORGNo).ToString(); string Chr1 = ClsStr.getDiff(CHr, Chr0).ToString("F0"); string Chr2 = ClsStr.getPercent(Chr0, CHr).ToString("F0"); m.LineCount = CHr; //总 m.LineCount0 = Chr0; //完成 m.LineCount1 = Chr1; //未完成 m.LineCount2 = Chr2 + "%"; //完成率 } //巡检与漏检 //巡检与漏检 string CCHr = dtHRRealData.Compute("sum(C1)", "BYORGNO='" + m.ORGNo + "'").ToString(); CCHr = (string.IsNullOrEmpty(CCHr) ? "0" : CCHr); if (CCHr != "0") { string Chr0 = dtHRRealData.Compute("sum(C2)", "BYORGNO='" + m.ORGNo + "'").ToString(); // BaseDT.T_IPSFR_ROUTERAIL_PATROL.getSumByOrgNo(dtPatrol, m.ORGNo, "1"); Chr0 = (string.IsNullOrEmpty(Chr0) ? "0" : Chr0); string Chr1 = dtHRRealData.Compute("sum(C3)", "BYORGNO='" + m.ORGNo + "'").ToString(); // BaseDT.T_IPSFR_ROUTERAIL_PATROL.getSumByOrgNo(dtPatrol, m.ORGNo, "0"); Chr1 = (string.IsNullOrEmpty(Chr1) ? "0" : Chr1); string Chr2 = ClsStr.getPercent(Chr0, CCHr).ToString("F0"); m.PointCount = CCHr; m.PointCount0 = Chr0; m.PointCount1 = Chr1; m.PointCount2 = Chr2 + "%"; } result.Add(m); } dtOrg.Clear(); dtOrg.Dispose(); } //dtPatrol.Clear(); //dtPatrol.Dispose(); dtHRRealData.Clear(); dtHRRealData.Dispose(); if (1 == 1) { HUReport_PatrolRouteStat_Model m = new HUReport_PatrolRouteStat_Model(); m.ORGName = "合计"; string LineCount = result.Sum(item => Convert.ToDecimal(item.LineCount)).ToString(); string LineCount0 = result.Sum(item => Convert.ToDecimal(item.LineCount0)).ToString(); string PointCount = result.Sum(item => Convert.ToDecimal(item.PointCount)).ToString(); string PointCount0 = result.Sum(item => Convert.ToDecimal(item.PointCount0)).ToString(); m.LineCount = LineCount; m.LineCount0 = LineCount0; m.LineCount1 = result.Sum(item => Convert.ToDecimal(item.LineCount1)).ToString(); m.LineCount2 = ClsStr.getPercent(LineCount0, LineCount).ToString("F0") + "%"; m.PointCount = PointCount; m.PointCount0 = PointCount0; m.PointCount1 = result.Sum(item => Convert.ToDecimal(item.PointCount1)).ToString(); m.PointCount2 = ClsStr.getPercent(PointCount0, PointCount).ToString("F0") + "%"; result.Insert(0, m); } return(result); }
/// <summary> /// 根据组织机构获取短信发送tree字符串 /// </summary> /// <param name="orgno"></param> /// <param name="type"></param> /// <returns></returns> public static SendMessage_Model getstr(string orgno, string type) { var s = ""; var d = ""; var dt = new DataTable(); var dtvillage = new DataTable(); var dtipuser = new DataTable(); if (orgno == "1") { dt = BaseDT.T_SYS_ORG_LINK.getDT(new T_SYS_ORG_LINK_SW { BYORGNO = SystemCls.getCurUserOrgNo() }); //列表 } else if (orgno == "2") { dtipuser = BaseDT.T_IPSFR_USER.getDT(new T_IPSFR_USER_SW { BYORGNO = SystemCls.getCurUserOrgNo() }); } else { if (PublicCls.OrgIsShi(orgno) == false && PublicCls.OrgIsXian(orgno) == false && PublicCls.OrgIsZhen(orgno) == false) { dtvillage = BaseDT.T_SYS_ORG_CWH.getVillagecComDT(new T_SYS_ORG_CWH_SW { CWHID = orgno }); } else { dtvillage = BaseDT.T_SYS_ORG_CWH.getVillagecComDT(new T_SYS_ORG_CWH_SW { BYORGNO = orgno }); dt = BaseDT.T_SYS_ORG_LINK.getDT(new T_SYS_ORG_LINK_SW { BYORGNO = orgno }); //列表 dtipuser = BaseDT.T_IPSFR_USER.getDT(new T_IPSFR_USER_SW { BYORGNO = orgno }); } } if (type == "1") { if (PublicCls.OrgIsShi(orgno) == false && PublicCls.OrgIsXian(orgno) == false && PublicCls.OrgIsZhen(orgno) == false) { for (int i = 0; i < dtvillage.Rows.Count; i++) { T_SYS_ORG_LINK_Model m = new T_SYS_ORG_LINK_Model(); m.NAME = dtvillage.Rows[i]["NAME"].ToString(); m.PHONE = dtvillage.Rows[i]["PHONE"].ToString(); s += m.NAME + ","; d += m.PHONE + ","; } } else { for (int i = 0; i < dt.Rows.Count; i++) { T_SYS_ORG_LINK_Model m = new T_SYS_ORG_LINK_Model(); m.NAME = dt.Rows[i]["NAME"].ToString(); m.PHONE = dt.Rows[i]["PHONE"].ToString(); s += m.NAME + ","; d += m.PHONE + ","; } for (int i = 0; i < dtvillage.Rows.Count; i++) { T_SYS_ORG_LINK_Model m = new T_SYS_ORG_LINK_Model(); m.NAME = dtvillage.Rows[i]["NAME"].ToString(); m.PHONE = dtvillage.Rows[i]["PHONE"].ToString(); s += m.NAME + ","; d += m.PHONE + ","; } } } if (type == "2") { for (int i = 0; i < dtipuser.Rows.Count; i++) { T_SYS_ORG_LINK_Model m = new T_SYS_ORG_LINK_Model(); m.NAME = dtipuser.Rows[i]["HNAME"].ToString(); m.PHONE = dtipuser.Rows[i]["PHONE"].ToString(); s += m.NAME + ","; d += m.PHONE + ","; } } s = s.TrimEnd(','); d = d.TrimEnd(','); SendMessage_Model m1 = new SendMessage_Model(); m1.PHONELIST = d; m1.NAMELIST = s; dt.Clear(); dt.Dispose(); dtvillage.Clear(); dtvillage.Dispose(); dtipuser.Clear(); dtipuser.Dispose(); return(m1); }
/// <summary> /// 巡检路线明细表 /// </summary> /// <param name="sw">参见PatrolRouteStat_SW</param> /// <returns>参见HUReport_PatrolRouteDetail_Model</returns> public static IEnumerable <HUReport_PatrolRouteDetail_Model> getPatrolRouteDetailModel(PatrolRouteStat_SW sw) { var result = new List <HUReport_PatrolRouteDetail_Model>(); if (string.IsNullOrEmpty(sw.DateBegin))//开始时间为空 { return(result); } if (string.IsNullOrEmpty(sw.DateEnd))//结束时间为空 { return(result); } if (string.IsNullOrEmpty(sw.orgNo))//组织机构编码 { return(result); } T_SYS_ORGSW swOrg = new T_SYS_ORGSW(); swOrg.SYSFLAG = ConfigCls.getSystemFlag(); swOrg.TopORGNO = sw.TopORGNO; if (PublicCls.OrgIsShi(sw.TopORGNO)) { swOrg.GetContyORGNOByCity = sw.TopORGNO;//获取所有县 } if (PublicCls.OrgIsXian(sw.TopORGNO)) { swOrg.GetXZOrgNOByConty = sw.TopORGNO;//获取所有镇 } DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(swOrg); //DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { SYSFLAG = ConfigCls.getSystemFlag() }); DataTable dtHU = BaseDT.T_IPSFR_USER.getDT(new T_IPSFR_USER_SW { ISENABLE = "1", PhoneHname = sw.PhoneHname, BYORGNO = sw.orgNo }); //获取护林员每日巡检信息 DataTable dtHRRealData = BaseDT.T_IPS_REALDATATEMPORARY.getHRAndRealDataDT(new T_IPS_REALDATATEMPORARYSW { DateBegin = sw.DateBegin, DateEnd = sw.DateEnd, ORGNO = sw.orgNo, PhoneHname = sw.PhoneHname }); //获取具体巡检情况 DataTable dtPatrol = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getDT(new T_IPSFR_ROUTERAIL_PATROL_SW { DateBegin = sw.DateBegin, DateEnd = sw.DateEnd }); int days = ClsStr.getDateDiff(sw.DateBegin, sw.DateEnd) + 1; //日期包含天数 for (int i = 0; i < dtHU.Rows.Count; i++) //获取每个护林员 { string orgNo = dtHU.Rows[i]["BYORGNO"].ToString(); string HID = dtHU.Rows[i]["HID"].ToString(); string orgName = BaseDT.T_SYS_ORG.getName(dtOrg, orgNo); HUReport_PatrolRouteDetail_Model m = new HUReport_PatrolRouteDetail_Model(); m.ORGName = orgName; m.ORGNo = orgNo; m.HNAME = dtHU.Rows[i]["HNAME"].ToString(); m.PHONE = dtHU.Rows[i]["PHONE"].ToString(); string CHr = "1";//每天一条路线 if (CHr != "0") { CHr = (int.Parse(CHr) * days).ToString(); string Chr0 = BaseDT.T_IPS_REALDATATEMPORARY.getCountByHID(dtHRRealData, HID).ToString(); string Chr1 = ClsStr.getDiff(CHr, Chr0).ToString("F0"); string Chr2 = ClsStr.getPercent(Chr0, CHr).ToString("F0"); m.LineCount = CHr; //总 m.LineCount0 = Chr0; //完成 m.LineCount1 = Chr1; //未完成 m.LineCount2 = Chr2 + "%"; //完成率 } //巡检与漏检 string CCHr = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getCountByHID(dtPatrol, HID, "").ToString(); if (CCHr != "0") { // CCHr = (int.Parse(CCHr) * days).ToString(); string Chr0 = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getCountByHID(dtPatrol, HID, "1").ToString(); string Chr1 = ClsStr.getDiff(CCHr, Chr0).ToString("F0"); string Chr2 = ClsStr.getPercent(Chr0, CCHr).ToString("F0"); m.PointCount = CCHr; //总 m.PointCount0 = Chr0; //完成 m.PointCount1 = Chr1; //未完成 m.PointCount2 = Chr2 + "%"; //完成率 } result.Add(m); } dtHU.Clear(); dtHU.Dispose(); dtHRRealData.Clear(); dtHRRealData.Dispose(); dtPatrol.Clear(); dtPatrol.Dispose(); dtOrg.Clear(); dtOrg.Dispose(); return(result); }
/// <summary> /// 获取视频列表 /// </summary> /// <param name="orgno"></param> /// <param name="eid"></param> /// <returns></returns> public static string getSynTree(string orgno, string eid) { JArray jObjects = new JArray(); string curUserOrg = SystemCls.getCurUserOrgNo();//获取当前登录用户的机构编码 if (string.IsNullOrEmpty(orgno) == false) { curUserOrg = orgno; } if (string.IsNullOrEmpty(orgno)) { var str = ""; if (PublicCls.OrgIsZhen(curUserOrg)) { str = PublicCls.GetOrgNameByOrgNO(curUserOrg.Substring(0, 6) + "000000000"); } else { str = PublicCls.GetOrgNameByOrgNO(curUserOrg); } JObject root = new JObject(); if (PublicCls.OrgIsShi(curUserOrg)) { root = new JObject { { "id", "1111" },//ORGNO { "text", str } }; } var resultlist = JC_MONITORCls.getListModel(new JC_MONITOR_BASICINFO_SW { BYORGNO = curUserOrg }); //获取所有有权限的监控摄像 if (resultlist.Any()) { var devOrgSXList = resultlist.Select(p => p.BYORGNO.Substring(0, 6) + "000000000").Distinct(); if (devOrgSXList.Any()) { JArray devSXArrary = new JArray(); foreach (var orgsx in devOrgSXList) { JObject rootSX = new JObject { { "id", orgsx },//ORGNO { "text", PublicCls.GetOrgNameByOrgNO(orgsx) } //{"state","closed"} }; var devOrgXZList = resultlist.Select(p => new { p.BYORGNO, p.ORGNAME }).Distinct() .Where(p => p.BYORGNO.Substring(0, 6) + "000000000" == orgsx); if (devOrgXZList.Any()) { JArray devXZArrary = new JArray(); foreach (var orgxz in devOrgXZList) { JObject rootXZ = new JObject { { "id", orgxz.BYORGNO },//ORGNO { "text", orgxz.ORGNAME } // {"state","closed"} }; var devlist = resultlist.Where(p => p.BYORGNO == orgxz.BYORGNO); if (devlist.Any()) { JArray devArrary = new JArray(); foreach (var dev in devlist) { JObject rootDevice = new JObject { { "id", dev.EMID }, { "text", dev.EMNAME }, { "objId", dev.OBJID }, { "templateId", dev.TEMPLATEDID }, { "ip", dev.IP }, { "port", dev.PORT }, { "type", dev.TYPE }, { "isVideo", true } }; devArrary.Add(rootDevice); } rootXZ.Add("children", devArrary); if (PublicCls.OrgIsZhen(curUserOrg))//乡镇级用户 { jObjects.Add(rootXZ); break; } devXZArrary.Add(rootXZ); } } rootSX.Add("children", devXZArrary); if (PublicCls.OrgIsXian(curUserOrg))//县级用户 { jObjects.Add(rootSX); break; } devSXArrary.Add(rootSX); } } if (PublicCls.OrgIsShi(curUserOrg))//市级用户 { root.Add("children", devSXArrary); } } if (PublicCls.OrgIsShi(curUserOrg)) { jObjects.Add(root); } } } else { var str = PublicCls.GetOrgNameByOrgNO(curUserOrg); JObject root = new JObject { { "id", "1111" }, //ORGNO { "text", str } }; var devlist = JC_MONITORCls.getListModel(new JC_MONITOR_BASICINFO_SW { BYORGNO = curUserOrg, EMID = eid }); //获取所有有权限的监控摄像 if (devlist.Any()) { JArray devArrary = new JArray(); foreach (var dev in devlist) { JObject rootDevice = new JObject { { "id", dev.EMID }, { "text", dev.EMNAME }, { "objId", dev.OBJID }, { "templateId", dev.TEMPLATEDID }, { "ip", dev.IP }, { "port", dev.PORT }, { "type", dev.TYPE }, { "isVideo", true } }; devArrary.Add(rootDevice); } root.Add("children", devArrary); jObjects.Add(root); } } return(JsonConvert.SerializeObject(jObjects)); }
/// <summary> /// 获取视频列表异步树 /// </summary> /// <param name="OrgNo"></param> /// <param name="eid"></param> /// <returns></returns> public static string getTree(string OrgNo, string eid) { JArray jObjects = new JArray(); string curUserOrg = SystemCls.getCurUserOrgNo();//获取当前登录用户的机构编码 if (string.IsNullOrEmpty(OrgNo) == false) { curUserOrg = OrgNo; } DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { TopORGNO = curUserOrg, SYSFLAG = ConfigCls.getSystemFlag() }); //获取当前登录用户有权限查看的单位 DataTable dtFRUser = BaseDT.JC_MONITOR_BASICINFO.getDT(new JC_MONITOR_BASICINFO_SW { BYORGNO = curUserOrg, EMID = eid }); //获取所有有权限的监控摄像 #region 市级用户 if (PublicCls.OrgIsShi(curUserOrg)) { DataRow[] drOrg = dtOrg.Select("", "ORGNO"); if (drOrg.Length > 0) { JObject root = new JObject { { "id", drOrg[0]["ORGNO"].ToString() },//ORGNO { "text", drOrg[0]["ORGNAME"].ToString() }, { "treeType", "org" }, }; JArray childArray = new JArray(); DataRow[] drOrgC = dtOrg.Select("SUBSTRING(ORGNO,1,4) = '" + curUserOrg.Substring(0, 4) + "' AND ORGNO<>'" + curUserOrg + "' and SUBSTRING(ORGNO,7,3)='000'", "");//获取所有县且〈〉市的 for (int i = 0; i < drOrgC.Length; i++) { JObject rootC = new JObject { { "id", drOrgC[i]["ORGNO"].ToString() },//ORGNO { "text", drOrgC[i]["ORGNAME"].ToString() }, { "state", "closed" }, { "treeType", "org" } }; childArray.Add(rootC); } root.Add("children", childArray); jObjects.Add(root); } } #endregion #region 县级用户 else if (PublicCls.OrgIsXian(curUserOrg)) { DataRow[] drOrg = dtOrg.Select("", "ORGNO"); if (drOrg.Length > 0) { JObject root = new JObject { { "id", drOrg[0]["ORGNO"].ToString() },//ORGNO { "text", drOrg[0]["ORGNAME"].ToString() }, { "state", "closed" }, { "treeType", "org" } }; JArray jObjectsC = new JArray(); DataRow[] drOrgC = dtOrg.Select("SUBSTRING(ORGNO,1,6) = '" + curUserOrg.Substring(0, 6) + "' AND ORGNO<>'" + curUserOrg + "'", ""); //获取所有县且〈〉市的 for (int i = 0; i < drOrgC.Length; i++) { JObject rootC = new JObject { { "id", drOrgC[i]["ORGNO"].ToString() },//ORGNO { "text", drOrgC[i]["ORGNAME"].ToString() }, { "state", "closed" }, { "treeType", "org" } }; //root.Add("children", getTreeChild(dtOrg, dtFRUser, dtRealTmp, drOrg[i]["ORGNO"].ToString()));//继续获取护林员 jObjectsC.Add(rootC); if (string.IsNullOrEmpty(OrgNo) == false)//异步加载,不显示县名 { jObjects.Add(rootC); } } if (string.IsNullOrEmpty(OrgNo))//县级用户登录 { jObjects.Add(root); root.Add("children", jObjectsC); } } } #endregion #region 乡镇用户 else { DataRow[] drOrg = dtOrg.Select("", "ORGNO"); if (drOrg.Length > 0) { JObject root = new JObject { { "id", drOrg[0]["ORGNO"].ToString() },//ORGNO { "text", drOrg[0]["ORGNAME"].ToString() }, { "state", "closed" }, { "treeType", "org" } }; DataRow[] drFRUser = dtFRUser.Select("BYORGNO = '" + curUserOrg + "'", "");//获取所有县且〈〉市的 JArray jObjectsC = new JArray(); for (int i = 0; i < drFRUser.Length; i++) { StringBuilder sb = new StringBuilder(); JObject rootC = new JObject { { "id", drFRUser[i]["EMID"].ToString() }, { "text", drFRUser[i]["EMNAME"].ToString() }, { "objId", drFRUser[i]["OBJID"].ToString() }, { "templateId", drFRUser[i]["TEMPLATEDID"].ToString() }, { "ip", drFRUser[i]["ip"].ToString() }, { "port", drFRUser[i]["PORT"].ToString() }, { "isVideo", true } }; jObjectsC.Add(rootC); if (string.IsNullOrEmpty(OrgNo) == false)//异步加载,不显示乡镇名 { jObjects.Add(rootC); } } if (string.IsNullOrEmpty(OrgNo))//乡镇级用户登录 { jObjects.Add(root); root.Add("children", jObjectsC); } } } #endregion dtOrg.Clear(); dtOrg.Dispose(); return(JsonConvert.SerializeObject(jObjects)); }