Пример #1
0
        public RequestResult SmallAndMid(string scode, string mcode, string orderno = "", string pno = "", int supplierid = 0)
        {
            RequestResult result = new RequestResult();

            try
            {
                // 权限功能控制
                if ((PDAUserMsg.Param.ScanProcess == 3 || PDAUserMsg.Param.ScanProcess == 4) && PDAUserMsg.Param.IsLink && PDAUserMsg.Param.SmallPacking)
                {
                    if (TB_BMCode.GetBoolBarCode(mcode, 1))        // 中标是否存在
                    {
                        Scale       scale   = Scale.GetScaleForSmall(scode);
                        LinkRtnData RtnInfo = new LinkRtnData();

                        if (scale != null)
                        {
                            if (scale.IsLinkMid || scale.IsLinkBig)      // 是否已经关联
                            {
                                RtnInfo.BoxCode  = scale.MiddleCode;
                                RtnInfo.LinkDate = CommonFunc.GetDateTimeFromTimestamp(scale.LinkMidTime);
                                result.data      = RtnInfo;
                                result.message   = "重复关联";
                                result.success   = false;
                            }
                            else if (PDAUserMsg.Param.ScanProcess == 4 && !scale.IsInto)
                            {
                                result.message = "请先入库,再关联装箱";
                                result.success = false;
                            }
                            else
                            {
                                // 先关联模式_如果中标已入库,小标关联也随之入库
                                if (PDAUserMsg.Param.ScanProcess == 3)
                                {
                                    List <Scale> scaleMiddle = Scale.GetScaleForMiddle(mcode);

                                    if (scaleMiddle != null && scaleMiddle.Count() > 0)
                                    {
                                        Scale middle = scaleMiddle.Last();

                                        if (!scale.IsInto && middle.IsInto)
                                        {
                                            scale.IsInto      = middle.IsInto;
                                            scale.IntoOrderNo = orderno;
                                            scale.IntoTime    = CommonFunc.GetNowTimestamp();
                                            scale.IntoPDAUser = PdaUser.PUserName;
                                            scale.ProductNo   = middle.ProductNo;
                                        }
                                        else if (!middle.IsInto && scale.IsInto)
                                        {
                                            result.message = "箱标未入库,无法关联装箱";
                                            result.success = false;
                                            PDALog.Write("小标装箱", "小标", scode + "," + mcode, PdaUser.PUserName + "-" + PdaUser.PRealName, string.Format("scode:{0}, mcode:{1}, orderno:{2},supplierid:{3},pno:{4}", scode, mcode, orderno, supplierid, pno), result.message);
                                            return(result);
                                        }
                                    }
                                }

                                Scale bigFrast = Scale.GetMiddleLinkBigScale(mcode);  // 查询中标关联大标

                                scale.IsLinkMid      = true;
                                scale.MiddleCode     = mcode;
                                scale.LinkMidPDAUser = PdaUser.PUserName;
                                scale.LinkMidOrderNo = orderno;
                                if (supplierid != 0)
                                {
                                    scale.SupplierId = supplierid;
                                }
                                if (!string.IsNullOrWhiteSpace(pno))
                                {
                                    scale.ProductNo = pno;
                                }
                                scale.LinkMidTime = CommonFunc.GetNowTimestamp();
                                scale.StateID     = 2;
                                if (bigFrast != null)
                                {
                                    scale.IsLinkBig = true; scale.BigCode = bigFrast.BigCode; scale.StateID = 3; scale.LinkBigTime = CommonFunc.GetNowTimestamp();
                                }
                                scale.UpdateByID();

                                RtnInfo.BoxCode  = mcode;
                                RtnInfo.LinkDate = DateTime.Now;
                                result.data      = RtnInfo;
                                result.message   = "成功";
                                result.success   = true;
                            }
                        }
                        else
                        {
                            result.code    = 304;
                            result.message = "条码不存在";
                            result.success = false;
                        }
                    }
                    else
                    {
                        result.code    = 304;
                        result.message = "条码不存在";
                        result.success = false;
                    }
                }
                else
                {
                    result.code    = 704;
                    result.message = "此装箱功能已被禁用,请在管理后台开启。";
                    result.success = false;
                }

                PDALog.Write("小标装箱", "小标", scode + "," + mcode, PdaUser.PUserName + "-" + PdaUser.PRealName, string.Format("scode:{0}, mcode:{1}, orderno:{2},supplierid:{3},pno:{4}", scode, mcode, orderno, supplierid, pno), result.message);
            }
            catch (Exception ex)
            {
                result.code    = 500;
                result.message = "服务出错";
                result.success = false;
                DAL.Log.Instance.Write("小标关联出错:" + ex.Message, "PDA上传出错");
            }

            return(result);
        }
