浏览代码

客户档案,物料对接

duhongyu 5 年之前
父节点
当前提交
1b52f18f5f
共有 18 个文件被更改,包括 2541 次插入43 次删除
  1. 9 0
      codegit/CallCenterApi/CallCenterApi.BLL/T_Cus_CustomerBaseNew.cs
  2. 168 0
      codegit/CallCenterApi/CallCenterApi.BLL/T_Cus_Customerrecords.cs
  3. 141 0
      codegit/CallCenterApi/CallCenterApi.BLL/T_Sys_AssToken.cs
  4. 49 0
      codegit/CallCenterApi/CallCenterApi.Common/CodeValidate.cs
  5. 15 0
      codegit/CallCenterApi/CallCenterApi.DAL/T_Cus_CustomerBaseNew.cs
  6. 365 0
      codegit/CallCenterApi/CallCenterApi.DAL/T_Cus_Customerrecords.cs
  7. 314 0
      codegit/CallCenterApi/CallCenterApi.DAL/T_Sys_AssToken.cs
  8. 140 26
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/customer/CustomerNewController.cs
  9. 540 0
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/customer/XLXCustomerController.cs
  10. 120 5
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/weixin/WxLoginController.cs
  11. 79 3
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/MaterialManageController.cs
  12. 405 0
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/MaterialManageXLXController.cs
  13. 8 6
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderNewController.cs
  14. 11 2
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Global.asax.cs
  15. 59 0
      codegit/CallCenterApi/CallCenterApi.Model/T_Cus_Customerrecords.cs
  16. 69 0
      codegit/CallCenterApi/CallCenterApi.Model/T_Sys_AssToken.cs
  17. 8 1
      codegit/CallCenterCommon/CallCenter.Utility/RequestString.cs
  18. 41 0
      codegit/CallCenterCommon/CallCenter.Utility/log/LogInterface.cs

+ 9 - 0
codegit/CallCenterApi/CallCenterApi.BLL/T_Cus_CustomerBaseNew.cs

80
             return dal.GetList(strWhere);
80
             return dal.GetList(strWhere);
81
         }
81
         }
82
         /// <summary>
82
         /// <summary>
83
+        ///工单导出
84
+        /// </summary>
85
+        /// <param name="strWhere"></param>
86
+        /// <returns></returns>
87
+        public DataSet GetExpt(string strWhere)
88
+        {
89
+            return dal.GetExpt(strWhere);
90
+        }
91
+        /// <summary>
83
         /// 获得前几行数据
92
         /// 获得前几行数据
84
         /// </summary>
93
         /// </summary>
85
         public DataSet GetList(int Top, string strWhere, string filedOrder)
94
         public DataSet GetList(int Top, string strWhere, string filedOrder)

+ 168 - 0
codegit/CallCenterApi/CallCenterApi.BLL/T_Cus_Customerrecords.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Data;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+
8
+namespace CallCenterApi.BLL
9
+{
10
+    public partial class T_Cus_Customerrecords
11
+    {
12
+        private readonly DAL.T_Cus_Customerrecords dal = new DAL.T_Cus_Customerrecords();
13
+        public T_Cus_Customerrecords()
14
+        { }
15
+        #region  BasicMethod
16
+
17
+        /// <summary>
18
+        /// 得到最大ID
19
+        /// </summary>
20
+        public int GetMaxId()
21
+        {
22
+            return dal.GetMaxId();
23
+        }
24
+
25
+        /// <summary>
26
+        /// 是否存在该记录
27
+        /// </summary>
28
+        public bool Exists(string F_Cuscode, string F_Cuscodeuuid, int F_Id)
29
+        {
30
+            return dal.Exists(F_Cuscode, F_Cuscodeuuid, F_Id);
31
+        }
32
+        /// <summary>
33
+        /// 是否存在该记录
34
+        /// </summary>
35
+        public bool ExistsCuscodeuuid( string F_Cuscodeuuid)
36
+        {
37
+            return dal.ExistsCuscodeuuid( F_Cuscodeuuid);
38
+        }
39
+        /// <summary>
40
+        /// 增加一条数据
41
+        /// </summary>
42
+        public int Add(Model.T_Cus_Customerrecords model)
43
+        {
44
+            return dal.Add(model);
45
+        }
46
+
47
+        /// <summary>
48
+        /// 更新一条数据
49
+        /// </summary>
50
+        public bool Update(Model.T_Cus_Customerrecords model)
51
+        {
52
+            return dal.Update(model);
53
+        }
54
+
55
+        /// <summary>
56
+        /// 删除一条数据
57
+        /// </summary>
58
+        public bool Delete(int F_Id)
59
+        {
60
+
61
+            return dal.Delete(F_Id);
62
+        }
63
+        /// <summary>
64
+        /// 删除一条数据
65
+        /// </summary>
66
+        public bool Delete(string F_Cuscode, string F_Cuscodeuuid, int F_Id)
67
+        {
68
+
69
+            return dal.Delete(F_Cuscode, F_Cuscodeuuid, F_Id);
70
+        }
71
+        /// <summary>
72
+        /// 删除一条数据
73
+        /// </summary>
74
+        public bool DeleteList(string F_Idlist)
75
+        {
76
+            return dal.DeleteList(F_Idlist);
77
+        }
78
+
79
+        /// <summary>
80
+        /// 得到一个对象实体
81
+        /// </summary>
82
+        public Model.T_Cus_Customerrecords GetModel(int F_Id)
83
+        {
84
+
85
+            return dal.GetModel(F_Id);
86
+        }
87
+
88
+
89
+        /// <summary>
90
+        /// 获得数据列表
91
+        /// </summary>
92
+        public DataSet GetList(string strWhere)
93
+        {
94
+            return dal.GetList(strWhere);
95
+        }
96
+        /// <summary>
97
+        /// 获得前几行数据
98
+        /// </summary>
99
+        public DataSet GetList(int Top, string strWhere, string filedOrder)
100
+        {
101
+            return dal.GetList(Top, strWhere, filedOrder);
102
+        }
103
+        /// <summary>
104
+        /// 获得数据列表
105
+        /// </summary>
106
+        public List<Model.T_Cus_Customerrecords> GetModelList(string strWhere)
107
+        {
108
+            DataSet ds = dal.GetList(strWhere);
109
+            return DataTableToList(ds.Tables[0]);
110
+        }
111
+        /// <summary>
112
+        /// 获得数据列表
113
+        /// </summary>
114
+        public List<Model.T_Cus_Customerrecords> DataTableToList(DataTable dt)
115
+        {
116
+            List<Model.T_Cus_Customerrecords> modelList = new List<Model.T_Cus_Customerrecords>();
117
+            int rowsCount = dt.Rows.Count;
118
+            if (rowsCount > 0)
119
+            {
120
+                Model.T_Cus_Customerrecords model;
121
+                for (int n = 0; n < rowsCount; n++)
122
+                {
123
+                    model = dal.DataRowToModel(dt.Rows[n]);
124
+                    if (model != null)
125
+                    {
126
+                        modelList.Add(model);
127
+                    }
128
+                }
129
+            }
130
+            return modelList;
131
+        }
132
+
133
+        /// <summary>
134
+        /// 获得数据列表
135
+        /// </summary>
136
+        public DataSet GetAllList()
137
+        {
138
+            return GetList("");
139
+        }
140
+
141
+        /// <summary>
142
+        /// 分页获取数据列表
143
+        /// </summary>
144
+        public int GetRecordCount(string strWhere)
145
+        {
146
+            return dal.GetRecordCount(strWhere);
147
+        }
148
+        /// <summary>
149
+        /// 分页获取数据列表
150
+        /// </summary>
151
+        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
152
+        {
153
+            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
154
+        }
155
+        /// <summary>
156
+        /// 分页获取数据列表
157
+        /// </summary>
158
+        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
159
+        //{
160
+        //return dal.GetList(PageSize,PageIndex,strWhere);
161
+        //}
162
+
163
+        #endregion  BasicMethod
164
+        #region  ExtensionMethod
165
+
166
+        #endregion  ExtensionMethod
167
+    }
168
+}

+ 141 - 0
codegit/CallCenterApi/CallCenterApi.BLL/T_Sys_AssToken.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Data;
6
+namespace CallCenterApi.BLL
7
+{
8
+    /// <summary>
9
+    /// T_Sys_AssToken
10
+    /// </summary>
11
+    public partial class T_Sys_AssToken
12
+    {
13
+        private readonly DAL.T_Sys_AssToken dal = new DAL.T_Sys_AssToken();
14
+        public T_Sys_AssToken()
15
+        { }
16
+        #region  BasicMethod
17
+
18
+        /// <summary>
19
+        /// 增加一条数据
20
+        /// </summary>
21
+        public int Add(Model.T_Sys_AssToken model)
22
+        {
23
+            return dal.Add(model);
24
+        }
25
+
26
+        /// <summary>
27
+        /// 更新一条数据
28
+        /// </summary>
29
+        public bool Update(Model.T_Sys_AssToken model)
30
+        {
31
+            return dal.Update(model);
32
+        }
33
+
34
+        /// <summary>
35
+        /// 删除一条数据
36
+        /// </summary>
37
+        public bool Delete(int F_ID)
38
+        {
39
+
40
+            return dal.Delete(F_ID);
41
+        }
42
+        /// <summary>
43
+        /// 删除一条数据
44
+        /// </summary>
45
+        public bool DeleteList(string F_IDlist)
46
+        {
47
+            return dal.DeleteList(F_IDlist);
48
+        }
49
+
50
+        /// <summary>
51
+        /// 得到一个对象实体
52
+        /// </summary>
53
+        public Model.T_Sys_AssToken GetModel(int F_ID)
54
+        {
55
+
56
+            return dal.GetModel(F_ID);
57
+        }
58
+
59
+      
60
+
61
+        /// <summary>
62
+        /// 获得数据列表
63
+        /// </summary>
64
+        public DataSet GetList(string strWhere)
65
+        {
66
+            return dal.GetList(strWhere);
67
+        }
68
+        /// <summary>
69
+        /// 获得前几行数据
70
+        /// </summary>
71
+        public DataSet GetList(int Top, string strWhere, string filedOrder)
72
+        {
73
+            return dal.GetList(Top, strWhere, filedOrder);
74
+        }
75
+        /// <summary>
76
+        /// 获得数据列表
77
+        /// </summary>
78
+        public List<Model.T_Sys_AssToken> GetModelList(string strWhere)
79
+        {
80
+            DataSet ds = dal.GetList(strWhere);
81
+            return DataTableToList(ds.Tables[0]);
82
+        }
83
+        /// <summary>
84
+        /// 获得数据列表
85
+        /// </summary>
86
+        public List<Model.T_Sys_AssToken> DataTableToList(DataTable dt)
87
+        {
88
+            List<Model.T_Sys_AssToken> modelList = new List<Model.T_Sys_AssToken>();
89
+            int rowsCount = dt.Rows.Count;
90
+            if (rowsCount > 0)
91
+            {
92
+                Model.T_Sys_AssToken model;
93
+                for (int n = 0; n < rowsCount; n++)
94
+                {
95
+                    model = dal.DataRowToModel(dt.Rows[n]);
96
+                    if (model != null)
97
+                    {
98
+                        modelList.Add(model);
99
+                    }
100
+                }
101
+            }
102
+            return modelList;
103
+        }
104
+
105
+        /// <summary>
106
+        /// 获得数据列表
107
+        /// </summary>
108
+        public DataSet GetAllList()
109
+        {
110
+            return GetList("");
111
+        }
112
+
113
+        /// <summary>
114
+        /// 分页获取数据列表
115
+        /// </summary>
116
+        public int GetRecordCount(string strWhere)
117
+        {
118
+            return dal.GetRecordCount(strWhere);
119
+        }
120
+        /// <summary>
121
+        /// 分页获取数据列表
122
+        /// </summary>
123
+        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
124
+        {
125
+            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
126
+        }
127
+        /// <summary>
128
+        /// 分页获取数据列表
129
+        /// </summary>
130
+        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
131
+        //{
132
+        //return dal.GetList(PageSize,PageIndex,strWhere);
133
+        //}
134
+
135
+        #endregion  BasicMethod
136
+        #region  ExtensionMethod
137
+
138
+        #endregion  ExtensionMethod
139
+    }
140
+}
141
+

+ 49 - 0
codegit/CallCenterApi/CallCenterApi.Common/CodeValidate.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.IO;
4
+using System.Linq;
5
+using System.Text;
6
+using CallCenter.Utility;
7
+
8
+namespace CallCenterApi.Common
9
+{
10
+    public class CodeValidate
11
+    {
12
+        /// <summary>
13
+        /// 安全参数
14
+        /// </summary>
15
+        /// <param name="obj">对象</param>
16
+        /// <returns></returns>
17
+        public static bool ICodeValidate(string strParams, string ICode)
18
+        {
19
+            string SecurityCode = Configs.GetValue("SecurityCode"); //ConfigurationManager.AppSettings["SecurityCode"];
20
+            string pwd = CommonHelper.MD5(SecurityCode + strParams);
21
+            return pwd.Equals(ICode);
22
+            //return true;
23
+        }
24
+
25
+        /// <summary>
26
+        /// 安全参数
27
+        /// </summary>
28
+        /// <param name="obj">对象</param>
29
+        /// <returns></returns>
30
+        public static bool ICodeValidateGridding(string strParams, string ICode)
31
+        {
32
+            string SecurityCode = Configs.GetValue("GriddingCode"); //ConfigurationManager.AppSettings["SecurityCode"];
33
+            string pwd = CommonHelper.MD5(SecurityCode + strParams);
34
+            return pwd.Equals(ICode);
35
+            //return true;
36
+        }
37
+
38
+        /// <summary>
39
+        /// 安全参数
40
+        /// </summary>
41
+        /// <param name="obj">对象</param>
42
+        /// <returns></returns>
43
+        public static string ICodeValidateGriddingT(string strParams, string ICode)
44
+        {
45
+            string SecurityCode = Configs.GetValue("GriddingCode"); //ConfigurationManager.AppSettings["SecurityCode"];
46
+            return CommonHelper.MD5(SecurityCode + strParams);
47
+        }
48
+    }
49
+}

文件差异内容过多而无法显示
+ 15 - 0
codegit/CallCenterApi/CallCenterApi.DAL/T_Cus_CustomerBaseNew.cs


+ 365 - 0
codegit/CallCenterApi/CallCenterApi.DAL/T_Cus_Customerrecords.cs

