Example #1
0
        public async Task <ResultEntity> AddReceiveLetter(ReceiveLetterEditDto receiveLetter)
        {
            var result                = new ResultEntity();
            var sendDepartmentCode    = TextHelper.RepairZeroRight(await _departmentManager.GetDepartmentCode(receiveLetter.SendDepartmentId), 11);
            var receiveDepartmentCode = TextHelper.RepairZeroRight(await _departmentManager.GetDepartmentCode(receiveLetter.ReceiveDepartmentId), 11);
            var serialNumber          = await _serialNumberManager.GetSerialNumber(receiveLetter.SendDepartmentId, EnumSerialNumberType.内部交换);

            var barcodeNo = _barcodeManager.MakeBarcodeLength33(sendDepartmentCode, receiveDepartmentCode,
                                                                (EnumSecretLevel)receiveLetter.SecretLevel, (EnumUrgentLevel)receiveLetter.UrgencyLevel,
                                                                serialNumber);

            if (barcodeNo == "")
            {
                result.Message = "条码生成失败";
                return(result);
            }
            receiveLetter.BarcodeNo = barcodeNo;
            receiveLetter.LetterNo  = barcodeNo.Substring(15, 7);
            var letter = Mapper.Map <Letter>(receiveLetter);
            await _letterRepository.AddAsync(letter);

            var barcode = new Barcode
            {
                BarcodeNo  = barcodeNo,
                Entity     = EnumBarcodeEntity.信件,
                Souce      = EnumBarcodeSouce.本系统,
                Status     = EnumBarcodeStatus.已就绪,
                SubStatus  = EnumBarcodeSubStatus.正常,
                CreateTime = DateTime.Now,
                CreateBy   = receiveLetter.CreateBy
            };

            barcode.BarcodeType = barcode.AnalysisBarcodeType(barcodeNo);
            await _barcodeRepository.AddAsync(barcode);

            var baroceLog = new BarcodeLog
            {
                BarcodeNumber = barcodeNo,
                BarcodeStatus = EnumBarcodeStatus.已就绪,
                DepartmentId  = letter.SendDepartmentId,
                OperationTime = DateTime.Now,
                OperatorId    = receiveLetter.CreateBy,
            };

            await _barcodeLogRepository.AddAsync(baroceLog);

            result.Success = true;
            await _unitOfWork.CommitAsync();

            result.Data = letter.Id;
            return(result);
        }
Example #2
0
        /// <summary>
        /// 登记条码
        /// </summary>
        /// <param name="barcodeNo"></param>
        /// <returns></returns>
        public async Task <ResultEntity> RegisterBarcode(string barcodeNo)
        {
            var result  = new ResultEntity();
            var barcode = new Barcode
            {
                BarcodeNo = barcodeNo
            };

            barcode.BarcodeType = barcode.AnalysisBarcodeType(barcodeNo);
            if (barcode.BarcodeType != EnumBarcodeType.未知条码)
            {
                barcode.Entity     = barcode.AnalysisBarcodeEntity(barcode.BarcodeType);
                barcode.Souce      = EnumBarcodeSouce.外部;
                barcode.Status     = EnumBarcodeStatus.已就绪;
                barcode.SubStatus  = EnumBarcodeSubStatus.正常;
                barcode.CreateTime = DateTime.Now;

                await _barcodeRepository.AddAsync(barcode);

                result.Success = true;
            }
            else
            {
                result.Message = "未知的条码类型";
            }
            return(result);
        }
Example #3
0
 /// <inheritdoc />
 public Task <string> AddAsync(Barcode barcode)
 {
     return(_repository.AddAsync(_mapper.Map <BarcodeDB>(barcode)));
 }
