修改引用
This commit is contained in:
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.新文件夹
|
||||
namespace Tnb.ProductionMgr.Entitys.Consts
|
||||
{
|
||||
/// <summary>
|
||||
/// 工单状态
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto.PrdManage
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备列表输出参数
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionPlanMgr.Entitys.Dto.WorkOrder
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产工单下发输入参数
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto.WorkOrder
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具列表输出参数
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto.PrdManage
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产操作记录查询参数
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto.PrdManage
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产操作记录输出类
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto.PrdManage
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产任务单下发输入参数
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto.PrdManage
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产任务重新排序输出参数
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto.WorkOrder
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产工单排产输入参数
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto.PrdManage
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto
|
||||
{
|
||||
public class TaskOperRecordOutput
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto.PrdManage
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 转移机台输入参数
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Entity
|
||||
{
|
||||
///<summary>
|
||||
///产品信息
|
||||
///</summary>
|
||||
[SugarTable("bas_item")]
|
||||
public partial class BasItem
|
||||
{
|
||||
public BasItem(){
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:主键
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey=true)]
|
||||
public string id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品代码
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string item_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品分类ID
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string categoryid {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:关联比例
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? relation_ratio {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? create_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? modify_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:扩展字段
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string extras {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:所属组织ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string org_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品名称
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_name {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品规格型号
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_standard {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:物料ID,BAS_MATERIAL.ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string material_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品类型: 半成品:SemiManufacture 成品:FinishedProduct
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_type {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:备注
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string remark {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:时间戳(用于并发控制)
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string timestamp {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id {get;set;}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,223 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Entity
|
||||
{
|
||||
///<summary>
|
||||
///设备登记
|
||||
///</summary>
|
||||
[SugarTable("eqp_equipment")]
|
||||
public partial class EqpEquipment
|
||||
{
|
||||
public EqpEquipment(){
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:自增ID
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey=true)]
|
||||
public string id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备代码
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string eqp_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备名称
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string eqp_name {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备类型代码
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string eqp_type_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:验收状态(合格:Qualified/不合格:Unqualified)
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string accept_status {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:使用部门代码
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string use_department_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:安装日期
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string install_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? create_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? modify_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:扩展字段
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string extras {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具Id
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:所属组织ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string org_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备类型ID,EQP_EQUIPMENTTYPE.ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string eqp_type_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备生产日期
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string product_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备生产厂家
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string supplier_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:正式使用日期
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string use_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:验收日期
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string accept_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:管理部门
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string manage_department_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工段(车间)代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string segment_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工位代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string station_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:质检代码,良率计算
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string quality_station_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产节拍
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string process_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:时间单位: 秒:s 分钟:m 小时:h
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string time_unit {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备当前状态,状态代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string current_status {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:技术性能
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string techno_logy {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:备注
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string remark {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:时间戳
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string timestamp {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id {get;set;}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using Mapster;
|
||||
using Tnb.ProductionMgr.Entitys.Dto.WorkOrder;
|
||||
using Tnb.ProductionMgr.Entitys.Dto;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Mapper
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Tnb.ProductionPlanMgr.Entitys.Dto.WorkOrder;
|
||||
using Tnb.ProductionMgr.Entitys.Dto;
|
||||
|
||||
namespace Tnb.ProductionPlanMgr.Interfaces
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 工单生成
|
||||
|
||||
@@ -1,29 +1,18 @@
|
||||
using System.Dynamic;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.OpenXmlFormats.Shared;
|
||||
using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entitys;
|
||||
using Tnb.ProductionMgr.Entitys;
|
||||
using Tnb.ProductionMgr.Entitys.Dto.PrdManage;
|
||||
using Tnb.ProductionMgr.Entitys.Dto.WorkOrder;
|
||||
using Tnb.BasicData.Entitys.Entity;
|
||||
using Tnb.ProductionMgr.Entitys.Dto;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
using Tnb.ProductionMgr.Entitys.新文件夹;
|
||||
using Tnb.ProductionPlanMgr.Entitys.Dto.WorkOrder;
|
||||
using Tnb.ProductionPlanMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -73,7 +62,7 @@ namespace Tnb.ProductionMgr
|
||||
/// <br/> }
|
||||
/// <br/>]
|
||||
/// </remarks>
|
||||
[HttpGet("moldlist/{itemId}")]
|
||||
[HttpGet("{itemId}")]
|
||||
public async Task<dynamic> GetMoldListByItemId(string itemId)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
@@ -97,7 +86,7 @@ namespace Tnb.ProductionMgr
|
||||
/// </summary>
|
||||
/// <param name="moldId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("equipments/{moldId}")]
|
||||
[HttpGet("{moldId}")]
|
||||
public async Task<dynamic> GetEquipmentListByMoldId(string moldId)
|
||||
{
|
||||
var items = await _repository.AsSugarClient().Queryable<EqpEquipment>()
|
||||
@@ -134,7 +123,7 @@ namespace Tnb.ProductionMgr
|
||||
/// <br/> }
|
||||
/// <br/>]
|
||||
/// </remarks>
|
||||
[HttpGet("sort/{eqpId}")]
|
||||
[HttpGet("{eqpId}")]
|
||||
public async Task<dynamic> PrdTaskSort(string eqpId)
|
||||
{
|
||||
var taskStatusDic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
@@ -160,7 +149,7 @@ namespace Tnb.ProductionMgr
|
||||
/// </summary>
|
||||
/// <param name="taskId">任务ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("record/{taskId}")]
|
||||
[HttpGet("{taskId}")]
|
||||
public async Task<dynamic> GetMoOperRecord(string taskId)
|
||||
{
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdTaskLog>().Where(it => it.id == taskId).ToListAsync();
|
||||
@@ -179,7 +168,7 @@ namespace Tnb.ProductionMgr
|
||||
/// </summary>
|
||||
/// <param name="input">生产工单下发输入参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("workorder-issue")]
|
||||
[HttpPut]
|
||||
public async Task<dynamic> WorkOrderIssue(MoCrInput input)
|
||||
{
|
||||
if (input is null)
|
||||
@@ -207,7 +196,7 @@ namespace Tnb.ProductionMgr
|
||||
/// </summary>
|
||||
/// <param name="input">关联同组工单输入参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("relevancy")]
|
||||
[HttpPost]
|
||||
public async Task<dynamic> RelevancySameGroupMo(MoCrInput input)
|
||||
{
|
||||
(bool executeRes, string errMsg) multi = (true, "");
|
||||
@@ -257,7 +246,7 @@ namespace Tnb.ProductionMgr
|
||||
/// </summary>
|
||||
/// <param name="input">取消关联输入参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CanelRelevancy")]
|
||||
[HttpPost]
|
||||
public async Task<dynamic> CanelRelevancy(MoCrInput input)
|
||||
{
|
||||
return await _repository.AsSugarClient().Updateable<PrdMo>()
|
||||
@@ -286,7 +275,7 @@ namespace Tnb.ProductionMgr
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpPost("scheduling")]
|
||||
[HttpPost]
|
||||
public async Task<dynamic> ProductionScheduling(ProductionSchedulingCrInput input)
|
||||
{
|
||||
var row = -1;
|
||||
@@ -294,51 +283,131 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
input.id ??= SnowflakeIdHelper.NextId();
|
||||
var entity = input.Adapt<PrdTask>();
|
||||
entity.status = "ToBeScheduled"; //任务单状态默认,待排产
|
||||
entity.status = DictConst.ToBeStartedEnCode; //任务单状态默认,待排产
|
||||
entity.create_id = _userManager.UserId;
|
||||
entity.create_time = DateTime.Now;
|
||||
entity.prd_task_id = input.id;
|
||||
var db = _repository.AsSugarClient();
|
||||
try
|
||||
{
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
row = await db.Storageable(entity).ExecuteCommandAsync();
|
||||
var taskLogEntity = input.Adapt<PrdTaskLog>();
|
||||
taskLogEntity.id ??= SnowflakeIdHelper.NextId();
|
||||
taskLogEntity.task_id = input.id;
|
||||
taskLogEntity.status ??= "ToBeStarted";
|
||||
taskLogEntity.create_id = _userManager.UserId;
|
||||
taskLogEntity.create_time = DateTime.Now;
|
||||
taskLogEntity.operator_name = _userManager.RealName;
|
||||
|
||||
//任务状态变更时插入操作记录
|
||||
if (!db.Queryable<PrdTaskLog>().Where(it => it.task_id == input.id && it.status == taskLogEntity.status).Any())
|
||||
List<PrdMo> entities = new();
|
||||
//根据工单Id查询同组工单号,进行同组工单排产处理
|
||||
var combineMoCodes = await db.Queryable<PrdMo>().Where(it => it.id == input.mo_id).Select(it => it.combine_mo_code).Distinct().ToListAsync();
|
||||
if (combineMoCodes?.Count > 0)
|
||||
{
|
||||
row = await db.Insertable(taskLogEntity).ExecuteCommandAsync();
|
||||
entities = await db.Queryable<PrdMo>().Where(it => combineMoCodes.Contains(it.combine_mo_code)).ToListAsync();
|
||||
}
|
||||
|
||||
await db.Ado.BeginTranAsync();
|
||||
//同组工单排产
|
||||
if (entities.Count > 0)
|
||||
{
|
||||
var icmoEntities = entities.Adapt<List<PrdTask>>();
|
||||
icmoEntities.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.status = DictConst.ToBeStartedEnCode; //任务单状态默认,待排产
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
x.prd_task_id = input.id;
|
||||
});
|
||||
row = await db.Storageable(entities).ExecuteCommandAsync();
|
||||
var icmoRecords = icmoEntities.Adapt<List<PrdTaskLog>>();
|
||||
icmoRecords.ForEach(x =>
|
||||
{
|
||||
x.id ??= SnowflakeIdHelper.NextId();
|
||||
x.task_id = input.id;
|
||||
x.status ??= "ToBeStarted";
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
x.operator_name = _userManager.RealName;
|
||||
});
|
||||
var icmoIds = icmoRecords.Select(it => it.id).ToList();
|
||||
var statusMany = icmoRecords.Select(it => it.status).ToList();
|
||||
//任务状态变更时插入操作记录
|
||||
var logEntities = await db.Queryable<PrdTaskLog>().Where(it => !icmoIds.Contains(it.id) && !statusMany.Contains(it.status)).ToListAsync();
|
||||
row = await db.Insertable(logEntities).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
row = await db.Storageable(entity).ExecuteCommandAsync();
|
||||
var taskLogEntity = input.Adapt<PrdTaskLog>();
|
||||
taskLogEntity.id ??= SnowflakeIdHelper.NextId();
|
||||
taskLogEntity.task_id = input.id;
|
||||
taskLogEntity.status ??= "ToBeStarted";
|
||||
taskLogEntity.create_id = _userManager.UserId;
|
||||
taskLogEntity.create_time = DateTime.Now;
|
||||
taskLogEntity.operator_name = _userManager.RealName;
|
||||
|
||||
//任务状态变更时插入操作记录
|
||||
if (!db.Queryable<PrdTaskLog>().Where(it => it.task_id == input.id && it.status == taskLogEntity.status).Any())
|
||||
{
|
||||
row = await db.Insertable(taskLogEntity).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (row > 0)
|
||||
{
|
||||
var obj = (await db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id));
|
||||
obj.input_qty += entity.scheduled_qty;
|
||||
var moStatus = "";
|
||||
//判断,已排产数量>=计划数量时将状态改为 已排产
|
||||
if (obj.input_qty >= obj.plan_qty)
|
||||
if (combineMoCodes?.Count > 0)
|
||||
{
|
||||
moStatus = MoStatus.AlreadyId;
|
||||
var moList = await db.Queryable<PrdMo>().Where(it => combineMoCodes.Contains(it.combine_mo_code)).ToListAsync();
|
||||
var icmoList = moList.Adapt<List<PrdTask>>();
|
||||
var combinePlanQty = icmoList.Sum(x => x.plan_qty); //合并工单后的计划数量
|
||||
var combineScheduledQty = icmoList.Sum(x => x.scheduled_qty); //合并后的已排产数量
|
||||
if (combineScheduledQty < combinePlanQty)
|
||||
{
|
||||
icmoList.ForEach(x =>
|
||||
{
|
||||
var item = moList.Find(xx => xx.id == x.mo_id);
|
||||
if (item != null)
|
||||
{
|
||||
item.input_qty += x.scheduled_qty;
|
||||
item.mo_status = DictConst.WaitProductId;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
//如果已排产数量大于计划数量,修改工单状态为,待开工
|
||||
if (combineScheduledQty >= combinePlanQty)
|
||||
{
|
||||
icmoList.ForEach(x =>
|
||||
{
|
||||
var item = moList.Find(xx => xx.id == x.mo_id);
|
||||
if (item != null)
|
||||
{
|
||||
item.input_qty += x.scheduled_qty;
|
||||
item.mo_status = DictConst.AlreadyId;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
row = await db.Updateable(moList).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//修改工单状态为待排产,同事修改已排产数量
|
||||
moStatus = MoStatus.WaitProductId;
|
||||
var obj = (await db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id));
|
||||
obj.input_qty += entity.scheduled_qty;
|
||||
var moStatus = "";
|
||||
//判断,已排产数量>=计划数量时将状态改为 已排产
|
||||
if (obj.input_qty >= obj.plan_qty)
|
||||
{
|
||||
moStatus = DictConst.AlreadyId;
|
||||
}
|
||||
else
|
||||
{
|
||||
//修改工单状态为待排产,同事修改已排产数量
|
||||
moStatus = DictConst.WaitProductId;
|
||||
}
|
||||
row = await db.Updateable<PrdMo>().SetColumns(it => new PrdMo
|
||||
{
|
||||
mo_status = moStatus,
|
||||
input_qty = obj.input_qty
|
||||
})
|
||||
.Where(it => it.id == entity.mo_id).ExecuteCommandAsync();
|
||||
}
|
||||
row = await db.Updateable<PrdMo>().SetColumns(it => new PrdMo
|
||||
{
|
||||
mo_status = moStatus,
|
||||
input_qty = obj.input_qty
|
||||
})
|
||||
.Where(it => it.id == entity.mo_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await db.Ado.CommitTranAsync();
|
||||
@@ -355,7 +424,7 @@ namespace Tnb.ProductionMgr
|
||||
/// 生产任务下发
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("task-release")]
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdTaskRelease(PrdTaskReleaseUpInput input)
|
||||
{
|
||||
if (input is null)
|
||||
@@ -381,7 +450,7 @@ namespace Tnb.ProductionMgr
|
||||
.SetColumns(it => new PrdTask { eqp_id = input.eqp_id })
|
||||
.Where(it => it.id == input.icmo_id)
|
||||
.ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -12,11 +12,10 @@ using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.UserModel;
|
||||
using SqlSugar;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
|
||||
namespace Tnb.ProductionPlanMgr
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产排产
|
||||
|
||||
Reference in New Issue
Block a user