Exemple #1
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);
        }
Exemple #2
0
        public bool UpLoad(Stream stream, string companyId)
        {
            var dataItems = (Dictionary <string, object>) new ItemsDetailApp().GetDataItemList();
            var count     = 2;
            var ds        = NPOIExcel.ImportExceltoDs(stream);

            if (ds == null)
            {
                return(false);
            }
            var dt = ds.Tables[0];

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(false);
            }
            foreach (DataRow item in dt.Rows)
            {
                try
                {
                    var row   = item;
                    var price = new PriceEntity();
                    if (companyId == "030eca51-483a-47b6-ad46-b6164278ebcb")
                    {
                        var metercode = row[4] as string;
                        if (string.IsNullOrEmpty(metercode))
                        {
                            continue;
                        }
                        price = _priceApp.GetDefault(companyId);
                        var customPara = new MeterCustomParameter
                        {
                            LINENO      = "",
                            BusinessID  = row[5] as string,
                            AreaID      = row[6] as string,
                            BookID      = row[7] as string,
                            InTabManIDs = row[8] as string,
                        };
                        var meterEntity         = new MeterEntity();
                        var meterChargingEntity = new MeterChargingEntity();
                        var meter = _service.FindEntity(x => x.F_MeterCode == metercode && x.F_DeleteMark != true && x.F_OwnerId == companyId);
                        if (meter != null)
                        {
                            var meterCharging = new MeterChargingApp().GetForm(meter.F_Id);
                            meterEntity         = meter;
                            meterChargingEntity = meterCharging;
                        }
                        meterEntity.F_MeterType          = "WaterMeter";
                        meterEntity.F_Factor             = "贝林电子";
                        meterEntity.F_MeterName          = row[1] as string;
                        meterEntity.F_MeterRate          = 1;
                        meterEntity.F_UserCard           = (string)row[0];
                        meterEntity.F_MeterCode          = (string)row[4];
                        meterEntity.F_CustomerName       = (string)row[1];
                        meterEntity.F_IDNumber           = row[0] as string;
                        meterEntity.F_MobilePhone        = row[3] as string;
                        meterEntity.F_CustomerAddress    = row[2] as string;
                        meterEntity.F_Description        = customPara.ToJson();
                        meterEntity.F_OwnerId            = companyId;
                        meterChargingEntity.F_PriceModel = price.F_Id;
                        meterChargingEntity.F_MeterModel = "1";
                        SubmitForm(meterEntity, meterChargingEntity, meter == null ? "" : meter.F_Id);
                        count++;
                    }
                    else
                    {
                        var metercode = row[7] as string;
                        if (string.IsNullOrEmpty(metercode))
                        {
                            continue;
                        }
                        var priceName = row[2] as string;
                        price = _priceApp.GetForm(companyId, priceName);
                        if (price == null)
                        {
                            throw new Exception("当前执行价格不存在");
                        }
                        double rate;
                        var    meterEntity         = new MeterEntity();
                        var    meterChargingEntity = new MeterChargingEntity();
                        var    meter = _service.FindEntity(x => x.F_MeterCode == metercode && x.F_DeleteMark != true && x.F_OwnerId == companyId);
                        if (meter != null)
                        {
                            var meterCharging = new MeterChargingApp().GetForm(meter.F_Id);
                            meterEntity         = meter;
                            meterChargingEntity = meterCharging;
                        }
                        meterEntity.F_MeterType          = ((Dictionary <string, string>)dataItems["DeviceType"]).First(x => x.Value == (string)row[0]).Key;
                        meterEntity.F_Factor             = (string)row[3];
                        meterEntity.F_MeterName          = row[4] as string;
                        meterEntity.F_MeterRate          = double.TryParse(row[5] as string, out rate) ? rate : 1;
                        meterEntity.F_UserCard           = (string)row[6];
                        meterEntity.F_MeterCode          = (string)row[7];
                        meterEntity.F_CustomerName       = (string)row[8];
                        meterEntity.F_IDNumber           = row[9] as string;
                        meterEntity.F_MobilePhone        = (string)row[10];
                        meterEntity.F_CustomerAddress    = row[11] as string;
                        meterEntity.F_Description        = row[12] as string;
                        meterEntity.F_OwnerId            = companyId;
                        meterChargingEntity.F_PriceModel = price.F_Id;
                        meterChargingEntity.F_MeterModel = ((Dictionary <string, string>)dataItems["MeterModel"]).First(x => x.Value == (string)row[1]).Key;
                        SubmitForm(meterEntity, meterChargingEntity, meter == null ? "" : meter.F_Id);
                        count++;
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("表格行" + count + "数据不正确," + ex.Message);
                }
            }
            return(count > 2);
        }