コード例 #1
0
ファイル: HandlerUpload.ashx.cs プロジェクト: dlang0214/Asset
        /// <summary>
        /// 导出盘点结果
        /// </summary>
        /// <param name="context"></param>
        private void OnExportPandianAsset(HttpContext context)
        {
            var pandianId = context.Request.QueryString["pandianId"];
            var bll       = new PandianAsset();
            var cmdText   = "and pda.PandianId = @PandianId ";
            var parm      = new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(pandianId);
            var dt = bll.GetExportData(cmdText, parm);

            HttpClientHelper.Export(context, dt);
        }
コード例 #2
0
ファイル: PdaService.cs プロジェクト: qq283335746/Asset
        public ResResultModel GetPandianAssetList(PdaPandianAssetModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, ""));
                }

                var userId = WebCommon.GetUserId();
                if (model.PageIndex < 1)
                {
                    model.PageIndex = 1;
                }
                if (model.PageSize < 10)
                {
                    model.PageSize = 10;
                }
                int totalRecord = 0;

                var pandianId = Guid.Empty;
                if (model.PandianId != null)
                {
                    Guid.TryParse(model.PandianId.ToString(), out pandianId);
                }

                var          sqlWhere = new StringBuilder(300);
                var          parms    = new ParamsHelper();
                SqlParameter parm     = null;

                sqlWhere.AppendFormat("and pda.Status = {0} ", (int)EnumPandianAssetStatus.未盘点);
                if (!pandianId.Equals(Guid.Empty))
                {
                    sqlWhere.Append("and PandianId = @PandianId ");
                    parm       = new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier);
                    parm.Value = pandianId;
                    parms.Add(parm);
                }

                var bll  = new PandianAsset();
                var list = bll.GetListByJoin(model.PageIndex, model.PageSize, out totalRecord, sqlWhere.ToString(), parms.ToArray());

                var totals = bll.GetTotal(pandianId);

                var dgData = "{\"total\":" + totalRecord + ",\"rows\":" + JsonConvert.SerializeObject(list) + ",\"footer\":[{\"TotalPan\":" + totals[0] + ",\"TotalYpan\":" + totals[1] + ",\"TotalNotPan\":" + totals[2] + "}]}";
                return(ResResult.Response(true, "", dgData));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
コード例 #3
0
ファイル: PdaService.cs プロジェクト: qq283335746/Asset
        public ResResultModel GetPandianAssetByBarcode(string appKey, string userName, object pandianId, string barcode)
        {
            try
            {
                var userId = WebCommon.GetUserId();

                if (string.IsNullOrWhiteSpace(barcode))
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, ""));
                }

                var gId = Guid.Empty;
                if (pandianId != null)
                {
                    Guid.TryParse(pandianId.ToString(), out gId);
                }
                if (gId.Equals(Guid.Empty))
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, ""));
                }

                var            sqlWhere = @"and pd.Id = @PandianId and ais.Barcode = @Barcode ";
                SqlParameter[] parms    =
                {
                    new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier),
                    new SqlParameter("@Barcode",   SqlDbType.VarChar, 36)
                };
                parms[0].Value = gId;
                parms[1].Value = barcode;

                var bll  = new PandianAsset();
                var list = bll.GetListByJoin(sqlWhere, parms.ToArray());
                if (list == null || list.Count == 0)
                {
                    return(ResResult.Response(false, MC.GetString(MC.Params_Data_NotExist, barcode)));
                }

                var item = list[0];

                return(ResResult.Response(true, MC.Response_Ok, JsonConvert.SerializeObject(item)));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
