This commit is contained in:
2024-09-30 10:51:15 +08:00
8 changed files with 174 additions and 118 deletions

View File

@@ -9,7 +9,11 @@ namespace Tnb.ProductionMgr.Entities.Dto
public string eqp_id { get; set; }
public string mo_task_status { get; set; }
public decimal? plan_qty { get; set; }
public decimal? rqty { get; set; }
/// <summary>
/// 已报工数量
/// </summary>
public decimal? reported_work_qty { get; set; } = 0;
public decimal? scrap_qty { get; set; }
public decimal? scheduled_qty { get; set; }
public string create_time { get; set; }
public string workstation_id { get; set; }

View File

@@ -130,7 +130,8 @@ namespace Tnb.ProductionMgr
dayshiftafter_worker_id = a.dayshiftafter_worker_id,
nightshift_worker_id = a.nightshift_worker_id,
nightshiftafter_worker_id = a.nightshiftafter_worker_id,
rqty = a.scrap_qty
reported_work_qty = a.reported_work_qty,
scrap_qty = a.scrap_qty
}).OrderByDescending(a => a.create_time).ToPagedListAsync(input.currentPage, input.pageSize);
List<string> userIdList = result.list.Select(x => x.dayshift_worker_id).Distinct().ToList();

View File

@@ -3224,6 +3224,13 @@ namespace Tnb.WarehouseMgr
return;
}
WmsMaterialTransfer wmsMaterialTransfer = await db.Queryable<WmsMaterialTransfer>().SingleAsync(x => x.id == dt.source_id);
//自制的不调erp接口
if (string.IsNullOrEmpty(wmsMaterialTransfer.erp_bill_code))
{
return;
}
List<WmsMaterialTransferD> wmsMaterialTransferDs = await db.Queryable<WmsMaterialTransferD>().Where(x => x.bill_id == dt.source_id).ToListAsync();
List<String> materialIds = wmsMaterialTransferDs.Select(x => x.material_id).Distinct().ToList();
List<String> unitCodes = wmsMaterialTransferDs.Select(x => x.unit_id).Distinct().ToList();

View File

@@ -357,6 +357,12 @@ namespace Tnb.WarehouseMgr
// 出库数量wmsMaterialSignD.sign_qty
}
//自制的不调erp接口
if (string.IsNullOrEmpty(wmsTransferOrderH.erp_pk))
{
break;
}
List<String> materialIds = wmsMaterialSignDs.Select(x => x.material_id).Distinct().ToList();
List<WmsErpWarehouserelaH> erpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x=>x.id!=null).ToListAsync();
@@ -469,6 +475,13 @@ namespace Tnb.WarehouseMgr
WmsMaterialTransferD wmsMaterialTransferd = await _db.Queryable<WmsMaterialTransferD>().Where(r => r.id == wmsDistaskH.source_id).FirstAsync();
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().Where(r => r.id == wmsMaterialTransferd.bill_id).FirstAsync();
//自制的不调erp接口
if (string.IsNullOrEmpty(wmsMaterialTransfer.erp_bill_code))
{
break;
}
List<WmsMaterialTransferD> dList = await _db.Queryable<WmsMaterialTransferD>().Where(x => x.bill_id == wmsMaterialTransferd.bill_id).OrderBy(x => x.id).ToListAsync();
DictionaryDataEntity unitData = await _db.Queryable<DictionaryTypeEntity>()
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)

View File

