| | |
| | | using MES.Service.Modes; |
| | | using MES.Service.util; |
| | | using SqlSugar; |
| | | using DbType = System.Data.DbType; |
| | | using System.Data; |
| | | using static Microsoft.EntityFrameworkCore.DbLoggerCategory; |
| | | |
| | | namespace MES.Service.service.QC; |
| | | |
| | |
| | | } |
| | | |
| | | //获取所有数据分页 |
| | | public List<SJPageResult> getPage(SJPageResult queryObj) |
| | | public (List<SJPageResult> items, int totalCount) getPage(SJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | "未完成".Equals(queryObj.Result), |
| | | a => a.Remarks == queryObj.Result) |
| | | a => a.Result == queryObj.Result) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | !"未完成".Equals(queryObj.Result), |
| | | a => a.Remarks != "未完成") |
| | | .OrderBy(a => a.BillNo, OrderByType.Desc) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit); |
| | | a => a.Result != "未完成") |
| | | .OrderBy(a => a.BillNo, OrderByType.Desc); |
| | | var totalCount = data.Count(); |
| | | var items = data.ToPageList(queryObj.PageIndex, queryObj.Limit); |
| | | |
| | | return data; |
| | | return (items, totalCount); |
| | | } |
| | | |
| | | |
| | |
| | | item.Items = getQSItems(qsItemIpiReq.Id, null); |
| | | var sjPageResult = new SJPageResult |
| | | { Id = item.From.Id, Limit = 1, PageIndex = 1 }; |
| | | item.Result = getPage(sjPageResult)[0]; |
| | | item.Result = getPage(sjPageResult).items[0]; |
| | | |
| | | return item; |
| | | } |
| | |
| | | if (icount == 0) return 1; |
| | | |
| | | //实际个数等于理论个数时对检验单进行判定 |
| | | if (sum == icount) |
| | | { |
| | | result = 0; |
| | | //if (sum == icount) |
| | | //{ |
| | | // result = 0; |
| | | |
| | | //获取这个检验单下的所有合格的检验结果 |
| | | passCount = db.Queryable<QsItemIpiItemDetail>() |
| | | .Where(s => s.Gid == detail.Gid && s.Fstand == "√").Count(); |
| | | // //获取这个检验单下的所有合格的检验结果 |
| | | // passCount = db.Queryable<QsItemIpiItemDetail>() |
| | | // .Where(s => s.Gid == detail.Gid && s.Fstand == "√").Count(); |
| | | |
| | | //合格的检验结果等于总检验数视为合格 |
| | | if (icount == passCount) result = 1; |
| | | // //合格的检验结果等于总检验数视为合格 |
| | | // if (icount == passCount) result = 1; |
| | | |
| | | useTransactionWithOracle += SqlSugarHelper.UseTransactionWithOracle( |
| | | db => |
| | | { |
| | | return db.Updateable<QsItemIpiReq>() |
| | | .SetColumns(s => s.IsPass == result) |
| | | .SetColumns(s => s.StatusUser == detail.CreateBy) |
| | | .SetColumns(s => s.CompleteTime == DateTime.Now) |
| | | .Where(s => s.Id == detail.Gid) |
| | | .ExecuteCommand(); |
| | | }); |
| | | } |
| | | // useTransactionWithOracle += SqlSugarHelper.UseTransactionWithOracle( |
| | | // db => |
| | | // { |
| | | // return db.Updateable<QsItemIpiReq>() |
| | | // .SetColumns(s => s.IsPass == result) |
| | | // .SetColumns(s => s.StatusUser == detail.CreateBy) |
| | | // .SetColumns(s => s.CompleteTime == DateTime.Now) |
| | | // .Where(s => s.Id == detail.Gid) |
| | | // .ExecuteCommand(); |
| | | // }); |
| | | //} |
| | | |
| | | return useTransactionWithOracle; |
| | | } |
| | |
| | | |
| | | return withOracle; |
| | | } |
| | | |
| | | public bool SJQaSubmit(QsItem item) |
| | | { |
| | | |
| | | if (item == null) |
| | | throw new ArgumentNullException(nameof(item), "质检项数据不能为空"); |
| | | |
| | | if (string.IsNullOrWhiteSpace(item.userNo)) |
| | | throw new ArgumentException("用户编号不能为空", nameof(item.userNo)); |
| | | |
| | | var (factory, company) = UserUtil.GetFactory(item.userNo); |
| | | try |
| | | { |
| | | // 定义输出参数 |
| | | var outputResult = new SugarParameter("o_Result", null, DbType.Int32, ParameterDirection.Output, |
| | | 4000); |
| | | |
| | | var outputMessage = new SugarParameter("o_Msg", null, DbType.String, ParameterDirection.Output, 4000); |
| | | |
| | | // 定义输入参数 |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | |
| | | new("p_Id", item.gid, DbType.Int32,ParameterDirection.Input), |
| | | new("p_Flag", 1, DbType.Int32,ParameterDirection.Input), |
| | | new("p_User", item.userNo, 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,:o_Result, :o_Msg); END;", |
| | | parameters.ToArray()); |
| | | |
| | | // 获取输出参数的值 |
| | | var resultValue = outputResult.Value?.ToString(); |
| | | var messageValue = outputMessage.Value?.ToString(); |
| | | |
| | | if ("1".Equals(resultValue)) { throw new Exception(messageValue); } |
| | | if ("0".Equals(resultValue)) { throw new Exception(messageValue); } |
| | | |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | | } |