44673626 3 years ago
parent
commit
dc2a7312fb
  1. 83
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSJitAppService.cs
  2. 125
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs
  3. 116
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs
  4. 32
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs
  5. 186
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SharePartUnSettledDapperRepository.cs
  6. 112
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SharePartUnSettledExport.cs
  7. 1
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/SettleAccount/SettleAccountImportService.cs

83
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSJitAppService.cs

@ -396,7 +396,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
{
_billNum = string.Empty;
}
return _billNum;
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 出库界面功能,核准出库功能
@ -410,45 +410,48 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
{
if (input.Guids != null)
{
List<WmsJitOutPutDetial> _ls = new List<WmsJitOutPutDetial>();
if (input.Guids.Count() > 0)
{
_ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.State != 2).ToListAsync();
}
else
{
_ls = await _wmsRepository.Where(p => p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync();
}
if (_ls.Count() > 0)
{
foreach (var itm in _ls)
{
itm.State = 1;
}
await _wmsRepository.GetDbContext().BulkUpdateAsync(_ls);
//var _first = _ls.FirstOrDefault();
//var _guid = GuidGenerator.Create();
//foreach (var itm in _ls)
//{
// itm.TaskId = _guid;
//}
//await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls);
//var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", version, "WmsJitOutPutDetail",_first.BillNum, 0,0 ,_guid)
//{
// TaskId = _guid,
// SourceBillNum = _first.BillNum,
// TableName = "WmsJitOutPutDetail",
// InterfaceType = "1",
// Version = version,
// SettleAccountState = 0,
// WmsState=0
//};
//var _l = new List<TS_UNI_API>();
//_l.Add(uniapi);
//await _wmsefRespository.GetDbContext().BulkInsertAsync(_l);
}
var sql = "DECLARE @return_value int\n" +
"EXEC @return_value = [dbo].[p_wms_output]\n" +
" @billnum = N'{0}',\n" +
" @type = 0\n" +
"SELECT 'Return Value' = @return_value";
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync(
string.Format(sql,input.BillNum)
);
//List<WmsJitOutPutDetial> _ls = new List<WmsJitOutPutDetial>();
//if (input.Guids.Count() > 0)
//{
// _ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.State != 2).ToListAsync();
//}
//else
//{
// _ls = await _wmsRepository.Where(p => p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync();
//}
//if (_ls.Count() > 0)
//{
// //var _first = _ls.FirstOrDefault();
// //var _guid = GuidGenerator.Create();
// //foreach (var itm in _ls)
// //{
// // itm.TaskId = _guid;
// //}
// //await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls);
// //var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", version, "WmsJitOutPutDetail",_first.BillNum, 0,0 ,_guid)
// //{
// // TaskId = _guid,
// // SourceBillNum = _first.BillNum,
// // TableName = "WmsJitOutPutDetail",
// // InterfaceType = "1",
// // Version = version,
// // SettleAccountState = 0,
// // WmsState=0
// //};
// //var _l = new List<TS_UNI_API>();
// //_l.Add(uniapi);
// //await _wmsefRespository.GetDbContext().BulkInsertAsync(_l);
//}
}
return true;

125
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs

@ -57,7 +57,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
[AllowAnonymous]
[Route("api/settleaccount/wmskanbanoutput")]
public class WMSKanbanAppService :
ApplicationService
SettleAccountApplicationBase<WmsKanbanOutPutDetial>
{
private readonly ISettleAccountBranchEfCoreRepository<WmsKanbanOutPutDetial, Guid> _wmsRepository;
@ -68,6 +68,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
private readonly ISettleAccountBranchEfCoreRepository<TaskJob, Guid> _job;
private readonly IExcelImportAppService _excelImportService;
private readonly TaskJobService _service;
/// <summary>
///
@ -86,8 +87,11 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
ISettleAccountBranchEfCoreRepository<TaskJob, Guid> job,
ISettleAccountBranchEfCoreRepository<WmsKanbanOutPut, Guid> wmsVersionRepository,
WMSEfCoreRepository<WmsKanbanOutPutDetial> wmsefRespository,
WMSEfCoreRepository<TB_BILL> wmstbRespository
)
WMSEfCoreRepository<TB_BILL> wmstbRespository,
IDistributedCache<WmsKanbanOutPutDetial> cache,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_job = job;
_wmstbRespository = wmstbRespository;
@ -200,40 +204,66 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
}
var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList();
var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version).ToListAsync();
var query = from itm1 in _ls1
join itm2 in outPutDetail on
new { itm1.MaterialCode, itm1.Kanban }
var error = from itm1 in outPutDetail
join itm2 in _ls1 on
new { itm1.MaterialCode, itm1.Kanban}
equals
new { itm2.MaterialCode, itm2.Kanban } into temp1
from tm1 in temp1.DefaultIfEmpty()
where tm1 == null
new { itm2.MaterialCode, itm2.Kanban }
select itm1;
var _wmslst = query.ToList();
foreach (var itm in _wmslst)
{
itm.BillNum = _billNum;
}
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 });
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum);
if (_count == 0)
var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) });
if (errList.Count() == 0)
{
var _version = new WmsKanbanOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email);
await _wmsVersionRepository.InsertAsync(_version, true);
var query = from itm1 in _ls1
join itm2 in outPutDetail on
new { itm1.MaterialCode, itm1.Kanban }
equals
new { itm2.MaterialCode, itm2.Kanban } into temp1
from tm1 in temp1.DefaultIfEmpty()
where tm1 == null
select itm1;
var _wmslst = query.ToList();
foreach (var itm in _wmslst)
{
itm.BillNum = _billNum;
}
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 });
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum);
if (_count == 0)
{
var _version = new WmsKanbanOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email);
}
await _wmsVersionRepository.InsertAsync(_version, true);
}
foreach (var job in _joblist)
foreach (var job in _joblist)
{
job.FileName = _billNum;
await _job.UpdateAsync(job);
}
}
else
{
job.FileName = _billNum;
await _job.UpdateAsync(job);
StringBuilder _buffer = new StringBuilder();
foreach (var itm in errList)
{
_buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number);
}
var _errinfo = _buffer.ToString();
foreach (var job in _joblist)
{
job.FileName = _errinfo;
await _job.UpdateAsync(job);
}
}
}
else
{
_billNum = string.Empty;
}
return _billNum;
return ApplicationConsts.SuccessStr; ;
}
/// <summary>
/// 出库界面功能,核准出库功能
@ -258,26 +288,33 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
}
if (_ls.Count() > 0)
{
var _first = _ls.FirstOrDefault();
var _guid = GuidGenerator.Create();
foreach (var itm in _ls)
{
itm.TaskId = _guid;
}
await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls);
var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", input.Version, "WmsKanbanOutPutDetail",_first.BillNum, 0,0 ,_guid)
{
TaskId = _guid,
SourceBillNum = _first.BillNum,
TableName = "WmsKanbanOutPutDetail",
InterfaceType = "2",
Version = input.Version,
SettleAccountState = 0,
WmsState=0
};
var _l = new List<TS_UNI_API>();
_l.Add(uniapi);
await _wmsefRespository.GetDbContext().BulkInsertAsync(_l);
var sql = "DECLARE @return_value int\n" +
"EXEC @return_value = [dbo].[p_wms_output]\n" +
" @billnum = N'{0}',\n" +
" @type = 1\n" +
"SELECT 'Return Value' = @return_value";
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync(
string.Format(sql, input.BillNum));
//var _first = _ls.FirstOrDefault();
//var _guid = GuidGenerator.Create();
//foreach (var itm in _ls)
//{
// itm.TaskId = _guid;
//}
//await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls);
//var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", input.Version, "WmsKanbanOutPutDetail",_first.BillNum, 0,0 ,_guid)
//{
// TaskId = _guid,
// SourceBillNum = _first.BillNum,
// TableName = "WmsKanbanOutPutDetail",
// InterfaceType = "2",
// Version = input.Version,
// SettleAccountState = 0,
// WmsState=0
//};
//var _l = new List<TS_UNI_API>();
//_l.Add(uniapi);
//await _wmsefRespository.GetDbContext().BulkInsertAsync(_l);
}
}
return true;

