Пример #1
0
        /// <summary>
        /// 生成一个维保工单
        /// </summary>
        /// <param name="plan_model">计划对象</param>
        public static void AddMaintenanceOrder(EccmPlanModel plan_model)
        {
            EccmPlanBLL plan_bll = new EccmPlanBLL();

            //获取设备
            string    equCodes = "";
            DataTable dt       = plan_bll.GetPlanDeviceCode(plan_model.plan_id, Convert.ToInt32(plan_model.choose_type));

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                equCodes += dt.Rows[i][0].ToString() + ",";
            }
            equCodes = equCodes.Substring(0, equCodes.Length - 1);

            //生成工单
            EccmMaintenanceOrderModel model = new EccmMaintenanceOrderModel();

            model.order_sn     = GetOrderSN("WB");
            model.order_stats  = 0;
            model.order_time   = DateTime.Now;
            model.order_type   = 0;
            model.term_order   = DateTime.Now.AddDays(Convert.ToInt32(plan_model.term_day));
            model.community_id = Convert.ToInt32(plan_model.communityID);
            model.uid          = Convert.ToInt32(plan_model.uid);
            model.plan_id      = plan_model.plan_id;

            EccmMaintenanceOrderBLL order_bll = new EccmMaintenanceOrderBLL();

            PlanLog(plan_model, order_bll.Add(model, equCodes));
        }
Пример #2
0
        /// <summary>
        /// 更改计划状态
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string UpdateStates(HttpContext context)
        {
            var jr = new JsonResultModel <int>()
            {
                IsSucceed   = false,
                Data        = 0,
                Msg         = "更改失败",
                RedirectUrl = string.Empty
            };

            //获取传递参数
            string planID = context.Request.Params["planid"];
            string states = context.Request.Params["planstats"];

            EccmPlanModel model = new EccmPlanModel();

            model.plan_id    = int.Parse(planID);
            model.plan_stats = int.Parse(states);

            EccmPlanBLL bll = new EccmPlanBLL();

            if (bll.UpdataStates(model))//更改计划状态
            {
                jr.IsSucceed = true;
                jr.Msg       = "更改成功";
            }

            return(JsonConvert.SerializeObject(jr));
        }
Пример #3
0
        /// <summary>
        /// 删除计划
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string DeletePlan(HttpContext context)
        {
            var jr = new JsonResultModel <int>()
            {
                IsSucceed   = false,
                Data        = 0,
                Msg         = "删除失败",
                RedirectUrl = string.Empty
            };

            //获取传递参数
            string planID = context.Request.Params["planID"];

            EccmPlanModel model = new EccmPlanModel();

            model.plan_id   = int.Parse(planID);
            model.is_delete = 1;

            EccmPlanBLL bll = new EccmPlanBLL();

            if (bll.Delete(model))//删除该id计划
            {
                jr.IsSucceed = true;
                jr.Msg       = "删除成功";
            }

            return(JsonConvert.SerializeObject(jr));
        }
Пример #4
0
        /// <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));
        }
Пример #5
0
        /// <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
                {
                }
            }
        }
Пример #6
0
        /// <summary>
        /// 添加计划
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string AddPlan(HttpContext context)
        {
            var jr = new JsonResultModel <int>()
            {
                IsSucceed   = false,
                Data        = 0,
                Msg         = "添加失败",
                RedirectUrl = string.Empty
            };

            #region  递参数处理为对象
            //获取传递参数
            string        plancycle          = context.Request.Params["plancycle"];
            string        planrole           = context.Request.Params["planrole"];
            string        executionfrequency = context.Request.Params["executionfrequency"];
            string        term_day           = context.Request.Params["term_day"];
            string        planstime          = context.Request.Params["planstime"];
            string        planetime          = context.Request.Params["planetime"];
            string        communityID        = context.Request.Params["communityID"];
            string        planstats          = context.Request.Params["planstats"];
            string        choosetype         = context.Request.Params["choosetype"];
            string        plantype           = context.Request.Params["plantype"];
            string        Codes = context.Request.Params["Codes"];
            EccmPlanModel model = new EccmPlanModel();
            model.plan_cycle          = int.Parse(plancycle);
            model.plan_role           = planrole;
            model.execution_frequency = int.Parse(executionfrequency);
            model.term_day            = int.Parse(term_day);
            model.plan_stime          = DateTime.Parse(planstime);
            if (planetime != "")
            {
                model.plan_etime = DateTime.Parse(planetime);
            }
            model.communityID     = int.Parse(communityID);
            model.plan_stats      = int.Parse(planstats);
            model.choose_type     = int.Parse(choosetype);
            model.plan_type       = int.Parse(plantype);
            model.plan_creat_time = DateTime.Now;
            model.is_delete       = 0;
            #endregion
            HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"];
            if (cook != null)
            {
                //解密Cookie
                HttpCookie decodeCookie = HttpSecureCookie.Decode(cook);
                string     uid          = decodeCookie.Values["userid"];
                //给对象赋值
                model.uid = int.Parse(uid);
            }
            EccmPlanBLL bll = new EccmPlanBLL();
            int         id  = bll.Add(model); //添加计划并获取id
            if (id > 0)                       //添加计划成功
            {
                if (model.choose_type == 0)   //设备类型
                {
                    EccmPlanDevicetypeModel pdt_model = new EccmPlanDevicetypeModel();
                    pdt_model.community_id     = model.communityID;
                    pdt_model.plan_id          = id;
                    pdt_model.system_type_code = Codes;

                    EccmPlanDevicetypeBLL pdt_bll = new EccmPlanDevicetypeBLL();
                    if (pdt_bll.Add(pdt_model))
                    {
                        jr.IsSucceed = true;
                        jr.Msg       = "添加成功";
                    }
                }
                else if (model.choose_type == 1)//设备
                {
                    EccmPlanDeviceModel pd_model = new EccmPlanDeviceModel();
                    pd_model.community_id = model.communityID;
                    pd_model.plan_id      = id;
                    pd_model.equCode      = Codes;

                    EccmPlanDeviceBLL pd_bll = new EccmPlanDeviceBLL();
                    if (pd_bll.Add(pd_model))
                    {
                        jr.IsSucceed = true;
                        jr.Msg       = "添加成功";
                    }
                }
            }

            return(JsonConvert.SerializeObject(jr));
        }