示例#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));
        }
        /// <summary>
        /// 更新改订单状态
        /// </summary>
        public bool UpdateStates(EccmMaintenanceOrderModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update eccm_maintenance_order set ");
            strSql.Append("order_stats=@order_stats,");
            strSql.Append("order_finish_time=@order_finish_time");
            strSql.Append(" where order_id=@order_id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@order_stats",       MySqlDbType.Int32,     11),
                new MySqlParameter("@order_finish_time", MySqlDbType.DateTime),
                new MySqlParameter("@order_id",          MySqlDbType.Int32)
            };
            parameters[0].Value = model.order_stats;
            parameters[1].Value = model.order_finish_time;
            parameters[2].Value = model.order_id;

            int rows = MySQLHelper.ExecuteNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        /// <summary>
        /// 添加维保实施记录
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string AddMaintenanceImplement(HttpContext context)
        {
            var jr = new JsonResultModel <int>()
            {
                IsSucceed   = false,
                Data        = 0,
                Msg         = "添加失败",
                RedirectUrl = string.Empty
            };

            //获取传递参数
            string     orderid = context.Request.Params["orderid"];
            string     ordersn = context.Request.Params["ordersn"];
            string     content = context.Request.Params["content"];
            HttpCookie cook    = HttpContext.Current.Request.Cookies["EccmUserinfo"];

            if (cook != null)
            {
                //解密Cookie
                HttpCookie decodeCookie = HttpSecureCookie.Decode(cook);
                string     uid          = decodeCookie.Values["userid"];
                string     imgurl       = context.Request.Params["imgurl"];
                string     type         = context.Request.Params["type"];//1巡检2维保3维修

                //给对象赋值
                EccmMaintenanceOrderImplementModel model = new EccmMaintenanceOrderImplementModel();
                model.order_id          = int.Parse(orderid);
                model.equCode           = "";//该处没有设备编码
                model.implement_content = content;
                model.implement_time    = DateTime.Now;
                model.uid_handle        = int.Parse(uid);

                EccmMaintenanceOrderImplementBLL bll = new EccmMaintenanceOrderImplementBLL();
                int id = bll.Add(model); //插入并获取id
                if (id > 0)              //实施内容插入成功
                {
                    EccmImplementImgModel imgModel = new EccmImplementImgModel();
                    imgModel.implement_id = id;
                    imgModel.img_path     = imgurl;
                    imgModel.img_type     = int.Parse(type);; //1巡检2维保3维修
                    EccmImplementImgBLL img_bll = new EccmImplementImgBLL();
                    if (img_bll.Add(imgModel))                //插入实施图片
                    {
                        EccmMaintenanceOrderModel maintenanceModel = new EccmMaintenanceOrderModel();
                        maintenanceModel.order_id          = int.Parse(orderid);
                        maintenanceModel.order_stats       = 4;//0未派单1已派单2已接单3处理中4完成
                        maintenanceModel.order_finish_time = DateTime.Now;
                        EccmMaintenanceOrderBLL maintenanceBLL = new EccmMaintenanceOrderBLL();
                        maintenanceBLL.UpdateStates(maintenanceModel);//更改订单为完成
                        jr.IsSucceed = true;
                        jr.Msg       = "添加成功";
                    }
                }
            }
            return(JsonConvert.SerializeObject(jr));
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int orderID = string.IsNullOrEmpty(Request.Params["orderID"]) ? 0 : int.Parse(Request.Params["orderID"]);

            if (orderID == 0)
            {
                Response.Write("参数错误");
                Response.End();
            }
            EccmMaintenanceOrderModel    model = _bll.GetModel(orderID);
            List <EccmReceiverUserModel> list  = _userBLL.GetEccmReceiverUserList(orderID, 1);

            //订单基本信息
            if (model != null)
            {
                this.orderID.Value      = orderID.ToString();
                this.orderSN.Value      = model.order_sn;
                this.dispatchName.Value = model.dispatchName;
                this.createTime.Value   = model.order_time.ToString();
                this.termTime.Value     = model.term_order.ToString();
                this.endTime.Value      = "暂无完成";
                switch (model.order_stats)
                {
                case 0:
                    this.orderStatus.Value = "未派单";
                    break;

                case 1:
                    this.orderStatus.Value = "已派单";
                    break;

                case 2:
                    this.orderStatus.Value = "已接单";
                    break;

                case 3:
                    this.orderStatus.Value = "处理中";
                    break;

                case 4:
                    this.orderStatus.Value = "完成";
                    this.endTime.Value     = model.order_finish_time.ToString();
                    break;
                }
            }
            //责任人和协同人员
            if (list.Count > 0)
            {
                this.receiverName.Value      = list.Where(p => p.is_duty == 1).FirstOrDefault().nickName;
                this.coordinationNames.Value = string.Join(",", list.Where(p => p.is_duty == 0).Select(p => p.nickName).ToArray());;
            }
        }