1
+using CallCenterApi.DB;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Data;
5
+using System.Data.SqlClient;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+
10
+namespace CallCenterApi.DAL
11
+{
12
+    /// <summary>
13
+    /// 数据访问类:T_Cus_Customerrecords
14
+    /// </summary>
15
+    public partial class T_Cus_Customerrecords
16
+    {
17
+        public T_Cus_Customerrecords()
18
+        { }
19
+        #region  BasicMethod
20
+
21
+        /// <summary>
22
+        /// 得到最大ID
23
+        /// </summary>
24
+        public int GetMaxId()
25
+        {
26
+            return DbHelperSQL.GetMaxID("F_Id", "T_Cus_Customerrecords");
27
+        }
28
+
29
+        /// <summary>
30
+        /// 是否存在该记录
31
+        /// </summary>
32
+        public bool Exists(string F_Cuscode, string F_Cuscodeuuid, int F_Id)
33
+        {
34
+            StringBuilder strSql = new StringBuilder();
35
+            strSql.Append("select count(1) from T_Cus_Customerrecords");
36
+            strSql.Append(" where F_Cuscode=@F_Cuscode and F_Cuscodeuuid=@F_Cuscodeuuid and F_Id=@F_Id ");
37
+            SqlParameter[] parameters = {
38
+                    new SqlParameter("@F_Cuscode", SqlDbType.VarChar,50),
39
+                    new SqlParameter("@F_Cuscodeuuid", SqlDbType.NVarChar,50),
40
+                    new SqlParameter("@F_Id", SqlDbType.Int,4)          };
41
+            parameters[0].Value = F_Cuscode;
42
+            parameters[1].Value = F_Cuscodeuuid;
43
+            parameters[2].Value = F_Id;
44
+
45
+            return DbHelperSQL.Exists(strSql.ToString(), parameters);
46
+        }
47
+        /// <summary>
48
+        /// 是否存在该记录
49
+        /// </summary>
50
+        public bool ExistsCuscodeuuid( string F_Cuscodeuuid)
51
+        {
52
+            StringBuilder strSql = new StringBuilder();
53
+            strSql.Append("select count(1) from T_Cus_Customerrecords");
54
+            strSql.Append(" where F_Cuscodeuuid=@F_Cuscodeuuid ");
55
+            SqlParameter[] parameters = {
56
+                    new SqlParameter("@F_Cuscodeuuid", SqlDbType.NVarChar,50),
57
+                        };
58
+            parameters[0].Value = F_Cuscodeuuid;
59
+            return DbHelperSQL.Exists(strSql.ToString(), parameters);
60
+        }
61
+
62
+        /// <summary>
63
+        /// 增加一条数据
64
+        /// </summary>
65
+        public int Add(Model.T_Cus_Customerrecords model)
66
+        {
67
+            StringBuilder strSql = new StringBuilder();
68
+            strSql.Append("insert into T_Cus_Customerrecords(");
69
+            strSql.Append("F_Cuscode,F_Cuscodeuuid,F_AddTime,F_Type)");
70
+            strSql.Append(" values (");
71
+            strSql.Append("@F_Cuscode,@F_Cuscodeuuid,@F_AddTime,@F_Type)");
72
+            strSql.Append(";select @@IDENTITY");
73
+            SqlParameter[] parameters = {
74
+                    new SqlParameter("@F_Cuscode", SqlDbType.VarChar,50),
75
+                    new SqlParameter("@F_Cuscodeuuid", SqlDbType.NVarChar,50),
76
+                    new SqlParameter("@F_AddTime", SqlDbType.DateTime),
77
+             new SqlParameter("@F_Type", SqlDbType.Int,4)};
78
+            parameters[0].Value = model.F_Cuscode;
79
+            parameters[1].Value = model.F_Cuscodeuuid;
80
+            parameters[2].Value = model.F_AddTime;
81
+            parameters[3].Value = model.F_Type;
82
+            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
83
+            if (obj == null)
84
+            {
85
+                return 0;
86
+            }
87
+            else
88
+            {
89
+                return Convert.ToInt32(obj);
90
+            }
91
+        }
92
+        /// <summary>
93
+        /// 更新一条数据
94
+        /// </summary>
95
+        public bool Update(Model.T_Cus_Customerrecords model)
96
+        {
97
+            StringBuilder strSql = new StringBuilder();
98
+            strSql.Append("update T_Cus_Customerrecords set ");
99
+            strSql.Append("F_AddTime=@F_AddTime");
100
+            strSql.Append(" where F_Id=@F_Id");
101
+            SqlParameter[] parameters = {
102
+                    new SqlParameter("@F_AddTime", SqlDbType.DateTime),
103
+                    new SqlParameter("@F_Id", SqlDbType.Int,4),
104
+                    new SqlParameter("@F_Cuscode", SqlDbType.VarChar,50),
105
+                    new SqlParameter("@F_Cuscodeuuid", SqlDbType.NVarChar,50)};
106
+            parameters[0].Value = model.F_AddTime;
107
+            parameters[1].Value = model.F_Id;
108
+            parameters[2].Value = model.F_Cuscode;
109
+            parameters[3].Value = model.F_Cuscodeuuid;
110
+
111
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
112
+            if (rows > 0)
113
+            {
114
+                return true;
115
+            }
116
+            else
117
+            {
118
+                return false;
119
+            }
120
+        }
121
+
122
+        /// <summary>
123
+        /// 删除一条数据
124
+        /// </summary>
125
+        public bool Delete(int F_Id)
126
+        {
127
+
128
+            StringBuilder strSql = new StringBuilder();
129
+            strSql.Append("delete from T_Cus_Customerrecords ");
130
+            strSql.Append(" where F_Id=@F_Id");
131
+            SqlParameter[] parameters = {
132
+                    new SqlParameter("@F_Id", SqlDbType.Int,4)
133
+            };
134
+            parameters[0].Value = F_Id;
135
+
136
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
137
+            if (rows > 0)
138
+            {
139
+                return true;
140
+            }
141
+            else
142
+            {
143
+                return false;
144
+            }
145
+        }
146
+        /// <summary>
147
+        /// 删除一条数据
148
+        /// </summary>
149
+        public bool Delete(string F_Cuscode, string F_Cuscodeuuid, int F_Id)
150
+        {
151
+
152
+            StringBuilder strSql = new StringBuilder();
153
+            strSql.Append("delete from T_Cus_Customerrecords ");
154
+            strSql.Append(" where F_Cuscode=@F_Cuscode and F_Cuscodeuuid=@F_Cuscodeuuid and F_Id=@F_Id ");
155
+            SqlParameter[] parameters = {
156
+                    new SqlParameter("@F_Cuscode", SqlDbType.VarChar,50),
157
+                    new SqlParameter("@F_Cuscodeuuid", SqlDbType.NVarChar,50),
158
+                    new SqlParameter("@F_Id", SqlDbType.Int,4)          };
159
+            parameters[0].Value = F_Cuscode;
160
+            parameters[1].Value = F_Cuscodeuuid;
161
+            parameters[2].Value = F_Id;
162
+
163
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
164
+            if (rows > 0)
165
+            {
166
+                return true;
167
+            }
168
+            else
169
+            {
170
+                return false;
171
+            }
172
+        }
173
+        /// <summary>
174
+        /// 批量删除数据
175
+        /// </summary>
176
+        public bool DeleteList(string F_Idlist)
177
+        {
178
+            StringBuilder strSql = new StringBuilder();
179
+            strSql.Append("delete from T_Cus_Customerrecords ");
180
+            strSql.Append(" where F_Id in (" + F_Idlist + ")  ");
181
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
182
+            if (rows > 0)
183
+            {
184
+                return true;
185
+            }
186
+            else
187
+            {
188
+                return false;
189
+            }
190
+        }
191
+
192
+
193
+        /// <summary>
194
+        /// 得到一个对象实体
195
+        /// </summary>
196
+        public Model.T_Cus_Customerrecords GetModel(int F_Id)
197
+        {
198
+
199
+            StringBuilder strSql = new StringBuilder();
200
+            strSql.Append("select  top 1 F_Id,F_Cuscode,F_Cuscodeuuid,F_AddTime from T_Cus_Customerrecords ");
201
+            strSql.Append(" where F_Id=@F_Id");
202
+            SqlParameter[] parameters = {
203
+                    new SqlParameter("@F_Id", SqlDbType.Int,4)
204
+            };
205
+            parameters[0].Value = F_Id;
206
+
207
+           Model.T_Cus_Customerrecords model = new Model.T_Cus_Customerrecords();
208
+            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
209
+            if (ds.Tables[0].Rows.Count > 0)
210
+            {
211
+                return DataRowToModel(ds.Tables[0].Rows[0]);
212
+            }
213
+            else
214
+            {
215
+                return null;
216
+            }
217
+        }
218
+
219
+
220
+        /// <summary>
221
+        /// 得到一个对象实体
222
+        /// </summary>
223
+        public Model.T_Cus_Customerrecords DataRowToModel(DataRow row)
224
+        {
225
+            Model.T_Cus_Customerrecords model = new Model.T_Cus_Customerrecords();
226
+            if (row != null)
227
+            {
228
+                if (row["F_Id"] != null && row["F_Id"].ToString() != "")
229
+                {
230
+                    model.F_Id = int.Parse(row["F_Id"].ToString());
231
+                }
232
+                if (row["F_Cuscode"] != null)
233
+                {
234
+                    model.F_Cuscode = row["F_Cuscode"].ToString();
235
+                }
236
+                if (row["F_Cuscodeuuid"] != null)
237
+                {
238
+                    model.F_Cuscodeuuid = row["F_Cuscodeuuid"].ToString();
239
+                }
240
+                if (row["F_AddTime"] != null && row["F_AddTime"].ToString() != "")
241
+                {
242
+                    model.F_AddTime = DateTime.Parse(row["F_AddTime"].ToString());
243
+                }
244
+                if (row["F_Type"] != null && row["F_Type"].ToString() != "")
245
+                {
246
+                    model.F_Type = int .Parse(row["F_Type"].ToString());
247
+                }
248
+            }
249
+            return model;
250
+        }
251
+
252
+        /// <summary>
253
+        /// 获得数据列表
254
+        /// </summary>
255
+        public DataSet GetList(string strWhere)
256
+        {
257
+            StringBuilder strSql = new StringBuilder();
258
+            strSql.Append("select F_Id,F_Cuscode,F_Cuscodeuuid,F_AddTime ");
259
+            strSql.Append(" FROM T_Cus_Customerrecords ");
260
+            if (strWhere.Trim() != "")
261
+            {
262
+                strSql.Append(" where " + strWhere);
263
+            }
264
+            return DbHelperSQL.Query(strSql.ToString());
265
+        }
266
+
267
+        /// <summary>
268
+        /// 获得前几行数据
269
+        /// </summary>
270
+        public DataSet GetList(int Top, string strWhere, string filedOrder)
271
+        {
272
+            StringBuilder strSql = new StringBuilder();
273
+            strSql.Append("select ");
274
+            if (Top > 0)
275
+            {
276
+                strSql.Append(" top " + Top.ToString());
277
+            }
278
+            strSql.Append(" F_Id,F_Cuscode,F_Cuscodeuuid,F_AddTime ");
279
+            strSql.Append(" FROM T_Cus_Customerrecords ");
280
+            if (strWhere.Trim() != "")
281
+            {
282
+                strSql.Append(" where " + strWhere);
283
+            }
284
+            strSql.Append(" order by " + filedOrder);
285
+            return DbHelperSQL.Query(strSql.ToString());
286
+        }
287
+
288
+        /// <summary>
289
+        /// 获取记录总数
290
+        /// </summary>
291
+        public int GetRecordCount(string strWhere)
292
+        {
293
+            StringBuilder strSql = new StringBuilder();
294
+            strSql.Append("select count(1) FROM T_Cus_Customerrecords ");
295
+            if (strWhere.Trim() != "")
296
+            {
297
+                strSql.Append(" where " + strWhere);
298
+            }
299
+            object obj = DbHelperSQL.GetSingle(strSql.ToString());
300
+            if (obj == null)
301
+            {
302
+                return 0;
303
+            }
304
+            else
305
+            {
306
+                return Convert.ToInt32(obj);
307
+            }
308
+        }
309
+        /// <summary>
310
+        /// 分页获取数据列表
311
+        /// </summary>
312
+        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
313
+        {
314
+            StringBuilder strSql = new StringBuilder();
315
+            strSql.Append("SELECT * FROM ( ");
316
+            strSql.Append(" SELECT ROW_NUMBER() OVER (");
317
+            if (!string.IsNullOrEmpty(orderby.Trim()))
318
+            {
319
+                strSql.Append("order by T." + orderby);
320
+            }
321
+            else
322
+            {
323
+                strSql.Append("order by T.F_Id desc");
324
+            }
325
+            strSql.Append(")AS Row, T.*  from T_Cus_Customerrecords T ");
326
+            if (!string.IsNullOrEmpty(strWhere.Trim()))
327
+            {
328
+                strSql.Append(" WHERE " + strWhere);
329
+            }
330
+            strSql.Append(" ) TT");
331
+            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
332
+            return DbHelperSQL.Query(strSql.ToString());
333
+        }
334
+
335
+        /*
336
+		/// <summary>
337
+		/// 分页获取数据列表
338
+		/// </summary>
339
+		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
340
+		{
341
+			SqlParameter[] parameters = {
342
+					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
343
+					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
344
+					new SqlParameter("@PageSize", SqlDbType.Int),
345
+					new SqlParameter("@PageIndex", SqlDbType.Int),
346
+					new SqlParameter("@IsReCount", SqlDbType.Bit),
347
+					new SqlParameter("@OrderType", SqlDbType.Bit),
348
+					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
349
+					};
350
+			parameters[0].Value = "T_Cus_Customerrecords";
351
+			parameters[1].Value = "F_Id";
352
+			parameters[2].Value = PageSize;
353
+			parameters[3].Value = PageIndex;
354
+			parameters[4].Value = 0;
355
+			parameters[5].Value = 0;
356
+			parameters[6].Value = strWhere;	
357
+			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
358
+		}*/
359
+
360
+        #endregion  BasicMethod
361
+        #region  ExtensionMethod
362
+
363
+        #endregion  ExtensionMethod
364
+    }
365
+}

