生产管理新增,同组工单下发,取消同组工单

This commit is contained in:
DEVICE8\12494
2023-04-25 15:54:27 +08:00
parent 32898552dc
commit 967c013d16
7 changed files with 447 additions and 22 deletions

View File

@@ -12,8 +12,11 @@ namespace Tnb.ProductionMgr.Entitys.新文件夹
/// 生产任务状态TypeId
/// </summary>
public const string PrdTaskStatusTypeId = "25572555259157";
/// <summary>
/// 工单状态 已下发字典Id
/// </summary>
public const string IssueId = "25019232867093";
}
/// <summary>
/// 工单状态
@@ -29,4 +32,6 @@ namespace Tnb.ProductionMgr.Entitys.新文件夹
/// </summary>
public const string WaitProductId = "25019244276501";
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tnb.ProductionMgr.Entitys.Entity;
namespace Tnb.ProductionMgr.Entitys.Dto.PrdManage
{
/// <summary>
/// 设备列表输出参数
/// </summary>
public class EquipmentListOutput : EqpEquipment
{
/// <summary>
/// 任务单数量
/// </summary>
public int task_list_qty { get; set; }
/// <summary>
/// 吨位
/// </summary>
public double tonnage { get; set; }
/// <summary>
/// 最早开始时间
/// </summary>
public DateTime? first_date { get; set; }
}
}

View File

@@ -0,0 +1,223 @@
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:设备类型IDEQP_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;}
}
}

View File

@@ -30,10 +30,13 @@ namespace Tnb.ProductionMgr.Entitys.Entity
/// Nullable:False
/// </summary>
public string mo_code { get; set; }
/// <summary>
/// 产品ID
/// </summary>
//public string item_id { get; set; }
public string item_id { get; set; }
/// <summary>
/// Desc:产品代码, BAS_MATERIA.MATERIALCODE BAS_ITEM.ITEMCODE
@@ -320,7 +323,7 @@ namespace Tnb.ProductionMgr.Entitys.Entity
/// Default:NULL::character varying
/// Nullable:True
/// </summary>
public string mo_group_no { get; set; }
public string mo_task_no { get; set; }
}
}

View File

@@ -120,7 +120,7 @@ namespace Tnb.ProductionMgr.Entitys.Entity
/// Default:
/// Nullable:True
/// </summary>
public decimal? tonnage { get; set; }
public double tonnage { get; set; }
/// <summary>
/// Desc:已排产数

View File

@@ -6,6 +6,7 @@ using JNPF.Common.Filter;
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;
@@ -13,6 +14,7 @@ using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NPOI.OpenXmlFormats.Shared;
using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
using SqlSugar;
using Tnb.ProductionMgr.Entitys.Dto.PrdManage;
using Tnb.ProductionMgr.Entitys.Dto.WorkOrder;
@@ -26,8 +28,8 @@ namespace Tnb.ProductionPlanMgr
/// <summary>
/// 生产计划管理
/// </summary>
[ApiDescriptionSettings(Tag = "ProductionMgr", Name = "WorkOrderCreate", Order = 700)]
[Route("api/production/[controller]")]
[ApiDescriptionSettings(Tag = "ProductionMgr", Area = "production", Order = 700)]
[Route("api/[area]/[controller]/[action]")]
public class PrdMoService : IPrdMoService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<PrdMo> _repository;
@@ -59,9 +61,18 @@ namespace Tnb.ProductionPlanMgr
{
throw new ArgumentNullException(nameof(input));
}
var db = _repository.AsSugarClient();
//获取同组工单的Id一起下发
var combineMoCodes = await db.Queryable<PrdMo>().Where(it => input.WorkOrderIds.Contains(it.id)).Select(it => it.combine_mo_code).ToListAsync();
if (combineMoCodes?.Count > 0)
{
var moIds = await db.Queryable<PrdMo>().Where(it => combineMoCodes.Contains(it.combine_mo_code) && !input.WorkOrderIds.Contains(it.id)).Select(it => it.id).ToListAsync();
input.WorkOrderIds = input.WorkOrderIds.Concat(moIds).ToList();
}
var row = await db.Updateable<PrdMo>()
.SetColumns(it => new PrdMo { mo_status = "25019232867093" })
.SetColumns(it => new PrdMo { mo_status = DictionaryConstants.IssueId })
.Where(it => input.WorkOrderIds.Contains(it.id))
.ExecuteCommandAsync();
return (row > 0);
@@ -74,31 +85,73 @@ namespace Tnb.ProductionPlanMgr
[HttpPost("relevancy")]
public async Task<dynamic> RelevancySameGroupMo(MoCrInput input)
{
var row = -1;
(bool executeRes, string errMsg) multi = (true, "");
var list = await _repository.AsSugarClient().Queryable<PrdMo>()
.InnerJoin<Molds>((a, b) => a.item_code == b.item_code)
.InnerJoin<Molds>((a, b) => a.item_code == b.item_id)
.Where((a, b) => input.WorkOrderIds.Contains(a.id))
.Select((a, b) => new
{
planDate = a.plan_start_date,
moldId = b.id,
mold_code = b.mold_code,
}).ToListAsync();
var planDateAll = true;
var moldIdAll = true;
if (list?.Count > 0)
{
var planDate = list.FirstOrDefault()?.planDate;
var moId = list.FirstOrDefault()?.moldId;
var moldCode = list.FirstOrDefault()?.mold_code;
var all = list.Skip(1).All(x => x.planDate == planDate && x.moldId == moId);
if (all)
planDateAll = list.Skip(1).All(x => x.planDate == planDate);
moldIdAll = list.Skip(1).All(x => x.mold_code == moldCode);
if (planDateAll && moldIdAll)
{
var groupId = SnowflakeIdHelper.NextId();
row = await _repository.AsSugarClient().Updateable<PrdMo>()
.SetColumns(c => new PrdMo { mo_group_no = groupId })
multi.executeRes = await _repository.AsSugarClient().Updateable<PrdMo>()
.SetColumns(c => new PrdMo { combine_mo_code = groupId })
.Where(it => input.WorkOrderIds.Contains(it.id))
.ExecuteCommandAsync();
.ExecuteCommandHasChangeAsync();
}
else
{
multi.executeRes = false;
if (!planDateAll)
{
throw new AppFriendlyException("计划开始日期不一致", null);
}
if (!moldIdAll)
{
throw new AppFriendlyException("未关联到同一模具下", null);
}
}
}
else
{
multi.executeRes = false;
if (!planDateAll)
{
throw new AppFriendlyException("计划开始日期不一致", null);
}
if (!moldIdAll)
{
throw new AppFriendlyException("未关联到同一模具下", null);
}
}
return row > 0;
return multi;
}
/// <summary>
/// 取消关联
/// </summary>
/// <param name="input">取消关联输入参数</param>
/// <returns></returns>
[HttpPost("CanelRelevancy")]
public async Task<dynamic> CanelRelevancy(MoCrInput input)
{
return await _repository.AsSugarClient().Updateable<PrdMo>()
.SetColumns(c => new PrdMo { combine_mo_code = "" })
.Where(it => input.WorkOrderIds.Contains(it.id))
.ExecuteCommandHasChangeAsync();
}
@@ -139,7 +192,7 @@ namespace Tnb.ProductionPlanMgr
{
await db.Ado.BeginTranAsync();
row = await db.Storageable(entity).ExecuteCommandAsync();
var taskLogEntity = input.Adapt<PrdTaskLog>();
taskLogEntity.id ??= SnowflakeIdHelper.NextId();
@@ -236,13 +289,36 @@ namespace Tnb.ProductionPlanMgr
mold_code = a.mold_code,
mold_name = a.mold_name,
item_name = b.item_name,
item_code = b.item_code,
cavity_qty = a.cavity_qty,
item_code = b.item_code,
})
.ToListAsync();
return list;
}
/// <summary>
/// 根据模具Id获取设备列表
/// </summary>
/// <param name="moldId"></param>
/// <returns></returns>
[HttpGet("equipments/{moldId}")]
public async Task<dynamic> GetEquipmentListByMoldId(string moldId)
{
var items = await _repository.AsSugarClient().Queryable<EqpEquipment>()
.InnerJoin<PrdTask>((a, b) => a.id == b.eqp_id)
.Where((a, b) => a.mold_id == moldId)
.Select((a, b) => new
{
eqp_code = a.eqp_code,
eqp_type_code = a.eqp_type_code,
tonnage = b.tonnage,
task_list_qty = SqlFunc.Subqueryable<PrdTask>().Where(it => it.eqp_id == a.id).Count(),
first_date = SqlFunc.Subqueryable<PrdTask>().Where(it => it.eqp_id == a.id).OrderByDesc(o => o.estimated_end_date).Select(it => it.estimated_end_date)
}).ToListAsync();
return items;
}
/// <summary>
/// 工单调整-生产任务重新排序
/// </summary>

