This commit is contained in:
2024-07-19 08:50:02 +08:00
parent 9326b55a8e
commit 6e3bda642a
7 changed files with 255 additions and 35 deletions

View File

@@ -23,17 +23,6 @@ namespace Tnb.ProductionMgr.Entities.Entity
/// </summary>
public string org_id { get; set; }
/// <summary>
/// erp表体行号
/// </summary>
public int erp_lineno { get; set; }
/// <summary>
/// 工单pk值
/// </summary>
public string erp_mo_pk { get; set; }
/// <summary>
/// 表体pk值
/// </summary>
public string erp_line_pk { get; set; }
/// <summary>
/// 用户id

View File

@@ -246,16 +246,11 @@ public partial class PrdMo : BaseEntity<string>
/// <summary>
/// erp表体行号
/// </summary>
[SugarColumn(IsIgnore = true)]
public int erp_lineno { get; set; }
/// <summary>
/// 工单pk值
/// </summary>
[SugarColumn(IsIgnore = true)]
public string erp_mo_pk { get; set; }
/// <summary>
/// 表体pk值
/// </summary>
[SugarColumn(IsIgnore = true)]
public string erp_line_pk { get; set; }
}

View File

@@ -96,27 +96,18 @@ namespace Tnb.ProductionMgr
item.id = SnowflakeIdHelper.NextId();
item.mo_source = "1";
item.mo_type = moTypeDic[item.mo_type];
item.mo_code = item.mo_code+"-"+item.erp_lineno;
item.mo_code = item.mo_code;
item.create_id = WmsWareHouseConst.AdministratorUserId;
item.create_time = DateTime.Now;
item.mo_status = DictConst.ToBeScheduledId;
item.erp_mo_pk = item.erp_mo_pk;
item.erp_lineno = item.erp_lineno;
moList.Add(item);
extendFieldList.Add(new ErpExtendField()
{
org_id =WmsWareHouseConst.AdministratorOrgId,
table_name = "prd_mo",
table_id = item.id,
erp_lineno = item.erp_lineno,
erp_line_pk = item.erp_line_pk,
erp_mo_pk = item.erp_mo_pk,
create_time = DateTime.Now
});
}
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
{
await _db.Insertable(moList).ExecuteCommandAsync();
await _db.Insertable(extendFieldList).ExecuteCommandAsync();
});
return !result.IsSuccess ? result.ErrorMessage : "保存成功";

View File

