| | |
| | | using System; |
| | | using System.Dynamic; |
| | | using MES.Service.Dto.service; |
| | | using MES.Service.Modes; |
| | |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | |
| | | namespace MESApplication.Controllers.QC |
| | | namespace MESApplication.Controllers.QC; |
| | | |
| | | /// <summary> |
| | | /// PCB检测数据控制器 |
| | | /// </summary> |
| | | [Route("api/[controller]")] |
| | | [ApiController] |
| | | public class PcbTestDataController : ControllerBase |
| | | { |
| | | private readonly MessageCenterManager _manager = new(); |
| | | private readonly PcbTestDataService _service = new(); |
| | | |
| | | private readonly string METHOD = "POST"; |
| | | private readonly string TableName = "MES_PCB_TEST_DATA"; |
| | | private readonly string URL = "http://localhost:10054/api/PcbTestData/"; |
| | | |
| | | /// <summary> |
| | | /// PCB检测数据控制器 |
| | | /// 保存整板检测数据 |
| | | /// </summary> |
| | | [Route("api/[controller]")] |
| | | [ApiController] |
| | | public class PcbTestDataController : ControllerBase |
| | | /// <param name="dto">整板检测数据DTO</param> |
| | | /// <returns>保存结果</returns> |
| | | [HttpPost("SaveWholeboardData")] |
| | | public ResponseResult SaveWholeboardData( |
| | | [FromBody] WholeboardGenerateDto dto) |
| | | { |
| | | private readonly MessageCenterManager _manager = new(); |
| | | private readonly PcbTestDataService _service = new(); |
| | | |
| | | private readonly string METHOD = "POST"; |
| | | private readonly string TableName = "MES_PCB_TEST_DATA"; |
| | | private readonly string URL = "http://localhost:10054/api/PcbTestData/"; |
| | | var entity = new MessageCenter(); |
| | | entity.TableName = TableName; |
| | | entity.Url = URL + "SaveWholeboardData"; |
| | | entity.Method = METHOD; |
| | | entity.Data = JsonConvert.SerializeObject(dto); |
| | | entity.Status = 1; |
| | | entity.CreateBy = "PL017"; |
| | | |
| | | /// <summary> |
| | | /// 保存整板检测数据 |
| | | /// </summary> |
| | | /// <param name="dto">整板检测数据DTO</param> |
| | | /// <returns>保存结果</returns> |
| | | [HttpPost("SaveWholeboardData")] |
| | | public ResponseResult SaveWholeboardData([FromBody] WholeboardGenerateDto dto) |
| | | try |
| | | { |
| | | var entity = new MessageCenter(); |
| | | entity.TableName = TableName; |
| | | entity.Url = URL + "SaveWholeboardData"; |
| | | entity.Method = METHOD; |
| | | entity.Data = JsonConvert.SerializeObject(dto); |
| | | entity.Status = 1; |
| | | entity.CreateBy = "PL017"; |
| | | |
| | | try |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | var result = _service.SaveWholeboardData(dto); |
| | | resultInfos.result = result; |
| | | resultInfos.message = result ? "整板检测数据保存成功" : "整板检测数据保存失败"; |
| | | |
| | | entity.Result = result ? (short)1 : (short)0; |
| | | entity.DealWith = 1; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | var result = _service.SaveWholeboardData(dto); |
| | | resultInfos.result = result; |
| | | resultInfos.message = result ? "整板检测数据保存成功" : "整板检测数据保存失败"; |
| | | |
| | | entity.Result = result ? (short)1 : (short)0; |
| | | entity.DealWith = 1; |
| | | _manager.save(entity); |
| | | |
| | | status = result ? 0 : 1, |
| | | message = result ? "OK" : "FAIL", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = ex.Message; |
| | | _manager.save(entity); |
| | | |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 保存单板检测数据 |
| | | /// </summary> |
| | | /// <param name="dto">单板检测数据DTO</param> |
| | | /// <returns>保存结果</returns> |
| | | [HttpPost("SaveSingleBoardData")] |
| | | public ResponseResult SaveSingleBoardData( |
| | | [FromBody] SingleBoardGenerateDto dto) |
| | | { |
| | | var entity = new MessageCenter(); |
| | | entity.TableName = TableName; |
| | | entity.Url = URL + "SaveSingleBoardData"; |
| | | entity.Method = METHOD; |
| | | entity.Data = JsonConvert.SerializeObject(dto); |
| | | entity.Status = 1; |
| | | entity.CreateBy = "PL017"; |
| | | |
| | | try |
| | | { |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | var result = _service.SaveSingleBoardData(dto); |
| | | resultInfos.result = result; |
| | | resultInfos.message = result ? "单板检测数据保存成功" : "单板检测数据保存失败"; |
| | | |
| | | entity.Result = result ? (short)1 : (short)0; |
| | | entity.DealWith = 1; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = result ? 0 : 1, |
| | | message = result ? "OK" : "FAIL", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = ex.Message; |
| | | _manager.save(entity); |
| | | |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 分页查询PCB检测数据 |
| | | /// </summary> |
| | | /// <param name="request">查询请求</param> |
| | | /// <returns>分页数据</returns> |
| | | [HttpPost("GetPage")] |
| | | public ResponseResult GetPage([FromBody] JObject request) |
| | | { |
| | | try |
| | | { |
| | | var dataType = request["dataType"]?.ToString(); |
| | | var deviceName = request["deviceName"]?.ToString(); |
| | | var pcbSn = request["pcbSn"]?.ToString(); |
| | | var startTime = request["startTime"]?.ToString(); |
| | | var endTime = request["endTime"]?.ToString(); |
| | | var pageIndex = request["pageIndex"]?.ToObject<int>() ?? 1; |
| | | var pageSize = request["pageSize"]?.ToObject<int>() ?? 20; |
| | | |
| | | DateTime? startDateTime = null; |
| | | DateTime? endDateTime = null; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(startTime) && |
| | | DateTime.TryParse(startTime, out var start)) |
| | | startDateTime = start; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(endTime) && |
| | | DateTime.TryParse(endTime, out var end)) |
| | | endDateTime = end; |
| | | |
| | | var (items, totalCount) = _service.GetPcbTestDataPage( |
| | | dataType, deviceName, pcbSn, startDateTime, endDateTime, |
| | | pageIndex, pageSize); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.items = items; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos, |
| | | TotalCount = totalCount |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据ID获取PCB检测数据 |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>PCB检测数据</returns> |
| | | [HttpPost("GetById")] |
| | | public ResponseResult GetById([FromBody] JObject request) |
| | | { |
| | | try |
| | | { |
| | | var id = request["id"]?.ToObject<decimal>(); |
| | | if (!id.HasValue) |
| | | return new ResponseResult |
| | | { |
| | | status = result ? 0 : 1, |
| | | message = result ? "OK" : "FAIL", |
| | | data = resultInfos |
| | | status = 1, |
| | | message = "ID不能为空", |
| | | data = null |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | |
| | | var testData = _service.GetPcbTestDataById(id.Value); |
| | | var componentData = _service.GetComponentDataByTestDataId(id.Value); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.testData = testData; |
| | | resultInfos.componentData = componentData; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据PCB条码获取检测数据 |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>检测数据列表</returns> |
| | | [HttpPost("GetByPcbSn")] |
| | | public ResponseResult GetByPcbSn([FromBody] JObject request) |
| | | { |
| | | try |
| | | { |
| | | var pcbSn = request["pcbSn"]?.ToString(); |
| | | if (StringUtil.IsNullOrEmpty(pcbSn)) |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "PCB条码不能为空", |
| | | data = null |
| | | }; |
| | | |
| | | var testDataList = _service.GetPcbTestDataByPcbSn(pcbSn); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.testDataList = testDataList; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取器件检测数据 |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>器件检测数据</returns> |
| | | [HttpPost("GetComponentData")] |
| | | public ResponseResult GetComponentData([FromBody] JObject request) |
| | | { |
| | | try |
| | | { |
| | | var testDataId = request["testDataId"]?.ToObject<decimal>(); |
| | | if (!testDataId.HasValue) |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "测试数据ID不能为空", |
| | | data = null |
| | | }; |
| | | |
| | | var componentData = |
| | | _service.GetComponentDataByTestDataId(testDataId.Value); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.componentData = componentData; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取检测统计数据 |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>统计数据</returns> |
| | | [HttpPost("GetStatistics")] |
| | | public ResponseResult GetStatistics([FromBody] JObject request) |
| | | { |
| | | try |
| | | { |
| | | var dataType = request["dataType"]?.ToString(); |
| | | var deviceName = request["deviceName"]?.ToString(); |
| | | var startTime = request["startTime"]?.ToString(); |
| | | var endTime = request["endTime"]?.ToString(); |
| | | |
| | | DateTime? startDateTime = null; |
| | | DateTime? endDateTime = null; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(startTime) && |
| | | DateTime.TryParse(startTime, out var start)) |
| | | startDateTime = start; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(endTime) && |
| | | DateTime.TryParse(endTime, out var end)) |
| | | endDateTime = end; |
| | | |
| | | var statistics = _service.GetTestStatistics(dataType, deviceName, |
| | | startDateTime, endDateTime); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.statistics = statistics; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除PCB检测数据 |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>删除结果</returns> |
| | | [HttpPost("Delete")] |
| | | public ResponseResult Delete([FromBody] JObject request) |
| | | { |
| | | var entity = new MessageCenter(); |
| | | entity.TableName = TableName; |
| | | entity.Url = URL + "Delete"; |
| | | entity.Method = METHOD; |
| | | entity.Data = JsonConvert.SerializeObject(request); |
| | | entity.Status = 1; |
| | | entity.CreateBy = "PL017"; |
| | | |
| | | try |
| | | { |
| | | var id = request["id"]?.ToObject<decimal>(); |
| | | if (!id.HasValue) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = ex.Message; |
| | | entity.ResultData = "ID不能为空"; |
| | | _manager.save(entity); |
| | | |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 保存单板检测数据 |
| | | /// </summary> |
| | | /// <param name="dto">单板检测数据DTO</param> |
| | | /// <returns>保存结果</returns> |
| | | [HttpPost("SaveSingleBoardData")] |
| | | public ResponseResult SaveSingleBoardData([FromBody] SingleBoardGenerateDto dto) |
| | | { |
| | | var entity = new MessageCenter(); |
| | | entity.TableName = TableName; |
| | | entity.Url = URL + "SaveSingleBoardData"; |
| | | entity.Method = METHOD; |
| | | entity.Data = JsonConvert.SerializeObject(dto); |
| | | entity.Status = 1; |
| | | entity.CreateBy = "PL017"; |
| | | |
| | | try |
| | | { |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | var result = _service.SaveSingleBoardData(dto); |
| | | resultInfos.result = result; |
| | | resultInfos.message = result ? "单板检测数据保存成功" : "单板检测数据保存失败"; |
| | | |
| | | entity.Result = result ? (short)1 : (short)0; |
| | | entity.DealWith = 1; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = result ? 0 : 1, |
| | | message = result ? "OK" : "FAIL", |
| | | data = resultInfos |
| | | status = 1, |
| | | message = "ID不能为空", |
| | | data = null |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | |
| | | var result = _service.DeletePcbTestData(id.Value); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.result = result; |
| | | resultInfos.message = result ? "删除成功" : "删除失败"; |
| | | |
| | | entity.Result = result ? (short)1 : (short)0; |
| | | entity.DealWith = 1; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = result ? 0 : 1, |
| | | message = result ? "OK" : "FAIL", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = ex.Message; |
| | | _manager.save(entity); |
| | | |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 统一保存接口(自动识别整板或单板数据) |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>保存结果</returns> |
| | | [HttpPost("SaveTestData")] |
| | | public ResponseResult SaveTestData([FromBody] JObject request) |
| | | { |
| | | var entity = new MessageCenter(); |
| | | entity.TableName = TableName; |
| | | entity.Url = URL + "SaveTestData"; |
| | | entity.Method = METHOD; |
| | | entity.Data = JsonConvert.SerializeObject(request); |
| | | entity.Status = 1; |
| | | entity.CreateBy = "PL017"; |
| | | |
| | | try |
| | | { |
| | | var dataType = request["dataType"]?.ToString(); |
| | | |
| | | if (StringUtil.IsNullOrEmpty(dataType)) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = ex.Message; |
| | | _manager.save(entity); |
| | | |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 分页查询PCB检测数据 |
| | | /// </summary> |
| | | /// <param name="request">查询请求</param> |
| | | /// <returns>分页数据</returns> |
| | | [HttpPost("GetPage")] |
| | | public ResponseResult GetPage([FromBody] JObject request) |
| | | { |
| | | try |
| | | { |
| | | var dataType = request["dataType"]?.ToString(); |
| | | var deviceName = request["deviceName"]?.ToString(); |
| | | var pcbSn = request["pcbSn"]?.ToString(); |
| | | var startTime = request["startTime"]?.ToString(); |
| | | var endTime = request["endTime"]?.ToString(); |
| | | var pageIndex = request["pageIndex"]?.ToObject<int>() ?? 1; |
| | | var pageSize = request["pageSize"]?.ToObject<int>() ?? 20; |
| | | |
| | | DateTime? startDateTime = null; |
| | | DateTime? endDateTime = null; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(startTime) && DateTime.TryParse(startTime, out var start)) |
| | | startDateTime = start; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(endTime) && DateTime.TryParse(endTime, out var end)) |
| | | endDateTime = end; |
| | | |
| | | var (items, totalCount) = _service.GetPcbTestDataPage( |
| | | dataType, deviceName, pcbSn, startDateTime, endDateTime, pageIndex, pageSize); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.items = items; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos, |
| | | TotalCount = totalCount |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据ID获取PCB检测数据 |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>PCB检测数据</returns> |
| | | [HttpPost("GetById")] |
| | | public ResponseResult GetById([FromBody] JObject request) |
| | | { |
| | | try |
| | | { |
| | | var id = request["id"]?.ToObject<decimal>(); |
| | | if (!id.HasValue) |
| | | { |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "ID不能为空", |
| | | data = null |
| | | }; |
| | | } |
| | | |
| | | var testData = _service.GetPcbTestDataById(id.Value); |
| | | var componentData = _service.GetComponentDataByTestDataId(id.Value); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.testData = testData; |
| | | resultInfos.componentData = componentData; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据PCB条码获取检测数据 |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>检测数据列表</returns> |
| | | [HttpPost("GetByPcbSn")] |
| | | public ResponseResult GetByPcbSn([FromBody] JObject request) |
| | | { |
| | | try |
| | | { |
| | | var pcbSn = request["pcbSn"]?.ToString(); |
| | | if (StringUtil.IsNullOrEmpty(pcbSn)) |
| | | { |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "PCB条码不能为空", |
| | | data = null |
| | | }; |
| | | } |
| | | |
| | | var testDataList = _service.GetPcbTestDataByPcbSn(pcbSn); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.testDataList = testDataList; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取器件检测数据 |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>器件检测数据</returns> |
| | | [HttpPost("GetComponentData")] |
| | | public ResponseResult GetComponentData([FromBody] JObject request) |
| | | { |
| | | try |
| | | { |
| | | var testDataId = request["testDataId"]?.ToObject<decimal>(); |
| | | if (!testDataId.HasValue) |
| | | { |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "测试数据ID不能为空", |
| | | data = null |
| | | }; |
| | | } |
| | | |
| | | var componentData = _service.GetComponentDataByTestDataId(testDataId.Value); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.componentData = componentData; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取检测统计数据 |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>统计数据</returns> |
| | | [HttpPost("GetStatistics")] |
| | | public ResponseResult GetStatistics([FromBody] JObject request) |
| | | { |
| | | try |
| | | { |
| | | var dataType = request["dataType"]?.ToString(); |
| | | var deviceName = request["deviceName"]?.ToString(); |
| | | var startTime = request["startTime"]?.ToString(); |
| | | var endTime = request["endTime"]?.ToString(); |
| | | |
| | | DateTime? startDateTime = null; |
| | | DateTime? endDateTime = null; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(startTime) && DateTime.TryParse(startTime, out var start)) |
| | | startDateTime = start; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(endTime) && DateTime.TryParse(endTime, out var end)) |
| | | endDateTime = end; |
| | | |
| | | var statistics = _service.GetTestStatistics(dataType, deviceName, startDateTime, endDateTime); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.statistics = statistics; |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除PCB检测数据 |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>删除结果</returns> |
| | | [HttpPost("Delete")] |
| | | public ResponseResult Delete([FromBody] JObject request) |
| | | { |
| | | var entity = new MessageCenter(); |
| | | entity.TableName = TableName; |
| | | entity.Url = URL + "Delete"; |
| | | entity.Method = METHOD; |
| | | entity.Data = JsonConvert.SerializeObject(request); |
| | | entity.Status = 1; |
| | | entity.CreateBy = "PL017"; |
| | | |
| | | try |
| | | { |
| | | var id = request["id"]?.ToObject<decimal>(); |
| | | if (!id.HasValue) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = "ID不能为空"; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "ID不能为空", |
| | | data = null |
| | | }; |
| | | } |
| | | |
| | | var result = _service.DeletePcbTestData(id.Value); |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.result = result; |
| | | resultInfos.message = result ? "删除成功" : "删除失败"; |
| | | |
| | | entity.Result = result ? (short)1 : (short)0; |
| | | entity.DealWith = 1; |
| | | entity.ResultData = "数据类型不能为空,请指定WHOLE或SINGLE"; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = result ? 0 : 1, |
| | | message = result ? "OK" : "FAIL", |
| | | data = resultInfos |
| | | status = 1, |
| | | message = "数据类型不能为空,请指定WHOLE或SINGLE", |
| | | data = null |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = ex.Message; |
| | | _manager.save(entity); |
| | | |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 统一保存接口(自动识别整板或单板数据) |
| | | /// </summary> |
| | | /// <param name="request">请求参数</param> |
| | | /// <returns>保存结果</returns> |
| | | [HttpPost("SaveTestData")] |
| | | public ResponseResult SaveTestData([FromBody] JObject request) |
| | | { |
| | | var entity = new MessageCenter(); |
| | | entity.TableName = TableName; |
| | | entity.Url = URL + "SaveTestData"; |
| | | entity.Method = METHOD; |
| | | entity.Data = JsonConvert.SerializeObject(request); |
| | | entity.Status = 1; |
| | | entity.CreateBy = "PL017"; |
| | | |
| | | try |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | var result = false; |
| | | var message = ""; |
| | | |
| | | switch (dataType.ToUpper()) |
| | | { |
| | | var dataType = request["dataType"]?.ToString(); |
| | | |
| | | if (StringUtil.IsNullOrEmpty(dataType)) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = "数据类型不能为空,请指定WHOLE或SINGLE"; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | case "WHOLE": |
| | | var wholeboardDto = request["data"] |
| | | ?.ToObject<WholeboardGenerateDto>(); |
| | | if (wholeboardDto == null) |
| | | { |
| | | status = 1, |
| | | message = "数据类型不能为空,请指定WHOLE或SINGLE", |
| | | data = null |
| | | }; |
| | | } |
| | | |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | bool result = false; |
| | | string message = ""; |
| | | |
| | | switch (dataType.ToUpper()) |
| | | { |
| | | case "WHOLE": |
| | | var wholeboardDto = request["data"]?.ToObject<WholeboardGenerateDto>(); |
| | | if (wholeboardDto == null) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = "整板数据不能为空"; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "整板数据不能为空", |
| | | data = null |
| | | }; |
| | | } |
| | | result = _service.SaveWholeboardData(wholeboardDto); |
| | | message = result ? "整板检测数据保存成功" : "整板检测数据保存失败"; |
| | | break; |
| | | |
| | | case "SINGLE": |
| | | var singleBoardDto = request["data"]?.ToObject<SingleBoardGenerateDto>(); |
| | | if (singleBoardDto == null) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = "单板数据不能为空"; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "单板数据不能为空", |
| | | data = null |
| | | }; |
| | | } |
| | | result = _service.SaveSingleBoardData(singleBoardDto); |
| | | message = result ? "单板检测数据保存成功" : "单板检测数据保存失败"; |
| | | break; |
| | | |
| | | default: |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = "不支持的数据类型,请指定WHOLE或SINGLE"; |
| | | entity.ResultData = "整板数据不能为空"; |
| | | _manager.save(entity); |
| | | |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "不支持的数据类型,请指定WHOLE或SINGLE", |
| | | message = "整板数据不能为空", |
| | | data = null |
| | | }; |
| | | } |
| | | } |
| | | |
| | | resultInfos.result = result; |
| | | resultInfos.message = message; |
| | | result = _service.SaveWholeboardData(wholeboardDto); |
| | | message = result ? "整板检测数据保存成功" : "整板检测数据保存失败"; |
| | | break; |
| | | |
| | | entity.Result = result ? (short)1 : (short)0; |
| | | entity.DealWith = 1; |
| | | _manager.save(entity); |
| | | case "SINGLE": |
| | | var singleBoardDto = request["data"] |
| | | ?.ToObject<SingleBoardGenerateDto>(); |
| | | if (singleBoardDto == null) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = "单板数据不能为空"; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = result ? 0 : 1, |
| | | message = result ? "OK" : "FAIL", |
| | | data = resultInfos |
| | | }; |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "单板数据不能为空", |
| | | data = null |
| | | }; |
| | | } |
| | | |
| | | result = _service.SaveSingleBoardData(singleBoardDto); |
| | | message = result ? "单板检测数据保存成功" : "单板检测数据保存失败"; |
| | | break; |
| | | |
| | | default: |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = "不支持的数据类型,请指定WHOLE或SINGLE"; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | status = 1, |
| | | message = "不支持的数据类型,请指定WHOLE或SINGLE", |
| | | data = null |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | |
| | | resultInfos.result = result; |
| | | resultInfos.message = message; |
| | | |
| | | entity.Result = result ? (short)1 : (short)0; |
| | | entity.DealWith = 1; |
| | | _manager.save(entity); |
| | | |
| | | return new ResponseResult |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = ex.Message; |
| | | _manager.save(entity); |
| | | |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | status = result ? 0 : 1, |
| | | message = result ? "OK" : "FAIL", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | entity.Result = 0; |
| | | entity.DealWith = 0; |
| | | entity.ResultData = ex.Message; |
| | | _manager.save(entity); |
| | | |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | } |