|
|
using Dapper;
|
|
|
using Estsh.Core.Controllers;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Services.IServices;
|
|
|
using Estsh.Core.Util;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using System.Collections;
|
|
|
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:配置管理
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 配置管理
|
|
|
/// </summary>
|
|
|
public class ModelPartController : BaseController
|
|
|
{
|
|
|
private IModelPartService service;
|
|
|
public ModelPartController(IModelPartService _service)
|
|
|
{
|
|
|
service = _service;
|
|
|
}
|
|
|
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取配置管理列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="ModelPartName">菜单名称</param>
|
|
|
/// <param name="pager">分页</param>
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
/// <param name="sort">排序列</param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getModelPartListByPage(string cmbTypeName, string cmbModelName, Pager pager, String direction, String sort, String enabled = "Y")
|
|
|
{
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
Hashtable dataHt = this.service.getModelPartListByPage(cmbTypeName, cmbModelName, enabled, pager, direction, sort);
|
|
|
result.Add("rows", dataHt["dataList"]);
|
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
|
result.Add("sort", sort);
|
|
|
result.Add("direction", direction);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectModelPart()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> ModelPartList = this.service.getSelectModelPart();
|
|
|
result.Add("list", ModelPartList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveModelPart()
|
|
|
{
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
|
|
|
String modelId = Request.Form["modelId"].ToString();
|
|
|
String modelCode = Request.Form["modelCode"].ToString();
|
|
|
String modelType = Request.Form["modelType"].ToString();
|
|
|
String modelName = Request.Form["modelName"].ToString();
|
|
|
String modelAlias = Request.Form["modelAlias"].ToString();
|
|
|
String modelDesc = Request.Form["modelDesc"].ToString();
|
|
|
String modelTypeId = Request.Form["modelTypeId"].ToString();
|
|
|
String pdline1 = Request.Form["pdline1"].ToString();
|
|
|
String pdline2 = Request.Form["pdline2"].ToString();
|
|
|
|
|
|
SysModel model = new SysModel();
|
|
|
model.ModelCode = modelCode;
|
|
|
model.ModelType = modelType;
|
|
|
model.ModelName = modelName;
|
|
|
model.ModelAlias = modelAlias;
|
|
|
model.ModelDesc = modelDesc;
|
|
|
model.ModelTypeId = Convert.ToInt32(modelTypeId);
|
|
|
model.Pdline1 =Convert.ToInt32( pdline1);
|
|
|
model.Pdline2 = Convert.ToInt32(pdline2);
|
|
|
|
|
|
SysPart partmodel = new SysPart();
|
|
|
partmodel.ModelName = modelName;
|
|
|
|
|
|
|
|
|
String message = "";
|
|
|
string flag = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
model.ModelId =Convert.ToInt32( modelId);
|
|
|
partmodel.ModelId = Convert.ToInt32(modelId);
|
|
|
|
|
|
model.UpdateUserId = CurrentEmp.EmpId;
|
|
|
int return_value =this.service.updateModelPart(model);
|
|
|
if (return_value > 0)
|
|
|
{
|
|
|
partmodel.UpdateUserId = CurrentEmp.EmpId;
|
|
|
this.service.updateModelPart_Sys_part(partmodel);
|
|
|
message = "修改成功";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "更新配置零件号失败";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
model.CreateUserId = CurrentEmp.EmpId;
|
|
|
int return_value = this.service.saveModelPart(model);
|
|
|
if (return_value > 0)
|
|
|
{
|
|
|
partmodel.CreateUserId = CurrentEmp.EmpId;
|
|
|
this.service.saveModelPart_Sys_part(partmodel);
|
|
|
message = "添加成功";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "新增配置零件号失败";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
result.Add("flag", flag);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看详情
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getModelPart(String ModelPart_id)
|
|
|
{
|
|
|
//List<SysModel> ModelPartInfo = this.service.getModelPart(ModelPart_id);
|
|
|
////Hashtable htModelPartInfo = (Hashtable)ModelPartInfo[0];
|
|
|
//ViewData.Add("partId", ModelPartInfo[0]["partId"]);
|
|
|
//ViewData.Add("cust_order", htModelPartInfo["cust_order"]);
|
|
|
//ViewData.Add("ship_unit", htModelPartInfo["ship_unit"]);
|
|
|
|
|
|
return View("viewModelPart");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editModelPart(String modelId)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(modelId))
|
|
|
{
|
|
|
List<SysModel> ModelPartInfo = this.service.getModelPart(modelId);
|
|
|
//Hashtable htModelPartInfo = (Hashtable)ModelPartInfo[0];
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("modelCode", ModelPartInfo[0].ModelCode);
|
|
|
ViewData.Add("modelType", ModelPartInfo[0].ModelType);
|
|
|
ViewData.Add("modelName", ModelPartInfo[0].ModelName);
|
|
|
ViewData.Add("modelAlias", ModelPartInfo[0].ModelAlias);
|
|
|
ViewData.Add("modelDesc", ModelPartInfo[0].ModelDesc);
|
|
|
ViewData.Add("modelTypeId", ModelPartInfo[0].ModelTypeId);
|
|
|
ViewData.Add("modelId", ModelPartInfo[0].ModelId);
|
|
|
ViewData.Add("pdline1", ModelPartInfo[0].Pdline1);
|
|
|
ViewData.Add("pdline2", ModelPartInfo[0].Pdline2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
|
|
|
return View("EditModelPart");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteModelPart(String ids)
|
|
|
{
|
|
|
//String enabled = Request["enabled"].ToString();
|
|
|
//if (enabled == "1")
|
|
|
//{
|
|
|
// return Json("该配置状态不能删除。");
|
|
|
//}
|
|
|
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteModelPart(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onEnable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.EnableData(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onDisable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.DisableData(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 变更状态
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onState(String modelId , String enabled)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.onState(modelId,enabled,CurrentEmp.EmpId.ToString());
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
public ActionResult uploadFile()
|
|
|
{
|
|
|
return View("uploadFile");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 车型
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetTypeName()
|
|
|
{
|
|
|
Hashtable ht = new Hashtable();
|
|
|
List<KeyValueResult> alType = service.GetTypeName();
|
|
|
ht.Add("list", alType);
|
|
|
return Json(ht);
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 配置
|
|
|
/// </summary>
|
|
|
/// <param name="typeName"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetModelName(string typeName)
|
|
|
{
|
|
|
Hashtable ht = new Hashtable();
|
|
|
List<KeyValueResult> alModel = service.GetModelName(typeName);
|
|
|
ht.Add("list", alModel);
|
|
|
return Json(ht);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导出数据到Excel
|
|
|
/// </summary>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="txtOrderNo"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="isPage"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult exportData(string cmbTypeName, string cmbModelName, string txtEnabled, Pager pager, String sort, String direction, String isPage)
|
|
|
{
|
|
|
|
|
|
Boolean paging = false;
|
|
|
if (isPage == null || "".Equals(isPage))
|
|
|
{
|
|
|
paging = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if ("1".Equals(isPage.Trim()))
|
|
|
{
|
|
|
paging = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
paging = false;
|
|
|
}
|
|
|
}
|
|
|
Hashtable dataHt = this.service.getModelPartListByPage2(cmbTypeName, cmbModelName, txtEnabled, pager, direction, sort);//txtOrderNo, pager, direction, sort, paging
|
|
|
List<ModelPart> listHt = (List<ModelPart>)dataHt["dataList"];
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "配置管理.xls");
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导入Excel文件
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult importModelTypeInfo()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
IFormFile file = Request.Form.Files[0];
|
|
|
List<ModelPart> data = ExcelHelper.GetList<ModelPart>(file, 0);
|
|
|
result = service.ImportExcel(data, CurrentEmp.EmpId);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|