コード例 #4
0
        public ResResultModel GetPandianAssetByBarcode(string appKey, string userName, object pandianId, string barcode)
        {
            try
            {
                object userId = null;
                SecurityService.DoCheckLogin(appKey, userName, out userId);

                if (string.IsNullOrWhiteSpace(barcode))
                {
                    return(ResResult.Response(false, "参数barcode值不能为空字符串", ""));
                }

                var gId = Guid.Empty;
                if (pandianId != null)
                {
                    Guid.TryParse(pandianId.ToString(), out gId);
                }
                if (gId.Equals(Guid.Empty))
                {
                    return(ResResult.Response(false, "参数pandianId值不正确", ""));
                }

                var            sqlWhere = @"and pd.Id = @PandianId and ais.Barcode = @Barcode ";
                SqlParameter[] parms    =
                {
                    new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier),
                    new SqlParameter("@Barcode",   SqlDbType.VarChar, 36)
                };
                parms[0].Value = gId;
                parms[1].Value = barcode;

                var bll  = new PandianAsset();
                var list = bll.GetListByJoin(sqlWhere, parms.ToArray());
                if (list == null || list.Count == 0)
                {
                    return(ResResult.Response(false, "数据不存在或已被删除", ""));
                }

                var pdaModel = new PdaPandianAssetInfo();
                var item     = list[0];

                pdaModel.PandianId   = item.PandianId;
                pdaModel.AssetId     = item.AssetId;
                pdaModel.Named       = item.Named;
                pdaModel.PandianUser = item.UserName;

                pdaModel.PandianAssetStatus = item.Status;
                pdaModel.PictureUrl         = "";
                pdaModel.AssetName          = item.AssetName;
                pdaModel.Barcode            = item.Barcode;
                pdaModel.Category           = item.Category;
                pdaModel.SpecModel          = item.SpecModel;
                pdaModel.OwnedCompany       = item.OwnedCompany;
                pdaModel.UseCompany         = item.UseCompany;
                pdaModel.UseDepmt           = item.UseDepmt;
                pdaModel.Region             = item.Region;
                pdaModel.StoreLocation      = item.StoreLocation;
                pdaModel.UsePerson          = item.UsePerson;
                pdaModel.Unit = item.Unit;

                return(ResResult.Response(true, "调用成功", JsonConvert.SerializeObject(pdaModel)));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
コード例 #5
0
        public ResResultModel SavePandianAsset(PdaPandianAssetFmModel model)
        {
            object userId = null;

            SecurityService.DoCheckLogin(model.AppKey, model.UserName, out userId);

            if (model == null)
            {
                return(ResResult.Response(false, "请求参数集为空字符串", ""));
            }
            var pandianId = Guid.Empty;

            if (model.PandianId == null || !Guid.TryParse(model.PandianId.ToString(), out pandianId))
            {
                return(ResResult.Response(false, "参数PandianId值为“" + model.PandianId + "”无效", ""));
            }
            if (model.ItemList == null || model.ItemList.Count == 0)
            {
                return(ResResult.Response(false, "请求参数集为空字符串", ""));
            }

            var pdaBll = new PandianAsset();
            var aisBll = new AssetInStore();
            var pdBll  = new Pandian();
            var effect = 0;

            foreach (var item in model.ItemList)
            {
                PandianAssetInfo pdaModel   = null;
                AssetInStoreInfo assetModel = null;

                var assetId = Guid.Empty;
                if (item.AssetId != null)
                {
                    Guid.TryParse(item.AssetId.ToString(), out assetId);
                }
                if (assetId == Guid.Empty)
                {
                    if (string.IsNullOrWhiteSpace(item.Barcode))
                    {
                        continue;
                    }

                    if (pdaBll.IsExist(item.Barcode))
                    {
                        assetModel = aisBll.GetModelByBarcode(item.Barcode);
                        if (assetModel != null)
                        {
                            CreateAssetInStoreInfo(item, ref assetModel, ref pdaModel);

                            pdaModel.AssetId   = assetModel.Id;
                            pdaModel.PandianId = pandianId;
                            assetModel.UserId  = Guid.Parse(userId.ToString());
                            pdaModel.UserId    = assetModel.UserId;
                            effect            += aisBll.Update(assetModel);
                            effect            += pdaBll.Update(pdaModel);
                        }
                    }
                    else
                    {
                        CreateAssetInStoreInfo(item, ref assetModel, ref pdaModel);
                        assetModel.Id      = Guid.NewGuid();
                        pdaModel.AssetId   = assetModel.Id;
                        pdaModel.PandianId = pandianId;
                        assetModel.UserId  = Guid.Parse(userId.ToString());
                        pdaModel.UserId    = assetModel.UserId;
                        effect            += aisBll.InsertByOutput(assetModel);
                        effect            += pdaBll.Insert(pdaModel);
                    }
                }
                else
                {
                    assetModel = aisBll.GetModel(assetId);
                    pdaModel   = pdaBll.GetModel(pandianId, assetId);
                    CreateAssetInStoreInfo(item, ref assetModel, ref pdaModel);

                    pdaModel.UserId = Guid.Parse(userId.ToString());
                    effect         += pdaBll.Update(pdaModel);
                }
            }

            if (effect < 1)
            {
                return(ResResult.Response(false, "操作失败", ""));
            }

            return(ResResult.Response(true, "调用成功", ""));
        }
コード例 #6
0
        public ResResultModel GetPandianAssetList(PdaPandianAssetModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, "未找到任何参数", ""));
                }

                if (model.PageIndex < 1)
                {
                    model.PageIndex = 1;
                }
                if (model.PageSize < 10)
                {
                    model.PageSize = 10;
                }
                int totalRecord = 0;

                var pandianId = Guid.Empty;
                if (model.PandianId != null)
                {
                    Guid.TryParse(model.PandianId.ToString(), out pandianId);
                }
                //if (pandianId.Equals(Guid.Empty)) return ResResult.Response(false, "参数PandianId值为“" + model.PandianId + "”不正确", "");

                var status = Enum.GetName(typeof(EnumData.EnumPandianAssetStatus), model.Status);
                //if (string.IsNullOrWhiteSpace(status)) return ResResult.Response(false, "参数Status值为“" + model.Status + "”不正确", "");

                var          sqlWhere = new StringBuilder(100);
                var          parms    = new ParamsHelper();
                SqlParameter parm     = null;

                if (!pandianId.Equals(Guid.Empty))
                {
                    sqlWhere.Append("and PandianId = @PandianId ");
                    parm       = new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier);
                    parm.Value = pandianId;
                    parms.Add(parm);
                }

                if (model.Status > -1)
                {
                    sqlWhere.Append("and pda.Status = @Status ");
                    parm       = new SqlParameter("@Status", SqlDbType.NVarChar, 20);
                    parm.Value = status;
                    parms.Add(parm);
                }

                var bll  = new PandianAsset();
                var list = bll.GetListByJoin(model.PageIndex, model.PageSize, out totalRecord, sqlWhere.ToString(), parms.ToArray());

                var pdaList = new List <PdaPandianAssetInfo>();
                foreach (var item in list)
                {
                    var pdaModel = new PdaPandianAssetInfo();
                    pdaModel.PandianId   = item.PandianId;
                    pdaModel.AssetId     = item.AssetId;
                    pdaModel.Named       = item.Named;
                    pdaModel.PandianUser = item.UserName;
                    pdaModel.TotalQty    = list.Count;
                    pdaModel.Remark      = item.Remark;

                    pdaModel.PandianAssetStatus = item.Status;
                    pdaModel.PictureUrl         = "";
                    pdaModel.AssetName          = item.AssetName;
                    pdaModel.Barcode            = item.Barcode;
                    pdaModel.SNCode             = item.SNCode;
                    pdaModel.Category           = item.Category;
                    pdaModel.CategoryId         = item.CategoryId;
                    pdaModel.SpecModel          = item.SpecModel;
                    pdaModel.OwnedCompany       = item.OwnedCompany;
                    pdaModel.UseCompany         = item.UseCompany;
                    pdaModel.UseDepmt           = item.UseDepmt;
                    pdaModel.Region             = item.Region;
                    pdaModel.StoreLocation      = item.StoreLocation;
                    pdaModel.UsePerson          = item.UsePerson;
                    pdaModel.Unit = item.Unit;

                    pdaList.Add(pdaModel);
                }

                var totals = bll.GetTotal(pandianId);

                var dgData = "{\"total\":" + pdaList.Count + ",\"rows\":" + JsonConvert.SerializeObject(pdaList) + ",\"footer\":[{\"TotalPan\":" + totals[0] + ",\"TotalYpan\":" + totals[1] + ",\"TotalNotPan\":" + totals[2] + "}]}";
                return(ResResult.Response(true, "", dgData));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
