|
|
@@ -14,6 +14,8 @@ using System.Reflection;
|
|
14
|
14
|
using System.Text;
|
|
15
|
15
|
using System.Web;
|
|
16
|
16
|
using System.Web.Mvc;
|
|
|
17
|
+using System.Diagnostics;
|
|
|
18
|
+using System.Security.Cryptography;
|
|
17
|
19
|
|
|
18
|
20
|
namespace RMYY_CallCenter_Api.Controllers
|
|
19
|
21
|
{
|
|
|
@@ -42,7 +44,7 @@ namespace RMYY_CallCenter_Api.Controllers
|
|
42
|
44
|
private static InternalMessagesController msg = new InternalMessagesController();
|
|
43
|
45
|
|
|
44
|
46
|
private static SchedulingController schcon = new SchedulingController();
|
|
45
|
|
-
|
|
|
47
|
+ private AjaxResult ajresult = new AjaxResult();
|
|
46
|
48
|
#region 获取工单详情相关的接口
|
|
47
|
49
|
public DataTable GetFileData(string ids,string prefix)
|
|
48
|
50
|
{
|
|
|
@@ -3464,5 +3466,172 @@ namespace RMYY_CallCenter_Api.Controllers
|
|
3464
|
3466
|
|
|
3465
|
3467
|
|
|
3466
|
3468
|
#endregion
|
|
|
3469
|
+
|
|
|
3470
|
+
|
|
|
3471
|
+ #region 对外提供的接口
|
|
|
3472
|
+ public static bool ICodeValidates(string strParams, string ICode)
|
|
|
3473
|
+ {
|
|
|
3474
|
+ string SecurityCode = "wuyuan%#@6"; //ConfigurationManager.AppSettings["SecurityCode"];
|
|
|
3475
|
+ string pwd = Md5(SecurityCode + strParams);
|
|
|
3476
|
+ return pwd.Equals(ICode);
|
|
|
3477
|
+ //return true;
|
|
|
3478
|
+ }
|
|
|
3479
|
+ public static string Md5(string txt)
|
|
|
3480
|
+ {
|
|
|
3481
|
+ byte[] sor = Encoding.UTF8.GetBytes(txt);
|
|
|
3482
|
+ MD5 md5 = MD5.Create();
|
|
|
3483
|
+ byte[] result = md5.ComputeHash(sor);
|
|
|
3484
|
+ StringBuilder strbul = new StringBuilder(40);
|
|
|
3485
|
+ for (int i = 0; i < result.Length; i++)
|
|
|
3486
|
+ {
|
|
|
3487
|
+ //加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
|
|
|
3488
|
+ strbul.Append(result[i].ToString("x2"));
|
|
|
3489
|
+ }
|
|
|
3490
|
+ return strbul.ToString().ToLower(); ;
|
|
|
3491
|
+ }
|
|
|
3492
|
+ /// <summary>
|
|
|
3493
|
+ /// 提交工单接口
|
|
|
3494
|
+ /// </summary>
|
|
|
3495
|
+ /// <param name="timestamp"></param>
|
|
|
3496
|
+ /// <returns></returns>
|
|
|
3497
|
+ public ActionResult AddWorkOrder(long timestamp)
|
|
|
3498
|
+ {
|
|
|
3499
|
+ string port_password = HttpUtility.UrlDecode(RequestString.GetQueryString("port_password")); //加密信息(安全验证用)
|
|
|
3500
|
+ string uuid = HttpUtility.UrlDecode(RequestString.GetQueryString("uuid")); //客户唯一标识(安全验证用)
|
|
|
3501
|
+ string applicant = HttpUtility.UrlDecode(RequestString.GetQueryString("applicant"));
|
|
|
3502
|
+ string ApplicationDeptCode = HttpUtility.UrlDecode(RequestString.GetQueryString("ApplicationDeptCode"));
|
|
|
3503
|
+
|
|
|
3504
|
+ string Phone = HttpUtility.UrlDecode(RequestString.GetQueryString("Phone"));
|
|
|
3505
|
+ string Applicantsphone = HttpUtility.UrlDecode(RequestString.GetQueryString("Applicantsphone"));
|
|
|
3506
|
+ string WorkOrderCategory = HttpUtility.UrlDecode(RequestString.GetQueryString("WorkOrderCategory"));
|
|
|
3507
|
+ string Content = HttpUtility.UrlDecode(RequestString.GetQueryString("Content"));
|
|
|
3508
|
+ string PlaceOfRepair = HttpUtility.UrlDecode(RequestString.GetQueryString("PlaceOfRepair"));
|
|
|
3509
|
+ string EmergencyTypes = HttpUtility.UrlDecode(RequestString.GetQueryString("EmergencyTypes"));
|
|
|
3510
|
+
|
|
|
3511
|
+ if (string.IsNullOrEmpty(uuid))
|
|
|
3512
|
+ {
|
|
|
3513
|
+ ajresult.state = (int)CodeStatus.ID不存在;
|
|
|
3514
|
+ ajresult.message = "客户唯一标识不能为空";
|
|
|
3515
|
+ return Process();
|
|
|
3516
|
+ }
|
|
|
3517
|
+ else if (uuid.Length > 50)
|
|
|
3518
|
+ {
|
|
|
3519
|
+ ajresult.state = (int)CodeStatus.字符串超出长度;
|
|
|
3520
|
+ ajresult.message = "客户唯一标识超出长度";
|
|
|
3521
|
+ }
|
|
|
3522
|
+ try
|
|
|
3523
|
+ {
|
|
|
3524
|
+ DateTime time = DateTimeConvert.FromTimetag(timestamp);
|
|
|
3525
|
+ }
|
|
|
3526
|
+ catch
|
|
|
3527
|
+ {
|
|
|
3528
|
+ var err = new
|
|
|
3529
|
+ {
|
|
|
3530
|
+ code = "1",
|
|
|
3531
|
+ message = "时间戳错误"
|
|
|
3532
|
+ };
|
|
|
3533
|
+ return Error(err.ToJson());
|
|
|
3534
|
+ }
|
|
|
3535
|
+ if (! ICodeValidates(uuid + timestamp, port_password))
|
|
|
3536
|
+ {
|
|
|
3537
|
+ ajresult.state = (int)CodeStatus.安全验证未通过;
|
|
|
3538
|
+ ajresult.message = "安全验证未通过";
|
|
|
3539
|
+ return Process();
|
|
|
3540
|
+ }
|
|
|
3541
|
+ if (string.IsNullOrEmpty(ApplicationDeptCode))
|
|
|
3542
|
+ {
|
|
|
3543
|
+ ajresult.state = (int)CodeStatus.必填字段为空;
|
|
|
3544
|
+ ajresult.message = "科室编码不能为空";
|
|
|
3545
|
+ return Process();
|
|
|
3546
|
+ }
|
|
|
3547
|
+ if (string.IsNullOrEmpty(WorkOrderCategory))
|
|
|
3548
|
+ {
|
|
|
3549
|
+ ajresult.state = (int)CodeStatus.必填字段为空;
|
|
|
3550
|
+ ajresult.message = "工单类别不能为空";
|
|
|
3551
|
+ return Process();
|
|
|
3552
|
+ }
|
|
|
3553
|
+ Model.T_FaultRepair_Base model = new Model.T_FaultRepair_Base();
|
|
|
3554
|
+
|
|
|
3555
|
+ string sql = "select F_DeptId from T_Sys_Department where F_DeptCode='" + ApplicationDeptCode + "' ";
|
|
|
3556
|
+ string deptid = DbHelperSQL.GetSingle(sql).ToString();
|
|
|
3557
|
+
|
|
|
3558
|
+ if (string.IsNullOrEmpty(deptid))
|
|
|
3559
|
+ {
|
|
|
3560
|
+ model.F_ApplicationDept = deptid;
|
|
|
3561
|
+ }
|
|
|
3562
|
+ else
|
|
|
3563
|
+ {
|
|
|
3564
|
+ ajresult.state = (int)CodeStatus.必填字段为空;
|
|
|
3565
|
+ ajresult.message = "科室编码不能为空";
|
|
|
3566
|
+ return Process();
|
|
|
3567
|
+ }
|
|
|
3568
|
+ model.F_Phone = Phone;
|
|
|
3569
|
+ model.F_Applicantsphone = Applicantsphone;
|
|
|
3570
|
+
|
|
|
3571
|
+ model.F_WorkOrderCategory = WorkOrderCategory;
|
|
|
3572
|
+ model.F_Content = Content;
|
|
|
3573
|
+ model.F_PlaceOfRepair = PlaceOfRepair;//报修地点
|
|
|
3574
|
+
|
|
|
3575
|
+
|
|
|
3576
|
+
|
|
|
3577
|
+ model.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
|
|
|
3578
|
+ model.F_EmergencyTypes = EmergencyTypes;
|
|
|
3579
|
+
|
|
|
3580
|
+ string message = "";
|
|
|
3581
|
+ var dicvalue = new Model.T_Sys_GongDan();
|
|
|
3582
|
+ dicvalue = new Bll.T_Sys_GongDan().GetModel(Convert.ToInt32(model.F_WorkOrderCategory));
|
|
|
3583
|
+ if (dicvalue != null)
|
|
|
3584
|
+ {
|
|
|
3585
|
+ message = "\n工单类型:故障报修/" + dicvalue.F_Name;
|
|
|
3586
|
+ }
|
|
|
3587
|
+ model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
|
|
|
3588
|
+ model.F_CreateTime = DateTime.Now;
|
|
|
3589
|
+ model.F_ReplayCount = 0;
|
|
|
3590
|
+ int returnid = baseBll.Add(model);
|
|
|
3591
|
+ if (returnid > 0)
|
|
|
3592
|
+ {
|
|
|
3593
|
+ AddAddlog(model.F_WorkOrderCode);
|
|
|
3594
|
+ AddOperatorLog(applicant + "创建报修工单", (int)EnumOperatorType.add, model.F_WorkOrderCode);
|
|
|
3595
|
+ return Success("添加成功!", returnid);
|
|
|
3596
|
+ }
|
|
|
3597
|
+ return Error("添加失败!");
|
|
|
3598
|
+
|
|
|
3599
|
+ }
|
|
|
3600
|
+ /// <summary>
|
|
|
3601
|
+ /// 成功的消息格式化
|
|
|
3602
|
+ /// </summary>
|
|
|
3603
|
+ /// <param name="message"></param>
|
|
|
3604
|
+ /// <returns></returns>
|
|
|
3605
|
+ protected virtual ActionResult Process()
|
|
|
3606
|
+ {
|
|
|
3607
|
+ string methodName = new StackTrace(true).GetFrame(1).GetMethod().Name; //事件源
|
|
|
3608
|
+ LogHelper.Info(this.GetType().ToString() + " -- " + methodName + "\r\n" + ajresult.state + "|" + ajresult.data + ajresult.message); //日志
|
|
|
3609
|
+ var jsonMsg = new AjaxResult { state = ajresult.state, message = ajresult.message, data = ajresult.data }.ToJson();
|
|
|
3610
|
+ return Content(jsonMsg);
|
|
|
3611
|
+ }
|
|
|
3612
|
+ /// <summary>
|
|
|
3613
|
+ /// 状态枚举
|
|
|
3614
|
+ /// </summary>
|
|
|
3615
|
+ enum CodeStatus
|
|
|
3616
|
+ {
|
|
|
3617
|
+ SUCCESS = 200,
|
|
|
3618
|
+ 安全验证未通过 = 400,
|
|
|
3619
|
+ 无法预测的程序错误 = 501,
|
|
|
3620
|
+ 参数格式错误 = 100,
|
|
|
3621
|
+ 必填字段为空 = 101,
|
|
|
3622
|
+ 字符串超出长度 = 102,
|
|
|
3623
|
+ 数据库错误 = 103,
|
|
|
3624
|
+ 执行超时 = 104,
|
|
|
3625
|
+ 参数逻辑错误 = 105,
|
|
|
3626
|
+ ID不存在 = 106,
|
|
|
3627
|
+ 无可上传文件 = 107,
|
|
|
3628
|
+ 执行失败 = 108,
|
|
|
3629
|
+ 用户已禁用 = 120,
|
|
|
3630
|
+
|
|
|
3631
|
+ 异常结果类型 = 500
|
|
|
3632
|
+
|
|
|
3633
|
+ }
|
|
|
3634
|
+
|
|
|
3635
|
+ #endregion
|
|
3467
|
3636
|
}
|
|
3468
|
3637
|
}
|