| | |
| | | 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) |
| | |
| | | }).OrderBy("b.LINE_NO").ToList(); |
| | | } |
| | | |
| | | public List<Womdaa> getDaa001(string daa020, string item) |
| | | public List<Womdaa> getDaa001(string daa020) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | return db.Queryable<Womdaa, MesItems>((a, b) => |
| | | new JoinQueryInfos(JoinType.Inner, a.Daa002 == b.Id.ToString())) |
| | | .Where((a, b) => |
| | | a.Daa015 == daa020 && |
| | | b.ItemNo == item && |
| | | statusArray.Contains(a.Daa018)) |
| | | .Select<Womdaa>(a => new Womdaa |
| | | return db.Queryable<Womdaa>() |
| | | .Where(a => a.Daa015 == daa020 && statusArray.Contains(a.Daa018)) |
| | | .Select(a => new Womdaa |
| | | { |
| | | Id = a.Id, |
| | | Daa001 = a.Daa001, |
| | | Daa003 = a.Daa003, |
| | | Daa008 = a.Daa008 |
| | | }).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取工单详细信息(包含物料信息) |
| | | /// </summary> |
| | | /// <param name="daa020">线体编号</param> |
| | | /// <returns>工单列表(包含物料信息)</returns> |
| | | public List<WorkOrderWithItemDto> getWorkOrderWithItem(string daa020) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | return db.Queryable<Womdaa, MesItems>((a, b) => |
| | | new JoinQueryInfos(JoinType.Inner, a.Daa002 == b.Id.ToString())) |
| | | .Where((a, b) => a.Daa015 == daa020 && statusArray.Contains(a.Daa018)) |
| | | .Select((a, b) => new WorkOrderWithItemDto |
| | | { |
| | | Id = a.Id, |
| | | Daa001 = a.Daa001, |
| | | Daa002 = a.Daa002, |
| | | Daa003 = a.Daa003, |
| | | Daa008 = a.Daa008, |
| | | Daa015 = a.Daa015, |
| | | Daa020 = a.Daa020, |
| | | ItemNo = b.ItemNo, |
| | | ItemName = b.ItemName, |
| | | ItemModel = b.ItemModel |
| | | }).ToList(); |
| | | } |
| | | |
| | |
| | | }).ToList(); |
| | | } |
| | | |
| | | public List<QsQaItemXj> getPage(XJPageResult queryObj) |
| | | public (List<QsQaItemXj> item, int TotalCount) getPage(XJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | |
| | | if (StringUtil.IsNotNullOrEmpty(queryObj.createUser)) |
| | | lineNo = _baseService.getUserLineNo(queryObj.createUser); |
| | | |
| | | return db |
| | | var totalCount = 0; |
| | | var data = db |
| | | .Queryable<QsQaItemXj, Womdaa, MesLine, |
| | | MesItems>((s, a, c, b) => |
| | | new JoinQueryInfos( |
| | |
| | | .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 |
| | | { |
| | |
| | | FcheckResu = s.FcheckResu, |
| | | Remarks = s.Remarks |
| | | }).OrderBy(s => s.CreateDate, OrderByType.Desc) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit); |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount); |
| | | |
| | | return (data, totalCount); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | xj.CreateBy = userNo; |
| | | xj.CreateDate = DateTime.Now; |
| | | xj.Fsubmit = 0; // 设置默认状态为未提交 |
| | | |
| | | var pid = db.Insertable(xj).ExecuteReturnIdentity(); |
| | | |
| | |
| | | return commit; |
| | | }); |
| | | |
| | | // 重新获取检验项目(包含ID) |
| | | xjDto.items = getJYItem(xj.Id, null); |
| | | |
| | | // 自动为没有上下限的检验项目生成默认的合格记录 |
| | | xjDto.items.ForEach(s => |
| | | { |
| | | if (s.MaxValue != null || s.StandardValue != null || |
| | |
| | | detail.count = (int?)s.LevelNum; |
| | | SetQSItemDetail(detail); |
| | | }); |
| | | |
| | | // 重新获取检验项目(包含自动生成的结果) |
| | | xjDto.items = getJYItem(xj.Id, null); |
| | | |
| | | return Convert.ToInt32(xj.Id); |
| | | } |
| | |
| | | }); |
| | | } |
| | | |
| | | //刷新检验项目 |
| | | 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 db = SqlSugarHelper.GetInstance(); |
| | | |
| | | // 直接更新Fsubmit字段为1(已提交状态) |
| | | var result = db.Updateable<QsQaItemXj>() |
| | | .SetColumns(s => s.Fsubmit == 1) |
| | | .SetColumns(s => s.FsubmitBy == dto.userNo) |
| | | .SetColumns(s => s.FsubmitDate == DateTime.Now) |
| | | .Where(s => s.Id == dto.id) |
| | | .ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("提交失败:未找到对应的检验单"); |
| | | } |
| | | } |
| | | 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(); |
| | | } |
| | | } |