Exemplo n.º 1
0
        public async Task <KgmApiResultEntity> TempScanFinish(FinishTempScanDto dto)
        {
            SearchCondition search = new SearchCondition();

            search.AddCondition("F_EnCode", dto.CMCWHCode, SqlOperator.Equal);
            var warehouse = BLLFactory <Mst_Warehouse> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty));

            search = new SearchCondition();
            search.AddCondition("F_EnCode", dto.CMPosCode, SqlOperator.Equal);
            var position = BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty));

            dto.CMCWHCode = warehouse == null ? "" : warehouse.F_Id;
            dto.CMPosCode = position == null ? "" : position.F_Id;
            KgmApiResultEntity result = new KgmApiResultEntity();

            result.result = true;
            return(await Task.Run(() =>
            {
                var dt = BLLFactory <AppCommon> .Instance.TempScanFinish(dto);
                if (Convert.ToInt32(dt.Rows[0][0]) == 0)
                {
                    result.result = false;
                }
                result.message = result.result == true ? "操作成功" : dt.Rows[0][1].ToString();

                return result;
            }));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 删除单据
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public KgmApiResultEntity DeleteOrder(string ID)
        {
            List <SmartDbParameter> paramList = new List <SmartDbParameter>();

            paramList.Add(CreateInSmartDbParameter("ID", DbType.String, ID));
            KgmApiResultEntity entity = new KgmApiResultEntity();

            return(entity);
        }
Exemplo n.º 3
0
        public async Task <KgmApiResultEntity> LoginSystem([FromBody] LoginSystemModel loginModel)
        {
            if (string.IsNullOrEmpty(loginModel.Password))
            {
                loginModel.Password = string.Empty;
            }
            KgmApiResultEntity result = await loginSystemAsync(loginModel);

            return(result);
        }
Exemplo n.º 4
0
        public async Task <KgmApiResultEntity> GetCurrentUserMenu()
        {
            return(await Task.Run(() =>
            {
                KgmApiResultEntity result = new KgmApiResultEntity();
                result.result = true;
                result.message = JsonAppHelper.ToJson(BLLFactory <Sys_RoleAuthorize> .Instance.GetUserMenu(currentUserId));

                return result;
            }));
        }
Exemplo n.º 5
0
 public async Task <KgmApiResultEntity> GetScanCyList(string orderNo, string orderType)
 {
     return(await Task.Run(() =>
     {
         KgmApiResultEntity resultEntity = new KgmApiResultEntity()
         {
             result = true,
             message = JsonAppHelper.ToJson(BLLFactory <AppCommon> .Instance.GetScanCyList(orderNo, orderType))
         };
         return resultEntity;
     }));
 }
