Пример #1
0
        public JsonResult GetPO4Box(string billType, string searchValue, int page, int rows)
        {
            var boxSv = new BoxSv();
            var drSv  = new DRSv();

            List <K3POs4BoxModel> pos;
            string GetPO4Box_param = (string)Session["GetPO4Box_param"];

            if (GetPO4Box_param == null || !GetPO4Box_param.Equals(billType + ":" + searchValue))
            {
                pos = boxSv.GetPos4Box(billType, searchValue, currentUser.userId, currentUser.userName, currentAccount);
                pos = pos.OrderByDescending(p => p.po_date).Take(1000).ToList(); //最多显示1000条记录
                Session["GetPO4Box_param"] = billType + ":" + searchValue;
                Session["GetPO4Box_list"]  = pos;                                //为加快翻页速度,将数据放在session中
            }
            else
            {
                pos = (List <K3POs4BoxModel>)Session["GetPO4Box_list"];
            }
            var result = pos.OrderByDescending(p => p.po_date).Skip((page - 1) * rows).Take(rows).ToList();

            //var noFinishBox = boxSv.GetNotFinishedBoxQty(result.Select(r => new IDModel() { interId = r.po_id, entryId = r.po_entry_id }).ToList());
            foreach (var p in result)
            {
                p.id_field = p.po_id + "-" + p.po_entry_id;
                //2019-10-24 因为TDD送货平台只用来打印标签,不做送货单,所以此规则改为:可做外箱数量=po数量-平台未关联外箱数量(不记k3关联数量)
                //p.can_make_box_qty = p.po_qty - (noFinishBox.Where(f => f.poId == p.po_id && f.poEntryId == p.po_entry_id).Sum(r => r.qty) ?? 0m);
                //p.can_make_box_qty = p.po_qty - p.realte_qty - (noFinishBox.Where(f => f.poId == p.po_id && f.poEntryId == p.po_entry_id).Sum(r => r.qty) ?? 0m);
                //2019-11-19 因为有退补货的存在,所以此规则再次修改为:可做外箱数量=po数量-k3关联数量
                p.can_make_box_qty = p.po_qty - p.realte_qty;
            }

            return(Json(new { suc = true, total = pos.Count(), rows = result }));
        }
Пример #2
0
        public JsonResult GetPO4Box(string billType, string searchType, string searchValue, int page, int rows)
        {
            var boxSv = new BoxSv();
            var drSv  = new DRSv();

            List <K3POs4BoxModel> pos;
            string GetPO4Box_param = (string)Session["GetPO4Box_param"];
            string searchInfo      = string.Format("{0};{1}:{2}", billType, searchType, searchValue);

            if (GetPO4Box_param == null || !GetPO4Box_param.Equals(searchInfo))
            {
                pos = boxSv.GetPos4Box(billType, searchType, searchValue, currentUser.userId, currentUser.userName, currentAccount);
                pos = pos.OrderByDescending(p => p.po_date).Take(1000).ToList(); //最多显示1000条记录
                Session["GetPO4Box_param"] = searchInfo;
                Session["GetPO4Box_list"]  = pos;                                //为加快翻页速度,将数据放在session中
            }
            else
            {
                pos = (List <K3POs4BoxModel>)Session["GetPO4Box_list"];
            }
            var result = pos.OrderByDescending(p => p.po_number).ThenBy(p => p.po_entry_id).Skip((page - 1) * rows).Take(rows).ToList();

            var noFinishBox = boxSv.GetNotFinishedBoxQty(result.Select(r => new IDModel()
            {
                interId = r.po_id, entryId = r.po_entry_id
            }).ToList(), currentAccount);

            foreach (var p in result)
            {
                p.id_field         = p.po_id + "-" + p.po_entry_id;
                p.can_make_box_qty = p.po_qty - p.realte_qty - (noFinishBox.Where(f => f.poId == p.po_id && f.poEntryId == p.po_entry_id).Sum(r => r.qty) ?? 0m);
            }

            return(Json(new { suc = true, total = pos.Count(), rows = result }));
        }
Пример #3
0
        public JsonResult SaveInnerBoxWithExtra(FormCollection fc)
        {
            InnerBoxesExtra extra = new InnerBoxesExtra();

            MyUtils.SetFieldValueToModel(fc, extra);

            if (string.IsNullOrEmpty(extra.item_number))
            {
                return(Json(new SRM(false, "请先选择物料信息后再保存")));
            }

            try {
                extra.create_date = DateTime.Now;
                extra.user_name   = currentUser.userName;
                int     packNum  = Int32.Parse(fc.Get("pack_num"));
                decimal everyQty = decimal.Parse(fc.Get("every_qty"));

                string innerBoxNumber = new BoxSv().SaveInnerBoxWithExtra(extra, packNum, everyQty);
                WLog("保存Extra内箱", "箱号:" + innerBoxNumber);
            }
            catch (Exception ex) {
                return(Json(new SRM(ex)));
            }
            return(Json(new SRM()));
        }
