diff --git a/BasicData/Tnb.BasicData.Entities/Dto/ThirdResult.cs b/BasicData/Tnb.BasicData.Entities/Dto/ThirdResult.cs
new file mode 100644
index 00000000..ba0ee32c
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Entities/Dto/ThirdResult.cs
@@ -0,0 +1,13 @@
+namespace Tnb.BasicData.Entities
+{
+ public class ThirdResult
+ {
+ public int Code { get; set; }
+ public string msgResult { get; set; }
+ }
+
+ // public enum ThirdResultCode
+ // {
+ // OK = 200
+ // }
+}
\ No newline at end of file
diff --git a/BasicData/Tnb.BasicData.Entities/Entity/ThirdWebapiRecord.cs b/BasicData/Tnb.BasicData.Entities/Entity/ThirdWebapiRecord.cs
new file mode 100644
index 00000000..e1e1bfa3
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Entities/Entity/ThirdWebapiRecord.cs
@@ -0,0 +1,78 @@
+using JNPF.Common.Contracts;
+using SqlSugar;
+
+namespace Tnb.BasicData.Entities
+{
+ ///
+ /// 第三方接口请求记录
+ ///
+ [SugarTable("third_webapi_record")]
+ public class ThirdWebapiRecord : BaseEntity
+ {
+ ///
+ /// 第三方名
+ ///
+ public string third_name { get; set; }
+
+ ///
+ /// 名称
+ ///
+ public string name { get; set; }
+
+ ///
+ /// 请求方式
+ ///
+ public string method { get; set; }
+
+ ///
+ /// 地址
+ ///
+ public string url { get; set; }
+
+ ///
+ /// 请求数据
+ ///
+ public string request_data { get; set; }
+
+ ///
+ /// 接收数据
+ ///
+ public string response_data { get; set; }
+
+ ///
+ /// 返回码
+ ///
+ public int response_code { get; set; }
+
+ ///
+ /// 响应时长
+ ///
+ public long response_time { get; set; }
+
+ ///
+ /// 是否发送 0 否 1是
+ ///
+ public int is_send { get; set; } = 1;
+
+ ///
+ /// 状态 0 失败或未发送 1 成功
+ ///
+ public int status { get; set; } = 0;
+
+ ///
+ /// 发送成功时类型 自动 手动
+ ///
+ public string send_type { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime create_time { get; set; }
+
+ ///
+ /// 最后发送时间
+ ///
+ public DateTime? last_send_time { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs
new file mode 100644
index 00000000..33ecc31a
--- /dev/null
+++ b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs
@@ -0,0 +1,80 @@
+using System.Diagnostics;
+using JNPF.Common.Core.Manager;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.Extras.CollectiveOAuth.Utils;
+using JNPF.Systems.Interfaces.Permission;
+using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
+using SqlSugar;
+using Tnb.BasicData.Entities;
+
+namespace Tnb.BasicData
+{
+ ///
+ /// 第三方接口发送记录
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+ public class ThirdApiRecordService : IDynamicApiController, ITransient
+ {
+ private readonly ISqlSugarRepository _repository;
+ private readonly IUserManager _userManager;
+
+ public ThirdApiRecordService(
+ ISqlSugarRepository repository,
+ IUserManager userManager
+ )
+ {
+ _repository = repository;
+ _userManager = userManager;
+ }
+
+ [HttpGet]
+ public async Task Send(string id)
+ {
+ var db = _repository.AsSugarClient();
+ string response = "";
+ ThirdWebapiRecord record = await _repository.GetSingleAsync(x=>x.id==id);
+ DateTime now = DateTime.Now;
+ Stopwatch 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();
+ var elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
+ ThirdResult thirdResult = JsonConvert.DeserializeObject(response);
+ if (thirdResult.Code == 200)
+ {
+ await db.Updateable()
+ .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()
+ .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 thirdResult.Code == 200 ? "成功" : "失败";
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeWorkerInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeWorkerInput.cs
new file mode 100644
index 00000000..63039a1f
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ChangeWorkerInput.cs
@@ -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; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs
index fb6e5593..ff06053e 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs
@@ -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; }
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs
index fff0a467..2133e2b0 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpExtendField.cs
@@ -35,6 +35,8 @@ namespace Tnb.ProductionMgr.Entities.Entity
///
public string erp_line_pk { get; set; }
+ public string user_id { get; set; }
+
public DateTime create_time { get; set; }
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index ce318912..d74ca75b 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -2568,13 +2568,14 @@ namespace Tnb.ProductionMgr
.LeftJoin((a, b, c, d, e, f) => a.mo_id == f.id)
.LeftJoin((a, b, c, d, e, f, g) => a.workline_id == g.Id)
.LeftJoin((a, b, c, d, e, f, g, h) => a.eqp_id == h.id)
+ .LeftJoin((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.SqlSugarPageResult(result);
}
@@ -2844,6 +2846,53 @@ namespace Tnb.ProductionMgr
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "更换成功" : result.ErrorMessage);
}
+
+ ///
+ /// 更换员工
+ ///
+ ///
+ [HttpPost]
+ public async Task ChangeWorker(ChangeWorkerInput input)
+ {
+ ISqlSugarClient db = _repository.AsSugarClient();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+ PrdMoTask moTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id);
+ if (moTask.worker_id == input.worker_id)
+ {
+ throw new Exception("与原员工相同");
+ }
+
+
+ _ = await db.Updateable().SetColumns(x => x.worker_id == input.worker_id)
+ .Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
+
+ PrdMo mo = await db.Queryable().SingleAsync(x => x.id == moTask.mo_id);
+ BasMaterial? material = await db.Queryable().SingleAsync(x => x.id == moTask.material_id);
+ BasMaterial process = await db.Queryable().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(taskLog).ExecuteCommandAsync();
+ });
+
+ return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "更换成功" : result.ErrorMessage);
+ }
///
/// 根据id获取任务单相关信息
diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
index 85420290..48f2024d 100644
--- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
@@ -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 SendThirdApi(string thirdNmaes)
+ {
+ string[] thirdNameArr = thirdNmaes.Split("-");
+ List records = await _db.Queryable().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(response);
+ if (thirdResult.Code == 200)
+ {
+ await _db.Updateable()
+ .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()
+ .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";
+ }
}
}
\ No newline at end of file
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
index 305aeb52..e626ac42 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
@@ -468,6 +468,15 @@
/// 血路管自动生产线2线
///
public const string XUELUGUAN2XIAN = "25966313322789";
-
+
+ ///
+ /// 第三方 bip
+ ///
+ public const string BIP = "BIP";
+
+ ///
+ /// 第三方 bip
+ ///
+ public const string BIP_DOMAIN = "http://192.168.1.11:8087/";
}
}
diff --git a/system/Tnb.Systems/Common/TestService.cs b/system/Tnb.Systems/Common/TestService.cs
index 68d6783c..c8786b91 100644
--- a/system/Tnb.Systems/Common/TestService.cs
+++ b/system/Tnb.Systems/Common/TestService.cs
@@ -1,4 +1,8 @@
-using JNPF.Common.Core.Manager;
+using JNPF.Common.Const;
+using JNPF.Common.Contracts;
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Security;
+using JNPF.DataEncryption;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.JsonSerialization;
@@ -7,7 +11,9 @@ using JNPF.Systems.Entitys.Permission;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
+using Npgsql.TypeHandlers;
using SqlSugar;
+using Tnb.ProductionMgr.Entities.Entity;
namespace JNPF.Systems.Common;
@@ -82,5 +88,67 @@ public class TestService : IDynamicApiController, ITransient
user.Account = "2312321";
}
+
+ [HttpGet]
+ [AllowAnonymous]
+ public string test1()
+ {
+ return "测试成功";
+ }
+
+ [HttpGet]
+ [AllowAnonymous]
+ public async Task insertUser()
+ {
+ List users = _sugar.Queryable().ToList();
+ List insertUsers = new List();
+ List insertUserRelations = new List();
+ List insertErpExtendFields = new List();
+ foreach (var user in users)
+ {
+ UserEntity userEntity = new UserEntity();
+ userEntity.Id = SnowflakeIdHelper.NextId();
+ userEntity.Account = user.code;
+ userEntity.RealName = user.name;
+ userEntity.Gender = 1;
+ userEntity.OrganizeId = "25193668006933";
+ userEntity.RoleId = "30327535942933";
+ userEntity.Secretkey = Guid.NewGuid().ToString();
+ userEntity.Password = MD5Encryption.Encrypt(MD5Encryption.Encrypt(CommonConst.DEFAULTPASSWORD) + userEntity.Secretkey);
+ userEntity.EntryDate = DateTime.Now;
+ userEntity.EnabledMark = 1;
+ userEntity.CreatorTime = DateTime.Now;
+ insertUsers.Add(userEntity);
+
+ UserRelationEntity userRelationEntity = new UserRelationEntity();
+ userRelationEntity.Id = SnowflakeIdHelper.NextId();
+ userRelationEntity.UserId = userEntity.Id;
+ userRelationEntity.ObjectType = "Role";
+ userRelationEntity.ObjectId = "30327535942933";
+ userRelationEntity.CreatorTime = DateTime.Now;
+ insertUserRelations.Add(userRelationEntity);
+
+ ErpExtendField extendField = new ErpExtendField();
+ extendField.id = SnowflakeIdHelper.NextId();
+ extendField.org_id = "25398501929509";
+ extendField.table_name = "base_user";
+ extendField.table_id = userEntity.Id;
+ extendField.user_id = user.id;
+ insertErpExtendFields.Add(extendField);
+ }
+
+ await _sugar.Insertable(insertUsers).ExecuteCommandAsync();
+ await _sugar.Insertable(insertUserRelations).ExecuteCommandAsync();
+ await _sugar.Insertable(insertErpExtendFields).ExecuteCommandAsync();
+ return "测试成功";
+ }
+
+
+ [SugarTable("temp_erp_user")]
+ public class TempErpUser : BaseEntity
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ }
}