This commit is contained in:
alex
2023-08-11 16:24:53 +08:00
16 changed files with 261 additions and 27 deletions

View File

@@ -87,7 +87,7 @@ public static class DictConst
/// </summary>
public const string ComplatedEnCode = "Complated";
/// <summary>
/// 任务单状态-待排产
/// 任务单状态-待下发
/// </summary>
public const string ToBeScheduledEncode = "ToBeScheduled";
/// <summary>

View File

@@ -203,4 +203,9 @@ public partial class EqpEquipment : BaseEntity<string>
/// </summary>
public string? responsibler_id { get; set; }
/// <summary>
/// 二维码
/// </summary>
public string? qrcode { get; set; }
}

View File

@@ -23,5 +23,12 @@ namespace Tnb.EquipMgr.Interfaces
/// </summary>
/// <returns></returns>
public Task<dynamic> GetWorklineAndEquipTree(Dictionary<string,string> dic);
/// <summary>
/// 根据二维码查设备
/// </summary>
/// <param name="dic"></param>
/// <returns></returns>
public Task<EqpEquipment> GetEntityByQrcode(Dictionary<string, string> dic);
}
}

View File

@@ -233,5 +233,12 @@ namespace Tnb.EquipMgr
["list"] = list1,
});
}
[HttpPost]
public async Task<EqpEquipment> GetEntityByQrcode(Dictionary<string, string> dic)
{
string qrcode = dic["qrcode"];
return await _repository.GetSingleAsync(x => x.qrcode == qrcode);
}
}
}

View File

@@ -0,0 +1,8 @@
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
{
public class ChangeEquipInput
{
public string mo_task_id { get; set; }
public string equip_id { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
{
public class ChangeMoldInput
{
public string mo_task_id { get; set; }
public string mold_id { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
{
public class ChangeWorklineInput
{
public string mo_task_id { get; set; }
public string workline_id { get; set; }
}
}

View File

@@ -16,5 +16,10 @@ namespace Tnb.ProductionMgr.Entities.Dto
///任务单操作状态
/// </summary>
public string statusName { get; set; }
/// <summary>
/// 排产类型:1、注塑、挤出2、组装、包装
/// </summary>
public int? schedule_type { get; set; }
}
}

View File

@@ -9,14 +9,18 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
public string mo_task_code { get; set; }
public string mo_task_status { get; set; }
public string material_id { get; set; }
public string material_id_id { get; set; }
public string mold_id { get; set; }
public string mold_id_id { get; set; }
public int? plan_qty { get; set; }
public int? complete_qty { get; set; }
public int? scheduled_qty { get; set; }
public string workline_id { get; set; }
public string workline_id_id { get; set; }
public string estimated_start_date { get; set; }
public string estimated_end_date { get; set; }
public string eqp_id { get; set; }
public string eqp_id_id { get; set; }
public string create_time { get; set; }
}
}

View File

@@ -114,6 +114,14 @@ namespace Tnb.ProductionMgr.Entities
[SugarColumn(IsIgnore = true)]
public string workline_code { get; set; }
/// <summary>
/// 工位编号
/// </summary>
public string? station_code { get; set; }
/// <summary>
/// 工序编号
/// </summary>
public string? process_code { get; set; }
}
}

View File

@@ -23,6 +23,7 @@ using Tnb.ProductionMgr.Entities.Consts;
using Tnb.WarehouseMgr;
using Tnb.WarehouseMgr.Entities;
using Tnb.BasicData;
using Tnb.EquipMgr.Entities;
namespace Tnb.ProductionMgr
{
@@ -141,9 +142,29 @@ namespace Tnb.ProductionMgr
throw new Exception("没有签收物料");
}
var mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
var material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
var station = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == input.station_id);
var process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == input.process_id);
var taskLog = new PrdTaskLog();
taskLog.id = SnowflakeIdHelper.NextId();
taskLog.mo_code = mo?.mo_code!;
taskLog.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.equip_id))?.code!;
taskLog.mold_code = "";
taskLog.item_code = material?.code!;
taskLog.item_standard = material?.material_standard!;
taskLog.status = "生产投料";
taskLog.operator_name = _userManager.RealName;
taskLog.create_id = _userManager.UserId;
taskLog.create_time = DateTime.Now;
taskLog.mo_task_id = moTask.id;
taskLog.mo_task_code = moTask.mo_task_code;
taskLog.station_code = station?.EnCode;
taskLog.process_code = process.code;
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
});

