public ActionResult BokRetrieveGds(String wmsno, String barcode, String gdsid, String gdstype, String bthno, String vlddat, double qty) { //检索主表、明细表 var qrymst = from e in WmsDc.wms_cang where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.wmsno == wmsno select e; var arrmst = qrymst.ToArray(); var qrydtl = from e in WmsDc.wms_cangdtl where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.gdsid == gdsid.Trim() && e.gdstype == gdstype.Trim() && e.bthno == bthno.Trim() && e.vlddat == vlddat.Trim() && e.barcode == barcode.Trim() && e.wmsno == wmsno select e; var arrdtl = qrydtl.ToArray(); #region 检查输入参数 if (arrmst.Length <= 0) { return(RNoData("N0248")); } if (arrdtl.Length <= 0) { return(RNoData("N0249")); } wms_cang mst = arrmst[0]; ////正在生成拣货单,请稍候重试 //string quRetrv = mst.qu; //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv)) //{ // return RInfo( "I0391" ); //} wms_cangdtl dtl = arrdtl[0]; //是否捡货单已经审核 if (mst != null && mst.chkflg == GetY()) { return(RInfo("I0460")); } #endregion #region 商品登帐 //判断是否已经被审核 WmsDc.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, dtl); if (dtl.bokflg == GetY()) { //看看是哪个审核的 string[] whoAdt = (from e in WmsDc.emp where e.empid == dtl.bkr select e.empdes).ToArray(); if (whoAdt.Count() > 0) { return(RInfo("I0125", string.Join(",", whoAdt))); } } if (dtl.bokflg == GetY() && dtl.bkr.Trim() != LoginInfo.Usrid) { return(RInfo("I0461", dtl.bkr)); } if (dtl.bokflg == GetN() && dtl.qty != null) { dtl.preqty = dtl.qty; } // 确认数量大于应拣数量 if (qty > dtl.preqty) { return(RInfo("i0473")); } dtl.qty = Math.Round(qty, 4); dtl.pkgqty = Math.Round(qty, 4); dtl.bokflg = GetY(); dtl.bokdat = DateTime.Now.ToString("yyyyMMddHHmmss"); dtl.bkr = LoginInfo.Usrid; #endregion try { try { WmsDc.SubmitChanges(); } catch (Exception ex) { if (ex.Message.IndexOf("牺牲品") > 0) { return(RInfo("E0075")); } else { return(RInfo("E0076", ex.Message)); } } return(RSucc("成功", null, "S0224")); } catch (Exception ex) { return(RErr(ex.Message, "E0072")); } }
public ActionResult BokRetrieve(String wmsno) { using (TransactionScope scop = new TransactionScope(TransactionScopeOption.Required, options)) { Rm.ResultObject = null; //检索捡货单主表、明细表 var qrymst = from e in WmsDc.wms_cang where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.wmsno == wmsno select e; var arrmst = qrymst.ToArray(); var qrydtl = from e in WmsDc.wms_cangdtl where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.wmsno == wmsno select e; var arrdtl = qrydtl.ToArray(); #region 检查输入参数 if (arrmst.Length <= 0) { return(RNoData("N0250")); } if (arrdtl.Length <= 0) { return(RNoData("N0251")); } wms_cang mst = arrmst[0]; ////正在生成拣货单,请稍候重试 //string quRetrv = mst.qu; //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv)) //{ // return RInfo( "I0392" ); //} foreach (wms_cangdtl d in arrdtl) { //是否捡货单商品已经审核 if (d.bokflg == GetN() && d.tpcode == "y") { return(RInfo("I0462", d.gdsid)); } } if (mst != null && mst.chkflg == GetY()) { return(RInfo("I0463")); } #endregion #region 播种单查询 ////播种单主表,明细表 var qrybzmst = from e in WmsDc.wms_bzmst where e.bllid == WMSConst.BLL_TYPE_BZ && e.lnkbocidat == mst.lnkbocidat && e.lnkbocino == mst.lnkbocino && e.qu == mst.qu && e.savdptid == mst.savdptid select e; var arrbzmst = qrybzmst.ToArray(); if (arrbzmst.Length <= 0) { return(RNoData("N0252")); } wms_bzmst bzmst = arrbzmst[0]; //播种单明细表 var qrybzdtl = from e in WmsDc.wms_bzdtl where e.wmsno == bzmst.wmsno && arrdtl.Select(e1 => e1.gdsid).Contains(e.gdsid.Trim()) select e; wms_bzdtl[] arrbzdtls = qrybzdtl.ToArray(); #endregion #region 差异数量生成捡货损溢单,记日志 //差异数量生成捡货损溢单,记日志 #region 差异数量生成捡货损溢单,记日志 //生成捡货损溢单 JsonResult jr = (JsonResult)MakeNewBllNo(this.LoginInfo.DefSavdptid, mst.qu, WMSConst.BLL_TYPE_RETRIEVE_PROFIT_LOSS, (bllno) => { //生成损溢单主表 wms_cang sycang = new wms_cang(); sycang.wmsno = bllno; sycang.bllid = WMSConst.BLL_TYPE_RETRIEVE_PROFIT_LOSS; sycang.savdptid = mst.savdptid; sycang.prvid = mst.prvid; sycang.qu = mst.qu; sycang.rcvdptid = mst.rcvdptid; sycang.times = mst.times; sycang.lnkbocino = mst.lnkbocino; sycang.lnkbocidat = mst.lnkbocidat; sycang.mkr = LoginInfo.Usrid; sycang.mkedat = DateTime.Now.ToString("yyyyMMdd"); sycang.mkedat2 = GetCurrentDate(); sycang.ckr = LoginInfo.Usrid; sycang.chkflg = GetY(); sycang.chkdat = DateTime.Now.ToString("yyyyMMddHHmmss"); sycang.opr = LoginInfo.Usrid; sycang.brief = ""; sycang.lnkbllid = mst.bllid; sycang.lnkno = mst.wmsno; sycang.lnkbrief = mst.brief; //生成损溢单明细 List <wms_cangdtl> lstsydtl = new List <wms_cangdtl>(); foreach (wms_cangdtl dt in arrdtl) { if (dt.qty != dt.preqty) { wms_cangdtl sydtl = new wms_cangdtl(); sydtl.wmsno = bllno; sydtl.bllid = WMSConst.BLL_TYPE_RETRIEVE_PROFIT_LOSS; sydtl.rcdidx = dt.rcdidx; sydtl.oldbarcode = dt.oldbarcode; sydtl.barcode = dt.barcode; sydtl.gdsid = dt.gdsid; sydtl.pkgid = dt.pkgid; sydtl.pkgqty = dt.pkgqty; sydtl.qty = dt.preqty.Value - dt.qty; sydtl.gdstype = dt.gdstype; sydtl.bthno = dt.bthno; sydtl.vlddat = dt.vlddat; sydtl.bcd = dt.bcd; sydtl.tpcode = dt.tpcode; sydtl.bkr = LoginInfo.Usrid; sydtl.bokflg = GetY(); sydtl.bokdat = DateTime.Now.ToString("yyyyMMddHHmmss"); sydtl.preqty = dt.preqty.Value - dt.qty; lstsydtl.Add(sydtl); //记录日志 Log.i(LoginInfo.Usrid, Mdlid, bllno, WMSConst.BLL_TYPE_RETRIEVE_PROFIT_LOSS, "损溢单生成", dt.gdsid.Trim() + ":应收:" + dt.preqty.Value + ";实收:" + dt.qty, mst.qu, mst.savdptid); //记账并删除为0的仓位信息。 var cwggdsbs = WmsDc.wms_cwgdsbs .Where(e => e.barcode == sydtl.barcode && e.bcd == sydtl.bcd && e.savdptid == mst.savdptid && e.gdsid == sydtl.gdsid && e.gdstype == sydtl.gdstype) .Select(e => e).Single(); if (cwggdsbs != null) { cwggdsbs.qty -= sydtl.qty; if (cwggdsbs.qty <= 0) { WmsDc.wms_cwgdsbs.DeleteOnSubmit(cwggdsbs); iDelCwgdsbs(new wms_cwgdsbs[] { cwggdsbs }); } } } } WmsDc.wms_cang.InsertOnSubmit(sycang); WmsDc.wms_cangdtl.InsertAllOnSubmit(lstsydtl); return(RRSucc("成功", null, "{{succ}}")); }); Rm = (ResultMessage)jr.Data; if (Rm.ResultCode != ResultMessage.RESULTMESSAGE_SUCCESS) { return(jr); } #endregion //拣货数量和应拣数量判断是不是相等, 不相等就改播种单数量 #region 拣货数量和应拣数量判断是不是相等, 不相等就改播种单数量 var arrdtly = arrdtl .Where(e => e.tpcode == "y") .Select(e => new { e.gdsid, e.gdstype, e.qty }); var arrdtln = arrdtl .Where(e => e.tpcode == "n") .Select(e => new { e.gdsid, e.gdstype, qty = 0.00 }); var qsum = arrdtly.Union(arrdtln) .GroupBy(g => new { g.gdsid, g.gdstype }) .Select(g => new { gdsid = g.Key.gdsid, gdstype = g.Key.gdstype, sumqty = g.Sum(e => e.qty) }); foreach (var q in qsum) { //查找播种明细商品汇总数量是否和捡货单的商品汇总数量一致 var qbzsum = arrbzdtls .Where(e => e.gdsid == q.gdsid && e.gdstype == q.gdstype) .GroupBy(g => new { g.gdsid, g.gdstype }) .Select(g => new { gdsid = g.Key.gdsid, gdstype = g.Key.gdstype, qsum = g.Sum(e => e.qty) }).Single(); if (qbzsum.qsum < q.sumqty) //如果数量不一致就生成捡货损溢单,并记日志 { return(RInfo("I0464")); } else if (qbzsum.qsum >= q.sumqty) //如果播种的数量小于捡货单的数量 { double remainqty = q.sumqty; var arrbzdtlsGdstyp = arrbzdtls.Where(e => e.gdstype == q.gdstype && e.gdsid == q.gdsid); //-----------分派数量---------- //按照播种数量从大到小的顺序 | //从小到大开始播种 | //播种到最后就播0 | //----------------------------- /*String cmdsql = "declare @remainqty deciaml(18,4)\r\n" + "declare @wmsno varchar(20), @gdstype varchar(20), @rcdidx int, @gdsid varchar(10), @rcvdptid varchar(10), @qty decimal\r\n" + "set @remainqty={0}\r\n" + "set @gdsid={1}\r\n" + "set @gdstype={2}\r\n" + "set @wmsno={3}\r\n" + "declare cur1 cursor for\r\n" + " select rcvdptid, qty, rcdidx from wms_bzdtl where wmsno=@wmsno and gdstype=@gdstype and gdsid=@gdsid order by qty desc, rcdidx \r\n" + "open cur1\r\n" + "fetch next from cur1 into @rcvdptid, @qty, @rcdidx\r\n" + "while @@fetch_status=0\r\n" + "begin\r\n" + " if @remainqty-@qty>0\r\n" + " begin\r\n" + " update wms_bzdtl set qty = @qty where wmsno=@wmsno and gdstype=@gdstype and gdsid=@gdsid and rcdidx=@rcdidx\r\n" + " end\r\n" + " else if @remainqty>0 and @remainqty-@qty<=0\r\n" + " begin\r\n" + " update wms_bzdtl set qty = @remainqty where wmsno=@wmsno and gdstype=@gdstype and gdsid=@gdsid and rcdidx=@rcdidx\r\n" + " end\r\n" + " else\r\n" + " begin\r\n" + " update wms_bzdtl set qty = 0 where wmsno=@wmsno and gdstype=@gdstype and gdsid=@gdsid and rcdidx=@rcdidx\r\n" + " end\r\n" + " set @remainqty = @remainqty-@qty\r\n" + " fetch next from cur1 into @rcvdptid, @qty, @rcdidx\r\n" + "end\r\n" + "close cur1\r\n" + "deallocate cur1";*/ /* * preqty = preqty==null ? qty : preqty * * 公式:taxamt = qty*prc*taxrto * amt = qty*prc * salamt = qty*salprc * patamt = qty*taxprc * stotcstamt = qty*stotcstprc * */ String cmdsql = ""; if (mst.lnkbllid.Trim() == "206" || mst.lnkbllid.Trim() == "501") { cmdsql = "declare @remainqty deciaml(18,4)\r\n" + "declare @wmsno varchar(20), @gdstype varchar(20), @rcdidx int, @gdsid varchar(10), @rcvdptid varchar(10), @qty decimal, @stkouno varchar(30)\r\n" + "set @remainqty={0}\r\n" + "set @gdsid={1}\r\n" + "set @wmsno={2}\r\n" + "declare cur1 cursor for\r\n" + " select b.rcvdptid, a.qty, a.rcdidx, b.stkouno from stkotdtl a inner join stkot b on a.stkouno=b.stkouno\r\n" + " where b.wmsno=@wmsno and b.wmsbllid='" + WMSConst.BLL_TYPE_RETRIEVE + "' and a.gdsid=@gdsid order by qty desc, rcdidx \r\n" + "open cur1\r\n" + "fetch next from cur1 into @rcvdptid, @qty, @rcdidx, @stkouno\r\n" + "while @@fetch_status=0\r\n" + "begin\r\n" + " update stkotdtl set preqty=case when preqty is null then qty else preqty end where stkouno=@stkouno and wmsbllid='" + WMSConst.BLL_TYPE_RETRIEVE + "' and gdsid=@gdsid and rcvidx=@rcvidx \r\n" + " if @remainqty-@qty>0\r\n" + " begin\r\n" + " update stkotdtl set qty = @qty where stkouno=@stkouno and gdsid=@gdsid and rcdidx=@rcdidx\r\n" + " end\r\n" + " else if @remainqty>0 and @remainqty-@qty<=0\r\n" + " begin\r\n" + " update stkotdtl set qty = @remainqty where stkouno=@stkouno and gdsid=@gdsid and rcdidx=@rcdidx\r\n" + " end\r\n" + " else\r\n" + " begin\r\n" + " update stkotdtl set qty = 0 where stkouno=@stkouno and gdsid=@gdsid and rcdidx=@rcdidx\r\n" + " end\r\n" + " update stkotdtl set amt=qty*prc, salamt=qty*salprc, patamt=qty*taxprc, stotcstamt=qty*stotcstprc where stkouno=@stkouno and gdsid=@gdsid and rcdidx=@rcdidx \r\n" + " set @remainqty = @remainqty-@qty\r\n" + " fetch next from cur1 into @rcvdptid, @qty, @rcdidx, @stkouno\r\n" + "end\r\n" + "close cur1\r\n" + "deallocate cur1"; WmsDc.ExecuteCommand(cmdsql, new object[] { remainqty, q.gdsid, bzmst.wmsno }); } } } #endregion #endregion #region 修改审核标记 //修改审核标记 mst.chkflg = GetY(); mst.chkdat = DateTime.Now.ToString("yyyyMMddHHmmss"); mst.ckr = LoginInfo.Usrid; #endregion try { WmsDc.SubmitChanges(); return(RSucc("成功", null, "S0225")); } catch (Exception ex) { return(RErr(ex.Message, "E0073")); } } }
public ActionResult BokReciev(String wmsno) { var qry = from e in WmsDc.wms_bllmst where e.bllid == WMSConst.BLL_TYPE_REVIECEBLL && e.wmsno == wmsno select e; var arrqry = qry.ToArray(); if (arrqry.Length <= 0) { return(RNoData("N0031")); } wms_bllmst bllmst = arrqry[0]; #region 判断收货单是否已经登帐 if (bllmst.chkflg == GetY()) { return(RInfo("I0053", wmsno)); } #endregion #region 判断操作员是否有审核该单据的权限 //0.判断操作员是否有审核该单据的权限 if (!this.qus.Contains(bllmst.qu.Trim())) { return(RInfo("I0054")); } #endregion #region 是否该单据下的所有商品都已经审核 //1.是否该单据下的所有商品都已经审核 var qry1 = from e in WmsDc.wms_blldtl where e.bllid == WMSConst.BLL_TYPE_REVIECEBLL && e.wmsno == wmsno select e; var arrqry1 = qry1.ToArray(); if (arrqry1.Length <= 0) { return(RNoData("N0032")); } foreach (wms_blldtl dtl in arrqry1) { if (dtl.bokflg == GetN()) { return(RInfo("I0055", dtl.gdsid)); } } #endregion var qrytp = from e in WmsDc.wms_blltp where e.wmsno == wmsno && e.bllid == WMSConst.BLL_TYPE_REVIECEBLL orderby e.tpcode, e.rcdidxtp select e; wms_bllmst rmst = arrqry[0]; wms_blldtl[] rdtl = arrqry1; return(MakeNewBllNo( bllmst.savdptid, rmst.qu, WMSConst.BLL_TYPE_UPBLL, (bllno) => { #region 修改内调单实收数量 //判断是否有比应收数量更大的商品 var qrytpdtl = from e in WmsDc.wms_blltp where e.wmsno == wmsno && e.bllid == WMSConst.BLL_TYPE_REVIECEBLL group e by new { e.wmsno, e.gdsid } into g select new { wmsno = g.Key.wmsno, gdsid = g.Key.gdsid, qty = g.Sum(e1 => e1.qty) }; var qryodrdtl = from e in WmsDc.stkindtl join e1 in WmsDc.wms_bllmst on new { e.stkinno, e.stkin.bllid } equals new { stkinno = e1.lnknewno, bllid = e1.lnknewbllid } join e2 in qrytpdtl on new { e1.wmsno, e.gdsid } equals new { e2.wmsno, e2.gdsid } where e1.wmsno == wmsno && e1.bllid == WMSConst.BLL_TYPE_REVIECEBLL && e.qty < e2.qty select e; var arrqryodrdtl = qryodrdtl.ToArray(); if (arrqryodrdtl.Length > 0) { return RRInfo("I0428", arrqryodrdtl[0].gdsid); } StringBuilder sb = new StringBuilder(); String cmdsql = null; //修改内调单实收数量 /*cmdsql = "update odrdtl set preqty=qty, qty=b.sumqty, pkgqty=b.sumqty, amt=convert(decimal(18,2),round(a.prc*b.sumqty, 4)), patamt=convert(decimal(18,2),round(a.taxprc*b.sumqty, 4)), taxamt=convert(decimal(18,2),round((a.taxprc*b.sumqty)-a.prc*b.sumqty, 4)) from " + " odrdtl a " + " inner join " + " ( " + " select a1.wmsno, a1.gdsid, sum(a1.qty) sumqty ,b1.lnknewno from wms_blltp a1 " + " inner join wms_bllmst b1 on a1.wmsno=b1.wmsno and a1.bllid=b1.bllid" + " where b1.wmsno={0} and b1.bllid={1}" + " group by a1.wmsno, a1.gdsid, b1.lnknewno " + " ) b on a.odrno=b.lnknewno and a.gdsid=b.gdsid "; + sb.Append(cmdsql); */ //设置收货单审核标志 cmdsql = "update wms_bllmst set chkflg='" + GetY() + "', ckr={0}, chkdat={1} where wmsno={2} and bllid={3} "; sb.Append(cmdsql); //设置内购单收货标志 cmdsql = "update stkin set inflg='" + GetY() + "', indat={4} from stkin a inner join wms_bllmst b on b.lnknewno=a.stkinno and b.lnknewbllid=a.bllid where b.wmsno={5} and b.bllid={6} "; sb.Append(cmdsql); //执行处理 string sNow = GetCurrentDate(); WmsDc.ExecuteCommand(sb.ToString(), new[] { LoginInfo.Usrid, sNow, wmsno, WMSConst.BLL_TYPE_REVIECEBLL, sNow, wmsno, WMSConst.BLL_TYPE_REVIECEBLL }); WmsDc.SubmitChanges(); #endregion #region 生成上架单 //4.生成上架单 //主表 wms_cang cwmst = new wms_cang(); List <wms_cangdtl> lstcwdtl = new List <wms_cangdtl>(); cwmst.wmsno = bllno; cwmst.bllid = WMSConst.BLL_TYPE_UPBLL; cwmst.savdptid = rmst.savdptid; cwmst.prvid = rmst.prvid; cwmst.qu = rmst.qu; /*mst.rcvdptid = rmst.rcvdptid;*/ /*mst.times = rmst.times; * mst.lnkbocino = rmst.lnkbocino; * mst.lnkbocidat = rmst.lnkbocidat;*/ cwmst.mkr = LoginInfo.Usrid; cwmst.mkedat = DateTime.Now.ToString("yyyyMMdd"); cwmst.mkedat2 = GetCurrentDate(); /*mst.ckr = rmst.ckr;*/ cwmst.ckr = ""; cwmst.chkflg = GetN(); cwmst.chkdat = ""; cwmst.opr = LoginInfo.Usrid; cwmst.brief = rmst.brief; cwmst.lnkbllid = rmst.bllid; cwmst.lnkno = rmst.wmsno; cwmst.lnkbrief = rmst.brief; //明细 var qrycwdtl = from e in qrytp join e1 in WmsDc.wms_blldtl on new { e.wmsno, e.bllid, e.gdsid } equals new { e1.wmsno, e1.bllid, e1.gdsid } orderby e.rcdidx, e.rcdidxtp select new { e, e1 }; int i = 1; foreach (var tp in qrycwdtl) { wms_cangdtl cwdtl = new wms_cangdtl(); cwdtl.wmsno = bllno; cwdtl.bllid = WMSConst.BLL_TYPE_UPBLL; cwdtl.rcdidx = i++; cwdtl.oldbarcode = ""; cwdtl.barcode = tp.e.barcode; cwdtl.gdsid = tp.e.gdsid; cwdtl.pkgid = tp.e.pkgid; cwdtl.pkgqty = tp.e.qty; cwdtl.qty = Math.Round(tp.e.qty, 4, MidpointRounding.AwayFromZero); cwdtl.gdstype = tp.e.gdstype; cwdtl.bthno = string.IsNullOrEmpty(tp.e1.bthno) ? "1" : tp.e1.bthno; cwdtl.vlddat = String.IsNullOrEmpty(tp.e1.vlddat) ? GetCurrentDay() : tp.e1.vlddat; cwdtl.bcd = tp.e1.bcd; cwdtl.tpcode = tp.e.tpcode; cwdtl.barcode = ""; cwdtl.bkr = ""; cwdtl.bokflg = GetN(); cwdtl.bokdat = GetCurrentDate(); lstcwdtl.Add(cwdtl); } WmsDc.wms_cang.InsertOnSubmit(cwmst); WmsDc.wms_cangdtl.InsertAllOnSubmit(lstcwdtl); WmsDc.SubmitChanges(); #endregion #region 推荐仓位 /*String cmdsql1 = "declare @wmsno varchar(20) " + " set @wmsno={0} " + " exec SuggestBarcode @wmsno "; + WmsDc.ExecuteCommand(cmdsql1, new[] { wmsno });*/ WmsDc.SuggestBarcode(wmsno); #endregion try { WmsDc.SubmitChanges(); return RRSucc("成功", null, "S0209"); } catch (Exception ex) { return RRErr(ex.Message, "E0058"); } })); }
public ActionResult BokRetrieveGds(String wmsno, String barcode, String gdsid, String gdstype, double qty) { using (TransactionScope scop = new TransactionScope()) { //检索主表、明细表 var qrymst = from e in WmsDc.wms_cang where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.wmsno == wmsno select e; var arrmst = qrymst.ToArray(); var qrydtl = from e in WmsDc.wms_cangdtl where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.gdsid == gdsid && e.gdstype == gdstype && e.barcode == barcode && e.wmsno == wmsno && e.tpcode == "y" select e; var arrdtl = qrydtl.ToArray(); #region 检查输入参数 if (arrmst.Length <= 0) { return(RNoData("N0228")); } if (arrdtl.Length <= 0) { return(RNoData("N0229")); } wms_cang mst = arrmst[0]; //正在生成拣货单,请稍候重试 //string quRetrv = mst.qu; //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv)) //{ // return RInfo( "I0117" ); //} wms_cangdtl dtl = arrdtl[0]; //是否捡货单已经审核 if (mst.chkflg == GetY()) { return(RInfo("I0430")); } #endregion #region 商品登帐 if (dtl.bokflg == GetY() && dtl.bkr.Trim() != LoginInfo.Usrid) { return(RInfo("I0431", dtl.bkr)); } if (dtl.bokflg == GetN() && dtl.qty != null) { //dtl.preqty = dtl.qty; } if (dtl.tpcode == "n") { return(RInfo("I0118")); } if (dtl.preqty < qty && dtl.tpcode == "y") { return(RInfo("I0119")); } dtl.qty = Math.Round(qty, 4); dtl.pkgqty = Math.Round(qty, 4); //如果是206的单据,同一个商品的最后一条确认完后就不能再修改 var qryallbygdsidN1 = from e in WmsDc.wms_cangdtl where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.gdsid == gdsid //&& e.gdstype == gdstype && e.wmsno == wmsno && e.bokflg == GetN() && e.tpcode == "y" select e; int iCnt = qryallbygdsidN1.Count(); if (mst.lnkbllid.Trim() == "206" && iCnt == 0) { return(RInfo("I0120")); } dtl.bokflg = GetY(); dtl.bokdat = DateTime.Now.ToString("yyyyMMddHHmmss"); dtl.bkr = LoginInfo.Usrid; WmsDc.SubmitChanges(); if (dtl.preqty != dtl.qty) { i(wmsno, WMSConst.BLL_TYPE_RETRIEVE, "拣货商品明细确认", "应拣数量:" + dtl.preqty + ",实拣数量:" + dtl.qty, mst.qu, mst.savdptid); } #endregion #region 如果是206配送拣货的单据,在同一个拣货单里面同一商品确认完后,写入分货表 if (mst.lnkbllid.Trim() == "206") { var qryallbygdsidN = from e in WmsDc.wms_cangdtl where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.gdsid == gdsid //&& e.gdstype == gdstype && e.wmsno == wmsno && e.bokflg == GetN() && e.tpcode == "y" select e; iCnt = qryallbygdsidN.Count(); if (iCnt == 0) { var qryAllByGdsidCang = from e in WmsDc.wms_cangdtl join e1 in WmsDc.wms_cang on new { e.wmsno, e.bllid } equals new { e1.wmsno, e1.bllid } where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.tpcode == "y" && e.gdsid == gdsid && e.wmsno == wmsno group e by new { e1.savdptid, e1.rcvdptid, e1.wmsno, e1.bllid, e1.lnkbocino, e1.lnkbocidat, e1.times, e.gdsid } into g select new { savdptid = g.Key.savdptid, wmsno = g.Key.wmsno, bllid = g.Key.bllid, bocino = g.Key.lnkbocino, bocidat = g.Key.lnkbocidat, clsid = g.Key.times, /*checi = (from e2 in WmsDc.psSndGds_dpt_dtl * where e2.dptid == g.Key.rcvdptid && e2.dh == g.Key.lnkbocino * select e2.busid.Substring(e2.busid.Trim().Length - 1, 1)).FirstOrDefault(),*/ gdsid = g.Key.gdsid, qty = g.Sum(e => e.qty), preqty = g.Sum(e => e.qty), ckr = "", chkflg = GetN(), chkdat = "" }; var cutgds = qryAllByGdsidCang.FirstOrDefault(); #region 如果拣货的数量不够的话,要去修改配送单的数量和金额 var qrystkdtl = from e in WmsDc.stkotdtl where e.stkot.wmsbllid == cutgds.bllid && e.stkot.wmsno == cutgds.wmsno && e.gdsid == cutgds.gdsid orderby e.qty descending select e; double q = qrystkdtl.Sum(e => e.qty) - cutgds.qty; if (q > 0) { double diff = q; var stkotdtl = qrystkdtl; //减小数部分 #region 减小数部分 foreach (stkotdtl d in stkotdtl) { if (d.preqty == null) { d.preqty = d.qty; } double xtmp = d.qty * 10000 % 10000 / 10000; if (diff > 0 && diff >= xtmp) { diff -= xtmp; d.qty -= xtmp; d.qty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.pkgqty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.taxamt = Math.Round(d.qty * d.prc * d.taxrto, 4); d.amt = Math.Round(d.qty * d.prc, 4); d.salamt = d.qty * d.salprc; d.patamt = Math.Round(d.qty * d.taxprc, 4); d.stotcstamt = Math.Round(d.qty * d.stotcstprc.Value, 4); } else if (diff > 0 && diff < xtmp) { d.qty -= diff; diff = 0; d.qty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.pkgqty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.taxamt = Math.Round(d.qty * d.prc * d.taxrto, 4); d.amt = Math.Round(d.qty * d.prc, 4); d.salamt = d.qty * d.salprc; d.patamt = Math.Round(d.qty * d.taxprc, 4); d.stotcstamt = Math.Round(d.qty * d.stotcstprc.Value, 4); } } //WmsDc.SubmitChanges(); #endregion 减小数部分 //减去零散件规 #region 减去零散件规 foreach (stkotdtl d in stkotdtl) { if (d.preqty == null) { d.preqty = d.qty; } double xtmp = (double)WmsDc.ExecuteQuery <decimal>("select convert(decimal,{0}) % convert(decimal,e.cnvrto) from v_wms_pkg e where e.gdsid={1}", d.qty, d.gdsid).FirstOrDefault(); /*double xtmp = (from e in WmsDc.v_wms_pkg * where e.gdsid == d.gdsid * select Convert.ToInt32(d.qty) % e.cnvrto).FirstOrDefault();*/ if (diff > 0 && diff >= xtmp) { diff -= xtmp; d.qty -= xtmp; d.qty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.pkgqty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.taxamt = Math.Round(d.qty * d.prc * d.taxrto, 4); d.amt = Math.Round(d.qty * d.prc, 4); d.salamt = d.qty * d.salprc; d.patamt = Math.Round(d.qty * d.taxprc, 4); d.stotcstamt = Math.Round(d.qty * d.stotcstprc.Value, 4); } else if (diff > 0 && diff < xtmp) { d.qty -= diff; diff = 0; d.qty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.pkgqty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.taxamt = Math.Round(d.qty * d.prc * d.taxrto, 4); d.amt = Math.Round(d.qty * d.prc, 4); d.salamt = d.qty * d.salprc; d.patamt = Math.Round(d.qty * d.taxprc, 4); d.stotcstamt = Math.Round(d.qty * d.stotcstprc.Value, 4); } } //WmsDc.SubmitChanges(); #endregion 减去零散件规 //减去从大到小的数量 #region 减去从大到小的数量 foreach (stkotdtl d in stkotdtl) { if (d.preqty == null) { d.preqty = d.qty; } if (diff > 0 && diff >= d.qty) { diff -= d.qty; d.qty = 0; d.qty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.pkgqty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.taxamt = Math.Round(d.qty * d.prc * d.taxrto, 4); d.amt = Math.Round(d.qty * d.prc, 4); d.salamt = d.qty * d.salprc; d.patamt = Math.Round(d.qty * d.taxprc, 4); d.stotcstamt = Math.Round(d.qty * d.stotcstprc.Value, 4); } else if (diff > 0 && diff < d.qty) { d.qty = d.qty - diff; diff = 0; d.qty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.pkgqty = Math.Round(d.qty, 4, MidpointRounding.AwayFromZero); d.taxamt = Math.Round(d.qty * d.prc * d.taxrto, 4); d.amt = Math.Round(d.qty * d.prc, 4); d.salamt = d.qty * d.salprc; d.patamt = Math.Round(d.qty * d.taxprc, 4); d.stotcstamt = Math.Round(d.qty * d.stotcstprc.Value, 4); } } WmsDc.SubmitChanges(); #endregion 减去从大到小的数量 } WmsDc.SubmitChanges(); #endregion // 写入分货表 #region 写入分货表 //var qryAllByGdsid = from e in WmsDc.stkotdtl // join e1 in WmsDc.wms_cang on new { e.stkot.wmsno, e.stkot.wmsbllid } equals new { e1.wmsno, wmsbllid = e1.bllid } // where e.stkot.wmsbllid == cutgds.bllid // && e.stkot.wmsno == cutgds.wmsno // && e.gdsid == cutgds.gdsid // && e.qty != 0 // group e by new // { // e1.savdptid, // e.stkot.rcvdptid, // e1.wmsno, // e1.bllid, // e1.lnkbocino, // e1.lnkbocidat, // e1.times, // e.gdsid // } into g // select new // { // savdptid = g.Key.savdptid, // wmsno = g.Key.wmsno, // bllid = g.Key.bllid, // bocino = g.Key.lnkbocino, // bocidat = g.Key.lnkbocidat, // clsid = g.Key.times, // checi = (from e2 in WmsDc.psSndGds_dpt_dtl // where e2.dptid == g.Key.rcvdptid && e2.dh == g.Key.lnkbocino // select e2.busid.Substring(e2.busid.Trim().Length - 1, 1)).FirstOrDefault(), // gdsid = g.Key.gdsid, // qty = g.Sum(e => e.qty), // preqty = g.Sum(e => e.qty), // ckr = "", // chkflg = GetN(), // chkdat = "" // }; ////i(wmsno, "", "拣货确认", qryAllByGdsid.ToString(), "", LoginInfo.DefSavdptid); //var arrQryAllByGdsid = qryAllByGdsid.ToArray(); //foreach (var a in arrQryAllByGdsid) //{ // if (a.checi == null) // { // iFile(cutgds.bllid + " " + cutgds.wmsno + " " + cutgds.gdsid + " "); // } //} //var qryAllByGdsidSum = from e in arrQryAllByGdsid // group e by new // { // e.savdptid, // e.wmsno, // e.bllid, // e.bocino, // e.bocidat, // e.clsid, // e.checi, // e.gdsid, // e.ckr, // e.chkflg, // e.chkdat // } into g // select new // { // g.Key.savdptid, // g.Key.wmsno, // g.Key.bllid, // g.Key.bocino, // g.Key.bocidat, // g.Key.clsid, // g.Key.checi, // g.Key.gdsid, // g.Key.ckr, // g.Key.chkflg, // g.Key.chkdat, // qty = g.Sum(e => e.qty), // preqty = g.Sum(e => e.preqty) // }; //List<wms_cutgds> lstCg = new List<wms_cutgds>(); //foreach (var tcg in qryAllByGdsidSum) //{ // wms_cutgds cg = new wms_cutgds(); // cg.bllid = tcg.bllid; // cg.bocidat = tcg.bocidat; // cg.bocino = tcg.bocino; // cg.checi = tcg.checi; // cg.chkdat = tcg.chkdat; // cg.chkflg = tcg.chkflg; // cg.ckr = tcg.ckr; // cg.clsid = tcg.clsid; // cg.gdsid = tcg.gdsid; // cg.preqty = tcg.preqty; // cg.qty = tcg.qty; // cg.savdptid = tcg.savdptid; // cg.wmsno = tcg.wmsno; // lstCg.Add(cg); //} //WmsDc.wms_cutgds.InsertAllOnSubmit(lstCg); #endregion 写入分货表 } } #endregion try { WmsDc.SubmitChanges(); scop.Complete(); return(RSucc("成功", null, "S0212")); } catch (Exception ex) { return(RErr(ex.Message, "E0059")); } } }
public ActionResult BokRetrieveGds(String wmsno, String barcode, String gdsid, String gdstype, double qty) { using (TransactionScope scop = new TransactionScope()) { //检索主表、明细表 var qrymst = from e in WmsDc.wms_cang where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.wmsno == wmsno select e; var arrmst = qrymst.ToArray(); var qrydtl = from e in WmsDc.wms_cangdtl where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.gdsid == gdsid && e.gdstype == gdstype && e.barcode == barcode && e.wmsno == wmsno select e; var arrdtl = qrydtl.ToArray(); #region 检查输入参数 if (arrmst.Length <= 0) { return(RNoData("N0248")); } if (arrdtl.Length <= 0) { return(RNoData("N0249")); } wms_cang mst = arrmst[0]; ////正在生成拣货单,请稍候重试 //string quRetrv = mst.qu; //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv)) //{ // return RInfo( "I0391" ); //} wms_cangdtl dtl = arrdtl[0]; //是否捡货单已经审核 if (mst.chkflg == GetY()) { return(RInfo("I0460")); } #endregion #region 商品登帐 if (dtl.bokflg == GetY() && dtl.bkr.Trim() != LoginInfo.Usrid) { return(RInfo("I0461", dtl.bkr)); } if (dtl.bokflg == GetN() && dtl.qty != null) { dtl.preqty = dtl.qty; } dtl.qty = Math.Round(qty, 4); dtl.pkgqty = Math.Round(qty, 4); dtl.bokflg = GetY(); dtl.bokdat = DateTime.Now.ToString("yyyyMMddHHmmss"); dtl.bkr = LoginInfo.Usrid; #endregion try { WmsDc.SubmitChanges(); scop.Complete(); return(RSucc("成功", null, "S0224")); } catch (Exception ex) { return(RErr(ex.Message, "E0072")); } } }
public ActionResult BokReciev(String wmsno) { var qry = from e in WmsDc.wms_bllmst where e.bllid == WMSConst.BLL_TYPE_REVIECEBLL && e.wmsno == wmsno select e; var arrqry = qry.ToArray(); if (arrqry.Length <= 0) { return(RNoData("N0239")); } wms_bllmst bllmst = arrqry[0]; return(MakeNewBllNo( LoginInfo.DefSavdptid, bllmst.qu, WMSConst.BLL_TYPE_UPBLL, (bllno) => { ////正在生成拣货单,请稍候重试 //string quRetrv = bllmst.qu; //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv)) //{ // return RRInfo( "I0226" ); //} //审核人是否是制单人 /*if (IsSameLogin(bllmst.mkr)) * { * return RRInfo("I0445" ,LoginInfo.Usrid ,bllmst.mkr ); * * }*/ #region 判断收货单是否已经登帐 if (bllmst.chkflg == GetY()) { return RRInfo("I0446", wmsno); } #endregion #region 判断操作员是否有审核该单据的权限 //0.判断操作员是否有审核该单据的权限 var dtapwrs = from e in LoginInfo.DatPwrs select e.qu; if (!dtapwrs.Contains(bllmst.qu.Trim())) { return RRInfo("I0447"); } #endregion #region 是否该单据下的所有商品都已经审核 //1.是否该单据下的所有商品都已经审核 var qry1 = from e in WmsDc.wms_blldtl where e.bllid == WMSConst.BLL_TYPE_REVIECEBLL && e.wmsno == wmsno select e; var arrqry1 = qry1.ToArray(); if (arrqry1.Length <= 0) { return RRNoData("N0240"); } foreach (wms_blldtl dtl in arrqry1) { if (dtl.bokflg == GetN()) { return RRInfo("I0448", dtl.gdsid); } } #endregion #region 修改采购单实收数量 //判断是否有比应收数量更大的商品 var qrytpdtl = from e in WmsDc.wms_blltp where e.wmsno == wmsno && e.bllid == WMSConst.BLL_TYPE_REVIECEBLL group e by new { e.wmsno, e.gdsid } into g select new { wmsno = g.Key.wmsno, gdsid = g.Key.gdsid, qty = g.Sum(e1 => e1.qty) }; var qryodrdtl = from e in WmsDc.odrdtl join e1 in WmsDc.wms_bllmst on e.odrno equals e1.lnknewno join e2 in qrytpdtl on new { e1.wmsno, e.gdsid } equals new { e2.wmsno, e2.gdsid } where e1.wmsno == wmsno && e1.bllid == WMSConst.BLL_TYPE_REVIECEBLL && e.qty < e2.qty select e; var arrqryodrdtl = qryodrdtl.ToArray(); if (arrqryodrdtl.Length > 0) { return RRInfo("I0449", arrqryodrdtl[0].gdsid); } StringBuilder sb = new StringBuilder(); String cmdsql = null; //修改采购单实收数量 cmdsql = "update odrdtl set preqty=qty, qty=isnull(b.sumqty,0), pkgqty=isnull(b.sumqty,0), amt=convert(decimal(18,2),round(a.prc*isnull(b.sumqty,0), 4)), patamt=convert(decimal(18,2),round(a.taxprc*isnull(b.sumqty,0), 4)), taxamt=convert(decimal(18,2),round((a.taxprc*isnull(b.sumqty,0))-a.prc*isnull(b.sumqty,0), 4)) from " + " odrdtl a " + " left join " + " ( " + " select a1.wmsno, a1.gdsid, sum(a1.qty) sumqty ,b1.lnknewno from wms_blltp a1 " + " inner join wms_bllmst b1 on a1.wmsno=b1.wmsno and a1.bllid=b1.bllid" + " where b1.wmsno={0} and b1.bllid={1}" + " group by a1.wmsno, a1.gdsid, b1.lnknewno " + " ) b on a.odrno=b.lnknewno and a.gdsid=b.gdsid " + " where a.odrno in (select lnknewno from wms_bllmst where wmsno={2})"; sb.Append(cmdsql); //设置收货单审核标志 cmdsql = "update wms_bllmst set chkflg='" + GetY() + "', ckr={3}, chkdat={4} where wmsno={5} and bllid={6} "; sb.Append(cmdsql); //设置采购单收货标志 cmdsql = "update odr set shflg='" + GetY() + "' from odr a inner join wms_bllmst b on b.lnknewno=a.odrno and b.lnknewbllid=a.bllid where b.wmsno={7} and b.bllid={8} "; sb.Append(cmdsql); //执行处理 string sNow = GetCurrentDate(); WmsDc.ExecuteCommand(sb.ToString(), new[] { wmsno, WMSConst.BLL_TYPE_REVIECEBLL, wmsno, LoginInfo.Usrid, sNow, wmsno, WMSConst.BLL_TYPE_REVIECEBLL, wmsno, WMSConst.BLL_TYPE_REVIECEBLL }); try { WmsDc.SubmitChanges(); } catch (Exception ex) { return RRErr(ex.Message, "E0066"); } #endregion #region 生成上架单 //4.生成上架单 //主表 var qrytp = from e in WmsDc.wms_blltp where e.wmsno == wmsno && e.bllid == WMSConst.BLL_TYPE_REVIECEBLL orderby e.tpcode, e.rcdidxtp select e; wms_bllmst rmst = arrqry[0]; wms_blldtl[] rdtl = arrqry1; wms_cang cwmst = new wms_cang(); List <wms_cangdtl> lstcwdtl = new List <wms_cangdtl>(); cwmst.wmsno = bllno; cwmst.bllid = WMSConst.BLL_TYPE_UPBLL; cwmst.savdptid = rmst.savdptid; cwmst.prvid = rmst.prvid; cwmst.qu = rmst.qu; /*mst.rcvdptid = rmst.rcvdptid;*/ /*mst.times = rmst.times; * mst.lnkbocino = rmst.lnkbocino; * mst.lnkbocidat = rmst.lnkbocidat;*/ cwmst.mkr = LoginInfo.Usrid; cwmst.mkedat = DateTime.Now.ToString("yyyyMMdd"); cwmst.mkedat2 = GetCurrentDate(); /*mst.ckr = rmst.ckr;*/ cwmst.ckr = ""; cwmst.chkflg = GetN(); cwmst.chkdat = ""; cwmst.opr = LoginInfo.Usrid; cwmst.brief = rmst.brief; cwmst.lnkbllid = rmst.bllid; cwmst.lnkno = rmst.wmsno; cwmst.lnkbrief = rmst.brief; //明细 var qrycwdtl = from e in qrytp join e1 in WmsDc.wms_blldtl on new { e.wmsno, e.bllid, e.gdsid } equals new { e1.wmsno, e1.bllid, e1.gdsid } orderby e.rcdidx, e.rcdidxtp select new { e, e1 }; int i = 1; foreach (var tp in qrycwdtl) { wms_cangdtl cwdtl = new wms_cangdtl(); cwdtl.wmsno = bllno; cwdtl.bllid = WMSConst.BLL_TYPE_UPBLL; cwdtl.rcdidx = i++; cwdtl.oldbarcode = ""; cwdtl.barcode = tp.e.barcode; cwdtl.gdsid = tp.e.gdsid; cwdtl.pkgid = tp.e.pkgid; cwdtl.pkgqty = tp.e.qty; cwdtl.qty = Math.Round(tp.e.qty, 4, MidpointRounding.AwayFromZero); cwdtl.gdstype = tp.e.gdstype; cwdtl.bthno = ""; cwdtl.vlddat = ""; cwdtl.bcd = tp.e1.bcd; cwdtl.tpcode = tp.e.tpcode; cwdtl.barcode = ""; cwdtl.bkr = ""; cwdtl.bokflg = GetN(); cwdtl.bokdat = ""; lstcwdtl.Add(cwdtl); } WmsDc.wms_cang.InsertOnSubmit(cwmst); WmsDc.wms_cangdtl.InsertAllOnSubmit(lstcwdtl); WmsDc.SubmitChanges(); #endregion #region 推荐仓位 /*String cmdsql1 = "declare @wmsno varchar(20) " + " set @wmsno={0} " + " exec SuggestBarcode @wmsno "; + WmsDc.ExecuteCommand(cmdsql1, new[] { wmsno });*/ WmsDc.SuggestBarcode(wmsno); #endregion try { WmsDc.SubmitChanges(); return RRSucc("成功", null, "S0218"); } catch (Exception ex) { return RRErr(ex.Message, "E0067"); } })); }
public ActionResult BokRetrieveGds(String wmsno, String barcode, String gdsid, String gdstype, double qty) { using (TransactionScope scop = new TransactionScope(TransactionScopeOption.Required, options)) { //检索主表、明细表 var qrymst = from e in WmsDc.wms_cang where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.wmsno == wmsno select e; var arrmst = qrymst.ToArray(); var qrydtl = from e in WmsDc.wms_cangdtl where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.gdsid == gdsid && e.gdstype == gdstype && e.barcode == barcode && e.wmsno == wmsno && e.tpcode == "y" select e; var arrdtl = qrydtl.ToArray(); #region 检查输入参数 if (arrmst.Length <= 0) { return(RNoData("N0228")); } if (arrdtl.Length <= 0) { return(RNoData("N0229")); } wms_cang mst = arrmst[0]; //正在生成拣货单,请稍候重试 //string quRetrv = mst.qu; //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv)) //{ // return RInfo( "I0117" ); //} wms_cangdtl dtl = arrdtl[0]; //是否捡货单已经审核 if (mst != null && mst.chkflg == GetY()) { return(RInfo("I0430")); } #endregion #region 商品登帐 //判断是否已经被审核 WmsDc.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, dtl); if (dtl.bokflg == GetY()) { //看看是哪个审核的 string[] whoAdt = (from e in WmsDc.emp where e.empid == dtl.bkr select e.empdes).ToArray(); if (whoAdt.Count() > 0) { return(RInfo("I0125", string.Join(",", whoAdt))); } } if (dtl.bokflg == GetY() && dtl.bkr.Trim() != LoginInfo.Usrid) { return(RInfo("I0431", dtl.bkr)); } if (dtl.bokflg == GetN() && dtl.qty != null) { //dtl.preqty = dtl.qty; } if (dtl.tpcode == "n") { return(RInfo("I0118")); } if (dtl.preqty < qty && dtl.tpcode == "y") { return(RInfo("I0119")); } dtl.qty = Math.Round(qty, 4); dtl.pkgqty = Math.Round(qty, 4); //如果是206的单据,同一个商品的最后一条确认完后就不能再修改 var qryallbygdsidN1 = from e in WmsDc.wms_cangdtl where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.gdsid == gdsid //&& e.gdstype == gdstype && e.wmsno == wmsno && e.bokflg == GetN() && e.tpcode == "y" select e; int iCnt = qryallbygdsidN1.Count(); if (mst.lnkbllid.Trim() == "206" && iCnt == 0) { return(RInfo("I0120")); } dtl.bokflg = GetY(); dtl.bokdat = DateTime.Now.ToString("yyyyMMddHHmmss"); dtl.bkr = LoginInfo.Usrid; try { WmsDc.SubmitChanges(); } catch (Exception ex) { if (ex.Message.IndexOf("牺牲品") > 0) { return(RInfo("E0075")); } else { return(RInfo("E0076", ex.Message)); } } if (dtl.preqty != dtl.qty) { i(wmsno, WMSConst.BLL_TYPE_RETRIEVE, "拣货商品明细确认", "应拣数量:" + dtl.preqty + ",实拣数量:" + dtl.qty, mst.qu, mst.savdptid); } #endregion #region 如果是206配送拣货的单据,在同一个拣货单里面同一商品确认完后,写入分货表 if (mst.lnkbllid.Trim() == "206") { var qryallbygdsidN = from e in WmsDc.wms_cangdtl where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.gdsid == gdsid //&& e.gdstype == gdstype && e.wmsno == wmsno && e.bokflg == GetN() && e.tpcode == "y" select e; iCnt = qryallbygdsidN.Count(); if (iCnt == 0) { var qryAllByGdsidCang = from e in WmsDc.wms_cangdtl join e1 in WmsDc.wms_cang on new { e.wmsno, e.bllid } equals new { e1.wmsno, e1.bllid } where e.bllid == WMSConst.BLL_TYPE_RETRIEVE && e.tpcode == "y" && e.gdsid == gdsid && e.wmsno == wmsno group e by new { e1.savdptid, e1.rcvdptid, e1.wmsno, e1.bllid, e1.lnkbocino, e1.lnkbocidat, e1.times, e.gdsid } into g select new { savdptid = g.Key.savdptid, wmsno = g.Key.wmsno, bllid = g.Key.bllid, bocino = g.Key.lnkbocino, bocidat = g.Key.lnkbocidat, clsid = g.Key.times, /*checi = (from e2 in WmsDc.psSndGds_dpt_dtl * where e2.dptid == g.Key.rcvdptid && e2.dh == g.Key.lnkbocino * select e2.busid.Substring(e2.busid.Trim().Length - 1, 1)).FirstOrDefault(),*/ gdsid = g.Key.gdsid, qty = g.Sum(e => e.qty), preqty = g.Sum(e => e.qty), ckr = "", chkflg = GetN(), chkdat = "" }; var cutgds = qryAllByGdsidCang.FirstOrDefault(); #region 如果拣货的数量不够的话,要去修改配送单的数量和金额 var qrystkdtl = from e in WmsDc.stkotdtl where e.stkot.wmsbllid == cutgds.bllid && e.stkot.wmsno == cutgds.wmsno && e.gdsid == cutgds.gdsid orderby Convert.ToInt32(e.stkot.rcvdptid) descending, e.qty descending select e; double q = qrystkdtl.Sum(e => e.qty) - cutgds.qty; if (q > 0) { double diff = q; var stkotdtl = qrystkdtl; //扣减stkotdtl里面的库存 RedcStkotQty(stkotdtl.ToArray(), diff); } try { WmsDc.SubmitChanges(); } catch (Exception ex) { if (ex.Message.IndexOf("牺牲品") > 0) { return(RInfo("E0075")); } else { return(RInfo("E0076", ex.Message)); } } #endregion // 写入分货表 #region 写入分货表 //var qryAllByGdsid = from e in WmsDc.stkotdtl // join e1 in WmsDc.wms_cang on new { e.stkot.wmsno, e.stkot.wmsbllid } equals new { e1.wmsno, wmsbllid = e1.bllid } // where e.stkot.wmsbllid == cutgds.bllid // && e.stkot.wmsno == cutgds.wmsno // && e.gdsid == cutgds.gdsid // && e.qty != 0 // group e by new // { // e1.savdptid, // e.stkot.rcvdptid, // e1.wmsno, // e1.bllid, // e1.lnkbocino, // e1.lnkbocidat, // e1.times, // e.gdsid // } into g // select new // { // savdptid = g.Key.savdptid, // wmsno = g.Key.wmsno, // bllid = g.Key.bllid, // bocino = g.Key.lnkbocino, // bocidat = g.Key.lnkbocidat, // clsid = g.Key.times, // checi = (from e2 in WmsDc.psSndGds_dpt_dtl // where e2.dptid == g.Key.rcvdptid && e2.dh == g.Key.lnkbocino // select e2.busid.Substring(e2.busid.Trim().Length - 1, 1)).FirstOrDefault(), // gdsid = g.Key.gdsid, // qty = g.Sum(e => e.qty), // preqty = g.Sum(e => e.qty), // ckr = "", // chkflg = GetN(), // chkdat = "" // }; ////i(wmsno, "", "拣货确认", qryAllByGdsid.ToString(), "", LoginInfo.DefSavdptid); //var arrQryAllByGdsid = qryAllByGdsid.ToArray(); //foreach (var a in arrQryAllByGdsid) //{ // if (a.checi == null) // { // iFile(cutgds.bllid + " " + cutgds.wmsno + " " + cutgds.gdsid + " "); // } //} //var qryAllByGdsidSum = from e in arrQryAllByGdsid // group e by new // { // e.savdptid, // e.wmsno, // e.bllid, // e.bocino, // e.bocidat, // e.clsid, // e.checi, // e.gdsid, // e.ckr, // e.chkflg, // e.chkdat // } into g // select new // { // g.Key.savdptid, // g.Key.wmsno, // g.Key.bllid, // g.Key.bocino, // g.Key.bocidat, // g.Key.clsid, // g.Key.checi, // g.Key.gdsid, // g.Key.ckr, // g.Key.chkflg, // g.Key.chkdat, // qty = g.Sum(e => e.qty), // preqty = g.Sum(e => e.preqty) // }; //List<wms_cutgds> lstCg = new List<wms_cutgds>(); //foreach (var tcg in qryAllByGdsidSum) //{ // wms_cutgds cg = new wms_cutgds(); // cg.bllid = tcg.bllid; // cg.bocidat = tcg.bocidat; // cg.bocino = tcg.bocino; // cg.checi = tcg.checi; // cg.chkdat = tcg.chkdat; // cg.chkflg = tcg.chkflg; // cg.ckr = tcg.ckr; // cg.clsid = tcg.clsid; // cg.gdsid = tcg.gdsid; // cg.preqty = tcg.preqty; // cg.qty = tcg.qty; // cg.savdptid = tcg.savdptid; // cg.wmsno = tcg.wmsno; // lstCg.Add(cg); //} //WmsDc.wms_cutgds.InsertAllOnSubmit(lstCg); #endregion 写入分货表 } } #endregion try { try { WmsDc.SubmitChanges(); } catch (Exception ex) { if (ex.Message.IndexOf("牺牲品") > 0) { return(RInfo("E0075")); } else { return(RInfo("E0076", ex.Message)); } } scop.Complete(); return(RSucc("成功", null, "S0212")); } catch (Exception ex) { return(RErr(ex.Message, "E0059")); } } }