SupplyController.cs 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  1. using JCSoft.WX.Framework.Api;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.AspNetCore.Http;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using Common.Wechat;
  9. using Common;
  10. using System.Data;
  11. using ZcPeng.PublicLibrary;
  12. using CoreEntity.Entity;
  13. using Common.Model;
  14. using Newtonsoft.Json.Converters;
  15. using Newtonsoft.Json;
  16. using CoreEntity.DAL;
  17. using System.Data.SqlClient;
  18. using PublicLibrary.Model;
  19. using Microsoft.Extensions.Caching.Memory;
  20. using System.Globalization;
  21. using Npoi.Mapper;
  22. using System.IO;
  23. using Microsoft.AspNetCore.Hosting;
  24. using SupplierWeb.Codes.mvc;
  25. namespace SupplierWeb.Controllers
  26. {
  27. [Route("web/supply")]
  28. public class SupplyController : BaseController
  29. {
  30. public SupplyController(IMemoryCache cache, IApiClient client) : base(cache, client)
  31. {
  32. }
  33. //(业务员)查看采购需求推送记录-所有记录
  34. [AuthPermission]
  35. [HttpPost, Route("pushrecord/{staffId}")]
  36. public ActionResult PushRecord(QueryFilter[] filters, Int32 pageIndex, Int32 pageSize,
  37. string sortField, Int32 sortDirection, string[] sumFields,
  38. string staffId,
  39. [FromBody]dynamic data,
  40. bool timeout = false,
  41. bool belowlimit = false,
  42. bool all = true)
  43. {
  44. string userids;
  45. userids = getStaffUserid(staffId);
  46. //判断参数是否合法
  47. if (string.IsNullOrEmpty(userids))
  48. {
  49. return Json(new
  50. {
  51. items = new string[] { },
  52. sum = new { },
  53. totalCount = -1,
  54. timeout = 1,
  55. });
  56. }
  57. if (data != null)
  58. {
  59. //Newtonsoft.Json.Linq.JArray
  60. filters = data.filters.ToObject<QueryFilter[]>();
  61. pageIndex = data.pageIndex;
  62. pageSize = data.pageSize;
  63. sortField = data.sortField;
  64. sortDirection = data.sortDirection;
  65. sumFields = data.sumFields.ToObject<string[]>();
  66. }
  67. #region 获取推送记录
  68. DataTable dt = new DataTable();
  69. string result;
  70. //filter参数
  71. string filterstr = "";
  72. List<SqlParameter> parameters = new List<SqlParameter>();
  73. filterstr += QueryFilter.getFilterSqlParam(filters, out parameters,new PushRecordExt(),"A.");
  74. if (filterstr.Contains("AccountRealName"))
  75. {
  76. filterstr = filterstr.Replace("and A.AccountRealName", "and B.AccountRealName");
  77. }
  78. if (timeout)
  79. filterstr += " and datediff( hour, A.CreationTime, getdate() ) >= 6";
  80. if (belowlimit)
  81. filterstr += " and exists (select A1.PushRecordId from " + Config.TablePrefix + "PushFeedback A1 where A1.PushRecordId = A.Id and A1.State=2)";
  82. if (all)
  83. filterstr += "";
  84. string direct = " desc ";
  85. if (sortDirection != 1)
  86. direct = " asc";
  87. int start = (pageIndex - 1) * pageSize;
  88. int end = (start + 1 + pageSize);
  89. string commandText0 = "select * from ";
  90. string commandText1 = "(" +
  91. "select A.*,B.AccountRealName,row_number() over" +
  92. "( order by " + sortField + " " + direct + " ) as rownum from " +
  93. Config.TablePrefix + "PushRecord as A " +
  94. " left join "+Config.TablePrefix+ "Account B on B.Id = A.PushAccountId "+
  95. " where 1=1 " +
  96. " and A.PushAccountId = '"+ userids + "'" +
  97. //" and exists(" + " select 1 from " + Config.TablePrefix + "PushFeedback A " +
  98. // " where A.PushRecordId = B.Id and A.PushAccountId = '"+ userids + "') " +
  99. //" and exists(" + " select 1 from " + Config.TablePrefix + "PushFeedback A " +
  100. // " where A.PushRecordId = B.Id and A.PushAccountId = '"+ userids + "') " +
  101. filterstr +
  102. ")AAA ";
  103. string commandText2 = " where AAA.rownum>" + start + " and AAA.rownum<" + end;
  104. bool success = DataAccess.GetValues(commandText0 + commandText1 + commandText2, ref dt, parameters.ToArray(), out result);
  105. // 把DataTable转换为IList<UserInfo>
  106. IList<PushRecordExt> users = new List<PushRecordExt>();
  107. if (dt != null && dt.Rows.Count > 0)
  108. {
  109. // 把DataTable转换为IList<UserInfo>
  110. users = ModelConvertHelper<PushRecordExt>.ConvertToModel(dt);
  111. }
  112. #endregion
  113. IsoDateTimeConverter timejson = new IsoDateTimeConverter
  114. {
  115. DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
  116. };
  117. var jsonData = JsonConvert.SerializeObject(users, timejson);
  118. string result1;
  119. string commandTextCount = "select count(Id) from " + commandText1;
  120. long totalcount = DataAccess.GetRowCountDefine(commandTextCount, parameters.ToArray(), out result1);
  121. return Json(new
  122. {
  123. items = JsonConvert.DeserializeObject(jsonData),
  124. sum = new { },
  125. totalCount = totalcount
  126. });
  127. }
  128. //(业务员)查看采购需求推送记录-最新明细
  129. [AuthPermission]
  130. [HttpPost, Route("pushfeedback/{staffId}")]
  131. public ActionResult PushFeedback(QueryFilter[] filters, Int32 pageIndex, Int32 pageSize,
  132. string sortField, Int32 sortDirection, string[] sumFields,
  133. string staffId,
  134. [FromBody]dynamic data,
  135. bool all = false)
  136. {
  137. string userids;
  138. userids = getStaffUserid(staffId);
  139. //判断参数是否合法
  140. if (string.IsNullOrEmpty(userids))
  141. {
  142. return Json(new
  143. {
  144. items = new string[]{ },
  145. sum = new { },
  146. totalCount = -1,
  147. timeout = 1,
  148. });
  149. }
  150. if (data != null)
  151. {
  152. //Newtonsoft.Json.Linq.JArray
  153. filters = data.filters.ToObject<QueryFilter[]>();
  154. pageIndex = data.pageIndex;
  155. pageSize = data.pageSize;
  156. sortField = data.sortField;
  157. sortDirection = data.sortDirection;
  158. sumFields = data.sumFields.ToObject<string[]>();
  159. }
  160. #region 获取推送记录明细
  161. DataTable dt = new DataTable();
  162. string result;
  163. string direct = " desc ";
  164. if (sortDirection != 1)
  165. direct = " asc";
  166. String filterstr = " ";
  167. //filter参数
  168. if (all)
  169. filterstr += "";
  170. else
  171. filterstr += " AND ((State = 0 OR State IS NULL) OR ( State in(5,6) ))" +
  172. " AND IsCancel = 0 ";//不包含取消的;
  173. filterstr += " AND PushAccountId = " + userids ;
  174. List<List<Object>> parameters = new List<List<Object>>();
  175. parameters.Add(new List<Object>() { "PushFbAccountId", Convert.ToInt32(userids) });
  176. List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
  177. filterstr += QueryFilter.getFilterSqlParam(filters, out parameters1, new PushFeedback(),"A.");
  178. //if (filterstr.IndexOf("PushRecordId") <0)
  179. //{
  180. // return Json(new
  181. // {
  182. // items = new string[] { ""},
  183. // sum = new { },
  184. // totalCount = 0
  185. // });
  186. //}
  187. int start = (pageIndex - 1) * pageSize;
  188. int end = (start + 1 + pageSize);
  189. string commandText0 = "select * from (";
  190. string commandText1 = "select A.*," +
  191. " E.Unit,F.WmsMeas," +
  192. " row_number() over" +
  193. "( order by " + sortField + " " + direct + " ) as rownum from " +
  194. Config.TablePrefix + "PushFeedback A " +
  195. " left join PGPrice E on E.EntId = A.EntId and E.GoodsId = A.GoodsId " +
  196. " left join GoodsAttr F on F.EntId = A.EntId and F.GoodsId = A.GoodsId " +
  197. " where 1=1 " +
  198. filterstr +
  199. ")AAA ";
  200. string commandText = commandText0 + commandText1 + " where AAA.rownum>" + start + " and AAA.rownum<" + end;
  201. bool success = DataAccess.GetValues(commandText, ref dt, parameters1.ToArray(), out result);
  202. //result = DataAccess.GetDataTable(Config.TablePrefix + "PushFeedback", "Id", "*", fieldFilter, "", sortField + direct, pageIndex, pageSize != 0 ? pageSize : Config.PageSize);
  203. // 把DataTable转换为IList<UserInfo>
  204. IList<PushFeedbackExt> users = new List<PushFeedbackExt>();
  205. if (dt != null && dt.Rows.Count > 0)
  206. {
  207. // 把DataTable转换为IList<UserInfo>
  208. users = ModelConvertHelper<PushFeedbackExt>.ConvertToModel(dt);
  209. foreach (PushFeedbackExt pfbe in users)
  210. {
  211. pfbe.ContactId = pfbe.ContactId.Trim() + "_" + pfbe.SuppliersId.Trim() + "_" + pfbe.PushAccountId;
  212. }
  213. }
  214. #endregion
  215. IsoDateTimeConverter timejson = new IsoDateTimeConverter
  216. {
  217. DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
  218. };
  219. var jsonData = JsonConvert.SerializeObject(users, timejson);
  220. string result1;
  221. string commandTextCount = "select count(*) from (" + commandText1;
  222. long totalcount = DataAccess.GetRowCountDefine(commandTextCount, parameters1.ToArray(), out result1);
  223. return Json(new
  224. {
  225. items = JsonConvert.DeserializeObject(jsonData),
  226. sum = new { },
  227. totalCount = totalcount
  228. });
  229. }
  230. [AuthPermission]
  231. [HttpPost, Route("exportexcel")]
  232. public ActionResult exportExcel([FromServices]IHostingEnvironment env, string RecordId,string staffId)
  233. {
  234. string userids;
  235. userids = getStaffUserid(staffId);
  236. //判断参数是否合法
  237. if (string.IsNullOrEmpty(userids))
  238. {
  239. return Json(new { success = false,
  240. msg = "没有登陆"
  241. });
  242. }
  243. #region 获取推送记录明细
  244. DataTable dt = new DataTable();
  245. string result;
  246. string direct = " desc ";
  247. if (0 != 1)
  248. direct = " asc";
  249. //filter参数
  250. String filterstr = " ((State = 0 OR State IS NULL) OR ( State in(5,6)))" +
  251. " AND PushAccountId = " + userids +
  252. " AND IsCancel = 0 " +
  253. " AND PushRecordId = @RecordId ";//不包含取消的
  254. List<List<Object>> parameters = new List<List<Object>>();
  255. parameters.Add(new List<Object>() { "PushFbAccountId", Convert.ToInt32(userids) });
  256. parameters.Add(new List<Object>() { "RecordId", RecordId });
  257. List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
  258. string commandText0 = "select * from (";
  259. string commandText1 = "select A.*,B.ApprovalNo, row_number() over" +
  260. "( order by A.SuppliersId " + direct + " ) as rownum from " +
  261. Config.TablePrefix + "PushFeedback A " +
  262. " left join GoodsAttr B on A.GoodsId = B.GoodsId and B.EntId = A.EntId " +
  263. " where " +
  264. filterstr +
  265. ")AAA ";
  266. string commandText = commandText0 + commandText1 ;
  267. bool success = DataAccess.GetValues(commandText, ref dt, parameters1.ToArray(), out result);
  268. //result = DataAccess.GetDataTable(Config.TablePrefix + "PushFeedback", "Id", "*", fieldFilter, "", sortField + direct, pageIndex, pageSize != 0 ? pageSize : Config.PageSize);
  269. // 把DataTable转换为IList<UserInfo>
  270. IList<PushFeedbackExcel> users = new List<PushFeedbackExcel>();
  271. if (dt != null && dt.Rows.Count > 0)
  272. {
  273. // 把DataTable转换为IList<UserInfo>
  274. users = ModelConvertHelper<PushFeedbackExcel>.ConvertToModel(dt);
  275. }
  276. #endregion
  277. var mapper = new Mapper();
  278. var fileName = Path.Combine("excel", RecordId+"_"+DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx");
  279. mapper
  280. .Map<PushFeedbackExcel>("Id", o => o.Id)
  281. .Map<PushFeedbackExcel>("推送汇总Id", o => o.PushRecordId)
  282. .Map<PushFeedbackExcel>("推送编码", o => o.Pushcode)
  283. .Map<PushFeedbackExcel>("品名", o => o.GoodsName)
  284. .Map<PushFeedbackExcel>("产品编码", o => o.GoodsCode)
  285. .Map<PushFeedbackExcel>("产品规格", o => o.GoodsSpec)
  286. .Map<PushFeedbackExcel>("厂家", o => o.Manufacturer)
  287. .Map<PushFeedbackExcel>("国药准字号", o => o.ApprovalNo)
  288. .Map<PushFeedbackExcel>("供应商名", o => o.BusinessName)
  289. .Map<PushFeedbackExcel>("产品实际价格", o => o.PurPrice)
  290. .Map<PushFeedbackExcel>("产品标准价格", o => o.ActPrice)
  291. .Map<PushFeedbackExcel>("供应数量", o => o.StoreGapNum)
  292. .Map<PushFeedbackExcel>("总需求数量", o => o.PurchaseTotalNum)
  293. .Map<PushFeedbackExcel>("备注", o => o.Feedback)
  294. .Save(Path.Combine(env.WebRootPath, fileName), users, "newSheet", overwrite: true);
  295. byte[] fileBytes = System.IO.File.ReadAllBytes(Path.Combine(env.WebRootPath, fileName));
  296. System.IO.File.Delete(env.WebRootPath +Path.DirectorySeparatorChar+ fileName);
  297. return File(fileBytes, "application/ms-excel", DateTime.Now.ToString("MMddHHmmss") + ".xlsx");
  298. }
  299. // 处理文件
  300. // fil = files;
  301. /*var file = Request.Form.Files;
  302. long size = files.Sum(f => f.Length);
  303. string webRootPath = env.WebRootPath;
  304. string contentRootPath = env.ContentRootPath;
  305. List<string> listfile = new List<string>();
  306. foreach (var formFile in files)
  307. {
  308. string suffix = formFile.FileName.Split('.')[1];
  309. if (formFile.Length > 0 && suffix == "xlsx")
  310. {
  311. string fileExt = "xlsx";
  312.                     /// string fileExt = GetFileExt(formFile.FileName); //文件扩展名,不含“.”
  313.                     long fileSize = formFile.Length; //获得文件大小,以字节为单位
  314.                     string newFileName = System.Guid.NewGuid().ToString() + "." + fileExt; //随机生成新的文件名
  315.                     var filePath = webRootPath + "/excel/" + formFile.FileName;
  316. var mapper = new Mapper(formFile.OpenReadStream());
  317. var objectInfos = mapper.Take<PushFeedbackExcel>("newSheet");
  318. List<DataAccessCommand> list = new List<DataAccessCommand>();
  319. string result;
  320. foreach (RowInfo< PushFeedbackExcel> e in objectInfos)
  321. {
  322. #region 更新数据
  323. string commandText = "UPDATE " + Config.TablePrefix + "PushFeedback " +
  324. "SET StoreGapNum = @StoreGapNum, " +
  325. " Feedback = @Feedback, " +
  326. " State = 1 " +
  327. " ) A" +
  328. " WHERE Id= @Id" +
  329. " AND PushAccountId = " + userids;
  330. //准备参数
  331. List<List<Object>> parameters = new List<List<Object>>();
  332. parameters.Add(new List<Object>() { "StoreGapNum", e.Value.StoreGapNum });
  333. parameters.Add(new List<Object>() { "Feedback", e.Value.Feedback });
  334. parameters.Add(new List<Object>() { "Id", e.Value.Id });
  335. List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
  336. list.Add(new DataAccessCommand(commandText, parameters1, CommandType.Text, true));
  337. //int success = DataAccess.ExecuteCommand(commandText, parameters1, out result);
  338. #endregion
  339. }
  340. bool success = DataAccess.ExecuteBatchCommands(list, out result);
  341. //mapper.Save(filePath);
  342. //using (var stream = new FileStream(filePath, FileMode.Create))
  343. //{
  344. // await formFile.OpenReadStream().CopyToAsync(stream);
  345. //}
  346. listfile.Add(filePath);
  347. }
  348. }*/
  349. /// <summary>
  350. /// 导入excel,提报供货数量
  351. /// </summary>
  352. /// <param name="files"></param>
  353. /// <returns></returns>
  354. [AuthPermission]
  355. [HttpPost, Route("excelsave")]
  356. //public async Task<IActionResult> ExcelSave([FromServices]IHostingEnvironment env,
  357. //List<IFormFile> files,
  358. public ActionResult ExcelSave([FromServices]IHostingEnvironment env,
  359. string files,
  360. string staffId,
  361. [FromBody]dynamic data)
  362. {
  363. string userids;
  364. userids = getStaffUserid(staffId);
  365. //判断参数是否合法
  366. if (string.IsNullOrEmpty(userids))
  367. {
  368. return Json(new
  369. {
  370. success = false,
  371. msg = "没有登陆"
  372. });
  373. }
  374. if (data != null)
  375. {
  376. files = data.files;
  377. }
  378. if (files != null && files.Split('.').Length >= 2) {
  379. string suffix = files.Split('.')[1];
  380. if (suffix != "xlsx")
  381. {
  382. return Json(new
  383. {
  384. success = false,
  385. msg = "格式错误"
  386. });
  387. }
  388. }
  389. else
  390. {
  391. return Json(new
  392. {
  393. success = false,
  394. msg = "格式错误"
  395. });
  396. }
  397. string webRootPath = env.WebRootPath;
  398. //string contentRootPath = env.ContentRootPath;
  399. var filePath = webRootPath + Path.DirectorySeparatorChar + files.Replace('/', Path.DirectorySeparatorChar);
  400. var mapper = new Mapper(filePath);
  401. var objectInfos = mapper
  402. .Map<PushFeedbackExcel>("Id", o => o.Id, (column, target) => // tryTake resolver : Custom logic to take cell value into target object.
  403. {
  404. // Note: return false to indicate a failure; and that will increase error count.
  405. if (column.HeaderValue == null || column.CurrentValue == null) return false;
  406. if (!(column.CurrentValue is string)) return false;
  407. var index = column.Attribute.Index;
  408. if ((index == 0))
  409. {
  410. ((PushFeedbackExcel)target).Id = Guid.Parse((string)column.CurrentValue);
  411. return true;
  412. }
  413. if ((index == 1))
  414. {
  415. ((PushFeedbackExcel)target).PushRecordId = Guid.Parse((string)column.CurrentValue);
  416. return true;
  417. }
  418. return true;
  419. })
  420. .Map<PushFeedbackExcel>("推送汇总Id", o => o.PushRecordId, (column, target) => // tryTake resolver : Custom logic to take cell value into target object.
  421. {
  422. // Note: return false to indicate a failure; and that will increase error count.
  423. if (column.HeaderValue == null || column.CurrentValue == null) return false;
  424. if (!(column.CurrentValue is string)) return false;
  425. var index = column.Attribute.Index;
  426. if ((index == 0))
  427. {
  428. ((PushFeedbackExcel)target).Id = Guid.Parse((string)column.CurrentValue);
  429. return true;
  430. }
  431. if ((index == 1))
  432. {
  433. ((PushFeedbackExcel)target).PushRecordId = Guid.Parse((string)column.CurrentValue);
  434. return true;
  435. }
  436. return true;
  437. })
  438. .Map<PushFeedbackExcel>("备注", o => o.Feedback, (column, target) => // tryTake resolver : Custom logic to take cell value into target object.
  439. {
  440. // Note: return false to indicate a failure; and that will increase error count.
  441. if (column.HeaderValue == null || column.CurrentValue == null) return false;
  442. if (!(column.CurrentValue is string))
  443. {
  444. if((column.CurrentValue is double))
  445. column.CurrentValue = DateTime.FromOADate((double)column.CurrentValue);
  446. }
  447. var index = column.Attribute.Index;
  448. if ((index == 3))
  449. {
  450. ((PushFeedbackExcel)target).Feedback = column.CurrentValue.ToString();
  451. return true;
  452. }
  453. return true;
  454. })
  455. .Map<PushFeedbackExcel>("推送编码", o => o.Pushcode)
  456. .Map<PushFeedbackExcel>("品名", o => o.GoodsName)
  457. .Map<PushFeedbackExcel>("产品编码", o => o.GoodsCode)
  458. .Map<PushFeedbackExcel>("产品规格", o => o.GoodsSpec)
  459. .Map<PushFeedbackExcel>("厂家", o => o.Manufacturer)
  460. .Map<PushFeedbackExcel>("国药准字号", o => o.ApprovalNo)
  461. .Map<PushFeedbackExcel>("供应商名", o => o.BusinessName)
  462. .Map<PushFeedbackExcel>("产品实际价格", o => o.PurPrice)
  463. .Map<PushFeedbackExcel>("产品标准价格", o => o.ActPrice)
  464. .Map<PushFeedbackExcel>("供应数量", o => o.StoreGapNum)
  465. .Map<PushFeedbackExcel>("总需求数量", o => o.PurchaseTotalNum)
  466. .Map<PushFeedbackExcel>("备注", o => o.Feedback)
  467. //.Map(
  468. //column => // column filter : Custom logic to determine whether or not to map and include an unmapped column.
  469. //{
  470. // var index = column.Attribute.Index;
  471. // if ((index == 0)|| (index == 1))
  472. // {
  473. // return true;
  474. // }
  475. // return false;
  476. //},
  477. //(column, target) => // tryTake resolver : Custom logic to take cell value into target object.
  478. //{
  479. // // Note: return false to indicate a failure; and that will increase error count.
  480. // if (column.HeaderValue == null || column.CurrentValue == null) return false;
  481. // if (!(column.CurrentValue is string)) return false;
  482. // var index = column.Attribute.Index;
  483. // if ((index == 0))
  484. // {
  485. // ((PushFeedbackExcel)target).Id = Guid.Parse((string)column.CurrentValue);
  486. // return true;
  487. // }
  488. // if ((index == 1))
  489. // {
  490. // ((PushFeedbackExcel)target).PushRecordId = Guid.Parse((string)column.CurrentValue);
  491. // return true;
  492. // }
  493. // return true;
  494. //},
  495. //(column, source) => // tryPut resolver : Custom logic to put property value into cell.
  496. //{
  497. // // Custom logic to set the cell value.
  498. // var sample = (PushFeedbackExcel)source;
  499. // if((column.Attribute.Index == 0))
  500. // {
  501. // column.CurrentValue = sample.Id.ToString();
  502. // }
  503. // if ((column.Attribute.Index == 1))
  504. // {
  505. // column.CurrentValue = sample.PushRecordId.ToString();
  506. // }
  507. // return true;
  508. //}
  509. //)
  510. .Take<PushFeedbackExcel>("newSheet");
  511. List<DataAccessCommand> list = new List<DataAccessCommand>();
  512. Dictionary<string, Object> mapHasUpdated = new Dictionary<string, object>();
  513. string result;
  514. foreach (RowInfo<PushFeedbackExcel> e in objectInfos)
  515. {
  516. if (e.Value.StoreGapNum.Equals(0))
  517. {
  518. var pfb = PushFeedBackDAL.GetFeedback(e.Value.Id.ToString());
  519. //string contactid = "";
  520. //if (pfb.ContactId.Split("_").Length > 0)
  521. // contactid = pfb.ContactId.Split("_")[0];
  522. ContactDAL.UpdatePushContactState(pfb.GoodsId, pfb.ContactId, pfb.SuppliersId.Trim(), "N");
  523. }
  524. #region 更新明细数据
  525. string commandText = "UPDATE " + Config.TablePrefix + "PushFeedback " +
  526. "SET StoreGapNum = @StoreGapNum, " +
  527. " Feedback = @Feedback, " +
  528. (e.Value.StoreGapNum<e.Value.PurchaseTotalNum? " State = 2 " : " State = 1 ") +
  529. " WHERE Id= @Id" +
  530. " AND PushAccountId = " + userids +
  531. " AND State = 0";
  532. //准备参数
  533. List<List<Object>> parameters = new List<List<Object>>();
  534. parameters.Add(new List<Object>() { "StoreGapNum", e.Value.StoreGapNum });
  535. parameters.Add(new List<Object>() { "Feedback", e.Value.Feedback });
  536. parameters.Add(new List<Object>() { "Id", e.Value.Id });
  537. List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
  538. list.Add(new DataAccessCommand(commandText, parameters1, CommandType.Text, true));
  539. //int success = DataAccess.ExecuteCommand(commandText, parameters1, out result);
  540. if (!mapHasUpdated.ContainsKey(e.Value.PushRecordId.ToString())) {
  541. //int successState = PushRecordDAL.SubmitState(userids, Id);
  542. #region 更新记录状态
  543. string commandTextState = "UPDATE " + Config.TablePrefix + "PushRecord " +
  544. " SET SubmitTime = @SubmitTime, " +
  545. " SubmitPerson = @SubmitPerson, " +
  546. " State = 1 " +
  547. " WHERE id= @PushRecordId" +
  548. " AND PushAccountId = " + userids +
  549. " AND State = 0";
  550. //string resultState;
  551. //准备参数
  552. List<List<Object>> parametersState = new List<List<Object>>();
  553. parametersState.Add(new List<Object>() { "SubmitTime", DateTime.Now });
  554. parametersState.Add(new List<Object>() { "SubmitPerson", userids });
  555. parametersState.Add(new List<Object>() { "PushRecordId", e.Value.PushRecordId });
  556. List<SqlParameter> parametersState1 = DataAccess.ToParameters(parametersState);
  557. list.Add(new DataAccessCommand(commandTextState, parametersState1, CommandType.Text, true));
  558. //int successState = DataAccess.ExecuteCommand(commandTextState, parametersState1, out resultState);
  559. #endregion
  560. mapHasUpdated.Add(e.Value.PushRecordId.ToString(), e.Value);
  561. }
  562. #endregion
  563. }
  564. System.IO.File.Delete(filePath);
  565. #region 删除文件记录
  566. string commandTextD = "DELETE FROM " + Config.TablePrefix + "UPLOADFILES WHERE Path = @Path";
  567. //准备参数
  568. List<List<Object>> parametersD = new List<List<Object>>();
  569. parametersD.Add(new List<Object>() { "Path", files.Replace("\\","/") });
  570. string resultD = "";
  571. List<SqlParameter> parametersD1 = DataAccess.ToParameters(parametersD);
  572. int successDel = DataAccess.ExecuteCommand(commandTextD, parametersD1, out resultD);
  573. #endregion
  574. bool success = DataAccess.ExecuteBatchCommands(list, out result);
  575. return Json(new{success = success,
  576. data = result,
  577. successDel = successDel,
  578. resultD = resultD,
  579. });
  580. }
  581. ////根据采购计划提交供货情况:添加提交状态 时间
  582. [AuthPermission]
  583. [HttpPost, Route("editfeedback/{staffId}")]
  584. public JsonResult EditFeedback(string Id,
  585. string PushCode,
  586. Int32 StoreGapNum,string Feedback,
  587. string BusinessId, string BusinessCode, string BusinessName,
  588. string SuppliersId, string PushRecordId, Int32 PushAccountId,
  589. string staffId,
  590. [FromBody]dynamic data)
  591. {
  592. string userids;
  593. userids = getStaffUserid(staffId);
  594. //判断参数是否合法
  595. if (string.IsNullOrEmpty(userids))
  596. {
  597. return Json(new
  598. {
  599. success = 0
  600. });
  601. }
  602. PushAccountId = Convert.ToInt32(userids);
  603. if (data != null)
  604. {
  605. //Newtonsoft.Json.Linq.JArray
  606. Id = data.Id;
  607. StoreGapNum = data.StoreGapNum;
  608. Feedback = data.Feedback;
  609. BusinessId = data.BusinessId;
  610. BusinessCode = data.BusinessCode;
  611. BusinessName = data.BusinessName;
  612. SuppliersId = data.SuppliersId;
  613. PushRecordId = data.PushRecordId;
  614. PushCode = data.PushCode;
  615. }
  616. #region 更新数据
  617. string commandText = "UPDATE " + Config.TablePrefix + "PushFeedback " +
  618. "SET StoreGapNum = @StoreGapNum, " +
  619. " Feedback = @Feedback, " +
  620. " BusinessId = @BusinessId, " +
  621. " BusinessCode = @BusinessCode, " +
  622. " BusinessName = @BusinessName, " +
  623. " SuppliersId = @SuppliersId," +
  624. " State = 1 " +
  625. " WHERE id= @Id" +
  626. " AND PushAccountId = " + userids;
  627. string result;
  628. //准备参数
  629. List<List<Object>> parameters = new List<List<Object>>();
  630. parameters.Add(new List<Object>() { "StoreGapNum", StoreGapNum });
  631. parameters.Add(new List<Object>() { "Feedback", Feedback });
  632. parameters.Add(new List<Object>() { "BusinessId", BusinessId });
  633. parameters.Add(new List<Object>() { "BusinessCode", BusinessCode });
  634. parameters.Add(new List<Object>() { "BusinessName", BusinessName });
  635. parameters.Add(new List<Object>() { "SuppliersId", SuppliersId });
  636. parameters.Add(new List<Object>() { "Id", Id });
  637. List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
  638. int success = DataAccess.ExecuteCommand(commandText, parameters1, out result);
  639. #endregion
  640. int successState = PushRecordDAL.SubmitState(userids,Id);
  641. return Json(new
  642. {
  643. success = success,
  644. successState = successState
  645. });
  646. }
  647. ////查询已经确认的订单:采购员已确认 已生成计划单
  648. [AuthPermission]
  649. [HttpPost, Route("feedbackorder/{staffId}/{state}")]
  650. public ActionResult feedbackOrder(QueryFilter[] filters, Int32 pageIndex, Int32 pageSize,
  651. string sortField, Int32 sortDirection, string[] sumFields,
  652. string state,
  653. string staffId,
  654. [FromBody]dynamic data)
  655. {
  656. string userids;
  657. userids = getStaffUserid(staffId);
  658. //判断参数是否合法
  659. if (string.IsNullOrEmpty(userids))
  660. {
  661. return Json(new
  662. {
  663. items = new string[] { },
  664. sum = new { },
  665. totalCount = -1,
  666. timeout = 1,
  667. });
  668. }
  669. if (data != null)
  670. {
  671. //Newtonsoft.Json.Linq.JArray
  672. filters = data.filters.ToObject<QueryFilter[]>();
  673. pageIndex = data.pageIndex;
  674. pageSize = data.pageSize;
  675. sortField = data.sortField;
  676. sortDirection = data.sortDirection;
  677. sumFields = data.sumFields.ToObject<string[]>();
  678. }
  679. #region 获取feedback 采购员已确认 3
  680. DataTable dt = new DataTable();
  681. string result = "";
  682. string direct = " desc ";
  683. if (sortDirection != 1)
  684. direct = " asc";
  685. string statefilter = " and A.";
  686. if (state == "1")
  687. {
  688. statefilter += "State = 1 ";
  689. }
  690. else if (state == "2")
  691. {
  692. statefilter += "State = 2 ";
  693. }
  694. else if (state == "1,2")
  695. {
  696. statefilter += "State in (1,2) ";
  697. }
  698. else if (state == "3")
  699. {
  700. statefilter = " and (A.State = 3 or (A.State in(2) and A.StoreGapNum = 0 ))";
  701. }
  702. else if (state == "4")
  703. {
  704. statefilter = " and (A.State = 4 or (A.State in(2) and A.StoreGapNum = 0 ))";
  705. }
  706. else if (state == "5")
  707. {
  708. statefilter += "State = 5 ";
  709. statefilter += " AND A.IsCancel = 0 ";//不包含取消的
  710. }
  711. else
  712. {
  713. return Json(new
  714. {
  715. items = new string[] { },
  716. sum = new { },
  717. totalCount = -1
  718. });
  719. }
  720. List<SqlParameter> parameters = new List<SqlParameter>();
  721. var filterstr = QueryFilter.getFilterSqlParam(filters, out parameters, new PushFeedbackExt(), "A.");
  722. if (filterstr.IndexOf("AccountRealName") > 0)
  723. {
  724. filterstr = filterstr.Replace("and A.AccountRealName", "and B.AccountRealName");
  725. }
  726. if (filterstr.IndexOf("PurName") > 0)
  727. {
  728. filterstr = filterstr.Replace("and A.PurName", "and C.AccountRealName");
  729. }
  730. filterstr = filterstr.Replace("and A.ReceiptMd", "and D.ReceiptMd");
  731. filterstr = filterstr.Replace("and A.CentPayMd", "and D.CentPayMd");
  732. filterstr = filterstr.Replace("and A.RequestDate", "and case isdate(enddate)when 1 then convert(datetime,D.enddate, 20)else null end");
  733. filterstr = filterstr.Replace("A.IsPrepayI", " Case D.IsPrepay When 'Y' Then 1 Else 0 End ");
  734. filterstr = filterstr.Replace("A.PrepayAmt", "D.PrepayAmt");
  735. statefilter += filterstr + " and PushAccountId = " + userids;
  736. //if (state == "3")
  737. //{
  738. // if (statefilter.IndexOf("PushRecordId") < 0)
  739. // {
  740. // return Json(new
  741. // {
  742. // items = new string[] { },
  743. // sum = new { },
  744. // totalCount = -1
  745. // });
  746. // }
  747. //}
  748. int start = (pageIndex - 1) * pageSize;
  749. int end = (start + 1 + pageSize);
  750. string commandText0 = "select * from ";
  751. string commandText1 = "(" +
  752. "select A.*,B.AccountRealName,C.AccountRealName as PurName," +
  753. (state == "3" || state == "4" ? ("D.ReceiptMd,D.CentPayMd,"
  754. + "case isdate(enddate)when 1 then convert(datetime,D.enddate, 20)else null end as RequestDate," +
  755. "Case D.IsPrepay When 'Y' Then 1 Else 0 End IsPrepayI,D.PrepayAmt,") : ""
  756. ) +
  757. "E.Unit," +
  758. "row_number() over" +
  759. "( order by A." + sortField + " " + direct + " ) as rownum from " +
  760. Config.TablePrefix + "PushFeedback as A " +
  761. " left join " + Config.TablePrefix + "Account B on B.Id = A.PushAccountId " +
  762. " left join " + Config.TablePrefix + "Account C on C.Id = A.ConfirmPuchaser " +
  763. (state == "3" || state == "4" ?
  764. " left join PurPlanMT D on D.PushRecordId = A.PushRecordId and D.K_ContactId = A.ContactId and isnull(D.billstate,0) =0 " : "") +
  765. " left join PGPrice E on E.EntId = A.EntId and E.GoodsId = A.GoodsId" +
  766. " where 1=1 " +
  767. (state == "3"||state == "4"? " and isnull(D.billstate,0) =0 ":"")+
  768. statefilter +
  769. ")AAA ";
  770. string commandText2 = " where AAA.rownum>" + start + " and AAA.rownum<" + end;
  771. string commandText = commandText0 + commandText1 + commandText2;
  772. //result = DataAccess.GetDataTable(Config.TablePrefix + "PushFeedback", "Id", "*", statefilter, "", sortField + direct, pageIndex, pageSize != 0 ? pageSize : Config.PageSize);
  773. bool success = DataAccess.GetDataTable(commandText, dt,parameters.ToArray(),out result);
  774. #endregion
  775. // 把DataTable转换为IList<PushFeedbackExt>
  776. IList<PushFeedbackExt> feedbacks = new List<PushFeedbackExt>();
  777. if (dt!=null && dt.Rows.Count > 0)
  778. {
  779. feedbacks = ModelConvertHelper<PushFeedbackExt>.ConvertToModel(dt);
  780. foreach(PushFeedbackExt pfb in feedbacks)
  781. {
  782. if((state == "3" || state == "4" || state == "2") &&pfb.StoreGapNum == 0)
  783. {
  784. pfb.Remark = "如有货请及时联系采购员";
  785. }
  786. }
  787. }
  788. IsoDateTimeConverter timejson = new IsoDateTimeConverter
  789. {
  790. DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
  791. };
  792. var jsonData = JsonConvert.SerializeObject(feedbacks, timejson);
  793. string result1;
  794. long totalcount = DataAccess.GetRowCountDefine("select count(*) from "+ commandText1, parameters.ToArray(), out result1);
  795. return Json(new
  796. {
  797. items = JsonConvert.DeserializeObject(jsonData),
  798. sum = new { },
  799. totalCount = totalcount,
  800. result = result
  801. });
  802. }
  803. ///供应商业务员二次确认:生成采购订单 开发票
  804. ///1 供应商业务员确认(数量提交确认) 2 供应商业务员取消 3 采购员确认(生成计划)
  805. ///4 供应商业务员确认(二次确认 开票 生成采购订单)
  806. ///如果修改了数据(设置状态为2 按钮显示:修改并提交) 需要重新提交
  807. //[HttpPost, Route("confirmfeedback/{staffId}/{State:int}")]
  808. //public JsonResult ConfirmFeedback(string Id, Int32 StoreGapNum, string Feedback,
  809. // string BusinessId, string BusinessCode, string BusinessName,
  810. // string SuppliersId, string PushRecordId, Int32 PushAccountId,
  811. // Int32 State,
  812. // string staffId,
  813. // [FromBody]dynamic data)
  814. //{
  815. // string userids;
  816. // userids = getStaffUserid(staffId);
  817. // //判断参数是否合法
  818. // if (string.IsNullOrEmpty(userids))
  819. // {
  820. // return Json(new
  821. // {
  822. // success = 0
  823. // });
  824. // }
  825. // PushAccountId = Convert.ToInt32(userids);
  826. // if (data != null)
  827. // {
  828. // //Newtonsoft.Json.Linq.JArray
  829. // Id = data.Id;
  830. // StoreGapNum = data.StoreGapNum;
  831. // Feedback = data.Feedback;
  832. // BusinessId = data.BusinessId;
  833. // BusinessCode = data.BusinessCode;
  834. // BusinessName = data.BusinessName;
  835. // SuppliersId = data.SuppliersId;
  836. // PushRecordId = data.PushRecordId;
  837. // }
  838. // PushRecord rec = PushRecordDAL.GetRecord(PushRecordId);
  839. // if (rec != null && rec.HasOrder == 1)
  840. // return Json(new
  841. // {
  842. // success = 0,
  843. // msg = "已经生成采购订单!"
  844. // });
  845. // #region 待更新状态
  846. // string fieldTime = string.Empty;
  847. // string fieldPerson = string.Empty;
  848. // string fieldFilter = string.Empty;
  849. // int state = 0;
  850. // int successo0 = 0;
  851. // if (State == 2)//修改数据
  852. // {
  853. // fieldTime = "CancelTime";
  854. // fieldPerson = "CancelPerson";
  855. // state = 2;
  856. // fieldFilter = " AND ((State = 0 OR State IS NULL) OR ( State in(5,6)) )" +
  857. // " AND PushAccountId="+PushAccountId;
  858. // successo0 = 1;
  859. // PushFeedback pf = PushFeedBackDAL.GetFeedbacks(PushRecordId," and PushFeddbackId = '"+Id+"'").ToArray()[0];
  860. // if (StoreGapNum >= pf.PurchaseTotalNum)
  861. // {
  862. // return Json(new
  863. // {
  864. // success = 0,
  865. // msg = "不能超过最大采购值"
  866. // });
  867. // }
  868. // }
  869. // else if (State == 1)//提交供货数量信息
  870. // {
  871. // fieldTime = "SubmitTime";
  872. // fieldPerson = "SubmitPerson";
  873. // state = 1;
  874. // fieldFilter = " AND (State = 0 OR State IS NULL OR State in(5,6) )";
  875. // }
  876. // else if (State == 4)//生成采购订单
  877. // {
  878. // fieldTime = "ConfirmOrderTime";
  879. // fieldPerson = "ConfirmOrderPerson";
  880. // state = 4;
  881. // fieldFilter = " AND State = 3 ";
  882. // //查询 plan
  883. // #region 获取 plan
  884. // string commandTextContact = "Select * From " +Config.TablePrefix+"PushFeedback " +
  885. // "Where Id=@Id and PushAccountId = @PushAccountId and State = 3";
  886. // string resultContact;
  887. // DataTable dt = new DataTable();
  888. // PushFeedback feedback;
  889. // List<PushFeedback> feedbacks = new List<PushFeedback>();
  890. // List<List<Object>> parametersContact = new List<List<Object>>();
  891. // if (PushAccountId != 0)
  892. // {
  893. // parametersContact.Add(new List<Object>() { "Id", Id });
  894. // parametersContact.Add(new List<Object>() { "PushAccountId", PushAccountId });
  895. // DataAccess.GetValues(commandTextContact, ref dt,DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
  896. // }
  897. // #endregion
  898. // if (dt != null&&dt.Rows.Count>0)
  899. // {
  900. // feedbacks = (List<PushFeedback>)ModelConvertHelper<PushFeedback>.ConvertToModel(dt);
  901. // feedback = feedbacks.ToArray()[0];
  902. // PurPlanDT plandt = PurPlanDAL.GetPlanDT(Id).ToArray()[0];
  903. // PurPlanMT PlanMT = PurPlanDAL.GetPlanMT(rec.Id.ToString(),Id, PushAccountId, feedback.SuppliersId).ToArray()[0];
  904. // string reqdate = PlanMT.EndDate;
  905. // string StaffDocId = PlanMT.SaleManId;
  906. // IDictionary<string,Object> dic = PurOrderDAL.AddOrder(PushAccountId.ToString(),
  907. // PlanMT.BillNo.ToString()
  908. // , feedback.EntId, PlanMT.ReceiptMd, PlanMT.CentPayMd
  909. // , PlanMT.OrgId, PlanMT.DeptId
  910. // , "", feedback.Remark
  911. // , feedback.GoodsId, feedback.SuppliersId
  912. // , feedback.BusinessId, feedback.BusinessCode
  913. // , StaffDocId
  914. // , reqdate);
  915. // Object successo;
  916. // dic.TryGetValue("successRecord", out successo);
  917. // if ((int)successo > 0) {
  918. // Object OrderBillNo;
  919. // dic.TryGetValue("OrderBillNo",out OrderBillNo);
  920. // IDictionary<string,Object> dicODAdd= PurOrderDAL.AddOrderDT((Int32)OrderBillNo, 0,
  921. // PlanMT.BillNo, 0, PlanMT.BillCode,
  922. // PlanMT.GoodsId, feedback.GoodsSpec, feedback.StoreGapNum,
  923. // feedback.PurPrice,
  924. // PlanMT.Remark,
  925. // PlanMT.EntId, PlanMT.OrgId,
  926. // feedback.BusinessId, feedback.BusinessCode,
  927. // feedback.SuppliersId,
  928. // feedback.PurchaseTotalNum,
  929. // plandt.SafeDays
  930. // , StaffDocId);
  931. // Object successo1;
  932. // dicODAdd.TryGetValue("successRecord", out successo1);
  933. // if ((int)successo > 0 && (int)successo1 > 0) {
  934. // successo0 = 1;
  935. // //增加更新hasOrder 1 feedback记录的状态state
  936. // int successOState = PurOrderDAL.UpdateOrderState(Id, PushRecordId);
  937. // }
  938. // }
  939. // }
  940. // }
  941. // #endregion
  942. // #region 更新数据
  943. // string commandText = "UPDATE " + Config.TablePrefix + "PushFeedback " +
  944. // " SET StoreGapNum = StoreGapNum1, " +
  945. // " Feedback = Feedback1, " +
  946. // " BusinessId = BusinessId1, " +
  947. // " BusinessCode = BusinessCode1, " +
  948. // " BusinessName = BusinessName1, " +
  949. // " SuppliersId = SuppliersId1, " +
  950. // " State = " + state +
  951. // " FROM (SELECT " +
  952. // "@StoreGapNum as StoreGapNum1," +
  953. // "@Feedback as Feedback1," +
  954. // "@BusinessId as BusinessId1," +
  955. // "@BusinessCode as BusinessCode1," +
  956. // "@BusinessName as BusinessName1," +
  957. // "@SuppliersId as SuppliersId1" +
  958. // " ) A" +
  959. // " WHERE id= @Id" +
  960. // fieldFilter;
  961. // string result;
  962. // //准备参数
  963. // List<List<Object>> parameters = new List<List<Object>>();
  964. // parameters.Add(new List<Object>() { "StoreGapNum", StoreGapNum });
  965. // parameters.Add(new List<Object>() { "Feedback", Feedback });
  966. // parameters.Add(new List<Object>() { "BusinessId", BusinessId });
  967. // parameters.Add(new List<Object>() { "BusinessCode", BusinessCode });
  968. // parameters.Add(new List<Object>() { "BusinessName", BusinessName });
  969. // parameters.Add(new List<Object>() { "SuppliersId", SuppliersId });
  970. // parameters.Add(new List<Object>() { "Id", Id });
  971. // List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
  972. // int success = DataAccess.ExecuteCommand(commandText, parameters1, out result);
  973. // #endregion
  974. // int successState = -1;
  975. // #region 更新记录状态
  976. // if (successo0 == 1) {
  977. // string commandTextState = "UPDATE " + Config.TablePrefix + "PushFeedback " +
  978. // " SET "+ fieldTime + " = "+ fieldTime + "1, " +
  979. // " " + fieldPerson + " = " + fieldPerson + "1, " +
  980. // " State = " + state +
  981. // " FROM (SELECT " +
  982. // "@" + fieldTime + " as " + fieldTime + "1," +
  983. // "@" + fieldPerson + " as " + fieldPerson + "1" +
  984. // " ) A" +
  985. // " WHERE id= @PushFeedbackId " +
  986. // fieldFilter;
  987. // string resultState;
  988. // //准备参数
  989. // List<List<Object>> parametersState = new List<List<Object>>();
  990. // parametersState.Add(new List<Object>() { fieldTime, DateTime.Now });
  991. // parametersState.Add(new List<Object>() { fieldPerson, PushAccountId });
  992. // parametersState.Add(new List<Object>() { "PushFeedbackId", Id });
  993. // List<SqlParameter> parametersState1 = DataAccess.ToParameters(parametersState);
  994. // successState = DataAccess.ExecuteCommand(commandTextState, parametersState1, out resultState);
  995. // }
  996. // #endregion
  997. // return Json(new
  998. // {
  999. // success = success,
  1000. // successState = successState
  1001. // });
  1002. //}
  1003. //////查询已提交的采购计划
  1004. //[HttpGet,Route("purchaseorder")]
  1005. //public ActionResult PurchaseOrder(string echostr, string signature, string timestamp, string nonce)
  1006. //{
  1007. // #region 获取Openid
  1008. // //WechatHelper.ReGetOpenId(HttpContext);
  1009. // #endregion
  1010. // return View();
  1011. //}
  1012. ////查看采购单的入库明细
  1013. [AuthPermission]
  1014. [HttpGet,Route("orderstockin")]
  1015. public ActionResult OrderStockIn(string echostr, string signature, string timestamp, string nonce)
  1016. {
  1017. #region 获取Openid
  1018. //WechatHelper.ReGetOpenId(HttpContext);
  1019. #endregion
  1020. return Content("");
  1021. }
  1022. ////查看采购单的拒收,退回明细
  1023. [AuthPermission]
  1024. [HttpGet,Route("orderrefund")]
  1025. public ActionResult OrderRefund(string echostr, string signature, string timestamp, string nonce)
  1026. {
  1027. #region 获取Openid
  1028. //WechatHelper.ReGetOpenId(HttpContext);
  1029. #endregion
  1030. return Content("");
  1031. }
  1032. ////邮寄发票,登记发票物流单号,查看发票签收状态
  1033. [AuthPermission]
  1034. [HttpGet,Route("orderinvoice")]
  1035. public ActionResult OrderInvoice(string echostr, string signature, string timestamp, string nonce)
  1036. {
  1037. #region 获取Openid
  1038. //WechatHelper.ReGetOpenId(HttpContext);
  1039. #endregion
  1040. return Content("");
  1041. }
  1042. ////查看付款状态付款日期
  1043. [AuthPermission]
  1044. [HttpGet,Route("orderpayment")]
  1045. public ActionResult OrderPayment(string echostr, string signature, string timestamp, string nonce)
  1046. {
  1047. #region 获取Openid
  1048. //WechatHelper.ReGetOpenId(HttpContext);
  1049. #endregion
  1050. return View();
  1051. }
  1052. /////////////////////////////////////
  1053. ////供应商业务员在有新品的情况下 可提报新品
  1054. /**
  1055. 分三种种情况:一是我方没有经营但品种库有的品种提交时需对应上我方的商品编码;
  1056. 二是我方有经营但和此供应商没有业务往来,同第一种处理防水;
  1057. 三是我方品种库没有品种直接录入基本信息(商品名称、商品规格、生产厂家、批准文号、件装数量、供货价格);
  1058. */
  1059. [AuthPermission]
  1060. [HttpGet,Route("newproductsubmit")]
  1061. public ActionResult NewProductSubmit(string echostr, string signature, string timestamp, string nonce)
  1062. {
  1063. #region 获取Openid
  1064. //WechatHelper.ReGetOpenId(HttpContext);
  1065. #endregion
  1066. return View();
  1067. }
  1068. ////提交新品种首营资料(品种首营、供应商首营)
  1069. [AuthPermission]
  1070. [HttpGet,Route("newcategorydocsubmit")]
  1071. public ActionResult NewCategoryDocSubmit(string echostr, string signature, string timestamp, string nonce)
  1072. {
  1073. #region 获取Openid
  1074. //WechatHelper.ReGetOpenId(HttpContext);
  1075. #endregion
  1076. return View();
  1077. }
  1078. ////提交新品种
  1079. [AuthPermission]
  1080. [HttpGet,Route("newcategorysubmit")]
  1081. public ActionResult NewCategorySubmit(string echostr, string signature, string timestamp, string nonce)
  1082. {
  1083. #region 获取Openid
  1084. //WechatHelper.ReGetOpenId(HttpContext);
  1085. #endregion
  1086. return View();
  1087. }
  1088. ////列表
  1089. //[HttpGet, Route("index")]
  1090. //public ActionResult index(string[] filters, Int32 pageIndex, Int32 pageSize,
  1091. // string sortField, Int32 sortDirection, string[] sumFields, string callback)
  1092. //{
  1093. // var r = this.indexp(filters, pageIndex, pageSize,
  1094. // sortField, sortDirection, sumFields, null);
  1095. // return Content(callback + "(" + JsonConvert.SerializeObject(r.Value)
  1096. // + ")");
  1097. //}
  1098. ////业务员的供应商
  1099. [AuthPermission]
  1100. [HttpGet, Route("getcontacts")]
  1101. public JsonResult GetContacts(string staffId,
  1102. string GoodsId)
  1103. {
  1104. string userids;
  1105. string PushAccountId = userids = getStaffUserid(staffId);
  1106. //判断参数是否合法
  1107. if (string.IsNullOrEmpty(userids))
  1108. {
  1109. return Json(new string[] { });
  1110. }
  1111. IList<ContactDocExt> users = new List<ContactDocExt>();
  1112. DataTable dt = new DataTable();
  1113. string result = string.Empty;
  1114. if (GoodsId == null || GoodsId == "")
  1115. {
  1116. return Json(new String[] { "" });
  1117. }
  1118. GoodsId = GoodsId.Replace(",", "','");
  1119. List<string> superior_list = new List<string>(0);
  1120. Dictionary<string, PushStorLimit> gapnum = new Dictionary<string, PushStorLimit>();
  1121. #region 获取 供应商
  1122. string commandTextContact = "Select D.* From GSRELAT A " +
  1123. " join SupplyDOC B on A.SuppliersId = B.SuppliersId and A.EntId=B.EntId and B.Beactive = 'Y'" +
  1124. " join BusinessDOC C on C.BusinessId=B.SuppliersId and C.Is_Supp = 'Y' and A.EntId=C.EntId " +
  1125. " join ContactDoc D on C.BusinessId = D.BusinessId and A.EntId=D.EntId " +
  1126. " Where A.Beactive = 'Y' and A.IsFreeze = 'N' " +
  1127. " and A.GoodsId = @GoodsId " +
  1128. " and D.UserId=@UserId";
  1129. string resultContact;
  1130. List<List<Object>> parametersContact = new List<List<Object>>();
  1131. if (PushAccountId != null && PushAccountId != "")
  1132. {
  1133. parametersContact.Add(new List<Object>() { "UserId", PushAccountId });
  1134. DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
  1135. }
  1136. #endregion
  1137. if( dt!=null && dt.Rows.Count > 0)
  1138. {
  1139. users = (List<ContactDocExt>)ModelConvertHelper<ContactDocExt>.ConvertToModel(dt);
  1140. }
  1141. IList<Option> options = new List<Option>();
  1142. foreach (ContactDocExt role in users)
  1143. {
  1144. var option = new Option()
  1145. {
  1146. label = role.BusinessName,
  1147. //value = (role.UserId==null)? "" :role.UserId.Trim(),
  1148. value = role.BusinessId,
  1149. disabled = (role.BusinessId == null || role.BusinessId.Trim() == "") ? true : false
  1150. };
  1151. options.Add(option);
  1152. }
  1153. return Json(options);
  1154. }
  1155. }
  1156. }