采购到货
This commit is contained in:
@@ -8,6 +8,7 @@ namespace Tnb.ProductionMgr.Entities.Entity.ErpEntity
|
||||
public string ID { get; set; }
|
||||
public string CODE { get; set; }
|
||||
public string NAME { get; set; }
|
||||
public string VID { get; set; }
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
|
||||
@@ -96,6 +96,11 @@ namespace Tnb.ProductionMgr.Entities.Entity
|
||||
/// </summary>
|
||||
public string supplier_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 供应商vid
|
||||
/// </summary>
|
||||
public string supplier_vid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
|
||||
@@ -2154,14 +2154,14 @@ namespace Tnb.ProductionMgr
|
||||
["cbmainmaterialvid"] = erpExtendFields.Find(x=>x.table_id==report.material_id)?.cmaterialvid ?? "",
|
||||
["cbmaterialid"] = erpExtendFields.Find(x=>x.table_id==report.material_id)?.cmaterialvid ?? "",
|
||||
["cbmaterialvid"] = erpExtendFields.Find(x=>x.table_id==report.material_id)?.cmaterialvid ?? "",
|
||||
["cbmobid"] = prdMo.erp_lineno,
|
||||
["cbmobid"] = prdMo.erp_line_pk,
|
||||
["cbmoid"] = prdMo.erp_mo_pk,
|
||||
["cbunitid"] = erpExtendFields.Find(x=>x.table_id==report.unit_id)?.cunitid ?? "",
|
||||
["cbastunitid"] = "",
|
||||
["cbastunitid"] = erpExtendFields.Find(x=>x.table_id==report.unit_id)?.cunitid ?? "",
|
||||
["nbplanwrnum"] = report.reported_qty,
|
||||
["nbwrnum"] = report.reported_qty,
|
||||
["tbendtime"] = "",
|
||||
["tbstarttime"] = "",
|
||||
["tbendtime"] = nowStr,
|
||||
["tbstarttime"] = prdMoTask.act_start_date!=null ? prdMoTask.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
|
||||
["vbinbatchcode"] = report.batch,
|
||||
["vbmobillcode"] = prdMo.mo_code,
|
||||
["vbmorowno"] = prdMo.erp_lineno,
|
||||
|
||||
@@ -1138,7 +1138,7 @@ namespace Tnb.ProductionMgr
|
||||
return result.IsSuccess ? $"新增单位{insertUnit.Count}条" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
return msg;
|
||||
return "新增单位0条";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1260,6 +1260,7 @@ namespace Tnb.ProductionMgr
|
||||
table_id = basSupplier.id,
|
||||
table_name = "bas_supplier",
|
||||
supplier_id = erpBdSupplier.ID,
|
||||
supplier_vid = erpBdSupplier.VID,
|
||||
create_time = DateTime.Now,
|
||||
erp_modify_time = erpBdSupplier.MODIFIEDTIME,
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using Mapster;
|
||||
@@ -29,6 +30,9 @@ using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.ProductionMgr.Entities.Entity;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -103,6 +107,114 @@ namespace Tnb.WarehouseMgr
|
||||
instockD.org_id = _userManager.User.OrganizeId;
|
||||
});
|
||||
await _db.Insertable(instockDs).ExecuteCommandAsync();
|
||||
|
||||
var purchase = await _db.Queryable<WmsPurchaseH>().FirstAsync(it => it.id == purchaseDs.First().bill_id);
|
||||
List<WmsPurchaseD> dList = await _db.Queryable<WmsPurchaseD>().Where(x=>x.bill_id==purchaseDs.First().bill_id).OrderBy(x=>x.id).ToListAsync();
|
||||
List<String> materialIds = purchaseDs.Select(x=>x.material_id).Distinct().ToList();
|
||||
List<String> unitCodes = purchaseDs.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<string> ids = new List<string>();
|
||||
ids.Add(_userManager.UserId);
|
||||
ids.Add(WmsWareHouseConst.AdministratorOrgId);
|
||||
ids.Add(purchase.warehouse_id);
|
||||
ids.AddRange(materialIds);
|
||||
ids.Add(purchase.supplier_id);
|
||||
ids.AddRange(unitDatas.Select(x=>x.Id).ToList());
|
||||
|
||||
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x=>ids.Contains(x.table_id)).ToListAsync();
|
||||
string erpCreateId = erpExtendFields.Find(x=>x.table_id==_userManager.UserId)?.user_id ?? "";
|
||||
ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId));
|
||||
string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
WmsPurchaseOrderH wmsPurchaseOrderH = await _db.Queryable<WmsPurchaseOrderH>().SingleAsync(x=>x.id==purchase.erp_bill_code);
|
||||
//todo 先取采购订单第一条
|
||||
WmsPurchaseOrderD wmsPurchaseOrderDs = await _db.Queryable<WmsPurchaseOrderD>().FirstAsync(x=>x.fk_wms_purchase_order_id==purchase.erp_bill_code);
|
||||
|
||||
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
||||
Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
|
||||
erpRequestData.Add("approver",erpCreateId);
|
||||
erpRequestData.Add("billmaker",erpCreateId);
|
||||
erpRequestData.Add("creationtime",nowStr);
|
||||
erpRequestData.Add("creator",erpCreateId);
|
||||
erpRequestData.Add("dbilldate",purchase.delivery_date.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
erpRequestData.Add("dmakedate",nowStr);
|
||||
//erpRequestData.Add("ntotalastnum",purchaseDs.Sum(x=>x.purchase_arriveqty));
|
||||
erpRequestData.Add("pk_arriveorder","");
|
||||
// erpRequestData.Add("pk_dept","1001A1100000000JRLI1");
|
||||
// erpRequestData.Add("pk_dept_v","0001A11000000007GGO8");
|
||||
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("pk_pupsndoc","");
|
||||
erpRequestData.Add("pk_purchaseorg",erpOrg.pk_org);
|
||||
erpRequestData.Add("pk_purchaseorg_v",erpOrg.pk_org_v);
|
||||
erpRequestData.Add("pk_supplier",erpExtendFields.Find(x=>x.table_id==purchase.supplier_id)?.supplier_id ?? "");//先写死
|
||||
erpRequestData.Add("pk_supplier_v",erpExtendFields.Find(x=>x.table_id==purchase.supplier_id)?.supplier_vid ?? "");//先写死
|
||||
erpRequestData.Add("vbillcode",purchase.bill_code);
|
||||
erpRequestData.Add("vmemo",purchase.remark);
|
||||
erpRequestData.Add("vtrantypecode","");
|
||||
|
||||
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
||||
foreach(WmsPurchaseD item in dList)
|
||||
{
|
||||
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
||||
{
|
||||
["castunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id)?.Id ?? ""))?.cunitid ?? "",
|
||||
["cfirstbid"] = "",
|
||||
["cfirstid"] = "",
|
||||
["cfirsttypecode"] = "",
|
||||
["crececountryid"] = "0001Z010000000079UJJ",
|
||||
["crowno"] = (dList.FindIndex(x=>x.id==item.id)+1) * 10,
|
||||
["csendcountryid"] = "0001Z010000000079UJJ",
|
||||
["csourcetypecode"] = "",
|
||||
["ctaxcountryid"] = "0001Z010000000079UJJ",
|
||||
["cunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id)?.Id ?? ""))?.cunitid ?? "",
|
||||
["dbilldate"] = "",
|
||||
["dplanreceivedate"] = "",
|
||||
["dproducedate"] = "",
|
||||
["fbuysellflag"] = 1,
|
||||
["fproductclass"] = 1,
|
||||
["naccumchecknum"] = 0,
|
||||
["nastnum"] = item.purchase_arriveqty,
|
||||
["nnum"] = null,
|
||||
// ["nplanastnum"] = 0,
|
||||
// ["nplannum"] = item.purchase_qty,
|
||||
["apfinanceorg"] = erpOrg.pk_org,
|
||||
["pk_apfinanceorg_v"] = erpOrg.pk_org_v,
|
||||
["pk_arriveorder"] = "",
|
||||
["pk_arriveorder_b"] = "",
|
||||
["pk_group"] = "",
|
||||
["pk_material"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "",
|
||||
["pk_order"] = wmsPurchaseOrderH?.erp_pk ?? "",
|
||||
["pk_order_b"] = wmsPurchaseOrderDs.erp_line_pk,
|
||||
["pk_org"] = erpOrg.pk_org,
|
||||
["pk_org_v"] = erpOrg.pk_org_v,
|
||||
["pk_psfinanceorg"] = erpOrg.pk_org_v,
|
||||
["pk_psfinanceorg_v"] = erpOrg.pk_org_v,
|
||||
["pk_receivestore"] = erpExtendFields.Find(x=>x.table_id==purchase.warehouse_id)?.cotherwhid ?? "",
|
||||
["pk_reqstoorg"] = erpOrg.pk_org,
|
||||
["pk_reqstoorg_v"] = erpOrg.pk_org_v,
|
||||
["pk_srcmaterial"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "",
|
||||
["vbatchcode"] = item.code_batch,
|
||||
});
|
||||
}
|
||||
erpRequestData.Add("dtls",erpRequestDataDetails);
|
||||
requestData.Add(erpRequestData);
|
||||
|
||||
ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord();
|
||||
thirdWebapiRecord.id = SnowflakeIdHelper.NextId();
|
||||
thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
|
||||
thirdWebapiRecord.name = "采购到货";
|
||||
thirdWebapiRecord.method = "POST";
|
||||
thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/purarrvial/save";
|
||||
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData);
|
||||
thirdWebapiRecord.create_time = DateTime.Now;
|
||||
|
||||
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
||||
}
|
||||
//通知Mes接口
|
||||
//_ = SyncMesData(instock.id, instockDs.Select(x => x.material_id).ToList(), EnumTriggerEvent.入厂检按物料编号);
|
||||
|
||||
Reference in New Issue
Block a user