入库单和出库单

This commit is contained in:
余宇波 2025-11-05 18:19:40 +08:00
parent cd93b84014
commit dfde366b8e
12 changed files with 243 additions and 16 deletions

View File

@ -13,6 +13,8 @@ namespace MyCode.Project.Domain.Message.Request.JackYun
/// </summary>
public class BusiOrderGoodsDocInRequest: BaseRequestBizData
{
public string contextId { get; set; }
/// <summary>
/// 需要查询的字段列表,多个字段用逗号分隔
/// 例如:"goodsNo,goodsName,skuName"

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyCode.Project.Infrastructure.JackYun
namespace MyCode.Project.Domain.Message.Response.JackYun
{
///// <summary>
///// 入库查询(规格模式)返回参数
@ -257,12 +257,22 @@ namespace MyCode.Project.Infrastructure.JackYun
/// <summary>
/// 出入库日期(表头数据)
/// </summary>
public DateTime? inOutDate { get; set; }
public long? inOutDate { get; set; }
/// <summary>
/// 出入库日期(表头数据)
/// </summary>
public DateTime? inOutDate2 { get; set; }
/// <summary>
/// 系统出入库日期(表头数据)
/// </summary>
public DateTime? gmtCreate { get; set; }
public long? gmtCreate { get; set; }
/// <summary>
/// 系统出入库日期(表头数据)
/// </summary>
public DateTime? gmtCreate2 { get; set; }
/// <summary>
/// 入库类型(表头数据)(100-期初库存101-采购入库102-调拨入库103-盘盈入库104-其他入库105-销售退货106-完工入库107-组装拆卸入库108-翻新入库109-报废入库110-残次品入库111-成本调整112-即采即入113-退料入库114-调拨退回115-维修返厂返还116-资产入库117-借用入库118-归还入库119-生产委外入库120-生产其他入库122-调拨退货入库123- 生产余料入库131-成本调价入库132-结算补差133-成本补差)
@ -503,7 +513,11 @@ namespace MyCode.Project.Infrastructure.JackYun
/// 物流单号(表头数据)
/// </summary>
public string logisticNo { get; set; }
/// <summary>
/// 货品明细id
/// </summary>
public long RecId { get; set; }
}

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyCode.Project.Infrastructure.JackYun
namespace MyCode.Project.Domain.Message.Response.JackYun
{
@ -654,4 +654,14 @@ namespace MyCode.Project.Infrastructure.JackYun
public string DetailField10 { get; set; }
}
public class ErpStorageGoodsDocOutV2ResponseBizData2
{
public List<ErpStorageGoodsDocOutV2ResponseBizData> Data { get; set; }
/// <summary>
/// 上下文编号
/// </summary>
public string contextId { get; set; }
}
}

View File

@ -35,14 +35,28 @@ namespace MyCode.Project.Domain.Model
/// Default:
/// Nullable:True
/// </summary>
public DateTime? InOutDate {get;set;}
public long? InOutDate {get;set;}
/// <summary>
/// Desc:系统出入库日期
/// Default:
/// Nullable:True
/// </summary>
public DateTime? GmtCreate {get;set;}
public long? GmtCreate {get;set;}
/// <summary>
/// Desc:出入库日期
/// Default:
/// Nullable:True
/// </summary>
public DateTime? InOutDate2 {get;set;}
/// <summary>
/// Desc:系统出入库日期
/// Default:
/// Nullable:True
/// </summary>
public DateTime? GmtCreate2 {get;set;}
/// <summary>
/// Desc:入库类型
@ -366,5 +380,19 @@ namespace MyCode.Project.Domain.Model
/// </summary>
public DateTime? UpdateTime {get;set;}
/// <summary>
/// Desc:货品明细id
/// Default:
/// Nullable:True
/// </summary>
public long? RecId {get;set;}
/// <summary>
/// Desc:0=未处理 1=已合并 2=已推送
/// Default:0
/// Nullable:True
/// </summary>
public int? Status {get;set;}
}
}

View File

@ -80,8 +80,10 @@
<Compile Include="Message\Response\Common\IdName.cs" />
<Compile Include="Message\Response\Common\ItemResult.cs" />
<Compile Include="Message\Response\Common\ListHeadFieldData.cs" />
<Compile Include="Message\Response\JackYun\BusiOrderGoodsDocInResponse.cs" />
<Compile Include="Message\Response\JackYun\CreateAndStockinResp.cs" />
<Compile Include="Message\Response\JackYun\PushOrderListResp.cs" />
<Compile Include="Message\Response\JackYun\StorageGoodsDocOutV2Response.cs" />
<Compile Include="Message\Response\KingDee\ErrorResponse.cs" />
<Compile Include="Message\Response\KingDee\K3Result\K3ApiResult.cs" />
<Compile Include="Message\Response\KingDee\K3Result\Model\K3CloudResult.cs" />

View File

@ -2,5 +2,6 @@
{
public class BaseRequestBizData
{
}
}

View File

@ -265,11 +265,9 @@
<Compile Include="Imports\ImportResult.cs" />
<Compile Include="Imports\ImportSplitProperty.cs" />
<Compile Include="JackYun\EnumAttribute.cs" />
<Compile Include="JackYun\BusiOrderGoodsDocInResponse.cs" />
<Compile Include="JackYun\GoodsDetail.cs" />
<Compile Include="JackYun\JackyunResponse.cs" />
<Compile Include="JackYun\ReturnChangeListResp.cs" />
<Compile Include="JackYun\StorageGoodsDocOutV2Response.cs" />
<Compile Include="JackYun\TradeFullinfogetResp.cs" />
<Compile Include="PayModels\ExtendedGateway.cs" />
<Compile Include="PayModels\FuiouBarcodepay.cs" />

View File

@ -1,6 +1,7 @@
using MyCode.Project.Infrastructure.JackYun;
using System.Collections.Generic;
using System;
using MyCode.Project.Domain.Message.Response.JackYun;
namespace MyCode.Project.Services
{
@ -38,5 +39,13 @@ namespace MyCode.Project.Services
/// <returns></returns>
/// <exception cref="BaseException"></exception>
List<BusiOrderGoodsDocInResponse> GetPurchaseInboundData(DateTime now);
/// <summary>
/// 获取吉客云采购出库单
/// </summary>
/// <param name="now">截止日期</param>
/// <returns></returns>
/// <exception cref="BaseException"></exception>
List<ErpStorageGoodsDocOutV2ResponseBizData> GetStorageGoodsDocOutV2(DateTime now);
}
}

View File

@ -45,5 +45,14 @@ namespace MyCode.Project.Services
/// </summary>
/// <param name="now"></param>
void GetPurchaseInboundData(string now);
/// <summary>
/// 调度运行吉客云采购出库单
/// </summary>
/// <param name="now"></param>
void GetStorageGoodsDocOutV2(string now);
}
}

View File

