/// <summary> /// 删除线材 /// </summary> /// <param name="ids">主键</param> /// <returns></returns> public int DelRollProduct(List <string> ids, string batchNo, string path) { TransactionHelper.BeginTransaction(); decimal bWgt = dal.GetRollProductWgt(batchNo); string id = dal.GetRollMain(batchNo); string planId = ""; if (dal.DelRollProduct(ids) <= 0) { TransactionHelper.RollBack(); return(0); } NcRollA1 ncA1 = new NcRollA1(); NcRollA2 ncA2 = new NcRollA2(); NcRollA3 ncA3 = new NcRollA3(); NcRollA4 ncA4 = new NcRollA4(); int errorStatus = 4; string errorId = ""; try { errorId = id; var wgd = dal.GetModel(id, 1); var plan = planDalItem.GetModel_Item(wgd.C_PLAN_ID); planId = wgd.C_PLAN_ID; var a1Sta = dal_TB_STA.GetModel(plan.C_STA_ID); var matrl = dal_TB_MATRL_MAIN.GetModel(plan.C_MAT_CODE); var main = dal_TRC_ROLL_MAIN.GetModel(id); var a2Sta = dal_TB_STA.GetModel(main.C_STA_ID); //DataTable factDt2 = dal.GetWgdFactAttrDP(wgd.C_BATCH_NO).Tables[0]; //for (int j = 0; j < factDt2.Rows.Count; j++) //{ // string slabWh = dal_TPB_LINEWH.GetList_id(factDt2.Rows[j]["C_LINEWH_CODE"].ToString()).ToString(); // if (string.IsNullOrEmpty(slabWh)) // { // return 0; // } //} DataTable a4FactDt = dal.GetWgdFactTran(wgd.C_BATCH_NO, 1, ids).Tables[0]; var a4M = dal_TB_MATRL_MAIN.GetModel(wgd.C_MAT_CODE); var a4Sta = dal_TB_STA.GetModel(wgd.C_STA_ID); ncA4.zdrid = RV.UI.UserInfo.userAccount; ncA4.rq = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString()); ncA4.gzzxbmid = a4Sta.C_STA_ERPCODE; ncA4.scbmid = a4Sta.C_SSBMID; ncA4.pch = wgd.C_BATCH_NO; ncA4.wlbmid = a4M.C_PK_INVBASDOC; ncA4.jldwid = a4M.C_PK_MEASDOC; ncA4.gzzxid = a4Sta.C_ERP_PK; ncA4.ccxh = wgd.C_BATCH_NO; ncA4.pk_produce = a4M.C_PK_PRODUCE; ncA4.ksrq = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString()); ncA4.jsrq = DateTime.Parse(wgd.D_PRODUCE_DATE_E == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_E.ToString()); ncA4.hgsl = a4FactDt.Rows[0]["WGT"].ToString(); ncA4.fhgsl = a4FactDt.Rows[0]["QUA"].ToString(); object wgdHandlerStatus = wgdHandlerDal.GetWgdHandlerStatus(wgd.C_ID); if (wgdHandlerStatus != null) { string status = wgdHandlerStatus.ToString(); ncA4.sflfcp = int.Parse(status) == 2 ? "Y" : "N"; ncA4.sffsgp = int.Parse(status) == 2 ? "Y" : "N"; } else { ncA4.sflfcp = "N"; ncA4.sffsgp = "N"; } ncA4.freeitemvalue1 = wgd.C_FREE_TERM; ncA4.freeitemvalue2 = wgd.C_FREE_TERM2; ncA4.freeitemvalue3 = wgd.C_PACK; string a4Name = Guid.NewGuid() + "_A4.xml"; if (dal.IsA4Repeat(main.C_BATCH_NO, "") > 0) { TransactionHelper.RollBack(); return(0); } var resultA4 = dal_Interface_NC_Roll_A4.SendXml_ROLL_A4("", a4Name, ncA4, path); if (resultA4[0] != "1") { dal.UpdateIfStatus(4, id, resultA4[1]); TransactionHelper.RollBack(); return(0); } errorStatus = 5; DataTable factDt = factDt = dal.GetWgdFactAttrDPTran(wgd.C_BATCH_NO, ids).Tables[0]; List <NcRoll46> nc46s = new List <NcRoll46>(); decimal wgdWgt = 0; for (int j = 0; j < factDt.Rows.Count; j++) { NcRoll46 nc46 = new NcRoll46(); var a46M = dal_TB_MATRL_MAIN.GetModel(factDt.Rows[j]["C_MAT_CODE"].ToString()); nc46.cwarehouseid = dal_TPB_LINEWH.GetList_id(factDt.Rows[j]["C_LINEWH_CODE"].ToString()).ToString(); nc46.taccounttime = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString()); nc46.coperatorid = RV.UI.UserInfo.userAccount; //if (wgd.C_MRSX == "DP") //{ } nc46.ccheckstate_bid = dal_TQB_CHECKSTATE.GetModelByName("DP", "1001").C_ID; //else // nc46.ccheckstate_bid = bll_TQB_CHECKSTATE.GetModelByName(factDt.Rows[j]["C_JUDGE_LEV_BP"].ToString(), "1001").C_ID; nc46.cworkcenterid = dal_TB_STA.Get_NC_ID(wgd.C_STA_ID); nc46.dbizdate = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString()); nc46.vbatchcode = wgd.C_BATCH_NO; nc46.cinvbasid = a46M.C_PK_INVBASDOC; nc46.pk_produce = a46M.C_PK_PRODUCE; nc46.ninnum = factDt.Rows[j]["WGT"].ToString(); nc46.ninassistnum = factDt.Rows[j]["QUA"].ToString(); nc46.castunitid = a46M.C_FJLDW; nc46.vfree1 = factDt.Rows[j]["C_ZYX1"].ToString(); nc46.vfree2 = factDt.Rows[j]["C_ZYX2"].ToString(); nc46.vfree3 = factDt.Rows[j]["C_BZYQ"].ToString(); nc46s.Add(nc46); wgdWgt += decimal.Parse(factDt.Rows[j]["WGT"].ToString()); } string a46Name = Guid.NewGuid() + "_A46.xml"; if (dal.Is46Repeat(main.C_BATCH_NO, "") > 0) { TransactionHelper.RollBack(); return(0); } var resultA46 = dal_Interface_NC_Roll_46.SendXml_ROLL_46("", a46Name, nc46s, path); if (resultA46[0] != "1") { dal.UpdateIfStatus(5, id, resultA46[1]); TransactionHelper.RollBack(); return(0); } TransactionHelper.Commit(); } catch (Exception ex) { TransactionHelper.RollBack(); dal.UpdateIfStatus(errorStatus, errorId, ex.Message); } decimal eWgt = dal.GetRollProductWgt(batchNo); dal.UpdateRollPlanItemWgt(planId, bWgt, 1); dal.UpdateRollPlanItemWgt(planId, eWgt); return(1); }
/// <summary> /// 下发条码 /// </summary> /// <returns></returns> public string Down_RF(DataTable dt) { string result = "1"; try { TransactionHelper.BeginTransaction(); TransactionHelper_SQL.BeginTransaction(); string userID = RV.UI.UserInfo.UserID; DateTime dTime = RV.UI.ServerTime.timeNow(); Dal_TRC_ROLL_PDD_ITEM dalRollPddItem = new Dal_TRC_ROLL_PDD_ITEM(); Dal_TPB_LINEWH dalTpbLineWh = new Dal_TPB_LINEWH(); Int64 i_ID_Main = 0; Int64 i_ID_Item = 0; string s_id_main = dal.Get_Max_ID(); if (string.IsNullOrEmpty(s_id_main)) { i_ID_Main = 20190200000; } else { i_ID_Main = Convert.ToInt64(s_id_main) + 1; } string s_id_item = dalRollPddItem.Get_Max_ID(); if (string.IsNullOrEmpty(s_id_item)) { i_ID_Item = 2019022500000; } else { i_ID_Item = Convert.ToInt64(s_id_item) + 1; } for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["条码账存卷数"].ToString() == "0") { continue; } string NC_CK_ID = dalTpbLineWh.GetList_id(dt.Rows[i]["仓库"].ToString()).ToString(); string strDH = dal.Get_PDDH(dTime.ToString(), dt.Rows[i]["仓库"].ToString()); if (string.IsNullOrEmpty(strDH)) { strDH = dal.Get_Max_PDDH(dTime.ToString()); if (string.IsNullOrEmpty(strDH)) { strDH = "PD" + dTime.ToString("yyyyMMdd") + "0001"; } else { strDH = "PD" + (Convert.ToUInt64(strDH) + 1).ToString(); } i_ID_Main++; Mod_TRC_ROLL_PDD modPdd = new Mod_TRC_ROLL_PDD(); modPdd.C_ID = i_ID_Main.ToString(); modPdd.C_CK = dt.Rows[i]["仓库"].ToString(); modPdd.D_PDRQ = dTime; modPdd.C_YSDH = strDH; modPdd.D_INSERT = dTime; if (!dal.Add_Trans(modPdd)) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("往CAP盘点主表插入失败!"); } string strSql = "insert into ReZJB_PDD(ZJBstatus,CAPPK,ck,pdrq,ysdh,insertts,beizhu)values('0','" + i_ID_Main.ToString() + "','" + NC_CK_ID + "','" + dTime + "','" + strDH + "','" + dTime + "','') "; if (!dal.Add_RF_Trans(strSql)) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("往RF盘点主表插入失败!"); } } i_ID_Item++; Mod_TRC_ROLL_PDD_ITEM modItem = new Mod_TRC_ROLL_PDD_ITEM(); modItem.C_YSDH = strDH; modItem.C_MATCODE = dt.Rows[i]["物料号"].ToString(); modItem.C_PCH = dt.Rows[i]["批次号"].ToString(); modItem.C_SX = dt.Rows[i]["质量等级"].ToString(); //modItem.C_ZCSL = dt.Rows[i]["仓库"].ToString(); //modItem.C_FZCZL = dt.Rows[i]["仓库"].ToString(); //modItem.C_FREE0 = ""; modItem.C_FREE1 = dt.Rows[i]["自由项1"].ToString(); modItem.C_FREE2 = dt.Rows[i]["自由项2"].ToString(); modItem.C_FREE3 = dt.Rows[i]["自由项3"].ToString(); //modItem.C_FREE4 = ""; modItem.C_ID = i_ID_Item.ToString(); modItem.D_INSERT = dTime; //modItem.C_REMARK = ""; modItem.C_CK = dt.Rows[i]["仓库"].ToString(); modItem.C_MATDESC = dt.Rows[i]["物料名称"].ToString(); modItem.C_SPEC = dt.Rows[i]["规格"].ToString(); modItem.C_STL_GRD = dt.Rows[i]["钢种"].ToString(); modItem.C_NC_SL = Convert.ToDecimal(dt.Rows[i]["NC账存卷数"].ToString()); modItem.C_NC_ZL = Convert.ToDecimal(dt.Rows[i]["NC账存数量"].ToString()); modItem.C_CAP_SL = Convert.ToDecimal(dt.Rows[i]["CAP账存卷数"].ToString()); modItem.C_CAP_ZL = Convert.ToDecimal(dt.Rows[i]["CAP账存数量"].ToString()); modItem.C_RF_SL = Convert.ToDecimal(dt.Rows[i]["条码账存卷数"].ToString()); modItem.C_RF_ZL = Convert.ToDecimal(dt.Rows[i]["条码账存数量"].ToString()); //modItem.C_RF_SJ_SL = dt.Rows[i]["仓库"].ToString(); //modItem.C_RF_SJ_ZL = dt.Rows[i]["仓库"].ToString(); modItem.C_NC_CAP_SL = Convert.ToDecimal(dt.Rows[i]["NC与CAP卷数账差"].ToString()); modItem.C_NC_CAP_ZL = Convert.ToDecimal(dt.Rows[i]["NC与CAP数量账差"].ToString()); modItem.C_RF_CAP_SL = Convert.ToDecimal(dt.Rows[i]["条码与CAP卷数账差"].ToString()); modItem.C_RF_CAP_ZL = Convert.ToDecimal(dt.Rows[i]["条码与CAP数量账差"].ToString()); //modItem.C_CAP_SJ_SL = Convert.ToDecimal(dt.Rows[i]["CAP与实盘卷数差异"].ToString()); //modItem.C_CAP_SJ_ZL = Convert.ToDecimal(dt.Rows[i]["CAP与实盘数量差异"].ToString()); if (!dalRollPddItem.Add_Trans(modItem)) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("往CAP盘点明细表插入失败!"); } string strSql_Item = "insert into ReZJB_PDD_Item(ysdh,BARCODE,PCH,SX,ZCSL,FZCZL,vfree0,vfree1,vfree2,vfree3,vfree4,ZJBstatus,CAPPK,insertts)values('" + strDH + "','" + dt.Rows[i]["物料号"].ToString() + "','" + dt.Rows[i]["批次号"].ToString() + "','" + dt.Rows[i]["质量等级"].ToString() + "','" + dt.Rows[i]["条码账存卷数"].ToString() + "','" + dt.Rows[i]["条码账存数量"].ToString() + "','','" + dt.Rows[i]["自由项1"].ToString() + "','" + dt.Rows[i]["自由项2"].ToString() + "','" + dt.Rows[i]["自由项3"].ToString() + "','','0','" + i_ID_Item.ToString() + "','" + dTime + "' ) "; if (!dal.Add_RF_Trans(strSql_Item)) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return("往RF盘点主表插入失败!"); } } TransactionHelper.Commit(); TransactionHelper_SQL.Commit(); } catch (Exception ex) { TransactionHelper.RollBack(); TransactionHelper_SQL.RollBack(); return(ex.Message); } return(result); }
/// <summary> /// 获得数据列表-主键获取 /// </summary> /// <param name="C_LINEWH_CODE">仓库编码</param> /// <returns></returns> public object GetList_id(string C_LINEWH_CODE) { return(dal.GetList_id(C_LINEWH_CODE)); }