|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
|
using DS.WMS.Core.Code.Entity;
|
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Fee.Interface;
|
|
|
|
@ -26,6 +27,11 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static readonly FeeStatus[] AuditStatusArray = [FeeStatus.AuditSubmitted, FeeStatus.ApplyDeletion, FeeStatus.ApplyModification];
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 一键审核支持的类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static readonly string[] AuditTypes = [FeeAuditType.ApplyAudit.ToString(), FeeAuditType.ApplyModification.ToString(), FeeAuditType.ApplyDeletion.ToString()];
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作流运行状态值
|
|
|
|
|
/// </summary>
|
|
|
|
@ -53,26 +59,25 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult<List<FeeAuditBusiness>> GetListByPage(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var flowList = db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus && x.MakerList.Contains(user.UserId))
|
|
|
|
|
.Select(x => new { x.BusinessId, x.BusinessType }).ToList();
|
|
|
|
|
var flowList = db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus
|
|
|
|
|
&& SqlFunc.SplitIn(x.MakerList, user.UserId) && AuditTypes.Contains(x.AuditType))
|
|
|
|
|
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType }).ToList();
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (flowList.Count == 0)
|
|
|
|
|
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var queryList = GetDataQuery(tenantDb);
|
|
|
|
|
var bidList = flowList.Select(x => x.BusinessId);
|
|
|
|
|
queryList = queryList.Where(x => bidList.Contains(x.Id));
|
|
|
|
|
var queryList = CreateQuery(tenantDb, flowList);
|
|
|
|
|
//queryList = queryList.Where(x => SqlFunc.Subqueryable<FlowInstance>().Where(
|
|
|
|
|
// y => y.BusinessId == x.Id && y.BusinessType == x.BusinessType && SqlFunc.SplitIn(y.MakerList, user.UserId)).Any());
|
|
|
|
|
|
|
|
|
|
List<IConditionalModel> whereList = null;
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
|
|
|
|
|
if (whereList != null)
|
|
|
|
|
{
|
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
queryList = queryList.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = queryList.ToQueryPage(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
if (result.Data.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//关联用户名称
|
|
|
|
@ -94,16 +99,20 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取各项业务数据的查询并集
|
|
|
|
|
internal static ISugarQueryable<FeeAuditBusiness> GetDataQuery(SqlSugarScopeProvider tenantDb)
|
|
|
|
|
//创建各项业务数据的查询并集
|
|
|
|
|
internal static ISugarQueryable<FeeAuditBusiness> CreateQuery(SqlSugarScopeProvider tenantDb, IEnumerable<FlowInstance> additions)
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var query1 = tenantDb.Queryable<SeaExport, BusinessFeeStatus, FeeRecord>((s, b, f) => new JoinQueryInfos(
|
|
|
|
|
var ids1 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingExport).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
var query1 = tenantDb.Queryable<SeaExport, BusinessFeeStatus, FeeRecord, CodeSource, CodeSourceDetail>((s, b, f, cs, csd) => new JoinQueryInfos(
|
|
|
|
|
JoinType.Left, s.Id == b.BusinessId && b.BusinessType == BusinessType.OceanShippingExport,
|
|
|
|
|
JoinType.Inner, s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport && AuditStatusArray.Contains(f.FeeStatus)
|
|
|
|
|
JoinType.Inner, s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport && AuditStatusArray.Contains(f.FeeStatus),
|
|
|
|
|
JoinType.Left,s.SourceId == cs.Id,
|
|
|
|
|
JoinType.Left, s.SourceDetailId == csd.Id
|
|
|
|
|
))
|
|
|
|
|
.WhereIF(ids1 != null && ids1.Length > 0, (s, b, f) => ids1.Contains(f.Id))
|
|
|
|
|
.GroupBy(s => s.Id)
|
|
|
|
|
.Select((s, b, f) => new FeeAuditBusiness
|
|
|
|
|
.Select((s, b, f, cs, csd) => new FeeAuditBusiness
|
|
|
|
|
{
|
|
|
|
|
Id = s.Id,
|
|
|
|
|
AccountDate = SqlFunc.ToDate(s.AccountDate),
|
|
|
|
@ -113,8 +122,6 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
BusinessStatus = s.BusinessStatusName,
|
|
|
|
|
BusinessDate = s.BusinessDate,//业务日期
|
|
|
|
|
BLType = s.BLType,
|
|
|
|
|
//BookingCompany = //订舱公司
|
|
|
|
|
//BusinessUnit = //经营单位
|
|
|
|
|
CargoId = s.CargoId,
|
|
|
|
|
Carrier = s.Carrier,
|
|
|
|
|
AgencyId = s.AgentId,
|
|
|
|
@ -133,6 +140,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
DischargePort = s.DischargePort,
|
|
|
|
|
Doc = s.Doc,
|
|
|
|
|
ETD = s.ETD,
|
|
|
|
|
Forwarder = s.Forwarder,
|
|
|
|
|
GoodsName = s.GoodsName,
|
|
|
|
|
HBLNO = s.HBLNO,
|
|
|
|
|
InvoiceNo = s.InvoiceNo,
|
|
|
|
@ -150,17 +158,29 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
ReceiptPlace = s.ReceiptPlace,
|
|
|
|
|
Remark = s.Remark,
|
|
|
|
|
SaleDeptId = s.SaleDeptId,
|
|
|
|
|
SaleId = s.SaleId,//揽货人
|
|
|
|
|
SaleName = s.Sale,
|
|
|
|
|
//SaleDeptName //所属部门
|
|
|
|
|
SaleId = s.SaleId,
|
|
|
|
|
SaleName = s.Sale,//揽货人
|
|
|
|
|
SourceId = s.SourceId,
|
|
|
|
|
SourceName = cs.SourceName,
|
|
|
|
|
SourceDetailId = s.SourceDetailId,
|
|
|
|
|
DetailName = csd.DetailName,
|
|
|
|
|
TradeTerm = s.TradeTerm,
|
|
|
|
|
TransitTerms = s.Service,//运输条款
|
|
|
|
|
Vessel = s.Vessel,//船名
|
|
|
|
|
Voyage = s.Voyno,//航次
|
|
|
|
|
Yard = s.Yard
|
|
|
|
|
//BusinessUnit = //经营单位
|
|
|
|
|
//ChangeOrder //更改单
|
|
|
|
|
//ChangeReason //更改单更改原因
|
|
|
|
|
//FreightRatio //运杂费比例
|
|
|
|
|
//查询:运输类型 (枚举值,暂未建立)
|
|
|
|
|
//查询:是否费用提交
|
|
|
|
|
//查询:利润减少
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//海运进口
|
|
|
|
|
//var ids2 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingImport).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
|
|
|
|
|
return tenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusiness>> { query1 });
|
|
|
|
|
}
|
|
|
|
@ -234,22 +254,16 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <param name="yesOrNo">审批结果:1=通过,2=驳回</param>
|
|
|
|
|
/// <param name="remark">备注</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult AuditBusiness(int yesOrNo, string remark)
|
|
|
|
|
public DataResult Audit(int yesOrNo, string remark)
|
|
|
|
|
{
|
|
|
|
|
var flowList = db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus && x.MakerList.Contains(user.UserId))
|
|
|
|
|
.Select(x => new { x.BusinessId, x.BusinessType }).ToList();
|
|
|
|
|
var recordIds = db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus &&
|
|
|
|
|
SqlFunc.SplitIn(x.MakerList, user.UserId) && AuditTypes.Contains(x.AuditType))
|
|
|
|
|
.Select(x => x.BusinessId).ToArray();
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (flowList.Count == 0)
|
|
|
|
|
if (recordIds.Length == 0)
|
|
|
|
|
return DataResult.Failed("当前暂无待审批的费用");
|
|
|
|
|
|
|
|
|
|
var request = new FeeBizAuditRequest
|
|
|
|
|
{
|
|
|
|
|
Items = flowList.Select(x => new BizAudit { Id = x.BusinessId, BusinessType = x.BusinessType }).ToList(),
|
|
|
|
|
Remark = remark,
|
|
|
|
|
Result = yesOrNo
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return AuditBusiness(request);
|
|
|
|
|
return Audit(yesOrNo, remark, recordIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -282,7 +296,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
return DataResult.Failed("业务的审批状态不正确");
|
|
|
|
|
|
|
|
|
|
var fIdArr = bizList.Select(x => x.FlowId).ToArray();
|
|
|
|
|
var flows = db.Queryable<FlowInstance>().Where(x => fIdArr.Contains(x.Id)).ToList();
|
|
|
|
|
string auditType = FeeAuditType.Business.ToString();
|
|
|
|
|
var flows = db.Queryable<FlowInstance>().Where(x => fIdArr.Contains(x.Id) && x.AuditType == auditType).ToList();
|
|
|
|
|
|
|
|
|
|
if (flows.Count == 0)
|
|
|
|
|
return DataResult.Failed("未能获取审批工作流");
|
|
|
|
|