@ -1,4 +1,5 @@
using MyCode.Project.Domain.Message.Request.JackYun;
using MyCode.Project.Domain.Message.Response.JackYun;
using MyCode.Project.Domain.Repositories;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Infrastructure.Enumeration;
@ -291,8 +292,8 @@ namespace MyCode.Project.Services.Implementation
}
//101-采购入库
requestBizData.Inouttypes = "101";
requestBizData.InOutDateStart = value;
requestBizData.InOutDateEnd = value1;
requestBizData.InOutDateStart = new DateTimeOffset(DateTime.Parse(value)).ToUnixTimeMilliseconds().ToString() ;
requestBizData.InOutDateEnd = new DateTimeOffset(DateTime.Parse(value1)).ToUnixTimeMilliseconds().ToString();
requestBizData.PageSize = 200;
requestBizData.PageIndex = 0;
@ -318,9 +319,93 @@ namespace MyCode.Project.Services.Implementation
var list1 = JsonHelper.ToObject<BusiOrderGoodsDocInResponse2>(orderjson);
int pageIndex = 1;
string TotalResults = list1.contextId;
while (list1.Data.Count>0)
{
trades.AddRange(list1.Data);
requestBizData.PageIndex = pageIndex;
requestBizData.contextId = TotalResults;
pageIndex++;
Thread.Sleep(100);
response = Call(EnumAttribute.GetAttribute(ApiEnum.STORAGEGOODSDOCINCOUNTS).Value, "1.0", requestBizData);
if (response.code == "200")
{
orderjson = JsonHelper.ToJson(response.result);
list1 = JsonHelper.ToObject<BusiOrderGoodsDocInResponse2>(orderjson);
TotalResults = list1.contextId;
}
else
{
TotalResults = "";
}
}
}
else
{
string msg = response.msg;
throw new BaseException(msg);
}
});
//var shocodes = shopConfigs.Select(t => t.FPURCHASINGWAREHOUSECODE).ToList();
//trades = trades.Where(t => shocodes.Contains(t.warehouseCode)).ToList();
return trades;
}
#endregion
#region
/// <summary>
/// 获取吉客云采购出库单
/// </summary>
/// <param name="now">截止日期</param>
/// <returns></returns>
/// <exception cref="BaseException"></exception>
public List<ErpStorageGoodsDocOutV2ResponseBizData> GetStorageGoodsDocOutV2(DateTime now)
{
var shopConfigs = _yTKJTShopParameterRepository.Queryable().Where(t => t.FDOCUMENTSTATUS == "C" && t.FPURCHASERECEIVING == "1").ToList();
StorageGoodsDocOutV2Request requestBizData = new StorageGoodsDocOutV2Request();
//string value = "2025-06-15 00:00:00";// DateTime.Now.Date.AddDays(-5).ToString("yyyy-MM-dd HH:mm:ss") ;
//string value1 = "2025-06-20 00:00:00";//DateTime.Now.Date.ToString("yyyy-MM-dd HH:mm:ss");
string value = now.Date.AddDays(-7).ToString("yyyy-MM-dd");
string value1 = now.Date.ToString("yyyy-MM-dd");
if (now.Date.AddDays(-7) < startTime)
{
value = startTime.ToString("yyyy-MM-dd");
}
//205采购退货
requestBizData.Inouttype = 205;
requestBizData.StartDate = value;
requestBizData.EndDate = value1;
requestBizData.PageSize = 200;
requestBizData.PageIndex = 0;
requestBizData.SelelctFields = "*"; //"RecId,GoodsdocNo,BillNo,InOutDate,GmtCreate,Inouttype,InouttypeName,VendCustomerName,CurrencyCode,CurrencyRate,UserName,WarehouseCode,WarehouseName,Comment,Memo,LogisticName,LogisticNo,CompanyId,CompanyName,LogisticType,LogisticCode,InOutReason,SourceBillNo,ChannelId,ChannelCode,ChannelName,RedStatus,Field1,Field2,Field3,Field4,Field5,FinanceBillStatus,VendCustomerId,ApplyDepartId,ApplyDepartName,OutBillNo,LogisticList,GmtModified,DepartCode,ApplyCompanyName,ApplyCompanyCode,ApplyCompanyId,ApplyUserId,ApplyUserName,CompanyCode,GoodsDocDetailList,SendCompanyName,Send,SendTel,SendPhone,SendEmail,SendCountryName,SendProvinceName,SendCityName,SendTownName,SendStreetName,SendAddress,ReceiveCompanyName,Receive,ReceiveTel,ReceivePhone,ReceiveEmail,ReceiveCountryName,ReceiveProvinceName,ReceiveCityName,ReceiveTownName,ReceiveStreetName,ReceiveAddress";
List<int> TradeTypeList = new List<int>();
TradeTypeList.Add(1005);
List<ErpStorageGoodsDocOutV2ResponseBizData> reslut = new List<ErpStorageGoodsDocOutV2ResponseBizData>();
List<ErpStorageGoodsDocOutV2ResponseBizData> trades = new List<ErpStorageGoodsDocOutV2ResponseBizData>();
TradeTypeList.ForEach(ty =>
{
string lggl = JsonHelper.ToJson(requestBizData);
LogHelper.Info(lggl);
JackyunResponse response = Call(EnumAttribute.GetAttribute(ApiEnum.ERPSTORAGEGOODSDOCOUTV2).Value, "1.0", requestBizData);
string ll = JsonHelper.ToJson(response);
LogHelper.Info(ll);
if (response.code == "200")
{
var orderjson = JsonHelper.ToJson(response.result);
var list1 = JsonHelper.ToObject<ErpStorageGoodsDocOutV2ResponseBizData2>(orderjson);
int pageIndex = 1;
string TotalResults = list1.contextId;
while (!string.IsNullOrWhiteSpace(TotalResults))
while (list1.Data.Count>0)
{
//list1.data.returnChangeList.ForEach(h => h.TradeType = ty);
@ -328,10 +413,11 @@ namespace MyCode.Project.Services.Implementation
requestBizData.PageIndex = pageIndex;
pageIndex++;
Thread.Sleep(100);
response = Call(EnumAttribute.GetAttribute(ApiEnum.STORAGEGOODSDOCINCOUNTS).Value, "1.0", requestBizData);
response = Call(EnumAttribute.GetAttribute(ApiEnum.ERPSTORAGEGOODSDOCOUTV2).Value, "1.0", requestBizData);
if (response.code == "200")
{
orderjson = JsonHelper.ToJson(response.result);
orderjson = JsonHelper.ToJson(response.result);
list1 = JsonHelper.ToObject<ErpStorageGoodsDocOutV2ResponseBizData2>(orderjson);
}
}
@ -384,7 +470,7 @@ namespace MyCode.Project.Services.Implementation
//return reslut;
return new List<BusiOrderGoodsDocInResponse>();
return new List<ErpStorageGoodsDocOutV2ResponseBizData>();
}
#endregion
}

View File

@ -3,6 +3,7 @@ using MyCode.Project.Domain.Model;
using MyCode.Project.Domain.Repositories;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Infrastructure.JackYun;
using MyCode.Project.Repositories;
using MyCode.Project.Repositories.Common;
using MyCode.Project.Services.IServices;
using System;
@ -21,6 +22,7 @@ namespace MyCode.Project.Services.Implementation
private IPushKingDeeOrderItemRepository _pushKingDeeOrderItemRepository;
private IYTKJTShopParameterRepository _yTKJTShopParameterRepository;
private IReturnChangeGoodsDetailRepository _ReturnChangeGoodsDetailRepository;
private IBusiOrderGoodsDocInRepository _busiOrderGoodsDocInRepository;
private IWorkProcessService _workProcessService;
@ -30,6 +32,7 @@ namespace MyCode.Project.Services.Implementation
, IPushKingDeeOrderItemRepository pushKingDeeOrderItemRepository
, IYTKJTShopParameterRepository yTKJTShopParameterRepository
, IReturnChangeGoodsDetailRepository returnChangeGoodsDetailRepository
, IBusiOrderGoodsDocInRepository busiOrderGoodsDocInRepository
, IJackYunService jackYunService,
IWorkProcessService workProcessService)
{
@ -39,6 +42,8 @@ namespace MyCode.Project.Services.Implementation
_jackOrdersRepository = jackOrdersRepository;
_jackOrdersItemRepository = jackOrdersItemRepository;
_ReturnChangeGoodsDetailRepository = returnChangeGoodsDetailRepository;
_busiOrderGoodsDocInRepository = busiOrderGoodsDocInRepository;
_jackYunService = jackYunService;
_workProcessService = workProcessService;
}
@ -329,11 +334,63 @@ namespace MyCode.Project.Services.Implementation
{
DateTime runTime = DateTime.Parse(now);
var list = _jackYunService.GetPurchaseInboundData(runTime);
//SetReturnOrder(list);
SetPurchaseInboundData(list);
//_workProcessService.Add<IJackYunTaskService>(this.MerchantId, "GetAndMergeJackReturnYunOrder", "合并吉客云退货订单到新表", now, 1);
}
#endregion
#region SetPurchaseInboundData()
/// <summary>
/// 把吉客云采购订单存进本地数据库
/// </summary>
/// <param name="trades"></param>
[TransactionCallHandler]
public void SetPurchaseInboundData(List<BusiOrderGoodsDocInResponse> trades)
{
var ids = trades.Select(t => t.RecId).Distinct().ToList();
ids = _busiOrderGoodsDocInRepository.Queryable().Where(t =>t.RecId!=null && ids.Contains(t.RecId.Value)).Select(t => t.RecId.Value).ToList();
trades = trades.Where(t => !ids.Contains(t.RecId)).ToList();
List<BusiOrderGoodsDocIn> addList = new List<BusiOrderGoodsDocIn>();
addList = AutoMapperHelper.AutoMappToList<BusiOrderGoodsDocIn, BusiOrderGoodsDocInResponse>(trades);
addList.ForEach(item =>
{
item.ID = Guid.NewGuid();
DateTime startTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
item.InOutDate2 = startTime.AddMilliseconds(item.InOutDate.Value).ToLocalTime();
item.GmtCreate2 = startTime.AddMilliseconds(item.GmtCreate.Value).ToLocalTime();
item.Status = 0;
item.CreateTime = DateTime.Now;
item.CreateUserName = "";
});
if (addList.Count > 0)
{
_busiOrderGoodsDocInRepository.Add(addList);
}
}
#endregion
#region GetStorageGoodsDocOutV2()
/// <summary>
/// 调度运行吉客云采购出库单
/// </summary>
/// <param name="now"></param>
public void GetStorageGoodsDocOutV2(string now)
{
DateTime runTime = DateTime.Parse(now);
var list = _jackYunService.GetStorageGoodsDocOutV2(runTime);
//SetPurchaseInboundData(list);
//_workProcessService.Add<IJackYunTaskService>(this.MerchantId, "GetAndMergeJackReturnYunOrder", "合并吉客云退货订单到新表", now, 1);
}
#endregion
}
}

View File

@ -259,7 +259,18 @@ namespace MyCode.Project.WebApi.Controllers
}
#endregion
#region
/// <summary>
/// 调度运行吉客云采购出库单
/// </summary>
[HttpGet]
[AllowAnonymous]
public void GetStorageGoodsDocOutV2(string now)
{
_jackYunTaskService.GetStorageGoodsDocOutV2(now);
}
#endregion
}
}