| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Dynamic; |
| | | using System.Globalization; |
| | | using System.Linq; |
| | | using System.Linq.Expressions; |
| | | using System.Reflection; |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | |
| | | _invokeERPService = invokeERPService; |
| | | _warehouseService = warehouseService; |
| | | _palletTypeInfoRepository = palletTypeInfoRepository; |
| | | } |
| | | public override object GetDetailPage(PageDataOptions pageData) |
| | | { |
| | | Type t = typeof(Dt_InboundOrder); |
| | | |
| | | if (pageData.Value == null) return new PageGridData<object>(total: 0, null); |
| | | string keyName = t.GetKeyName(); |
| | | ////çææ¥è¯¢æ¡ä»¶ |
| | | //Expression<Func<TEntity, bool>> whereExpression = keyName.CreateExpression<TEntity>(pageData.Value, LinqExpressionType.Equal); |
| | | int totalCount = 0; |
| | | PropertyInfo propertyInfo = t.GetProperties().FirstOrDefault(x => x.GetCustomAttribute<Navigate>() != null); |
| | | if (propertyInfo != null) |
| | | { |
| | | Type detailType = propertyInfo.PropertyType.GetGenericArguments()[0]; |
| | | Navigate navigate = propertyInfo.GetCustomAttribute<Navigate>(); |
| | | List<Dt_InboundOrderDetail> list = BaseDal.Db.Queryable<Dt_InboundOrderDetail>().Where(navigate.GetName(), "=", pageData.Value).ToPageList(pageData.Page, pageData.Rows, ref totalCount); |
| | | decimal sum = 0; |
| | | list.ForEach(x => |
| | | { |
| | | sum += Convert.ToDecimal(x.OrderQuantity); |
| | | }); |
| | | PageGridData<Dt_InboundOrderDetail> pageGridData = new PageGridData<Dt_InboundOrderDetail>() |
| | | { |
| | | Total= totalCount, |
| | | Rows=list, |
| | | Summary=new |
| | | { |
| | | OrderQuantity = Math.Round(sum, 3), |
| | | } |
| | | }; |
| | | return pageGridData; |
| | | } |
| | | return new PageGridData<object>(total: 0, null); |
| | | } |
| | | /// <summary> |
| | | /// å
¶ä»å
¥åºåæ¥æ¶(è°æå
¥ä»,客ä¾åæ¶,ç©æéå®éè´§) |
| | |
| | | List<Dt_InboundOrder> dt_ReceiveOrders = new List<Dt_InboundOrder>(); |
| | | if (string.IsNullOrEmpty(orderNo)) |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt() && x.WarehouseId == warehouseId).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 5); |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt() && x.WarehouseId == warehouseId).Includes(x=>x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 10); |
| | | } |
| | | else |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.InboundOrderNo.Contains(orderNo)) && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt() && x.WarehouseId == warehouseId).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 5); |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.InboundOrderNo.Contains(orderNo)) && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 10); |
| | | } |
| | | |
| | | content.OK(data: dt_ReceiveOrders); |
| | |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåæç»ä¿¡æ¯"); |
| | | } |
| | | List<MatSerNumAnalysisModel> models = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(AnalysisCodeEnum.MatSerNumAnalysis, serNums); |
| | | //éªè¯å¤ææ¶é´æ ¼å¼ |
| | | WebResponseContent IsValidContent = IsValidMCDates(models); |
| | | if (!IsValidContent.Status) |
| | | { |
| | | return content.Error(IsValidContent.Message); |
| | | } |
| | | //é¤éè´å
¥åºå以å¤å
¶ä»å
¥åºåç»çæ°æ®å¤ç |
| | | if (inboundOrder.OrderType != InOrderTypeEnum.Purchase.ObjToInt()) |
| | | { |
| | |
| | | } |
| | | |
| | | List<string> purchaseOrderNos = receiveOrder.Details.Select(x => x.PurchaseOrderNo).ToList(); |
| | | |
| | | if (models.Select(x => x.MaterielCode).Distinct().Count() > 1) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç©æä¸å¯æ··æ¾"); |
| | |
| | | stockInfoDetails.Add(stockInfoDetail); |
| | | |
| | | notGroupDetail.ReceiptQuantity += model.Quantity; |
| | | if (notGroupDetail.ReceiptQuantity>notGroupDetail.OrderQuantity) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç»çæ°é溢åº{notGroupDetail.ReceiptQuantity - notGroupDetail.OrderQuantity}"); |
| | | } |
| | | if (notGroupDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | notGroupDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | |
| | | { |
| | | return content.Error($"ç©æä¸å¯æ··æ¾"); |
| | | } |
| | | |
| | | //éªè¯å¤ææ¶é´æ ¼å¼ |
| | | WebResponseContent IsValidContent = IsValidMCDates(models); |
| | | if (!IsValidContent.Status) |
| | | { |
| | | return content.Error(IsValidContent.Message); |
| | | } |
| | | string materielCode = models.FirstOrDefault()?.MaterielCode ?? ""; |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materielCode); |
| | | if (materielInfo == null) |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç©æä¸å¯æ··æ¾"); |
| | | } |
| | | |
| | | //éªè¯å¤ææ¶é´æ ¼å¼ |
| | | WebResponseContent IsValidContent = IsValidMCDates(models); |
| | | if (!IsValidContent.Status) |
| | | { |
| | | return content.Error(IsValidContent.Message); |
| | | } |
| | | string materielCode = models.FirstOrDefault()?.MaterielCode ?? ""; |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materielCode); |
| | | if (materielInfo == null) |
| | |
| | | } |
| | | return -1; |
| | | } |
| | | /// <summary> |
| | | /// 夿æ£ç¡®æ¶é´æ ¼å¼ |
| | | /// </summary> |
| | | public WebResponseContent IsValidMCDates(List<MatSerNumAnalysisModel> analysisModels) |
| | | { |
| | | string[] effDates = analysisModels.Select(x => x.EffectiveDate).Distinct().ToArray(); |
| | | string[] ProDates = analysisModels.Select(x => x.ProductionDate).Distinct().ToArray(); |
| | | foreach (string effDate in effDates) |
| | | { |
| | | string format = "yyyy-MM-dd"; // ç®æ æ ¼å¼ |
| | | DateTime parsedDate; |
| | | // è§£æå¹¶éªè¯æ ¼å¼ |
| | | bool isValid = DateTime.TryParseExact( |
| | | effDate, |
| | | format, |
| | | CultureInfo.InvariantCulture, |
| | | DateTimeStyles.None, |
| | | out parsedDate |
| | | ); |
| | | |
| | | if (!isValid) |
| | | { |
| | | return WebResponseContent.Instance.Error("æ ¼å¼æ æææ¥æä¸åæ³"); |
| | | } |
| | | } |
| | | foreach (string ProDate in ProDates) |
| | | { |
| | | string format = "yyyy-MM-dd"; // ç®æ æ ¼å¼ |
| | | DateTime parsedDate; |
| | | // è§£æå¹¶éªè¯æ ¼å¼ |
| | | bool isValid = DateTime.TryParseExact( |
| | | ProDate, |
| | | format, |
| | | CultureInfo.InvariantCulture, |
| | | DateTimeStyles.None, |
| | | out parsedDate |
| | | ); |
| | | |
| | | if (!isValid) |
| | | { |
| | | return WebResponseContent.Instance.Error("æ ¼å¼æ æææ¥æä¸åæ³"); |
| | | } |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | } |
| | | } |