using Microsoft.AspNetCore.Mvc;
using ZR.Model.MES.ql;
using ZR.Model.MES.ql.DTO;
using ZR.Service.mes.ql.IService;
namespace ZR.Admin.WebApi.Controllers.mes.ql
{
[Route("mes/ql/PaintLab")]
public class PainLab02Controller : BaseController
{
private readonly IPLTestService plTestService;
public PainLab02Controller(IPLTestService pltestservice)
{
this.plTestService = pltestservice;
}
///
/// 获取测试数据
///
///
///
/// 颜色代码
/// 产品描述
///
///
///
[HttpGet("gettestlist")]
public IActionResult GetTestlist(DateTime starttime, DateTime endTime, string workorderid, string description, int pageNum, int pageSize,int dateType)
{
//starttime = starttime.AddHours(8);
//endTime = endTime.AddHours(8);
// 时间要增加,8个小时
(List, int) lst = plTestService.GetPLTestTable(starttime, endTime, workorderid, description, pageNum, pageSize, dateType);
return ToResponse(new ApiResult(200, "success", lst));
}
///
/// 增加测试数据记录
///
///
///
[HttpGet("addtestlist")]
public IActionResult AddTestlist(int num)
{
int ret = plTestService.AddPLTestRecords(1, 5);
return ToResponse(new ApiResult(200, "success", ret));
}
///
/// 删除测试数据记录
///
///
///
[HttpGet("deltestlist")]
public IActionResult DelTestlist(string idGroup)
{
int ret = plTestService.DelPLTestRecords(idGroup);
return ToResponse(new ApiResult(200, "success", ret));
}
///
/// 更新测试数据记录
///
///
///
[HttpPost("updatetestlist")]
[Log(Title = "更新测试数据记录", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateTestlist([FromBody] List list)
{
List lstDest = new List();
foreach (PLTestDto dto in list)
{
lstDest.Add(ConvertDTO2PLTest(dto));
}
int ret = plTestService.UpdatePLTestRecords(lstDest);
return ToResponse(new ApiResult(200, "success", ret));
}
public PLTest ConvertDTO2PLTest(PLTestDto pLTestDto)
{
PLTest pLTest = new PLTest();
pLTest.Id = pLTestDto.Id;
pLTest.IdGroup = pLTestDto.plIdGroup;
pLTest.Description = pLTestDto.Description;
pLTest.Code = pLTestDto.plCode;
pLTest.Dt = pLTestDto.plDt;
pLTest.Value01 = pLTestDto.plValue01;
pLTest.Value02 = pLTestDto.plValue02;
pLTest.Value03 = pLTestDto.plValue03;
pLTest.Value04 = pLTestDto.plValue04;
pLTest.Value05 = pLTestDto.plValue05;
pLTest.Value06 = pLTestDto.plValue06;
pLTest.Value07 = pLTestDto.plValue07;
pLTest.Value08 = pLTestDto.plValue08;
pLTest.Value09 = pLTestDto.plValue09;
pLTest.Value10 = pLTestDto.plValue10;
pLTest.Value11 = pLTestDto.plValue11;
pLTest.Value12 = pLTestDto.plValue12;
pLTest.Value13 = pLTestDto.plValue13;
pLTest.Value14 = pLTestDto.plValue14;
pLTest.Value15 = pLTestDto.plValue15;
pLTest.Value16 = pLTestDto.plValue16;
pLTest.CreatedBy = pLTestDto.plCreatedBy;
pLTest.UpdatedBy = pLTestDto.plUpdatedBy;
try
{
pLTest.CreatedTime = Convert.ToDateTime(pLTestDto.plCreatedTime);
pLTest.UpdatedTime = Convert.ToDateTime(pLTestDto.plUpdatedTime);
}
catch { }
return pLTest;
}
}
}