public override void GetResult(object data, int nWorkTypeID) { DBDrink db = new DBDrink(); DBStep dbs = new DBStep(); InSubmitDrink input = Newtonsoft.Json.JsonConvert.DeserializeObject <InSubmitDrink>(data.ToString()); db.AddDrinkInfo(input, nWorkTypeID); dbs.creatMsg("RS.STEP.DRINKTEST", input.TrainPlanGUID, input.cid, nWorkTypeID, input.DrinkInfo.strWorkShopGUID); dbs.creatDrinkMsg(input); }
//向旧的数据库中增加数据 private void SaveDrinkStepData(string strTrainPlanGUID, string strTrainmanGUID, string strTrainmanNumber, string strTainmanName, InSubmitDrink InParams) { MDPlan_Beginwork_Step step = new MDPlan_Beginwork_Step(); SubTestAlcoholInfo alcoholInfo = new SubTestAlcoholInfo(); alcoholInfo.TestAlcoholResult = int.Parse(InParams.DrinkInfo.drinkResult); alcoholInfo.VerfiyID = InParams.VerifyID; alcoholInfo.TestTime = ObjectConvertClass.static_ext_date(InParams.DrinkInfo.createTime); alcoholInfo.TestPicturePath = InParams.DrinkInfo.imagePath; alcoholInfo.Alcoholicity = ObjectConvertClass.static_ext_int(InParams.DrinkInfo.dwAlcoholicity); step.nStepID = 1003; step.nStepResultID = 1; step.strTrainmanGUID = strTrainmanGUID; step.strTrainmanNumber = strTrainmanNumber; step.strTrainmanName = strTainmanName; step.strTrainPlanGUID = strTrainPlanGUID; step.dtEventTime = ObjectConvertClass.static_ext_date(InParams.DrinkInfo.createTime); step.dtEventEndTime = ObjectConvertClass.static_ext_date(InParams.DrinkInfo.createTime); step.strStepResultText = Newtonsoft.Json.JsonConvert.SerializeObject(alcoholInfo); DBStep db = new DBStep(); db.AddPlan_Beginwork_Step(step); }
public void AddDrinkInfo(InSubmitDrink InParams, int nWorkTypeID, string strStepName = "RS.STEP.DRINKTEST") { //为了和之前的程序进行兼容,继续向老的数据库中增加数据,按照原有老的方式 string chuqinID = ""; int nDrinkWorkTypeID = 0; if (nWorkTypeID == 1) { this.SubBeginWorkForOld(InParams.TrainPlanGUID, InParams.TrainmanGUID, InParams.DrinkInfo.createTime, InParams.VerifyID, InParams.Remark, InParams, ref chuqinID); nDrinkWorkTypeID = 2;//将测酒类型变成出勤测酒 } else if (nWorkTypeID == 2) { this.SubEndWorkForOld(InParams.TrainPlanGUID, InParams.TrainmanGUID, InParams.DrinkInfo.createTime, InParams.VerifyID, InParams.Remark, ref chuqinID); nDrinkWorkTypeID = 3;//将测酒类型变成退勤测酒 } //添加测酒记录 string strSql = @"insert into TAB_Drink_Information ( strGUID,strTrainmanGUID,strTrainmanNumber,strTrainmanName ,dwAlcoholicity ,nDrinkResult,dtCreateTime , strTrainNo , strTrainNumber , strTrainTypeName , strPlaceID , strPlaceName, strSiteGUID , strSiteName , strWorkShopGUID , strWorkShopName ,strAreaGUID,strDutyNumber,strDutyName,nVerifyID,nWorkTypeID,strWorkID,strImagePath,strSiteNumber,bLocalAreaTrainman,strDepartmentID,strDepartmentName,nCadreTypeID,strCadreTypeName) values (@strGUID,@strTrainmanGUID,@strTrainmanNumber,@strTrainmanName,@dwAlcoholicity,@nDrinkResult,@dtCreateTime, @strTrainNo , @strTrainNumber , @strTrainTypeName , @strPlaceID , @strPlaceName, @strSiteGUID , @strSiteName , @strWorkShopGUID , @strWorkShopName ,@strAreaGUID,@strDutyNumber,@strDutyName,@nVerifyID,@nWorkTypeID,@strWorkID,@strImagePath,@strSiteNumber,@bLocalAreaTrainman,@strDepartmentID,@strDepartmentName,@nCadreTypeID,@strCadreTypeName)"; int bLocalAreaTrainman; if (InParams.DrinkInfo.bLocalAreaTrainman) { bLocalAreaTrainman = 1; } else { bLocalAreaTrainman = 0; } //职位信息----- 开始---------- DrinkLogic.DBDrinkLogic dbdl = new DrinkLogic.DBDrinkLogic(); DrinkLogic.MDDrinkLogic mddl = new DrinkLogic.MDDrinkLogic(); mddl = dbdl.GetDrinkCadreEntity(InParams.DrinkInfo.strTrainmanNumber); if (mddl != null) { InParams.DrinkInfo.strDepartmentID = mddl.strDepartmentID; InParams.DrinkInfo.strDepartmentName = mddl.strDepartmentName; InParams.DrinkInfo.nCadreTypeID = mddl.nCadreTypeID; InParams.DrinkInfo.strCadreTypeName = mddl.strCadreTypeName; } else { InParams.DrinkInfo.strDepartmentID = ""; InParams.DrinkInfo.strDepartmentName = ""; InParams.DrinkInfo.nCadreTypeID = ""; InParams.DrinkInfo.strCadreTypeName = ""; } //职位信息----- 结束---------- SqlParameter[] sqlParamsDrink = new SqlParameter[] { new SqlParameter("strGUID", Guid.NewGuid().ToString()), new SqlParameter("strTrainmanGUID", InParams.TrainmanGUID), new SqlParameter("strTrainmanNumber", InParams.DrinkInfo.strTrainmanNumber), new SqlParameter("strTrainmanName", InParams.DrinkInfo.strTrainmanName), new SqlParameter("dwAlcoholicity", InParams.DrinkInfo.dwAlcoholicity), new SqlParameter("strTrainNo", InParams.DrinkInfo.strTrainNo), new SqlParameter("strTrainNumber", InParams.DrinkInfo.strTrainNumber), new SqlParameter("strTrainTypeName", InParams.DrinkInfo.strTrainTypeName), new SqlParameter("strPlaceID", InParams.DrinkInfo.strPlaceID), new SqlParameter("strPlaceName", InParams.DrinkInfo.strPlaceName), new SqlParameter("strSiteGUID", InParams.DrinkInfo.strSiteGUID), new SqlParameter("strSiteName", InParams.DrinkInfo.strSiteName), new SqlParameter("strWorkShopGUID", InParams.DrinkInfo.strWorkShopGUID), new SqlParameter("strWorkShopName", InParams.DrinkInfo.strWorkShopName), new SqlParameter("nDrinkResult", InParams.DrinkInfo.drinkResult), new SqlParameter("strImagePath", InParams.DrinkInfo.imagePath), new SqlParameter("dtCreateTime", InParams.DrinkInfo.createTime), new SqlParameter("strAreaGUID", InParams.DrinkInfo.strAreaGUID), new SqlParameter("strDutyNumber", ""), new SqlParameter("strDutyName", ""), new SqlParameter("nVerifyID", InParams.VerifyID), new SqlParameter("nWorkTypeID", nDrinkWorkTypeID), new SqlParameter("strWorkID", chuqinID), new SqlParameter("strSiteNumber", ""), new SqlParameter("bLocalAreaTrainman", bLocalAreaTrainman), new SqlParameter("strDepartmentID", InParams.DrinkInfo.strDepartmentID), new SqlParameter("strDepartmentName", InParams.DrinkInfo.strDepartmentName), new SqlParameter("nCadreTypeID", InParams.DrinkInfo.nCadreTypeID), new SqlParameter("strCadreTypeName", InParams.DrinkInfo.strCadreTypeName) }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, sqlParamsDrink); string strTrainmanNumber = ""; string strTrainmanName = ""; DataTable dt = GetTrainman(InParams.TrainmanGUID); if (dt.Rows.Count > 0) { strTrainmanNumber = ObjectConvertClass.static_ext_string(dt.Rows[0]["strTrainmanNumber"]); strTrainmanName = ObjectConvertClass.static_ext_string(dt.Rows[0]["strTrainmanName"]); } SaveDrinkStepData(InParams.TrainPlanGUID, InParams.TrainmanGUID, strTrainmanNumber, strTrainmanName, InParams, nWorkTypeID, strStepName); }
public void SubBeginWorkForOld(string TrainPlanGUID, string TrainmanGUID, string createTime, int VerifyID, string Remark, InSubmitDrink InParams, ref string chuqinID) { //添加或者覆盖出勤计划 string strSql = "select dtCreateTime,strBeginWorkGUID from TAB_Plan_BeginWork where strTrainPlanGUID = @strTrainPlanGUID and strTrainmanGUID = @strTrainmanGUID"; SqlParameter[] sqlParamsCQ = new SqlParameter[] { new SqlParameter("strTrainPlanGUID", TrainPlanGUID), new SqlParameter("strTrainmanGUID", TrainmanGUID) }; DataTable dtCQ = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql, sqlParamsCQ).Tables[0]; bool bReDrink = false; if (dtCQ.Rows.Count == 0) { chuqinID = Guid.NewGuid().ToString(); strSql = @"insert into TAB_Plan_BeginWork (strBeginWorkGUID,strTrainPlanGUID,strTrainmanGUID,dtCreateTime,nVerifyID,strRemark) values (@strBeginWorkGUID,@strTrainPlanGUID,@strTrainmanGUID,@dtCreateTime,@nVerifyID,@strRemark)"; SqlParameter[] sqlParamsTemp = new SqlParameter[] { new SqlParameter("strBeginWorkGUID", chuqinID), new SqlParameter("strTrainPlanGUID", TrainPlanGUID), new SqlParameter("strTrainmanGUID", TrainmanGUID), new SqlParameter("dtCreateTime", createTime), new SqlParameter("nVerifyID", VerifyID), new SqlParameter("strRemark", Remark) }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, sqlParamsTemp); } else { chuqinID = dtCQ.Rows[0]["strBeginWorkGUID"].ToString(); bReDrink = true; strSql = @"update TAB_Plan_BeginWork set nVerifyID=@nVerifyID,strRemark=@strRemark where strBeginWorkGUID=@strBeginWorkGUID"; SqlParameter[] sqlParamsTemp = new SqlParameter[] { new SqlParameter("strBeginWorkGUID", chuqinID), new SqlParameter("nVerifyID", VerifyID), new SqlParameter("strRemark", Remark) }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, sqlParamsTemp); } //将之前的测酒记录和计划关联取消 if (bReDrink) { strSql = "update TAB_Drink_Information set strWorkID = '' where strWorkID = @strWorkID and strTrainmanGUID = @strTrainmanGUID and nWorkTypeID = 2"; SqlParameter[] sqlParamsTemp = new SqlParameter[] { new SqlParameter("strWorkID", chuqinID), new SqlParameter("strTrainmanGUID", TrainmanGUID) }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, sqlParamsTemp); } strSql = "update TAB_Plan_Train set dtBeginWorkTime=getdate() where strTrainPlanGUID = @strTrainPlanGUID and dtBeginWorkTime is null "; SqlParameter[] sqlParamsCQTime = new SqlParameter[] { new SqlParameter("strTrainPlanGUID", TrainPlanGUID) }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, sqlParamsCQTime); //修改实际出勤时间 string strTrainmanNumber = ""; string strTrainmanName = ""; DataTable dt = GetTrainman(TrainmanGUID); if (dt.Rows.Count > 0) { strTrainmanNumber = ObjectConvertClass.static_ext_string(dt.Rows[0]["strTrainmanNumber"]); strTrainmanName = ObjectConvertClass.static_ext_string(dt.Rows[0]["strTrainmanName"]); } //向旧的数据库中增加数据 SaveDrinkStepData(TrainPlanGUID, TrainmanGUID, strTrainmanNumber, strTrainmanName, InParams); }
private void SaveDrinkStepData(string strTrainPlanGUID, string strTrainmanGUID, string strTrainmanNumber, string strTainmanName, InSubmitDrink InParams, int nWorkTypeID, string strStepName) { DBStep db = new DBStep(); #region 出勤步骤结果的实体信息 StepResult StepResult = new StepResult(); StepResult.dtBeginTime = ObjectConvertClass.static_ext_date(InParams.DrinkInfo.createTime); StepResult.dtCreateTime = ObjectConvertClass.static_ext_date(InParams.DrinkInfo.createTime); StepResult.dtEndTime = ObjectConvertClass.static_ext_date(InParams.DrinkInfo.createTime); int nStepIndex = db.getIndexOfStep(InParams.DrinkInfo.strWorkShopGUID, "RS.STEP.DRINKTEST", nWorkTypeID); StepResult.nStepIndex = nStepIndex; StepResult.strStepBrief = nWorkTypeID == 1?"出勤测酒":"退勤测酒"; StepResult.strStepName = strStepName; StepResult.strTrainPlanGUID = strTrainPlanGUID; StepResult.strTrainmanGUID = InParams.DrinkInfo.trainmanID; StepResult.strTrainmanNumber = strTrainmanNumber; StepResult.strTrainmanName = InParams.DrinkInfo.strTrainmanName; StepResult.nWorkTypeID = nWorkTypeID; StepResult.nStepResult = 1; #endregion #region 出勤步骤索引信息 DateTime dtStartTime = GetdtStartTime(strTrainPlanGUID); string npost = getTmPost(strTrainPlanGUID, strTrainmanNumber); List <StepIndex> LStepIndex = new List <StepIndex>(); StepIndex StepIndex = new StepIndex(); StepIndex.dtStartTime = ObjectConvertClass.static_ext_date(dtStartTime); StepIndex.strFieldName = "nDrinkResult"; StepIndex.nStepData = int.Parse(InParams.DrinkInfo.drinkResult); StepIndex.strTrainmanNumber = strTrainmanNumber; StepIndex.strTrainPlanGUID = strTrainPlanGUID; StepIndex.nWorkTypeID = nWorkTypeID; LStepIndex.Add(StepIndex); StepIndex StepIndex2 = new StepIndex(); StepIndex2.dtStartTime = ObjectConvertClass.static_ext_date(dtStartTime); StepIndex2.strTrainmanNumber = strTrainmanNumber; StepIndex2.strTrainPlanGUID = strTrainPlanGUID; StepIndex2.strFieldName = "LateTimeDiff"; DateTime dt1 = Convert.ToDateTime(DateTime.Now); DateTime dt2 = Convert.ToDateTime(dtStartTime); TimeSpan ts = dt1 - dt2; StepIndex2.nStepData = Convert.ToInt32(ts.TotalMinutes); StepIndex2.nWorkTypeID = nWorkTypeID; LStepIndex.Add(StepIndex2); StepIndex StepIndex3 = new StepIndex(); StepIndex3.dtStartTime = ObjectConvertClass.static_ext_date(dtStartTime); StepIndex3.strTrainmanNumber = strTrainmanNumber; StepIndex3.strTrainPlanGUID = strTrainPlanGUID; StepIndex3.strFieldName = "bbtimediff"; StepIndex3.nWorkTypeID = nWorkTypeID; StepIndex3.nStepData = GetdtStartTimeDiff(strTrainPlanGUID, Convert.ToDateTime(InParams.DrinkInfo.createTime)); LStepIndex.Add(StepIndex3); #endregion #region 出勤步骤详细信息 List <StepData> LStepData = new List <StepData>(); StepData StepData1 = new StepData(); StepData1.strTrainPlanGUID = strTrainPlanGUID; StepData1.strFieldName = "nDrinkResult" + npost; StepData1.strStepName = strStepName; StepData1.strTrainmanNumber = strTrainmanNumber; StepData1.nWorkTypeID = nWorkTypeID; StepData1.nStepData = int.Parse(InParams.DrinkInfo.drinkResult); LStepData.Add(StepData1); StepData StepData2 = new StepData(); StepData2.strTrainPlanGUID = strTrainPlanGUID; StepData2.strFieldName = "LateTimeDiff" + npost; StepData2.strTrainmanNumber = strTrainmanNumber; StepData2.strStepName = strStepName; StepData2.nWorkTypeID = nWorkTypeID; StepData2.nStepData = Convert.ToInt32(ts.TotalMinutes); LStepData.Add(StepData2); StepData StepData3 = new StepData(); StepData3.strTrainPlanGUID = strTrainPlanGUID; StepData3.strFieldName = "dtEventTime" + npost; StepData3.strTrainmanNumber = strTrainmanNumber; StepData3.strStepName = strStepName; StepData3.nWorkTypeID = nWorkTypeID; StepData3.dtStepData = ObjectConvertClass.static_ext_date(InParams.DrinkInfo.createTime); LStepData.Add(StepData3); StepData StepData4 = new StepData(); StepData4.strTrainPlanGUID = strTrainPlanGUID; StepData4.strFieldName = "picture" + npost; StepData4.strTrainmanNumber = strTrainmanNumber; StepData4.strStepName = strStepName; StepData4.nWorkTypeID = nWorkTypeID; StepData4.strStepData = ObjectConvertClass.static_ext_string(InParams.DrinkInfo.imagePath); LStepData.Add(StepData4); StepData StepData5 = new StepData(); StepData5.strTrainPlanGUID = strTrainPlanGUID; StepData5.strFieldName = "nVerifyID" + npost; StepData5.strTrainmanNumber = strTrainmanNumber; StepData5.strStepName = strStepName; StepData5.nWorkTypeID = nWorkTypeID; StepData5.nStepData = ObjectConvertClass.static_ext_int(InParams.VerifyID); LStepData.Add(StepData5); #endregion db.AddStep(LStepIndex, LStepData, StepResult); List <trainmanList> trainmanlist = new List <trainmanList>(); trainmanList trainman = new trainmanList(); trainman.strTrainmanGUID = strTrainmanGUID; trainmanlist.Add(trainman); //检测是否是特殊步骤 if (db.CheckIsSpecialStep(strStepName, InParams.DrinkInfo.strWorkShopGUID, nWorkTypeID)) { if (CheckIsCejiuAll(strTrainPlanGUID, nWorkTypeID)) { if (nWorkTypeID == 1) { db.UpdateToYiChuQin(strTrainPlanGUID, DateTime.Now, "", "", "", nWorkTypeID); } else if (nWorkTypeID == 2) { DBStep dal = new DBStep(); dal.UpdateToYiTuiQin(InParams.TrainPlanGUID, InParams.DrinkInfo.strSiteGUID, DateTime.Now, "", "", "", 2); } } } //检测是否是断网测酒 if (getSetTime(InParams.DrinkInfo.strWorkShopGUID, nWorkTypeID) > Convert.ToDateTime(InParams.DrinkInfo.createTime)) { if (CheckIsCejiuAll(strTrainPlanGUID, nWorkTypeID)) { if (nWorkTypeID == 1) { db.UpdateToYiChuQin(strTrainPlanGUID, DateTime.Now, "", "", "", nWorkTypeID); } else if (nWorkTypeID == 2) { DBStep dal = new DBStep(); dal.UpdateToYiTuiQin(InParams.TrainPlanGUID, InParams.DrinkInfo.strSiteGUID, DateTime.Now, "", "", "", 2); } } } }