Example #4
0
        public async Task <int> SaveLetter(int placeId, string barCodeNo, int boxId, int fileCount, bool isJiaJi)
        {
            _logger.LogWarning($"--------------开始保存条码:{barCodeNo}--------------");
            var place = await _placeRepository.GetByIdAsync(placeId);

            var letter = await _letterRepository.GetQueryable().Where(a => a.BarcodeNo == barCodeNo).FirstOrDefaultAsync();

            if (letter == null)
            {
                //保存信件基本信息
                letter = new Letter
                {
                    BarcodeNo = barCodeNo
                };
                letter.LetterNo = letter.GetLetterNo(barCodeNo);
                //本系统未登记过的信件,全部判定为收信
                letter.LetterType          = EnumLetterType.收信;
                letter.ReceiveDepartmentId = await _barcodeManager.GetReceiveDepartmentId(barCodeNo);

                letter.SendDepartmentId = await _barcodeManager.GetSendDepartmentId(barCodeNo);

                letter.SecretLevel  = letter.GetSecretLevel(barCodeNo);
                letter.UrgencyLevel = letter.GetUrgencyLevel(barCodeNo);
                letter.CreateTime   = DateTime.Now;
                letter.LetterNo     = letter.GetLetterNo(barCodeNo);
                await _letterRepository.AddAsync(letter);
            }

            var barCode = await _barcodeRepository.GetQueryable().Where(a => a.BarcodeNo == barCodeNo)
                          .FirstOrDefaultAsync();

            var boxObject = await _boxObjectRepository.GetQueryable().Where(a => a.BoxId == boxId).FirstOrDefaultAsync();

            if (barCode == null)
            {
                //添加条码记录
                barCode = new Barcode
                {
                    BarcodeNo       = barCodeNo,
                    Entity          = EnumBarcodeEntity.信件,
                    Souce           = EnumBarcodeSouce.外部,
                    Status          = EnumBarcodeStatus.已投递,
                    SubStatus       = EnumBarcodeSubStatus.正常,
                    CreateTime      = DateTime.Now,
                    CurrentObjectId = boxObject.ExchangeObjectId,
                    CurrentPlaceId  = placeId
                };
                barCode.BarcodeType = barCode.AnalysisBarcodeType(barCodeNo);
                await _barcodeRepository.AddAsync(barCode);
            }

            barCode.CurrentObjectId = boxObject.ExchangeObjectId;
            barCode.CurrentPlaceId  = placeId;
            barCode.UpdateTime      = DateTime.Now;
            switch (barCode.Status)
            {
            case EnumBarcodeStatus.已就绪:
            case EnumBarcodeStatus.已签收:
            case EnumBarcodeStatus.已勘误:
                barCode.Status = EnumBarcodeStatus.已投递;
                break;

            case EnumBarcodeStatus.已投递:
            case EnumBarcodeStatus.已退回:
                break;

            case EnumBarcodeStatus.申请退回:
                barCode.Status    = EnumBarcodeStatus.已投递;
                barCode.SubStatus = EnumBarcodeSubStatus.退回;
                break;
            }
            //添加条码日志记录
            var preBarcodeLog = await _barcodeLogRepository.GetQueryable().Where(a => a.BarcodeNumber == barCodeNo)
                                .OrderByDescending(a => a.Id).FirstOrDefaultAsync();

            var barcodeLog = new BarcodeLog
            {
                BarcodeNumber   = barCodeNo,
                BarcodeStatus   = EnumBarcodeStatus.已投递,
                DepartmentId    = preBarcodeLog?.DepartmentId ?? place.DepartmentId,
                OperationTime   = DateTime.Now,
                OperatorId      = null,
                CurrentObjectId = boxObject.ExchangeObjectId,
                CurrentPlaceId  = placeId
            };

            if (barCode.SubStatus == EnumBarcodeSubStatus.退回)
            {
                barcodeLog.Remark = "已投递申请退回的文件";
            }
            await _barcodeLogRepository.AddAsync(barcodeLog);

            //更新箱格信息
            var box = await _boxRepository.GetByIdAsync(boxId);

            box.FileCount += 1;
            box.HasUrgent  = letter.UrgencyLevel != EnumUrgentLevel.普通 || isJiaJi;

            _logger.LogWarning($"--------------结束保存条码--------------");
            return(1);
        }