| | |
| | | using MES.Service.DB; |
| | | using System.Data; |
| | | using MES.Service.DB; |
| | | using MES.Service.Dto.service; |
| | | using MES.Service.Modes; |
| | | using MES.Service.util; |
| | |
| | | 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) |
| | |
| | | .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 |
| | | { |
| | |
| | | }); |
| | | } |
| | | |
| | | //刷新检验项目 |
| | | 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(); |
| | | } |
| | | } |