Exemplo n.º 6
0
        ///// 获取审核状态
        ///// </summary>
        ///// <param name="KeyValue"></param>
        ///// <returns></returns>
        //public string StatusSate(string KeyValue)
        //{
        //    SO_HeadInfo soHeadInfo = BLLFactory<SO_Head>.Instance.FindByID(KeyValue);
        //    if (soHeadInfo.F_Status == "True")
        //    {
        //        return "该产品还没审核";
        //    }
        //    else
        //    {
        //        return "产品已审核";
        //    }

        //}
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public KgmApiResultEntity DeleteById(string Id)
        {
            Hashtable ht = new Hashtable();

            ht.Add("@Id", Id);
            DataSet            ds     = base.ExecuteDataSetByProc("DELETE_SO", ht);
            KgmApiResultEntity result = new KgmApiResultEntity
            {
                result  = ds.Tables[0].Rows[0][0].ToString() == "0" ? true : false,
                message = ds.Tables[0].Rows[0][1].ToString()
            };

            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="user"></param>
        /// <param name="orderType"></param>
        /// <returns></returns>
        public KgmApiResultEntity Verify(string Id, string user, int orderType)
        {
            Hashtable ht = new Hashtable();

            ht.Add("@Id", Id);
            ht.Add("@@USERNAME", user);
            ht.Add("@ORDERTYPE", orderType);
            DataSet            ds     = base.ExecuteDataSetByProc("[VERIFYLIST_SO]", ht);
            KgmApiResultEntity result = new KgmApiResultEntity
            {
                result  = ds.Tables[0].Rows[0][0].ToString() == "0" ? true : false,
                message = ds.Tables[0].Rows[0][1].ToString()
            };

            return(result);
        }
Exemplo n.º 8
0
        public async Task <KgmApiResultEntity> TempScanFinish(FinishTempScanDto dto)
        {
            KgmApiResultEntity result = new KgmApiResultEntity();

            result.result = true;
            return(await Task.Run(() =>
            {
                var dt = BLLFactory <AppCommon> .Instance.TempScanFinish(dto);
                if (Convert.ToInt32(dt.Rows[0][0]) == 0)
                {
                    result.result = false;
                }

                result.message = dt.Rows[0][1].ToString();
                return result;
            }));
        }
Exemplo n.º 9
0
        public async Task <string> GetCurrentUser(LoginModel model)
        {
            KgmApiResultEntity result    = new KgmApiResultEntity();//返回对象
            SearchCondition    condition = new SearchCondition();

            condition.AddCondition("F_Account", model.Account, SqlOperator.Equal);
            Sys_UserInfo loginResult = BLLFactory <Sys_User> .Instance.FindSingle(condition.BuildConditionSql().Replace(" Where (1=1)  AND", string.Empty));

            if (loginResult == null)
            {
                result.result  = false;
                result.message = "用户名不存在!";
            }
            else if (!loginResult.F_UserPassword.Equals(DESEncrypt.Encrypt(model.Password)))
            {
                result.result  = false;
                result.message = "用户名与密码不匹配!";
            }
            else
            {
                bool isadmin = false;
                if (loginResult.F_EnabledMark == false)
                {
                    result.result  = false;
                    result.message = "该用户已被禁用,请联系管理员启用后再进行登录!";
                }
                else
                {
                    if (loginResult.F_IsAdministrator == true)
                    {
                        isadmin = true;
                    }
                    //生成token
                    var token = await JWTTokenHelper.GetTokenAsync(loginResult.F_Id, "0", isadmin);

                    var id = currentUserId;
                    result.result  = true;
                    result.message = token;
                }
            }


            return(JsonAppHelper.ToJson(new { status = result.result, token = result.message, User = loginResult }));
        }
Exemplo n.º 10
0
 public async Task <string> GetModuleTree()
 {
     return(await Task.Run(() =>
     {
         SearchCondition search = new SearchCondition();
         search.AddCondition("F_IsApp", true, SqlOperator.Equal);
         KgmApiResultEntity result = new KgmApiResultEntity();
         List <GetModel> getModels = new List <GetModel>();
         var moduleList = BLLFactory <Sys_Module> .Instance.Find(BuilderConditionStr(search));
         for (int i = 0; i < moduleList.Count(); i++)
         {
             GetModel model = new GetModel();
             model.icon = moduleList[i].F_Icon;
             model.src = moduleList[i].F_UrlAddress;
             model.title = moduleList[i].F_FullName;
             model.parent = "inStock";
             getModels.Add(model);
         }
         return JsonAppHelper.ToJson(new { result = true, message = getModels });
     }));
 }
Exemplo n.º 11
0
        public async Task <KgmApiResultEntity> GetWarSelectList()
        {
            return(await Task.Run(() => {
                KgmApiResultEntity result = new KgmApiResultEntity();
                List <Mst_WarehouseInfo> wList = BLLFactory <Mst_Warehouse> .Instance.GetAll();
                List <SelectModel> list = new List <SelectModel>();
                if (wList != null && wList.Count > 0)
                {
                    foreach (var item in wList)
                    {
                        SelectModel select = new SelectModel()
                        {
                            id = item.F_EnCode,
                            text = "[" + item.F_EnCode + "]" + item.F_FullName
                        };

                        list.Add(select);
                    }
                }
                result.message = JsonAppHelper.ToJson(list);
                return result;
            }));
        }
Exemplo n.º 12
0
        /// <summary>
        /// 登录系统
        /// </summary>
        /// <param name="loginModel">登录对象</param>
        /// <returns></returns>
        private async Task <KgmApiResultEntity> loginSystemAsync(LoginSystemModel loginModel)
        {
            KgmApiResultEntity result = new KgmApiResultEntity();//返回对象

            result.result  = false;
            result.message = "";

            string errorInfo = string.Empty;

            if (!bRegister(out errorInfo))
            {
                result.result  = false;
                result.message = errorInfo;
                return(result);
            }

            Sys_UserInfo loginResult;//登录对象
            bool         bAdmin = false;

            if (loginModel.Account.Equals(ConstValue.KGMADMIN_USERNAME) && loginModel.Password.Equals(ConstValue.KGMADMIN_PASSWORD))
            {
                //超级管理员
                loginResult                = new Sys_UserInfo();
                loginResult.F_Id           = ConstValue.KGMADMIN_USERID;
                loginResult.F_UserPassword = ConstValue.KGMADMIN_PASSWORD;
                loginResult.F_RealName     = ConstValue.KGMADMIN_USERNAME;
                bAdmin = true;
            }
            else
            {
                SearchCondition condition = new SearchCondition();
                condition.AddCondition("F_Account", loginModel.Account, SqlOperator.Equal);
                loginResult = BLLFactory <Sys_User> .Instance.FindSingle(condition.BuildConditionSql().Replace(" Where (1=1)  AND", string.Empty));
            }


            if (loginResult == null)
            {
                SaveLoginLog(loginModel.Account, string.Empty, loginModel.LoginSystem.ToString(), false, "用户名不存在!");
                result.result  = false;
                result.message = "用户名不存在!";
            }
            else if (!loginResult.F_UserPassword.Equals(DESEncrypt.Encrypt(loginModel.Password)))
            {
                SaveLoginLog(loginModel.Account, string.Empty, loginModel.LoginSystem.ToString(), false, "用户名与密码不匹配!");
                result.result  = false;
                result.message = "用户名与密码不匹配!";
            }
            else
            {
                string token = "";    //token
                //生成token
                token = await JWTTokenHelper.GetTokenAsync(loginResult.F_Id, loginModel.LoginSystem, bAdmin);

                SaveLoginLog(loginResult.F_Account, loginResult.F_NickName, loginModel.LoginSystem.ToString(), true, "登录成功");
                result.result  = true;
                result.message = token;
            }

            return(result);
        }
Exemplo n.º 13
0
        ///// <summary>
        /////审核单据
        ///// </summary>

        ///// <param name="Id">审核单据</param>
        ///// <param name="user">审核人</param>
        //public string Audit(string Id, string user)
        //{

        //    using (DbTransactionScope<SO_HeadInfo> dbtran = base.CreateTransactionScope())
        //    {
        //        DateTime time = DateTime.Now;
        //        try
        //        {
        //            SO_HeadInfo info = BLLFactory<SO_Head>.Instance.FindByID(Id);
        //            if (info.F_Status == "True") return "单据已审核出库";
        //            //根据单据找到需要出库的产品
        //            SearchCondition search = new SearchCondition();
        //            search.AddCondition("F_Hid", Id, SqlOperator.Equal);
        //            List<SO_BodyInfo> BodyInfo = BLLFactory<SO_Body>.Instance.Find(search.BuildConditionSql().Replace("Where (1=1)  AND ", string.Empty).Replace("Where (1=1)", " ( 1 = 1 ) "));
        //           //获取单据
        //            SO_HeadInfo HeadInfo = BLLFactory<SO_Head>.Instance.FindByID(Id);
        //            //循环出库,添加记录
        //            List<Sys_StockInfo> list = BLLFactory<Sys_Stock>.Instance.GetAll();
        //            List<Sys_OutRecordsInfo> OutList = new List<Sys_OutRecordsInfo>();
        //            List<Sys_StockHistoryInfo> StockHisList = new List<Sys_StockHistoryInfo>();
        //            //客户Id
        //            string CustomerId = BLLFactory<SO_Head>.Instance.FindByID(Id).F_CustomerId;
        //            foreach (var item in BodyInfo)
        //            {
        //                Sys_StockInfo stockInfo = list.Find(u => u.F_CargoPositionId == item.F_CargoPositionId && u.F_WarehouseId == item.F_WarehouseId && u.F_GoodsId == item.F_GoodsId);

        //                if (stockInfo.F_Number - item.F_OutStockNum < 0)
        //                {
        //                    return "产品数量发生了变化,请重新选择审核出库";
        //                }

        //                Hashtable has = new Hashtable();
        //                has.Add("F_Number", stockInfo.F_Number - item.F_OutStockNum);
        //                Sys_Stock.Instance.Update(stockInfo.F_Id, has, dbtran.Transaction);
        //                //产品出库记录
        //                Sys_OutRecordsInfo outInfo = new Sys_OutRecordsInfo();
        //                outInfo.F_Batch = info.F_EnCode;
        //                outInfo.F_GoodsId = item.F_GoodsId;
        //                outInfo.F_GoodsName = item.F_GoodsName;
        //                outInfo.F_EnCode = item.F_EnCode;
        //                outInfo.F_OutStockNum =item.F_OutStockNum;
        //                outInfo.F_CargoPositionId = item.F_CargoPositionId;
        //                outInfo.F_CargoPositionName = item.F_CargoPositionName;
        //                outInfo.F_WarehouseId = item.F_WarehouseId;
        //                outIn[';'' arehouseName = item.F_WarehouseName;
        //                outInfo.F_CreatorTime = DateTime.Now;
        //                outInfo.F_CreatorUserId = item.F_CreatorUserId;
        //                outInfo.F_Description = item.F_Description;
        //                outInfo.F_CustomerId = CustomerId;
        //                outInfo.F_Unit = item.F_Unit;
        //                outInfo.F_Address = info.F_Address;
        //                outInfo.F_Contacts = info.F_Contacts;

        //                outInfo.F_Operator = info.F_Operator;
        //                outInfo.F_CustomerName = info.F_CustomerName;
        //                outInfo.F_TelePhone = info.F_TelePhone;


        //                OutList.Add(outInfo);
        //                //添加库存信息
        //                Sys_StockHistoryInfo7 HistoryInfo = new Sys_StockHistoryInfo();
        //                HistoryInfo.F_CargoPositionId = item.F_CargoPositionId;
        //                HistoryInfo.F_CargoPositionName = item.F_CargoPositionName;
        //                HistoryInfo.F_WarehouseId = item.F_WarehouseId;
        //                HistoryInfo.F_WarehouseName = item.F_WarehouseName;
        //                HistoryInfo.F_EnCode= info.F_EnCode;
        //                HistoryInfo.F_Batch =item.F_Batch;
        //                HistoryInfo.F_BllCategory = "出库";
        //                HistoryInfo.F_OperationNum = 0 - item.F_OutStockNum;
        //                HistoryInfo.F_SpecifModel = item.F_SpecifModel;
        //                HistoryInfo.F_Vendor = user;
        //                HistoryInfo.F_GoodsId = item.F_GoodsId;
        //                HistoryInfo.F_GoodsName = item.F_GoodsName;
        //                HistoryInfo.F_Unit = item.F_Unit;
        //                HistoryInfo.F_VendorName = info.F_CustomerName;
        //                HistoryInfo.F_Contacts = info.F_Contacts;
        //                HistoryInfo.F_TelePhone = info.F_TelePhone;
        //                HistoryInfo.F_Maker = info.F_CreatorUserId;
        //                HistoryInfo.F_Verify = user;
        //                HistoryInfo.F_VeriDate = time;

        //                StockHisList.Add(HistoryInfo);
        //            }
        //            //添加出库记录
        //            Sys_OutRecords.Instance.InsertRange(OutList, dbtran.Transaction);
        //            //添加库存记录
        //            Sys_StockHistory.Instance.InsertRange(StockHisList, dbtran.Transaction);
        //            //审核单据
        //            Hashtable hash = new Hashtable();
        //            hash.Add("F_Status", 1);
        //            hash.Add("F_AuditingUser", user);
        //            hash.Add("F_VeriDate", time);
        //            SO_Head.Instance.Update(Id, hash, dbtran.Transaction);

        //            dbtran.Commit();
        //            return "审核出库成功";
        //        }
        //        catch (Exception)
        //        {

        //            dbtran.RollBack();
        //            throw;
        //        }
        //    }
        //}


        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        public KgmApiResultEntity  Save(DataSet ds)
        {
            Hashtable ht = new Hashtable();

            ht.Add("@PARM_SAVELIST_DP_HEAD", ds.Tables[0]);
            ht.Add("@PARM_SAVELIST_DP_BODY", ds.Tables[1]);
            ds = base.ExecuteDataSetByProc("SAVELIST_SO", ht);
            KgmApiResultEntity result = new KgmApiResultEntity
            {
                result  = ds.Tables[0].Rows[0][0].ToString() == "0" ? true : false,
                message = ds.Tables[0].Rows[0][1].ToString()
            };

            return(result);

            //using (DbTransactionScope<SO_HeadInfo> dbtran = base.CreateTransactionScope())
            //{
            //    try
            //    {
            //        if (string.IsNullOrEmpty(info.F_EnCode))
            //        {
            //            string orderNo = "OT" + DateTime.Now.ToString("yyyyMMdd");
            //            Hashtable hash = new Hashtable();
            //            hash.Add("Prefix", orderNo);
            //            DataTable dt = base.StorePorcToDataTable("SYS_CREATESN", hash, null, dbtran.Transaction);
            //            string SN = dt.Rows[0][0].ToString().PadLeft(6, '0');
            //            info.F_EnCode = orderNo + SN;
            //        }
            //        else
            //        {
            //            //判断当前单据是否已经审核
            //            var head = this.FindByID(info.F_Id, dbtran.Transaction);
            //            if (head != null && head.F_Status == "True")
            //            {
            //                throw new ApplicationException("单据已经审核!");
            //            }
            //        }
            //        //添加主表
            //        info.F_Date = info.F_Date;
            //        SO_Head.Instance.InsertUpdate(info, info.F_Id, dbtran.Transaction);
            //        //删除子表
            //        SearchCondition condition = new SearchCondition();
            //        condition.AddCondition("F_HId", info.F_Id, SqlOperator.Equal);
            //        SO_Body.Instance.DeleteByCondition(condition.BuildConditionSql().Replace("Where (1=1)  AND ", string.Empty), dbtran.Transaction);
            //        //循环添加子表
            //        foreach (SO_BodyInfo item in dInfo)
            //        {
            //            item.F_CreatorTime = DateTime.Now;
            //            item.F_CreatorUserId = info.F_CreatorUserId;
            //            item.F_Id = Guid.NewGuid().ToString();
            //            item.F_HId = info.F_Id;
            //            item.F_GoodsName = BLLFactory<Mst_Goods>.Instance.FindByID(item.F_GoodsId).F_FullName;
            //        }

            //        SO_Body.Instance.InsertRange(dInfo, dbtran.Transaction);
            //        dbtran.Commit();

            //        return info;
            //    }
            //    catch (Exception ex)
            //    {
            //        dbtran.RollBack();
            //        throw ex;
            //    }
        }
Exemplo n.º 14
0
        public async Task <KgmApiResultEntity> SaveTempScan([FromBody] SaveTempScanModel dto)
        {
            string[]           str    = dto.Barcode.Split('|');
            KgmApiResultEntity result = new KgmApiResultEntity();
            SearchCondition    search = new SearchCondition();

            search.AddCondition("F_EnCode", dto.Warehouse, SqlOperator.Equal);



            var warehouse = BLLFactory <Mst_Warehouse> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty));

            if (warehouse == null)
            {
                result.result  = false;
                result.message = "仓库编码错误";
                return(result);
            }
            ;
            dto.Warehouse = warehouse.F_Id;
            search        = new SearchCondition();
            search.AddCondition("F_EnCode", str[0], SqlOperator.Equal);
            search = new SearchCondition();
            search.AddCondition("F_EnCode", dto.Position, SqlOperator.Equal);
            var position = BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty));

            if (position == null)
            {
                result.result  = false;
                result.message = "货位编码错误";
                return(result);
            }
            dto.Position = position.F_Id;
            if (!String.IsNullOrEmpty(dto.DesPosition))
            {
                search = new SearchCondition();
                search.AddCondition("F_EnCode", dto.DesPosition, SqlOperator.Equal);
                var DesPosition = BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty));

                if (DesPosition == null)
                {
                    result.result  = false;
                    result.message = "目标仓库编码错误";


                    return(result);
                }
            }
            if (!string.IsNullOrEmpty(dto.DesWarehouse))
            {
                search = new SearchCondition();
                search.AddCondition("F_EnCode", dto.DesWarehouse, SqlOperator.Equal);
                var DesWarehouse = BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty));

                if (DesWarehouse == null)
                {
                    result.result  = false;
                    result.message = "目标货位编码错误";
                    return(result);
                }
            }

            result.result = true;
            return(await Task.Run(() =>
            {
                var dt = BLLFactory <AppCommon> .Instance.SaveTempScan(dto);
                if (!string.IsNullOrEmpty(dt.Rows[0][0].ToString()))
                {
                    result.result = false;
                }

                result.message = result.result == true ? "操作成功" : dt.Rows[0][0].ToString();
                if (dto.DeleteMark)
                {
                    result.message = result.result == true ? "删除成功" : dt.Rows[0][0].ToString();
                }
                return result;
            }));
        }
