Esempio n. 1
0
        public string SaveCheckTransScanPro(int checkID, string strBarcode, string strAreaNo, string strUserJson, bool isTray)
        {
            CheckTransInfo model = new CheckTransInfo();
            string strError = string.Empty;

            try
            {
                //AreaInfo area = JSONHelper.JsonToObject<AreaInfo>(strAreaNo);

                UserInfo user = JSONHelper.JsonToObject<UserInfo>(strUserJson);
                if (user == null || string.IsNullOrEmpty(user.UserNo))
                {
                    model.Status = "E";
                    model.Message = "用户信息获取失败!";
                    return JSONHelper.ObjectToJson(model);
                }
                Area_Func func = new Area_Func();
                AreaInfo area = new AreaInfo();
                area.AreaNo = strAreaNo;
                string strErrMsg = null;
                if (!func.GetAreaByAreaNo(ref area, user, ref strErrMsg))
                {
                    throw new Exception(strErrMsg);
                }
                if (area == null || string.IsNullOrEmpty(area.AreaNo))
                {
                    model.Status = "E";
                    model.Message = "货位信息获取失败!";
                    return JSONHelper.ObjectToJson(model);
                }

                PrintBarcode.Barcode_Func bfunc = new PrintBarcode.Barcode_Func();
                model.ScanBarcode = bfunc.GetCheckBarcode(checkID, strBarcode, isTray, ref strError);
                if (model.ScanBarcode == null)
                {
                    model.Status = "E";
                    model.Message = "条码信息获取失败!" + strError;
                    return JSONHelper.ObjectToJson(model);
                }
                List<string> lstBarcode = new List<string>();
                if (isTray)
                {
                    foreach (var item in model.ScanBarcode.tray_Model.listDetails)
                    {
                        lstBarcode.AddRange(item.listBarcode);
                    }
                }
                else
                {
                    lstBarcode.Add(model.ScanBarcode.SERIALNO);
                }
                bool res = true;
                List<Barcode_Model> lstScanBar = new List<Barcode_Model>();
                foreach (var item in lstBarcode)
                {
                    Barcode_Model bar = bfunc.GetCheckBarcode(item, ref strError);
                    if (bar != null && !string.IsNullOrEmpty(bar.SERIALNO))
                        lstScanBar.Add(bar);
                }
                foreach (var item in lstScanBar)
                {
                    model = new CheckTransInfo();
                    model.CheckID = checkID;

                    model.AreaNo = area.AreaNo;
                    model.HouseNo = area.HouseNo;
                    model.WarehouseNo = area.WarehouseNo;

                    model.Operator = user.UserNo;
                    model.Barcode = item.BARCODE;
                    model.SerialNo = item.SERIALNO;
                    model.BatchNo = item.BATCHNO;
                    model.SN = item.SN;
                    model.MaterialNo = item.MATERIALNO;
                    model.MaterialDesc = item.MATERIALDESC;
                    model.ScanQty = item.QTY;
                    res = SaveCheckTrans(ref model, user, ref strError);
                    if (!res)
                        break;
                }

                if (res)
                {
                    model.Status = "S";
                    return JSONHelper.ObjectToJson(model);
                }
                else
                {
                    model.Status = "E";
                    model.Message = strError;
                    return JSONHelper.ObjectToJson(model);
                }
            }
            catch (Exception ex)
            {
                model.Status = "E";
                model.Message = "Web异常:" + ex.Message + ex.StackTrace;
                //if (Common_Func.IsOracleError(model.Message, ref strError)) model.Message = strError;
                return JSONHelper.ObjectToJson(model);
            }
        }
Esempio n. 2
0
        public string SaveCheckTransScan(int checkID, string strBarcode, string strAreaNo, string strUserJson, bool isTray)
        {
            CheckTransInfo model = new CheckTransInfo();
            string strError = string.Empty;

            try
            {
                //AreaInfo area = JSONHelper.JsonToObject<AreaInfo>(strAreaNo);

                UserInfo user = JSONHelper.JsonToObject<UserInfo>(strUserJson);
                if (user == null || string.IsNullOrEmpty(user.UserNo))
                {
                    model.Status = "E";
                    model.Message = "用户信息获取失败!";
                    return JSONHelper.ObjectToJson(model);
                }
                Area_Func func = new Area_Func();
                AreaInfo area = new AreaInfo();
                area.AreaNo = strAreaNo;
                string strErrMsg = null;
                if (!func.GetAreaByAreaNo(ref area, user, ref strErrMsg))
                {
                    throw new Exception(strErrMsg);
                }
                if (area == null || string.IsNullOrEmpty(area.AreaNo))
                {
                    model.Status = "E";
                    model.Message = "货位信息获取失败!";
                    return JSONHelper.ObjectToJson(model);
                }

                PrintBarcode.Barcode_Func bfunc = new PrintBarcode.Barcode_Func();
                model.ScanBarcode = bfunc.GetCheckBarcode(checkID, strBarcode, isTray, ref strError);
                if (model.ScanBarcode == null)
                {
                    model.Status = "E";
                    model.Message = "条码信息获取失败!" + strError;
                    return JSONHelper.ObjectToJson(model);
                }
                List<string> lstBarcode = new List<string>();
                bool res = true;
                model.CheckID = checkID;
                model.AreaNo = area.AreaNo;
                model.HouseNo = area.HouseNo;
                model.WarehouseNo = area.WarehouseNo;

                model.Operator = user.UserNo;
                model.Barcode = model.ScanBarcode.BARCODE;
                model.SerialNo = model.ScanBarcode.SERIALNO;
                model.BatchNo = model.ScanBarcode.BATCHNO;
                model.SN = model.ScanBarcode.SN;
                model.MaterialNo = model.ScanBarcode.MATERIALNO;
                model.MaterialDesc = model.ScanBarcode.MATERIALDESC;

                model.ScanQty = model.ScanBarcode.QTY;
                if (isTray)
                {
                    res = SaveCheckTransList(ref model, user, ref strError);
                }
                else
                {

                    res = SaveCheckTrans(ref model, user, ref strError);
                }

                if (res)
                {
                    model.Status = "S";
                    return JSONHelper.ObjectToJson(model);
                }
                else
                {
                    model.Status = "E";
                    model.Message = strError;
                    return JSONHelper.ObjectToJson(model);
                }
            }
            catch (Exception ex)
            {
                model.Status = "E";
                model.Message = "Web异常:" + ex.Message + ex.StackTrace;
                //if (Common_Func.IsOracleError(model.Message, ref strError)) model.Message = strError;
                return JSONHelper.ObjectToJson(model);
            }
        }