Browse Source

红旗未结核对代码

FoShanPG
44673626 3 years ago
parent
commit
db445b1e26
  1. 24
      src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/UnHQSettleAccounts/UnHQSettleExportDto.cs
  2. 31
      src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs
  3. 11
      src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  4. 238
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs
  5. 302
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs
  6. 139
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQFactoryUnSettledDetailDiffExportService.cs

24
src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/UnHQSettleAccounts/UnHQSettleExportDto.cs

@ -17,8 +17,8 @@ namespace Win.Sfs.SettleAccount.Entities.UnHQSettleAccounts
/// <summary> /// <summary>
///外部看板编号 ///外部看板编号
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "外部看板编号")] //[ExporterHeader(DisplayName = "外部看板编号")]
public string ExternalKanbanNumber { get; set; } //public string ExternalKanbanNumber { get; set; }
/// <summary> /// <summary>
///看板编号 ///看板编号
/// </summary> /// </summary>
@ -30,16 +30,16 @@ namespace Win.Sfs.SettleAccount.Entities.UnHQSettleAccounts
[ExporterHeader(DisplayName = "物料凭证号")] [ExporterHeader(DisplayName = "物料凭证号")]
public string MaterialVoucherNo { get; set; } public string MaterialVoucherNo { get; set; }
/// <summary> ///// <summary>
///会计年度 /////会计年度
/// </summary> ///// </summary>
[ExporterHeader(DisplayName = "会计年度")] //[ExporterHeader(DisplayName = "会计年度")]
public string Year { get; set; } //public string Year { get; set; }
/// <summary> ///// <summary>
/// 期间 ///// 期间
/// </summary> ///// </summary>
[ExporterHeader(DisplayName = "期间")] //[ExporterHeader(DisplayName = "期间")]
public string Period { set; get; } //public string Period { set; get; }
/// <summary> /// <summary>
/// 版本号 /// 版本号
/// </summary> /// </summary>

31
src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs

@ -29,6 +29,7 @@ using Win.Sfs.SettleAccount.Entities.Wms;
using Win.Sfs.SettleAccount.Entities.WMS; using Win.Sfs.SettleAccount.Entities.WMS;
using Win.Sfs.SettleAccount.FISes; using Win.Sfs.SettleAccount.FISes;
using Win.Sfs.SettleAccount.Reports.ReportRequestDto; using Win.Sfs.SettleAccount.Reports.ReportRequestDto;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
namespace Win.Sfs.SettleAccount.Reports.ReportServices namespace Win.Sfs.SettleAccount.Reports.ReportServices
{ {
@ -720,6 +721,36 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
return _taskid; return _taskid;
} }
/// <summary>
///红旗未结核对
/// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpPost]
[Route("HQFactoryUnSettledDetailDiffExportService")]
[DisableRequestSizeLimit]
public async Task<string> HQFactoryUnSettledDetailDiffExportService(
HQKanbanRequestDto input
)
{
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = input.Version });
customConditionList.Add(new CustomCondition() { Name = "MaterialCode", Value = input.MaterialCode });
customConditionList.Add(new CustomCondition() { Name = "BeginTime", Value = input.Begin });
customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = input.End });
customConditionList.Add(new CustomCondition() { Name = "MaterialCode", Value = input.MaterialCode });
customConditionList.Add(new CustomCondition() { Name = "AcceptNo", Value = input.AcceptNo });
customConditionList.Add(new CustomCondition() { Name = "WarehouseDesc", Value = input.WarehouseDesc });
customConditionList.Add(new CustomCondition() { Name = "Kanban", Value = input.Kanban });
customConditionList.Add(new CustomCondition() { Name = "MaterialGroup", Value = string.IsNullOrEmpty(input.MaterialGroup) ? string.Empty : input.MaterialGroup });
customConditionList.Add(new CustomCondition() { Name = "SapCode", Value = string.IsNullOrEmpty(input.SapCode) ? string.Empty : input.SapCode });
var _taskid = await _service.ExportEnqueueAsync("红旗未结核对", ExportExtentsion.Excel, input.Version, string.IsNullOrEmpty(input.MaterialGroup) ? string.Empty : input.MaterialGroup, CurrentUser, typeof(HQFactorySettledDetailDapperRepository), customConditionList, (rs) =>
{
});
return _taskid;
}
/// <summary> /// <summary>
/// 红旗工厂备件明细 /// 红旗工厂备件明细
/// </summary> /// </summary>

