123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326 |
- using JCSoft.WX.Framework.Api;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Common.Wechat;
- using Common;
- using System.Data;
- using ZcPeng.PublicLibrary;
- using CoreEntity.Entity;
- using Common.Model;
- using Newtonsoft.Json.Converters;
- using Newtonsoft.Json;
- using CoreEntity.DAL;
- using System.Data.SqlClient;
- using PublicLibrary.Model;
- using Microsoft.Extensions.Caching.Memory;
- using System.Globalization;
- using Npoi.Mapper;
- using System.IO;
- using Microsoft.AspNetCore.Hosting;
- using SupplierWeb.Codes.mvc;
- namespace SupplierWeb.Controllers
- {
- [Route("web/supply")]
- public class SupplyController : BaseController
- {
- public SupplyController(IMemoryCache cache, IApiClient client) : base(cache, client)
- {
- }
- //(业务员)查看采购需求推送记录-所有记录
- [AuthPermission]
- [HttpPost, Route("pushrecord/{staffId}")]
- public ActionResult PushRecord(QueryFilter[] filters, Int32 pageIndex, Int32 pageSize,
- string sortField, Int32 sortDirection, string[] sumFields,
- string staffId,
- [FromBody]dynamic data,
- bool timeout = false,
- bool belowlimit = false,
- bool all = true)
- {
- string userids;
- userids = getStaffUserid(staffId);
- //判断参数是否合法
- if (string.IsNullOrEmpty(userids))
- {
- return Json(new
- {
- items = new string[] { },
- sum = new { },
- totalCount = -1,
- timeout = 1,
- });
- }
- if (data != null)
- {
- //Newtonsoft.Json.Linq.JArray
- filters = data.filters.ToObject<QueryFilter[]>();
- pageIndex = data.pageIndex;
- pageSize = data.pageSize;
- sortField = data.sortField;
- sortDirection = data.sortDirection;
- sumFields = data.sumFields.ToObject<string[]>();
- }
- #region 获取推送记录
- DataTable dt = new DataTable();
- string result;
- //filter参数
- string filterstr = "";
- List<SqlParameter> parameters = new List<SqlParameter>();
- filterstr += QueryFilter.getFilterSqlParam(filters, out parameters,new PushRecordExt(),"A.");
- if (filterstr.Contains("AccountRealName"))
- {
- filterstr = filterstr.Replace("and A.AccountRealName", "and B.AccountRealName");
- }
- if (timeout)
- filterstr += " and datediff( hour, A.CreationTime, getdate() ) >= 6";
- if (belowlimit)
- filterstr += " and exists (select A1.PushRecordId from " + Config.TablePrefix + "PushFeedback A1 where A1.PushRecordId = A.Id and A1.State=2)";
- if (all)
- filterstr += "";
- string direct = " desc ";
- if (sortDirection != 1)
- direct = " asc";
- int start = (pageIndex - 1) * pageSize;
- int end = (start + 1 + pageSize);
- string commandText0 = "select * from ";
- string commandText1 = "(" +
- "select A.*,B.AccountRealName,row_number() over" +
- "( order by " + sortField + " " + direct + " ) as rownum from " +
- Config.TablePrefix + "PushRecord as A " +
- " left join "+Config.TablePrefix+ "Account B on B.Id = A.PushAccountId "+
- " where 1=1 " +
- " and A.PushAccountId = '"+ userids + "'" +
- //" and exists(" + " select 1 from " + Config.TablePrefix + "PushFeedback A " +
- // " where A.PushRecordId = B.Id and A.PushAccountId = '"+ userids + "') " +
- //" and exists(" + " select 1 from " + Config.TablePrefix + "PushFeedback A " +
- // " where A.PushRecordId = B.Id and A.PushAccountId = '"+ userids + "') " +
- filterstr +
- ")AAA ";
- string commandText2 = " where AAA.rownum>" + start + " and AAA.rownum<" + end;
-
- bool success = DataAccess.GetValues(commandText0 + commandText1 + commandText2, ref dt, parameters.ToArray(), out result);
- // 把DataTable转换为IList<UserInfo>
- IList<PushRecordExt> users = new List<PushRecordExt>();
- if (dt != null && dt.Rows.Count > 0)
- {
- // 把DataTable转换为IList<UserInfo>
- users = ModelConvertHelper<PushRecordExt>.ConvertToModel(dt);
- }
- #endregion
- IsoDateTimeConverter timejson = new IsoDateTimeConverter
- {
- DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
- };
- var jsonData = JsonConvert.SerializeObject(users, timejson);
- string result1;
- string commandTextCount = "select count(Id) from " + commandText1;
- long totalcount = DataAccess.GetRowCountDefine(commandTextCount, parameters.ToArray(), out result1);
- return Json(new
- {
- items = JsonConvert.DeserializeObject(jsonData),
- sum = new { },
- totalCount = totalcount
- });
- }
- //(业务员)查看采购需求推送记录-最新明细
- [AuthPermission]
- [HttpPost, Route("pushfeedback/{staffId}")]
- public ActionResult PushFeedback(QueryFilter[] filters, Int32 pageIndex, Int32 pageSize,
- string sortField, Int32 sortDirection, string[] sumFields,
- string staffId,
- [FromBody]dynamic data,
- bool all = false)
- {
- string userids;
- userids = getStaffUserid(staffId);
- //判断参数是否合法
- if (string.IsNullOrEmpty(userids))
- {
- return Json(new
- {
- items = new string[]{ },
- sum = new { },
- totalCount = -1,
- timeout = 1,
- });
- }
- if (data != null)
- {
- //Newtonsoft.Json.Linq.JArray
- filters = data.filters.ToObject<QueryFilter[]>();
- pageIndex = data.pageIndex;
- pageSize = data.pageSize;
- sortField = data.sortField;
- sortDirection = data.sortDirection;
- sumFields = data.sumFields.ToObject<string[]>();
- }
- #region 获取推送记录明细
- DataTable dt = new DataTable();
- string result;
- string direct = " desc ";
- if (sortDirection != 1)
- direct = " asc";
- String filterstr = " ";
- //filter参数
- if (all)
- filterstr += "";
- else
- filterstr += " AND ((State = 0 OR State IS NULL) OR ( State in(5,6) ))" +
- " AND IsCancel = 0 ";//不包含取消的;
- filterstr += " AND PushAccountId = " + userids ;
- List<List<Object>> parameters = new List<List<Object>>();
- parameters.Add(new List<Object>() { "PushFbAccountId", Convert.ToInt32(userids) });
- List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
- filterstr += QueryFilter.getFilterSqlParam(filters, out parameters1, new PushFeedback(),"A.");
- //if (filterstr.IndexOf("PushRecordId") <0)
- //{
- // return Json(new
- // {
- // items = new string[] { ""},
- // sum = new { },
- // totalCount = 0
- // });
- //}
- int start = (pageIndex - 1) * pageSize;
- int end = (start + 1 + pageSize);
- string commandText0 = "select * from (";
- string commandText1 = "select A.*," +
- " E.Unit,F.WmsMeas," +
- " row_number() over" +
- "( order by " + sortField + " " + direct + " ) as rownum from " +
- Config.TablePrefix + "PushFeedback A " +
- " left join PGPrice E on E.EntId = A.EntId and E.GoodsId = A.GoodsId " +
- " left join GoodsAttr F on F.EntId = A.EntId and F.GoodsId = A.GoodsId " +
- " where 1=1 " +
- filterstr +
- ")AAA ";
- string commandText = commandText0 + commandText1 + " where AAA.rownum>" + start + " and AAA.rownum<" + end;
- bool success = DataAccess.GetValues(commandText, ref dt, parameters1.ToArray(), out result);
- //result = DataAccess.GetDataTable(Config.TablePrefix + "PushFeedback", "Id", "*", fieldFilter, "", sortField + direct, pageIndex, pageSize != 0 ? pageSize : Config.PageSize);
- // 把DataTable转换为IList<UserInfo>
- IList<PushFeedbackExt> users = new List<PushFeedbackExt>();
- if (dt != null && dt.Rows.Count > 0)
- {
- // 把DataTable转换为IList<UserInfo>
- users = ModelConvertHelper<PushFeedbackExt>.ConvertToModel(dt);
- foreach (PushFeedbackExt pfbe in users)
- {
- pfbe.ContactId = pfbe.ContactId.Trim() + "_" + pfbe.SuppliersId.Trim() + "_" + pfbe.PushAccountId;
- }
- }
- #endregion
- IsoDateTimeConverter timejson = new IsoDateTimeConverter
- {
- DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
- };
- var jsonData = JsonConvert.SerializeObject(users, timejson);
- string result1;
- string commandTextCount = "select count(*) from (" + commandText1;
- long totalcount = DataAccess.GetRowCountDefine(commandTextCount, parameters1.ToArray(), out result1);
- return Json(new
- {
- items = JsonConvert.DeserializeObject(jsonData),
- sum = new { },
- totalCount = totalcount
- });
- }
- [AuthPermission]
- [HttpPost, Route("exportexcel")]
- public ActionResult exportExcel([FromServices]IHostingEnvironment env, string RecordId,string staffId)
- {
- string userids;
- userids = getStaffUserid(staffId);
- //判断参数是否合法
- if (string.IsNullOrEmpty(userids))
- {
- return Json(new { success = false,
- msg = "没有登陆"
- });
- }
- #region 获取推送记录明细
- DataTable dt = new DataTable();
- string result;
- string direct = " desc ";
- if (0 != 1)
- direct = " asc";
- //filter参数
- String filterstr = " ((State = 0 OR State IS NULL) OR ( State in(5,6)))" +
- " AND PushAccountId = " + userids +
- " AND IsCancel = 0 " +
- " AND PushRecordId = @RecordId ";//不包含取消的
- List<List<Object>> parameters = new List<List<Object>>();
- parameters.Add(new List<Object>() { "PushFbAccountId", Convert.ToInt32(userids) });
- parameters.Add(new List<Object>() { "RecordId", RecordId });
- List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
- string commandText0 = "select * from (";
- string commandText1 = "select A.*,B.ApprovalNo, row_number() over" +
- "( order by A.SuppliersId " + direct + " ) as rownum from " +
- Config.TablePrefix + "PushFeedback A " +
- " left join GoodsAttr B on A.GoodsId = B.GoodsId and B.EntId = A.EntId " +
- " where " +
- filterstr +
- ")AAA ";
- string commandText = commandText0 + commandText1 ;
- bool success = DataAccess.GetValues(commandText, ref dt, parameters1.ToArray(), out result);
- //result = DataAccess.GetDataTable(Config.TablePrefix + "PushFeedback", "Id", "*", fieldFilter, "", sortField + direct, pageIndex, pageSize != 0 ? pageSize : Config.PageSize);
- // 把DataTable转换为IList<UserInfo>
- IList<PushFeedbackExcel> users = new List<PushFeedbackExcel>();
- if (dt != null && dt.Rows.Count > 0)
- {
- // 把DataTable转换为IList<UserInfo>
- users = ModelConvertHelper<PushFeedbackExcel>.ConvertToModel(dt);
-
- }
- #endregion
- var mapper = new Mapper();
- var fileName = Path.Combine("excel", RecordId+"_"+DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx");
- mapper
- .Map<PushFeedbackExcel>("Id", o => o.Id)
- .Map<PushFeedbackExcel>("推送汇总Id", o => o.PushRecordId)
- .Map<PushFeedbackExcel>("推送编码", o => o.Pushcode)
- .Map<PushFeedbackExcel>("品名", o => o.GoodsName)
- .Map<PushFeedbackExcel>("产品编码", o => o.GoodsCode)
- .Map<PushFeedbackExcel>("产品规格", o => o.GoodsSpec)
- .Map<PushFeedbackExcel>("厂家", o => o.Manufacturer)
- .Map<PushFeedbackExcel>("国药准字号", o => o.ApprovalNo)
- .Map<PushFeedbackExcel>("供应商名", o => o.BusinessName)
- .Map<PushFeedbackExcel>("产品实际价格", o => o.PurPrice)
- .Map<PushFeedbackExcel>("产品标准价格", o => o.ActPrice)
- .Map<PushFeedbackExcel>("供应数量", o => o.StoreGapNum)
- .Map<PushFeedbackExcel>("总需求数量", o => o.PurchaseTotalNum)
- .Map<PushFeedbackExcel>("备注", o => o.Feedback)
- .Save(Path.Combine(env.WebRootPath, fileName), users, "newSheet", overwrite: true);
- byte[] fileBytes = System.IO.File.ReadAllBytes(Path.Combine(env.WebRootPath, fileName));
- System.IO.File.Delete(env.WebRootPath +Path.DirectorySeparatorChar+ fileName);
- return File(fileBytes, "application/ms-excel", DateTime.Now.ToString("MMddHHmmss") + ".xlsx");
- }
- // 处理文件
- // fil = files;
- /*var file = Request.Form.Files;
- long size = files.Sum(f => f.Length);
- string webRootPath = env.WebRootPath;
- string contentRootPath = env.ContentRootPath;
- List<string> listfile = new List<string>();
- foreach (var formFile in files)
- {
- string suffix = formFile.FileName.Split('.')[1];
- if (formFile.Length > 0 && suffix == "xlsx")
- {
- string fileExt = "xlsx";
- /// string fileExt = GetFileExt(formFile.FileName); //文件扩展名,不含“.”
- long fileSize = formFile.Length; //获得文件大小,以字节为单位
- string newFileName = System.Guid.NewGuid().ToString() + "." + fileExt; //随机生成新的文件名
- var filePath = webRootPath + "/excel/" + formFile.FileName;
- var mapper = new Mapper(formFile.OpenReadStream());
- var objectInfos = mapper.Take<PushFeedbackExcel>("newSheet");
- List<DataAccessCommand> list = new List<DataAccessCommand>();
- string result;
- foreach (RowInfo< PushFeedbackExcel> e in objectInfos)
- {
- #region 更新数据
- string commandText = "UPDATE " + Config.TablePrefix + "PushFeedback " +
- "SET StoreGapNum = @StoreGapNum, " +
- " Feedback = @Feedback, " +
- " State = 1 " +
- " ) A" +
- " WHERE Id= @Id" +
- " AND PushAccountId = " + userids;
- //准备参数
- List<List<Object>> parameters = new List<List<Object>>();
- parameters.Add(new List<Object>() { "StoreGapNum", e.Value.StoreGapNum });
- parameters.Add(new List<Object>() { "Feedback", e.Value.Feedback });
- parameters.Add(new List<Object>() { "Id", e.Value.Id });
- List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
- list.Add(new DataAccessCommand(commandText, parameters1, CommandType.Text, true));
- //int success = DataAccess.ExecuteCommand(commandText, parameters1, out result);
- #endregion
- }
- bool success = DataAccess.ExecuteBatchCommands(list, out result);
- //mapper.Save(filePath);
- //using (var stream = new FileStream(filePath, FileMode.Create))
- //{
- // await formFile.OpenReadStream().CopyToAsync(stream);
- //}
- listfile.Add(filePath);
- }
- }*/
- /// <summary>
- /// 导入excel,提报供货数量
- /// </summary>
- /// <param name="files"></param>
- /// <returns></returns>
- [AuthPermission]
- [HttpPost, Route("excelsave")]
- //public async Task<IActionResult> ExcelSave([FromServices]IHostingEnvironment env,
- //List<IFormFile> files,
- public ActionResult ExcelSave([FromServices]IHostingEnvironment env,
- string files,
- string staffId,
- [FromBody]dynamic data)
- {
- string userids;
- userids = getStaffUserid(staffId);
- //判断参数是否合法
- if (string.IsNullOrEmpty(userids))
- {
- return Json(new
- {
- success = false,
- msg = "没有登陆"
- });
- }
- if (data != null)
- {
- files = data.files;
- }
- if (files != null && files.Split('.').Length >= 2) {
- string suffix = files.Split('.')[1];
- if (suffix != "xlsx")
- {
- return Json(new
- {
- success = false,
- msg = "格式错误"
- });
- }
- }
- else
- {
- return Json(new
- {
- success = false,
- msg = "格式错误"
- });
- }
- string webRootPath = env.WebRootPath;
- //string contentRootPath = env.ContentRootPath;
- var filePath = webRootPath + Path.DirectorySeparatorChar + files.Replace('/', Path.DirectorySeparatorChar);
- var mapper = new Mapper(filePath);
- var objectInfos = mapper
- .Map<PushFeedbackExcel>("Id", o => o.Id, (column, target) => // tryTake resolver : Custom logic to take cell value into target object.
- {
- // Note: return false to indicate a failure; and that will increase error count.
- if (column.HeaderValue == null || column.CurrentValue == null) return false;
- if (!(column.CurrentValue is string)) return false;
- var index = column.Attribute.Index;
- if ((index == 0))
- {
- ((PushFeedbackExcel)target).Id = Guid.Parse((string)column.CurrentValue);
- return true;
- }
- if ((index == 1))
- {
- ((PushFeedbackExcel)target).PushRecordId = Guid.Parse((string)column.CurrentValue);
- return true;
- }
- return true;
- })
- .Map<PushFeedbackExcel>("推送汇总Id", o => o.PushRecordId, (column, target) => // tryTake resolver : Custom logic to take cell value into target object.
- {
- // Note: return false to indicate a failure; and that will increase error count.
- if (column.HeaderValue == null || column.CurrentValue == null) return false;
- if (!(column.CurrentValue is string)) return false;
- var index = column.Attribute.Index;
- if ((index == 0))
- {
- ((PushFeedbackExcel)target).Id = Guid.Parse((string)column.CurrentValue);
- return true;
- }
- if ((index == 1))
- {
- ((PushFeedbackExcel)target).PushRecordId = Guid.Parse((string)column.CurrentValue);
- return true;
- }
- return true;
- })
- .Map<PushFeedbackExcel>("备注", o => o.Feedback, (column, target) => // tryTake resolver : Custom logic to take cell value into target object.
- {
- // Note: return false to indicate a failure; and that will increase error count.
- if (column.HeaderValue == null || column.CurrentValue == null) return false;
- if (!(column.CurrentValue is string))
- {
- if((column.CurrentValue is double))
- column.CurrentValue = DateTime.FromOADate((double)column.CurrentValue);
- }
- var index = column.Attribute.Index;
- if ((index == 3))
- {
- ((PushFeedbackExcel)target).Feedback = column.CurrentValue.ToString();
- return true;
- }
- return true;
- })
- .Map<PushFeedbackExcel>("推送编码", o => o.Pushcode)
- .Map<PushFeedbackExcel>("品名", o => o.GoodsName)
- .Map<PushFeedbackExcel>("产品编码", o => o.GoodsCode)
- .Map<PushFeedbackExcel>("产品规格", o => o.GoodsSpec)
- .Map<PushFeedbackExcel>("厂家", o => o.Manufacturer)
- .Map<PushFeedbackExcel>("国药准字号", o => o.ApprovalNo)
- .Map<PushFeedbackExcel>("供应商名", o => o.BusinessName)
- .Map<PushFeedbackExcel>("产品实际价格", o => o.PurPrice)
- .Map<PushFeedbackExcel>("产品标准价格", o => o.ActPrice)
- .Map<PushFeedbackExcel>("供应数量", o => o.StoreGapNum)
- .Map<PushFeedbackExcel>("总需求数量", o => o.PurchaseTotalNum)
- .Map<PushFeedbackExcel>("备注", o => o.Feedback)
- //.Map(
- //column => // column filter : Custom logic to determine whether or not to map and include an unmapped column.
- //{
- // var index = column.Attribute.Index;
- // if ((index == 0)|| (index == 1))
- // {
- // return true;
- // }
- // return false;
- //},
- //(column, target) => // tryTake resolver : Custom logic to take cell value into target object.
- //{
- // // Note: return false to indicate a failure; and that will increase error count.
- // if (column.HeaderValue == null || column.CurrentValue == null) return false;
- // if (!(column.CurrentValue is string)) return false;
- // var index = column.Attribute.Index;
- // if ((index == 0))
- // {
- // ((PushFeedbackExcel)target).Id = Guid.Parse((string)column.CurrentValue);
- // return true;
- // }
- // if ((index == 1))
- // {
- // ((PushFeedbackExcel)target).PushRecordId = Guid.Parse((string)column.CurrentValue);
- // return true;
- // }
- // return true;
- //},
- //(column, source) => // tryPut resolver : Custom logic to put property value into cell.
- //{
- // // Custom logic to set the cell value.
- // var sample = (PushFeedbackExcel)source;
- // if((column.Attribute.Index == 0))
- // {
- // column.CurrentValue = sample.Id.ToString();
- // }
- // if ((column.Attribute.Index == 1))
- // {
- // column.CurrentValue = sample.PushRecordId.ToString();
- // }
- // return true;
- //}
- //)
- .Take<PushFeedbackExcel>("newSheet");
- List<DataAccessCommand> list = new List<DataAccessCommand>();
- Dictionary<string, Object> mapHasUpdated = new Dictionary<string, object>();
- string result;
- foreach (RowInfo<PushFeedbackExcel> e in objectInfos)
- {
- if (e.Value.StoreGapNum.Equals(0))
- {
- var pfb = PushFeedBackDAL.GetFeedback(e.Value.Id.ToString());
- //string contactid = "";
- //if (pfb.ContactId.Split("_").Length > 0)
- // contactid = pfb.ContactId.Split("_")[0];
- ContactDAL.UpdatePushContactState(pfb.GoodsId, pfb.ContactId, pfb.SuppliersId.Trim(), "N");
- }
- #region 更新明细数据
- string commandText = "UPDATE " + Config.TablePrefix + "PushFeedback " +
- "SET StoreGapNum = @StoreGapNum, " +
- " Feedback = @Feedback, " +
- (e.Value.StoreGapNum<e.Value.PurchaseTotalNum? " State = 2 " : " State = 1 ") +
- " WHERE Id= @Id" +
- " AND PushAccountId = " + userids +
- " AND State = 0";
- //准备参数
- List<List<Object>> parameters = new List<List<Object>>();
- parameters.Add(new List<Object>() { "StoreGapNum", e.Value.StoreGapNum });
- parameters.Add(new List<Object>() { "Feedback", e.Value.Feedback });
- parameters.Add(new List<Object>() { "Id", e.Value.Id });
- List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
- list.Add(new DataAccessCommand(commandText, parameters1, CommandType.Text, true));
- //int success = DataAccess.ExecuteCommand(commandText, parameters1, out result);
- if (!mapHasUpdated.ContainsKey(e.Value.PushRecordId.ToString())) {
- //int successState = PushRecordDAL.SubmitState(userids, Id);
- #region 更新记录状态
- string commandTextState = "UPDATE " + Config.TablePrefix + "PushRecord " +
- " SET SubmitTime = @SubmitTime, " +
- " SubmitPerson = @SubmitPerson, " +
- " State = 1 " +
- " WHERE id= @PushRecordId" +
- " AND PushAccountId = " + userids +
- " AND State = 0";
- //string resultState;
- //准备参数
- List<List<Object>> parametersState = new List<List<Object>>();
- parametersState.Add(new List<Object>() { "SubmitTime", DateTime.Now });
- parametersState.Add(new List<Object>() { "SubmitPerson", userids });
- parametersState.Add(new List<Object>() { "PushRecordId", e.Value.PushRecordId });
- List<SqlParameter> parametersState1 = DataAccess.ToParameters(parametersState);
- list.Add(new DataAccessCommand(commandTextState, parametersState1, CommandType.Text, true));
- //int successState = DataAccess.ExecuteCommand(commandTextState, parametersState1, out resultState);
- #endregion
- mapHasUpdated.Add(e.Value.PushRecordId.ToString(), e.Value);
- }
- #endregion
- }
- System.IO.File.Delete(filePath);
- #region 删除文件记录
- string commandTextD = "DELETE FROM " + Config.TablePrefix + "UPLOADFILES WHERE Path = @Path";
- //准备参数
- List<List<Object>> parametersD = new List<List<Object>>();
- parametersD.Add(new List<Object>() { "Path", files.Replace("\\","/") });
- string resultD = "";
- List<SqlParameter> parametersD1 = DataAccess.ToParameters(parametersD);
- int successDel = DataAccess.ExecuteCommand(commandTextD, parametersD1, out resultD);
- #endregion
- bool success = DataAccess.ExecuteBatchCommands(list, out result);
- return Json(new{success = success,
- data = result,
- successDel = successDel,
- resultD = resultD,
- });
- }
- ////根据采购计划提交供货情况:添加提交状态 时间
- [AuthPermission]
- [HttpPost, Route("editfeedback/{staffId}")]
- public JsonResult EditFeedback(string Id,
- string PushCode,
- Int32 StoreGapNum,string Feedback,
- string BusinessId, string BusinessCode, string BusinessName,
- string SuppliersId, string PushRecordId, Int32 PushAccountId,
- string staffId,
- [FromBody]dynamic data)
- {
- string userids;
- userids = getStaffUserid(staffId);
- //判断参数是否合法
- if (string.IsNullOrEmpty(userids))
- {
- return Json(new
- {
- success = 0
- });
- }
- PushAccountId = Convert.ToInt32(userids);
- if (data != null)
- {
- //Newtonsoft.Json.Linq.JArray
- Id = data.Id;
- StoreGapNum = data.StoreGapNum;
- Feedback = data.Feedback;
- BusinessId = data.BusinessId;
- BusinessCode = data.BusinessCode;
- BusinessName = data.BusinessName;
- SuppliersId = data.SuppliersId;
- PushRecordId = data.PushRecordId;
- PushCode = data.PushCode;
- }
- #region 更新数据
- string commandText = "UPDATE " + Config.TablePrefix + "PushFeedback " +
- "SET StoreGapNum = @StoreGapNum, " +
- " Feedback = @Feedback, " +
- " BusinessId = @BusinessId, " +
- " BusinessCode = @BusinessCode, " +
- " BusinessName = @BusinessName, " +
- " SuppliersId = @SuppliersId," +
- " State = 1 " +
- " WHERE id= @Id" +
- " AND PushAccountId = " + userids;
- string result;
- //准备参数
- List<List<Object>> parameters = new List<List<Object>>();
- parameters.Add(new List<Object>() { "StoreGapNum", StoreGapNum });
- parameters.Add(new List<Object>() { "Feedback", Feedback });
- parameters.Add(new List<Object>() { "BusinessId", BusinessId });
- parameters.Add(new List<Object>() { "BusinessCode", BusinessCode });
- parameters.Add(new List<Object>() { "BusinessName", BusinessName });
- parameters.Add(new List<Object>() { "SuppliersId", SuppliersId });
- parameters.Add(new List<Object>() { "Id", Id });
- List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
- int success = DataAccess.ExecuteCommand(commandText, parameters1, out result);
- #endregion
- int successState = PushRecordDAL.SubmitState(userids,Id);
- return Json(new
- {
- success = success,
- successState = successState
- });
- }
- ////查询已经确认的订单:采购员已确认 已生成计划单
- [AuthPermission]
- [HttpPost, Route("feedbackorder/{staffId}/{state}")]
- public ActionResult feedbackOrder(QueryFilter[] filters, Int32 pageIndex, Int32 pageSize,
- string sortField, Int32 sortDirection, string[] sumFields,
- string state,
- string staffId,
- [FromBody]dynamic data)
- {
- string userids;
- userids = getStaffUserid(staffId);
- //判断参数是否合法
- if (string.IsNullOrEmpty(userids))
- {
- return Json(new
- {
- items = new string[] { },
- sum = new { },
- totalCount = -1,
- timeout = 1,
- });
- }
- if (data != null)
- {
- //Newtonsoft.Json.Linq.JArray
- filters = data.filters.ToObject<QueryFilter[]>();
- pageIndex = data.pageIndex;
- pageSize = data.pageSize;
- sortField = data.sortField;
- sortDirection = data.sortDirection;
- sumFields = data.sumFields.ToObject<string[]>();
- }
- #region 获取feedback 采购员已确认 3
- DataTable dt = new DataTable();
- string result = "";
- string direct = " desc ";
- if (sortDirection != 1)
- direct = " asc";
- string statefilter = " and A.";
- if (state == "1")
- {
- statefilter += "State = 1 ";
- }
- else if (state == "2")
- {
- statefilter += "State = 2 ";
- }
- else if (state == "1,2")
- {
- statefilter += "State in (1,2) ";
- }
- else if (state == "3")
- {
- statefilter = " and (A.State = 3 or (A.State in(2) and A.StoreGapNum = 0 ))";
- }
- else if (state == "4")
- {
- statefilter = " and (A.State = 4 or (A.State in(2) and A.StoreGapNum = 0 ))";
- }
- else if (state == "5")
- {
- statefilter += "State = 5 ";
- statefilter += " AND A.IsCancel = 0 ";//不包含取消的
- }
- else
- {
- return Json(new
- {
- items = new string[] { },
- sum = new { },
- totalCount = -1
- });
- }
- List<SqlParameter> parameters = new List<SqlParameter>();
- var filterstr = QueryFilter.getFilterSqlParam(filters, out parameters, new PushFeedbackExt(), "A.");
- if (filterstr.IndexOf("AccountRealName") > 0)
- {
- filterstr = filterstr.Replace("and A.AccountRealName", "and B.AccountRealName");
- }
- if (filterstr.IndexOf("PurName") > 0)
- {
- filterstr = filterstr.Replace("and A.PurName", "and C.AccountRealName");
- }
- filterstr = filterstr.Replace("and A.ReceiptMd", "and D.ReceiptMd");
- filterstr = filterstr.Replace("and A.CentPayMd", "and D.CentPayMd");
- filterstr = filterstr.Replace("and A.RequestDate", "and case isdate(enddate)when 1 then convert(datetime,D.enddate, 20)else null end");
- filterstr = filterstr.Replace("A.IsPrepayI", " Case D.IsPrepay When 'Y' Then 1 Else 0 End ");
- filterstr = filterstr.Replace("A.PrepayAmt", "D.PrepayAmt");
- statefilter += filterstr + " and PushAccountId = " + userids;
- //if (state == "3")
- //{
- // if (statefilter.IndexOf("PushRecordId") < 0)
- // {
- // return Json(new
- // {
- // items = new string[] { },
- // sum = new { },
- // totalCount = -1
- // });
- // }
- //}
- int start = (pageIndex - 1) * pageSize;
- int end = (start + 1 + pageSize);
- string commandText0 = "select * from ";
- string commandText1 = "(" +
- "select A.*,B.AccountRealName,C.AccountRealName as PurName," +
- (state == "3" || state == "4" ? ("D.ReceiptMd,D.CentPayMd,"
- + "case isdate(enddate)when 1 then convert(datetime,D.enddate, 20)else null end as RequestDate," +
- "Case D.IsPrepay When 'Y' Then 1 Else 0 End IsPrepayI,D.PrepayAmt,") : ""
- ) +
- "E.Unit," +
- "row_number() over" +
- "( order by A." + sortField + " " + direct + " ) as rownum from " +
- Config.TablePrefix + "PushFeedback as A " +
- " left join " + Config.TablePrefix + "Account B on B.Id = A.PushAccountId " +
- " left join " + Config.TablePrefix + "Account C on C.Id = A.ConfirmPuchaser " +
- (state == "3" || state == "4" ?
- " left join PurPlanMT D on D.PushRecordId = A.PushRecordId and D.K_ContactId = A.ContactId and isnull(D.billstate,0) =0 " : "") +
- " left join PGPrice E on E.EntId = A.EntId and E.GoodsId = A.GoodsId" +
- " where 1=1 " +
- (state == "3"||state == "4"? " and isnull(D.billstate,0) =0 ":"")+
- statefilter +
- ")AAA ";
- string commandText2 = " where AAA.rownum>" + start + " and AAA.rownum<" + end;
- string commandText = commandText0 + commandText1 + commandText2;
- //result = DataAccess.GetDataTable(Config.TablePrefix + "PushFeedback", "Id", "*", statefilter, "", sortField + direct, pageIndex, pageSize != 0 ? pageSize : Config.PageSize);
- bool success = DataAccess.GetDataTable(commandText, dt,parameters.ToArray(),out result);
- #endregion
- // 把DataTable转换为IList<PushFeedbackExt>
- IList<PushFeedbackExt> feedbacks = new List<PushFeedbackExt>();
- if (dt!=null && dt.Rows.Count > 0)
- {
- feedbacks = ModelConvertHelper<PushFeedbackExt>.ConvertToModel(dt);
- foreach(PushFeedbackExt pfb in feedbacks)
- {
- if((state == "3" || state == "4" || state == "2") &&pfb.StoreGapNum == 0)
- {
- pfb.Remark = "如有货请及时联系采购员";
- }
- }
- }
- IsoDateTimeConverter timejson = new IsoDateTimeConverter
- {
- DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
- };
- var jsonData = JsonConvert.SerializeObject(feedbacks, timejson);
- string result1;
- long totalcount = DataAccess.GetRowCountDefine("select count(*) from "+ commandText1, parameters.ToArray(), out result1);
- return Json(new
- {
- items = JsonConvert.DeserializeObject(jsonData),
- sum = new { },
- totalCount = totalcount,
- result = result
- });
- }
- ///供应商业务员二次确认:生成采购订单 开发票
- ///1 供应商业务员确认(数量提交确认) 2 供应商业务员取消 3 采购员确认(生成计划)
- ///4 供应商业务员确认(二次确认 开票 生成采购订单)
- ///如果修改了数据(设置状态为2 按钮显示:修改并提交) 需要重新提交
- //[HttpPost, Route("confirmfeedback/{staffId}/{State:int}")]
- //public JsonResult ConfirmFeedback(string Id, Int32 StoreGapNum, string Feedback,
- // string BusinessId, string BusinessCode, string BusinessName,
- // string SuppliersId, string PushRecordId, Int32 PushAccountId,
- // Int32 State,
- // string staffId,
- // [FromBody]dynamic data)
- //{
- // string userids;
- // userids = getStaffUserid(staffId);
- // //判断参数是否合法
- // if (string.IsNullOrEmpty(userids))
- // {
- // return Json(new
- // {
- // success = 0
- // });
- // }
- // PushAccountId = Convert.ToInt32(userids);
- // if (data != null)
- // {
- // //Newtonsoft.Json.Linq.JArray
- // Id = data.Id;
- // StoreGapNum = data.StoreGapNum;
- // Feedback = data.Feedback;
- // BusinessId = data.BusinessId;
- // BusinessCode = data.BusinessCode;
- // BusinessName = data.BusinessName;
- // SuppliersId = data.SuppliersId;
- // PushRecordId = data.PushRecordId;
- // }
- // PushRecord rec = PushRecordDAL.GetRecord(PushRecordId);
- // if (rec != null && rec.HasOrder == 1)
- // return Json(new
- // {
- // success = 0,
- // msg = "已经生成采购订单!"
- // });
- // #region 待更新状态
- // string fieldTime = string.Empty;
- // string fieldPerson = string.Empty;
- // string fieldFilter = string.Empty;
- // int state = 0;
- // int successo0 = 0;
- // if (State == 2)//修改数据
- // {
- // fieldTime = "CancelTime";
- // fieldPerson = "CancelPerson";
- // state = 2;
- // fieldFilter = " AND ((State = 0 OR State IS NULL) OR ( State in(5,6)) )" +
- // " AND PushAccountId="+PushAccountId;
- // successo0 = 1;
- // PushFeedback pf = PushFeedBackDAL.GetFeedbacks(PushRecordId," and PushFeddbackId = '"+Id+"'").ToArray()[0];
- // if (StoreGapNum >= pf.PurchaseTotalNum)
- // {
- // return Json(new
- // {
- // success = 0,
- // msg = "不能超过最大采购值"
- // });
- // }
- // }
- // else if (State == 1)//提交供货数量信息
- // {
- // fieldTime = "SubmitTime";
- // fieldPerson = "SubmitPerson";
- // state = 1;
- // fieldFilter = " AND (State = 0 OR State IS NULL OR State in(5,6) )";
- // }
- // else if (State == 4)//生成采购订单
- // {
- // fieldTime = "ConfirmOrderTime";
- // fieldPerson = "ConfirmOrderPerson";
- // state = 4;
- // fieldFilter = " AND State = 3 ";
- // //查询 plan
- // #region 获取 plan
- // string commandTextContact = "Select * From " +Config.TablePrefix+"PushFeedback " +
- // "Where Id=@Id and PushAccountId = @PushAccountId and State = 3";
- // string resultContact;
- // DataTable dt = new DataTable();
- // PushFeedback feedback;
- // List<PushFeedback> feedbacks = new List<PushFeedback>();
- // List<List<Object>> parametersContact = new List<List<Object>>();
- // if (PushAccountId != 0)
- // {
- // parametersContact.Add(new List<Object>() { "Id", Id });
- // parametersContact.Add(new List<Object>() { "PushAccountId", PushAccountId });
- // DataAccess.GetValues(commandTextContact, ref dt,DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
- // }
- // #endregion
- // if (dt != null&&dt.Rows.Count>0)
- // {
- // feedbacks = (List<PushFeedback>)ModelConvertHelper<PushFeedback>.ConvertToModel(dt);
- // feedback = feedbacks.ToArray()[0];
- // PurPlanDT plandt = PurPlanDAL.GetPlanDT(Id).ToArray()[0];
- // PurPlanMT PlanMT = PurPlanDAL.GetPlanMT(rec.Id.ToString(),Id, PushAccountId, feedback.SuppliersId).ToArray()[0];
- // string reqdate = PlanMT.EndDate;
- // string StaffDocId = PlanMT.SaleManId;
- // IDictionary<string,Object> dic = PurOrderDAL.AddOrder(PushAccountId.ToString(),
- // PlanMT.BillNo.ToString()
- // , feedback.EntId, PlanMT.ReceiptMd, PlanMT.CentPayMd
- // , PlanMT.OrgId, PlanMT.DeptId
- // , "", feedback.Remark
- // , feedback.GoodsId, feedback.SuppliersId
- // , feedback.BusinessId, feedback.BusinessCode
- // , StaffDocId
- // , reqdate);
- // Object successo;
- // dic.TryGetValue("successRecord", out successo);
- // if ((int)successo > 0) {
- // Object OrderBillNo;
- // dic.TryGetValue("OrderBillNo",out OrderBillNo);
- // IDictionary<string,Object> dicODAdd= PurOrderDAL.AddOrderDT((Int32)OrderBillNo, 0,
- // PlanMT.BillNo, 0, PlanMT.BillCode,
- // PlanMT.GoodsId, feedback.GoodsSpec, feedback.StoreGapNum,
- // feedback.PurPrice,
- // PlanMT.Remark,
- // PlanMT.EntId, PlanMT.OrgId,
- // feedback.BusinessId, feedback.BusinessCode,
- // feedback.SuppliersId,
- // feedback.PurchaseTotalNum,
- // plandt.SafeDays
- // , StaffDocId);
- // Object successo1;
- // dicODAdd.TryGetValue("successRecord", out successo1);
- // if ((int)successo > 0 && (int)successo1 > 0) {
- // successo0 = 1;
- // //增加更新hasOrder 1 feedback记录的状态state
- // int successOState = PurOrderDAL.UpdateOrderState(Id, PushRecordId);
- // }
- // }
- // }
- // }
- // #endregion
- // #region 更新数据
- // string commandText = "UPDATE " + Config.TablePrefix + "PushFeedback " +
- // " SET StoreGapNum = StoreGapNum1, " +
- // " Feedback = Feedback1, " +
- // " BusinessId = BusinessId1, " +
- // " BusinessCode = BusinessCode1, " +
- // " BusinessName = BusinessName1, " +
- // " SuppliersId = SuppliersId1, " +
- // " State = " + state +
- // " FROM (SELECT " +
- // "@StoreGapNum as StoreGapNum1," +
- // "@Feedback as Feedback1," +
- // "@BusinessId as BusinessId1," +
- // "@BusinessCode as BusinessCode1," +
- // "@BusinessName as BusinessName1," +
- // "@SuppliersId as SuppliersId1" +
- // " ) A" +
- // " WHERE id= @Id" +
- // fieldFilter;
- // string result;
- // //准备参数
- // List<List<Object>> parameters = new List<List<Object>>();
- // parameters.Add(new List<Object>() { "StoreGapNum", StoreGapNum });
- // parameters.Add(new List<Object>() { "Feedback", Feedback });
- // parameters.Add(new List<Object>() { "BusinessId", BusinessId });
- // parameters.Add(new List<Object>() { "BusinessCode", BusinessCode });
- // parameters.Add(new List<Object>() { "BusinessName", BusinessName });
- // parameters.Add(new List<Object>() { "SuppliersId", SuppliersId });
- // parameters.Add(new List<Object>() { "Id", Id });
- // List<SqlParameter> parameters1 = DataAccess.ToParameters(parameters);
- // int success = DataAccess.ExecuteCommand(commandText, parameters1, out result);
- // #endregion
- // int successState = -1;
- // #region 更新记录状态
- // if (successo0 == 1) {
- // string commandTextState = "UPDATE " + Config.TablePrefix + "PushFeedback " +
- // " SET "+ fieldTime + " = "+ fieldTime + "1, " +
- // " " + fieldPerson + " = " + fieldPerson + "1, " +
- // " State = " + state +
- // " FROM (SELECT " +
- // "@" + fieldTime + " as " + fieldTime + "1," +
- // "@" + fieldPerson + " as " + fieldPerson + "1" +
- // " ) A" +
- // " WHERE id= @PushFeedbackId " +
- // fieldFilter;
- // string resultState;
- // //准备参数
- // List<List<Object>> parametersState = new List<List<Object>>();
- // parametersState.Add(new List<Object>() { fieldTime, DateTime.Now });
- // parametersState.Add(new List<Object>() { fieldPerson, PushAccountId });
- // parametersState.Add(new List<Object>() { "PushFeedbackId", Id });
- // List<SqlParameter> parametersState1 = DataAccess.ToParameters(parametersState);
- // successState = DataAccess.ExecuteCommand(commandTextState, parametersState1, out resultState);
- // }
- // #endregion
- // return Json(new
- // {
- // success = success,
- // successState = successState
- // });
- //}
- //////查询已提交的采购计划
- //[HttpGet,Route("purchaseorder")]
- //public ActionResult PurchaseOrder(string echostr, string signature, string timestamp, string nonce)
- //{
- // #region 获取Openid
- // //WechatHelper.ReGetOpenId(HttpContext);
- // #endregion
- // return View();
- //}
- ////查看采购单的入库明细
- [AuthPermission]
- [HttpGet,Route("orderstockin")]
- public ActionResult OrderStockIn(string echostr, string signature, string timestamp, string nonce)
- {
- #region 获取Openid
- //WechatHelper.ReGetOpenId(HttpContext);
- #endregion
- return Content("");
- }
- ////查看采购单的拒收,退回明细
- [AuthPermission]
- [HttpGet,Route("orderrefund")]
- public ActionResult OrderRefund(string echostr, string signature, string timestamp, string nonce)
- {
- #region 获取Openid
- //WechatHelper.ReGetOpenId(HttpContext);
- #endregion
- return Content("");
- }
- ////邮寄发票,登记发票物流单号,查看发票签收状态
- [AuthPermission]
- [HttpGet,Route("orderinvoice")]
- public ActionResult OrderInvoice(string echostr, string signature, string timestamp, string nonce)
- {
- #region 获取Openid
- //WechatHelper.ReGetOpenId(HttpContext);
- #endregion
- return Content("");
- }
- ////查看付款状态付款日期
- [AuthPermission]
- [HttpGet,Route("orderpayment")]
- public ActionResult OrderPayment(string echostr, string signature, string timestamp, string nonce)
- {
- #region 获取Openid
- //WechatHelper.ReGetOpenId(HttpContext);
- #endregion
- return View();
- }
- /////////////////////////////////////
- ////供应商业务员在有新品的情况下 可提报新品
- /**
- 分三种种情况:一是我方没有经营但品种库有的品种提交时需对应上我方的商品编码;
- 二是我方有经营但和此供应商没有业务往来,同第一种处理防水;
- 三是我方品种库没有品种直接录入基本信息(商品名称、商品规格、生产厂家、批准文号、件装数量、供货价格);
- */
- [AuthPermission]
- [HttpGet,Route("newproductsubmit")]
- public ActionResult NewProductSubmit(string echostr, string signature, string timestamp, string nonce)
- {
- #region 获取Openid
- //WechatHelper.ReGetOpenId(HttpContext);
- #endregion
- return View();
- }
- ////提交新品种首营资料(品种首营、供应商首营)
- [AuthPermission]
- [HttpGet,Route("newcategorydocsubmit")]
- public ActionResult NewCategoryDocSubmit(string echostr, string signature, string timestamp, string nonce)
- {
- #region 获取Openid
- //WechatHelper.ReGetOpenId(HttpContext);
- #endregion
- return View();
- }
- ////提交新品种
- [AuthPermission]
- [HttpGet,Route("newcategorysubmit")]
- public ActionResult NewCategorySubmit(string echostr, string signature, string timestamp, string nonce)
- {
- #region 获取Openid
- //WechatHelper.ReGetOpenId(HttpContext);
- #endregion
- return View();
- }
- ////列表
- //[HttpGet, Route("index")]
- //public ActionResult index(string[] filters, Int32 pageIndex, Int32 pageSize,
- // string sortField, Int32 sortDirection, string[] sumFields, string callback)
- //{
- // var r = this.indexp(filters, pageIndex, pageSize,
- // sortField, sortDirection, sumFields, null);
- // return Content(callback + "(" + JsonConvert.SerializeObject(r.Value)
- // + ")");
- //}
- ////业务员的供应商
- [AuthPermission]
- [HttpGet, Route("getcontacts")]
- public JsonResult GetContacts(string staffId,
- string GoodsId)
- {
- string userids;
- string PushAccountId = userids = getStaffUserid(staffId);
- //判断参数是否合法
- if (string.IsNullOrEmpty(userids))
- {
- return Json(new string[] { });
- }
- IList<ContactDocExt> users = new List<ContactDocExt>();
- DataTable dt = new DataTable();
- string result = string.Empty;
- if (GoodsId == null || GoodsId == "")
- {
- return Json(new String[] { "" });
- }
- GoodsId = GoodsId.Replace(",", "','");
- List<string> superior_list = new List<string>(0);
- Dictionary<string, PushStorLimit> gapnum = new Dictionary<string, PushStorLimit>();
- #region 获取 供应商
- string commandTextContact = "Select D.* From GSRELAT A " +
- " join SupplyDOC B on A.SuppliersId = B.SuppliersId and A.EntId=B.EntId and B.Beactive = 'Y'" +
- " join BusinessDOC C on C.BusinessId=B.SuppliersId and C.Is_Supp = 'Y' and A.EntId=C.EntId " +
- " join ContactDoc D on C.BusinessId = D.BusinessId and A.EntId=D.EntId " +
- " Where A.Beactive = 'Y' and A.IsFreeze = 'N' " +
- " and A.GoodsId = @GoodsId " +
- " and D.UserId=@UserId";
- string resultContact;
- List<List<Object>> parametersContact = new List<List<Object>>();
- if (PushAccountId != null && PushAccountId != "")
- {
- parametersContact.Add(new List<Object>() { "UserId", PushAccountId });
- DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
- }
- #endregion
- if( dt!=null && dt.Rows.Count > 0)
- {
- users = (List<ContactDocExt>)ModelConvertHelper<ContactDocExt>.ConvertToModel(dt);
- }
- IList<Option> options = new List<Option>();
- foreach (ContactDocExt role in users)
- {
- var option = new Option()
- {
- label = role.BusinessName,
- //value = (role.UserId==null)? "" :role.UserId.Trim(),
- value = role.BusinessId,
- disabled = (role.BusinessId == null || role.BusinessId.Trim() == "") ? true : false
- };
- options.Add(option);
- }
- return Json(options);
- }
- }
- }
|