public ActionResult CheckCangwei(String wmsno, String barcode, String newbarcode, String tpcode) { using (TransactionScope scop = new TransactionScope(TransactionScopeOption.Required, options)) { wms_cangwei oldCw = null; String rqu = GetQuByBarcode(newbarcode); String oqu = GetQuByBarcode(barcode); //如果旧仓位不为空,就需要查询出就仓位,以便修改其仓位托盘tpflg标志 if (!string.IsNullOrEmpty(barcode.Trim())) { //判断仓位码是否有效 if (!IsExistBarcode(barcode)) { return(RInfo("I0396", barcode.Trim())); } oldCw = GetCangWei(barcode); } //判断仓位码是否有效 if (!string.IsNullOrEmpty(newbarcode) && !IsExistBarcode(newbarcode)) { return(RInfo("I0397", newbarcode.Trim())); } //todo 判断新的仓位码是否为今天已经上架单中已有的仓位 //主表 wms_cang cang = GetCangMst(wmsno); //明细表 var qrydtl = GetCangDtl(wmsno) .Where(e => e.barcode.Trim() == barcode.Trim() && e.tpcode.Trim() == tpcode.Trim()); var arrqrydtl = qrydtl.ToArray(); // 判断明细的分区是否是同一个分区,而且newbarcode的分区也在商品的分区内 string initQu = null; foreach (wms_cangdtl dtl in arrqrydtl) { string gdsqu = GetQuByGdsid(dtl.gdsid, LoginInfo.DefStoreid).FirstOrDefault(); if (string.IsNullOrEmpty(initQu)) { initQu = gdsqu; } if (initQu != gdsqu) { return(RInfo("I0398")); } } if (!dtqus.Contains(rqu)) { if (initQu != newbarcode.Substring(0, 2)) { return(RInfo("I0399")); } } #region 效性检查 //检查单号是否有效 if (cang == null) { return(RNoData("N0213")); } ////正在生成拣货单,请稍候重试 //string quRetrv = cang.qu; //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv)) //{ // return RInfo( "I0400" ); //} //检查是否已经审核 if (cang.chkflg == GetY()) { return(RInfo("I0401")); } //未查找到托盘的正确仓位 if (arrqrydtl.Length <= 0) { return(RNoData("N0214")); } //检查同一个托盘是否都已经上架 if (arrqrydtl[0].bokflg == GetY()) { return(RInfo("I0402")); } #endregion wms_cangwei cw = null; //如果调入不在堆头区,就判断一下区域间能不能互相调用 //if (!dtqus.Contains(rqu)) //{ //查看新仓位是否不为推荐仓位 if (!String.IsNullOrEmpty(newbarcode) && barcode.Trim() != newbarcode.Trim()) { cw = GetCangWei(newbarcode); if (cw == null) { return(RNoData("N0215", newbarcode)); } if (!savdpts.Contains(cw.savdptid.Trim())) { return(RInfo("I0403", newbarcode)); } if (!qus.Contains(cw.qu.Trim())) { return(RInfo("I0404", newbarcode)); } /*var qrynewcw = from e in WmsDc.wms_cang * join e1 in WmsDc.wms_cangdtl on new { e.wmsno, e.bllid } equals new { e1.wmsno, e1.bllid } * where //e.wmsno == wmsno && * e.bllid == "102" //上架单 * && e1.barcode == newbarcode * && e.mkedat.Substring(0, 8) == GetCurrentDay() * select e; * if (oldCw != null && * ( * !qrynewcw.Any() && //这两句不能换位置 * cw.tjflg == GetY() //调整仓位{0}为不在当天上架单中的推荐仓位,不能使用 * ) * ) * { * return RInfo("I0405", newbarcode); * }*/ //修改新仓位标记tpflg=GetY() cw.tpflg = GetY(); //修改旧仓位tpflg=GetN() if (oldCw != null) { oldCw.tpflg = GetN(); } WmsDc.SubmitChanges(); } //} #region 架托盘到仓位 foreach (wms_cangdtl cangdtl in arrqrydtl) { cangdtl.bkr = LoginInfo.Usrid; cangdtl.bokflg = GetY(); cangdtl.bokdat = DateTime.Now.ToString("yyyyMMddHHmmss"); if (cw != null) { cangdtl.oldbarcode = cangdtl.barcode; cangdtl.barcode = newbarcode; } } try { WmsDc.SubmitChanges(); //done: 判断是否已经上架单明细已经审核完毕,完毕后就直接审核整单 //明细表 /**/ int?isLasted = WmsDc.ExecuteQuery <int?>("select count(*) from wms_cangdtl with(updlock) where wmsno={0} and bllid={1} and bokflg={2}", wmsno, WMSConst.BLL_TYPE_UPBLL, GetN()).FirstOrDefault(); if (isLasted == null || isLasted == 0) { wms_cangdtl[] arrqryaldtl = GetCangDtl(wmsno) .Where(e => e.bokflg == GetN()) .ToArray(); // done: 判断盘点收货单有没有整单审核,提示不能上架 wms_bllmst bllmst = GetBllMst(wmsno); if (bllmst == null) { return(RInfo("I0406")); } if (bllmst.chkflg == GetN()) { return(RInfo("I0407")); } #region 审核整单 JsonResult ar = (JsonResult)AdtUpShelf(wmsno); ResultMessage rm = (ResultMessage)ar.Data; if (rm.ResultCode != ResultMessage.RESULTMESSAGE_SUCCESS) { return(ar); } #endregion 审核整单 } scop.Complete(); return(RSucc("扫描仓位码和托盘码匹配成功!", null, "S0196")); } catch (Exception ex) { return(RErr("异常错误!" + ex.Message, "E0053")); } #endregion } } private wms_cangwei GetCangWei(String newbarcode) { var qrytj = from e in WmsDc.wms_cangwei where e.isvld == GetY() // && e.tjflg == GetN() //&& savdpts.Contains(e.savdptid) //&& qus.Contains(e.qu) && e.barcode == newbarcode select e; wms_cangwei cw = qrytj.FirstOrDefault(); return(cw); } private wms_cangdtl[] GetCangDtl(String wmsno) { var qryaldtl = 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.wmsno == wmsno && e1.bllid == WMSConst.BLL_TYPE_UPBLL //&& e.bokflg == GetN() select e; var arrqryaldtl = qryaldtl.ToArray(); return(arrqryaldtl); } private wms_bllmst GetBllMst(String wmsno) { var qry = from e in WmsDc.wms_bllmst join e1 in WmsDc.wms_cang on new { e.wmsno, e.bllid } equals new { wmsno = e1.lnkno, bllid = e1.lnkbllid } where e1.wmsno == wmsno && e1.bllid == WMSConst.BLL_TYPE_UPBLL select e; wms_bllmst bllmst = qry.FirstOrDefault(); return(bllmst); } private ActionResult AdtUpShelf(String wmsno) { //主表 wms_cang cang = GetCangMst(wmsno); //明细表 wms_cangdtl[] arrqrydtl = GetCangDtl(wmsno); #region 效性检查 //检查单号是否有效 if (cang == null) { return(RNoData("N0216")); } ////正在生成拣货单,请稍候重试 //string quRetrv = cang.qu; //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv)) //{ // return RInfo( "I0408" ); //} //检查是否已经审核 if (cang.chkflg == GetY()) { return(RInfo("I0409")); } //未查找到收货单明细 if (arrqrydtl.Length <= 0) { return(RNoData("N0217")); } //检查是否所有托盘都已经确认 foreach (wms_cangdtl cangdtl in arrqrydtl) { if (cangdtl.bokflg == GetN()) { return(RInfo("I0410", cangdtl.tpcode)); } } #endregion #region 登帐 String fscprdid = GetCurrentFscprdid(); var qrygdsbs = from e in WmsDc.wms_gdsbs where e.fscprdid == fscprdid && e.srcbllno == cang.wmsno && e.bllid == cang.bllid select e; var arrqrygdsbs = qrygdsbs.ToArray(); WmsDc.wms_gdsbs.DeleteAllOnSubmit(arrqrygdsbs); WmsDc.SubmitChanges(); List <wms_gdsbs> lstgdsbs = new List <wms_gdsbs>(); foreach (wms_cangdtl cangdtl in arrqrydtl) { wms_gdsbs gdsbs = new wms_gdsbs(); gdsbs.actdat = DateTime.Now.ToString("yyyyMMdd"); gdsbs.barcode = cangdtl.barcode; gdsbs.bcd = cangdtl.bcd; gdsbs.bllid = cang.bllid; gdsbs.brief = cang.brief; gdsbs.bthno = cangdtl.bthno; gdsbs.dbtcrt = '1'; gdsbs.empid = LoginInfo.Usrid; gdsbs.fscprdid = fscprdid; gdsbs.gdsid = cangdtl.gdsid; gdsbs.gdstype = cangdtl.gdstype; gdsbs.prvid = cang.prvid; gdsbs.qty = cangdtl.qty; gdsbs.savdptid = cang.savdptid; gdsbs.srcbllno = cang.wmsno; gdsbs.srcrcdidx = cangdtl.rcdidx; gdsbs.vlddat = cangdtl.vlddat; lstgdsbs.Add(gdsbs); #region 统计帐表数据更新 wms_cangwei cw = GetCangWei(cangdtl.barcode); if (cw == null) { return(RNoData("N0218", gdsbs.gdsid)); } #region 修改仓位有货标记 /*try //周熙写了触发器,说不用改这个了 * { * cw.kcflg = WMSConst.KC_FLG_HASQTY; //修改仓位有无库存,有为1,没有为0; * cw.tpflg = GetN(); * WmsDc.SubmitChanges(); * } * catch (Exception ex) * { * }*/ #endregion var qrycwgdsbs = from e in WmsDc.wms_cwgdsbs where e.barcode == gdsbs.barcode.Trim() //&& e.bcd == gdsbs.bcd //&& e.bthno == gdsbs.bthno && e.gdsid == gdsbs.gdsid.Trim() && e.gdstype == gdsbs.gdstype.Trim() && e.bthno == gdsbs.bthno && e.vlddat == gdsbs.vlddat //&& e.prvid == gdsbs.prvid && e.savdptid == gdsbs.savdptid && e.qu == cw.qu.Trim() select e; var arrqrycwgdsbs = qrycwgdsbs.ToArray(); //如果统计帐表里面没有就增加一条记录 if (arrqrycwgdsbs.Length <= 0) { wms_cwgdsbs cwgdsbs = new wms_cwgdsbs(); cwgdsbs.barcode = gdsbs.barcode; cwgdsbs.bcd = gdsbs.bcd; cwgdsbs.gdsid = gdsbs.gdsid; cwgdsbs.qty = gdsbs.qty; cwgdsbs.gdstype = gdsbs.gdstype; cwgdsbs.prvid = gdsbs.prvid; cwgdsbs.qu = cw.qu; cwgdsbs.savdptid = gdsbs.savdptid; cwgdsbs.bthno = gdsbs.bthno == null ? "1" : gdsbs.bthno; cwgdsbs.vlddat = gdsbs.vlddat == null?GetCurrentDay() : gdsbs.vlddat; WmsDc.wms_cwgdsbs.InsertOnSubmit(cwgdsbs); WmsDc.SubmitChanges(); } else //如果有的话就修改统计帐表的信息 { wms_cwgdsbs cwgdsbs = arrqrycwgdsbs[0]; cwgdsbs.qty += gdsbs.qty; WmsDc.SubmitChanges(); } #endregion //WmsDc.SubmitChanges(); } //WmsDc.wms_gdsbs.InsertAllOnSubmit(lstgdsbs); #endregion #region 修改审核标记 cang.chkflg = GetY(); cang.ckr = LoginInfo.Usrid; cang.chkdat = DateTime.Now.ToString("yyyyMMddHHmmss"); #endregion WmsDc.SubmitChanges(); return(RSucc("上架单审核成功!", null, "S0197")); }
private ActionResult AdtUpShelf(String wmsno) { //主表 wms_cang cang = GetCangMst(wmsno); //明细表 wms_cangdtl[] arrqrydtl = GetCangDtl(wmsno); #region 效性检查 //检查单号是否有效 if (cang == null) { return(RNoData("N0216")); } ////正在生成拣货单,请稍候重试 //string quRetrv = cang.qu; //if (DoingRetrieve(LoginInfo.DefStoreid, quRetrv)) //{ // return RInfo( "I0408" ); //} //检查是否已经审核 if (cang.chkflg == GetY()) { return(RInfo("I0409")); } //未查找到收货单明细 if (arrqrydtl.Length <= 0) { return(RNoData("N0217")); } //检查是否所有托盘都已经确认 foreach (wms_cangdtl cangdtl in arrqrydtl) { if (cangdtl.bokflg == GetN()) { return(RInfo("I0410", cangdtl.tpcode)); } } #endregion #region 登帐 String fscprdid = GetCurrentFscprdid(); var qrygdsbs = from e in WmsDc.wms_gdsbs where e.fscprdid == fscprdid && e.srcbllno == cang.wmsno && e.bllid == cang.bllid select e; var arrqrygdsbs = qrygdsbs.ToArray(); WmsDc.wms_gdsbs.DeleteAllOnSubmit(arrqrygdsbs); WmsDc.SubmitChanges(); List <wms_gdsbs> lstgdsbs = new List <wms_gdsbs>(); foreach (wms_cangdtl cangdtl in arrqrydtl) { wms_gdsbs gdsbs = new wms_gdsbs(); gdsbs.actdat = DateTime.Now.ToString("yyyyMMdd"); gdsbs.barcode = cangdtl.barcode; gdsbs.bcd = cangdtl.bcd; gdsbs.bllid = cang.bllid; gdsbs.brief = cang.brief; gdsbs.bthno = cangdtl.bthno; gdsbs.dbtcrt = '1'; gdsbs.empid = LoginInfo.Usrid; gdsbs.fscprdid = fscprdid; gdsbs.gdsid = cangdtl.gdsid; gdsbs.gdstype = cangdtl.gdstype; gdsbs.prvid = cang.prvid; gdsbs.qty = cangdtl.qty; gdsbs.savdptid = cang.savdptid; gdsbs.srcbllno = cang.wmsno; gdsbs.srcrcdidx = cangdtl.rcdidx; gdsbs.vlddat = cangdtl.vlddat; lstgdsbs.Add(gdsbs); #region 统计帐表数据更新 wms_cangwei cw = GetCangWei(cangdtl.barcode); if (cw == null) { return(RNoData("N0218", gdsbs.gdsid)); } #region 修改仓位有货标记 /*try //周熙写了触发器,说不用改这个了 * { * cw.kcflg = WMSConst.KC_FLG_HASQTY; //修改仓位有无库存,有为1,没有为0; * cw.tpflg = GetN(); * WmsDc.SubmitChanges(); * } * catch (Exception ex) * { * }*/ #endregion var qrycwgdsbs = from e in WmsDc.wms_cwgdsbs where e.barcode == gdsbs.barcode.Trim() //&& e.bcd == gdsbs.bcd //&& e.bthno == gdsbs.bthno && e.gdsid == gdsbs.gdsid.Trim() && e.gdstype == gdsbs.gdstype.Trim() && e.bthno == gdsbs.bthno && e.vlddat == gdsbs.vlddat //&& e.prvid == gdsbs.prvid && e.qu == cw.qu.Trim() select e; var arrqrycwgdsbs = qrycwgdsbs.ToArray(); //如果统计帐表里面没有就增加一条记录 if (arrqrycwgdsbs.Length <= 0) { wms_cwgdsbs cwgdsbs = new wms_cwgdsbs(); cwgdsbs.barcode = gdsbs.barcode; cwgdsbs.bcd = gdsbs.bcd; cwgdsbs.gdsid = gdsbs.gdsid; cwgdsbs.qty = gdsbs.qty; cwgdsbs.gdstype = gdsbs.gdstype; cwgdsbs.prvid = gdsbs.prvid; cwgdsbs.qu = cw.qu; cwgdsbs.savdptid = gdsbs.savdptid; cwgdsbs.bthno = gdsbs.bthno == null ? "1" : gdsbs.bthno; cwgdsbs.vlddat = gdsbs.vlddat == null?GetCurrentDay() : gdsbs.vlddat; WmsDc.wms_cwgdsbs.InsertOnSubmit(cwgdsbs); WmsDc.SubmitChanges(); } else //如果有的话就修改统计帐表的信息 { wms_cwgdsbs cwgdsbs = arrqrycwgdsbs[0]; cwgdsbs.qty += gdsbs.qty; WmsDc.SubmitChanges(); } #endregion //WmsDc.SubmitChanges(); } //WmsDc.wms_gdsbs.InsertAllOnSubmit(lstgdsbs); #endregion #region 修改审核标记 cang.chkflg = GetY(); cang.ckr = LoginInfo.Usrid; cang.chkdat = DateTime.Now.ToString("yyyyMMddHHmmss"); #endregion WmsDc.SubmitChanges(); return(RSucc("上架单审核成功!", null, "S0197")); }