@@ -47,6 +47,7 @@ using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Interfaces;
using Tnb.WarehouseMgr;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.ProductionMgr.Entities.Entity;
// using Tnb.PerMgr.Entities;
@@ -2110,6 +2111,116 @@ namespace Tnb.ProductionMgr
throw Oops.Bah(result2.msg !=null ? result2.msg : "生产入库接口报错");
}
List<string> erpExtendIds = new List<string>();
erpExtendIds.Add(_userManager.UserId);
erpExtendIds.Add(WmsWareHouseConst.AdministratorOrgId);
erpExtendIds.Add(report.material_id);
erpExtendIds.Add(report.unit_id);
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x=>erpExtendIds.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");
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
erpRequestData.Add("auditer",erpCreateId);
erpRequestData.Add("billmaker",erpCreateId);
erpRequestData.Add("cdeptid","");
erpRequestData.Add("cdeptvid","");
erpRequestData.Add("creationtime",nowStr);
erpRequestData.Add("creator",erpCreateId);
erpRequestData.Add("cshiftid","");
erpRequestData.Add("cteamid","");
erpRequestData.Add("cwkid","");
erpRequestData.Add("cworkmanid",erpCreateId);
erpRequestData.Add("dbilldate",nowStr);
erpRequestData.Add("dmakedate",nowStr);
erpRequestData.Add("fbillstatus",1);
erpRequestData.Add("fprodmode",1);
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_wr","");
erpRequestData.Add("vbillcode","");
erpRequestData.Add("vnote","");
erpRequestData.Add("vtrantypecode","55A4-01");
erpRequestData.Add("vtrantypeid","0001A11000000002LVX8");
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
erpRequestDataDetails.Add(new Dictionary<string, object>()
{
["bbchkflag"] = "N",
["bbhasbckfled"] = "N",
["bbhaspicked"] = "N",
["bbinstock"] = "N",
["bbisempass"] = "N",
["bbotherreject"] = "N",
["bbsetmark"] = "N",
["bbstockbycheck"] = "N",
["cbastunitid"] = "",
["cbbomversionid"] = "",
["cbdeptid"] = "",
["cbdeptvid"] = "",
["cbfirstmobid"] = "",
["cbfirstmoid"] = "",
["cbmainbomid"] = "",
["cbmainmaterialid"] = erpExtendFields.Find(x=>x.table_id==report.material_id)?.cmaterialoid ?? "",
["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,
["cbmoid"] = prdMo.erp_mo_pk,
["cbsrctranstype"] = "",
["cbsrctype"] = "",
["cbunitid"] = erpExtendFields.Find(x=>x.table_id==report.unit_id)?.cunitid ?? "",
["cbworkmanid"] = erpCreateId,
["fbproducttype"] = 1,
["fbsourcetype"] = 2,
// ["nbplanwrastnum"] = "",
["nbplanwrnum"] = report.reported_qty,
["nbwrnum"] = report.reported_qty,
["pk_wr"] = "",
["pk_wr_product"] = "",
["pseudocolumn"] = 10,
["tbendtime"] = "",
["tbstarttime"] = "",
["vbbatchcode"] = report.batch,
["vbbatchid"] = "",
["vbchangerate"] = "",
["vbfirstcode"] = "",
["vbfirstid"] = "",
["vbfirstmocode"] = "",
["vbfirstmorowno"] = "",
["vbfirsttype"] = "",
["vbidentify"] = "",
["vbinbatchcode"] = report.batch,
["vbinbatchid"] = "",
["vbmainbomcode"] = "",
["vbmainidentify"] = "",
["vbmainmorowno"] = "",
["vbmobillcode"] = prdMo.mo_code,
["vbrowno"] = prdMo.erp_lineno,
["vbsrccode"] = "",
["vbsrcid"] = "",
["vbsrcrowid"] = "",
["vbsrcrowno"] = "",
["vbsrctranstype"] = "",
["vbdef2"] = 10,
});
erpRequestData.Add("AggWrDtl",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/pwrnew/save";
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData);
thirdWebapiRecord.create_time = DateTime.Now;
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
if (prdMoTask.schedule_type == 2)
{

View File

@@ -113,6 +113,8 @@ namespace Tnb.ProductionMgr
bool? cs01 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS01");
bool? cs03 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS03");
bool? cs06 = await _redisData.TryGetValueByKeyField<bool?>("YTCS", "CallCtuEmptyIn_CS06");
bool? wbzxx1 = await _redisData.TryGetValueByKeyField<bool?>("外包装箱码垛线", "WBZX_x1_AGV_fan");
bool? wbzxx2 = await _redisData.TryGetValueByKeyField<bool?>("外包装箱码垛线", "WBZX_x2_AGV_fan");
// bool cs01Flag = _redisData.Get<bool>("YTCS_CallCtuEmptyIn_CS01_flag");
// bool cs03Flag = _redisData.Get<bool>("YTCS_CallCtuEmptyIn_CS03_flag");
// bool cs06Flag = _redisData.Get<bool>("YTCS_CallCtuEmptyIn_CS06_flag");
@@ -120,6 +122,8 @@ namespace Tnb.ProductionMgr
bool cs01Flag = await _db.Queryable<WmsPretaskH>().AnyAsync(x => x.endlocation_code == "SSX-021-001" && statusList.Contains(x.status) );
bool cs03Flag = await _db.Queryable<WmsPretaskH>().AnyAsync(x => x.endlocation_code == "SSX-021-003" && statusList.Contains(x.status) );
bool cs06Flag = await _db.Queryable<WmsPretaskH>().AnyAsync(x => x.endlocation_code == "SSX-011-006" && statusList.Contains(x.status) );
bool wbzxx1Flag = await _db.Queryable<WmsPretaskH>().AnyAsync(x => x.endlocation_code == "ZZ-01-01" && statusList.Contains(x.status) );
bool wbzxx2Flag = await _db.Queryable<WmsPretaskH>().AnyAsync(x => x.endlocation_code == "ZZ-02-01" && statusList.Contains(x.status) );
if (cs01Flag)
{
@@ -133,6 +137,14 @@ namespace Tnb.ProductionMgr
{
Log.Information($"【EmptyCarryOutStk】ctu6空箱入呼叫存在未完成的预任务,跳过此次自动呼叫");
}
if (wbzxx1Flag)
{
Log.Information($"【EmptyCarryOutStk】外包装x1空托盘呼叫存在未完成的预任务,跳过此次自动呼叫");
}
if (wbzxx2Flag)
{
Log.Information($"【EmptyCarryOutStk】外包装x2空托盘呼叫存在未完成的预任务,跳过此次自动呼叫");
}
if (cs01==true && !cs01Flag)
{
@@ -160,6 +172,24 @@ namespace Tnb.ProductionMgr
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(response);
result += authResponse.data.ToString();
}
if (wbzxx1==true && !wbzxx1Flag)
{
BasFactoryConfig config = await _repository.AsSugarClient().Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN);
string response = HttpUtils.RequestGet($"{config.value}/api/production/time-work/empty-carry-out-stk-wbzx1");
// string response = HttpUtils.RequestGet($"http://localhost:9232/api/production/time-work/empty-carry-out-stk-right");
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(response);
result += authResponse.data.ToString();
}
if (wbzxx2==true && !wbzxx2Flag)
{
BasFactoryConfig config = await _repository.AsSugarClient().Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN);
string response = HttpUtils.RequestGet($"{config.value}/api/production/time-work/empty-carry-out-stk-wbzx2");
// string response = HttpUtils.RequestGet($"http://localhost:9232/api/production/time-work/empty-carry-out-stk-right");
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(response);
result += authResponse.data.ToString();
}
return result;
}
@@ -250,6 +280,62 @@ namespace Tnb.ProductionMgr
}
return msg;
}
[HttpGet]
[AllowAnonymous]
public async Task<string> EmptyCarryOutStkWbzx1()
{
string msg = "";
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
input.org_id = WmsWareHouseConst.AdministratorOrgId;
input.location_code = "ZZ-01-01";
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_F2KTQ_ID;
input.carrystd_id = WmsWareHouseConst.CARRY_TP_ID;
input.qty = 1;
input.create_id = WmsWareHouseConst.AdministratorUserId;
Log.Information($"【EmptyCarryOutStk】外包装x1空托盘呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);
if (result.code == HttpStatusCode.OK)
{
msg = "外包装x1空托盘呼叫成功";
Log.Information("【EmptyCarryOutStk】外包装x1空托盘呼叫成功");
//_redisData.Set("YTCS_CallCtuEmptyIn_CS06_flag", true, TimeSpan.FromMinutes(20));
}
else
{
msg = $"外包装x1空托盘呼叫失败:{result.msg}";
Log.Error($"【EmptyCarryOutStk】外包装x1空托盘呼叫失败:{result.msg}");
}
return msg;
}
[HttpGet]
[AllowAnonymous]
public async Task<string> EmptyCarryOutStkWbzx2()
{
string msg = "";
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
input.org_id = WmsWareHouseConst.AdministratorOrgId;
input.location_code = "ZZ-02-01";
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_F2KTQ_ID;
input.carrystd_id = WmsWareHouseConst.CARRY_TP_ID;
input.qty = 1;
input.create_id = WmsWareHouseConst.AdministratorUserId;
Log.Information($"【EmptyCarryOutStk】外包装x2空托盘呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);
if (result.code == HttpStatusCode.OK)
{
msg = "外包装x2空托盘呼叫成功";
Log.Information("【EmptyCarryOutStk】外包装x2空托盘呼叫成功");
//_redisData.Set("YTCS_CallCtuEmptyIn_CS06_flag", true, TimeSpan.FromMinutes(20));
}
else
{
msg = $"外包装x2空托盘呼叫失败:{result.msg}";
Log.Error($"【EmptyCarryOutStk】外包装x2空托盘呼叫失败:{result.msg}");
}
return msg;
}
// [HttpGet]
// [AllowAnonymous]
@@ -377,10 +463,15 @@ namespace Tnb.ProductionMgr
// return msg;
// }
/// <summary>
/// 定点配送
/// </summary>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<string> FixedPointDelivery()
{
string state = await _redisData.TryGetValueByKeyField<string>("YTCS", "State");
if ("OK" != state)
{
@@ -468,6 +559,16 @@ namespace Tnb.ProductionMgr
{
startLocationCode = "ZSSSXCTU01ZSSSXCTU02".Replace(last_fixed_point_delivery, "");
}
if (startLocationCode == "ZSSSXCTU01")
{
cs01Count--;
}
if (startLocationCode == "ZSSSXCTU02")
{
cs03Count--;
}
}
else
{
@@ -517,7 +618,7 @@ namespace Tnb.ProductionMgr
return msg;
}
/// <summary>
/// 自动提报
/// </summary>
@@ -674,22 +775,41 @@ namespace Tnb.ProductionMgr
{
var mysqlDb = _db.AsTenant().GetConnection("erpdb");
List<ErpBdMaterial> list = await mysqlDb.Queryable<ErpBdMaterial>().ToListAsync();
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().ToListAsync();
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x=>x.table_name=="base_dictionarydata").ToListAsync();
Dictionary<string,object> unitDic = await _db.Queryable<DictionaryDataEntity>().Where(x=>x.DictionaryTypeId==WmsWareHouseConst.UNITTYPEID).ToDictionaryAsync(x=>x.Id,y=>y.EnCode);
List<BasMaterial> materials = await _db.Queryable<BasMaterial>().ToListAsync();
List<BasMaterial> insertMaterial = new List<BasMaterial>();
List<BasMaterialUnit> insertMaterialUnits = new List<BasMaterialUnit>();
List<ErpExtendField> insertExtendFields = new List<ErpExtendField>();
foreach (ErpBdMaterial erpBdMaterial in list)
{
if (erpExtendFields.All(x => x.cmaterialoid != erpBdMaterial.ID))
{
insertMaterial.Add(new BasMaterial()
string unitId = erpExtendFields.Find(x => x.cunitid == erpBdMaterial.PK_MEASDOC)?.table_id ?? "";
unitId = unitDic.ContainsKey(unitId) ? unitDic[unitId].ToString() : "";
string auxiliaryUnitId = erpExtendFields.Find(x => x.cunitid == erpBdMaterial.FMEASDOC)?.table_id ?? "";
auxiliaryUnitId = unitDic.ContainsKey(auxiliaryUnitId) ? unitDic[auxiliaryUnitId].ToString() : "";
BasMaterial basMaterial = new BasMaterial()
{
id = SnowflakeIdHelper.NextId(),
name = erpBdMaterial.NAME,
code = erpBdMaterial.CODE,
org_id = WmsWareHouseConst.AdministratorOrgId,
material_specification = erpBdMaterial.MATERIALSPEC,
material_standard = erpBdMaterial.MATERIALTYPE
material_standard = erpBdMaterial.MATERIALTYPE,
category_id = "[\"CGJCJ\"]",
unit_id = unitId,
};
insertMaterial.Add(basMaterial);
string[] unitArr = erpBdMaterial.MEASRATE.Split("/");
insertMaterialUnits.Add(new BasMaterialUnit()
{
id = SnowflakeIdHelper.NextId(),
material_id = basMaterial.id,
number_of_primary_unit = unitArr[0],
number_of_auxiliary_unit = unitArr[1],
auxiliary_unit_id = auxiliaryUnitId
});
}
}
@@ -744,6 +864,7 @@ namespace Tnb.ProductionMgr
await _db.Insertable(insertUnit).ExecuteCommandAsync();
await _db.Insertable(insertExtendFields).ExecuteCommandAsync();
});
return result.IsSuccess ? "成功" : result.ErrorMessage;
}
return "true";

View File

@@ -59,6 +59,10 @@
/// 二楼包材区
/// </summary>
public const string WAREHOUSE_F2BCQ_ID = "35434198944789";
/// <summary>
/// 二楼空托区
/// </summary>
public const string WAREHOUSE_F2KTQ_ID = "35434202453013";
/// <summary>
@@ -328,7 +332,11 @@
/// <summary>
/// 载具规格-料箱
/// </summary>
public const string CARRY_LXSTD_ID = "26037262680357";
public const string CARRY_LXSTD_ID = "26037262680357";
/// <summary>
/// 载具规格-托盘
/// </summary>
public const string CARRY_TP_ID = "26032423715365";
/// <summary>
/// 载具规格-载运小车
/// </summary>

View File

@@ -145,5 +145,10 @@ public partial class WmsPurchaseH : BaseEntity<string>, IPurchaseAndSaleAuitEnti
/// </summary>
public int? audit_status { get; set; }
/// <summary>
/// erp_bill_code
/// </summary>
public string? erp_bill_code { get; set; }
}