using Microsoft.AspNetCore.Mvc;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using Microsoft.Extensions.Logging;
|
using IServices;
|
using DTO;
|
using Newtonsoft.Json;
|
using zhengcaioa.Models;
|
using Microsoft.AspNetCore.Http;
|
using zhengcaioa.IService;
|
using System.IO;
|
using Microsoft.Extensions.Configuration;
|
|
namespace zhengcaioa.Controllers.Expert
|
{
|
[CheckLogin]
|
public class ExpertController : Controller
|
{
|
private readonly ILogger<ExpertController> _logger;
|
private readonly IExpertService _expertService;
|
private readonly ILiaotianService _liaotianService;
|
private readonly IProjectService _projectService;
|
private readonly IUserService _userService;
|
public ExpertController(ILogger<ExpertController> logger, IExpertService expertService, IProjectService projectService, ILiaotianService liaotianService, IUserService userService)
|
{
|
_logger = logger;
|
_expertService = expertService;
|
_projectService = projectService;
|
_liaotianService = liaotianService;
|
_userService = userService;
|
}
|
public IActionResult Index()
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
List<ActionEntity> actionlist = new List<ActionEntity>();
|
ActionEntity actionEntity = new ActionEntity();
|
actionEntity.OpenType = 0;
|
actionEntity.ActionUrl = "";
|
actionEntity.ActionFun = "Search";
|
actionEntity.PageIco = "fa fa-search";
|
actionEntity.ActionName = "查询";
|
actionlist.Add(actionEntity);
|
ActionEntity actionEntity1 = new ActionEntity();
|
actionEntity1.OpenType = 0;
|
actionEntity1.ActionUrl = "";
|
actionEntity1.ActionFun = "Add";
|
actionEntity1.PageIco = "fa fa-plus";
|
actionEntity1.ActionName = "新增";
|
actionlist.Add(actionEntity1);
|
ViewData["ActionInfo"] = actionlist;
|
|
ViewBag.expertType = _liaotianService.GetSYScode("experts", "expertType").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
ViewBag.level = _liaotianService.GetSYScode("experts", "level").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
ViewBag.Province = _projectService.Getsheng().Select(x => new { code = x.CodeId, label = x.Name }).ToList();
|
// ViewBag.City = _projectService.Getshi( ).Select(x => new { code = x.CodeId, label = x.Name }).ToList();
|
ViewBag.ReviewItem = _liaotianService.GetSYScode("experts", "ReviewItem").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
return View();
|
}
|
|
#region 查询
|
[CheckLogin]
|
public string GetList(ExpertDTOSearch search)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
search.ShenheStatus = "A";
|
ViewData["curentuser"] = curentuser;
|
return JsonConvert.SerializeObject(_expertService.SearchByPaging(search));
|
}
|
#endregion
|
|
|
#region 编辑
|
|
public ActionResult Edit(string id = null)
|
{
|
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
List<ActionEntity> actionlist = new List<ActionEntity>();
|
ActionEntity actionEntity = new ActionEntity();
|
actionEntity.OpenType = 0;
|
actionEntity.ActionUrl = "";
|
actionEntity.ActionFun = "Save";
|
actionEntity.PageIco = "glyphicon glyphicon-ok";
|
actionEntity.ActionName = "保存";
|
actionlist.Add(actionEntity);
|
|
ViewData["ActionInfo"] = actionlist;
|
|
ExpertDTO expertDTO = new ExpertDTO();
|
if (!string.IsNullOrEmpty(id))
|
{
|
expertDTO = _expertService.Get(id);
|
}
|
else
|
{
|
expertDTO.Province = "510000";
|
expertDTO.City = "510100";
|
}
|
// var sheng = _projectService.Getsheng();
|
|
|
ViewBag.InfoSource = _liaotianService.GetSYScode("CooperatecustomCustomer", "khly");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
ViewBag.sex = _liaotianService.GetSYScode("plt_user", "sex");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
ViewBag.expertType = _liaotianService.GetSYScode("experts", "expertType");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
ViewBag.level = _liaotianService.GetSYScode("experts", "level");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
ViewBag.ReviewItem = _liaotianService.GetSYScode("experts", "ReviewItem");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
|
|
ViewBag.Province = _projectService.Getsheng();//.Select(x => new { code = x.CodeId, label = x.Name }).ToList();
|
ViewBag.City = _projectService.Getshi(expertDTO.Province);//.Select(x => new { code = x.CodeId, label = x.Name }).ToList();
|
ViewData.Model = expertDTO;
|
return View();
|
}
|
|
|
|
/// <summary>
|
/// 图片上传
|
/// </summary>
|
/// <returns></returns>
|
public string UploadImage()
|
{
|
var files = Request.Form.Files;
|
if (files.Count == 0)
|
{
|
return "File does not exist!";
|
}
|
var file = files[0];
|
string fileName = file.FileName;
|
if (string.IsNullOrEmpty(fileName))//服务器是否存在该文件
|
{
|
return "File does not exist!";
|
}
|
// 获取上传的图片名称和扩展名称
|
string fileFullName = Path.GetFileName(file.FileName);
|
string fileExtName = Path.GetExtension(fileFullName);
|
|
|
string imgPath = string.Format("{0}\\wwwroot\\{1}\\", Directory.GetCurrentDirectory(), "UploadFile");
|
|
var newPath = fileFullName.Substring(0, fileFullName.IndexOf(fileExtName)) + System.DateTime.UtcNow.Ticks + fileExtName;
|
var src = imgPath + newPath;
|
|
// 如果目录不存在则要先创建
|
if (!Directory.Exists(imgPath))
|
{
|
Directory.CreateDirectory(imgPath);
|
}
|
using (FileStream fs = System.IO.File.Create(src))
|
{
|
file.CopyTo(fs);
|
fs.Flush();
|
}
|
// imgPath = string.Format("~/UploadFile/{0}", fileFullName);
|
return newPath;
|
}
|
|
public string Get(string id = null)
|
{
|
ExpertDTO expertDTO = new ExpertDTO();
|
if (!String.IsNullOrEmpty(id))
|
{
|
expertDTO = _expertService.Get(id);
|
}
|
|
return JsonConvert.SerializeObject(expertDTO);
|
}
|
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <param name="data">岗位实体类对象</param>
|
/// <returns></returns>
|
[HttpPost]
|
|
public string Save(ExpertDTO data)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
data.ShenheStatus = "A";
|
data.ReviewItem = data.ReviewItemSelect;
|
data.RecStatus = "A";
|
if (String.IsNullOrEmpty(data.Id))
|
{
|
data.Creater = curentuser.Id;
|
data.Createtime = DateTime.Now;
|
}
|
data.Modifier = curentuser.Id;
|
data.Modifytime = DateTime.Now;
|
|
ResultEntity resultEntity = _expertService.save(data);
|
|
return JsonConvert.SerializeObject(resultEntity);
|
}
|
#endregion
|
|
|
|
|
|
|
/// <summary>
|
/// 删除主信息
|
/// </summary>
|
/// <param name="info">实体</param>
|
/// <returns></returns>
|
///
|
|
public string Nullify(string Id = "")
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
return JsonConvert.SerializeObject(_expertService.ModifyStatus(Id, curentuser.Id));
|
}
|
|
|
#region 推广记录
|
/// <summary>
|
/// 取得推广记录列表
|
/// </summary>
|
/// <param name="search"></param>
|
/// <returns></returns>
|
[CheckLogin]
|
public string GetPromoteList(ExpertPromoteDTOSearch search)
|
{
|
return JsonConvert.SerializeObject(_expertService.SearchExpPromote(search));
|
}
|
|
/// <summary>
|
/// 查看推广记录
|
/// </summary>
|
/// <param name="experId"></param>
|
/// <returns></returns>
|
[CheckLogin]
|
public IActionResult Promote(string experId)
|
{
|
// ViewData["curentuser"] = curentuser;
|
List<ActionEntity> actionlist = new List<ActionEntity>();
|
ActionEntity actionEntity = new ActionEntity();
|
actionEntity.OpenType = 0;
|
actionEntity.ActionUrl = "";
|
actionEntity.ActionFun = "Search";
|
actionEntity.PageIco = "fa fa-search";
|
actionEntity.ActionName = "查询";
|
actionlist.Add(actionEntity);
|
ViewData["ActionInfo"] = actionlist;
|
ViewData["experId"] = experId;
|
ViewBag.users = _userService.GetList().Select(x => new { code = x.Id, label = x.UserSn }).ToList();
|
return View();
|
}
|
|
/// <summary>
|
/// 新增推广记录
|
/// </summary>
|
/// <param name="experId"></param>
|
/// <returns></returns>
|
[CheckLogin]
|
public IActionResult EditPromote(string experId)
|
{
|
ViewData["experId"] = experId;
|
return View();
|
}
|
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <param name="data">保存推广记录</param>
|
/// <returns></returns>
|
[HttpPost]
|
public string SavePromte(ExpertPromoteDTO data)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
data.RecStatus = "A";
|
if (String.IsNullOrEmpty(data.Id))
|
{
|
data.Creater = curentuser.Id;
|
data.Createtime = DateTime.Now;
|
}
|
data.Modifier = curentuser.Id;
|
data.Modifytime = DateTime.Now;
|
|
ResultEntity resultEntity = _expertService.SaveExpPromote(data);
|
|
return JsonConvert.SerializeObject(resultEntity);
|
}
|
#endregion
|
|
#region 专家派工
|
public IActionResult ExpertOrderDispatch()
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
List<ActionEntity> actionlist = new List<ActionEntity>();
|
ActionEntity actionEntity = new ActionEntity();
|
actionEntity.OpenType = 0;
|
actionEntity.ActionUrl = "";
|
actionEntity.ActionFun = "Search";
|
actionEntity.PageIco = "fa fa-search";
|
actionEntity.ActionName = "查询";
|
actionlist.Add(actionEntity);
|
ViewData["ActionInfo"] = actionlist;
|
|
ViewBag.OrderType = _liaotianService.GetSYScode("CooperVisit", "jtype").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
ViewBag.users = _userService.GetList().Where(x => x.IsYwjl == "A").Select(x => new { code = x.Id, label = x.UserName }).ToList();
|
|
ViewBag.Khlx = _liaotianService.GetSYScode("CooperatecustomCustomer", "khlx").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
|
ViewBag.HuifangStatus = _liaotianService.GetSYScode("CooperOrder", "huifang_status").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
|
ViewBag.PingjiaStatus = _liaotianService.GetSYScode("CooperOrder", "pingjia_status").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
|
return View();
|
}
|
|
public string GetOrderList(ExpertOrderDipatchDTOSearch search)
|
{
|
return JsonConvert.SerializeObject(_expertService.SearchOrderDispatch(search));
|
}
|
public IActionResult Dispatch(string orderid)
|
{
|
|
List<ExpertDTO> list = _expertService.GetList();
|
ViewData["experts"] = list;
|
ViewBag.OrderId = orderid;
|
return View();
|
}
|
public string SaveDispatch(ExpertOrderDipatchDTO data)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
data.RecStatus = "A";
|
if (String.IsNullOrEmpty(data.Id))
|
{
|
data.Creater = curentuser.Id;
|
data.Createtime = DateTime.Now;
|
}
|
data.Modifier = curentuser.Id;
|
data.Modifytime = DateTime.Now;
|
|
ResultEntity resultEntity = _expertService.SaveDispatch(data);
|
|
return JsonConvert.SerializeObject(resultEntity);
|
}
|
#endregion
|
|
|
|
|
|
|
|
}
|
}
|