|
|
@@ -0,0 +1,832 @@
|
|
|
1
|
+using Newtonsoft.Json;
|
|
|
2
|
+using Newtonsoft.Json.Linq;
|
|
|
3
|
+using RMYY_CallCenter_Api.Bll;
|
|
|
4
|
+using RMYY_CallCenter_Api.DB;
|
|
|
5
|
+using RMYY_CallCenter_Api.Model;
|
|
|
6
|
+using RMYY_CallCenter_Api.Utility;
|
|
|
7
|
+using System;
|
|
|
8
|
+using System.Collections.Generic;
|
|
|
9
|
+using System.IO;
|
|
|
10
|
+using System.Linq;
|
|
|
11
|
+using System.Net;
|
|
|
12
|
+using System.Net.Security;
|
|
|
13
|
+using System.Security.Cryptography.X509Certificates;
|
|
|
14
|
+using System.Text;
|
|
|
15
|
+using System.Web.Mvc;
|
|
|
16
|
+
|
|
|
17
|
+namespace RMYY_CallCenter_Api.Controllers
|
|
|
18
|
+{
|
|
|
19
|
+
|
|
|
20
|
+ public class HospitalUserController : BaseController
|
|
|
21
|
+ {
|
|
|
22
|
+ private string ip = "";
|
|
|
23
|
+ private string port = "";
|
|
|
24
|
+ private string master = "";
|
|
|
25
|
+ #region http
|
|
|
26
|
+ /// <summary>
|
|
|
27
|
+ /// HTTP POST方式请求数据
|
|
|
28
|
+ /// </summary>
|
|
|
29
|
+ /// <param name="url">URL.</param>
|
|
|
30
|
+ /// <param name="param">POST的数据</param>
|
|
|
31
|
+ /// <returns></returns>
|
|
|
32
|
+ public static string HttpPost(string url, string param = null, string contentType = "application/json;charset=utf-8"
|
|
|
33
|
+ )
|
|
|
34
|
+ {
|
|
|
35
|
+ HttpWebRequest request;
|
|
|
36
|
+
|
|
|
37
|
+ //如果是发送HTTPS请求
|
|
|
38
|
+ if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
|
|
|
39
|
+ {
|
|
|
40
|
+ ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
|
|
|
41
|
+ request = WebRequest.Create(url) as HttpWebRequest;
|
|
|
42
|
+ request.ProtocolVersion = HttpVersion.Version10;
|
|
|
43
|
+ }
|
|
|
44
|
+ else
|
|
|
45
|
+ {
|
|
|
46
|
+ request = WebRequest.Create(url) as HttpWebRequest;
|
|
|
47
|
+ }
|
|
|
48
|
+ request.Method = "POST";
|
|
|
49
|
+ request.ContentType = contentType;
|
|
|
50
|
+ request.Accept = "*/*";
|
|
|
51
|
+ request.Timeout = 15000;
|
|
|
52
|
+ request.AllowAutoRedirect = false;
|
|
|
53
|
+
|
|
|
54
|
+ StreamWriter requestStream = null;
|
|
|
55
|
+ WebResponse response = null;
|
|
|
56
|
+ string responseStr = null;
|
|
|
57
|
+
|
|
|
58
|
+ try
|
|
|
59
|
+ {
|
|
|
60
|
+ requestStream = new StreamWriter(request.GetRequestStream());
|
|
|
61
|
+ requestStream.Write(param);
|
|
|
62
|
+ requestStream.Close();
|
|
|
63
|
+
|
|
|
64
|
+ response = request.GetResponse();
|
|
|
65
|
+ if (response != null)
|
|
|
66
|
+ {
|
|
|
67
|
+ StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
|
|
|
68
|
+ responseStr = reader.ReadToEnd();
|
|
|
69
|
+ reader.Close();
|
|
|
70
|
+ }
|
|
|
71
|
+ }
|
|
|
72
|
+ catch (Exception ex)
|
|
|
73
|
+ {
|
|
|
74
|
+ }
|
|
|
75
|
+ finally
|
|
|
76
|
+ {
|
|
|
77
|
+ request = null;
|
|
|
78
|
+ requestStream = null;
|
|
|
79
|
+ response = null;
|
|
|
80
|
+ }
|
|
|
81
|
+
|
|
|
82
|
+ return responseStr;
|
|
|
83
|
+ }
|
|
|
84
|
+ private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
|
|
|
85
|
+ {
|
|
|
86
|
+ return true; //总是接受
|
|
|
87
|
+ }
|
|
|
88
|
+ #endregion
|
|
|
89
|
+ #region 术语查询接口
|
|
|
90
|
+ public class Term
|
|
|
91
|
+ {
|
|
|
92
|
+ public int iDomainID { set; get; }//术语ID
|
|
|
93
|
+ public string cDomainCode { set; get; }//术语编码
|
|
|
94
|
+ public string cDomainName { set; get; }//术语名称
|
|
|
95
|
+ public string cDomainDescription { set; get; }//描述
|
|
|
96
|
+ public int iState { set; get; }//描述1 有效 0 无效
|
|
|
97
|
+ }
|
|
|
98
|
+ public ActionResult TermQuery()
|
|
|
99
|
+ {
|
|
|
100
|
+ var responseString = HttpPost ($"http://{ip}:{port}/mdm/domain",null );
|
|
|
101
|
+ List <Term> jo = JsonConvert.DeserializeObject<List<Term>>(responseString);
|
|
|
102
|
+ return Success("获取成功", jo);
|
|
|
103
|
+ }
|
|
|
104
|
+ #endregion
|
|
|
105
|
+ #region 术语值域查询接口
|
|
|
106
|
+ public class Termrange
|
|
|
107
|
+ {
|
|
|
108
|
+ public int id { set; get; }//术语值域主键
|
|
|
109
|
+ public string cDomainCode { set; get; }//术语代码
|
|
|
110
|
+ public string cCode { set; get; }//值域
|
|
|
111
|
+ public string cName { set; get; }//值描述
|
|
|
112
|
+ public string cDomainType { set; get; }//术语类别
|
|
|
113
|
+ public string cDescription { set; get; }//描述
|
|
|
114
|
+ public string iState { set; get; }//1 有效 0 无效
|
|
|
115
|
+ }
|
|
|
116
|
+ public ActionResult TermrangeQuery()
|
|
|
117
|
+ {
|
|
|
118
|
+ var responseString = HttpPost($"http://{ip}:{port}/mdm/domain", null);
|
|
|
119
|
+ List<Termrange> jo = JsonConvert.DeserializeObject<List<Termrange>>(responseString);
|
|
|
120
|
+ return Success("获取成功", jo);
|
|
|
121
|
+ }
|
|
|
122
|
+ #endregion
|
|
|
123
|
+
|
|
|
124
|
+
|
|
|
125
|
+ #region 获取机构
|
|
|
126
|
+ /// <summary>
|
|
|
127
|
+ /// 机构
|
|
|
128
|
+ /// </summary>
|
|
|
129
|
+ public class pubDictHospital
|
|
|
130
|
+ {
|
|
|
131
|
+ public string cHosCode { set; get; }//编码主键
|
|
|
132
|
+ public string cHosName { set; get; }//名称
|
|
|
133
|
+ public string cHelpCode { set; get; }//拼音码
|
|
|
134
|
+ public string cHosLisCode { set; get; }//检验条码专用机构编码
|
|
|
135
|
+ public int useFlag { set; get; }//启用停用
|
|
|
136
|
+ }
|
|
|
137
|
+
|
|
|
138
|
+ public List <pubDictHospital> MechanismHospitals()
|
|
|
139
|
+ {
|
|
|
140
|
+ Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
|
141
|
+ keyValuePairs.Add("pubDictHospital", "pubDictHospital");
|
|
|
142
|
+ var responseString = HttpPost($"http://{ip}:{port}/{master}/webApi/pubDictHospital", keyValuePairs.ToJson());
|
|
|
143
|
+ List<pubDictHospital> jo = JsonConvert.DeserializeObject<List<pubDictHospital>>(responseString);
|
|
|
144
|
+ return jo;
|
|
|
145
|
+ }
|
|
|
146
|
+ #endregion
|
|
|
147
|
+ #region 获取院区
|
|
|
148
|
+ /// <summary>
|
|
|
149
|
+ /// 院区
|
|
|
150
|
+ /// </summary>
|
|
|
151
|
+ public class DictHospitals
|
|
|
152
|
+ {
|
|
|
153
|
+ public int noHospital { set; get; }//主键id
|
|
|
154
|
+ public string HosSectionCode { set; get; }//院区代码
|
|
|
155
|
+ public string HosSectionName { set; get; }//院区名称
|
|
|
156
|
+ public string pycode { set; get; }//拼音码
|
|
|
157
|
+ public string HosStandCode { set; get; }//院区标准代码
|
|
|
158
|
+ public string cHosCode { set; get; }//医疗机构代码
|
|
|
159
|
+ public string firsttitle { set; get; }//医疗机构名称
|
|
|
160
|
+ public string pycParentHosCodeode { set; get; }//上级机构代码
|
|
|
161
|
+ public string hosTypeCode { set; get; }//机构类型
|
|
|
162
|
+ public int useFlag { set; get; }//启用停用
|
|
|
163
|
+ }
|
|
|
164
|
+ public IEnumerable <DictHospitals> YardHospitals(string cHosCode)
|
|
|
165
|
+ {
|
|
|
166
|
+ Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
|
167
|
+ keyValuePairs.Add("DictHospitals", "DictHospitals");
|
|
|
168
|
+ var responseString = HttpPost($"http://{ip}:{port}/{master}/webApi/DictHospitals", keyValuePairs.ToJson());
|
|
|
169
|
+ List<DictHospitals> jo = JsonConvert.DeserializeObject<List<DictHospitals>>(responseString);
|
|
|
170
|
+ var Hospitals = jo.Where (x => x.cHosCode == cHosCode && x.useFlag == 1);
|
|
|
171
|
+ var list = new T_Wowo_repairyqbll().GetListall();
|
|
|
172
|
+ if (Hospitals!=null && Hospitals.Count ()>0)
|
|
|
173
|
+ {
|
|
|
174
|
+ foreach (var it in Hospitals)
|
|
|
175
|
+ {
|
|
|
176
|
+ if (list != null && list.Count > 0)
|
|
|
177
|
+ {
|
|
|
178
|
+ if (it.useFlag !=1)
|
|
|
179
|
+ continue;
|
|
|
180
|
+ if (list.Where(x => x.T_Woname == it.HosSectionName).Count() > 0)
|
|
|
181
|
+ continue;
|
|
|
182
|
+ T_Wowo_repairyq model = new T_Wowo_repairyq();
|
|
|
183
|
+ model.T_Woname = it.HosSectionName;
|
|
|
184
|
+ model.T_Hospital = it.noHospital;
|
|
|
185
|
+ int n = new T_Wowo_repairyqbll().Addrepairitems(model);
|
|
|
186
|
+ if (n >0)
|
|
|
187
|
+ {
|
|
|
188
|
+ Department(n, model.T_Woname);
|
|
|
189
|
+ }
|
|
|
190
|
+ }
|
|
|
191
|
+ }
|
|
|
192
|
+ }
|
|
|
193
|
+
|
|
|
194
|
+ return Hospitals;
|
|
|
195
|
+ }
|
|
|
196
|
+ #endregion
|
|
|
197
|
+ #region 获取科室
|
|
|
198
|
+ /// <summary>
|
|
|
199
|
+ /// 科室
|
|
|
200
|
+ /// </summary>
|
|
|
201
|
+ public class DictDept
|
|
|
202
|
+ {
|
|
|
203
|
+ public int noDept { set; get; }//主键id
|
|
|
204
|
+ public int nohospital { set; get; }//院区
|
|
|
205
|
+ public string deptname { set; get; }//科室名称
|
|
|
206
|
+ public string deptAlias { set; get; }//科室简介
|
|
|
207
|
+ public string deptCode { set; get; }//科室编码
|
|
|
208
|
+ public int useFlag { set; get; }//启用停用1启用
|
|
|
209
|
+ public string deptParentCode { set; get; }//上级急诊科室
|
|
|
210
|
+ }
|
|
|
211
|
+ public IEnumerable<DictDept> Department(int nohospital,string HosSectionName)
|
|
|
212
|
+ {
|
|
|
213
|
+ Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
|
214
|
+ keyValuePairs.Add("DictDept", "DictDept");
|
|
|
215
|
+ var responseString = HttpPost($"http://{ip}:{port}/{master}/webApi/DictDept", keyValuePairs.ToJson());
|
|
|
216
|
+ List<DictDept> jo = JsonConvert.DeserializeObject<List<DictDept>>(responseString);
|
|
|
217
|
+ var Dept = jo.Where(x => x.nohospital == nohospital && x.useFlag == 1);
|
|
|
218
|
+ var list = new Bll.T_Sys_Department().GetModelList("F_State=1");
|
|
|
219
|
+ var Wowo = new T_Wowo_repairyqbll().GetListall();
|
|
|
220
|
+ var model = Wowo.Where(x => x.T_Woname == HosSectionName);
|
|
|
221
|
+ if (model != null && model.Count() > 0)
|
|
|
222
|
+ {
|
|
|
223
|
+ if (Dept != null && Dept.Count() > 0)
|
|
|
224
|
+ {
|
|
|
225
|
+ foreach (var it in Dept)
|
|
|
226
|
+ {
|
|
|
227
|
+ if (list != null && list.Count > 0)
|
|
|
228
|
+ {
|
|
|
229
|
+ if (it.useFlag != 1)
|
|
|
230
|
+ continue;
|
|
|
231
|
+ if (list.Where(x => x.F_DeptName == it.deptname).Count() > 0)
|
|
|
232
|
+ continue;
|
|
|
233
|
+ Model.T_Sys_Department dModel = new Model.T_Sys_Department();
|
|
|
234
|
+ if (!string .IsNullOrEmpty (it .deptParentCode))
|
|
|
235
|
+ {
|
|
|
236
|
+ var deptParent = list.Where(x => x.F_DeptCode == it.deptParentCode);
|
|
|
237
|
+ if (deptParent!=null && deptParent.Count ()>0)
|
|
|
238
|
+ dModel.F_ParentId = deptParent.FirstOrDefault ().F_DeptId ;
|
|
|
239
|
+ }
|
|
|
240
|
+ dModel.F_Sort = 0;
|
|
|
241
|
+ dModel.F_DeptCode = it.deptCode;
|
|
|
242
|
+ dModel.F_DeptName = it.deptname;
|
|
|
243
|
+ dModel.F_State = 1;
|
|
|
244
|
+ dModel.F_CreateTime = DateTime.Now;
|
|
|
245
|
+ dModel.F_CreateUser = User.F_UserCode;
|
|
|
246
|
+ dModel.T_Woid = model.First().T_Woid;
|
|
|
247
|
+ dModel.F_Location = "";
|
|
|
248
|
+ dModel.F_FloorDistribution = "";
|
|
|
249
|
+ dModel.F_OfficeTelephone = "";
|
|
|
250
|
+ int n = new Bll.T_Sys_Department().Add(dModel);
|
|
|
251
|
+ }
|
|
|
252
|
+ }
|
|
|
253
|
+ }
|
|
|
254
|
+ }
|
|
|
255
|
+ else
|
|
|
256
|
+ return null;
|
|
|
257
|
+
|
|
|
258
|
+ return Dept;
|
|
|
259
|
+ }
|
|
|
260
|
+ #endregion
|
|
|
261
|
+ #region 获取人员
|
|
|
262
|
+ /// <summary>
|
|
|
263
|
+ /// 性别
|
|
|
264
|
+ /// </summary>
|
|
|
265
|
+ public class DictSex
|
|
|
266
|
+ {
|
|
|
267
|
+ public int No_Sex { set; get; }//性别主键
|
|
|
268
|
+ public string SexCode { set; get; }//性别编码
|
|
|
269
|
+ public string SexName { set; get; }//性别名称
|
|
|
270
|
+ }
|
|
|
271
|
+ /// <summary>
|
|
|
272
|
+ /// 职务
|
|
|
273
|
+ /// </summary>
|
|
|
274
|
+ public class DictZhiwu
|
|
|
275
|
+ {
|
|
|
276
|
+ public int No_Zhi { set; get; }//性别主键
|
|
|
277
|
+ public string ZhiCode { set; get; }//性别编码
|
|
|
278
|
+ public string ZhiName { set; get; }//性别名称
|
|
|
279
|
+ }
|
|
|
280
|
+ /// <summary>
|
|
|
281
|
+ /// 人员
|
|
|
282
|
+ /// </summary>
|
|
|
283
|
+ public class DictStaff
|
|
|
284
|
+ {
|
|
|
285
|
+ public int noStaff { set; get; }//主键id
|
|
|
286
|
+ public int noSex { set; get; }//性别
|
|
|
287
|
+ public string staffName { set; get; }//人员姓名
|
|
|
288
|
+ public int noDept { set; get; }//所属科室
|
|
|
289
|
+ public string dhhm { set; get; }//联系电话
|
|
|
290
|
+ public string staffCode { set; get; }//人员编码
|
|
|
291
|
+ public int zw { set; get; }//职务
|
|
|
292
|
+ }
|
|
|
293
|
+ public int Getcode()
|
|
|
294
|
+ {
|
|
|
295
|
+ int UserCode = 0;
|
|
|
296
|
+ string strSql = "select Max(F_UserCode) F_UserCode from T_Sys_UserAccount where (F_See!='5' or F_See is null) ";
|
|
|
297
|
+ object ob = DbHelperSQL.GetSingle(strSql.ToString());
|
|
|
298
|
+ if (ob == null)
|
|
|
299
|
+ {
|
|
|
300
|
+ UserCode = 0;
|
|
|
301
|
+ }
|
|
|
302
|
+ else
|
|
|
303
|
+ {
|
|
|
304
|
+ UserCode = Convert.ToInt32(ob);
|
|
|
305
|
+ }
|
|
|
306
|
+ return UserCode + 1;
|
|
|
307
|
+ }
|
|
|
308
|
+ public IEnumerable<DictStaff> Staff(int noDept,int deptid)
|
|
|
309
|
+ {
|
|
|
310
|
+ Dictionary<string, string> keyValuePair = new Dictionary<string, string>();
|
|
|
311
|
+ keyValuePair.Add("DictSex", "DictSex");
|
|
|
312
|
+ var responseStrings = HttpPost($"http://{ip}:{port}/{master}/webApi/DictSex", keyValuePair.ToJson());
|
|
|
313
|
+ List<DictSex> sex = JsonConvert.DeserializeObject<List<DictSex>>(responseStrings);
|
|
|
314
|
+ Dictionary<string, string> keyValuePairszhiwu = new Dictionary<string, string>();
|
|
|
315
|
+ keyValuePairszhiwu.Add("DictZhiwu", "DictZhiwu");
|
|
|
316
|
+ var respon = HttpPost($"http://{ip}:{port}/{master}/webApi/DictZhiwu", keyValuePairszhiwu.ToJson());
|
|
|
317
|
+ List<DictZhiwu> zhuwu = JsonConvert.DeserializeObject<List<DictZhiwu>>(respon);
|
|
|
318
|
+ Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
|
319
|
+ keyValuePairs.Add("DictStaff", "DictStaff");
|
|
|
320
|
+ var responseString = HttpPost($"http://{ip}:{port}/{master}/webApi/DictStaff", keyValuePairs.ToJson());
|
|
|
321
|
+ List<DictStaff> jo = JsonConvert.DeserializeObject<List<DictStaff>>(responseString);
|
|
|
322
|
+ var user = jo.Where(x => x.noDept == noDept );
|
|
|
323
|
+ var list = new Bll.T_Sys_UserAccount ().GetModelList("F_DeleteFlag=0");
|
|
|
324
|
+ if (user != null && user.Count() > 0)
|
|
|
325
|
+ {
|
|
|
326
|
+ foreach (var it in user)
|
|
|
327
|
+ {
|
|
|
328
|
+ if (list != null && list.Count > 0)
|
|
|
329
|
+ {
|
|
|
330
|
+ if (list.Where(x => x.F_StaffCode == it.staffCode).Count() > 0)
|
|
|
331
|
+ continue;
|
|
|
332
|
+ Model.T_Sys_UserAccount ua = new Model.T_Sys_UserAccount();
|
|
|
333
|
+ int usercode = Getcode();
|
|
|
334
|
+ ua.F_UserCode = usercode.ToString ();
|
|
|
335
|
+ ua.F_UserName = it .staffName;
|
|
|
336
|
+ ua.F_Password = "e10adc3949ba59abbe56e057f20f883e";
|
|
|
337
|
+ ua.F_ExtensionNumber ="";
|
|
|
338
|
+ ua.F_DeptId = deptid;
|
|
|
339
|
+ ua.F_SeatFlag = 0;
|
|
|
340
|
+ ua.F_Telephone = it .dhhm;
|
|
|
341
|
+ var uasex= sex.Where(x => x.No_Sex == it.noSex);
|
|
|
342
|
+ if (uasex!=null && uasex.Count() >0)
|
|
|
343
|
+ ua.F_Sex = uasex.FirstOrDefault ().SexName ;
|
|
|
344
|
+ ua.F_CreateTime = DateTime.Now;
|
|
|
345
|
+ ua.F_EnableFlag = 1;
|
|
|
346
|
+ var uazhuwu = zhuwu.Where(x => x.No_Zhi == it.zw );
|
|
|
347
|
+ if (uazhuwu != null && uazhuwu.Count() > 0)
|
|
|
348
|
+ ua.F_Job = uazhuwu.FirstOrDefault().ZhiName ;
|
|
|
349
|
+ ua.F_DeleteFlag = 0;
|
|
|
350
|
+ new Bll.T_Sys_UserAccount().Add(ua);
|
|
|
351
|
+ }
|
|
|
352
|
+ }
|
|
|
353
|
+ }
|
|
|
354
|
+ return user;
|
|
|
355
|
+ }
|
|
|
356
|
+ #endregion
|
|
|
357
|
+ #region 数据同步接口
|
|
|
358
|
+ /// <summary>
|
|
|
359
|
+ /// 数据同步接口
|
|
|
360
|
+ /// </summary>
|
|
|
361
|
+ /// <returns></returns>
|
|
|
362
|
+ //[Authority]
|
|
|
363
|
+ public ActionResult synchronization(string cHosCode)
|
|
|
364
|
+ {
|
|
|
365
|
+ StreamReader reader = new StreamReader(Request.InputStream);
|
|
|
366
|
+ var postString = reader.ReadToEnd();
|
|
|
367
|
+ JObject paras = null;
|
|
|
368
|
+ paras = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(postString);
|
|
|
369
|
+ var DictInfo = paras["DictInfo"].ToString();
|
|
|
370
|
+ var result = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(DictInfo);
|
|
|
371
|
+ var DictCode = result["DictCode"].ToString();
|
|
|
372
|
+ var RecordChangeType = result["RecordChangeType"].ToString();
|
|
|
373
|
+ var RecordInfo= result["RecordInfo"] == null ? "" : result["RecordInfo"].ToString();
|
|
|
374
|
+ if (DictCode== "DictHospitals")
|
|
|
375
|
+ {
|
|
|
376
|
+ var list = new T_Wowo_repairyqbll().GetListall();
|
|
|
377
|
+ DictHospitals jo = JsonConvert.DeserializeObject<DictHospitals>(RecordInfo);
|
|
|
378
|
+ if (RecordChangeType== "Add")
|
|
|
379
|
+ {
|
|
|
380
|
+ if (list.Where(x => x.T_Woname == jo.HosSectionName).Count() <= 0)
|
|
|
381
|
+ {
|
|
|
382
|
+ T_Wowo_repairyq model = new T_Wowo_repairyq();
|
|
|
383
|
+ model.T_Woname = jo.HosSectionName;
|
|
|
384
|
+ model.T_Hospital = jo.noHospital;
|
|
|
385
|
+ int n = new T_Wowo_repairyqbll().Addrepairitems(model);
|
|
|
386
|
+ if (n > 0)
|
|
|
387
|
+ {
|
|
|
388
|
+ var obj = new
|
|
|
389
|
+ {
|
|
|
390
|
+ iResult= "1",
|
|
|
391
|
+ cResult= "",
|
|
|
392
|
+ pk= n
|
|
|
393
|
+ };
|
|
|
394
|
+ return Content(obj.ToJson());
|
|
|
395
|
+ }
|
|
|
396
|
+ else
|
|
|
397
|
+ {
|
|
|
398
|
+ var obj = new
|
|
|
399
|
+ {
|
|
|
400
|
+ iResult = "0",
|
|
|
401
|
+ cResult = "添加失败",
|
|
|
402
|
+ pk = ""
|
|
|
403
|
+ };
|
|
|
404
|
+ return Content(obj.ToJson());
|
|
|
405
|
+ }
|
|
|
406
|
+ }
|
|
|
407
|
+ else
|
|
|
408
|
+ {
|
|
|
409
|
+ var obj = new
|
|
|
410
|
+ {
|
|
|
411
|
+ iResult = "0",
|
|
|
412
|
+ cResult = "该院区已存在",
|
|
|
413
|
+ pk = ""
|
|
|
414
|
+ };
|
|
|
415
|
+ return Content(obj.ToJson());
|
|
|
416
|
+ }
|
|
|
417
|
+ }
|
|
|
418
|
+ else if (RecordChangeType == "Modify")
|
|
|
419
|
+ {
|
|
|
420
|
+ var model = list.Where(x => x.T_Woname == jo.HosSectionName);
|
|
|
421
|
+ if (model!=null &&model .Count()>=0)
|
|
|
422
|
+ {
|
|
|
423
|
+ model.FirstOrDefault ().T_Woname = jo.HosSectionName;
|
|
|
424
|
+ model.FirstOrDefault().T_Hospital = jo.noHospital;
|
|
|
425
|
+ bool n = new T_Wowo_repairyqbll().Updaterepair(model.FirstOrDefault());
|
|
|
426
|
+ if (n )
|
|
|
427
|
+ {
|
|
|
428
|
+ var obj = new
|
|
|
429
|
+ {
|
|
|
430
|
+ iResult = "1",
|
|
|
431
|
+ cResult = "",
|
|
|
432
|
+ pk = n
|
|
|
433
|
+ };
|
|
|
434
|
+ return Content(obj.ToJson());
|
|
|
435
|
+ }
|
|
|
436
|
+ else
|
|
|
437
|
+ {
|
|
|
438
|
+ var obj = new
|
|
|
439
|
+ {
|
|
|
440
|
+ iResult = "0",
|
|
|
441
|
+ cResult = "修改失败",
|
|
|
442
|
+ pk = ""
|
|
|
443
|
+ };
|
|
|
444
|
+ return Content(obj.ToJson());
|
|
|
445
|
+ }
|
|
|
446
|
+ }
|
|
|
447
|
+ else
|
|
|
448
|
+ {
|
|
|
449
|
+ var obj = new
|
|
|
450
|
+ {
|
|
|
451
|
+ iResult = "0",
|
|
|
452
|
+ cResult = "该院区不存在",
|
|
|
453
|
+ pk = ""
|
|
|
454
|
+ };
|
|
|
455
|
+ return Content(obj.ToJson());
|
|
|
456
|
+ }
|
|
|
457
|
+ }
|
|
|
458
|
+ else if (RecordChangeType == "Delete")
|
|
|
459
|
+ {
|
|
|
460
|
+ var model = list.Where(x => x.T_Woname == jo.HosSectionName);
|
|
|
461
|
+ if (model != null && model.Count() >= 0)
|
|
|
462
|
+ {
|
|
|
463
|
+ bool n = new T_Wowo_repairyqbll().Deleterepair (model.FirstOrDefault().T_Woid );
|
|
|
464
|
+ if (n)
|
|
|
465
|
+ {
|
|
|
466
|
+ var obj = new
|
|
|
467
|
+ {
|
|
|
468
|
+ iResult = "1",
|
|
|
469
|
+ cResult = "",
|
|
|
470
|
+ pk = n
|
|
|
471
|
+ };
|
|
|
472
|
+ return Content(obj.ToJson());
|
|
|
473
|
+ }
|
|
|
474
|
+ else
|
|
|
475
|
+ {
|
|
|
476
|
+ var obj = new
|
|
|
477
|
+ {
|
|
|
478
|
+ iResult = "0",
|
|
|
479
|
+ cResult = "删除失败",
|
|
|
480
|
+ pk = ""
|
|
|
481
|
+ };
|
|
|
482
|
+ return Content(obj.ToJson());
|
|
|
483
|
+ }
|
|
|
484
|
+ }
|
|
|
485
|
+ else
|
|
|
486
|
+ {
|
|
|
487
|
+ var obj = new
|
|
|
488
|
+ {
|
|
|
489
|
+ iResult = "0",
|
|
|
490
|
+ cResult = "该院区不存在",
|
|
|
491
|
+ pk = ""
|
|
|
492
|
+ };
|
|
|
493
|
+ return Content(obj.ToJson());
|
|
|
494
|
+ }
|
|
|
495
|
+ }
|
|
|
496
|
+ }
|
|
|
497
|
+ else if (DictCode == "DictDept")
|
|
|
498
|
+ {
|
|
|
499
|
+
|
|
|
500
|
+ DictDept jo = JsonConvert.DeserializeObject<DictDept>(RecordInfo);
|
|
|
501
|
+ var list = new Bll.T_Sys_Department().GetModelList("F_State=1 ");
|
|
|
502
|
+ var Wowo = new T_Wowo_repairyqbll().GetListall();
|
|
|
503
|
+ var model1 = Wowo.Where(x => x.T_Hospital == jo .nohospital );
|
|
|
504
|
+ if (RecordChangeType == "Add")
|
|
|
505
|
+ {
|
|
|
506
|
+ if (list.Where(x=>x.F_DeptCode ==jo .deptCode ).Count ()<=0 )
|
|
|
507
|
+ {
|
|
|
508
|
+ Model.T_Sys_Department dModel = new Model.T_Sys_Department();
|
|
|
509
|
+ if (!string.IsNullOrEmpty(jo .deptParentCode))
|
|
|
510
|
+ {
|
|
|
511
|
+ var deptParent = list.Where(x => x.F_DeptCode == jo.deptParentCode);
|
|
|
512
|
+ if (deptParent != null && deptParent.Count() > 0)
|
|
|
513
|
+ dModel.F_ParentId = deptParent.FirstOrDefault().F_DeptId;
|
|
|
514
|
+ }
|
|
|
515
|
+ dModel.F_Sort = 0;
|
|
|
516
|
+ dModel.F_DeptCode = jo.deptCode;
|
|
|
517
|
+ dModel.F_DeptName = jo.deptname;
|
|
|
518
|
+ dModel.F_State = 1;
|
|
|
519
|
+ dModel.F_CreateTime = DateTime.Now;
|
|
|
520
|
+ dModel.F_CreateUser = User.F_UserCode;
|
|
|
521
|
+ dModel.T_Woid = model1.First().T_Woid;
|
|
|
522
|
+ dModel.F_Location = "";
|
|
|
523
|
+ dModel.F_FloorDistribution = "";
|
|
|
524
|
+ dModel.F_OfficeTelephone = "";
|
|
|
525
|
+ int n = new Bll.T_Sys_Department().Add(dModel);
|
|
|
526
|
+ if (n > 0)
|
|
|
527
|
+ {
|
|
|
528
|
+ var obj = new
|
|
|
529
|
+ {
|
|
|
530
|
+ iResult = "1",
|
|
|
531
|
+ cResult = "",
|
|
|
532
|
+ pk = n
|
|
|
533
|
+ };
|
|
|
534
|
+ return Content(obj.ToJson());
|
|
|
535
|
+ }
|
|
|
536
|
+ else
|
|
|
537
|
+ {
|
|
|
538
|
+ var obj = new
|
|
|
539
|
+ {
|
|
|
540
|
+ iResult = "0",
|
|
|
541
|
+ cResult = "添加失败",
|
|
|
542
|
+ pk = ""
|
|
|
543
|
+ };
|
|
|
544
|
+ return Content(obj.ToJson());
|
|
|
545
|
+ }
|
|
|
546
|
+ }
|
|
|
547
|
+ else
|
|
|
548
|
+ {
|
|
|
549
|
+ var obj = new
|
|
|
550
|
+ {
|
|
|
551
|
+ iResult = "0",
|
|
|
552
|
+ cResult = "该科室已存在",
|
|
|
553
|
+ pk = ""
|
|
|
554
|
+ };
|
|
|
555
|
+ return Content(obj.ToJson());
|
|
|
556
|
+ }
|
|
|
557
|
+ }
|
|
|
558
|
+ else if (RecordChangeType == "Modify")
|
|
|
559
|
+ {
|
|
|
560
|
+ var model = list.Where(x => x.F_DeptCode == jo.deptCode);
|
|
|
561
|
+ if (model != null && model.Count() >= 0)
|
|
|
562
|
+ {
|
|
|
563
|
+
|
|
|
564
|
+ if (!string.IsNullOrEmpty(jo.deptParentCode))
|
|
|
565
|
+ {
|
|
|
566
|
+ var deptParent = list.Where(x => x.F_DeptCode == jo.deptParentCode);
|
|
|
567
|
+ if (deptParent != null && deptParent.Count() > 0)
|
|
|
568
|
+ model.FirstOrDefault ().F_ParentId = deptParent.FirstOrDefault().F_DeptId;
|
|
|
569
|
+ }
|
|
|
570
|
+ model.FirstOrDefault().F_Sort = 0;
|
|
|
571
|
+ model.FirstOrDefault().F_DeptCode = jo.deptCode;
|
|
|
572
|
+ model.FirstOrDefault().F_DeptName = jo.deptname;
|
|
|
573
|
+ model.FirstOrDefault().F_State = 1;
|
|
|
574
|
+ model.FirstOrDefault().F_CreateTime = DateTime.Now;
|
|
|
575
|
+ model.FirstOrDefault().F_CreateUser = User.F_UserCode;
|
|
|
576
|
+ model.FirstOrDefault().T_Woid = model1.First().T_Woid;
|
|
|
577
|
+ model.FirstOrDefault().F_Location = "";
|
|
|
578
|
+ model.FirstOrDefault().F_FloorDistribution = "";
|
|
|
579
|
+ model.FirstOrDefault().F_OfficeTelephone = "";
|
|
|
580
|
+ bool n = new Bll.T_Sys_Department().Update(model.FirstOrDefault());
|
|
|
581
|
+ if (n)
|
|
|
582
|
+ {
|
|
|
583
|
+ var obj = new
|
|
|
584
|
+ {
|
|
|
585
|
+ iResult = "1",
|
|
|
586
|
+ cResult = "",
|
|
|
587
|
+ pk = n
|
|
|
588
|
+ };
|
|
|
589
|
+ return Content(obj.ToJson());
|
|
|
590
|
+ }
|
|
|
591
|
+ else
|
|
|
592
|
+ {
|
|
|
593
|
+ var obj = new
|
|
|
594
|
+ {
|
|
|
595
|
+ iResult = "0",
|
|
|
596
|
+ cResult = "修改失败",
|
|
|
597
|
+ pk = ""
|
|
|
598
|
+ };
|
|
|
599
|
+ return Content(obj.ToJson());
|
|
|
600
|
+ }
|
|
|
601
|
+ }
|
|
|
602
|
+ else
|
|
|
603
|
+ {
|
|
|
604
|
+ var obj = new
|
|
|
605
|
+ {
|
|
|
606
|
+ iResult = "0",
|
|
|
607
|
+ cResult = "该科室不存在",
|
|
|
608
|
+ pk = ""
|
|
|
609
|
+ };
|
|
|
610
|
+ return Content(obj.ToJson());
|
|
|
611
|
+ }
|
|
|
612
|
+ }
|
|
|
613
|
+ else if (RecordChangeType == "Delete")
|
|
|
614
|
+ {
|
|
|
615
|
+ var model = list.Where(x => x.F_DeptCode == jo.deptCode);
|
|
|
616
|
+ if (model != null && model.Count() >= 0)
|
|
|
617
|
+ {
|
|
|
618
|
+ bool n = new Bll.T_Sys_Department().Delete (model.FirstOrDefault().F_DeptId );
|
|
|
619
|
+ if (n)
|
|
|
620
|
+ {
|
|
|
621
|
+ var obj = new
|
|
|
622
|
+ {
|
|
|
623
|
+ iResult = "1",
|
|
|
624
|
+ cResult = "",
|
|
|
625
|
+ pk = n
|
|
|
626
|
+ };
|
|
|
627
|
+ return Content(obj.ToJson());
|
|
|
628
|
+ }
|
|
|
629
|
+ else
|
|
|
630
|
+ {
|
|
|
631
|
+ var obj = new
|
|
|
632
|
+ {
|
|
|
633
|
+ iResult = "0",
|
|
|
634
|
+ cResult = "删除失败",
|
|
|
635
|
+ pk = ""
|
|
|
636
|
+ };
|
|
|
637
|
+ return Content(obj.ToJson());
|
|
|
638
|
+ }
|
|
|
639
|
+ }
|
|
|
640
|
+ else
|
|
|
641
|
+ {
|
|
|
642
|
+ var obj = new
|
|
|
643
|
+ {
|
|
|
644
|
+ iResult = "0",
|
|
|
645
|
+ cResult = "该科室不存在",
|
|
|
646
|
+ pk = ""
|
|
|
647
|
+ };
|
|
|
648
|
+ return Content(obj.ToJson());
|
|
|
649
|
+ }
|
|
|
650
|
+ }
|
|
|
651
|
+ }
|
|
|
652
|
+ else if (DictCode == "DictStaff")
|
|
|
653
|
+ {
|
|
|
654
|
+ DictStaff jo = JsonConvert.DeserializeObject<DictStaff>(RecordInfo);
|
|
|
655
|
+ Dictionary<string, string> keyValuePair = new Dictionary<string, string>();
|
|
|
656
|
+ keyValuePair.Add("DictSex", "DictSex");
|
|
|
657
|
+ var responseStrings = HttpPost($"http://{ip}:{port}/{master}/webApi/DictSex", keyValuePair.ToJson());
|
|
|
658
|
+ List<DictSex> sex = JsonConvert.DeserializeObject<List<DictSex>>(responseStrings);
|
|
|
659
|
+ Dictionary<string, string> keyValuePairszhiwu = new Dictionary<string, string>();
|
|
|
660
|
+ keyValuePairszhiwu.Add("DictZhiwu", "DictZhiwu");
|
|
|
661
|
+ var respon = HttpPost($"http://{ip}:{port}/{master}/webApi/DictZhiwu", keyValuePairszhiwu.ToJson());
|
|
|
662
|
+ List<DictZhiwu> zhuwu = JsonConvert.DeserializeObject<List<DictZhiwu>>(respon);
|
|
|
663
|
+
|
|
|
664
|
+ var list = new Bll.T_Sys_UserAccount().GetModelList("F_DeleteFlag=0");
|
|
|
665
|
+
|
|
|
666
|
+ Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
|
667
|
+ keyValuePairs.Add("DictDept", "DictDept");
|
|
|
668
|
+ var responseString = HttpPost($"http://{ip}:{port}/{master}/webApi/DictDept", keyValuePairs.ToJson());
|
|
|
669
|
+ List<DictDept> jodept = JsonConvert.DeserializeObject<List<DictDept>>(responseString);
|
|
|
670
|
+ var dept= new Bll.T_Sys_Department().GetModelList("F_State=1 and F_DeptCode="+ jodept.Where (x=>x.noDept ==
|
|
|
671
|
+ jo .noDept ) .FirstOrDefault ().deptCode + ")");
|
|
|
672
|
+ if (RecordChangeType == "Add")
|
|
|
673
|
+ {
|
|
|
674
|
+ if (list.Where(x => x.F_StaffCode == jo.staffCode ).Count() <= 0)
|
|
|
675
|
+ {
|
|
|
676
|
+ Model.T_Sys_UserAccount ua = new Model.T_Sys_UserAccount();
|
|
|
677
|
+ int usercode = Getcode();
|
|
|
678
|
+ ua.F_UserCode = usercode.ToString();
|
|
|
679
|
+ ua.F_UserName = jo .staffName;
|
|
|
680
|
+ ua.F_Password = "e10adc3949ba59abbe56e057f20f883e";
|
|
|
681
|
+ ua.F_ExtensionNumber = "";
|
|
|
682
|
+ ua.F_DeptId = dept==null ? dept .FirstOrDefault ().F_DeptId :0 ;
|
|
|
683
|
+ ua.F_SeatFlag = 0;
|
|
|
684
|
+ ua.F_Telephone = jo.dhhm;
|
|
|
685
|
+ var uasex = sex.Where(x => x.No_Sex == jo.noSex);
|
|
|
686
|
+ if (uasex != null && uasex.Count() > 0)
|
|
|
687
|
+ ua.F_Sex = uasex.FirstOrDefault().SexName;
|
|
|
688
|
+ ua.F_CreateTime = DateTime.Now;
|
|
|
689
|
+ ua.F_EnableFlag = 1;
|
|
|
690
|
+ var uazhuwu = zhuwu.Where(x => x.No_Zhi == jo .zw);
|
|
|
691
|
+ if (uazhuwu != null && uazhuwu.Count() > 0)
|
|
|
692
|
+ ua.F_Job = uazhuwu.FirstOrDefault().ZhiName;
|
|
|
693
|
+ ua.F_DeleteFlag = 0;
|
|
|
694
|
+ int n = new Bll.T_Sys_UserAccount().Add(ua);
|
|
|
695
|
+ if (n > 0)
|
|
|
696
|
+ {
|
|
|
697
|
+ var obj = new
|
|
|
698
|
+ {
|
|
|
699
|
+ iResult = "1",
|
|
|
700
|
+ cResult = "",
|
|
|
701
|
+ pk = n
|
|
|
702
|
+ };
|
|
|
703
|
+ return Content(obj.ToJson());
|
|
|
704
|
+ }
|
|
|
705
|
+ else
|
|
|
706
|
+ {
|
|
|
707
|
+ var obj = new
|
|
|
708
|
+ {
|
|
|
709
|
+ iResult = "0",
|
|
|
710
|
+ cResult = "添加失败",
|
|
|
711
|
+ pk = ""
|
|
|
712
|
+ };
|
|
|
713
|
+ return Content(obj.ToJson());
|
|
|
714
|
+ }
|
|
|
715
|
+ }
|
|
|
716
|
+ else
|
|
|
717
|
+ {
|
|
|
718
|
+ var obj = new
|
|
|
719
|
+ {
|
|
|
720
|
+ iResult = "0",
|
|
|
721
|
+ cResult = "该人员已存在",
|
|
|
722
|
+ pk = ""
|
|
|
723
|
+ };
|
|
|
724
|
+ return Content(obj.ToJson());
|
|
|
725
|
+ }
|
|
|
726
|
+ }
|
|
|
727
|
+ else if (RecordChangeType == "Modify")
|
|
|
728
|
+ {
|
|
|
729
|
+ var model = list.Where(x => x.F_StaffCode == jo.staffCode);
|
|
|
730
|
+ if (model != null && model.Count() >= 0)
|
|
|
731
|
+ {
|
|
|
732
|
+ var ua = model.FirstOrDefault();
|
|
|
733
|
+ ua.F_UserName = jo.staffName;
|
|
|
734
|
+ ua.F_Password = "e10adc3949ba59abbe56e057f20f883e";
|
|
|
735
|
+ ua.F_ExtensionNumber = "";
|
|
|
736
|
+ ua.F_DeptId = dept == null ? dept.FirstOrDefault().F_DeptId : 0;
|
|
|
737
|
+ ua.F_SeatFlag = 0;
|
|
|
738
|
+ ua.F_Telephone = jo.dhhm;
|
|
|
739
|
+ var uasex = sex.Where(x => x.No_Sex == jo.noSex);
|
|
|
740
|
+ if (uasex != null && uasex.Count() > 0)
|
|
|
741
|
+ ua.F_Sex = uasex.FirstOrDefault().SexName;
|
|
|
742
|
+ ua.F_CreateTime = DateTime.Now;
|
|
|
743
|
+ ua.F_EnableFlag = 1;
|
|
|
744
|
+ var uazhuwu = zhuwu.Where(x => x.No_Zhi == jo.zw);
|
|
|
745
|
+ if (uazhuwu != null && uazhuwu.Count() > 0)
|
|
|
746
|
+ ua.F_Job = uazhuwu.FirstOrDefault().ZhiName;
|
|
|
747
|
+ ua.F_DeleteFlag = 0;
|
|
|
748
|
+ //int n = new Bll.T_Sys_UserAccount().Add(ua);
|
|
|
749
|
+ bool n = new Bll.T_Sys_UserAccount().Update(ua);
|
|
|
750
|
+ if (n)
|
|
|
751
|
+ {
|
|
|
752
|
+ var obj = new
|
|
|
753
|
+ {
|
|
|
754
|
+ iResult = "1",
|
|
|
755
|
+ cResult = "",
|
|
|
756
|
+ pk = n
|
|
|
757
|
+ };
|
|
|
758
|
+ return Content(obj.ToJson());
|
|
|
759
|
+ }
|
|
|
760
|
+ else
|
|
|
761
|
+ {
|
|
|
762
|
+ var obj = new
|
|
|
763
|
+ {
|
|
|
764
|
+ iResult = "0",
|
|
|
765
|
+ cResult = "修改失败",
|
|
|
766
|
+ pk = ""
|
|
|
767
|
+ };
|
|
|
768
|
+ return Content(obj.ToJson());
|
|
|
769
|
+ }
|
|
|
770
|
+ }
|
|
|
771
|
+ else
|
|
|
772
|
+ {
|
|
|
773
|
+ var obj = new
|
|
|
774
|
+ {
|
|
|
775
|
+ iResult = "0",
|
|
|
776
|
+ cResult = "该人员不存在",
|
|
|
777
|
+ pk = ""
|
|
|
778
|
+ };
|
|
|
779
|
+ return Content(obj.ToJson());
|
|
|
780
|
+ }
|
|
|
781
|
+ }
|
|
|
782
|
+ else if (RecordChangeType == "Delete")
|
|
|
783
|
+ {
|
|
|
784
|
+ var model = list.Where(x => x.F_StaffCode == jo.staffCode);
|
|
|
785
|
+ if (model != null && model.Count() >= 0)
|
|
|
786
|
+ {
|
|
|
787
|
+ bool n = new Bll.T_Sys_UserAccount().Delete(model.FirstOrDefault().F_UserId );
|
|
|
788
|
+ if (n)
|
|
|
789
|
+ {
|
|
|
790
|
+ var obj = new
|
|
|
791
|
+ {
|
|
|
792
|
+ iResult = "1",
|
|
|
793
|
+ cResult = "",
|
|
|
794
|
+ pk = n
|
|
|
795
|
+ };
|
|
|
796
|
+ return Content(obj.ToJson());
|
|
|
797
|
+ }
|
|
|
798
|
+ else
|
|
|
799
|
+ {
|
|
|
800
|
+ var obj = new
|
|
|
801
|
+ {
|
|
|
802
|
+ iResult = "0",
|
|
|
803
|
+ cResult = "删除失败",
|
|
|
804
|
+ pk = ""
|
|
|
805
|
+ };
|
|
|
806
|
+ return Content(obj.ToJson());
|
|
|
807
|
+ }
|
|
|
808
|
+ }
|
|
|
809
|
+ else
|
|
|
810
|
+ {
|
|
|
811
|
+ var obj = new
|
|
|
812
|
+ {
|
|
|
813
|
+ iResult = "0",
|
|
|
814
|
+ cResult = "该人员不存在",
|
|
|
815
|
+ pk = ""
|
|
|
816
|
+ };
|
|
|
817
|
+ return Content(obj.ToJson());
|
|
|
818
|
+ }
|
|
|
819
|
+ }
|
|
|
820
|
+ }
|
|
|
821
|
+ var obj1 = new
|
|
|
822
|
+ {
|
|
|
823
|
+ iResult = "0",
|
|
|
824
|
+ cResult = "",
|
|
|
825
|
+ pk = ""
|
|
|
826
|
+ };
|
|
|
827
|
+ return Content(obj1.ToJson());
|
|
|
828
|
+ }
|
|
|
829
|
+ #endregion
|
|
|
830
|
+
|
|
|
831
|
+ }
|
|
|
832
|
+}
|