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");
                }
            }));
        }
示例#2
0
        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");
                }
            }));
        }