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

@@ -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);