@@ -1,8 +1,12 @@ | |||
using Learun.Util; | |||
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 | |||
{ | |||
@@ -16,6 +20,9 @@ namespace Learun.Application.Web.Areas.AssetManagementSystem.Controllers | |||
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(); | |||
#region 视图功能 | |||
@@ -92,6 +99,111 @@ namespace Learun.Application.Web.Areas.AssetManagementSystem.Controllers | |||
}; | |||
return Success(jsonData); | |||
} | |||
/// <summary> | |||
/// 导出 | |||
/// <summary> | |||
/// <param name="queryJson">查询参数</param> | |||
/// <returns></returns> | |||
[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 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"] = dataSourceIBLL.GetDataTable(dataSourceEntity, | |||
"t.f_userid='" + AIUsePeople.ToString() + "'"); | |||
} | |||
} | |||
departmentList = null; | |||
//设置导出格式 | |||
ExcelConfig excelconfig = new ExcelConfig(); | |||
//excelconfig.Title = " 资产数据"; | |||
excelconfig.TitleFont = "微软雅黑"; | |||
excelconfig.TitlePoint = 20; | |||
excelconfig.FileName = "在册登记资产数据导出.xls"; | |||
excelconfig.IsAllSizeColumn = true; | |||
excelconfig.ColumnEntity = new List<ColumnModel>(); | |||
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 = "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("导出成功"); | |||
} | |||
/// <summary> | |||
/// 获取左侧树形数据 | |||
/// <summary> | |||
@@ -95,6 +95,7 @@ | |||
<a id="lr_scrap" class="btn btn-default"><i class="fa fa-trash-o"></i> 报废</a> | |||
<a id="lr_detail" class="btn btn-default"><i class="fa fa-bars"></i> 查看出入记录</a> | |||
<a id="lr_usedetail" class="btn btn-default"><i class="fa fa-bars"></i> 查看使用人员记录</a> | |||
<a id="lr_exportexcel" class="btn btn-default"><i class="fa fa-sign-out"></i> 导出</a> | |||
</div> | |||
</div> | |||
</div> | |||
@@ -9,6 +9,7 @@ var AId = request("AId"); | |||
var TreeAIASSClass = ''; | |||
var currentUser = request("currentUser");//我的资产需要用到 | |||
var IsDelete = request("IsDelete");//报废资产需要使用 | |||
var exportWhere = ''; | |||
var bootstrap = function ($, learun) { | |||
"use strict"; | |||
var page = { | |||
@@ -41,6 +42,7 @@ var bootstrap = function ($, learun) { | |||
} | |||
}); | |||
$('#multiple_condition_query').lrMultipleQuery(function (queryJson) { | |||
exportWhere = queryJson; | |||
page.search(queryJson); | |||
}, 500, 400); | |||
$('#AIIStorageId').lrselect({ | |||
@@ -215,7 +217,11 @@ var bootstrap = function ($, learun) { | |||
}); | |||
} | |||
}); | |||
$('#lr_exportexcel').on('click', function () { | |||
page.exportExcel(); | |||
}); | |||
}, | |||
// 初始化列表 | |||
initGird: function () { | |||
@@ -470,6 +476,25 @@ var bootstrap = function ($, learun) { | |||
} | |||
param.AIIsScrap = false; | |||
$('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); | |||
}, | |||
exportExcel: function () { | |||
var param = exportWhere || {}; | |||
param.AId = AId; | |||
param.AIASSClass = TreeAIASSClass; | |||
if (currentUser) { | |||
var userInfo = top.learun.clientdata.get(['userinfo']); | |||
param.userId = userInfo.userId; | |||
} | |||
param.AIIsScrap = false; | |||
learun.download({ | |||
method: "POST", | |||
url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/ExportList', | |||
param: { | |||
queryJson: JSON.stringify(param) | |||
} | |||
}); | |||
//$('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); | |||
} | |||
}; | |||
refreshGirdData = function () { | |||
@@ -299,6 +299,25 @@ namespace Learun.Application.Base.SystemModule | |||
} | |||
} | |||
public IEnumerable<DataItemDetailEntity> GetAllDetailList() | |||
{ | |||
try | |||
{ | |||
return dataItemService.GetAllDetailList(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 获取数据字典详细映射数据 | |||
/// </summary> | |||
@@ -70,6 +70,7 @@ namespace Learun.Application.Base.SystemModule | |||
/// <param name="itemCode">分类编码</param> | |||
/// <returns></returns> | |||
List<DataItemDetailEntity> GetDetailList(string itemCode); | |||
IEnumerable<DataItemDetailEntity> GetAllDetailList(); | |||
/// <summary> | |||
/// 获取数据字典明显 | |||
/// </summary> | |||
@@ -149,6 +149,38 @@ namespace Learun.Application.Base.SystemModule | |||
#endregion | |||
#region 数据字典明细 | |||
/// <summary> | |||
/// 获取数据字典明细 | |||
/// </summary> | |||
/// <returns></returns> | |||
public IEnumerable<DataItemDetailEntity> GetAllDetailList() | |||
{ | |||
try | |||
{ | |||
StringBuilder strSql = new StringBuilder(); | |||
strSql.Append("SELECT " + @"t.F_ItemId, | |||
t.F_ParentId, | |||
t2.F_ItemCode, | |||
t.F_ItemName, | |||
t.F_ItemValue " + @" FROM LR_Base_DataItemDetail t | |||
INNER JOIN LR_Base_DataItem t2 ON t.F_ItemId = t2.F_ItemId | |||
WHERE t.F_DeleteMark = 0 and t.F_EnabledMark=1 Order By t.F_SortCode | |||
"); | |||
return this.BaseRepository().FindList<DataItemDetailEntity>(strSql.ToString()); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowServiceException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 获取数据字典明显根据分类编号 | |||
/// </summary> | |||
@@ -197,6 +197,51 @@ namespace Learun.Application.Base.SystemModule | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 获取数据源的数据 | |||
/// </summary> | |||
/// <param name="code">数据源编码</param> | |||
/// <param name="strWhere">sql查询条件语句</param> | |||
/// <param name="queryJson">查询条件</param> | |||
/// <returns></returns> | |||
public DataTable GetDataTable(DataSourceEntity entity, string strWhere, string queryJson = "{}") | |||
{ | |||
try | |||
{ | |||
if (entity == null) | |||
{ | |||
return new DataTable(); | |||
} | |||
else | |||
{ | |||
if (!string.IsNullOrEmpty(strWhere)) | |||
{ | |||
strWhere = " where " + strWhere; | |||
} | |||
else | |||
{ | |||
strWhere = ""; | |||
} | |||
var queryParam = queryJson.ToJObject(); | |||
string sql = string.Format(" select * From ({0})t {1} ", entity.F_Sql, strWhere); | |||
return databaseLinkIBLL.FindTable(entity.F_DbId, sql, queryParam); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 获取树形数据 | |||
/// </summary> | |||
@@ -59,6 +59,7 @@ namespace Learun.Application.Base.SystemModule | |||
/// <returns></returns> | |||
DataTable GetDataTable(string code, string strWhere, string queryJson = "{}"); | |||
DataTable GetDataTable(DataSourceEntity entity, string strWhere, string queryJson = "{}"); | |||
/// <summary> | |||
/// 获取树形数据 | |||
/// </summary> | |||
@@ -139,6 +139,26 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem | |||
} | |||
} | |||
} | |||
public DataTable GetExportList(string queryJson) | |||
{ | |||
try | |||
{ | |||
return ass_AssetsInfoItemService.GetExportList(queryJson); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 获取页面显示列表数据 | |||
/// <summary> | |||
@@ -23,6 +23,7 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem | |||
IEnumerable<Ass_AssetsInfoItemEntity> GetPageList(Pagination pagination, string queryJson); | |||
object GetList(string queryJson); | |||
DataTable GetExportList(string queryJson); | |||
/// <summary> | |||
/// 获取左侧树形数据 | |||
/// <summary> | |||
@@ -159,6 +159,133 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 获取页面显示列表数据 | |||
/// <summary> | |||
/// <param name="queryJson">查询参数</param> | |||
/// <returns></returns> | |||
public DataTable GetExportList(string queryJson) | |||
{ | |||
try | |||
{ | |||
var strSql = new StringBuilder(); | |||
strSql.Append(@"SELECT t.AICodeNumJY ,storage.sname as AIIStorageName,room.rcode,room.RFunction,room.RArea,'' as REnabledName,t.AIASSName,t.AISpecification, t.AISpecificationtype, t.AIUnits, '' as AIASSStateName,t.AIDepartment, t.AIUsePeople, AIPlace, AIAssValue,AIAddTime, AIRemark, DepreciationMethod, DepreciationStatus, UsefulLife, MonthlyDepreciation, MonthsOfDepreciation, MonthlyDepreciationRate, | |||
AccumulatedDepreciation, NetWorth, VehicleLicenseUser, AIVehicleNumber, AIPlateNumber, AIBuiltArea, AIOwnership, LandUseType, LandUseUser,room.REnabled,t.AIASSState | |||
"); | |||
strSql.Append(" FROM Ass_AssetsInfoItem t "); | |||
strSql.Append(" left join Ass_Storage_Room room on t.AIIStoragePosition=room.rid "); | |||
strSql.Append(" left join Ass_Storage storage on t.AIIStorageId=storage.sid "); | |||
strSql.Append(" WHERE 1=1 "); | |||
var queryParam = queryJson.ToJObject(); | |||
// 虚拟参数 | |||
var dp = new DynamicParameters(new { }); | |||
if (!queryParam["AICode"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AICode Like '%{queryParam["AICode"].ToString()}%' "); | |||
} | |||
if (!queryParam["AICodeNumJY"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AICodeNumJY Like '%{queryParam["AICodeNumJY"].ToString()}%' "); | |||
} | |||
if (!queryParam["userId"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AIUsePeople = '{queryParam["userId"].ToString()}' "); | |||
} | |||
if (!queryParam["AIAssType"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AIAssType = '{queryParam["AIAssType"].ToString()}' "); | |||
} | |||
if (!queryParam["AIUsePeople"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AIUsePeople = '{queryParam["AIUsePeople"].ToString()}' "); | |||
} | |||
if (!queryParam["AIDepartment"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AIDepartment Like '%{queryParam["AIDepartment"].ToString()}%' "); | |||
} | |||
if (!queryParam["AIASSState"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AIASSState = '{queryParam["AIASSState"].ToString()}' "); | |||
} | |||
if (!queryParam["AIASSClass"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AIASSClass = '{queryParam["AIASSClass"].ToString()}' "); | |||
} | |||
if (!queryParam["AIIsScrap"].IsEmpty()) | |||
{ | |||
var isScrap = Convert.ToBoolean(queryParam["AIIsScrap"].ToString()); | |||
if (!isScrap) | |||
{ | |||
strSql.Append(" AND (t.AIASSState <> 2 or t.AIASSState is null)"); | |||
} | |||
else | |||
{ | |||
strSql.Append(" AND t.AIASSState = 2 "); | |||
} | |||
} | |||
if (!queryParam["AId"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AId='{queryParam["AId"].ToString()}' "); | |||
} | |||
if (!queryParam["AIASSName"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AIASSName Like '%{queryParam["AIASSName"].ToString()}%' "); | |||
} | |||
if (!queryParam["AIIStorageId"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AIIStorageId = '{queryParam["AIIStorageId"].ToString()}' "); | |||
} | |||
if (!queryParam["AIIStoragePosition"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AIIStoragePosition Like '%{queryParam["AIIStoragePosition"].ToString()}%' "); | |||
} | |||
//房间功能 | |||
if (!queryParam["RFunction"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND room.RFunction Like '{queryParam["RFunction"].ToString()}' "); | |||
} | |||
//房间面积 | |||
if (!queryParam["RArea"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND room.RArea Like '%{queryParam["RArea"].ToString()}%' "); | |||
} | |||
//房间状态 | |||
if (!queryParam["REnabled"].IsEmpty()) | |||
{ | |||
var REnabled = Convert.ToBoolean(queryParam["REnabled"].ToString()); | |||
if (REnabled) | |||
{ | |||
strSql.Append(" AND room.REnabled=1 "); | |||
} | |||
else | |||
{ | |||
strSql.Append(" AND room.REnabled=0 "); | |||
} | |||
} | |||
if (!queryParam["AIAssValue"].IsEmpty()) | |||
{ | |||
strSql.Append($" AND t.AIAssValue Like '%{queryParam["AIAssValue"].ToString()}%' "); | |||
} | |||
return this.BaseRepository().FindTable(strSql.ToString()); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowServiceException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 获取树形数据 | |||
/// </summary> | |||