Exemple #1
0
        public void CacheLoaded()
        {
            if (this.TransferTask != null)
                this.TransferTask = RepositoryFactory.GetRepository<ITransferTaskRepository, TransferTask>().FindBy(this.TransferTask.Key);

            if (this.PrevPos != null)
                this.PrevPos = RepositoryFactory.GetRepository<IPipePositionRepository, PipePosition>().FindBy(this.PrevPos.Key);

            if (this.NewPos != null)
                this.NewPos = RepositoryFactory.GetRepository<IPipePositionRepository, PipePosition>().FindBy(this.NewPos.Key);
        }
        public JsonResult CreateTask(int pipeTypeId, String code, String diggerId,String team,String faxno, String items)
        {
            string pipeneednoticeitemid = Request.Form["needlength"].ToString();
            PipeType pipeType = null;
            Digger targetDigger = null;
            IList<PDCPMS.DataContracts.Transfer.TransferItem> transferItemContracts;
            Account onlineAccount = UserSession.OnlineAccount;

            #region Get Basic Data

            if (onlineAccount.DetectionCompany == null) { return Json(new { success = false, message = "你无权发起常检任务" }); }

            if (string.IsNullOrEmpty(code))
            {
                return Json(new { success = false, message = "编号不能为空" });
            }
            Regex codePattern = new Regex("^[-|a-z|A-Z|0-9]+$");
            if (!codePattern.IsMatch(code))
            {
                return Json(new { success = false, message = "编号格式不正确,只能为英文字母、数字或者短横线(-)的组合" });
            }

            if (null != repository.FindByCode(code))
            {
                return Json(new { success = false, message = string.Format("编号为{0}的常检任务存在,请尝试使用其他编号", code) });
            }

            if (string.IsNullOrEmpty(items))
            {
                return Json(new { success = false, message = "未指定调度项" });
            }
            transferItemContracts = new JavaScriptSerializer().Deserialize<IList<PDCPMS.DataContracts.Transfer.TransferItem>>(items);
            if (transferItemContracts.Count < 1)
            {
                return Json(new { success = false, message = "未指定调度项" });
            }

            if (pipeTypeId < 1)
            {
                return Json(new { success = false, message = "未指定管材类型" });
            }
            pipeType = RepositoryFactory.GetRepository<IPipeTypeRepository, PipeType>().FindBy(pipeTypeId);

            if (pipeType == null)
            {
                return Json(new { success = false, message = "未指定管材类型" });
            }
            if (!string.IsNullOrEmpty(diggerId))
            {
                targetDigger = RepositoryFactory.GetRepository<IDiggerRepository, Digger>().FindBy(diggerId);
            }

            #endregion

            ITransferTaskRepository transferTaskRepository = RepositoryFactory.GetRepository<ITransferTaskRepository, TransferTask>(unitOfWork);
            ITransferItemRepository transferItemRepository = RepositoryFactory.GetRepository<ITransferItemRepository, TransferItem>(unitOfWork);
            ITransferRecordRepository transferRecordRepository = RepositoryFactory.GetRepository<ITransferRecordRepository, TransferRecord>(unitOfWork);
            IPipePositionRepository posRepository = RepositoryFactory.GetRepository<IPipePositionRepository, PipePosition>();
            IPipeRepository pipeRepository = RepositoryFactory.GetRepository<IPipeRepository, PDCPMS.Model.Common.Pipe>(unitOfWork);
            DateTime now = DateTime.Now;

            StringBuilder sb = new StringBuilder();
            sb.Append("Begin ");
            TransferTask transferTask = new TransferTask(Guid.NewGuid().ToString("N"), pipeType, onlineAccount.DetectionCompany, onlineAccount, now, true);

            #region 我的修改insert TransferTask
            string TransferTaskId = Guid.NewGuid().ToString("N");
            string DateCreated = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string CreatorId = onlineAccount.Key.ToString();
            int TotalCount = transferItemContracts[0].Count;
            string PipeTypeId = pipeTypeId.ToString();
            string DetectionCompanyId = onlineAccount.DetectionCompany.Key.ToString();
            sb.Append("Insert Into TransferTask(TransferTaskId,IsSystemTask,DateCreated,CreatorId,IsFinished,DateFinished,TotalCount,PipeTypeId,DetectionCompanyId,\"Comment\")Values(");
            sb.Append("'" + TransferTaskId + "',");
            sb.Append("1,");
            sb.Append("to_date('" + DateCreated + "', 'yyyy-mm-dd HH24:mi:ss'),");
            sb.Append("'" + CreatorId + "',");
            sb.Append("0,");
            sb.Append("null,");
            sb.Append("" + TotalCount + ",");
            sb.Append("'" + PipeTypeId + "',");
            sb.Append("'" + DetectionCompanyId + "',");
            sb.Append("'');");
            #endregion
            TotalCount = 0;

            foreach (PDCPMS.DataContracts.Transfer.TransferItem tic in transferItemContracts)
            {
                PipePosition prePos = posRepository.FindBy(tic.PrevPosId);
                PipePosition newPos = posRepository.FindBy(tic.NewPosId);

                if (prePos == null || newPos == null || tic.Count < 0)
                {
                    return Json(new { success = false, message = "你的调度项输入有误" });
                }

                TransferItem item = new TransferItem(Guid.NewGuid().ToString("N"), transferTask);

                item.PrevPos = prePos;
                item.NewPos = newPos;
                item.Count = tic.Count;

                #region 我的修改 TransferItem Insert
                string TransferItemId = Guid.NewGuid().ToString("N");
                string TransferTaskId_Forignkey = TransferTaskId;
                int Count = TotalCount;
                string PrevPositionId = item.PrevPos.Key.ToString();
                string NewPositionId = item.NewPos.Key.ToString();
                sb.Append("Insert Into TransferItem(TransferItemId, TransferTaskId, Count, PrevPositionId, NewPositionId)Values(");
                sb.Append("'" + TransferItemId + "',");
                sb.Append("'" + TransferTaskId_Forignkey + "',");
                sb.Append("" + tic.Count + ",");
                sb.Append("'" + PrevPositionId + "',");
                sb.Append("'" + NewPositionId + "');");
                #endregion

                System.Data.DataTable dt = pipeRepository.FindByMyCondition(prePos, pipeType, PipeState.Received | PipeState.Storing, PipeState.Transfering | PipeState.NormalChecking);

                if (dt.Rows.Count < tic.Count)
                {
                    return Json(new { success = false, message = string.Format("调度失败:垛位({0})已无{1}根可检测的存货,可能已经被调至别处", prePos.ToString(), tic.Count) });
                }
                for (int i = 0; i < tic.Count; i++)
                {
                    #region 我改的 TransferRecord Insert
                    string TransferRecordId = Guid.NewGuid().ToString("N");
                    string TransferItemId_ForignKey = TransferItemId;
                    string DateCreated_Record = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    string PrevPositionId_Record = item.PrevPos.Key.ToString();
                    string NewPositionId_Record = item.NewPos.Key.ToString();
                    string PipeId = dt.Rows[i]["pipeid"].ToString();

                    sb.Append("Insert Into TransferRecord(TransferRecordId,TransferItemId,DateCreated,DateFinished,PrevPositionId,NewPositionId,PipeId)Values(");
                    sb.Append("'" + TransferRecordId + "',");
                    sb.Append("'" + TransferItemId_ForignKey + "',");
                    sb.Append("to_date('" + DateCreated + "', 'yyyy-mm-dd HH24:mi:ss'),");
                    sb.Append("null,");
                    sb.Append("'" + PrevPositionId_Record + "',");
                    sb.Append("'" + NewPositionId_Record + "',");
                    sb.Append("'" + PipeId + "');");

                    //2010-12-01 by huncherby  发起常检任务改变状态
                    sb.Append("update Pipe set state = (state + ");
                    sb.Append((int)PipeState.Transfering);
                    sb.Append(" - bitand(state, ");
                    sb.Append((int)PipeState.Transfering);
                    sb.Append(" )) Where PipeId = ");

                    sb.Append(dt.Rows[i]["PipeId"].ToString());
                    sb.Append(";");

                    #endregion
                }
                TotalCount += item.Count;
                transferTask.TotalCount += item.Count;
            }

            NormalCheckTask ncTask = new NormalCheckTask(Guid.NewGuid().ToString("N"), code, onlineAccount.DetectionCompany, pipeType, targetDigger, transferTask, onlineAccount, now);

            #region 我的修改 NormalCheckTask Insert
            string NormalCheckTaskId = Guid.NewGuid().ToString("N");
            string PipeTypeId_ForignKey = PipeTypeId;
            string DetectionCompanyId_ForignKey = DetectionCompanyId;
            string DiggerId = diggerId;
            string TransferTaskId_ForignKey = TransferTaskId;
            string Code = code;
            string DateCreated_NCTask = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            int Count_NCTask = TotalCount;
            //string pipeneednoticeitemid = null;

            sb.Append("Insert Into NormalCheckTask(NormalCheckTaskId,PipeTypeId,DetectionCompanyId,DiggerId,TransferTaskId,State,Code,WorkNO,CreatorId,DateCreated,SenderId,DateSent,ReceiverId,DateReceived,CheckItemCreatorId,CheckItemDateCreated,Count,CheckStandard,IsNeedMark,IsCheckAppearance,IsCheckThickness,IsCheckLength,IsNeedWash,IsCheckUnBlock,IsCheckPressure,CheckPressureType,IsCheckCloseness,IsCheckBodyCrack,CheckBodyCrackType,IsCheckBlindCrack,\"Comment\",FinisherId,DateFinished,CheckTools,CheckConclusion,ReportComment,MainCheckId,VeriferId,DateVerified,ApproverId,DateApproved,ReportNO,team,faxno,pipeneednoticeitemid)Values(");
            sb.Append("'" + NormalCheckTaskId + "',");
            sb.Append("'" + PipeTypeId_ForignKey + "',");
            sb.Append("'" + DetectionCompanyId_ForignKey + "',");
            sb.Append("'" + diggerId + "',");
            sb.Append("'" + TransferTaskId_ForignKey + "',");
            sb.Append("0,");
            sb.Append("'" + Code + "',");
            sb.Append("'',");
            sb.Append("'" + CreatorId + "',");
            sb.Append("to_date('" + DateCreated_NCTask + "', 'yyyy-mm-dd HH24:mi:ss'),");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("'" + Count_NCTask + "',");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("-1,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("-1,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,");
            sb.Append("null,'"+team+"','"+faxno+"',");
            sb.Append("'" + pipeneednoticeitemid + "');");
            sb.Append(" End;");
            #endregion
            INormalCheckTaskRepository NCTaskR = RepositoryFactory.GetRepository<INormalCheckTaskRepository, NormalCheckTask>();
            NCTaskR.Excute(sb.ToString());
            TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("成功发起常检任务({0})", Code) };
            return Json(new { success = true, taskId = Code });
        }
Exemple #3
0
 public TransferItem(string key, TransferTask task)
     : base(key)
 {
     this.TransferTask = task;
 }
        public NormalCheckTask(string key, string code, DetectionCompany company, PipeType pipeTye, Digger targetDigger,
            TransferTask transferTask, Account creator, DateTime dateCreated)
            : base(key)
        {
            this.Code = code;
            this.Company = company;
            this.PipeType = pipeTye;
            this.TargetDigger = targetDigger;
            this.TransferTask = transferTask;
            this.Creator = creator;
            this.DateCreated = dateCreated;

            this.CheckPressureType = CheckPressureType.NotGiven;
            this.CheckBodyCrackType = PDCPMS.Model.NormalCheck.CheckBodyCrackType.NotGiven;
        }