zyf
2025-09-29 263e0e39c18a4ade744b4d1111fe8dc9de7875e8
MESApplication/Controllers/QC/SJController.cs
@@ -1,6 +1,9 @@
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;
@@ -41,14 +44,14 @@
        try
        {
            dynamic resultInfos = new ExpandoObject();
            var tbBillList =
                new SJService().getPage(queryObj);
            resultInfos.tbBillList = tbBillList;
            var (items, totalCount) = new SJService().getPage(queryObj);
            resultInfos.tbBillList = items;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
                data = resultInfos,
                TotalCount = totalCount
            };
        }
        catch (Exception ex)
@@ -153,6 +156,127 @@
            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)
@@ -272,6 +396,29 @@
            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")]
@@ -319,4 +466,68 @@
            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);
        }
    }
}