Exemple #1
0
        public override void GetResult(object data, int nWorkTypeID)
        {
            InFlows_Card input = Newtonsoft.Json.JsonConvert.DeserializeObject <InFlows_Card>(data.ToString());
            DBStep       db    = new DBStep();
            IdIcCard     c     = new IdIcCard();
            int          k     = 0;//判断循环的次数

            foreach (trainmanList t in input.trainmanList)
            {
                #region 出勤步骤结果的实体信息
                StepResult StepResult = new StepResult();
                StepResult.dtBeginTime  = ObjectConvertClass.static_ext_date(input.dtBeginTime);
                StepResult.dtCreateTime = ObjectConvertClass.static_ext_date(input.dtCreateTime);
                StepResult.dtEndTime    = ObjectConvertClass.static_ext_date(input.dtEndTime);
                int nStepIndex = db.getIndexOfStep(input.strWorkShopGUID, "RS.STEP.CHECKCARD", nWorkTypeID);
                if (nStepIndex == 0)
                {
                    break;
                }
                StepResult.nStepIndex        = nStepIndex;
                StepResult.strStepBrief      = "验卡记录";
                StepResult.strStepName       = "RS.STEP.CHECKCARD";
                StepResult.strTrainPlanGUID  = input.strTrainPlanGUID;
                StepResult.strTrainmanGUID   = t.strTrainmanGUID;
                StepResult.nStepResult       = input.nStepResult;
                StepResult.strTrainmanName   = t.strTrainmanName;
                StepResult.strTrainmanNumber = t.strTrainmanNumber;
                StepResult.nWorkTypeID       = nWorkTypeID;
                #endregion

                #region 出勤步骤索引信息
                List <StepIndex> LStepIndex = new List <StepIndex>();
                StepIndex        StepIndex  = new StepIndex();
                StepIndex.dtStartTime       = ObjectConvertClass.static_ext_date(DateTime.Now);
                StepIndex.strFieldName      = "IsCheckCard";
                StepIndex.nStepData         = input.nTestCardResult;;
                StepIndex.strTrainmanNumber = t.strTrainmanNumber;
                StepIndex.strTrainPlanGUID  = input.strTrainPlanGUID;
                StepIndex.nWorkTypeID       = nWorkTypeID;
                LStepIndex.Add(StepIndex);
                #endregion

                #region 出勤步骤详细信息

                DBDrink dbpost = new DBDrink();
                string  npost  = dbpost.getTmPost(input.strTrainPlanGUID, t.strTrainmanNumber);

                List <StepData> LStepData = new List <StepData>();
                StepData        StepData1 = new StepData();
                StepData1.strTrainPlanGUID  = input.strTrainPlanGUID;
                StepData1.strFieldName      = "nTestCardResult" + npost;
                StepData1.nStepData         = input.nTestCardResult;
                StepData1.strTrainmanNumber = t.strTrainmanNumber;
                StepData1.strStepName       = "RS.STEP.CHECKCARD";
                StepData1.nWorkTypeID       = nWorkTypeID;
                LStepData.Add(StepData1);

                StepData StepData2 = new StepData();
                StepData2.strTrainPlanGUID  = input.strTrainPlanGUID;
                StepData2.strFieldName      = "strTestCardResult" + npost;
                StepData2.strStepData       = input.strTestCardResult;
                StepData2.strTrainmanNumber = t.strTrainmanNumber;
                StepData2.strStepName       = "RS.STEP.CHECKCARD";
                StepData2.nWorkTypeID       = nWorkTypeID;
                LStepData.Add(StepData2);
                #endregion


                c.dtCreateTime      = input.dtCreateTime.ToString();
                c.dtEventTime       = input.dtBeginTime.ToString();
                c.strEventBrief     = input.strTestCardResult;
                c.strTrainmanName   = t.strTrainmanName;
                c.strTrainmanNumber = t.strTrainmanNumber;
                c.strTrainPlanGUID  = input.strTrainPlanGUID;
                db.AddStep(LStepIndex, LStepData, StepResult);

                //添加验卡实际的业务逻辑
                db.AddIDICCard(c);

                //向旧的接口提交数据
                MDPlan_Beginwork_Step md = new MDPlan_Beginwork_Step();
                md.dtCreateTime      = input.dtCreateTime;
                md.dtEventEndTime    = input.dtEndTime;
                md.dtEventTime       = input.dtCreateTime;
                md.nStepID           = 1008;
                md.nStepResultID     = 1;
                md.strStepResultText = "";
                md.strTrainmanGUID   = t.strTrainmanGUID;
                md.strTrainmanName   = t.strTrainmanName;
                md.strTrainmanNumber = t.strTrainmanName;
                md.strTrainPlanGUID  = input.strTrainPlanGUID;
                db.AddPlan_Beginwork_Step(md);

                //向运行记录中增加数据
                MDRunEvent runEvent = new MDRunEvent();
                runEvent.dtCreateTime     = DateTime.Now;
                runEvent.dtEventTime      = input.dtBeginTime;
                runEvent.nEventID         = 10008;
                runEvent.nResult          = 10008;
                runEvent.nTMIS            = input.placeID;
                runEvent.strFlowID        = "";
                runEvent.strGroupGUID     = input.strTrainPlanGUID;
                runEvent.strResult        = input.strTestCardResult;
                runEvent.strTrainPlanGUID = input.strTrainPlanGUID;
                runEvent.strRunEventGUID  = Guid.NewGuid().ToString();
                int    isAddResult = 0;
                string Ex          = "";
                if (!string.IsNullOrEmpty(input.strTrainPlanGUID))
                {
                    DataTable dt = db.getTrainInfo(input.strTrainPlanGUID);
                    if (dt.Rows.Count > 0)
                    {
                        runEvent.strTrainTypeName   = dt.Rows[0]["strTrainTypeName"].ToString();
                        runEvent.nKeHuo             = Convert.ToInt32(dt.Rows[0]["nKehuoID"].ToString());
                        runEvent.strTrainNo         = dt.Rows[0]["strTrainNo"].ToString();
                        runEvent.strTrainNumber     = dt.Rows[0]["strTrainNumber"].ToString();
                        runEvent.strTrainmanNumber1 = dt.Rows[0]["strTrainmanNumber1"].ToString();
                        runEvent.strTrainmanNumber2 = dt.Rows[0]["strTrainmanNumber2"].ToString();
                        try
                        {
                            if (db.nCheckIsExist(input.strTrainPlanGUID) >= 1)
                            {
                                if (k == 0)//如果是循环到第一个人,并且是数据库中有记录的话  要进行覆盖
                                {
                                    isAddResult = db.UpdatePlan_RunEvent(runEvent);
                                }
                            }
                            else
                            {
                                isAddResult = db.AddPlan_RunEvent(runEvent);
                                k++;
                            }
                        }
                        catch (Exception ex)
                        {
                            isAddResult = 2;
                            Ex          = ex.Message.ToString();
                        }
                    }
                }
                RunEvent_TrainmanDetail rt = new RunEvent_TrainmanDetail();
                rt.dtCreateTime = DateTime.Now;
                rt.dtEventTime  = input.dtBeginTime;
                rt.nEventID     = 10008;
                rt.nKeHuo       = runEvent.nKeHuo;
                rt.nResultID    = input.nTestCardResult;
                rt.strResult    = input.strTestCardResult;
                if (isAddResult == 0)
                {
                    rt.nSubmitResult   = 0;
                    rt.strSubmitRemark = "添加失败,返回0条数据!";
                }
                else if (isAddResult == 1)
                {
                    rt.nSubmitResult   = 1;
                    rt.strSubmitRemark = "添加成功!";
                }
                else if (isAddResult == 2)
                {
                    rt.nSubmitResult   = 2;
                    rt.strSubmitRemark = "添加失败!异常信息" + Ex;
                }

                rt.nTMIS             = input.placeID;
                rt.strRunEventGUID   = runEvent.strRunEventGUID;
                rt.strTrainmanNumber = t.strTrainmanNumber;
                db.AddTrainmanDetail(rt);

                //检测是否是特殊步骤
                if (db.CheckIsSpecialStep("RS.STEP.CHECKCARD", input.strWorkShopGUID, nWorkTypeID))
                {
                    db.UpdateToYiChuQin(input.strTrainPlanGUID, DateTime.Now, "", "", "", nWorkTypeID);
                }
            }
            db.creatMsg("RS.STEP.CHECKCARD", input.strTrainPlanGUID, input.cid, nWorkTypeID, input.strWorkShopGUID);
        }