Browse Source

更新版本

FoShanPG
Administrator 3 years ago
parent
commit
043226d191
  1. 155
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOutputSumInterfaceAppService.cs
  2. 266
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpSumOutputDapperRepository.cs
  3. 54
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs

155
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOutputSumInterfaceAppService.cs

@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Distributed;
using AutoMapper;
using System.Linq;
using System.Text;
using Volo.Abp.Guids;
using Volo.Abp.Application.Services;
using Volo.Abp.Caching;
using Volo.Abp.ObjectMapping;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.Shared.CacheBase;
using Win.Utils;
using Volo.Abp.Application.Dtos;
using Win.Sfs.BaseData.ImportExcelCommon;
using Volo.Abp.Domain.Repositories;
using EFCore.BulkExtensions;
using System.IO;
using Microsoft.EntityFrameworkCore;
using Win.Sfs.SettleAccount.Entities.SettleAccountVersion;
using Win.Sfs.SettleAccount.FISes;
using Win.Sfs.Shared.Enums.SettleAccount;
using Win.Sfs.Shared.Filter;
using Shouldly;
using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using System.Data.Common;
using Volo.Abp.Uow;
using Volo.Abp;
using Win.Abp.Snowflakes;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Magicodes.ExporterAndImporter.Core.Models;
using TaskJob.Services;
using TaskJob.EventArgs;
using Win.Sfs.SettleAccount.Entities.WMS;
using Win.Sfs.SettleAccount.Entities.Wms;
using Win.Sfs.SettleAccount.Repository;
using WY.NewJit.Extends.PaiGe.WMS;
using System.Text.RegularExpressions;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
namespace Win.Sfs.SettleAccount.Entities.WMS
{
[Route("api/settleaccount/WmsOutputSumInterface")]
public class WmsOutputSumInterfaceAppService :ApplicationService
{
private readonly TaskJobService _service;
private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<TaskJob, Guid> _job;
private readonly ErpSumOutputDapperRepository _dapper;
public WmsOutputSumInterfaceAppService(
IExcelImportAppService excelImportService,
ErpSumOutputDapperRepository dapper,
//ISettleAccountBranchEfCoreRepository<TaskJob, Guid> job,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
)
{
_dapper = dapper;
_excelImportService = excelImportService;
}
[HttpPost]
[Route("ExcelImport")]
[UnitOfWork(false)]
//[Authorize(SettleAccountPermissions.PriceLists.Create)]
virtual public async Task<string> ImportAsync([FromForm] IFormFileCollection files, string version,string accountDate)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<WmsOutputSumReport>(files, _excelImportService);
var _list = result.Where(p => p. != 0).ToList();
_dapper.InsertWmsSum(_list, version,DateTime.Parse(accountDate));
return ApplicationConsts.SuccessStr;
}
//public async Task<string> GetWmsSum(WmsJitOutPutDetial input)
//{
// var jobList= _job.Where(p => p.Type == input.Version).ToList();
// var _fileList= jobList.Where(p=>p.Name == "准时化结算核对明细" && Regex.Replace(p.FileName, @"^[A-Z]+[0-9]+$", string.Empty)==string.Empty);
// List<WmsJitOutPutDetial> _lst = new List<WmsJitOutPutDetial>();
// foreach (var filename in _fileList)
// {
// string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename.RealDownFileName;
// ExcelHelper _excelHelper = new ExcelHelper(fileSavePath);
// var _list = _excelHelper.ExcelToList<WmsJitOutPutDetial>();
// var _ls1 = _list.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList();
// _ls1.GroupBy(p=>new {p.MaterialCode,p. })
// foreach (var itm in _ls1)
// {
// var _detail = new List<WmsOutputSum>();
// }
// //var _lsCopy = new List<WmsJitOutPutDetial>();
// //foreach (var itm in _list)
// //{
// // WmsJitOutPutDetial _detail = new WmsJitOutPutDetial(
// // GuidGenerator.Create(),
// // itm.WmsBillNum,
// // itm.KennCode,
// // itm.ChassisNumber,
// // itm.MaterialCode,
// // itm.MaterialDesc,
// // itm.MaterialGroup,
// // string.Empty,
// // string.Empty,
// // 0,
// // string.Empty,
// // string.Empty,
// // input.Version,
// // itm.ParentMaterialCode,
// // itm.BillNum,
// // GuidGenerator.Create()
// // , string.Empty
// // , itm.Qty
// // );
// // _lsCopy.Add(_detail);
// //}
// //_lst.AddRange(_lsCopy.ToArray());
// }
//}
}
}