11
src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -427,7 +427,6 @@ namespace Win.Sfs.SettleAccount
/// 红旗明细未结导入 /// 红旗明细未结导入
/// </summary> /// </summary>
private void CreateMapUnHQSettleAccount() private void CreateMapUnHQSettleAccount()
{ {
CreateMap<UnHQSettleAccount, UnHQSettleDto>().ReverseMap(); CreateMap<UnHQSettleAccount, UnHQSettleDto>().ReverseMap();
CreateMap<UnHQSettleAccount, UnHQSettleRequestDto>().ReverseMap(); CreateMap<UnHQSettleAccount, UnHQSettleRequestDto>().ReverseMap();
@ -442,11 +441,11 @@ namespace Win.Sfs.SettleAccount
private void CreateMapUnHQSettleAccountVersion() private void CreateMapUnHQSettleAccountVersion()
{ {
CreateMap<HQ_H_PlatformVersion, HQ_H_PlatformVersionDto>().ReverseMap(); CreateMap<UnHQSettleAccountVersion, UnHQSettleVersionDto>().ReverseMap();
CreateMap<HQ_H_PlatformVersion, HQ_H_PlatformVersionCreateDto>(); CreateMap<UnHQSettleAccountVersion, UnHQSettleVersionCreateDto>();
CreateMap<HQ_H_PlatformVersion, HQ_H_PlatformVersionUpdateDto>(); CreateMap<UnHQSettleAccountVersion, UnHQSettleVersionUpdateDto>();
CreateMap<HQ_H_PlatformVersionCreateDto, HQ_H_PlatformVersion>(); CreateMap<UnHQSettleVersionCreateDto, UnHQSettleAccountVersion>();
CreateMap<HQ_H_PlatformVersionUpdateDto, HQ_H_PlatformVersion>(); CreateMap<UnHQSettleVersionUpdateDto, UnHQSettleAccountVersion>();
} }
/// <summary> /// <summary>

238
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs

@ -0,0 +1,238 @@
using Dapper;
using Magicodes.ExporterAndImporter.Core;
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;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
public class HQFactorySettledDetailDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{
public HQFactorySettledDetailDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
/// <summary>
/// 红旗主机厂未结比对红旗系统未对
/// </summary>
/// <param name="version"></param>
/// <param name="materialCode"></param>
/// <param name="begin"></param>
/// <param name="end"></param>
/// <param name="materialGroup"></param>
/// <returns></returns>
public virtual List<HQFactoryUnSettledDetailDiff> GetHQFactoryDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup)
{
List<HQFactoryUnSettledDetailDiff> _list = new List<HQFactoryUnSettledDetailDiff>();
string condition = " ";
//if (!string.IsNullOrEmpty(begin))
//{
// condition += string.Format(" and a.LastModificationTime>='{0}' ", begin);
//}
//if (!string.IsNullOrEmpty(end))
//{
// condition += string.Format(" and a.LastModificationTime<='{0}' ", end);
//}
string str = "SELECT\n" +
" temp3.StorageLocation 收货仓库,\n" +
" temp3.StorageLocationDesc 收货仓库描述,\n" +
" temp3.HQHKanBan 订货看板编号,\n" +
" temp3.AcceptanceNo 结算验收单号,\n" +
" temp3.MaterialCode Sap编码,\n" +
" temp3.CustomerPartCode 客户物料号,\n" +
" temp3.EstimateTypeDesc 物料组,\n" +
" temp3.MaterialDesc 零件中文名称,\n" +
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
" temp3.UnHQAmt 金额,\n" +
" temp3.系统未结数量,\n" +
" temp3.UnHQQty 红旗未结数量,\n" +
" ( ISNULL( temp3.系统未结数量, 0 ) - ISNULL( temp3.UnHQQty, 0 ) ) 差异 \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" * \n" +
" FROM\n" +
" (\n" +
" SELECT\n" +
" h.StorageLocation,\n" +
" h.StorageLocationDesc,\n" +
" h.HQHKanBan,\n" +
" h.AcceptanceNo,\n" +
" m.MaterialCode,\n" +
" m.CustomerPartCode,\n" +
" m.MaterialDesc,\n" +
" m.EstimateTypeDesc,\n" +
" ISNULL( h.Qty, 0 ) AS UnHQQty,\n" +
" ISNULL( h.Amt, 0 ) AS UnHQAmt \n" +
" FROM\n" +
" Set_UnHQSettleAccount AS h\n" +
" LEFT JOIN Set_material AS m ON h.MaterialCode = m.CustomerPartCode \n" +
" ) AS unhq\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" a.Kanban AS 订货看板编号,\n" +
" b.MaterialCode AS 订货零件号,\n" +
" c.MaterialCode Sap编码,\n" +
" c.CustomerPartCode 客户物料号,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" isnull( a.Qty, 0 ) AS 系统未结数量,\n" +
" b.AcceptanceNo AS 结算验收单号,\n" +
" C.EstimateTypeDesc AS 物料组 \n" +
" FROM\n" +
" Set_HQ_H_Kanban AS a\n" +
" LEFT OUTER JOIN ( SELECT * FROM Set_HQ_H_Platform WHERE HQHKanBan <> 'BJ' ) AS b ON a.Kanban = b.HQHKanBan \n" +
" AND a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" +
" b.HQHKanBan IS NULL \n" +
" AND b.MaterialCode IS NULL \n" +
" ) AS temp1 ON unhq.HQHKanBan = temp1.[订货看板编号] \n" +
" AND unhq.CustomerPartCode= temp1.客户物料号 -- WHERE\n" +
"-- temp1.[订货看板编号] IS NULL \n" +
"-- AND temp1.客户物料号 IS NULL\n" +
" \n" +
" ) temp3\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp3.MaterialCode = TEMP2.MaterialCode";
var _sql = string.Format(str, condition);
var _query = DbConnection.Query<HQFactoryUnSettledDetailDiff>(_sql, null, null, true, 1200, null);
_list = _query.ToList();
return _list;
}
/// <summary>
/// 红旗系统未对比对红旗主机厂未结
/// </summary>
/// <param name="version"></param>
/// <param name="materialCode"></param>
/// <param name="begin"></param>
/// <param name="end"></param>
/// <param name="materialGroup"></param>
/// <returns></returns>
public virtual List<HQFactoryUnSettledDetailDiff> GetSettleToFactoryDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup)
{
List<HQFactoryUnSettledDetailDiff> _list = new List<HQFactoryUnSettledDetailDiff>();
string condition = " ";
if (!string.IsNullOrEmpty(begin))
{
condition += string.Format(" and a.LastModificationTime>='{0}' ", begin);
}
if (!string.IsNullOrEmpty(end))
{
condition += string.Format(" and a.LastModificationTime<='{0}' ", end);
}
string str = "SELECT\n" +
" temp1.交货单号,\n" +
" temp1.交货日期,\n" +
" temp1.收货仓库,\n" +
" temp1.收货仓库描述,\n" +
" temp1.订货看板编号,\n" +
" temp1.结算验收单号,\n" +
" temp1.Sap编码,\n" +
" temp1.[客户物料号],\n" +
" temp1.物料组,\n" +
" temp1.零件中文名称,\n" +
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
" ISNULL( temp1.系统未结数量, 0 ) 系统未结数量,\n" +
" isnull( temp3.Qty, 0 ) AS 红旗未结数量,\n" +
" ( ISNULL( temp1.系统未结数量, 0 ) - ISNULL( temp3.Qty, 0 ) ) 差异 \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.WmsBillNum [交货单号],\n" +
" CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) 交货日期,\n" +
" b.StorageLocation AS 收货仓库,\n" +
" b.StorageLocationDesc AS 收货仓库描述,\n" +
" a.Kanban AS 订货看板编号,\n" +
" c.MaterialCode Sap编码,\n" +
" c.CustomerPartCode 客户物料号,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" isnull( a.Qty, 0 ) AS 系统未结数量,\n" +
" b.AcceptanceNo AS 结算验收单号,\n" +
" C.EstimateTypeDesc AS 物料组 \n" +
" FROM\n" +
" Set_HQ_H_Kanban AS a\n" +
" LEFT OUTER JOIN ( SELECT * FROM Set_HQ_H_Platform WHERE HQHKanBan <> 'BJ' ) AS b ON a.Kanban = b.HQHKanBan \n" +
" AND a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" +
" b.HQHKanBan IS NULL \n" +
" AND b.MaterialCode IS NULL {0}\n" +
" ) AS temp1\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" +
" LEFT JOIN ( SELECT Qty, HQHKanBan, MaterialCode FROM Set_UnHQSettleAccount ) temp3 ON temp1.[结算验收单号] = temp3.HQHKanBan \n" +
" AND temp1.[客户物料号] = temp3.MaterialCode";
var _sql = string.Format(str, condition);
var _query = DbConnection.Query<HQFactoryUnSettledDetailDiff>(_sql, null, null, true, 1200, null);
_list = _query.ToList();
return _list;
}
public class HQFactoryUnSettledDetailDiff
{
[ExporterHeader(DisplayName = "收货仓库")]
public string { set; get; }
[ExporterHeader(DisplayName = "收货仓库描述")]
public string { set; get; }
[ExporterHeader(DisplayName = "订货看板编号")]
public string { set; get; }
[ExporterHeader(DisplayName = "结算验收单号")]
public string { set; get; }
[ExporterHeader(DisplayName = "Sap编码")]
public string Sap编码 { set; get; }
[ExporterHeader(DisplayName = "客户物料号")]
public string { set; get; }
[ExporterHeader(DisplayName = "零件中文名称")]
public string { set; get; }
[ExporterHeader(DisplayName = "物料组")]
public string { set; get; }
[ExporterHeader(DisplayName = "验收单日期",IsIgnore =true)]
public string { set; get; }
[ExporterHeader(DisplayName = "发货定价")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "金额")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "系统未结数量")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "红旗未结数量")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "差异")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "工厂", IsIgnore = true)]
public string { set; get; }
}
}
}

