BICommonWay.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace TEAMModelOS.SDK.Models.Service.BI
  7. {
  8. public static class BICommonWay
  9. {
  10. /// <summary>
  11. /// 字串类型分割成double类型数组,在指定位置赋值
  12. /// </summary>
  13. /// <param name="source">需要分割的字符</param>
  14. /// <param name="splitChar">分割字符</param>
  15. /// <param name="indexes">索引</param>
  16. /// <param name="num">需要加减数量</param>
  17. /// <returns></returns>
  18. public static string SplitStr(string source, char splitChar, int indexes, int num)
  19. {
  20. string str = null;
  21. if (source != null)
  22. {
  23. double[] temps = Array.ConvertAll<string, double>(source.Split(splitChar), s => double.Parse(s));
  24. temps[indexes] = temps[indexes] + num;
  25. str = string.Join(splitChar, temps);
  26. }
  27. if (str != null)
  28. return str;
  29. else
  30. return source;
  31. }
  32. public static string ManyScSql(string name, List<string> scIds)
  33. {
  34. StringBuilder scSql = new();
  35. if (scIds.Count > 0)
  36. {
  37. scSql.Append($"c.{name} in (");
  38. for (int i = 0; i < scIds.Count; i++)
  39. {
  40. if (i == scIds.Count - 1)
  41. scSql.Append($"'{scIds[i]}'");
  42. else
  43. scSql.Append($"'{scIds[i]}',");
  44. }
  45. scSql.Append($" )");
  46. }
  47. return scSql.ToString();
  48. }
  49. }
  50. }