Files
shgx_tz_mes_backend_sync/ZR.Admin.WebApi/Controllers/mes/ql/PainLab02Controller.cs
xiaowei.song 95103397b1 111
2024-06-11 17:04:49 +08:00

138 lines
4.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Infrastructure.Extensions;
using JinianNet.JNTemplate;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Text.Json;
using ZR.Admin.WebApi.Extensions;
using ZR.Model.mes.pro;
using ZR.Model.MES.qc.DTO;
using ZR.Model.MES.ql;
using ZR.Model.MES.ql.DTO;
using ZR.Service.mes.pro;
using ZR.Service.mes.pro.IService;
using ZR.Service.mes.ql;
using ZR.Service.mes.ql.IService;
using ZR.Service.mes.qu.IService;
using static System.Runtime.InteropServices.JavaScript.JSType;
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;
}
/// <summary>
/// 获取测试数据
/// </summary>
/// <param name="starttime"></param>
/// <param name="endTime"></param>
/// <param name="pageNum"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
[HttpGet("gettestlist")]
public IActionResult GetTestlist(DateTime starttime, DateTime endTime, int pageNum, int pageSize)
{
starttime = starttime.AddHours(8);
endTime = endTime.AddHours(8);
// 时间要增加8个小时
(List<PLTest>, int) lst = plTestService.GetPLTestTable(starttime, endTime, pageNum, pageSize);
return ToResponse(new ApiResult(200, "success", lst));
}
/// <summary>
/// 增加测试数据记录
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
[HttpGet("addtestlist")]
public IActionResult AddTestlist(int num)
{
int ret = plTestService.AddPLTestRecords(1, 5);
return ToResponse(new ApiResult(200, "success", ret));
}
/// <summary>
/// 删除测试数据记录
/// </summary>
/// <param name="idGroup"></param>
/// <returns></returns>
[HttpGet("deltestlist")]
public IActionResult DelTestlist(string idGroup)
{
int ret = plTestService.DelPLTestRecords(idGroup);
return ToResponse(new ApiResult(200, "success", ret));
}
/// <summary>
/// 更新测试数据记录
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
[HttpPost("updatetestlist")]
[Log(Title = "更新测试数据记录", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateTestlist([FromBody] List<PLTestDto> list)
{
List<PLTest> lstDest = new List<PLTest>();
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.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;
}
}
}