View File

@@ -226,7 +226,11 @@ namespace Tnb.ProductionMgr
var list = await _repository.AsSugarClient().Queryable<PrdTaskLog>().Where(it => it.mo_task_id == taskId).ToListAsync();
var data = list.Adapt<List<PrdTaskOperOutput>>();
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
_repository.AsSugarClient().ThenMapper(data, x => x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : "");
_repository.AsSugarClient().ThenMapper(data, x =>
{
x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : x.status;
x.schedule_type = _repository.AsSugarClient().Queryable<PrdMoTask>().Single(y => y.id == x.mo_task_id).schedule_type;
});
return data;
}
/// <summary>
@@ -1820,20 +1824,25 @@ namespace Tnb.ProductionMgr
(a, b, c, d) => a.workline_id == eqpId || a.eqp_id == eqpId)
.WhereIF(worklineIds.Count > 0, (a, b, c, d) => worklineIds.Contains(a.workline_id))
.WhereIF(equipIds.Count > 0, (a, b, c, d) => equipIds.Contains(a.eqp_id))
.Where((a)=>a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_code==DictConst.ToBeScheduledEncode || a.mo_task_code==DictConst.MoStatusPauseCode)
.Select((a, b, c, d,e,f,g,h) => new WorkOrderAdjustmentListOutput
{
id = a.id,
mo_task_code = a.mo_task_code,
material_id = b.code+"/"+b.name,
material_id_id = a.material_id,
mold_id = e.mold_code+"/"+e.mold_name,
mold_id_id = a.mold_id,
mo_task_status = d.FullName,
plan_qty = f.plan_qty,
complete_qty = SqlFunc.IsNull(a.reported_work_qty,0) + SqlFunc.IsNull(a.scrap_qty,0),
scheduled_qty = a.scheduled_qty,
workline_id = a.workline_id==null ? "" :g.EnCode+"/"+g.FullName,
workline_id_id = a.workline_id,
estimated_start_date = a.estimated_start_date==null ? "" : a.estimated_start_date.Value.ToString("yyyy-MM-dd"),
estimated_end_date = a.estimated_end_date==null ? "" : a.estimated_end_date.Value.ToString("yyyy-MM-dd"),
eqp_id = a.eqp_id==null ? "" : h.code+"/"+h.name,
eqp_id_id = a.eqp_id,
create_time = a.create_time==null ? "" :a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss")
}).OrderByDescending(a => a.create_time).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<WorkOrderAdjustmentListOutput>.SqlSugarPageResult(result);
@@ -1924,5 +1933,145 @@ namespace Tnb.ProductionMgr
.Where(x => x.workline_id == id && x.mo_task_status == DictConst.InProgressEnCode).FirstAsync();
}
/// <summary>
/// 更换机台
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> ChangeEquip(ChangeEquipInput input)
{
var db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
var moTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
if (moTask.eqp_id == input.equip_id)
{
throw new Exception("与原机台相同");
}
await db.Updateable<PrdMoTask>().SetColumns(x => x.eqp_id == input.equip_id)
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
var mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
var material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
var process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.process_id);
var taskLog = new PrdTaskLog();
taskLog.id = SnowflakeIdHelper.NextId();
taskLog.mo_code = mo?.mo_code!;
taskLog.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.equip_id))?.code!;
taskLog.mold_code = "";
taskLog.item_code = material?.code!;
taskLog.item_standard = material?.material_standard!;
taskLog.status = "更换机台";
taskLog.operator_name = _userManager.RealName;
taskLog.create_id = _userManager.UserId;
taskLog.create_time = DateTime.Now;
taskLog.mo_task_id = moTask.id;
taskLog.mo_task_code = moTask.mo_task_code;
taskLog.station_code = "";
taskLog.process_code = process?.code;
await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
});
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
return result.IsSuccess ? "延期成功" : result.ErrorMessage;
}
/// <summary>
/// 更换模具
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> ChangeMold(ChangeMoldInput input)
{
var db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
var moTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
if (moTask.mold_id == input.mold_id)
{
throw new Exception("与原模具相同");
}
await db.Updateable<PrdMoTask>().SetColumns(x => x.mold_id == input.mold_id)
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
var mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
var mold = await db.Queryable<ToolMolds>().SingleAsync(x => x.id == input.mold_id);
var material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
var process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.process_id);
var taskLog = new PrdTaskLog();
taskLog.id = SnowflakeIdHelper.NextId();
taskLog.mo_code = mo?.mo_code!;
taskLog.eqp_code = "";
taskLog.mold_code = mold?.mold_code;
taskLog.item_code = material?.code!;
taskLog.item_standard = material?.material_standard!;
taskLog.status = "更换模具";
taskLog.operator_name = _userManager.RealName;
taskLog.create_id = _userManager.UserId;
taskLog.create_time = DateTime.Now;
taskLog.mo_task_id = moTask.id;
taskLog.mo_task_code = moTask.mo_task_code;
taskLog.station_code = "";
taskLog.process_code = process?.code;
await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
});
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
return result.IsSuccess ? "延期成功" : result.ErrorMessage;
}
/// <summary>
/// 更换产线
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> ChangeWorkline(ChangeWorklineInput input)
{
var db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
var moTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
if (moTask.workline_id == input.workline_id)
{
throw new Exception("与原产线相同");
}
await db.Updateable<PrdMoTask>().SetColumns(x => x.workline_id == input.workline_id)
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
var mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
var material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
var process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.process_id);
var taskLog = new PrdTaskLog();
taskLog.id = SnowflakeIdHelper.NextId();
taskLog.mo_code = mo?.mo_code!;
taskLog.eqp_code = "";
taskLog.mold_code = "";
taskLog.item_code = material?.code!;
taskLog.item_standard = material?.material_standard!;
taskLog.status = "更换产线";
taskLog.operator_name = _userManager.RealName;
taskLog.create_id = _userManager.UserId;
taskLog.create_time = DateTime.Now;
taskLog.mo_task_id = moTask.id;
taskLog.mo_task_code = moTask.mo_task_code;
taskLog.station_code = "";
taskLog.process_code = process?.code;
await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
});
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
return result.IsSuccess ? "延期成功" : result.ErrorMessage;
}
}
}

View File

@@ -49,7 +49,17 @@ namespace Tnb.WarehouseMgr
foreach (var d in dics)
{
var LCode = d["location_code"].ToString() ?? string.Empty;
if (LCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据起始点位编号不可为空", 500);
if (LCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据位编号不可为空", 500);
var isType = d["is_type"].ToString() ?? string.Empty;
if (isType == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位类型不可为空", 500);
var floor = d["floor"].ToString() ?? string.Empty;
if (floor == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500);
var layers = d["layers"].ToString() ?? string.Empty;
var locLine = d["loc_line"].ToString() ?? string.Empty;
var locColumn = d["loc_column"].ToString() ?? string.Empty;
if (locLine == string.Empty || locColumn == string.Empty || layers == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据行列层不可为空", 500);
var isSign = d["is_sign"].ToString() ?? string.Empty;
if(isSign==string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据自动签收不可为空", 500);
var cStdCode = d["carrystd_id"].ToString() ?? string.Empty;
cStdCodes.Add(cStdCode);
d["create_time"] = DateTime.Now;
@@ -58,21 +68,19 @@ namespace Tnb.WarehouseMgr
locs.Add(loc);
}
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cStdCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
if (carryStdDic?.Count > 0)
locs.ForEach(x =>
{
locs.ForEach(x =>
{
if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500);
x.id = SnowflakeIdHelper.NextId();
x.org_id = _userManager.User.OrganizeId;
x.is_lock = 0;
x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500);
x.create_id = _userManager.UserId;
x.modify_id = null;
x.modify_time = null;
x.is_mix = 1;
});
}
if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500);
x.id = SnowflakeIdHelper.NextId();
x.org_id = _userManager.User.OrganizeId;
x.is_lock = 0;
x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500);
x.create_id = _userManager.UserId;
x.modify_id = null;
x.modify_time = null;
x.is_mix = 1;
});
row = await _db.Insertable(locs).ExecuteCommandAsync();
}
catch (Exception ex)

