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
......@@ -52,6 +52,10 @@ namespace Property.Module.FixedAssets
/// 资产使用关联
/// </summary>
private RB_Property_UseRelevanceRepository useRelevanceRepository = new RB_Property_UseRelevanceRepository();
/// <summary>
/// 请购单
/// </summary>
private RB_Property_BuyingRequisitionRepository property_BuyingRequisitionRepository = new RB_Property_BuyingRequisitionRepository();
private Rb_branchRepository branchRepository = new Rb_branchRepository();
private Rb_departmentRepository departmentRepository = new Rb_departmentRepository();
......@@ -60,14 +64,8 @@ namespace Property.Module.FixedAssets
//流程
private Rb_Workflow_TemplateRepository workflow_TemplateRepository = new Rb_Workflow_TemplateRepository();
private RB_FinanceFlowConnectRepository financeFlowConnectRepository = new RB_FinanceFlowConnectRepository();
private Rb_Workflow_ConditionRepository workflow_ConditionRepository = new Rb_Workflow_ConditionRepository();
private Rb_Workflow_AuditRepository workflow_AuditRepository = new Rb_Workflow_AuditRepository();
private Rb_Workflow_AuditUserRepository workflow_AuditUserRepository = new Rb_Workflow_AuditUserRepository();
private Rb_Workflow_AuditrecordRepository workflow_AuditrecordRepository = new Rb_Workflow_AuditrecordRepository();
private Rb_Workflow_AuditRelevanceRepository workflow_AuditRelevanceRepository = new Rb_Workflow_AuditRelevanceRepository();
private Rb_Workflow_AuditUserRelevanceRepository workflow_AuditUserRelevanceRepository = new Rb_Workflow_AuditUserRelevanceRepository();
private RB_Audit_DelegateRepository audit_DelegateRepository = new RB_Audit_DelegateRepository();
private Rb_Workflow_CopyToPeopleRepository workflow_CopyToPeopleRepository = new Rb_Workflow_CopyToPeopleRepository();
private RB_Workfolw_Change_LogRepository workfolw_Change_LogRepository = new RB_Workfolw_Change_LogRepository();
//资产折旧
......@@ -244,7 +242,12 @@ namespace Property.Module.FixedAssets
{
if (item.EmployeeId > 0)
{
item.EmName = CacheManager.User.UserReidsCache.GetEmployee(item.EmployeeId)?.EmName ?? "";
var emodel = CacheManager.User.UserReidsCache.GetEmployee(item.EmployeeId);
item.EmName = emodel?.EmName ?? "";
item.EmBranchId = emodel.RB_Branch_id;
item.EmDepartmentId = emodel.RB_Department_Id;
item.EmDepartmentName = emodel.DepartName;
item.EmBranchName = emodel.BranchName;
}
else
{
......@@ -455,6 +458,134 @@ namespace Property.Module.FixedAssets
}
}
/// <summary>
/// 批量导入资产
/// </summary>
/// <param name="deList"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public ApiResult SetPropertyInfoBatchImport(List<RB_Property_Info_Extend> deList, UserInfo userInfo)
{
//查询集团下所有的员工列表
var elist = employeeRepository.GetList(new RB_Employee_Extend() { RB_Group_id = userInfo.RB_Group_id });
//查询所有的公司
var blist = branchRepository.GetList(new RB_Branch_Extend() { RB_Group_Id = userInfo.RB_Group_id });
//查询所有的供应商
var slist = property_SupplierRepository.GetList(new RB_Property_Supplier_Extend() { RB_Group_Id = userInfo.RB_Group_id });
//查询所有的资产分类
var clist = property_CategoryRepository.GetList(new RB_Property_Category_Extend() { RB_Group_Id = userInfo.RB_Group_id });
//再次验证数据有效性
foreach (var item in deList) {
if (!string.IsNullOrEmpty(item.EmName)) {
var eclist = elist.Where(x => x.EmName == item.EmName).ToList();
if (eclist.Count() > 1)
{
return ApiResult.ParamIsNull("ID:" + item.Id + ",资产名称:" + item.Name + ",领用人:" + item.EmName + " 匹配有重复人员!请删除此条数据后再试");
}
else if (eclist.Count() == 0) {
return ApiResult.ParamIsNull("ID:" + item.Id + ",资产名称:" + item.Name + ",领用人:" + item.EmName + " 未匹配到领用人!请修改此条数据后再试");
}
item.EmployeeId = eclist.FirstOrDefault().EmployeeId;
}
//公司
var bModel= blist.Where(x => x.BName.Contains(item.BranchName)).FirstOrDefault();
if (bModel == null) {
return ApiResult.ParamIsNull("ID:" + item.Id + ",资产名称:" + item.Name + ",领用人:" + item.EmName + " 未匹配到公司信息!请修改此条数据后再试");
}
item.BranchId = bModel.Id;
//分类
var cModel = clist.Where(x => x.Name==item.CategoryName).FirstOrDefault();
if (cModel == null)
{
return ApiResult.ParamIsNull("ID:" + item.Id + ",资产名称:" + item.Name + ",领用人:" + item.EmName + " 未匹配到分类信息!请修改此条数据后再试");
}
item.CategoryId = cModel.Id;
//供应商
var sModel = slist.Where(x => x.Name == item.SupplierName).FirstOrDefault();
if (sModel == null)
{
return ApiResult.ParamIsNull("ID:" + item.Id + ",资产名称:" + item.Name + ",领用人:" + item.EmName + " 未匹配到供应商信息!请修改此条数据后再试");
}
item.SupplierId = sModel.Id;
}
var trans = property_InfoRepository.DbTransaction;
try
{
//有效数据批量新增
foreach (var demodel in deList)
{
demodel.UseStatus = PropertyUseStateEnum.Normal;
demodel.PropertyStatus = PropertyStatusEnum.Leisure;
demodel.EmployeeId = demodel.EmployeeId ?? 0;
if (demodel.EmployeeId > 0)
{
demodel.PropertyStatus = PropertyStatusEnum.Receive;
demodel.GetTime= Convert.ToDateTime(demodel.StartTime);
}
demodel.BuyType = PropertyBuyTypeEnum.Purchase;
demodel.BuyDate = Convert.ToDateTime(demodel.EndTime);
int PropertyId = property_InfoRepository.Insert(demodel, trans);
bool flag = PropertyId > 0;
if (flag)
{
//编码自动生成
string BMStr = PropertyId.ToString();
if (BMStr.Length < 5)
{
switch (BMStr.Length)
{
case 1:
BMStr = "0000" + BMStr; break;
case 2:
BMStr = "000" + BMStr; break;
case 3:
BMStr = "00" + BMStr; break;
case 4:
BMStr = "0" + BMStr; break;
}
}
Dictionary<string, object> files = new Dictionary<string, object>() {
{ nameof(RB_Property_Info.PropertyNum),BMStr}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Property_Info.Id),
FiledValue=PropertyId,
OperatorEnum=OperatorEnum.Equal
}
};
property_InfoRepository.Update(files, wheres, trans);
string Content = "批量导入资产";
if (demodel.EmployeeId > 0)
{
Content += ";设置使用人:" + demodel.EmName;
}
//写入日志
property_LogRepository.Insert(new RB_Property_Log()
{
PropertyId = PropertyId,
Status = 0,
Content = Content,
TypeName = "入库",
RB_Branch_Id = userInfo.RB_Branch_id,
RB_Group_Id = userInfo.RB_Group_id,
CreateBy = userInfo.EmployeeId,
CreateDate = DateTime.Now
}, trans);
}
}
property_InfoRepository.DBSession.Commit();
return ApiResult.Success();
}
catch (Exception ex)
{
LogHelper.Write(ex, "SetPropertyInfoBatchImport");
property_InfoRepository.DBSession.Rollback();
return ApiResult.Failed();
}
}
/// <summary>
/// 删除资产信息
/// </summary>
......@@ -3317,5 +3448,134 @@ namespace Property.Module.FixedAssets
return Robj;
}
#endregion
#region 请购单
/// <summary>
/// 获取请购单分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="demodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Property_BuyingRequisition_Extend> GetBuyingRequisitionPageList(int pageIndex, int pageSize, RB_Property_BuyingRequisition_Extend demodel, out long count)
{
return property_BuyingRequisitionRepository.GetPageList(pageIndex, pageSize, demodel, out count);
}
/// <summary>
/// 新增修改请购单
/// </summary>
/// <param name="demodel"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool SetBuyingRequisitionInfo(RB_Property_BuyingRequisition_Extend demodel, UserInfo userInfo)
{
if (demodel.Id > 0)
{
var model = property_BuyingRequisitionRepository.GetEntity(demodel.Id);
if (model.BuyStatus != BuyingRequisitionStatusEnum.Pending)
{
return false;
}
model.Name = demodel.Name;
model.Type = demodel.Type;
model.CategoryId = demodel.CategoryId;
model.Content = demodel.Content;
model.UseTime = demodel.UseTime;
model.UpdateBy = demodel.UpdateBy;
model.UpdateDate = demodel.UpdateDate;
return property_BuyingRequisitionRepository.Update(model);
}
else
{
demodel.BuyStatus = BuyingRequisitionStatusEnum.Pending;
return property_BuyingRequisitionRepository.Insert(demodel) > 0;
}
}
/// <summary>
/// 设置请购单状态
/// </summary>
/// <param name="buyingRequisitionId"></param>
/// <param name="type"></param>
/// <param name="buyTime"></param>
/// <param name="rejectRemark"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool SetBuyingRequisitionStatus(int buyingRequisitionId, int type, string buyTime, string rejectRemark, UserInfo userInfo)
{
var model = property_BuyingRequisitionRepository.GetEntity(buyingRequisitionId);
if (model == null)
{
return false;
}
if (type == 1)
{//购买中
model.BuyStatus = BuyingRequisitionStatusEnum.DuringPurchase;
model.BuyTime = Convert.ToDateTime(buyTime);
}
else if (type == 2)
{//驳回
model.BuyStatus = BuyingRequisitionStatusEnum.Reject;
model.RejectRemark = rejectRemark;
}
else if (type == 3)
{
//已购买
model.BuyStatus = BuyingRequisitionStatusEnum.Purchased;
model.BuyTime = Convert.ToDateTime(buyTime);
}
else if (type == 4)
{
if (model.CreateBy == userInfo.EmployeeId)
{
model.BuyStatus = BuyingRequisitionStatusEnum.Withdraw;
}
else {
return false;
}
}
model.UpdateBy = userInfo.EmployeeId;
model.UpdateDate = DateTime.Now;
bool flag = property_BuyingRequisitionRepository.Update(model);
if (flag)
{
List<EmAccoutIdModel> account = new List<EmAccoutIdModel>();
var emodel = CacheManager.User.UserReidsCache.GetEmployee(model.CreateBy);
if (emodel != null) {
account.Add(new EmAccoutIdModel()
{
EmployeeId = emodel.EmployeeId,
EmAccount = emodel.LoginMobile
});
}
//发送通知
PushBuyingMessage(account, 0, "您有资产请购信息已购买,请往资产管理系统查看", "请购单通知", userInfo.EmployeeId, SysTemPushTypeEnum.PropertyAudit);
}
return flag;
}
/// <summary>
/// 推送资产购买消息
/// </summary>
/// <param name="account"></param>
/// <param name="workFlowId"></param>
/// <param name="content"></param>
/// <param name="title"></param>
/// <param name="empId"></param>
/// <param name="type"></param>
public void PushBuyingMessage(List<EmAccoutIdModel> account, int workFlowId, string content, string title, int? empId, SysTemPushTypeEnum type)
{
//Dictionary<string, object> appExtras = new Dictionary<string, object>();
Dictionary<string, object> webExtras = new Dictionary<string, object>();
webExtras.Add("jumpUrl", "");
//appExtras.Add("jumpUrl", "vt://financeApprovalDetail/view?ID=" + workFlowId + "&Conditon=3&Source=message&Type=" + Type);
//IMService.PushFinanceMessage(account, empId, content, title, type, SystemPushLogTypeEnum.XMApp, appExtras);
IMService.PushMessage(account.RefMapperToList<Property.Common.Models.EmAccoutIdModel>(), empId, content, title, type, SystemPushLogTypeEnum.Web, webExtras);
}
#endregion
}
}
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();
}
}
}
}
......@@ -205,6 +205,7 @@ namespace Property.WebApi.Controllers.User
}
}
#endregion
#region 资产基本
/// <summary>
/// 获取资产分页列表
......@@ -264,7 +265,6 @@ namespace Property.WebApi.Controllers.User
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 资产清单下载excel
/// </summary>
......@@ -351,6 +351,269 @@ namespace Property.WebApi.Controllers.User
}
/// <summary>
/// 资产领用下载excel
/// </summary>
[HttpPost]
public FileContentResult GetPropertyUseListStatisticsToExcel()
{
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
RB_Property_Info_Extend demodel = JsonConvert.DeserializeObject<RB_Property_Info_Extend>(requestParm.msg.ToString());
List<ExcelDataSource> slist = new List<ExcelDataSource>();
ExcelDataSource header = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value:"公司"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"部门"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"人员"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"使用日期"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"资产编码"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"资产状态"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"资产名称"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"资产分类"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"品牌"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"金额"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"购置日期"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"使用状态"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"单位"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"型号"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"设备序列号"){CellWidth=25,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"公司别"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"供应商"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER }
},
};
slist.Add(header);
try
{
if (demodel.IsSelectSelfApplication == 1)
{
demodel.CreateBy = userInfo.EmployeeId;
}
if (demodel.IsSelectMyProperty == 1)
{
demodel.CreateBy = userInfo.EmployeeId;
demodel.EmployeeId = 0;
}
demodel.IsSelectUseProperty = 1;
demodel.RB_Group_Id = userInfo.RB_Group_id;
var list = propertyModule.PropertyGetPageList(1, 99999, demodel, out long count);
#region 组装数据
//根据公司 部门 人员 分类
List<int> Blist = list.Select(x => x.EmBranchId ?? 0).Distinct().ToList();
int bNum = 1, dNum = 1, eNum = 1;
foreach (var bitem in Blist) {
bNum = 1;
var bplist = list.Where(x => x.EmBranchId == bitem).ToList();
var bcount = bplist.Count();
List<int> Dlist = bplist.Select(x => x.EmDepartmentId ?? 0).Distinct().ToList();
foreach (var ditem in Dlist) {
dNum = 1;
var dplist = bplist.Where(x => x.EmDepartmentId == ditem).ToList();
var Elist = dplist.Select(x => x.EmployeeId ?? 0).Distinct().ToList();
var dcount = dplist.Count();
foreach (var eitem in Elist)
{
eNum = 1;
var eplist = dplist.Where(x => x.EmployeeId == eitem).ToList();
var ecount = eplist.Count();
foreach (var item in eplist) {
if (bNum == 1 && dNum == 1 && eNum == 1)
{
ExcelDataSource datarow = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value:item.EmBranchName){ Rowspan=bcount },
new ExcelColumn(value:item.EmDepartmentName){ Rowspan=dcount },
new ExcelColumn(value:item.EmName){ Rowspan=ecount },
new ExcelColumn(value:item.GetTime.HasValue ? item.GetTime.Value.ToString("yyyy-MM-dd") : ""){ },
new ExcelColumn(value:item.PropertyNum){ },
new ExcelColumn(value:item.PropertyStatus.GetEnumName()){ },
new ExcelColumn(value:item.Name){ },
new ExcelColumn(value:item.CategoryName){ },
new ExcelColumn(value:item.BrandName){ },
new ExcelColumn(value:(item.Money??0).ToString("#0.00")){ },
new ExcelColumn(value:item.BuyDate.HasValue ? item.BuyDate.Value.ToString("yyyy-MM-dd") : ""){ },
new ExcelColumn(value:item.UseStatus.GetEnumName()){ },
new ExcelColumn(value:item.Units){ },
new ExcelColumn(value:item.PropertyModel){ },
new ExcelColumn(value:item.SerialNumber){ },
new ExcelColumn(value:CacheManager.User.BranchReidsCache.GetBranch(item.BranchId)?.BName ?? ""){ },
new ExcelColumn(value:item.SupplierName){ }
}
};
slist.Add(datarow);
}
else if (bNum != 1 && dNum == 1 && eNum == 1)
{
ExcelDataSource datarow = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value:""){ },
new ExcelColumn(value:item.EmDepartmentName){ Rowspan=dcount },
new ExcelColumn(value:item.EmName){ Rowspan=ecount },
new ExcelColumn(value:item.GetTime.HasValue ? item.GetTime.Value.ToString("yyyy-MM-dd") : ""){ },
new ExcelColumn(value:item.PropertyNum){ },
new ExcelColumn(value:item.PropertyStatus.GetEnumName()){ },
new ExcelColumn(value:item.Name){ },
new ExcelColumn(value:item.CategoryName){ },
new ExcelColumn(value:item.BrandName){ },
new ExcelColumn(value:(item.Money??0).ToString("#0.00")){ },
new ExcelColumn(value:item.BuyDate.HasValue ? item.BuyDate.Value.ToString("yyyy-MM-dd") : ""){ },
new ExcelColumn(value:item.UseStatus.GetEnumName()){ },
new ExcelColumn(value:item.Units){ },
new ExcelColumn(value:item.PropertyModel){ },
new ExcelColumn(value:item.SerialNumber){ },
new ExcelColumn(value:CacheManager.User.BranchReidsCache.GetBranch(item.BranchId)?.BName ?? ""){ },
new ExcelColumn(value:item.SupplierName){ }
}
};
slist.Add(datarow);
}
else if (bNum != 1 && dNum != 1 && eNum == 1) {
ExcelDataSource datarow = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value:""){ },
new ExcelColumn(value:""){ },
new ExcelColumn(value:item.EmName){ Rowspan=ecount },
new ExcelColumn(value:item.GetTime.HasValue ? item.GetTime.Value.ToString("yyyy-MM-dd") : ""){ },
new ExcelColumn(value:item.PropertyNum){ },
new ExcelColumn(value:item.PropertyStatus.GetEnumName()){ },
new ExcelColumn(value:item.Name){ },
new ExcelColumn(value:item.CategoryName){ },
new ExcelColumn(value:item.BrandName){ },
new ExcelColumn(value:(item.Money??0).ToString("#0.00")){ },
new ExcelColumn(value:item.BuyDate.HasValue ? item.BuyDate.Value.ToString("yyyy-MM-dd") : ""){ },
new ExcelColumn(value:item.UseStatus.GetEnumName()){ },
new ExcelColumn(value:item.Units){ },
new ExcelColumn(value:item.PropertyModel){ },
new ExcelColumn(value:item.SerialNumber){ },
new ExcelColumn(value:CacheManager.User.BranchReidsCache.GetBranch(item.BranchId)?.BName ?? ""){ },
new ExcelColumn(value:item.SupplierName){ }
}
};
slist.Add(datarow);
}
else
{
ExcelDataSource datarow = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value:""){ },
new ExcelColumn(value:""){ },
new ExcelColumn(value:""){ },
new ExcelColumn(value:item.GetTime.HasValue ? item.GetTime.Value.ToString("yyyy-MM-dd") : ""){ },
new ExcelColumn(value:item.PropertyNum){ },
new ExcelColumn(value:item.PropertyStatus.GetEnumName()){ },
new ExcelColumn(value:item.Name){ },
new ExcelColumn(value:item.CategoryName){ },
new ExcelColumn(value:item.BrandName){ },
new ExcelColumn(value:(item.Money??0).ToString("#0.00")){ },
new ExcelColumn(value:item.BuyDate.HasValue ? item.BuyDate.Value.ToString("yyyy-MM-dd") : ""){ },
new ExcelColumn(value:item.UseStatus.GetEnumName()){ },
new ExcelColumn(value:item.Units){ },
new ExcelColumn(value:item.PropertyModel){ },
new ExcelColumn(value:item.SerialNumber){ },
new ExcelColumn(value:CacheManager.User.BranchReidsCache.GetBranch(item.BranchId)?.BName ?? ""){ },
new ExcelColumn(value:item.SupplierName){ }
}
};
slist.Add(datarow);
}
bNum++;
dNum++;
eNum++;
}
}
}
}
#endregion
var byteData = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData, "application/octet-stream", "资产清单.xls");
}
catch (Exception ex)
{
LogHelper.Write(ex, string.Format("GetFileFromWebApi_requestData: {0}", JsonHelper.Serialize(requestParm)));
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", "资产清单.xls");
}
}
/// <summary>
/// 资产批量导入
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetPropertyInfoBatchImport()
{
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
List<RB_Property_Info_Extend> deList = JsonConvert.DeserializeObject<List<RB_Property_Info_Extend>>(requestParm.msg.ToString());
foreach (var demodel in deList)
{
if (string.IsNullOrEmpty(demodel.Name))
{
return ApiResult.ParamIsNull("资产名称不能为空");
}
if (string.IsNullOrEmpty(demodel.CategoryName))
{
return ApiResult.ParamIsNull("分类名称不能为空");
}
if (string.IsNullOrEmpty(demodel.BrandName))
{
return ApiResult.ParamIsNull("品牌不能为空");
}
if (string.IsNullOrEmpty(demodel.PropertyModel))
{
return ApiResult.ParamIsNull("型号不能为空");
}
if (string.IsNullOrEmpty(demodel.Units))
{
return ApiResult.ParamIsNull("单位不能为空");
}
if (string.IsNullOrEmpty(demodel.SerialNumber))
{
return ApiResult.ParamIsNull("序列号不能为空");
}
if (string.IsNullOrEmpty(demodel.EndTime))
{
return ApiResult.ParamIsNull("购置日期不能为空");
}
if ((demodel.Money??0)<=0)
{
return ApiResult.ParamIsNull("金额不能小于0");
}
if ((demodel.UseMonths??0)<=0)
{
return ApiResult.ParamIsNull("使用月份期限不能为空");
}
if (string.IsNullOrEmpty(demodel.BranchName))
{
return ApiResult.ParamIsNull("所属公司不能为空");
}
if (string.IsNullOrEmpty(demodel.SupplierName))
{
return ApiResult.ParamIsNull("供应商名称不能为空");
}
demodel.Status = 0;
demodel.RB_Branch_Id = userInfo.RB_Branch_id;
demodel.RB_Group_Id = userInfo.RB_Group_id;
demodel.CreateBy = userInfo.EmployeeId;
demodel.CreateDate = DateTime.Now;
demodel.UpdateBy = userInfo.EmployeeId;
demodel.UpdateDate = DateTime.Now;
}
return propertyModule.SetPropertyInfoBatchImport(deList, userInfo);
}
/// <summary>
/// 获取资产信息
/// </summary>
......@@ -4494,5 +4757,152 @@ namespace Property.WebApi.Controllers.User
}
#endregion
#region 请购单
/// <summary>
/// 获取请购单分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetBuyingRequisitionPageList()
{
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(requestParm.msg.ToString());
RB_Property_BuyingRequisition_Extend demodel = JsonConvert.DeserializeObject<RB_Property_BuyingRequisition_Extend>(requestParm.msg.ToString());
demodel.RB_Group_Id = userInfo.RB_Group_id;
var list = propertyModule.GetBuyingRequisitionPageList(pagelist.pageIndex, pagelist.pageSize, demodel, out long count);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.Name,
CategoryName = string.IsNullOrEmpty(x.CategoryName) ? "未收录" : x.CategoryName,
x.Type,
TypeName = x.Type == 1 ? "资产" : "耗材",
x.BuyStatus,
BuyStatusName = x.BuyStatus.GetEnumName(),
x.Content,
x.RejectRemark,
UseTime = x.UseTime.HasValue ? x.UseTime.Value.ToString("yyyy-MM-dd") : "",
BuyTime = x.BuyTime.HasValue ? x.BuyTime.Value.ToString("yyyy-MM-dd") : "",
CreateBy = CacheManager.User.UserReidsCache.GetEmployee(x.CreateBy)?.EmName ?? "",
UpdateBy = CacheManager.User.UserReidsCache.GetEmployee(x.UpdateBy)?.EmName ?? "",
UpdateDate = x.UpdateDate.Value.ToString("yyyy-MM-dd")
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 设置请购单信息
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetBuyingRequisitionInfo()
{
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
RB_Property_BuyingRequisition_Extend demodel = JsonConvert.DeserializeObject<RB_Property_BuyingRequisition_Extend>(requestParm.msg.ToString());
if (string.IsNullOrEmpty(demodel.Name))
{
return ApiResult.ParamIsNull("请输入请购单名称");
}
if ((demodel.CategoryId ?? 0) < 0)
{
return ApiResult.ParamIsNull("请选择资产分类");
}
if (demodel.Type <= 0)
{
return ApiResult.ParamIsNull("请选择类型");
}
if (string.IsNullOrEmpty(demodel.Content))
{
return ApiResult.ParamIsNull("请输入内容信息");
}
if (!demodel.UseTime.HasValue)
{
return ApiResult.ParamIsNull("请选择预计使用日期");
}
demodel.Status = 0;
demodel.RB_Branch_Id = userInfo.RB_Branch_id;
demodel.RB_Group_Id = userInfo.RB_Group_id;
demodel.CreateBy = userInfo.EmployeeId;
demodel.CreateDate = DateTime.Now;
demodel.UpdateBy = userInfo.EmployeeId;
demodel.UpdateDate = DateTime.Now;
bool flag = propertyModule.SetBuyingRequisitionInfo(demodel, userInfo);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
/// <summary>
/// 设置请购单状态
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetBuyingRequisitionStatus()
{
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
JObject parms = JObject.Parse(requestParm.msg.ToString());
int BuyingRequisitionId = parms.GetInt("BuyingRequisitionId", 0);
int Type = parms.GetInt("Type", 0);// 1购买中 2驳回 3已购买 4撤回
string BuyTime = parms.GetStringValue("BuyTime");
string RejectRemark = parms.GetStringValue("RejectRemark");
if (BuyingRequisitionId <= 0) {
return ApiResult.ParamIsNull();
}
if (Type <= 0) {
return ApiResult.ParamIsNull();
}
if (Type == 1 || Type == 3)
{
if (string.IsNullOrEmpty(BuyTime))
{
return ApiResult.ParamIsNull("请传递购买日期");
}
}
else if (Type == 4) {
//撤回
}
else
{
if (string.IsNullOrEmpty(RejectRemark))
{
return ApiResult.ParamIsNull("请输入驳回理由");
}
}
bool flag = propertyModule.SetBuyingRequisitionStatus(BuyingRequisitionId, Type, BuyTime, RejectRemark, userInfo);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
/// <summary>
/// 获取请购单状态列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetBuyingRequisitionEnumList()
{
var list = EnumHelper.GetEnumList(typeof(REBORN.Common.Enum.BuyingRequisitionStatusEnum));
return ApiResult.Success("", list.Select(x => new { Id = x.Value, Name = x.Key }));
}
#endregion
}
}
......@@ -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;
......@@ -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