@@ -1093,6 +1093,12 @@ namespace Tnb.WarehouseMgr
|| wmsMaterialTransfer.type == WmsWareHouseConst.MATERIALTRANSFER_CROSSLAYER_CODE
|| wmsMaterialTransfer.type == WmsWareHouseConst.MATERIALTRANSFER_WXDBOUTWAREHOUSE_CODE)
{
//自制的不调erp接口
if (string.IsNullOrEmpty(wmsMaterialTransfer.erp_bill_code))
{
return;
}
Logger.LogInformation("【WmsMaterialTransferService ModifyAsync】同步其它入库单到erp...");
List<WmsMaterialTransferD> dList = await _db.Queryable<WmsMaterialTransferD>().Where(x => x.bill_id == wmsMaterialTransferd.bill_id).OrderBy(x => x.id).ToListAsync();
@@ -1199,6 +1205,13 @@ namespace Tnb.WarehouseMgr
// 原材料仓出库在签收后回传其它出库
if (wmsMaterialTransfer.warehouse_outstock != WmsWareHouseConst.WAREHOUSE_YCL_ID)
{
//自制的不调erp接口
if (string.IsNullOrEmpty(wmsMaterialTransfer.erp_bill_code))
{
return;
}
Logger.LogInformation("【WmsMaterialTransferService ModifyAsync】同步其它出库单到erp...");
List<WmsMaterialTransferD> dList = await _db.Queryable<WmsMaterialTransferD>().Where(x => x.bill_id == wmsMaterialTransferd.bill_id).OrderBy(x => x.id).ToListAsync();

View File

@@ -204,126 +204,132 @@ namespace Tnb.WarehouseMgr
//todo 先取采购订单第一条
//WmsPurchaseOrderD wmsPurchaseOrderDs = await _db.Queryable<WmsPurchaseOrderD>().FirstAsync(x=>x.fk_wms_purchase_order_id==purchase.erp_bill_code);
List<string> ids = new List<string>();
// ids.Add(_userManager.UserId);
// ids.Add(WmsWareHouseConst.AdministratorUserId);
ids.Add(WmsWareHouseConst.AdministratorOrgId);
ids.Add(purchase.warehouse_id);
ids.AddRange(materialIds);
ids.Add(wmsPurchaseOrderH.supplier_id);
ids.AddRange(unitDatas.Select(x=>x.Id).ToList());
string userId = _userManager.UserId ?? WmsWareHouseConst.AdministratorUserId;
ids.Add(userId);
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x=>ids.Contains(x.table_id)).ToListAsync();
// string erpCreateId = erpExtendFields.Find(x=>x.table_id==userId)?.user_id ?? WmsWareHouseConst.ERPUSERID;
string erpCreateId = WmsWareHouseConst.ERPUSERID;
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("approver",erpCreateId);
erpRequestData.Add("billmaker",erpCreateId);
erpRequestData.Add("creationtime",nowStr);
erpRequestData.Add("creator",erpCreateId);
erpRequestData.Add("dbilldate",purchase.create_time.ToString("yyyy-MM-dd HH:mm:ss"));
erpRequestData.Add("dmakedate",nowStr);
erpRequestData.Add("ntotalastnum",purchaseDs.Sum(x=>x.purchase_arriveqty));
erpRequestData.Add("pk_arriveorder",null);
// erpRequestData.Add("pk_dept","1001A1100000001JFOPQ");
// erpRequestData.Add("pk_dept_v","0001A1100000000AOMIQ");
erpRequestData.Add("Pk_receivepsndoc",erpCreateId);
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("csourceid", wmsPurchaseOrderH?.erp_pk ?? "");
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)
//自制的不调erp接口
if (!string.IsNullOrEmpty(wmsPurchaseOrderH.erp_bill_code))
{
erpRequestDataDetails.Add(new Dictionary<string, object>()
List<string> ids = new List<string>();
// ids.Add(_userManager.UserId);
// ids.Add(WmsWareHouseConst.AdministratorUserId);
ids.Add(WmsWareHouseConst.AdministratorOrgId);
ids.Add(purchase.warehouse_id);
ids.AddRange(materialIds);
ids.Add(wmsPurchaseOrderH.supplier_id);
ids.AddRange(unitDatas.Select(x=>x.Id).ToList());
string userId = _userManager.UserId ?? WmsWareHouseConst.AdministratorUserId;
ids.Add(userId);
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x=>ids.Contains(x.table_id)).ToListAsync();
// string erpCreateId = erpExtendFields.Find(x=>x.table_id==userId)?.user_id ?? WmsWareHouseConst.ERPUSERID;
string erpCreateId = WmsWareHouseConst.ERPUSERID;
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("approver",erpCreateId);
erpRequestData.Add("billmaker",erpCreateId);
erpRequestData.Add("creationtime",nowStr);
erpRequestData.Add("creator",erpCreateId);
erpRequestData.Add("dbilldate",purchase.create_time.ToString("yyyy-MM-dd HH:mm:ss"));
erpRequestData.Add("dmakedate",nowStr);
erpRequestData.Add("ntotalastnum",purchaseDs.Sum(x=>x.purchase_arriveqty));
erpRequestData.Add("pk_arriveorder",null);
// erpRequestData.Add("pk_dept","1001A1100000001JFOPQ");
// erpRequestData.Add("pk_dept_v","0001A1100000000AOMIQ");
erpRequestData.Add("Pk_receivepsndoc",erpCreateId);
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("csourceid", wmsPurchaseOrderH?.erp_pk ?? "");
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)
{
["castunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id || x.Id==item.unit_id)?.Id ?? ""))?.cunitid ?? "",
["cfirstbid"] = wmsPurchaseOrderH?.erp_pk ?? "",
["cfirstid"] = item.erp_purchase_order_d_pk,
["cfirsttypecode"] = "",
["crececountryid"] = "0001Z010000000079UJJ",
["crowno"] = item.erp_purchase_order_d_lineno,
["csendcountryid"] = "0001Z010000000079UJJ",
["csourcetypecode"] = "",
["ctaxcountryid"] = "0001Z010000000079UJJ",
["cunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id || x.Id==item.unit_id)?.Id ?? ""))?.cunitid ?? "",
["dbilldate"] = purchase.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
["dplanreceivedate"] = purchase.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
["dproducedate"] = purchase.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
// ["fbuysellflag"] = 2,
["fproductclass"] = 1,
// ["naccumchecknum"] = 0,
// ["nastnum"] = item.purchase_arriveqty,
["nnum"] = item.purchase_arriveqty,
// ["nplanastnum"] = 0,
["nplannum"] = item.purchase_qty,
["pk_apfinanceorg"] = erpOrg.corpoid,
["pk_apfinanceorg_v"] = erpOrg.corpvid,
["pk_arriveorder"] = null,
["pk_arriveorder_b"] = null,
["pk_group"] = erpOrg.pk_group,
["pk_material"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "",
["pk_order"] = wmsPurchaseOrderH?.erp_pk ?? "",
["pk_order_b"] = item.erp_purchase_order_d_pk,
["pk_org"] = erpOrg.pk_org,
["pk_org_v"] = erpOrg.pk_org_v,
["pk_psfinanceorg"] = erpOrg.corpoid,
["pk_psfinanceorg_v"] = erpOrg.corpvid,
// ["pk_receivestore"] = erpExtendFields.Find(x=>x.table_id==purchase.warehouse_id)?.cotherwhid ?? "",
// ["pk_receivestore"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == item.erp_wh_type)?.erp_warehouseid ?? "",
["pk_receivestore"] = item.erp_wh_type,
["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,
["Vfree1"] = item.code_batch,
["mes_detail_id"] = item.id,
["bpresent"] = item.gift==1,
["csourceid"] = wmsPurchaseOrderH?.erp_pk ?? "",
["vsourcecode"] = wmsPurchaseOrderH.erp_bill_code,
["csourcebid"] = item.erp_purchase_order_d_pk,
["IsType"] = 0,
["csourcetypecode"] = null,
["vsourcerowno"] = null,
["vsourcetrantype"] = null,
["cproductorid"] = item.production_unit,
});
}
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/purarrvial/save";
thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/purarrvial/save";
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData);
thirdWebapiRecord.create_time = DateTime.Now;
thirdWebapiRecord.remark = $"erp采购订单:{wmsPurchaseOrderH.erp_bill_code}";
erpRequestDataDetails.Add(new Dictionary<string, object>()
{
["castunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id || x.Id==item.unit_id)?.Id ?? ""))?.cunitid ?? "",
["cfirstbid"] = wmsPurchaseOrderH?.erp_pk ?? "",
["cfirstid"] = item.erp_purchase_order_d_pk,
["cfirsttypecode"] = "",
["crececountryid"] = "0001Z010000000079UJJ",
["crowno"] = item.erp_purchase_order_d_lineno,
["csendcountryid"] = "0001Z010000000079UJJ",
["csourcetypecode"] = "",
["ctaxcountryid"] = "0001Z010000000079UJJ",
["cunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id || x.Id==item.unit_id)?.Id ?? ""))?.cunitid ?? "",
["dbilldate"] = purchase.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
["dplanreceivedate"] = purchase.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
["dproducedate"] = purchase.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
// ["fbuysellflag"] = 2,
["fproductclass"] = 1,
// ["naccumchecknum"] = 0,
// ["nastnum"] = item.purchase_arriveqty,
["nnum"] = item.purchase_arriveqty,
// ["nplanastnum"] = 0,
["nplannum"] = item.purchase_qty,
["pk_apfinanceorg"] = erpOrg.corpoid,
["pk_apfinanceorg_v"] = erpOrg.corpvid,
["pk_arriveorder"] = null,
["pk_arriveorder_b"] = null,
["pk_group"] = erpOrg.pk_group,
["pk_material"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "",
["pk_order"] = wmsPurchaseOrderH?.erp_pk ?? "",
["pk_order_b"] = item.erp_purchase_order_d_pk,
["pk_org"] = erpOrg.pk_org,
["pk_org_v"] = erpOrg.pk_org_v,
["pk_psfinanceorg"] = erpOrg.corpoid,
["pk_psfinanceorg_v"] = erpOrg.corpvid,
// ["pk_receivestore"] = erpExtendFields.Find(x=>x.table_id==purchase.warehouse_id)?.cotherwhid ?? "",
// ["pk_receivestore"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == item.erp_wh_type)?.erp_warehouseid ?? "",
["pk_receivestore"] = item.erp_wh_type,
["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,
["Vfree1"] = item.code_batch,
["mes_detail_id"] = item.id,
["bpresent"] = item.gift==1,
["csourceid"] = wmsPurchaseOrderH?.erp_pk ?? "",
["vsourcecode"] = wmsPurchaseOrderH.erp_bill_code,
["csourcebid"] = item.erp_purchase_order_d_pk,
["IsType"] = 0,
["csourcetypecode"] = null,
["vsourcerowno"] = null,
["vsourcetrantype"] = null,
["cproductorid"] = item.production_unit,
});
}
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/purarrvial/save";
thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/purarrvial/save";
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData);
thirdWebapiRecord.create_time = DateTime.Now;
thirdWebapiRecord.remark = $"erp采购订单:{wmsPurchaseOrderH.erp_bill_code}";
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
BasFactoryConfig callErp = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.CALLERP);
if(callErp.value=="1"){
await _thirdApiRecordService.Send(new List<ThirdWebapiRecord> { thirdWebapiRecord }, "自动", _db);
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
BasFactoryConfig callErp = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.CALLERP);
if(callErp.value=="1"){
await _thirdApiRecordService.Send(new List<ThirdWebapiRecord> { thirdWebapiRecord }, "自动", _db);
}
}
}
//通知Mes接口
//_ = SyncMesData(instock.id, instockDs.Select(x => x.material_id).ToList(), EnumTriggerEvent.入厂检按物料编号);

View File

@@ -97,6 +97,12 @@ namespace Tnb.WarehouseMgr
string rawmatTransferinstockHId = wmsRawmatTransferinstockD?.bill_id ?? "";
WmsRawmatTransferinstockH wmsRawmatTransferinstockH = await _db.Queryable<WmsRawmatTransferinstockH>().SingleAsync(x => x.id == rawmatTransferinstockHId);
//自制的不调erp接口
if (string.IsNullOrEmpty(wmsRawmatTransferinstockH.erp_pk))
{
return;
}
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>()

View File

@@ -81,6 +81,12 @@ namespace Tnb.WarehouseMgr
string TransferInstockHId = wmsTransferInstockD?.bill_id ?? "";
WmsTransferInstockH wmsTransferInstockH = await _db.Queryable<WmsTransferInstockH>().SingleAsync(x => x.id == TransferInstockHId);
//自制的不调erp接口
if (string.IsNullOrEmpty(wmsTransferInstockH.erp_pk))
{
return;
}
List<WmsTransferInstockD> allInstockDetails = await _db.Queryable<WmsTransferInstockD>().Where(it => it.bill_id == TransferInstockHId).ToListAsync();
List<String> materialIds = allInstockDetails.Select(x => x.material_id).Distinct().ToList();