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 PainLab03Controller : BaseController { private readonly IPLBatchService plBatchService; public PainLab03Controller(IPLBatchService plbatchservice) { this.plBatchService = plbatchservice; } /// /// 获取批处理数据 /// /// /// /// 颜色代码 /// /// /// /// [HttpGet("getbatchlist")] public IActionResult GetBatchlist(DateTime starttime, DateTime endTime, string workorderid, string description, int pageNum, int pageSize, int dateType, string workOrder) { //starttime = starttime.AddHours(8); //endTime = endTime.AddHours(8); // 时间要增加,8个小时 (List, int) lst = plBatchService.GetPLBatchTable(starttime, endTime, workorderid, description, pageNum, pageSize, dateType, workOrder); return ToResponse(new ApiResult(200, "success", lst)); } /// /// 增加批处理数据记录 /// /// /// [HttpGet("addbatchlist")] public IActionResult AddBatchlist(int num) { int ret = plBatchService.AddPLBatchRecords(1, 5); return ToResponse(new ApiResult(200, "success", ret)); } /// /// 根据工单自动生成批处理记录 /// /// 执行时间 /// [HttpGet("AddBatchListByWorkOrder")] public IActionResult AddBatchListByWorkOrder(DateTime actionDate) { try { int ret = plBatchService.CreatePLBatchRecordsByWorkOrder(actionDate); return ToResponse(new ApiResult(200, "success", ret)); } catch (Exception e) { return ToResponse(new ApiResult(500, "error", e.Message)); throw; } } /// /// 删除测试数据记录 /// /// /// [HttpGet("delbatchlist")] public IActionResult DelBatchlist(string idGroup) { int ret = plBatchService.DelPLBatchRecords(idGroup); return ToResponse(new ApiResult(200, "success", ret)); } /// /// 更新批处理数据记录 /// /// /// [HttpPost("updatebatchlist")] [Log(Title = "更新批处理数据记录", BusinessType = BusinessType.UPDATE)] public IActionResult UpdateTestlist([FromBody] List list) { List lstDest = new List(); foreach (PLBatchDto dto in list) { lstDest.Add(ConvertDTO2PLBatch(dto)); } int ret = plBatchService.UpdatePLBatchRecords(lstDest); return ToResponse(new ApiResult(200, "success", ret)); } public PLBatch ConvertDTO2PLBatch(PLBatchDto pLBatchDto) { PLBatch pLBatch = new PLBatch(); pLBatch.Id = pLBatchDto.Id; pLBatch.IdGroup = pLBatchDto.plIdGroup; pLBatch.Workorder = pLBatchDto.Workorder; pLBatch.Description = pLBatchDto.Description; pLBatch.Code = pLBatchDto.plCode; pLBatch.Dt = pLBatchDto.plDt; pLBatch.Value01 = pLBatchDto.plValue01; pLBatch.Value02 = pLBatchDto.plValue02; pLBatch.Value03 = pLBatchDto.plValue03; pLBatch.Value04 = pLBatchDto.plValue04; pLBatch.Value05 = pLBatchDto.plValue05; pLBatch.Value06 = pLBatchDto.plValue06; pLBatch.Value07 = pLBatchDto.plValue07; pLBatch.Value08 = pLBatchDto.plValue08; pLBatch.Value09 = pLBatchDto.plValue09; pLBatch.Value10 = pLBatchDto.plValue10; pLBatch.Value11 = pLBatchDto.plValue11; pLBatch.Value12 = pLBatchDto.plValue12; pLBatch.Value13 = pLBatchDto.plValue13; pLBatch.Value14 = pLBatchDto.plValue14; pLBatch.Value15 = pLBatchDto.plValue15; pLBatch.Value16 = pLBatchDto.plValue16; pLBatch.Value17 = pLBatchDto.plValue17; pLBatch.Value18 = pLBatchDto.plValue18; pLBatch.Value19 = pLBatchDto.plValue19; pLBatch.CreatedBy = pLBatchDto.plCreatedBy; pLBatch.UpdatedBy = pLBatchDto.plUpdatedBy; try { pLBatch.CreatedTime = Convert.ToDateTime(pLBatchDto.plCreatedTime); pLBatch.UpdatedTime = Convert.ToDateTime(pLBatchDto.plUpdatedTime); } catch { } return pLBatch; } } }