302
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs

@ -70,104 +70,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// condition += string.Format(" and b.LastModificationTime<='{0}' ", end); // condition += string.Format(" and b.LastModificationTime<='{0}' ", end);
//} //}
string str = "SELECT\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" +
" temp1.交货时间,\n" +
" isnull( temp1.手工或自动, '' ) 手工或自动,\n" +
" temp1.[工厂],\n" +
" temp1.收货仓库,\n" +
" temp1.收货仓库描述,\n" +
" temp1.订货看板编号,\n" +
" temp1.订货零件号,\n" +
" temp1.验收单日期,\n" +
" temp1.Sap编码,\n" +
" temp1.看板编号,\n" +
" temp1.物料组,\n" +
" temp1.零件中文名称,\n" +
" temp1.发货数量,\n" +
" temp1.发货状态,\n" +
" temp1.结算验收单号,\n" +
" temp1.结算数量,\n" +
" temp3.Price AS 结算单价,\n" +
" ( temp1.[结算数量] * ISNULL( temp3.Price, 0 ) ) AS 结算金额,\n" +
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
" isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
" ( isnull( temp1.发货数量, 0 ) - isnull( temp1.[结算数量], 0 ) ) AS 数量差异,\n" +
" ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
" ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" '' AS 交货单号,\n" +
" NULL AS 交货时间,\n" +
" '' AS 手工或自动,\n" +
" a.StorageLocation AS 收货仓库,\n" +
" a.StorageLocationDesc AS 收货仓库描述,\n" +
" a.HQHKanBan AS 订货看板编号,\n" +
" a.MaterialCode AS 订货零件号,\n" +
" c.MaterialCode Sap编码,\n" +
" a.MaterialCode 结算物料代码,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" isnull( b.Qty, 0 ) AS 发货数量,\n" +
" 2 AS 发货状态,\n" +
" a.[AcceptanceNo] AS 结算验收单号,\n" +
" isnull( a.Qty, 0 ) AS 结算数量,\n" +
" C.EstimateTypeDesc AS 物料组,\n" +
" a.Factory AS 工厂,\n" +
" '' AS 看板编号,\n" +
" '' AS 验收单日期 \n" +
" FROM\n" +
" (\n" +
" SELECT SUM\n" +
" ( Qty ) AS Qty,\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" Version,\n" +
" StorageLocation,\n" +
" StorageLocationDesc,\n" +
" Factory,AcceptanceNo \n" +
" FROM\n" +
" Set_HQ_H_Platform \n" +
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" Version,\n" +
" StorageLocation,\n" +
" StorageLocationDesc,\n" +
" Factory,AcceptanceNo \n" +
" ) AS a\n" +
" INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n" +
" AND a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" +
" ( a.HQHKanBan <> 'BJ' AND a.HQHKanBan IS NOT NULL ) \n" +
" AND a.Version= '{0}' \n" +
" ) AS temp1\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" Version \n" +
" FROM\n" +
" Set_HQ_H_Platform \n" +
" WHERE\n" +
" HQHKanBan <> 'BJ' \n" +
" AND Version = '{0}' \n" +
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" Version \n" +
" ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
" AND temp1.订货看板编号 = TEMP3.HQHKanBan";
//string str = "SELECT\n" + //string str = "SELECT\n" +
// " aaaa.* \n" +
// "FROM\n" +
// " (\n" +
// " SELECT\n" +
// " isnull( temp1.交货单号, '' ) 交货单号,\n" + // " isnull( temp1.交货单号, '' ) 交货单号,\n" +
// " temp1.交货时间,\n" + // " temp1.交货时间,\n" +
// " isnull( temp1.手工或自动, '' ) 手工或自动,\n" + // " isnull( temp1.手工或自动, '' ) 手工或自动,\n" +
@ -192,7 +95,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// " ( isnull( temp1.发货数量, 0 ) - isnull( temp1.[结算数量], 0 ) ) AS 数量差异,\n" + // " ( isnull( temp1.发货数量, 0 ) - isnull( temp1.[结算数量], 0 ) ) AS 数量差异,\n" +
// " ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" + // " ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
// " ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" + // " ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" +
// " FROM\n" + // "FROM\n" +
// " (\n" + // " (\n" +
// " SELECT\n" + // " SELECT\n" +
// " '' AS 交货单号,\n" + // " '' AS 交货单号,\n" +
@ -207,7 +110,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// " c.MaterialDesc AS 零件中文名称,\n" + // " c.MaterialDesc AS 零件中文名称,\n" +
// " isnull( b.Qty, 0 ) AS 发货数量,\n" + // " isnull( b.Qty, 0 ) AS 发货数量,\n" +
// " 2 AS 发货状态,\n" + // " 2 AS 发货状态,\n" +
// " '' AS 结算验收单号,\n" + // " a.[AcceptanceNo] AS 结算验收单号,\n" +
// " isnull( a.Qty, 0 ) AS 结算数量,\n" + // " isnull( a.Qty, 0 ) AS 结算数量,\n" +
// " C.EstimateTypeDesc AS 物料组,\n" + // " C.EstimateTypeDesc AS 物料组,\n" +
// " a.Factory AS 工厂,\n" + // " a.Factory AS 工厂,\n" +
@ -222,7 +125,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// " Version,\n" + // " Version,\n" +
// " StorageLocation,\n" + // " StorageLocation,\n" +
// " StorageLocationDesc,\n" + // " StorageLocationDesc,\n" +
// " Factory \n" + // " Factory,AcceptanceNo \n" +
// " FROM\n" + // " FROM\n" +
// " Set_HQ_H_Platform \n" + // " Set_HQ_H_Platform \n" +
// " GROUP BY\n" + // " GROUP BY\n" +
@ -231,7 +134,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// " Version,\n" + // " Version,\n" +
// " StorageLocation,\n" + // " StorageLocation,\n" +
// " StorageLocationDesc,\n" + // " StorageLocationDesc,\n" +
// " Factory \n" + // " Factory,AcceptanceNo \n" +
// " ) AS a\n" + // " ) AS a\n" +
// " INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n" + // " INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n" +
// " AND a.MaterialCode = b.MaterialCode\n" + // " AND a.MaterialCode = b.MaterialCode\n" +
@ -257,98 +160,108 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// " MaterialCode,\n" + // " MaterialCode,\n" +
// " Version \n" + // " Version \n" +
// " ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" + // " ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
// " AND temp1.订货看板编号 = TEMP3.HQHKanBan \n" + // " AND temp1.订货看板编号 = TEMP3.HQHKanBan";
// " ) aaaa UNION ALL\n" +
// "SELECT\n" +
// " ccc.* \n" + string str = "SELECT\n" +
// "FROM\n" + " isnull( temp1.交货单号, '' ) 交货单号,\n" +
// " (\n" + " temp1.交货时间,\n" +
// " SELECT\n" + " isnull( temp1.手工或自动, '' ) 手工或自动,\n" +
// " isnull( temp1.交货单号, '' ) 交货单号,\n" + " temp1.[工厂],\n" +
// " temp1.交货时间,\n" + " temp1.收货仓库,\n" +
// " isnull( temp1.手工或自动, '' ) 手工或自动,\n" + " temp1.收货仓库描述,\n" +
// " temp1.[工厂],\n" + " temp1.订货看板编号,\n" +
// " temp1.收货仓库,\n" + " temp1.订货零件号,\n" +
// " temp1.收货仓库描述,\n" + " temp1.验收单日期,\n" +
// " temp1.订货看板编号,\n" + " temp1.Sap编码,\n" +
// " temp1.订货零件号,\n" + " temp1.看板编号,\n" +
// " temp1.验收单日期,\n" + " temp1.物料组,\n" +
// " temp1.Sap编码,\n" + " temp1.零件中文名称,\n" +
// " temp1.看板编号,\n" + " temp1.发货数量,\n" +
// " temp1.物料组,\n" + " temp1.发货状态,\n" +
// " temp1.零件中文名称,\n" + " temp1.结算验收单号,\n" +
// " temp1.发货数量,\n" + " temp1.结算数量,\n" +
// " temp1.发货状态,\n" + " temp3.Price AS 结算单价,\n" +
// " temp1.结算验收单号,\n" + " ( temp1.[结算数量] * ISNULL( temp3.Price, 0 ) ) AS 结算金额,\n" +
// " temp1.结算数量,\n" + " isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
// " temp3.Price AS 结算单价,\n" + " isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
// " ( temp1.[结算数量] * ISNULL( temp3.Price, 0 ) ) AS 结算金额,\n" + " ( isnull( temp1.发货数量, 0 ) - isnull( temp1.[结算数量], 0 ) - ISNULL( temp4.Qty, 0 ) ) AS 数量差异,\n" +
// " isnull( TEMP2.Price, 0 ) AS 发货定价,\n" + " ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
// " isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" + " ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 ,\n" +
// " ( isnull( temp1.发货数量, 0 ) - isnull( temp1.[结算数量], 0 ) ) AS 数量差异,\n" + " temp4.Qty 退货数量 \n" +
// " ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" + "FROM\n" +
// " ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" + " (\n" +
// " FROM\n" + " SELECT\n" +
// " (\n" + " '' AS 交货单号,\n" +
// " SELECT\n" + " NULL AS 交货时间,\n" +
// " '' AS 交货单号,\n" + " '' AS 手工或自动,\n" +
// " NULL AS 交货时间,\n" + " a.StorageLocation AS 收货仓库,\n" +
// " '' AS 手工或自动,\n" + " a.StorageLocationDesc AS 收货仓库描述,\n" +
// " a.StorageLocation AS 收货仓库,\n" + " a.HQHKanBan AS 订货看板编号,\n" +
// " a.StorageLocationDesc AS 收货仓库描述,\n" + " a.MaterialCode AS 订货零件号,\n" +
// " '' AS 订货看板编号,\n" + " c.MaterialCode Sap编码,\n" +
// " a.MaterialCode AS 订货零件号,\n" + " a.MaterialCode 结算物料代码,\n" +
// " c.MaterialCode Sap编码,\n" + " c.MaterialDesc AS 零件中文名称,\n" +
// " a.MaterialCode 结算物料代码,\n" + " isnull( b.Qty, 0 ) AS 发货数量,\n" +
// " c.MaterialDesc AS 零件中文名称,\n" + " 2 AS 发货状态,\n" +
// " 0 AS 发货数量,\n" + " a.[AcceptanceNo] AS 结算验收单号,\n" +
// " 2 AS 发货状态,\n" + " isnull( a.Qty, 0 ) AS 结算数量,\n" +
// " '' AS 结算验收单号,\n" + " C.EstimateTypeDesc AS 物料组,\n" +
// " isnull( a.Qty, 0 ) AS 结算数量,\n" + " a.Factory AS 工厂,\n" +
// " C.EstimateTypeDesc AS 物料组,\n" + " '' AS 看板编号,\n" +
// " a.Factory AS 工厂,\n" + " '' AS 验收单日期 \n" +
// " '' AS 看板编号,\n" + " FROM\n" +
// " '' AS 验收单日期 \n" + " (\n" +
// " FROM\n" + " SELECT SUM\n" +
// " (\n" + " ( Qty ) AS Qty,\n" +
// " SELECT SUM\n" + " HQHKanBan,\n" +
// " ( Qty ) AS Qty,\n" + " MaterialCode,\n" +
// " MaterialCode,\n" + " Version,\n" +
// " Version,\n" + " StorageLocation,\n" +
// " StorageLocation,\n" + " StorageLocationDesc,\n" +
// " StorageLocationDesc,\n" + " Factory,\n" +
// " Factory \n" + " AcceptanceNo \n" +
// " FROM\n" + " FROM\n" +
// " Set_HQ_H_Platform \n" + " Set_HQ_H_Platform \n" +
// " WHERE\n" + " GROUP BY\n" +
// " HQHKanBan IS NULL \n" + " HQHKanBan,\n" +
// " GROUP BY\n" + " MaterialCode,\n" +
// " MaterialCode,\n" + " Version,\n" +
// " Version,\n" + " StorageLocation,\n" +
// " StorageLocation,\n" + " StorageLocationDesc,\n" +
// " StorageLocationDesc,\n" + " Factory,\n" +
// " Factory \n" + " AcceptanceNo \n" +
// " ) AS a\n" + " ) AS a\n" +
// " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + " INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n" +
// " WHERE\n" + " AND a.MaterialCode = b.MaterialCode\n" +
// " a.Version= '{0}' \n" + " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
// " ) AS temp1\n" + " WHERE\n" +
// " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" + " ( a.Version= '{0}' AND a.HQHKanBan IS NOT NULL ) \n" +
// " LEFT JOIN (\n" + " AND a.HQHKanBan <> 'BJ' \n" +
// " SELECT\n" + " ) AS temp1\n" +
// " ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n" + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" +
// " MaterialCode,\n" + " LEFT JOIN (\n" +
// " Version \n" + " SELECT\n" +
// " FROM\n" + " ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n" +
// " Set_HQ_H_Platform \n" + " HQHKanBan,\n" +
// " WHERE\n" + " MaterialCode,\n" +
// " HQHKanBan IS NULL \n" + " Version \n" +
// " AND Version = '{0}' \n" + " FROM\n" +
// " GROUP BY\n" + " Set_HQ_H_Platform \n" +
// " MaterialCode,\n" + " WHERE\n" +
// " Version \n" + " Version = '{0}' \n" +
// " ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" + " AND HQHKanBan <> 'BJ' \n" +
// " ) ccc"; " GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" Version \n" +
" ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
" AND temp1.订货看板编号 = TEMP3.HQHKanBan\n" +
" LEFT JOIN set_backQty temp4 ON temp1.订货看板编号 = temp4.Code \n" +
" AND temp1.Sap编码= temp4.MaterialCode";
//var _sql = string.Format(str, version, condition); //var _sql = string.Format(str, version, condition);
var _sql = string.Format(str, version); var _sql = string.Format(str, version);
@ -1410,6 +1323,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
[ExporterHeader(DisplayName = "验收单日期")] [ExporterHeader(DisplayName = "验收单日期")]
public string { set; get; } public string { set; get; }
[ExporterHeader(DisplayName = "退货数量")]
public string 退 { set; get; }
} }

