Example #1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, PersongpsEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
        /// <summary>
        /// 车辆出厂
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="Note"></param>
        /// <param name="type"></param>
        public void CarOut(string keyValue, string Note, int type, List <PersongpsEntity> pergps)
        {
            //开始事物
            var res = DbFactory.Base().BeginTrans();

            try
            {
                List <CarUserFileImgEntity>       dellist   = new List <CarUserFileImgEntity>();//离场
                Repository <CarUserFileImgEntity> caruserdb = new Repository <CarUserFileImgEntity>(DbFactory.Base());
                if (type == 0)
                {//拜访车辆
                    Repository <VisitcarEntity> inlogdb = new Repository <VisitcarEntity>(DbFactory.Base());
                    VisitcarEntity old = inlogdb.FindEntity(keyValue);
                    //old.OutTime = DateTime.Now;
                    //old.State = 4;
                    old.Issubmit = 1;
                    old.Note     = Note;
                    old.Modify(old.ID);
                    Repository <PersongpsEntity> pgpsinlogdb = new Repository <PersongpsEntity>(DbFactory.Base());
                    List <PersongpsEntity>       pgps        = pgpsinlogdb.IQueryable(it => it.VID == keyValue && it.State == 0).ToList();
                    foreach (PersongpsEntity item in pergps)
                    {
                        if (item.UserName == "车辆" && item.State == 1)
                        {//车辆出厂但跟随人员部分未出厂
                            old.Issubmit = 2;
                            //List<PersongpsEntity> list = pgpsinlogdb.IQueryable(it => it.VID == keyValue && it.State == 0).ToList();
                            //if (list.Count == 0)
                            //{//子表所有人员都出厂修改主表出厂状态
                            //    old.OutTime = DateTime.Now;
                            //    old.State = 4;
                            //}
                        }
                        else
                        {//人员
                            PersongpsEntity entity = pgpsinlogdb.FindEntity(item.ID);
                            if (entity != null)
                            {
                                entity.Issubmit = 1;
                                entity.State    = item.State;
                                entity.Modify(item.ID);
                                if (item.State == 1)
                                {
                                    entity.OutTime = DateTime.Now;
                                    var carentity = caruserdb.IQueryable(it => it.Baseid == keyValue && it.Username == entity.UserName).ToList();
                                    dellist.AddRange(carentity);
                                }
                                pgps.Add(entity);
                            }
                        }
                        if (pergps.Where(t => t.State == 1).ToList().Count == pergps.Count)
                        {//子表所有人员都出厂修改主表出厂状态
                            old.OutTime = DateTime.Now;
                            old.State   = 4;
                        }
                    }
                    res.Update <VisitcarEntity>(old);
                    res.Update <PersongpsEntity>(pgps);
                }
                else if (type == 1)
                {
                    //将该车1小时内的打卡记录都变为已进场
                    Repository <OperticketmanagerEntity> inlogdb = new Repository <OperticketmanagerEntity>(DbFactory.Base());
                    OperticketmanagerEntity old = inlogdb.FindEntity(keyValue);
                    old.ExamineStatus = 4;
                    old.OutDate       = DateTime.Now;
                    old.PassRemark    = Note;
                    old.Modify(old.ID);
                    res.Update <OperticketmanagerEntity>(old);
                }
                else
                {//危化品车辆
                    //将该车1小时内的打卡记录都变为已进场
                    Repository <HazardouscarEntity> inlogdb = new Repository <HazardouscarEntity>(DbFactory.Base());
                    HazardouscarEntity old = inlogdb.FindEntity(keyValue);
                    //old.OutTime = DateTime.Now;
                    //old.State = 4;
                    old.Note     = Note;
                    old.Issubmit = 1;
                    old.Modify(old.ID);
                    Repository <PersongpsEntity> pgpsinlogdb = new Repository <PersongpsEntity>(DbFactory.Base());
                    List <PersongpsEntity>       pgps        = new List <PersongpsEntity>();
                    foreach (PersongpsEntity item in pergps)
                    {
                        if (item.UserName == "车辆" && item.State == 1)
                        {//车辆出厂但跟随人员部分未出厂
                            old.Issubmit = 2;
                        }
                        else
                        {//人员
                            PersongpsEntity entity = pgpsinlogdb.FindEntity(item.ID);
                            if (entity != null)
                            {
                                entity.Issubmit = 1;
                                entity.State    = item.State;
                                entity.Modify(item.ID);
                                if (item.State == 1)
                                {
                                    entity.OutTime = DateTime.Now;
                                    var carentity = caruserdb.IQueryable(it => it.Baseid == keyValue && it.Username == entity.UserName).ToList();
                                    dellist.AddRange(carentity);
                                }
                                pgps.Add(entity);
                            }
                        }
                        if (pergps.Where(t => t.State == 1).ToList().Count == pergps.Count)
                        {//子表所有人员都出厂修改主表出厂状态
                            old.OutTime = DateTime.Now;
                            old.State   = 4;
                        }
                    }
                    res.Update <HazardouscarEntity>(old);
                    res.Update <PersongpsEntity>(pgps);
                }
                Repository <CargpsEntity> cgpsinlogdb = new Repository <CargpsEntity>(DbFactory.Base());
                List <CargpsEntity>       cgps        = cgpsinlogdb.IQueryable(it => it.AID == keyValue && it.Status == 0).ToList();
                if (cgps.Count > 0)
                {
                    for (int i = 0; i < cgps.Count; i++)
                    {
                        cgps[i].Status  = 1;
                        cgps[i].EndTime = DateTime.Now;
                        cgps[i].Modify(cgps[i].ID);
                    }
                    res.Update <CargpsEntity>(cgps);
                }

                //车辆违章记录处理
                Repository <CarviolationEntity> violinlogdb = new Repository <CarviolationEntity>(DbFactory.Base());
                List <CarviolationEntity>       violation   = violinlogdb.IQueryable(it => it.CID == keyValue && it.IsProcess == 0).ToList();
                if (violation.Count > 0)
                {
                    for (int i = 0; i < violation.Count; i++)
                    {
                        violation[i].IsProcess      = 1;
                        violation[i].ProcessMeasure = Note;
                        violation[i].Modify(violation[i].ID);
                    }
                    res.Update <CarviolationEntity>(violation);
                }

                res.Commit();
                DeleteUserHiK(dellist, 1);
            }
            catch (Exception ex)
            {
                res.Rollback();
                throw ex;
            }
        }
