xwt
2025-10-17 707e8f07abb295629f73557759cf0e708ca6b5fa
StandardInterface/MESApplication/Controllers/QC/LljController.cs
@@ -476,4 +476,378 @@
        
        return Ok();
    }
[HttpPost("getWomdab")]
    public ResponseResult getWomdab([FromBody] GetWomdabRequest data)
    {
        var daa001 = data.daa001?.ToString();
        try
        {
            dynamic resultInfos = new System.Dynamic.ExpandoObject();
            var tbBillList = new LljService().GetWomdab(daa001);
            if (tbBillList == null || tbBillList.Count == 0)
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "该检验单未上传附件信息!",
                    data = null
                };
            }
            resultInfos.tbBillList = tbBillList;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    [HttpPost("GetWomdabById")]
    public ResponseResult GetWomdabById([FromBody] GetWomdabRequest data)
    {
        var daa001 = data.daa001?.ToString();
        var ItemNo = data.ItemNo?.ToString();
        try
        {
            dynamic resultInfos = new System.Dynamic.ExpandoObject();
            var tbBillList = new LljService().GetWomdabById(daa001,ItemNo);
            if (tbBillList == null || tbBillList.Count == 0)
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "该检验单未上传附件信息!",
                    data = null
                };
            }
            resultInfos.tbBillList = tbBillList;
            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("GetMaterialByBarcode")]
    public ResponseResult GetMaterialByBarcode([FromBody] GetMaterialByBarcodeRequest data)
    {
        try
        {
            if (string.IsNullOrEmpty(data.itemBarcode))
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "二维码内容不能为空",
                    data = null
                };
            }
            dynamic resultInfos = new System.Dynamic.ExpandoObject();
            var materialInfo = new LljService().GetMaterialByBarcode(data.itemBarcode, data.currentBillNo);
            if (materialInfo == null || materialInfo.Count == 0)
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "未找到对应的物料信息,请检查二维码是否正确",
                    data = null
                };
            }
            resultInfos.tbBillList = materialInfo;
            return new ResponseResult
            {
                status = 0,
                message = "查询成功",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return new ResponseResult
            {
                status = 1,
                message = ex.Message, // 直接返回异常信息,包含"该条码不是此检验单条码!"
                data = null
            };
        }
    }
    /// <summary>
    /// 查询破坏实验记录是否存在
    /// </summary>
    /// <param name="data">查询请求数据</param>
    /// <returns>查询结果</returns>
    [HttpPost("CheckPhsyRecord")]
    public ResponseResult CheckPhsyRecord([FromBody] CheckPhsyRecordRequest data)
    {
        try
        {
            if (string.IsNullOrEmpty(data.billNo))
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "到货单号不能为空",
                    data = null
                };
            }
            if (string.IsNullOrEmpty(data.releaseNo))
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "检验单号不能为空",
                    data = null
                };
            }
            var exists = new LljService().CheckPhsyRecordExists(data.billNo, data.releaseNo);
            dynamic resultInfos = new System.Dynamic.ExpandoObject();
            resultInfos.exists = exists;
            return new ResponseResult
            {
                status = 0,
                message = "查询成功",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return new ResponseResult
            {
                status = 1,
                message = $"查询失败: {ex.Message}",
                data = null
            };
        }
    }
    /// <summary>
    /// 调用破坏实验存储过程
    /// </summary>
    /// <param name="data">破坏实验请求数据</param>
    /// <returns>执行结果</returns>
    [HttpPost("CallPhsyUpdateProcedure")]
    public ResponseResult CallPhsyUpdateProcedure([FromBody] PhsyUpdateRequest data)
    {
        try
        {
            if (string.IsNullOrEmpty(data.itemBarcode))
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "条码不能为空",
                    data = null
                };
            }
            if (string.IsNullOrEmpty(data.billNo))
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "到货单号不能为空",
                    data = null
                };
            }
            if (data.yqty <= 0)
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "条码数量必须大于0",
                    data = null
                };
            }
            if (data.cqty <= 0)
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "破坏实验数量必须大于0",
                    data = null
                };
            }
            if (string.IsNullOrEmpty(data.releaseNo))
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "检验单号不能为空",
                    data = null
                };
            }
            var (result, message) = new LljService().CallPhsyUpdateProcedure(
                data.itemBarcode,
                data.yqty,
                data.cqty,
                data.billNo,
                data.lx,
                data.releaseNo,
                data.itemId);
            dynamic resultInfos = new System.Dynamic.ExpandoObject();
            resultInfos.result = result;
            resultInfos.message = message;
            return new ResponseResult
            {
                status = result,
                message = message,
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return new ResponseResult
            {
                status = 1,
                message = $"调用存储过程失败: {ex.Message}",
                data = null
            };
        }
    }
    public class GetWomdabRequest
    {
        public string daa001 { get; set; }
        public string ItemNo { get; set; }
    }
    public class GetMaterialByBarcodeRequest
    {
        public string itemBarcode { get; set; }
        public string currentBillNo { get; set; }
    }
    public class PhsyUpdateRequest
    {
        public string itemBarcode { get; set; }
        public decimal yqty { get; set; }
        public decimal cqty { get; set; }
        public string billNo { get; set; }
        public int lx { get; set; } // 操作类型:1新增,2修改,3删除
        public string releaseNo { get; set; } // 检验单号
        public decimal? itemId { get; set; } // 物料ID
    }
    public class CheckPhsyRecordRequest
    {
        public string billNo { get; set; }
        public string releaseNo { get; set; }
    }
    [HttpPost("GetPhsyRecordInfo")]
    public ResponseResult GetPhsyRecordInfo([FromBody] CheckPhsyRecordRequest data)
    {
        try
        {
            if (string.IsNullOrEmpty(data.billNo))
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "到货单号不能为空",
                    data = null
                };
            }
            if (string.IsNullOrEmpty(data.releaseNo))
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "检验单号不能为空",
                    data = null
                };
            }
            var records = new LljService().GetPhsyRecordInfo(data.billNo, data.releaseNo);
            return new ResponseResult
            {
                status = 0,
                message = "查询成功",
                data = new { tbBillList = records }
            };
        }
        catch (Exception ex)
        {
            return new ResponseResult
            {
                status = 1,
                message = $"查询失败: {ex.Message}",
                data = null
            };
        }
    }
    /// <summary>
    /// 设置堵穴信息
    /// </summary>
    /// <param name="data">堵穴设置请求数据</param>
    /// <returns>执行结果</returns>
    [HttpPost("SetBlockedHoles")]
    public ResponseResult SetBlockedHoles([FromBody] SetBlockedHolesRequest data)
    {
        try
        {
            if (string.IsNullOrEmpty(data.releaseNo))
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "检验单号不能为空",
                    data = null
                };
            }
            if (string.IsNullOrEmpty(data.blockedHoles))
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "堵穴信息不能为空",
                    data = null
                };
            }
            if (data.itemId <= 0)
            {
                return new ResponseResult
                {
                    status = 1,
                    message = "检验项目ID不能为空",
                    data = null
                };
            }
            var (result, message) = new LljService().SetBlockedHoles(data.releaseNo, data.blockedHoles, data.itemId);
            return new ResponseResult
            {
                status = result,
                message = message,
                data = new { result = result, message = message }
            };
        }
        catch (Exception ex)
        {
            return new ResponseResult
            {
                status = 1,
                message = $"设置堵穴失败: {ex.Message}",
                data = null
            };
        }
    }
    public class SetBlockedHolesRequest
    {
        public string releaseNo { get; set; }
        public string blockedHoles { get; set; }
        public decimal itemId { get; set; }
    }
}