Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class ChangeWorkerInput
|
||||
{
|
||||
public string mo_task_id { get; set; }
|
||||
public string worker_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
public int? complete_qty { get; set; }
|
||||
public int? scheduled_qty { get; set; }
|
||||
public string workline_id { get; set; }
|
||||
public string worker_id { get; set; }
|
||||
public string workline_id_id { get; set; }
|
||||
public string estimated_start_date { get; set; }
|
||||
public string estimated_end_date { get; set; }
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace Tnb.ProductionMgr.Entities.Entity
|
||||
/// </summary>
|
||||
public string erp_line_pk { get; set; }
|
||||
|
||||
public string user_id { get; set; }
|
||||
|
||||
public DateTime create_time { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2568,13 +2568,14 @@ namespace Tnb.ProductionMgr
|
||||
.LeftJoin<PrdMo>((a, b, c, d, e, f) => a.mo_id == f.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c, d, e, f, g) => a.workline_id == g.Id)
|
||||
.LeftJoin<EqpEquipment>((a, b, c, d, e, f, g, h) => a.eqp_id == h.id)
|
||||
.LeftJoin<UserEntity>((a, b, c, d, e, f, g, h,i)=>a.worker_id==i.Id)
|
||||
.WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(eqpId) && equipIds.Count <= 0 && worklineIds.Count <= 0,
|
||||
(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
|
||||
.Select((a, b, c, d, e, f, g, h,i) => new WorkOrderAdjustmentListOutput
|
||||
{
|
||||
id = a.id,
|
||||
mo_task_code = a.mo_task_code,
|
||||
@@ -2594,6 +2595,7 @@ namespace Tnb.ProductionMgr
|
||||
eqp_id_id = a.eqp_id,
|
||||
create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
|
||||
schedule_type = a.schedule_type,
|
||||
worker_id = i.RealName
|
||||
}).OrderByDescending(a => a.create_time).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<WorkOrderAdjustmentListOutput>.SqlSugarPageResult(result);
|
||||
}
|
||||
@@ -2844,6 +2846,53 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "更换成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更换员工
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> ChangeWorker(ChangeWorkerInput input)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
PrdMoTask moTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
||||
if (moTask.worker_id == input.worker_id)
|
||||
{
|
||||
throw new Exception("与原员工相同");
|
||||
}
|
||||
|
||||
|
||||
_ = await db.Updateable<PrdMoTask>().SetColumns(x => x.worker_id == input.worker_id)
|
||||
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
|
||||
|
||||
PrdMo mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
|
||||
BasMaterial? material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
|
||||
BasMaterial process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.process_id);
|
||||
PrdTaskLog taskLog = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
mo_code = mo?.mo_code!,
|
||||
eqp_code = "",
|
||||
mold_code = "",
|
||||
item_code = material?.code!,
|
||||
item_standard = material?.material_specification!,
|
||||
status = "更换员工",
|
||||
operator_name = _userManager.RealName,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
mo_task_id = moTask.id,
|
||||
mo_task_code = moTask.mo_task_code,
|
||||
station_code = "",
|
||||
process_code = process?.code
|
||||
};
|
||||
|
||||
_ = await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
|
||||
});
|
||||
|
||||
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "更换成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据id获取任务单相关信息
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF;
|
||||
using JNPF.Common.Core.Manager;
|
||||
@@ -432,6 +433,62 @@ namespace Tnb.ProductionMgr
|
||||
await _prdMoTaskService.PrdReport(input);
|
||||
return "true";
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<string> SendThirdApi(string thirdNmaes)
|
||||
{
|
||||
string[] thirdNameArr = thirdNmaes.Split("-");
|
||||
List<ThirdWebapiRecord> records = await _db.Queryable<ThirdWebapiRecord>().Where(x => thirdNameArr.Contains(x.third_name) && x.status == 0 && x.is_send == 1).ToListAsync();
|
||||
DateTime now = DateTime.Now;
|
||||
Stopwatch stopwatch = null;
|
||||
string response = "";
|
||||
var elapsedMilliseconds = 0l;
|
||||
ThirdResult thirdResult = null;
|
||||
foreach (var record in records)
|
||||
{
|
||||
now = DateTime.Now;
|
||||
stopwatch = Stopwatch.StartNew();
|
||||
switch (record.method.ToUpper())
|
||||
{
|
||||
case "GET":
|
||||
response = HttpUtils.RequestGet(record.url);
|
||||
break;
|
||||
case "POST":
|
||||
response = HttpUtils.RequestPost(record.url, record.request_data);
|
||||
break;
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
|
||||
thirdResult = JsonConvert.DeserializeObject<ThirdResult>(response);
|
||||
if (thirdResult.Code == 200)
|
||||
{
|
||||
await _db.Updateable<ThirdWebapiRecord>()
|
||||
.SetColumns(x => x.response_data == response)
|
||||
.SetColumns(x => x.response_code == thirdResult.Code)
|
||||
.SetColumns(x => x.last_send_time == now)
|
||||
.SetColumns(x => x.response_time == elapsedMilliseconds)
|
||||
.SetColumns(x => x.send_type == "自动")
|
||||
.SetColumns(x => x.status == 1)
|
||||
.Where(x=>x.id==record.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<ThirdWebapiRecord>()
|
||||
.SetColumns(x => x.response_data == response)
|
||||
.SetColumns(x => x.response_code == thirdResult.Code)
|
||||
.SetColumns(x => x.last_send_time == now)
|
||||
.SetColumns(x => x.response_time == elapsedMilliseconds)
|
||||
.Where(x=>x.id==record.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return "true";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user