This commit is contained in:
2024-09-25 11:40:49 +08:00
parent 3feb48169b
commit 9d0cecc1f6
6 changed files with 60 additions and 33 deletions

View File

@@ -11,6 +11,6 @@ namespace Tnb.BasicData.Interfaces
/// <param name="id"></param>
/// <param name="send_type">手动 自动</param>
/// <returns></returns>
Task<string> Send(List<ThirdWebapiRecord> records, string send_type,ISqlSugarClient db=null);
Task<ThirdResult> Send(List<ThirdWebapiRecord> records, string send_type,ISqlSugarClient db=null);
}
}

View File

@@ -44,7 +44,8 @@ namespace Tnb.BasicData
public async Task<string> Send(string id)
{
ThirdWebapiRecord record = await _repository.GetSingleAsync(x=>x.id==id);
return await Send(Arrays.AsList(record), "手动");
ThirdResult thirdResult = await Send(Arrays.AsList(record), "手动");
return thirdResult.msgResult;
}
[HttpGet]
@@ -88,14 +89,14 @@ namespace Tnb.BasicData
return "失败";
}
public async Task<string> Send(List<ThirdWebapiRecord> records, string send_type,ISqlSugarClient db=null)
public async Task<ThirdResult> Send(List<ThirdWebapiRecord> records, string send_type,ISqlSugarClient db=null)
{
ThirdResult thirdResult = null;
bool tranFlag = true;
try
{
if (records == null || records.IsEmpty())
return "";
return new ThirdResult();
if (db == null)
{
@@ -272,9 +273,9 @@ namespace Tnb.BasicData
Log.Error(e.Message,e);
if(tranFlag) await db.Ado.RollbackTranAsync();
}
return thirdResult.Code == 200 ? "成功" : "失败";
return thirdResult;
}
}

View File

@@ -83,5 +83,19 @@ public partial class WmsRawmatOutstockH : BaseEntity<string>
/// 下发状态
/// </summary>
public string? issuance_status { get; set; }
/// <summary>
/// erp领出仓库
/// </summary>
public string? erp_outstock { get; set; }
/// <summary>
/// erp领用仓库
/// </summary>
public string? erp_instock { get; set; }
/// <summary>
/// erp成本域
/// </summary>
public string? erp_org_costregion { get; set; } = "1001A1100000001MNB3H";
}

View File

@@ -488,10 +488,10 @@ namespace Tnb.WarehouseMgr
//string erpCreateId = erpExtendFields.Find(x => x.table_id == userId)?.user_id ?? WmsWareHouseConst.ERPUSERID;
string erpCreateId = WmsWareHouseConst.ERPUSERID;
List<WmsErpWarehouserelaH> erpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x => x.id != null).ToListAsync();
BasWarehouse outWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_outstock);
BasWarehouse inWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_instock);
string inwhcode = inWarehouse?.whcode ?? "";
string outwhcode = outWarehouse?.whcode ?? "";
// BasWarehouse outWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_outstock);
// BasWarehouse inWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_instock);
// string inwhcode = inWarehouse?.whcode ?? "";
// string outwhcode = outWarehouse?.whcode ?? "";
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
@@ -504,11 +504,11 @@ namespace Tnb.WarehouseMgr
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("cotherwhid", erpWarehouserelaHs.Find(x => x.wms_warehousecode == inwhcode)?.erp_warehouseid ?? "");
erpRequestData.Add("cotherwhid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_instock)?.erp_warehouseid ?? "");
erpRequestData.Add("creationtime", nowStr);
erpRequestData.Add("creator", erpCreateId);
erpRequestData.Add("ctrantypeid", "0001H11000000000D31X");
erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.wms_warehousecode == outwhcode)?.erp_warehouseid ?? "");
erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_outstock)?.erp_warehouseid ?? "");
erpRequestData.Add("dbilldate", nowStr);
erpRequestData.Add("dmakedate", nowStr);
erpRequestData.Add("ntotalnum", wmsMaterialSignDs.Sum(r => r.sign_qty));
@@ -522,7 +522,7 @@ namespace Tnb.WarehouseMgr
erpRequestDataDetails.Add(new Dictionary<string, object>()
{
["cbodytranstypecode"] = "4I-02",
["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.wms_warehousecode == outwhcode)?.erp_warehouseid ?? "",
["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_outstock)?.erp_warehouseid ?? "",
["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,
@@ -562,7 +562,11 @@ namespace Tnb.WarehouseMgr
BasFactoryConfig callErp2 = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.CALLERP);
if(callErp2.value=="1"){
await _thirdApiRecordService.Send(new List<ThirdWebapiRecord> { thirdWebapiRecord }, "自动", _db);
ThirdResult thirdResult = await _thirdApiRecordService.Send(new List<ThirdWebapiRecord> { thirdWebapiRecord }, "自动", _db);
if (thirdResult.Code!=200)
{
throw Oops.Bah(thirdResult.msgResult);
}
}
if (wmsMaterialTransfer.type == WmsWareHouseConst.MATERIALTRANSFER_JZGLRK_CODE
@@ -638,7 +642,11 @@ namespace Tnb.WarehouseMgr
Logger.LogInformation("【WmsMaterialSignHService ModifyAsync】同步其它入库单到erp成功");
if(callErp2.value=="1"){
await _thirdApiRecordService.Send(new List<ThirdWebapiRecord> { thirdWebapiRecord2 }, "自动", _db);
ThirdResult thirdResult = await _thirdApiRecordService.Send(new List<ThirdWebapiRecord> { thirdWebapiRecord2 }, "自动", _db);
if (thirdResult.Code!=200)
{
throw Oops.Bah(thirdResult.msgResult);
}
}
}
break;

View File

@@ -1205,10 +1205,10 @@ namespace Tnb.WarehouseMgr
// string erpCreateId = erpExtendFields.Find(x => x.table_id == userId)?.user_id ?? WmsWareHouseConst.ERPUSERID;
string erpCreateId = WmsWareHouseConst.ERPUSERID;
List<WmsErpWarehouserelaH> erpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x => x.id != null).ToListAsync();
BasWarehouse outWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_outstock);
BasWarehouse inWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_instock);
string inwhcode = inWarehouse?.whcode ?? "";
string outwhcode = outWarehouse?.whcode ?? "";
// BasWarehouse outWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_outstock);
// BasWarehouse inWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_instock);
// string inwhcode = inWarehouse?.whcode ?? "";
// string outwhcode = outWarehouse?.whcode ?? "";
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
@@ -1221,11 +1221,11 @@ namespace Tnb.WarehouseMgr
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("cotherwhid", erpWarehouserelaHs.Find(x => x.wms_warehousecode == inwhcode)?.erp_warehouseid ?? "");
erpRequestData.Add("cotherwhid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_instock)?.erp_warehouseid ?? "");
erpRequestData.Add("creationtime", nowStr);
erpRequestData.Add("creator", erpCreateId);
erpRequestData.Add("ctrantypeid", "0001H11000000000D31X");
erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.wms_warehousecode == outwhcode)?.erp_warehouseid ?? "");
erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_outstock)?.erp_warehouseid ?? "");
erpRequestData.Add("dbilldate", nowStr);
erpRequestData.Add("dmakedate", nowStr);
erpRequestData.Add("ntotalnum", wmsCarryCodes.Sum(r => r.codeqty));
@@ -1239,7 +1239,7 @@ namespace Tnb.WarehouseMgr
erpRequestDataDetails.Add(new Dictionary<string, object>()
{
["cbodytranstypecode"] = "4I-02",
["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.wms_warehousecode == outwhcode)?.erp_warehouseid ?? "",
["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_outstock)?.erp_warehouseid ?? "",
["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,

View File

@@ -89,6 +89,7 @@ namespace Tnb.WarehouseMgr
.Where(r => r.carry_id == input.wmsDistaskH.carry_id)
.Where(r => r.material_id == wmsRawmatOutstockD.material_id && r.code_batch == wmsRawmatOutstockD.batchno)
.ToListAsync();
List<string> supplierIds = wmsCarryCodes.Select(x => x.auxprop_gys).Distinct().ToList();
decimal qty = wmsCarryCodes.Sum(r => r.codeqty);
@@ -96,7 +97,7 @@ namespace Tnb.WarehouseMgr
List<string> materialIds = wmsCarryCodes.Select(x => x.material_id).ToList();
List<DictionaryDataEntity> unitDatas = await _db.Queryable<DictionaryTypeEntity>()
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && unitCodes.Contains(y.EnCode))
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && (unitCodes.Contains(y.EnCode) || unitCodes.Contains(y.Id)))
.Select((x, y) => y)
.ToListAsync();
@@ -107,11 +108,12 @@ namespace Tnb.WarehouseMgr
.FirstAsync();
OrganizeEntity dept = await _db.Queryable<OrganizeEntity>().Where(x=>x.EnCode==wmsRawmatOutstockH.department).FirstAsync();
string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
// string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
List<string> tableIds = new List<string>();
tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
tableIds.AddRange(materialIds);
tableIds.Add(supplierId);
// tableIds.Add(supplierId);
tableIds.AddRange(supplierIds);
tableIds.Add(dept?.Id);
tableIds.Add(tranTypeDataEntity?.Id);
tableIds.AddRange(unitDatas.Select(x => x.Id).ToList());
@@ -128,10 +130,11 @@ namespace Tnb.WarehouseMgr
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
erpRequestData.Add("billmaker", erpCreateId);
erpRequestData.Add("ccostdomainoid", null);
erpRequestData.Add("ccostdomainoid", wmsRawmatOutstockH.erp_org_costregion ?? "1001A1100000001MNB3H");
erpRequestData.Add("cdrawcalbodyoid", erpOrg.pk_org);
erpRequestData.Add("cdrawcalbodyvid", erpOrg.pk_org_v);
// erpRequestData.Add("cdrawwarehouseid", null);
erpRequestData.Add("cdrawwarehouseid", wmsRawmatOutstockH.erp_instock);
erpRequestData.Add("cwarehouseid", wmsRawmatOutstockH.erp_outstock);
erpRequestData.Add("cdptid", erpExtendFields.Find(x=>x.table_id==dept?.Id)?.cdptid ?? "");
erpRequestData.Add("cdptvid", erpExtendFields.Find(x=>x.table_id==dept?.Id)?.cdptvid ?? "");
erpRequestData.Add("cfanaceorgoid", erpOrg.corpoid);
@@ -141,7 +144,6 @@ namespace Tnb.WarehouseMgr
erpRequestData.Add("creationtime", nowStr);
erpRequestData.Add("creator", erpCreateId);
erpRequestData.Add("ctrantypeid", erpExtendFields.Find(x=>x.table_id==tranTypeDataEntity?.Id)?.transaction_type_id ?? "");//先写死
erpRequestData.Add("cwarehouseid", wmsErpWarehouserelaHs.Find(x=>x.wms_warehousecode==wmsRawmatOutstockH.warehouse_id)?.erp_warehouseid ?? "");
erpRequestData.Add("dbilldate", wmsRawmatOutstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"));
erpRequestData.Add("dmakedate", nowStr);
erpRequestData.Add("fbillflag", 2);
@@ -160,14 +162,15 @@ namespace Tnb.WarehouseMgr
erpRequestDataDetails.Add(new Dictionary<string, object>()
{
["cbodytranstypecode"] = wmsRawmatOutstockH.outstock_type,
["cbodywarehouseid"] = wmsRawmatOutstockH.erp_outstock,
["cmaterialoid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialoid ?? "",
["cmaterialvid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialvid ?? "",
["corpoid"] = erpOrg.corpoid,
["corpvid"] = erpOrg.corpvid,
["crowno"] = wmsRawmatOutstockD.lineno,
["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id)?.Id ?? ""))?.cunitid ?? "",
["cvendorid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? "",
["cvendorvid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? "",
["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id || x.Id==item.unit_id)?.Id ?? ""))?.cunitid ?? "",
["cvendorid"] = erpExtendFields.Find((x=>x.table_id==item.auxprop_gys))?.supplier_id ?? "",
["cvendorvid"] = erpExtendFields.Find((x=>x.table_id==item.auxprop_gys))?.supplier_vid ?? "",
["dbizdate"] = wmsRawmatOutstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
["nshouldnum"] = item.codeqty,
["nnum"] = item.codeqty,
@@ -186,10 +189,11 @@ namespace Tnb.WarehouseMgr
thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
thirdWebapiRecord.name = "材料出库单(自制)";
thirdWebapiRecord.method = "POST";
thirdWebapiRecord.url = config.value + "uapws/rest/materialOut/self/save";
// thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/transIn/save";
// thirdWebapiRecord.url = config.value + "uapws/rest/materialOut/self/save";
thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/materialOut/self/save";
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData);
thirdWebapiRecord.create_time = DateTime.Now;
thirdWebapiRecord.remark = $"材料出库wms_rawmat_outstock_h:{wmsRawmatOutstockH.bill_code}";
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
BasFactoryConfig callErp = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.CALLERP);