Browse Source

问题类别、生产批次号截取

zhengbingbing 6 years ago
parent
commit
cbd564139f

+ 99 - 9
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

@@ -3,8 +3,10 @@ using CallCenterApi.Common;
3 3
 using CallCenterApi.DB;
4 4
 using CallCenterApi.Interface.Controllers.Base;
5 5
 using CallCenterApi.Interface.Models.Enum;
6
+using CallCenterApi.Model;
6 7
 using CallCenterAPI.WechatSDK;
7 8
 using System;
9
+using System.Collections.Generic;
8 10
 using System.Data;
9 11
 using System.Linq;
10 12
 using System.Web;
@@ -21,6 +23,94 @@ namespace CallCenterApi.Interface.Controllers.workorder
21 23
         BLL.T_Sys_Department sysDeptBll = new BLL.T_Sys_Department();
22 24
         BLL.T_Sys_DictionaryValue dicvalueBll = new BLL.T_Sys_DictionaryValue();
23 25
 
26
+        BLL.T_Wo_QuestionManage quesBLL = new BLL.T_Wo_QuestionManage();
27
+
28
+        #region 质量管理部
29
+        //根据工单id获取工单类型 根据类型区别提交处理
30
+
31
+        #endregion
32
+
33
+        #region 市场管理科
34
+        #endregion
35
+        #region 
36
+        /// <summary>
37
+        /// 根据生产批次号获取超出质保期限
38
+        /// 质保期限以月为单位
39
+        /// </summary>
40
+        /// <param name="BatchNumber">生产批次号</param>
41
+        /// <param name="createtime">工单创建时间</param>
42
+        public int GetProTime(string BatchNumber,DateTime createtime)
43
+        {
44
+            //生产批次号截取前六位日期
45
+            var prono = BatchNumber.Substring(0, 6);
46
+            //转为生产日期格式
47
+            var pronos = DateTime.ParseExact(prono, "yyMMdd", null).ToString("yyyy-MM-dd");
48
+            var protime = Convert.ToDateTime(pronos);
49
+            TimeSpan ts = createtime - protime;
50
+            var days = ts.TotalDays;
51
+            var month = (int)Math.Ceiling((days / 30));//以30天为一月计算几个月并且有余数取整
52
+            return month;
53
+        }
54
+        #endregion
55
+        #region 读取问题类别
56
+        public ActionResult GetQuestionType(int type=0,int pid=0)
57
+        {
58
+            var sql = " F_IsDelete=0 and F_ParentId=" + pid;
59
+            if (type == (int)EnumWOType.Complaint)//投诉
60
+                sql += " and F_Type='"+ EnumWOType.Complaint.ToString()+ "'";
61
+            if (type == (int)EnumWOType.ConsultingNeeds)//咨询及需求
62
+                sql += " and F_Type='" + EnumWOType.ConsultingNeeds.ToString() + "'";
63
+            if (type == (int)EnumWOType.SpotCheck)//抽检
64
+                sql += " and F_Type='" + EnumWOType.SpotCheck.ToString() + "'";
65
+            DataTable dt = quesBLL.GetList(sql).Tables[0];
66
+            List<Model.TreeModel> modelList = BindTree(dt, "0");
67
+            if (modelList != null)
68
+            {
69
+                if (modelList.Count > 0)
70
+                    return Success("加载成功", modelList);
71
+            }
72
+            return Error("加载失败");
73
+        }
74
+        /// <summary>
75
+        /// tree  树形部门
76
+        /// </summary>
77
+        /// <param name="tab"></param>
78
+        /// <param name="parentid"></param>
79
+        /// <returns></returns>
80
+        private List<Model.TreeModel> BindTree(DataTable tab, string parentid)
81
+        {
82
+            DataTable tab2 = new DataTable();
83
+
84
+            if (tab != null && tab.Rows.Count > 0)
85
+            {
86
+                List<Model.T_Wo_QuestionManage> categorylist = quesBLL.DataTableToList(tab);
87
+                List<Model.TreeModel> modelList = new List<Model.TreeModel>(categorylist.Count);
88
+                for (int i = 0; i < categorylist.Count; i++)
89
+                {
90
+                    Model.TreeModel model = new Model.TreeModel();
91
+                    string currentID = categorylist[i].F_Id.ToString();//当前功能ID
92
+                    model.id = currentID;
93
+                    model.code = "";
94
+                    model.IconCls = "";//图标
95
+                    model.text = categorylist[i].F_QuestionName;
96
+                    model.headerid = categorylist[i].F_ParentId ?? 0;   
97
+                    tab2 = new BLL.T_Sys_Department().GetList("F_ParentId=" + currentID + " and F_IsDelete=0 ").Tables[0];
98
+                    if (tab2 != null && tab2.Rows.Count > 0)
99
+                    {
100
+                        model.children = BindTree(tab2, currentID);
101
+                    }
102
+                    modelList.Add(model);
103
+                }
104
+                return modelList;
105
+
106
+            }
107
+            else
108
+            {
109
+                return null;
110
+            }
111
+
112
+        }
113
+        #endregion
24 114
         //#region 工单状态
