using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using AutoMapper;
|
using AngleSharp.Html.Parser;
|
using DTO;
|
using IServices;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.Bot.Builder.Integration.AspNet.Core;
|
using Microsoft.Extensions.Logging;
|
using Newtonsoft.Json;
|
using System.Net.Http;
|
using System.Threading.Tasks;
|
using zhengcaioa.Models;
|
using zhengcaioa.IService;
|
using CommonToolsCore;
|
using Services;
|
|
namespace zhengcaioa.Controllers.BusinessOrder
|
{
|
|
public class OrderBanciController : Controller
|
{
|
private readonly ILogger<OrderBanciController> _logger;
|
private readonly ILiaotianService _liaotianService;
|
private readonly IOrderBanciService _orderBanciService;
|
private readonly IOrderBanciDtlService _orderBanciDtlService;
|
|
|
public OrderBanciController(ILogger<OrderBanciController> logger, ILiaotianService liaotianService, IOrderBanciService orderBanciService, IOrderBanciDtlService orderBanciDtlService)
|
{
|
_logger = logger;
|
_liaotianService = liaotianService;
|
_orderBanciService = orderBanciService;
|
_orderBanciDtlService = orderBanciDtlService;
|
}
|
|
[CheckLogin]
|
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;
|
|
|
|
|
|
return View();
|
|
}
|
[CheckLogin]
|
public IActionResult GetList(OrderBanciDTOSearch search)
|
{
|
//JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver());
|
return new JsonResult(_orderBanciService.SearchByPaging(search));
|
}
|
[CheckLogin]
|
public IActionResult Edit(string id = null)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
|
OrderBanciDTO dto = new OrderBanciDTO();
|
if (!String.IsNullOrEmpty(id))
|
{
|
dto = _orderBanciService.Get(id);
|
if (dto.Shijian.HasValue)
|
{
|
dto.ShijianName = dto.Shijian.Value.ToString("yyyy-MM-dd HH:mm");
|
}
|
if (dto.Shijianend.HasValue)
|
{
|
dto.ShijianendName = dto.Shijianend.Value.ToString("yyyy-MM-dd HH:mm");
|
}
|
|
}
|
else
|
{
|
dto.Shijian = DateTime.Now;
|
dto.ShijianName = dto.Shijian.Value.ToString("yyyy-MM-dd HH:mm");
|
dto.Shijianend = DateTime.Now;
|
dto.ShijianendName = dto.Shijianend.Value.ToString("yyyy-MM-dd HH:mm");
|
}
|
|
|
|
|
|
|
|
|
|
|
ViewData.Model = dto;
|
return View();
|
}
|
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <param name="data">岗位实体类对象</param>
|
/// <returns></returns>
|
///
|
[CheckLogin]
|
[HttpPost]
|
public IActionResult Save(OrderBanciDTO 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 = _orderBanciService.save(data);
|
|
return new JsonResult(resultEntity);
|
}
|
|
|
/// <summary>
|
/// 删除主信息
|
/// </summary>
|
/// <param name="info">实体</param>
|
/// <returns></returns>
|
///
|
[CheckLogin]
|
public IActionResult Nullify(string Id = "")
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
return new JsonResult(_orderBanciService.ModifyStatus(Id, curentuser.Id));
|
}
|
|
|
|
|
|
[CheckLogin]
|
public IActionResult IndexDtl(string OrderBanciId)
|
{
|
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.OrderBanciId = OrderBanciId;
|
|
|
|
return View();
|
|
}
|
[CheckLogin]
|
public IActionResult GetListDtl(OrderBanciDtlDTOSearch search)
|
{
|
//JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver());
|
return new JsonResult(_orderBanciDtlService.SearchByPaging(search));
|
}
|
[CheckLogin]
|
public IActionResult EditDtl(string id = null,string OrderBanciId = null)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
|
OrderBanciDtlDTO dto = new OrderBanciDtlDTO();
|
if (!String.IsNullOrEmpty(id))
|
{
|
dto = _orderBanciDtlService.Get(id);
|
|
|
}
|
else
|
{
|
dto.OrderBanciId = OrderBanciId;
|
}
|
|
|
|
ViewData["shangxiawu"] = _liaotianService.GetSYScode("order_banci_order", "kechengleixing_id");
|
|
|
|
|
|
|
ViewData.Model = dto;
|
return View();
|
}
|
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <param name="data">岗位实体类对象</param>
|
/// <returns></returns>
|
///
|
[CheckLogin]
|
[HttpPost]
|
public IActionResult SaveDtl(OrderBanciDtlDTO 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 = _orderBanciDtlService.save(data);
|
|
return new JsonResult(resultEntity);
|
}
|
|
|
/// <summary>
|
/// 删除主信息
|
/// </summary>
|
/// <param name="info">实体</param>
|
/// <returns></returns>
|
///
|
[CheckLogin]
|
public IActionResult NullifyDtl(string Id = "")
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
return new JsonResult(_orderBanciDtlService.ModifyStatus(Id, curentuser.Id));
|
}
|
|
|
|
//获取当前的培训
|
public IActionResult GetBanCi()
|
{
|
ReturnMsg<OrderBanciDTO> returnMsg = new ReturnMsg<OrderBanciDTO>();
|
returnMsg.code = 2;
|
try
|
{
|
OrderBanciDTOSearch search = new OrderBanciDTOSearch();
|
search.page = 1;
|
search.rows = 1000;
|
search.Createtime = DateTime.Now.Date.ToString();
|
ResultDataEntity < OrderBanciDTO > resultDataEntity = _orderBanciService.SearchByPaging(search);
|
var ssss = resultDataEntity.DataList.OrderBy(x=>x.Shijian).FirstOrDefault();
|
|
if (ssss != null)
|
{
|
var sysCodeDtls = _liaotianService.GetSYScode("order_banci_dtl", "shangxiawu");
|
List<OrderBanciDtlDTO> orderBanciDtlDTOs = _orderBanciDtlService.GetList(ssss.Id);
|
if(orderBanciDtlDTOs!=null&& orderBanciDtlDTOs.Count > 0)
|
{
|
foreach (var orderBanciDtlDTO in orderBanciDtlDTOs)
|
{
|
var sysCodeDtl = sysCodeDtls.Where(x => x.CodeSn == orderBanciDtlDTO.Shangxiawu).FirstOrDefault();
|
if (sysCodeDtl != null)
|
{
|
orderBanciDtlDTO.ShangxiawuName = sysCodeDtl.Comments;
|
}
|
}
|
}
|
|
|
ssss.orderBanciDtlDTOs = orderBanciDtlDTOs;
|
returnMsg.code = 1;
|
returnMsg.count = 1;
|
returnMsg.returnObj = ssss;
|
}
|
|
|
|
|
}
|
catch (Exception ex)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有获取到token";
|
returnMsg.count = 0;
|
|
}
|
return new JsonResult(returnMsg);
|
}
|
|
|
public IActionResult GetBanciAll(string id)
|
{
|
ReturnMsg<OrderBanciDTO> returnMsg = new ReturnMsg<OrderBanciDTO>();
|
returnMsg.code = 2;
|
try
|
{
|
var orderBanciDTO = _orderBanciService.GetAll(id);
|
if (orderBanciDTO==null)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有查询到班次";
|
returnMsg.count = 0;
|
}
|
else
|
{
|
OrderBanciDtlDTOSearch searchEntity = new OrderBanciDtlDTOSearch();
|
searchEntity.page = 1;
|
searchEntity.rows = 1000;
|
searchEntity.OrderBanciId = id;
|
orderBanciDTO.orderBanciDtlDTOs = _orderBanciDtlService.SearchByPaging(searchEntity).DataList;
|
returnMsg.code = 1;
|
returnMsg.count = 1;
|
returnMsg.returnObj = orderBanciDTO;
|
}
|
|
}
|
catch (Exception ex)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有获取到token";
|
returnMsg.count = 0;
|
|
}
|
return new JsonResult(returnMsg);
|
|
|
}
|
|
|
|
|
|
//获取当前的培训
|
public IActionResult GetJifenBanciList()
|
{
|
ReturnMsg<List<OrderBanciDTO>> returnMsg = new ReturnMsg<List<OrderBanciDTO>>();
|
returnMsg.code = 2;
|
try
|
{
|
|
List<OrderBanciDTO> orderBanciDTOs = _orderBanciService.GetJifenBanciList();
|
|
|
|
returnMsg.code = 1;
|
returnMsg.count = orderBanciDTOs.Count;
|
returnMsg.returnObj = orderBanciDTOs;
|
|
|
|
|
|
}
|
catch (Exception ex)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有获取到token";
|
returnMsg.count = 0;
|
|
}
|
return new JsonResult(returnMsg);
|
}
|
}
|
}
|