using System.Data;
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;
using Newtonsoft.Json.Linq;
namespace MESApplication.Controllers.QC;
[Route("api/[controller]")]
[ApiController]
public class LljController : ControllerBase
{
[HttpPost("getPage")]
public ResponseResult getPage([FromBody] XJPageResult queryObj)
{
try
{
dynamic resultInfos = new ExpandoObject();
var (item, totalCount) = new LljService().GetPage(queryObj);
var tbBillList =
resultInfos.tbBillList = item;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos,
TotalCount = totalCount
};
}
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());
var releaseNo = data["releaseNo"].ToString();
try
{
dynamic resultInfos = new ExpandoObject();
var msg = new LljService().SetItems(itemNo, quantity, releaseNo);
return new ResponseResult
{
status = int.Parse(msg[0]),
message = msg[1],
data = msg[1]
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
[HttpPost("saveItem")]
public ResponseResult saveItem([FromBody] LLJDto lljDto)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new LljService().saveItem(lljDto);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
[HttpPost("SaveCheckBy")]
public ResponseResult SaveCheckBy([FromBody] JObject data)
{
try
{
var NewStaffName = data["NewStaffName"].ToString();
var userID = data["userID"].ToString();
var releaseNo = data["releaseNo"].ToString();
var NewStaffUserID = data["NewStaffUserID"].ToString();
var msg =
new LljService().SaveCheckBy(NewStaffUserID, userID, releaseNo);
return new ResponseResult
{
status = int.Parse(msg[0]),
message = msg[1],
data = msg[1]
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//getItems
[HttpPost("getJYItem")]
public ResponseResult getJYItem([FromBody] JObject data)
{
var id = data["id"]?.ToString();
var releaseNo = data["releaseNo"]?.ToString();
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new LljService().GetItems(releaseNo,
Convert.ToDecimal(id));
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 获取一致性核对项目
///
///
///
[HttpPost("getYzxItem")]
public ResponseResult getYzxItem([FromBody] JObject data)
{
var id = data["id"]?.ToString();
try
{
var tbBillList = new LljService().getYzxBDlist(id);
return new ResponseResult
{
status = 0,
message = "OK",
data = tbBillList
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 获取检验单所有不良描述
///
///
///
[HttpPost("getJYBlmsItem")]
public ResponseResult getJYBlmsItem([FromBody] JObject data)
{
var id = data["id"]?.ToString();
try
{
var tbBillList = new LljService().getBlmsItem(id);
return new ResponseResult
{
status = 0,
message = "OK",
data = tbBillList
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 保存一致性核对项目
///
///
///
[HttpPost("saveYzxItem")]
public ResponseResult saveYzxItem([FromBody] JObject data)
{
var id = data["id"]?.ToString();
var dataDt = data["data"]?.ToString();
var dt = JsonConvert.DeserializeObject(dataDt);
try
{
new LljService().saveYzxBDlist(id, dt);
var msg = new LljService().YzxImgVerify(id);
return new ResponseResult
{
status = int.Parse(msg[0]),
message = msg[1],
data = ""
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 获取所有检验员信息
///
///
///
[HttpPost("getAllInspectors")]
public ResponseResult getAllInspectors([FromBody] JObject data)
{
try
{
var tbBillList = new LljService().getAllInspectors();
return new ResponseResult
{
status = 0,
message = "OK",
data = tbBillList
};
}
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 LljService().getXjDetail02ById(Convert.ToDecimal(id));
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 通过条码获取送检单信息
///
///
///
[HttpPost("getFromInfo")]
public ResponseResult getFromInfo([FromBody] JObject data)
{
var id = data["Barcode"]?.ToString();
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new LljService().getFromInfo(id);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 获取不良描述信息
///
///
///
[HttpPost("getBlmsItem")]
public ResponseResult getBlmsItem([FromBody] JObject data)
{
try
{
var tbBillList = new LljService().getBlmsItem();
string[] arrRate = tbBillList.AsEnumerable()
.Select(d => d.Field("DEFECT_NAME")).ToArray();
return new ResponseResult
{
status = 0,
message = "OK",
data = arrRate
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
[HttpPost("SetQSItemDetail")]
public ResponseResult SetQSItemDetail(
[FromBody] MesQaItemsDetectDetail12 detail)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList = new LljService();
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] MesQaItemsDetectDetail12 detail)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList = new LljService();
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] LLJDto rkjDto)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new LljService().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] LLJDto rkjDto)
{
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new LljService().saveRemarksPid(rkjDto);
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 releaseNo = data["releaseNo"]?.ToString();
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new LljService().removeXJ(releaseNo);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//IqcQaSubmit
[HttpPost("IqcQaSubmit")]
public ResponseResult IqcQaSubmit(LLJDto rkjDto)
{
try
{
dynamic resultInfos = new ExpandoObject();
var msg = new LljService().IqcQaSubmit(rkjDto);
return new ResponseResult
{
status = int.Parse(msg[0]),
message = msg[1],
data = msg[1]
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//IqcQaSubmit
[HttpPost("getImgBDlist")]
public ResponseResult getImgBDlist([FromBody] JObject data)
{
try
{
var id = data["id"]?.ToString();
var db = new LljService().getImgBDlist(id);
return new ResponseResult
{
status = int.Parse("0"),
message = "OK",
data = db
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 获取U9图纸数据
///
///
///
[HttpPost("GetFileUrlByU9List")]
public async Task GetFileUrlByU9List(
[FromBody] JObject data)
{
try
{
var type = data["type"]?.ToString();
var itemID = data["u9No"]?.ToString();
dynamic resultInfos = new ExpandoObject();
var lljService = new LljService();
var tbBillList = await lljService.GetFileUrlByU9List(type, itemID);
if (tbBillList != null)
return new ResponseResult
{
status = 0,
message = "OK",
data = tbBillList
};
return new ResponseResult
{
status = 0,
message = "OK",
data = ""
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 实验室送检数据保存
///
/// 实验室送检数据
///
[HttpPost("SaveSysSubmit")]
public ResponseResult SaveSysSubmit(SysSubmit sysSubmit)
{
try
{
var msg = new LljService().SaveSysSubmit(sysSubmit);
return new ResponseResult
{
status = int.Parse(msg[0]),
message = msg[1],
data = msg[1]
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 送货单签收并生成到货单
///
///
///
[HttpPost("SignDelivery")]
public async Task SignDelivery(string id)
{
try
{
//string[] msg = new LljService().SaveSysSubmit(sysSubmit);
var msg = await new LljService().SignDelivery(id);
return new ResponseResult
{
status = int.Parse(msg[0]),
message = msg[1],
data = msg[1]
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
}