using System.Dynamic;
|
using MES.Service.Dto.service;
|
using MES.Service.Modes;
|
using MES.Service.service.QC;
|
using MES.Service.util;
|
using Microsoft.AspNetCore.Mvc;
|
using Newtonsoft.Json.Linq;
|
|
namespace MESApplication.Controllers.QC;
|
|
[Route("api/[controller]")]
|
[ApiController]
|
public class THJController : ControllerBase
|
{
|
[HttpPost("getPage")]
|
public ResponseResult GetPage([FromBody] THJPageResult queryObj)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new THJService().getPage(queryObj);
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("getMaxReleaseNo")]
|
public ResponseResult GetMaxReleaseNo()
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new THJService().getMaxReleaseNo();
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("getQSItems")]
|
public ResponseResult GetQSItems([FromBody] JObject data)
|
{
|
var pid = data["pid"]?.ToString();
|
var id = data["id"]?.ToString();
|
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new THJService();
|
var detail021 = tbBillList.getQSItems(Convert.ToDecimal(pid), Convert.ToDecimal(id));
|
resultInfos.tbBillList = detail021;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("saveItem")]
|
public ResponseResult SaveItem([FromBody] THJDto thjDto)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new THJService().saveItem(thjDto);
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("submitTHJResult")]
|
public ResponseResult SubmitTHJResult([FromBody] JObject data)
|
{
|
try
|
{
|
var gid = Convert.ToDecimal(data["gid"]?.ToString());
|
var userNo = data["userNo"]?.ToString();
|
|
if (gid <= 0)
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "检验单ID不能为空",
|
data = null
|
};
|
}
|
|
if (string.IsNullOrEmpty(userNo))
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "操作人不能为空",
|
data = null
|
};
|
}
|
|
var result = new THJService().SubmitTHJResult(gid, userNo);
|
|
if (result)
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = new { success = true, message = "提交成功" };
|
return new ResponseResult
|
{
|
status = 0,
|
message = "提交成功",
|
data = resultInfos
|
};
|
}
|
else
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "提交失败",
|
data = null
|
};
|
}
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("getReturnwareInfo")]
|
public ResponseResult GetReturnwareInfo([FromBody] JObject data)
|
{
|
try
|
{
|
var returnType = data["returnType"]?.ToString();
|
var returnNo = data["returnNo"]?.ToString();
|
|
if (string.IsNullOrEmpty(returnType) || string.IsNullOrEmpty(returnNo))
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "退货单别和退货单号不能为空",
|
data = null
|
};
|
}
|
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new THJService().getReturnwareInfo(returnType, returnNo);
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("getReturnDetails")]
|
public ResponseResult GetReturnDetails([FromBody] JObject data)
|
{
|
try
|
{
|
var pid = data["pid"]?.ToString();
|
|
if (string.IsNullOrEmpty(pid))
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "检验单ID不能为空",
|
data = null
|
};
|
}
|
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new THJService().getReturnDetails(pid);
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("setInspectItem")]
|
public ResponseResult SetInspectItem([FromBody] JObject data)
|
{
|
try
|
{
|
var gid = data["gid"]?.ToString();
|
var updateBy = data["updateBy"]?.ToString() ?? "系统";
|
|
if (string.IsNullOrEmpty(gid))
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "检验单ID不能为空",
|
data = null
|
};
|
}
|
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new THJService().setInspectItem(gid, updateBy);
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 测试接口 - 验证基本功能
|
/// </summary>
|
[HttpPost("testConnection")]
|
public ResponseResult TestConnection()
|
{
|
try
|
{
|
return new ResponseResult
|
{
|
status = 0,
|
message = "连接正常",
|
data = new { timestamp = DateTime.Now }
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 根据ID获取检验项目详情
|
/// </summary>
|
[HttpPost("getThjDetail02ById")]
|
public ResponseResult GetThjDetail02ById([FromBody] JObject data)
|
{
|
try
|
{
|
var id = Convert.ToDecimal(data["id"]);
|
var result = new THJService().getThjDetail02ById(id);
|
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = result;
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 设置检验项目详情
|
/// </summary>
|
[HttpPost("SetQSItemDetail")]
|
public ResponseResult SetQSItemDetail([FromBody] JObject data)
|
{
|
try
|
{
|
var pid = Convert.ToDecimal(data["pid"]);
|
var gid = Convert.ToDecimal(data["gid"]);
|
var fstand = data["fstand"]?.ToString();
|
var fcheckResu = data["fcheckResu"]?.ToString();
|
var updateBy = data["updateBy"]?.ToString();
|
var count = Convert.ToInt32(data["count"]);
|
|
var result = new THJService().SetQSItemDetail(pid, gid, fstand, fcheckResu, updateBy, count);
|
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = result;
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 更新检验项目详情
|
/// </summary>
|
[HttpPost("UpdateQSItemDetail")]
|
public ResponseResult UpdateQSItemDetail([FromBody] JObject data)
|
{
|
try
|
{
|
// 安全地转换decimal参数,处理NULL值
|
if (!decimal.TryParse(data["id"]?.ToString(), out decimal id))
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "检验结果ID不能为空或格式不正确",
|
data = null
|
};
|
}
|
|
if (!decimal.TryParse(data["pid"]?.ToString(), out decimal pid))
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "检验项目ID不能为空或格式不正确",
|
data = null
|
};
|
}
|
|
if (!decimal.TryParse(data["gid"]?.ToString(), out decimal gid))
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "检验单ID不能为空或格式不正确",
|
data = null
|
};
|
}
|
|
var fstand = data["fstand"]?.ToString();
|
var fcheckResu = data["fcheckResu"]?.ToString();
|
var updateBy = data["updateBy"]?.ToString();
|
|
var result = new THJService().UpdateQSItemDetail(id, pid, gid, fstand, fcheckResu, updateBy);
|
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = result;
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 保存检验项目备注
|
/// </summary>
|
[HttpPost("saveRemarksPid")]
|
public ResponseResult SaveRemarksPid([FromBody] JObject data)
|
{
|
try
|
{
|
var pid = Convert.ToDecimal(data["pid"]);
|
var remarks = data["remarks"]?.ToString();
|
|
var result = new THJService().saveRemarksPid(pid, remarks);
|
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = result;
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 获取退货单列表
|
/// </summary>
|
[HttpPost("getReturnOrders")]
|
public ResponseResult GetReturnOrders()
|
{
|
try
|
{
|
var result = new THJService().getReturnOrders();
|
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = result;
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 保存退货明细
|
/// </summary>
|
[HttpPost("SaveReturnDetails")]
|
public ResponseResult SaveReturnDetails([FromBody] JObject data)
|
{
|
try
|
{
|
var returnDetails = data["returnDetails"]?.ToString();
|
var result = new THJService().SaveReturnDetails(returnDetails);
|
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = result;
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 保存检验项目
|
/// </summary>
|
[HttpPost("saveInspectItem")]
|
public ResponseResult SaveInspectItem([FromBody] JObject data)
|
{
|
try
|
{
|
var gid = data["gid"]?.ToString();
|
var items = data["items"]?.ToString();
|
var userNo = data["userNo"]?.ToString();
|
|
var result = new THJService().saveInspectItem(gid, items, userNo);
|
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = result;
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 保存检验单备注(不合格描述)
|
/// </summary>
|
[HttpPost("saveRemarksGid")]
|
public ResponseResult SaveRemarksGid([FromBody] JObject data)
|
{
|
try
|
{
|
var gid = Convert.ToDecimal(data["gid"]?.ToString());
|
var remarks = data["remarks"]?.ToString();
|
|
var result = new THJService().saveRemarksGid(gid, remarks);
|
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = result;
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 通过存储过程提交检验结果
|
/// </summary>
|
[HttpPost("submitTHJResultByProcedure")]
|
public ResponseResult SubmitTHJResultByProcedure([FromBody] JObject data)
|
{
|
try
|
{
|
var releaseNo = data["releaseNo"]?.ToString();
|
var userNo = data["userNo"]?.ToString();
|
|
if (string.IsNullOrEmpty(releaseNo))
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "检验单号不能为空",
|
data = null
|
};
|
}
|
|
if (string.IsNullOrEmpty(userNo))
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "操作人不能为空",
|
data = null
|
};
|
}
|
|
var result = new THJService().SubmitTHJResultByProcedure(releaseNo, userNo);
|
|
if (result.success)
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = new { success = true, message = result.message };
|
return new ResponseResult
|
{
|
status = 0,
|
message = result.message,
|
data = resultInfos
|
};
|
}
|
else
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = result.message,
|
data = null
|
};
|
}
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
}
|