| | |
| | | throw new Exception($"转æ¢ååä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | Dt_MaterielInfo materielInfo = MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == materialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | throw new Exception("åä½è½¬æ¢æ¶ç©æä¿¡æ¯æªæ¾å°"); |
| | | } |
| | | decimal ratio = 1; |
| | | |
| | | if (materielInfo.inventoryUOM.Trim().ToLower() == fromUnit.Trim().ToLower()) |
| | | if (fromUnit.Trim().ToLower() == toUnit.Trim().ToLower()) |
| | | { |
| | | return new UnitConvertResultDTO(materialCode, fromUnit, toUnit, quantity, ratio); |
| | | } |
| | | |
| | | Dt_MaterialUnit materialUnit = MaterialUnitService.Repository.QueryFirst(x => x.ItemNo == materialCode && x.FromUom == fromUnit && x.ToUom == toUnit); |
| | | if (materialUnit != null) |
| | | { |
| | | ratio = materialUnit.Ratio; |
| | | return new UnitConvertResultDTO(materialCode, fromUnit, toUnit, quantity, ratio); |
| | | } |
| | | else |
| | | { |
| | | Dt_MaterialUnit materialUnit = MaterialUnitService.Repository.QueryFirst(x => x.ItemNo == materialCode && x.FromUom == fromUnit); |
| | | if (materialUnit != null) |
| | | materialUnit = MaterialUnitService.Repository.QueryFirst(x => x.ItemNo == materialCode && x.FromUom == toUnit && x.ToUom == fromUnit); |
| | | if (materialUnit == null) |
| | | { |
| | | toUnit = materialUnit.ToUom; |
| | | ratio = materialUnit.Ratio; |
| | | return new UnitConvertResultDTO(materialCode, fromUnit, toUnit, quantity, ratio); |
| | | throw new Exception($"æªæ¾å°åä½è½¬æ¢å
³ç³»ï¼ç©æç¼å·ï¼{materialCode}ï¼è½¬æ¢ååä½ï¼{fromUnit}ï¼è½¬æ¢ååä½ï¼{toUnit}"); |
| | | } |
| | | else |
| | | { |
| | | throw new Exception($"æªæ¾å°åä½è½¬æ¢å
³ç³»ï¼ç©æç¼å·ï¼{materialCode}ï¼è½¬æ¢ååä½ï¼{fromUnit}"); |
| | | } |
| | | ratio = materialUnit.Ratio; |
| | | return new UnitConvertResultDTO(materialCode, fromUnit, toUnit, quantity, ratio); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |