|
|
|
|
@@ -66,6 +66,7 @@ namespace Tnb.WarehouseMgr
|
|
|
|
|
private readonly IWmsCarryQueryService _wmsCarryQueryService;
|
|
|
|
|
|
|
|
|
|
public static SemaphoreSlim s_taskDistributeToZCC = new(1);
|
|
|
|
|
public static SemaphoreSlim s_taskDistributeYCL2ZCC = new(1);
|
|
|
|
|
|
|
|
|
|
public WmsMaterialTransferService(
|
|
|
|
|
ISqlSugarRepository<WmsCarryH> repository,
|
|
|
|
|
@@ -292,7 +293,7 @@ namespace Tnb.WarehouseMgr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按托下发
|
|
|
|
|
/// 按托下发(到集中供料或外协)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
@@ -322,12 +323,12 @@ namespace Tnb.WarehouseMgr
|
|
|
|
|
WmsMaterialTransferD wmsMaterialTransferD = await _db.Queryable<WmsMaterialTransferD>().FirstAsync(it => it.id == input.source_id);
|
|
|
|
|
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().FirstAsync(it => it.id == wmsMaterialTransferD.bill_id);
|
|
|
|
|
|
|
|
|
|
if (wmsMaterialTransferD.yxfqty == wmsMaterialTransferD.qty)
|
|
|
|
|
await s_taskExecuteSemaphore.WaitAsync();
|
|
|
|
|
if (wmsMaterialTransferD.yxfqty >= wmsMaterialTransferD.qty)
|
|
|
|
|
{
|
|
|
|
|
throw new AppFriendlyException("已下发数量已达到转库数量", 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await s_taskExecuteSemaphore.WaitAsync();
|
|
|
|
|
await _db.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
|
|
//入库取终点 //出库起点
|
|
|
|
|
@@ -432,6 +433,120 @@ namespace Tnb.WarehouseMgr
|
|
|
|
|
return await ToApiResult(HttpStatusCode.OK, "成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// PDA操作(8线到中储仓)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, NonUnify, AllowAnonymous]
|
|
|
|
|
public async Task<Entities.Dto.Outputs.Result> DistributeYCL2ZCC(MaterialTransferDistributeYCL2ZCCInput input)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(input.source_id))
|
|
|
|
|
{
|
|
|
|
|
throw new AppFriendlyException("来源单据id不可为空", 500);
|
|
|
|
|
}
|
|
|
|
|
if (input.details.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw new AppFriendlyException("请先扫描料箱", 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
input.details.ForEach(r =>
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(r.carry_code))
|
|
|
|
|
{
|
|
|
|
|
throw new AppFriendlyException($"料箱编码不能为空", 500);
|
|
|
|
|
}
|
|
|
|
|
if (r.qty <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new AppFriendlyException($"料箱{r.carry_code}的数量必须大于0", 500);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await s_taskDistributeYCL2ZCC.WaitAsync();
|
|
|
|
|
WmsMaterialTransferD wmsMaterialTransferD = await _db.Queryable<WmsMaterialTransferD>().FirstAsync(it => it.id == input.source_id);
|
|
|
|
|
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().FirstAsync(it => it.id == wmsMaterialTransferD.bill_id);
|
|
|
|
|
|
|
|
|
|
if (wmsMaterialTransferD.yxfqty_rk >= wmsMaterialTransferD.qty)
|
|
|
|
|
{
|
|
|
|
|
throw new AppFriendlyException("已下发数量已达到转库数量", 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
decimal qty = input.details.Sum(r => r.qty);
|
|
|
|
|
if (qty > wmsMaterialTransferD.qty - wmsMaterialTransferD.yxfqty_rk)
|
|
|
|
|
{
|
|
|
|
|
throw new AppFriendlyException($"下发数量{qty}已超过可下发数量{wmsMaterialTransferD.qty - wmsMaterialTransferD.yxfqty_rk}", 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _db.Ado.BeginTranAsync();
|
|
|
|
|
//入库取终点 //出库起点
|
|
|
|
|
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID, Size = input.details.Count };
|
|
|
|
|
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
|
|
|
|
if (endLocations.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogWarning("没有可用的入库库位");
|
|
|
|
|
throw new AppFriendlyException("没有可用的入库库位", 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (input.details.Count > endLocations.Count)
|
|
|
|
|
{
|
|
|
|
|
throw new AppFriendlyException("可用的入库库位数量少于扫描的料箱数量", 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
|
|
List<WmsCarryH> wmsCarryHs = await _db.Queryable<WmsCarryH>().Where(r => input.details.Select(x => x.carry_code).Contains(r.carry_code)).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var wmsCarryH in input.details)
|
|
|
|
|
{
|
|
|
|
|
BasLocation startLocation = await _db.Queryable<BasLocation>().Where(r => r.id == WmsWareHouseConst.ZZCSSX011008).FirstAsync();
|
|
|
|
|
|
|
|
|
|
BasLocation endLocation = endLocations[index];
|
|
|
|
|
|
|
|
|
|
CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput();
|
|
|
|
|
commonCreatePretaskInput.startlocation_id = startLocation.id;
|
|
|
|
|
commonCreatePretaskInput.endlocation_id = endLocation.id;
|
|
|
|
|
commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
|
|
|
|
|
commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WMSMATERIALTRANSFER_ID;
|
|
|
|
|
commonCreatePretaskInput.source_id = input.source_id;
|
|
|
|
|
commonCreatePretaskInput.carry_id = wmsCarryHs[index].id;
|
|
|
|
|
commonCreatePretaskInput.carry_code = wmsCarryHs[index].carry_code;
|
|
|
|
|
commonCreatePretaskInput.isExcuteMission = false;
|
|
|
|
|
|
|
|
|
|
Entities.Dto.Outputs.Result res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput, _db);
|
|
|
|
|
|
|
|
|
|
if (res.code != HttpStatusCode.OK)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogInformation($@"生成预任务失败");
|
|
|
|
|
throw new AppFriendlyException($@"生成预任务失败", 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新子表已下发数量
|
|
|
|
|
await _db.Updateable<WmsMaterialTransferD>().SetColumns(r => r.yxfqty_rk == r.yxfqty_rk + qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
await _db.Ado.CommitTranAsync();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await _db.Ado.RollbackTranAsync();
|
|
|
|
|
Logger.LogError("【Distribute】" + ex.Message);
|
|
|
|
|
Logger.LogError("【Distribute】" + ex.StackTrace);
|
|
|
|
|
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
_ = s_taskDistributeYCL2ZCC.Release();
|
|
|
|
|
InvokeGenPretaskExcute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await ToApiResult(HttpStatusCode.OK, "成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按料架下发(缓存仓)
|
|
|
|
|
/// </summary>
|
|
|
|
|
@@ -770,7 +885,6 @@ namespace Tnb.WarehouseMgr
|
|
|
|
|
return await ToApiResult(HttpStatusCode.OK, "成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task ModifyAsync(WareHouseUpInput input)
|
|
|
|
|
{
|
|
|
|
|
if (input == null)
|
|
|
|
|
@@ -788,10 +902,21 @@ namespace Tnb.WarehouseMgr
|
|
|
|
|
}
|
|
|
|
|
await _db.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
|
|
// 更新已转数量
|
|
|
|
|
bool isOk = await _db.Updateable<WmsMaterialTransferD>().SetColumns(it => new WmsMaterialTransferD { yzqty = it.yzqty + wmsCarryCodes.Sum(r => r.codeqty) })
|
|
|
|
|
.Where(it => it.id == input.source_id).ExecuteCommandHasChangeAsync();
|
|
|
|
|
|
|
|
|
|
bool isOk = false;
|
|
|
|
|
// 入库回写入库数量字段
|
|
|
|
|
if (input.wmsDistaskH.task_type == WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID)
|
|
|
|
|
{
|
|
|
|
|
// 更新已转数量(入库)
|
|
|
|
|
isOk = await _db.Updateable<WmsMaterialTransferD>().SetColumns(it => new WmsMaterialTransferD { yzqty_rk = it.yzqty_rk + wmsCarryCodes.Sum(r => r.codeqty) })
|
|
|
|
|
.Where(it => it.id == input.source_id).ExecuteCommandHasChangeAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 更新已转数量
|
|
|
|
|
isOk = await _db.Updateable<WmsMaterialTransferD>().SetColumns(it => new WmsMaterialTransferD { yzqty = it.yzqty + wmsCarryCodes.Sum(r => r.codeqty) })
|
|
|
|
|
.Where(it => it.id == input.source_id).ExecuteCommandHasChangeAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果所有明细已完成 更新主表状态为完成
|
|
|
|
|
WmsMaterialTransferD wmsMaterialTransferd = await _db.Queryable<WmsMaterialTransferD>().Where(r => r.id == input.source_id).SingleAsync();
|
|
|
|
|
List<WmsMaterialTransferD> wmsMaterialTransferDs = _db.Queryable<WmsMaterialTransferD>()
|
|
|
|
|
@@ -814,87 +939,96 @@ namespace Tnb.WarehouseMgr
|
|
|
|
|
if (input.area_code == "E")
|
|
|
|
|
await sign(input);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().SingleAsync(x => x.id == wmsMaterialTransferd.bill_id);
|
|
|
|
|
List<WmsMaterialTransferD> dList = await _db.Queryable<WmsMaterialTransferD>().Where(x => x.bill_id == wmsMaterialTransferd.bill_id).OrderBy(x=>x.id).ToListAsync();
|
|
|
|
|
DictionaryDataEntity unitData = await _db.Queryable<DictionaryTypeEntity>()
|
|
|
|
|
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
|
|
|
|
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode == wmsMaterialTransferd.unit_id)
|
|
|
|
|
.Select((x,y)=>y)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
List<string> ids = new List<string>();
|
|
|
|
|
ids.Add(wmsMaterialTransfer.create_id);
|
|
|
|
|
ids.Add(WmsWareHouseConst.AdministratorOrgId);
|
|
|
|
|
ids.Add(wmsMaterialTransfer.warehouse_outstock);
|
|
|
|
|
ids.Add(wmsMaterialTransfer.warehouse_instock);
|
|
|
|
|
ids.Add(wmsMaterialTransferd.material_id);
|
|
|
|
|
if (unitData != null)
|
|
|
|
|
// 其它入库
|
|
|
|
|
if (input.wmsDistaskH.task_type == WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID)
|
|
|
|
|
{
|
|
|
|
|
ids.Add(unitData.Id);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x=>ids.Contains(x.table_id)).ToListAsync();
|
|
|
|
|
|
|
|
|
|
ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (wmsMaterialTransfer.org_id ?? WmsWareHouseConst.AdministratorOrgId));
|
|
|
|
|
string erpCreateId = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.create_id)?.user_id ?? "";
|
|
|
|
|
|
|
|
|
|
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
|
|
|
|
Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
|
|
|
|
|
string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
erpRequestData.Add("billmaker",erpCreateId);
|
|
|
|
|
erpRequestData.Add("cdptid","1001A1100000000JRLI1");// 先写死
|
|
|
|
|
erpRequestData.Add("cdptvid","0001A11000000007GGO8");// 先写死
|
|
|
|
|
erpRequestData.Add("corpoid",erpOrg.corpoid);
|
|
|
|
|
erpRequestData.Add("corpvid",erpOrg.corpoid);
|
|
|
|
|
erpRequestData.Add("cothercalbodyoid",erpOrg.pk_org);
|
|
|
|
|
erpRequestData.Add("cotherwhid",erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? "");
|
|
|
|
|
erpRequestData.Add("creationtime",nowStr);
|
|
|
|
|
erpRequestData.Add("creator",erpCreateId);
|
|
|
|
|
erpRequestData.Add("ctrantypeid","0001H11000000000D31W");
|
|
|
|
|
erpRequestData.Add("cwarehouseid",erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_outstock)?.cotherwhid ?? "");
|
|
|
|
|
erpRequestData.Add("dbilldate",nowStr);
|
|
|
|
|
erpRequestData.Add("dmakedate",nowStr);
|
|
|
|
|
erpRequestData.Add("ntotalnum",wmsCarryCodes.Sum(r => r.codeqty));
|
|
|
|
|
erpRequestData.Add("pk_group",erpOrg.pk_group);
|
|
|
|
|
erpRequestData.Add("pk_org",erpOrg.pk_org);
|
|
|
|
|
erpRequestData.Add("pk_org_v",erpOrg.pk_org_v);
|
|
|
|
|
erpRequestData.Add("vbillcode",wmsMaterialTransfer.bill_code);
|
|
|
|
|
erpRequestData.Add("vtrantypecode","4I-01");//其他出库 先写死
|
|
|
|
|
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
|
|
|
|
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
|
|
|
|
// 其它出库
|
|
|
|
|
{
|
|
|
|
|
["cbodytranstypecode"] = "4I-01",
|
|
|
|
|
["cbodywarehouseid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_outstock)?.cotherwhid ?? "",
|
|
|
|
|
["cmaterialoid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransferd.material_id)?.cmaterialoid ?? "",
|
|
|
|
|
["cmaterialvid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransferd.material_id)?.cmaterialvid ?? "",
|
|
|
|
|
["corpoid"] = erpOrg.corpoid,
|
|
|
|
|
["corpvid"] = erpOrg.corpvid,
|
|
|
|
|
["crowno"] = wmsMaterialTransferd.lineno,
|
|
|
|
|
["csourcebillbid"] = wmsMaterialTransferd.erp_line_pk,
|
|
|
|
|
["csourcebillhid"] = wmsMaterialTransfer.erp_pk,
|
|
|
|
|
["cunitid"] = erpExtendFields.Find(x=>x.table_id==unitData.Id)?.cunitid ?? "",
|
|
|
|
|
["cvendorid"] = "",
|
|
|
|
|
["cvendorvid"] = "",
|
|
|
|
|
["dbizdate"] = nowStr,
|
|
|
|
|
["nnum"] = wmsCarryCodes.Sum(r => r.codeqty),
|
|
|
|
|
["nshouldnum"] = wmsMaterialTransferd.qty,
|
|
|
|
|
["pk_group"] = erpOrg.pk_group,
|
|
|
|
|
["pk_org"] = erpOrg.pk_org,
|
|
|
|
|
["pk_org_v"] = erpOrg.pk_org_v,
|
|
|
|
|
["vbatchcode"] = wmsMaterialTransferd.code_batch,
|
|
|
|
|
});
|
|
|
|
|
erpRequestData.Add("dtls",erpRequestDataDetails);
|
|
|
|
|
requestData.Add(erpRequestData);
|
|
|
|
|
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().SingleAsync(x => x.id == wmsMaterialTransferd.bill_id);
|
|
|
|
|
List<WmsMaterialTransferD> dList = await _db.Queryable<WmsMaterialTransferD>().Where(x => x.bill_id == wmsMaterialTransferd.bill_id).OrderBy(x => x.id).ToListAsync();
|
|
|
|
|
DictionaryDataEntity unitData = await _db.Queryable<DictionaryTypeEntity>()
|
|
|
|
|
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
|
|
|
|
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode == wmsMaterialTransferd.unit_id)
|
|
|
|
|
.Select((x, y) => y)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
List<string> ids = new List<string>();
|
|
|
|
|
ids.Add(wmsMaterialTransfer.create_id);
|
|
|
|
|
ids.Add(WmsWareHouseConst.AdministratorOrgId);
|
|
|
|
|
ids.Add(wmsMaterialTransfer.warehouse_outstock);
|
|
|
|
|
ids.Add(wmsMaterialTransfer.warehouse_instock);
|
|
|
|
|
ids.Add(wmsMaterialTransferd.material_id);
|
|
|
|
|
if (unitData != null)
|
|
|
|
|
{
|
|
|
|
|
ids.Add(unitData.Id);
|
|
|
|
|
}
|
|
|
|
|
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x => ids.Contains(x.table_id)).ToListAsync();
|
|
|
|
|
|
|
|
|
|
ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord();
|
|
|
|
|
thirdWebapiRecord.id = SnowflakeIdHelper.NextId();
|
|
|
|
|
thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
|
|
|
|
|
thirdWebapiRecord.name = "其它出库";
|
|
|
|
|
thirdWebapiRecord.method = "POST";
|
|
|
|
|
thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/generalout/save";
|
|
|
|
|
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData);
|
|
|
|
|
thirdWebapiRecord.create_time = DateTime.Now;
|
|
|
|
|
ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (wmsMaterialTransfer.org_id ?? WmsWareHouseConst.AdministratorOrgId));
|
|
|
|
|
string erpCreateId = erpExtendFields.Find(x => x.table_id == wmsMaterialTransfer.create_id)?.user_id ?? "";
|
|
|
|
|
|
|
|
|
|
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
|
|
|
|
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
|
|
|
|
Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
|
|
|
|
|
string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
erpRequestData.Add("billmaker", erpCreateId);
|
|
|
|
|
erpRequestData.Add("cdptid", "1001A1100000000JRLI1");// 先写死
|
|
|
|
|
erpRequestData.Add("cdptvid", "0001A11000000007GGO8");// 先写死
|
|
|
|
|
erpRequestData.Add("corpoid", erpOrg.corpoid);
|
|
|
|
|
erpRequestData.Add("corpvid", erpOrg.corpoid);
|
|
|
|
|
erpRequestData.Add("cothercalbodyoid", erpOrg.pk_org);
|
|
|
|
|
erpRequestData.Add("cotherwhid", erpExtendFields.Find(x => x.table_id == wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? "");
|
|
|
|
|
erpRequestData.Add("creationtime", nowStr);
|
|
|
|
|
erpRequestData.Add("creator", erpCreateId);
|
|
|
|
|
erpRequestData.Add("ctrantypeid", "0001H11000000000D31W");
|
|
|
|
|
erpRequestData.Add("cwarehouseid", erpExtendFields.Find(x => x.table_id == wmsMaterialTransfer.warehouse_outstock)?.cotherwhid ?? "");
|
|
|
|
|
erpRequestData.Add("dbilldate", nowStr);
|
|
|
|
|
erpRequestData.Add("dmakedate", nowStr);
|
|
|
|
|
erpRequestData.Add("ntotalnum", wmsCarryCodes.Sum(r => r.codeqty));
|
|
|
|
|
erpRequestData.Add("pk_group", erpOrg.pk_group);
|
|
|
|
|
erpRequestData.Add("pk_org", erpOrg.pk_org);
|
|
|
|
|
erpRequestData.Add("pk_org_v", erpOrg.pk_org_v);
|
|
|
|
|
erpRequestData.Add("vbillcode", wmsMaterialTransfer.bill_code);
|
|
|
|
|
erpRequestData.Add("vtrantypecode", "4I-01");//其他出库 先写死
|
|
|
|
|
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
|
|
|
|
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
|
|
|
|
{
|
|
|
|
|
["cbodytranstypecode"] = "4I-01",
|
|
|
|
|
["cbodywarehouseid"] = erpExtendFields.Find(x => x.table_id == wmsMaterialTransfer.warehouse_outstock)?.cotherwhid ?? "",
|
|
|
|
|
["cmaterialoid"] = erpExtendFields.Find(x => x.table_id == wmsMaterialTransferd.material_id)?.cmaterialoid ?? "",
|
|
|
|
|
["cmaterialvid"] = erpExtendFields.Find(x => x.table_id == wmsMaterialTransferd.material_id)?.cmaterialvid ?? "",
|
|
|
|
|
["corpoid"] = erpOrg.corpoid,
|
|
|
|
|
["corpvid"] = erpOrg.corpvid,
|
|
|
|
|
["crowno"] = wmsMaterialTransferd.lineno,
|
|
|
|
|
["csourcebillbid"] = wmsMaterialTransferd.erp_line_pk,
|
|
|
|
|
["csourcebillhid"] = wmsMaterialTransfer.erp_pk,
|
|
|
|
|
["cunitid"] = erpExtendFields.Find(x => x.table_id == unitData.Id)?.cunitid ?? "",
|
|
|
|
|
["cvendorid"] = "",
|
|
|
|
|
["cvendorvid"] = "",
|
|
|
|
|
["dbizdate"] = nowStr,
|
|
|
|
|
["nnum"] = wmsCarryCodes.Sum(r => r.codeqty),
|
|
|
|
|
["nshouldnum"] = wmsMaterialTransferd.qty,
|
|
|
|
|
["pk_group"] = erpOrg.pk_group,
|
|
|
|
|
["pk_org"] = erpOrg.pk_org,
|
|
|
|
|
["pk_org_v"] = erpOrg.pk_org_v,
|
|
|
|
|
["vbatchcode"] = wmsMaterialTransferd.code_batch,
|
|
|
|
|
});
|
|
|
|
|
erpRequestData.Add("dtls", erpRequestDataDetails);
|
|
|
|
|
requestData.Add(erpRequestData);
|
|
|
|
|
|
|
|
|
|
ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord();
|
|
|
|
|
thirdWebapiRecord.id = SnowflakeIdHelper.NextId();
|
|
|
|
|
thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
|
|
|
|
|
thirdWebapiRecord.name = "其它出库";
|
|
|
|
|
thirdWebapiRecord.method = "POST";
|
|
|
|
|
thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/generalout/save";
|
|
|
|
|
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData);
|
|
|
|
|
thirdWebapiRecord.create_time = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _db.Ado.CommitTranAsync();
|
|
|
|
|
}
|
|
|
|
|
|