コード例 #1
0
 public void SubmitForm(ChargeRecordEntity chargeRecordEntity, ReadTaskEntity readTaskEntity)
 {
     using (var db = new RepositoryBase().BeginTrans())
     {
         db.Insert(chargeRecordEntity);
         if (readTaskEntity != null)
         {
             db.Insert(readTaskEntity);
         }
         db.Commit();
     }
 }
コード例 #2
0
        public bool ClearDosage(string imsi)
        {
            var task = new ReadTaskEntity()
            {
                F_Id          = Common.GuId(),
                F_MeterCode   = imsi,
                F_MeterType   = "WaterMeter",
                F_Factor      = "贝林电子",
                F_TaskType    = (int)TaskTypeEnum.SetBaseDosage,
                F_State       = 0,
                F_Param       = "0",
                F_WorkId      = "xxxxxxxx-xxxx-xxxx-xxxx-000000000005",
                F_CreatorTime = DateTime.Now
            };

            return(_service.Insert(task) > 0);
        }
コード例 #3
0
ファイル: TaskListApp.cs プロジェクト: hyl2015275/NF_DEV
        public void SubmitForm(TaskListEntity taskListEntity, string companyId)
        {
            var tasks      = new List <ReadTaskEntity>();
            var meterTypes = new List <string>
            {
                taskListEntity.F_MeterType
            };
            var meters    = _meterApp.GetListByMeterType(meterTypes, companyId);
            var taskMeter = new List <MeterViewModel>();

            taskListEntity.F_DeviceNumber = meters.Count;
            taskListEntity.F_LoopMark     = false;
            taskListEntity.Create();
            if (meters.Count <= 0)
            {
                return;
            }
            foreach (var item in meters)
            {
                var channel = _channelApp.GetFormByArchiveId(item.F_Id);
                if (channel != null)
                {
                    var readTaskEntity = new ReadTaskEntity
                    {
                        F_MeterType   = item.F_MeterType,
                        F_CreatorTime = DateTime.Now,
                        F_State       = (int)TaskStateEnum.Wait,
                        F_Factor      = item.F_Factor,
                        F_MeterCode   = item.F_MeterCode,
                        F_Id          = Common.GuId(),
                        F_WorkId      = taskListEntity.F_Id,
                        F_Param       = channel.F_Id,
                        F_TaskType    = (int)TaskTypeEnum.Read,
                        F_ChannelType = (int)ChannelTypeEnum.Mbus
                    };
                    tasks.Add(readTaskEntity);
                }
                else if (meterTypes.Contains(MeterTypeEnum.WattMeter.ToString()))
                {
                    taskMeter.Add(item);
                }
            }
            tasks.AddRange(new ReadTaskApp().WattReadWithOther(taskMeter, taskListEntity.F_Id, TaskTypeEnum.Read));
            _service.SubmitForm(taskListEntity, tasks);
        }
コード例 #4
0
        public bool RelevanceMeterCode(string meterCode, string imsi)
        {
            _meterApp.InsertTestMeter(meterCode);
            var task = new ReadTaskEntity()
            {
                F_Id          = Common.GuId(),
                F_MeterCode   = imsi,
                F_MeterType   = "WaterMeter",
                F_Factor      = "贝林电子",
                F_TaskType    = (int)TaskTypeEnum.ModuleAddress,
                F_State       = 0,
                F_Param       = meterCode,
                F_WorkId      = "xxxxxxxx-xxxx-xxxx-xxxx-000000001102",
                F_CreatorTime = DateTime.Now
            };

            return(_service.Insert(task) > 0);
        }
コード例 #5
0
 /// <summary>
 /// 提交表单
 /// </summary>
 /// <param name="readTaskEntity"></param>
 /// <param name="keyValue"></param>
 public void SubmitForm(ReadTaskEntity readTaskEntity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         _service.Update(readTaskEntity);
     }
     else
     {
         var meter = _meterApp.GetFormByMeterCode(readTaskEntity.F_MeterCode);
         if (meter != null)
         {
             var channel = new ChannelApp().GetFormByArchiveId(meter.F_Id);
             if (channel != null)
             {
                 readTaskEntity.F_Param       = channel.F_Id;
                 readTaskEntity.F_ChannelType = (int)ChannelTypeEnum.Mbus;
             }
         }
         readTaskEntity.F_Id          = Common.GuId();
         readTaskEntity.F_CreatorTime = DateTime.Now;
         _service.Insert(readTaskEntity);
     }
 }