示例#5
0
        /// <summary>
        /// 新增维保工单
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string AddMaintenanceOrder(HttpContext context)
        {
            var jr = new JsonResultModel <int>()
            {
                IsSucceed   = false,
                Data        = 0,
                Msg         = "新增失败",
                RedirectUrl = string.Empty
            };

            //获取传递参数
            string equCodes = context.Request.Params["equCodes"];
            string termtime = context.Request.Params["termtime"];
            //string reason = context.Request.Params["reason"];
            int        communityID = string.IsNullOrEmpty(context.Request.Params["communityID"]) ? 0 : int.Parse(context.Request.Params["communityID"]);
            string     orderSn     = OrderHelp.GetOrderSN("WB");
            HttpCookie cook        = HttpContext.Current.Request.Cookies["EccmUserinfo"];

            if (cook != null)
            {
                //解密Cookie
                HttpCookie decodeCookie = HttpSecureCookie.Decode(cook);
                string     uid          = decodeCookie.Values["userid"];
                //给对象赋值
                EccmMaintenanceOrderModel model = new EccmMaintenanceOrderModel();
                model.order_sn     = orderSn;
                model.order_stats  = 0;
                model.order_time   = DateTime.Now;
                model.order_type   = 0;
                model.term_order   = DateTime.Parse(termtime);
                model.community_id = communityID;
                model.uid          = int.Parse(uid);
                model.plan_id      = 0;//手动增加工单时,该字段为0

                if (_bll.Add(model, equCodes))
                {
                    jr.IsSucceed = true;
                    jr.Msg       = "新增成功";
                }
            }

            return(JsonConvert.SerializeObject(jr));
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(EccmMaintenanceOrderModel model, string equCodes)
        {
            List <string> cmdlist = new List <string>();
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("insert into eccm_maintenance_order(");
            strSql.Append("order_sn,order_type,order_time,term_order,community_id,order_stats,uid_dispatch,ext1,ext2,ext3,uid)");
            strSql.Append(" values (");
            strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')", model.order_sn, model.order_type, model.order_time, model.term_order, model.community_id, model.order_stats, model.uid_dispatch, model.ext1, model.ext2, model.ext3, model.uid);
            cmdlist.Add(strSql.ToString());


            StringBuilder strSql2 = new StringBuilder();

            strSql2.Append(" insert into eccm_order_device_standard(order_sn, equCode, device_standard, order_device_standard_type) ");
            strSql2.AppendFormat(" select '{0}',ei.equCode,s.inspection_standard,2 FROM equipmentinfo ei ", model.order_sn);
            strSql2.Append(" left join eccm_device_relation_standard drs ON ei.device_type_code = drs.device_type_code ");
            strSql2.Append(" left join eccm_standard s ON drs.standard_id = s.standard_id  and s.standard_type = 2 ");
            StringBuilder codes = new StringBuilder();

            foreach (string d in equCodes.Split(','))
            {
                codes.AppendFormat("'{0}',", d);
            }
            codes.Remove(codes.Length - 1, 1);
            strSql2.AppendFormat(" where ei.equCode in ({0}) ", codes);
            cmdlist.Add(strSql2.ToString());

            int rows = MySQLHelper.ExecuteSqlByTran(cmdlist);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#7
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
                {
                }
            }
        }
示例#8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(EccmMaintenanceOrderModel model, string equCodes)
 {
     return(_dal.Add(model, equCodes));
 }
 /// <summary>
 /// 更新改订单状态
 /// </summary>
 public bool UpdateStates(EccmMaintenanceOrderModel model)
 {
     return(_dal.UpdateStates(model));
 }
示例#10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public EccmMaintenanceOrderModel DataRowToModel(DataRow row)
        {
            EccmMaintenanceOrderModel model = new EccmMaintenanceOrderModel();

            if (row != null)
            {
                if (row["order_id"] != null && row["order_id"].ToString() != "")
                {
                    model.order_id = int.Parse(row["order_id"].ToString());
                }
                if (row["plan_id"] != null && row["plan_id"].ToString() != "")
                {
                    model.plan_id = int.Parse(row["plan_id"].ToString());
                }
                if (row["order_sn"] != null)
                {
                    model.order_sn = row["order_sn"].ToString();
                }
                if (row["order_type"] != null && row["order_type"].ToString() != "")
                {
                    model.order_type = int.Parse(row["order_type"].ToString());
                }
                if (row["order_time"] != null && row["order_time"].ToString() != "")
                {
                    model.order_time = DateTime.Parse(row["order_time"].ToString());
                }
                if (row["term_order"] != null && row["term_order"].ToString() != "")
                {
                    model.term_order = DateTime.Parse(row["term_order"].ToString());
                }
                if (row["order_finish_time"] != null && row["order_finish_time"].ToString() != "" && row["order_finish_time"].ToString() != "0000/0/0 0:00:00")
                {
                    model.order_finish_time = DateTime.Parse(row["order_finish_time"].ToString());
                }
                if (row["community_id"] != null && row["community_id"].ToString() != "")
                {
                    model.community_id = int.Parse(row["community_id"].ToString());
                }
                if (row["order_stats"] != null && row["order_stats"].ToString() != "")
                {
                    model.order_stats = int.Parse(row["order_stats"].ToString());
                }
                if (row["uid_dispatch"] != null && row["uid_dispatch"].ToString() != "")
                {
                    model.uid_dispatch = int.Parse(row["uid_dispatch"].ToString());
                }
                if (row["ext1"] != null)
                {
                    model.ext1 = row["ext1"].ToString();
                }
                if (row["ext2"] != null)
                {
                    model.ext2 = row["ext2"].ToString();
                }
                if (row["ext3"] != null)
                {
                    model.ext3 = row["ext3"].ToString();
                }
                if (row["uid"] != null && row["uid"].ToString() != "")
                {
                    model.uid = int.Parse(row["uid"].ToString());
                }
                if (row["dispatchName"] != null && row["dispatchName"].ToString() != "")
                {
                    model.dispatchName = row["dispatchName"].ToString();
                }
            }
            return(model);
        }