340 lines
13 KiB
C#
340 lines
13 KiB
C#
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;
|
|
using JNPF.Logging.Attributes;
|
|
using JNPF.Systems.Entitys.Permission;
|
|
using JNPF.Systems.Entitys.System;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Cors;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using Npgsql.TypeHandlers;
|
|
using SqlSugar;
|
|
using Tnb.BasicData.Entities;
|
|
using Tnb.ProductionMgr.Entities.Entity;
|
|
using Tnb.ProductionMgr.Entities.Entity.ErpEntity;
|
|
using Tnb.WarehouseMgr.Entities.Entity;
|
|
using Tnb.WarehouseMgr.Entities.Consts;
|
|
using Tnb.BasicData;
|
|
using Tnb.WarehouseMgr.Entities;
|
|
|
|
namespace JNPF.Systems.Common;
|
|
|
|
/// <summary>
|
|
/// 测试接口.
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Name = "Test", Order = 306)]
|
|
[Route("api")]
|
|
public class TestService : IDynamicApiController, ITransient
|
|
{
|
|
//private readonly ISqlSugarRepository<UserEntity> _repository;
|
|
private readonly SqlSugarScope _sugar;
|
|
private readonly IDataBaseManager _databaseService;
|
|
|
|
public TestService(ISqlSugarClient db, IDataBaseManager databaseService)
|
|
{
|
|
//_repository = repository;
|
|
_sugar = (SqlSugarScope)db;
|
|
_databaseService = databaseService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 用于健康检查应用程序
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("heart-beat")]
|
|
[AllowAnonymous]
|
|
[IgnoreLog]
|
|
[DisableCors]
|
|
public async Task<dynamic> Heartbeat()
|
|
{
|
|
return await Task.FromResult<dynamic>(new { reply = "应用程序运行正常" });
|
|
}
|
|
|
|
[HttpGet("test")]
|
|
[AllowAnonymous]
|
|
[IgnoreLog]
|
|
[DisableCors]
|
|
public async Task<dynamic> test()
|
|
{
|
|
try
|
|
{
|
|
//var aaaaa= JsEngineUtil.AggreFunction("COUNT('1','1','1')").ToString();
|
|
//var xx = App.HttpContext.Request.Host.ToString();
|
|
//var sql = "SELECT TOP 1 [F_PARENTID],[F_PROCESSID],[F_ENCODE],[F_FULLNAME],[F_FLOWURGENT],[F_FLOWID],[F_FLOWCODE],[F_FLOWNAME],[F_FLOWTYPE],[F_FLOWCATEGORY],[F_FLOWFORM],[F_FLOWFORMCONTENTJSON],[F_FLOWTEMPLATEJSON],[F_FLOWVERSION],[F_STARTTIME],[F_ENDTIME],[F_THISSTEP],[F_THISSTEPID],[F_GRADE],[F_STATUS],[F_COMPLETION],[F_DESCRIPTION],[F_SORTCODE],[F_ISASYNC],[F_ISBATCH],[F_TASKNODEID],[F_TEMPLATEID],[F_REJECTDATAID],[F_DELEGATEUSER],[F_CREATORTIME],[F_CREATORUSERID],[F_ENABLEDMARK],[F_LastModifyTime],[F_LastModifyUserId],[F_DeleteMark],[F_DeleteTime],[F_DeleteUserId],[F_Id] FROM [FLOW_TASK] WHERE (( [F_DeleteMark] IS NULL ) AND ( [F_Id] = N'367536153122855173' ))";
|
|
//var darta = _sqlSugarRepository.AsSugarClient().Ado.SqlQuery<dynamic>(sql);
|
|
var data = await _sugar.Queryable<UserEntity>().FirstAsync(a => true);
|
|
var json = App.GetService<IJsonSerializerProvider>();
|
|
return data;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task ImportMoldData()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
public void xx(UserEntity user)
|
|
{
|
|
user.Account = "2312321";
|
|
|
|
}
|
|
|
|
public void xx1(UserEntity user)
|
|
{
|
|
user.Account = "2312321";
|
|
|
|
}
|
|
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public string test1()
|
|
{
|
|
var mysqlDb = _sugar.GetConnection("erpdb");
|
|
List<BasFactoryConfig2> list = mysqlDb.Queryable<BasFactoryConfig2>().ToList();
|
|
List<BasMaterial> list2 = _sugar.Queryable<BasMaterial>().ToList();
|
|
return JsonConvert.SerializeObject(list);
|
|
}
|
|
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public async Task<string> test2()
|
|
{
|
|
WmsMaterialTransferD wmsMaterialTransferd = await _sugar.Queryable<WmsMaterialTransferD>().Where(r => r.id == "35610026468885").SingleAsync();
|
|
WmsMaterialTransfer wmsMaterialTransfer = await _sugar.Queryable<WmsMaterialTransfer>().SingleAsync(x => x.id == wmsMaterialTransferd.bill_id);
|
|
List<WmsMaterialTransferD> dList = await _sugar.Queryable<WmsMaterialTransferD>().Where(x => x.bill_id == wmsMaterialTransferd.bill_id).OrderBy(x=>x.id).ToListAsync();
|
|
DictionaryDataEntity unitData = await _sugar.Queryable<DictionaryTypeEntity>()
|
|
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
|
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode == wmsMaterialTransferd.unit_id)
|
|
.Select((x,y)=>y)
|
|
.FirstAsync();
|
|
List<string> ids = new List<string>();
|
|
ids.Add(wmsMaterialTransfer.create_id);
|
|
ids.Add(WmsWareHouseConst.AdministratorOrgId);
|
|
ids.Add(wmsMaterialTransfer.warehouse_outstock);
|
|
ids.Add(wmsMaterialTransfer.warehouse_instock);
|
|
ids.Add(wmsMaterialTransferd.material_id);
|
|
if (unitData != null)
|
|
{
|
|
ids.Add(unitData.Id);
|
|
}
|
|
List<ErpExtendField> erpExtendFields = await _sugar.Queryable<ErpExtendField>().Where(x=>ids.Contains(x.table_id)).ToListAsync();
|
|
|
|
ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (wmsMaterialTransfer.org_id ?? WmsWareHouseConst.AdministratorOrgId));
|
|
string erpCreateId = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.create_id)?.user_id ?? "";
|
|
|
|
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
|
Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
|
|
string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
erpRequestData.Add("billmaker",erpCreateId);
|
|
erpRequestData.Add("cdptid","1001A1100000000JRLI1");// 先写死
|
|
erpRequestData.Add("cdptvid","0001A11000000007GGO8");// 先写死
|
|
erpRequestData.Add("corpoid",erpOrg.corpoid);
|
|
erpRequestData.Add("corpvid",erpOrg.corpoid);
|
|
erpRequestData.Add("cothercalbodyoid",erpOrg.pk_org);
|
|
erpRequestData.Add("cotherwhid",erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? "");
|
|
erpRequestData.Add("creationtime",nowStr);
|
|
erpRequestData.Add("creator",erpCreateId);
|
|
erpRequestData.Add("ctrantypeid","0001H11000000000D31W");
|
|
erpRequestData.Add("cwarehouseid",erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_outstock)?.cotherwhid ?? "");
|
|
erpRequestData.Add("dbilldate",nowStr);
|
|
erpRequestData.Add("dmakedate",nowStr);
|
|
erpRequestData.Add("ntotalnum",20);
|
|
erpRequestData.Add("pk_group",erpOrg.pk_group);
|
|
erpRequestData.Add("pk_org",erpOrg.pk_org);
|
|
erpRequestData.Add("pk_org_v",erpOrg.pk_org_v);
|
|
erpRequestData.Add("vbillcode",wmsMaterialTransfer.bill_code);
|
|
erpRequestData.Add("vtrantypecode","4I-01");//其他出库 先写死
|
|
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
|
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
|
{
|
|
["cbodytranstypecode"] = "4I-01",
|
|
["cbodywarehouseid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_outstock)?.cotherwhid ?? "",
|
|
["cmaterialoid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransferd.material_id)?.cmaterialoid ?? "",
|
|
["cmaterialvid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransferd.material_id)?.cmaterialvid ?? "",
|
|
["corpoid"] = erpOrg.corpoid,
|
|
["corpvid"] = erpOrg.corpvid,
|
|
["crowno"] = wmsMaterialTransferd.lineno,
|
|
["csourcebillbid"] = wmsMaterialTransferd.erp_line_pk,
|
|
["csourcebillhid"] = wmsMaterialTransfer.erp_pk,
|
|
["cunitid"] = erpExtendFields.Find(x=>x.table_id==unitData.Id)?.cunitid ?? "",
|
|
["cvendorid"] = "",
|
|
["cvendorvid"] = "",
|
|
["dbizdate"] = nowStr,
|
|
["nnum"] = 20,
|
|
["nshouldnum"] = wmsMaterialTransferd.qty,
|
|
["pk_group"] = erpOrg.pk_group,
|
|
["pk_org"] = erpOrg.pk_org,
|
|
["pk_org_v"] = erpOrg.pk_org_v,
|
|
["vbatchcode"] = wmsMaterialTransferd.code_batch,
|
|
});
|
|
erpRequestData.Add("dtls",erpRequestDataDetails);
|
|
requestData.Add(erpRequestData);
|
|
|
|
ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord();
|
|
thirdWebapiRecord.id = SnowflakeIdHelper.NextId();
|
|
thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
|
|
thirdWebapiRecord.name = "其它出库";
|
|
thirdWebapiRecord.method = "POST";
|
|
thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/generalout/save";
|
|
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData);
|
|
thirdWebapiRecord.create_time = DateTime.Now;
|
|
|
|
await _sugar.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
|
return "123";
|
|
}
|
|
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public async Task<string> insertUser()
|
|
{
|
|
List<TempErpUser> users = _sugar.Queryable<TempErpUser>().ToList();
|
|
List<UserEntity> insertUsers = new List<UserEntity>();
|
|
List<UserRelationEntity> insertUserRelations = new List<UserRelationEntity>();
|
|
List<ErpExtendField> insertErpExtendFields = new List<ErpExtendField>();
|
|
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);
|
|
|
|
UserRelationEntity userRelationEntity2 = new UserRelationEntity();
|
|
userRelationEntity2.Id = SnowflakeIdHelper.NextId();
|
|
userRelationEntity2.UserId = userEntity.Id;
|
|
userRelationEntity2.ObjectType = "Organize";
|
|
userRelationEntity2.ObjectId = "25193668006933";
|
|
userRelationEntity2.CreatorTime = DateTime.Now;
|
|
insertUserRelations.Add(userRelationEntity2);
|
|
|
|
ErpExtendField extendField = new ErpExtendField();
|
|
extendField.org_id = "25193668006933";
|
|
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<string>
|
|
{
|
|
public string code { get; set; }
|
|
public string name { get; set; }
|
|
}
|
|
|
|
[SugarTable("bas_factory_config")]
|
|
public partial class BasFactoryConfig2 : BaseEntity<string>
|
|
{
|
|
public BasFactoryConfig2()
|
|
{
|
|
id = SnowflakeIdHelper.NextId();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 名称
|
|
/// </summary>
|
|
public string name { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// key
|
|
/// </summary>
|
|
public string code { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 值
|
|
/// </summary>
|
|
public string value { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 是否启用
|
|
/// </summary>
|
|
public int enabled { get; set; }
|
|
|
|
/// <summary>
|
|
/// 备注
|
|
/// </summary>
|
|
public string? remark { get; set; }
|
|
|
|
/// <summary>
|
|
/// 创建用户
|
|
/// </summary>
|
|
public string? create_id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 创建时间
|
|
/// </summary>
|
|
public DateTime? create_time { get; set; }
|
|
|
|
/// <summary>
|
|
/// 修改用户
|
|
/// </summary>
|
|
public string? modify_id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 修改时间
|
|
/// </summary>
|
|
public DateTime? modify_time { get; set; }
|
|
|
|
/// <summary>
|
|
/// 所属组织
|
|
/// </summary>
|
|
public string? org_id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
public long? ordinal { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否系统
|
|
/// </summary>
|
|
public int? is_system { get; set; }
|
|
|
|
/// <summary>
|
|
/// 流程任务Id
|
|
/// </summary>
|
|
public string? f_flowtaskid { get; set; }
|
|
|
|
/// <summary>
|
|
/// 流程引擎Id
|
|
/// </summary>
|
|
public string? f_flowid { get; set; }
|
|
}
|
|
|
|
}
|