Example #3
0
 public ActionResult SaveForm(string keyValue, PersongpsEntity entity)
 {
     persongpsbll.SaveForm(keyValue, entity);
     return(Success("操作成功。"));
 }
Example #4
0
        /// <summary>
        /// 车辆出厂
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="Note"></param>
        /// <param name="type"></param>
        public void CarOut(string keyValue, string Note, int type, List <PersongpsEntity> pergps)
        {
            //开始事物
            var res = DbFactory.Base().BeginTrans();

            try
            {
                List <CarUserFileImgEntity> dellist = new List <CarUserFileImgEntity>(); //离厂人员
                if (type == 3)
                {                                                                        //拜访人员
                    Repository <CarUserEntity> inlogdb = new Repository <CarUserEntity>(DbFactory.Base());
                    CarUserEntity old = inlogdb.FindEntity(keyValue);
                    old.Note = Note;
                    old.Modify(old.ID);
                    Repository <PersongpsEntity>      pgpsinlogdb = new Repository <PersongpsEntity>(DbFactory.Base());
                    Repository <CarUserFileImgEntity> caruserdb   = new Repository <CarUserFileImgEntity>(DbFactory.Base());
                    List <PersongpsEntity>            pgps        = new List <PersongpsEntity>();
                    foreach (PersongpsEntity item in pergps)
                    {
                        PersongpsEntity entity = pgpsinlogdb.FindEntity(item.ID);
                        if (entity != null)
                        {
                            entity.Issubmit = 1;
                            entity.State    = item.State;
                            entity.Modify(item.ID);
                            if (item.State == 1)
                            {
                                entity.OutTime = DateTime.Now;
                                var carentity = caruserdb.IQueryable(it => it.Baseid == keyValue && it.Username == entity.UserName).ToList();
                                dellist.AddRange(carentity);
                            }
                            pgps.Add(entity);
                        }
                    }
                    if (pergps.Where(t => t.State == 1).ToList().Count == pergps.Count)
                    {//子表所有人员都出厂修改主表出厂状态
                        old.OutTime = DateTime.Now;
                        old.State   = 4;
                    }
                    res.Update <CarUserEntity>(old);
                    res.Update <PersongpsEntity>(pgps);
                }

                Repository <CargpsEntity> cgpsinlogdb = new Repository <CargpsEntity>(DbFactory.Base());
                List <CargpsEntity>       cgps        = cgpsinlogdb.IQueryable(it => it.AID == keyValue && it.Status == 0).ToList();
                if (cgps.Count > 0)
                {
                    for (int i = 0; i < cgps.Count; i++)
                    {
                        cgps[i].Status  = 1;
                        cgps[i].EndTime = DateTime.Now;
                        cgps[i].Modify(cgps[i].ID);
                    }
                    res.Update <CargpsEntity>(cgps);
                }

                //车辆违章记录处理
                Repository <CarviolationEntity> violinlogdb = new Repository <CarviolationEntity>(DbFactory.Base());
                List <CarviolationEntity>       violation   = violinlogdb.IQueryable(it => it.CID == keyValue && it.IsProcess == 0).ToList();
                if (violation.Count > 0)
                {
                    for (int i = 0; i < violation.Count; i++)
                    {
                        violation[i].IsProcess      = 1;
                        violation[i].ProcessMeasure = Note;
                        violation[i].Modify(violation[i].ID);
                    }
                    res.Update <CarviolationEntity>(violation);
                }
                res.Commit();
                DeleteUserHiK(dellist, 1);
            }
            catch (Exception ex)
            {
                res.Rollback();
                throw ex;
            }
        }