using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Mvc;
|
using WIDESEA_Core;
|
using WIDESEA_Core.BaseRepository;
|
using WIDESEA_Core.BaseServices;
|
using WIDESEA_IBusinessesRepository;
|
using WIDESEA_IBusinessServices;
|
using WIDESEA_Model.Models;
|
using WIDESEA_Repository;
|
|
namespace WIDESEA_BusinessServices
|
{
|
public class Dt_PalletInfoService : ServiceBase<Dt_PalletInfo, IDt_PalletInfoRepository>, IDt_PalletInfoService
|
{
|
private readonly IUnitOfWorkManage _unitOfWorkManage;
|
private readonly IDt_AreaInfoRepository _areaInfoRepository;
|
public Dt_PalletInfoService(IDt_PalletInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IDt_AreaInfoRepository areaInfoRepository) : base(BaseDal)
|
{
|
_unitOfWorkManage = unitOfWorkManage;
|
_areaInfoRepository = areaInfoRepository;
|
}
|
|
public override WebResponseContent AddData(SaveModel saveModel)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
//string palletCode = saveModel.MainData["palletCode"].ToString();
|
string areaCode = saveModel.MainData["areaCode"].ToString();
|
|
var areaInfo = _areaInfoRepository.QueryFirst(x => x.AreaCode == areaCode);
|
if (areaInfo == null) throw new Exception("未知区域");
|
|
var barcodeInfo = BaseDal.QueryData(x => x.AreaCode == areaCode).OrderByDescending(x => x.CreateDate).FirstOrDefault();
|
int serial = 1;
|
if (barcodeInfo != null)
|
{
|
serial = barcodeInfo.SerialNo + 1;
|
}
|
|
Dt_PalletInfo palletInfo = new Dt_PalletInfo
|
{
|
AreaCode = areaCode,
|
CreateDate = DateTime.Now,
|
Creater = App.User.UserName,
|
PalletCode = areaInfo.AreaType + serial.ToString().PadLeft(6, '0'),
|
PalletType = 1,
|
PrintStatus = 0,
|
SerialNo = serial
|
};
|
|
if (BaseDal.AddData(palletInfo) > 0)
|
{
|
return content.OK($"添加条码信息成功");
|
}
|
else
|
{
|
throw new Exception("添加条码信息异常");
|
}
|
}
|
catch (Exception ex)
|
{
|
return content.Error($"添加托盘信息异常{ex.Message}");
|
}
|
}
|
|
|
|
public WebResponseContent PrintStatusUp(string printCode)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
var palletInfo = BaseDal.QueryFirst(x => x.PalletCode == printCode);
|
if (palletInfo == null) throw new Exception("打印条码信息不存在");
|
|
palletInfo.PrintStatus = 1;
|
BaseDal.UpdateData(palletInfo);
|
return content.OK("打印条码成功");
|
}
|
catch (Exception ex)
|
{
|
return content.Error($"打印条码异常{ex.Message}");
|
}
|
}
|
}
|
}
|