| | |
| | | { |
| | | public class PalletCodeInfoService : ServiceBase<Dt_PalletCodeInfo, IRepository<Dt_PalletCodeInfo>>, IPalletCodeInfoService |
| | | { |
| | | private readonly IRepository<Dt_PalletCodeInfo> _palletCodeInforepository; |
| | | private readonly IRepository<Dt_PalletTypeInfo> _palletTypeInforepository; |
| | | |
| | | public PalletCodeInfoService(IRepository<Dt_PalletCodeInfo> BaseDal) : base(BaseDal) |
| | | public PalletCodeInfoService(IRepository<Dt_PalletCodeInfo> BaseDal, IRepository<Dt_PalletCodeInfo> palletCodeInforepository, IRepository<Dt_PalletTypeInfo> palletTypeInforepository) : base(BaseDal) |
| | | { |
| | | |
| | | _palletCodeInforepository = palletCodeInforepository; |
| | | _palletTypeInforepository = palletTypeInforepository; |
| | | } |
| | | |
| | | public IRepository<Dt_PalletCodeInfo> Repository => BaseDal; |
| | | |
| | | static object locker = new object(); |
| | | |
| | | public WebResponseContent AddData(int warehouseId, int count, int palletTypeId) |
| | | { |
| | | try |
| | | { |
| | | Dt_PalletTypeInfo palletTypeInfo = _palletTypeInforepository.QueryFirst(x => x.Id == palletTypeId && x.WarehouseId == warehouseId); |
| | | if (palletTypeInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°æçç±»åé
置信æ¯"); |
| | | } |
| | | lock (locker) |
| | | { |
| | | List<Dt_PalletCodeInfo> palletCodeInfos = new List<Dt_PalletCodeInfo>(); |
| | | int serialNo = 0; |
| | | DateTime now = DateTime.Now; |
| | | Dt_PalletCodeInfo palletCodeInfo = BaseDal.QueryFirst(x => x.WarehouseId == warehouseId && x.PalletTypeId == palletTypeId && x.CreateDate.Year == now.Year && x.CreateDate.Month == now.Month && x.CreateDate.Day == now.Day, new Dictionary<string, OrderByType> { { nameof(Dt_PalletCodeInfo.SerialNo), OrderByType.Desc } }); |
| | | if (palletCodeInfo != null && palletCodeInfo.CreateDate.Year == now.Year && palletCodeInfo.CreateDate.Month == now.Month && palletCodeInfo.CreateDate.Day == now.Day) |
| | | { |
| | | serialNo = palletCodeInfo.SerialNo + 1; |
| | | } |
| | | else |
| | | { |
| | | serialNo = 1; |
| | | } |
| | | |
| | | for (int i = 0; i < count; i++) |
| | | { |
| | | |
| | | palletCodeInfos.Add(new Dt_PalletCodeInfo |
| | | { |
| | | SerialNo = serialNo, |
| | | PalletCode = palletTypeInfo.CodeStartStr + now.ToString("yyyyMMdd") + serialNo.ToString().PadLeft(3, '0'), |
| | | PalletType = 1, |
| | | PalletTypeId = palletTypeId, |
| | | WarehouseId = warehouseId, |
| | | Status = 0, |
| | | Size = 0 |
| | | }); |
| | | |
| | | serialNo = serialNo + 1; |
| | | } |
| | | BaseDal.AddData(palletCodeInfos); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent PrintStatusUp(string printCode) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_PalletCodeInfo palletCodeInfo = BaseDal.QueryFirst(x => x.PalletCode == printCode); |
| | | if (palletCodeInfo == null) |
| | | { |
| | | return content.Error("æå°çæçç ä¸åå¨"); |
| | | } |
| | | palletCodeInfo.Status = PrintStatusEnum.Printed.ObjToInt(); |
| | | BaseDal.UpdateData(palletCodeInfo); |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error("é误:" + ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |