|
|
|
|
@@ -7,21 +7,28 @@ using Aop.Api.Domain;
|
|
|
|
|
using JNPF.Common.Core.Manager;
|
|
|
|
|
using JNPF.Common.Dtos.VisualDev;
|
|
|
|
|
using JNPF.Common.Enums;
|
|
|
|
|
using JNPF.Common.Security;
|
|
|
|
|
using JNPF.FriendlyException;
|
|
|
|
|
using JNPF.Systems.Entitys.Permission;
|
|
|
|
|
using JNPF.Systems.Entitys.System;
|
|
|
|
|
using JNPF.Systems.Interfaces.System;
|
|
|
|
|
using JNPF.VisualDev;
|
|
|
|
|
using JNPF.VisualDev.Interfaces;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using Tnb.BasicData.Entities;
|
|
|
|
|
using Tnb.WarehouseMgr.Entities;
|
|
|
|
|
using Tnb.WarehouseMgr.Entities.Attributes;
|
|
|
|
|
using Tnb.WarehouseMgr.Entities.Consts;
|
|
|
|
|
using Tnb.WarehouseMgr.Entities.Dto;
|
|
|
|
|
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
|
|
|
|
using Tnb.WarehouseMgr.Entities.Entity;
|
|
|
|
|
using Tnb.WarehouseMgr.Interfaces;
|
|
|
|
|
using Tnb.BasicData;
|
|
|
|
|
using Tnb.ProductionMgr.Entities.Entity;
|
|
|
|
|
|
|
|
|
|
namespace Tnb.WarehouseMgr
|
|
|
|
|
{
|
|
|
|
|
@@ -56,6 +63,125 @@ namespace Tnb.WarehouseMgr
|
|
|
|
|
_wmsPDAScanInStock = wmsPDAScanInStock;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override async Task ModifyAsync(WareHouseUpInput input)
|
|
|
|
|
{
|
|
|
|
|
if (input == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(input));
|
|
|
|
|
}
|
|
|
|
|
Logger.Information($"进入成品调拨入库单上传BIP逻辑");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
string rawmatTransferinstockDId = input.source_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 userAccount = wmsRawmatTransferinstockH?.biller ?? "";
|
|
|
|
|
string deptCode = wmsRawmatTransferinstockH?.dept_code ?? "";
|
|
|
|
|
UserEntity userEntity = await _db.Queryable<UserEntity>().Where(x=>x.Account==userAccount).FirstAsync();
|
|
|
|
|
string userId = userEntity?.Id ?? WmsWareHouseConst.AdministratorUserId;
|
|
|
|
|
|
|
|
|
|
string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
|
|
|
|
|
List<string> tableIds = new List<string>();
|
|
|
|
|
tableIds.Add(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 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,
|
|
|
|
|
["nnum"] = wmsRawmatTransferinstockD.actual_qty,
|
|
|
|
|
["nshouldnum"] = wmsRawmatTransferinstockD.actual_qty,
|
|
|
|
|
["pk_group"] = erpOrg.pk_group,
|
|
|
|
|
["pk_org"] = erpOrg.pk_org,
|
|
|
|
|
["pk_org_v"] = erpOrg.pk_org_v,
|
|
|
|
|
["vbatchcode"] = item.code_batch,
|
|
|
|
|
["coutcalbodyoid"] = wmsRawmatTransferinstockH.outstockorg_code,
|
|
|
|
|
["coutcalbodyvid"] = wmsRawmatTransferinstockH.outstockorg_id,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
thirdWebapiRecord.remark = "成品调拨入库";
|
|
|
|
|
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
|
|
|
|
Logger.Information($"完成成品调拨入库单上传BIP逻辑");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|