25 115
         //public ActionResult GetWorkState()
26 116
         //{
@@ -395,7 +485,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
395 485
         //    }
396 486
         //    return res;
397 487
         //}
398
-        
488
+
399 489
         ///// <summary>
400 490
         ///// 获取待接单的工单编号
401 491
         ///// </summary>
@@ -406,7 +496,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
406 496
         //    str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType=" + (int)EnumItemType.deal 
407 497
         //        + " and F_WoState="+ (int)EnumWorkOrderState.assign
408 498
         //        + " and isnull(F_IsUsed,'0')='0' and F_NextUser='" + user + "' ";
409
-           
499
+
410 500
         //    return str;
411 501
         //}
412 502
 
@@ -658,7 +748,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
658 748
         //    }
659 749
         //    return Error("无操作权限!");
660 750
         //}
661
-        
751
+
662 752
         ///// <summary>
663 753
         ///// 指派/转派工单
664 754
         ///// </summary>
@@ -690,7 +780,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
690 780
         //    }
691 781
         //    return Error("无操作权限!");
692 782
         //}
693
-        
783
+
694 784
         ///// <summary>
695 785
         ///// 接单 - 确认工单
696 786
         ///// </summary>
@@ -719,7 +809,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
719 809
         //    }
720 810
         //    return Error("无操作权限");
721 811
         //}
722
-        
812
+
723 813
         ///// <summary>
724 814
         ///// 退回工单
725 815
         ///// </summary>
@@ -749,7 +839,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
749 839
         //    }
750 840
         //    return Error("无操作权限");
751 841
         //}
752
-        
842
+
753 843
         ///// <summary>
754 844
         ///// 催办工单
755 845
         ///// </summary>
@@ -2171,7 +2261,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
2171 2261
         ////    model.IsReturn = 0;
2172 2262
         ////    model.IsReturnBak = 0;
2173 2263
         ////    model.Answer = "";
2174
-            
2264
+
2175 2265
         ////    workorderid = bll.Add(model).ToString();
2176 2266
         ////    return workorderid;
2177 2267
         ////}
@@ -2246,7 +2336,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
2246 2336
         ////                if (itemid > 0)
2247 2337
         ////                {
2248 2338
         ////                    #region
2249
-                           
2339
+
2250 2340
         ////                    //工单完结要更新工单的状态
2251 2341
         ////                    if (isend == 0)
2252 2342
         ////                    {
@@ -2316,7 +2406,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
2316 2406
         ////                                    //WxHelper.SendWechatMsg1(model.WorkOrderID, "你有新的工单需要处理", wotype, model.State.ToString(), content, orderid.ToString(), modelUser2.F_WxOpenId);
2317 2407
         ////                                    //WxHelper.SendWechatMsg1(model.WorkOrderID, "你有新的工单需要处理", wotype, content, orderid.ToString(), modelUser2.F_WxOpenId);
2318 2408
 
2319
-                                            
2409
+
2320 2410
         ////                                }
2321 2411
         ////                            }
2322 2412
         ////                        }