| | |
| | | _invokeERPService = invokeERPService; |
| | | _basicRepository = basicRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 淇濆瓨鏁版嵁 |
| | | /// </summary> |
| | | public void SaveStatic(MesBagInfoModel mesBagInfoModel) |
| | | { |
| | | List<ProInStaticDTO> mESBagDetails = mesBagInfoModel.BagDetails.GroupBy(x=>new { x.ProductCode, x.ProductVersion }).Select(x=>new ProInStaticDTO |
| | | List<ProInStaticDTO> mESBagDetails = mesBagInfoModel.BagDetails.GroupBy(x => new { x.ProductCode, x.ProductVersion }).Select(x => new ProInStaticDTO |
| | | { |
| | | ProductCode= x.Key.ProductCode, |
| | | ProductVersion= x.Key.ProductVersion, |
| | | SumPcs=x.Sum(x => x.OKPCSQTY) |
| | | ProductCode = x.Key.ProductCode, |
| | | ProductVersion = x.Key.ProductVersion, |
| | | SumPcs = x.Sum(x => x.OKPCSQTY), |
| | | SumPcsArea = x.Sum(x=>x.OKPCSArea) |
| | | }).ToList(); |
| | | List<Dt_ProInStatistics> proInStatistics= new List<Dt_ProInStatistics>(); |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseCode==mesBagInfoModel.WarehouseCode); |
| | | foreach (var m in mESBagDetails) |
| | | { |
| | | string response = _invokeERPService.InvokeProInErpStatic(m.ProductCode, m.ProductCode + m.ProductVersion); |
| | | ErpProInErpStaticResponseContent erpProInErpStatic = response.DeserializeObject<ErpProInErpStaticResponseContent>(); |
| | | if (erpProInErpStatic.Code != 200) |
| | | { |
| | | return; |
| | | } |
| | | float adjusted = (float)Math.Round(erpProInErpStatic.Data[0].UnitArea, 3); |
| | | Dt_ProInStatistics inStatistics = new Dt_ProInStatistics() |
| | | { |
| | | WarehouseId = warehouse.WarehouseId, |
| | | ProductCode = m.ProductCode, |
| | | ProductRev = m.ProductVersion, |
| | | PcsQty = m.SumPcs, |
| | | SquareMeter = (float)Math.Round((adjusted * m.SumPcs), 3), |
| | | SquareMeter = (float)Math.Round(m.SumPcsArea, 3), |
| | | Remark = mesBagInfoModel.BatchNo |
| | | }; |
| | | proInStatistics.Add(inStatistics); |