139
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQFactoryUnSettledDetailDiffExportService.cs

@ -0,0 +1,139 @@
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
{
/// <summary>
/// 红旗工厂未结明细
/// </summary>
public class HQFactoryUnSettledDetailDiffExportService : ITransientDependency, IExportJob
{
private readonly HQFactorySettledDetailDapperRepository _dapperRepository;
private readonly ErpPartDapperRepository _erpdapperRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
private readonly OutputService _outputService;
private readonly InputService _inputService;
public HQFactoryUnSettledDetailDiffExportService(
ErpPartDapperRepository erpdapperRepository,
HQFactorySettledDetailDapperRepository dapperRepository,
OutputService outputService,
InputService inputService
, IBlobContainer<MyFileContainer> fileContainer
)
{
_inputService = inputService;
_outputService = outputService;
_erpdapperRepository = erpdapperRepository;
_fileContainer = fileContainer;
_dapperRepository = dapperRepository;
}
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 kanban = p_list.Where(p => p.Name == "Kanban").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 materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value;
var acceptNo = p_list.Where(p => p.Name == "AcceptNo").FirstOrDefault().Value;
var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value;
var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value;
//红旗系统未对比对红旗主机厂未结
var _ls = _dapperRepository.GetSettleToFactoryDetailDiffReportList(version, materialCode, begin, end, materialGroup);
//红旗主机厂未结比对红旗系统未对
var _ls_reversal = _dapperRepository.GetHQFactoryDetailDiffReportList(version, materialCode, begin, end, materialGroup);
//if (!string.IsNullOrEmpty(kanban))
//{
// var _groupList = kanban.Split(new char[] { '\n' }).Distinct().ToList();
// if (_groupList.Count() > 0)
// {
// _ls = _ls.Where(p => _groupList.Contains(p.订货看板编号)).ToList();
// }
//}
//if (!string.IsNullOrEmpty(warehouseDesc))
//{
// var _groupList = warehouseDesc.Split(new char[] { '\n' }).Distinct().ToList();
// if (_groupList.Count() > 0)
// {
// _ls = _ls.Where(p => _groupList.Contains(p.收货仓库描述)).ToList();
// }
//}
//if (!string.IsNullOrEmpty(acceptNo))
//{
// var _groupList = acceptNo.Split(new char[] { '\n' }).Distinct().ToList();
// if (_groupList.Count() > 0)
// {
// _ls = _ls.Where(p => _groupList.Contains(p.结算验收单号)).ToList();
// }
//}
if (!string.IsNullOrEmpty(materialGroup))
{
var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_ls = _ls.Where(p => _groupList.Contains(p.)).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.)).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.Sap编码)).ToList();
}
}
ExcelExporter _exporter = new ExcelExporter();//导出Excel
var result = _exporter.Append(_ls.ToList(), "红旗系统未对比对红旗主机厂未结")
.SeparateBySheet()
.Append(_ls_reversal.ToList(), "红旗主机厂未结比对红旗系统未对")
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(_filename, result.Result, true);
return id.ToString();
}
}
}
Loading…
Cancel
Save