/// <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> /// <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)); }
/// <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 { } } }