コード例 #6
0
        public void SubmitForm(ChangeMeterEntity changeMeterEntity, string meterCode)
        {
            CheckEntity(changeMeterEntity, meterCode);
            changeMeterEntity.F_ArchiveId = Common.GuId();
            var            meter          = new MeterApp().GetForm(changeMeterEntity.F_OldArchiveId);
            var            meterCharging  = new MeterChargingApp().GetForm(changeMeterEntity.F_OldArchiveId);
            ReadTaskEntity readTaskEntity = null;

            if (changeMeterEntity.F_AllowReplace == true)
            {
                readTaskEntity = new ReadTaskEntity
                {
                    F_CreatorTime = DateTime.Now,
                    F_Factor      = meter.F_Factor,
                    F_Id          = Common.GuId(),
                    F_MeterCode   = meterCode,
                    F_MeterType   = meter.F_MeterType,
                    F_Param       = changeMeterEntity.F_BaseDosage.ToString(),
                    F_TaskType    = (int)TaskTypeEnum.SetBaseDosage,
                    F_State       = (int)TaskStateEnum.Wait,
                };
            }
            _service.SubmitForm(changeMeterEntity, meter, meterCharging, meterCode, readTaskEntity);
        }
コード例 #7
0
 public void SubmitForm(PayOrderEntity payOrderEntity, MeterChargingEntity meterChargingEntity, ReadTaskEntity readTaskEntity)
 {
     using (var db = new RepositoryBase().BeginTrans())
     {
         db.Insert(payOrderEntity);
         db.Update(meterChargingEntity);
         if (readTaskEntity != null)
         {
             db.Insert(readTaskEntity);
         }
         db.Commit();
     }
 }
コード例 #8
0
ファイル: ReadRecordApp.cs プロジェクト: hyl2015275/NF_DEV
        public void ServiceSubmit(MeterRecord record, string imsi = "")
        {
            decimal balance = 0;

            //正在换表不记录数
            if (_readTaskApp.GetLastEntity((int)TaskTypeEnum.SetBaseDosage, record.MeterCode) != null)
            {
                return;
            }
            //获取表信息
            var meter = _meterApp.GetFormByMeterCode(record.MeterCode);

            if (meter == null)
            {
                return;
            }
            //表计倍率处理
            if (meter.F_MeterRate != null)
            {
                record.Value = (double.Parse(record.Value) * (double)meter.F_MeterRate).ToString(CultureInfo.InvariantCulture);
            }
            const int read       = (int)TaskTypeEnum.Read;
            const int task       = (int)TaskTypeEnum.Task;
            var       readTask   = _readTaskApp.GetLastEntity(task, record.MeterCode) ?? _readTaskApp.GetLastEntity(read, record.MeterCode);
            var       lastDosage = decimal.Parse(GetLastReadRecord(meter.F_Id, DateTime.Now));
            //本次用量
            var thisDosage = decimal.Parse(record.Value) - lastDosage;

            //过滤异常数据并加载到异常信息表内
            //if (lastDosage != 0 && (thisDosage > 2000 || thisDosage < -2000))
            if (1 > 1)
            {
                var readUnusualEntity = new ReadUnusualEntity()
                {
                    F_Id              = Common.GuId(),
                    F_CreatorTime     = DateTime.Now,
                    F_ErrorType       = ((int)ReadUnusualEnum.Read).ToString(),
                    F_MeterCode       = meter.F_MeterCode,
                    F_MeterType       = meter.F_MeterType,
                    F_Description     = meter.F_Description,
                    F_CustomerAddress = meter.F_CustomerAddress,
                    F_CustomerName    = meter.F_CustomerName,
                    F_Factor          = meter.F_Factor,
                    F_MobilePhone     = meter.F_MobilePhone,
                    F_OwnerId         = meter.F_OwnerId,
                    F_UserCard        = meter.F_UserCard,
                    F_Value           = thisDosage,
                };
                _readUnusualApp.SubmitForm(readUnusualEntity, "");
                return;
            }
            else
            {
                var readRecordEntity = new ReadRecordEntity
                {
                    F_TaskId      = readTask == null ? "" : readTask.F_Id,
                    F_ReadTime    = record.ReadingTime,
                    F_ArchiveId   = meter.F_Id,
                    F_ReadType    = readTask == null ? "-1" : readTask.F_TaskType.ToString(),
                    F_TotalDosage = decimal.Parse(record.Value),
                    F_CreatorTime = DateTime.Now,
                    F_Id          = Common.GuId(),
                    F_ThisDosage  = thisDosage,
                    F_Details     = record.Data == null ? "" : record.Data.ToJson(),
                    F_Settlement  = record.Settlement == null ? "" : record.Settlement.ToJson(),
                    F_Imsi        = imsi
                };
                ReadTaskEntity     controlTask        = null;
                PayOrderEntity     payOrderEntity     = null;
                ChargeRecordEntity chargeRecordEntity = null;
                MoneyAlarmEntity   moneyAlarmEntity   = null;
                //获取计费信息
                var meterCharging       = _meterChargingApp.GetForm(readRecordEntity.F_ArchiveId);
                var subsistenceCharging = _subsistenceSecurityApp.GetFormByArchiveId(readRecordEntity.F_ArchiveId);
                //0.判断表是否为IC卡预付费表
                //获取当前周期开始时间
                var cycleStartTime = _priceApp.GetCycleStartTime(subsistenceCharging != null && subsistenceCharging.F_PriceId != null ? subsistenceCharging.F_PriceId : meterCharging.F_PriceModel);
                //获取当前周期开始时间前一天最后一条抄表记录
                var cycleDosage = cycleStartTime == DateTime.MinValue
                    ? 0
                    : decimal.Parse(GetLastReadRecord(readRecordEntity.F_ArchiveId, cycleStartTime));
                //单位价格
                var uintPrice = _priceApp.GetPriceValue(subsistenceCharging != null && subsistenceCharging.F_PriceId != null ? subsistenceCharging.F_PriceId : meterCharging.F_PriceModel,
                                                        ((readRecordEntity.F_TotalDosage ?? 0) - cycleDosage).ToString(CultureInfo.InvariantCulture));
                if (meterCharging.F_MeterModel != "3")
                {
                    //扣费后的余额
                    balance = _meterChargingApp.UpdateBalance(readRecordEntity.F_ArchiveId, (readRecordEntity.F_ThisDosage ?? 0) * uintPrice);
                }
                else
                {
                    var count = _payOrderApp.GetPayOrderCount(record.MeterCode);
                    if (record.Data != null && record.Data.Keys.Contains("充值次数") && (count + 1).ToString() == record.Data["充值次数"])
                    {
                        payOrderEntity = _payOrderApp.GetLastPayOrder(record.MeterCode);
                        if (payOrderEntity != null)
                        {
                            payOrderEntity.F_State = "1";
                        }
                    }
                    if (record.Data != null && record.Data.Keys.Contains("余额"))
                    {
                        decimal money;
                        //上传的余额
                        balance = decimal.TryParse(record.Data["余额"], out money) ? _meterChargingApp.SetBalance(readRecordEntity.F_ArchiveId, money) : 0;
                    }
                }
                chargeRecordEntity = new ChargeRecordEntity
                {
                    F_ThisBill    = (readRecordEntity.F_ThisDosage ?? 0) * uintPrice,
                    F_ReadId      = readRecordEntity.F_Id,
                    F_UnitPrice   = uintPrice,
                    F_Description = "",
                    F_Balance     = balance,
                    F_ChargeTime  = DateTime.Now
                };
                //1.设备是否阀控,是否报警
                if (meterCharging.F_EnableClose == true && balance <= meterCharging.F_CloseAmount)
                {
                    //2. 判断设备类型+是否可以阀控
                    if (meter.F_MeterType == MeterTypeEnum.WattMeter.ToString()) //电表关阀命令
                    {
                        controlTask = new ReadTaskEntity
                        {
                            F_MeterCode   = meter.F_MeterCode,
                            F_Factor      = meter.F_Factor,
                            F_MeterType   = meter.F_MeterType,
                            F_State       = (int)TaskStateEnum.Wait,
                            F_Id          = Common.GuId(),
                            F_CreatorTime = DateTime.Now,
                            F_TaskType    = (int)TaskTypeEnum.TripSwitch
                        };
                    }
                    else //水表、燃气表、热表关阀命令
                    {
                        //判断是否应急或关阀状态
                        if (!IsEmergency(readRecordEntity))
                        {
                            controlTask = new ReadTaskEntity
                            {
                                F_MeterCode   = meter.F_MeterCode,
                                F_Factor      = meter.F_Factor,
                                F_MeterType   = meter.F_MeterType,
                                F_State       = (int)TaskStateEnum.Wait,
                                F_Id          = Common.GuId(),
                                F_CreatorTime = DateTime.Now,
                                F_TaskType    = (int)TaskTypeEnum.CloseValve
                            };
                        }
                    }
                }
                if (meterCharging.F_EnableClose == true && balance > meterCharging.F_CloseAmount)
                {
                    if (meter.F_MeterType == MeterTypeEnum.WattMeter.ToString()) //电表开阀命令
                    {
                        //电表充值自动开阀,不启用
                        //controlTask = new ReadTaskEntity
                        //{
                        //    F_MeterCode = meter.F_MeterCode,
                        //    F_Factor = meter.F_Factor,
                        //    F_MeterType = meter.F_MeterType,
                        //    F_State = (int)TaskStateEnum.Wait,
                        //    F_Id = Common.GuId(),
                        //    F_CreatorTime = DateTime.Now,
                        //    F_TaskType = (int)TaskTypeEnum.CloseSwitch
                        //};
                    }
                    else //水表、燃气表、热表开阀命令
                    {
                        //判断是否应急或关阀状态
                        if (IsEmergency(readRecordEntity))
                        {
                            controlTask = new ReadTaskEntity
                            {
                                F_MeterCode   = meter.F_MeterCode,
                                F_Factor      = meter.F_Factor,
                                F_MeterType   = meter.F_MeterType,
                                F_State       = (int)TaskStateEnum.Wait,
                                F_Id          = Common.GuId(),
                                F_CreatorTime = DateTime.Now,
                                F_TaskType    = (int)TaskTypeEnum.OpenValve
                            };
                        }
                    }
                }
                if (meterCharging.F_EnableAlarm == true && balance <= meterCharging.F_AlarmAmount)
                {
                    if (_moneyAlarmApp.IsCanSend(meter.F_Id))//判断是否可报警
                    {
                        var dataItems = (Dictionary <string, object>) new ItemsDetailApp().GetDataItemList();
                        var content   = SmsHelper.UrlEncode("#name#=" + meter.F_CustomerName + "&#time#=" + DateTime.Now.ToString("yyyy年MM月dd日") + "&#meter#=" + meter.F_CustomerAddress + ((Dictionary <string, string>)dataItems["DeviceType"])[meter.F_MeterType] + "&#balance#=" + balance.ToString("#0.00"));
                        var content2  = SmsHelper.UrlEncode("#name#=" + meter.F_CustomerName + "&#time#=" + DateTime.Now.ToString("yyyy年MM月dd日") + "&#meter#=" + ((Dictionary <string, string>)dataItems["DeviceType"])[meter.F_MeterType] + "&#balance#=" + balance.ToString("#0.00"));
                        moneyAlarmEntity = new MoneyAlarmEntity
                        {
                            F_Id          = Common.GuId(),
                            F_ArchiveId   = meter.F_Id,
                            F_AlarmMonry  = balance,
                            F_AlarmState  = (meter.F_OwnerId == "ff92def0-dabe-4878-915b-1b8cd0560ce4" && SmsHelper.Send(meter.F_MobilePhone, "58698", content, "c9eb4d0f54ad274842ef562d79f67e59")) || (meter.F_OwnerId == "bd602a97-eb06-4a5e-9c36-30eb45bc717b" && SmsHelper.Send(meter.F_MobilePhone, "96473", content2, "f73188115023c7e37955b095fefe0bb7")), //发送短信
                            F_SureState   = false,
                            F_CreatorTime = DateTime.Now,
                        };
                    }
                }
                else
                {
                    _moneyAlarmApp.SureAlarm(meter.F_Id);
                }
                //3.插入抄表信息、计费信息、阀控命令/报警命令
                _service.SubmitService(readRecordEntity, chargeRecordEntity, readTask, controlTask, payOrderEntity, moneyAlarmEntity);
            }
        }
コード例 #9
0
 public void SubmitForm(ChangeMeterEntity changeMeterEntity, MeterEntity meterEntity, MeterChargingEntity meterChargingEntity, string meterCode, ReadTaskEntity readTaskEntity)
 {
     using (var db = new RepositoryBase().BeginTrans())
     {
         try
         {
             changeMeterEntity.Create();
             db.Insert(changeMeterEntity);
             meterEntity.Remove();
             db.Update(meterEntity);
             db.Insert(new MeterEntity
             {
                 F_CreatorTime      = meterEntity.F_CreatorTime,
                 F_DeleteMark       = false,
                 F_IDNumber         = meterEntity.F_IDNumber,
                 F_DeleteTime       = null,
                 F_DeleteUserId     = null,
                 F_MeterCode        = meterCode,
                 F_Id               = changeMeterEntity.F_ArchiveId,
                 F_UserCard         = meterEntity.F_UserCard,
                 F_OwnerId          = meterEntity.F_OwnerId,
                 F_MobilePhone      = meterEntity.F_MobilePhone,
                 F_CreatorUserId    = meterEntity.F_CreatorUserId,
                 F_CustomerAddress  = meterEntity.F_CustomerAddress,
                 F_CustomerName     = meterEntity.F_CustomerName,
                 F_Description      = meterEntity.F_Description,
                 F_Factor           = meterEntity.F_Factor,
                 F_LastModifyTime   = meterEntity.F_LastModifyTime,
                 F_LastModifyUserId = meterEntity.F_LastModifyUserId,
                 F_MeterName        = meterEntity.F_MeterName,
                 F_MeterNumber      = meterEntity.F_MeterNumber,
                 F_MeterRate        = meterEntity.F_MeterRate,
                 F_MeterType        = meterEntity.F_MeterType
             });
             var newMeterChargingEntity = meterChargingEntity;
             newMeterChargingEntity.F_StartValue = changeMeterEntity.F_BaseDosage;
             newMeterChargingEntity.F_ArchiveId  = changeMeterEntity.F_ArchiveId;
             db.Insert(newMeterChargingEntity);
             if (readTaskEntity != null)
             {
                 readTaskEntity.F_WorkId = changeMeterEntity.F_Id;
                 db.Insert(readTaskEntity);
             }
             db.Commit();
         }
         catch (Exception ex)
         {
         }
     }
 }
コード例 #10
0
 public ActionResult SubmitForm(ReadTaskEntity roleEntity, string keyValue)
 {
     _readTaskApp.SubmitForm(roleEntity, keyValue);
     return(Success("操作成功。"));
 }
コード例 #11
0
ファイル: PayOrderApp.cs プロジェクト: hyl2015275/NF_DEV
 public void SubmitForm(PayOrderEntity payOrderEntity, MeterChargingEntity meterChargingEntity, ReadTaskEntity readTaskEntity)
 {
     payOrderEntity.Create();
     CheckEntity(payOrderEntity);
     _service.SubmitForm(payOrderEntity, meterChargingEntity, readTaskEntity);
 }
コード例 #12
0
 public void SubmitService(ReadRecordEntity readRecordEntity, ChargeRecordEntity chargeRecordEntity, ReadTaskEntity readTaskEntity, ReadTaskEntity controlTask, PayOrderEntity payOrderEntity, MoneyAlarmEntity moneyAlarmEntity)
 {
     using (var db = new RepositoryBase().BeginTrans())
     {
         db.Insert(readRecordEntity);
         if (chargeRecordEntity != null)
         {
             db.Insert(chargeRecordEntity);
         }
         if (readTaskEntity != null)
         {
             readTaskEntity.F_State       = (int)TaskStateEnum.Finish;
             readTaskEntity.F_ExecuteTime = DateTime.Now;
             db.Update(readTaskEntity);
         }
         if (controlTask != null)
         {
             db.Insert(controlTask);
         }
         if (payOrderEntity != null)
         {
             db.Update(payOrderEntity);
         }
         if (moneyAlarmEntity != null)
         {
             db.Insert(moneyAlarmEntity);
         }
         db.Commit();
     }
 }
