示例#1
0
        /// <summary>
        /// 查找最后入库的记录
        /// </summary>
        /// <returns></returns>
        public static TbRawMaterialStockRecord GetLastRecordForRawMaterial(InOrderRequest request)
        {
            var stockRecordList = Repository <TbRawMaterialStockRecord> .Query(p => p.MaterialCode == request.MaterialCode &&
                                                                               p.ProjectId == request.ProjectId &&
                                                                               p.WorkAreaCode == request.WorkAreaCode &&
                                                                               p.ChackState == 1
                                                                               )
                                  .OrderBy(p => p.SiteCode).ThenByDescending(p => p.InsertTime).ToList();

            if (!stockRecordList.Any())
            {
                return(null);
            }
            var stockRecord = stockRecordList[0];

            stockRecord.UseCountS = stockRecordList.Sum(p => p.LockCount) + stockRecordList.Sum(p => p.UseCount);
            return(stockRecord);
        }
示例#2
0
        /// <summary>
        /// 获取分页列表数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ActionResult GetGridJson(InOrderRequest request)
        {
            var data = _inOrder.GetDataListForPage(request);

            return(Content(data.ToJson()));
        }
示例#3
0
        /// <summary>
        /// 获取数据列表(批次计划明细)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ActionResult GetBatchPlanItemGridJson(InOrderRequest request)
        {
            var data = _inOrder.GetBatchPlanItemDataList(request);

            return(Content(data.ToJson()));
        }
示例#4
0
        /// <summary>
        /// 获取数据列表(供应商)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ActionResult GetSupplierGridJson(InOrderRequest request)
        {
            var data = _inOrder.GetSupplierDataList(request);

            return(Content(data.ToJson()));
        }
        /// <summary>
        /// 获取数据列表(厂家,炉批号,质检报告)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ActionResult GetTestReportList(InOrderRequest request)
        {
            var data = _RM.GetTestReportList(request);

            return(Content(data.ToJson()));
        }
示例#6
0
        /// <summary>
        /// 获取数据列表(厂家,炉批号,质检报告)
        /// </summary>
        public PageModel GetDataListForPage(InOrderRequest request)
        {
            #region 搜索条件

            List <Parameter> parameter = new List <Parameter>();
            string where = " where 1=1 and Factory IS NOT NULL and BatchNumber IS NOT NULL and (a.UseCount+isnull(d.LockCount,0))>0 and a.ChackState=1";
            if (!string.IsNullOrWhiteSpace(request.keyword))
            {
                where += " and c.CompanyFullName like @keyword";
                parameter.Add(new Parameter("@keyword", '%' + request.keyword + '%', DbType.String, null));
            }
            if (!string.IsNullOrWhiteSpace(request.MaterialCode))
            {
                where += " and a.MaterialCode=@MaterialCode";
                parameter.Add(new Parameter("@MaterialCode", request.MaterialCode, DbType.String, null));
            }
            if (!string.IsNullOrEmpty(request.ProjectId))
            {
                where += " and a.ProjectId=@ProjectId";
                parameter.Add(new Parameter("@ProjectId", request.ProjectId, DbType.String, null));
            }
            if (!string.IsNullOrWhiteSpace(request.WorkAreaCode))
            {
                where += " and a.WorkAreaCode=@WorkAreaCode";
                parameter.Add(new Parameter("@WorkAreaCode", request.WorkAreaCode, DbType.String, null));
            }
            if (!string.IsNullOrWhiteSpace(request.CollarCode))
            {
                parameter.Add(new Parameter("@CollarCode", request.CollarCode, DbType.String, null));
            }
            parameter.Add(new Parameter("@WorkOrderItemId", request.WorkOrderItemId, DbType.Int32, null));
            #endregion

            var sql = @"select 
                                 c.CompanyFullName as InOrderSiteName,
                                 a.InsertTime as InOrderTime,
                                 a.ID as InOrderItemId,
                                 a.Factory,
                                 a.BatchNumber,
                                 a.TestReportNo,
                                 a.Count,
                                 (a.UseCount+isnull(d.LockCount,0)) as PassCount
                                from TbRawMaterialStockRecord a
                                left join TbCompany c on a.SiteCode=c.CompanyCode
                                LEFT JOIN (
                                    SELECT  StockRecordId,SUM(LockCount) AS LockCount FROM TbRMProductionMaterialLockCount
                                    WHERE SourceType=1 AND CollarCode=@CollarCode AND WorkOrderItemId=@WorkOrderItemId
                                    GROUP BY StockRecordId
                                ) AS d ON a.ID=d.StockRecordId";
            try
            {
                var data = Repositorys <RawMaterialStockRecordResponse> .FromSqlToPage(sql + where, parameter, request.rows, request.page, "InOrderTime");

                if (data.total == 0)
                {
                    //查找最近的炉批号
                    var RawMaterial = GetLastRecordForRawMaterial(request);
                    if (RawMaterial != null)
                    {
                        var a = new RawMaterialStockRecordResponse()
                        {
                            InOrderTime   = RawMaterial.InsertTime,
                            InOrderItemId = RawMaterial.ID,
                            Factory       = RawMaterial.Factory,
                            BatchNumber   = RawMaterial.BatchNumber,
                            TestReportNo  = RawMaterial.TestReportNo,
                            Count         = RawMaterial.Count,
                            PassCount     = RawMaterial.UseCountS.Value
                        };
                        var b = Repository <TbCompany> .First(p => p.CompanyCode == RawMaterial.SiteCode);

                        if (b != null)
                        {
                            a.InOrderSiteName = b.ParentCompanyName;
                        }
                        data.rows = new List <RawMaterialStockRecordResponse>()
                        {
                            a
                        };
                    }
                }
                return(data);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#7
0
        /// <summary>
        /// 获取所有列表信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage inoGetGridJson([FromUri] InOrderRequest pt)
        {
            var data = _inOrder.GetDataListForPage(pt);

            return(AjaxResult.Success(data).ToJsonApi());
        }
示例#8
0
        /// <summary>
        /// 获取所有列表信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage inoImg2([FromUri] InOrderRequest pt)
        {
            var data = _inOrder.Img2(pt);

            return(AjaxResult.Success(data).ToJsonApi());
        }