xwt
2 天以前 3f7693504fdb48ab76fd41029859d84774b42a28
首检巡检修改
已修改8个文件
428 ■■■■■ 文件已修改
StandardInterface/MES.Service/Dto/service/SJPageResult.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/Modes/MesLine.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/Modes/QsQaItemXj.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/service/QC/SJService.cs 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/service/QC/XJService.cs 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MESApplication/Controllers/QC/SJController.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MESApplication/Controllers/QC/XJController.cs 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MESApplication/appsettings.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/Dto/service/SJPageResult.cs
@@ -83,6 +83,9 @@
    [SugarColumn(ColumnName = "DAA008")]
    public decimal? Daa008 { get; set; }
    [SugarColumn(ColumnName = "FSUBMIT")]
    public decimal? Fsubmit { get; set; }
    /// <summary>
    ///     物料ID
    /// </summary>
StandardInterface/MES.Service/Modes/MesLine.cs
@@ -149,6 +149,12 @@
    public string Departmentcode { get; set; }
    /// <summary>
    ///     部门ID
    /// </summary>
    [SugarColumn(ColumnName = "DEPOT_ID")]
    public decimal? DepotId { get; set; }
    /// <summary>
    ///     所属工序
    /// </summary>
    [SugarColumn(ColumnName = "PROC_NO")]
StandardInterface/MES.Service/Modes/QsQaItemXj.cs
@@ -80,6 +80,18 @@
    public string? Modify1By { get; set; }
    /// <summary>
    ///     车间
    /// </summary>
    [SugarColumn(ColumnName = "WORKSHOP")]
    public string? WorkShop { get; set; }
    /// <summary>
    ///     部门ID
    /// </summary>
    [SugarColumn(ColumnName = "DEPARTMENT_ID")]
    public string? DepartmentId { get; set; }
    /// <summary>
    ///     单位
    /// </summary>
    [SugarColumn(ColumnName = "ITEM_UNIT")]
StandardInterface/MES.Service/service/QC/SJService.cs
@@ -3,6 +3,7 @@
using MES.Service.Modes;
using MES.Service.util;
using SqlSugar;
using System.Data;
namespace MES.Service.service.QC;
@@ -30,7 +31,7 @@
            number = no.ToString().PadLeft(4, '0');
        }
        return "SJN" + date.Replace("-", "") + number;
        return "SJ" + date.Replace("-", "") + number;
    }
    //获取所有数据分页
@@ -52,11 +53,11 @@
            .WhereIF(
                StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
                "未完成".Equals(queryObj.Result),
                a => a.Result == queryObj.Result)
                a => a.Fsubmit == 0)
            .WhereIF(
                StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
                !"未完成".Equals(queryObj.Result),
                a => a.Result != "未完成");
                a => a.Fsubmit == 1);
        // 新增的动态搜索逻辑
        if (!string.IsNullOrEmpty(queryObj.SearchValue) && !string.IsNullOrEmpty(queryObj.searchField))
@@ -501,4 +502,73 @@
        return withOracle;
    }
    //刷新检验项目
    public (int result, string message) GenUpdate(decimal? id, string? no, string? user)
    {
        var outputResult = new SugarParameter("PO_RESULT", null, System.Data.DbType.Int32, ParameterDirection.Output, 4000);
        var outputMessage = new SugarParameter("PO_TEXT", null, System.Data.DbType.String, ParameterDirection.Output, 4000);
        var parameters = new List<SugarParameter>
    {
        new("P_ID", id, System.Data.DbType.Decimal, ParameterDirection.Input),
        new("P_NO", no, System.Data.DbType.String, ParameterDirection.Input),
        new("P_USER", user, System.Data.DbType.String, ParameterDirection.Input),
        outputResult,
        outputMessage
    };
        var db = SqlSugarHelper.GetInstance();
        db.Ado.ExecuteCommand(
            "BEGIN PRC_GEN_UPDATE(:P_ID, :P_NO, :P_USER, :PO_RESULT, :PO_TEXT); END;",
            parameters.ToArray());
        int result = outputResult.Value == null ? -1 : Convert.ToInt32(outputResult.Value);
        string message = outputMessage.Value?.ToString() ?? "";
        return (result, message);
    }
    public bool SjSubmit(SJDto dto)
    {
        try
        {
            // 定义输出参数
            var outputResult = new SugarParameter("c_res", null,
                System.Data.DbType.Int32, ParameterDirection.Output,
                4000);
            var outputMessage = new SugarParameter("c_msg", null,
                System.Data.DbType.String,
                ParameterDirection.Output, 4000);
            // 定义输入参数,固定FLAG为1(审核)
            var parameters = new List<SugarParameter>
            {
                new("P_ID", dto.id, System.Data.DbType.Decimal, ParameterDirection.Input),
                new("P_FLAG", 1, System.Data.DbType.Int32, ParameterDirection.Input),
                new("P_USER", dto.userNo, System.Data.DbType.String, ParameterDirection.Input),
                outputResult,
                outputMessage
            };
            var db = SqlSugarHelper.GetInstance();
            // 使用 SqlSugar 执行存储过程
            db.Ado.ExecuteCommand(
                "BEGIN PRC_WOMDAA_SJ_UPDATE_RES(:P_ID, :P_FLAG, :P_USER, :c_res, :c_msg); END;",
                parameters.ToArray());
            // 获取输出参数的值
            var resultValue = outputResult.Value?.ToString();
            var messageValue = outputMessage.Value?.ToString();
            if ("1".Equals(resultValue)) throw new Exception(messageValue);
            return true;
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
}
StandardInterface/MES.Service/service/QC/XJService.cs
@@ -1,4 +1,5 @@
using MES.Service.DB;
using System.Data;
using MES.Service.DB;
using MES.Service.Dto.service;
using MES.Service.Modes;
using MES.Service.util;
@@ -28,14 +29,14 @@
        var number = "0001";
        var olReleaseNo = executeScalar.ToString();
        //判断今天是否生成了巡检单
        if (string.IsNullOrEmpty(olReleaseNo)) return "XJN" + date + number;
        if (string.IsNullOrEmpty(olReleaseNo)) return "XJ" + date + number;
        //截取后四位的流水号累加
        var substring = Convert.ToInt32(olReleaseNo.Substring(10));
        substring += 1;
        number = substring.ToString("D4");
        //如果为空直接返回0001
        return "XJN" + date + number;
        return "XJ" + date + number;
    }
    public List<Womdaa> getItem(string daa001)
@@ -132,11 +133,11 @@
            .WhereIF(
                StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                "未完成".Equals(queryObj.result),
                (s, a, c, b) => s.FcheckResu == null)
                (s, a, c, b) => s.Fsubmit == 0)
            .WhereIF(
                StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                !"未完成".Equals(queryObj.result),
                (s, a, c, b) => s.FcheckResu != null)
                (s, a, c, b) => s.Fsubmit != 1)
            .WhereIF(id > 0, (s, a, c, b) => s.Id == id)
            .Select((s, a, c, b) => new QsQaItemXj
            {
@@ -532,4 +533,143 @@
        });
    }
    //刷新检验项目
    public (int result, string message) GenUpdate(decimal? id, string? no, string? user)
    {
        var outputResult = new SugarParameter("PO_RESULT", null, System.Data.DbType.Int32, ParameterDirection.Output, 4000);
        var outputMessage = new SugarParameter("PO_TEXT", null, System.Data.DbType.String, ParameterDirection.Output, 4000);
        var parameters = new List<SugarParameter>
    {
        new("P_ID", id, System.Data.DbType.Decimal, ParameterDirection.Input),
        new("P_NO", no, System.Data.DbType.String, ParameterDirection.Input),
        new("P_USER", user, System.Data.DbType.String, ParameterDirection.Input),
        outputResult,
        outputMessage
    };
        var db = SqlSugarHelper.GetInstance();
        db.Ado.ExecuteCommand(
            "BEGIN PRC_GEN_UPDATE_XJ(:P_ID, :P_NO, :P_USER, :PO_RESULT, :PO_TEXT); END;",
            parameters.ToArray());
        int result = outputResult.Value == null ? -1 : Convert.ToInt32(outputResult.Value);
        string message = outputMessage.Value?.ToString() ?? "";
        return (result, message);
    }
    public bool SjSubmit(SJDto dto)
    {
        try
        {
            // 定义输出参数
            var outputResult = new SugarParameter("c_res", null,
                System.Data.DbType.Int32, ParameterDirection.Output,
                4000);
            var outputMessage = new SugarParameter("c_msg", null,
                System.Data.DbType.String,
                ParameterDirection.Output, 4000);
            // 定义输入参数,固定FLAG为1(审核)
            var parameters = new List<SugarParameter>
            {
                new("P_ID", dto.id, System.Data.DbType.Decimal, ParameterDirection.Input),
                new("P_FLAG", 1, System.Data.DbType.Int32, ParameterDirection.Input),
                new("P_USER", dto.userNo, System.Data.DbType.String, ParameterDirection.Input),
                outputResult,
                outputMessage
            };
            var db = SqlSugarHelper.GetInstance();
            // 使用 SqlSugar 执行存储过程
            db.Ado.ExecuteCommand(
                "BEGIN PRC_WOMDAA_XJ_UPDATE_RES(:P_ID, :P_FLAG, :P_USER, :c_res, :c_msg); END;",
                parameters.ToArray());
            // 获取输出参数的值
            var resultValue = outputResult.Value?.ToString();
            var messageValue = outputMessage.Value?.ToString();
            if ("1".Equals(resultValue)) throw new Exception(messageValue);
            return true;
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
    /// <summary>
    /// 获取有线体的部门列表
    /// </summary>
    /// <returns>部门列表</returns>
    public List<SysDepartment> GetDepartmentsWithLines()
    {
        var db = SqlSugarHelper.GetInstance();
        // 查询有线体的部门,链接条件是线体的DEPOT_ID等于部门的Departmentid
        var departments = db.Queryable<SysDepartment, MesLine>((dept, line) =>
                new JoinQueryInfos(JoinType.Inner, line.DepotId == dept.Departmentid))
            .Where((dept, line) => line.LineNo != null && line.LineName != null)
            .GroupBy((dept, line) => new
            {
                dept.Departmentid,
                dept.Departmentname
            })
            .Select((dept, line) => new SysDepartment
            {
                Departmentid = dept.Departmentid,
                Departmentname = dept.Departmentname
            })
            .OrderBy(dept => dept.Departmentname)
            .ToList();
        return departments;
    }
    /// <summary>
    /// 保存部门选择
    /// </summary>
    /// <param name="id">巡检单ID</param>
    /// <param name="departmentId">部门ID</param>
    /// <param name="departmentName">部门名称</param>
    /// <returns>保存结果</returns>
    public int SaveDepartmentSelection(decimal id, string departmentId, string departmentName)
    {
        return SqlSugarHelper.UseTransactionWithOracle(db =>
        {
            return db.Updateable<QsQaItemXj>()
                .SetColumns(it => it.WorkShop == departmentName)
                .SetColumns(it => it.DepartmentId == departmentId)
                .Where(it => it.Id == id)
                .ExecuteCommand();
        });
    }
    /// <summary>
    /// 根据部门ID获取该部门下的线体列表
    /// </summary>
    /// <param name="departmentId">部门ID</param>
    /// <returns>线体列表</returns>
    public List<MesLine> GetLinesByDepartment(string departmentId)
    {
        var db = SqlSugarHelper.GetInstance();
        // 将字符串转换为decimal进行比较
        if (!decimal.TryParse(departmentId, out var deptId))
        {
            return new List<MesLine>();
        }
        return db.Queryable<MesLine>()
            .Where(line => line.DepotId == deptId &&
                          line.LineNo != null &&
                          line.LineName != null)
            .OrderBy(line => line.LineNo)
            .ToList();
    }
}
StandardInterface/MESApplication/Controllers/QC/SJController.cs
@@ -319,4 +319,54 @@
            return ResponseResult.ResponseError(ex);
        }
    }
    //刷新检验项目
    [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 SJService().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);
        }
    }
    //提交检验
    [HttpPost("SjSubmit")]
    public ResponseResult SjSubmit([FromBody] SJDto sjDto)
    {
        try
        {
            dynamic resultInfos = new ExpandoObject();
            var tbBillList = new SJService().SjSubmit(sjDto);
            resultInfos.tbBillList = tbBillList;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
}
StandardInterface/MESApplication/Controllers/QC/XJController.cs
@@ -444,4 +444,133 @@
            return ResponseResult.ResponseError(ex);
        }
    }
    //刷新检验项目
    [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 XJService().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);
        }
    }
    //提交检验
    [HttpPost("SjSubmit")]
    public ResponseResult SjSubmit([FromBody] SJDto sjDto)
    {
        try
        {
            dynamic resultInfos = new ExpandoObject();
            var tbBillList = new XJService().SjSubmit(sjDto);
            resultInfos.tbBillList = tbBillList;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    /// <summary>
    /// 获取有线体的部门列表
    /// </summary>
    [HttpPost("getDepartmentsWithLines")]
    public ResponseResult GetDepartmentsWithLines()
    {
        try
        {
            dynamic resultInfos = new ExpandoObject();
            var tbBillList = new XJService().GetDepartmentsWithLines();
            resultInfos.tbBillList = tbBillList;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    /// <summary>
    /// 保存部门选择
    /// </summary>
    [HttpPost("saveDepartmentSelection")]
    public ResponseResult SaveDepartmentSelection([FromBody] JObject data)
    {
        try
        {
            var id = Convert.ToDecimal(data["id"]);
            var departmentId = data["departmentId"].ToString();
            var departmentName = data["departmentName"].ToString();
            dynamic resultInfos = new ExpandoObject();
            var result = new XJService().SaveDepartmentSelection(id, departmentId, departmentName);
            resultInfos.tbBillList = result;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    /// <summary>
    /// 根据部门ID获取该部门下的线体列表
    /// </summary>
    [HttpPost("getLinesByDepartment")]
    public ResponseResult GetLinesByDepartment([FromBody] JObject data)
    {
        try
        {
            var departmentId = data["departmentId"].ToString();
            dynamic resultInfos = new ExpandoObject();
            var tbBillList = new XJService().GetLinesByDepartment(departmentId);
            resultInfos.tbBillList = tbBillList;
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
}
StandardInterface/MESApplication/appsettings.json
@@ -10,6 +10,6 @@
  "AppSettings": {
    "TestErpUrl": "http://192.168.11.120:8098/WebService1.asmx/mesToErpinfo",
    "ProductionErpUrl": "http://192.168.11.120:8098/WebService1.asmx/mesToErpinfoFormal",
    "DataBaseConn": "Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ORCL))); Persist Security Info=True;User ID = hm_prd; Password=hmprd"
    "DataBaseConn": "Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ORCL))); Persist Security Info=True;User ID = test_dev; Password=hmprd"
  }
}