Exemplo n.º 15
0
        public async Task <KgmApiResultEntity> GetBoolPostion(string orderNo, string orderType, string PositionCode)
        {
            return(await Task.Run(() =>
            {
                KgmApiResultEntity entity = new KgmApiResultEntity()
                {
                    result = true
                };
                SearchCondition search = new SearchCondition();
                search.AddCondition("F_EnCode", orderNo, SqlOperator.Equal);
                switch (orderType.ToUpper())
                {
                case "PI":
                    var PIdata = BLLFactory <PI_Head> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty));
                    search = new SearchCondition();
                    search.AddCondition("F_EnCode", PositionCode, SqlOperator.Equal);
                    search.AddCondition("F_WarehouseId", PIdata.F_WarehouseId, SqlOperator.Equal);
                    if (BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)) == null)
                    {
                        var warehouse = BLLFactory <Mst_Warehouse> .Instance.FindByID(PIdata.F_WarehouseId);
                        entity.result = false;
                        entity.message = "货位编码错误或货位不属于仓库" + warehouse.F_Id;
                        return entity;
                    }
                    break;

                case "SO":
                    var SOdata = BLLFactory <SO_Head> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty));
                    search = new SearchCondition();
                    search.AddCondition("F_EnCode", PositionCode, SqlOperator.Equal);
                    search.AddCondition("F_WarehouseId", SOdata.F_WarehouseId, SqlOperator.Equal);
                    if (BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)) == null)
                    {
                        var warehouse = BLLFactory <Mst_Warehouse> .Instance.FindByID(SOdata.F_WarehouseId);
                        entity.result = false;
                        entity.message = "货位编码错误或货位不属于仓库" + warehouse.F_Id;
                        return entity;
                    }
                    break;

                case "CW":
                    var CWdata = BLLFactory <SO_Head> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty));
                    search = new SearchCondition();
                    search.AddCondition("F_EnCode", PositionCode, SqlOperator.Equal);
                    search.AddCondition("F_WarehouseId", CWdata.F_WarehouseId, SqlOperator.Equal);
                    if (BLLFactory <Mst_CargoPosition> .Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)) == null)
                    {
                        var warehouse = BLLFactory <Mst_Warehouse> .Instance.FindByID(CWdata.F_WarehouseId);
                        entity.result = false;
                        entity.message = "货位编码错误或货位不属于仓库" + warehouse.F_Id;
                        return entity;
                    }
                    break;
                    //case "MP":
                    //    var CWdata = BLLFactory<SO_Head>.Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty));
                    //    search = new SearchCondition();
                    //    search.AddCondition("F_EnCode", PositionCode, SqlOperator.Equal);
                    //    search.AddCondition("F_WarehouseId", CWdata.F_WarehouseId, SqlOperator.Equal);
                    //    if (BLLFactory<Mst_CargoPosition>.Instance.FindSingle(search.BuildConditionSql().Replace("Where", string.Empty)) == null)
                    //    {
                    //        var warehouse = BLLFactory<Mst_Warehouse>.Instance.FindByID(CWdata.F_WarehouseId);
                    //        entity.result = false;
                    //        entity.message = "货位编码错误或货位不属于仓库" + warehouse.F_Id;
                    //        return entity;
                    //    }
                    //    break;
                }

                return entity;
            }));
        }
