Commit 031242bf authored by liudong1993's avatar liudong1993

功能新增

parent 754e05ce
using REBORN.Common.Plugin;
namespace REBORN.Common.Enum
{
/// <summary>
/// 数据状态
/// </summary>
public enum BuyingRequisitionStatusEnum
{
/// <summary>
/// 已购买
/// </summary>
[EnumField("已购买")]
Purchased = 1,
/// <summary>
/// 购买中
/// </summary>
[EnumField("购买中")]
DuringPurchase = 2,
/// <summary>
/// 驳回
/// </summary>
[EnumField("驳回")]
Reject = 3,
/// <summary>
/// 待处理
/// </summary>
[EnumField("待处理")]
Pending = 4,
/// <summary>
/// 撤回
/// </summary>
[EnumField("撤回")]
Withdraw = 5
}
}

using Property.Model.Extend;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace REBORN.DataHelper
{
public class PropertyBetchDataHelper
{
/// <summary>
/// 导入模板
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static List<RB_Property_Info_Extend> ImportClaimData(string fileName)
{
List<RB_Property_Info_Extend> list = new List<RB_Property_Info_Extend>();
var dt = REBORN.Common.Plugin.NPOIHelper.ImportExceltoDt(fileName, 0, 0, true);
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
RB_Property_Info_Extend model = DataRowToModel(dr);
list.Add(model);
}
}
return list;
}
/// <summary>
/// DataRow转实体
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
public static RB_Property_Info_Extend DataRowToModel(DataRow dr)
{
RB_Property_Info_Extend model = new RB_Property_Info_Extend();
if (dr != null)
{
if (dr.Table.Columns.Contains("资产名称") && !string.IsNullOrEmpty(dr["资产名称"].ToString().Trim()))
{
model.Name = dr["资产名称"].ToString().Trim();
}
if (dr.Table.Columns.Contains("分类名称") && !string.IsNullOrEmpty(dr["分类名称"].ToString().Trim()))
{
model.CategoryName = dr["分类名称"].ToString().Trim();
}
if (dr.Table.Columns.Contains("品牌") && !string.IsNullOrEmpty(dr["品牌"].ToString().Trim()))
{
model.BrandName = dr["品牌"].ToString().Trim();
}
if (dr.Table.Columns.Contains("型号") && !string.IsNullOrEmpty(dr["型号"].ToString().Trim()))
{
model.PropertyModel = dr["型号"].ToString().Trim();
}
if (dr.Table.Columns.Contains("单位") && !string.IsNullOrEmpty(dr["单位"].ToString().Trim()))
{
model.Units = dr["单位"].ToString().Trim();
}
if (dr.Table.Columns.Contains("序列号") && !string.IsNullOrEmpty(dr["序列号"].ToString().Trim()))
{
model.SerialNumber = dr["序列号"].ToString().Trim();
}
if (dr.Table.Columns.Contains("领用人") && !string.IsNullOrEmpty(dr["领用人"].ToString().Trim()))
{
model.EmName = dr["领用人"].ToString().Trim();
}
if (dr.Table.Columns.Contains("领用时间") && !string.IsNullOrEmpty(dr["领用时间"].ToString().Trim()))
{
model.StartTime = dr["领用时间"].ToString().Trim();
}
if (dr.Table.Columns.Contains("购置日期") && !string.IsNullOrEmpty(dr["购置日期"].ToString().Trim()))
{
model.EndTime = dr["购置日期"].ToString().Trim();
}
if (dr.Table.Columns.Contains("金额") && !string.IsNullOrEmpty(dr["金额"].ToString().Trim()))
{
model.Money = Convert.ToDecimal(dr["金额"].ToString().Trim());
}
if (dr.Table.Columns.Contains("使用月份期限") && !string.IsNullOrEmpty(dr["使用月份期限"].ToString().Trim()))
{
model.UseMonths = Convert.ToInt32(dr["使用月份期限"].ToString().Trim());
}
if (dr.Table.Columns.Contains("所属公司") && !string.IsNullOrEmpty(dr["所属公司"].ToString().Trim()))
{
model.BranchName = dr["所属公司"].ToString().Trim();
}
if (dr.Table.Columns.Contains("供应商") && !string.IsNullOrEmpty(dr["供应商"].ToString().Trim()))
{
model.SupplierName = dr["供应商"].ToString().Trim();
}
}
return model;
}
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@
<ItemGroup>
<ProjectReference Include="..\Property.Common\Property.Common.csproj" />
<ProjectReference Include="..\Property.DataAccess\Property.DataAccess.csproj" />
<ProjectReference Include="..\Property.Model\Property.Model.csproj" />
</ItemGroup>
</Project>
using System;
using REBORN.Common.AOP;
using REBORN.Common.Enum;
using REBORN.Common.Plugin;
namespace Property.Model.Entity
{
/// <summary>
/// 请购单
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Property_BuyingRequisition
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 请购单名称
/// </summary>
public string Name
{
get;
set;
}
/// <summary>
/// 类型 1资产 2耗材
/// </summary>
public int? Type
{
get;
set;
}
/// <summary>
/// 分类id 0表示没有
/// </summary>
public int? CategoryId
{
get;
set;
}
/// <summary>
/// 购买状态 1已购买 2购买中 3驳回 4待处理
/// </summary>
public BuyingRequisitionStatusEnum? BuyStatus
{
get;
set;
}
/// <summary>
/// 内容
/// </summary>
public string Content
{
get;
set;
}
/// <summary>
/// 预计使用日期
/// </summary>
public DateTime? UseTime { get; set; }
/// <summary>
/// 购买日期
/// </summary>
public DateTime? BuyTime { get; set; }
/// <summary>
/// /驳回备注
/// </summary>
public string RejectRemark { get; set; }
/// <summary>
/// 状态 0正常 1删除
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 公司
/// </summary>
public int? RB_Branch_Id
{
get;
set;
}
/// <summary>
/// 集团
/// </summary>
public int? RB_Group_Id
{
get;
set;
}
/// <summary>
/// CreateBy
/// </summary>
public int? CreateBy
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// UpdateBy
/// </summary>
public int? UpdateBy
{
get;
set;
}
/// <summary>
/// UpdateDate
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
}
}
\ No newline at end of file
using System;
using Property.Model.Entity;
using REBORN.Common.AOP;
namespace Property.Model.Extend
{
/// <summary>
/// 请购单扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Property_BuyingRequisition_Extend : RB_Property_BuyingRequisition
{
/// <summary>
/// 开始时间
/// </summary>
public string StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public string EndTime { get; set; }
/// <summary>
/// 分类名称
/// </summary>
public string CategoryName { get; set; }
}
}
\ No newline at end of file
......@@ -42,6 +42,10 @@ namespace Property.Model.Extend
/// </summary>
public int? IsSelectMyProperty { get; set; }
/// <summary>
/// 是否查询资产使用资产 1是 其他否
/// </summary>
public int? IsSelectUseProperty { get; set; }
/// <summary>
/// 分类名词
/// </summary>
public string CategoryName { get; set; }
......@@ -62,6 +66,22 @@ namespace Property.Model.Extend
/// 使用人
/// </summary>
public string EmName { get; set; }
/// <summary>
/// 员工公司id
/// </summary>
public int? EmBranchId { get; set; }
/// <summary>
/// 员工公司
/// </summary>
public string EmBranchName { get; set; }
/// <summary>
/// 员工部门id
/// </summary>
public int? EmDepartmentId { get; set; }
/// <summary>
/// 员工部门名称
/// </summary>
public string EmDepartmentName { get; set; }
/// <summary>
/// 开始时间
......@@ -110,5 +130,9 @@ namespace Property.Model.Extend
/// 日志列表
/// </summary>
public List<RB_Property_Log_Extend> LogList { get; set; }
/// <summary>
/// 公司名称
/// </summary>
public string BranchName { get; set; }
}
}
\ No newline at end of file
using Property.Model.Entity;
using Property.Model.Extend;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Property.Repository
{
/// <summary>
/// 请购单仓储类
/// </summary>
public partial class RB_Property_BuyingRequisitionRepository : RepositoryBase<RB_Property_BuyingRequisition>
{
/// <summary>
/// 获取请购单分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Property_BuyingRequisition_Extend> GetPageList(int pageIndex, int pageSize, RB_Property_BuyingRequisition_Extend dmodel, out long count)
{
string where = " where 1=1 ";
where += string.Format(" AND pb.{0}={1}", nameof(RB_Property_BuyingRequisition_Extend.Status), 0);
where += $@" and pb.RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrEmpty(dmodel.Name)) {
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.Name) + " like '%" + dmodel.Name+"%'";
}
if (dmodel.Type > 0) {
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.Type) + " =" + dmodel.Type;
}
if (dmodel.CreateBy > 0) {
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.CreateBy) + " =" + dmodel.CreateBy;
}
if (dmodel.BuyStatus > 0) {
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.BuyStatus) + " =" + (int)dmodel.BuyStatus;
}
if (!string.IsNullOrEmpty(dmodel.StartTime)) {
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.CreateDate) + " >='" + dmodel.StartTime + "'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime)) {
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.CreateDate) + " <='" + dmodel.EndTime + " 23:59:59'";
}
string sql = $@" select pb.*,pc.Name as CategoryName from RB_Property_BuyingRequisition pb
left join rb_property_category pc on pb.CategoryId = pc.Id
{where} order by pb.Id desc";
return GetPage<RB_Property_BuyingRequisition_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取列表数据
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Property_BuyingRequisition_Extend> GetList(RB_Property_BuyingRequisition_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND pb.{0}={1}", nameof(RB_Property_BuyingRequisition_Extend.Status), 0);
where += $@" and pb.RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrEmpty(dmodel.Name))
{
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.Name) + " like '%" + dmodel.Name + "%'";
}
if (dmodel.Type > 0)
{
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.Type) + " =" + dmodel.Type;
}
if (dmodel.BuyStatus > 0)
{
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.BuyStatus) + " =" + (int)dmodel.BuyStatus;
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.CreateDate) + " >='" + dmodel.StartTime + "'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += " and pb." + nameof(RB_Property_BuyingRequisition_Extend.CreateDate) + " <='" + dmodel.EndTime + " 23:59:59'";
}
string sql = $@" select pb.*,pc.Name as CategoryName from RB_Property_BuyingRequisition pb
left join rb_property_category pc on pb.CategoryId = pc.Id
{where} order by pb.Id desc";
return Get<RB_Property_BuyingRequisition_Extend>(sql).ToList();
}
}
}
......@@ -83,6 +83,9 @@ namespace Property.Repository
where += " and pi.EmployeeId=" + dmodel.CreateBy ;
}
}
if (dmodel.IsSelectUseProperty == 1) {
where += " and pi.EmployeeId > 0 ";
}
string sql = $@" select pi.*,pc.Name as CategoryName,ps.Name as SupplierName from RB_Property_Info pi
left join RB_Property_Category pc on pc.Id=pi.CategoryId
left join rb_property_supplier ps on pi.SupplierId=ps.Id
......

