Commit e27671a9 authored by liudong1993's avatar liudong1993

教育耗材出库功能

parent ee015e96
...@@ -47,7 +47,7 @@ namespace Property.Model.Entity ...@@ -47,7 +47,7 @@ namespace Property.Model.Entity
set; set;
} }
/// <summary> /// <summary>
/// 购买状态 1已购买 2购买中 3驳回 4待处理 /// 购买状态 看枚举
/// </summary> /// </summary>
public BuyingRequisitionStatusEnum? BuyStatus public BuyingRequisitionStatusEnum? BuyStatus
{ {
......
...@@ -131,5 +131,10 @@ namespace Property.Model.Entity ...@@ -131,5 +131,10 @@ namespace Property.Model.Entity
/// 出库公司 /// 出库公司
/// </summary> /// </summary>
public int? BranchId { get; set; } public int? BranchId { get; set; }
/// <summary>
/// 耗材出库申请id
/// </summary>
public int ApplyForId { get; set; }
} }
} }
\ No newline at end of file
using System;
using REBORN.Common.AOP;
using REBORN.Common.Plugin;
namespace Property.Model.Entity
{
/// <summary>
/// 耗材出库申请实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_StockOutApplyFor
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 总数量
/// </summary>
public int TotalNumber { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { 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; }
/// <summary>
/// 关联财务单据id(英文逗号分隔)
/// </summary>
public string FinanceIds { get; set; }
/// <summary>
/// 出库状态 1未出库 2部分出库 3已出库
/// </summary>
public int StockOutStatus { get; set; }
/// <summary>
/// 审核状态 1审核中 2通过 3驳回
/// </summary>
public int AuditStatus { get; set; }
/// <summary>
/// 审核备注
/// </summary>
public string AuditRemark { get; set; }
/// <summary>
/// 审核人
/// </summary>
public int AuditEmpId { get; set; }
/// <summary>
/// 审核时间
/// </summary>
public DateTime? AuditDate { get; set; }
}
}
\ No newline at end of file
using System;
using REBORN.Common.AOP;
using REBORN.Common.Plugin;
namespace Property.Model.Entity
{
/// <summary>
/// 耗材出库申请明细实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_StockOutApplyForDetail
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 申请id
/// </summary>
public int ApplyForId { get; set; }
/// <summary>
/// 班级id
/// </summary>
public int ClassId { get; set; }
/// <summary>
/// 班级名称
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// 课程名称
/// </summary>
public string CourseName { get; set; }
/// <summary>
/// 耗材id
/// </summary>
public int SuppliesId { get; set; }
/// <summary>
/// 出库数量
/// </summary>
public int Number { get; set; }
/// <summary>
/// 已出库数量
/// </summary>
public int StockOutNum { 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; }
/// <summary>
/// 校区id
/// </summary>
public int SchoolId { get; set; }
/// <summary>
/// 校区名称
/// </summary>
public string SchoolName { get; set; }
}
}
\ No newline at end of file
...@@ -70,5 +70,10 @@ namespace Property.Model.Entity ...@@ -70,5 +70,10 @@ namespace Property.Model.Entity
/// 币种id /// 币种id
/// </summary> /// </summary>
public int CurrencyId { get; set; } public int CurrencyId { get; set; }
/// <summary>
/// 付款对象id (出库时使用)
/// </summary>
public int ClientID { get; set; }
} }
} }
using System;
using System.Collections.Generic;
using Property.Model.Entity;
using REBORN.Common.AOP;
namespace Property.Model.Extend
{
/// <summary>
/// 耗材出库申请明细扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_StockOutApplyForDetail_Extend : RB_Supplies_StockOutApplyForDetail
{
/// <summary>
/// 物料名称
/// </summary>
public string SuppliesName { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string SuppliesNum { get; set; }
/// <summary>
/// 分类名称
/// </summary>
public string CategoryName { get; set; }
/// <summary>
/// 待出库数量
/// </summary>
public int WaitStockOutNum { get; set; }
/// <summary>
/// 品牌
/// </summary>
public string BrandName { get; set; }
/// <summary>
/// 单位
/// </summary>
public string Units { get; set; }
/// <summary>
/// 申请ids
/// </summary>
public string ApplyForIds { get; set; }
/// <summary>
/// 金额
/// </summary>
public decimal Money { get; set; }
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using Property.Model.Entity;
using REBORN.Common.AOP;
namespace Property.Model.Extend
{
/// <summary>
/// 耗材出库申请扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_StockOutApplyFor_Extend : RB_Supplies_StockOutApplyFor
{
/// <summary>
/// 明细列表
/// </summary>
public List<RB_Supplies_StockOutApplyForDetail_Extend> DetailList { get; set; }
/// <summary>
/// 开始时间
/// </summary>
public string StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public string EndTime { get; set; }
/// <summary>
/// 班级名称
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// 物料名称
/// </summary>
public string SuppliesName { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreateByName { get; set; }
/// <summary>
/// 仓库id
/// </summary>
public int WareHouseId { get; set; }
}
}
\ No newline at end of file
...@@ -4098,7 +4098,7 @@ namespace Property.Module.FixedAssets ...@@ -4098,7 +4098,7 @@ namespace Property.Module.FixedAssets
blist = schoolRepository.GetSchoolListRepository(new RB_School_ViewModel() { QSIds = bstr }); blist = schoolRepository.GetSchoolListRepository(new RB_School_ViewModel() { QSIds = bstr });
//获取流程相关信息 //获取流程相关信息
List<Rb_Workflow_AuditRelevance_Extend> warlist = workflow_AuditRelevanceRepository.GetAuditRelevanceList(dmodel.Id); List<Rb_Workflow_AuditRelevance_Extend> warlist = workflow_AuditRelevanceRepository.GetAuditRelevanceList(dmodel.Id, "", null, 2);
List<Rb_Workflow_Auditrecord_Extend> walist = new List<Rb_Workflow_Auditrecord_Extend>(); List<Rb_Workflow_Auditrecord_Extend> walist = new List<Rb_Workflow_Auditrecord_Extend>();
walist = workflow_AuditrecordRepository.GetFinaceAuditRecordList(new Rb_Workflow_Auditrecord_Extend() { WorkFlowId = dmodel.Id, TemplateType = 2 }); walist = workflow_AuditrecordRepository.GetFinaceAuditRecordList(new Rb_Workflow_Auditrecord_Extend() { WorkFlowId = dmodel.Id, TemplateType = 2 });
...@@ -4524,7 +4524,13 @@ namespace Property.Module.FixedAssets ...@@ -4524,7 +4524,13 @@ namespace Property.Module.FixedAssets
Remark = DateTime.Now.ToString("yyyy年MM月dd日") + "生成财务单据", Remark = DateTime.Now.ToString("yyyy年MM月dd日") + "生成财务单据",
detailList, detailList,
RB_Depart_Id = userInfo.RB_Department_Id, RB_Depart_Id = userInfo.RB_Department_Id,
ReFinanceId = ProcurementId ReFinanceId = ProcurementId,
FinanceType = 2,
RB_Group_Id = userInfo.RB_Group_id,
RB_CreateByName = userInfo.emName,
RB_DepartName = userInfo.DepartName,
RB_BranchName = schoolRepository.GetEntity(demodel.SchoolId)?.SName ?? "",
RB_GroupName = userInfo.GroupName
}; };
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey); string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new var resultInfo = new
......
...@@ -55,8 +55,17 @@ namespace Property.Module.FixedAssets ...@@ -55,8 +55,17 @@ namespace Property.Module.FixedAssets
/// 出库单明细 /// 出库单明细
/// </summary> /// </summary>
private readonly RB_Supplies_StockOutDetailRepository supplies_StockOutDetailRepository = new RB_Supplies_StockOutDetailRepository(); private readonly RB_Supplies_StockOutDetailRepository supplies_StockOutDetailRepository = new RB_Supplies_StockOutDetailRepository();
/// <summary>
/// 校区
/// </summary>
private readonly RB_SchoolRepository schoolRepository = new RB_SchoolRepository(); private readonly RB_SchoolRepository schoolRepository = new RB_SchoolRepository();
/// <summary>
/// 部门
/// </summary>
private readonly RB_DepartmentRepository departmentRepository = new RB_DepartmentRepository(); private readonly RB_DepartmentRepository departmentRepository = new RB_DepartmentRepository();
/// <summary>
/// 人员
/// </summary>
private readonly RB_AccountRepository employeeRepository = new RB_AccountRepository(); private readonly RB_AccountRepository employeeRepository = new RB_AccountRepository();
//耗材申请 //耗材申请
private readonly RB_Supplies_ApplyforRepository supplies_ApplyforRepository = new RB_Supplies_ApplyforRepository(); private readonly RB_Supplies_ApplyforRepository supplies_ApplyforRepository = new RB_Supplies_ApplyforRepository();
...@@ -131,6 +140,14 @@ namespace Property.Module.FixedAssets ...@@ -131,6 +140,14 @@ namespace Property.Module.FixedAssets
/// 付款对象 /// 付款对象
/// </summary> /// </summary>
private readonly RB_ClientBankAccountRepository clientBankAccountRepository = new RB_ClientBankAccountRepository(); private readonly RB_ClientBankAccountRepository clientBankAccountRepository = new RB_ClientBankAccountRepository();
/// <summary>
/// 出库申请
/// </summary>
private readonly RB_Supplies_StockOutApplyForRepository supplies_StockOutApplyForRepository = new RB_Supplies_StockOutApplyForRepository();
/// <summary>
/// 出库申请明细
/// </summary>
private readonly RB_Supplies_StockOutApplyForDetailRepository supplies_StockOutApplyForDetailRepository = new RB_Supplies_StockOutApplyForDetailRepository();
//流程模板 //流程模板
...@@ -3240,8 +3257,6 @@ namespace Property.Module.FixedAssets ...@@ -3240,8 +3257,6 @@ namespace Property.Module.FixedAssets
return false; return false;
} }
} }
#endregion #endregion
#region 物料有效期 #region 物料有效期
...@@ -3961,7 +3976,13 @@ namespace Property.Module.FixedAssets ...@@ -3961,7 +3976,13 @@ namespace Property.Module.FixedAssets
Remark = DateTime.Now.ToString("yyyy年MM月dd日") + "生成财务单据", Remark = DateTime.Now.ToString("yyyy年MM月dd日") + "生成财务单据",
detailList, detailList,
RB_Depart_Id = userInfo.RB_Department_Id, RB_Depart_Id = userInfo.RB_Department_Id,
ReFinanceId = ProcurementId ReFinanceId = ProcurementId,
FinanceType = 2,
RB_Group_Id = userInfo.RB_Group_id,
RB_CreateByName = userInfo.emName,
RB_DepartName = userInfo.DepartName,
RB_BranchName = schoolRepository.GetEntity(demodel.SchoolId)?.SName ?? "",
RB_GroupName = userInfo.GroupName
}; };
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey); string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new var resultInfo = new
...@@ -4253,5 +4274,561 @@ namespace Property.Module.FixedAssets ...@@ -4253,5 +4274,561 @@ namespace Property.Module.FixedAssets
return ApiResult.Success(); return ApiResult.Success();
} }
#endregion #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_Supplies_StockOutApplyFor_Extend> GetSuppliesStockOutApplyForPageList(int pageIndex, int pageSize, RB_Supplies_StockOutApplyFor_Extend demodel, out long count)
{
var list = supplies_StockOutApplyForRepository.GetPageList(pageIndex, pageSize, demodel, out count);
if (list.Any()) {
//查询明细
string Ids = string.Join(",", list.Select(x => x.Id));
var dlist = supplies_StockOutApplyForDetailRepository.GetList(new RB_Supplies_StockOutApplyForDetail_Extend() { RB_Group_Id = demodel.RB_Group_Id, ApplyForIds = Ids });
//查询人员
string createByIds = string.Join(",", list.Select(x => x.CreateBy).Distinct());
var ulist = employeeRepository.GetEmployeeListRepository(new Employee_ViewModel() { Group_Id = demodel.RB_Group_Id, QIds = createByIds });
foreach (var item in list) {
item.DetailList = dlist.Where(x => x.ApplyForId == item.Id).ToList();
item.CreateByName = ulist.Where(x => x.Id == item.CreateBy).FirstOrDefault()?.EmployeeName ?? "";
}
}
return list;
}
/// <summary>
/// 获取耗材出库申请详情
/// </summary>
/// <param name="applyForId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public RB_Supplies_StockOutApplyFor_Extend GetSuppliesStokcOutApplyForInfo(int applyForId, UserInfo userInfo)
{
var model = supplies_StockOutApplyForRepository.GetEntity<RB_Supplies_StockOutApplyFor_Extend>(applyForId);
if (model != null) {
model.DetailList = supplies_StockOutApplyForDetailRepository.GetList(new RB_Supplies_StockOutApplyForDetail_Extend() { RB_Group_Id = userInfo.RB_Group_id, ApplyForId = model.Id });
model.CreateByName = employeeRepository.GetEmployeeInfo(model.CreateBy)?.EmployeeName ?? "";
}
return model;
}
/// <summary>
/// 新增耗材出库申请
/// </summary>
/// <param name="demodel"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public string SetSuppliesStockOutApplyForInfo(RB_Supplies_StockOutApplyFor_Extend demodel, UserInfo userInfo)
{
#region 验证库存是否足够
string suppliesIds = string.Join(",", demodel.DetailList.Select(x => x.SuppliesId).Distinct());
var inventoryList = supplies_InventoryRepository.GetList(new RB_Supplies_Inventory_Extend() { RB_Group_Id = userInfo.RB_Group_id, SuppliesIdStr = suppliesIds });
foreach (var item in demodel.DetailList) {
int num = inventoryList.Where(x => x.SuppliesId == item.SuppliesId).Sum(x => x.Number ?? 0);
int SONumber = demodel.DetailList.Where(x => x.SuppliesId == item.SuppliesId).Sum(x => x.Number);
if (num < SONumber) {
return "耗材" + item.SuppliesName + "(" + item.SuppliesId + ")库存不足,请核实后再试";
}
}
#endregion
if (demodel.Id > 0)
{
var oldModel = supplies_StockOutApplyForRepository.GetEntity(demodel.Id);
if (oldModel == null || oldModel.AuditStatus == 2) { return "状态不正确,无法修改"; }
demodel.TotalNumber = demodel.DetailList.Sum(x => x.Number);
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Supplies_StockOutApplyFor_Extend.TotalNumber),demodel.TotalNumber},
{ nameof(RB_Supplies_StockOutApplyFor_Extend.Remark),demodel.Remark},
{ nameof(RB_Supplies_StockOutApplyFor_Extend.AuditStatus),1},
{ nameof(RB_Supplies_StockOutApplyFor_Extend.AuditEmpId),0},
{ nameof(RB_Supplies_StockOutApplyFor_Extend.AuditRemark),""},
{ nameof(RB_Supplies_StockOutApplyFor_Extend.AuditDate),null},
{ nameof(RB_Supplies_StockOutApplyFor_Extend.UpdateBy), userInfo.EmployeeId},
{ nameof(RB_Supplies_StockOutApplyFor_Extend.UpdateDate), DateTime.Now},
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Supplies_StockOutApplyFor_Extend.Id),
FiledValue=demodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag = supplies_StockOutApplyForRepository.Update(keyValues, wheres);
if (flag) {
var list = supplies_StockOutApplyForDetailRepository.GetList(new RB_Supplies_StockOutApplyForDetail_Extend() { RB_Group_Id = userInfo.RB_Group_id, ApplyForId = demodel.Id });
foreach (var item in demodel.DetailList) {
var oldDetail = list.Where(x => x.ClassId == item.ClassId && x.SuppliesId == item.SuppliesId).FirstOrDefault();
if (oldDetail == null)
{
//新增
supplies_StockOutApplyForDetailRepository.Insert(new RB_Supplies_StockOutApplyForDetail()
{
Id = 0,
ApplyForId = demodel.Id,
ClassId = item.ClassId,
ClassName = item.ClassName,
CourseName = item.CourseName,
CreateBy = demodel.CreateBy,
CreateDate = demodel.CreateDate,
Number = item.Number,
RB_Branch_Id = demodel.RB_Branch_Id,
RB_Group_Id = demodel.RB_Group_Id,
Status = 0,
StockOutNum = 0,
SuppliesId = item.SuppliesId,
UpdateBy = demodel.UpdateBy,
UpdateDate = demodel.UpdateDate,
SchoolId = item.SchoolId,
SchoolName = item.SchoolName
});
}
else {
if (item.Number != oldDetail.Number) {
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Supplies_StockOutApplyForDetail.Number),item.Number}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Supplies_StockOutApplyForDetail.Id),
FiledValue=oldDetail.Id,
OperatorEnum=OperatorEnum.Equal
}
};
supplies_StockOutApplyForDetailRepository.Update(keyValues1, wheres1);
}
}
}
foreach (var item in list) {
var model = demodel.DetailList.Where(x => x.ClassId == item.ClassId && x.SuppliesId == item.SuppliesId).FirstOrDefault();
if (model == null) {
//删除
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Supplies_StockOutApplyForDetail.Status),1}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Supplies_StockOutApplyForDetail.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
supplies_StockOutApplyForDetailRepository.Update(keyValues1, wheres1);
}
}
return "";
}
return "出错了,请联系管理员";
}
else
{
demodel.FinanceIds = "[]";
demodel.TotalNumber = demodel.DetailList.Sum(x => x.Number);
var applyForId = supplies_StockOutApplyForRepository.Insert(demodel);
if (applyForId > 0)
{
//插入明细
foreach (var item in demodel.DetailList)
{
supplies_StockOutApplyForDetailRepository.Insert(new RB_Supplies_StockOutApplyForDetail()
{
Id = 0,
ApplyForId = applyForId,
ClassId = item.ClassId,
ClassName = item.ClassName,
CourseName = item.CourseName,
CreateBy = demodel.CreateBy,
CreateDate = demodel.CreateDate,
Number = item.Number,
RB_Branch_Id = demodel.RB_Branch_Id,
RB_Group_Id = demodel.RB_Group_Id,
Status = 0,
StockOutNum = 0,
SuppliesId = item.SuppliesId,
UpdateBy = demodel.UpdateBy,
UpdateDate = demodel.UpdateDate,
SchoolId = item.SchoolId,
SchoolName = item.SchoolName
});
}
return "";
}
return "出错了,请联系管理员";
}
}
/// <summary>
/// 获取出库申请实体
/// </summary>
/// <param name="applyForId"></param>
/// <returns></returns>
public RB_Supplies_StockOutApplyFor_Extend GetSuppliesStokcOutApplyForEntry(int applyForId)
{
return supplies_StockOutApplyForRepository.GetEntity<RB_Supplies_StockOutApplyFor_Extend>(applyForId);
}
/// <summary>
/// 设置出库申请状态
/// </summary>
/// <param name="applyForId"></param>
/// <param name="type"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool SetSuppliesStockOutApplyForState(int applyForId, int type, string remark, UserInfo userInfo)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>();
if (type == 1)
{
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.Status), 1);
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.UpdateBy), userInfo.EmployeeId);
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.UpdateDate), DateTime.Now);
}
else if (type == 2)
{
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.AuditStatus), 2);
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.AuditEmpId), userInfo.EmployeeId);
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.AuditRemark), remark);
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.AuditDate), DateTime.Now);
}
else if (type == 3) {
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.AuditStatus), 3);
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.AuditEmpId), userInfo.EmployeeId);
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.AuditRemark), remark);
keyValues.Add(nameof(RB_Supplies_StockOutApplyFor.AuditDate), DateTime.Now);
}
else {
return false;
}
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Supplies_StockOutApplyFor.Id),
FiledValue=applyForId,
OperatorEnum=OperatorEnum.Equal
}
};
return supplies_StockOutApplyForRepository.Update(keyValues, wheres);
}
/// <summary>
/// 出库
/// </summary>
/// <param name="demodel"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public string SetSuppliesApplyForStockOut(RB_Supplies_StockOutApplyFor_Extend demodel, UserInfo userInfo)
{
var oldModel = supplies_StockOutApplyForRepository.GetEntity(demodel.Id);
if (oldModel == null) { return "出库申请不存在"; }
if (oldModel.AuditStatus != 2) { return "未审核通过,无法出库"; }
if (oldModel.StockOutStatus == 3) { return "已出库完毕"; }
var configModel = finance_ConfigRepository.GetList(new RB_Finance_Config_ViewModel() { Group_Id = userInfo.RB_Group_id, Type = FinanceConfigTypeEnum.SuppliesStockOut }).FirstOrDefault();
if (configModel == null) { return "未配置费用/流程信息,请联系管理员"; }
var list = supplies_StockOutApplyForDetailRepository.GetList(new RB_Supplies_StockOutApplyForDetail_Extend() { RB_Group_Id = userInfo.RB_Group_id, ApplyForId = demodel.Id });
List<RB_Supplies_StockOutApplyForDetail_Extend> SuppliesList = new List<RB_Supplies_StockOutApplyForDetail_Extend>();
List<int> ClassIdList = new List<int>();
foreach (var item in demodel.DetailList) {
var model = list.Where(x => x.Id == item.Id).FirstOrDefault();
item.SuppliesId = model.SuppliesId;
item.SuppliesName = model.SuppliesName;
item.Number = model.Number;
item.StockOutNum = model.StockOutNum;
if (item.Number < item.StockOutNum + item.WaitStockOutNum) {
return "耗材" + item.SuppliesName + "(" + item.SuppliesId + ")超过最大出库数量,请核实后再试";
}
item.ClassId = model.ClassId;
item.ClassName = model.ClassName;
item.CourseName = model.CourseName;
item.SchoolId = model.SchoolId;
item.SchoolName = model.SchoolName;
ClassIdList.Add(model.ClassId);
var smodel = SuppliesList.Where(x => x.SuppliesId == item.SuppliesId).FirstOrDefault();
if (smodel == null)
{
SuppliesList.Add(new RB_Supplies_StockOutApplyForDetail_Extend()
{
SuppliesId = item.SuppliesId,
WaitStockOutNum = item.WaitStockOutNum,
SuppliesName = item.SuppliesName,
BrandName = model.BrandName + "(" + item.WaitStockOutNum + "件)"
});
}
else {
smodel.WaitStockOutNum += item.WaitStockOutNum;
smodel.BrandName += ";" + model.BrandName + "(" + item.WaitStockOutNum + "件)";
}
}
#region 验证库存是否足够
string suppliesIds = string.Join(",", demodel.DetailList.Select(x => x.SuppliesId).Distinct());
var inventoryList = supplies_InventoryRepository.GetList(new RB_Supplies_Inventory_Extend() { RB_Group_Id = userInfo.RB_Group_id, WarehouseId = demodel.WareHouseId, SuppliesIdStr = suppliesIds });
foreach (var item in SuppliesList)
{
int num = inventoryList.Where(x => x.SuppliesId == item.SuppliesId).Sum(x => x.Number ?? 0);
if (num < item.WaitStockOutNum)
{
return "耗材" + item.SuppliesName + "(" + item.SuppliesId + ")库存不足,请核实后再试";
}
}
#endregion
var trans = supplies_StockOutApplyForRepository.DbTransaction;
try
{
#region 更新出库数量
foreach (var item in demodel.DetailList)
{
item.StockOutNum += item.WaitStockOutNum;
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Supplies_StockOutApplyForDetail_Extend.StockOutNum),item.StockOutNum}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Supplies_StockOutApplyForDetail_Extend.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
supplies_StockOutApplyForDetailRepository.Update(keyValues, wheres, trans);
}
#endregion
#region 新增出库单
int StockOutId = supplies_StockOutRepository.Insert(new RB_Supplies_StockOut()
{
BranchId = userInfo.RB_Branch_id,
CreateBy = userInfo.EmployeeId,
CreateDate = DateTime.Now,
EmployeeId = oldModel.CreateBy,
DepartmentId = userInfo.RB_Department_Id,
Id = 0,
RB_Branch_Id = userInfo.RB_Branch_id,
RB_Group_Id = userInfo.RB_Group_id,
Remark = "耗材出库-自动生成出库单",
Status = 0,
StockOutDate = DateTime.Now,
StockOutNum = "",
StockOutState = StockOutStatusEnum.StockOut,
UpdateBy = userInfo.EmployeeId,
UpdateDate = DateTime.Now,
WarehouseId = demodel.WareHouseId,
ApplyForId = demodel.Id
}, trans);
if (StockOutId > 0)
{
#region 编码更新
string BMStr = StockOutId.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;
}
}
BMStr = "CK" + DateTime.Now.ToString("yyyyMMdd") + BMStr;
Dictionary<string, object> files = new Dictionary<string, object>() {
{ nameof(RB_Supplies_StockOut.StockOutNum),BMStr}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Supplies_StockOut.Id),
FiledValue=StockOutId,
OperatorEnum=OperatorEnum.Equal
}
};
supplies_StockOutRepository.Update(files, wheres, trans);
#endregion
//新增明细
foreach (var item in SuppliesList)
{
var ilist = supplies_InventoryRepository.GetList(new RB_Supplies_Inventory_Extend() { RB_Group_Id = demodel.RB_Group_Id, WarehouseId = demodel.WareHouseId, SuppliesId = item.SuppliesId });
decimal Price = 0;
if (ilist.Any())
{
var iModel = ilist.FirstOrDefault();
item.Money = Math.Round((iModel.Money ?? 0) / (iModel.Number ?? 1), 2, MidpointRounding.AwayFromZero);
Price = item.Money * item.WaitStockOutNum;
}
supplies_StockOutDetailRepository.Insert(new RB_Supplies_StockOutDetail()
{
CreateBy = demodel.CreateBy,
CreateDate = demodel.CreateDate,
Number = item.WaitStockOutNum,
Money = Price,
RB_Branch_Id = demodel.RB_Branch_Id,
Id = 0,
RB_Group_Id = demodel.RB_Group_Id,
Remark = item.BrandName,
Status = 0,
StockOutId = StockOutId,
SuppliesId = item.SuppliesId,
UpdateBy = demodel.UpdateBy,
UpdateDate = demodel.UpdateDate
}, trans);
//新增库存表数据
if (ilist.Any())
{
var iModel = ilist.FirstOrDefault();
iModel.Number -= item.WaitStockOutNum;//减少库存
iModel.Money -= Price;
if (iModel.Money < 0)
{
iModel.Money = 0;
}
var iflag = supplies_InventoryRepository.Update(iModel, trans);
if (iflag)
{
//增加库存明细
supplies_InventoryDetailRepository.Insert(new RB_Supplies_InventoryDetail()
{
CreateBy = demodel.CreateBy,
CreateDate = DateTime.Now,
InventoryId = iModel.Id,
Number = item.WaitStockOutNum,
Money = Price,
RB_Branch_Id = demodel.RB_Branch_Id,
RB_Group_Id = demodel.RB_Group_Id,
Status = 0,
Type = 2,
Id = 0,
Description = "减少库存-出库"
}, trans);
}
}
}
}
#endregion
#region 生成财务单据
#region 查询所有耗材信息
var materialList = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { RB_Group_Id = userInfo.RB_Group_id, SuppliesIdStr = suppliesIds });
string categoryIds = string.Join(",", materialList.Select(x => x.CategoryId).Distinct());
var cateList = property_CategoryRepository.GetList(new RB_Property_Category_Extend() { RB_Group_Id = demodel.RB_Group_Id, CategoryIdStr = categoryIds });
#endregion
List<int> FinanceIdList = JsonConvert.DeserializeObject<List<int>>(oldModel.FinanceIds);
string FinanceRematk = oldModel.Remark;
//根据班级区分 每个班级生成一张财务单据
ClassIdList = ClassIdList.Distinct().ToList();
foreach (var classId in ClassIdList)
{
var dlist = demodel.DetailList.Where(x => x.ClassId == classId).ToList();
var dmodel = dlist.FirstOrDefault();
#region 生成财务单据
var detailList = new List<object>();
decimal TotalCostMoney = 0;
int SchoolId = dmodel?.SchoolId ?? 0;
foreach (var item in dlist)
{
var mModel = materialList.Where(x => x.Id == item.SuppliesId).FirstOrDefault();
decimal UnitPrice = SuppliesList.Where(x => x.SuppliesId == item.SuppliesId).FirstOrDefault()?.Money ?? 0;
detailList.Add(new
{
configModel.CostTypeId,
Number = item.WaitStockOutNum,
OriginalMoney = UnitPrice * item.WaitStockOutNum,
UnitPrice,
Remark = item.ClassName + " " + mModel.Name + "(" + mModel.SuppliesNum + ") "
});
TotalCostMoney += UnitPrice * item.WaitStockOutNum;
}
var financeObj = new
{
demodel.CreateBy,
IsPublic = 0,//存货出库
ClientType = 10,
configModel.ClientID,
configModel.CurrencyId,
WBMoney = TotalCostMoney,
RB_Branch_Id = SchoolId,
PayDate = DateTime.Now.ToString("yyyy-MM-dd"),
TemplateId = configModel.TempleteId,
OrderSource = 17,
OtherType = 33,
Remark = DateTime.Now.ToString("yyyy年MM月dd日") + "生成财务单据",
detailList,
RB_Depart_Id = userInfo.RB_Department_Id,
ReFinanceId = StockOutId,
ReFinanceId2 = demodel.Id,
TCIDList = new List<int>() { classId },
FinanceType = 2,
RB_Group_Id = userInfo.RB_Group_id,
RB_CreateByName = userInfo.emName,
RB_DepartName = userInfo.DepartName,
RB_BranchName = schoolRepository.GetEntity(SchoolId)?.SName ?? "",
RB_GroupName = userInfo.GroupName
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
{
msg = sign,
};
string apiResult = HttpHelper.HttpPost(Config.PaymentFinanceApi, JsonHelper.Serialize(resultInfo), "");
JObject parmsJob = JObject.Parse(apiResult);
int frid = parmsJob.GetInt("data", 0);
#endregion
if (frid > 0)
{
FinanceIdList.Add(frid);
FinanceRematk += dmodel?.ClassName + "生成单据" + frid + ";";
}
else
{
FinanceRematk += dmodel?.ClassName + "生成单据失败;";
}
}
#endregion
#region 更新申请单
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Supplies_StockOutApplyFor_Extend.FinanceIds),JsonConvert.SerializeObject(FinanceIdList)},
{ nameof(RB_Supplies_StockOutApplyFor_Extend.Remark),FinanceRematk},
};
if (demodel.DetailList.Where(x => x.Number > x.StockOutNum).Any())
{
keyValues1.Add(nameof(RB_Supplies_StockOutApplyFor_Extend.StockOutStatus), 2);
}
else
{
keyValues1.Add(nameof(RB_Supplies_StockOutApplyFor_Extend.StockOutStatus), 3);
}
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Supplies_StockOutApplyFor_Extend.Id),
FiledValue=demodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
supplies_StockOutApplyForRepository.Update(keyValues1, wheres1);
#endregion
supplies_StockOutApplyForRepository.DBSession.Commit();
return "";
}
catch (Exception ex)
{
supplies_StockOutApplyForRepository.DBSession.Rollback();
LogHelper.Write(ex, "SetSuppliesApplyForStockOut");
return "出错了,请联系管理员";
}
}
#endregion
} }
} }
...@@ -3965,7 +3965,7 @@ namespace Property.Module.FixedAssets ...@@ -3965,7 +3965,7 @@ namespace Property.Module.FixedAssets
{ {
ApplyForList = new List<int>() { usemodel.CreateBy ?? 0 }; ApplyForList = new List<int>() { usemodel.CreateBy ?? 0 };
} }
var flag = InsertAuditRelevanceNext(tempModel, modelNext, usemodel.CreateBy ?? 0, userInfo.EmployeeId, usemodel.Id, ApplyForList, trans, out AuditAccountList, 0); var flag = InsertAuditRelevanceNext(tempModel, modelNext, usemodel.CreateBy ?? 0, userInfo.EmployeeId, usemodel.Id, ApplyForList, trans, out AuditAccountList, 2);
if (flag == false) if (flag == false)
{ {
workflow_AuditRelevanceRepository.DBSession.Rollback(); workflow_AuditRelevanceRepository.DBSession.Rollback();
...@@ -4109,7 +4109,7 @@ namespace Property.Module.FixedAssets ...@@ -4109,7 +4109,7 @@ namespace Property.Module.FixedAssets
{ {
ApplyForList = new List<int>() { usemodel.CreateBy ?? 0 }; ApplyForList = new List<int>() { usemodel.CreateBy ?? 0 };
} }
var flag = InsertAuditRelevanceNext(tempModel, modelNext, usemodel.CreateBy ?? 0, userInfo.EmployeeId, usemodel.Id, ApplyForList, trans, out AuditAccountList, 0); var flag = InsertAuditRelevanceNext(tempModel, modelNext, usemodel.CreateBy ?? 0, userInfo.EmployeeId, usemodel.Id, ApplyForList, trans, out AuditAccountList, 2);
if (flag == false) if (flag == false)
{ {
workflow_AuditRelevanceRepository.DBSession.Rollback(); workflow_AuditRelevanceRepository.DBSession.Rollback();
...@@ -4196,7 +4196,7 @@ namespace Property.Module.FixedAssets ...@@ -4196,7 +4196,7 @@ namespace Property.Module.FixedAssets
{ {
ApplyForList = new List<int>() { usemodel.CreateBy ?? 0 }; ApplyForList = new List<int>() { usemodel.CreateBy ?? 0 };
} }
var flag = InsertAuditRelevanceNext(tempModel, modelNext, usemodel.CreateBy ?? 0, userInfo.EmployeeId, usemodel.Id, ApplyForList, trans, out AuditAccountList, 0); var flag = InsertAuditRelevanceNext(tempModel, modelNext, usemodel.CreateBy ?? 0, userInfo.EmployeeId, usemodel.Id, ApplyForList, trans, out AuditAccountList, 2);
if (flag == false) if (flag == false)
{ {
workflow_AuditRelevanceRepository.DBSession.Rollback("Audit审核失败22,单号:" + WorkFlowId); workflow_AuditRelevanceRepository.DBSession.Rollback("Audit审核失败22,单号:" + WorkFlowId);
......
...@@ -124,7 +124,7 @@ left join rb_property_category pc on pb.CategoryId = pc.Id ...@@ -124,7 +124,7 @@ left join rb_property_category pc on pb.CategoryId = pc.Id
{ {
where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.BuyStatus) + "=" + (int)dmodel.BuyStatus; where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.BuyStatus) + "=" + (int)dmodel.BuyStatus;
} }
if (dmodel.SchoolId > 0) if (dmodel.SchoolId >= 0)
{ {
where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.SchoolId) + "=" + dmodel.SchoolId; where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.SchoolId) + "=" + dmodel.SchoolId;
} }
...@@ -147,6 +147,7 @@ left join rb_property_category pc on pb.CategoryId = pc.Id ...@@ -147,6 +147,7 @@ left join rb_property_category pc on pb.CategoryId = pc.Id
if (dmodel.IsWaitDeal == 1) if (dmodel.IsWaitDeal == 1)
{ {
where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.ManagersId) + "=" + dmodel.ManagersId; where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.ManagersId) + "=" + dmodel.ManagersId;
where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.BuyStatus) + "=" + (int)BuyingRequisitionStatusEnum.Purchased;
where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.ProcurementId) + "=0"; where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.ProcurementId) + "=0";
} }
if (dmodel.AuditEmId > 0) if (dmodel.AuditEmId > 0)
...@@ -155,14 +156,14 @@ left join rb_property_category pc on pb.CategoryId = pc.Id ...@@ -155,14 +156,14 @@ left join rb_property_category pc on pb.CategoryId = pc.Id
where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditStatus) + "=" + (int)WFRrocessStatus.NotAudit; where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditStatus) + "=" + (int)WFRrocessStatus.NotAudit;
where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.BuyStatus) + "=" + (int)BuyingRequisitionStatusEnum.Pending;//需要申请单在审核中 where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.BuyStatus) + "=" + (int)BuyingRequisitionStatusEnum.Pending;//需要申请单在审核中
where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.SpecialNode) + " !=" + (int)WFSpecialNodeEnum.Pay;//排除签名的 where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.SpecialNode) + " !=" + (int)WFSpecialNodeEnum.Pay;//排除签名的
where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.TemplateType) + " =0"; where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.TemplateType) + " =2";
} }
if (dmodel.AuditedEmId > 0) if (dmodel.AuditedEmId > 0)
{ {
where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditEmId) + "=" + dmodel.AuditedEmId; where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditEmId) + "=" + dmodel.AuditedEmId;
where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditStatus) + " in(" + (int)WFRrocessStatus.AuditThrough + "," + (int)WFRrocessStatus.AuditNotThrough + "," + (int)WFRrocessStatus.Rejected + ")"; where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditStatus) + " in(" + (int)WFRrocessStatus.AuditThrough + "," + (int)WFRrocessStatus.AuditNotThrough + "," + (int)WFRrocessStatus.Rejected + ")";
where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.SpecialNode) + " !=" + (int)WFSpecialNodeEnum.Pay;//排除签名的 where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.SpecialNode) + " !=" + (int)WFSpecialNodeEnum.Pay;//排除签名的
where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.TemplateType) + " =0"; where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.TemplateType) + " =2";
} }
string sql = $@" select pu.*,pc.Name as CategoryName from string sql = $@" select pu.*,pc.Name as CategoryName from
RB_Property_BuyingRequisition pu RB_Property_BuyingRequisition pu
...@@ -225,6 +226,7 @@ LEFT JOIN rb_workflow_auditrelevance war on wa.AuditId=war.Id ...@@ -225,6 +226,7 @@ LEFT JOIN rb_workflow_auditrelevance war on wa.AuditId=war.Id
if (dmodel.IsWaitDeal == 1) if (dmodel.IsWaitDeal == 1)
{ {
where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.ManagersId) + "=" + dmodel.ManagersId; where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.ManagersId) + "=" + dmodel.ManagersId;
where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.BuyStatus) + "=" + (int)BuyingRequisitionStatusEnum.Purchased;
where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.ProcurementId) + "=0"; where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.ProcurementId) + "=0";
} }
if (dmodel.AuditEmId > 0) if (dmodel.AuditEmId > 0)
...@@ -233,22 +235,23 @@ LEFT JOIN rb_workflow_auditrelevance war on wa.AuditId=war.Id ...@@ -233,22 +235,23 @@ LEFT JOIN rb_workflow_auditrelevance war on wa.AuditId=war.Id
where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditStatus) + "=" + (int)WFRrocessStatus.NotAudit; where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditStatus) + "=" + (int)WFRrocessStatus.NotAudit;
where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.BuyStatus) + "=" + (int)BuyingRequisitionStatusEnum.Pending;//需要申请单在审核中 where += " and pu." + nameof(RB_Property_BuyingRequisition_Extend.BuyStatus) + "=" + (int)BuyingRequisitionStatusEnum.Pending;//需要申请单在审核中
where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.SpecialNode) + " !=" + (int)WFSpecialNodeEnum.Pay;//排除签名的 where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.SpecialNode) + " !=" + (int)WFSpecialNodeEnum.Pay;//排除签名的
where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.TemplateType) + " =0"; where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.TemplateType) + " =2";
} }
if (dmodel.AuditedEmId > 0) if (dmodel.AuditedEmId > 0)
{ {
where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditEmId) + "=" + dmodel.AuditedEmId; where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditEmId) + "=" + dmodel.AuditedEmId;
where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditStatus) + " in(" + (int)WFRrocessStatus.AuditThrough + "," + (int)WFRrocessStatus.AuditNotThrough + "," + (int)WFRrocessStatus.Rejected + ")"; where += " and wa." + nameof(Rb_Workflow_Auditrecord.AuditStatus) + " in(" + (int)WFRrocessStatus.AuditThrough + "," + (int)WFRrocessStatus.AuditNotThrough + "," + (int)WFRrocessStatus.Rejected + ")";
where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.SpecialNode) + " !=" + (int)WFSpecialNodeEnum.Pay;//排除签名的 where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.SpecialNode) + " !=" + (int)WFSpecialNodeEnum.Pay;//排除签名的
where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.TemplateType) + " =0"; where += " and war." + nameof(Rb_Workflow_AuditRelevance_Extend.TemplateType) + " =2";
} }
string sql = $@" string sql = $@"
select count(pu.Id) as Number from SELECT COUNT(0) as Number FROM(
select pu.Id from
RB_Property_BuyingRequisition pu RB_Property_BuyingRequisition pu
left join rb_workflow_auditrecord wa on pu.Id=wa.WorkFlowId left join rb_workflow_auditrecord wa on pu.Id=wa.WorkFlowId
LEFT JOIN rb_workflow_auditrelevance war on wa.AuditId=war.Id LEFT JOIN rb_workflow_auditrelevance war on wa.AuditId=war.Id
{where} group by pu.Id"; {where} group by pu.Id)t";
return Get<RB_Property_UseReceive_Extend>(sql).FirstOrDefault()?.Number ?? 0; return Get<RB_Property_UseReceive_Extend>(sql).FirstOrDefault()?.Number ?? 0;
} }
} }
......
...@@ -45,6 +45,10 @@ namespace Property.Repository ...@@ -45,6 +45,10 @@ namespace Property.Repository
if (dmodel.CategoryId > 0) { if (dmodel.CategoryId > 0) {
where += " and sm." + nameof(RB_Supplies_Material_Extend.CategoryId) + "=" + dmodel.CategoryId; where += " and sm." + nameof(RB_Supplies_Material_Extend.CategoryId) + "=" + dmodel.CategoryId;
} }
if (dmodel.FeeType > 0)
{
where += " and pc." + nameof(RB_Supplies_Material_Extend.FeeType) + "=" + dmodel.FeeType;
}
string sql = $@" select sm.*,pc.Name as CategoryName from RB_Supplies_Material sm string sql = $@" select sm.*,pc.Name as CategoryName from RB_Supplies_Material sm
left join rb_property_category pc on sm.CategoryId=pc.Id left join rb_property_category pc on sm.CategoryId=pc.Id
......
using Property.Model.Entity;
using Property.Model.Extend;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dapper;
namespace Property.Repository
{
/// <summary>
/// 耗材出库申请明细仓储类
/// </summary>
public partial class RB_Supplies_StockOutApplyForDetailRepository : RepositoryBase<RB_Supplies_StockOutApplyForDetail>
{
/// <summary>
/// 获取岗位分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_StockOutApplyForDetail_Extend> GetPageList(int pageIndex, int pageSize, RB_Supplies_StockOutApplyForDetail_Extend dmodel, out long count)
{
DynamicParameters parms = new DynamicParameters();
string where = " where 1=1 ";
where += string.Format(" AND pc.{0}={1}", nameof(RB_Supplies_StockOutApplyForDetail_Extend.Status), 0);
where += $@" and pc.RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.ApplyForId > 0)
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyForDetail_Extend.ApplyForId) + "=" + dmodel.ApplyForId;
}
if (!string.IsNullOrEmpty(dmodel.ApplyForIds))
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyForDetail_Extend.ApplyForId) + " in(" + dmodel.ApplyForIds + ")";
}
string sql = $@" select pc.* from RB_Supplies_StockOutApplyForDetail pc
{where} order by pc.Id desc";
return GetPage<RB_Supplies_StockOutApplyForDetail_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Supplies_StockOutApplyForDetail_Extend> GetList(RB_Supplies_StockOutApplyForDetail_Extend dmodel)
{
DynamicParameters parms = new DynamicParameters();
string where = " where 1=1 ";
where += string.Format(" AND pc.{0}={1}", nameof(RB_Supplies_StockOutApplyForDetail_Extend.Status), 0);
where += $@" and pc.RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.ApplyForId > 0)
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyForDetail_Extend.ApplyForId) + "=" + dmodel.ApplyForId;
}
if (!string.IsNullOrEmpty(dmodel.ApplyForIds))
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyForDetail_Extend.ApplyForId) + " in(" + dmodel.ApplyForIds + ")";
}
string sql = $@" select pc.*,m.Name as SuppliesName,m.SuppliesNum,m.BrandName,m.Units,c.Name as CategoryName from RB_Supplies_StockOutApplyForDetail pc
left join rb_supplies_material m on m.Id = pc.SuppliesId
left join rb_property_category c on c.Id = m.CategoryId
{where} order by pc.Id desc";
return Get<RB_Supplies_StockOutApplyForDetail_Extend>(sql).ToList();
}
}
}
using Property.Model.Entity;
using Property.Model.Extend;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dapper;
namespace Property.Repository
{
/// <summary>
/// 耗材出库申请仓储类
/// </summary>
public partial class RB_Supplies_StockOutApplyForRepository : RepositoryBase<RB_Supplies_StockOutApplyFor>
{
/// <summary>
/// 获取分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_StockOutApplyFor_Extend> GetPageList(int pageIndex, int pageSize, RB_Supplies_StockOutApplyFor_Extend dmodel, out long count)
{
DynamicParameters parms = new DynamicParameters();
string where = " where 1=1 ";
where += string.Format(" AND pc.{0}={1}", nameof(RB_Supplies_StockOutApplyFor_Extend.Status), 0);
where += $@" and pc.RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.AuditStatus > 0)
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyFor_Extend.AuditStatus) + "=" + dmodel.AuditStatus;
}
if (dmodel.StockOutStatus > 0)
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyFor_Extend.StockOutStatus) + "=" + dmodel.StockOutStatus;
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyFor_Extend.CreateDate) + " >='" + dmodel.StartTime + "'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyFor_Extend.CreateDate) + " <='" + dmodel.EndTime + " 23:59:59'";
}
if (!string.IsNullOrEmpty(dmodel.ClassName))
{
where += " and pc2.ClassName like @ClassName";
parms.Add("ClassName", "%" + dmodel.ClassName + "%");
}
if (!string.IsNullOrEmpty(dmodel.SuppliesName))
{
where += " and m.Name like @SuppliesName";
parms.Add("SuppliesName", "%" + dmodel.SuppliesName + "%");
}
string sql = $@" select pc.* from RB_Supplies_StockOutApplyFor pc
left join rb_supplies_stockoutapplyfordetail pc2 on pc.Id=pc2.ApplyForId
left join rb_supplies_material m on pc2.SuppliesId = m.Id
{where} group by pc.Id order by pc.Id desc";
return GetPage<RB_Supplies_StockOutApplyFor_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Supplies_StockOutApplyFor_Extend> GetList(RB_Supplies_StockOutApplyFor_Extend dmodel)
{
DynamicParameters parms = new DynamicParameters();
string where = " where 1=1 ";
where += string.Format(" AND pc.{0}={1}", nameof(RB_Supplies_StockOutApplyFor_Extend.Status), 0);
where += $@" and pc.RB_Group_Id={dmodel.RB_Group_Id}";
if (dmodel.AuditStatus > 0)
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyFor_Extend.AuditStatus) + "=" + dmodel.AuditStatus;
}
if (dmodel.StockOutStatus > 0)
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyFor_Extend.StockOutStatus) + "=" + dmodel.StockOutStatus;
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyFor_Extend.CreateDate) + " >='" + dmodel.StartTime + "'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += " and pc." + nameof(RB_Supplies_StockOutApplyFor_Extend.CreateDate) + " <='" + dmodel.EndTime + " 23:59:59'";
}
if (!string.IsNullOrEmpty(dmodel.ClassName))
{
where += " and pc2.ClassName like @ClassName";
parms.Add("ClassName", "%" + dmodel.ClassName + "%");
}
if (!string.IsNullOrEmpty(dmodel.SuppliesName))
{
where += " and m.Name like @SuppliesName";
parms.Add("SuppliesName", "%" + dmodel.SuppliesName + "%");
}
string sql = $@" select pc.* from RB_Supplies_StockOutApplyFor pc
left join rb_supplies_stockoutapplyfordetail pc2 on pc.Id=pc2.ApplyForId
left join rb_supplies_material m on pc2.SuppliesId = m.Id
{where} group by pc.Id order by pc.Id desc";
return Get<RB_Supplies_StockOutApplyFor_Extend>(sql).ToList();
}
}
}
...@@ -3050,5 +3050,265 @@ namespace Property.WebApi.Controllers.User ...@@ -3050,5 +3050,265 @@ namespace Property.WebApi.Controllers.User
return suppliesModule.SetSuppliesProcurementStockIn(demodel, userInfo); return suppliesModule.SetSuppliesProcurementStockIn(demodel, userInfo);
} }
#endregion #endregion
#region 耗材出库申请
/// <summary>
/// 获取耗材出库申请分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetSuppliesStockOutApplyForPageList()
{
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(requestParm.msg.ToString());
RB_Supplies_StockOutApplyFor_Extend demodel = JsonConvert.DeserializeObject<RB_Supplies_StockOutApplyFor_Extend>(requestParm.msg.ToString());
demodel.RB_Group_Id = userInfo.RB_Group_id;
var list = suppliesModule.GetSuppliesStockOutApplyForPageList(pagelist.pageIndex, pagelist.pageSize, demodel, out long count);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.TotalNumber,
x.Remark,
x.FinanceIds,
FinanceIdList = JsonConvert.DeserializeObject<List<int>>(x.FinanceIds),
x.StockOutStatus,
x.AuditStatus,
x.AuditRemark,
DetailList = x.DetailList.Select(z=>new {
z.Id,
z.ClassId,
z.ClassName,
z.CourseName,
z.SuppliesId,
z.SuppliesName,
z.SuppliesNum,
z.CategoryName,
z.BrandName,
z.Units,
z.Number,
z.StockOutNum
}),
x.CreateBy,
x.CreateByName,
CreateDate = x.CreateDate.ToString("yyyy-MM-dd HH:mm")
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取耗材出库申请明细
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetSuppliesStockOutApplyForInfo() {
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
var parms = JObject.Parse(requestParm.msg.ToString());
int ApplyForId = parms.GetInt("ApplyForId", 0);
if (ApplyForId <= 0) {
return ApiResult.ParamIsNull("请传递申请id");
}
var model = suppliesModule.GetSuppliesStokcOutApplyForInfo(ApplyForId, userInfo);
if (model == null) { return ApiResult.ParamIsNull("该申请单不存在"); }
var Robj = new
{
model.Id,
model.TotalNumber,
model.Remark,
model.FinanceIds,
FinanceIdList = JsonConvert.DeserializeObject<List<int>>(model.FinanceIds),
model.StockOutStatus,
model.AuditStatus,
model.AuditRemark,
DetailList = model.DetailList.Select(z => new {
z.Id,
z.ClassId,
z.ClassName,
z.CourseName,
z.SuppliesId,
z.SuppliesName,
z.SuppliesNum,
z.CategoryName,
z.BrandName,
z.Units,
z.Number,
z.StockOutNum
}),
model.CreateBy,
model.CreateByName,
CreateDate = model.CreateDate.ToString("yyyy-MM-dd HH:mm")
};
return ApiResult.Success("", Robj);
}
/// <summary>
/// 新增出库申请
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetSuppliesStockOutApplyForInfo() {
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
RB_Supplies_StockOutApplyFor_Extend demodel = JsonConvert.DeserializeObject<RB_Supplies_StockOutApplyFor_Extend>(requestParm.msg.ToString());
if (demodel.DetailList == null || !demodel.DetailList.Any()) {
return ApiResult.ParamIsNull("请选择出库耗材");
}
List<int> ClassIdList = new List<int>();
foreach (var item in demodel.DetailList) {
if (item.ClassId <= 0) {
return ApiResult.ParamIsNull("请传递班级id");
}
if (string.IsNullOrEmpty(item.ClassName)) {
return ApiResult.ParamIsNull("请传递班级名称");
}
if (string.IsNullOrEmpty(item.CourseName)) {
return ApiResult.ParamIsNull("请传递课程名称");
}
if (item.SchoolId <= 0) {
return ApiResult.ParamIsNull("请传递校区id");
}
if (string.IsNullOrEmpty(item.SchoolName)) {
return ApiResult.ParamIsNull("请传递校区名称");
}
if (item.SuppliesId <= 0) {
return ApiResult.ParamIsNull("请传递耗材id");
}
if (item.Number <= 0) {
return ApiResult.ParamIsNull("请传递出库数量");
}
ClassIdList.Add(item.ClassId);
}
ClassIdList = ClassIdList.Distinct().ToList();
foreach (var item in ClassIdList) {
var classList = demodel.DetailList.Where(x => x.ClassId == item).ToList();
if (classList.Count() != classList.Select(x => x.SuppliesId).Distinct().Count()) {
return ApiResult.Failed("班级(" + item + ")存在重复数量,请核实后再试");
}
}
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;
demodel.StockOutStatus = 1;
demodel.AuditStatus = 1;
demodel.AuditRemark = "";
demodel.AuditEmpId = 0;
string msg = suppliesModule.SetSuppliesStockOutApplyForInfo(demodel, userInfo);
if (msg == "")
{
return ApiResult.Success();
}
else {
return ApiResult.Failed(msg);
}
}
/// <summary>
/// 设置出库申请状态
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetSuppliesStockOutApplyForState() {
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
var parms = JObject.Parse(requestParm.msg.ToString());
int ApplyForId = parms.GetInt("ApplyForId", 0);
int Type = parms.GetInt("Type", 1);//类型 1取消 2审核通过 3审核驳回
string Remark = parms.GetStringValue("Remark");
if (ApplyForId <= 0)
{
return ApiResult.ParamIsNull("请传递申请id");
}
var model = suppliesModule.GetSuppliesStokcOutApplyForEntry(ApplyForId);
if (model == null) { return ApiResult.Failed("出库申请不存在"); }
if (model.Status == 1) { return ApiResult.Failed("已取消,无法操作"); }
if (Type == 1)
{
if (model.AuditStatus != 1 && model.AuditStatus != 3)
{
return ApiResult.Failed("状态不正确,请核实后再试");
}
}
else
{
if (model.AuditStatus != 1)
{
return ApiResult.Failed("状态不正确,请核实后再试");
}
}
bool flag = suppliesModule.SetSuppliesStockOutApplyForState(ApplyForId, Type, Remark, userInfo);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
/// <summary>
/// 设置出库数量
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetSuppliesApplyForStockOut() {
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
RB_Supplies_StockOutApplyFor_Extend demodel = JsonConvert.DeserializeObject<RB_Supplies_StockOutApplyFor_Extend>(requestParm.msg.ToString());
if (demodel.Id <= 0)
{
return ApiResult.ParamIsNull("请传递出库申请id");
}
if (demodel.WareHouseId <= 0)
{
return ApiResult.ParamIsNull("请选择出库仓库");
}
if (demodel.DetailList == null || !demodel.DetailList.Any())
{
return ApiResult.ParamIsNull("请选择出库耗材");
}
demodel.DetailList = demodel.DetailList.Where(x => x.WaitStockOutNum > 0).ToList();
foreach (var item in demodel.DetailList)
{
if (item.Id <= 0)
{
return ApiResult.ParamIsNull("请传递出库申请明细id");
}
if (item.WaitStockOutNum <= 0)
{
return ApiResult.ParamIsNull("请传递出库数量");
}
}
//判断当前仓库是否在盘点中2020-07-28 Add By:W
var suppliesCheckList = suppliesModule.GetSuppliesCheckList(new RB_Supplies_Check_Extend { RB_Group_Id = userInfo.RB_Group_id, StartDate = System.DateTime.Now, EndDate = System.DateTime.Now, WarehouseId = demodel.WareHouseId, CheckState = REBORN.Common.Enum.SuppliesCheckStatusEnum.InTheInventory });
if (suppliesCheckList != null && suppliesCheckList.Any())
{
return ApiResult.ParamIsNull("仓库盘点中,不能出库");
}
string msg = suppliesModule.SetSuppliesApplyForStockOut(demodel, userInfo);
if (msg == "")
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed(msg);
}
}
#endregion
} }
} }
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