erp生产工单同步接口
This commit is contained in:
@@ -45,6 +45,11 @@ namespace Tnb.BasicData
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string PRDINSTOCK_CODE = "PrdInStock";
|
public const string PRDINSTOCK_CODE = "PrdInStock";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生产工单
|
||||||
|
/// </summary>
|
||||||
|
public const string PROMO_CODE = "ProMoCode";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,6 +70,10 @@ public static class DictConst
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string AlreadyId = "26033187948309";
|
public const string AlreadyId = "26033187948309";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 工单状态-待下发Id
|
||||||
|
/// </summary>
|
||||||
|
public const string ToBeScheduledId = "25019228116501";
|
||||||
|
/// <summary>
|
||||||
/// 工单状态-已下发Id
|
/// 工单状态-已下发Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ScheduledId = "25019232867093";
|
public const string ScheduledId = "25019232867093";
|
||||||
|
|||||||
80
ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs
Normal file
80
ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Extension;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using JNPF.DependencyInjection;
|
||||||
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.Message.Service;
|
||||||
|
using JNPF.Systems.Interfaces.System;
|
||||||
|
using JNPF.TaskScheduler;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData;
|
||||||
|
using Tnb.BasicData.Entities;
|
||||||
|
using Tnb.ProductionMgr.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr
|
||||||
|
{
|
||||||
|
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||||
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
|
public class MesForErpService: IDynamicApiController, ITransient
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarClient _db;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IBillRullService _billRuleService;
|
||||||
|
|
||||||
|
public MesForErpService(ISqlSugarRepository<PrdMo> repository,
|
||||||
|
IBillRullService billRuleService,
|
||||||
|
IUserManager userManager)
|
||||||
|
{
|
||||||
|
_userManager = userManager;
|
||||||
|
_billRuleService = billRuleService;
|
||||||
|
_db = repository.AsSugarClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<string> SavePrdMo(PrdMo input)
|
||||||
|
{
|
||||||
|
if (input == null)
|
||||||
|
throw Oops.Bah("参数不能为空");
|
||||||
|
if(string.IsNullOrEmpty(input.mo_code))
|
||||||
|
throw Oops.Bah("工单代码不能为空");
|
||||||
|
if(string.IsNullOrEmpty(input.mo_type))
|
||||||
|
throw Oops.Bah("工单类型不能为空");
|
||||||
|
if(input.plan_start_date==null)
|
||||||
|
throw Oops.Bah("计划开始日期不能为空");
|
||||||
|
if(input.plan_end_date==null)
|
||||||
|
throw Oops.Bah("计划结束日期不能为空");
|
||||||
|
if(string.IsNullOrEmpty(input.material_code))
|
||||||
|
throw Oops.Bah("物料编号不能为空");
|
||||||
|
if(string.IsNullOrEmpty(input.unit_id))
|
||||||
|
throw Oops.Bah("单位不能为空");
|
||||||
|
if(input.plan_qty==null || input.plan_qty<=0)
|
||||||
|
throw Oops.Bah("计划数量不能为空");
|
||||||
|
|
||||||
|
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().SingleAsync(x => x.code == input.material_code);
|
||||||
|
if(basMaterial==null)
|
||||||
|
throw Oops.Bah($"未找到物料编号为{input.material_code}的物料");
|
||||||
|
|
||||||
|
List<BasMaterialUnit> basMaterialUnits = await _db.Queryable<BasMaterialUnit>().Where(x => x.material_id == basMaterial.id).ToListAsync();
|
||||||
|
List<String> units = basMaterialUnits.Select(x => x.auxiliary_unit_id).Distinct().ToList();
|
||||||
|
if(units!=null && !string.IsNullOrEmpty(basMaterial.unit_id)) units.Add(basMaterial.unit_id);
|
||||||
|
|
||||||
|
if(!units.Contains(input.unit_id))
|
||||||
|
throw Oops.Bah($"{basMaterial.name}不存在{input.unit_id}该单位");
|
||||||
|
|
||||||
|
input.id = SnowflakeIdHelper.NextId();
|
||||||
|
input.mo_source = "1";
|
||||||
|
input.mo_code = input.mo_code;
|
||||||
|
input.create_id = WmsWareHouseConst.AdministratorUserId;
|
||||||
|
input.create_time = DateTime.Now;
|
||||||
|
input.mo_status = DictConst.ToBeScheduledId;
|
||||||
|
await _db.Insertable(input).ExecuteCommandAsync();
|
||||||
|
return "true";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user