コード例 #7
0
ファイル: PdaService.cs プロジェクト: qq283335746/Asset
        public ResResultModel SavePandianAsset(PdaPandianAssetFmModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, "请求参数集为空字符串", ""));
                }
                var userId = WebCommon.GetUserId();
                if (userId.Equals(Guid.Empty))
                {
                    return(ResResult.Response((int)ResCode.未登录, MC.Login_NotExist, ""));
                }
                var depmtId = new Staff().GetOrgId(userId);

                var pandianId = Guid.Empty;
                if (!Guid.TryParse(model.PandianId, out pandianId))
                {
                    return(ResResult.Response(false, "参数PandianId值为“" + model.PandianId + "”无效", ""));
                }

                var currTime = DateTime.Now;
                var gEmpty   = Guid.Empty;
                var minDate  = DateTime.Parse("1754-01-01");

                var pdaBll = new PandianAsset();
                var pBll   = new Product();
                var pdBll  = new Pandian();
                var effect = 0;

                foreach (var item in model.ItemList)
                {
                    var assetId = Guid.Empty;
                    if (!string.IsNullOrEmpty(item.AssetId))
                    {
                        Guid.TryParse(item.AssetId, out assetId);
                    }
                    var categoryId = Guid.Empty;
                    if (!string.IsNullOrEmpty(item.CategoryId))
                    {
                        Guid.TryParse(item.CategoryId, out categoryId);
                    }
                    var useDepmtId = Guid.Empty;
                    if (!string.IsNullOrEmpty(item.UseDepmtId))
                    {
                        Guid.TryParse(item.UseDepmtId, out useDepmtId);
                    }
                    var mgrDepmtId = Guid.Empty;
                    if (!string.IsNullOrEmpty(item.MgrDepmtId))
                    {
                        Guid.TryParse(item.MgrDepmtId, out mgrDepmtId);
                    }
                    var storeLocationId = Guid.Empty;
                    if (!string.IsNullOrEmpty(item.StoreLocationId))
                    {
                        Guid.TryParse(item.StoreLocationId, out storeLocationId);
                    }

                    ProductInfo productInfo = null;
                    if (item.Status == (int)EnumPandianAssetStatus.盘盈)
                    {
                        #region 盘盈

                        productInfo = new ProductInfo(GlobalConfig.SiteCode, userId, depmtId, Guid.NewGuid(), categoryId, item.Barcode, item.AssetName, item.Barcode, item.SpecModel, 1, 0, 0, item.Unit, 0, string.Empty, string.Empty, string.Empty, minDate, "1754-01-01", string.Empty, useDepmtId, item.UsePerson, mgrDepmtId, storeLocationId, string.Empty, item.Status, 0, true, currTime, currTime);
                        effect     += pBll.InsertByOutput(productInfo);
                        var pandianAssetInfo = new PandianAssetInfo(pandianId, productInfo.Id, productInfo.AppCode, productInfo.UserId, productInfo.DepmtId, gEmpty, gEmpty, gEmpty, string.Empty, 0, item.Remark, item.Status, currTime, currTime);
                        pdaBll.Insert(pandianAssetInfo);

                        #endregion
                    }
                    else
                    {
                        #region 非盘盈

                        productInfo = pBll.GetModel(assetId);
                        var pandianAssetInfo = pdaBll.GetModel(pandianId, assetId);
                        if (!useDepmtId.Equals(Guid.Empty) && !useDepmtId.Equals(productInfo.UseDepmtId))
                        {
                            pandianAssetInfo.LastUseDepmtId = useDepmtId;
                        }
                        if (!mgrDepmtId.Equals(Guid.Empty) && !mgrDepmtId.Equals(productInfo.MgrDepmtId))
                        {
                            pandianAssetInfo.LastMgrDepmtId = mgrDepmtId;
                        }
                        if (!storeLocationId.Equals(Guid.Empty) && !storeLocationId.Equals(productInfo.StoragePlaceId))
                        {
                            pandianAssetInfo.LastStoragePlaceId = storeLocationId;
                        }
                        if (!string.IsNullOrEmpty(item.UsePerson) && item.UsePerson != productInfo.UsePersonName)
                        {
                            pandianAssetInfo.LastUsePerson = item.UsePerson;
                        }
                        pandianAssetInfo.Status = item.Status;

                        effect += pdaBll.Update(pandianAssetInfo);

                        #endregion
                    }
                }

                if (effect < 1)
                {
                    return(ResResult.Response(false, "操作失败", ""));
                }

                return(ResResult.Response(true, "调用成功", ""));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }