| | |
| | | using NewPdaSqlServer.entity.Base; |
| | | using NewPdaSqlServer.util; |
| | | using SqlSugar; |
| | | using static Microsoft.EntityFrameworkCore.DbLoggerCategory; |
| | | |
| | | namespace NewPdaSqlServer.service.Warehouse; |
| | | |
| | |
| | | /// 获取未完成的退料单号列表 |
| | | /// </summary> |
| | | /// <returns>退料单号列表</returns> |
| | | public List<string> GetPendingQtList() |
| | | { |
| | | const string sql = @"SELECT qtck |
| | | FROM MES_ITEM_QT |
| | | WHERE qt015 = 1 |
| | | AND qt026 = 1 |
| | | AND QT029 = 1 |
| | | AND qt032 = 1 |
| | | AND QT014 = 0 |
| | | ORDER BY qt002"; |
| | | public dynamic GetPendingQtList(dynamic RequestInfo) |
| | | { |
| | | var orgId = RequestInfo.OrgId; |
| | | |
| | | return Db.Ado.SqlQuery<string>(sql); |
| | | if (orgId == null) |
| | | throw new Exception("组织不存在!"); |
| | | |
| | | // 获取未完成的退料单号列表 |
| | | var parameters = new[] |
| | | { |
| | | new SugarParameter("@pi_orgId", orgId), |
| | | new SugarParameter("@inP1", null), |
| | | new SugarParameter("@inP2", null), |
| | | new SugarParameter("@inP3", null), |
| | | new SugarParameter("@inP4", null) |
| | | }; |
| | | try |
| | | { |
| | | // 返回单号字符串列表 |
| | | var blDetails = Db.Ado.SqlQuery<string>( |
| | | "EXEC prc_pda_qtck_list @pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters); |
| | | return blDetails; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="query">仓库查询参数,包含用户名和单据号</param> |
| | | /// <returns>待处理的退料单明细列表</returns> |
| | | public ProductionPickDto GetPendingQtList(WarehouseQuery query) |
| | | public dynamic GetPendingQtDetailList(dynamic query, dynamic RequestInfo) |
| | | { |
| | | // 从查询参数中获取用户名和单据号 |
| | | var c_User = query.userName; |
| | | var p_bill_no = query.billNo; |
| | | var orgId = RequestInfo.OrgId; |
| | | |
| | | // 根据单据号查询退料单主表信息 |
| | | var mesItemQt = Db.Queryable<MesItemQt>() |
| | | .Where(it => it.Qtck == p_bill_no) |
| | | .First(); |
| | | if (orgId == null) |
| | | throw new Exception("组织不存在!"); |
| | | |
| | | // 如果未找到退料单,抛出异常 |
| | | if (mesItemQt == null) throw new Exception($"未查询到此其他入库申请单 {p_bill_no}"); |
| | | |
| | | //// 检查退料单的审核状态(Qt015),未审核则抛出异常 |
| | | //if (mesItemQt.Qt015 == false) |
| | | // throw new Exception($"其他出库申请单 {p_bill_no} 未审核,请确认!"); |
| | | |
| | | // 检查退料单的完结状态(Qt014),已完结则抛出异常 |
| | | //if (mesItemQt.Qt014 == true) |
| | | // throw new Exception($"其他出库申请单 {p_bill_no} 已完结,请确认!"); |
| | | |
| | | var sql = @"SELECT c.item_no ItemNo,c.item_name ItemName,c.item_model ItemModel, |
| | | ISNULL(A.qd007,0) FQty,ISNULL(A.qd008,0) SQty,ISNULL(A.qd007,0) - ISNULL(A.qd008,0) DSQty, |
| | | dbo.F_QX_GETRECODEPOTSE(A.itemId,'','','') as RecoKw |
| | | FROM MES_ITEM_QT_DATALL A |
| | | LEFT JOIN MES_ITEM_QT B ON A.qtGuid = B.guid |
| | | LEFT JOIN MES_ITEMS C ON A.itemId = C.item_id |
| | | WHERE B.qtck = @billNo AND (qt015 = 1 AND qt026 =1 AND QT029 = 1 AND qt032 = 1)"; |
| | | |
| | | var sqlParams = new List<SugarParameter> { |
| | | new("@billNo", query.billNo) |
| | | var parameters = new[] |
| | | { |
| | | new SugarParameter("@billNo",query.billNo), |
| | | new SugarParameter("@pi_orgId", orgId), |
| | | new SugarParameter("@inP1", null), |
| | | new SugarParameter("@inP2", null), |
| | | new SugarParameter("@inP3", null), |
| | | new SugarParameter("@inP4", null) |
| | | }; |
| | | |
| | | var womdabs = Db.Ado.SqlQuery<ItemDetailModel>(sql, sqlParams); |
| | | |
| | | // 检查退料单的完结状态(Qt014),已完结则抛出异常 |
| | | if (womdabs.Count < 1) |
| | | throw new Exception($"该其他出库申请单 {p_bill_no} 未全部审核,请确认!"); |
| | | |
| | | var DS_list = womdabs.Where(s => s.DSQty > 0).ToList(); |
| | | |
| | | var YS_list = womdabs.Where(s => s.SQty > 0).ToList(); |
| | | |
| | | var dto = new ProductionPickDto |
| | | try |
| | | { |
| | | //daa001 = womdaa.Daa001, |
| | | //PlanNo = womcaa.Caa020, |
| | | items = DS_list, |
| | | Ysitems = YS_list |
| | | }; |
| | | |
| | | return dto; |
| | | List<dynamic>? blDetails = Db.Ado.SqlQuery<dynamic>( |
| | | "EXEC prc_pda_qtck_detailList @billNo,@pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters); |
| | | var items = blDetails.Where(x => x.DSQty > 0).ToList(); // 待扫物料 |
| | | var ysitems = blDetails.Where(x => x.SQty > 0).ToList(); // 已扫物料 |
| | | return new |
| | | { |
| | | items = items, |
| | | ysitems = ysitems |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 保留原有异常处理逻辑 |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 扫码出库 |
| | | /// </summary> |
| | | /// <param name="query"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public (WarehouseQuery form, List<MesItemQtDatall> item, string message) |
| | | OutScanBarcode( |
| | | WarehouseQuery query) |
| | |
| | | return (query, mesItemQtDatalls, mess); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 拆分条码并出库 |
| | | /// </summary> |
| | | /// <param name="query"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public (WarehouseQuery form, List<MesItemQtDatall> item, string message) |
| | | PrintQtckBarcode( |
| | | WarehouseQuery query) |