コード例 #13
0
        public ActionResult SubmitForm(string F_UserCard, string F_Money, string F_Recharge)
        {
            var companyId = OperatorProvider.Provider.GetCurrent().CompanyId;
            var meter     = _meterApp.GetFormByUserCard(F_UserCard, companyId);

            if (meter == null)
            {
                throw new Exception("用户卡不存在");
            }
            var meterCharging = _meterChargingApp.GetForm(meter.F_Id);

            meterCharging.F_Balance += decimal.Parse(F_Money);
            var payOrder = new PayOrderEntity
            {
                F_CreatorUserName = OperatorProvider.Provider.GetCurrent().UserName,
                F_State           = ((int)PayStateEnum.Wait).ToString(),
                F_Balance         = meterCharging.F_Balance,
                F_ArchiveId       = meter.F_Id,
                F_OrderNumber     = Common.CreateNo(),
                F_OutOrder        = "",
                F_Money           = decimal.Parse(F_Money),
                F_OwnerId         = companyId,
                F_PaymentTime     = DateTime.Now,
                F_PayType         = ((int)PayTypeEnum.BusinessPay).ToString()
            };
            ReadTaskEntity controlTask = null;

            if (meterCharging.F_MeterModel != ((int)MeterModelEnum.CardPrepay).ToString())//非IC卡预付费
            {
                payOrder.F_State = ((int)PayStateEnum.Finish).ToString();
                if (meter.F_MeterType == MeterTypeEnum.WattMeter.ToString() && meterCharging.F_EnableClose == true &&
                    meterCharging.F_Balance > meterCharging.F_CloseAmount) //电表合闸命令
                {
                    controlTask = new ReadTaskEntity
                    {
                        F_Id          = Common.GuId(),
                        F_CreatorTime = DateTime.Now,
                        F_MeterCode   = meter.F_MeterCode,
                        F_Factor      = meter.F_Factor,
                        F_MeterType   = meter.F_MeterType,
                        F_State       = (int)TaskStateEnum.Wait,
                        F_TaskType    = (int)TaskTypeEnum.CloseSwitch,
                    };
                }
            }
            else if (F_Recharge == ((int)RechargeEnum.Card).ToString())//IC卡预付费卡充值
            {
                payOrder.F_State = ((int)PayStateEnum.Write).ToString();
            }
            else//IC卡预付费互联网充值
            {
                payOrder.F_State = ((int)PayStateEnum.Wait).ToString();
                controlTask      = new ReadTaskEntity
                {
                    F_Id          = Common.GuId(),
                    F_CreatorTime = DateTime.Now,
                    F_MeterCode   = meter.F_MeterCode,
                    F_Factor      = meter.F_Factor,
                    F_MeterType   = meter.F_MeterType,
                    F_Param       = decimal.Parse(F_Money).ToString("0.00"),
                    F_State       = (int)TaskStateEnum.Wait,
                    F_TaskType    = (int)TaskTypeEnum.Pay,
                };
            }
            if (companyId == "bd602a97-eb06-4a5e-9c36-30eb45bc717b")//临朐清源充值确认
            {
                _moneyAlarmApp.SureAlarm(meter.F_Id);
            }
            _payOrderApp.SubmitForm(payOrder, meterCharging, controlTask);
            return(Success("操作成功。"));
        }