+ 314 - 0
codegit/CallCenterApi/CallCenterApi.DAL/T_Sys_AssToken.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Data.SqlClient;
6
+using System.Data;
7
+using CallCenterApi.DB;
8
+namespace CallCenterApi.DAL
9
+{
10
+    /// <summary>
11
+    /// 数据访问类:T_Sys_AssToken
12
+    /// </summary>
13
+    public partial class T_Sys_AssToken
14
+    {
15
+        public T_Sys_AssToken()
16
+        { }
17
+        #region  BasicMethod
18
+
19
+
20
+
21
+        /// <summary>
22
+        /// 增加一条数据
23
+        /// </summary>
24
+        public int Add(Model.T_Sys_AssToken model)
25
+        {
26
+            StringBuilder strSql = new StringBuilder();
27
+            strSql.Append("insert into T_Sys_AssToken(");
28
+            strSql.Append("F_Token,F_CreatTime,F_Url,F_Ticket,F_IsDelete)");
29
+            strSql.Append(" values (");
30
+            strSql.Append("@F_Token,@F_CreatTime,@F_Url,@F_Ticket,@F_IsDelete)");
31
+            strSql.Append(";select @@IDENTITY");
32
+            SqlParameter[] parameters = {
33
+                    new SqlParameter("@F_Token", SqlDbType.NVarChar,500),
34
+                    new SqlParameter("@F_CreatTime", SqlDbType.DateTime),
35
+                    new SqlParameter("@F_Url", SqlDbType.NVarChar,500),
36
+                    new SqlParameter("@F_Ticket", SqlDbType.NVarChar,500),
37
+             new SqlParameter("@F_IsDelete",SqlDbType.Int,4)};
38
+            parameters[0].Value = model.F_Token;
39
+            parameters[1].Value = model.F_CreatTime;
40
+            parameters[2].Value = model.F_Url;
41
+            parameters[3].Value = model.F_Ticket;
42
+            parameters[4].Value = model.F_IsDelete;
43
+            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
44
+            if (obj == null)
45
+            {
46
+                return 0;
47
+            }
48
+            else
49
+            {
50
+                return Convert.ToInt32(obj);
51
+            }
52
+        }
53
+        /// <summary>
54
+        /// 更新一条数据
55
+        /// </summary>
56
+        public bool Update(Model.T_Sys_AssToken model)
57
+        {
58
+            StringBuilder strSql = new StringBuilder();
59
+            strSql.Append("update T_Sys_AssToken set ");
60
+            strSql.Append("F_Token=@F_Token,");
61
+            strSql.Append("F_CreatTime=@F_CreatTime,");
62
+            strSql.Append("F_Url=@F_Url,");
63
+            strSql.Append("F_Ticket=@F_Ticket");
64
+            strSql.Append("F_IsDelete=@F_IsDelete");
65
+            strSql.Append(" where F_ID=@F_ID");
66
+            SqlParameter[] parameters = {
67
+                    new SqlParameter("@F_Token", SqlDbType.NVarChar,500),
68
+                    new SqlParameter("@F_CreatTime", SqlDbType.DateTime),
69
+                    new SqlParameter("@F_Url", SqlDbType.NVarChar,500),
70
+                    new SqlParameter("@F_Ticket", SqlDbType.NVarChar,500),
71
+                     new SqlParameter("@F_IsDelete",SqlDbType.Int,4),
72
+                    
73
+                    new SqlParameter("@F_ID", SqlDbType.Int,4)};
74
+            parameters[0].Value = model.F_Token;
75
+            parameters[1].Value = model.F_CreatTime;
76
+            parameters[2].Value = model.F_Url;
77
+            parameters[3].Value = model.F_Ticket;
78
+            parameters[4].Value = model.F_IsDelete;
79
+            parameters[5].Value = model.F_ID;
80
+
81
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
82
+            if (rows > 0)
83
+            {
84
+                return true;
85
+            }
86
+            else
87
+            {
88
+                return false;
89
+            }
90
+        }
91
+
92
+        /// <summary>
93
+        /// 删除一条数据
94
+        /// </summary>
95
+        public bool Delete(int F_ID)
96
+        {
97
+
98
+            StringBuilder strSql = new StringBuilder();
99
+            strSql.Append("delete from T_Sys_AssToken ");
100
+            strSql.Append(" where F_ID=@F_ID");
101
+            SqlParameter[] parameters = {
102
+                    new SqlParameter("@F_ID", SqlDbType.Int,4)
103
+            };
104
+            parameters[0].Value = F_ID;
105
+
106
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
107
+            if (rows > 0)
108
+            {
109
+                return true;
110
+            }
111
+            else
112
+            {
113
+                return false;
114
+            }
115
+        }
116
+        /// <summary>
117
+        /// 批量删除数据
118
+        /// </summary>
119
+        public bool DeleteList(string F_IDlist)
120
+        {
121
+            StringBuilder strSql = new StringBuilder();
122
+            strSql.Append("delete from T_Sys_AssToken ");
123
+            strSql.Append(" where F_ID in (" + F_IDlist + ")  ");
124
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
125
+            if (rows > 0)
126
+            {
127
+                return true;
128
+            }
129
+            else
130
+            {
131
+                return false;
132
+            }
133
+        }
134
+
135
+
136
+        /// <summary>
137
+        /// 得到一个对象实体
138
+        /// </summary>
139
+        public Model.T_Sys_AssToken GetModel(int F_ID)
140
+        {
141
+
142
+            StringBuilder strSql = new StringBuilder();
143
+            strSql.Append("select  top 1 F_ID,F_Token,F_CreatTime,F_Url,F_Ticket,F_IsDelete from T_Sys_AssToken ");
144
+            strSql.Append(" where F_ID=@F_ID");
145
+            SqlParameter[] parameters = {
146
+                    new SqlParameter("@F_ID", SqlDbType.Int,4)
147
+            };
148
+            parameters[0].Value = F_ID;
149
+
150
+            Model.T_Sys_AssToken model = new Model.T_Sys_AssToken();
151
+            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
152
+            if (ds.Tables[0].Rows.Count > 0)
153
+            {
154
+                return DataRowToModel(ds.Tables[0].Rows[0]);
155
+            }
156
+            else
157
+            {
158
+                return null;
159
+            }
160
+        }
161
+
162
+
163
+        /// <summary>
164
+        /// 得到一个对象实体
165
+        /// </summary>
166
+        public Model.T_Sys_AssToken DataRowToModel(DataRow row)
167
+        {
168
+            Model.T_Sys_AssToken model = new Model.T_Sys_AssToken();
169
+            if (row != null)
170
+            {
171
+                if (row["F_ID"] != null && row["F_ID"].ToString() != "")
172
+                {
173
+                    model.F_ID = int.Parse(row["F_ID"].ToString());
174
+                }
175
+                if (row["F_Token"] != null)
176
+                {
177
+                    model.F_Token = row["F_Token"].ToString();
178
+                }
179
+                if (row["F_CreatTime"] != null && row["F_CreatTime"].ToString() != "")
180
+                {
181
+                    model.F_CreatTime = DateTime.Parse(row["F_CreatTime"].ToString());
182
+                }
183
+                if (row["F_Url"] != null)
184
+                {
185
+                    model.F_Url = row["F_Url"].ToString();
186
+                }
187
+                if (row["F_Ticket"] != null)
188
+                {
189
+                    model.F_Ticket = row["F_Ticket"].ToString();
190
+                }
191
+                if (row["F_IsDelete"] != null && row["F_IsDelete"].ToString() != "")
192
+                {
193
+                    model.F_IsDelete = int.Parse(row["F_IsDelete"].ToString());
194
+                }
195
+                
196
+            }
197
+            return model;
198
+        }
199
+
200
+        /// <summary>
201
+        /// 获得数据列表
202
+        /// </summary>
203
+        public DataSet GetList(string strWhere)
204
+        {
205
+            StringBuilder strSql = new StringBuilder();
206
+            strSql.Append("select F_ID,F_Token,F_CreatTime,F_Url,F_Ticket,F_IsDelete ");
207
+            strSql.Append(" FROM T_Sys_AssToken ");
208
+            if (strWhere.Trim() != "")
209
+            {
210
+                strSql.Append(" where " + strWhere);
211
+            }
212
+            return DbHelperSQL.Query(strSql.ToString());
213
+        }
214
+
215
+        /// <summary>
216
+        /// 获得前几行数据
217
+        /// </summary>
218
+        public DataSet GetList(int Top, string strWhere, string filedOrder)
219
+        {
220
+            StringBuilder strSql = new StringBuilder();
221
+            strSql.Append("select ");
222
+            if (Top > 0)
223
+            {
224
+                strSql.Append(" top " + Top.ToString());
225
+            }
226
+            strSql.Append(" F_ID,F_Token,F_CreatTime,F_Url,F_Ticket,F_IsDelete ");
227
+            strSql.Append(" FROM T_Sys_AssToken ");
228
+            if (strWhere.Trim() != "")
229
+            {
230
+                strSql.Append(" where " + strWhere);
231
+            }
232
+            strSql.Append(" order by " + filedOrder);
233
+            return DbHelperSQL.Query(strSql.ToString());
234
+        }
235
+
236
+        /// <summary>
237
+        /// 获取记录总数
238
+        /// </summary>
239
+        public int GetRecordCount(string strWhere)
240
+        {
241
+            StringBuilder strSql = new StringBuilder();
242
+            strSql.Append("select count(1) FROM T_Sys_AssToken ");
243
+            if (strWhere.Trim() != "")
244
+            {
245
+                strSql.Append(" where " + strWhere);
246
+            }
247
+            object obj = DbHelperSQL.GetSingle(strSql.ToString());
248
+            if (obj == null)
249
+            {
250
+                return 0;
251
+            }
252
+            else
253
+            {
254
+                return Convert.ToInt32(obj);
255
+            }
256
+        }
257
+        /// <summary>
258
+        /// 分页获取数据列表
259
+        /// </summary>
260
+        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
261
+        {
262
+            StringBuilder strSql = new StringBuilder();
263
+            strSql.Append("SELECT * FROM ( ");
264
+            strSql.Append(" SELECT ROW_NUMBER() OVER (");
265
+            if (!string.IsNullOrEmpty(orderby.Trim()))
266
+            {
267
+                strSql.Append("order by T." + orderby);
268
+            }
269
+            else
270
+            {
271
+                strSql.Append("order by T.F_ID desc");
272
+            }
273
+            strSql.Append(")AS Row, T.*  from T_Sys_AssToken T ");
274
+            if (!string.IsNullOrEmpty(strWhere.Trim()))
275
+            {
276
+                strSql.Append(" WHERE " + strWhere);
277
+            }
278
+            strSql.Append(" ) TT");
279
+            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
280
+            return DbHelperSQL.Query(strSql.ToString());
281
+        }
282
+
283
+        /*
284
+		/// <summary>
285
+		/// 分页获取数据列表
286
+		/// </summary>
287
+		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
288
+		{
289
+			SqlParameter[] parameters = {
290
+					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
291
+					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
292
+					new SqlParameter("@PageSize", SqlDbType.Int),
293
+					new SqlParameter("@PageIndex", SqlDbType.Int),
294
+					new SqlParameter("@IsReCount", SqlDbType.Bit),
295
+					new SqlParameter("@OrderType", SqlDbType.Bit),
296
+					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
297
+					};
298
+			parameters[0].Value = "T_Sys_AssToken";
299
+			parameters[1].Value = "F_ID";
300
+			parameters[2].Value = PageSize;
301
+			parameters[3].Value = PageIndex;
302
+			parameters[4].Value = 0;
303
+			parameters[5].Value = 0;
304
+			parameters[6].Value = strWhere;	
305
+			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
306
+		}*/
307
+
308
+        #endregion  BasicMethod
309
+        #region  ExtensionMethod
310
+
311
+        #endregion  ExtensionMethod
312
+    }
313
+}
314
+

+ 140 - 26
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/customer/CustomerNewController.cs

45
         /// <param name="contel">联系人电话</param>
45
         /// <param name="contel">联系人电话</param>
46
         /// <returns></returns>
46
         /// <returns></returns>
47
         public ActionResult GetList(string keywords, string channel,string code, string cmpname, string legname, string legtel, string province, string city,
47
         public ActionResult GetList(string keywords, string channel,string code, string cmpname, string legname, string legtel, string province, string city,
48
-            string country, string township, int areaid = 0, int branchid = 0, int pageindex = 1, int pagesize = 10)
48
+            string country, string township, int areaid = 0, int branchid = 0, int pageindex = 1, int pagesize = 10,int isdc=0)
49
         {
49
         {
50
             string sql = $" and F_IsDelete=0";
50
             string sql = $" and F_IsDelete=0";
51
             DataTable dt = new DataTable();
51
             DataTable dt = new DataTable();
86
             #endregion
86
             #endregion
87
 
87
 
88
             int recordCount = 0;
88
             int recordCount = 0;
89
-            if (!string.IsNullOrWhiteSpace(sql))
89
+            if (isdc>0)
90
             {
90
             {
91
-                dt = BLL.PagerBLL.GetListPager(
92
-                    "T_Cus_CustomerBaseNew",
93
-                    "F_CustomerId",
94
-                    "*,dbo.GetUserName(F_CreateBy) as F_CreateByName",
95
-                    sql,
96
-                    "ORDER BY F_CustomerId desc",
97
-                    pagesize,
98
-                    pageindex,
99
-                    true,
100
-                    out recordCount);
91
+                dt = new BLL.T_Cus_CustomerBaseNew().GetExpt(sql).Tables[0];
92
+                NPOIHelper npoi = new NPOIHelper();
93
+                if (npoi.ExportToExcel("客户档案", dt, cjcol()) == "")
94
+                {
95
+                    return Success("导出成功");
96
+                }
97
+                else
98
+                {
99
+                    return Error("导出失败");
100
+                }
101
             }
101
             }
102
-            List<Model.T_Cus_CustomerBaseNew> modlelist = new BLL.T_Cus_CustomerBaseNew().DataTableToList(dt);
103
-            List<CustomerBaseNewInput> Input = modeltooip(modlelist);
104
-            var obj = new
102
+            else
105
             {
103
             {
106
-                state = "success",
107
-                message = "成功",
108
-                rows = Input,
109
-                total = recordCount
110
-            };
104
+                if (!string.IsNullOrWhiteSpace(sql))
105
+                {
106
+                    dt = BLL.PagerBLL.GetListPager(
107
+                        "T_Cus_CustomerBaseNew",
108
+                        "F_CustomerId",
109
+                        "*",
110
+                        sql,
111
+                        "ORDER BY F_CustomerId desc",
112
+                        pagesize,
113
+                        pageindex,
114
+                        true,
115
+                        out recordCount);
116
+                }
117
+                List<Model.T_Cus_CustomerBaseNew> modlelist = new BLL.T_Cus_CustomerBaseNew().DataTableToList(dt);
118
+                List<CustomerBaseNewInput> Input = modeltooip(modlelist);
119
+                var obj = new
120
+                {
121
+                    state = "success",
122
+                    message = "成功",
123
+                    rows = Input,
124
+                    total = recordCount
125
+                };
111
 
126
 
112
-            return Content(obj.ToJson());
127
+                return Content(obj.ToJson());
128
+            }
129
+       
113
 
130
 
114
         }
131
         }
