123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- using Dm;
- using NPOI.SS.Formula.Functions;
- using Org.BouncyCastle.Asn1.Ocsp;
- using Org.BouncyCastle.Bcpg;
- using SqlSugar;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using wms.sqlsugar.model.hj;
- using WMS.BZModels;
- using WMS.BZModels.Dto.HJ.BillInvDtos;
- using WMS.BZModels.Dto.HJ.TaskDtos;
- using WMS.Info;
- using WMS.BZSqlSugar;
- using WMS.Util;
- using static log4net.Appender.ColoredConsoleAppender;
- using static NPOI.HSSF.Util.HSSFColor;
- using static System.Formats.Asn1.AsnWriter;
- namespace WMS.BZServices.HJ
- {
- public class BaseInvService
- {
- private readonly Repository<BillInvnow> _billInvnowrepository;
- public BaseInvService(Repository<BillInvnow> billInvnowrepository)
- {
- _billInvnowrepository = billInvnowrepository;
- }
- public PagedInfo<BillInvNowDto> GetPageList(Pagination pagination, BillInvNowQueryDto billInvNowQueryDto)
- {
- ISugarQueryable<BillInvNowDto> sugarQueryable = GetQueryable(billInvNowQueryDto);
- var list = sugarQueryable.ToPage(pagination);
- return list;
- }
- public IList<BillInvNowDto> GetList(BillInvNowQueryDto billInvNowQueryDto)
- {
- ISugarQueryable<BillInvNowDto> sugarQueryable = GetQueryable(billInvNowQueryDto);
- var list = sugarQueryable.ToList();
- return list;
- }
- private ISugarQueryable<BillInvNowDto> GetQueryable(BillInvNowQueryDto billInvNowQueryDto)
- {
- var predicate = Expressionable.Create<BillInvnow, BaseWarecell>();
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.KeyWord), (billInvnow, warecell) => warecell.Code.Contains(billInvNowQueryDto.KeyWord) || billInvnow.ContGrpBarCode.Contains(billInvNowQueryDto.KeyWord) || billInvnow.MatCode.Contains(billInvNowQueryDto.KeyWord) || billInvnow.MatName.Contains(billInvNowQueryDto.KeyWord) || billInvnow.InvBarCode.Contains(billInvNowQueryDto.KeyWord));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.Id), (billInvnow, warecell) => billInvnow.Id.ToString().Contains(billInvNowQueryDto.Id));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.ContGrpId), (billInvnow, warecell) => billInvnow.ContGrpId.ToString().Contains(billInvNowQueryDto.ContGrpId));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.EquContGrpId), (billInvnow, warecell) => billInvnow.ContGrpId.ToString().Equals(billInvNowQueryDto.EquContGrpId));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.MatCode), (billInvnow, warecell) => billInvnow.MatCode.Contains(billInvNowQueryDto.MatCode));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.MatName), (billInvnow, warecell) => billInvnow.MatName.Contains(billInvNowQueryDto.MatName));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.RFIDBarCode), (billInvnow, warecell) => billInvnow.RFIDBarCode.Contains(billInvNowQueryDto.RFIDBarCode));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.InvBarCode), (billInvnow, warecell) => billInvnow.InvBarCode.Contains(billInvNowQueryDto.InvBarCode));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.PutRow), (billInvnow, warecell) => billInvnow.PutRow.Equals(billInvNowQueryDto.PutRow));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.PutCol), (billInvnow, warecell) => billInvnow.PutCol.Equals(billInvNowQueryDto.PutCol));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.PutLayer), (billInvnow, warecell) => billInvnow.PutLayer.Equals(billInvNowQueryDto.PutLayer));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.Grade), (billInvnow, warecell) => billInvnow.Grade.Contains(billInvNowQueryDto.Grade));
- predicate = predicate.AndIF(billInvNowQueryDto != null && billInvNowQueryDto.OneInTimeBegin.HasValue, (billInvnow, warecell) => billInvnow.OneInTime >= billInvNowQueryDto.OneInTimeBegin);
- predicate = predicate.AndIF(billInvNowQueryDto != null && billInvNowQueryDto.OneInTimeEnd.HasValue, (billInvnow, warecell) => billInvnow.OneInTime <= billInvNowQueryDto.OneInTimeEnd);
- predicate = predicate.AndIF(billInvNowQueryDto != null && billInvNowQueryDto.ProductTimeBegin.HasValue, (billInvnow, warecell) => billInvnow.ProductTime >= billInvNowQueryDto.ProductTimeBegin);
- predicate = predicate.AndIF(billInvNowQueryDto != null && billInvNowQueryDto.ProductTimeEnd.HasValue, (billInvnow, warecell) => billInvnow.ProductTime <= billInvNowQueryDto.ProductTimeEnd);
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.Tunnel), (billInvnow, warecell) => warecell.Tunnel.Equals(billInvNowQueryDto.Tunnel));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.Code), (billInvnow, warecell) => warecell.Code.Contains(billInvNowQueryDto.Code));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.IsSurplus), (billInvnow, warecell) => billInvnow.IsSurplus.Equals(billInvNowQueryDto.IsSurplus));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.IsRework), (billInvnow, warecell) => billInvnow.IsRework.Equals(billInvNowQueryDto.IsRework));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.IsFail), (billInvnow, warecell) => billInvnow.IsFail.Equals(billInvNowQueryDto.IsFail));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.IsFast), (billInvnow, warecell) => billInvnow.IsFast.Equals(billInvNowQueryDto.IsFast));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.IsBack), (billInvnow, warecell) => billInvnow.IsBack.Equals(billInvNowQueryDto.IsBack));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.ExecStateCode), (billInvnow, warecell) => billInvnow.ExecStateCode.Equals(billInvNowQueryDto.ExecStateCode));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.ContGrpType), (billInvnow, warecell) => billInvnow.ContGrpType.Equals(billInvNowQueryDto.ContGrpType));
- if (!string.IsNullOrEmpty(billInvNowQueryDto?.InvStateCode))
- {
- var enums = (InvState)Enum.ToObject(typeof(InvState), Convert.ToInt32(billInvNowQueryDto?.InvStateCode));
- predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.InvStateCode), (billInvnow, warecell) => billInvnow.InvStateCode.Equals(enums.ToString()));
- }
- var sugarQueryable = _billInvnowrepository.Context.Queryable<BillInvnow, BaseWarecell>((billInvnow, warecell) => new object[] {
- JoinType.Left,billInvnow.ContGrpId == warecell.ContGrpId && billInvnow.WarehouseId ==warecell.WarehouseId }).Where(predicate.ToExpression())
- .Select((billInvnow, warecell) => new BillInvNowDto
- {
- Id = billInvnow.Id.ToString(),
- WarehouseId = billInvnow.WarehouseId.ToString(),
- ContGrpId = billInvnow.ContGrpId.ToString(),
- ContGrpBarCode = billInvnow.ContGrpBarCode,
- ContGrpType = billInvnow.ContGrpType,
- BoxBarCode = billInvnow.BoxBarCode,
- BomDocsNo = billInvnow.BomDocsNo,
- BomMatId = billInvnow.BomMatId.ToString(),
- BomMatCode = billInvnow.BomMatCode,
- BomMatName = billInvnow.BomMatName,
- BomSetId = billInvnow.BomSetId.ToString(),
- ExecStateCode = billInvnow.ExecStateCode,
- InvStateCode = billInvnow.InvStateCode,
- ExecDocsNo = billInvnow.ExecDocsNo,
- ExecDocsRowNo = billInvnow.ExecDocsRowNo,
- ExecDocsTypeCode = billInvnow.ExecDocsTypeCode,
- InvInOut = billInvnow.InvInOut,
- ExecWho = billInvnow.ExecWho,
- ExecTime = billInvnow.ExecTime,
- PutRow = billInvnow.PutRow,
- PutCol = billInvnow.PutCol,
- PutLayer = billInvnow.PutLayer,
- InvBarCode = billInvnow.InvBarCode,
- InDocsNo = billInvnow.InDocsNo,
- InDocsRowNo = billInvnow.InDocsRowNo,
- SuppCode = billInvnow.SuppCode,
- SuppName = billInvnow.SuppName,
- CustCode = billInvnow.CustCode,
- CustName = billInvnow.CustName,
- MatId = billInvnow.MatId.ToString(),
- MatCode = billInvnow.MatCode,
- MatName = billInvnow.MatName,
- TolWQty = billInvnow.TolWQty,
- NetWQty = billInvnow.NetWQty,
- TareWQty = billInvnow.TareWQty,
- LengthQty = billInvnow.LengthQty,
- CaQty = billInvnow.CaQty,
- SolderQty = billInvnow.SolderQty,
- ContUsageQty = billInvnow.ContUsageQty,
- BatchNo = billInvnow.BatchNo,
- ProductTime = billInvnow.ProductTime,
- OneInTime = billInvnow.OneInTime,
- RodBarCode = billInvnow.RodBarCode,
- HWBarCode = billInvnow.HWBarCode,
- RFIDBarCode = billInvnow.RFIDBarCode,
- CLBarCode = billInvnow.CLBarCode,
- HWTypeCode = billInvnow.HWTypeCode,
- BoilerNo = billInvnow.BoilerNo,
- PackNo = billInvnow.PackNo,
- BrandNo = billInvnow.BrandNo,
- ExecStd = billInvnow.ExecStd,
- LicenceCode = billInvnow.LicenceCode,
- IsSurplus = billInvnow.IsSurplus,
- IsRework = billInvnow.IsRework,
- IsBlack = billInvnow.IsBlack,
- IsCore = billInvnow.IsCore,
- IsFast = billInvnow.IsFast,
- IsFail = billInvnow.IsFail,
- FailReason = billInvnow.FailReason,
- SilkTypeCode = billInvnow.SilkTypeCode,
- Grade = billInvnow.Grade,
- IsBack = billInvnow.IsBack,
- BackReason = billInvnow.BackReason,
- IsTorsChk = billInvnow.IsTorsChk,
- TorsChkQty = billInvnow.TorsChkQty,
- TorsChkTime = billInvnow.TorsChkTime,
- TorsChkValue = billInvnow.TorsChkValue,
- TorsChkMachCode = billInvnow.TorsChkMachCode,
- ProcessDocsCode = billInvnow.ProcessDocsCode,
- ProductMachCode = billInvnow.ProductMachCode,
- ProductLineNo = billInvnow.ProductLineNo,
- HoldDuration=billInvnow.HoldDuration,
- Remark = billInvnow.Remark,
- Default1 = billInvnow.Default1,
- Default2 = billInvnow.Default2,
- Default3 = billInvnow.Default3,
- AddWho = billInvnow.AddWho,
- AddTime = billInvnow.AddTime,
- EditWho = billInvnow.EditWho,
- EditTime = billInvnow.EditTime,
- Size = billInvnow.Size,
- Memo = billInvnow.Memo,
- Tunnel = warecell.Tunnel,
- Code = warecell.Code,
- CellState = warecell.IsStop,
- }).MergeTable();
- return sugarQueryable;
- }
- public List<EnumEntity> InvStateList()
- {
- return BZModels.Extensions.EnumToList<InvState>();
- }
- public List<EnumEntity> TaskStatusList()
- {
- return BZModels.Extensions.EnumToList<BZModels.TaskStatus>();
- }
- public List<EnumEntity> TaskTypeList()
- {
- return BZModels.Extensions.EnumToList<TaskType>();
- }
- public List<EnumEntity2> TaskBusTypeList()
- {
- return BZModels.Extensions.EnumToListDesc<TaskBusType>();
- }
- public List<EnumEntity> AGVTaskTypeList()
- {
- return BZModels.Extensions.EnumToList<AGVTaskType>();
- }
- public List<EnumEntity> FackbeekTypeList()
- {
- return BZModels.Extensions.EnumToList<FackbeekType>();
- }
- public List<EnumEntity> AGVTaskStatus()
- {
- return BZModels.Extensions.EnumToList<AGVTaskStatus>();
- }
- public List<EnumEntity> ContGrpTypeList()
- {
- return BZModels.Extensions.EnumToList<ContGrpType>();
- }
- public List<EnumEntity> DocTypeList()
- {
- return BZModels.Extensions.EnumToList<DocType>();
- }
- public List<EnumEntity> DocStateList()
- {
- return BZModels.Extensions.EnumToList<DocState>();
- }
- public List<EnumEntity> LocationStateList()
- {
- return BZModels.Extensions.EnumToList<LocationState>();
- }
- public List<EnumEntity> AutoManualOutTypeList()
- {
- return BZModels.Extensions.EnumToList<AutoManualOutType>();
- }
- public List<EnumEntity2> InvLockStateList()
- {
- return BZModels.Extensions.EnumToListIdDesc<InvLockState>();
- }
- public List<EnumEntity> YesNoList()
- {
- return BZModels.Extensions.EnumToList<YesNo>();
- }
-
- }
- }
|