116
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs

@ -200,41 +200,68 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
}
var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList();
var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version).ToListAsync();
var query = from itm1 in _ls1
join itm2 in outPutDetail on
var error = from itm1 in outPutDetail
join itm2 in _ls1 on
new { itm1.MaterialCode, itm1.OrderBillNum }
equals
new { itm2.MaterialCode, itm2.OrderBillNum } into temp1
from tm1 in temp1.DefaultIfEmpty()
where tm1 == null
new { itm2.MaterialCode, itm2.OrderBillNum }
select itm1;
var _wmslst = query.ToList();
foreach (var itm in _wmslst)
var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) });
if (errList.Count() == 0)
{
itm.BillNum = _billNum;
var query = from itm1 in _ls1
join itm2 in outPutDetail on
new { itm1.MaterialCode, itm1.OrderBillNum }
equals
new { itm2.MaterialCode, itm2.OrderBillNum } into temp1
from tm1 in temp1.DefaultIfEmpty()
where tm1 == null
select itm1;
var _wmslst = query.ToList();
foreach (var itm in _wmslst)
{
itm.BillNum = _billNum;
}
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 });
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum);
if (_count == 0)
{
var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email);
await _wmsVersionRepository.InsertAsync(_version, true);
}
foreach (var job in _joblist)
{
job.FileName = _billNum;
await _job.UpdateAsync(job);
}
}
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 });
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum);
if (_count == 0)
else
{
var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email);
//var _ls = new List<WmsSharePartOutPut>();
//_ls.Add(_version);
await _wmsVersionRepository.InsertAsync(_version, true);
StringBuilder _buffer = new StringBuilder();
foreach (var itm in errList)
{
_buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number);
}
var _errinfo = _buffer.ToString();
}
foreach (var job in _joblist)
{
job.FileName = _errinfo;
await _job.UpdateAsync(job);
}
foreach (var job in _joblist)
{
job.FileName = _billNum;
await _job.UpdateAsync(job);
}
}
else
{
_billNum = string.Empty;
}
return _billNum;
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 出库界面功能,核准出库功能
@ -259,26 +286,33 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
}
if (_ls.Count() > 0)
{
var _first = _ls.FirstOrDefault();
var _guid = GuidGenerator.Create();
foreach (var itm in _ls)
{
itm.TaskId = _guid;
}
await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls);
var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", input.Version, "WmsSharePartOutPutDetail",_first.BillNum, 0,0 ,_guid)
{
TaskId = _guid,
SourceBillNum = _first.BillNum,
TableName = "WmsSharePartOutPutDetail",
InterfaceType = "3",
Version = input.Version,
SettleAccountState = 0,
WmsState=0
};
var _l = new List<TS_UNI_API>();
_l.Add(uniapi);
await _wmsefRespository.GetDbContext().BulkInsertAsync(_l);
var sql = "DECLARE @return_value int\n" +
"EXEC @return_value = [dbo].[p_wms_output]\n" +
" @billnum = N'{0}',\n" +
" @type = 2\n" +
"SELECT 'Return Value' = @return_value";
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync(
string.Format(sql, input.BillNum));
//var _first = _ls.FirstOrDefault();
//var _guid = GuidGenerator.Create();
//foreach (var itm in _ls)
//{
// itm.TaskId = _guid;
//}
//await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls);
//var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", input.Version, "WmsSharePartOutPutDetail",_first.BillNum, 0,0 ,_guid)
//{
// TaskId = _guid,
// SourceBillNum = _first.BillNum,
// TableName = "WmsSharePartOutPutDetail",
// InterfaceType = "3",
// Version = input.Version,
// SettleAccountState = 0,
// WmsState=0
//};
//var _l = new List<TS_UNI_API>();
//_l.Add(uniapi);
//await _wmsefRespository.GetDbContext().BulkInsertAsync(_l);
}
}
return true;

