using System; using Learun.Util; using System.Data; using Learun.Application.TwoDevelopment.AssetManagementSystem; using System.Web.Mvc; using System.Collections.Generic; using System.Linq; using Learun.Application.Base.SystemModule; using Learun.Application.Organization; namespace Learun.Application.Web.Areas.AssetManagementSystem.Controllers { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创 建:超级管理员 /// 日 期:2019-03-29 11:27 /// 描 述:在册登记明细 /// public class Ass_AssetsInfoItemController : MvcControllerBase { private Ass_AssetsInfoItemIBLL ass_AssetsInfoItemIBLL = new Ass_AssetsInfoItemBLL(); private DataItemIBLL dataItemIBLL = new DataItemBLL(); private DataSourceIBLL dataSourceIBLL = new DataSourceBLL(); private DepartmentIBLL departmentIBLL = new DepartmentBLL(); private UserIBLL userIBLL = new UserBLL(); private Ass_AssetsTypeIBLL ass_AssetsTypeIBLL = new Ass_AssetsTypeBLL(); #region 视图功能 /// /// 主页面 /// /// [HttpGet] public ActionResult Index() { return View(); } /// /// 主页面 /// /// [HttpGet] public ActionResult IndexTwo() { return View(); } [HttpGet] public ActionResult IndexOfMy() { return View(); } /// /// 表单页 /// /// [HttpGet] public ActionResult Form() { ViewBag.NewCode = CommonHelper.CreateNo(); return View(); } [HttpGet] public ActionResult FormView() { return View(); } [HttpGet] public ActionResult IndexScrap() { return View(); } [HttpGet] public ActionResult QRPrint() { return View(); } #endregion #region 获取数据 /// /// 获取页面显示列表数据 /// /// 查询参数 /// [HttpGet] [AjaxOnly] public ActionResult GetPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = ass_AssetsInfoItemIBLL.GetPageList(paginationobj, queryJson); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } /// /// 导出 /// /// 查询参数 /// [HttpPost, ValidateInput(false)] public ActionResult ExportList(string queryJson) { var exportTable = ass_AssetsInfoItemIBLL.GetExportList(queryJson); //exportTable.Columns.Add("REnabledName", typeof(string)); //exportTable.Columns.Add("AIASSStateName", typeof(string)); var dataItem_REnabled = dataItemIBLL.GetDetailList("RoomState"); var dataItem_sldw = dataItemIBLL.GetDetailList("sldw"); var dataItem_AssState = dataItemIBLL.GetDetailList("AssState"); var departmentList = departmentIBLL.GetAllList(); var userList = userIBLL.GetAllList(); var ass_AssetsTypeList = ass_AssetsTypeIBLL.GetAllList(); var dataSourceEntity = dataSourceIBLL.GetEntityByCode("BaseUser"); for (int i = 0; i < exportTable.Rows.Count; i++) { var REnabled = exportTable.Rows[i]["REnabled"]; if (REnabled != null && !string.IsNullOrEmpty(REnabled.ToString())) { exportTable.Rows[i]["renabledname"] = dataItem_REnabled.Where(x => x.F_ItemValue == REnabled.ToString()).FirstOrDefault()?.F_ItemName; } var AIUnits = exportTable.Rows[i]["AIUnits"]; if (AIUnits != null && !string.IsNullOrEmpty(AIUnits.ToString())) { exportTable.Rows[i]["AIUnits"] = dataItem_sldw.FirstOrDefault(x => x.F_ItemValue == AIUnits.ToString())?.F_ItemName; } var AIASSState = exportTable.Rows[i]["AIASSState"]; if (AIASSState != null && !string.IsNullOrEmpty(AIASSState.ToString())) { exportTable.Rows[i]["AIASSStateName"] = dataItem_AssState.FirstOrDefault(x => x.F_ItemValue == AIASSState.ToString())?.F_ItemName; } var AIDepartment = exportTable.Rows[i]["AIDepartment"]; if (AIDepartment != null && !string.IsNullOrEmpty(AIDepartment.ToString())) { exportTable.Rows[i]["AIDepartment"] = departmentList.FirstOrDefault(x => x.F_DepartmentId == AIDepartment.ToString())?.F_FullName; } var AIUsePeople = exportTable.Rows[i]["AIUsePeople"]; if (AIUsePeople != null && !string.IsNullOrEmpty(AIUsePeople.ToString())) { exportTable.Rows[i]["AIUsePeople"] = userList.Where(x=>x.F_UserId== AIUsePeople.ToString()).FirstOrDefault()?.F_RealName; } var AIASSClass = exportTable.Rows[i]["AIASSClass"]; if (AIASSClass != null && !string.IsNullOrEmpty(AIASSClass.ToString())) { exportTable.Rows[i]["AIASSClass"] = ass_AssetsTypeList.Where(x => x.ATId == AIASSClass.ToString()).FirstOrDefault()?.AName; } } departmentList = null; //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); //excelconfig.Title = " 资产数据"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 20; excelconfig.FileName = "在册登记资产数据导出.xls"; excelconfig.IsAllSizeColumn = true; excelconfig.ColumnEntity = new List(); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aicodenumjy", ExcelColumn = "资产编号" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiistoragename", ExcelColumn = "楼宇名称" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "rcode", ExcelColumn = "房间号" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "rfunction", ExcelColumn = "房间功能" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "rarea", ExcelColumn = "房间面积" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "renabledname", ExcelColumn = "房间状态" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiassname", ExcelColumn = "资产名称" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiassclass", ExcelColumn = "资产分类" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aispecification", ExcelColumn = "资产品牌" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aispecificationtype", ExcelColumn = "规格型号" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiunits", ExcelColumn = "计量单位" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiassstatename", ExcelColumn = "资产状态" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aidepartment", ExcelColumn = "管理部门" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiusepeople", ExcelColumn = "使用人" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiplace", ExcelColumn = "存放地点" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiassvalue", ExcelColumn = "资产原价值" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiaddtime", ExcelColumn = "入账日期" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "airemark", ExcelColumn = "备注" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "depreciationmethod", ExcelColumn = "折旧方法" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "depreciationstatus", ExcelColumn = "折旧状态" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "usefullife", ExcelColumn = "折旧年限" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "monthlydepreciation", ExcelColumn = "月折旧额" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "monthsofdepreciation", ExcelColumn = "已提折旧月数" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "monthlydepreciationrate", ExcelColumn = "月折旧率" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "accumulateddepreciation", ExcelColumn = "累计折旧" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "networth", ExcelColumn = "净值" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "vehiclelicenseuser", ExcelColumn = "车辆行驶证所有人" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aivehiclenumber", ExcelColumn = "车辆识别号" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiplatenumber", ExcelColumn = "车牌号" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aibuiltarea", ExcelColumn = "面积" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "aiownership", ExcelColumn = "权属证号" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "landusetype", ExcelColumn = "土地使用权类型" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "landuseuser", ExcelColumn = "土地使用权人/房屋所有权人" }); //调用导出方法 ExcelHelper.ExcelDownload(exportTable, excelconfig); return Success("导出成功"); } /// /// 获取左侧树形数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetTree() { var data = ass_AssetsInfoItemIBLL.GetTree(); return Success(data); } /// /// 获取资产类别树 /// /// [HttpGet] [AjaxOnly] public ActionResult GetTypeTree() { var data = ass_AssetsInfoItemIBLL.GetAssTypeTree(); return Success(data); } /// /// 获取列表不带分页 /// /// /// [HttpGet] [AjaxOnly] public ActionResult GetList(string queryJson) { var data = ass_AssetsInfoItemIBLL.GetList(queryJson); return Success(data); } /// /// 获取表单数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetFormData(string keyValue) { if (!keyValue.Contains(",")) { var Ass_AssetsInfoItemData = ass_AssetsInfoItemIBLL.GetAss_AssetsInfoItemEntity(keyValue); var jsonData = new { Ass_AssetsInfoItem = Ass_AssetsInfoItemData, }; return Success(jsonData); } else { var Ass_AssetsInfoItemData = ass_AssetsInfoItemIBLL.GetDatas(keyValue); var jsonData = new { Ass_AssetsInfoItem = Ass_AssetsInfoItemData, }; return Success(jsonData); } } /// /// 获取表单数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetData(string keyValue) { var result = ass_AssetsInfoItemIBLL.GetAss_AssetsInfoByAIId(keyValue); return Success(result); } /// /// 获取表单数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetDatas(string keyValue) { var result = ass_AssetsInfoItemIBLL.GetDatas(keyValue); List list = new List(); foreach (var item in result) { var entity = new Ass_ScrapItemEntity(); entity.AAIAId = item.AIId; entity.AAICode = item.AICode; entity.AAIName = item.AIASSName; entity.AAIStorage = item.AIIStorageId; entity.AAILocation = item.AIIStoragePosition; entity.AAITId = item.AIASSClass; entity.AAIModel = item.AISpecificationtype; entity.AAIManufacturer = item.AIBrand; entity.AAIContent = item.AIAssValue.ToString(); list.Add(entity); } return Success(list); } #endregion #region 提交数据 /// /// 删除实体数据 /// 主键 /// /// [HttpPost] [AjaxOnly] public ActionResult DeleteForm(string keyValue) { ass_AssetsInfoItemIBLL.DeleteEntity(keyValue); return Success("删除成功!"); } [HttpPost] [AjaxOnly] public ActionResult ScrapForm(string keyValue) { ass_AssetsInfoItemIBLL.ScrapEntity(keyValue); return Success("报废成功!"); } [HttpPost] [AjaxOnly] public ActionResult UnScrapForm(string keyValue) { ass_AssetsInfoItemIBLL.UnScrap(keyValue); return Success("报废成功!"); } /// /// 保存实体数据(新增、修改) /// 主键 /// /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveForm(string keyValue, string strEntity) { Ass_AssetsInfoItemEntity entity = strEntity.ToObject(); ass_AssetsInfoItemIBLL.SaveEntity(keyValue, entity); return Success("保存成功!"); } #endregion } }