/// <summary> /// 线材综合判定确认 /// </summary> /// <param name="strBatchNo">批号</param> /// <param name="strUrl">xml地址</param> /// <returns></returns> public string Roll_Compre_OK(string strBatchNo, string strUrl) { string result = "1"; try { Dal_TRC_ROLL_PRODCUT dalTrcRollProduct = new Dal_TRC_ROLL_PRODCUT(); Dal_TRC_ROLL_WGD dalTrcRollWgd = new Dal_TRC_ROLL_WGD(); Dal_TQC_ROLL_COMMUTE DalTqcRollCommute = new Dal_TQC_ROLL_COMMUTE(); Dal_Interface_NC_Roll_KC4N_ZP dal_interface = new Dal_Interface_NC_Roll_KC4N_ZP(); Dal_Interface_NC_Roll_KC4N_ZP_No_WGD dal_interface_No_Wgd = new Dal_Interface_NC_Roll_KC4N_ZP_No_WGD(); Dal_TQR_ZBS_ITEM dalTqrZbsItem = new Dal_TQR_ZBS_ITEM(); Dal_TQC_COMPRE_ITEM_RESULT dalTqcCompreItemResult = new Dal_TQC_COMPRE_ITEM_RESULT(); Dal_TQC_PHYSICS_RESULT_MAIN dalTqcPhysicsResultMain = new Dal_TQC_PHYSICS_RESULT_MAIN(); TransactionHelper.BeginTransaction(); TransactionHelper_SQL.BeginTransaction(); string strUserID = RV.UI.UserInfo.userID; DateTime time = RV.UI.ServerTime.timeNow(); string C_MASTER_ID = ""; string C_GP_BEFORE_ID = ""; string C_GP_AFTER_ID = ""; DataTable dt_CompreRoll = dal.Get_List(strBatchNo).Tables[0]; if (dt_CompreRoll.Rows.Count > 0) { int num = 0; for (int i = 0; i < dt_CompreRoll.Rows.Count; i++) { num++; Mod_TQC_COMPRE_ROLL modTqcCompreRoll = dal.GetModel(dt_CompreRoll.Rows[i]["C_ID"].ToString()); if (!string.IsNullOrEmpty(modTqcCompreRoll.C_RESULT_PEOPLE) || !string.IsNullOrEmpty(modTqcCompreRoll.C_RESULT_ALL)) { //判定结果回写实绩表 string strResult = ""; if (!string.IsNullOrEmpty(modTqcCompreRoll.C_RESULT_PEOPLE)) { strResult = modTqcCompreRoll.C_RESULT_PEOPLE; } else { strResult = modTqcCompreRoll.C_RESULT_ALL; } if (strResult == "N") { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("综判等级为N,请选择人工判定等级!"); } modTqcCompreRoll.C_QR_STATE = "Y"; modTqcCompreRoll.C_EMP_ID = strUserID; modTqcCompreRoll.D_MOD_DT = time; if (!dal.Update_Trans(modTqcCompreRoll)) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("操作失败!"); } DataTable dt = DalTqcRollCommute.GetList_max_Trans().Tables[0]; if (string.IsNullOrEmpty(dt.Rows[0]["C_GP_AFTER_ID"].ToString())) { C_GP_AFTER_ID = "ph" + time.ToString("yyMMdd00001"); } else { C_GP_AFTER_ID = "ph" + (Convert.ToInt64(dt.Rows[0]["C_GP_AFTER_ID"].ToString()) + 1).ToString(); } if (!dalTrcRollProduct.Update_Trans(strResult, modTqcCompreRoll.C_EMP_ID, modTqcCompreRoll, C_GP_AFTER_ID)) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("操作失败!"); } } else { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("请先选择人工判定等级!"); } } int num_main = dalTqcPhysicsResultMain.Get_Count(strBatchNo); if (num_main > 0) { if (!dalTqcPhysicsResultMain.Update_PD_Trans(strBatchNo)) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("更新判定状态失败!"); } } if (num == dt_CompreRoll.Rows.Count) { #region 步重量 DataTable dtTM = dal.Get_TM_List(strBatchNo).Tables[0]; if (dtTM.Rows.Count > 0) { for (int i = 0; i < dtTM.Rows.Count; i++) { if (!dalTrcRollProduct.Update_Wgt_Trans(strBatchNo, dtTM.Rows[i]["GH"].ToString(), dtTM.Rows[i]["ZL"].ToString())) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("更新重量失败!"); } } } else { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("没有找到条码库存信息,判定失败!"); } #endregion Mod_TRC_ROLL_WGD mod_wgd = dalTrcRollWgd.Get_WGD_Modle(strBatchNo);//获取完工单信息 if (mod_wgd != null) { DataTable dt_Group = dalTrcRollProduct.Get_List_ByGroup(strBatchNo).Tables[0]; for (int i = 0; i < dt_Group.Rows.Count; i++) { #region 更新线材实绩表 DataTable dt = DalTqcRollCommute.GetList_max_MasterID_Trans().Tables[0]; if (string.IsNullOrEmpty(dt.Rows[0]["C_MASTER_ID"].ToString())) { C_MASTER_ID = "sj" + time.ToString("yyMMdd00001"); } else { C_MASTER_ID = "sj" + (Convert.ToInt64(dt.Rows[0]["C_MASTER_ID"].ToString()) + 1).ToString(); } if (string.IsNullOrEmpty(dt.Rows[0]["C_GP_BEFORE_ID"].ToString())) { C_GP_BEFORE_ID = "pq" + time.ToString("yyMMdd00001"); } else { C_GP_BEFORE_ID = "pq" + (Convert.ToInt64(dt.Rows[0]["C_GP_BEFORE_ID"].ToString()) + 1).ToString(); } if (!dalTrcRollProduct.Update_Trans(C_MASTER_ID, C_GP_BEFORE_ID, dt_Group.Rows[i]["C_STD_CODE"].ToString(), dt_Group.Rows[i]["C_MAT_CODE"].ToString(), dt_Group.Rows[i]["C_ZYX1"].ToString(), dt_Group.Rows[i]["C_ZYX2"].ToString(), strBatchNo)) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("操作失败!"); } #endregion #region 条码 DataTable dt_Details = dalTrcRollProduct.Get_Details(strBatchNo, dt_Group.Rows[i]["C_STD_CODE"].ToString(), dt_Group.Rows[i]["C_MAT_CODE"].ToString(), dt_Group.Rows[i]["C_ZYX1"].ToString(), dt_Group.Rows[i]["C_ZYX2"].ToString()).Tables[0]; if (dt_Details.Rows.Count > 0) { string sql = ""; for (int kk = 0; kk < dt_Details.Rows.Count; kk++) { if (mod_wgd.C_MRSX.ToString() == "DP") { sql = "insert into ReZJB_GPD(Barcode,WGDH,CK,HW,PCH,WLH,WLMC,SX,PH,GG,BB,GH,ZL,BZ,RQ,RKType,RKRY,WeightRQ,ProduceData,PCInfo,vfree0,vfree3,GPTYPE,ZJBstatus,CAPPK,insertts,vfree1,vfree2) values('" + dt_Details.Rows[kk]["C_BARCODE"] + "','" + dt_Details.Rows[kk]["C_TRC_ROLL_MAIN_ID"] + "','" + dt_Details.Rows[kk]["C_LINEWH_CODE"] + "','" + dt_Details.Rows[kk]["C_LINEWH_LOC_CODE"] + "','" + dt_Details.Rows[kk]["C_BATCH_NO"] + "','" + dt_Details.Rows[kk]["C_MAT_CODE"] + "','" + dt_Details.Rows[kk]["C_MAT_DESC"] + "','" + dt_Details.Rows[kk]["C_JUDGE_LEV_ZH"] + "','" + dt_Details.Rows[kk]["C_STL_GRD"] + "','" + dt_Details.Rows[kk]["C_SPEC"] + "mm','" + dt_Details.Rows[kk]["C_GROUP"] + "','" + dt_Details.Rows[kk]["C_TICK_NO"] + "','" + dt_Details.Rows[kk]["N_WGT"] + "','" + dt_Details.Rows[kk]["C_STD_CODE"] + "','" + dt_Details.Rows[kk]["D_RKRQ"] + "','" + dt_Details.Rows[kk]["C_MOVE_DESC"] + "','" + dt_Details.Rows[kk]["C_RKRY"] + "','" + dt_Details.Rows[kk]["D_WEIGHT_DT"] + "','" + dt_Details.Rows[kk]["D_PRODUCE_DATE"] + "','" + dt_Details.Rows[kk]["C_PCINFO"] + "','" + dt_Details.Rows[kk]["C_STOVE"] + "','" + dt_Details.Rows[kk]["C_BZYQ"] + "','','0','" + dt_Details.Rows[kk]["C_ID"] + "','" + time + "','" + dt_Details.Rows[kk]["C_ZYX1"].ToString() + "','" + dt_Details.Rows[kk]["C_ZYX2"].ToString() + "')"; if (TransactionHelper_SQL.ExecuteSql(sql) == 0) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("信息传到条码时出错!"); } } else { if (dt_Details.Rows[kk]["C_JUDGE_LEV_BP"].ToString() != dt_Details.Rows[kk]["C_JUDGE_LEV_ZH"].ToString()) { sql = "insert into ReZJB_GPD(Barcode,WGDH,CK,HW,PCH,WLH,WLMC,SX,PH,GG,BB,GH,ZL,BZ,RQ,RKType,RKRY,WeightRQ,ProduceData,PCInfo,vfree0,vfree3,GPTYPE,ZJBstatus,CAPPK,insertts,vfree1,vfree2) values('" + dt_Details.Rows[kk]["C_BARCODE"] + "','" + dt_Details.Rows[kk]["C_TRC_ROLL_MAIN_ID"] + "','" + dt_Details.Rows[kk]["C_LINEWH_CODE"] + "','" + dt_Details.Rows[kk]["C_LINEWH_LOC_CODE"] + "','" + dt_Details.Rows[kk]["C_BATCH_NO"] + "','" + dt_Details.Rows[kk]["C_MAT_CODE"] + "','" + dt_Details.Rows[kk]["C_MAT_DESC"] + "','" + dt_Details.Rows[kk]["C_JUDGE_LEV_ZH"] + "','" + dt_Details.Rows[kk]["C_STL_GRD"] + "','" + dt_Details.Rows[kk]["C_SPEC"] + "mm','" + dt_Details.Rows[kk]["C_GROUP"] + "','" + dt_Details.Rows[kk]["C_TICK_NO"] + "','" + dt_Details.Rows[kk]["N_WGT"] + "','" + dt_Details.Rows[kk]["C_STD_CODE"] + "','" + dt_Details.Rows[kk]["D_RKRQ"] + "','" + dt_Details.Rows[kk]["C_MOVE_DESC"] + "','" + dt_Details.Rows[kk]["C_RKRY"] + "','" + dt_Details.Rows[kk]["D_WEIGHT_DT"] + "','" + dt_Details.Rows[kk]["D_PRODUCE_DATE"] + "','" + dt_Details.Rows[kk]["C_PCINFO"] + "','" + dt_Details.Rows[kk]["C_STOVE"] + "','" + dt_Details.Rows[kk]["C_BZYQ"] + "','','0','" + dt_Details.Rows[kk]["C_ID"] + "','" + time + "','" + dt_Details.Rows[kk]["C_ZYX1"].ToString() + "','" + dt_Details.Rows[kk]["C_ZYX2"].ToString() + "')"; if (TransactionHelper_SQL.ExecuteSql(sql) == 0) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("信息传到条码时出错!"); } } } } } else { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("信息传到条码时出错!"); } #endregion #region NC string sql_NC = "select count(distinct t.STORCODE) from XGERP50.V_ONHAND_XC t where t.批次号='" + strBatchNo + "' AND T.INVTYPE='" + dt_Group.Rows[i]["C_STL_GRD"].ToString() + "' AND T.INVCODE='" + dt_Group.Rows[i]["C_MAT_CODE"].ToString() + "' "; int countNC = dal.Get_NC_Batch_Count(sql_NC); if (countNC > 1) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("该批次信息不在同一个仓库,不能判定!"); } else if (countNC == 0) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("该批次信息还没有入库!"); } string interface_nc = dal_interface.SendXml_GP(strUrl, strBatchNo, C_MASTER_ID, dt_Group.Rows[i]["C_MAT_CODE"].ToString(), dt_Group.Rows[i]["N_WGT"].ToString(), dt_Group.Rows[i]["QUA"].ToString(), dt_Group.Rows[i]["C_ZYX1"].ToString(), dt_Group.Rows[i]["C_ZYX2"].ToString(), mod_wgd, C_GP_BEFORE_ID); if (interface_nc != "1") { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return(interface_nc); } #endregion } } else { DataTable dt_Group = dalTrcRollProduct.Get_List_ByGroup(strBatchNo).Tables[0]; for (int i = 0; i < dt_Group.Rows.Count; i++) { #region 更新线材实绩表 DataTable dt = DalTqcRollCommute.GetList_max_MasterID_Trans().Tables[0]; if (string.IsNullOrEmpty(dt.Rows[0]["C_MASTER_ID"].ToString())) { C_MASTER_ID = "sj" + time.ToString("yyMMdd00001"); } else { C_MASTER_ID = "sj" + (Convert.ToInt64(dt.Rows[0]["C_MASTER_ID"].ToString()) + 1).ToString(); } if (string.IsNullOrEmpty(dt.Rows[0]["C_GP_BEFORE_ID"].ToString())) { C_GP_BEFORE_ID = "pq" + time.ToString("yyMMdd00001"); } else { C_GP_BEFORE_ID = "pq" + (Convert.ToInt64(dt.Rows[0]["C_GP_BEFORE_ID"].ToString()) + 1).ToString(); } if (!dalTrcRollProduct.Update_Trans(C_MASTER_ID, C_GP_BEFORE_ID, dt_Group.Rows[i]["C_STD_CODE"].ToString(), dt_Group.Rows[i]["C_MAT_CODE"].ToString(), dt_Group.Rows[i]["C_ZYX1"].ToString(), dt_Group.Rows[i]["C_ZYX2"].ToString(), strBatchNo)) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("操作失败!"); } #endregion #region 条码 DataTable dt_Details = dalTrcRollProduct.Get_Details(strBatchNo, dt_Group.Rows[i]["C_STD_CODE"].ToString(), dt_Group.Rows[i]["C_MAT_CODE"].ToString(), dt_Group.Rows[i]["C_ZYX1"].ToString(), dt_Group.Rows[i]["C_ZYX2"].ToString()).Tables[0]; if (dt_Details.Rows.Count > 0) { string sql = ""; for (int kk = 0; kk < dt_Details.Rows.Count; kk++) { sql = "insert into ReZJB_GPD(Barcode,WGDH,CK,HW,PCH,WLH,WLMC,SX,PH,GG,BB,GH,ZL,BZ,RQ,RKType,RKRY,WeightRQ,ProduceData,PCInfo,vfree0,vfree3,GPTYPE,ZJBstatus,CAPPK,insertts,vfree1,vfree2) values('" + dt_Details.Rows[kk]["C_BARCODE"] + "','" + dt_Details.Rows[kk]["C_TRC_ROLL_MAIN_ID"] + "','" + dt_Details.Rows[kk]["C_LINEWH_CODE"] + "','" + dt_Details.Rows[kk]["C_LINEWH_LOC_CODE"] + "','" + dt_Details.Rows[kk]["C_BATCH_NO"] + "','" + dt_Details.Rows[kk]["C_MAT_CODE"] + "','" + dt_Details.Rows[kk]["C_MAT_DESC"] + "','" + dt_Details.Rows[kk]["C_JUDGE_LEV_ZH"] + "','" + dt_Details.Rows[kk]["C_STL_GRD"] + "','" + dt_Details.Rows[kk]["C_SPEC"] + "mm','" + dt_Details.Rows[kk]["C_GROUP"] + "','" + dt_Details.Rows[kk]["C_TICK_NO"] + "','" + dt_Details.Rows[kk]["N_WGT"] + "','" + dt_Details.Rows[kk]["C_STD_CODE"] + "','" + dt_Details.Rows[kk]["D_RKRQ"] + "','" + dt_Details.Rows[kk]["C_MOVE_DESC"] + "','" + dt_Details.Rows[kk]["C_RKRY"] + "','" + dt_Details.Rows[kk]["D_WEIGHT_DT"] + "','" + dt_Details.Rows[kk]["D_PRODUCE_DATE"] + "','" + dt_Details.Rows[kk]["C_PCINFO"] + "','" + dt_Details.Rows[kk]["C_STOVE"] + "','" + dt_Details.Rows[kk]["C_BZYQ"] + "','','0','" + dt_Details.Rows[kk]["C_ID"] + "','" + time + "','" + dt_Details.Rows[kk]["C_ZYX1"].ToString() + "','" + dt_Details.Rows[kk]["C_ZYX2"].ToString() + "')"; if (TransactionHelper_SQL.ExecuteSql(sql) == 0) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("信息传到条码时出错!"); } } } else { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("信息传到条码时出错!"); } #endregion #region NC string sql_NC = "select count(distinct t.STORCODE) from XGERP50.V_ONHAND_XC t where t.批次号='" + strBatchNo + "' AND T.INVTYPE='" + dt_Group.Rows[i]["C_STL_GRD"].ToString() + "' AND T.INVCODE='" + dt_Group.Rows[i]["C_MAT_CODE"].ToString() + "' "; int countNC = dal.Get_NC_Batch_Count(sql_NC); if (countNC > 1) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("该批次信息不在同一个仓库,不能判定!"); } else if (countNC == 0) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("该批次信息还没有入库!"); } string interface_nc = dal_interface_No_Wgd.SendXml_GP(strUrl, strBatchNo, C_MASTER_ID, dt_Group.Rows[i]["C_MAT_CODE"].ToString(), dt_Group.Rows[i]["N_WGT"].ToString(), dt_Group.Rows[i]["QUA"].ToString(), dt_Group.Rows[i]["C_ZYX1"].ToString(), dt_Group.Rows[i]["C_ZYX2"].ToString(), C_GP_BEFORE_ID); if (interface_nc != "1") { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return(interface_nc); } #endregion } } } else { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("信息有误!"); } } TransactionHelper.Commit(); TransactionHelper_SQL.Commit(); } catch (Exception ex) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return(ex.Message); } return(result); }