32
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs

@ -56,22 +56,22 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode ";
string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version);
if (!string.IsNullOrEmpty(purchaseOrderNo))
{
addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo);
}
else if (!string.IsNullOrEmpty(sapCode))
{
addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode);
}
else if (!string.IsNullOrEmpty(matialCode))
{
addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode);
}
else if (!string.IsNullOrEmpty(begintime)&& !string.IsNullOrEmpty(endtime))
{
addwhere += string.Format(" AND OrderDate BETWEEN '{0}' AND '{1}' ", begintime, endtime);
}
//if (!string.IsNullOrEmpty(purchaseOrderNo))
//{
// addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo);
//}
//else if (!string.IsNullOrEmpty(sapCode))
//{
// addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode);
//}
//else if (!string.IsNullOrEmpty(matialCode))
//{
// addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode);
//}
//else if (!string.IsNullOrEmpty(begintime)&& !string.IsNullOrEmpty(endtime))
//{
// addwhere += string.Format(" AND OrderDate BETWEEN '{0}' AND '{1}' ", begintime, endtime);
//}
string _sql = string.Format(addSqlStr, addwhere);
//string _sql = string.Format(sqlString, version);

186
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SharePartUnSettledDapperRepository.cs

@ -0,0 +1,186 @@
using Dapper;
using Magicodes.ExporterAndImporter.Core;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories.Dapper;
using Volo.Abp.EntityFrameworkCore;
using Win.Sfs.SettleAccount.Entities.FISes;
using Win.Sfs.SettleAccount.FISes;
//using Win.Sfs.Shared.Enums.SettleAccount;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
public class SharePartUnSettled
{
[ExporterHeader(DisplayName = "交货单号")]
public string WMSDeliveryNote {set;get;}
[ExporterHeader(DisplayName = "发货日期")]
public string OrderDate {set;get;}
[ExporterHeader(DisplayName = "订单编号")]
public string PurchaseOrderNo {set;get;}
[ExporterHeader(DisplayName = "物料编码")]
public string SAPCode {set;get;}
[ExporterHeader(DisplayName = "客户物料号")]
public string MaterialCode {set;get;}
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDesc {set;get;}
[ExporterHeader(DisplayName = "物料组(车型)")]
public string MaterilGroup {set;get;}
[ExporterHeader(DisplayName = "发货数量")]
//public string PurchaseOrderNoText {set;get;}
public decimal Qty {set;get;}
[ExporterHeader(DisplayName = "收货数量")]
public decimal ReceiptQty {set;get;}
[ExporterHeader(DisplayName = "数量差异")]
public decimal DiffQty {set;get;}
[ExporterHeader(DisplayName = "单价")]
public decimal Price { set; get; }
[ExporterHeader(DisplayName = "差异金额")]
public decimal DiffAMT { set; get; }
//[ExporterHeader(DisplayName = "交货单号")]
//public string WmsBillNum { set; get; }
//[ExporterHeader(DisplayName = "发货日期")]
//public string BeginDate { set; get; }
//[ExporterHeader(DisplayName = "看板号")]
//public string Kanban { set; get; }
//[ExporterHeader(DisplayName = "零件号")]
//public string SapCode { set; get; }
//[ExporterHeader(DisplayName = "零件描述")]
//public string MaterialDesc { set; get; }
//[ExporterHeader(DisplayName = "客户零件号")]
//public string CustomerPartCode { set; get; }
//[ExporterHeader(DisplayName = "物料组")]
//public string MaterialGroup { set; get; }
//[ExporterHeader(DisplayName = "结算数量")]
//public decimal SettleQty { set; get; }
//[ExporterHeader(DisplayName = "发货数量")]
//public decimal Qty { set; get; }
//[ExporterHeader(DisplayName = "量差")]
//public decimal DiffQty { set; get; }
//[ExporterHeader(DisplayName = "单价")]
//public decimal Price { set; get; }
//[ExporterHeader(DisplayName = "差异金额")]
//public decimal DiffAMT { set; get; }
}
public class SharePartUnSettledExtend
{
[ExporterHeader(DisplayName = "物料编码")]
public string SAPCode {set;get;}
[ExporterHeader(DisplayName = "客户物料号")]
public string MaterialCode {set;get;}
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDesc {set;get;}
[ExporterHeader(DisplayName = "物料组(车型)")]
public string MaterilGroup {set;get;}
[ExporterHeader(DisplayName = "发货数量")]
public string Qty {set;get;}
[ExporterHeader(DisplayName = "收货数量")]
public string ReceiptQty {set;get;}
[ExporterHeader(DisplayName = "数量差异")]
public string DiffQty {set;get;}
[ExporterHeader(DisplayName = "单价")]
public decimal Price { set; get; }
[ExporterHeader(DisplayName = "差异金额")]
public string DiffAMT { set; get; }
}
public class SharePartUnSettledDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{
public SharePartUnSettledDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public virtual List<SharePartUnSettled> GetKanbanReportList( string version, string begintime, string endtime)
{
var sql = "SELECT\n" +
" temp1.*,\n" +
" ( temp2.Price * temp1.DiffQty ) DiffAMT, \n" +
" temp2.Price \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" A.WMSDeliveryNote,\n" +
" A.SpareDate AS OrderDate,\n" +
" a.PurchaseOrderNo,\n" +
" C.MaterialCode AS SAPCode,\n" +
" a.MaterialCode,\n" +
" C.MaterialDesc,\n" +
" C.EstimateTypeDesc MaterilGroup,\n" +
" a.PurchaseOrderNoText,\n" +
" A.ReceiptQty Qty,\n" +
" ISNULL( B.ReceiptQty, 0 ) ReceiptQty,\n" +
" ISNULL( A.ReceiptQty, 0 )- ISNULL( B.ReceiptQty, 0 ) DiffQty \n" +
" FROM\n" +
" Set_WmsSparePart A\n" +
" LEFT JOIN Set_SparePart B ON A.PurchaseOrderNo = B.PurchaseOrderNo \n" +
" AND A.MaterialCode = B.MaterialCode\n" +
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n" +
" ) temp1\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" Price,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_PriceList \n" +
"WHERE\n" +
" version = ( SELECT MAX( Version ) FROM Set_PriceList )) temp2 ON temp1.SAPCode = temp2.MaterialCode";
string str = string.Empty;
str += " where 1=1 ";
var _query = DbConnection.Query<SharePartUnSettled>(sql, null, null, true, 1200, null);
var _list = _query.ToList();
return _list;
}
public virtual List<SharePartUnSettledExtend> GetNoOrderSharePartReportList( string version, string begintime, string endtime)
{
var sql = "SELECT\n" +
" temp1.*,\n" +
" temp2.Price , Round( temp2.Price * temp1.DiffQty, 2 ) DiffAMT \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" C.MaterialCode AS SAPCode,\n" +
" a.MaterialCode,\n" +
" C.MaterialDesc,\n" +
" C.EstimateTypeDesc MaterilGroup,\n" +
" A.Qty,\n" +
" ISNULL( B.ReceiptQty, 0 ) ReceiptQty,\n" +
" ISNULL( A.Qty, 0 )- ISNULL( B.ReceiptQty, 0 ) DiffQty \n" +
" FROM\n" +
" ( SELECT SUM( ReceiptQty ) Qty, MaterialCode FROM Set_WmsSparePart GROUP BY MaterialCode ) a\n" +
" LEFT JOIN Set_SparePart B ON A.MaterialCode = B.MaterialCode\n" +
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n" +
" ) temp1\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" Price,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_PriceList \n" +
"WHERE\n" +
" version = ( SELECT MAX( Version ) FROM Set_PriceList )) temp2 ON temp1.SAPCode = temp2.MaterialCode";
string str = string.Empty;
str += " where 1=1 ";
var _query = DbConnection.Query<SharePartUnSettledExtend>(sql, null, null, true, 1200, null);
var _list = _query.ToList();
return _list;
}
}
}