Exemplo n.º 16
0
        public async Task <KgmApiResultEntity> GetList([FromBody] SearchModel model)
        {
            return(await Task.Run(() =>
            {
                KgmApiResultEntity result = new KgmApiResultEntity();
                var message = string.Empty;
                if (string.IsNullOrEmpty(model.orderNo))
                {
                    result.result = false;
                    result.message = "未获取到单据号";
                    return result;
                }
                var user = BLLFactory <Sys_User> .Instance.FindByID(model.UserId);
                SearchCondition search = new SearchCondition();
                search.AddCondition("F_EnCode", model.orderNo, SqlOperator.Equal);
                switch (model.orderType.ToLower())
                {
                case "pi":
                    PI_HeadInfo PIhead = BLLFactory <PI_Head> .Instance.FindSingle(BuilderConditionStr(search));
                    var warehosue = BLLFactory <Mst_Warehouse> .Instance.FindByID(PIhead.F_WarehouseId);
                    if (PIhead == null)
                    {
                        result.result = false;
                        result.message = "未获取到单据信息,请输入正确的单据号!";
                        return result;
                    }
                    if (PIhead.F_Status == 0)
                    {
                        result.result = false;
                        result.message = "单据未审核,请先审核!";
                        return result;
                    }
                    if (PIhead.F_Status > 1)
                    {
                        result.result = false;
                        result.message = "单据已经完成,不允许扫描!";
                        return result;
                    }
                    if (user.F_IsAdministrator == false && PIhead.F_WarehouseId != user.F_WarehouseId)
                    {
                        result.result = false;
                        result.message = "用户" + user.F_FullName + "不允许操作仓库为" + warehosue.F_FullName + "的数据";
                        return result;
                    }
                    else
                    {
                        search = new SearchCondition();
                        search.AddCondition("F_Hid", PIhead.F_Id, SqlOperator.Equal);
                        var data = BLLFactory <PI_Body> .Instance.Find(BuilderConditionStr(search));
                        if (data != null && data.Count > 0)
                        {
                            foreach (var item in data)
                            {
                                //  var position = BLLFactory<Mst_CargoPosition>.Instance.FindByID(item.F_CargoPositionId);
                                var goods = BLLFactory <Mst_Goods> .Instance.FindByID(item.F_GoodsId);

                                item.F_WarehouseName = warehosue == null ? "" : warehosue.F_FullName;
                                item.F_WarehouseCode = warehosue == null ? "" : warehosue.F_EnCode;
                                //item.F_CargoPositionName = position == null ? "" : position.F_FullName;
                                //item.F_CargoPositionCode = position == null ? "" : position.F_EnCode;
                                item.F_GoodsId = goods == null ? "" : goods.F_FullName;
                                item.F_BarCode = goods == null ? "|" : goods.F_EnCode + "|";
                                item.F_QTY = item.F_InStockNum;
                            }
                        }
                        result.result = true;
                        result.message = JsonAppHelper.ToJson(data);
                    }

                    break;

                case "so":

                    SO_HeadInfo SOhead = BLLFactory <SO_Head> .Instance.FindSingle(BuilderConditionStr(search));
                    var SOwarehosue = BLLFactory <Mst_Warehouse> .Instance.FindByID(SOhead.F_WarehouseId);
                    if (SOhead == null)
                    {
                        result.result = false;
                        result.message = "未获取到单据信息,请输入正确的单据号!";
                        return result;
                        // return JsonAppHelper.ToJson(new { result = false, message = "未获取到单据信息,请输入正确的单据号!" });
                    }
                    if (int.Parse(SOhead.F_Status) == 0)
                    {
                        result.result = false;
                        result.message = "未审核,请先审核!";
                        return result;
                        // return JsonAppHelper.ToJson(new { result = false, message = "单据未审核,请先审核!" });
                    }
                    if (int.Parse(SOhead.F_Status) > 1)
                    {
                        result.result = false;
                        result.message = "单据已经完成,不允许扫描!";
                        return result;
                        // return JsonAppHelper.ToJson(new { result = false, message = "单据已经完成,不允许扫描!" });
                    }
                    if (user.F_IsAdministrator == false && SOhead.F_WarehouseId != user.F_WarehouseId)
                    {
                        result.result = false;
                        result.message = "用户" + user.F_FullName + "不允许操作仓库为" + SOwarehosue.F_FullName + "的数据";
                        return result;
                    }
                    else
                    {
                        search = new SearchCondition();
                        search.AddCondition("F_Hid", SOhead.F_Id, SqlOperator.Equal);


                        var data = BLLFactory <SO_Body> .Instance.Find(BuilderConditionStr(search));
                        if (data != null && data.Count > 0)
                        {
                            foreach (var item in data)
                            {
                                // var position = BLLFactory<Mst_CargoPosition>.Instance.FindByID(item.F_CargoPositionId);
                                var goods = BLLFactory <Mst_Goods> .Instance.FindByID(item.F_GoodsId);
                                item.F_WarehouseName = SOwarehosue == null ? "" : SOwarehosue.F_FullName;
                                item.F_WarehouseCode = SOwarehosue == null ? "" : SOwarehosue.F_EnCode;
                                //item.F_CargoPositionName = position == null ? "" : position.F_FullName;
                                //item.F_CargoPositionCode = position == null ? "" : position.F_EnCode;
                                item.F_GoodsId = goods == null ? "" : goods.F_FullName;
                                item.F_BarCode = goods == null ? "|" : goods.F_EnCode + "|" + item.F_Batch;
                                item.F_QTY = item.F_OutStockNum;
                            }
                        }
                        result.result = true;
                        result.message = JsonAppHelper.ToJson(data);
                    }
                    break;

                case "cw":
                    SO_StockMakeHeadInfo CWhead = BLLFactory <SO_StockMakeHead> .Instance.FindSingle(BuilderConditionStr(search));
                    var Cwwarehosue = BLLFactory <Mst_Warehouse> .Instance.FindByID(CWhead.F_WarehouseId);
                    if (CWhead == null)
                    {
                        result.result = false;
                        result.message = "未获取到单据信息,请输入正确的单据号!";
                        return result;
                        //  return JsonAppHelper.ToJson(new { result = false, message = "未获取到单据信息,请输入正确的单据号!" });
                    }
                    if (CWhead.F_Status == 0)
                    {
                        result.result = false;
                        result.message = "单据未审核,请先审核!";
                        return result;
                        //return JsonAppHelper.ToJson(new { result = false, message = "单据未审核,请先审核!" });
                    }
                    if (CWhead.F_Status > 1)
                    {
                        result.result = false;
                        result.message = "单据已经完成,不允许扫描!";
                        return result;
                        //return JsonAppHelper.ToJson(new { result = false, message = "单据已经完成,不允许扫描!" });
                    }
                    if (user.F_IsAdministrator == false && CWhead.F_WarehouseId != user.F_WarehouseId)
                    {
                        result.result = false;
                        result.message = "用户" + user.F_FullName + "不允许操作仓库为" + Cwwarehosue.F_FullName + "的数据";
                        return result;
                    }
                    else
                    {
                        search = new SearchCondition();
                        search.AddCondition("F_Hid", CWhead.F_Id, SqlOperator.Equal);



                        var data = BLLFactory <SO_StockMakeBody> .Instance.Find(BuilderConditionStr(search));
                        if (data != null && data.Count > 0)
                        {
                            foreach (var item in data)
                            {
                                var position = BLLFactory <Mst_CargoPosition> .Instance.FindByID(item.F_CargoPositionId);
                                var goods = BLLFactory <Mst_Goods> .Instance.FindByID(item.F_GoodsId);

                                item.F_WarehouseName = Cwwarehosue == null ? "" : Cwwarehosue.F_FullName;
                                item.F_WarehouseCode = Cwwarehosue == null ? "" : Cwwarehosue.F_EnCode;
                                item.F_CargoPositionName = position == null ? "" : position.F_FullName;
                                item.F_CargoPositionCode = position == null ? "" : position.F_EnCode;
                                item.F_GoodsId = goods == null ? "" : goods.F_FullName;
                                item.F_BarCode = goods == null ? "|" : goods.F_EnCode + "|" + item.F_Batch;
                                item.F_QTY = int.Parse(item.F_RealNumber);
                            }
                        }
                        result.result = true;

                        result.message = JsonAppHelper.ToJson(data);
                    }
                    break;

                default:
                    result.message = "[]";
                    break;
                }
                return result;
                //return JsonAppHelper.ToJson(new { result = t, message = "单据未审核,请先审核!" });
            }));
        }