using Microsoft.AspNetCore.Mvc;
using REBORN.Common.API;
using REBORN.Common.Plugin;
using Property.Module.FixedAssets;
using System;
using System.IO;
using Property.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Property.Model.Extend;
using System.Collections.Generic;
using System.Linq;
namespace Property.WebApi.Controllers.User
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class FileController : ControllerBase
{
PropertyModule propertyModule = new PropertyModule();
/// <summary>
/// 上传文件解析文件内容
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult LocalFileUploadImport()
{
try
{
var files = Request.Form.Files;
if (files.Count == 0)
{
return new ApiResult { resultCode = (int)ResultCode.Fail, message = "未选择文件", data = "" };
}
string filename = files[0].FileName;
string fileExtention = System.IO.Path.GetExtension(files[0].FileName);
string path = Guid.NewGuid().ToString() + fileExtention;
string basepath = AppContext.BaseDirectory;
string path_server = basepath + "\\upfile\\" + path;
if (!Directory.Exists(basepath + "\\upfile"))
{
Directory.CreateDirectory(basepath + "\\upfile");
}
using (FileStream fstream = new FileStream(path_server, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
files[0].CopyTo(fstream);
}
//处理文件内容读取
List<RB_Property_Info_Extend> list = REBORN.DataHelper.PropertyBetchDataHelper.ImportClaimData(path_server);
list = list.Where(x => !string.IsNullOrWhiteSpace(x.Name)).ToList();
int Num = 1;
list.ForEach(x =>
{
x.Id = Num;
Num++;
});
System.IO.File.Delete(path_server);
return ApiResult.Success("", list.Select(x => new
{
x.Id,
x.Name,
x.CategoryName,
x.BrandName,
x.PropertyModel,
x.Units,
x.SerialNumber,
x.EmName,
x.StartTime,
x.EndTime,
x.Money,
x.UseMonths,
x.BranchName,
x.SupplierName
}));
}
catch (Exception ex)
{
LogHelper.Write(ex, "LocalFileUploadImport");
return ApiResult.Failed();
}
}
}
}
......@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.IO;
using System.Text.Encodings.Web;
using System.Text.Unicode;
......@@ -71,7 +72,7 @@ namespace Property.WebApi
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseHttpsRedirection();
app.UseRouting();
// 允许所有跨域,cors是在ConfigureServices方法中配置的跨域策略名称
......@@ -86,6 +87,12 @@ namespace Property.WebApi
System.WebHttpContext.HttpContext.Configure(app.ApplicationServices.GetRequiredService<Microsoft.AspNetCore.Http.IHttpContextAccessor>());
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "ExportFile")),
RequestPath = "/ExportFile"
});
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment