/* * namespace MPServices { public class SteelItem { #region STANDARD public static string STANDARD(string C60STDFORMAT, string[] strSIZE) { decimal[] d = ConvertUnit.ConverttoMM(strSIZE); return STANDARD(C60STDFORMAT, d); } public static string STANDARD(string C60STDFORMAT, decimal[] SIZE) { return ConvertUnit.stdFormat(C60STDFORMAT, SIZE); } #endregion #region SelectSize public static cSize[] SelectSize(string CID, string Comp, string KSJIS, string SKEY) { SqlRepository rep = SqlRepository.GetInstance(CID); string[] item = SKEY.Split('|'); cItem[] v = SelectCPUM(CID, Comp, item[0]); if (v.Length != 1) { throw new NotExistItemException(); } decimal cdoo = ConvertUnit.ConverttoMM(item[1]); decimal cpok = ConvertUnit.ConverttoMM(item[2]); decimal ch1 = ConvertUnit.ConverttoMM(item[3]); decimal ch2 = ConvertUnit.ConverttoMM(item[4]); decimal ct1 = ConvertUnit.ConverttoMM(item[5]); decimal ct2 = ConvertUnit.ConverttoMM(item[6]); decimal cpi1 = ConvertUnit.ConverttoMM(item[7]); decimal cgil = ConvertUnit.ConverttoMM(item[8]); var rows = from r in rep.CF640PR where r.REFCODE == v[0].Rfcd && (0 == ch1 || r.CH1 == ch1) && (0 == ch2 || r.CH2 == ch2) && (0 == ct1 || r.CT1 == ct1) && (0 == ct2 || r.CT2 == ct2) && r.KSJIS == KSJIS select new cSize() { Cdoo = ConvertUnit.ConverttoOrigin(item[1], r.CDOO), Cpok = ConvertUnit.ConverttoOrigin(item[2], r.CPOK), Ch1 = ConvertUnit.ConverttoOrigin(item[3], r.CH1), Ch2 = ConvertUnit.ConverttoOrigin(item[4], r.CH2), Ct1 = ConvertUnit.ConverttoOrigin(item[5], r.CT1), Ct2 = ConvertUnit.ConverttoOrigin(item[6], r.CT2), Cpi1 = ConvertUnit.ConverttoOrigin(item[7], r.CPI1), Cgil = ConvertUnit.ConverttoOrigin(item[8], (cgil == 0 ? r.CGIL : cgil)), Std = STANDARD(v[0].Sfmt, new decimal[] { r.CDOO, r.CPOK, r.CH1, r.CH2, r.CT1, r.CT2, r.CPI1, (cgil == 0 ? r.CGIL : cgil)}) }; return rows.ToArray(); } #endregion #region SelectCPUM public static cItem[] SelectCPUM(string CID, string Comp, string CodeorName) { SqlRepository rep = SqlRepository.GetInstance(CID); var cf610s = (from r in rep.CF610PR where r.CWCOMP == Comp && (r.CPUMCD == CodeorName || System.Data.Linq.SqlClient.SqlMethods.Like(r.CPUMNM, "%" + CodeorName + "%")) select new cItem() { Comp = r.CWCOMP, Code = r.CPUMCD, Name = r.CPUMNM, Matr = r.CJEJIL, Topc = r.C60TCD, Midc = r.C60MCD, Type = r.ITEM_TYPE, Type2 = r.ITEM_TYPE2, Unit = r.C60UNIT, Unit2 = r.C60UNIT2, Calc = r.C60CAL, Rfcd = r.REFCODE, Sfmt = r.C60STDFORMAT, Stk = r.C60STK, Orgn = r.CORIGIN, Usjs = r.USEJIS, }).ToArray(); var k = (from r in rep.T_CFCODE where r.COMP == Comp && r.UP_CMCD == "STYPE" select r) .ToDictionary(n => n.CMCD, n => n.CMCD_NAME); foreach(var f in cf610s) { f.Tynm = (k.ContainsKey(f.Type) ? k[f.Type] : ""); f.Tynm2 = (k.ContainsKey(f.Type2) ? k[f.Type2] : ""); } return cf610s; } #endregion #region GetWeight public static decimal[] GetWeight(string CID, string Comp, string Skey, string ms, string ea_bd, string ksjis) { SqlRepository rep = SqlRepository.GetInstance(CID); string[] key = Skey.Split('|'); decimal[] d = ConvertUnit.ConverttoMM(new string[] { key[1], key[2], key[3], key[4] , key[5], key[6], key[7], key[8] , "0" // 변경된 BD , "0" // 변경된 매수. , "0" // 중량 }); decimal[] res = d; // 단위중량의 기본 단위는 kg/M 이므로 중량을 구할동안만 M 로 변경한다. d[7] = d[7] / 1000; var cf610s = from r in rep.CF610PR where r.CWCOMP == Comp && r.CPUMCD == key[0] select r; if (cf610s.Count() != 1) throw new NotExistItemException(); CF610 c = cf610s.Single(); decimal dms = 0; decimal.TryParse(ms , System.Globalization.NumberStyles.Number , System.Globalization.CultureInfo.CurrentCulture , out dms); bool isBAND = ea_bd.IndexOf("bd", StringComparison.OrdinalIgnoreCase) > -1; if (c.C60CAL != "CF500" && isBAND) throw new IncorrectBandException(); d[8] = 0; d[9] = dms; switch (c.C60CAL) { // Math.Round(단중 * 길이/1000,(값>100?0,1)) * 수량 -- HBEAM case "CF100": d[10] = CF100(CID, c, ksjis, d, dms, true); break; // Math.Round(단중 * 길이/1000 * 수량,0) -- ANGLE case "CF110": d[10] = CF100(CID, c, ksjis, d, dms, false); break; // Math.Round(지름* 지름 * 비중(0.00617) * 길이/1000 * 수량, 0) -- S/B, R/B, M/R case "CF200": d[10] = CF200(CID, c, ksjis, d, dms); break; // Math.Round(단중 * 수량, 0) -- 철판망 (없으면 직접 구함.) case "CF300": d[10] = CF300(CID, c, ksjis, d, dms); break; // 평철 case "CF400": d[10] = CF400(CID, c, ksjis, d, dms); break; // 철근 - (밴드 * 밴드중량) + (매수 * 단위중량) case "CF500": d[10] = CF500(CID, c, ksjis, d, isBAND, ref d[8], ref d[9]); break; // Math.Round((두께*비중(0.00785) + 도금량) * 폭* 길이/1000 , (값>100 ?>0,1)) * 수량 -- 일반철판, 체크플레이트,평철 case "DI100": d[10] = DI100(CID, c, ksjis, d, dms); break; // //경량형강1 - ((폭1- 두께2 * 2.0) * 두께1 + (폭2 * 두께2 * 2.0)) * 0.00000785; case "DI200": d[10] = DI200(c, d, dms); break; // //파이프,welded : (외경-두께)*두께*0.02466 * 길이; case "DI_PI": d[10] = DI_PI(c, d, dms); break; // //각형강관 ((A+B)-(3.287*T))*T*0.0157 * 길이; case "DI_SP": d[10] = DI_SP(c, d, dms); break; } // 길이를 M 에서 다시 mm 로 변경 d[7] = d[7] * 1000; return d; } #region CF100 Hbeam, Angle private static decimal CF100(string CID, CF610 c, string ks, decimal[] Size, decimal ms, bool isRound) { // 단위중량 가져옴. CF640[] c640 = GetUnitWeight(CID, c, ks, new decimal[] { -1, -1, Size[2], Size[3], Size[4], Size[5], Size[6], -1 }); if (c640.Length == 1) { decimal cukg = (decimal)c640[0].CUKG * (decimal)Size[7]; if (isRound) return (decimal)(Math.Round(cukg, (cukg > 100 ? 0 : 1), MidpointRounding.AwayFromZero) * (decimal)ms); // hbeam else return (decimal)Math.Round(cukg * (decimal)ms, 0, MidpointRounding.AwayFromZero); //angle } throw new NotExistWeightInfoException(); } #endregion #region CF200 S/B, R/B, M/R 기타 private static decimal CF200(string CID, CF610 c, string ks, decimal[] Size, decimal ms) { CF640[] c640 = GetUnitWeight(CID, c, ks, new decimal[] { -1, -1, Size[2], Size[3], Size[4], Size[5], Size[6], -1 }); if (c640.Length == 1) { decimal cukg = (decimal)c640[0].CUKG * ((decimal)Size[7] == 0 ? 1 : (decimal)Size[7]); return (decimal)Math.Round(cukg * (decimal)ms, 0, MidpointRounding.AwayFromZero); //angle } // S/B, R/B, M/R 경우 비중 정보 가져옴. c640 = GetUnitWeight(CID, c, ks, new decimal[] { -1, -1, -1, -1, -1, -1, -1, -1 }); if (c640.Length > 0) { return chulpan(Size[6], c640[0].COPT, 0, Size[6], Size[7], ms, false); } throw new NotExistWeightInfoException(); } #endregion #region CF300 철판망 private static decimal CF300(string CID, CF610 c, string ks, decimal[] Size, decimal ms) { // 단위중량 가져옴. CF640[] c640 = GetUnitWeight(CID, c, ks, new decimal[] { Size[0], Size[1], -1, -1, -1, -1, -1, Size[7] * 1000 }); decimal cukg = 0; if (c640.Length == 1) { cukg = c640[0].CUKG.Value; return (decimal)Math.Round((decimal)c640[0].CUKG * (decimal)ms, 0, MidpointRounding.AwayFromZero); } c640 = GetUnitWeight(CID, c, ks, new decimal[] { Size[0], -1, -1, -1, -1, -1, -1, -1 }); if (c640.Length > 0 && c640[0].COPT.HasValue) { decimal SWM = c640[0].COPT.Value; decimal W = c640[0].COPT2.HasValue?c640[0].COPT2.Value: 0; cukg = (decimal)Math.Round((decimal)Size[7] / (decimal)SWM * 2 * (decimal)W * (decimal)Size[1] / 1000 * (decimal)Size[0] * 7.85M, 2, MidpointRounding.AwayFromZero); return (decimal)Math.Round((decimal)c640[0].CUKG * (decimal)ms, 0, MidpointRounding.AwayFromZero); } throw new NotExistWeightInfoException(); } #endregion #region CF400 평철. private static decimal CF400(string CID, CF610 c, string ks, decimal[] Size, decimal ms) { // 단위중량 가져옴. CF640[] c640 = GetUnitWeight(CID, c, ks, new decimal[] { Size[0], Size[1], -1, -1, -1, -1, -1, -1 }); decimal cukg = 0; if (c640.Length == 1) { cukg = c640[0].CUKG.Value; return Math.Round(c640[0].CUKG.Value * Size[7] * ms, 0, MidpointRounding.AwayFromZero); } // 단위중량 없으면 철판 공식으로 처리. return chulpan(Size[0], 7.85m, 0, Size[1], Size[7], ms, false); } #endregion #region CF500 철근 private static decimal CF500(string CID, CF610 c, string ks, decimal[] Size, bool inBD, ref decimal BAND, ref decimal inputMs) { decimal qty = 0; decimal cbd = 0; decimal cukg = 0; // (밴드 * 밴드중량) + (매수 * 단위중량) CF640[] c640 = GetUnitWeight(CID, c, ks, new decimal[] { -1, -1, -1, -1, -1, -1, Size[6], Size[7] }); // 밴드 정보가 있으면,, if (c640.Length == 1) { cbd = c640[0].CBD.Value; cukg = c640[0].CUKG.Value; } else { // 길이가 0 c640 = GetUnitWeight(CID, c, ks, new decimal[] { -1, -1, -1, -1, -1, -1, Size[6], 0 }); if (c640.Length == 1) { cukg = c640[0].CUKG.Value; } } if (cbd > 0) { qty = Math.Round((inBD ? cbd : 1) * inputMs, 0, MidpointRounding.AwayFromZero); if (inBD) { BAND = inputMs; inputMs = qty; } else BAND = Math.Round(qty / cbd, 1, MidpointRounding.AwayFromZero); decimal bd = Math.Floor(qty / cbd); decimal ms = qty - (Math.Floor(qty / cbd) * cbd); // 총중량 = (밴드 * 밴드중량) + (매수 * 단위중량) decimal res = (bd * Math.Round(cbd * cukg, 0, MidpointRounding.AwayFromZero)) + Math.Round(ms * cukg, 0, MidpointRounding.AwayFromZero); return (res >= 100) ? Math.Round(res, 0) : Math.Round(res, 1); } else { if (inBD) throw new NotInitializeBandException(); return cukg * Size[7] * qty; } throw new NotExistWeightInfoException(); } #endregion #region DI100 철판 냉열철판 무늬철판 sus철판 private static decimal DI100(string CID, CF610 c, string ks, decimal[] Size, decimal ms) { decimal DOGUM = 0; decimal dd = 7.85m; // 무늬철판 if(c.CPUMCD.StartsWith("CP")) { if (Size[0] == 3.2m && Size[1] == 914 && Size[7] == 1.829m) return ms * 44.8m; else if (Size[0] == 3.2m && Size[1] == 1219 && Size[7] == 2.438m) return ms * 79.8m; else if (Size[0] == 4.5m && Size[1] == 914 && Size[7] == 1.829m) return ms * 61.9m; else if (Size[0] == 4.5m && Size[1] == 1219 && Size[7] == 2.438m) return ms * 110m; else if (Size[0] == 6 && Size[1] == 914 && Size[7] == 1.829m) return ms * 81.6m; else if (Size[0] == 6 && Size[1] == 1219 && Size[7] == 2.438m) return ms * 145m; else return chulpan(Size[0], dd, 1.67m, Size[1], Size[7], ms, true); } CF640[] c640 = GetUnitWeight(CID,c, ks, new decimal[] { -1, -1, -1, -1, -1, -1, -1, -1 }); if (c640.Length > 0) { if(c640[0].COPT.HasValue) dd = c640[0].COPT.Value; // 비중. DOGUM = c640[0].COPT2.HasValue?c640[0].COPT2.Value:0; // 도금. //case "DI100_E": DOGUM = 0.04; //EGI 전기아연도금강판(냉연철판) //if (DI100_G) // GI 용융아연도금강판(냉연철판) //{ // if (Size[0] < 0.6) // DOGUM = 0.244; // else if (Size[0] < 1.2) // DOGUM = 0.305; // else // DOGUM = 0.381; //} } return chulpan(Size[0], dd, DOGUM, Size[1], Size[7], ms, true); } private static decimal chulpan(decimal cdoo, Nullable bijung, decimal dogum, decimal cpok, decimal cgil, decimal qty, bool round) { // (두께 * 7.85 + 도금량) * 폭* 길이(M) / 1000 decimal res = (cdoo * (bijung.HasValue?bijung.Value:0) + dogum) * (cpok * cgil) / 1000; if(round) return Math.Round(res, (res >= 100 ? 0 : 1), MidpointRounding.AwayFromZero) * qty; else return Math.Round(res * qty, 0, MidpointRounding.AwayFromZero); } #endregion #region DI200 경량형강1 private static decimal DI200(CF610 c, decimal[] Size, decimal ms) { // ((폭1- 두께2 * 2.0) * 두께1 + (폭2 * 두께2 * 2.0)) * 0.00000785; decimal cukg = ((Size[2] - Size[5] * 2.0m) * Size[4] + (Size[3] * Size[5] * 2.0m)) * 0.00000785m; decimal res = cukg * Size[7]; return Math.Round(res, ((res >= 100) ? 0 : 1), MidpointRounding.AwayFromZero) * ms; } #endregion #region DI_PI SML'S, WELDED private static decimal DI_PI(CF610 c, decimal[] Size, decimal ms) { // (외경-두께)*두께*0.02466*M decimal T = Size[0]; decimal P = Size[6]; decimal L = Size[7]; decimal res = Math.Round((P - T) * T * 0.02466m * L, MidpointRounding.AwayFromZero) * ms; return res; } #endregion #region DI_SP SQ/PIPE private static decimal DI_SP(CF610 c, decimal[] Size, decimal ms) { // (A+B)-(3.287*두께) * 두께 * 0.0157 * M =((A+B)-(3.287*T))*T*0.0157 decimal A = Size[2]; decimal B = Size[3]; decimal T = Size[4]; decimal res = Math.Round(((A + B) - (3.287m * T)) * T * 0.0157m * Size[7], MidpointRounding.AwayFromZero) * ms; return res; } #endregion #region GetUnitWeight private static CF640[] GetUnitWeight(string CID, CF610 c610, string ksjis, decimal[] Size) { SqlRepository steelDBInfo = SqlRepository.GetInstance(CID); var cf640s = from r in steelDBInfo.CF640PR where r.REFCODE == c610.REFCODE && (Size[0] == -1 || Size[0] == r.CDOO) && (Size[1] == -1 || Size[1] == r.CPOK) && (Size[2] == -1 || Size[2] == r.CH1) && (Size[3] == -1 || Size[3] == r.CH2) && (Size[4] == -1 || Size[4] == r.CT1) && (Size[5] == -1 || Size[5] == r.CT2) && (Size[6] == -1 || Size[6] == r.CPI1) && (Size[7] == -1 || Size[7] == r.CGIL) && (c610.USEJIS== "N" || r.KSJIS == (ksjis == "" ? "KS" : ksjis)) // c.KSJIS select r; return cf640s.ToArray(); } #endregion #endregion } } */