using Masuit.Tools;
|
using MES.Service.Modes;
|
using NewPdaSqlServer.DB;
|
using NewPdaSqlServer.Dto.service;
|
using NewPdaSqlServer.entity;
|
using NewPdaSqlServer.entity.Base;
|
using NewPdaSqlServer.util;
|
using SqlSugar;
|
using SqlSugar.Extensions;
|
using System.Data;
|
using System.Data.SqlClient;
|
using DbHelperSQL = NewPdaSqlServer.DB.DbHelperSQL;
|
|
namespace NewPdaSqlServer.service.Warehouse;
|
|
public class MesXsckManager : Repository<MesItemBl>
|
{
|
#region 生产补料
|
|
/// <summary>
|
/// 获取生产发货通知单号列表
|
/// </summary>
|
/// <returns>发货通知单号列表</returns>
|
public dynamic GetFHTZBillNo(dynamic query, dynamic RequestInfo)
|
{
|
var orgId = RequestInfo.OrgId;
|
|
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
|
{
|
// 返回单号字符串列表Get_Qt_ck_List
|
var blDetails = Db.Ado.SqlQuery<string>(
|
"EXEC prc_pda_xsck_list @pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters);
|
return blDetails;
|
}
|
catch (Exception ex)
|
{
|
throw new Exception($"{ex.Message}");
|
}
|
}
|
|
/// <summary>
|
/// 根据发货通知单获取对应代发货明细 prc_rf_pda_scan_zout_showbl
|
/// </summary>
|
/// <returns>发货通知单明细列表</returns>
|
public dynamic GetMesItemFHTZetailByBillNo(dynamic query, dynamic RequestInfo)
|
{
|
if (string.IsNullOrEmpty(query.billNo))
|
throw new Exception("请选单据号!");
|
|
if (query == null)
|
throw new ArgumentNullException(nameof(query), "参数对象不能为null");
|
|
if (string.IsNullOrEmpty(query.billNo?.ToString()))
|
throw new ArgumentException("单据号不能为空", nameof(query.billNo));
|
|
var orgId = RequestInfo.OrgId;
|
|
if (orgId == null)
|
throw new Exception("组织不存在!");
|
|
// 获取未完成的发货通知单明细
|
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)
|
};
|
try
|
{
|
List<dynamic>? blDetails = Db.Ado.SqlQuery<dynamic>(
|
"EXEC prc_pda_xsck_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,
|
allList = blDetails
|
};
|
}
|
catch (Exception ex)
|
{
|
// 保留原有异常处理逻辑
|
throw new Exception($"{ex.Message}");
|
}
|
}
|
|
/// <summary>
|
/// 生产工单补料扫码
|
/// 扫描条码 prc_rf_pda_scan_zout_barcode3
|
/// </summary>
|
/// <param name="query">查询参数</param>
|
/// <returns>扫描结果</returns>
|
/// <remarks>
|
/// 参数说明:
|
/// - billNo: 单据号(必填)
|
/// - barcode: 条码(必填)
|
/// - userName: 用户名
|
/// - blNo: 发货通知单号(必填)
|
/// </remarks>
|
public ProductionPickDto XSCKScanBarcode( WarehouseQuery query)
|
{
|
var _strMsg = "";
|
var _intSum = "";
|
using (var conn = new SqlConnection(DbHelperSQL.strConn))
|
{
|
if (query.userName.IsNullOrEmpty()) throw new Exception("用户名不允许为空");
|
if (query.billNo.IsNullOrEmpty()) throw new Exception("发货通知单号不允许为空");
|
if (query.barcode.IsNullOrEmpty()) throw new Exception("条码不允许为空");
|
|
using (var cmd = new SqlCommand("[prc_pda_XSCK]", conn))
|
{
|
try
|
{
|
conn.Open();
|
cmd.CommandType = CommandType.StoredProcedure;
|
SqlParameter[] parameters =
|
{
|
new("@outMsg", SqlDbType.NVarChar, 300),
|
new("@outSum", SqlDbType.NVarChar, 300),
|
new("@barcode_num", SqlDbType.NVarChar, 300),
|
new("@split_num", SqlDbType.NVarChar, 300),
|
new("@c_User", query.userName),
|
new("@p_biLL_no", query.billNo),
|
new("@p_item_barcode", query.barcode)
|
};
|
parameters[0].Direction = ParameterDirection.Output;
|
parameters[1].Direction = ParameterDirection.Output;
|
parameters[2].Direction = ParameterDirection.Output;
|
parameters[3].Direction = ParameterDirection.Output;
|
foreach (var parameter in parameters)
|
cmd.Parameters.Add(parameter);
|
cmd.ExecuteNonQuery();
|
_strMsg = parameters[0].Value.ToString();
|
_intSum = parameters[1].Value.ToString();
|
|
var barcodeNum = parameters[2].Value.ToString();
|
var splitNum = parameters[3].Value.ToString();
|
|
var result = Convert.ToInt32(_intSum);
|
if (result <= 0) throw new Exception(_strMsg);
|
|
var dto = new ProductionPickDto
|
{
|
daa001 = query.daa001,
|
barcodeNum = barcodeNum,
|
splitNum = splitNum,
|
barcode = query.barcode,
|
strMsg = _strMsg,
|
result = _intSum
|
};
|
|
return dto;
|
}
|
catch (Exception ex)
|
{
|
throw new Exception(ex.Message);
|
}
|
finally
|
{
|
conn.Close();
|
}
|
}
|
}
|
}
|
|
/// <summary>
|
/// 生产发货通知单条码拆分 prc_rf_pda_prnt_zout_barcode2
|
/// </summary>
|
/// <param name="query">查询参数</param>
|
/// <returns>(成功标志, 待处理列表)</returns>
|
/// <remarks>
|
/// 前台需要传入的参数:
|
/// - userName: 用户名(必填)
|
/// - billNo: 工单号(必填)
|
/// - barcode: 物料条码(必填)
|
/// - Num: 发料数量(必填,必须大于0)
|
/// - blNo: 发货通知单号(必填)
|
/// </remarks>
|
public ProductionPickDto SplitBarcode(WarehouseQuery query)
|
{
|
if (query.userName.IsNullOrEmpty()) throw new Exception("用户名不允许为空");
|
if (query.billNo.IsNullOrEmpty()) throw new Exception("申请单号不允许为空");
|
if (query.barcode.IsNullOrEmpty()) throw new Exception("条码不允许为空");
|
|
if (query.Num is null or 0) throw new Exception("条码拆分数不允许为空或者为0");
|
|
var _strMsg = "";
|
var _intSum = "";
|
var _cfBar = "";//拆分后条码
|
using (var conn = new SqlConnection(DbHelperSQL.strConn))
|
{
|
using (var cmd = new SqlCommand("[prc_pda_XSCK_CF_new]", conn))
|
{
|
try
|
{
|
conn.Open();
|
cmd.CommandType = CommandType.StoredProcedure;
|
SqlParameter[] parameters =
|
{
|
new("@outMsg", SqlDbType.NVarChar, 2000),
|
new("@outSum", SqlDbType.NVarChar, 300),
|
new("@outCfBar", SqlDbType.NVarChar, 300),
|
new("@c_user", query.userName),
|
new("@p_biLL_no", query.billNo),
|
new("@p_item_barcode", query.barcode),
|
new("@NUM", query.Num)
|
};
|
parameters[0].Direction = ParameterDirection.Output;
|
parameters[1].Direction = ParameterDirection.Output;
|
parameters[2].Direction = ParameterDirection.Output;
|
foreach (var parameter in parameters)
|
cmd.Parameters.Add(parameter);
|
cmd.ExecuteNonQuery();
|
_strMsg = parameters[0].Value.ToString();
|
_intSum = parameters[1].Value.ToString();
|
_cfBar = parameters[2].Value.ToString();
|
|
|
var result = Convert.ToInt32(_intSum);
|
if (result <= 0) throw new Exception(_strMsg);
|
|
var dto = new ProductionPickDto
|
{
|
daa001 = query.billNo,
|
barcode = query.barcode,//原条码
|
cfBarcode = _cfBar//拆分后条码
|
};
|
|
return dto;
|
}
|
catch (Exception ex)
|
{
|
throw new Exception(ex.Message);
|
}
|
finally
|
{
|
conn.Close();
|
}
|
}
|
}
|
}
|
#endregion
|
}
|