Blame view

netcore/src/Modularity/Extend/NCC.Extend/AttendanceSummarySourceHelper.cs 2.82 KB
e5f8ae55   “wangming”   ```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  using NCC.Extend.Entitys.Enum;
  using NCC.Extend.Entitys.lq_attendance_summary;
  
  namespace NCC.Extend
  {
      /// <summary>
      /// 考勤汇总数据来源识别(Excel 导入 vs 打卡同步)
      /// </summary>
      public static class AttendanceSummarySourceHelper
      {
          /// <summary>Excel 导入备注前缀</summary>
          public const string ExcelImportRemarkPrefix = "[Excel导入]";
  
          /// <summary>打卡同步备注特征</summary>
          public const string PunchSyncRemarkMarker = "系统按考勤打卡汇总生成";
  
          /// <summary>
          /// 构建导入备注(带来源前缀)
          /// </summary>
          public static string BuildImportRemark(string userRemark)
          {
              if (string.IsNullOrWhiteSpace(userRemark))
              {
                  return ExcelImportRemarkPrefix;
              }
  
              if (userRemark.StartsWith(ExcelImportRemarkPrefix))
              {
                  return userRemark;
              }
  
              return ExcelImportRemarkPrefix + userRemark;
          }
  
          /// <summary>
          /// 是否 Excel 导入来源
          /// </summary>
          public static bool IsExcelImport(LqAttendanceSummaryEntity entity)
          {
              if (entity == null)
              {
                  return false;
              }
  
              if (entity.DataSource == (int)AttendanceSummaryDataSourceEnum.Excel导入)
              {
                  return true;
              }
  
              if (!string.IsNullOrEmpty(entity.Remark) && entity.Remark.StartsWith(ExcelImportRemarkPrefix))
              {
                  return true;
              }
  
              return entity.DataSource == 0
                  && !string.IsNullOrEmpty(entity.Remark)
                  && !entity.Remark.Contains(PunchSyncRemarkMarker);
          }
  
          /// <summary>
          /// 是否 Excel 导入来源(列表行)
          /// </summary>
          public static bool IsExcelImport(string remark, int dataSource)
          {
              if (dataSource == (int)AttendanceSummaryDataSourceEnum.Excel导入)
              {
                  return true;
              }
  
              if (!string.IsNullOrEmpty(remark) && remark.StartsWith(ExcelImportRemarkPrefix))
              {
                  return true;
              }
  
              if (dataSource == (int)AttendanceSummaryDataSourceEnum.打卡同步)
              {
                  return false;
              }
  
              return !string.IsNullOrEmpty(remark) && !remark.Contains(PunchSyncRemarkMarker);
          }
  
          /// <summary>
          /// 解析数据来源枚举值
          /// </summary>
          public static int ResolveDataSource(string remark, int dataSource)
          {
              return IsExcelImport(remark, dataSource)
                  ? (int)AttendanceSummaryDataSourceEnum.Excel导入
                  : (int)AttendanceSummaryDataSourceEnum.打卡同步;
          }
      }
  }