xwt
4 天以前 82dac540156cb29e58c86f7d7d840e3c7e548c15
StandardInterface/MESApplication/Controllers/QC/RKJController.cs
@@ -87,7 +87,15 @@
    public ResponseResult setJYItem([FromBody] JObject data)
    {
        var itemNo = data["itemNo"].ToString();
        var quantity = Convert.ToDecimal(data["quantity"].ToString());
        var quantityStr = data["quantity"]?.ToString();
        // 处理quantity为空或无效的情况
        decimal quantity = 0;
        if (!string.IsNullOrEmpty(quantityStr) && decimal.TryParse(quantityStr, out var parsedQuantity))
        {
            quantity = parsedQuantity;
        }
        try
        {
            dynamic resultInfos = new ExpandoObject();
@@ -364,4 +372,146 @@
            return ResponseResult.ResponseError(ex);
        }
    }
    /// <summary>
    /// 获取有线体的部门列表(生产车间)
    /// </summary>
    /// <returns>部门列表</returns>
    [HttpPost("GetDepartmentsWithLines")]
    public ResponseResult GetDepartmentsWithLines()
    {
        try
        {
            dynamic resultInfos = new ExpandoObject();
            var tbBillList = new RKJService().GetDepartmentsWithLines();
            resultInfos.tbBillList = tbBillList;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    /// <summary>
    /// 根据部门ID获取该部门下的线体列表
    /// </summary>
    /// <param name="data">包含departmentId的JSON对象</param>
    /// <returns>线体列表</returns>
    [HttpPost("GetLinesByDepartment")]
    public ResponseResult GetLinesByDepartment([FromBody] JObject data)
    {
        var departmentId = data["departmentId"]?.ToString();
        try
        {
            dynamic resultInfos = new ExpandoObject();
            var tbBillList = new RKJService().GetLinesByDepartment(departmentId);
            resultInfos.tbBillList = tbBillList;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    /// <summary>
    /// 保存部门选择
    /// </summary>
    /// <param name="data">包含id、departmentId、departmentName的JSON对象</param>
    /// <returns>保存结果</returns>
    [HttpPost("SaveDepartmentSelection")]
    public ResponseResult SaveDepartmentSelection([FromBody] JObject data)
    {
        var id = Convert.ToDecimal(data["id"]?.ToString());
        var departmentId = data["departmentId"]?.ToString();
        var departmentName = data["departmentName"]?.ToString();
        try
        {
            dynamic resultInfos = new ExpandoObject();
            var tbBillList = new RKJService().SaveDepartmentSelection(id, departmentId, departmentName);
            resultInfos.tbBillList = tbBillList;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    /// <summary>
    /// 提交检验单
    /// </summary>
    /// <param name="data">包含id、userNo的JSON对象</param>
    /// <returns>提交结果</returns>
    [HttpPost("submitInspection")]
    public ResponseResult SubmitInspection([FromBody] JObject data)
    {
        var id = Convert.ToDecimal(data["id"]?.ToString());
        var userNo = data["userNo"]?.ToString();
        try
        {
            dynamic resultInfos = new ExpandoObject();
            var tbBillList = new RKJService().SubmitInspection(id, userNo);
            resultInfos.tbBillList = tbBillList;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    /// <summary>
    /// 刷新检验项目 - 调用存储过程
    /// </summary>
    /// <param name="data">包含id、no、user的JSON对象</param>
    /// <returns>刷新结果</returns>
    [HttpPost("genUpdate")]
    public ResponseResult GenUpdate([FromBody] JObject data)
    {
        try
        {
            decimal? id = data["id"]?.ToObject<decimal>();
            string? no = data["no"]?.ToString();
            string? user = data["user"]?.ToString();
            var (result, message) = new RKJService().GenUpdate(id, no, user);
            dynamic resultInfos = new ExpandoObject();
            resultInfos.result = result;
            resultInfos.message = message;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
}