132
+        private string[] cjcol()
133
+        {
134
+
135
+            string[] ccc = {
136
+                   "客户编号","公司名称","大区名称","分公司名称","业务员","业务员电话","渠道类型","信用等级","客户",
137
+                  "客户电话","性别","省","市","县","乡","详细地址","经营品牌"
138
+                  ,"产品" ,"是否经营心连心","年销量","配方","种植作物","种植面积","用肥品牌","备注"
139
+            };
140
+            return ccc;
141
+        }
115
         /// <summary>
142
         /// <summary>
116
         /// 通过来电号码获取来电弹屏左侧客户信息
143
         /// 通过来电号码获取来电弹屏左侧客户信息
117
         /// </summary>
144
         /// </summary>
487
             else
514
             else
488
                 return Error("新增失败!");
515
                 return Error("新增失败!");
489
         }
516
         }
517
+        public int  CustemweCode(string customercode, string gender,
518
+          string companyname, string area, string branch, string salesman
519
+          , string salesphone, string channel, string credit, string customername,
520
+          string customerphone, string province, string city, string country, string township
521
+          , string addressfull, string brands, string product, string isrunxlx, string annualsales
522
+          , string formula, string raisecrops, string plantingarea, string fertilizerbrand, string remark,int id=0)
523
+        {
524
+            
525
+            var model = new Model.T_Cus_CustomerBaseNew();
526
+            if (id >0)
527
+            {
528
+                model = new BLL.T_Cus_CustomerBaseNew().GetModel(id);
529
+            }
530
+            int i = 0;
531
+            model.F_CustomerCode = customercode;//客户编号
532
+            model.F_CompanyName = companyname;//公司名称
533
+            model.F_AreaID = area;//大区
534
+            model.F_BranchID = branch;//分公司
535
+            model.F_Gender = gender;//性别
536
+            model.F_Salesman = salesman;//业务员
537
+            model.F_SalesPhone = salesphone;//业务员电话
538
+            model.F_Channel = channel;// 渠道类型:总经销、二级商、种田大户、农户、化工客户、公司员工
539
+            model.F_Credit = credit;//信用等级:一星、二星、三星、四星、五星、空
540
+            model.F_Legal = customername;//法人 
541
+            model.F_LegalPhone = customerphone;//法人电话
542
+            model.F_AddressProvince = province;//省
543
+            model.F_AddressCity = city;//市
544
+            model.F_AddressCountry = country;
545
+            model.F_AddressTownship = township;//乡
546
+            model.F_AddressFull = addressfull;//详细地址
547
+            model.F_Brands = brands;// 经营品牌:心连心、手拉手、沃利沃、双心、空
548
+            model.F_Product = product;//产品:复合肥心连心、复合肥手拉手、复合肥沃利沃、复合肥双心、尿素心连心、尿素手拉手、尿素沃利沃、尿素双心
549
+            model.F_IsRunXLX = isrunxlx;// 是否经营心连心:是、否
550
+            model.F_AnnualSales = annualsales;//年销量
551
+            model.F_Formula = formula;//配方
552
+            model.F_RaiseCrops = raisecrops;//种植作物
553
+            model.F_PlantingArea = plantingarea;//种植面积
554
+            model.F_FertilizerBrand = fertilizerbrand;//用肥品牌
555
+            model.F_Remark = remark;//备注
556
+            model.F_FileId = 0;
557
+            model.F_CreateBy = "系统外添加";
558
+            model.F_CreateOn = DateTime.Now;
559
+            model.F_IsDelete = 0;
560
+            if (id >0)
561
+            {
562
+                bool  n = cusbll.Update (model);
563
+                if (n)
564
+                {
565
+                    return id ;
566
+                }
567
+                else
568
+                    return 0;
569
+            }
570
+            else
571
+            {
572
+                int n = cusbll.Add(model);
573
+                if (n > 0)
574
+                {
575
+                    return n;
576
+                }
577
+                else
578
+                    return 0;
579
+            }
580
+           
581
+        }
490
         public static bool IsNumeric(string value)
582
         public static bool IsNumeric(string value)
