コード例 #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);
        }
コード例 #2
0
        public async Task <ResultEntity> AddSendLetter(LetterSendEditDto sendLetter)
        {
            var result = new ResultEntity();
            var letter = Mapper.Map <Letter>(sendLetter);

            if (string.IsNullOrWhiteSpace(letter.BarcodeNo))
            {
                var receiveDepartment = await _departmentManager.GetAsync(sendLetter.ReceiveDepartmentId);

                var sendDepartmentCode    = TextHelper.RepairZeroRight(await _departmentManager.GetDepartmentCode(sendLetter.SendDepartmentId), 11);
                var receiveDepartmentCode = TextHelper.RepairZeroRight(await _departmentManager.GetDepartmentCode(sendLetter.ReceiveDepartmentId), 11);
                letter.LetterType = letter.GetSendLetterType(sendDepartmentCode, receiveDepartmentCode);
                if (receiveDepartment.ReceiveChannel == EnumChannel.机要通信)
                {
                    letter.LetterType = EnumLetterType.发信;
                }
                int serialNumber;
                var barcodeNo = "";
                switch (letter.LetterType)
                {
                case EnumLetterType.发信:
                    switch (receiveDepartment.ReceiveChannel)
                    {
                    case EnumChannel.城交换:
                        serialNumber = await _serialNumberManager.GetSerialNumber(letter.SendDepartmentId, EnumSerialNumberType.城交换);

                        barcodeNo = _barcodeManager.MakeBarcodeLength26(sendDepartmentCode, receiveDepartmentCode,
                                                                        letter.SecretLevel, letter.UrgencyLevel,
                                                                        serialNumber);
                        break;

                    case EnumChannel.机要通信:
                        serialNumber = await _serialNumberManager.GetSerialNumber(letter.SendDepartmentId, EnumSerialNumberType.机要通信);

                        barcodeNo = _barcodeManager.MakeBarcodeLength33(sendDepartmentCode, receiveDepartmentCode,
                                                                        letter.SecretLevel, letter.UrgencyLevel,
                                                                        serialNumber);
                        break;
                    }
                    break;

                case EnumLetterType.内交换:
                    serialNumber = await _serialNumberManager.GetSerialNumber(letter.SendDepartmentId, EnumSerialNumberType.内部交换);

                    barcodeNo = _barcodeManager.MakeBarcodeLength33(sendDepartmentCode, receiveDepartmentCode,
                                                                    letter.SecretLevel, letter.UrgencyLevel,
                                                                    serialNumber);
                    break;

                default:
                    throw new ArgumentOutOfRangeException($"发信类型有误");
                }

                if (barcodeNo == "")
                {
                    result.Message = "条码生成失败";
                    return(result);
                }
                letter.BarcodeNo = barcodeNo;
                letter.LetterNo  = letter.GetLetterNo(barcodeNo);
            }
            else
            {
                var receiveDepartment = await _departmentManager.GetAsync(sendLetter.ReceiveDepartmentId);

                var sendDepartment = await _departmentManager.GetAsync(sendLetter.SendDepartmentId);

                var sendDepartmentCode    = TextHelper.RepairZeroRight(await _departmentManager.GetDepartmentCode(sendLetter.SendDepartmentId), 11);
                var receiveDepartmentCode = TextHelper.RepairZeroRight(await _departmentManager.GetDepartmentCode(sendLetter.ReceiveDepartmentId), 11);
                letter.LetterType = letter.GetSendLetterType(sendDepartmentCode, receiveDepartmentCode);
                letter.LetterNo   = letter.GetLetterNo(letter.BarcodeNo);
                if (receiveDepartment.ReceiveChannel == EnumChannel.机要通信)
                {
                    letter.LetterType = EnumLetterType.发信;
                }

                if (sendDepartment.ReceiveChannel == EnumChannel.机要通信)
                {
                    letter.LetterType = EnumLetterType.收信;
                }
            }
            await _letterRepository.AddAsync(letter);

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

            barcode.BarcodeType = barcode.AnalysisBarcodeType(letter.BarcodeNo);
            await _barcodeRepository.AddAsync(barcode);

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

            await _barcodeLogRepository.AddAsync(baroceLog);

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

            result.Data = letter.Id;
            return(result);
        }
コード例 #3
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);
        }