/// <summary> /// 生成一个巡检工单 /// </summary> /// <param name="plan_model">计划对象</param> public static void AddInspectionOrder(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); //生成工单 EccmInspectionOrderModel model = new EccmInspectionOrderModel(); model.order_sn = GetOrderSN("XJ"); model.order_stats = 0; model.order_time = DateTime.Now; model.order_type = 0; model.term_time = DateTime.Now.AddDays(Convert.ToInt32(plan_model.term_day)); model.community_id = plan_model.communityID; model.uid = plan_model.uid; model.plan_id = plan_model.plan_id; EccmInspectionOrderBLL order_bll = new EccmInspectionOrderBLL(); PlanLog(plan_model, order_bll.Add(model, equCodes)); }
/// <summary> /// 更新改订单状态 /// </summary> public bool UpdateStates(EccmInspectionOrderModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update eccm_inspection_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); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(EccmInspectionOrderModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update eccm_inspection_order set "); strSql.Append("order_sn=@order_sn,"); strSql.Append("order_type=@order_type,"); strSql.Append("order_time=@order_time,"); strSql.Append("term_time=@term_time,"); strSql.Append("order_finish_time=@order_finish_time,"); strSql.Append("community_id=@community_id,"); strSql.Append("order_stats=@order_stats,"); strSql.Append("uid_dispatch=@uid_dispatch,"); strSql.Append("ext1=@ext1,"); strSql.Append("ext2=@ext2,"); strSql.Append("ext3=@ext3,"); strSql.Append("uid=@uid"); strSql.Append(" where order_id=@order_id"); MySqlParameter[] parameters = { new MySqlParameter("@order_sn", MySqlDbType.VarChar, 32), new MySqlParameter("@order_type", MySqlDbType.Int32, 11), new MySqlParameter("@order_time", MySqlDbType.DateTime), new MySqlParameter("@term_time", MySqlDbType.DateTime), new MySqlParameter("@order_finish_time", MySqlDbType.DateTime), new MySqlParameter("@community_id", MySqlDbType.Int32, 11), new MySqlParameter("@order_stats", MySqlDbType.Int32, 11), new MySqlParameter("@uid_dispatch", MySqlDbType.Int32, 11), new MySqlParameter("@ext1", MySqlDbType.VarChar, 50), new MySqlParameter("@ext2", MySqlDbType.VarChar, 50), new MySqlParameter("@ext3", MySqlDbType.VarChar, 50), new MySqlParameter("@uid", MySqlDbType.Int32), new MySqlParameter("@order_id", MySqlDbType.Int32) }; parameters[0].Value = model.order_sn; parameters[1].Value = model.order_type; parameters[2].Value = model.order_time; parameters[3].Value = model.term_time; parameters[4].Value = model.order_finish_time; parameters[5].Value = model.community_id; parameters[6].Value = model.order_stats; parameters[7].Value = model.uid_dispatch; parameters[8].Value = model.ext1; parameters[9].Value = model.ext2; parameters[10].Value = model.ext3; parameters[11].Value = model.uid; parameters[12].Value = model.order_id; int rows = MySQLHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 添加巡检实施 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddInspectionImplement(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维修 //给对象赋值 EccmInspectionOrderImplementModel model = new EccmInspectionOrderImplementModel(); model.order_id = int.Parse(orderid); model.equCode = "";//该处没有设备编码 model.implement_content = content; model.implement_time = DateTime.Now; model.uid_handle = int.Parse(uid); EccmInspectionOrderImplementBLL bll = new EccmInspectionOrderImplementBLL(); int id = bll.Add(model); //插入并获取id if (id > 0) //实施内容插入成功 { EccmImplementImgModel img_model = new EccmImplementImgModel(); img_model.implement_id = id; img_model.img_path = imgurl; img_model.img_type = int.Parse(type);; //1巡检2维保3维修 EccmImplementImgBLL img_bll = new EccmImplementImgBLL(); if (img_bll.Add(img_model)) //插入实施图片 { EccmInspectionOrderModel inspection_model = new EccmInspectionOrderModel(); inspection_model.order_id = int.Parse(orderid); inspection_model.order_stats = 4;//0未派单1已派单2已接单3处理中4完成 inspection_model.order_finish_time = DateTime.Now; EccmInspectionOrderBLL inspection_bll = new EccmInspectionOrderBLL(); inspection_bll.UpdateStates(inspection_model);//更改订单为完成 jr.IsSucceed = true; jr.Msg = "添加成功"; } } } return(JsonConvert.SerializeObject(jr)); }
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(); } EccmInspectionOrderModel 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_time.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());; } }
/// <summary> /// 新增巡检工单 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddInspectionOrder(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("XJ"); HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; //给对象赋值 EccmInspectionOrderModel model = new EccmInspectionOrderModel(); model.order_sn = orderSn; model.order_stats = 0; model.order_time = DateTime.Now; model.order_type = 0; model.term_time = DateTime.Parse(termtime); model.community_id = communityID; model.uid = int.Parse(uid); //model.plan_id = 0;//手动增加工单时,该字段为0 if (_inspectionBLL.Add(model, equCodes)) { jr.IsSucceed = true; jr.Msg = "新增成功"; } } return(JsonConvert.SerializeObject(jr)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(EccmInspectionOrderModel model, string equCodes) { List <string> cmdlist = new List <string>(); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into eccm_inspection_order("); strSql.Append("order_sn,order_type,order_time,term_time,order_finish_time,community_id,order_stats,uid_dispatch,ext1,ext2,ext3,uid,plan_id)"); strSql.Append(" values ("); strSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')", model.order_sn, model.order_type, model.order_time, model.term_time, model.order_finish_time, model.community_id, model.order_stats, model.uid_dispatch, model.ext1, model.ext2, model.ext3, model.uid, model.plan_id); 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,1 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 = 1 "); 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 = Common.MySQLHelper.ExecuteSqlByTran(cmdlist); if (rows > 0) { return(true); } else { return(false); } }
/// <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 { } } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(EccmInspectionOrderModel model, string equCodes) { return(dal.Add(model, equCodes)); }
/// <summary> /// 得到一个对象实体 /// </summary> public EccmInspectionOrderModel DataRowToModel(DataRow row) { EccmInspectionOrderModel model = new EccmInspectionOrderModel(); 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_time"] != null && row["term_time"].ToString() != "") { model.term_time = DateTime.Parse(row["term_time"].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); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(EccmInspectionOrderModel model, string equCodes) { List <string> cmdlist = new List <string>(); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into eccm_inspection_order("); strSql.Append("order_sn,order_type,order_time,term_time,order_finish_time,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}','{11}')", model.order_sn, model.order_type, model.order_time, model.term_time, model.order_finish_time, model.community_id, model.order_stats, model.uid_dispatch, model.ext1, model.ext2, model.ext3, model.uid); //MySqlParameter[] parameters = { // new MySqlParameter("@order_sn", MySqlDbType.VarChar,32), // new MySqlParameter("@order_type", MySqlDbType.Int32,11), // new MySqlParameter("@order_time", MySqlDbType.DateTime), // new MySqlParameter("@term_time", MySqlDbType.DateTime), // new MySqlParameter("@order_finish_time", MySqlDbType.DateTime), // new MySqlParameter("@community_id", MySqlDbType.Int32,11), // new MySqlParameter("@order_stats", MySqlDbType.Int32,11), // new MySqlParameter("@uid_dispatch", MySqlDbType.Int32,11), // new MySqlParameter("@ext1", MySqlDbType.VarChar,50), // new MySqlParameter("@ext2", MySqlDbType.VarChar,50), // new MySqlParameter("@ext3", MySqlDbType.VarChar,50), // new MySqlParameter("@uid", MySqlDbType.Int32)}; //parameters[0].Value = model.order_sn; //parameters[1].Value = model.order_type; //parameters[2].Value = model.order_time; //parameters[3].Value = model.term_time; //parameters[4].Value = model.order_finish_time; //parameters[5].Value = model.community_id; //parameters[6].Value = model.order_stats; //parameters[7].Value = model.uid_dispatch; //parameters[8].Value = model.ext1; //parameters[9].Value = model.ext2; //parameters[10].Value = model.ext3; //parameters[11].Value = 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,1 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 = 1 "); 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); } }
/// <summary> /// 更新改订单状态 /// </summary> public bool UpdateStates(EccmInspectionOrderModel model) { return(dal.UpdateStates(model)); }