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 RKJController : ControllerBase
{
//getMaxReleaseNo
[HttpPost("getMaxReleaseNo")]
public ResponseResult getMaxReleaseNo()
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().getMaxBillNo();
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//getLine
[HttpPost("getLineAll")]
public ResponseResult getLineAll()
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().getLineNo();
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//getDaa001
[HttpPost("getDaa001")]
public ResponseResult getDaa001([FromBody] JObject data)
{
var lineNo = data["lineNo"].ToString();
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().GetDaa001s(lineNo);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
[HttpPost("setJYItem")]
public ResponseResult setJYItem([FromBody] JObject data)
{
var itemNo = data["itemNo"].ToString();
var quantity = Convert.ToDecimal(data["quantity"].ToString());
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().SetItems(itemNo, quantity);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
[HttpPost("save")]
public ResponseResult save([FromBody] RKJDto rkjDto)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().save(rkjDto);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
[HttpPost("getPage")]
public ResponseResult getPage([FromBody] XJPageResult queryObj)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().getPage(queryObj);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//getItems
[HttpPost("getItems")]
public ResponseResult getJYItem([FromBody] JObject data)
{
var pid = data["pid"]?.ToString();
var id = data["id"]?.ToString();
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().GetItems(Convert.ToDecimal(pid),
Convert.ToDecimal(id));
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//removeXJ
[HttpPost("removeXJ")]
public ResponseResult removeXJ([FromBody] JObject data)
{
var id = data["id"]?.ToString();
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().removeXJ(Convert.ToDecimal(id));
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//getXjDetail02ById
[HttpPost("getXjDetail02ById")]
public ResponseResult getXjDetail02ById([FromBody] JObject data)
{
var id = data["id"]?.ToString();
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().getXjDetail02ById(Convert.ToDecimal(id));
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
[HttpPost("SetQSItemDetail")]
public ResponseResult SetQSItemDetail([FromBody] QsItemOqcItemDetail detail)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList = new RKJService();
var detail021 = tbBillList.SetQSItemDetail(detail);
resultInfos.tbBillList = detail021;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
[HttpPost("UpdateQSItemDetail")]
public ResponseResult UpdateQSItemDetail(
[FromBody] QsItemOqcItemDetail detail)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList = new RKJService();
var detail021 = tbBillList.UpdateQSItemDetail(detail);
resultInfos.tbBillList = detail021;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//saveRemarksGid
[HttpPost("saveRemarksGid")]
public ResponseResult saveRemarksGid([FromBody] RKJDto rkjDto)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().saveRemarksGid(rkjDto);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//saveRemarksPid
[HttpPost("saveRemarksPid")]
public ResponseResult saveRemarksPid([FromBody] RKJDto rkjDto)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().saveRemarksPid(rkjDto);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//saveRemarksById
[HttpPost("saveRemarksById")]
public ResponseResult saveRemarksById([FromBody] RKJDto rkjDto)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().saveRemarksById(rkjDto);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
[HttpPost("saveItem")]
public ResponseResult saveItem([FromBody] RKJDto xjDto)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new RKJService().saveItem(xjDto);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 提交入库检结果
///
/// 包含gid和userNo的JSON对象
/// 提交结果
[HttpPost("submitRKJResult")]
public ResponseResult submitRKJResult([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
};
}
dynamic resultInfos = new ExpandoObject();
var result = new RKJService().SubmitRKJResult(gid, userNo);
resultInfos.tbBillList = result;
return new ResponseResult
{
status = 0,
message = "提交成功",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
}