Пример #2
0
        public RequestResult MidAndLarge(string mcode, string lcode, string orderno = "", string pno = "", int supplierid = 0)
        {
            RequestResult result = new RequestResult();

            try
            {
                if ((PDAUserMsg.Param.ScanProcess == 3 || PDAUserMsg.Param.ScanProcess == 4) && PDAUserMsg.Param.IsLink && PDAUserMsg.Param.MiddlePacking)
                {
                    if (TB_BMCode.GetBoolBarCode(lcode, 2))                    // 大标是否存在
                    {
                        Scale       scale   = Scale.GetScaleForMiddle(mcode).FirstOrDefault();
                        LinkRtnData RtnInfo = new LinkRtnData();

                        if (scale != null)
                        {
                            if (scale.IsLinkBig)                            // 是否已经关联
                            {
                                RtnInfo.BoxCode  = scale.MiddleCode;
                                RtnInfo.LinkDate = CommonFunc.GetDateTimeFromTimestamp(scale.LinkMidTime);
                                result.data      = RtnInfo;
                                result.message   = "已关联";
                                result.success   = false;
                            }
                            else if (PDAUserMsg.Param.ScanProcess == 4 && !scale.IsInto)
                            {
                                result.message = "请先入库,再关联装箱";
                                result.success = false;
                            }
                            else
                            {
                                // 先关联模式_如果中标已入库,小标关联也随之入库,如果已入库,不再入库。
                                if (PDAUserMsg.Param.ScanProcess == 3)
                                {
                                    List <Scale> scaleBig = Scale.GetScaleForBig(lcode);
                                    if (scaleBig != null && scaleBig.Count() > 0)
                                    {
                                        Scale BigLast = scaleBig.Last();
                                        if (!scale.IsInto && BigLast.IsInto)
                                        {
                                            scale.IsInto      = BigLast.IsInto;
                                            scale.IntoOrderNo = orderno;
                                            scale.IntoTime    = CommonFunc.GetNowTimestamp();
                                            scale.IntoPDAUser = PdaUser.PUserName;
                                            scale.ProductNo   = BigLast.ProductNo;
                                        }
                                        else if (!BigLast.IsInto && scale.IsInto)
                                        {
                                            result.message = "大箱标未入库,无法关联装箱";
                                            result.success = false;
                                            PDALog.Write("中标装箱", "中标", mcode + "," + lcode, PdaUser.PUserName + "-" + PdaUser.PRealName, string.Format("mcode:{0}, lcode:{1}, orderno:{2},supplierid:{3},pno:{4}", mcode, lcode, orderno, supplierid, pno), result.message);
                                            return(result);
                                        }
                                    }
                                }

                                scale.IsLinkBig      = true;
                                scale.BigCode        = lcode;
                                scale.LinkBigPDAUser = PdaUser.PUserName;
                                scale.LinkBigOrderNo = orderno;
                                if (supplierid != 0)
                                {
                                    scale.SupplierId = supplierid;
                                }
                                if (!string.IsNullOrWhiteSpace(pno))
                                {
                                    scale.ProductNo = pno;
                                }
                                scale.LinkBigTime = CommonFunc.GetNowTimestamp();
                                scale.StateID     = 3;
                                scale.UpdateByMiddle();
                                //Scale_Big.InsertScaleBigCode(mcode);        // 关联后插入大标数据表

                                RtnInfo.BoxCode  = lcode;
                                RtnInfo.LinkDate = DateTime.Now;
                                result.data      = RtnInfo;
                                result.message   = "成功";
                                result.success   = true;
                            }
                        }
                        else
                        {
                            result.code    = 304;
                            result.message = "条码不存在";
                            result.success = false;
                        }
                    }
                    else
                    {
                        result.code    = 304;
                        result.message = "条码不存在";
                        result.success = false;
                    }
                }
                else
                {
                    result.code    = 704;
                    result.message = "此装箱功能已被禁用,请在管理后台开启。";
                    result.success = false;
                }
                PDALog.Write("中标装箱", "中标", mcode + "," + lcode, PdaUser.PUserName + "-" + PdaUser.PRealName, string.Format("mcode:{0}, lcode:{1}, orderno:{2},supplierid:{3},pno:{4}", mcode, lcode, orderno, supplierid, pno), result.message);
            }
            catch (Exception ex)
            {
                result.code    = 500;
                result.message = "服务出错";
                result.success = false;
                DAL.Log.Instance.Write("中标关联出错:" + ex.Message, "PDA上传出错");
            }

            return(result);
        }