修改了同步序列号
This commit is contained in:
@@ -102,6 +102,11 @@ namespace WMS.Web.Domain.Entitys
|
||||
///</summary>
|
||||
[Column("IsActivate")]
|
||||
public bool? IsActivate { get; set; } = false;
|
||||
///// <summary>
|
||||
///// 产生第二个
|
||||
///// </summary>
|
||||
//[Column("TwoSerialNumber")]
|
||||
//public string? TwoSerialNumber { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 操作(绑定箱信息)
|
||||
|
||||
@@ -75,6 +75,10 @@ namespace WMS.Web.Domain.IService.Public
|
||||
/// <returns></returns>
|
||||
Task<ResultList<ErpInStockResultDto>> BillQueryForAssembledApp_Disassembly(List<string> sourceBillNos = null, DateTime? beginTime = null, bool isCheck = true);
|
||||
|
||||
|
||||
Task<ResultList<ErpInStockResultDto>> BillQueryForProduceSotckin(List<string> sourceBillNos = null, DateTime? beginTime = null, bool isCheck = true);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// erp:单据查询-出库单
|
||||
/// </summary>
|
||||
|
||||
@@ -30,6 +30,10 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
Task<List<SerialNumbers>> GetEntityListByBoxId(int boxId);
|
||||
/// 根据箱Ids查询集合
|
||||
Task<List<SerialNumbers>> GetEntityListByBoxIds(List<int> boxIds);
|
||||
|
||||
/// 根据生成记录id查询序列码
|
||||
Task<List<SerialNumbers>> GetEntityListBySuitNumber(string suitNumber);
|
||||
|
||||
/// 修改实体集合
|
||||
Task<bool> EditEntityList(List<SerialNumbers> entitys, bool isTransaction = true);
|
||||
//批量删除
|
||||
|
||||
@@ -103,7 +103,14 @@ namespace WMS.Web.Domain.Services
|
||||
var opsSerial = list.FirstOrDefault(f => f.OpsBoxId == b.OpsBoxId).Details
|
||||
.SelectMany(s => s.SerialNumbers)
|
||||
.FirstOrDefault(s => s.SerialNumber.Equals(sn.SerialNumber));
|
||||
//序列号
|
||||
////序列号
|
||||
//var serialList = await _serialNumbersRepositories.GetEntityListBySuitNumber(sn.SerialNumber);
|
||||
|
||||
//for (int i = 0; i < serialList.Count; i++)
|
||||
//{
|
||||
//SerialNumbers s = new SerialNumbers(serialList[i].SerialNumber, detail.MaterialNumber, b.Id, b.OpsBoxId, opsSerial.BarCereateUser, opsSerial.BarCreateTime, b.CompleteCartonTime);
|
||||
//sList.Add(s);
|
||||
|
||||
SerialNumbers s = new SerialNumbers(sn.SerialNumber, detail.MaterialNumber, b.Id, b.OpsBoxId, opsSerial.BarCereateUser, opsSerial.BarCreateTime, b.CompleteCartonTime);
|
||||
sList.Add(s);
|
||||
//序列号记录(序列号生成)
|
||||
@@ -113,6 +120,15 @@ namespace WMS.Web.Domain.Services
|
||||
SerialNumberOperate so_g = new SerialNumberOperate();
|
||||
so_g.CompleteCartonBox(sn.SerialNumber, detail.MaterialNumber, b);
|
||||
soList.Add(so_g);
|
||||
|
||||
////序列号记录(序列号生成)
|
||||
//SerialNumberOperate so = new SerialNumberOperate(serialList[i].SerialNumber, SerialNumberOperateType.Generate, detail.MaterialNumber, opsSerial.BarCereateUser, "", b.SupplierId, b.OrgId, null, opsSerial.BarCreateTime);
|
||||
//soList.Add(so);
|
||||
////序列号记录(装箱)
|
||||
//SerialNumberOperate so_g = new SerialNumberOperate();
|
||||
//so_g.CompleteCartonBox(serialList[i].SerialNumber, detail.MaterialNumber, b);
|
||||
//soList.Add(so_g);
|
||||
//}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -124,6 +124,25 @@ namespace WMS.Web.Domain.Services
|
||||
return await this.SysnDataNew(erp_list.ToList(), isTransaction);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 同步:生产入库单据
|
||||
/// </summary>
|
||||
/// <param name="billNos"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> SsynProduceSotck(List<string> billNos = null, bool isTransaction = true, DateTime? beginTime = null)
|
||||
{
|
||||
//1.获取金蝶数据:生产入库数据
|
||||
var erp_result = await _erpService.BillQueryForProduceSotckin(billNos, beginTime);
|
||||
if (!erp_result.IsSuccess)
|
||||
return Result.ReFailure(erp_result.Message, erp_result.Status);
|
||||
var erp_list = erp_result.Data;
|
||||
|
||||
return await this.SysnDataNew(erp_list.ToList(), isTransaction);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 同步:其他入库单
|
||||
/// </summary>
|
||||
@@ -240,6 +259,13 @@ namespace WMS.Web.Domain.Services
|
||||
{
|
||||
var beginTime = DateTime.Now.AddHours(-262);//默认拉去8小时以内的数据,ALTER BY YZH
|
||||
|
||||
//6.同步数据:生产入库单
|
||||
var ProduceSotck_result = await this.SsynProduceSotck(null, isTransaction, beginTime);
|
||||
if (!ProduceSotck_result.IsSuccess)
|
||||
return Result.ReFailure(ProduceSotck_result.Message, ProduceSotck_result.Status);
|
||||
|
||||
|
||||
|
||||
//1.同步数据:采购订单
|
||||
var purchase_result = await this.SsynPurchaseInStock(null, isTransaction, beginTime);
|
||||
if (!purchase_result.IsSuccess)
|
||||
@@ -755,6 +781,7 @@ namespace WMS.Web.Domain.Services
|
||||
List<string> TransferDirect_sourceBillNos = new List<string>();
|
||||
List<string> Transferin_sourceBillNos = new List<string>();
|
||||
List<string> AssembledApp_sourceBillNos = new List<string>();
|
||||
List<string> ProduceSotck_sourceBillNos = new List<string>();//生产入库
|
||||
|
||||
foreach (var entity in list)
|
||||
{
|
||||
@@ -768,6 +795,16 @@ namespace WMS.Web.Domain.Services
|
||||
AssembledApp_sourceBillNos.Add(entity.SourceBillNo);
|
||||
else if (entity.Type == InstockType.Miscellaneous)
|
||||
Miscellaneous_sourceBillNos.Add(entity.SourceBillNo);
|
||||
else if (entity.Type == InstockType.ProduceSotck)
|
||||
ProduceSotck_sourceBillNos.Add(entity.SourceBillNo);
|
||||
}
|
||||
|
||||
if (ProduceSotck_sourceBillNos.Count() > 0)//生产入库
|
||||
{
|
||||
var erp_result = await _erpService.BillQueryForProduceSotckin(ProduceSotck_sourceBillNos, null);
|
||||
if (!erp_result.IsSuccess)
|
||||
return Result<List<ErpInStockResultDto>>.ReFailure(erp_result.Message, erp_result.Status);
|
||||
erp_list.AddRange(erp_result.Data);
|
||||
}
|
||||
|
||||
if (Instock_sourceBillNos.Count() > 0)
|
||||
@@ -812,6 +849,8 @@ namespace WMS.Web.Domain.Services
|
||||
|
||||
erp_list.AddRange(erp_result_disass.Data);
|
||||
}
|
||||
|
||||
|
||||
return Result<List<ErpInStockResultDto>>.ReSuccess(erp_list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,6 +620,124 @@ namespace WMS.Web.Domain.Services.Public
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// erp:单据查询-生产入单,生产汇报单(已审核的)
|
||||
/// </summary>
|
||||
/// <param name="sourceBillNos"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ResultList<ErpInStockResultDto>> BillQueryForProduceSotckin(List<string> sourceBillNos = null, DateTime? beginTime = null, bool isCheck = true)
|
||||
{
|
||||
string result_json = "";
|
||||
try
|
||||
{
|
||||
|
||||
var stocks = await _basicsRepositories.GetUcStockAsync(ManagementSystemCode.GLXT0004.ToString(), "", _appOptions.CompanyId);
|
||||
if (stocks.Count == 0)
|
||||
return ResultList<ErpInStockResultDto>.ReFailure(ResultCodes.ErpStockNoData);
|
||||
var stocks_codes = string.Join(",", stocks.Select(x => $"'{x.Code}'"));
|
||||
var stocks_orgs = string.Join(",", stocks.Select(x => $"'{x.ErpOrgCode}'"));
|
||||
|
||||
//1.先登录金蝶-拿到token
|
||||
var token_result = await this.Init();
|
||||
if (!token_result.IsSuccess)
|
||||
return ResultList<ErpInStockResultDto>.ReFailure(token_result);
|
||||
|
||||
//2.时间条件:可能还有其它条件
|
||||
//var beginTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
|
||||
var beginStr = DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
if (beginTime != null) beginStr = beginTime?.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
//3.获取金蝶分步式入库订单:拼接参数和条件
|
||||
var query = new ErpBillQueryDto(token_result.Data);
|
||||
var param = new ErpBillQueryParamDto(FormIdParam.PRD_MORPT.ToString());
|
||||
param.FieldKeys = "FBillNo,FReqBillNo,FPrdOrgId,FPrdOrgId.FNumber,FMATERIALID.FNumber,FSpecification,FMaterialName,FSTOCKID,FSTOCKID.FNumber,FQuaQty,FCreateDate,FDescriptionE,FEntity_FEntryID";
|
||||
param.Limit = 10000;
|
||||
//查询条件:备注其中的条件值以金蝶的值为准!!!
|
||||
//1.创建时间在两天前和当天时间之间
|
||||
//2.审核状态:已审核
|
||||
//3.单据类型:标准分步式调入单;这里要注意了-----------测试端的“单据类型ID”和线上的可能不一样;上线的时候要核对下
|
||||
//5.仓库:wms系统的仓库值---现在这个没有加,因为还单点没有和金蝶同步
|
||||
//当金蝶系统物料明细行调出仓库和调入仓库相同, 数据不需要拉取
|
||||
//param.FilterString = " FDocumentStatus='C' and FBillTypeID='e65a4f29743a44b7b67dc8145e1f9c92'";
|
||||
param.FilterString = " 1=1";
|
||||
if (isCheck) param.FilterString += " and FDocumentStatus='C'";
|
||||
//param.FilterString += " and FSrcStockId!=FDestStockId";
|
||||
for (int i = 0; i < stocks.Count(); i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
param.FilterString += " and (";
|
||||
param.FilterString += $"(FSTOCKID.FNumber='{stocks[i].Code}' and FPrdOrgId.FNumber='{stocks[i].ErpOrgCode}')";
|
||||
// param.FilterString += $"( FPrdOrgId.FNumber='{stocks[i].ErpOrgCode}')";
|
||||
}
|
||||
else
|
||||
param.FilterString += $" or (FSTOCKID.FNumber='{stocks[i].Code}' and FPrdOrgId.FNumber='{stocks[i].ErpOrgCode}')";
|
||||
if (i == stocks.Count() - 1) param.FilterString += ")";
|
||||
|
||||
}
|
||||
|
||||
//根据原订单号查询
|
||||
if (sourceBillNos != null && sourceBillNos.Count() > 0)
|
||||
{
|
||||
param.FilterString = param.FilterString + " and FBillNo in (";
|
||||
|
||||
var bill_str = "";
|
||||
int bill_index = 0;
|
||||
//var srt_b = JsonConvert.SerializeObject(sourceBillNos);
|
||||
foreach (var bill in sourceBillNos)
|
||||
{
|
||||
bill_index++;
|
||||
if (bill_index == sourceBillNos.Count)
|
||||
bill_str = bill_str + $"'{bill}'";
|
||||
else
|
||||
bill_str = bill_str + $"'{bill}'" + ",";
|
||||
}
|
||||
param.FilterString = param.FilterString + bill_str + ")";
|
||||
}//注意:当有单据编号的查询的时候,时间条件去掉;不然就查不到数据了
|
||||
else
|
||||
{
|
||||
//param.FilterString = param.FilterString + " and FCreateDate>='" + beginTime + "' and FCreateDate<='" + endTime + "'";
|
||||
param.FilterString = param.FilterString + " and FApproveDate>='" + beginStr + "' and FApproveDate<='" + endTime + "'";
|
||||
}
|
||||
|
||||
query.Data = JsonConvert.SerializeObject(param);
|
||||
var json = JsonConvert.SerializeObject(query);
|
||||
|
||||
//4.请求查询接口
|
||||
result_json = await _client.ExecuteBillQueryAsync(json);
|
||||
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
|
||||
|
||||
//5.返回数据的组装
|
||||
var erp_list = new List<ErpInStockResultDto>();
|
||||
foreach (var item in result)
|
||||
{
|
||||
var lis = new ErpInStockResultDto();
|
||||
lis.BillNo = item[0];
|
||||
lis.OrgId = Convert.ToInt32(item[2]);
|
||||
lis.MaterialNumber = item[4];
|
||||
lis.StockId = Convert.ToInt32(item[7]);
|
||||
lis.StockCode = item[8];
|
||||
lis.Qty = Convert.ToDecimal(item[9]);
|
||||
lis.CreateTime = Convert.ToDateTime(item[10]);
|
||||
lis.Remark = item[11];
|
||||
lis.OrgCode = item[3];
|
||||
lis.ErpDetailId = Convert.ToInt32(item[12]);
|
||||
lis.Type = (int)InstockType.ProduceSotck;
|
||||
lis.SaleBillNo= item[1];
|
||||
erp_list.Add(lis);
|
||||
}
|
||||
//_logger.LogInformation("分步式调入条数:" + erp_list.Count);
|
||||
return ResultList<ErpInStockResultDto>.ReSuccess(erp_list);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"BillQueryForTransferin->拉取金蝶数据失败yzh:{ex.Message} 返回json:{result_json}");
|
||||
return ResultList<ErpInStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// erp:单据查询-组装拆卸单-组装(成品入库)
|
||||
/// </summary>
|
||||
@@ -2469,6 +2587,8 @@ namespace WMS.Web.Domain.Services.Public
|
||||
return ResultList<ErpDeliveryNoticeOutStockResultDto>.ReFailure(ResultCodes.Erp_BillQuery_Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 销售出库单
|
||||
/// </summary>
|
||||
|
||||
@@ -80,6 +80,11 @@ namespace WMS.Web.Domain.Values.Erp
|
||||
/// <summary>
|
||||
/// 即时库存
|
||||
/// </summary>
|
||||
STK_Inventory = 18
|
||||
STK_Inventory = 18,
|
||||
/// <summary>
|
||||
/// 生产入库单(来源于生产汇报单)
|
||||
/// </summary>
|
||||
PRD_MORPT = 19,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,5 +35,10 @@ namespace WMS.Web.Domain.Values
|
||||
/// </summary>
|
||||
[EnumRemark("组装拆卸入库")]
|
||||
Assembled = 5,
|
||||
/// <summary>
|
||||
/// 生产入库
|
||||
/// </summary>
|
||||
[EnumRemark("生产入库")]
|
||||
ProduceSotck = 6,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user