This commit is contained in:
yang.lee
2023-12-01 22:16:49 +08:00
11 changed files with 216 additions and 40 deletions

View File

@@ -37,4 +37,10 @@
public string result { get; set; }
}
public class MaintainItemResult
{
public string item_name { get; set; }
public string group_name { get; set; }
public string result { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tnb.EquipMgr.Entities
{
public class MoldStartWxInput
{
public string? id { get; set; }
}
}

View File

@@ -16,5 +16,6 @@
public string plan_start_time { get; set; }
public string starttime { get; set; }
public string finishtime { get; set; }
}
}

View File

@@ -20,5 +20,6 @@ namespace Tnb.EquipMgr.Entities.Dto
public string repairer_id { get; set; }
public string repairer_id_id { get; set; }
public string status { get; set; }
public string attachment { get; set; }
}
}

View File

@@ -53,4 +53,12 @@ public partial class ToolMoldMaintainTask : BaseEntity<string>
/// </summary>
public string status { get; set; }
public string? name { get; set; }
public string? attachment { get; set; }
public string? describe { get; set; }
public int is_finish { get; set; }
public string? wxattachment { get; set; }
public string? wxdescribe { get; set; }
}

View File

@@ -397,7 +397,8 @@ namespace Tnb.EquipMgr
repairer_id = c.RealName,
repairer_id_id = c.Id,
remark = a.remark,
status = f.FullName
status = f.FullName,
attachment=a.attachment
}).ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
return PageResult<PadRepairListOutput>.SqlSugarPageResult(result);

View File

