调拨入库修改
This commit is contained in:
@@ -119,7 +119,7 @@ namespace Tnb.ProductionMgr
|
|||||||
|
|
||||||
output.equip_pie_list = await _db.Queryable<EqpEquipment>()
|
output.equip_pie_list = await _db.Queryable<EqpEquipment>()
|
||||||
.GroupBy(x => x.status)
|
.GroupBy(x => x.status)
|
||||||
.OrderBy(x=>x.code)
|
// .OrderBy(x=>x.code)
|
||||||
.Select(x => new EquipPieOutput
|
.Select(x => new EquipPieOutput
|
||||||
{
|
{
|
||||||
name = x.status,
|
name = x.status,
|
||||||
@@ -140,8 +140,9 @@ namespace Tnb.ProductionMgr
|
|||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
foreach (var item in output.equip_info_list)
|
foreach (var item in output.equip_info_list)
|
||||||
{
|
{
|
||||||
item.status = _redisData.Get<string>($"{item.code}:ActstsMach");
|
item.status = _redisData.Get<string>($"{item.code}:ActStsMach");
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,115 +448,115 @@ namespace Tnb.WarehouseMgr
|
|||||||
// 调拨入库
|
// 调拨入库
|
||||||
else if (instock.bill_type == WmsWareHouseConst.BILLTYPE_RAWMATTRANSFERINSTOCK_ID)
|
else if (instock.bill_type == WmsWareHouseConst.BILLTYPE_RAWMATTRANSFERINSTOCK_ID)
|
||||||
{
|
{
|
||||||
List<WmsInstockD> allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
// List<WmsInstockD> allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||||
|
//
|
||||||
WmsTempCode wmsTempCode = await _db.Queryable<WmsCarryCode>()
|
// WmsTempCode wmsTempCode = await _db.Queryable<WmsCarryCode>()
|
||||||
.LeftJoin<WmsTempCode>((a, b) => a.barcode == b.barcode)
|
// .LeftJoin<WmsTempCode>((a, b) => a.barcode == b.barcode)
|
||||||
.Where((a, b) => a.carry_id == input.wmsDistaskH.carry_id)
|
// .Where((a, b) => a.carry_id == input.wmsDistaskH.carry_id)
|
||||||
.Select((a, b) => b)
|
// .Select((a, b) => b)
|
||||||
.FirstAsync();
|
// .FirstAsync();
|
||||||
|
//
|
||||||
string rawmatTransferinstockDId = wmsTempCode?.require_id ?? "";
|
// string rawmatTransferinstockDId = wmsTempCode?.require_id ?? "";
|
||||||
WmsRawmatTransferinstockD wmsRawmatTransferinstockD = await _db.Queryable<WmsRawmatTransferinstockD>().SingleAsync(x => x.id == rawmatTransferinstockDId);
|
// WmsRawmatTransferinstockD wmsRawmatTransferinstockD = await _db.Queryable<WmsRawmatTransferinstockD>().SingleAsync(x => x.id == rawmatTransferinstockDId);
|
||||||
string rawmatTransferinstockHId = wmsRawmatTransferinstockD?.bill_id ?? "";
|
// string rawmatTransferinstockHId = wmsRawmatTransferinstockD?.bill_id ?? "";
|
||||||
WmsRawmatTransferinstockH wmsRawmatTransferinstockH = await _db.Queryable<WmsRawmatTransferinstockH>().SingleAsync(x => x.id == rawmatTransferinstockHId);
|
// WmsRawmatTransferinstockH wmsRawmatTransferinstockH = await _db.Queryable<WmsRawmatTransferinstockH>().SingleAsync(x => x.id == rawmatTransferinstockHId);
|
||||||
|
//
|
||||||
List<String> materialIds = allInstockDetails.Select(x => x.material_id).Distinct().ToList();
|
// List<String> materialIds = allInstockDetails.Select(x => x.material_id).Distinct().ToList();
|
||||||
List<String> unitCodes = allInstockDetails.Select(x => x.unit_id).Distinct().ToList();
|
// List<String> unitCodes = allInstockDetails.Select(x => x.unit_id).Distinct().ToList();
|
||||||
List<DictionaryDataEntity> unitDatas = await _db.Queryable<DictionaryTypeEntity>()
|
// List<DictionaryDataEntity> unitDatas = await _db.Queryable<DictionaryTypeEntity>()
|
||||||
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
// .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))
|
||||||
.Select((x, y) => y)
|
// .Select((x, y) => y)
|
||||||
.ToListAsync();
|
// .ToListAsync();
|
||||||
List<WmsErpWarehouserelaH> erpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x=>x.id!=null).ToListAsync();
|
// List<WmsErpWarehouserelaH> erpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x=>x.id!=null).ToListAsync();
|
||||||
BasWarehouse basWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x=>x.id==instock.warehouse_id);
|
// BasWarehouse basWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x=>x.id==instock.warehouse_id);
|
||||||
|
//
|
||||||
string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
|
// string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
|
||||||
List<string> tableIds = new List<string>();
|
// List<string> tableIds = new List<string>();
|
||||||
tableIds.Add(_userManager.UserId);
|
// tableIds.Add(_userManager.UserId);
|
||||||
tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
|
// tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
|
||||||
tableIds.Add(instock.warehouse_id);
|
// tableIds.Add(instock.warehouse_id);
|
||||||
tableIds.AddRange(materialIds);
|
// tableIds.AddRange(materialIds);
|
||||||
tableIds.Add(supplierId);
|
// tableIds.Add(supplierId);
|
||||||
tableIds.AddRange(unitDatas.Select(x => x.Id).ToList());
|
// tableIds.AddRange(unitDatas.Select(x => x.Id).ToList());
|
||||||
|
//
|
||||||
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x => tableIds.Contains(x.table_id)).ToListAsync();
|
// List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x => tableIds.Contains(x.table_id)).ToListAsync();
|
||||||
string userAccount = wmsRawmatTransferinstockH?.biller ?? "";
|
// string userAccount = wmsRawmatTransferinstockH?.biller ?? "";
|
||||||
string deptCode = wmsRawmatTransferinstockH?.dept_code ?? "";
|
// string deptCode = wmsRawmatTransferinstockH?.dept_code ?? "";
|
||||||
UserEntity userEntity = await _db.Queryable<UserEntity>().Where(x=>x.Account==userAccount).FirstAsync();
|
// UserEntity userEntity = await _db.Queryable<UserEntity>().Where(x=>x.Account==userAccount).FirstAsync();
|
||||||
string userId = userEntity?.Id ?? "";
|
// string userId = userEntity?.Id ?? "";
|
||||||
string erpCreateId = erpExtendFields.Find(x => x.table_id == userId)?.user_id ?? "";
|
// string erpCreateId = erpExtendFields.Find(x => x.table_id == userId)?.user_id ?? "";
|
||||||
ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId));
|
// ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId));
|
||||||
string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
// string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
//
|
||||||
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
// List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
||||||
Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
|
// Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
|
||||||
erpRequestData.Add("billmaker", erpCreateId);
|
// erpRequestData.Add("billmaker", erpCreateId);
|
||||||
erpRequestData.Add("cbiztype", "");
|
// erpRequestData.Add("cbiztype", "");
|
||||||
erpRequestData.Add("cdptid","1001A1100000000JRLI1");//部门先写死
|
// erpRequestData.Add("cdptid","1001A1100000000JRLI1");//部门先写死
|
||||||
erpRequestData.Add("cdptvid","0001A11000000007GGO8");//部门先写死
|
// erpRequestData.Add("cdptvid","0001A11000000007GGO8");//部门先写死
|
||||||
erpRequestData.Add("corpoid", erpOrg.corpoid);
|
// erpRequestData.Add("corpoid", erpOrg.corpoid);
|
||||||
erpRequestData.Add("corpvid", erpOrg.corpvid);
|
// erpRequestData.Add("corpvid", erpOrg.corpvid);
|
||||||
erpRequestData.Add("creationtime", nowStr);
|
// erpRequestData.Add("creationtime", nowStr);
|
||||||
erpRequestData.Add("creator", erpCreateId);
|
// erpRequestData.Add("creator", erpCreateId);
|
||||||
// erpRequestData.Add("cwarehouseid", erpExtendFields.Find(x => x.table_id == instock.warehouse_id)?.cotherwhid ?? "");//类型视图里取
|
// // erpRequestData.Add("cwarehouseid", erpExtendFields.Find(x => x.table_id == instock.warehouse_id)?.cotherwhid ?? "");//类型视图里取
|
||||||
erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == basWarehouse.whcode)?.erp_warehouseid ?? "");//类型视图里取
|
// erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == basWarehouse.whcode)?.erp_warehouseid ?? "");//类型视图里取
|
||||||
erpRequestData.Add("dbilldate", nowStr);
|
// erpRequestData.Add("dbilldate", nowStr);
|
||||||
erpRequestData.Add("dmakedate", nowStr);
|
// erpRequestData.Add("dmakedate", nowStr);
|
||||||
erpRequestData.Add("fbillflag", 1);
|
// erpRequestData.Add("fbillflag", 1);
|
||||||
erpRequestData.Add("ntotalnum", allInstockDetails.Sum(x => x.qty));
|
// erpRequestData.Add("ntotalnum", allInstockDetails.Sum(x => x.qty));
|
||||||
erpRequestData.Add("pk_org", erpOrg.pk_org);
|
// erpRequestData.Add("pk_org", erpOrg.pk_org);
|
||||||
erpRequestData.Add("pk_org_v", erpOrg.pk_org_v);
|
// erpRequestData.Add("pk_org_v", erpOrg.pk_org_v);
|
||||||
erpRequestData.Add("pk_group", erpOrg.pk_group);
|
// erpRequestData.Add("pk_group", erpOrg.pk_group);
|
||||||
erpRequestData.Add("vdef1", null);
|
// erpRequestData.Add("vdef1", null);
|
||||||
erpRequestData.Add("vbillcode", instock.bill_code);
|
// erpRequestData.Add("vbillcode", instock.bill_code);
|
||||||
erpRequestData.Add("ctrantypeid", "0001H11000000000D31E");//先写死
|
// erpRequestData.Add("ctrantypeid", "0001H11000000000D31E");//先写死
|
||||||
erpRequestData.Add("vtrantypecode", "4E-01");//先写死
|
// erpRequestData.Add("vtrantypecode", "4E-01");//先写死
|
||||||
erpRequestData.Add("csourcebillhid", wmsRawmatTransferinstockH?.erp_pk ?? "");
|
// erpRequestData.Add("csourcebillhid", wmsRawmatTransferinstockH?.erp_pk ?? "");
|
||||||
|
//
|
||||||
|
//
|
||||||
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
// List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
||||||
foreach (WmsInstockD item in allInstockDetails)
|
// foreach (WmsInstockD item in allInstockDetails)
|
||||||
{
|
// {
|
||||||
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
// erpRequestDataDetails.Add(new Dictionary<string, object>()
|
||||||
{
|
// {
|
||||||
["cbodytranstypecode"] = "4E-01",
|
// ["cbodytranstypecode"] = "4E-01",
|
||||||
// ["cbodywarehouseid"] = erpExtendFields.Find(x => x.table_id == instock.warehouse_id)?.cotherwhid ?? "",
|
// // ["cbodywarehouseid"] = erpExtendFields.Find(x => x.table_id == instock.warehouse_id)?.cotherwhid ?? "",
|
||||||
["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == basWarehouse.whcode)?.erp_warehouseid ?? "",
|
// ["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == basWarehouse.whcode)?.erp_warehouseid ?? "",
|
||||||
["cmaterialoid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialoid ?? "",
|
// ["cmaterialoid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialoid ?? "",
|
||||||
["cmaterialvid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialvid ?? "",
|
// ["cmaterialvid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialvid ?? "",
|
||||||
["corpoid"] = erpOrg.corpoid,
|
// ["corpoid"] = erpOrg.corpoid,
|
||||||
["corpvid"] = erpOrg.corpvid,
|
// ["corpvid"] = erpOrg.corpvid,
|
||||||
["crowno"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10,
|
// ["crowno"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10,
|
||||||
["csourcebillhid"] = wmsRawmatTransferinstockH?.erp_pk ?? "",
|
// ["csourcebillhid"] = wmsRawmatTransferinstockH?.erp_pk ?? "",
|
||||||
["csourcebillbid"] = wmsRawmatTransferinstockD?.erp_line_pk ?? "",
|
// ["csourcebillbid"] = wmsRawmatTransferinstockD?.erp_line_pk ?? "",
|
||||||
["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id)?.Id ?? ""))?.cunitid ?? "",
|
// ["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 ?? "",
|
// ["cvendorid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? "",
|
||||||
["cvendorvid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? "",
|
// ["cvendorvid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? "",
|
||||||
["dbizdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
// ["dbizdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
["dplanarrivedate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
// ["dplanarrivedate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
["dplanoutdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
// ["dplanoutdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
["nnum"] = item.qty,
|
// ["nnum"] = item.qty,
|
||||||
["nshouldnum"] = item.pr_qty,
|
// ["nshouldnum"] = item.pr_qty,
|
||||||
["pk_group"] = erpOrg.pk_group,
|
// ["pk_group"] = erpOrg.pk_group,
|
||||||
["pk_org"] = erpOrg.pk_org,
|
// ["pk_org"] = erpOrg.pk_org,
|
||||||
["pk_org_v"] = erpOrg.pk_org_v,
|
// ["pk_org_v"] = erpOrg.pk_org_v,
|
||||||
["vbatchcode"] = item.code_batch,
|
// ["vbatchcode"] = item.code_batch,
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
erpRequestData.Add("dtls", erpRequestDataDetails);
|
// erpRequestData.Add("dtls", erpRequestDataDetails);
|
||||||
requestData.Add(erpRequestData);
|
// requestData.Add(erpRequestData);
|
||||||
BasFactoryConfig config = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.BIPURL);
|
// BasFactoryConfig config = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.BIPURL);
|
||||||
ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord();
|
// ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord();
|
||||||
thirdWebapiRecord.id = SnowflakeIdHelper.NextId();
|
// thirdWebapiRecord.id = SnowflakeIdHelper.NextId();
|
||||||
thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
|
// thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
|
||||||
thirdWebapiRecord.name = "调拨入库";
|
// thirdWebapiRecord.name = "调拨入库";
|
||||||
thirdWebapiRecord.method = "POST";
|
// thirdWebapiRecord.method = "POST";
|
||||||
thirdWebapiRecord.url = config.value + "uapws/rest/transIn/save";
|
// thirdWebapiRecord.url = config.value + "uapws/rest/transIn/save";
|
||||||
// thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/transIn/save";
|
// // thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/transIn/save";
|
||||||
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData);
|
// thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData);
|
||||||
thirdWebapiRecord.create_time = DateTime.Now;
|
// thirdWebapiRecord.create_time = DateTime.Now;
|
||||||
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
// await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ using JNPF.Common.Extension;
|
|||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
using JNPF.Logging;
|
using JNPF.Logging;
|
||||||
|
using JNPF.Systems.Entitys.Permission;
|
||||||
|
using JNPF.Systems.Entitys.System;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using JNPF.VisualDev;
|
using JNPF.VisualDev;
|
||||||
using JNPF.VisualDev.Interfaces;
|
using JNPF.VisualDev.Interfaces;
|
||||||
@@ -15,6 +17,7 @@ using Mapster;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
@@ -27,6 +30,8 @@ using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
|||||||
using Tnb.WarehouseMgr.Entities.Entity;
|
using Tnb.WarehouseMgr.Entities.Entity;
|
||||||
using Tnb.WarehouseMgr.Entities.Enums;
|
using Tnb.WarehouseMgr.Entities.Enums;
|
||||||
using Tnb.WarehouseMgr.Interfaces;
|
using Tnb.WarehouseMgr.Interfaces;
|
||||||
|
using Tnb.BasicData;
|
||||||
|
using Tnb.ProductionMgr.Entities.Entity;
|
||||||
|
|
||||||
namespace Tnb.WarehouseMgr
|
namespace Tnb.WarehouseMgr
|
||||||
{
|
{
|
||||||
@@ -62,10 +67,116 @@ namespace Tnb.WarehouseMgr
|
|||||||
throw new ArgumentNullException(nameof(input));
|
throw new ArgumentNullException(nameof(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (!isOk)
|
WmsInstockH instock = await _db.Queryable<WmsInstockH>().SingleAsync(x => x.id == input.requireId);
|
||||||
//{
|
List<WmsInstockD> allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||||
// throw Oops.Oh(ErrorCode.COM1001);
|
|
||||||
//}
|
WmsTempCode wmsTempCode = await _db.Queryable<WmsCarryCode>()
|
||||||
|
.LeftJoin<WmsTempCode>((a, b) => a.barcode == b.barcode)
|
||||||
|
.Where((a, b) => a.carry_id == input.wmsDistaskH.carry_id)
|
||||||
|
.Select((a, b) => b)
|
||||||
|
.FirstAsync();
|
||||||
|
|
||||||
|
string rawmatTransferinstockDId = wmsTempCode?.require_id ?? "";
|
||||||
|
WmsRawmatTransferinstockD wmsRawmatTransferinstockD = await _db.Queryable<WmsRawmatTransferinstockD>().SingleAsync(x => x.id == rawmatTransferinstockDId);
|
||||||
|
string rawmatTransferinstockHId = wmsRawmatTransferinstockD?.bill_id ?? "";
|
||||||
|
WmsRawmatTransferinstockH wmsRawmatTransferinstockH = await _db.Queryable<WmsRawmatTransferinstockH>().SingleAsync(x => x.id == rawmatTransferinstockHId);
|
||||||
|
|
||||||
|
List<String> materialIds = allInstockDetails.Select(x => x.material_id).Distinct().ToList();
|
||||||
|
List<String> unitCodes = allInstockDetails.Select(x => x.unit_id).Distinct().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))
|
||||||
|
.Select((x, y) => y)
|
||||||
|
.ToListAsync();
|
||||||
|
List<WmsErpWarehouserelaH> erpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x=>x.id!=null).ToListAsync();
|
||||||
|
BasWarehouse basWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x=>x.id==instock.warehouse_id);
|
||||||
|
|
||||||
|
string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
|
||||||
|
List<string> tableIds = new List<string>();
|
||||||
|
tableIds.Add(_userManager.UserId);
|
||||||
|
tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
|
||||||
|
tableIds.Add(instock.warehouse_id);
|
||||||
|
tableIds.AddRange(materialIds);
|
||||||
|
tableIds.Add(supplierId);
|
||||||
|
tableIds.AddRange(unitDatas.Select(x => x.Id).ToList());
|
||||||
|
|
||||||
|
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x => tableIds.Contains(x.table_id)).ToListAsync();
|
||||||
|
string userAccount = wmsRawmatTransferinstockH?.biller ?? "";
|
||||||
|
string deptCode = wmsRawmatTransferinstockH?.dept_code ?? "";
|
||||||
|
UserEntity userEntity = await _db.Queryable<UserEntity>().Where(x=>x.Account==userAccount).FirstAsync();
|
||||||
|
string userId = userEntity?.Id ?? "";
|
||||||
|
string erpCreateId = erpExtendFields.Find(x => x.table_id == userId)?.user_id ?? "";
|
||||||
|
ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId));
|
||||||
|
string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
||||||
|
Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
|
||||||
|
erpRequestData.Add("billmaker", erpCreateId);
|
||||||
|
erpRequestData.Add("cbiztype", "");
|
||||||
|
erpRequestData.Add("cdptid","1001A1100000000JRLI1");//部门先写死
|
||||||
|
erpRequestData.Add("cdptvid","0001A11000000007GGO8");//部门先写死
|
||||||
|
erpRequestData.Add("corpoid", erpOrg.corpoid);
|
||||||
|
erpRequestData.Add("corpvid", erpOrg.corpvid);
|
||||||
|
erpRequestData.Add("creationtime", nowStr);
|
||||||
|
erpRequestData.Add("creator", erpCreateId);
|
||||||
|
// erpRequestData.Add("cwarehouseid", erpExtendFields.Find(x => x.table_id == instock.warehouse_id)?.cotherwhid ?? "");//类型视图里取
|
||||||
|
erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == basWarehouse.whcode)?.erp_warehouseid ?? "");//类型视图里取
|
||||||
|
erpRequestData.Add("dbilldate", nowStr);
|
||||||
|
erpRequestData.Add("dmakedate", nowStr);
|
||||||
|
erpRequestData.Add("fbillflag", 1);
|
||||||
|
erpRequestData.Add("ntotalnum", allInstockDetails.Sum(x => x.qty));
|
||||||
|
erpRequestData.Add("pk_org", erpOrg.pk_org);
|
||||||
|
erpRequestData.Add("pk_org_v", erpOrg.pk_org_v);
|
||||||
|
erpRequestData.Add("pk_group", erpOrg.pk_group);
|
||||||
|
erpRequestData.Add("vdef1", null);
|
||||||
|
erpRequestData.Add("vbillcode", instock.bill_code);
|
||||||
|
erpRequestData.Add("ctrantypeid", "0001H11000000000D31E");//先写死
|
||||||
|
erpRequestData.Add("vtrantypecode", "4E-01");//先写死
|
||||||
|
erpRequestData.Add("csourcebillhid", wmsRawmatTransferinstockH?.erp_pk ?? "");
|
||||||
|
|
||||||
|
|
||||||
|
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
||||||
|
foreach (WmsInstockD item in allInstockDetails)
|
||||||
|
{
|
||||||
|
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
["cbodytranstypecode"] = "4E-01",
|
||||||
|
// ["cbodywarehouseid"] = erpExtendFields.Find(x => x.table_id == instock.warehouse_id)?.cotherwhid ?? "",
|
||||||
|
["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == basWarehouse.whcode)?.erp_warehouseid ?? "",
|
||||||
|
["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"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10,
|
||||||
|
["csourcebillhid"] = wmsRawmatTransferinstockH?.erp_pk ?? "",
|
||||||
|
["csourcebillbid"] = wmsRawmatTransferinstockD?.erp_line_pk ?? "",
|
||||||
|
["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 ?? "",
|
||||||
|
["dbizdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
|
["dplanarrivedate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
|
["dplanoutdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
|
["nnum"] = item.qty,
|
||||||
|
["nshouldnum"] = item.pr_qty,
|
||||||
|
["pk_group"] = erpOrg.pk_group,
|
||||||
|
["pk_org"] = erpOrg.pk_org,
|
||||||
|
["pk_org_v"] = erpOrg.pk_org_v,
|
||||||
|
["vbatchcode"] = item.code_batch,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
erpRequestData.Add("dtls", erpRequestDataDetails);
|
||||||
|
requestData.Add(erpRequestData);
|
||||||
|
BasFactoryConfig config = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.BIPURL);
|
||||||
|
ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord();
|
||||||
|
thirdWebapiRecord.id = SnowflakeIdHelper.NextId();
|
||||||
|
thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
|
||||||
|
thirdWebapiRecord.name = "调拨入库";
|
||||||
|
thirdWebapiRecord.method = "POST";
|
||||||
|
thirdWebapiRecord.url = config.value + "uapws/rest/transIn/save";
|
||||||
|
// thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/transIn/save";
|
||||||
|
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData);
|
||||||
|
thirdWebapiRecord.create_time = DateTime.Now;
|
||||||
|
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|||||||
Reference in New Issue
Block a user