View File

@@ -2886,9 +2886,27 @@ public class RunService : IRunService, ITransient
// 多选时为模糊查询
if (model.multiple)
{
conModels.Add(new ConditionalCollections()
if (jarr?.Children() != null && jarr?.Children().ToList().Count > 1)
{
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
var values = jarr.ToList().Select(t => t.Value<string>()).ToList();
var condition = new ConditionalCollections();
condition.ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>(values.Count);
values.ForEach(x =>
{
condition.ConditionalList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel
{
FieldName = item.Key,
ConditionalType = ConditionalType.Like,
FieldValue = x,
}));
});
conModels.Add(condition);
}
else
{
conModels.Add(new ConditionalCollections()
{
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
{
new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
{
@@ -2897,7 +2915,9 @@ public class RunService : IRunService, ITransient
FieldValue = itemValue
})
}
});
});
}
}
//modified by ly on 20230407
else if (jarr?.Children() != null && jarr?.Children().ToList().Count > 1)
@@ -2940,6 +2960,73 @@ public class RunService : IRunService, ITransient
}
}
break;
case JnpfKeyConst.TAB: //modifed by ly on 20230425
{
var itemValue = item.Value.ToString().Contains("[") ? item.Value.ToJsonString() : item.Value.ToString();
//modified by ly on 20230407
JArray jarr = null;
if (itemValue!.Contains("["))
{
jarr = JArray.Parse(itemValue);
}
// 多选时为模糊查询
if (model.multiple)
{
conModels.Add(new ConditionalCollections()
{
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
{
new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
{
FieldName = item.Key,
ConditionalType = ConditionalType.Like,
FieldValue = itemValue
})
}
});
}
//modified by ly on 20230407
else if (jarr?.Children() != null && jarr?.Children().ToList().Count > 1)
{
var values = jarr.ToList().Select(t => t.Value<string>()).ToList();
var condition = new ConditionalCollections();
condition.ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>(values.Count);
values.ForEach(x =>
{
condition.ConditionalList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel
{
FieldName = item.Key,
ConditionalType = ConditionalType.Equal,
FieldValue = x,
}));
});
conModels.Add(condition);
}
else
{
//modified by ly on 20230407
if (itemValue.IsMatch(@"\[(.+)\]"))
{
itemValue = Regex.Match(itemValue, @"\[(.+)\]").Groups[1].Value;
itemValue = itemValue.Trim('"');
}
conModels.Add(new ConditionalCollections()
{
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
{
new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
{
FieldName = item.Key,
ConditionalType = ConditionalType.Equal,
FieldValue = itemValue
})
}
});
}
}
break;
default:
{