BICommonWay.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /// <summary>
  33. /// 多个拼接in条件
  34. /// </summary>
  35. /// <param name="condName"></param>
  36. /// <param name="scIds"></param>
  37. /// <returns></returns>
  38. public static string ManyScSql(string condName, List<string> scIds)
  39. {
  40. StringBuilder scSql = new();
  41. if (scIds.Count > 0)
  42. {
  43. scSql.Append($" {condName} in (");
  44. for (int i = 0; i < scIds.Count; i++)
  45. {
  46. if (i == scIds.Count - 1)
  47. scSql.Append($"'{scIds[i]}'");
  48. else
  49. scSql.Append($"'{scIds[i]}',");
  50. }
  51. scSql.Append($" )");
  52. }
  53. return scSql.ToString();
  54. }
  55. }
  56. }