Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -16,6 +16,8 @@ using Tnb.ProductionMgr.Entities;
|
|||||||
using Tnb.ProductionMgr.Entities.Dto;
|
using Tnb.ProductionMgr.Entities.Dto;
|
||||||
using Tnb.ProductionMgr.Interfaces;
|
using Tnb.ProductionMgr.Interfaces;
|
||||||
using Tnb.WarehouseMgr.Entities;
|
using Tnb.WarehouseMgr.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||||
|
using Tnb.WarehouseMgr.Interfaces;
|
||||||
|
|
||||||
namespace Tnb.ProductionMgr
|
namespace Tnb.ProductionMgr
|
||||||
{
|
{
|
||||||
@@ -31,6 +33,7 @@ namespace Tnb.ProductionMgr
|
|||||||
private readonly IPrdMoTaskService _prdMoTaskService;
|
private readonly IPrdMoTaskService _prdMoTaskService;
|
||||||
private readonly IBillRullService _billRullService;
|
private readonly IBillRullService _billRullService;
|
||||||
private readonly IDictionaryDataService _dictionaryDataService;
|
private readonly IDictionaryDataService _dictionaryDataService;
|
||||||
|
private readonly IWmsCarryBindService _wmsCarryBindService;
|
||||||
// private readonly WmsSignForDeliveryService _wmsSignForDeliveryService;
|
// private readonly WmsSignForDeliveryService _wmsSignForDeliveryService;
|
||||||
|
|
||||||
|
|
||||||
@@ -41,6 +44,7 @@ namespace Tnb.ProductionMgr
|
|||||||
IPrdMoTaskService prdMoTaskService,
|
IPrdMoTaskService prdMoTaskService,
|
||||||
// WmsSignForDeliveryService wmsSignForDeliveryService,
|
// WmsSignForDeliveryService wmsSignForDeliveryService,
|
||||||
IDictionaryDataService dictionaryDataService,
|
IDictionaryDataService dictionaryDataService,
|
||||||
|
IWmsCarryBindService wmsCarryBindService,
|
||||||
IUserManager userManager
|
IUserManager userManager
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -50,6 +54,7 @@ namespace Tnb.ProductionMgr
|
|||||||
// _wmsSignForDeliveryService = _wmsSignForDeliveryService;
|
// _wmsSignForDeliveryService = _wmsSignForDeliveryService;
|
||||||
_dictionaryDataService = dictionaryDataService;
|
_dictionaryDataService = dictionaryDataService;
|
||||||
_billRullService = billRullService;
|
_billRullService = billRullService;
|
||||||
|
_wmsCarryBindService = wmsCarryBindService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -452,6 +457,10 @@ namespace Tnb.ProductionMgr
|
|||||||
|
|
||||||
_ = await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
_ = await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||||
_ = await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
_ = await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||||
|
_wmsCarryBindService.CarryCodeUnbind(new CarryCodeUnbindInput()
|
||||||
|
{
|
||||||
|
carry_id = carry.id
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ using Tnb.ProductionMgr.Entities.Dto;
|
|||||||
using Tnb.ProductionMgr.Interfaces;
|
using Tnb.ProductionMgr.Interfaces;
|
||||||
using Tnb.WarehouseMgr;
|
using Tnb.WarehouseMgr;
|
||||||
using Tnb.WarehouseMgr.Entities;
|
using Tnb.WarehouseMgr.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||||
using Tnb.WarehouseMgr.Entities.Dto;
|
using Tnb.WarehouseMgr.Entities.Dto;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||||
|
using Tnb.WarehouseMgr.Interfaces;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||||
|
|
||||||
namespace Tnb.ProductionMgr
|
namespace Tnb.ProductionMgr
|
||||||
{
|
{
|
||||||
@@ -28,19 +32,23 @@ namespace Tnb.ProductionMgr
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||||
[Route("api/[area]/[controller]/[action]")]
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
public class PrdMaterialReceiptService : IPrdMaterialReceiptService, IDynamicApiController, ITransient
|
[ServiceModule(BizTypeId)]
|
||||||
|
public class PrdMaterialReceiptService : BaseWareHouseService,IPrdMaterialReceiptService, IDynamicApiController, ITransient
|
||||||
{
|
{
|
||||||
|
private const string BizTypeId = "26786119531541";
|
||||||
private readonly ISqlSugarRepository<PrdMaterialReceiptH> _repository;
|
private readonly ISqlSugarRepository<PrdMaterialReceiptH> _repository;
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
private readonly IOrganizeService _organizeService;
|
private readonly IOrganizeService _organizeService;
|
||||||
private readonly IBillRullService _billRullService;
|
private readonly IBillRullService _billRullService;
|
||||||
private readonly IPrdMoTaskService _prdMoTaskService;
|
private readonly IPrdMoTaskService _prdMoTaskService;
|
||||||
|
private readonly IWmsCarryQueryService _wmsCarryQueryService;
|
||||||
|
|
||||||
public PrdMaterialReceiptService(
|
public PrdMaterialReceiptService(
|
||||||
ISqlSugarRepository<PrdMaterialReceiptH> repository,
|
ISqlSugarRepository<PrdMaterialReceiptH> repository,
|
||||||
IBillRullService billRullService,
|
IBillRullService billRullService,
|
||||||
IOrganizeService organizeService,
|
IOrganizeService organizeService,
|
||||||
IPrdMoTaskService prdMoTaskService,
|
IPrdMoTaskService prdMoTaskService,
|
||||||
|
IWmsCarryQueryService wmsCarryQueryService,
|
||||||
IUserManager userManager
|
IUserManager userManager
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -49,6 +57,7 @@ namespace Tnb.ProductionMgr
|
|||||||
_organizeService = organizeService;
|
_organizeService = organizeService;
|
||||||
_billRullService = billRullService;
|
_billRullService = billRullService;
|
||||||
_prdMoTaskService = prdMoTaskService;
|
_prdMoTaskService = prdMoTaskService;
|
||||||
|
_wmsCarryQueryService = wmsCarryQueryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -370,5 +379,93 @@ namespace Tnb.ProductionMgr
|
|||||||
? throw Oops.Bah(result.ErrorMessage)
|
? throw Oops.Bah(result.ErrorMessage)
|
||||||
: !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功";
|
: !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||||
|
{
|
||||||
|
if (input == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(input.requireId))
|
||||||
|
{
|
||||||
|
throw Oops.Bah("来源id为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
PrdMoTask moTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.requireId);
|
||||||
|
if (moTask == null)
|
||||||
|
{
|
||||||
|
throw Oops.Bah($"未找到来源id为{input.requireId}的生产任务单");
|
||||||
|
}
|
||||||
|
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE);
|
||||||
|
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(moTask.workstation_id, DictConst.RegionCategoryWorkshopCode);
|
||||||
|
List<PrdMaterialReceiptH> insertHList = new List<PrdMaterialReceiptH>();
|
||||||
|
List<PrdMaterialReceiptD> insertDList = new List<PrdMaterialReceiptD>();
|
||||||
|
string orgId = _userManager.GetUserInfo().Result.organizeId;
|
||||||
|
foreach(string carryId in input.carryIds)
|
||||||
|
{
|
||||||
|
WmsCarryH carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.id == carryId);
|
||||||
|
|
||||||
|
PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH()
|
||||||
|
{
|
||||||
|
code = code,
|
||||||
|
station_id = moTask.workstation_id,
|
||||||
|
mo_task_id = moTask.id,
|
||||||
|
process_id = moTask.process_id,
|
||||||
|
equip_id = moTask.eqp_id,
|
||||||
|
workshop_id = workshop?.Id ?? "",
|
||||||
|
carry_id = carry.id,
|
||||||
|
workline_id = moTask.workline_id,
|
||||||
|
carry_code = carry.carry_code,
|
||||||
|
mbom_process_id = moTask.mbom_process_id,
|
||||||
|
create_id = _userManager.UserId,
|
||||||
|
create_time = DateTime.Now,
|
||||||
|
org_id = orgId
|
||||||
|
};
|
||||||
|
insertHList.Add(prdMaterialReceiptH);
|
||||||
|
|
||||||
|
CarryQueryOutput carryQueryOutput = await _wmsCarryQueryService.MESCarryQueryResult(new MESCarryQueryResultInput(){carry_code = carry.carry_code});
|
||||||
|
if (carryQueryOutput.wmsCarryCodes != null && carryQueryOutput.wmsCarryCodes.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in carryQueryOutput.wmsCarryCodes)
|
||||||
|
{
|
||||||
|
|
||||||
|
insertDList.Add(new PrdMaterialReceiptD
|
||||||
|
{
|
||||||
|
material_receipt_id = prdMaterialReceiptH.id,
|
||||||
|
material_id = item.material_id,
|
||||||
|
num = item.codeqty,
|
||||||
|
batch = item.code_batch,
|
||||||
|
unit_id = item.unit_id,
|
||||||
|
carry_id = carry.id,
|
||||||
|
barcode = item.barcode,
|
||||||
|
is_all_feeding = 0,
|
||||||
|
member_carry_id = item.member_carryid,
|
||||||
|
member_carry_code = item.member_carrycode,
|
||||||
|
feeding_num = 0,
|
||||||
|
supplier_id = item.supplier_id,
|
||||||
|
instock_time = item.instock_time,
|
||||||
|
check_conclusion = item.check_conclusion,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw Oops.Bah("未找到物料明细");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
|
{
|
||||||
|
await db.Insertable(insertHList).ExecuteCommandAsync();
|
||||||
|
await db.Insertable(insertDList).ExecuteCommandAsync();
|
||||||
|
});
|
||||||
|
if (!result.IsSuccess)
|
||||||
|
{
|
||||||
|
throw Oops.Bah(result.ErrorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1952,6 +1952,55 @@ namespace Tnb.ProductionMgr
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
if (prdMoTask.schedule_type == 2)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> dicCommand2 = new(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
["DevName"] = dic[prdMoTask.workline_id],
|
||||||
|
["token"] = _eleCtlCfg.token,
|
||||||
|
["TagName"] = "WBZX_x1_ok",
|
||||||
|
["Value"] = "true",
|
||||||
|
};
|
||||||
|
Log.Information($"提拔确认完成参数:{JsonConvert.SerializeObject(dicCommand2)}");
|
||||||
|
string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2);
|
||||||
|
Log.Information($"提拔确认完成参数成返回结果:{responseresult}");
|
||||||
|
X2ServerResult x2ServerResult = JsonConvert.DeserializeObject<X2ServerResult>(responseresult);
|
||||||
|
if (x2ServerResult.Result != X2ServerResult.Ok)
|
||||||
|
{
|
||||||
|
throw Oops.Bah(x2ServerResult.Msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prdMoTask.schedule_type == 1)
|
||||||
|
{
|
||||||
|
EqpEquipment equipment = await _db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
|
||||||
|
EqpDaq eqpDaq3 = await _repository.AsSugarClient().Queryable<EqpDaq>().
|
||||||
|
LeftJoin<EqpEquipment>((x,y)=>x.equip_id==y.id).
|
||||||
|
Where((x,y) => y.code == equipment.code && x.label_name.Contains("称重完成")).FirstAsync();
|
||||||
|
|
||||||
|
if (eqpDaq3 == null)
|
||||||
|
{
|
||||||
|
throw Oops.Bah("未在数据采集中设置称重完成标签点");
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> dicCommand3 = new(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
["DevName"] = eqpDaq3.equip_code,
|
||||||
|
["token"] = _eleCtlCfg.token,
|
||||||
|
["TagName"] = eqpDaq3.label_name,
|
||||||
|
["Value"] = "true",
|
||||||
|
};
|
||||||
|
Log.Information($"称重完成参数:{JsonConvert.SerializeObject(dicCommand3)}");
|
||||||
|
string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand3,false);
|
||||||
|
Log.Information($"{eqpDaq3.equip_code},{eqpDaq3.label_name}称重完成返回结果:{responseresult}");
|
||||||
|
X2ServerResult x2ServerResult = JsonConvert.DeserializeObject<X2ServerResult>(responseresult);
|
||||||
|
if (x2ServerResult.Result != X2ServerResult.Ok)
|
||||||
|
{
|
||||||
|
throw Oops.Bah(x2ServerResult.Msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Dictionary<string, object> header = new()
|
// Dictionary<string, object> header = new()
|
||||||
// {
|
// {
|
||||||
// ["Authorization"] = App.HttpContext != null ? App.HttpContext.Request.Headers["Authorization"] : ""
|
// ["Authorization"] = App.HttpContext != null ? App.HttpContext.Request.Headers["Authorization"] : ""
|
||||||
@@ -2029,54 +2078,6 @@ namespace Tnb.ProductionMgr
|
|||||||
throw Oops.Bah(result2.msg !=null ? result2.msg : "生产入库接口报错");
|
throw Oops.Bah(result2.msg !=null ? result2.msg : "生产入库接口报错");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prdMoTask.schedule_type == 2)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> dicCommand2 = new(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
["DevName"] = dic[prdMoTask.workline_id],
|
|
||||||
["token"] = _eleCtlCfg.token,
|
|
||||||
["TagName"] = "WBZX_x1_ok",
|
|
||||||
["Value"] = "true",
|
|
||||||
};
|
|
||||||
Log.Information($"提拔确认完成参数:{JsonConvert.SerializeObject(dicCommand2)}");
|
|
||||||
string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2);
|
|
||||||
Log.Information($"提拔确认完成参数成返回结果:{responseresult}");
|
|
||||||
X2ServerResult x2ServerResult = JsonConvert.DeserializeObject<X2ServerResult>(responseresult);
|
|
||||||
if (x2ServerResult.Result != "OK")
|
|
||||||
{
|
|
||||||
throw Oops.Bah(x2ServerResult.Msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prdMoTask.schedule_type == 1)
|
|
||||||
{
|
|
||||||
EqpEquipment equipment = await _db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
|
|
||||||
EqpDaq eqpDaq3 = await _repository.AsSugarClient().Queryable<EqpDaq>().
|
|
||||||
LeftJoin<EqpEquipment>((x,y)=>x.equip_id==y.id).
|
|
||||||
Where((x,y) => y.code == equipment.code && x.label_name.Contains("称重完成")).FirstAsync();
|
|
||||||
|
|
||||||
if (eqpDaq3 == null)
|
|
||||||
{
|
|
||||||
throw Oops.Bah("未在数据采集中设置称重完成标签点");
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary<string, string> dicCommand3 = new(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
["DevName"] = eqpDaq3.equip_code,
|
|
||||||
["token"] = _eleCtlCfg.token,
|
|
||||||
["TagName"] = eqpDaq3.label_name,
|
|
||||||
["Value"] = "true",
|
|
||||||
};
|
|
||||||
Log.Information($"称重完成参数:{JsonConvert.SerializeObject(dicCommand3)}");
|
|
||||||
string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand3,false);
|
|
||||||
Log.Information($"{eqpDaq3.equip_code},{eqpDaq3.label_name}称重完成返回结果:{responseresult}");
|
|
||||||
X2ServerResult x2ServerResult = JsonConvert.DeserializeObject<X2ServerResult>(responseresult);
|
|
||||||
if (x2ServerResult.Result != "OK")
|
|
||||||
{
|
|
||||||
throw Oops.Bah(x2ServerResult.Msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
await _db.Ado.CommitTranAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,12 @@ namespace Tnb.Common.Utils
|
|||||||
public string Content { get; set; }
|
public string Content { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class X2ServerResult : Exception
|
|
||||||
|
|
||||||
|
public class X2ServerResult
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public const string Ok = "Ok";
|
||||||
public string Result { get; set; }
|
public string Result { get; set; }
|
||||||
|
|
||||||
public string Msg { get; set; }
|
public string Msg { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user