View File

@@ -61,6 +61,7 @@ namespace Tnb.WarehouseMgr
{
List<Dictionary<string, object>> dics = input.list;
List<WmsCarryH> carrys = new List<WmsCarryH>();
Dictionary<string, object>? locs = null;
List<string> locCodes = new();
List<string> cStdCodes = new();
WmsCarryH carryH = new WmsCarryH();
@@ -68,8 +69,7 @@ namespace Tnb.WarehouseMgr
foreach (var d in dics)
{
var cStdCode = d["carrystd_id"].ToString() ?? string.Empty;
//if (cStdCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据载具规格不可为空", 500);
locCodes.Add(d["location_code"]?.ToString() ?? string.Empty);
locCodes.Add(d["location_code"].ToString() ?? string.Empty);
cStdCodes.Add(cStdCode);
d["create_time"] = DateTime.Now;
d.Remove("modify_time");
@@ -77,18 +77,19 @@ namespace Tnb.WarehouseMgr
carrys.Add(carryH);
}
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it => cStdCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
var locs = await _db.Queryable<BasLocation>().Where(it => locCodes.Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id);
if (locCodes?.Count > 0)
locs = await _db.Queryable<BasLocation>().Where(it => locCodes.Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id);
carrys.ForEach(x =>
{
if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的载具规格有误", 500);
if (!locs.Keys.Contains(x.location_code)) throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的库位编号有误", 500);
x.id = SnowflakeIdHelper.NextId();
x.org_id = _userManager.User.OrganizeId;
x.status = 1;
x.is_lock = 0;
x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的载具规格有误", 500);
x.carry_status = ((int)EnumCarryStatus.).ToString();
x.location_id = locs[x.location_code].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的库位编号有误", 500);
if (locs != null && x.location_code != null && x.location_code != string.Empty)
x.location_id = locs[x.location_code].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的库位编号有误", 500);
x.out_status = ((int)EnumOutStatus.).ToString();
x.is_check = 1;
x.create_id = _userManager.UserId;

View File

@@ -49,7 +49,6 @@ namespace Tnb.WarehouseMgr
var floor = d["floor"].ToString() ?? string.Empty;
if (pCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据点位编号不可为空", 500);
if (pName == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据点位名称不可为空", 500);
//if (aCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据管理区编号不可为空", 500);
if (floor == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500);
aCodes.Add(aCode);
d["create_time"] = DateTime.Now;

View File

@@ -83,10 +83,6 @@ namespace Tnb.WarehouseMgr
var eCode = d["endpoint_code"].ToString() ?? string.Empty;
var dis = d["distance"].ToString() ?? string.Empty;
if(sCode == eCode) throw new AppFriendlyException("起始点位不能等于终止点位", 500);
//if (sCode.IsEmpty())
// throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据数据起始点位编号不可为空", 500);
//if (eCode.IsEmpty())
// throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据终止点位编号不可为空", 500);
if (dis.IsEmpty())
throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据距离不可为空", 500);
pointCodes.Add(sCode);