Пример #4
0
 public JsonResult SplitInnerBoxWithExtra(int innerBoxId, int splitNum)
 {
     try {
         var result = new BoxSv().SplitInnerBoxesWithExtra(innerBoxId, splitNum);
         WLog("拆分内箱Extra", string.Format("{0}-->{1};{2}", result[0], result[1], result[2]));
         return(Json(new SRM()));
     }
     catch (Exception ex) {
         return(Json(new SRM(ex)));
     }
 }
Пример #5
0
        public JsonResult GetInnerBoxExtraBefore(string itemNumber)
        {
            var extra = new BoxSv().GetInnerBoxExtraBefore(currentUser.userName, itemNumber);

            if (extra == null)
            {
                return(Json(new SRM(false)));
            }
            extra.account = currentAccount;
            return(Json(new { suc = true, boxInfo = extra }));
        }
Пример #6
0
 public JsonResult SplitOuterBox(int outerBoxId, int splitNum)
 {
     try {
         string[] boxArr = new BoxSv().SplitOuterbox(outerBoxId, splitNum);
         WLog("拆分外箱", string.Format("外箱箱号为【{0}】拆分为【{1}】和【{2}】", boxArr[0], boxArr[1], boxArr[2]));
     }
     catch (Exception ex) {
         return(Json(new SRM(ex)));
     }
     return(Json(new SRM()));
 }
Пример #7
0
 public JsonResult RemoveInnerBox(int innerBoxId)
 {
     try {
         string boxNumber = new BoxSv().RemoveInnerBox(innerBoxId);
         WLog("删除内箱", "箱号:" + boxNumber + ";ID:" + innerBoxId);
     }
     catch (Exception ex) {
         return(Json(new SRM(ex)));
     }
     return(Json(new SRM()));
 }
Пример #8
0
 public JsonResult RemoveOuterBox(int outerBoxId)
 {
     try {
         string boxNumber = new BoxSv().RemoveOuterBox(outerBoxId);
         WLog("删除外箱", "箱号是:" + boxNumber);
     }
     catch (Exception ex) {
         return(Json(new SRM(ex)));
     }
     return(Json(new SRM()));
 }
Пример #9
0
        public JsonResult GetBoxBySupplierAndItem(string supplierNumber, string itemNumber)
        {
            var result = new BoxSv().GetBoxBySupplierAndItem(supplierNumber, itemNumber);

            if (result == null)
            {
                return(Json(new SRM(false)));
            }
            result.bill_id = 0;//2018-11-29 if not 0, the relation will be faulty
            result.account = currentAccount;
            return(Json(new { suc = true, boxInfo = result }));
        }
Пример #10
0
        public JsonResult LoadBoxDatas(string poInfo, string exceptBoxIds, string supplierNumber, int billId)
        {
            List <IDModel> idList        = JsonConvert.DeserializeObject <List <IDModel> >(poInfo);
            List <IDModel> excepteIdList = JsonConvert.DeserializeObject <List <IDModel> >(exceptBoxIds);

            try {
                var result = new BoxSv().GetOuterBoxesByPoInfo(currentAccount, supplierNumber, idList, excepteIdList, billId);
                return(Json(new { suc = true, result = result }));
            }
            catch (Exception ex) {
                return(Json(new SRM(ex)));
            }
        }
