/// <summary> /// 查询计划 /// </summary> /// <param name="context"></param> /// <returns></returns> private string GetPlan(HttpContext context) { var jr = new JsonResultModel <DataTable>() { IsSucceed = false, Data = null, Msg = "查询失败", RedirectUrl = string.Empty }; #region 分页参数 int pagesize = 1; int pageindex = 1; string _pindex = context.Request.Params["pageNumber"]; string _psize = context.Request.Params["pageSize"]; if (!string.IsNullOrEmpty(_pindex)) { pageindex = int.Parse(_pindex); } if (!string.IsNullOrEmpty(_psize)) { pagesize = int.Parse(_psize); } #endregion #region 查询条件 int communityID = string.IsNullOrEmpty(context.Request.Params["communityID"]) ? 0 : int.Parse(context.Request.Params["communityID"]); string timespan = context.Request.Params["timeSpan"]; var ts = System.Text.RegularExpressions.Regex.Matches(timespan, "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}"); DateTime begintime = DateTime.Parse(ts[0].Value); DateTime endtime = DateTime.Parse(ts[1].Value).AddDays(1); StringBuilder strWhere = new StringBuilder(); strWhere.AppendFormat(" and p.plan_creat_time>='{0}' and p.plan_creat_time<='{1}'", begintime, endtime); strWhere.AppendFormat(" and p.communityID={0} ", communityID); strWhere.Append(" and p.is_delete=0 "); if (strWhere.Length > 0) { strWhere.Remove(0, 4); } #endregion EccmPlanBLL bll = new EccmPlanBLL(); int rowcount = 0; var pr = new PagingResultModel <DataTable>() { total = 0, rows = new DataTable() }; DataTable dt = bll.GetPlanList(strWhere.ToString(), pageindex, pagesize, out rowcount); pr.rows = dt; pr.total = rowcount; return(JsonConvert.SerializeObject(pr)); }
/// <summary> /// 执行计划 /// </summary> public static void BulidOrder() { /** step1:获取计划列表 */ EccmPlanBLL plan_bll = new EccmPlanBLL(); List <EccmPlanModel> plan_list = plan_bll.GetPlanList(); /** step2:循环计划列表,进行逻辑判断 */ foreach (EccmPlanModel plan_model in plan_list) { /** step3: 判断是巡检还是维保 plan_type:1巡检,2维保 */ if (plan_model.plan_type == 1)//巡检 { /** step4: 获取最后一次计划生成的工单 */ EccmInspectionOrderBLL order_bll = new EccmInspectionOrderBLL(); EccmInspectionOrderModel order_model = new EccmInspectionOrderModel(); order_model = order_bll.GetModel(plan_model.plan_id); if (order_model == null)//该计划从未生成过工单 { /** step5: 生成一个新的工单 */ AddInspectionOrder(plan_model); } else { if (plan_model.plan_cycle == 1)//当计划为重复执行时,才进入下面流程 { /** step5: 判断时间间隔,是否生成一个新的工单 */ DateTime order_time = Convert.ToDateTime(order_model.order_time); //工单时间 DateTime now_time = DateTime.Now; //当前时间 if (TimeLogic(plan_model, now_time, order_time)) //当为true时 生成新工单 { //生成新工单 AddInspectionOrder(plan_model); } } } } else if (plan_model.plan_type == 2)//维保 { /** step4: 获取最后一次计划生成的工单 */ EccmMaintenanceOrderBLL order_bll = new EccmMaintenanceOrderBLL(); EccmMaintenanceOrderModel order_model = new EccmMaintenanceOrderModel(); order_model = order_bll.GetModel(plan_model.plan_id); /** step4: 判断最后一次计划生成的工单,是否生成新的工单 */ if (order_model == null)//该计划从未生成过工单 { /** step5: 生成一个新的工单 */ AddMaintenanceOrder(plan_model); } else { if (plan_model.plan_cycle == 1)//当计划为重复执行时,才进入下面流程 { /** step5: 判断时间间隔,是否生成一个新的工单 */ DateTime order_time = Convert.ToDateTime(order_model.order_time); //工单时间 DateTime now_time = DateTime.Now; //当前时间 if (TimeLogic(plan_model, now_time, order_time)) //当为true时 生成新工单 { //生成一个新工单 AddMaintenanceOrder(plan_model); } } } } else { } } }