using System.Dynamic;
|
using Masuit.Tools.Models;
|
using MES.Service.DB;
|
using MES.Service.Dto.service;
|
using MES.Service.Modes;
|
using MES.Service.Modes.DingAPI;
|
using MES.Service.service.QC;
|
using MES.Service.util;
|
using Microsoft.AspNetCore.Mvc;
|
using Newtonsoft.Json.Linq;
|
using SqlSugar.Extensions;
|
|
namespace MESApplication.Controllers.QC;
|
|
[Route("api/[controller]")]
|
[ApiController]
|
public class SJController : ControllerBase
|
{
|
[HttpPost("GetMaxBillNo")]
|
public ResponseResult GetMaxBillNo()
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList =
|
new SJService().getMaxBillNo();
|
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] SJPageResult queryObj)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var (items, totalCount) = new SJService().getPage(queryObj);
|
resultInfos.tbBillList = items;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos,
|
TotalCount = totalCount
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
|
|
//SetQSItems
|
[HttpPost("SetQSItems")]
|
public ResponseResult SetQSItems([FromBody] JObject data)
|
{
|
var itemNo = data["itemNo"].ToString();
|
var planName = data["planName"].ToString();
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
var detail021 = tbBillList.SetQSItems(itemNo, planName);
|
resultInfos.tbBillList = detail021;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("SavePlan")]
|
public ResponseResult SavePlan([FromBody] JObject data)
|
{
|
decimal pid = Convert.ToDecimal(data["pid"]);
|
string planName = data["planName"].ToString();
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var SJ = new SJService();
|
decimal res = SJ.SavePlan(pid, planName);
|
resultInfos.res = res;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("GetItemProj")]
|
public ResponseResult GetItemProj([FromBody] JObject data)
|
{
|
var itemNo = data["itemNo"]?.ToString();
|
|
try
|
{
|
var service = new SJService();
|
var qaPlans = service.GetItemProj(itemNo);
|
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.qaPlans = qaPlans; // 返回到前端
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("CreateNew")]
|
public ResponseResult CreateNew([FromBody] JObject data)
|
{
|
var daaNo = data["daaNo"]?.ToString();
|
var userNo = data["statusUser"]?.ToString();
|
var planName = data["planName"]?.ToString();
|
|
try
|
{
|
var service = new SJService();
|
var (res, msg, billNo) = service.CreateNew(daaNo, userNo,planName);
|
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.res = res;
|
resultInfos.msg = msg;
|
resultInfos.billNo = billNo;// 返回到前端
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("Save")]
|
public ResponseResult Save([FromBody] QsItem item)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
var detail021 = tbBillList.Save(item);
|
resultInfos.tbBillList = detail021;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
//SaveItem
|
[HttpPost("SaveItem")]
|
public ResponseResult SaveItem([FromBody] QsItem item)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
var detail021 = tbBillList.SaveItem(item);
|
resultInfos.tbBillList = detail021;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
//getQSItems
|
[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 SJService();
|
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);
|
}
|
}
|
|
/// <summary>
|
/// 获取行不良原因
|
/// </summary>
|
/// <param name="data"></param>
|
/// <returns></returns>
|
[HttpPost("GetReason")]
|
public ResponseResult GetReason([FromBody] JObject data)
|
{
|
string billNo = data["billNo"].ToString();
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
var reasons = tbBillList.GetReason(billNo);
|
resultInfos.tbBillList = reasons;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = reasons
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("GetDingDept")]
|
public ResponseResult GetDingDept()
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
var depts = tbBillList.getDingDept();
|
resultInfos.tbBillList = depts;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = depts
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("GetDeptTree")]
|
public ResponseResult GetDeptTree()
|
{
|
try
|
{
|
var db = SqlSugarHelper.GetInstance();
|
var flatList = db.Queryable<DingDept>().ToList();
|
var tbBillList = new SJService();
|
|
// 转换为树
|
var tree = tbBillList.BuildDeptTree();
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = tree
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
|
[HttpPost("GetDingUser")]
|
public ResponseResult GetDingUser()
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
var users = tbBillList.getDingUser();
|
resultInfos.tbBillList = users;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = users
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("DingJZCSD")]
|
public ResponseResult DingJZCSD(JzcsdData Indata)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
var depts = tbBillList.DingJZCSD(Indata);
|
resultInfos.tbBillList = depts;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = depts
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
|
[HttpPost("SetQSItemDetail")]
|
public ResponseResult SetQSItemDetail([FromBody] QsItemIpiItemDetail detail)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
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("getQSItemDetail")]
|
public ResponseResult getQSItemDetail([FromBody] JObject data)
|
{
|
var pid = data["pid"]?.ToString();
|
var gid = data["gid"]?.ToString();
|
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
var detail021 = tbBillList.getQSItemDetail(Convert.ToDecimal(pid),
|
Convert.ToDecimal(gid));
|
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] QsItemIpiItemDetail detail)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
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] QsItem rkjDto)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList =
|
new SJService().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] QsItem rkjDto)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList =
|
new SJService().saveRemarksPid(rkjDto);
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
//saveNotesPid
|
[HttpPost("saveNotesPid")]
|
public ResponseResult saveNotesPid([FromBody] QsItem rkjDto)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList =
|
new SJService().saveNotesPid(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] QsItem rkjDto)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList =
|
new SJService().saveRemarksById(rkjDto);
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
//removeSJ
|
[HttpPost("removeSJ")]
|
public ResponseResult removeSJ([FromBody] JObject data)
|
{
|
var id = data["id"]?.ToString();
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList =
|
new SJService().removeXJ(Convert.ToDecimal(id));
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("SJQaSubmit")]
|
public ResponseResult SJQaSubmit([FromBody] QsItem item)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new SJService();
|
var detail021 = tbBillList.SJQaSubmit(item);
|
resultInfos.tbBillList = detail021;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 更新QsItemIpiItem的IsPass值
|
/// </summary>
|
/// <param name="data">包含id和isPass的JSON对象</param>
|
/// <returns>更新结果</returns>
|
[HttpPost("UpdateQsItemIpiItemIsPass")]
|
public ResponseResult UpdateQsItemIpiItemIsPass([FromBody] JObject data)
|
{
|
try
|
{
|
var id = data["id"]?.ToString();
|
var isPass = data["isPass"]?.ToString();
|
|
if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(isPass))
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "参数不能为空",
|
data = null
|
};
|
}
|
|
dynamic resultInfos = new ExpandoObject();
|
var sjService = new SJService();
|
var result = sjService.UpdateQsItemIpiItemIsPass(Convert.ToDecimal(id), Convert.ToDecimal(isPass));
|
resultInfos.tbBillList = result;
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
}
|