312 lines
11 KiB
C#
312 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Threading.Tasks;
|
|
|
|
using APT.Domain;
|
|
using APT.Infrastructure.Api.WebFilters;
|
|
using APT.Infrastructure.Core;
|
|
using APT.Infrastructure.EF;
|
|
using APT.Infrastructure.EF.Infrastructure;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using APT.Infrastructure.Api;
|
|
namespace APT.API
|
|
{
|
|
public class ValuesController : CommonApiController
|
|
{
|
|
private readonly EfDbContext efDbContext;
|
|
|
|
public ValuesController(EfDbContext storeDbContext)
|
|
{
|
|
this.efDbContext = storeDbContext;
|
|
//this.storeDbContext.Database.EnsureCreated();
|
|
|
|
//this.storeDbContext.Database.Migrate();
|
|
}
|
|
[HttpGet, Route("api/values")]
|
|
|
|
public JsonActionResult<IEnumerable<APT_Test_User>> Get()
|
|
{
|
|
var commonService = ServiceLocator.Instance.GetService<ICommonService>();
|
|
////////return commonService.UnitWork();
|
|
//var param = new CodeRuleParam()
|
|
//{
|
|
// CodeType = 1014,
|
|
// OrgId = new Guid("b043b28b-bbc3-c452-6052-4fba1457abfa"),
|
|
// Count = 1,
|
|
//};
|
|
////var xx = commonService.GetRuleCodes(param);
|
|
var codeRule = new T_PF_CODE_RULE_SERIAL()
|
|
{
|
|
ID = Guid.NewGuid(),
|
|
CODE_TYPE = 3500,
|
|
ORG_ID = new Guid("b043b28b-bbc3-c452-6052-4fba1457abfa")
|
|
|
|
};
|
|
|
|
this.efDbContext.AddEntity(codeRule);
|
|
this.efDbContext.SaveChanges();
|
|
|
|
var db = this.efDbContext.GetEntity<T_PF_CODE_RULE_SERIAL>(t => t.CODE_TYPE == 3500, null);
|
|
//EfDbContext dbContext = new EfDbContext("User ID=postgres;Password=123456;Host=localhost;Port=5432;Database=Infracture_Test;CommandTimeout=1024;");
|
|
//var dbs = dbContext.GetEntity<T_PF_CODE_RULE_SERIAL>(t => t.CODE_TYPE == 3500, null);
|
|
////Expression<Func<T_PF_CODE_RULE_SERIAL, bool>> expression = t => t.ORG_ID == param.OrgId
|
|
//// && t.CODE_TYPE == 1038;
|
|
////expression = expression.And(t => t.DATE_VALUE == "20191016");
|
|
////var pageFilter = new BasePageFilter(1, 1);
|
|
////pageFilter.Sort = "NUM";
|
|
////pageFilter.Order = DbOrder.DESC;
|
|
////var maxDbCodeRuleSerial = this.GetOrderPageEntities<T_PF_CODE_RULE_SERIAL>(expression, pageFilter);
|
|
//ServiceLocator serviceLocator = ServiceLocator.Instance;
|
|
//var _connectionResolver = serviceLocator.GetService<IConnectionResolver>();
|
|
//var x1 = commonService.GetEntity<T_PF_CODE_RULE_SERIAL>(t => t.CODE_TYPE == 3500);
|
|
|
|
//x1.MODIFY_TIME = DateTime.Now;
|
|
//this.UpdateEntity(x1);
|
|
|
|
////x1.STATUS = 2;
|
|
|
|
////var x2 = commonService.GetEntity<T_PF_CODE_RULE_SERIAL>(t => t.CODE_TYPE == 3500 &&
|
|
//// t.ORG_ID == param.OrgId && t.STATUS == 0 && t.ID != x1.ID);
|
|
////x2.STATUS = 2;
|
|
////this.UpdateEntity(x2);
|
|
|
|
////Dictionary<string, object> bodyParams = new Dictionary<string, object>();
|
|
////bodyParams.Add("sn", "L1002497A000052");
|
|
////bodyParams.Add("stationId", "FinallyFunctionTest");
|
|
////Dictionary<string, string> headParams = new Dictionary<string, string>();
|
|
////headParams.Add("Access-Token", "D2B471BAA84582052F9AD2EE49FFB3EE");
|
|
|
|
////var ret = WebUtils.ExecuteByResolving<ExtTestResultModel>("http://172.20.8.29:9001/api/TestData/GetTestData",
|
|
//// bodyParams, string.Empty, SendType.Get, headParams);
|
|
|
|
//var sttr = WitEntities(null, new KeywordFilter());
|
|
//return sttr;
|
|
|
|
var entity = new TestNoneBaseModel
|
|
{
|
|
ID = "Test",
|
|
Name = "Test"
|
|
};
|
|
|
|
var entities = new List<TestNoneBaseModel>
|
|
{
|
|
new TestNoneBaseModel
|
|
{
|
|
ID = "Test1",
|
|
Name = "Test1"
|
|
},
|
|
new TestNoneBaseModel
|
|
{
|
|
ID = "Test2",
|
|
Name = "Test2"
|
|
}
|
|
};
|
|
|
|
//var str = commonService.AddAndGetEntity_noneBase<TestNoneBaseModel>(entity);
|
|
|
|
//commonService.AddEntities_noneBase(entities);
|
|
|
|
var str1 = commonService.GetEntity_noneBase<TestNoneBaseModel>(o => o.ID == "Test");
|
|
var strall = commonService.GetEntities_noneBase<TestNoneBaseModel>(o => o.ID.StartsWith("Test"));
|
|
|
|
|
|
return null;
|
|
}
|
|
[HttpGet, Route("api/asynctest")]
|
|
public async Task<JsonActionResult<bool>> asynctest(string id)
|
|
{
|
|
return await SafeExecuteAsync<bool>(async () =>
|
|
{
|
|
await GetAsync();
|
|
return true;
|
|
});
|
|
}
|
|
|
|
private async Task GetAsync()
|
|
{
|
|
await this.GetPageEntitiesSync<T_PF_CODE_RULE_SERIAL>(t => t.CODE_TYPE == 3500, null);
|
|
return;
|
|
}
|
|
|
|
[HttpGet, Route("api/test")]
|
|
|
|
public ActionResult<bool> test()
|
|
{
|
|
var commonService = ServiceLocator.Instance.GetService<ICommonService>();
|
|
////////return commonService.UnitWork();
|
|
//var param = new CodeRuleParam()
|
|
//{
|
|
// CodeType = 1014,
|
|
// OrgId = new Guid("b043b28b-bbc3-c452-6052-4fba1457abfa"),
|
|
// Count = 1,
|
|
//};
|
|
////var xx = commonService.GetRuleCodes(param);
|
|
var codeRule = new T_PF_CODE_RULE_SERIAL()
|
|
{
|
|
ID = Guid.NewGuid(),
|
|
CODE_TYPE = 3700,
|
|
ORG_ID = new Guid("b043b28b-bbc3-c452-6052-4fba1457abfa")
|
|
|
|
};
|
|
var codeRule1 = new T_PF_CODE_RULE_SERIAL()
|
|
{
|
|
ID = Guid.NewGuid(),
|
|
CODE_TYPE = 3700,
|
|
ORG_ID = new Guid("b043b28b-bbc3-c452-6052-4fba1457abfa")
|
|
|
|
};
|
|
commonService.UnifiedCommit(() =>
|
|
{
|
|
commonService.AddEntityNoCommit(codeRule);
|
|
commonService.AddEntityNoCommit(codeRule1);
|
|
});
|
|
|
|
//this.efDbContext.AddEntity(codeRule);
|
|
//this.efDbContext.SaveChanges();
|
|
|
|
var db = this.efDbContext.GetEntity<T_PF_CODE_RULE_SERIAL>(t => t.ID == codeRule.ID, null);
|
|
|
|
|
|
|
|
return true;
|
|
}
|
|
//[HttpGet]
|
|
//[Route("api/testError")]
|
|
//public JsonActionResult<bool> testError()
|
|
//{
|
|
|
|
// return SafeExecute<bool>(()=>{
|
|
|
|
// ThrowError("100000",100,200);
|
|
// return true;
|
|
// });
|
|
//}
|
|
///// <summary>
|
|
///// 查询
|
|
///// </summary>
|
|
///// <param name="filter"></param>
|
|
///// <returns></returns>
|
|
//[HttpPost]
|
|
//[Route("api/users")]
|
|
//public IActionResult Entities([FromBody]KeywordFilter filter)
|
|
//{
|
|
// return Ok(WitEntities(null, filter));
|
|
//}
|
|
///// <summary>
|
|
///// 查询
|
|
///// </summary>
|
|
///// <param name="filter"></param>
|
|
///// <returns></returns>
|
|
/////
|
|
|
|
//[HttpPost, Route("OrderEntities")]
|
|
//public JsonActionResult<IEnumerable<APT_Test_User>> OrderEntities([FromBody]KeywordFilter filter)
|
|
//{
|
|
// return WitOrderEntities(null, filter);
|
|
//}
|
|
///// <summary>
|
|
///// 查询
|
|
///// </summary>
|
|
///// <param name="pageFilter"></param>
|
|
///// <returns></returns>
|
|
//[HttpPost, Route("Paged")]
|
|
//public PagedActionResult<APT_Test_User> Paged([FromBody]KeywordPageFilter pageFilter)
|
|
//{
|
|
// return WitPaged(null, pageFilter);
|
|
//}
|
|
///// <summary>
|
|
///// 查询
|
|
///// </summary>
|
|
///// <param name="pageFilter"></param>
|
|
///// <returns></returns>
|
|
//[HttpPost, Route("OrderPaged")]
|
|
//public async Task<PagedActionResult<APT_Test_User>> OrderPaged([FromBody]KeywordPageFilter pageFilter)
|
|
//{
|
|
// return await WitOrderPagedSync(null, pageFilter);
|
|
//}
|
|
///// <summary>
|
|
///// 删除
|
|
///// </summary>
|
|
///// <param name="id"></param>
|
|
///// <returns></returns>
|
|
//[HttpGet, Route("Delete")]
|
|
//public JsonActionResult<bool> Delete(string id)
|
|
//{
|
|
// return WitRealDelete(id);
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 更新
|
|
///// </summary>
|
|
///// <param name="id"></param>
|
|
///// <returns></returns>
|
|
//[HttpPost, Route("Update")]
|
|
//public JsonActionResult<bool> Update([FromBody]APT_Test_User entity)
|
|
//{
|
|
// return WitUpdate(entity);
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 批量删除
|
|
///// </summary>
|
|
///// <param name="ids"></param>
|
|
///// <returns></returns>
|
|
//[HttpGet, Route("BatchDelete")]
|
|
//public JsonActionResult<bool> BatchDelete(string ids)
|
|
//{
|
|
// return WitRealBatchDelete(ids);
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 获得单条实体数据
|
|
///// </summary>
|
|
///// <param name="filter"></param>
|
|
///// <returns></returns>
|
|
//[HttpPost, Route("Get")]
|
|
//public JsonActionResult<APT_Test_User> Get([FromBody] KeywordFilter filter)
|
|
//{
|
|
// return WitEntity(null, filter);
|
|
//}
|
|
}
|
|
|
|
public class ExtTestResultModel
|
|
{
|
|
public int code { get; set; }
|
|
public bool success { get; set; }
|
|
public string message { get; set; }
|
|
|
|
public ICollection<ExtTestResultDataModel> data { get; set; }
|
|
}
|
|
public class ExtTestResultDataModel
|
|
{
|
|
public string WORKORDER_ID { get; set; }
|
|
public string STATION_ID { get; set; }
|
|
public ICollection<ExtTestResultTestDataModel> TestDataModels { get; set; }
|
|
}
|
|
|
|
public class ExtTestResultTestDataModel
|
|
{
|
|
public string SN { get; set; }
|
|
public string MAC { get; set; }
|
|
public DateTime TEST_TIME { get; set; }
|
|
public string TEST_STATE { get; set; }
|
|
public string PRODUCT_ID { get; set; }
|
|
public string WORKORDER_ID { get; set; }
|
|
public string STATION_ID { get; set; }
|
|
|
|
public ICollection<ExtTestResultTestDataParamModel> ParamList { get; set; }
|
|
}
|
|
|
|
public class ExtTestResultTestDataParamModel
|
|
{
|
|
public string PARAM_ID { get; set; }
|
|
public string PARAM_NAME { get; set; }
|
|
public string PARAM_VALUE { get; set; }
|
|
public string LIMIT_MIN_VALUE { get; set; }
|
|
public string LIMIT_MAX_VALUE { get; set; }
|
|
}
|
|
|
|
}
|