Beispiel #1
0
        public ActionResult BokBozBllGds(String wmsno, String stkouno, String rcvdptid, String gdsid, double qty, int?rcdidx)
        {
            using (TransactionScope scop = new TransactionScope(TransactionScopeOption.Required, options))
            {
                gdsid = GetGdsidByGdsidOrBcd(gdsid);

                //正在生成拣货单,请稍候重试
                string quRetrv = GetQuByGdsid(gdsid, LoginInfo.DefStoreid).FirstOrDefault();
                //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv))
                //{
                //    return RInfo( "I0077" );
                //}

                if (gdsid == null)
                {
                    return(RInfo("I0078"));
                }

                String Dat = GetCurrentDay();

                /*
                 * var qry = from e in WmsDc.stkot
                 *        from e1 in e.stkotdtl
                 *        join e2 in WmsDc.gds on e1.gdsid equals e2.gdsid
                 *        where e.wmsno == wmsno
                 *        && e.bllid == WMSConst.BLL_TYPE_DISPATCH
                 *        && e.wmsbllid == WMSConst.BLL_TYPE_RETRIEVE
                 *        && dpts.Contains(e.dptid)
                 *        && e.savdptid == LoginInfo.DefSavdptid
                 *        && e.rcvdptid == rcvdptid
                 *        && e1.gdsid == gdsid
                 *        && e1.rcdidx == rcdidx
                 *        select e;
                 */

                var qry = from e in WmsDc.stkot
                          where e.stkouno == stkouno &&
                          e.bllid == WMSConst.BLL_TYPE_DISPATCH &&
                          e.wmsbllid == WMSConst.BLL_TYPE_RETRIEVE &&
                          dpts.Contains(e.dptid.Trim()) &&
                          (e.savdptid == LoginInfo.DefSavdptid || e.savdptid == LoginInfo.DefCsSavdptid) &&
                          e.rcvdptid == rcvdptid
                          select e;
                var arrqry = qry.ToArray();
                if (arrqry.Length <= 0)
                {
                    return(RNoData("N0048"));
                }
                var stkotgds = arrqry[0];
                if (wmsno == null)
                {
                    wmsno = stkotgds.wmsno;
                }
                if (stkotgds.chkflg == GetY())
                {
                    return(RInfo("I0079"));
                }

                /*if (stkotgds.bzflg == GetY())
                 * {
                 *  return RInfo( "I0080" );
                 * }*/
                var qrydtl = from e in stkotgds.stkotdtl
                             where e.gdsid.Trim() == gdsid.Trim() && e.rcdidx == rcdidx
                             select e;
                var arrqrydtl = qrydtl.ToArray();
                if (arrqrydtl.Length <= 0)
                {
                    return(RNoData("N0049"));
                }
                stkotdtl stkdtl = arrqrydtl[0];
                double?  preqty = stkdtl.preqty;
                if (stkdtl.preqty == null)              ///如果应收数量为空,就把qty中的数量填入其中
                {
                    stkdtl.preqty = stkdtl.qty;
                    preqty        = stkdtl.qty;
                }
                if (preqty < qty)       //如果实收数量大于应收数量就退出
                {
                    return(RInfo("I0081"));
                }
                if (preqty != qty)
                {
                    GetRealteQuResult qu = GetRealteQu(stkotgds.dptid, LoginInfo.DefSavdptid);
                    Log.i(LoginInfo.Usrid, Mdlid, stkotgds.stkouno, stkotgds.bllid, "播种审核",
                          gdsid.Trim() + ":应播:" + preqty + ";实播:" + qty,
                          qu.qu, qu.savdptid);
                }

                //查看该商品是否已经被非本人确认
                if (stkdtl.bzflg == GetY() && stkdtl.bzr != LoginInfo.Usrid)
                {
                    return(RInfo("I0082", stkdtl.bzr));
                }

                #region 检查参数有效性
                if (arrqry == null)
                {
                    return(RInfo("I0083"));
                }
                if (stkdtl == null)
                {
                    return(RInfo("I0084"));
                }

                #endregion

                //修改审核标记
                try
                {
                    /*
                     * preqty = preqty==null ? qty : preqty
                     *
                     * 公式:taxamt = qty*prc*taxrto
                     * amt = qty*prc
                     * salamt = qty*salprc
                     * patamt = qty*taxprc
                     * stotcstamt = qty*stotcstprc
                     *
                     */
                    stkdtl.qty        = Math.Round(qty, 4, MidpointRounding.AwayFromZero);
                    stkdtl.pkgqty     = Math.Round(qty, 4, MidpointRounding.AwayFromZero);
                    stkdtl.bzdat      = GetCurrentDate();
                    stkdtl.bzr        = LoginInfo.Usrid;
                    stkdtl.bzflg      = GetY();
                    stkdtl.taxamt     = Math.Round(qty * stkdtl.prc * stkdtl.taxrto, 4);
                    stkdtl.amt        = Math.Round(qty * stkdtl.prc, 4);
                    stkdtl.salamt     = qty * stkdtl.salprc;
                    stkdtl.patamt     = Math.Round(qty * stkdtl.taxprc, 4);
                    stkdtl.stotcstamt = Math.Round(qty * stkdtl.stotcstprc.Value, 4);

                    //判断改单据是否已经全部商品已经确认,全部确认后的,实收商品总数和应收商品总数相同就直接修改主单的审核标记

                    /*double? sqty = stkotgds
                     *              .stkotdtl
                     *              .Where(e=>e.bzflg==GetY())
                     *              .Sum(e=>e.qty==null?0:e.qty);
                     * double? spreqty = stkotgds.stkotdtl.Sum(e=>e.preqty==null?e.qty:e.preqty);
                     * if(sqty==spreqty){
                     *  stkotgds.chkflg = GetY();
                     *  stkotgds.chkdat = Dat;
                     *  stkotgds.ckr = LoginInfo.Usrid;
                     *  stklst astklst = new stklst();
                     *  astklst.stkouno = stkotgds.stkouno;
                     *  WmsDc.stklst.InsertOnSubmit(astklst);
                     * }*/

                    WmsDc.SubmitChanges();

                    ///如果明细全部播种完
                    ///就修改审核标记
                    ///和播种标记
                    double sqtycnt = stkotgds
                                     .stkotdtl
                                     .Where(e => e.bzflg == GetY() && Math.Round(e.qty, 2, MidpointRounding.AwayFromZero) != 0)
                                     .Count();
                    double spreqtycnt = stkotgds
                                        .stkotdtl
                                        .Where(e => Math.Round(e.qty, 2, MidpointRounding.AwayFromZero) != 0)
                                        .Count();
                    d(wmsno, WMSConst.BLL_TYPE_UPBLL, "审核播种商品", "sqtycnt=" + sqtycnt + "&spreqtycnt=" + spreqtycnt, "", LoginInfo.DefSavdptid);
                    if (sqtycnt == spreqtycnt)
                    {
                        CkBzFlg(stkotgds);

                        //查看有没有明细为空的单据,直接修改播种标记
                        var qryZeroBz = from e in WmsDc.stkotdtl
                                        where e.stkot.wmsno == wmsno && e.stkot.wmsbllid == WMSConst.BLL_TYPE_RETRIEVE
                                        group e by e.stkouno into g
                                        select new
                        {
                            stkouno = g.Key,
                            sqty    = g.Sum(e => e.qty)
                        };
                        qryZeroBz = qryZeroBz.Where(e => e.sqty == 0);
                        var qryZeroBzmst = from e in WmsDc.stkot
                                           join e1 in qryZeroBz on e.stkouno equals e1.stkouno
                                           where e.chkflg != GetY()
                                           select e;
                        foreach (var q in qryZeroBzmst)
                        {
                            CkBzFlg(q);
                            foreach (var dl in q.stkotdtl)
                            {
                                dl.bzflg = GetY();
                                dl.bzdat = GetCurrentDate();
                                dl.bzr   = LoginInfo.Usrid;
                            }
                        }
                    }

                    WmsDc.SubmitChanges();
                    scop.Complete();
                    return(RSucc("成功", null, "S0038"));
                }
                catch (Exception ex)
                {
                    return(RErr(ex.Message, "E0012"));
                }
            }
        }