@@ -196,33 +196,35 @@ namespace Tnb.EquipMgr
else
{
input.sidx = "b." + input.sidx;
input.sort = "desc";
}
List<string> records = await _db.Queryable<ToolMoldMaintainItemRecord>().Select(p => p.plan_id + p.mold_id).ToListAsync();
SqlSugarPagedList<PadMainListOutput> result = await _db.Queryable<ToolMoldMaintainPlanRelation>()
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c, d) => b.plan_code == d.plan_code && c.mold_code == d.mold_code)
.LeftJoin<ToolMoldMaintainItemRecord>((a, b, c, d, e) => e.plan_id == b.id && e.mold_id == c.id)
.LeftJoin<UserEntity>((a, b, c, d, e, f) => b.create_id == f.Id)
.LeftJoin<DictionaryDataEntity>((a, b, c, d, e, f, g) => c.mold_status == g.Id)
// .LeftJoin<ToolMoldMaintainItemRecord>((a, b, c, d, e) => e.plan_id == b.id && e.mold_id == c.id)
.LeftJoin<UserEntity>((a, b, c, d, e) => b.create_id == e.Id)
.LeftJoin<DictionaryDataEntity>((a, b, c, d, e, f) => c.mold_status == f.Id)
.Where((a, b, c, d, e, f) => b.create_time != null)
.WhereIF(!string.IsNullOrEmpty(input.maintain_info), (a, b, c, d, e, f, g) => c.mold_code!.Contains(input.maintain_info) || c.mold_name!.Contains(input.maintain_info))
.WhereIF(start_time != null, (a, b, c, d, e, f, g) => b.create_time != null && b.create_time >= start_time)
.WhereIF(end_time != null, (a, b, c, d, e, f, g) => b.create_time != null && b.create_time <= end_time)
.WhereIF(input.status == "待保养", (a, b, c, d, e, f, g) => !records.Contains(a.maintain_plan_id + a.mold_id))
.WhereIF(input.status == "已完成", (a, b, c, d, e, f, g) => records.Contains(a.maintain_plan_id + a.mold_id))
.Select((a, b, c, d, e, f, g) => new PadMainListOutput
.WhereIF(!string.IsNullOrEmpty(input.maintain_info), (a, b, c, d, e, f) => c.mold_code!.Contains(input.maintain_info) || c.mold_name!.Contains(input.maintain_info))
.WhereIF(start_time != null, (a, b, c, d, e, f) => b.create_time != null && b.create_time >= start_time)
.WhereIF(end_time != null, (a, b, c, d, e, f) => b.create_time != null && b.create_time <= end_time)
.WhereIF(input.status == "待保养", (a, b, c, d, e, f) => !records.Contains(a.maintain_plan_id + a.mold_id))
.WhereIF(input.status == "已完成", (a, b, c, d, e, f) => records.Contains(a.maintain_plan_id + a.mold_id))
.Select((a, b, c, d, e, f) => new PadMainListOutput
{
plan_id = b.id,
mold_id = c.id,
mold_code = c.mold_code!,
mold_name = c.mold_name!,
mold_status = g.FullName!,
mold_status = f.FullName!,
status = input.status,
createuser = f.RealName,
createuser = e.RealName,
createtime = b.create_time == null ? "" : b.create_time.Value.ToString(DbTimeFormat.SS),
plan_start_time = b.plan_start_date == null ? "" : b.plan_start_date.Value.ToString(DbTimeFormat.SS),
starttime = d.plan_start_time == null ? "" : d.plan_start_time.Value.ToString(DbTimeFormat.SS),
finishtime= d.plan_end_time == null ? "" : d.plan_end_time.Value.ToString(DbTimeFormat.SS),
}).OrderBy($"{input.sidx} {input.sort}").ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
return PageResult<PadMainListOutput>.SqlSugarPageResult(result);
}
@@ -303,7 +305,23 @@ namespace Tnb.EquipMgr
return items;
}
[HttpPost]
public async Task<dynamic> GetMaintainItem(MoldMaintainRunUpInput input)
{
var data = await _db.Queryable<ToolMoldMaintainItemRecord>()
.LeftJoin<ToolMoldMaintainItem>((a, b) => a.item_id == b.id)
.LeftJoin<ToolMoldMaintainGroup>((a, b, c) => a.item_group_id == c.id)
.Where((a, b, c) => a.plan_id == input.plan_id && a.mold_id == input.mold_id)
.Select((a, b, c) => new MaintainItemResult
{
group_name = c.name!,
item_name = b.name!,
result = a.result,
})
.ToListAsync();
return data;
}
/// <summary>
/// 模具保养计划执行-开始模具保养
/// </summary>
@@ -447,6 +465,11 @@ namespace Tnb.EquipMgr
{
throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty");
}
var plan_code = _db.Queryable<ToolMoldMaintainPlan>().Where(p => p.id == input.plan_id).Select(p=>p.plan_code).First();
var mold_code = _db.Queryable<ToolMolds>().Where(p => p.id == input.mold_id).Select(p => p.mold_code).First();
if (!string.IsNullOrEmpty(plan_code)&& !string.IsNullOrEmpty(mold_code)) {
_ = await _db.Updateable<ToolMoldMaintainRunRecord>().SetColumns(it => new ToolMoldMaintainRunRecord { plan_end_time = DateTime.Now }).Where(it => it.plan_code == plan_code && it.mold_code== mold_code).ExecuteCommandAsync();
}
List<ToolMoldMaintainItemRecord> records = new();
foreach (MaintainItemInfo item in input.items)
@@ -505,6 +528,11 @@ namespace Tnb.EquipMgr
}
}
/// <summary>
/// 模具保养计划执行-保养完成
/// </summary>

View File

@@ -1,4 +1,5 @@
using JNPF.Common.Enums;
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
@@ -29,16 +30,19 @@ namespace Tnb.EquipMgr
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
private static Dictionary<string, (string code, string name)> _dicMold = new();
private readonly IUserManager _userManager;
public ToolMoldMaintainTaskService(
ISqlSugarRepository<ToolMoldMaintainTask> repository,
IRunService runService,
IVisualDevService visualDevService
IVisualDevService visualDevService,
IUserManager userManager
)
{
_db = repository.AsSugarClient();
_runService = runService;
_visualDevService = visualDevService;
OverideFuncs.GetListAsync = GetList;
_userManager = userManager;
//OverideFuncs.CreateAsync = Create;
}
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
@@ -100,5 +104,23 @@ namespace Tnb.EquipMgr
throw Oops.Oh(ErrorCode.COM1001);
}
}
/// <summary>
/// 开始维修
/// </summary>
/// <param name="input">输入参数</param>
/// <returns></returns>
[HttpPost]
public async Task StartWx(MoldStartWxInput input)
{
DateTime? StartTime = DateTime.Now;
int row = await _db.Updateable<ToolMoldMaintainTask>().SetColumns(it => new ToolMoldMaintainTask { status = "WXZ", modify_strat_time = StartTime, modify_id = _userManager.UserId })
.Where(it => input.id == it.id).ExecuteCommandAsync();
if (row < 1)
{
throw Oops.Oh(ErrorCode.COM1001);
}
}
}
}

View File

@@ -0,0 +1,9 @@
using JNPF.Common.Filter;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Tnb.ProductionMgr.Entities.Dto
{
public class AndonPdaListInput : PageInputBase
{
}
}

View File

@@ -68,17 +68,75 @@ namespace Tnb.ProductionMgr
andon_info_name = b.name,
promoter_name = d.RealName,
repair_name = c.RealName,
promoter_time = a.create_time == null ? "" : a.create_time.Value.ToString("yyyy-MM-dd hh:mm:ss"),
response_time = a.response_time == null ? "" : a.response_time.Value.ToString("yyyy-MM-dd hh:mm:ss"),
start_repair_time = a.start_repair_time == null ? "" : a.start_repair_time.Value.ToString("yyyy-MM-dd hh:mm:ss"),
end_repair_time = a.end_repair_time == null ? "" : a.end_repair_time.Value.ToString("yyyy-MM-dd hh:mm:ss"),
confirm_time = a.confirm_time == null ? "" : a.confirm_time.Value.ToString("yyyy-MM-dd hh:mm:ss"),
promoter_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
response_time = a.response_time == null ? "" : a.response_time.Value.ToString(DbTimeFormat.SS),
start_repair_time = a.start_repair_time == null ? "" : a.start_repair_time.Value.ToString(DbTimeFormat.SS),
end_repair_time = a.end_repair_time == null ? "" : a.end_repair_time.Value.ToString(DbTimeFormat.SS),
confirm_time = a.confirm_time == null ? "" : a.confirm_time.Value.ToString(DbTimeFormat.SS),
status = f.FullName,
}).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<AndonPadListOutput>.SqlSugarPageResult(result);
}
[HttpPost]
public async Task<dynamic> GetAndonPdaList(AndonPdaListInput input)
{
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
string? status = queryJson.ContainsKey("status") ? queryJson["status"].ToString() : "";
List<string> statusList = new();
if (!string.IsNullOrEmpty(status))
{
switch (status)
{
case "1":
statusList.Add(DictConst.AndonStatusHJZ);
break;
case "2":
statusList.Add(DictConst.AndonStatusYXY);
statusList.Add(DictConst.AndonStatusCLZ);
break;
case "3":
statusList.Add(DictConst.AndonStatusDQR);
statusList.Add(DictConst.AndonStatusYWC);
break;
}
}
if (string.IsNullOrEmpty(input.sidx))
{
input.sidx = "create_time";
input.sort = "desc";
}
SqlSugarPagedList<AndonPadListOutput> result = await _db.Queryable<AndonRecords>()
.LeftJoin<AndonInfo>((a, b) => a.andon_info_id == b.id)
.LeftJoin<UserEntity>((a, b, c) => a.repair_id == c.Id)
.LeftJoin<UserEntity>((a, b, c, d) => a.create_id == d.Id)
.LeftJoin<DictionaryTypeEntity>((a, b, c, d, e) => e.EnCode == DictConst.AndonStatus)
.LeftJoin<DictionaryDataEntity>((a, b, c, d, e, f) => a.status == f.EnCode && e.Id == f.DictionaryTypeId)
.WhereIF(statusList.Count > 0, a => statusList.Contains(a.status))
.Select((a, b, c, d, e, f) => new AndonPadListOutput
{
id = a.id,
andon_info_name = b.name,
promoter_name = d.RealName,
repair_name = c.RealName,
promoter_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
response_time = a.response_time == null ? "" : a.response_time.Value.ToString(DbTimeFormat.SS),
start_repair_time = a.start_repair_time == null ? "" : a.start_repair_time.Value.ToString(DbTimeFormat.SS),
end_repair_time = a.end_repair_time == null ? "" : a.end_repair_time.Value.ToString(DbTimeFormat.SS),
confirm_time = a.confirm_time == null ? "" : a.confirm_time.Value.ToString(DbTimeFormat.SS),
status = f.FullName,
})
.MergeTable()
.OrderBy($"{input.sidx} {input.sort}")
.ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<AndonPadListOutput>.SqlSugarPageResult(result);
}
[HttpPost]
public async Task<dynamic> AddAndon(AddAndonInput input)
@@ -247,19 +305,28 @@ namespace Tnb.ProductionMgr
AndonRecords andonRecords = await _db.Queryable<AndonRecords>().SingleAsync(x => x.id == id);
if (andonRecords != null)
{
if (andonRecords.status != DictConst.AndonStatusYXY)
if (andonRecords.repair_id!=_userManager.UserId)
{
throw Oops.Bah($"状态错误");
UserEntity user = await _db.Queryable<UserEntity>().SingleAsync(x => x.Id == andonRecords.repair_id);
throw Oops.Bah($"您不是处理人");
}
else
{
_ = await _db.Updateable<AndonRecords>()
.SetColumns(x => x.start_repair_time == DateTime.Now)
.Where(x => x.id == id)
.ExecuteCommandAsync();
return true;
if (andonRecords.status != DictConst.AndonStatusYXY)
{
throw Oops.Bah($"状态错误");
}
else
{
_ = await _db.Updateable<AndonRecords>()
.SetColumns(x => x.start_repair_time == DateTime.Now)
.Where(x => x.id == id)
.ExecuteCommandAsync();
return true;
}
}
}
else
{
@@ -274,19 +341,28 @@ namespace Tnb.ProductionMgr
AndonRecords andonRecords = await _db.Queryable<AndonRecords>().SingleAsync(x => x.id == id);
if (andonRecords != null)
{
if (andonRecords.status != DictConst.AndonStatusCLZ)
if (andonRecords.repair_id!=_userManager.UserId)
{
throw Oops.Bah($"状态错误");
UserEntity user = await _db.Queryable<UserEntity>().SingleAsync(x => x.Id == andonRecords.repair_id);
throw Oops.Bah($"您不是处理人");
}
else
{
_ = await _db.Updateable<AndonRecords>()
.SetColumns(x => x.end_repair_time == DateTime.Now)
.Where(x => x.id == id)
.ExecuteCommandAsync();
return true;
if (andonRecords.status != DictConst.AndonStatusCLZ)
{
throw Oops.Bah($"状态错误");
}
else
{
_ = await _db.Updateable<AndonRecords>()
.SetColumns(x => x.end_repair_time == DateTime.Now)
.Where(x => x.id == id)
.ExecuteCommandAsync();
return true;
}
}
}
else
{
@@ -301,19 +377,28 @@ namespace Tnb.ProductionMgr
AndonRecords andonRecords = await _db.Queryable<AndonRecords>().SingleAsync(x => x.id == id);
if (andonRecords != null)
{
if (andonRecords.status != DictConst.AndonStatusYWC)
if (andonRecords.repair_id!=_userManager.UserId)
{
throw Oops.Bah($"状态错误");
UserEntity user = await _db.Queryable<UserEntity>().SingleAsync(x => x.Id == andonRecords.repair_id);
throw Oops.Bah($"您不是处理人");
}
else
{
_ = await _db.Updateable<AndonRecords>()
.SetColumns(x => x.confirm_time == DateTime.Now)
.Where(x => x.id == id)
.ExecuteCommandAsync();
return true;
if (andonRecords.status != DictConst.AndonStatusYWC)
{
throw Oops.Bah($"状态错误");
}
else
{
_ = await _db.Updateable<AndonRecords>()
.SetColumns(x => x.confirm_time == DateTime.Now)
.Where(x => x.id == id)
.ExecuteCommandAsync();
return true;
}
}
}
else
{

View File

@@ -609,6 +609,8 @@ namespace Tnb.WarehouseMgr
.And((a, b, c) => a.status == (int)EnumCarryStatus.)
.And((a, b, c) => c.is_type == ((int)EnumLocationType.).ToString())
.And((a, b, c) => b.material_id == os.material_id)
.AndIF(!string.IsNullOrEmpty(os.material_specification), (a, b, c) => b.material_specification == os.material_specification)
.AndIF(!string.IsNullOrEmpty(os.container_no), (a, b, c) => b.container_no == os.container_no)
.AndIF(!string.IsNullOrEmpty(os.code_batch), (a, b, c) => b.code_batch == os.code_batch);
List<WmsCarryCode> carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)