产成品入库
This commit is contained in:
@@ -7,13 +7,17 @@ using System.Threading.Tasks;
|
||||
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.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.Util;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Entities;
|
||||
@@ -25,6 +29,7 @@ using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities.Entity;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -319,8 +324,110 @@ namespace Tnb.WarehouseMgr
|
||||
// 如果生产入库 输送线到仓库这条任务完成,反写单据数据
|
||||
if (input.bizTypeId == WmsWareHouseConst.BIZTYPE_WMSPRDINSTOCK_ID)
|
||||
{
|
||||
isOk = await _db.Updateable<WmsPrdInstockD>().SetColumns(it => new WmsPrdInstockD { status = WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID })
|
||||
.Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
|
||||
isOk = await _db.Updateable<WmsPrdInstockD>()
|
||||
.SetColumns(it => new WmsPrdInstockD { status = WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID })
|
||||
.Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
|
||||
|
||||
WmsPrdInstockD wmsPrdInstockD = await _db.Queryable<WmsPrdInstockD>().SingleAsync(x=>x.id==input.requireId);
|
||||
WmsPrdInstockH instock = await _db.Queryable<WmsPrdInstockH>().SingleAsync(x=>x.id==wmsPrdInstockD.prd_instock_id);
|
||||
BasWarehouse scWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x=>x.id==wmsPrdInstockD.scwarehouse_id);
|
||||
BasWarehouse kcWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x=>x.id==wmsPrdInstockD.warehouse_id);
|
||||
//todo 产成品入库
|
||||
List<WmsPrdInstockCode> allInstockDetails = await _db.Queryable<WmsPrdInstockCode>().Where(it => it.prd_instock_id == instock.id).ToListAsync();
|
||||
|
||||
|
||||
List<String> materialIds = Arrays.AsList(instock.material_id);
|
||||
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();
|
||||
string userId = instock?.create_id ?? WmsWareHouseConst.AdministratorUserId;
|
||||
|
||||
string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
|
||||
List<string> tableIds = new List<string>();
|
||||
tableIds.Add(userId);
|
||||
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 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("corpoid", erpOrg.corpoid);
|
||||
erpRequestData.Add("corpvid", erpOrg.corpvid);
|
||||
erpRequestData.Add("cprocalbodyoid", erpOrg.pk_org_v);
|
||||
erpRequestData.Add("cprocalbodyvid", erpOrg.pk_group);
|
||||
erpRequestData.Add("creationtime", nowStr);
|
||||
erpRequestData.Add("creator", erpCreateId);
|
||||
erpRequestData.Add("ctrantypeid", "0001H11000000000D30X");//先写死
|
||||
erpRequestData.Add("cprowarehouseid", erpWarehouserelaHs.Find(x=>x.wms_warehousecode==scWarehouse.whcode)?.erp_warehouseid ?? "");//先写死
|
||||
erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x=>x.wms_warehousecode==kcWarehouse.whcode)?.erp_warehouseid ?? "");//先写死
|
||||
erpRequestData.Add("cwhsmanagerid", null);
|
||||
erpRequestData.Add("dbilldate", nowStr);
|
||||
erpRequestData.Add("dmakedate", nowStr);
|
||||
erpRequestData.Add("fbillflag", 1);
|
||||
erpRequestData.Add("ntotalnum", allInstockDetails.Sum(x=>x.pqty));
|
||||
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", instock.bill_code);
|
||||
erpRequestData.Add("vtrantypecode", "46-01");
|
||||
erpRequestData.Add("csourcebillhid", "");//todo 后面填
|
||||
|
||||
|
||||
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
||||
foreach (WmsPrdInstockCode item in allInstockDetails)
|
||||
{
|
||||
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
||||
{
|
||||
["cbodytranstypecode"] = "46-01",
|
||||
["cbodywarehouseid"] = erpWarehouserelaHs.Find(x=>x.wms_warehousecode==kcWarehouse.whcode)?.erp_warehouseid ?? "",
|
||||
["cmaterialoid"] = erpExtendFields.Find(x => x.table_id == instock.material_id)?.cmaterialoid ?? "",
|
||||
["cmaterialvid"] = erpExtendFields.Find(x => x.table_id == instock.material_id)?.cmaterialvid ?? "",
|
||||
["corpoid"] = erpOrg.corpoid,
|
||||
["corpvid"] = erpOrg.corpvid,
|
||||
["cproductid"] = erpExtendFields.Find(x => x.table_id == instock.material_id)?.cmaterialoid ?? "",
|
||||
["fproductclass"] = 1,
|
||||
["crowno"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10,
|
||||
["csourcebillhid"] = "",
|
||||
["csourcebillbid"] = "",
|
||||
["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.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
["dplanarrivedate"] = instock.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
["dplanoutdate"] = instock.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
["nnum"] = item.pqty,
|
||||
["nshouldnum"] = item.pqty,
|
||||
["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/productin/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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Tnb.WarehouseMgr
|
||||
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 userId = userEntity?.Id ?? WmsWareHouseConst.AdministratorUserId;
|
||||
|
||||
string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
|
||||
List<string> tableIds = new List<string>();
|
||||
|
||||
Reference in New Issue
Block a user