491
         {
583
         {
492
             return Regex.IsMatch(value, @"^[+-]?\d*[.]?\d*$");
584
             return Regex.IsMatch(value, @"^[+-]?\d*[.]?\d*$");
690
         /// <summary>
782
         /// <summary>
691
         /// 验证客户编号是否唯一
783
         /// 验证客户编号是否唯一
692
         /// </summary>
784
         /// </summary>
693
-        private bool getunique(int id, string code)
785
+        public  bool getunique(int id, string code)
694
         {
786
         {
695
             var sql = " F_IsDelete=0 ";
787
             var sql = " F_IsDelete=0 ";
696
             sql += "and (F_CustomerCode='" + code + "')";
788
             sql += "and (F_CustomerCode='" + code + "')";
703
         /// <summary>
795
         /// <summary>
704
         /// 验证客户电话是否唯一
796
         /// 验证客户电话是否唯一
705
         /// </summary>
797
         /// </summary>
706
-        private bool getunphone(int id, string phone)
798
+        public  bool getunphone(int id, string phone)
707
         {
799
         {
708
             var sql = " F_IsDelete=0 ";
800
             var sql = " F_IsDelete=0 ";
709
             sql += "and (F_LegalPhone='" + phone.Trim() + "')";
801
             sql += "and (F_LegalPhone='" + phone.Trim() + "')";
716
         /// <summary>
808
         /// <summary>
717
         /// 删除客户
809
         /// 删除客户
718
         /// </summary>
810
         /// </summary>
811
+        /// <param name="ids"></param>getunique
812
+        /// <returns></returns>
813
+        public bool  DelCustomer(string id)
814
+        {
815
+              if (cusbll.DeleteList(id))
816
+                {
817
+                    // conbll.DeleteListByCusid(idd.TrimEnd(','));
818
+                    return true;
819
+                }
820
+                else
821
+                {
822
+                    return false;
823
+                }
824
+           
825
+        }
826
+        /// <summary>
827
+        /// 删除客户
828
+        /// </summary>
719
         /// <param name="ids"></param>
829
         /// <param name="ids"></param>
720
         /// <returns></returns>
830
         /// <returns></returns>
721
         public ActionResult DelCustomer(string[] ids)
831
         public ActionResult DelCustomer(string[] ids)
731
                 {
841
                 {
732
                     if (cusbll.DeleteList(idd.TrimEnd(',')))
842
                     if (cusbll.DeleteList(idd.TrimEnd(',')))
733
                     {
843
                     {
734
-                        conbll.DeleteListByCusid(idd.TrimEnd(','));
844
+                       // conbll.DeleteListByCusid(idd.TrimEnd(','));
735
                         return Success("设置成功");
845
                         return Success("设置成功");
736
                     }
846
                     }
737
                     else
847
                     else
749
                 return Error("获取参数失败");
859
                 return Error("获取参数失败");
750
             }
860
             }
751
         }
861
         }
862
+        public Model.T_Sys_Department IsModelDeptment(string deptname)
863
+        {
864
+            Model.T_Sys_Department pdModel = departmentBLL.GetModel(deptname);
865
+            return pdModel;
866
+        }
752
         #region 客户使用微信端才会使用
867
         #region 客户使用微信端才会使用
753
         ///// <summary>
868
         ///// <summary>
754
         ///// 重置密码
869
         ///// 重置密码
844
                         {
959
                         {
845
                             #region 数据入库
960
                             #region 数据入库
846
                             headrow = headrow + 1;
961
                             headrow = headrow + 1;
847
-
848
                             if (dr["客户编号"].ToString() != "" && valcode(dr["客户编号"].ToString()))
962
                             if (dr["客户编号"].ToString() != "" && valcode(dr["客户编号"].ToString()))
849
                             {
963
                             {
850
                                 if (!getunique(0, dr["客户编号"].ToString()))
964
                                 if (!getunique(0, dr["客户编号"].ToString()))
1078
         /// <summary>
1192
         /// <summary>
1079
         /// 验证物料编码为10位纯数字
1193
         /// 验证物料编码为10位纯数字
1080
         /// </summary>
1194
         /// </summary>
1081
-        private bool valcode(string code)
1195
+        public  bool valcode(string code)
1082
         {
1196
         {
1083
             var res = false;
1197
             var res = false;
1084
             //11位数字
1198
             //11位数字

+ 540 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/customer/XLXCustomerController.cs

1
+using CallCenter.Utility;
2
+using CallCenter.Utility.log;
3
+using CallCenterApi.Common;
4
+using CallCenterApi.DB;
5
+using CallCenterApi.Interface.Controllers.Base;
6
+using Newtonsoft.Json.Linq;
7
+using System;
8
+using System.Collections.Generic;
9
+using System.Data;
10
+using System.Linq;
11
+using System.Text.RegularExpressions;
12
+using System.Web;
13
+using System.Web.Mvc;
14
+
15
+namespace CallCenterApi.Interface.Controllers.customer
16
+{
17
+    public class XLXCustomerController : BaseController
18
+    {
19
+        private AjaxResult ajresult = new AjaxResult();
20
+        BLL.T_Cus_Customerrecords t_Cus_Customerrecords = new BLL.T_Cus_Customerrecords();
21
+        public ActionResult AddCustomer()
22
+        {
23
+            Model.T_Cus_Customerrecords cusmodel = new Model.T_Cus_Customerrecords();
24
+            string port_password = RequestString.GetFormString("port_password");   //加密信息(安全验证用)
25
+            string uuid = RequestString.GetFormString("uuid");          //客户唯一标识(安全验证用)
26
+               //信息来源
27
+            string customercode = RequestString.GetFormString("customercode");   //客户code10位数字
28
+            int  gender = RequestString.GetInt("gender", 1);     //客户性别1男2女
29
+            string companyname = RequestString.GetFormString("companyname");    //公司名称
30
+            string areaname = RequestString.GetFormString("areaname");    //大区名称
31
+            string branchname = RequestString.GetFormString("branchname");    //分公司名称
32
+            string salesman = RequestString.GetFormString("salesman");    //业务员
33
+            string salesphone = RequestString.GetFormString("salesphone");    //业务员电话
34
+            string channel = RequestString.GetFormString("channel");    //渠道类型
35
+            string credit = RequestString.GetFormString("credit");    //信用等级
36
+            string customername = RequestString.GetFormString("customername");    //客户姓名
37
+            string customerphone = RequestString.GetFormString("customerphone");    //客户电话
38
+            string province = RequestString.GetFormString("province");    //省份
39
+            string city = RequestString.GetFormString("city");    //市
40
+            string country  = RequestString.GetFormString("country");    //区/县
41
+            string township = RequestString.GetFormString("township");    //乡镇
42
+            string  addressfull = RequestString.GetFormString("addressfull");    //详细地址
43
+            string brands = RequestString.GetFormString("brands");    //经营品牌
44
+            string product = RequestString.GetFormString("product");    //产品
45
+            string isrunxlx = RequestString.GetFormString("isrunxlx");     //是否经营心连心0否1是
46
+            string annualsales = RequestString.GetFormString("annualsales");    //年销量
47
+            string formula = RequestString.GetFormString("formula");    //配方
48
+            string raisecrops = RequestString.GetFormString("raisecrops");    //种植作物
49
+            string plantingarea = RequestString.GetFormString("plantingarea");    //种植面积
50
+            string fertilizerbrand = RequestString.GetFormString("fertilizerbrand");    //用肥品牌
51
+            string remark = RequestString.GetFormString("remark");    //备注
52
+            if (string.IsNullOrEmpty(uuid))
53
+            {
54
+                ajresult.state = (int)CodeStatus.ID不存在;
55
+                ajresult.message = "客户唯一标识不能为空";
56
+                return Process();
57
+            }
58
+            else if (uuid.Length > 50)
59
+            {
60
+                ajresult.state = (int)CodeStatus.字符串超出长度;
61
+                ajresult.message = "客户唯一标识超出长度";
62
+                return Process();
63
+            }
64
+            CustomerNewController cus = new CustomerNewController();
65
+            if (!string.IsNullOrEmpty(customercode))
66
+            {
67
+                if (!cus.valcode(customercode))
68
+                {
69
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
70
+                    ajresult.message = "客户编号必须是10位数字";
71
+                    return Process();
72
+                }
73
+                  
74
+                if (cus.getunique(0, customercode))
75
+                {
76
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
77
+                    ajresult.message = "客户编号已被占用,请重新输入!";
78
+                    return Process();
79
+                }
80
+            }
81
+            else
82
+            {
83
+                ajresult.state = (int)CodeStatus.必填字段为空;
84
+                ajresult.message = "客户编号不能为空";
85
+                return Process();
86
+            }
87
+            if (string.IsNullOrEmpty(customerphone))
88
+            {
89
+                ajresult.state = (int)CodeStatus.必填字段为空;
90
+                ajresult.message = "客户电话不能为空";
91
+                return Process();
92
+            }
93
+            if (!Common.CodeValidate.ICodeValidate(uuid + customercode, port_password))
94
+            {
95
+                ajresult.state = (int)CodeStatus.安全验证未通过;
96
+                ajresult.message = "安全验证未通过";
97
+                return Process();
98
+            }
99
+            if (string.IsNullOrEmpty(customername))
100
+            {
101
+                ajresult.state = (int)CodeStatus.必填字段为空;
102
+                ajresult.message = "客户姓名不能为空";
103
+                return Process();
104
+            }
105
+            if (cus.getunphone(0, customerphone))
106
+            {
107
+                ajresult.state = (int)CodeStatus.参数逻辑错误;
108
+                ajresult.message = "已存在该客户请勿重复添加";
109
+                return Process();
110
+            }
111
+            if (!string.IsNullOrEmpty(salesphone))
112
+            {
113
+                if (!IsNumeric(salesphone))
114
+                   {
115
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
116
+                    ajresult.message = "请输入正确的业务员电话";
117
+                    return Process();
118
+                 }
119
+            }
120
+            if (gender>2|| gender<1)
121
+            {
122
+                ajresult.state = (int)CodeStatus.参数逻辑错误;
123
+                ajresult.message = "性别错误!";
124
+                return Process();
125
+            }
126
+            string  area="", branch = "";
127
+            if (!string .IsNullOrEmpty (areaname))
128
+            {
129
+                if (cus .IsModelDeptment (areaname)==null )
130
+                {
131
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
132
+                    ajresult.message = "大区名称错误!查找不到该大区";
133
+                    return Process();
134
+                }
135
+                else
136
+                {
137
+                    area = cus.IsModelDeptment(areaname).F_DeptId.ToString ();
138
+                }
139
+            }
140
+           
141
+            if (!string.IsNullOrEmpty(branchname))
142
+            {
143
+                if (cus.IsModelDeptment(branchname) == null)
144
+                {
145
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
146
+                    ajresult.message = "分公司名称错误!查找不到该分公司";
147
+                    return Process();
148
+                }
149
+                else
150
+                    branch = cus.IsModelDeptment(branchname).F_DeptId.ToString();
151
+            }
152
+          
153
+            if (!t_Cus_Customerrecords.ExistsCuscodeuuid(uuid))  //uuid不存在时,防止重复添加
154
+            {
155
+                int  cusid = cus .CustemweCode(customercode, gender.ToString (),
156
+                companyname, area, branch, salesman, salesphone, channel, credit, customername
157
+                , customerphone, province, city, country, township, addressfull, brands, product
158
+                , isrunxlx, annualsales, formula, raisecrops, plantingarea, fertilizerbrand, remark);
159
+                if (cusid==0)
160
+                {
161
+                    ajresult.state = (int)CodeStatus.异常结果类型;
162
+                    ajresult.message = "操作失败";
163
+                    return Process();
164
+                }
165
+
166
+                cusmodel.F_Cuscode  = cusid.ToString ();
167
+                cusmodel.F_Cuscodeuuid  = uuid;
168
+                cusmodel.F_AddTime = DateTime.Now;
169
+                cusmodel.F_Type = 0;
170
+                int n = t_Cus_Customerrecords.Add(cusmodel);
171
+                if (n <= 0)
172
+                {
173
+                    ajresult.state = (int)CodeStatus.异常结果类型;
174
+                    ajresult.message = "操作失败";
175
+                    return Process();
176
+                }
177
+
178
+                ajresult.state = (int)CodeStatus.SUCCESS;
179
+                ajresult.message = "操作成功";
180
+                ajresult.data = cusid;  //订单号
181
+                return Process();
182
+            }
183
+            else
184
+            {
185
+                ajresult.state = (int)CodeStatus.数据库错误;
186
+                ajresult.message = "操作失败,信息已存在";
187
+                return Process();
188
+            }
189
+
190
+        }
191
+        public ActionResult EditCustomer()
192
+        {
193
+            Model.T_Cus_Customerrecords cusmodel = new Model.T_Cus_Customerrecords();
194
+            string port_password = RequestString.GetFormString("port_password");   //加密信息(安全验证用)
195
+            string uuid = RequestString.GetFormString("uuid");          //客户唯一标识(安全验证用)
196
+                                                                        //信息来源
197
+            int  id = RequestString.GetInt("id",0);   //客户档案id
198
+            string customercode = RequestString.GetFormString("customercode");   //客户code10位数字
199
+            int gender = RequestString.GetInt("gender", 1);     //客户性别1男2女
200
+            string companyname = RequestString.GetFormString("companyname");    //公司名称
201
+            string areaname = RequestString.GetFormString("areaname");    //大区名称
202
+            string branchname = RequestString.GetFormString("branchname");    //分公司名称
203
+            string salesman = RequestString.GetFormString("salesman");    //业务员
204
+            string salesphone = RequestString.GetFormString("salesphone");    //业务员电话
205
+            string channel = RequestString.GetFormString("channel");    //渠道类型
206
+            string credit = RequestString.GetFormString("credit");    //信用等级
207
+            string customername = RequestString.GetFormString("customername");    //客户姓名
208
+            string customerphone = RequestString.GetFormString("customerphone");    //客户电话
209
+            string province = RequestString.GetFormString("province");    //省份
210
+            string city = RequestString.GetFormString("city");    //市
211
+            string country = RequestString.GetFormString("country");    //区/县
212
+            string township = RequestString.GetFormString("township");    //乡镇
213
+            string addressfull = RequestString.GetFormString("addressfull");    //详细地址
214
+            string brands = RequestString.GetFormString("brands");    //经营品牌
215
+            string product = RequestString.GetFormString("product");    //产品
216
+            string isrunxlx = RequestString.GetFormString("isrunxlx");     //是否经营心连心0否1是
217
+            string annualsales = RequestString.GetFormString("annualsales");    //年销量
218
+            string formula = RequestString.GetFormString("formula");    //配方
219
+            string raisecrops = RequestString.GetFormString("raisecrops");    //种植作物
220
+            string plantingarea = RequestString.GetFormString("plantingarea");    //种植面积
221
+            string fertilizerbrand = RequestString.GetFormString("fertilizerbrand");    //用肥品牌
222
+            string remark = RequestString.GetFormString("remark");    //备注
223
+            if (string.IsNullOrEmpty(uuid))
224
+            {
225
+                ajresult.state = (int)CodeStatus.ID不存在;
226
+                ajresult.message = "客户唯一标识不能为空";
227
+                return Process();
228
+            }
229
+            else if (uuid.Length > 50)
230
+            {
231
+                ajresult.state = (int)CodeStatus.字符串超出长度;
232
+                ajresult.message = "客户唯一标识超出长度";
233
+                return Process();
234
+            }
235
+            if (id <=0)
236
+            {
237
+                ajresult.state = (int)CodeStatus.ID不存在 ;
238
+                ajresult.message = "请输入正确的ID";
239
+                return Process();
240
+            }
241
+            Model .T_Cus_CustomerBaseNew _Customer=new BLL.T_Cus_CustomerBaseNew().GetModel(id);
242
+            if (_Customer==null )
243
+            {
244
+                ajresult.state = (int)CodeStatus.ID不存在;
245
+                ajresult.message = "请输入正确的ID";
246
+                return Process();
247
+            }
248
+            CustomerNewController cus = new CustomerNewController();
249
+            if (!string.IsNullOrEmpty(customercode))
250
+            {
251
+                if (!cus.valcode(customercode))
252
+                {
253
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
254
+                    ajresult.message = "客户编号必须是10位数字";
255
+                    return Process();
256
+                }
257
+
258
+                if (cus.getunique(id , customercode))
259
+                {
260
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
261
+                    ajresult.message = "客户编号已被占用,请重新输入!";
262
+                    return Process();
263
+                }
264
+            }
265
+            else
266
+            {
267
+                ajresult.state = (int)CodeStatus.必填字段为空;
268
+                ajresult.message = "客户编号不能为空";
269
+                return Process();
270
+            }
271
+            if (string.IsNullOrEmpty(customerphone))
272
+            {
273
+                ajresult.state = (int)CodeStatus.必填字段为空;
274
+                ajresult.message = "客户电话不能为空";
275
+                return Process();
276
+            }
277
+            if (!Common.CodeValidate.ICodeValidate(uuid + customercode, port_password))
278
+            {
279
+                ajresult.state = (int)CodeStatus.安全验证未通过;
280
+                ajresult.message = "安全验证未通过";
281
+                return Process();
282
+            }
283
+            if (string.IsNullOrEmpty(customername))
284
+            {
285
+                ajresult.state = (int)CodeStatus.必填字段为空;
286
+                ajresult.message = "客户姓名不能为空";
287
+                return Process();
288
+            }
289
+           
290
+            if (!string.IsNullOrEmpty(salesphone))
291
+            {
292
+                if (!IsNumeric(salesphone))
293
+                {
294
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
295
+                    ajresult.message = "请输入正确的业务员电话";
296
+                    return Process();
297
+                }
298
+            }
299
+            if (gender > 2 || gender < 1)
300
+            {
301
+                ajresult.state = (int)CodeStatus.参数逻辑错误;
302
+                ajresult.message = "性别错误!";
303
+                return Process();
304
+            }
305
+            string area = "", branch = "";
306
+            if (!string.IsNullOrEmpty(areaname))
307
+            {
308
+                if (cus.IsModelDeptment(areaname) == null)
309
+                {
310
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
311
+                    ajresult.message = "大区名称错误!查找不到该大区";
312
+                    return Process();
313
+                }
314
+                else
315
+                {
316
+                    area = cus.IsModelDeptment(areaname).F_DeptId.ToString();
317
+                }
318
+            }
319
+
320
+            if (!string.IsNullOrEmpty(branchname))
321
+            {
322
+                if (cus.IsModelDeptment(branchname) == null)
323
+                {
324
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
325
+                    ajresult.message = "分公司名称错误!查找不到该分公司";
326
+                    return Process();
327
+                }
328
+                else
329
+                    branch = cus.IsModelDeptment(branchname).F_DeptId.ToString();
330
+            }
331
+            
332
+            if (!t_Cus_Customerrecords.ExistsCuscodeuuid(uuid))  //uuid不存在时,防止重复添加
333
+            {
334
+                int cusid = cus.CustemweCode(customercode, gender.ToString(),
335
+                companyname, area, branch, salesman, salesphone, channel, credit, customername
336
+                , customerphone, province, city, country, township, addressfull, brands, product
337
+                , isrunxlx, annualsales, formula, raisecrops, plantingarea, fertilizerbrand, remark,id );
338
+                if (cusid == 0)
339
+                {
340
+                    ajresult.state = (int)CodeStatus.异常结果类型;
341
+                    ajresult.message = "操作失败";
342
+                    return Process();
343
+                }
344
+                cusmodel.F_Cuscode = cusid.ToString();
345
+                cusmodel.F_Cuscodeuuid = uuid;
346
+                cusmodel.F_AddTime = DateTime.Now;
347
+                cusmodel.F_Type  = 1;
348
+                int a = 0;
349
+                int n = t_Cus_Customerrecords.Add(cusmodel);
350
+                if (n <= 0)
351
+                {
352
+                    ajresult.state = (int)CodeStatus.异常结果类型;
353
+                    ajresult.message = "操作失败";
354
+                    return Process();
355
+                }
356
+
357
+                ajresult.state = (int)CodeStatus.SUCCESS;
358
+                ajresult.message = "操作成功";
359
+                ajresult.data = cusid;  //订单号
360
+                return Process();
361
+            }
362
+            else
363
+            {
364
+                ajresult.state = (int)CodeStatus.数据库错误;
365
+                ajresult.message = "操作失败,信息已存在";
366
+                return Process();
367
+            }
368
+
369
+        }
370
+        public ActionResult GetCustomer()
371
+        {
372
+            string port_password = RequestString.GetFormString("port_password");   //加密信息(安全验证用)
373
+            string uuid = RequestString.GetFormString("uuid");          //客户唯一标识(安全验证用)
374
+                                                                        //信息来源
375
+            string customercode = RequestString.GetFormString("customercode");   //客户code10位数字
376
+            if (string.IsNullOrEmpty(uuid))
377
+            {
378
+                ajresult.state = (int)CodeStatus.ID不存在;
379
+                ajresult.message = "客户唯一标识不能为空";
380
+                return Process();
381
+            }
382
+            else if (uuid.Length > 50)
383
+            {
384
+                ajresult.state = (int)CodeStatus.字符串超出长度;
385
+                ajresult.message = "客户唯一标识超出长度";
386
+                return Process();
387
+            }
388
+
389
+            if (!Common.CodeValidate.ICodeValidate(uuid + customercode, port_password))
390
+            {
391
+                ajresult.state = (int)CodeStatus.安全验证未通过;
392
+                ajresult.message = "安全验证未通过";
393
+                return Process();
394
+            }
395
+            CustomerNewController cus = new CustomerNewController();
396
+            if (!string.IsNullOrEmpty(customercode))
397
+            {
398
+                if (!cus.valcode(customercode))
399
+                {
400
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
401
+                    ajresult.message = "客户编号必须是10位数字";
402
+                    return Process();
403
+                }
404
+               
405
+            }
406
+            else
407
+            {
408
+                ajresult.state = (int)CodeStatus.必填字段为空;
409
+                ajresult.message = "客户编号不能为空";
410
+                return Process();
411
+            }
412
+            Model.T_Cus_CustomerBaseNew _Customer = new BLL.T_Cus_CustomerBaseNew().GetModelList ("F_IsDelete=0 and F_CustomerCode='"+ customercode + "'")
413
+                .FirstOrDefault ();
414
+            if (_Customer==null )
415
+            {
416
+                ajresult.state = (int)CodeStatus.ID不存在;
417
+                ajresult.message = "该客户不存在";
418
+                return Process();
419
+            }
420
+            else
421
+            {
422
+                ajresult.state = (int)CodeStatus.SUCCESS;
423
+                ajresult.message = "操作成功";
424
+                ajresult.data = _Customer.F_CustomerId ;  //订单号
425
+                return Process();
426
+            }
427
+
428
+        }
429
+        public ActionResult DelCustomer( string uuid, string port_password, int  id =0)
430
+        {
431
+            Model.T_Cus_Customerrecords cusmodel = new Model.T_Cus_Customerrecords();
432
+            if (string.IsNullOrEmpty(uuid))
433
+            {
434
+                ajresult.state = (int)CodeStatus.ID不存在;
435
+                ajresult.message = "客户唯一标识不能为空";
436
+                return Process();
437
+            }
438
+            else if (uuid.Length > 50)
439
+            {
440
+                ajresult.state = (int)CodeStatus.字符串超出长度;
441
+                ajresult.message = "客户唯一标识超出长度";
442
+                return Process();
443
+            }
444
+            if (id <=0)
445
+            {
446
+                ajresult.state = (int)CodeStatus.ID不存在 ;
447
+                ajresult.message = "请输入正确的ID";
448
+                return Process();
449
+            }
450
+            Model.T_Cus_CustomerBaseNew _Customer = new BLL.T_Cus_CustomerBaseNew().GetModel(id);
451
+            if (_Customer == null)
452
+            {
453
+                ajresult.state = (int)CodeStatus.ID不存在;
454
+                ajresult.message = "请输入正确的ID";
455
+                return Process();
456
+            }
457
+            if (!Common.CodeValidate.ICodeValidate(uuid + _Customer.F_CustomerCode  , port_password))
458
+            {
459
+                ajresult.state = (int)CodeStatus.安全验证未通过;
460
+                ajresult.message = "安全验证未通过";
461
+                return Process();
462
+            }
463
+            CustomerNewController cus = new CustomerNewController();
464
+            if (cus .DelCustomer (id .ToString ()))
465
+            {
466
+                cusmodel.F_Cuscode = id.ToString();
467
+                cusmodel.F_Cuscodeuuid = uuid;
468
+                cusmodel.F_AddTime = DateTime.Now;
469
+                cusmodel.F_Type = 2;
470
+                int n = t_Cus_Customerrecords.Add(cusmodel);
471
+                if (n <= 0)
472
+                {
473
+                    ajresult.state = (int)CodeStatus.异常结果类型;
474
+                    ajresult.message = "操作失败";
475
+                    return Process();
476
+                }
477
+                ajresult.state = (int)CodeStatus.SUCCESS;
478
+                ajresult.message = "操作成功";
479
+                ajresult.data = "";  //订单号
480
+                return Process();
481
+            }
482
+            else
483
+            {
484
+                ajresult.state = (int)CodeStatus.数据库错误;
485
+                ajresult.message = "操作失败";
486
+                return Process();
487
+            }
488
+        }
489
+
490
+
491
+        public static bool IsNumeric(string value)
492
+        {
493
+            return Regex.IsMatch(value, @"^[+-]?\d*[.]?\d*$");
494
+
495
+        }
496
+        /// <summary>
497
+        /// 验证物料编码为10位纯数字
498
+        /// </summary>
499
+        private bool valcode(string code)
500
+        {
501
+            var res = false;
502
+            //11位数字
503
+            if (code.Length == 10 && Regex.IsMatch(code, @"^\d{10}$"))
504
+                res = true;
505
+            return res;
506
+        }
507
+        /// <summary>
508
+        /// 成功的消息格式化
509
+        /// </summary>
510
+        /// <param name="message"></param>
511
+        /// <returns></returns>
512
+        protected virtual ActionResult Process()
513
+        {
514
+            string methodName = new System.Diagnostics.StackTrace(true).GetFrame(1).GetMethod().Name;   //事件源
515
+            LogInterface.WriteLog(this.GetType().ToString() + " -- " + methodName + "\r\n" + ajresult.state + "|" + ajresult.data + ajresult.message); //日志
516
+            var jsonMsg = new AjaxResult { state = ajresult.state, message = ajresult.message, data = ajresult.data }.ToJson();
517
+            return Content(jsonMsg);
518
+        }
519
+        /// <summary>
520
+        /// 状态枚举
521
+        /// </summary>
522
+        enum CodeStatus
523
+        {
524
+            SUCCESS = 200,
525
+            安全验证未通过 = 400,
526
+            无法预测的程序错误 = 501,
527
+            参数格式错误 = 100,
528
+            必填字段为空 = 101,
529
+            字符串超出长度 = 102,
530
+            数据库错误 = 103,
531
+            执行超时 = 104,
532
+            参数逻辑错误 = 105,
533
+            ID不存在 = 106,
534
+            执行失败 = 108,
535
+            用户已禁用 = 120,
536
+            异常结果类型 = 500
537
+
538
+        }
539
+    }
540
+}

+ 120 - 5
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/weixin/WxLoginController.cs

775
         /// <summary>
775
         /// <summary>
776
         ///工单列表
776
         ///工单列表
777
         /// </summary>
777
         /// </summary>
778
-        public ActionResult GetList(string handler,string description,string OpenId, string code, string cusname, string keywords, string cusphone, string companyname, string province, string city,
779
-            string country, string township, string category, string salebase, string touser, int source = 0, int state = -1, int status = -1, int type = 0, int pageindex = 1, int pagesize = 10)
778
+        public ActionResult GetList(string handler,string description,string OpenId, string code, string cusname, string keywords, string cusphone, string companyname, string province, string city,string createby,string createtel,
779
+            string country, string township, string category, string salebase, string touser, int source = 0, int state = -1, int status = -1, int type = 0,int condition=-1, int pageindex = 1, int pagesize = 10)
780
         {
780
         {
781
             //  int userId = CurrentUser.UserData.F_UserId;
781
             //  int userId = CurrentUser.UserData.F_UserId;
782
             if (!string.IsNullOrEmpty(OpenId))
782
             if (!string.IsNullOrEmpty(OpenId))
799
                 if (source > 0)//工单来源
799
                 if (source > 0)//工单来源
800
                 {
800
                 {
801
                     if (source == 1)
801
                     if (source == 1)
802
-                        sql += $" and F_Source in (1,'')";
802
+                        sql += $"  and (F_Source in (1,'')or F_Source is null )";
803
                     else
803
                     else
804
                         sql += $" and F_Source='" + source + "'";
804
                         sql += $" and F_Source='" + source + "'";
805
                 }
805
                 }
831
                     sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
831
                     sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
832
                 if (!string.IsNullOrWhiteSpace(province))//乡
832
                 if (!string.IsNullOrWhiteSpace(province))//乡
833
                     sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
833
                     sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
834
+                if (condition>-1)
835
+                {
836
+                   
837
+                        if (condition == 5)
838
+                        {
839
+                            sql += $" and F_State in (2,3,4,5)";
840
+                        }
841
+                        else if (condition == 6)
842
+                        {
843
+                            sql += $" and F_State in (11)";
844
+                            sql += $" and F_IsVisit=" + 1; ;
845
+                            sql += $"and F_DealType != '当即办理'  and F_VisitBy != ''";
846
+                        }
847
+                        else if (condition == 10)
848
+                        {
849
+                            sql += $" and F_State in (10,11)";
850
+                        }
851
+                        else if (condition == 12)
852
+                        {
853
+                            sql += $" and F_State=" + (int)EnumWorkOrderState.finish + " and F_IsVisit = '" + "1" + "' ";
854
+                        }
855
+                        else
856
+                        {
857
+                            sql += $" and F_State=" + condition;
858
+                        }
859
+                     if (ua != null)
860
+                    {
861
+                        Model.T_Sys_RoleInfo re = rolebll.GetModel(ua.F_RoleId);
862
+                        if (re.F_RoleCode == "QTJS" || re.F_RoleCode == "YWY")
863
+                            sql += $" and F_CreateBy like '%" + ua.F_UserCode.Trim() + "%'";
864
+                        else if (re.F_RoleCode == "DQJL" || re.F_RoleCode == "FGSJL" || re.F_RoleCode == "BLRY" || re.F_RoleCode == "ZG")
865
+                        {
866
+                            string detpid = "" + ua.F_DeptId;
867
+                            var deparmentlist = new List<Model.T_Sys_Department>();
868
+                            Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
869
+                            if (dModel != null)
870
+                            {
871
+                                if (dModel.F_Layer == 1)
872
+                                {
873
+                                    deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
874
+                                    if (deparmentlist.Count > 0)
875
+                                    {
876
+                                        foreach (var it in deparmentlist)
877
+                                        {
878
+                                            if (detpid != "")
879
+                                            {
880
+                                                detpid += "," + it.F_DeptId;
881
+                                            }
882
+                                            else
883
+                                            {
884
+                                                detpid = "" + it.F_DeptId;
885
+                                            }
886
+                                        }
887
+                                    }
888
+                                }
889
+                                else
890
+                                {
891
+                                    detpid = ua.F_DeptId.ToString();
892
+                                }
893
+                                if (state >= 0)
894
+                                {
895
+                                    if (GetDeptWorkOrderID(detpid) != "")
896
+                                    {
897
+
898
+                                        sql += $"  and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid) + ") ";
899
+                                    }
900
+                                    else
901
+                                    {
902
+
903
+                                        return Success("暂无工单"); ;
904
+                                    }
905
+                                }
906
+                                else
907
+                                {
908
+                                    if (GetDeptWorkOrderID(detpid) != "")
909
+                                    {
910
+
911
+                                        sql += $"  and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid) + ") ";
912
+                                    }
913
+                                    else
914
+                                    {
915
+
916
+                                        return Success("暂无工单"); ;
917
+                                    }
918
+                                }
834
 
919
 
920
+                            }
921
+                            else
922
+                            {
923
+                                return Error("加载失败");
924
+                            }
925
+                        }
926
+                    }
927
+
928
+                }
929
+                if (!string.IsNullOrWhiteSpace(createby))//创建人
930
+                {
931
+                    sql += $" and F_CustomerID  in(select F_CustomerCode from T_Cus_CustomerBaseNew where F_Salesman like '%" +createby+ "%' and F_IsDelete =0) ";
932
+             }
933
+                if (!string.IsNullOrWhiteSpace(createtel))//创建人
934
+                {
935
+                    sql += $" and F_CustomerID  in(select F_CustomerCode from T_Cus_CustomerBaseNew where F_SalesPhone like '%" + createtel + "%' and F_IsDelete =0) ";
936
+                }
835
                 if (!string .IsNullOrEmpty (handler))
937
                 if (!string .IsNullOrEmpty (handler))
836
                 {
938
                 {
837
                     Model.T_Sys_UserAccount user = userAccountBLL .GetworkModel(handler);
939
                     Model.T_Sys_UserAccount user = userAccountBLL .GetworkModel(handler);
3190
         /// </summary>
3292
         /// </summary>
3191
         /// <param name="user"></param>
3293
         /// <param name="user"></param>
3192
         /// <returns></returns>
3294
         /// <returns></returns>
3295
+        public string GetID(string user)
3296
+        {
3297
+            string str = string.Empty;
3298
+            str = "select F_WoID from T_Wo_WorkOrderItem_New where F_CreateUser in(" + user + ") ";
3299
+
3300
+            ;
3301
+            return str;
3302
+        }
3303
+        /// <summary>
3304
+        /// 获取我参与的工单编号
3305
+        /// </summary>
3306
+        /// <param name="user"></param>
3307
+        /// <returns></returns>
3193
         public string GetParticipate(string user)
3308
         public string GetParticipate(string user)
3194
         {
3309
         {
3195
             string str = string.Empty;
3310
             string str = string.Empty;
5194
                 //}
5309
                 //}
5195
                 if (isover == 1)
5310
                 if (isover == 1)
5196
                 {
5311
                 {
5197
-                    if (!string.IsNullOrEmpty(model.F_WxOpenId))
5198
-                        sendwxmsg(model, model.F_WxOpenId, nowUser, model.F_DealContent);
5312
+                   // if (!string.IsNullOrEmpty(model.F_WxOpenId))
5313
+//sendwxmsg(model, model.F_WxOpenId, nowUser, model.F_DealContent);
5199
                 }
5314
                 }
5200
                   
5315
                   
5201
                 #endregion
5316
                 #endregion

+ 79 - 3
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/MaterialManageController.cs

113
                 return Error("获取参数失败");
113
                 return Error("获取参数失败");
114
             }
114
             }
115
         }
115
         }
116
-  
116
+        //[Authority]
117
+        //添加物料
118
+        public int  Add(string materialcode,string materialname,string model,string specs,
119
+      string      level1,string level2,string level3,string brand,string materialeffect,string
120
+           craft,string pipeline,string remark,int id=0)
121
+        {
122
+         
123
+            Model.T_Wo_MaterialManage dModel = new Model.T_Wo_MaterialManage();
124
+            if (id >0)
125
+             dModel = new BLL.T_Wo_MaterialManage().GetModel(id);
126
+            #region 验证物料编码为11位纯数字
127
+            #endregion
128
+            #region
129
+            dModel.F_MaterialCode = materialcode;//物料编号
130
+            dModel.F_MaterialName = materialname;//物料名称
131
+            dModel.F_Model = model;//型号
132
+            dModel.F_Specs = specs;//规格
133
+            dModel.F_Level1 = level1;//一级分类
134
+            dModel.F_Level2 = level2;//二级分类
135
+            dModel.F_Level3 = level3;//三级分类
136
+            dModel.F_Brand = brand;//品牌
137
+            dModel.F_MaterialEffect = materialeffect;//复合肥肥效
138
+            dModel.F_Craft = craft;//工艺
139
+            dModel.F_Pipeline = pipeline;//产品线
140
+            dModel.F_Remark = remark;
141
+
142
+            dModel.F_IsDelete = 0;
143
+            dModel.F_CreateOn = DateTime.Now;
144
+            dModel.F_CreateBy ="系统外添加";
145
+            #endregion
146
+            if (id >0)
147
+            {
148
+                bool b = mmBLL.Update(dModel);
149
+                if (b)
150
+                {
151
+                    addoptlog("系统外添加", DTRequest.GetIP(), EnumOpt.edit.ToString(), dModel.F_Id.ToString(), "编辑成功,物料编号为" + dModel.F_MaterialCode + "的资料");
152
+                    return id ;
153
+                }
154
+                else
155
+                {
156
+                    return 0;
157
+                }
158
+
159
+            }
160
+            else
161
+            {
162
+                int b = mmBLL.Add(dModel);
163
+                if (b > 0)
164
+                {
165
+                    addoptlog("系统外添加", DTRequest.GetIP(), EnumOpt.add.ToString(), b.ToString(), "添加成功,物料编号为" + dModel.F_MaterialCode + "的资料");
166
+                    return b;
167
+                }
168
+                else
169
+                {
170
+                    return 0;
171
+                }
172
+            }
173
+            
174
+
175
+        }
117
         //[Authority]
176
         //[Authority]
118
         //添加物料
177
         //添加物料
119
         public ActionResult AddModel(WoMaterialManageInput input)
178
         public ActionResult AddModel(WoMaterialManageInput input)
215
         }
274
         }
216
         //[Authority]
275
         //[Authority]
217
         //批量删除物料
276
         //批量删除物料
277
+        public bool  Del( string ids)
278
+        {
279
+            string optuser = "系统外删除";
280
+            DateTime dtnow = DateTime.Now;
281
+            if (new BLL.T_Wo_MaterialManage().DeleteList(ids, optuser, dtnow))
282
+            {
283
+                if (ids.Length > 1)
284
+                    addoptlog(optuser, DTRequest.GetIP(), EnumOpt.deletion.ToString(), ids, "批量删除成功");
285
+                else
286
+                    addoptlog(optuser, DTRequest.GetIP(), EnumOpt.delete.ToString(), ids, "删除成功");
287
+                return true ;
288
+            }
289
+            else
290
+                return false ;
291
+        }
292
+        //[Authority]
293
+        //批量删除物料
218
         public ActionResult DelModels(string[] ids)
294
         public ActionResult DelModels(string[] ids)
219
         {
295
         {
220
             if (ids != null && ids.Length > 0)
296
             if (ids != null && ids.Length > 0)
346
         /// <summary>
422
         /// <summary>
347
         /// 验证客户编号是否唯一
423
         /// 验证客户编号是否唯一
348
         /// </summary>
424
         /// </summary>
349
-        private bool getunique(int id, string code)
425
+        public  bool getunique(int id, string code)
350
         {
426
         {
351
             var sql = " F_IsDelete=0 ";
427
             var sql = " F_IsDelete=0 ";
352
             sql += "and (F_MaterialCode='" + code + "')";
428
             sql += "and (F_MaterialCode='" + code + "')";
461
         /// <summary>
537
         /// <summary>
462
         /// 验证物料编码为11位纯数字
538
         /// 验证物料编码为11位纯数字
463
         /// </summary>
539
         /// </summary>
464
-        private bool valcode(string code)
540
+        public  bool valcode(string code)
465
         {
541
         {
466
             var res = false;
542
             var res = false;
467
             //11位数字
543
             //11位数字

+ 405 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/MaterialManageXLXController.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text.RegularExpressions;
5
+using System.Web;
6
+using System.Web.Mvc;
7
+using CallCenter.Utility;
8
+using CallCenter.Utility.log;
9
+using CallCenterApi.Interface.Controllers.Base;
10
+
11
+namespace CallCenterApi.Interface.Controllers.workorder
12
+{
13
+    public class MaterialManageXLXController : BaseController
14
+    {
15
+        private AjaxResult ajresult = new AjaxResult();
16
+        BLL.T_Cus_Customerrecords t_Cus_Customerrecords = new BLL.T_Cus_Customerrecords();
17
+        public ActionResult AddMaterial()
18
+        {
19
+            Model.T_Cus_Customerrecords cusmodel = new Model.T_Cus_Customerrecords();
20
+            string port_password = RequestString.GetFormString("port_password");   //加密信息(安全验证用)
21
+            string uuid = RequestString.GetFormString("uuid");          //客户唯一标识(安全验证用)
22
+                                                                       
23
+            string materialcode = RequestString.GetFormString("materialcode");   //物料编码11位数字
24
+            string materialname = RequestString.GetFormString("materialname");   //物料名称
25
+            string model = RequestString.GetFormString("model");   //型号
26
+            string specs = RequestString.GetFormString("specs");   //规格
27
+            string level1 = RequestString.GetFormString("level1");   //一级分类
28
+            string level2 = RequestString.GetFormString("level2");   //二级分类
29
+            string level3 = RequestString.GetFormString("level3");   //三级分类
30
+            string brand = RequestString.GetFormString("brand");   //品牌
31
+            string materialeffect = RequestString.GetFormString("materialeffect");   //复合肥肥效
32
+            string craft = RequestString.GetFormString("craft");   //工艺
33
+            string pipeline = RequestString.GetFormString("pipeline");   //产品线
34
+            string remark = RequestString.GetFormString("remark");   //备注
35
+            if (string.IsNullOrEmpty(uuid))
36
+            {
37
+                ajresult.state = (int)CodeStatus.ID不存在;
38
+                ajresult.message = "客户唯一标识不能为空";
39
+                return Process();
40
+            }
41
+            else if (uuid.Length > 50)
42
+            {
43
+                ajresult.state = (int)CodeStatus.字符串超出长度;
44
+                ajresult.message = "客户唯一标识超出长度";
45
+                return Process();
46
+            }
47
+            MaterialManageController cus = new MaterialManageController();
48
+            if (!string.IsNullOrEmpty(materialcode))
49
+            {
50
+                if (!cus.valcode(materialcode))
51
+                {
52
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
53
+                    ajresult.message = "物料编号必须是11位数字";
54
+                    return Process();
55
+                }
56
+
57
+                if (cus.getunique(0, materialcode))
58
+                {
59
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
60
+                    ajresult.message = "物料编号已被占用,请重新输入!";
61
+                    return Process();
62
+                }
63
+            }
64
+            else
65
+            {
66
+                ajresult.state = (int)CodeStatus.必填字段为空;
67
+                ajresult.message = "物料编号不能为空";
68
+                return Process();
69
+            }
70
+            if (string.IsNullOrEmpty(materialname))
71
+            {
72
+                ajresult.state = (int)CodeStatus.必填字段为空;
73
+                ajresult.message = "物料名称不能为空";
74
+                return Process();
75
+            }
76
+            if (!Common.CodeValidate.ICodeValidate(uuid + materialcode, port_password))
77
+            {
78
+                ajresult.state = (int)CodeStatus.安全验证未通过;
79
+                ajresult.message = "安全验证未通过";
80
+                return Process();
81
+            }
82
+            if (!t_Cus_Customerrecords.ExistsCuscodeuuid(uuid))  //uuid不存在时,防止重复添加
83
+            {
84
+                int cusid = cus.Add ( materialcode,  materialname,  model,  specs,
85
+            level1,  level2,  level3,  brand,  materialeffect, 
86
+           craft,  pipeline,  remark);
87
+                if (cusid == 0)
88
+                {
89
+                    ajresult.state = (int)CodeStatus.异常结果类型;
90
+                    ajresult.message = "操作失败";
91
+                    return Process();
92
+                }
93
+
94
+                cusmodel.F_Cuscode = cusid.ToString();
95
+                cusmodel.F_Cuscodeuuid = uuid;
96
+                cusmodel.F_AddTime = DateTime.Now;
97
+                cusmodel.F_Type = 3;
98
+                int n = t_Cus_Customerrecords.Add(cusmodel);
99
+                if (n <= 0)
100
+                {
101
+                    ajresult.state = (int)CodeStatus.异常结果类型;
102
+                    ajresult.message = "操作失败";
103
+                    return Process();
104
+                }
105
+
106
+                ajresult.state = (int)CodeStatus.SUCCESS;
107
+                ajresult.message = "操作成功";
108
+                ajresult.data = cusid;  //订单号
109
+                return Process();
110
+            }
111
+            else
112
+            {
113
+                ajresult.state = (int)CodeStatus.数据库错误;
114
+                ajresult.message = "操作失败,信息已存在";
115
+                return Process();
116
+            }
117
+
118
+        }
119
+        public ActionResult EditMaterial()
120
+        {
121
+            Model.T_Cus_Customerrecords cusmodel = new Model.T_Cus_Customerrecords();
122
+            string port_password = RequestString.GetFormString("port_password");   //加密信息(安全验证用)
123
+            string uuid = RequestString.GetFormString("uuid");          //客户唯一标识(安全验证用)
124
+            int id = RequestString.GetInt("id", 0);   //客户档案id
125
+            string materialcode = RequestString.GetFormString("materialcode");   //物料编码11位数字
126
+            string materialname = RequestString.GetFormString("materialname");   //物料名称
127
+            string model = RequestString.GetFormString("model");   //型号
128
+            string specs = RequestString.GetFormString("specs");   //规格
129
+            string level1 = RequestString.GetFormString("level1");   //一级分类
130
+            string level2 = RequestString.GetFormString("level2");   //二级分类
131
+            string level3 = RequestString.GetFormString("level3");   //三级分类
132
+            string brand = RequestString.GetFormString("brand");   //品牌
133
+            string materialeffect = RequestString.GetFormString("materialeffect");   //复合肥肥效
134
+            string craft = RequestString.GetFormString("craft");   //工艺
135
+            string pipeline = RequestString.GetFormString("pipeline");   //产品线
136
+            string remark = RequestString.GetFormString("remark");   //备注
137
+            if (string.IsNullOrEmpty(uuid))
138
+            {
139
+                ajresult.state = (int)CodeStatus.ID不存在;
140
+                ajresult.message = "客户唯一标识不能为空";
141
+                return Process();
142
+            }
143
+            else if (uuid.Length > 50)
144
+            {
145
+                ajresult.state = (int)CodeStatus.字符串超出长度;
146
+                ajresult.message = "客户唯一标识超出长度";
147
+                return Process();
148
+            }
149
+            if (id <=0)
150
+            {
151
+                ajresult.state = (int)CodeStatus.ID不存在 ;
152
+                ajresult.message = "请输入正确的ID";
153
+                return Process();
154
+              
155
+            }
156
+            Model.T_Wo_MaterialManage _Customer = new BLL.T_Wo_MaterialManage().GetModel(id);
157
+            if (_Customer == null)
158
+            {
159
+                ajresult.state = (int)CodeStatus.ID不存在;
160
+                ajresult.message = "请输入正确的ID";
161
+                return Process();
162
+            }
163
+            MaterialManageController cus = new MaterialManageController();
164
+            if (!string.IsNullOrEmpty(materialcode))
165
+            {
166
+                if (!cus.valcode(materialcode))
167
+                {
168
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
169
+                    ajresult.message = "物料编号必须是11位数字";
170
+                    return Process();
171
+                }
172
+
173
+                if (cus.getunique(_Customer.F_Id , materialcode))
174
+                {
175
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
176
+                    ajresult.message = "物料编号已被占用,请重新输入!";
177
+                    return Process();
178
+                }
179
+            }
180
+            else
181
+            {
182
+                ajresult.state = (int)CodeStatus.必填字段为空;
183
+                ajresult.message = "物料编号不能为空";
184
+                return Process();
185
+            }
186
+            if (string.IsNullOrEmpty(materialname))
187
+            {
188
+                ajresult.state = (int)CodeStatus.必填字段为空;
189
+                ajresult.message = "物料名称不能为空";
190
+                return Process();
191
+            }
192
+            if (!Common.CodeValidate.ICodeValidate(uuid + materialcode, port_password))
193
+            {
194
+                ajresult.state = (int)CodeStatus.安全验证未通过;
195
+                ajresult.message = "安全验证未通过";
196
+                return Process();
197
+            }
198
+            if (!t_Cus_Customerrecords.ExistsCuscodeuuid(uuid))  //uuid不存在时,防止重复添加
199
+            {
200
+                int cusid = cus.Add(materialcode, materialname, model, specs,
201
+             level1, level2, level3, brand, materialeffect,
202
+            craft, pipeline, remark,id );
203
+                if (cusid == 0)
204
+                {
205
+                    ajresult.state = (int)CodeStatus.异常结果类型;
206
+                    ajresult.message = "操作失败";
207
+                    return Process();
208
+                }
209
+                cusmodel.F_Cuscode = cusid.ToString();
210
+                cusmodel.F_Cuscodeuuid = uuid;
211
+                cusmodel.F_AddTime = DateTime.Now;
212
+                cusmodel.F_Type = 4;
213
+                int n = t_Cus_Customerrecords.Add(cusmodel);
214
+                if (n <= 0)
215
+                {
216
+                    ajresult.state = (int)CodeStatus.异常结果类型;
217
+                    ajresult.message = "操作失败";
218
+                    return Process();
219
+                }
220
+
221
+                ajresult.state = (int)CodeStatus.SUCCESS;
222
+                ajresult.message = "操作成功";
223
+                ajresult.data = cusid;  //订单号
224
+                return Process();
225
+            }
226
+            else
227
+            {
228
+                ajresult.state = (int)CodeStatus.数据库错误;
229
+                ajresult.message = "操作失败,信息已存在";
230
+                return Process();
231
+            }
232
+
233
+        }
234
+        public ActionResult GetMaterial()
235
+        {
236
+            string port_password = RequestString.GetFormString("port_password");   //加密信息(安全验证用)
237
+            string uuid = RequestString.GetFormString("uuid");          //客户唯一标识(安全验证用)
238
+                                                                        //信息来源
239
+            string materialcode = RequestString.GetFormString("materialcode");   //客户code10位数字
240
+            if (string.IsNullOrEmpty(uuid))
241
+            {
242
+                ajresult.state = (int)CodeStatus.ID不存在;
243
+                ajresult.message = "客户唯一标识不能为空";
244
+                return Process();
245
+            }
246
+            else if (uuid.Length > 50)
247
+            {
248
+                ajresult.state = (int)CodeStatus.字符串超出长度;
249
+                ajresult.message = "客户唯一标识超出长度";
250
+                return Process();
251
+            }
252
+
253
+            if (!Common.CodeValidate.ICodeValidate(uuid + materialcode, port_password))
254
+            {
255
+                ajresult.state = (int)CodeStatus.安全验证未通过;
256
+                ajresult.message = "安全验证未通过";
257
+                return Process();
258
+            }
259
+            MaterialManageController cus = new MaterialManageController();
260
+            if (!string.IsNullOrEmpty(materialcode))
261
+            {
262
+                if (!cus.valcode(materialcode))
263
+                {
264
+                    ajresult.state = (int)CodeStatus.参数逻辑错误;
265
+                    ajresult.message = "物料编号必须是11位数字";
266
+                    return Process();
267
+                }
268
+
269
+            }
270
+            else
271
+            {
272
+                ajresult.state = (int)CodeStatus.必填字段为空;
273
+                ajresult.message = "物料编号不能为空";
274
+                return Process();
275
+            }
276
+            Model.T_Wo_MaterialManage _Customer = new BLL.T_Wo_MaterialManage().GetModelList("F_IsDelete=0 and F_MaterialCode='" + materialcode + "'")
277
+                .FirstOrDefault();
278
+            if (_Customer == null)
279
+            {
280
+                ajresult.state = (int)CodeStatus.ID不存在;
281
+                ajresult.message = "该物料不存在";
282
+                return Process();
283
+            }
284
+            else
285
+            {
286
+                ajresult.state = (int)CodeStatus.SUCCESS;
287
+                ajresult.message = "操作成功";
288
+                ajresult.data = _Customer.F_Id ;  //订单号
289
+                return Process();
290
+            }
291
+
292
+        }
293
+        public ActionResult DelCustomeMaterial(string uuid, string port_password, int id = 0)
294
+        {
295
+            Model.T_Cus_Customerrecords cusmodel = new Model.T_Cus_Customerrecords();
296
+            if (string.IsNullOrEmpty(uuid))
297
+            {
298
+                ajresult.state = (int)CodeStatus.ID不存在;
299
+                ajresult.message = "客户唯一标识不能为空";
300
+                return Process();
301
+            }
302
+            else if (uuid.Length > 50)
303
+            {
304
+                ajresult.state = (int)CodeStatus.字符串超出长度;
305
+                ajresult.message = "客户唯一标识超出长度";
306
+                return Process();
307
+            }
308
+            if (id <= 0)
309
+            {
310
+                ajresult.state = (int)CodeStatus.ID不存在;
311
+                ajresult.message = "请输入正确的ID";
312
+                return Process();
313
+            }
314
+            Model.T_Wo_MaterialManage _Customer = new BLL.T_Wo_MaterialManage().GetModel(id);
315
+            if (_Customer == null)
316
+            {
317
+                ajresult.state = (int)CodeStatus.ID不存在;
318
+                ajresult.message = "请输入正确的ID";
319
+                return Process();
320
+            }
321
+            if (!Common.CodeValidate.ICodeValidate(uuid + _Customer.F_MaterialCode , port_password))
322
+            {
323
+                ajresult.state = (int)CodeStatus.安全验证未通过;
324
+                ajresult.message = "安全验证未通过";
325
+                return Process();
326
+            }
327
+            MaterialManageController cus = new MaterialManageController();
328
+            if (cus.Del(id.ToString()))
329
+            {
330
+                cusmodel.F_Cuscode = id.ToString();
331
+                cusmodel.F_Cuscodeuuid = uuid;
332
+                cusmodel.F_AddTime = DateTime.Now;
333
+                cusmodel.F_Type = 2;
334
+                int n = t_Cus_Customerrecords.Add(cusmodel);
335
+                if (n <= 0)
336
+                {
337
+                    ajresult.state = (int)CodeStatus.异常结果类型;
338
+                    ajresult.message = "操作失败";
339
+                    return Process();
340
+                }
341
+                ajresult.state = (int)CodeStatus.SUCCESS;
342
+                ajresult.message = "操作成功";
343
+                ajresult.data = "";  //订单号
344
+                return Process();
345
+            }
346
+            else
347
+            {
348
+                ajresult.state = (int)CodeStatus.数据库错误;
349
+                ajresult.message = "操作失败";
350
+                return Process();
351
+            }
352
+        }
353
+
354
+
355
+        public static bool IsNumeric(string value)
356
+        {
357
+            return Regex.IsMatch(value, @"^[+-]?\d*[.]?\d*$");
358
+
359
+        }
360
+        /// <summary>
361
+        /// 验证物料编码为10位纯数字
362
+        /// </summary>
363
+        private bool valcode(string code)
364
+        {
365
+            var res = false;
366
+            //11位数字
367
+            if (code.Length == 10 && Regex.IsMatch(code, @"^\d{10}$"))
368
+                res = true;
369
+            return res;
370
+        }
371
+        /// <summary>
372
+        /// 成功的消息格式化
373
+        /// </summary>
374
+        /// <param name="message"></param>
375
+        /// <returns></returns>
376
+        protected virtual ActionResult Process()
377
+        {
378
+            string methodName = new System.Diagnostics.StackTrace(true).GetFrame(1).GetMethod().Name;   //事件源
379
+            LogInterface.WriteLog(this.GetType().ToString() + " -- " + methodName + "\r\n" + ajresult.state + "|" + ajresult.data + ajresult.message); //日志
380
+            var jsonMsg = new AjaxResult { state = ajresult.state, message = ajresult.message, data = ajresult.data }.ToJson();
381
+            return Content(jsonMsg);
382
+        }
383
+        /// <summary>
384
+        /// 状态枚举
385
+        /// </summary>
386
+        enum CodeStatus
387
+        {
388
+            SUCCESS = 200,
389
+            安全验证未通过 = 400,
390
+            无法预测的程序错误 = 501,
391
+            参数格式错误 = 100,
392
+            必填字段为空 = 101,
393
+            字符串超出长度 = 102,
394
+            数据库错误 = 103,
395
+            执行超时 = 104,
396
+            参数逻辑错误 = 105,
397
+            ID不存在 = 106,
398
+            执行失败 = 108,
399
+            用户已禁用 = 120,
400
+
401
+            异常结果类型 = 500
402
+
403
+        }
404
+    }
405
+}

+ 8 - 6
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderNewController.cs

2262
                 if (source > 0)//工单来源
2262
                 if (source > 0)//工单来源
2263
                 {
2263
                 {
2264
                     if (source == 1)
2264
                     if (source == 1)
2265
-                        sql += $" and F_Source in (1,'')";
2265
+                        sql += $" and (F_Source in (1,'')or F_Source is null )";
2266
                     else
2266
                     else
2267
                         sql += $" and F_Source='" + source + "'";
2267
                         sql += $" and F_Source='" + source + "'";
2268
                 }
2268
                 }
5909
                     {
5909
                     {
5910
                        if (clus.F_WorkNumber =="7000")
5910
                        if (clus.F_WorkNumber =="7000")
5911
                             return Error("不能转派到市场管理员");
5911
                             return Error("不能转派到市场管理员");
5912
-                       else if (clus.F_RoleId == 58)
5912
+                        else if (clus.F_RoleId == 1 || clus.F_RoleId == 4)
5913
+                            return Error("不能转派到话务人员");
5914
+                        else if (clus.F_RoleId == 58)
5913
                             return Error("不能转派到业务员");
5915
                             return Error("不能转派到业务员");
5914
                         else if (clus.F_RoleId == 60)
5916
                         else if (clus.F_RoleId == 60)
5915
                             return Error("不能转派到分公司经理");
5917
                             return Error("不能转派到分公司经理");
6803
                     //if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
6805
                     //if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
6804
                     //    sendwxmsg(model, lastUser.F_WxOpenId, nowUser, opt);
6806
                     //    sendwxmsg(model, lastUser.F_WxOpenId, nowUser, opt);
6805
                 }
6807
                 }
6806
-                if (!string.IsNullOrEmpty(model.F_WxOpenId))
6807
-                    sendwxmsg(model, model.F_WxOpenId, nowUser, model.F_DealContent );
6808
+             //   if (!string.IsNullOrEmpty(model.F_WxOpenId))
6809
+                //    sendwxmsg(model, model.F_WxOpenId, nowUser, model.F_DealContent );
6808
                 #endregion
6810
                 #endregion
6809
                 #endregion
6811
                 #endregion
6810
                 return true;
6812
                 return true;
6930
                    }
6932
                    }
6931
                     if (isover == 1)
6933
                     if (isover == 1)
6932
                     {
6934
                     {
6933
-                        if (!string.IsNullOrEmpty(model.F_WxOpenId))
6934
-                            sendwxmsg(model, model.F_WxOpenId, nowUser, model.F_DealContent);
6935
+                      //  if (!string.IsNullOrEmpty(model.F_WxOpenId))
6936
+                         //   sendwxmsg(model, model.F_WxOpenId, nowUser, model.F_DealContent);
6935
                     }
6937
                     }
6936
                         
6938
                         
6937
                 }
6939
                 }

+ 11 - 2
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Global.asax.cs

1
-using CallCenterApi.Common;
1
+using CallCenter.Utility;
2
+using CallCenterApi.Common;
2
 using CallCenterApi.Interface.Models.Common;
3
 using CallCenterApi.Interface.Models.Common;
3
 using System;
4
 using System;
4
 using System.Collections.Generic;
5
 using System.Collections.Generic;
6
+using System.Data;
7
+using System.IO;
5
 using System.Linq;
8
 using System.Linq;
9
+using System.Net;
10
+using System.Text;
6
 using System.Web;
11
 using System.Web;
7
 using System.Web.Mvc;
12
 using System.Web.Mvc;
8
 using System.Web.Routing;
13
 using System.Web.Routing;
9
 using System.Web.Script.Serialization;
14
 using System.Web.Script.Serialization;
10
 using System.Web.Security;
15
 using System.Web.Security;
16
+using System.Xml;
11
 
17
 
12
 namespace CallCenterApi.Interface
18
 namespace CallCenterApi.Interface
13
 {
19
 {
14
     public class MvcApplication : System.Web.HttpApplication
20
     public class MvcApplication : System.Web.HttpApplication
15
     {
21
     {
22
+      
16
         protected void Application_Start()
23
         protected void Application_Start()
17
         {
24
         {
18
             AreaRegistration.RegisterAllAreas();
25
             AreaRegistration.RegisterAllAreas();
19
             RouteConfig.RegisterRoutes(RouteTable.Routes);
26
             RouteConfig.RegisterRoutes(RouteTable.Routes);
20
             //clq 增加异常日志记录 自定义 HandleErrorAttribute
27
             //clq 增加异常日志记录 自定义 HandleErrorAttribute
21
             FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
28
             FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
29
+          
22
 
30
 
23
         }
31
         }
24
-
32
+     
33
+      
25
         protected void Application_AuthenticateRequest(object sender, EventArgs e)
34
         protected void Application_AuthenticateRequest(object sender, EventArgs e)
26
         {
35
         {
27
             HttpApplication app = (HttpApplication)sender;
36
             HttpApplication app = (HttpApplication)sender;

+ 59 - 0
codegit/CallCenterApi/CallCenterApi.Model/T_Cus_Customerrecords.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+
6
+namespace CallCenterApi.Model
7
+{
8
+    [Serializable]
9
+    public partial class T_Cus_Customerrecords
10
+    {
11
+        public T_Cus_Customerrecords()
12
+        { }
13
+        #region Model
14
+        private int _f_id;
15
+        private string _f_cuscode;
16
+        private string _f_cuscodeuuid;
17
+        private DateTime? _f_addtime;
18
+        private int? _f_type;
19
+        /// <summary>
20
+        /// id,自增
21
+        /// </summary>
22
+        public int F_Id
23
+        {
24
+            set { _f_id = value; }
25
+            get { return _f_id; }
26
+        }
27
+        /// <summary>
28
+        /// 工单流水号
29
+        /// </summary>
30
+        public string F_Cuscode
31
+        {
32
+            set { _f_cuscode = value; }
33
+            get { return _f_cuscode; }
34
+        }
35
+        /// <summary>
36
+        /// 政府服务网工单流水号
37
+        /// </summary>
38
+        public string F_Cuscodeuuid
39
+        {
40
+            set { _f_cuscodeuuid = value; }
41
+            get { return _f_cuscodeuuid; }
42
+        }
43
+        /// <summary>
44
+        /// 添加时间
45
+        /// </summary>
46
+        public DateTime? F_AddTime
47
+        {
48
+            set { _f_addtime = value; }
49
+            get { return _f_addtime; }
50
+        }
51
+        public int ? F_Type
52
+        {
53
+            set { _f_type = value; }
54
+            get { return _f_type; }
55
+        }
56
+        #endregion Model
57
+
58
+    }
59
+}

+ 69 - 0
codegit/CallCenterApi/CallCenterApi.Model/T_Sys_AssToken.cs

1
+using System;
2
+
3
+namespace CallCenterApi.Model
4
+{
5
+    /// <summary>
6
+    /// T_Sys_AssToken:实体类(属性说明自动提取数据库字段的描述信息)
7
+    /// </summary>
8
+    [Serializable]
9
+    public partial class T_Sys_AssToken
10
+    {
11
+        public T_Sys_AssToken()
12
+        { }
13
+        #region Model
14
+        private int _f_id;
15
+        private string _f_token;
16
+        private DateTime? _f_creattime;
17
+        private string _f_url;
18
+        private string _f_ticket;
19
+        public int? _f_isdelete;
20
+        public int ? F_IsDelete
21
+        {
22
+            set { _f_isdelete = value; }
23
+            get { return _f_isdelete; }
24
+        }
25
+        /// <summary>
26
+        /// 
27
+        /// </summary>
28
+        public int F_ID
29
+        {
30
+            set { _f_id = value; }
31
+            get { return _f_id; }
32
+        }
33
+        /// <summary>
34
+        /// 
35
+        /// </summary>
36
+        public string F_Token
37
+        {
38
+            set { _f_token = value; }
39
+            get { return _f_token; }
40
+        }
41
+        /// <summary>
42
+        /// 
43
+        /// </summary>
44
+        public DateTime? F_CreatTime
45
+        {
46
+            set { _f_creattime = value; }
47
+            get { return _f_creattime; }
48
+        }
49
+        /// <summary>
50
+        /// 
51
+        /// </summary>
52
+        public string F_Url
53
+        {
54
+            set { _f_url = value; }
55
+            get { return _f_url; }
56
+        }
57
+        /// <summary>
58
+        /// 
59
+        /// </summary>
60
+        public string F_Ticket
61
+        {
62
+            set { _f_ticket = value; }
63
+            get { return _f_ticket; }
64
+        }
65
+        #endregion Model
66
+
67
+    }
68
+}
69
+

+ 8 - 1
codegit/CallCenterCommon/CallCenter.Utility/RequestString.cs

32
         {
32
         {
33
             return HttpContext.Current.Request.HttpMethod.Equals("GET");
33
             return HttpContext.Current.Request.HttpMethod.Equals("GET");
34
         }
34
         }
35
-
35
+        /// <summary>
36
+        /// 获取文件
37
+        /// </summary>
38
+        /// <returns></returns>
39
+        public static HttpFileCollection GetFiles()
40
+        {
41
+            return HttpContext.Current.Request.Files;
42
+        }
36
         /// <summary>
43
         /// <summary>
37
         /// 返回URL中结尾的文件名
44
         /// 返回URL中结尾的文件名
38
         /// </summary>		
45
         /// </summary>		

+ 41 - 0
codegit/CallCenterCommon/CallCenter.Utility/log/LogInterface.cs

1
+
2
+using System;
3
+using System.Collections.Generic;
4
+using System.IO;
5
+using System.Linq;
6
+using System.Text;
7
+
8
+namespace CallCenter.Utility.log
9
+{
10
+    public class LogInterface
11
+    {
12
+        //心连心接口调用 日志
13
+        public static void WriteLog(string strLog)
14
+        {
15
+            //string sFilePath = System.Web.HttpContext.Current.Server.MapPath("\\Log\\" + DateTime.Now.ToString("yyyyMM"));
16
+            string sFilePath = "D:\\CallCenter_log\\LogInterface\\" + DateTime.Now.ToString("yyyy-MM");
17
+            string sFileName = "" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
18
+            sFileName = sFilePath + "\\" + sFileName; //文件的绝对路径
19
+            if (!Directory.Exists(sFilePath))//验证路径是否存在
20
+            {
21
+                Directory.CreateDirectory(sFilePath);
22
+                //不存在则创建
23
+            }
24
+            FileStream fs;
25
+            StreamWriter sw;
26
+            if (File.Exists(sFileName))
27
+            //验证文件是否存在,有则追加,无则创建
28
+            {
29
+                fs = new FileStream(sFileName, FileMode.Append, FileAccess.Write);
30
+            }
31
+            else
32
+            {
33
+                fs = new FileStream(sFileName, FileMode.Create, FileAccess.Write);
34
+            }
35
+            sw = new StreamWriter(fs);
36
+            sw.WriteLine("记录时间:[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] -- " + RequestString.GetIP() + "  " + strLog + "\r\n");
37
+            sw.Close();
38
+            fs.Close();
39
+        }
40
+    }
41
+}