zhoufan лет назад: 4
Родитель
Сommit
1183c4a6d9

+ 272 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

@@ -13,6 +13,7 @@ using System.Linq;
13 13
 using System.Net;
14 14
 using System.Text;
15 15
 using System.Text.RegularExpressions;
16
+using System.Threading.Tasks;
16 17
 using System.Transactions;
17 18
 using System.Web;
18 19
 using System.Web.Mvc;
@@ -9175,6 +9176,277 @@ namespace CallCenterApi.Interface.Controllers.workorder
9175 9176
         /// 添加工单信息
9176 9177
         /// </summary>
9177 9178
         /// <returns></returns>
9179
+        //[Authority]
9180
+        public ActionResult AddWorkOrderNew()
9181
+        {
9182
+            if (User.F_RoleCode == "ZXHWY" || User.F_RoleCode == "ZXBZ"
9183
+                || User.F_RoleCode == "ZXLD" || User.F_RoleCode == "ZXLDGLYGLY"
9184
+                || User.F_RoleCode == "ZJZY" || User.F_RoleCode == "DBZY"
9185
+                || User.F_RoleCode == "11" || User.F_RoleCode == "GLY" || User.F_RoleCode == "DDZG"
9186
+                || User.F_RoleCode == "DFZF" || User.F_RoleCode == "MTDD") //增加新闻媒体(编号11)的添加工单权限 
9187
+            {
9188
+
9189
+                int source = RequestString.GetInt("source", 0);
9190
+                string cusname = RequestString.GetFormString("cusname");
9191
+                string cussex = RequestString.GetFormString("cussex");
9192
+                string cusphone = RequestString.GetFormString("cusphone");
9193
+                string cusaddress = RequestString.GetFormString("cusaddress");
9194
+                string email = RequestString.GetFormString("email");
9195
+                string zipcode = RequestString.GetFormString("zipcode");
9196
+                string conname = RequestString.GetFormString("conname");
9197
+                string conphone = RequestString.GetFormString("conphone");
9198
+                string title = RequestString.GetFormString("title");
9199
+                string content = RequestString.GetFormString("content");
9200
+                string files = RequestString.GetFormString("files");
9201
+                int sourcearea = RequestString.GetInt("sourcearea", 0);
9202
+                string sourceaddress = RequestString.GetFormString("sourceaddress");
9203
+                int isresult = RequestString.GetInt("isresult", 0);
9204
+                string result = RequestString.GetFormString("result");
9205
+                string keys = RequestString.GetFormString("keys");
9206
+                string splituser = RequestString.GetFormString("splituser");
9207
+                int type = RequestString.GetInt("type", 0);
9208
+                int bigtype = RequestString.GetInt("bigtype", 0);
9209
+                int smalltype = RequestString.GetInt("smalltype", 0);
9210
+                int isprotect = RequestString.GetInt("isprotect", 0);
9211
+                int level = RequestString.GetInt("level", 0);
9212
+                int issubmit = RequestString.GetInt("issubmit", 0);
9213
+                string callid = RequestString.GetFormString("callid");
9214
+                string longitude = RequestString.GetFormString("longitude");//经度
9215
+                string latitude = RequestString.GetFormString("latitude");//纬度
9216
+                int business = RequestString.GetInt("business", 0); ;//
9217
+                int ispd = RequestString.GetInt("ispd", 0); ;//是否自动派单
9218
+                int visittype = RequestString.GetInt("visittype", 0); ;//回访方式
9219
+
9220
+                string phonetype = RequestString.GetFormString("phonetype");//电话类型
9221
+                lock (_MyLock)
9222
+                {
9223
+                    int deptid = 0;
9224
+                    var modeldept = new Model.T_Sys_Department();
9225
+                    if (ispd > 0)
9226
+                    {
9227
+                        if (string.IsNullOrEmpty(keys))
9228
+                            return Error("自动派单失败,请选择反映类别!");
9229
+
9230
+                        try
9231
+                        {
9232
+                            var model = new BLL.T_Sys_DictionaryValue().GetModel
9233
+                                 (int.Parse(keys));
9234
+                            if (model != null)
9235
+                            {
9236
+                                if (model.F_Deptid != null)
9237
+                                    deptid = (int)model.F_Deptid;
9238
+                                else
9239
+                                    return Error("当前反映类别暂未设置相应派单部门,自动派单失败");
9240
+                            }
9241
+                            else
9242
+                                return Error("自动派单失败,请选择反映类别.");
9243
+                        }
9244
+                        catch
9245
+                        {
9246
+                            return Error("自动派单失败,请选择反映类别");
9247
+                        }
9248
+                        modeldept = new BLL.T_Sys_Department().GetModel(deptid);
9249
+                        if (modeldept == null)
9250
+                            return Error("自动派单失败,派单单位不存在");
9251
+                    }
9252
+
9253
+                    using (TransactionScope trans = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 10, 0)))
9254
+                    {
9255
+                        #region 保存工单信息
9256
+                        Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new Model.T_Bus_WorkOrder();
9257
+                        string creattime = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
9258
+                        string endtime = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
9259
+                        modelT_Bus_WorkOrder.F_WorkOrderId = workorderBLL.GetNewWorkOrderID(source, sourcearea, creattime, endtime);
9260
+                        modelT_Bus_WorkOrder.F_InfoSource = source;//信息来源
9261
+                        modelT_Bus_WorkOrder.F_PhoneType = phonetype;//电话类型
9262
+                        modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
9263
+                        modelT_Bus_WorkOrder.F_InfoConBigType = bigtype;//内容大类
9264
+                        modelT_Bus_WorkOrder.F_InfoConSmallType = smalltype;//内容小类
9265
+                        modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
9266
+                        modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
9267
+                        modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
9268
+                        modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
9269
+                        modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
9270
+                        modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
9271
+                        modelT_Bus_WorkOrder.F_ZipCode = zipcode;//邮编
9272
+                        modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
9273
+                        modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
9274
+                        modelT_Bus_WorkOrder.F_Email = email;//E-mail
9275
+                        modelT_Bus_WorkOrder.F_ComTitle = title;//标题
9276
+                        modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
9277
+                        modelT_Bus_WorkOrder.F_File = files;//附件
9278
+                        modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
9279
+                        modelT_Bus_WorkOrder.F_Key = keys;
9280
+                        modelT_Bus_WorkOrder.F_SplitUser = splituser;
9281
+                        modelT_Bus_WorkOrder.F_Level = level;
9282
+                        modelT_Bus_WorkOrder.F_VisitType = visittype;
9283
+
9284
+                        modelT_Bus_WorkOrder.F_Latitude = latitude != "" ? decimal.Parse(latitude) : 0;//纬度
9285
+                        modelT_Bus_WorkOrder.F_Longitude = longitude != "" ? decimal.Parse(longitude) : 0;//经度
9286
+                                                                                                          // modelT_Bus_WorkOrder.F_IsOpen = isopen;
9287
+                                                                                                          //是否直办(即时答复)0:,否1: 是         
9288
+                        modelT_Bus_WorkOrder.F_IsResult = isresult;
9289
+                        modelT_Bus_WorkOrder.F_Result = result;//处理结果
9290
+
9291
+                        modelT_Bus_WorkOrder.F_CreateUser = User.F_UserCode;//登记人工号
9292
+                        modelT_Bus_WorkOrder.F_CreateTime = DateTime.Now;//登记时间
9293
+                        modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.neworder;// 0;//工单状态0登记中
9294
+                        modelT_Bus_WorkOrder.F_IsClosed = 0;//工单是否关闭
9295
+                        modelT_Bus_WorkOrder.F_IsOverdue = 0;//是否逾期(0:否,1:是)
9296
+                        modelT_Bus_WorkOrder.F_IsDelete = 0;//是否删除(0:否,1:是)
9297
+                        modelT_Bus_WorkOrder.F_ToBereply = 0;
9298
+                        modelT_Bus_WorkOrder.F_Business = business;
9299
+                        //如果选择即刻答复:是,即为直办,工单结束
9300
+                        if (isresult == 1)
9301
+                        {
9302
+                            modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.finish;// 9;//已结案
9303
+                            modelT_Bus_WorkOrder.F_DealDeptId = User.F_DeptId;
9304
+                            modelT_Bus_WorkOrder.F_DealUser = User.F_UserCode;
9305
+                            modelT_Bus_WorkOrder.F_DealTime = DateTime.Now;
9306
+                            modelT_Bus_WorkOrder.F_IsClosed = 1;
9307
+                            modelT_Bus_WorkOrder.F_CloseUser = User.F_UserCode;
9308
+                            modelT_Bus_WorkOrder.F_CloseTime = DateTime.Now;
9309
+                        }
9310
+                        else if (issubmit == 1)
9311
+                        {
9312
+                            modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
9313
+                            modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;// 
9314
+                        }
9315
+                        #region
9316
+                        #region
9317
+                        #endregion
9318
+                        #endregion
9319
+                        if (!string.IsNullOrEmpty(callid))
9320
+                        {
9321
+                            modelT_Bus_WorkOrder.F_CallId = callid;
9322
+                            var rd = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
9323
+                            if (rd != null)
9324
+                            {
9325
+                                rd.IsExitWorkOrder = true;
9326
+                                new BLL.T_Call_CallRecords().Update(rd);
9327
+
9328
+                                modelT_Bus_WorkOrder.F_CallRecordId = rd.CallRecordsId;
9329
+                            }
9330
+                        }
9331
+                        int a = workorderBLL.Add(modelT_Bus_WorkOrder);
9332
+                        if (a <= 0)
9333
+                            return Error("添加失败");
9334
+                        #endregion
9335
+
9336
+                        Task.Factory.StartNew(() =>
9337
+                        {
9338
+                            #region 插入操作记录
9339
+                            Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
9340
+                            oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
9341
+                            oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
9342
+                            oper.F_CallRecordId = modelT_Bus_WorkOrder.F_CallRecordId;
9343
+                            oper.F_File = modelT_Bus_WorkOrder.F_File;
9344
+                            string userinfo = User.depname + "(" + User.F_UserCode + ")";
9345
+                            //if (modelT_Bus_WorkOrder.F_WorkState == 0)
9346
+                            if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)
9347
+                            {
9348
+                                oper.F_Message = userinfo + " 登记了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
9349
+                            }
9350
+                            //if (modelT_Bus_WorkOrder.F_WorkState == 1)
9351
+                            if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)
9352
+                            {
9353
+                                oper.F_Message = userinfo + " 登记并提交了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
9354
+                            }
9355
+                            //if (modelT_Bus_WorkOrder.F_WorkState == 9)
9356
+                            if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.finish)
9357
+                            {
9358
+                                oper.F_Message = userinfo + " 登记并结案了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
9359
+                            }
9360
+                            else
9361
+                            {
9362
+                                string count = "您反映的事项已受理并转交相关部门处理,感谢您拨打市长热线!";
9363
+                                string msg = "";
9364
+                                bool n = SMSController.AddSmS(0, msg, count, modelT_Bus_WorkOrder.F_CusPhone, "197387", "", modelT_Bus_WorkOrder.F_WorkOrderId);
9365
+                            }
9366
+                            oper.F_CreateUser = User.F_UserCode;
9367
+                            oper.F_CreateTime = DateTime.Now;
9368
+                            oper.F_IsDelete = 0;
9369
+                            operBLL.Add(oper);
9370
+                            #region 自动派单
9371
+                            if (ispd > 0)
9372
+                            {
9373
+                                string resdatetime = "";
9374
+                                string resdate = DateTime.Now.Date.ToString("yyyy-MM-dd");
9375
+                                DataTable dt = DbHelperSQL.Query("select top " + 7 + " F_OffDate from  T_Sys_WorkOFFDays  where F_OffState = 1   and F_OffDate>'" + resdate + "' order by F_OffDate").Tables[0];
9376
+                                resdatetime = dt.Rows[dt.Rows.Count - 1]["F_OffDate"].ToString();
9377
+                                resdatetime = Convert.ToDateTime(resdatetime).ToString("yyyy-MM-dd") + " 23:59:59 ";
9378
+
9379
+                                Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = new Model.T_Bus_AssignedInfo();
9380
+                                modelT_Bus_AssignedInfo.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
9381
+                                modelT_Bus_AssignedInfo.F_LimitTime = Convert.ToDateTime(resdatetime);
9382
+                                modelT_Bus_AssignedInfo.F_MainDeptId = deptid;
9383
+                                modelT_Bus_AssignedInfo.F_OtherDeptIds = "";//协办单位id
9384
+                                modelT_Bus_AssignedInfo.F_AssignedOpinion = "自动派单";//交办意见
9385
+                                modelT_Bus_AssignedInfo.F_State = 1;//0草稿  1正式
9386
+                                modelT_Bus_AssignedInfo.F_CreateUser = User.F_UserCode;
9387
+                                modelT_Bus_AssignedInfo.F_CreateTime = DateTime.Now;
9388
+                                modelT_Bus_AssignedInfo.F_IsDelete = 0;
9389
+                                modelT_Bus_AssignedInfo.F_IsOverdue = 0;
9390
+                                modelT_Bus_AssignedInfo.F_IsSure = 0;
9391
+                                modelT_Bus_AssignedInfo.F_IsReload = 0;
9392
+                                modelT_Bus_AssignedInfo.F_IsNext = 0;
9393
+                                modelT_Bus_AssignedInfo.F_TimeResp = assignBLL.GetRepTimly(DateTime.Now);//及时查收时间点
9394
+                                int aid = assignBLL.Add(modelT_Bus_AssignedInfo);
9395
+                                modelT_Bus_WorkOrder.F_LimitTime = Convert.ToDateTime(resdatetime);
9396
+                                modelT_Bus_WorkOrder.F_MainDeptId = deptid;
9397
+                                modelT_Bus_WorkOrder.F_OtherDeptIds = "";
9398
+                                modelT_Bus_WorkOrder.F_AssignUser = User.F_UserCode;
9399
+                                modelT_Bus_WorkOrder.F_AssignTime = DateTime.Now;
9400
+                                workorderBLL.Update(modelT_Bus_WorkOrder);
9401
+                                var msgss = userinfo + " 交办了工单,主办单位:" + modeldept.F_DeptName;
9402
+
9403
+                                addoptlog(modelT_Bus_WorkOrder.F_WorkOrderId, modelT_Bus_WorkOrder.F_WorkState, modelT_Bus_AssignedInfo.F_Id, msgss, User.F_UserCode);
9404
+
9405
+                                //推送消息表
9406
+                                var users = userBLL.GetModelList(" F_DeptId='" + deptid + "' ");
9407
+
9408
+                                foreach (var u in users)
9409
+                                {
9410
+                                    msg.AddInternalMessagesInfo("工单消息", msgss + ",工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId, u.F_UserCode, User.F_UserCode, (int)EnumSmsType.workorder);
9411
+                                    string count = "你有新工单:" + modelT_Bus_WorkOrder.F_WorkOrderId + ",请及时查收处理。";
9412
+                                    string mag = modelT_Bus_WorkOrder.F_WorkOrderId;
9413
+                                    bool n = SMSController.AddSmS(0, mag, count, u.F_Mobile, "153305", "");
9414
+                                }
9415
+                                var user = new BLL.T_Sys_UserAccount().GetModelList("F_DeptId in (" + deptid + ") ");
9416
+                            }
9417
+                            #endregion
9418
+                            //推送消息表
9419
+                            if (modelT_Bus_WorkOrder.F_WorkState != (int)EnumWorkState.neworder && modelT_Bus_WorkOrder.F_WorkState != (int)EnumWorkState.audit) //0)
9420
+                            {
9421
+
9422
+                                var role = new BLL.T_Sys_RoleInfo().GetModelList(" (F_RoleCode='ZXLD' or F_RoleCode='ZXLDGLYGLY' or F_RoleCode='MTDD')  ").Select(p => p.F_RoleId);
9423
+                                var users = userBLL.GetModelList(" F_RoleId in (" + string.Join(",", role) + ")  ");
9424
+
9425
+                                foreach (var u in users)
9426
+                                {
9427
+                                    msg.AddInternalMessagesInfo("工单消息", oper.F_Message, u.F_UserCode, User.F_UserCode, (int)EnumSmsType.workorder);
9428
+                                }
9429
+                            }
9430
+                            #endregion
9431
+                        });
9432
+
9433
+
9434
+                        trans.Complete();
9435
+                    }
9436
+                }
9437
+                return Success("操作成功");
9438
+
9439
+            }
9440
+            else
9441
+            {
9442
+                return Error("权限不足");
9443
+            }
9444
+        }
9445
+
9446
+        /// <summary>
9447
+        /// 添加工单信息
9448
+        /// </summary>
9449
+        /// <returns></returns>
9178 9450
         public string AddWorkOrderBySource(int source, string cusname, string cussex, string cusphone, string cusaddress, string email,
9179 9451
             string zipcode, string conname, string conphone, string title, string content, int sourcearea, string sourceaddress,
9180 9452
             string keys, string splituser, int type, int bigtype, int smalltype, int isprotect, int level, string files = null)