转库单
This commit is contained in:
@@ -744,7 +744,14 @@ namespace Tnb.ProductionMgr
|
||||
elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
|
||||
try
|
||||
{
|
||||
thirdResult = JsonConvert.DeserializeObject<ThirdResult>(response);
|
||||
if (response != null && !response.IsEmpty())
|
||||
{
|
||||
thirdResult = JsonConvert.DeserializeObject<ThirdResult>(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
thirdResult.Code = 500;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -5,11 +5,13 @@ using JNPF.Common.Extension;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.EventBus;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
@@ -19,6 +21,9 @@ using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities.Entity;
|
||||
using Tnb.BasicData;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
|
||||
@@ -64,14 +69,16 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
|
||||
BasLocation endLocation = await _db.Queryable<BasLocation>().Where(r => r.id == input.wmsDistaskH.endlocation_id).FirstAsync();
|
||||
string outWhid = "";
|
||||
// 生产入库(灭菌完成) 仓库传 1001A1100000001MA8KP
|
||||
if (endLocation.wh_id == WmsWareHouseConst.WAREHOUSE_MJC_ID)
|
||||
{
|
||||
|
||||
outWhid = WmsWareHouseConst.bipwarehouseid_bz;
|
||||
}
|
||||
// 生产入库(成品) 仓库传 1001A1100000001MA8ME
|
||||
else if (endLocation.wh_id == WmsWareHouseConst.WAREHOUSE_CP_ID)
|
||||
{
|
||||
outWhid = WmsWareHouseConst.bipwarehouseid_mj;
|
||||
bool isOk = await _db.Updateable<WmsSterilizationInstockH>().SetColumns(it => new WmsSterilizationInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID })
|
||||
.Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
|
||||
if (!isOk)
|
||||
@@ -80,6 +87,93 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
}
|
||||
WmsSterilizationInstockH wmsRawmatTransferoutstockH = await _db.Queryable<WmsSterilizationInstockH>().SingleAsync(x=>x.id==input.requireId);
|
||||
List<WmsCarryCode> wmsCarryCodes = await _db.Queryable<WmsCarryCode>().Where(r => r.carry_id == input.wmsDistaskH.carry_id).ToListAsync();
|
||||
|
||||
decimal qty = wmsCarryCodes.Sum(r => r.codeqty);
|
||||
|
||||
List<String> unitCodes = wmsCarryCodes.Select(x => x.unit_id).Distinct().ToList();
|
||||
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))
|
||||
.Select((x, y) => y)
|
||||
.ToListAsync();
|
||||
|
||||
string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
|
||||
List<string> tableIds = new List<string>();
|
||||
tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
|
||||
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 userId = wmsRawmatTransferoutstockH.create_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<WmsErpWarehouserelaH> wmsErpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x=>!SqlFunc.IsNullOrEmpty(x.id)).ToListAsync();
|
||||
|
||||
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
||||
Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
|
||||
erpRequestData.Add("billmaker", erpCreateId);
|
||||
erpRequestData.Add("corpoid", erpOrg.corpoid);
|
||||
erpRequestData.Add("corpvid", erpOrg.corpvid);
|
||||
erpRequestData.Add("cdptid","1001A1100000000JRLI1");//部门先写死
|
||||
erpRequestData.Add("cdptvid","0001A11000000007GGO8");//部门先写死
|
||||
erpRequestData.Add("cotherdptid","1001A1100000000JRLI1");//部门先写死
|
||||
erpRequestData.Add("cotherdptvid","0001A11000000007GGO8");//部门先写死
|
||||
erpRequestData.Add("creationtime", nowStr);
|
||||
erpRequestData.Add("creator", erpCreateId);
|
||||
erpRequestData.Add("ctrantypeid", "0001H11000000000D32A");//先写死
|
||||
erpRequestData.Add("cwarehouseid", "outWhid");//先写死
|
||||
erpRequestData.Add("dbilldate", wmsRawmatTransferoutstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
erpRequestData.Add("dmakedate", nowStr);
|
||||
erpRequestData.Add("dshldarrivedate", nowStr);
|
||||
erpRequestData.Add("dshlddiliverdate", nowStr);
|
||||
erpRequestData.Add("fbillflag", 1);
|
||||
erpRequestData.Add("isbackdeliver", false);
|
||||
erpRequestData.Add("ntotalnum", 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("vbillcode", wmsRawmatTransferoutstockH.bill_code);
|
||||
erpRequestData.Add("vtrantypecode", "4Y-01");//先写死
|
||||
|
||||
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
||||
foreach(var item in wmsCarryCodes)
|
||||
{
|
||||
// 出库数量wmsMaterialSignD.sign_qty
|
||||
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
||||
{
|
||||
["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"] = (wmsCarryCodes.FindIndex(x => x.id == item.id) + 1) * 10,
|
||||
["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id)?.Id ?? ""))?.cunitid ?? "",
|
||||
["nnum"] = item.codeqty,
|
||||
["nshouldnum"] = item.codeqty,
|
||||
["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/whstrans/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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user