Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -26,7 +26,7 @@ namespace Tnb.BasicData
|
||||
[OverideVisualDev(ModelId)]
|
||||
public class BasMbomService : IBasMbomService, IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
public const string ModelId = "25574817510421";
|
||||
public const string ModelId = "27204627275029";
|
||||
private readonly ISqlSugarRepository<BasMbom> _repository;
|
||||
private readonly DataBaseManager _dbManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto
|
||||
{
|
||||
public class MaterialReceiptNewInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 工位id
|
||||
/// </summary>
|
||||
public string station_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 任务单id
|
||||
/// </summary>
|
||||
public string? mo_task_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string? equip_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 二维码信息
|
||||
/// </summary>
|
||||
public string? carry_code { get; set; }
|
||||
|
||||
public List<Dictionary<string,string>>? details { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int icmo_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工位
|
||||
/// </summary>
|
||||
public string? station { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,5 +78,39 @@ public partial class PrdReport : BaseEntity<string>
|
||||
/// 生产任务量
|
||||
/// </summary>
|
||||
public int? icmo_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 批次
|
||||
/// </summary>
|
||||
public string? batch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string? equip_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工位id
|
||||
/// </summary>
|
||||
public string? station { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产bom工序id
|
||||
/// </summary>
|
||||
public string? mbom_process_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态 0 未入库 1 已入库
|
||||
/// </summary>
|
||||
public int status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料id
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料单位
|
||||
/// </summary>
|
||||
public string? unit_id { get; set; }
|
||||
}
|
||||
|
||||
@@ -14,5 +14,12 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> SaveData(MaterialReceiptInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 保存数据
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> SaveDataNew(MaterialReceiptNewInput input);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.ClearScript.Util.Web;
|
||||
@@ -13,6 +14,8 @@ using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -26,16 +29,20 @@ namespace Tnb.ProductionMgr
|
||||
private readonly ISqlSugarRepository<PrdFeedingH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRullService;
|
||||
private readonly WmsSignForDeliveryService _wmsSignForDeliveryService;
|
||||
|
||||
|
||||
|
||||
public PrdFeedingService(
|
||||
ISqlSugarRepository<PrdFeedingH> repository,
|
||||
IBillRullService billRullService,
|
||||
WmsSignForDeliveryService wmsSignForDeliveryService,
|
||||
IUserManager userManager
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_wmsSignForDeliveryService = _wmsSignForDeliveryService;
|
||||
_billRullService = billRullService;
|
||||
}
|
||||
|
||||
@@ -132,6 +139,131 @@ namespace Tnb.ProductionMgr
|
||||
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
//签收后调用载具签收接口
|
||||
await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = input.carry_code ?? "",
|
||||
});
|
||||
}
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||
return result.IsSuccess ? "签收成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveDataNew(MaterialReceiptNewInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
var parentMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == moTask.parent_id);
|
||||
var carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.carry_code == input.carry_code);
|
||||
var workline = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == parentMoTask.workline_id);
|
||||
var workshop = await db.Queryable<OrganizeEntity>().SingleAsync(x=>x.Id==workline.ParentId);
|
||||
var inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
.Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == moTask.mbom_process_id)
|
||||
.Select(x=>x.material_id)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
|
||||
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
|
||||
PrdFeedingH prdFeedingH = new PrdFeedingH()
|
||||
{
|
||||
code = code,
|
||||
station_id = input.station_id,
|
||||
mo_task_id = input.mo_task_id,
|
||||
process_id = moTask.process_id,
|
||||
equip_id = input.equip_id,
|
||||
workshop_id = workshop?.Id,
|
||||
carry_id = carry.id,
|
||||
workline_id = moTask.workline_id,
|
||||
carry_code = input.carry_code,
|
||||
// remark = input.remark,
|
||||
mbom_process_id = moTask.mbom_process_id,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||
};
|
||||
|
||||
List<PrdFeedingD> list = new List<PrdFeedingD>();
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (var item in input.details)
|
||||
{
|
||||
if(!inputMaterials.Contains(item["material_id"]))
|
||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
|
||||
var detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.Where(x => x.carry_id == carry.id && x.is_all_feeding == 0).FirstAsync();
|
||||
decimal num = Convert.ToDecimal(item["num"]);
|
||||
list.Add(new PrdFeedingD
|
||||
{
|
||||
feeding_id = prdFeedingH.id,
|
||||
material_receipt_detail_id = detail?.id,
|
||||
material_id = item["material_id"],
|
||||
num = num,
|
||||
batch = item["batch"],
|
||||
unit_id = item["unit_id"],
|
||||
carry_id = carry.id,
|
||||
status = "0",
|
||||
use_num = 0,
|
||||
});
|
||||
|
||||
if (detail != null)
|
||||
{
|
||||
if(detail.feeding_num + num > detail.num)
|
||||
{
|
||||
throw new Exception("投料数量不能大于签收数量");
|
||||
}else if (detail.feeding_num + num == detail.num)
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("没有签收单,无法投料");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("没有签收物料");
|
||||
}
|
||||
|
||||
|
||||
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
//签收后调用载具签收接口
|
||||
await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = input.carry_code ?? "",
|
||||
});
|
||||
}
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||
return result.IsSuccess ? "签收成功" : result.ErrorMessage;
|
||||
|
||||
@@ -11,7 +11,7 @@ using Tnb.ProductionMgr.Interfaces;
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// mes入库申请
|
||||
/// mes生产入库申请
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
eqp_id = b.id,
|
||||
eqp_code = b.code,
|
||||
eqp_type_code = SqlFunc.Subqueryable<EqpEquipType>().Where(iit => iit.id == b.equip_type_id).Select(iit => iit.code),
|
||||
eqp_type_code = SqlFunc.Subqueryable<EqpEquipType>().Where(iit => iit.id == b.equip_type_id).Select(iit => iit.name),
|
||||
eqp_machine_num = b.eqp_machine_num,
|
||||
tonnage = b.tonnage,
|
||||
task_list_qty = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == b.id).Count(),
|
||||
@@ -1254,16 +1254,24 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
var row = -1;
|
||||
var report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
var prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
||||
|
||||
report = input.Adapt<PrdReport>();
|
||||
report.id = SnowflakeIdHelper.NextId();
|
||||
report.reported_qty = input.reported_qty;
|
||||
report.create_id = _userManager.UserId;
|
||||
report.create_time = DateTime.Now;
|
||||
|
||||
report.batch = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
|
||||
report.equip_id = prdMoTask.eqp_id;
|
||||
report.mbom_process_id = prdMoTask.mbom_process_id;
|
||||
report.station = input.station;
|
||||
report.status = 0;
|
||||
report.material_id = prdMoTask.material_id;
|
||||
report.unit_id = prdMoTask.unit_id;
|
||||
|
||||
row = await db.Insertable(report).ExecuteCommandAsync();
|
||||
|
||||
var prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
||||
|
||||
if (prdMoTask.reported_work_qty == null)
|
||||
{
|
||||
await db.Updateable<PrdMoTask>()
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<ProjectReference Include="..\..\taskschedule\Tnb.TaskScheduler\Tnb.TaskScheduler.csproj" />
|
||||
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
|
||||
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr.Entities\Tnb.WarehouseMgr.Entities.csproj" />
|
||||
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr\Tnb.WarehouseMgr.csproj" />
|
||||
<ProjectReference Include="..\Tnb.ProductionMgr.Interfaces\Tnb.ProductionMgr.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -24,33 +24,34 @@ namespace Tnb.TaskScheduler.Listener
|
||||
/// </summary>
|
||||
public class QcTaskTimeWorker : ISpareTimeWorker
|
||||
{
|
||||
private ISqlSugarRepository<QcCheckPlanH> repository => App.GetService<ISqlSugarRepository<QcCheckPlanH>>();
|
||||
private ISqlSugarClient repository => App.GetService<ISqlSugarClient>();
|
||||
|
||||
[SpareTime("0 0 0 * * ?", "生成质检任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
|
||||
public async void CreateTask(SpareTimer timer, long count)
|
||||
{
|
||||
var timeTaskEntity = await repository.AsSugarClient().Queryable<TimeTaskEntity>().Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstAsync();
|
||||
var timeTaskEntity = await repository.Queryable<TimeTaskEntity>().Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstAsync();
|
||||
if (timeTaskEntity == null)
|
||||
return;
|
||||
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();
|
||||
var PlanH = await repository.AsQueryable().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
|
||||
var PlanDs = await repository.AsSugarClient().Queryable<QcCheckPlanD>().Where(p => p.mainid == timeTaskEntity.Description).ToListAsync();
|
||||
var PlanH = await repository.Queryable<QcCheckPlanH>().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
|
||||
var PlanDs = await repository.Queryable<QcCheckPlanD>().Where(p => p.mainid == PlanH.id).ToListAsync();
|
||||
if (PlanH == null || PlanDs.Count == 0)
|
||||
return;
|
||||
var PlanMaterials = repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == PlanH.id).Select(p => p.materialid).ToList();
|
||||
var PlanProcesss = repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == PlanH.id).Select(p => p.processid).ToList();
|
||||
var PlanWork = repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == PlanH.id).Select(p => p.workid).ToList();
|
||||
var PlanMaterials = repository.Queryable<QcCheckPlanMaterial>().Where(p => p.planid == PlanH.id).Select(p => p.materialid).ToList();
|
||||
var PlanProcesss = repository.Queryable<QcCheckPlanProcess>().Where(p => p.planid == PlanH.id).Select(p => p.processid).ToList();
|
||||
var PlanWork = repository.Queryable<QcCheckPlanWork>().Where(p => p.planid == PlanH.id).Select(p => p.workid).ToList();
|
||||
//物料工序工位不能同时为空
|
||||
if (PlanMaterials.Count == 0 && PlanProcesss.Count == 0 && PlanWork.Count == 0)
|
||||
return;
|
||||
var PrdMoTasks = await repository.AsSugarClient().Queryable<PrdMoTask>()
|
||||
var PrdMoTasks = await repository.Queryable<PrdMoTask>()
|
||||
.WhereIF(PlanMaterials.Count > 0, p => PlanMaterials.Contains(p.material_id))
|
||||
.WhereIF(PlanProcesss.Count > 0, p => PlanProcesss.Contains(p.process_id))
|
||||
.WhereIF(PlanWork.Count > 0, p => PlanWork.Contains(p.workstation_id))
|
||||
.Where(p => p.mo_task_status == "InProgress")//进行中
|
||||
.ToListAsync();
|
||||
|
||||
var DictionaryType = await repository.AsSugarClient().Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
|
||||
var DictionaryData = await repository.AsSugarClient().Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
|
||||
var DictionaryType = await repository.Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
|
||||
var DictionaryData = await repository.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
|
||||
foreach (var PrdMoTask in PrdMoTasks)
|
||||
{
|
||||
QcCheckExecH qcCheckExecH = new QcCheckExecH();
|
||||
@@ -79,15 +80,15 @@ namespace Tnb.TaskScheduler.Listener
|
||||
QcCheckExecD.itemid = PlanD.itemid;
|
||||
ExecDs.Add(QcCheckExecD);
|
||||
}
|
||||
await repository.AsSugarClient().Insertable(qcCheckExecH).ExecuteCommandAsync();
|
||||
await repository.AsSugarClient().Insertable(ExecDs).ExecuteCommandAsync();
|
||||
await repository.Insertable(qcCheckExecH).ExecuteCommandAsync();
|
||||
await repository.Insertable(ExecDs).ExecuteCommandAsync();
|
||||
}
|
||||
//只执行一次的 修改EnabledMark字段
|
||||
var InterfaceParameter = comtentModel.parameter.Where(p => p.field == "doonce").FirstOrDefault();
|
||||
if (InterfaceParameter != null && bool.Parse(InterfaceParameter.value))
|
||||
{
|
||||
timeTaskEntity.EnabledMark = 0;
|
||||
await repository.AsSugarClient().Updateable(timeTaskEntity).ExecuteCommandAsync();
|
||||
await repository.Updateable(timeTaskEntity).ExecuteCommandAsync();
|
||||
SpareTime.Cancel(timeTaskEntity.Id);
|
||||
}
|
||||
|
||||
|
||||
@@ -230,9 +230,8 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
|
||||
var entitys = await _repository.AsQueryable().Where(p=>p.FullName==fullName).ToListAsync();
|
||||
foreach (var entity in entitys)
|
||||
{
|
||||
var isOk = await _repository.AsUpdateable(entity).CallEntityMethod(m => m.Delete()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId }).ExecuteCommandHasChangeAsync();
|
||||
if (!isOk)
|
||||
throw Oops.Oh(ErrorCode.COM1002);
|
||||
await _repository.AsSugarClient().Deleteable(entity).ExecuteCommandAsync();
|
||||
|
||||
// 从调度器里取消
|
||||
SpareTime.Cancel(entity.Id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user