| | |
| | | using System.Text; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System.Data; |
| | | |
| | | namespace PadApplication.Services; |
| | | |
| | |
| | | /// </summary> |
| | | public class MesCutterLedgerManager : Repository<MesCutterLedger> |
| | | { |
| | | private readonly MesQaItemsDetect02Manager |
| | | mesQaItemsDetect02Manager = new(); |
| | | //private readonly MesQaItemsDetect02Manager |
| | | //mesQaItemsDetect02Manager = new(); |
| | | |
| | | /// <summary> |
| | | /// 刀具查询(支持编号或名称模糊查询) |
| | | /// </summary> |
| | | /// <param name="searchKey">查询关键字</param> |
| | | /// <returns>刀具列表</returns> |
| | | public List<MesCutterLedger> QueryTools(string searchKey) |
| | | /// <param name="pageIndex">页码</param> |
| | | /// <param name="pageSize">每页大小</param> |
| | | /// <returns>刀具查询结果</returns> |
| | | public MesCutterLedger QueryTools(string searchKey, int pageIndex, int pageSize) |
| | | { |
| | | return Db.Queryable<MesCutterLedger>() |
| | | var query = Db.Queryable<MesCutterLedger>() |
| | | .WhereIF(!string.IsNullOrEmpty(searchKey), |
| | | t => t.CutterId.Contains(searchKey) || t.CutterName.Contains(searchKey)) |
| | | .ToList(); |
| | | t => t.CutterId.Contains(searchKey) || t.CutterName.Contains(searchKey)); |
| | | |
| | | var total = query.Count(); |
| | | var tbBillList = query |
| | | .OrderBy(t => t.CutterId) |
| | | .ToPageList(pageIndex, pageSize, ref total); // 使用ToPageList分页 |
| | | |
| | | return new MesCutterLedger |
| | | { |
| | | tbBillList = tbBillList, |
| | | total = total |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 上下刀操作(上刀type=0,下刀type=1) |
| | | /// 仅负责参数转发,所有数据写入由存储过程完成。 |
| | | /// </summary> |
| | | /// <param name="machineNo">机台编号</param> |
| | | /// <param name="toolNo">刀具编号</param> |
| | | /// <param name="type">操作类型(上刀、下刀)</param> |
| | | /// <param name="useLimit">使用上限</param> |
| | | /// <returns>存储过程执行结果</returns> |
| | | public object SubmitToolAction(string workOrderNo, string machineNo, string toolNo, string type, int? useLimit) |
| | | { |
| | | var parameters = new[] |
| | | { |
| | | new SugarParameter("V_WORK_ORDER_NO", workOrderNo), |
| | | new SugarParameter("V_MACHINE_NO", machineNo), |
| | | new SugarParameter("V_TOOL_NO", toolNo), |
| | | new SugarParameter("V_TYPE", type), |
| | | new SugarParameter("V_USE_LIMIT", useLimit ?? (object)DBNull.Value), |
| | | new SugarParameter("PO_OUTMSG", null) { Direction = ParameterDirection.Output, DbType = System.Data.DbType.String, Size = 200 }, |
| | | new SugarParameter("PO_OUTSUM", null) { Direction = ParameterDirection.Output, DbType = System.Data.DbType.Int32 } |
| | | }; |
| | | try |
| | | { |
| | | Db.Ado.UseStoredProcedure().SqlQuery<object>( |
| | | "PROC_TOOL_ACTION", parameters); |
| | | var outMsg = parameters[5].Value?.ToString(); |
| | | var outSum = parameters[6].Value; |
| | | return new { outMsg, outSum }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | } |