Kaynağa Gözat

流程模板启用停用接口
流程分页查询接口
流程版本更新接口

ylchen 4 yıl önce
ebeveyn
işleme
86237fd291

+ 11 - 3
WorkFlowApi/WorkFlowApi.Business/BaseBusiness.cs

@@ -273,10 +273,18 @@ namespace WorkFlowApi.Business
273 273
             List<SqlParameter> ps = new List<SqlParameter>();
274 274
             foreach (var p in Prop.Where(p => p.Name.ToLower() != KeyField.ToLower()))
275 275
             {
276
-                if (string.IsNullOrEmpty(fieldvalues)) { fieldvalues = string.Format("[{0}]=@{1}", p.Name, p.Name); }
277
-                else { fieldvalues += string.Format(",[{0}]=@{1}", p.Name, p.Name); }
276
+                var value = p.GetValue(entity, null) ?? DBNull.Value;
277
+                if (value != null)
278
+                {
279
+                    if (value.ToString() != "")
280
+                    {
281
+                        if (string.IsNullOrEmpty(fieldvalues)) { fieldvalues = string.Format("[{0}]=@{1}", p.Name, p.Name); }
282
+                        else { fieldvalues += string.Format(",[{0}]=@{1}", p.Name, p.Name); }
278 283
 
279
-                ps.Add(new SqlParameter(string.Format("@{0}", p.Name), p.GetValue(entity, null) ?? DBNull.Value));
284
+                        ps.Add(new SqlParameter(string.Format("@{0}", p.Name), p.GetValue(entity, null) ?? DBNull.Value));
285
+                    }
286
+                }
287
+                   
280 288
             }
281 289
 
282 290
             string sql = string.Format("update [{0}] set {1} where [{2}]='{3}';", type.Name, fieldvalues, KeyField, KeyProp?.GetValue(entity, null) ?? null);

+ 69 - 7
WorkFlowApi/WorkFlowApi.Business/Scheme/WFSchemeInfoBusiness.cs

@@ -12,6 +12,7 @@ using WorkFlowApi.Entity.SchemeView;
12 12
 using WorkFlowApi.IBusiness.Scheme;
13 13
 using WorkFlowApi.Utility;
14 14
 using WorkFlowApi.ViewModels.Input;
15
+using WorkFlowApi.ViewModels.View;
15 16
 
16 17
 namespace WorkFlowApi.Business.Scheme
17 18
 {
@@ -41,7 +42,7 @@ namespace WorkFlowApi.Business.Scheme
41 42
                     strWhereSql.AppendFormat(" AND t.F_Category = '{0}' )", getSchemeInfoPageListReq.category);
42 43
                 }
43 44
 
44
-                string fields = string.Join(",", Prop.Select(p => string.Format("[{0}]", p.Name))) + "F_Type,F_CreateDate,F_CreateUserId,F_CreateUserName";
45
+                string fields = string.Join(",", Prop.Select(p => string.Format("[{0}]", p.Name))) + ",F_Type,F_CreateDate,F_CreateUserId,F_CreateUserName";
45 46
                 var dt = DbHelperSQL.RunPagination("V_SchemeInfo", KeyField, fields, strWhereSql.ToString(), "ORDER BY F_CreateDate desc", getSchemeInfoPageListReq.pagesize, getSchemeInfoPageListReq.page, true, out RecordCount);
46 47
                 return dt.ConvertToList<SchemeInfoEntityView>();
47 48
             }
@@ -53,6 +54,29 @@ namespace WorkFlowApi.Business.Scheme
53 54
           
54 55
         }
55 56
 
57
+        public List<SchemeView> GetSchemePageList(GetSchemePageListReq  getSchemePageListReq, out int RecordCount)
58
+        {
59
+            try
60
+            {
61
+                var strWhereSql = new StringBuilder();
62
+                if (!getSchemePageListReq.schemeInfoId.IsNullOrEmpty())
63
+                {
64
+                    strWhereSql.AppendFormat("and F_SchemeInfoId = '{0}'", getSchemePageListReq.schemeInfoId);
65
+                }
66
+
67
+              var dt = wFSchemeBusiness.GetDataTablePage(strWhereSql.ToString(), "ORDER BY F_CreateDate DESC", getSchemePageListReq.pagesize, getSchemePageListReq.page,out RecordCount).ConvertToList<T_WF_Scheme>();
68
+
69
+              return dt.MapToList<SchemeView>();
70
+
71
+            }
72
+            catch (Exception)
73
+            {
74
+
75
+                throw;
76
+            }
77
+
78
+        }
79
+
56 80
 
57 81
         public void SaveSchemeInfo(SaveSchemeInfoReq  saveSchemeInfoReq, T_Sys_UserAccount currentUser)
58 82
         {
@@ -76,8 +100,6 @@ namespace WorkFlowApi.Business.Scheme
76 100
                     InsertExe(t_WF_SchemeInfo);
77 101
                     wFSchemeBusiness.InsertExe(t_WF_Scheme);
78 102
 
79
-
80
-
81 103
                 }
82 104
                 else
83 105
                 {
@@ -108,14 +130,10 @@ namespace WorkFlowApi.Business.Scheme
108 130
 
109 131
                     }
110 132
 
111
-                  
112
-
113
-
114 133
 
115 134
                 }
116 135
 
117 136
                
118
-
119 137
             }
120 138
             catch (Exception e)
121 139
             {
@@ -139,5 +157,49 @@ namespace WorkFlowApi.Business.Scheme
139 157
             }
140 158
             
141 159
         }
160
+
161
+        public void UpdateState(string keyValue, int state, T_Sys_UserAccount currentUser)
162
+        {
163
+            try
164
+            {
165
+                T_WF_SchemeInfo t_WF_SchemeInfo = new T_WF_SchemeInfo()
166
+                {
167
+                    F_Id = keyValue,
168
+                    F_EnabledMark = state
169
+                };
170
+                UpdateExe(t_WF_SchemeInfo);
171
+
172
+            }
173
+            catch (Exception)
174
+            {
175
+
176
+                throw;
177
+            }
178
+           
179
+        }
180
+
181
+        public void UpdateScheme(string schemeInfoId, string schemeId, T_Sys_UserAccount currentUser)
182
+        {
183
+            try
184
+            {
185
+                T_WF_Scheme t_WF_Scheme = wFSchemeBusiness.GetEntity(schemeId);
186
+                T_WF_SchemeInfo t_WF_SchemeInfo = new T_WF_SchemeInfo()
187
+                {
188
+                    F_Id= schemeInfoId,
189
+                    F_SchemeId= schemeId
190
+                };
191
+                if (t_WF_Scheme.F_Type != 1)
192
+                {
193
+                    t_WF_SchemeInfo.F_EnabledMark = 0;
194
+                }
195
+
196
+                UpdateExe(t_WF_SchemeInfo);
197
+            }
198
+            catch (Exception)
199
+            {
200
+
201
+                throw;
202
+            }
203
+        }
142 204
     }
143 205
 }

+ 4 - 0
WorkFlowApi/WorkFlowApi.IBusiness/Scheme/IWFSchemeInfoBusiness.cs

@@ -7,13 +7,17 @@ using WorkFlowApi.Entity;
7 7
 using WorkFlowApi.Entity.SchemeEntity;
8 8
 using WorkFlowApi.Entity.SchemeView;
9 9
 using WorkFlowApi.ViewModels.Input;
10
+using WorkFlowApi.ViewModels.View;
10 11
 
11 12
 namespace WorkFlowApi.IBusiness.Scheme
12 13
 {
13 14
    public interface IWFSchemeInfoBusiness : IBaseBusiness<T_WF_SchemeInfo>
14 15
     {
15 16
         List<SchemeInfoEntityView> GetSchemeInfoPageList(GetSchemeInfoPageListReq getSchemeInfoPageListReq, out int RecordCount);
17
+        List<SchemeView> GetSchemePageList(GetSchemePageListReq getSchemePageListReq, out int RecordCount);
16 18
         void SaveSchemeInfo(SaveSchemeInfoReq  saveSchemeInfoReq, T_Sys_UserAccount currentUser);
17 19
         void DeleteSchemeInfo(string keyValue, T_Sys_UserAccount currentUser);
20
+        void UpdateState(string keyValue, int state, T_Sys_UserAccount currentUser);
21
+        void UpdateScheme(string schemeInfoId, string schemeId, T_Sys_UserAccount currentUser);
18 22
     }
19 23
 }

+ 0 - 12
WorkFlowApi/WorkFlowApi.Models/Class1.cs

@@ -1,12 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Threading.Tasks;
6
-
7
-namespace WorkFlowApi.ViewModels
8
-{
9
-    class Class1
10
-    {
11
-    }
12
-}

+ 16 - 0
WorkFlowApi/WorkFlowApi.Models/Input/GetSchemePageListReq.cs

@@ -0,0 +1,16 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace WorkFlowApi.ViewModels.Input
8
+{
9
+    public class GetSchemePageListReq: PageInput
10
+    {
11
+        /// <summary>
12
+        /// 流程信息主键
13
+        /// </summary>
14
+        public string schemeInfoId { get; set; }
15
+    }
16
+}

+ 43 - 0
WorkFlowApi/WorkFlowApi.Models/View/SchemeView.cs

@@ -0,0 +1,43 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace WorkFlowApi.ViewModels.View
8
+{
9
+    public class SchemeView
10
+    {
11
+        public string Id { get; set; }
12
+        /// <summary> 
13
+        /// 流程模板信息主键 
14
+        /// </summary> 
15
+        /// <returns></returns> 
16
+        public string SchemeInfoId { get; set; }
17
+        /// <summary> 
18
+        /// 1.正式2.草稿 
19
+        /// </summary> 
20
+        /// <returns></returns> 
21
+        public int? Type { get; set; }
22
+        /// <summary> 
23
+        /// 创建时间 
24
+        /// </summary> 
25
+        /// <returns></returns> 
26
+        public DateTime? CreateDate { get; set; }
27
+        /// <summary> 
28
+        /// 创建人主键 
29
+        /// </summary> 
30
+        /// <returns></returns> 
31
+        public string CreateUserId { get; set; }
32
+        /// <summary> 
33
+        /// 创建人名字 
34
+        /// </summary> 
35
+        /// <returns></returns> 
36
+        public string CreateUserName { get; set; }
37
+        /// <summary> 
38
+        /// 流程模板内容 
39
+        /// </summary> 
40
+        /// <returns></returns> 
41
+        public string Content { get; set; }
42
+    }
43
+}

+ 2 - 1
WorkFlowApi/WorkFlowApi.Models/WorkFlowApi.ViewModels.csproj

@@ -42,7 +42,7 @@
42 42
     <Reference Include="System.Xml" />
43 43
   </ItemGroup>
44 44
   <ItemGroup>
45
-    <Compile Include="Class1.cs" />
45
+    <Compile Include="Input\GetSchemePageListReq.cs" />
46 46
     <Compile Include="Input\SaveSchemeInfoReq.cs" />
47 47
     <Compile Include="Input\GetSchemeInfoPageListReq.cs" />
48 48
     <Compile Include="Input\LoginInput.cs" />
@@ -50,6 +50,7 @@
50 50
     <Compile Include="Input\UserAccountInput.cs" />
51 51
     <Compile Include="Properties\AssemblyInfo.cs" />
52 52
     <Compile Include="View\SchemeInfoView.cs" />
53
+    <Compile Include="View\SchemeView.cs" />
53 54
     <Compile Include="View\UserAccountView.cs" />
54 55
   </ItemGroup>
55 56
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

+ 85 - 5
WorkFlowApi/WorkFlowApi/Controllers/Scheme/WFSchemeController.cs

@@ -20,6 +20,7 @@ namespace WorkFlowApi.Controllers.Scheme
20 20
     public class WFSchemeController : BaseController
21 21
     {
22 22
         private readonly IWFSchemeInfoBusiness  _wFSchemeInfo;
23
+    
23 24
         /// <summary>
24 25
         /// 构造函数
25 26
         /// </summary>
@@ -34,6 +35,7 @@ namespace WorkFlowApi.Controllers.Scheme
34 35
         [HttpPost]
35 36
         public IHttpActionResult GetSchemeInfoPageList(GetSchemeInfoPageListReq  getSchemeInfoPageListReq)
36 37
         {
38
+            LogHelper.Info("GetSchemeInfoPageList-请求开始:"+getSchemeInfoPageListReq.ToJson()+"\n");
37 39
             int total = 0;
38 40
             try
39 41
             {
@@ -42,11 +44,41 @@ namespace WorkFlowApi.Controllers.Scheme
42 44
                     return Error("请求参数不正确");
43 45
                 }
44 46
                 var list= _wFSchemeInfo.GetSchemeInfoPageList(getSchemeInfoPageListReq,out total);
47
+                LogHelper.Info("GetSchemeInfoPageList-请求结束:" + list.ToJson() + "\n");
45 48
                 return Success("成功", list.MapToList<SchemeInfoView>(), total);
49
+               
46 50
             }
47
-            catch (Exception)
51
+            catch (Exception e)
48 52
             {
53
+                LogHelper.Error("GetSchemeInfoPageList-请求异常:" + e.Message + "\n");
54
+                return Error("系统异常");
55
+            }
56
+
57
+        }
58
+        /// <summary>
59
+        /// 获取流程分页信息
60
+        /// </summary>
61
+        /// <param name="getSchemePageListReq"></param>
62
+        /// <returns></returns>
63
+        [HttpPost]
64
+        public IHttpActionResult GetSchemePageList(GetSchemePageListReq  getSchemePageListReq)
65
+        {
66
+            LogHelper.Info("GetSchemePageList-请求开始:" + getSchemePageListReq.ToJson() + "\n");
67
+            int total = 0;
68
+            try
69
+            {
70
+                if (getSchemePageListReq == null)
71
+                {
72
+                    return Error("请求参数不正确");
73
+                }
74
+                var list = _wFSchemeInfo.GetSchemePageList(getSchemePageListReq, out total);
75
+                LogHelper.Info("GetSchemePageList-请求结束:" + list.ToJson() + "\n");
76
+                return Success("成功", list, total);
49 77
 
78
+            }
79
+            catch (Exception e)
80
+            {
81
+                LogHelper.Error("GetSchemePageList-请求异常:" + e.Message + "\n");
50 82
                 return Error("系统异常");
51 83
             }
52 84
 
@@ -59,6 +91,7 @@ namespace WorkFlowApi.Controllers.Scheme
59 91
         [HttpPost]
60 92
         public IHttpActionResult SaveSchemeInfo(SaveSchemeInfoReq  saveSchemeInfoReq)
61 93
         {
94
+            LogHelper.Info("SaveSchemeInfo-请求开始:" + saveSchemeInfoReq.ToJson() + "\n");
62 95
             try
63 96
             {
64 97
                 T_WF_SchemeInfo t_WF_SchemeInfo = saveSchemeInfoReq.schemeInfo.MapTo<T_WF_SchemeInfo>();
@@ -71,11 +104,12 @@ namespace WorkFlowApi.Controllers.Scheme
71 104
                 }
72 105
               
73 106
                 _wFSchemeInfo.SaveSchemeInfo(saveSchemeInfoReq, CurrentUser);
107
+                LogHelper.Info("SaveSchemeInfo-请求结束:" + "保存成功" + "\n");
74 108
                 return Success("保存成功");
75 109
             }
76
-            catch (Exception)
110
+            catch (Exception e)
77 111
             {
78
-
112
+                LogHelper.Error("SaveSchemeInfo-请求异常:" + e.Message + "\n");
79 113
                 return Error("系统异常");
80 114
             }
81 115
         }