112
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SharePartUnSettledExport.cs

@ -0,0 +1,112 @@
using Magicodes.ExporterAndImporter.Excel;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.BlobStoring;
using Volo.Abp.DependencyInjection;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
namespace SettleAccount.Job.Services.Report
{
public class SharePartUnSettledExport : ITransientDependency, IExportJob
{
private readonly OutputService _outputService;
KanbanUnSettledDapperRepository _dapper;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
public SharePartUnSettledExport(KanbanUnSettledDapperRepository dapper, OutputService outputService,
IBlobContainer<MyFileContainer> fileContainer
)
{
_dapper = dapper;
_outputService = outputService;
_fileContainer = fileContainer;
}
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list)
{
var _filename = exportName.FirstOrDefault();
var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value;
var materialCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value;
var begin = p_list.Where(p => p.Name == "BeginTime").FirstOrDefault().Value;
var end = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value;
var cp7begin = p_list.Where(p => p.Name == "Cp7BeginTime").FirstOrDefault().Value;
var cp7end = p_list.Where(p => p.Name == "Cp7EndTime").FirstOrDefault().Value;
var kenncode = p_list.Where(p => p.Name == "KennCode").FirstOrDefault().Value;
var chassisNumber = p_list.Where(p => p.Name == "ChassisNumber").FirstOrDefault().Value;
var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value;
var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value;
var _ls = _dapper.GetKanbanReportList(version, begin,end);
var _lst = _dapper.GetNoKanbanReportList(version, begin, end);
if (!string.IsNullOrEmpty(materialGroup))
{
var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_ls = _ls.Where(p => _groupList.Contains(p.MaterialGroup)).ToList();
}
}
if (!string.IsNullOrEmpty(materialCode))
{
var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_ls = _ls.Where(p => _groupList.Contains(p.CustomerPartCode)).ToList();
}
}
if (!string.IsNullOrEmpty(sapCode))
{
var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_ls = _ls.Where(p => _groupList.Contains(p.SapCode)).ToList();
}
}
if (!string.IsNullOrEmpty(materialGroup))
{
var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_lst = _lst.Where(p => _groupList.Contains(p.MaterialGroup)).ToList();
}
}
if (!string.IsNullOrEmpty(materialCode))
{
var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_lst = _lst.Where(p => _groupList.Contains(p.MaterialCode)).ToList();
}
}
if (!string.IsNullOrEmpty(sapCode))
{
var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_lst = _lst.Where(p => _groupList.Contains(p.SapCode)).ToList();
}
}
ExcelExporter _exporter = new ExcelExporter();//导出Excel
var result = _exporter.Append(_ls.ToList(), "有看板号未结差异对比")
.SeparateBySheet()
.Append(_lst.ToList(), "无看板号未结差异对比")
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(_filename, result.Result, true);
return id.ToString();
}
}
}

1
src/Modules/SettleAccount/src/SettleAccount.Job/Services/SettleAccount/SettleAccountImportService.cs

@ -52,7 +52,6 @@ namespace TaskJob.Services
//_versionRepository.Delete(version);
//_repository.Delete(version);
List<Win.Sfs.SettleAccount.Entities.SettleAccounts.SettleAccount> _setls = new List<Win.Sfs.SettleAccount.Entities.SettleAccounts.SettleAccount>();
var _id = Guid.NewGuid();
foreach (var itm in fileName)
{

Loading…
Cancel
Save