Browse Source

更新版本

master
zhaoxinyu 5 months ago
parent
commit
4c9c23068b
  1. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  2. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  3. 173
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

13
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -1824,7 +1824,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
if (unsettle != null) if (unsettle != null)
{ {
_excel.Append(unsettle, "未结零件汇总"); _excel.Append(unsettle, "未结零件汇总");
} }
} }
if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO)
@ -1841,8 +1841,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if ( first.BusinessType == EnumBusinessType.YinDuJian || first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) if ( first.BusinessType == EnumBusinessType.YinDuJian || first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
{ {
if (jitunsettle != null) if (jitunsettle != null)
{ {
_excel.Append(jitunsettle, "未结零件汇总"); if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
{
unsettle = unsettle.Where(p => p.State == "可结算").ToList();
_excel.Append(unsettle, "未结零件汇总");
}
else
{
_excel.Append(jitunsettle, "未结零件汇总");
}
} }
if (m != null) if (m != null)
{ {

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs

@ -235,9 +235,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
PartCode = p.PartCode PartCode = p.PartCode
}).ToList();//不能结算 }).ToList();//不能结算
await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType,notlist).ConfigureAwait(false);
await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType,notlist).ConfigureAwait(false);
} }
} }
} }

173
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -53,6 +53,7 @@ using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.BlobStoring; using Volo.Abp.BlobStoring;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Guids; using Volo.Abp.Guids;
@ -70,6 +71,7 @@ using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared; using Win.Sfs.Shared;
using Win.Sfs.Shared.DomainBase;
using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -1489,34 +1491,52 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
} }
[HttpPost]
public async Task<string> GetMatchSummar(EnumBusinessType p_businessType, string sebegin, string seend, string sabegin, string saend)
private async Task<List<ShipReceiveSum>> GetBusinessSum(IServiceProvider serviceProvider,EnumBusinessType p_businessType, string sebegin, string seend, string sabegin, string saend)
{ {
List<ShipReceiveSum> ls = new List<ShipReceiveSum>();
var connectionString = serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new Microsoft.Data.SqlClient.SqlConnection(connectionString);
connection.Open();
var command = connection.CreateCommand();
string satablename = string.Empty; string satablename = string.Empty;
string setablename = string.Empty; string setablename = string.Empty;
string sanottablename = string.Empty;
string businesstype = string.Empty; string businesstype = string.Empty;
switch (p_businessType) switch (p_businessType)
{ {
case EnumBusinessType.JisBBAC: case EnumBusinessType.JisBBAC:
satablename = "Set_BBAC_CAN_SA_DETAIL"; satablename = "Set_BBAC_CAN_SA_DETAIL";
setablename = "Set_BBAC_SE_DETAIL"; setablename = "Set_BBAC_SE_DETAIL";
sanottablename= "Set_BBAC_NOT_SA_DETAIL";
break; break;
case EnumBusinessType.JisHBPO: case EnumBusinessType.JisHBPO:
satablename = "Set_HBPO_CAN_SA_DETAIL"; satablename = "Set_HBPO_CAN_SA_DETAIL";
setablename = "Set_HBPO_SE_DETAIL"; setablename = "Set_HBPO_SE_DETAIL";
sanottablename = "Set_HBPO_NOT_SA_DETAIL";
break; break;
case EnumBusinessType.MaiDanJianHBPO: case EnumBusinessType.MaiDanJianHBPO:
satablename = "Set_HBPO_CAN_SA_DETAIL"; satablename = "Set_HBPO_CAN_SA_DETAIL";
setablename = "Set_HBPO_SE_DETAIL"; setablename = "Set_HBPO_SE_DETAIL";
sanottablename = "Set_HBPO_NOT_SA_DETAIL";
break; break;
case EnumBusinessType.MaiDanJianBBAC: case EnumBusinessType.MaiDanJianBBAC:
satablename = "Set_BBAC_CAN_SA_DETAIL"; satablename = "Set_BBAC_CAN_SA_DETAIL";
setablename = "Set_BBAC_SE_DETAIL"; setablename = "Set_BBAC_SE_DETAIL";
sanottablename = "Set_BBAC_NOT_SA_DETAIL";
break; break;
default: default:
satablename = "Set_PUB_CAN_SA_DETAIL"; satablename = "Set_PUB_CAN_SA_DETAIL";
setablename = "Set_PUB_SE_DETAIL"; setablename = "Set_PUB_SE_DETAIL";
sanottablename = "Set_PUB_NOT_SA_DETAIL";
break; break;
} }
string sql = string sql =
@ -1559,11 +1579,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (!string.IsNullOrEmpty(sebegin)) if (!string.IsNullOrEmpty(sebegin))
{ {
sql += $" AND BillTime > '{sebegin}'\n"; sql += $" AND BillTime >= '{sebegin}'\n";
} }
if (!string.IsNullOrEmpty(seend)) if (!string.IsNullOrEmpty(seend))
{ {
sql += $" AND BillTime <'{seend}'\n"; sql += $" AND BillTime <='{seend}'\n";
} }
sql += sql +=
@ -1573,11 +1593,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (!string.IsNullOrEmpty(sebegin)) if (!string.IsNullOrEmpty(sebegin))
{ {
sql += $" AND BillTime > '{sebegin}'\n"; sql += $" AND BillTime >= '{sebegin}'\n";
} }
if (!string.IsNullOrEmpty(seend)) if (!string.IsNullOrEmpty(seend))
{ {
sql += $" AND BillTime <'{seend}'\n"; sql += $" AND BillTime <='{seend}'\n";
} }
sql += sql +=
"UNION ALL\n" + "UNION ALL\n" +
@ -1586,23 +1606,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (!string.IsNullOrEmpty(sebegin)) if (!string.IsNullOrEmpty(sebegin))
{ {
sql += $" AND BillTime > '{sebegin}'\n"; sql += $" AND BillTime >= '{sebegin}'\n";
} }
if (!string.IsNullOrEmpty(seend)) if (!string.IsNullOrEmpty(seend))
{ {
sql += $" AND BillTime <'{seend}'\n"; sql += $" AND BillTime <='{seend}'\n";
} }
sql += "UNION ALL\n" + sql += "UNION ALL\n" +
"SELECT LU,PN,BusinessType,Qty,150 Type\n" + "SELECT LU,PN,BusinessType,Qty,150 Type\n" +
$"from {setablename} A WITH(NOLOCK) whereBusinessType={(int)p_businessType} AND Qty<0 and Remark<>'期初初始化' \n"; $"from {setablename} A WITH(NOLOCK) where BusinessType={(int)p_businessType} AND Qty<0 and Remark<>'期初初始化' \n";
if (!string.IsNullOrEmpty(sebegin)) if (!string.IsNullOrEmpty(sebegin))
{ {
sql += $" AND BillTime > '{sebegin}'\n"; sql += $" AND BillTime >= '{sebegin}'\n";
} }
if (!string.IsNullOrEmpty(seend)) if (!string.IsNullOrEmpty(seend))
{ {
sql += $" AND BillTime <'{seend}'\n"; sql += $" AND BillTime <='{seend}'\n";
} }
sql += "UNION ALL\n" + sql += "UNION ALL\n" +
@ -1612,59 +1632,118 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (!string.IsNullOrEmpty(sabegin)) if (!string.IsNullOrEmpty(sabegin))
{ {
sql += $" AND SettleDate >'{sabegin}'\n"; sql += $" AND SettleDate >='{sabegin}'\n";
} }
if (!string.IsNullOrEmpty(saend)) if (!string.IsNullOrEmpty(saend))
{ {
sql += $" AND SettleDate<'{saend}'\n"; sql += $" AND SettleDate <='{saend}'\n";
} }
sql += "UNION ALL\n" + sql += "UNION ALL\n" +
"SELECT LU,PN,BusinessType,Qty,800 Type\n" + "SELECT LU,PN,BusinessType,Qty,800 Type\n" +
$"from {satablename} A WITH(NOLOCK) WHERE BusinessType={(int)p_businessType} \n"; $"from {sanottablename} A WITH(NOLOCK) WHERE BusinessType={(int)p_businessType} \n";
if (!string.IsNullOrEmpty(sabegin)) if (!string.IsNullOrEmpty(sabegin))
{ {
sql += $" AND SettleDate >'{sabegin}'\n"; sql += $" AND SettleDate >='{sabegin}'\n";
} }
if (!string.IsNullOrEmpty(saend)) if (!string.IsNullOrEmpty(saend))
{ {
sql += $" AND SettleDate<'{saend}'\n"; sql += $" AND SettleDate <='{saend}'\n";
} }
sql += ") a\n" + sql += ") a\n" +
"PIVOT (\n" + "PIVOT (\n" +
"SUM(qty)\n" + "SUM(qty)\n" +
"FOR Type IN ([10],[20],[100],[150],[200],[800])\n" + "FOR Type IN ([10],[20],[100],[150],[200],[800])\n" +
") AS piv\n" + ") AS piv\n" +
$") temp1 left join (select LU,PN,InvbillNum,Qty from {satablename} where BusinessType={(int)p_businessType} ) temp2 on temp1.PN=temp2.PN and temp1.LU=temp2.LU\n" + $") temp1 left join (select LU,PN,InvbillNum,Qty from {satablename} where BusinessType={(int)p_businessType}) temp2 on temp1.PN=temp2.PN and temp1.LU=temp2.LU\n" +
") tempsum group by LU\n"; ") tempsum group by LU\n";
return sql;
command.CommandText = sql;
command.CommandTimeout = 1200;
var reader = command.ExecuteReader();
while (reader.Read())
{
ShipReceiveSum shipReceiveSum = new ShipReceiveSum();
shipReceiveSum.LU = reader.GetString(0);
shipReceiveSum.PartCode = "";
shipReceiveSum.BusinessType = p_businessType.ToString();
shipReceiveSum.BSEQty = reader.GetDecimal(1).ToString();
shipReceiveSum.BRETQty = reader.GetDecimal(2).ToString();
shipReceiveSum.SEQTY = reader.GetDecimal(3).ToString();
shipReceiveSum.RETQty = reader.GetDecimal(4).ToString();
shipReceiveSum.CANQty = reader.GetDecimal(5).ToString();
shipReceiveSum.NOTQty = reader.GetDecimal(6).ToString();
shipReceiveSum.SE_SA_CAN_QTY = reader.GetDecimal(7).ToString();
shipReceiveSum.SE_SA_NOT_QTY = reader.GetDecimal(8).ToString();
shipReceiveSum.ONLY_SE_QTY = reader.GetDecimal(9).ToString();
shipReceiveSum.ONLY_SA_QTY = reader.GetDecimal(10).ToString();
shipReceiveSum.INVQty = reader.GetDecimal(11).ToString();
ls.Add(shipReceiveSum);
// result += reader.GetString(0) + "," + reader.GetInt64(1) + "," + reader.GetInt64(2) + "," + reader.GetInt64(3) + "," + reader.GetInt64(4) + "," + reader.GetInt64(5) + "," + reader.GetInt64(6) + "," + reader.GetInt64(7) + "," + reader.GetInt64(8) + "," + reader.GetInt64(9) + "," + reader.GetInt64(10) + "," + reader.GetInt64(11) + "," + reader.GetInt64(12) + "," + reader.GetInt64(13) + "," + reader.GetInt64(14) + "\n";
}
reader.Close();
connection.Close();
return ls;
} }
[HttpPost]
public async Task<string> GetReceiveShipSum(string sebegin, string seend, string sabegin, string saend)
{
ConcurrentBag<ShipReceiveSum> bagList = new ConcurrentBag<ShipReceiveSum>();
List<EnumBusinessType> list = new List<EnumBusinessType>();
list.Add(EnumBusinessType.JisBBAC);
list.Add(EnumBusinessType.JisHBPO);
list.Add(EnumBusinessType.MaiDanJianHBPO);
list.Add(EnumBusinessType.MaiDanJianBBAC);
list.Add(EnumBusinessType.BeiJian);
list.Add(EnumBusinessType.ZhiGongJianHBPO);
list.Add(EnumBusinessType.ZhiGongJianBBAC);
list.Add(EnumBusinessType.YinDuJian);
Parallel.ForEach(list, async chunk =>
{
var ls = await GetBusinessSum(this._serviceProvider, chunk, sebegin, seend, sabegin, saend).ConfigureAwait(false);
foreach (var itm in ls)
{
bagList.Add(itm);
}
});
var entities=bagList.ToList<ShipReceiveSum>();
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
byte[] result = null;
result = await _excel.ExportAsByteArray(entities).ConfigureAwait(false);
result.ShouldNotBeNull();
string _fileName = $"收发存汇总{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
).ConfigureAwait(false);
return _fileName;
}
@ -2060,16 +2139,50 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public string ErpToLoc { set; get; } public string ErpToLoc { set; get; }
[Display(Name = "数量")] [Display(Name = "数量")]
public decimal Qty { set; get; } public decimal Qty { set; get; }
}
public class ShipReceiveSum
{
[Display(Name = "客户零件号")]
public string LU { set; get; }
[Display(Name = "厂内零件号")]
public string PartCode { set; get; }
[Display(Name = "业务类型")]
public string BusinessType { set; get; }
[Display(Name = "期初发货数量")]
public string BSEQty { set; get; }
[Display(Name = "期初退货数量")]
public string BRETQty { set; get; }
[Display(Name = "实际发货数量")]
public string SEQTY { set; get; }
[Display(Name = "实际退货数量")]
public string RETQty { set; get; }
[Display(Name = "可结数量")]
public string CANQty { set; get; }
[Display(Name = "不可结数量")]
public string NOTQty { set; get; }
[Display(Name = "有发有结有价格数量")]
public string SE_SA_CAN_QTY { set; get; }
[Display(Name = "有发有结无价格数量")]
public string SE_SA_NOT_QTY { set; get; }
[Display(Name = "有发运无结算数量")]
public string ONLY_SE_QTY { set; get; }
[Display(Name = "有结算无发运数量")]
public string ONLY_SA_QTY { set; get; }
[Display(Name = "已开票数量")]
public string INVQty { set; get; }
} }
// 扩展方法类,用于为IEnumerable类型添加额外功能 // 扩展方法类,用于为IEnumerable类型添加额外功能
public class FileInfoGroup public class FileInfoGroup

Loading…
Cancel
Save