Пример #11
0
        public JsonResult SaveOuterBoxes(FormCollection fc)
        {
            OuterBoxes box = new OuterBoxes();

            MyUtils.SetFieldValueToModel(fc, box);

            if (!box.account.Equals(currentAccount))
            {
                return(Json(new SRM(false, "当前登录公司与此外箱所在公司不一致,请刷新页面后再制作箱子")));
            }

            if (box.package_date == DateTime.MinValue)
            {
                return(Json(new SRM(false, "请填写正确的包装日期")));
            }
            if (box.produce_date == DateTime.MinValue)
            {
                return(Json(new SRM(false, "请填写正确的生产日期")));
            }
            if (box.expire_date == DateTime.MinValue)
            {
                return(Json(new SRM(false, "请填写正确的有效期")));
            }

            try {
                List <OuterBoxPOs> poList = JsonConvert.DeserializeObject <List <OuterBoxPOs> >(fc.Get("poRows"));

                //关联小标签信息
                List <int> innerBoxIds = new List <int>();
                if (!string.IsNullOrEmpty(fc.Get("innerBoxIds")))
                {
                    innerBoxIds = fc.Get("innerBoxIds").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(i => Int32.Parse(i)).ToList();
                }
                else
                {
                    if (new BoxSv().GetNoRelatedInnerBox(currentUser.userName, box.item_number, box.trade_type_name, currentAccount, canCheckAll).Count() > 0)
                    {
                        return(Json(new SRM(false, string.Format("检测到型号为【{0}】的物料存在未关联的小标签,必须关联后才能保存外箱。关联路径:标签管理--->新增外箱", box.item_model))));
                    }
                }
                string boxNumber = new BoxSv().SaveOuterBox(box, poList, innerBoxIds);
                WLog("新增外箱", "保存外箱,箱号:" + boxNumber);
            }
            catch (Exception ex) {
                return(Json(new SRM(ex)));
            }

            return(Json(new SRM()));
        }
Пример #12
0
        public JsonResult SaveInnerBox(FormCollection fc)
        {
            InneBoxes ib = new InneBoxes();

            MyUtils.SetFieldValueToModel(fc, ib);

            try {
                string[] innerBox = new BoxSv().SaveInnerBox(ib);
                WLog("新增内箱", "保存内箱,箱号:" + innerBox[0]);

                return(Json(new { suc = true, msg = "内箱保存成功", boxNumber = innerBox[0], boxId = innerBox[1] }));
            }
            catch (Exception ex) {
                return(Json(new SRM(ex)));
            }
        }
Пример #13
0
        public JsonResult GetBoxNodes(FormCollection fc)
        {
            SearchBoxParams p = new SearchBoxParams();

            MyUtils.SetFieldValueToModel(fc, p);

            p.endDate  = p.endDate.AddDays(1);
            p.account  = currentAccount;
            p.itemInfo = p.itemInfo ?? "";
            p.userName = currentUser.userName;

            BoxSv sv = new BoxSv();

            if (p.id == null)
            {
                //搜索外箱信息
                try {
                    var result = sv.GetOuterBoxes(p, canCheckAll).OrderByDescending(r => r.create_date);
                    if (result.Count() < p.rows && p.page > 1)
                    {
                        p.page = 1;                                                               //应该是当前easyui的bug,翻页后,比如在第二页以后的页码中搜索箱子,结果有1行,但是page还是搜索时候的那个页码,导致页面加载不出箱子,在这里手动将页码调为1
                    }
                    var outerBoxes    = result.Skip((p.page - 1) * p.rows).Take(p.rows).ToList(); //外箱信息
                    var obIds         = outerBoxes.Select(o => o.outer_box_id).ToList();          //所有外箱id
                    var pos           = sv.GetBoxPos(obIds);                                      //po信息
                    var boxIdHasInner = sv.HasGotInnerBox(obIds);                                 //有内箱的外箱id集合
                    var billNoInfo    = new DRSv().GetBillIdAndNo(outerBoxes.Where(o => o.bill_id != null).Select(o => (int)o.bill_id).Distinct().ToList());

                    return(Json(new { suc = true, total = result.Count(), box = outerBoxes, po = pos, boxIdHasInner = boxIdHasInner, billNoInfo = billNoInfo }));
                }
                catch (Exception ex) {
                    return(Json(new SRM(ex)));
                }
            }
            else
            {
                //展开内箱信息
                try {
                    var innerboxes = sv.GetInnerBoxes(p.id);
                    return(Json(new { suc = true, box = innerboxes }));
                }
                catch (Exception ex) {
                    return(Json(new SRM(ex)));
                }
            }
        }
Пример #14
0
        public JsonResult GetInnerBoxexExtra(FormCollection fc)
        {
            SearchInnerBoxExtraParam p = new SearchInnerBoxExtraParam();

            MyUtils.SetFieldValueToModel(fc, p);

            p.endDate        = p.endDate.AddDays(1);
            p.account        = currentAccount;
            p.itemInfo       = p.itemInfo ?? "";
            p.userName       = currentUser.userName;
            p.innerBoxNumber = p.innerBoxNumber ?? "";
            p.outerBoxNumber = p.outerBoxNumber ?? "";

            var result = new BoxSv().GetInnerBoxesExtra(p, canCheckAll);
            int total  = result.Count();

            return(Json(new { suc = true, total = total, result = result.Skip((p.page - 1) * p.rows).Take(p.rows).ToList() }));
        }