/// <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> /// 根据工位主键获取NC主键 /// </summary> /// <param name="C_ID">工位主键</param> /// <returns>工位名称</returns> public string Get_NC_ID(string C_ID) { return(dal.Get_NC_ID(C_ID)); }