/// <summary> /// 出围查询Json /// </summary> /// <returns></returns> public ActionResult getOutRaiLCountJson() { OutRaiLCount_SW sw = new OutRaiLCount_SW(); sw.TopORGNO = Request.Params["BYORGNO"]; sw.DateBegin = Request.Params["TIMEBegin"]; sw.DateEnd = Request.Params["TIMEEnd"]; var list = HUCheckCls.getOutRaiLCountModel(sw); StringBuilder sb = new StringBuilder(); DateTime dt1 = Convert.ToDateTime(sw.DateBegin); DateTime dt2 = Convert.ToDateTime(sw.DateEnd); int days = ClsStr.getDateDiff(sw.DateBegin, sw.DateEnd) + 1;//日期包含天数 sb.AppendFormat("<table cellpadding=\"0\" cellspacing=\"0\">"); sb.AppendFormat("<thead>"); sb.AppendFormat(" <tr>"); sb.AppendFormat(" <th rowspan=\"2\">单位<br>(姓名)</th>"); sb.AppendFormat(" <th rowspan=\"2\">出围合计</th>"); sb.AppendFormat(" <th colspan=\"{1}\">{0}</th>", "日期(日)", days.ToString()); sb.AppendFormat(" </tr>"); sb.AppendFormat(" <tr>"); for (DateTime tm = dt1; tm <= dt2; tm = tm.AddDays(1)) { sb.AppendFormat(" <th>{0}</th>", tm.ToString("dd")); } sb.AppendFormat(" </tr>"); sb.AppendFormat("</thead>"); sb.AppendFormat("<tbody>"); //var list = HUCheckCls.getCheckInModel(new HUCheckINCount_SW { DateBegin = arr[1], DateEnd = arr[2], ORGNO = arr[0], HUNM = arr[3] }); int j = 0; foreach (var v in list) { string orgName = v.ORGName; string orgNo = v.ORGNo; j++; if (j % 2 == 0) { sb.AppendFormat("<tr>"); } else { sb.AppendFormat("<tr class='row1'>"); } sb.AppendFormat("<td class=\"center\">{0}</td>", v.ORGName); sb.AppendFormat("<td class=\"center\">{0}</td>", v.Count);//总 string[] arr1 = v.DayCountList.Split(','); for (int i = 0; i < days; i++) { sb.AppendFormat("<td class=\"center\">{0}</td>", arr1[i]); } sb.AppendFormat("</tr>"); } sb.AppendFormat("</tbody>"); sb.AppendFormat("</table>"); return(Content(JsonConvert.SerializeObject(new Message(true, sb.ToString(), "")), "text/html;charset=UTF-8")); }
/// <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> /// 查询漏检统计 /// </summary> /// <param name="sw">参见OmitCheckCount_SW</param> /// <returns>参见HUCheck_OmitCount_Model</returns> public static IEnumerable <HUCheck_OmitCount_Model> getOmitCheckModel1(OmitCheckCount_SW sw) { var result = new List <HUCheck_OmitCount_Model>(); if (string.IsNullOrEmpty(sw.DateBegin))//开始时间为空 { return(result); } if (string.IsNullOrEmpty(sw.DateEnd))//结束时间为空 { return(result); } if (string.IsNullOrEmpty(sw.ORGNO))//组织机构编码 { return(result); } //根据机构编码获取下属组织机构 注意:这个函数含本级及所有下级的 DataTable dtOrg = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { TopORGNO = sw.ORGNO }); DataTable dtHU = BaseDT.T_IPSFR_USER.getDT( new T_IPSFR_USER_SW { ISENABLE = "1", BYORGNO = sw.ORGNO, HNAME = sw.PhoneHname, HID = sw.HID }); //获取具体巡检情况 DataTable dtPatrol = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getDT( new T_IPSFR_ROUTERAIL_PATROL_SW { DateBegin = sw.DateBegin, DateEnd = sw.DateEnd, orgNo = sw.ORGNO, PhoneHname = sw.PhoneHname, HID = sw.HID }); DateTime dt1 = Convert.ToDateTime(sw.DateBegin); DateTime dt2 = Convert.ToDateTime(sw.DateEnd); DataRow[] drOrg = dtOrg.Select("", "ORGNO"); //取所有 int days = ClsStr.getDateDiff(sw.DateBegin, sw.DateEnd) + 1; //日期包含天数 for (int i = 0; i < drOrg.Length; i++) { HUCheck_OmitCount_Model m = new HUCheck_OmitCount_Model(); string orgNo = drOrg[i]["ORGNO"].ToString(); m.ORGNo = orgNo; string orgName = BaseDT.T_SYS_ORG.getName(dtOrg, orgNo); m.ORGName = orgName; //巡检与漏检 string CCHr = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getCountByOrgNo(dtPatrol, orgNo, "").ToString(); if (CCHr != "0") { string Chr0 = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getCountByOrgNo(dtPatrol, orgNo, "1").ToString(); string Chr1 = ClsStr.getDiff(CCHr, Chr0).ToString("F0"); string Chr2 = ClsStr.getPercent(Chr0, CCHr).ToString("F0"); m.OmitCount0 = CCHr; //总 m.OmitCount1 = Chr0; //完成 m.OmitCount2 = Chr1; //未完成 m.OmitCount3 = Chr2 + "%"; //完成率 } result.Add(m); } if (PublicCls.OrgIsZhen(sw.ORGNO)) //显示所有护林员 { DataRow[] drHU = dtHU.Select("", ""); for (int k = 0; k < drHU.Length; k++)//循环护林员 { HUCheck_OmitCount_Model m = new HUCheck_OmitCount_Model(); string HID = dtHU.Rows[k]["HID"].ToString(); m.HID = HID; m.ORGName = dtHU.Rows[k]["HNAME"].ToString();//护林员姓名与机构名称共用一个 string CCHr1 = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getCountByHID(dtPatrol, HID, "").ToString(); if (CCHr1 != "0") { string Chr0 = BaseDT.T_IPSFR_ROUTERAIL_PATROL.getCountByHID(dtPatrol, HID, "1").ToString(); string Chr1 = ClsStr.getDiff(CCHr1, Chr0).ToString("F0"); string Chr2 = ClsStr.getPercent(Chr0, CCHr1).ToString("F0"); m.OmitCount0 = CCHr1; //总 m.OmitCount1 = Chr0; //完成 m.OmitCount2 = Chr1; //未完成 m.OmitCount3 = Chr2 + "%"; //完成率 } result.Add(m); } } dtHU.Clear(); dtHU.Dispose(); dtPatrol.Clear(); dtPatrol.Dispose(); dtOrg.Clear(); dtOrg.Dispose(); 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> /// 考勤统计 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">参见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="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> /// 导出 /// </summary> /// <returns></returns> public FileResult OutRaiLExportExcel() { OutRaiLCount_SW sw = new OutRaiLCount_SW(); sw.TopORGNO = Request.Params["BYORGNO"]; sw.DateBegin = Request.Params["TIMEBegin"]; sw.DateEnd = Request.Params["TIMEEnd"]; var list = HUCheckCls.getOutRaiLCountModel(sw); DateTime dt1 = Convert.ToDateTime(sw.DateBegin); DateTime dt2 = Convert.ToDateTime(sw.DateEnd); int days = ClsStr.getDateDiff(sw.DateBegin, sw.DateEnd) + 1;//日期包含天数 //vMenu.MENUNAME 页面/菜单名称 NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); //添加一个sheet NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1"); sheet1.IsPrintGridlines = true; //打印时显示网格线 sheet1.DisplayGridlines = true; //查看时显示网格线 sheet1.SetColumnWidth(0, 30 * 256); sheet1.SetColumnWidth(1, 10 * 256); for (int i = 0; i < days; i++) { sheet1.SetColumnWidth(i + 2, 10 * 256); } IRow row = sheet1.CreateRow(0); row.CreateCell(0).SetCellValue("出围统计表"); row.GetCell(0).CellStyle = getCellStyleTitle(book); row = sheet1.CreateRow(1); row.CreateCell(0).SetCellValue("单位/姓名"); row.CreateCell(1).SetCellValue("出围合计"); row.CreateCell(2).SetCellValue("日期(日)"); row.GetCell(0).CellStyle = getCellStyleHead(book); row.GetCell(1).CellStyle = getCellStyleHead(book); row.GetCell(2).CellStyle = getCellStyleHead(book); row = sheet1.CreateRow(2); for (int i = 0; i < days; i++) { DateTime tm = dt1.AddDays(i); row.CreateCell(i + 2).SetCellValue(tm.ToString("dd")); row.GetCell(i + 2).CellStyle = getCellStyleHead(book); } sheet1.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0, 0, 0, days + 1)); sheet1.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(1, 1, 2, days - 2)); sheet1.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(1, 2, 0, 0)); sheet1.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(1, 2, 1, 1)); int rowI = 0; foreach (var v in list) { row = sheet1.CreateRow(rowI + 3); row.CreateCell(0).SetCellValue(v.ORGName); row.CreateCell(1).SetCellValue(v.Count); string[] arr = v.DayCountList.Split(','); for (int i = 0; i < days; i++) { row.CreateCell(i + 2).SetCellValue(arr[i]); } rowI++; } // 写入到客户端 System.IO.MemoryStream ms = new System.IO.MemoryStream(); book.Write(ms); ms.Seek(0, SeekOrigin.Begin); string fileName = "出围统计表" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls"; return(File(ms, "application/vnd.ms-excel", fileName)); }
/// <summary> /// 怠工统计Json /// </summary> /// <returns></returns> public ActionResult getSabotageCountJson() { SabotageCount_SW sw = new SabotageCount_SW(); //sw.ORGNO = Request.Params["BYORGNO"]; sw.TopORGNO = Request.Params["BYORGNO"]; sw.DateBegin = Request.Params["TIMEBegin"]; sw.DateEnd = Request.Params["TIMEEnd"]; DateTime dt1 = Convert.ToDateTime(sw.DateBegin); DateTime dt2 = Convert.ToDateTime(sw.DateEnd); int days = ClsStr.getDateDiff(sw.DateBegin, sw.DateEnd) + 1;//日期包含天数 StringBuilder sb = new StringBuilder(); sb.AppendFormat("<table id=\"tb\" cellpadding=\"0\" cellspacing=\"0\">"); sb.AppendFormat("<thead>"); sb.AppendFormat(" <tr>"); sb.AppendFormat(" <th rowspan=\"2\">单位<br>(姓名)</th>"); sb.AppendFormat(" <th rowspan=\"2\">总数</th>"); sb.AppendFormat(" <th colspan=\"{1}\">{0}</th>", "日期(日)", days.ToString()); sb.AppendFormat(" <th rowspan=\"2\">正常</th>"); sb.AppendFormat(" <th rowspan=\"2\">怠工</th>"); sb.AppendFormat(" <th rowspan=\"2\">完成率(%)</th>"); sb.AppendFormat(" </tr>"); sb.AppendFormat(" <tr>"); for (DateTime tm = dt1; tm <= dt2; tm = tm.AddDays(1)) { sb.AppendFormat(" <th>{0}</th>", tm.ToString("dd")); } sb.AppendFormat(" </tr>"); sb.AppendFormat("</thead>"); sb.AppendFormat("<tbody>"); var list = HUCheckCls.getSabotageCountModel(sw); int j = 0; foreach (var v in list) { string orgName = v.ORGName; string orgNo = v.ORGNo; //bool isHU = false; //if (PublicCls.OrgIsZhen(sw.TopORGNO) == true && orgName.Contains("合计") == false) //{ // isHU = true; //} j++; if (j % 2 == 0) { sb.AppendFormat("<tr>"); } else { sb.AppendFormat("<tr class='row1'>"); } sb.AppendFormat("<td class=\"center\">{0}</td>", v.ORGName + ""); // sb.AppendFormat("<td class=\"center\">{0}</td>", v.Count + ""); //总 string[] arr1 = v.DayCountList.Split(','); for (int i = 0; i < days; i++) { //if (isHU == true) //{ //arr1[i] = (arr1[i] == "0") == true ? "正常" : ""; //} sb.AppendFormat("<td class=\"center\">{0}</td>", arr1[i]); } sb.AppendFormat("<td class=\"center\">{0}</td>", v.Count0 + ""); //完成 sb.AppendFormat("<td class=\"center\">{0}</td>", v.Count1 + ""); //未完成 sb.AppendFormat("<td class=\"center\">{0}</td>", v.CountPer + ""); //完成率 sb.AppendFormat("</tr>"); } return(Content(JsonConvert.SerializeObject(new Message(true, sb.ToString(), "")), "text/html;charset=UTF-8")); }