@@ -88,16 +122,62 @@ namespace WorkFlowApi.Controllers.Scheme
88 122
  
89 123
         public IHttpActionResult DeleteSchemeInfo(string keyValue)
90 124
         {
125
+            LogHelper.Info("DeleteSchemeInfo-请求开始:" + keyValue + "\n");
91 126
             try
92 127
             {
93 128
                 _wFSchemeInfo.DeleteSchemeInfo(keyValue, CurrentUser);
129
+                LogHelper.Info("DeleteSchemeInfo-请求结束:" + "删除成功" + "\n");
94 130
                 return Success("删除成功");
95 131
             }
96
-            catch (Exception)
132
+            catch (Exception e)
97 133
             {
98
-
134
+                LogHelper.Error("DeleteSchemeInfo-请求异常:" + e.Message + "\n");
135
+                return Error("系统异常");
136
+            }
137
+        }
138
+        /// <summary>
139
+        /// 启用/停用
140
+        /// </summary>
141
+        /// <param name="keyValue"></param>
142
+        /// <param name="state"></param>
143
+        /// <returns></returns>
144
+        public IHttpActionResult UpdateState(string keyValue,int state)
145
+        {
146
+            LogHelper.Info("UpdateState-请求开始:" + keyValue+":"+ state + "\n");
147
+            try
148
+            {
149
+                _wFSchemeInfo.UpdateState(keyValue, state, CurrentUser);
150
+                LogHelper.Info("UpdateState-请求结束:" +"操作成功" + "\n");
151
+                return Success((state == 1 ? "启用" : "禁用") + "成功!");
152
+            }
153
+            catch (Exception e)
154
+            {
155
+                LogHelper.Error("UpdateState-请求异常:" +e.Message + "\n");
156
+                return Error("系统异常");
157
+            }
158
+        }
159
+        /// <summary>
160
+        /// 更新模板版本
161
+        /// </summary>
162
+        /// <param name="schemeInfoId"></param>
163
+        /// <param name="schemeId"></param>
164
+        /// <returns></returns>
165
+        public IHttpActionResult UpdateScheme(string schemeInfoId, string schemeId)
166
+        {
167
+            LogHelper.Info("UpdateScheme-请求开始:" + schemeInfoId + ";" + schemeId + "\n");
168
+            try
169
+            {
170
+                _wFSchemeInfo.UpdateScheme(schemeInfoId, schemeId, CurrentUser);
171
+                LogHelper.Info("UpdateScheme-请求结束:" + "操作成功" + "\n");
172
+                return Success("更新成功!");
173
+            }
174
+            catch (Exception e)
175
+            {
176
+                LogHelper.Error("UpdateScheme-请求异常:" + e.Message + "\n");
99 177
                 return Error("系统异常");
100 178
             }
101 179
         }
180
+
181
+
102 182
     }
103 183
 }