44673626 3 years ago
parent
commit
2e8ce6d546
  1. 49
      src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs
  2. 179
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs
  3. 57
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs
  4. 5
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs

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

@ -397,19 +397,6 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
{
//if (!_settleAccountVersionrepository.Any(p => p.Version == version))
//{
// throw new BusinessException("8989", string.Format("不存结算{0}期间",version));
//}
//if (!_invoiceVersionRepository.Any(p => p.Version == version))
//{
// throw new BusinessException("8989", string.Format("不存发票{0}期间", version));
//}
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "MatialCode", Value = matialCode ?? string.Empty });
@ -844,6 +831,42 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
/// <summary>
/// 结算未结寄售核对表
/// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpPost]
[Route("UnSettledSum-Make")]
[DisableRequestSizeLimit]
public async Task<string> UnSettledSumServiceMake(
BaseRequestDto input
)
{
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = !string.IsNullOrEmpty(input.Version) ? input.Version : string.Empty });
customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = string.Empty });
customConditionList.Add(new CustomCondition() { Name = "MaterialCode", Value = !string.IsNullOrEmpty(input.MaterialCode) ? input.MaterialCode : string.Empty });
customConditionList.Add(new CustomCondition() { Name = "MaterialGroup", Value = !string.IsNullOrEmpty(input.MaterialGroup) ? input.MaterialGroup : string.Empty });
customConditionList.Add(new CustomCondition() { Name = "SapMaterialCode", Value = string.Empty });
customConditionList.Add(new CustomCondition() { Name = "Begin", Value = string.IsNullOrEmpty(input.Begin) ? string.Empty : input.Begin });
customConditionList.Add(new CustomCondition() { Name = "End", Value = string.IsNullOrEmpty(input.End) ? string.Empty : input.End });
customConditionList.Add(new CustomCondition() { Name = "KennCode", Value = string.IsNullOrEmpty(input.Kenncode) ? string.Empty : input.Kenncode });
customConditionList.Add(new CustomCondition() { Name = "ChassisNumber", Value = string.IsNullOrEmpty(input.ChassisNumber) ? string.Empty : input.ChassisNumber });
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(UnSettledSumService), customConditionList, (rs) =>
{
});
return _taskid;
}
#region F及M平台已经合并入H平台

179
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs

@ -43,51 +43,65 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
condition += string.Format(" and c.WMSActualGoodsDate<='{0}' ", endtime);
}
var datestr= version.Substring(0, 4) +"-"+ version.Substring(4, 2) + "-01";
var date= DateTime.Parse(datestr).AddMonths(1).AddDays(-1);
var datetime=date.ToShortDateString()+" 23:59:59 ";
string sqlString = "SELECT\n" +
" * ,\n" +
" ISNULL( temp1.InvoicePrice * Qty, 0 ) AS InvoiceMoney,--开票金额\n" +
" ISNULL( Price * WMSDeliveryQty, 0 ) AS Amount,--金额\n" +
" ISNULL( Price * Qty, 0 ) AS SettlePrice,--结算金额\n" +
" ( Price - InvoicePrice ) AS InvoiceDiffPrice,--单价差异\n" +
" ISNULL( Price * Qty - InvoicePrice * Qty, 0 ) AS SumDiffMoney,--总金额差异\n" +
" '' DeliveryOrderNo --出库单号\n" +
" \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" row_number ( ) OVER ( ORDER BY b.EstimateTypeDesc ) AS RowId,\n" +
" c.WMSDeliveryNote,--交货单号\n" +
" CONVERT ( VARCHAR ( 100 ), c.WMSActualGoodsDate, 23 ) AS WMSActualGoodsDate,--实际发货日期年-月-日\n" +
" a.Kanban,--条码号\n" +
" b.MaterialCode SapMaterialCode,--厂内物料号\n" +
" b.MaterialDesc,--物料描述\n" +
" b.CustomerPartCode,--客户物料\n" +
" b.EstimateTypeDesc,--物料组(车型)\n" +
" c.WMSDeliveryQty,--交货数量\n" +
" ISNULL( a.Qty, 0 ) AS SettleNumber,--结算数量\n" +
" CONVERT ( VARCHAR ( 100 ), a.SettleDate, 23 ) SettleDate,--结算日期\n" +
" ISNULL( a.Qty, 0 ) AS Qty,--用于计算\n" +
" ( ISNULL( a.Qty, 0 ) - ISNULL( c.WMSDeliveryQty, 0 ) ) AS SettleWMSDiffQty,--结算与发货差异\n" +
" 0 AS SettleInvoiceDiffQty,--结算与开票差异\n" +
" ISNULL( a.Qty, 0 ) AS InvoiceDiffQty,--开票数量,默认0,后续拿算法动态算\n" +
" ISNULL( d.InvoicePrice, 0 ) InvoicePrice --开票单价\n" +
" \n" +
" FROM\n" +
" Set_KanBanSettle AS a\n" +
" LEFT JOIN Set_material AS b ON a.MaterialCode= b.CustomerPartCode\n" +
" LEFT JOIN Set_WMSKanBanSettle c ON a.Kanban= c.Kanban \n" +
" AND a.MaterialCode= c.MaterialCode\n" +
" LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE version = '{0}' GROUP BY materialcode ) d ON a.MaterialCode= d.MaterialCode \n" +
" WHERE\n" +
" a.VERSION= '{0}' {1} \n" +
" ) TEMP1\n" +
" LEFT JOIN ( SELECT Price, --定价\n" +
" MaterialCode --厂内物料号\n" +
" FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapMaterialCode= TEMP2.MaterialCode \n" +
"WHERE\n" +
" 1 =1";
" * ,\n" +
" ISNULL ( temp1.InvoicePrice * Qty, 0 ) AS InvoiceMoney,--开票金额\n" +
" ISNULL ( Price * WMSDeliveryQty, 0 ) AS Amount,--金额\n" +
" ISNULL ( Price * Qty, 0 ) AS SettlePrice,--结算金额\n" +
" ( Price - InvoicePrice ) AS InvoiceDiffPrice,--单价差异\n" +
" ISNULL ( Price * Qty - InvoicePrice * Qty, 0 ) AS SumDiffMoney,--总金额差异\n" +
" '' DeliveryOrderNo --出库单号\n" +
" \n" +
"FROM\n" +
" (\n" +
" SELECT ROW_NUMBER\n" +
" ( ) OVER ( ORDER BY b.EstimateTypeDesc ) AS RowId,\n" +
"--c.WMSDeliveryNote,--交货单号\n" +
"--CONVERT ( VARCHAR ( 100 ), c.WMSActualGoodsDate, 23 ) AS WMSActualGoodsDate,--实际发货日期年-月-日\n" +
" A.Kanban,--条码号\n" +
" b.MaterialCode SapMaterialCode,--厂内物料号\n" +
" b.MaterialDesc,--物料描述\n" +
" b.CustomerPartCode,--客户物料\n" +
" b.EstimateTypeDesc,--物料组(车型)\n" +
" C.WMSDeliveryQty,--交货数量\n" +
" ISNULL ( A.Qty, 0 ) AS SettleNumber,--结算数量\n" +
" CONVERT ( VARCHAR ( 100 ), A.SettleDate, 23 ) SettleDate,--结算日期\n" +
" ISNULL ( A.Qty, 0 ) AS Qty,--用于计算\n" +
" ( ISNULL ( A.Qty, 0 ) - ISNULL ( C.WMSDeliveryQty, 0 ) ) AS SettleWMSDiffQty,--结算与发货差异\n" +
" 0 AS SettleInvoiceDiffQty,--结算与开票差异\n" +
" ISNULL ( A.Qty, 0 ) AS InvoiceDiffQty,--开票数量,默认0,后续拿算法动态算\n" +
" ISNULL ( d.InvoicePrice, 0 ) InvoicePrice --开票单价\n" +
" \n" +
" FROM\n" +
" Set_KanBanSettle\n" +
" AS A LEFT JOIN Set_material AS b ON A.MaterialCode = b.CustomerPartCode\n" +
" LEFT JOIN (\n" +
"   SELECT\n" +
" ( temp1.Qty - ISNULL ( temp2.Qty, 0 ) ) WMSDeliveryQty,\n" +
" temp1.MaterialCode,\n" +
" temp1.Kanban \n" +
" FROM\n" +
" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle WHERE VERSION < '{0}' GROUP BY kanban, MaterialCode ) temp1\n" +
" INNER JOIN ( SELECT SUM ( WMSDeliveryQty ) Qty, KanBan, MaterialCode FROM Set_WMSKanBanSettle WHERE WMSActualGoodsDate < '{2}' GROUP BY KanBan, MaterialCode ) temp2 ON temp1.Kanban = temp2.KanBan \n" +
" AND temp1.MaterialCode = temp2.KanBan \n" +
" ) C ON A.Kanban = C.Kanban \n" +
" AND A.MaterialCode = C.MaterialCode\n" +
" LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE VERSION = '{0}' GROUP BY materialcode ) d ON A.MaterialCode = d.MaterialCode \n" +
" WHERE\n" +
" A.VERSION = '{0}' {1}\n" +
" ) TEMP1\n" +
" LEFT JOIN ( SELECT Price, --定价\n" +
" MaterialCode --厂内物料号\n" +
" FROM Set_PriceList WHERE VERSION = ( SELECT MAX ( VERSION ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapMaterialCode = TEMP2.MaterialCode \n" +
"WHERE\n" +
" 1 = 1;";
string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version, condition);
string addSqlStr = string.Format(sqlString, version, condition,datetime);
//if (!string.IsNullOrEmpty(kanBan))
//{
@ -106,9 +120,86 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// addwhere += string.Format(" AND EstimateTypeDesc LIKE '{0}%' ", estimateTypeDesc);
//}
string _sql = string.Format(addSqlStr, addwhere);
var _query = DbConnection.Query<SettleKBWithCode>(_sql, null, null, true, 1200, null);
return _query.ToList();
var sql2 = "SELECT\n" +
" a.WmsBillNum,\n" +
" t1.MaterialCode MaterialCode,\n" +
" a.Kanban ,\n" +
" A.LastModificationTime WmsDate \n" +
"FROM\n" +
" Set_HQ_H_Kanban A\n" +
" INNER JOIN ( SELECT MaterialCode, Kanban FROM Set_HQ_H_Kanban GROUP BY MaterialCode, Kanban HAVING COUNT(*)> 1 ) B ON A.Kanban = B.Kanban \n" +
" AND A.MaterialCode = B.MaterialCode " +
" left join Set_material t1 on a.MaterialCode=t1.CustomerPartCode ";
var listCompare = DbConnection.Query<CompareExtend>(sql2);
var _lst=_query.ToList();
List<CompareExtend> _ls = new List<CompareExtend>();
foreach (var itm in listCompare.ToList())
{
var first = _ls.FirstOrDefault(p => p.Kanban == itm.Kanban && p.MaterialCode == itm.MaterialCode);
if (first != null)
{
if (!string.IsNullOrEmpty(itm.WmsDate))
{
itm.WmsDate = DateTime.Parse(itm.WmsDate).ToShortDateString();
}
first.WmsBillNum += "," + itm.WmsBillNum;
first.WmsDate += "," + itm.WmsDate;
}
else
{
if (!string.IsNullOrEmpty(itm.WmsDate))
{
itm.WmsDate = DateTime.Parse(itm.WmsDate).ToShortDateString();
}
_ls.Add(itm);
}
}
foreach (var itm1 in _lst)
{
var itm = _ls.FirstOrDefault(p => p.Kanban == itm1.Kanban && p.MaterialCode == itm1.MaterialCode);
if (itm != null)
{
itm1.WMSDeliveryNote = itm.WmsBillNum;
itm1.WMSActualGoodsDate = itm.WmsDate;
}
}
return _lst;
}

57
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs

@ -375,7 +375,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsJitOutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" GROUP BY\n" +
" BillNum,\n" +
" MaterialCode,\n" +
@ -395,7 +395,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsKanbanOutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" GROUP BY\n" +
" BillNum,\n" +
" MaterialCode,\n" +
@ -415,7 +415,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsWithOutKanbanOutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" GROUP BY\n" +
" BillNum,\n" +
" SapMaterialCode,\n" +
@ -435,7 +435,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsSharePartOutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" GROUP BY\n" +
" BillNum,\n" +
" MaterialCode,\n" +
@ -455,7 +455,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsSharePart90OutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" GROUP BY\n" +
" BillNum,\n" +
" MaterialCode,\n" +
@ -475,7 +475,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsHQHKanbanOutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" GROUP BY\n" +
" BillNum,\n" +
" MaterialCode,\n" +
@ -496,7 +496,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Set_WmsHQWithOutKanbanOutPutDetial \n" +
" WHERE\n" +
" IsBack = 0 \n" +
" AND VERSION = '{0}' \n" +
" AND VERSION = '{0} AND STATE<>4' \n" +
" AND Extend = '100113' \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -519,7 +519,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Set_WmsHQWithOutKanbanOutPutDetial \n" +
" WHERE\n" +
" IsBack = 1 \n" +
" AND VERSION = '{0}' \n" +
" AND VERSION = '{0} AND STATE<>4' \n" +
" AND Extend = '100113' \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -542,7 +542,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Set_WmsHQWithOutKanbanOutPutDetial \n" +
" WHERE\n" +
" IsBack = 0 \n" +
" AND VERSION = '{0}' \n" +
" AND VERSION = '{0} AND STATE<>4' \n" +
" AND Extend = '100053' \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -565,7 +565,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Set_WmsHQWithOutKanbanOutPutDetial \n" +
" WHERE\n" +
" IsBack = 1 \n" +
" AND VERSION = '{0}' \n" +
" AND VERSION = '{0} AND STATE<>4' \n" +
" AND Extend = '100053' \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -589,7 +589,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Set_WmsOneTimeSaleOutPutDetial\n" +
" WHERE\n" +
" \n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" GROUP BY\n" +
" BillNum,\n" +
" SapMaterialCode,\n" +
@ -635,7 +635,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsJitOutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -656,7 +656,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsKanbanOutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -677,7 +677,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsWithOutKanbanOutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -698,7 +698,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsSharePartOutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -719,7 +719,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsSharePart90OutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -740,7 +740,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_WmsHQHKanbanOutPutDetial \n" +
" WHERE\n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -762,7 +762,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Set_WmsHQWithOutKanbanOutPutDetial \n" +
" WHERE\n" +
" IsBack = 0 \n" +
" AND VERSION = '{0}' \n" +
" AND VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" AND Extend = '100113' \n" +
" GROUP BY\n" +
@ -786,7 +786,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Set_WmsHQWithOutKanbanOutPutDetial \n" +
" WHERE\n" +
" IsBack = 1 \n" +
" AND VERSION = '{0}' \n" +
" AND VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" AND Extend = '100113' \n" +
" GROUP BY\n" +
@ -810,7 +810,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Set_WmsHQWithOutKanbanOutPutDetial \n" +
" WHERE\n" +
" IsBack = 0 \n" +
" AND VERSION = '{0}' \n" +
" AND VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" AND Extend = '100053' \n" +
" GROUP BY\n" +
@ -834,7 +834,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Set_WmsHQWithOutKanbanOutPutDetial \n" +
" WHERE\n" +
" IsBack = 1 \n" +
" AND VERSION = '{0}' \n" +
" AND VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" AND Extend = '100053' \n" +
" GROUP BY\n" +
@ -859,7 +859,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Set_WmsOneTimeSaleOutPutDetial\n" +
" WHERE\n" +
" \n" +
" VERSION = '{0}' \n" +
" VERSION = '{0} AND STATE<>4' \n" +
" AND State = 2 \n" +
" GROUP BY\n" +
" BillNum,\n" +
@ -881,24 +881,11 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
_sql = string.Format(_sql, version);
var _query = DbConnection.Query<WmsOutputSumReport>(_sql, null, null, true, 1200, null);
return _query.ToList();
}
public virtual List<WmsOutputSumReport2> GetWmsSumReportList(string version, string state)
{

5
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs

@ -68,7 +68,10 @@ namespace SettleAccount.Job.Services.Report
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list)
{
GetReport(id,exportName,p_list);
var _lsExport= GetReport(id,exportName,p_list);
var _first = exportName.FirstOrDefault();
_outputService.Export<UnSettledSum>(id, _first, _lsExport);
return id.ToString();
}

Loading…
Cancel
Save