123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- using SqlSugar;
- using wms.sqlsugar.model.pt;
- using WMS.BZModels;
- using WMS.BZModels.Dto.PT.BillInvDtos;
- using WMS.Info;
- using WMS.BZSqlSugar;
- namespace WMS.BZServices.PT
- {
- 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) => billInvnow.RFIDBarCode.Contains(billInvNowQueryDto.KeyWord) || billInvnow.ContGrpBarCode.Contains(billInvNowQueryDto.KeyWord) || billInvnow.MatCode.Contains(billInvNowQueryDto.KeyWord) || billInvnow.MatName.Contains(billInvNowQueryDto.KeyWord) || billInvnow.RodBarCode.Contains(billInvNowQueryDto.KeyWord) || billInvnow.BoilerNo.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?.BoilerNo), (billInvnow, warecell) => billInvnow.BoilerNo.Contains(billInvNowQueryDto.BoilerNo));
- 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()));
- }
- //if (!string.IsNullOrEmpty(billInvNowQueryDto?.ExecStateCode))
- //{
- // var enums = (InvLockState)Enum.ToObject(typeof(InvLockState), Convert.ToInt32(billInvNowQueryDto?.ExecStateCode));
- // predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvNowQueryDto?.ExecStateCode), (billInvnow, warecell) => billInvnow.ExecStateCode.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,
- 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,
- //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 bool UpdateInvLockState(List<string> tunnels, InvLockState invLockState, string userId)
- {
- if (!tunnels.Any())
- {
- throw new ArgumentException("没有选择数据!");
- }
- var list = _billInvnowrepository.Queryable().Where(o => tunnels.Contains(o.Id.ToString())).ToList();
- if (!list.Any())
- {
- throw new ArgumentException("没有找到数据!");
- }
- list.ForEach(o =>
- {
- o.Memo = (!string.IsNullOrWhiteSpace(o.Memo)? o.Memo+"。":"") + "原:"+o.ExecStateCode+",修改为:"+ invLockState.ToString()+",修改人:"+ userId+",修改时间"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+"。";
- o.ExecStateCode= invLockState.ToString();
- o.EditWho = userId;
- o.EditTime = DateTime.Now;
-
- });
- var result = _billInvnowrepository.UpdateRange(list.ToArray());
-
- return result;
- }
- }
- }
|