266
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpSumOutputDapperRepository.cs

@ -10,16 +10,276 @@ using Volo.Abp.EntityFrameworkCore;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
public class TA_WMS_CTRL
{
public string wms_seq { set; get; }
public string wms_table { set; get; }
public string wms_state { set; get; }
public string SourceBillNum { set; get; }
public DateTime AccountDate { set; get; }
}
public class ErpSumOutputDapperRepository: DapperRepository<WMSDbContext>, ITransientDependency
{
public ErpSumOutputDapperRepository(IDbContextProvider<WMSDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public virtual async void InsertWmsSum(List<WmsOutputSum> p_list)
public virtual List<TA_WMS_CTRL> GetTask(string begin,string end)
{
var str = "";
if (!string.IsNullOrEmpty(begin))
{
str += string.Format(" and AccountDate>={0} ", begin);
}
if (!string.IsNullOrEmpty(end))
{
str += string.Format(" and AccountDate<={0} ", end);
}
var sql = "SELECT TOP (1000) [wms_seq]\n" +
" ,[wms_table]\n" +
" ,[wms_table_qty]\n" +
" ,[wms_state]\n" +
" ,[remark]\n" +
" ,[createtime]\n" +
" ,[wms_domin]\n" +
" ,[SourceBillNum]\n" +
" ,[updatetime]\n" +
" ,[wms_uid]\n" +
" ,[JsonString]\n" +
" ,[AccountDate]\n" +
" FROM [TA_WMS_CTRL] WHERE {0}" +
" SourceBillNum LIKE 'S2%' order by createtime desc2";
sql= string.Format(sql, str);
var query= DbConnection.Query<TA_WMS_CTRL>(sql);
return query.ToList();
}
public virtual void InsertWmsSum(List<WmsOutputSumReport> p_list,string version,DateTime accountDate)
{
StringBuilder _buffer = new StringBuilder();
var billnum ="S" +DateTime.Now.ToString("yyyyMMddhhmmss");
var taskid = Guid.NewGuid().ToString();
foreach (var itm in p_list)
{
// var sql ="INSERT INTO [dbo].[TA_WMS_JSKH]\n" +
//" ([wms_seq]\n" +
//" ,[POSNR]\n" +
//" ,[ZVBELN]\n" +
//" ,[AUART]\n" +
//" ,[VKORG]\n" +
//" ,[SPART]\n" +
//" ,[VTWEG]\n" +
//" ,[KUNNR]\n" +
//" ,[KUNNR2]\n" +
//" ,[AUGRU]\n" +
//" ,[MATNR]\n" +
//" ,[WERKS]\n" +
//" ,[LGORT]\n" +
//" ,[ZPR0]\n" +
//" ,[KWMENG]\n" +
//" ,[ZNOTE1]\n" +
//" ,[ZNOTE2]\n" +
//" ,[ZNOTE3]\n" +
//" ,[ZNOTE4]\n" +
//" ,[ZNOTE5]\n" +
//" ,[STATE]\n" +
//" ,[REMARK])\n" +
//" VALUES\n" +
//" ( '{0}' wms_seq,\n" +
//" '{1}' POSNR, \n" +
//" '{2}' ZVBELN, \n" +
//" '{3}' AUART, \n" +
//" '{4}' VKORG, \n" +
//" '{5}' SPART, \n" +
//" '{6}' VTWEG, \n" +
//" '{7}' KUNNR, \n" +
//" '{8}' KUNNR2, \n" +
//" '{9}' AUGRU, \n" +
//" '{10}' MATNR, \n" +
//" '{11}' WERKS, \n" +
//" '{12}' LGORT, \n" +
//" '{13}' ZPR0, \n" +
//" '{14}' KWMENG, \n" +
//" '{15}' ZNOTE1, \n" +
//" '{16}' ZNOTE2, \n" +
//" '{17}' ZNOTE3, \n" +
//" '{18}' ZNOTE4, \n" +
//" '{19}' ZNOTE5, \n" +
//" {20} STATE, \n" +
//" '{21}' REMARK ) \n"+
var sql = "INSERT INTO [dbo].[TA_WMS_JSKH]\n" +
" ([wms_seq]\n" +
" ,[POSNR]\n" +
" ,[ZVBELN]\n" +
" ,[AUART]\n" +
" ,[VKORG]\n" +
" ,[SPART]\n" +
" ,[VTWEG]\n" +
" ,[KUNNR]\n" +
" ,[KUNNR2]\n" +
" ,[AUGRU]\n" +
" ,[MATNR]\n" +
" ,[WERKS]\n" +
" ,[LGORT]\n" +
" ,[ZPR0]\n" +
" ,[KWMENG]\n" +
" ,[ZNOTE1]\n" +
" ,[ZNOTE2]\n" +
" ,[ZNOTE3]\n" +
" ,[ZNOTE4]\n" +
" ,[ZNOTE5]\n" +
" ,[STATE]\n" +
" ,[REMARK])\n" +
" VALUES\n" +
" ( '{0}' ,\n" +
" '{1}' , \n" +
" '{2}' , \n" +
" '{3}' , \n" +
" '{4}' , \n" +
" '{5}' , \n" +
" '{6}' , \n" +
" '{7}' , \n" +
" '{8}' , \n" +
" '{9}' , \n" +
" '{10}' , \n" +
" '{11}' , \n" +
" '{12}' , \n" +
" '{13}' , \n" +
" '{14}' , \n" +
" '{15}' , \n" +
" '{16}' , \n" +
" '{17}' , \n" +
" '{18}' , \n" +
" '{19}' , \n" +
" {20} , \n" +
" '{21}' ) \n";
sql = string.Format(sql,
taskid,
itm.,
itm.,
"ZOR1",
"1001",
"00",
itm.,
itm.,
itm.,
itm.,
itm.,
"1000",
itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
"0",
billnum
);
_buffer.AppendLine(sql);
}
var count= DbConnection.Execute(_buffer.ToString(), null, null, 1200, null);
if (count > 0)
{
var sql = "INSERT INTO [TA_WMS_CTRL]\n" +
" ([wms_seq]\n" +
" ,[wms_table]\n" +
" ,[wms_table_qty]\n" +
" ,[wms_state]\n" +
" ,[remark]\n" +
" ,[createtime]\n" +
" ,[wms_domin]\n" +
" ,[SourceBillNum]\n" +
" ,[JsonString]\n" +
" ,[AccountDate])\n" +
" VALUES\n" +
" ( '{0}' \n" +
" , '{1}' \n" +
" , '{2}' \n" +
" , '{3}' \n" +
" , '{4}' \n" +
" , '{5}' \n" +
" , '{6}' \n" +
" , '{7}' \n" +
" , '{8}' \n" +
" , {9} )";
sql= string.Format(sql,
taskid
, "TA_WMS_JSKH"
, count.ToString(),
5,
string.Empty,
DateTime.Now,
"1000",
billnum
,version
,accountDate.ToShortDateString()
);
DbConnection.Execute(sql, null, null, 1200, null);
}
//" \n" +
//"SELECT NEWID() [wms_seq] \n" +
//" ,[行号] [POSNR] \n" +
//" ,[结算单] [ZVBELN] \n" +
//" ,'ZOR1' [AUART] \n" +
//" ,'1001' [VKORG] \n" +
//" ,'00' [SPART] \n" +
//" ,[销售渠道] [VTWEG] \n" +
//" ,[客户代码] [KUNNR] \n" +
//" ,[客户代码] [KUNNR2] \n" +
//" ,[结算编码] [AUGRU] \n" +
//" ,[物料号] [MATNR] \n" +
//" ,'1000' [WERKS] \n" +
//" ,[寄售类别] [LGORT] \n" +
//" ,[实际出库数量] [KWMENG] \n" +
//" ,已出库金额 [ZPR0]\n" +
//" ,'' [ZNOTE1] \n" +
//" ,'' [ZNOTE2] \n" +
//" ,'' [ZNOTE3] \n" +
//" ,'' [ZNOTE4] \n" +
//" ,'' [ZNOTE5] \n" +
//" ,0 [STATE] \n" +
//" ,'' [REMARK] \n" +
//" \n" +
//" FROM [CPAT_WMS_TEST].[dbo].[temp1]"
//DbConnection.Execute("INSERT ")

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

@ -12,46 +12,69 @@ using Volo.Abp.EntityFrameworkCore;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
public class WmsOutputSum
public class WmsOutputSumReport
{
[ImporterHeader(Name = "行号")]
[ExporterHeader(DisplayName = "行号")]
public string { set; get; }
[ImporterHeader(Name = "客户")]
[ExporterHeader(DisplayName = "客户")]
public string { set; get; }
[ImporterHeader(Name = "出库类型")]
[ExporterHeader(DisplayName = "出库类型")]
public string { set; get; }
[ImporterHeader(Name = "结算编码")]
[ExporterHeader(DisplayName = "结算编码")]
public string { set; get; }
[ImporterHeader(Name = "销售渠道")]
[ExporterHeader(DisplayName = "销售渠道")]
public string { set; get; }
[ImporterHeader(Name = "客户代码")]
[ExporterHeader(DisplayName = "客户代码")]
public string { set; get; }
[ImporterHeader(Name = "结算单")]
[ExporterHeader(DisplayName = "结算单")]
public string { set; get; }
[ImporterHeader(Name = "物料号")]
[ExporterHeader(DisplayName = "物料号")]
public string { set; get; }
[ImporterHeader(Name = "通用代码号")]
[ExporterHeader(DisplayName = "通用代码号")]
public string { set; get; }
[ImporterHeader(Name = "寄售类别")]
[ExporterHeader(DisplayName = "寄售类别")]
public string { set; get; }
[ImporterHeader(Name = "结算数量")]
[ExporterHeader(DisplayName = "结算数量")]
public decimal { set; get; }
[ImporterHeader(Name = "实际出库数量")]
[ExporterHeader(DisplayName = "实际出库数量")]
public decimal { set; get; }
[ImporterHeader(Name = "差异数量")]
[ExporterHeader(DisplayName = "差异数量")]
public decimal { set; get; }
[ImporterHeader(Name = "开票单价")]
[ExporterHeader(DisplayName = "开票单价")]
public decimal { set; get; }
[ImporterHeader(Name = "结算金额")]
[ExporterHeader(DisplayName = "结算金额")]
public decimal { set; get; }
[ImporterHeader(Name = "已出库金额")]
[ExporterHeader(DisplayName = "已出库金额")]
public decimal { set; get; }
[ImporterHeader(Name = "WMS待出库金额")]
[ExporterHeader(DisplayName = "WMS待出库金额")]
public decimal WMS待出库金额 { set; get; }
[ImporterHeader(Name = "物料组编码")]
[ExporterHeader(DisplayName = "物料组编码")]
public string { set; get; }
[ImporterHeader(Name = "物料组车型")]
[ExporterHeader(DisplayName = "物料组车型")]
public string { set; get; }
[ImporterHeader(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string { set; get; }
[ImporterHeader(Name = "备注")]
[ExporterHeader(DisplayName = "备注")]
public string { set; get; }
}
@ -88,7 +111,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
}
public virtual List<WmsOutputSum> GetWmsSumExtendList(string version)
public virtual List<WmsOutputSumReport> GetWmsSumExtendList(string version)
{
var _sql = "SELECT\n" +
@ -99,11 +122,15 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" CODE 结算编码,\n" +
" SaleCode 销售渠道,\n" +
" ClientCode 客户代码,\n" +
" LOGN 寄售类别,\n" +
" LOGN 寄售类别,\n" +
" MaterialCode 物料号,\n" +
" MaterialDesc 物料描述,\n" +
" BillNum 结算单号,\n" +
" MaterialGroup 物料组,\n" +
" MaterialGroup 物料组车型,\n" +
" EstimateType 物料组编码,\n" +
" ISnull([ 0 ], 2 ) 结算数量,\n" +
" ISNULL([ 2 ], 0 ) 实际出库数量,\n" +
" isnull([ 0 ], 2 ) - ISNULL([ 2 ], 0 ) 数量差异,\n" +
@ -602,7 +629,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" 客户,出库类型,结算单;";
_sql = string.Format(_sql, version);
var _query = DbConnection.Query<WmsOutputSum>(_sql, null, null, true, 1200, null);
var _query = DbConnection.Query<WmsOutputSumReport>(_sql, null, null, true, 1200, null);
return _query.ToList();
}
@ -613,13 +640,13 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
public virtual List<WmsOutputSum> GetWmsSumReportList(string version,string state)
public virtual List<WmsOutputSumReport> GetWmsSumReportList(string version,string state)
{
var _sql = "SELECT\n" +
" ROW_NUMBER()OVER(ORDER BY Type DESC) 行号 ,\n"+
" ROW_NUMBER()OVER(ORDER BY Type DESC) 行号 ,\n" +
" temp1.Client 客户,\n" +
" temp1.Type 出库类型,\n" +
" temp1.BillNum 结算单,\n" +
@ -630,10 +657,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Isnull( temp1.Qty, 0 )- Isnull( temp1.OutputQty, 0 ) 差异数量,\n" +
" temp1.Price 开票单价,\n" +
" Round( Isnull( temp1.Qty, 0 )* temp1.Price, 2 ) 结算金额,\n" +
" Round(( Isnull( temp1.Qty, 0 )- Isnull( temp1.OutputQty, 0 ))* temp1.Price, 2 ) WMS待出库金额 \n" +
" temp2.EstimateType 物料组编码, \n"+
" temp2.EstimateTypeDesc 物料组车型, \n"+
" temp2.MaterialDesc 物料描述 \n"+
" Round(( Isnull( temp1.Qty, 0 )- Isnull( temp1.OutputQty, 0 ))* temp1.Price, 2 ) WMS待出库金额, \n" +
" temp2.EstimateType 物料组编码, \n" +
" temp2.EstimateTypeDesc 物料组车型, \n" +
" temp2.MaterialDesc 物料描述 \n" +
"FROM\n" +
" (\n" +
@ -767,12 +794,13 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" IsBack = 1 \n" +
" AND VERSION = '{0}' \n" +
" AND State = 3 \n" +
" ) temp1";
" ) temp1 \n" +
" LEFT JOIN(SELECT max(Id) Id, MaterialCode, MaterialDesc, EstimateType, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, EstimateType) temp2 ON temp1.MaterialCode = temp2.MaterialCode ";
_sql = string.Format(_sql, version,state);
var _query = DbConnection.Query<WmsOutputSum>(_sql,null,null,true,1200,null);
var _query = DbConnection.Query<WmsOutputSumReport>(_sql,null,null,true,1200,null);

Loading…
Cancel
Save