Beispiel #2
0
        public ActionResult BokBozBllGds(String wmsno, String stkouno, String rcvdptid, String gdsid, double qty, int?rcdidx, String checi)
        {
            using (TransactionScope scop = new TransactionScope())
            {
                // done 删除临时调试日志
                //d(wmsno, WMSConst.BLL_TYPE_DISPATCH, "审核播种商品", "wmsno=" + wmsno + "&stkouno=" + stkouno + "&rcvdptid=" + rcvdptid + "&gdsid=" + gdsid + "&qty=" + qty + "&rcdidx=" + rcdidx + "&checi=" + checi, "", "");

                gdsid = GetGdsidByGdsidOrBcd(gdsid);
                //正在生成拣货单,请稍候重试
                //string quRetrv = GetQuByGdsid(gdsid, LoginInfo.DefStoreid).FirstOrDefault();
                //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv))
                //{
                //    return RInfo( "I0089" );
                //}

                if (gdsid == null)
                {
                    return(RInfo("I0090"));
                }

                String Dat = GetCurrentDay();

                //检查该单子的分单是否结束(拣货确认一条,就可以播种一条)
                var qryfd = from e in WmsDc.wms_cutgds
                            where e.wmsno == wmsno && e.gdsid == gdsid && e.checi == checi &&
                            e.chkflg == GetN()
                            select e;
                foreach (wms_cutgds c in qryfd)
                {
                    return(RInfo("I0091"));
                }

                /*
                 * var qry = from e in WmsDc.stkot
                 *        from e1 in e.stkotdtl
                 *        join e2 in WmsDc.gds on e1.gdsid equals e2.gdsid
                 *        where e.wmsno == wmsno
                 *        && e.bllid == WMSConst.BLL_TYPE_DISPATCH
                 *        && dpts.Contains(e.dptid)
                 *        && (e.savdptid == LoginInfo.DefSavdptid || e.savdptid == LoginInfo.DefCsSavdptid)
                 *        && e.rcvdptid == rcvdptid
                 *        && e1.gdsid == gdsid
                 *        && e1.rcdidx == rcdidx
                 *        select e;
                 */

                var qry = from e in WmsDc.stkot
                          join e3 in WmsDc.wms_cang on new { e.wmsno, e.wmsbllid } equals new { e3.wmsno, wmsbllid = e3.bllid }
                join e4 in WmsDc.wms_boci on new { dh = e3.lnkbocino, sndtmd = e3.lnkbocidat, e3.qu } equals new { e4.dh, e4.sndtmd, e4.qu }
                join e5 in WmsDc.view_pssndgds on new { e4.dh, e4.clsid, e4.sndtmd, e.rcvdptid, e4.qu } equals new { e5.dh, e5.clsid, e5.sndtmd, e5.rcvdptid, e5.qu }
                where e.stkouno == stkouno &&
                e.bllid == WMSConst.BLL_TYPE_DISPATCH &&
                dpts.Contains(e.dptid.Trim()) &&
                (e.savdptid == LoginInfo.DefSavdptid || e.savdptid == LoginInfo.DefCsSavdptid) &&
                e.rcvdptid == rcvdptid &&
                e5.busid.Trim().Substring(e5.busid.Trim().Length - 1, 1) == checi
                select e;
                var arrqry = qry.Distinct().ToArray();
                if (arrqry.Length <= 0)
                {
                    return(RNoData("N0056"));
                }
                var stkotgds = arrqry[0];
                if (wmsno == null)
                {
                    wmsno = stkotgds.wmsno;
                }
                if (stkotgds.chkflg == GetY())
                {
                    return(RInfo("I0092"));
                }

                /*if (stkotgds.bzflg == GetY())
                 * {
                 *  return RInfo( "I0093" );
                 * }*/
                var qrydtl = from e in stkotgds.stkotdtl
                             where e.gdsid.Trim() == gdsid.Trim() && e.rcdidx == rcdidx &&
                             (from e1 in WmsDc.wms_cutgds where e1.wmsno == stkotgds.wmsno && e1.bllid == stkotgds.wmsbllid && e1.gdsid == e.gdsid && e1.checi == checi select e1).Any()
                             select e;
                var arrqrydtl = qrydtl.ToArray();
                if (arrqrydtl.Length <= 0)
                {
                    return(RNoData("N0057"));
                }
                stkotdtl stkdtl = arrqrydtl[0];
                double?  preqty = stkdtl.preqty;
                if (stkdtl.preqty == null)              ///如果应收数量为空,就把qty中的数量填入其中
                {
                    stkdtl.preqty = stkdtl.qty;
                    preqty        = stkdtl.qty;
                }
                if (preqty < qty)       //如果实收数量大于应收数量就退出
                {
                    return(RInfo("I0094"));
                }
                if (preqty != qty)
                {
                    GetRealteQuResult qu = GetRealteQu(stkotgds.dptid, LoginInfo.DefSavdptid);
                    Log.i(LoginInfo.Usrid, Mdlid, stkotgds.stkouno, stkotgds.bllid, "播种审核",
                          gdsid.Trim() + ":应播:" + preqty + ";实播:" + qty,
                          qu.qu, qu.savdptid);
                }

                //查看该商品是否已经被非本人确认
                if (stkdtl.bzflg == GetY() && stkdtl.bzr != LoginInfo.Usrid)
                {
                    return(RInfo("I0095", stkdtl.bzr));
                }

                #region 检查参数有效性
                if (arrqry == null)
                {
                    return(RInfo("I0096"));
                }
                if (stkdtl == null)
                {
                    return(RInfo("I0097"));
                }

                #endregion

                //修改审核标记
                try
                {
                    /*
                     * preqty = preqty==null ? qty : preqty
                     *
                     * 公式:taxamt = qty*prc*taxrto
                     * amt = qty*prc
                     * salamt = qty*salprc
                     * patamt = qty*taxprc
                     * stotcstamt = qty*stotcstprc
                     *
                     */
                    stkdtl.qty        = Math.Round(qty, 4, MidpointRounding.AwayFromZero);
                    stkdtl.pkgqty     = Math.Round(qty, 4, MidpointRounding.AwayFromZero);
                    stkdtl.bzdat      = GetCurrentDate();
                    stkdtl.bzr        = LoginInfo.Usrid;
                    stkdtl.bzflg      = GetY();
                    stkdtl.taxamt     = Math.Round(qty * stkdtl.prc * stkdtl.taxrto, 4);
                    stkdtl.amt        = Math.Round(qty * stkdtl.prc, 4);
                    stkdtl.salamt     = qty * stkdtl.salprc;
                    stkdtl.patamt     = Math.Round(qty * stkdtl.taxprc, 4);
                    stkdtl.stotcstamt = Math.Round(qty * stkdtl.stotcstprc.Value, 4);

                    //判断改单据是否已经全部商品已经确认,全部确认后的,实收商品总数和应收商品总数相同就直接修改主单的审核标记

                    /*double? sqty = stkotgds
                     *              .stkotdtl
                     *              .Where(e=>e.bzflg==GetY())
                     *              .Sum(e=>e.qty==null?0:e.qty);
                     * double? spreqty = stkotgds.stkotdtl.Sum(e=>e.preqty==null?e.qty:e.preqty);
                     * if(sqty==spreqty){
                     *  stkotgds.chkflg = GetY();
                     *  stkotgds.chkdat = Dat;
                     *  stkotgds.ckr = LoginInfo.Usrid;
                     *  stklst astklst = new stklst();
                     *  astklst.stkouno = stkotgds.stkouno;
                     *  WmsDc.stklst.InsertOnSubmit(astklst);
                     * }*/

                    WmsDc.SubmitChanges();

                    ///如果明细全部播种完
                    ///就修改审核标记
                    ///和播种标记
                    double sqtycnt = stkotgds
                                     .stkotdtl
                                     .Where(e => e.bzflg == GetY() && Math.Round(e.qty, 2, MidpointRounding.AwayFromZero) != 0)
                                     .Count();
                    double spreqtycnt = stkotgds
                                        .stkotdtl
                                        .Where(e => Math.Round(e.qty, 2, MidpointRounding.AwayFromZero) != 0)
                                        .Count();
                    d(wmsno, WMSConst.BLL_TYPE_UPBLL, "审核播种商品", "sqtycnt=" + sqtycnt + "&spreqtycnt=" + spreqtycnt, "", LoginInfo.DefSavdptid);
                    if (sqtycnt == spreqtycnt)
                    {
                        CkBzFlg(stkotgds);

                        //查看有没有明细为空的单据,直接修改播种标记
                        var qryZeroBz = from e in WmsDc.stkotdtl
                                        where e.stkot.wmsno == wmsno && e.stkot.wmsbllid == WMSConst.BLL_TYPE_RETRIEVE
                                        group e by e.stkouno into g
                                        select new
                        {
                            stkouno = g.Key,
                            sqty    = g.Sum(e => e.qty)
                        };
                        qryZeroBz = qryZeroBz.Where(e => e.sqty == 0);
                        var qryZeroBzmst = from e in WmsDc.stkot
                                           join e1 in qryZeroBz on e.stkouno equals e1.stkouno
                                           where e.chkflg != GetY()
                                           select e;
                        foreach (var q in qryZeroBzmst)
                        {
                            CkBzFlg(q);
                            foreach (var dtl in q.stkotdtl)
                            {
                                dtl.bzflg = GetY();
                                dtl.bzdat = GetCurrentDate();
                                dtl.bzr   = LoginInfo.Usrid;
                            }
                        }
                    }

                    WmsDc.SubmitChanges();
                    scop.Complete();
                    return(RSucc("成功", null, "S0047"));
                }
                catch (Exception ex)
                {
                    return(RErr(ex.Message, "E0013"));
                }
            }
        }