Browse Source

更新版本

branch_ccpg_220107
Administrator 3 years ago
parent
commit
e8823190ca
  1. 41
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSJitAppService.cs
  2. 17
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS-KanBan/WmsKanban.cs
  3. 149
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs
  4. 119
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs

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

@ -57,7 +57,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
[AllowAnonymous]
[Route("api/settleaccount/wmsjitoutput")]
public class WMSJitAppService :
ApplicationService
SettleAccountApplicationBase<WmsJitOutPutDetial>
{
private readonly ISettleAccountBranchEfCoreRepository<WmsJitOutPutDetial, Guid> _wmsRepository;
private readonly ISettleAccountBranchEfCoreRepository<WmsJitOutPut, Guid> _wmsVersionRepository;
@ -76,12 +76,15 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
/// <param name="wmstbRespository"></param>
public WMSJitAppService(
IExcelImportAppService excelImportService,
ISettleAccountBranchEfCoreRepository<WmsJitOutPutDetial, Guid> wmsRepository,
ISettleAccountBranchEfCoreRepository<WmsJitOutPutDetial, Guid> wmsRepository,
ISettleAccountBranchEfCoreRepository<TaskJob, Guid> job,
ISettleAccountBranchEfCoreRepository<WmsJitOutPut, Guid> wmsVersionRepository,
WMSEfCoreRepository<WmsJitOutPutDetial> wmsefRespository,
WMSEfCoreRepository<TB_BILL> wmstbRespository
)
WMSEfCoreRepository<TB_BILL> wmstbRespository,
IDistributedCache<WmsJitOutPutDetial> cache,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_job = job;
_wmstbRespository = wmstbRespository;
@ -129,8 +132,38 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
}
_lst.AddRange(_lsCopy.ToArray());
var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList();
var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync();
var error = from itm1 in outPutDetail
join itm2 in _ls1 on
new { itm1.MaterialCode, itm1.KennCode, itm1.ChassisNumber }
equals
new { itm2.MaterialCode, itm2.KennCode, itm2.ChassisNumber }
select itm1;
var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) });
var checkList = new List<ErrorExportDto>();
foreach (var itm in errList)
{
checkList.Add( new ErrorExportDto() { Message = string.Format("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number) });
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
var query = from itm1 in _ls1
join itm2 in outPutDetail on
new { itm1.MaterialCode, itm1.KennCode, itm1.ChassisNumber }

17
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS-KanBan/WmsKanban.cs

@ -15,36 +15,19 @@ namespace Win.Sfs.SettleAccount.Entities.WMS_KanBan
/// </summary>
public DateTime BeginTime { set; get; }
/// <summary>
///
/// </summary>
public string Version { set; get; }
/// <summary>
/// 零件号
/// </summary>
public string MaterialCode { set; get; }
/// <summary>
/// 用量
/// </summary>
public decimal Qty { set; get; }
}
}

149
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs

@ -0,0 +1,149 @@
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 KanbanUnSettled
{
[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 KanbanUnSettledExtend
{
[ExporterHeader(DisplayName = "客户物料号")]
public string MaterialCode { set; get; }
[ExporterHeader(DisplayName = "物料号")]
public string SapCode { set; get; }
[ExporterHeader(DisplayName = "物料名称")]
public string MaterialDesc { set; get; }
//[ExporterHeader(DisplayName = "ERP物料号")]
//public string CustomerPartCode { set; get; }
[ExporterHeader(DisplayName = "物料组车型")]
public string MaterialGroup { set; get; }
[ExporterHeader(DisplayName = "发货数量")]
public string Qty { set; get; }
[ExporterHeader(DisplayName = "结算数量")]
public string SettleQty { set; get; }
[ExporterHeader(DisplayName = "量差")]
public string DiffQty { set; get; }
[ExporterHeader(DisplayName = "单价")]
public string Price { set; get; }
[ExporterHeader(DisplayName = "差异金额")]
public string DiffAMT { set; get; }
}
public class KanbanUnSettledDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{
public KanbanUnSettledDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public virtual List<KanbanUnSettled> GetKanbanReportList( string version, string begintime, string endtime)
{
string sql = " SELECT\n" +
" TEMP1.*,\n" +
" TEMP2.Price,\n" +
" ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.WMSDeliveryNote WmsBillNum,\n" +
" a.WMSActualGoodsDate BeginDate,\n" +
" a.Kanban,\n" +
" C.MaterialCode SapCode,\n" +
" C.MaterialDesc,\n" +
" C.CustomerPartCode,\n" +
" C.EstimateTypeDesc MaterialGroup,\n" +
" ISNULL( B.Qty, 0 ) SettleQty,\n" +
" a.Qty,\n" +
" (\n" +
" a.Qty - ISNULL( b.Qty, 0 )) AS DiffQty \n" +
" FROM\n" +
" Set_WMSKanBanSettle A\n" +
" LEFT JOIN ( SELECT * FROM Set_KanBanSettle WHERE version = '{0}' ) B ON A.Kanban = B.Kanban \n" +
" AND A.MaterialCode = B.MaterialCode\n" +
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n" +
" ) TEMP1\n" +
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE 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<KanbanUnSettled>(sql, null, null, true, 1200, null);
var _list = _query.ToList();
return _list;
}
public virtual List<KanbanUnSettledExtend> GetNoKanbanReportList( string version, string begintime, string endtime)
{
var sql = "SELECT\n" +
" TEMP1.*,\n" +
" TEMP2.Price,\n" +
" ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.MaterialCode,\n" +
" C.MaterialCode SapCode,\n" +
" C.MaterialDesc,\n" +
" C.CustomerPartCode,\n" +
" C.EstimateTypeDesc MaterialGroup,\n" +
" isnull( a.Qty, 0 ) Qty,\n" +
" isnull( b.Qty, 0 ) SettleQty,\n" +
" isnull( a.Qty, 0 )- isnull( b.Qty, 0 ) DiffQty \n" +
" FROM\n" +
" ( SELECT SUM( Qty ) Qty, MaterialCode FROM Set_WMSKanBanSettle WHERE PartType = 1 GROUP BY MaterialCode ) a\n" +
" LEFT JOIN ( SELECT sum( qty ) Qty, MaterialCode FROM Set_KanBanSettle GROUP BY MaterialCode ) b ON a.MaterialCode = b.MaterialCode\n" +
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n" +
" ) temp1\n" +
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE 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<KanbanUnSettledExtend>(sql, null, null, true, 1200, null);
var _list = _query.ToList();
return _list;
}
}
}

119
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs

@ -0,0 +1,119 @@
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 KanBanUnSettledExport : ITransientDependency, IExportJob
{
private readonly OutputService _outputService;
KanbanUnSettledDapperRepository _dapper;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
public KanBanUnSettledExport(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();
}
}
}
Loading…
Cancel
Save