using System.Data;
|
using System.Data.SqlClient;
|
using Masuit.Tools;
|
using MES.Service.Models;
|
using NewPdaSqlServer.DB;
|
using NewPdaSqlServer.Dto.service;
|
using NewPdaSqlServer.entity;
|
using NewPdaSqlServer.entity.Base;
|
using SqlSugar;
|
|
namespace NewPdaSqlServer.service.Warehouse;
|
|
public class MesSctkManager : Repository<MesScthSq>
|
{
|
public List<MesScthSq> GetMesSctkSq()
|
{
|
return Db.Queryable<MesScthSq>()
|
.Where(s => s.Status == true)
|
.OrderByDescending(s => s.CreateDate)
|
.ToList();
|
}
|
|
public ProductionPickDto GetSumItem(WarehouseQuery query)
|
{
|
if (string.IsNullOrEmpty(query.billNo)) throw new Exception("申请单号为空");
|
|
var mesInvItemOuts = base.GetSingle(it => it.BillNo == query.billNo);
|
if (mesInvItemOuts == null) throw new Exception("采购退货申请单不存在");
|
|
var sql = string.Format(@"SELECT c.item_no ItemNo,c.item_name ItemName,c.item_model ItemModel,A.SQ_NUM FQty,A.YS_NUM SQty,A.SQ_NUM - A.YS_NUM DSQty,
|
dbo.F_QX_GETRECODEPOTSE(A.ITEM_ID,'','','') as RecoKw
|
fROM MES_SCTH_SQ_DETAIL A
|
LEFT JOIN MES_SCTH_SQ B ON A.MID = B.ID
|
LEFT JOIN MES_ITEMS C ON A.ITEM_ID = C.item_id
|
WHERE B.BILL_NO = '{0}'", query.billNo);
|
|
var womdabs = Db.Ado.SqlQuery<ItemDetailModel>(sql);
|
|
|
var DS_list = womdabs.Where(s => s.DSQty > 0).ToList();
|
|
var YS_list = womdabs.Where(s => s.SQty > 0).ToList();
|
|
var dto = new ProductionPickDto
|
{
|
//daa001 = womdaa.Daa001,
|
//PlanNo = womcaa.Caa020,
|
items = DS_list,
|
Ysitems = YS_list
|
};
|
|
return dto;
|
}
|
|
|
public ProductionPickDto ScanCode(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_SCTK]", 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
|
};
|
|
return dto;
|
}
|
catch (Exception ex)
|
{
|
throw new Exception(ex.Message);
|
}
|
finally
|
{
|
conn.Close();
|
}
|
}
|
}
|
}
|
}
|