Ejemplo n.º 1
0
        /// <summary>
        /// 获取作业报告列表
        /// </summary>
        /// <param name="status">作业报告状态</param>
        /// <param name="urgency">派工单紧急程度</param>
        /// <param name="filterField">搜索条件</param>
        /// <param name="filterText">搜索框填写内容</param>
        /// <param name="sortField">排序字段</param>
        /// <param name="sortDirection">排序方式</param>
        /// <param name="curRowNum">当前页数第一个数据的位置</param>
        /// <param name="pageSize">一页几条数据</param>
        /// <returns>作业报告列表</returns>
        public List <DispatchReportInfo> QueryDispatchReports(int status, int urgency, string filterField, string filterText, string sortField, bool sortDirection, int curRowNum = 0, int pageSize = 0)
        {
            List <DispatchReportInfo> dispatches = new List <DispatchReportInfo>();

            sqlStr = "SELECT DISTINCT d.*,r.ID AS DispatchReportID , r.StatusID AS DispatchReportStatusID ,j.ID as DispatchJournalID, j.StatusID AS DispatchJournalStatusID " +
                     " FROM tblDispatchReport r " +
                     " LEFT JOIN tblDispatch d ON d.ID = r.DispatchID " +
                     " LEFT JOIN tblDispatchJournal j ON d.ID = j.DispatchID " +
                     " WHERE 1=1 ";
            if (status != 0)
            {
                sqlStr += " AND r.StatusID=" + status;
            }
            else
            {
                sqlStr += " AND r.StatusID <> " + DispatchReportInfo.DispatchReportStatus.Cancelled;
            }
            if (urgency != 0)
            {
                sqlStr += " AND d.UrgencyID=" + urgency;
            }

            if (!string.IsNullOrEmpty(filterText))
            {
                sqlStr += GetFieldFilterClause(filterField);
            }

            sqlStr += GenerateSortClause(sortDirection, sortField, "r.ID");

            sqlStr = AppendLimitClause(sqlStr, curRowNum, pageSize);
            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                if (!String.IsNullOrEmpty(filterText))
                {
                    AddFieldFilterParam(command, filterField, filterText);
                }

                using (DataTable dt = GetDataTable(command))
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        DispatchReportInfo dispatchReport = new DispatchReportInfo();
                        dispatchReport.ID          = SQLUtil.ConvertInt(dr["DispatchReportID"]);
                        dispatchReport.Status.ID   = SQLUtil.ConvertInt(dr["DispatchReportStatusID"]);
                        dispatchReport.Status.Name = LookupManager.GetDispatchDocStatusDesc(dispatchReport.Status.ID);

                        dispatchReport.Dispatch.ID               = SQLUtil.ConvertInt(dr["ID"]);
                        dispatchReport.Dispatch.Request.ID       = SQLUtil.ConvertInt(dr["RequestID"]);
                        dispatchReport.Dispatch.RequestType.ID   = SQLUtil.ConvertInt(dr["RequestType"]);
                        dispatchReport.Dispatch.RequestType.Name = LookupManager.GetRequestTypeDesc(dispatchReport.Dispatch.RequestType.ID);
                        dispatchReport.Dispatch.Urgency.ID       = SQLUtil.ConvertInt(dr["UrgencyID"]);
                        dispatchReport.Dispatch.Urgency.Name     = LookupManager.GetUrgencyDesc(dispatchReport.Dispatch.Urgency.ID);
                        dispatchReport.Dispatch.ScheduleDate     = SQLUtil.ConvertDateTime(dr["ScheduleDate"]);
                        dispatchReport.Dispatch.EndDate          = SQLUtil.ConvertDateTime(dr["EndDate"]);
                        dispatches.Add(dispatchReport);
                    }
                }
            }
            return(dispatches);
        }
Ejemplo n.º 2
0
        public JsonResult SaveDispatchReport(DispatchReportInfo dispatchReport)
        {
            ResultModelBase result = new ResultModelBase();

            if (CheckSession() == false)
            {
                return(Json(ResultModelBase.CreateTimeoutModel(), JsonRequestBehavior.AllowGet));
            }
            if (CheckSessionID() == false)
            {
                return(Json(ResultModelBase.CreateLogoutModel(), JsonRequestBehavior.AllowGet));
            }
            try
            {
                DispatchInfo dispatch = this.dispatchManager.GetDispatchByID(dispatchReport.Dispatch.ID);
                if (dispatch.DispatchReport.Status.ID != DispatchInfo.DocStatus.New)
                {
                    result.SetFailed(ResultCodes.ParameterError, "不可重复提交");
                }
                else
                {
                    this.dispatchManager.SaveDispatchReport(dispatchReport, GetLoginUser());
                }
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(JsonResult(result));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 作业报告填写/审批/查看页面
 /// </summary>
 /// <param name="actionName">父级页面名称</param>
 /// <param name="dispatchID">派工单编号</param>
 /// <param name="dispatchReportID">作业报告编号</param>
 /// <param name="dispatchJournalID">服务凭证编号</param>
 /// <param name="requestType">派工类型</param>
 /// <returns>作业报告填写/审批/查看页面</returns>
 public ActionResult DispatchReportDetail(string actionName = "", int dispatchID = 0, int dispatchReportID = 0, int dispatchJournalID = 0, int requestType = 0)
 {
     if (!CheckSession())
     {
         Response.Redirect(Url.Action(ConstDefinition.HOME_ACTION, ConstDefinition.HOME_CONTROLLER), true);
         return(null);
     }
     ViewBag.ActionName        = actionName;
     ViewBag.DispatchID        = dispatchID;
     ViewBag.DispatchJournalID = dispatchJournalID;
     ViewBag.RequestType       = requestType;
     if (dispatchReportID == 0)
     {
         int existsReportID = this.dispatchDao.GetDispatchByID(dispatchID).DispatchReport.ID;
         if (existsReportID == 0)
         {
             DispatchReportInfo dispatchReport = new DispatchReportInfo();
             dispatchReport.Type        = DispatchReportInfo.DispatchReportTypes.GetDispatchReportType(requestType);
             dispatchReport.Status.ID   = DispatchReportInfo.DispatchReportStatus.New;
             dispatchReport.Status.Name = LookupManager.GetDispatchDocStatusDesc(dispatchReport.Status.ID);
             dispatchReport.Dispatch.ID = dispatchID;
             dispatchReportID           = this.dispatchManager.SaveDispatchReport(dispatchReport, GetLoginUser());
         }
         else
         {
             dispatchReportID = existsReportID;
         }
     }
     ViewBag.ID = dispatchReportID;
     return(View());
 }
Ejemplo n.º 4
0
        public JsonResult ApproveDispatchReport(DispatchReportInfo info, int userID, string sessionID) //comments是审批备注
        {
            ServiceResultModelBase response = new ServiceResultModelBase();

            try
            {
                if (!CheckSessionID(userID, sessionID, response))
                {
                    return(MyJson(response, JsonRequestBehavior.AllowGet));
                }
                UserInfo user = null;
                if (CheckUser(userID, response, out user, UserRole.SuperAdmin) == false)
                {
                    return(MyJson(response, JsonRequestBehavior.AllowGet));
                }

                if (info == null)
                {
                    response.SetFailed(ResultCodes.ParameterError, "作业报告不存在");
                }
                else if (info.Status.ID != DispatchReportInfo.DispatchReportStatus.Pending)
                {
                    response.SetFailed(ResultCodes.ParameterError, "作业报告状态非待审批");
                }
                else if (info.SolutionResultStatus.ID < DispatchReportInfo.SolutionResultStatuses.Allocating || info.SolutionResultStatus.ID > DispatchReportInfo.SolutionResultStatuses.Resolved)
                {
                    response.SetFailed(ResultCodes.ParameterError, "作业结果不存在");
                }
                else
                {
                    if (info.FileInfo != null)
                    {
                        info.FileInfo.FileContent = ParseBase64String(info.FileInfo.FileContent);
                    }
                    if (info.ReportAccessories != null)
                    {
                        foreach (ReportAccessoryInfo item in info.ReportAccessories)
                        {
                            if (item.FileInfos != null && item.FileInfos.Count > 0)
                            {
                                foreach (UploadFileInfo fileInfo in item.FileInfos)
                                {
                                    fileInfo.FileContent = ParseBase64String(fileInfo.FileContent);
                                }
                            }
                        }
                    }
                    this.dispatchManager.PassDispatchReport4App(info, user);
                }
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                response.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(MyJson(response, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public void PassDispatchReport(DispatchReportInfo info, UserInfo user)
        {
            info.Status.ID = DispatchInfo.DocStatus.Approved;
            this.dispatchReportDao.UpdateDispatchReport(info);

            HistoryInfo history = new HistoryInfo(info.ID, ObjectTypes.DispatchReport, user.ID, DispatchReportInfo.Actions.Pass, info.FujiComments);

            this.historyDao.AddHistory(history);

            UpdateDispatchStatusByJournalAndReport(info.Dispatch.ID, user);
        }
Ejemplo n.º 6
0
        public void RejectDispatchReport4App(DispatchReportInfo info, UserInfo user)
        {
            info.Status.ID = DispatchReportInfo.DispatchReportStatus.New;
            SaveDispatchReport4App(info, user);

            UpdateDispatchStatusByJournalAndReport(info.Dispatch.ID, user);

            HistoryInfo history = new HistoryInfo(info.ID, ObjectTypes.DispatchReport, user.ID, DispatchReportInfo.Actions.Reject, info.FujiComments);

            this.historyDao.AddHistory(history);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 根据作业报告id获取作业报告信息
        /// </summary>
        /// <param name="dispatchReportID">作业报告编号</param>
        /// <returns>作业报告信息</returns>
        public DispatchReportInfo GetDispatchReportByID(int dispatchReportID)
        {
            DispatchReportInfo dispatchReport = dispatchReportDao.GetDispatchReportByID(dispatchReportID);
            DispatchInfo       dispatchInfo   = this.dispatchDao.GetDispatchByID(dispatchReport.Dispatch.ID);

            dispatchReport.Dispatch = dispatchInfo.Copy4Base();
            if (dispatchReport != null)
            {
                UploadFileInfo fileInfo = this.fileDao.GetFile(ObjectTypes.DispatchReport, dispatchReport.ID);
                if (fileInfo != null)
                {
                    dispatchReport.FileInfo = fileInfo;
                }
                else
                {
                    dispatchReport.FileInfo = new UploadFileInfo();
                }

                List <HistoryInfo> histories = this.historyDao.GetHistories(ObjectTypes.DispatchReport, dispatchReport.ID);
                if (histories != null && histories.Count > 0)
                {
                    foreach (HistoryInfo history in histories)
                    {
                        history.Action.Name = DispatchReportInfo.Actions.GetDesc(history.Action.ID);
                    }
                    dispatchReport.Histories = histories;
                    dispatchReport.SetHis4Comments();
                }

                dispatchReport.ReportComponent = dispatchReportDao.GetReportComponentByDispatchReportID(dispatchReport.ID);
                if (dispatchReport.ReportComponent.Count > 0)
                {
                    foreach (ReportComponentInfo component in dispatchReport.ReportComponent)
                    {
                        component.FileInfos = this.fileDao.GetFiles(ObjectTypes.ReportAccessory, component.ID);
                    }
                }
                dispatchReport.ReportConsumable = dispatchReportDao.GetReportConsumableByDispatchReportID(dispatchReport.ID);
                dispatchReport.ReportService    = dispatchReportDao.GetReportServiceByDispatchReportID(dispatchReport.ID);
            }
            return(dispatchReport);
        }
Ejemplo n.º 8
0
        public int SaveDispatchReport(DispatchReportInfo dispatchReport, UserInfo user)
        {
            if (dispatchReport.ID > 0)
            {
                this.dispatchReportDao.UpdateDispatchReport(dispatchReport);

                if (dispatchReport.Status.ID == DispatchReportInfo.DispatchReportStatus.Pending)
                {
                    UpdateDispatchStatusByJournalAndReport(dispatchReport.Dispatch.ID, user);

                    HistoryInfo history = new HistoryInfo(dispatchReport.ID, ObjectTypes.DispatchReport, user.ID, DispatchReportInfo.Actions.Submit, dispatchReport.FujiComments);
                    this.historyDao.AddHistory(history);
                }
                return(dispatchReport.ID);
            }
            else
            {
                return(this.dispatchReportDao.AddDispatchReport(dispatchReport));
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 新增作业报告
        /// </summary>
        /// <param name="dispatchReport">作业报告信息</param>
        /// <returns>作业报告ID</returns>
        public int AddDispatchReport(DispatchReportInfo dispatchReport)
        {
            sqlStr = "INSERT INTO tblDispatchReport(DispatchID ,TypeID ,FaultCode ," +
                     " FaultDesc ,SolutionCauseAnalysis ,SolutionWay,IsPrivate, ServiceProvider,SolutionResultStatusID ," +
                     " SolutionUnsolvedComments ,DelayReason,Comments,FujiComments ,StatusID, " +
                     " EquipmentStatus, PurchaseAmount, ServiceScope, Result, IsRecall,AcceptanceDate) " +
                     " VALUES(@DispatchID ,@TypeID ,@FaultCode ," +
                     " @FaultDesc ,@SolutionCauseAnalysis , @SolutionWay,@IsPrivate,@ServiceProvider,@SolutionResultStatusID ," +
                     " @SolutionUnsolvedComments ,@DelayReason,@Comments,@FujiComments,@StatusID,  " +
                     " @EquipmentStatus, @PurchaseAmount, @ServiceScope, @Result, @IsRecall,@AcceptanceDate); " +
                     " SELECT @@IDENTITY";

            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@DispatchID", SqlDbType.Int).Value                    = dispatchReport.Dispatch.ID;
                command.Parameters.Add("@TypeID", SqlDbType.Int).Value                        = dispatchReport.Type.ID;
                command.Parameters.Add("@FaultCode", SqlDbType.NVarChar).Value                = SQLUtil.TrimNull(dispatchReport.FaultCode);
                command.Parameters.Add("@FaultDesc", SqlDbType.NVarChar).Value                = SQLUtil.TrimNull(dispatchReport.FaultDesc);
                command.Parameters.Add("@SolutionCauseAnalysis", SqlDbType.NVarChar).Value    = SQLUtil.TrimNull(dispatchReport.SolutionCauseAnalysis);
                command.Parameters.Add("@SolutionWay", SqlDbType.NVarChar).Value              = SQLUtil.TrimNull(dispatchReport.SolutionWay);
                command.Parameters.Add("@IsPrivate", SqlDbType.Bit).Value                     = dispatchReport.IsPrivate;
                command.Parameters.Add("@ServiceProvider", SqlDbType.Int).Value               = SQLUtil.ZeroToNull(dispatchReport.ServiceProvider.ID);
                command.Parameters.Add("@SolutionResultStatusID", SqlDbType.Int).Value        = dispatchReport.SolutionResultStatus.ID;
                command.Parameters.Add("@SolutionUnsolvedComments", SqlDbType.NVarChar).Value = SQLUtil.TrimNull(dispatchReport.SolutionUnsolvedComments);
                command.Parameters.Add("@DelayReason", SqlDbType.NVarChar).Value              = SQLUtil.TrimNull(dispatchReport.DelayReason);
                command.Parameters.Add("@Comments", SqlDbType.NVarChar).Value                 = SQLUtil.TrimNull(dispatchReport.Comments);
                command.Parameters.Add("@FujiComments", SqlDbType.NVarChar).Value             = SQLUtil.TrimNull(dispatchReport.FujiComments);
                command.Parameters.Add("@StatusID", SqlDbType.Int).Value                      = dispatchReport.Status.ID;

                command.Parameters.Add("@EquipmentStatus", SqlDbType.Int).Value     = dispatchReport.EquipmentStatus.ID;
                command.Parameters.Add("@PurchaseAmount", SqlDbType.Decimal).Value  = SQLUtil.ConvertDouble(dispatchReport.PurchaseAmount);
                command.Parameters.Add("@ServiceScope", SqlDbType.Bit).Value        = dispatchReport.ServiceScope;
                command.Parameters.Add("@Result", SqlDbType.NVarChar).Value         = SQLUtil.TrimNull(dispatchReport.Result);
                command.Parameters.Add("@IsRecall", SqlDbType.Bit).Value            = dispatchReport.IsRecall;
                command.Parameters.Add("@AcceptanceDate", SqlDbType.DateTime).Value = SQLUtil.MinDateToNull(dispatchReport.AcceptanceDate);

                dispatchReport.ID = SQLUtil.ConvertInt(command.ExecuteScalar());
            }
            return(dispatchReport.ID);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 更新作业报告
        /// </summary>
        /// <param name="dispatchReport">作业报告信息</param>
        public void UpdateDispatchReport(DispatchReportInfo dispatchReport)
        {
            sqlStr = "UPDATE tblDispatchReport SET DispatchID=@DispatchID ,TypeID=@TypeID ," +
                     " FaultCode=@FaultCode ,FaultDesc=@FaultDesc ," +
                     " SolutionCauseAnalysis=@SolutionCauseAnalysis,SolutionWay=@SolutionWay," +
                     " IsPrivate=@IsPrivate,ServiceProvider=@ServiceProvider,SolutionResultStatusID=@SolutionResultStatusID ," +
                     " SolutionUnsolvedComments=@SolutionUnsolvedComments ,DelayReason=@DelayReason,Comments=@Comments," +
                     " FujiComments=@FujiComments ,StatusID=@StatusID, " +
                     " EquipmentStatus=@EquipmentStatus, PurchaseAmount=@PurchaseAmount, ServiceScope=@ServiceScope, Result= @Result, IsRecall=@IsRecall,AcceptanceDate=@AcceptanceDate";
            sqlStr += " WHERE ID = @ID";

            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@DispatchID", SqlDbType.Int).Value                    = dispatchReport.Dispatch.ID;
                command.Parameters.Add("@TypeID", SqlDbType.Int).Value                        = dispatchReport.Type.ID;
                command.Parameters.Add("@FaultCode", SqlDbType.NVarChar).Value                = SQLUtil.TrimNull(dispatchReport.FaultCode);
                command.Parameters.Add("@FaultDesc", SqlDbType.NVarChar).Value                = SQLUtil.TrimNull(dispatchReport.FaultDesc);
                command.Parameters.Add("@SolutionCauseAnalysis", SqlDbType.NVarChar).Value    = SQLUtil.TrimNull(dispatchReport.SolutionCauseAnalysis);
                command.Parameters.Add("@SolutionWay", SqlDbType.NVarChar).Value              = SQLUtil.TrimNull(dispatchReport.SolutionWay);
                command.Parameters.Add("@IsPrivate", SqlDbType.Bit).Value                     = dispatchReport.IsPrivate;
                command.Parameters.Add("@ServiceProvider", SqlDbType.Int).Value               = SQLUtil.ZeroToNull(dispatchReport.ServiceProvider.ID);
                command.Parameters.Add("@SolutionResultStatusID", SqlDbType.Int).Value        = dispatchReport.SolutionResultStatus.ID;
                command.Parameters.Add("@SolutionUnsolvedComments", SqlDbType.NVarChar).Value = SQLUtil.TrimNull(dispatchReport.SolutionUnsolvedComments);
                command.Parameters.Add("@DelayReason", SqlDbType.NVarChar).Value              = SQLUtil.TrimNull(dispatchReport.DelayReason);
                command.Parameters.Add("@Comments", SqlDbType.NVarChar).Value                 = SQLUtil.TrimNull(dispatchReport.Comments);
                command.Parameters.Add("@FujiComments", SqlDbType.NVarChar).Value             = SQLUtil.TrimNull(dispatchReport.FujiComments);
                command.Parameters.Add("@StatusID", SqlDbType.Int).Value                      = dispatchReport.Status.ID;
                command.Parameters.Add("@ID", SqlDbType.Int).Value = dispatchReport.ID;

                command.Parameters.Add("@EquipmentStatus", SqlDbType.Int).Value     = dispatchReport.EquipmentStatus.ID;
                command.Parameters.Add("@PurchaseAmount", SqlDbType.Decimal).Value  = SQLUtil.ConvertDouble(dispatchReport.PurchaseAmount);
                command.Parameters.Add("@ServiceScope", SqlDbType.Bit).Value        = dispatchReport.ServiceScope;
                command.Parameters.Add("@Result", SqlDbType.NVarChar).Value         = SQLUtil.TrimNull(dispatchReport.Result);
                command.Parameters.Add("@IsRecall", SqlDbType.Bit).Value            = dispatchReport.IsRecall;
                command.Parameters.Add("@AcceptanceDate", SqlDbType.DateTime).Value = SQLUtil.MinDateToNull(dispatchReport.AcceptanceDate);

                command.ExecuteNonQuery();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 派工单状态已审批时根据作业报告信息修改设备信息
        /// </summary>
        /// <param name="dispatchReportInfo">作业报告信息</param>
        /// <param name="user">操作的用户信息</param>
        private void PassDispatchReportInternal(DispatchReportInfo dispatchReportInfo, UserInfo user)
        {
            DispatchInfo dispatchInfo = this.dispatchDao.GetDispatchByID(dispatchReportInfo.Dispatch.ID);

            if (dispatchReportInfo.Type.ID != DispatchReportInfo.DispatchReportTypes.Common)
            {
                List <EquipmentInfo> equipments = this.requestDao.GetRequestEgpts(dispatchInfo.RequestID);
                foreach (EquipmentInfo equipment in equipments)
                {
                    if (dispatchInfo.RequestType.ID == RequestInfo.RequestTypes.AddEquipment)
                    {
                        equipment.PurchaseAmount = dispatchReportInfo.PurchaseAmount;
                        equipment.ServiceScope   = dispatchReportInfo.ServiceScope;
                    }
                    else if (dispatchInfo.RequestType.ID == RequestInfo.RequestTypes.Repair)
                    {
                        if (dispatchReportInfo.EquipmentStatus.ID != MachineStatuses.Normal)
                        {
                            equipment.EquipmentStatus.ID = EquipmentInfo.EquipmentStatuses.Fault;
                        }
                        else
                        {
                            equipment.EquipmentStatus.ID = dispatchReportInfo.EquipmentStatus.ID;
                        }
                    }
                    else if (dispatchInfo.RequestType.ID == RequestInfo.RequestTypes.Accetance)
                    {
                        if (dispatchReportInfo.AcceptanceDate != DateTime.MinValue)
                        {
                            equipment.AcceptanceDate = dispatchReportInfo.AcceptanceDate;
                            equipment.Accepted       = true;
                        }
                    }

                    this.equipmentManager.SaveEquipment(equipment, null, user);
                }
            }
        }
Ejemplo n.º 12
0
        public JsonResult RejectDispatchReport(DispatchReportInfo info)
        {
            ResultModelBase result = new ResultModelBase();

            if (CheckSession() == false)
            {
                return(Json(ResultModelBase.CreateTimeoutModel(), JsonRequestBehavior.AllowGet));
            }
            if (CheckSessionID() == false)
            {
                return(Json(ResultModelBase.CreateLogoutModel(), JsonRequestBehavior.AllowGet));
            }
            try
            {
                this.dispatchManager.RejectDispatchReport(info, GetLoginUser());
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(JsonResult(result));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 通过作业报告编号获取作业报告信息
        /// </summary>
        /// <param name="userID">用户编号</param>
        /// <param name="dispatchReportID">作业报告编号</param>
        /// <param name="sessionID">当前请求所在设备储存的SessionID</param>
        /// <returns>作业报告信息</returns>
        public JsonResult GetDispatchReport(int userID, string sessionID, int dispatchReportID)
        {
            ServiceResultModel <DispatchReportInfo> response = new ServiceResultModel <DispatchReportInfo>();

            try
            {
                if (!CheckSessionID(userID, sessionID, response))
                {
                    return(MyJson(response, JsonRequestBehavior.AllowGet));
                }
                DispatchReportInfo info = this.dispatchManager.GetDispatchReportByID(dispatchReportID);

                UserInfo user = null;
                if (CheckUser(userID, response, out user) == false)
                {
                    return(MyJson(response, JsonRequestBehavior.AllowGet));
                }


                if (info == null)
                {
                    response.SetFailed(ResultCodes.ParameterError, "作业报告不存在");
                }
                else
                {
                    response.Data = info.Copy4App();
                }
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                response.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }

            return(MyJson(response, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 14
0
        private void GenerateRequestRegularPatrol(List <EquipmentInfo> equipmentInfos, ref int nextRequestId, ref int nextDispatchId, DateTime fromDate)
        {
            DateTime monthEnd = fromDate.AddMonths(1).AddDays(-1);

            List <EquipmentInfo> toProcessEquips = (from EquipmentInfo temp in equipmentInfos
                                                    where temp.InstalEndDate <= fromDate && (temp.ScrapDate == DateTime.MinValue || temp.ScrapDate >= monthEnd)
                                                    select temp).ToList();

            List <EntityInfo> requestInfos     = new List <EntityInfo>();
            List <EntityInfo> requestEqupInfos = new List <EntityInfo>();
            List <EntityInfo> dispatchInfos    = new List <EntityInfo>();
            List <EntityInfo> journalInfos     = new List <EntityInfo>();
            List <EntityInfo> reportInfos      = new List <EntityInfo>();

            foreach (EquipmentInfo info in toProcessEquips)
            {
                nextRequestId++;
                RequestInfo requestInfo = new RequestInfo();
                requestInfo.ID             = nextRequestId;
                requestInfo.RequestType.ID = RequestInfo.RequestTypes.OnSiteInspection;
                requestInfo.Source.ID      = 3;
                requestInfo.FaultDesc      = "检查设备";
                requestInfo.Status.ID      = 99;
                requestInfo.DealType.ID    = 1;
                requestInfo.Priority.ID    = 1;
                requestInfo.RequestDate    = GetRandom(fromDate, fromDate, DateTime.MinValue, monthEnd);
                requestInfo.DistributeDate = requestInfo.RequestDate.AddHours(this.rd.Next(8, 12)).AddMinutes(this.rd.Next(0, 60));
                requestInfo.ResponseDate   = requestInfo.DistributeDate.AddMinutes(this.rd.Next(5, 30));
                requestInfo.CloseDate      = requestInfo.DistributeDate.AddHours(this.rd.Next(2, 6)).AddMinutes(this.rd.Next(0, 60));

                requestInfos.Add(requestInfo);

                requestEqupInfos.Add(new RequestEqptInfo()
                {
                    RequestID = requestInfo.ID, EquipmentID = info.ID
                });

                nextDispatchId++;
                DispatchInfo dispatchInfo = new DispatchInfo();
                dispatchInfo.ID               = nextDispatchId;
                dispatchInfo.Request.ID       = requestInfo.ID;
                dispatchInfo.RequestType.ID   = requestInfo.RequestType.ID;
                dispatchInfo.Urgency.ID       = 1;
                dispatchInfo.MachineStatus.ID = 1;
                dispatchInfo.Engineer.ID      = 4;
                dispatchInfo.ScheduleDate     = requestInfo.DistributeDate;
                dispatchInfo.Status.ID        = 4;
                dispatchInfo.CreateDate       = dispatchInfo.ScheduleDate;
                dispatchInfo.StartDate        = requestInfo.ResponseDate;
                dispatchInfo.EndDate          = requestInfo.CloseDate;
                dispatchInfos.Add(dispatchInfo);

                DispatchJournalInfo journalInfo = new DispatchJournalInfo();
                journalInfo.DispatchID      = dispatchInfo.ID;
                journalInfo.FaultCode       = "检查设备";
                journalInfo.JobContent      = "检查设备";
                journalInfo.ResultStatus.ID = 2;
                journalInfo.UserName        = "******";
                journalInfo.UserMobile      = "18866988878";
                journalInfo.Status.ID       = 3;
                journalInfos.Add(journalInfo);

                DispatchReportInfo reportInfo = new DispatchReportInfo();
                reportInfo.DispatchID              = dispatchInfo.ID;
                reportInfo.Type.ID                 = 401;
                reportInfo.SolutionCauseAnalysis   = "检查设备";
                reportInfo.SolutionWay             = "没问题";
                reportInfo.ServiceProvider.ID      = 1;
                reportInfo.SolutionResultStatus.ID = 4;
                reportInfo.Status.ID               = 3;
                reportInfos.Add(reportInfo);
            }

            this.importDao.ImportRequest(requestInfos);
            this.importDao.ImportRequestEqpt(requestEqupInfos);
            this.importDao.ImportDispatch(dispatchInfos);
            this.importDao.ImportDispatchJournal(journalInfos);
            this.importDao.ImportDispatchReport(reportInfos);
        }
Ejemplo n.º 15
0
        private void GenerateRequestRepair(List <EquipmentInfo> equipmentInfos, ref int nextRequestId, ref int nextDispatchId, DateTime fromDate)
        {
            DateTime monthEnd = fromDate.AddMonths(1).AddDays(-1);

            List <EquipmentInfo> toProcessEquips = (from EquipmentInfo temp in equipmentInfos
                                                    where temp.InstalEndDate <= fromDate && (temp.ScrapDate == DateTime.MinValue || temp.ScrapDate >= monthEnd)
                                                    select temp).ToList();

            List <EntityInfo> requestInfos     = new List <EntityInfo>();
            List <EntityInfo> requestEqupInfos = new List <EntityInfo>();
            List <EntityInfo> dispatchInfos    = new List <EntityInfo>();
            List <EntityInfo> journalInfos     = new List <EntityInfo>();
            List <EntityInfo> reportInfos      = new List <EntityInfo>();

            int        totalEquips         = this.rd.Next(70, 80 + 1);
            int        quickResponseEquips = (int)Math.Ceiling(totalEquips * 0.9) + 1;
            List <int> equipIndexs         = new List <int>();
            int        tryCount            = 0;
            int        rdMinutes           = 0;

            while (tryCount < totalEquips * 2)
            {
                int rdIndex = this.rd.Next(0, toProcessEquips.Count);
                if (!equipIndexs.Contains(rdIndex))
                {
                    nextRequestId++;
                    RequestInfo requestInfo = new RequestInfo();
                    requestInfo.ID               = nextRequestId;
                    requestInfo.RequestType.ID   = RequestInfo.RequestTypes.Repair;
                    requestInfo.Source.ID        = 1;
                    requestInfo.RequestUser.ID   = 6;
                    requestInfo.FaultDesc        = "无法开机";
                    requestInfo.Status.ID        = 99;
                    requestInfo.DealType.ID      = 1;
                    requestInfo.Priority.ID      = 1;
                    requestInfo.MachineStatus.ID = 1;
                    requestInfo.RequestDate      = GetRandom(fromDate, toProcessEquips[rdIndex].InstalEndDate, toProcessEquips[rdIndex].ScrapDate, monthEnd);
                    requestInfo.RequestDate      = requestInfo.RequestDate.AddHours(this.rd.Next(8, 14)).AddMinutes(this.rd.Next(0, 60));
                    if (equipIndexs.Count <= quickResponseEquips)
                    {
                        rdMinutes = this.rd.Next(2, 5);
                        requestInfo.DistributeDate = requestInfo.RequestDate.AddMinutes(rdMinutes);
                        requestInfo.ResponseDate   = requestInfo.DistributeDate.AddMinutes(this.rd.Next(5, 15 - rdMinutes));
                    }
                    else
                    {
                        rdMinutes = this.rd.Next(5, 10);
                        requestInfo.DistributeDate = requestInfo.RequestDate.AddMinutes(rdMinutes);
                        requestInfo.ResponseDate   = requestInfo.DistributeDate.AddMinutes(this.rd.Next(10, 30 - rdMinutes));
                    }
                    requestInfo.CloseDate = requestInfo.ResponseDate.AddMinutes(this.rd.Next(30, 60));

                    requestInfos.Add(requestInfo);
                    requestEqupInfos.Add(new RequestEqptInfo()
                    {
                        RequestID = requestInfo.ID, EquipmentID = toProcessEquips[rdIndex].ID
                    });

                    nextDispatchId++;
                    DispatchInfo dispatchInfo = new DispatchInfo();
                    dispatchInfo.ID               = nextDispatchId;
                    dispatchInfo.Request.ID       = requestInfo.ID;
                    dispatchInfo.RequestType.ID   = requestInfo.RequestType.ID;
                    dispatchInfo.Urgency.ID       = 1;
                    dispatchInfo.MachineStatus.ID = 1;
                    dispatchInfo.Engineer.ID      = 4;
                    dispatchInfo.ScheduleDate     = requestInfo.DistributeDate;
                    dispatchInfo.Status.ID        = 4;
                    dispatchInfo.CreateDate       = dispatchInfo.ScheduleDate;
                    dispatchInfo.StartDate        = requestInfo.ResponseDate;
                    dispatchInfo.EndDate          = requestInfo.CloseDate;
                    dispatchInfos.Add(dispatchInfo);

                    DispatchJournalInfo journalInfo = new DispatchJournalInfo();
                    journalInfo.DispatchID      = dispatchInfo.ID;
                    journalInfo.FaultCode       = "错误代码112";
                    journalInfo.JobContent      = "检查电源和操作系统";
                    journalInfo.ResultStatus.ID = 2;
                    journalInfo.Advice          = "恢复出厂设置";
                    journalInfo.UserName        = "******";
                    journalInfo.UserMobile      = "18866881888";
                    journalInfo.Status.ID       = 3;
                    journalInfos.Add(journalInfo);

                    DispatchReportInfo reportInfo = new DispatchReportInfo();
                    reportInfo.DispatchID              = dispatchInfo.ID;
                    reportInfo.Type.ID                 = 1;
                    reportInfo.FaultCode               = "112";
                    reportInfo.FaultDesc               = "无法开机";
                    reportInfo.SolutionCauseAnalysis   = "系统设置错误";
                    reportInfo.SolutionWay             = "恢复出厂设置";
                    reportInfo.SolutionResultStatus.ID = 4;
                    reportInfo.Status.ID               = 3;
                    reportInfos.Add(reportInfo);

                    equipIndexs.Add(rdIndex);
                    if (equipIndexs.Count == totalEquips)
                    {
                        break;
                    }
                }

                tryCount++;
            }

            this.importDao.ImportRequest(requestInfos);
            this.importDao.ImportRequestEqpt(requestEqupInfos);
            this.importDao.ImportDispatch(dispatchInfos);
            this.importDao.ImportDispatchJournal(journalInfos);
            this.importDao.ImportDispatchReport(reportInfos);
        }
Ejemplo n.º 16
0
        private void GenerateRequestRepair4Expense(ref int nextRequestId, ref int nextDispatchId, ref int nextDispatchReportId, DateTime fromDate)
        {
            DateTime yearEnd = GetYearEndDate(fromDate);

            List <ServiceHisInfo> incomeInfos = this.queryDao.GetServiceHis(fromDate.Year);

            List <EntityInfo> requestInfos         = new List <EntityInfo>();
            List <EntityInfo> requestEqupInfos     = new List <EntityInfo>();
            List <EntityInfo> dispatchInfos        = new List <EntityInfo>();
            List <EntityInfo> journalInfos         = new List <EntityInfo>();
            List <EntityInfo> reportInfos          = new List <EntityInfo>();
            List <EntityInfo> reportAccessoryInfos = new List <EntityInfo>();

            foreach (ServiceHisInfo info in incomeInfos)
            {
                nextRequestId++;
                RequestInfo requestInfo = new RequestInfo();
                requestInfo.ID               = nextRequestId;
                requestInfo.RequestType.ID   = RequestInfo.RequestTypes.Repair;
                requestInfo.Source.ID        = 1;
                requestInfo.RequestUser.ID   = 6;
                requestInfo.FaultDesc        = "无法开机";
                requestInfo.Status.ID        = 99;
                requestInfo.DealType.ID      = 1;
                requestInfo.Priority.ID      = 1;
                requestInfo.MachineStatus.ID = 1;
                requestInfo.RequestDate      = GetRandom(fromDate, fromDate, yearEnd, yearEnd);
                requestInfo.RequestDate      = requestInfo.RequestDate.AddHours(this.rd.Next(8, 14)).AddMinutes(this.rd.Next(0, 60));
                requestInfo.DistributeDate   = requestInfo.RequestDate.AddMinutes(this.rd.Next(2, 5));
                requestInfo.ResponseDate     = requestInfo.DistributeDate.AddMinutes(this.rd.Next(5, 10));
                requestInfo.CloseDate        = requestInfo.ResponseDate.AddMinutes(this.rd.Next(30, 60));

                requestInfos.Add(requestInfo);
                requestEqupInfos.Add(new RequestEqptInfo()
                {
                    RequestID = requestInfo.ID, EquipmentID = info.EquipmentID
                });

                nextDispatchId++;
                DispatchInfo dispatchInfo = new DispatchInfo();
                dispatchInfo.ID               = nextDispatchId;
                dispatchInfo.Request.ID       = requestInfo.ID;
                dispatchInfo.RequestType.ID   = requestInfo.RequestType.ID;
                dispatchInfo.Urgency.ID       = 1;
                dispatchInfo.MachineStatus.ID = 1;
                dispatchInfo.Engineer.ID      = 4;
                dispatchInfo.ScheduleDate     = requestInfo.DistributeDate;
                dispatchInfo.Status.ID        = 4;
                dispatchInfo.CreateDate       = dispatchInfo.ScheduleDate;
                dispatchInfo.StartDate        = requestInfo.ResponseDate;
                dispatchInfo.EndDate          = requestInfo.CloseDate;
                dispatchInfos.Add(dispatchInfo);

                DispatchJournalInfo journalInfo = new DispatchJournalInfo();
                journalInfo.DispatchID      = dispatchInfo.ID;
                journalInfo.FaultCode       = "错误代码112";
                journalInfo.JobContent      = "检查电源和操作系统";
                journalInfo.ResultStatus.ID = 2;
                journalInfo.Advice          = "恢复出厂设置";
                journalInfo.UserName        = "******";
                journalInfo.UserMobile      = "18866881888";
                journalInfo.Status.ID       = 3;
                journalInfos.Add(journalInfo);

                nextDispatchReportId++;
                DispatchReportInfo reportInfo = new DispatchReportInfo();
                reportInfo.ID                      = nextDispatchReportId;
                reportInfo.DispatchID              = dispatchInfo.ID;
                reportInfo.Type.ID                 = 1;
                reportInfo.FaultCode               = "112";
                reportInfo.FaultDesc               = "无法开机";
                reportInfo.SolutionCauseAnalysis   = "系统设置错误";
                reportInfo.SolutionWay             = "恢复出厂设置";
                reportInfo.SolutionResultStatus.ID = 4;
                reportInfo.Status.ID               = 3;
                reportInfos.Add(reportInfo);

                ReportAccessoryInfo accessoryInfo = new ReportAccessoryInfo();
                accessoryInfo.DispatchReportID = reportInfo.ID;
                accessoryInfo.Name             = "监控";
                accessoryInfo.Source.ID        = 1;
                accessoryInfo.SupplierID       = 3;
                accessoryInfo.NewSerialCode    = this.rd.Next(100000, 500000).ToString();
                accessoryInfo.OldSerialCode    = this.rd.Next(500000, 1000000).ToString();
                accessoryInfo.Qty = 1;
                if (info.EquipmentID == 528)
                {
                    accessoryInfo.Amount = this.rd.Next((int)(info.Income * 1.29), (int)(info.Income * 1.31));
                }
                else
                {
                    accessoryInfo.Amount = this.rd.Next((int)(info.Income * 0.29), (int)(info.Income * 0.31));
                }
                reportAccessoryInfos.Add(accessoryInfo);
            }

            this.importDao.ImportRequest(requestInfos);
            this.importDao.ImportRequestEqpt(requestEqupInfos);
            this.importDao.ImportDispatch(dispatchInfos);
            this.importDao.ImportDispatchJournal(journalInfos);
            this.importDao.ImportDispatchReport(reportInfos);
            this.importDao.ImportReportAccessory(reportAccessoryInfos);
        }
Ejemplo n.º 17
0
        public int SaveDispatchReport4App(DispatchReportInfo dispatchReport, UserInfo user)
        {
            if (dispatchReport.ID > 0)
            {
                DispatchReportInfo exsistReport = GetDispatchReportByID(dispatchReport.ID);
                this.dispatchReportDao.UpdateDispatchReport(dispatchReport);

                if (dispatchReport.FileInfo != null && dispatchReport.FileInfo.ID <= 0)
                {
                    this.fileManager.DeleteUploadFileByID(ObjectTypes.DispatchReport, exsistReport.FileInfo.ID);
                }
                else if (dispatchReport.FileInfo == null)
                {
                    this.fileManager.DeleteUploadFileByID(ObjectTypes.DispatchReport, exsistReport.FileInfo.ID);
                }
                if (dispatchReport.ReportAccessories != null && dispatchReport.ReportAccessories.Count > 0)
                {
                    List <int> newIdList = SQLUtil.GetIDListFromObjectList(dispatchReport.ReportAccessories);

                    foreach (ReportAccessoryInfo info in (from ReportAccessoryInfo temp in exsistReport.ReportAccessories where !newIdList.Contains(temp.ID) select temp))
                    {
                        DeleteReportAccessory(info.ID);
                    }
                }
                else if ((dispatchReport.ReportAccessories == null || dispatchReport.ReportAccessories.Count == 0) && exsistReport.ReportAccessories.Count > 0)
                {
                    foreach (ReportAccessoryInfo info in exsistReport.ReportAccessories)
                    {
                        DeleteReportAccessory(info.ID);
                    }
                }
            }
            else
            {
                dispatchReport.ID = this.dispatchReportDao.AddDispatchReport(dispatchReport);
            }

            if (dispatchReport.FileInfo != null && !string.IsNullOrEmpty(dispatchReport.FileInfo.FileName) && dispatchReport.FileInfo.ID <= 0)
            {
                dispatchReport.FileInfo.ObjectID   = dispatchReport.ID;
                dispatchReport.FileInfo.ObjectName = ObjectTypes.DispatchReport;
                this.fileManager.SaveUploadFile(dispatchReport.FileInfo);
            }
            if (dispatchReport.ReportAccessories != null && dispatchReport.ReportAccessories.Count > 0)
            {
                foreach (ReportAccessoryInfo info in (from ReportAccessoryInfo temp in dispatchReport.ReportAccessories where temp.ID <= 0 select temp))
                {
                    info.DispatchReportID = dispatchReport.ID;
                    SaveReportAccessory(info, info.FileInfos);
                }
            }

            if (dispatchReport.Status.ID == DispatchReportInfo.DispatchReportStatus.Pending)
            {
                UpdateDispatchStatusByJournalAndReport(dispatchReport.Dispatch.ID, user);

                HistoryInfo history = new HistoryInfo(dispatchReport.ID, ObjectTypes.DispatchReport, user.ID, DispatchReportInfo.Actions.Submit, dispatchReport.FujiComments);
                this.historyDao.AddHistory(history);
            }
            return(dispatchReport.ID);
        }
Ejemplo n.º 18
0
        public JsonResult SaveDispatchReport(int userID, string sessionID, DispatchReportInfo dispatchReport)
        {
            ServiceResultModel <int> response = new ServiceResultModel <int>();

            try
            {
                if (!CheckSessionID(userID, sessionID, response))
                {
                    return(MyJson(response, JsonRequestBehavior.AllowGet));
                }
                UserInfo user = null;
                if (CheckUser(userID, response, out user, UserRole.Admin) == false)
                {
                    return(MyJson(response, JsonRequestBehavior.AllowGet));
                }

                DispatchInfo dispatchInfo = this.dispatchManager.GetDispatchByID(dispatchReport.Dispatch.ID);

                if (dispatchInfo == null)
                {
                    response.SetFailed(ResultCodes.ParameterError, "派工单不存在");
                }
                else if (dispatchInfo.Engineer.ID != userID)
                {
                    response.SetFailed(ResultCodes.ParameterError, "派工人不正确");
                }
                else if (dispatchInfo.Status.ID != BusinessObjects.Domain.DispatchInfo.Statuses.Responded && dispatchInfo.Status.ID != BusinessObjects.Domain.DispatchInfo.Statuses.Pending)
                {
                    response.SetFailed(ResultCodes.ParameterError, "派工单当前状态不可进行该操作");
                }
                else if (dispatchInfo.DispatchReport.ID != dispatchReport.ID)
                {
                    response.SetFailed(ResultCodes.ParameterError, "派工单作业报告编号不匹配");
                }
                else if (dispatchReport.SolutionResultStatus.ID < DispatchReportInfo.SolutionResultStatuses.Allocating || dispatchReport.SolutionResultStatus.ID > DispatchReportInfo.SolutionResultStatuses.Resolved)
                {
                    response.SetFailed(ResultCodes.ParameterError, "作业结果不存在");
                }
                else if (dispatchInfo.DispatchReport.Status.ID != DispatchReportInfo.DispatchReportStatus.New && dispatchInfo.DispatchReport.Status.ID != 0)
                {
                    response.SetFailed(ResultCodes.ParameterError, "当前作业报告状态非新建");
                }
                else if (dispatchReport.Status.ID != DispatchReportInfo.DispatchReportStatus.Pending && dispatchReport.Status.ID != DispatchReportInfo.DispatchReportStatus.New)
                {
                    response.SetFailed(ResultCodes.ParameterError, "更新作业报告状态非待审批或新建");
                }
                else
                {
                    if (dispatchReport.FileInfo != null)
                    {
                        dispatchReport.FileInfo.FileContent = ParseBase64String(dispatchReport.FileInfo.FileContent);
                    }
                    if (dispatchReport.ReportAccessories != null)
                    {
                        foreach (ReportAccessoryInfo info in dispatchReport.ReportAccessories)
                        {
                            if (info.FileInfos != null && info.FileInfos.Count > 0)
                            {
                                foreach (UploadFileInfo fileInfo in info.FileInfos)
                                {
                                    fileInfo.FileContent = ParseBase64String(fileInfo.FileContent);
                                }
                            }
                        }
                    }
                    response.Data = this.dispatchManager.SaveDispatchReport4App(dispatchReport, user);
                }
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                response.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(MyJson(response, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 派工单状态已审批时根据作业报告信息修改设备信息
        /// </summary>
        /// <param name="dispatchReportInfo">作业报告信息</param>
        /// <param name="user">操作的用户信息</param>
        private void PassDispatchReportInternal(DispatchReportInfo dispatchReportInfo, UserInfo user)
        {
            DispatchInfo dispatchInfo = this.dispatchDao.GetDispatchByID(dispatchReportInfo.Dispatch.ID);

            List <EquipmentInfo> equipments = this.requestDao.GetRequestEgpts(dispatchInfo.RequestID);

            if (dispatchReportInfo.Type.ID != DispatchReportInfo.DispatchReportTypes.Common)
            {
                foreach (EquipmentInfo equipment in equipments)
                {
                    if (dispatchInfo.RequestType.ID == RequestInfo.RequestTypes.AddEquipment)
                    {
                        equipment.PurchaseAmount = dispatchReportInfo.PurchaseAmount;
                        equipment.ServiceScope   = dispatchReportInfo.ServiceScope;
                    }
                    else if (dispatchInfo.RequestType.ID == RequestInfo.RequestTypes.Repair)
                    {
                        if (dispatchReportInfo.EquipmentStatus.ID != MachineStatuses.Normal)
                        {
                            equipment.EquipmentStatus.ID = EquipmentInfo.EquipmentStatuses.Fault;
                        }
                        else
                        {
                            equipment.EquipmentStatus.ID = dispatchReportInfo.EquipmentStatus.ID;
                        }
                    }
                    else if (dispatchInfo.RequestType.ID == RequestInfo.RequestTypes.Accetance)
                    {
                        if (dispatchReportInfo.AcceptanceDate != DateTime.MinValue)
                        {
                            equipment.AcceptanceDate = dispatchReportInfo.AcceptanceDate;
                            equipment.Accepted       = true;
                        }
                    }

                    this.equipmentManager.SaveEquipment(equipment, null, user);
                }
            }

            DataTable dt = new DataTable();

            dt.Columns.Add("DispatchReportID", typeof(System.Int32));
            dt.Columns.Add("ObjectType", typeof(System.Int32));
            dt.Columns.Add("ObjectID", typeof(System.Int32));
            dt.Columns.Add("EquipmentID", typeof(System.Int32));
            dt.Columns.Add("Qty", typeof(System.Double));
            dt.Columns.Add("UserID", typeof(System.Int32));

            if (dispatchReportInfo.ReportComponent != null && dispatchReportInfo.ReportComponent.Count > 0)
            {
                this.invComponentDao.UpdateComponentStatus(dispatchReportInfo.ReportComponent.Select(info => info.NewComponent.ID).ToList(), InvComponentInfo.ComponentStatus.Used);
                this.invComponentDao.UpdateComponentStatus(dispatchReportInfo.ReportComponent.Select(info => info.OldComponent.ID).ToList(), InvComponentInfo.ComponentStatus.Scrap);

                foreach (ReportComponentInfo info in dispatchReportInfo.ReportComponent)
                {
                    DataRow dr = dt.NewRow();
                    dr["DispatchReportID"] = dispatchReportInfo.ID;
                    dr["ObjectType"]       = ReportMaterialInfo.MaterialTypes.NewComponent;
                    dr["ObjectID"]         = info.NewComponent.ID;
                    dr["EquipmentID"]      = equipments[0].ID;
                    dr["UserID"]           = dispatchInfo.Engineer.ID;
                    dr["Qty"] = 0;
                    dt.Rows.Add(dr);

                    dr = dt.NewRow();
                    dr["DispatchReportID"] = dispatchReportInfo.ID;
                    dr["ObjectType"]       = ReportMaterialInfo.MaterialTypes.OldComponent;
                    dr["ObjectID"]         = info.OldComponent.ID;
                    dr["EquipmentID"]      = equipments[0].ID;
                    dr["UserID"]           = dispatchInfo.Engineer.ID;
                    dr["Qty"] = 0;
                    dt.Rows.Add(dr);
                }
            }
            if (dispatchReportInfo.ReportConsumable != null && dispatchReportInfo.ReportConsumable.Count > 0)
            {
                foreach (ReportConsumableInfo info in dispatchReportInfo.ReportConsumable)
                {
                    this.invConsumableDao.UpdateConsumableQty(info.InvConsumable.ID, info.Qty);

                    DataRow dr = dt.NewRow();
                    dr["DispatchReportID"] = dispatchReportInfo.ID;
                    dr["ObjectType"]       = ReportMaterialInfo.MaterialTypes.Consumable;
                    dr["ObjectID"]         = info.InvConsumable.ID;
                    dr["EquipmentID"]      = equipments[0].ID;
                    dr["UserID"]           = dispatchInfo.Engineer.ID;
                    dr["Qty"] = info.Qty;
                    dt.Rows.Add(dr);
                }
            }
            if (dispatchReportInfo.ReportService != null && dispatchReportInfo.ReportService.Count > 0)
            {
                this.invServiceDao.UpdateServiceTimes(dispatchReportInfo.ReportService.Select(info => info.Service.ID).ToList());
                foreach (ReportServiceInfo info in dispatchReportInfo.ReportService)
                {
                    DataRow dr = dt.NewRow();
                    dr["DispatchReportID"] = dispatchReportInfo.ID;
                    dr["ObjectType"]       = ReportMaterialInfo.MaterialTypes.Service;
                    dr["ObjectID"]         = info.Service.ID;
                    dr["EquipmentID"]      = equipments[0].ID;
                    dr["UserID"]           = dispatchInfo.Engineer.ID;
                    dr["Qty"] = 0;
                    dt.Rows.Add(dr);
                }
            }

            if (dt.Rows.Count > 0)
            {
                this.dispatchReportDao.AddMaterialHistory(dt);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 获取派工单列表
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="userRoleID">用户角色ID</param>
        /// <param name="statusList">状态ID</param>
        /// <param name="urgency">派工单紧急程度</param>
        /// <param name="type">派工类型</param>
        /// <param name="filterField">搜索条件</param>
        /// <param name="filterText">搜索框填写内容</param>
        /// <param name="sortField">排序字段</param>
        /// <param name="sortDirection">排序方式</param>
        /// <param name="curRowNum">当前页数第一个数据的位置</param>
        /// <param name="pageSize">一页几条数据</param>
        /// <returns>派工单列表</returns>
        public List <DispatchInfo> QueryDispatches(int userID, int userRoleID, List <int> statusList, int urgency, int type, string filterField, string filterText, string sortField, bool sortDirection, int curRowNum = 0, int pageSize = 0)
        {
            List <DispatchInfo> dispatches = new List <DispatchInfo>();

            sqlStr = "SELECT DISTINCT d.*, CONVERT(VARCHAR(10),d.CreateDate,112),j.ID as DispatchJournalID,dr.ID as DispatchReportID , j.StatusID AS DispatchJournalStatusID,dr.StatusID AS DispatchReportStatusID, " + DispatchReportInfo.GetOverDueSQL() + string.Format(", CASE WHEN d.StatusID = {0} THEN -1 ELSE d.StatusID END AS newStatusID ", DispatchInfo.Statuses.Responded) +
                     " FROM tblDispatch d " +
                     " LEFT JOIN tblDispatchJournal  j ON d.ID = j.DispatchID " +
                     " LEFT JOIN tblDispatchReport dr ON d.ID = dr.DispatchID " +
                     " LEFT JOIN tblRequest as r on r.ID = d.RequestID " +
                     " LEFT JOIN jctRequestEqpt jc ON jc.RequestID=r.ID  " +
                     " LEFT JOIN tblEquipment e ON e.ID=jc.EquipmentID " +
                     " WHERE 1=1 ";
            if (statusList != null && statusList.Count > 1)
            {
                sqlStr += " AND d.StatusID IN (" + SQLUtil.ConvertToInStr(statusList) + ")";
            }
            else if (statusList != null && statusList.Count == 1 && statusList[0] != 0)
            {
                sqlStr += " AND d.StatusID IN (" + SQLUtil.ConvertToInStr(statusList) + ")";
            }
            else
            {
                sqlStr += " AND d.StatusID <> " + DispatchInfo.Statuses.Cancelled;
            }

            if (urgency != 0)
            {
                sqlStr += " AND d.UrgencyID=" + urgency;
            }
            if (type != 0)
            {
                sqlStr += " AND d.RequestType=" + type;
            }
            if (userRoleID == BusinessObjects.Domain.UserRole.Admin)
            {
                sqlStr += " AND d.EngineerID=" + userID;
            }

            if (!string.IsNullOrEmpty(filterText))
            {
                sqlStr += GetFieldFilterClause(filterField);
            }

            if (sortField.Equals("init"))
            {
                if (userRoleID == BusinessObjects.Domain.UserRole.Admin)
                {
                    sqlStr += string.Format(" ORDER BY newStatusID, d.RequestType, CONVERT(VARCHAR(10),d.CreateDate,112) DESC , d.ID ", DispatchInfo.Statuses.Responded, DispatchReportInfo.GetOverDueSQL());
                }
                else
                {
                    sqlStr += string.Format(" ORDER BY {0} DESC, d.RequestType, CONVERT(VARCHAR(10),d.CreateDate,112) DESC, d.StatusID, d.ID ", DispatchReportInfo.GetOverDueSQL());
                }
            }
            else
            {
                sqlStr += GenerateSortClause(sortDirection, sortField, "d.ID");
            }

            sqlStr = AppendLimitClause(sqlStr, curRowNum, pageSize);
            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                if (!String.IsNullOrEmpty(filterText))
                {
                    AddFieldFilterParam(command, filterField, filterText);
                }

                using (DataTable dt = GetDataTable(command))
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        dispatches.Add(new DispatchInfo(dr));
                    }
                }
            }
            return(dispatches);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 根据服务凭证、作业报告状态修改派工单状态和请求状态
        /// </summary>
        /// <param name="dispatchID">派工单编号</param>
        /// <param name="user">操作的用户信息</param>
        private void UpdateDispatchStatusByJournalAndReport(int dispatchID, UserInfo user)
        {
            int                 dispatchStatusID = 0;
            int                 requestStatusID  = 0;
            DispatchInfo        dispatch         = this.dispatchDao.GetDispatchByID(dispatchID);
            List <DispatchInfo> dispatches       = this.dispatchDao.GetOpenDispatchesByRequestID(dispatch.Request.ID);
            RequestInfo         request          = this.requestDao.QueryRequestByID(dispatch.Request.ID);

            if (dispatch.DispatchReport.Status.ID == DispatchReportInfo.DispatchReportStatus.Approved && dispatch.DispatchJournal.Status.ID == DispatchJournalInfo.DispatchJournalStatus.Approved)
            {   //Journal和Report全部审批结束 ——派工单显示已审批、请求更新状态
                dispatchStatusID = DispatchInfo.Statuses.Approved;

                DispatchReportInfo dispatchReport = this.dispatchReportDao.GetDispatchReportByID(dispatch.DispatchReport.ID);
                if (request.Status.ID == RequestInfo.Statuses.Close)
                {
                    requestStatusID = RequestInfo.Statuses.Close;
                }
                else
                {
                    requestStatusID = DispatchReportInfo.SolutionResultStatuses.GetRequestStatusBySolutionResult(dispatchReport.SolutionResultStatus.ID);
                }

                this.requestDao.UpdateLastStatusID(dispatch.Request.ID, requestStatusID);
                if (requestStatusID == RequestInfo.Statuses.Close)
                {
                    this.requestDao.UpdateRequestCloseDate(dispatch.Request.ID);

                    dispatch.Request = this.requestManager.GetRequest(dispatch.Request.ID);
                    if (dispatch.Request.Source.ID == RequestInfo.Sources.SysRequest)
                    {
                        foreach (EquipmentInfo info in dispatch.Request.Equipments)
                        {
                            if (dispatch.RequestType.ID == RequestInfo.RequestTypes.Maintain)
                            {
                                this.equipmentManager.UpdateEquipmentLastMaintenanceCheck(info);
                            }
                            else if (dispatch.RequestType.ID == RequestInfo.RequestTypes.Correcting)
                            {
                                this.equipmentManager.UpdateEquipmentLastCorrectionCheck(info);
                            }
                            else if (dispatch.RequestType.ID == RequestInfo.RequestTypes.OnSiteInspection)
                            {
                                DateTime dt = dispatch.Request.SelectiveDate != DateTime.MinValue ? dispatch.Request.SelectiveDate : dispatch.Request.RequestDate;
                                this.equipmentManager.UpdateEquipmentLastPatrolCheck(info.ID, dt);
                            }
                        }
                    }
                }
                this.dispatchDao.UpdateDispatchEndDate(dispatchID);

                PassDispatchReportInternal(dispatchReport, user);

                HistoryInfo historyRequest = new HistoryInfo(dispatch.Request.ID, ObjectTypes.Request, user.ID, RequestInfo.Actions.Update);
                this.historyDao.AddHistory(historyRequest);//添加历史操作——请求 更新状态

                HistoryInfo historyDisptach = new HistoryInfo(dispatchID, ObjectTypes.Dispatch, user.ID, DispatchInfo.Actions.Finish);
                this.historyDao.AddHistory(historyDisptach);//添加历史操作——派工单 完成
            }
            else if (dispatch.DispatchReport.Status.ID < DispatchReportInfo.DispatchReportStatus.Pending && dispatch.DispatchJournal.Status.ID < DispatchJournalInfo.DispatchJournalStatus.Pending)
            {   //Journal和Report 未创建、两者均被退回、一者被退回 另一者未提交 未新建 ——派工单显示已响应,请求显示已响应
                dispatchStatusID = DispatchInfo.Statuses.Responded;
                if (request.Status.ID == RequestInfo.Statuses.Close)
                {
                    requestStatusID = RequestInfo.Statuses.Close;
                }
                else
                {
                    requestStatusID = RequestInfo.Statuses.Responded;
                    foreach (DispatchInfo info in dispatches)
                    {
                        if (info.ID != dispatchID && info.Status.ID == DispatchInfo.Statuses.Pending)
                        {
                            requestStatusID = RequestInfo.Statuses.Pending;
                            break;
                        }
                    }
                }
            }
            else
            {//其余情况均为 派工单状态——待审批
                dispatchStatusID = DispatchInfo.Statuses.Pending;
                if (request.Status.ID == RequestInfo.Statuses.Close)
                {
                    requestStatusID = RequestInfo.Statuses.Close;
                }
                else
                {
                    requestStatusID = RequestInfo.Statuses.Pending;
                }
            }

            this.requestDao.UpdateRequestStatus(dispatch.Request.ID, requestStatusID);
            this.dispatchDao.UpdateDispatchStatus(dispatchID, dispatchStatusID);
        }