Ejemplo n.º 1
0
        void btnNew_Click(object sender, RoutedEventArgs e)
        {
            string filter = "";
            ObservableCollection <object> paras = new ObservableCollection <object>();
            T_HR_SALARYSTANDARDITEM       salarystandarditem = new T_HR_SALARYSTANDARDITEM();
            T_HR_SALARYSTANDARD           salarystandard     = new T_HR_SALARYSTANDARD();

            salarystandard.SALARYSTANDARDID = savesid;
            Dictionary <string, string> cols = new Dictionary <string, string>();

            cols.Add("SALARYITEMNAME", "SALARYITEMNAME");
            cols.Add("GUERDONSUM", "GUERDONSUM");
            cols.Add("CALCULATEFORMULA", "CALCULATEFORMULA");
            RefreshUI(RefreshedTypes.ProgressBar);
            filter += "CREATECOMPANYID==@" + paras.Count().ToString();
            paras.Add(SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID);
            LookupForm lookup = new LookupForm(EntityNames.SalaryItemSet,
                                               typeof(List <T_HR_SALARYITEM>), cols, filter, paras);

            lookup.TitleContent   = Utility.GetResourceStr("SALARYITEM");
            lookup.SelectedClick += (o, ev) =>
            {
                T_HR_SALARYITEM ent = lookup.SelectedObj as T_HR_SALARYITEM;
                if (ent != null)
                {
                    salarystandarditem.STANDRECORDITEMID   = Guid.NewGuid().ToString();
                    salarystandarditem.T_HR_SALARYITEM     = ent;
                    salarystandarditem.T_HR_SALARYSTANDARD = salarystandard;
                    salarystandarditem.SUM          = ent.GUERDONSUM.ToString();
                    salarystandarditem.REMARK       = ent.REMARK;
                    salarystandarditem.CREATEDATE   = System.DateTime.Now;
                    salarystandarditem.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                    client.SalaryStandardItemAddAsync(salarystandarditem);
                }
            };
            lookup.Show <string>(DialogMode.Default, SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot, "", (result) => { });

            #region ----
            //System.Collections.ObjectModel.ObservableCollection<object> paras = new System.Collections.ObjectModel.ObservableCollection<object>();
            ////string filter = "";
            ////filter = "CHECKSTATE==@" + paras.Count;
            //paras.Add(Convert.ToInt16(CheckStates.Approved).ToString());
            //LookupForm lookup = new LookupForm(EntityNames.SalaryStandard,
            //  typeof(List<T_HR_SALARYSTANDARD>), cols, filter, paras);
            #endregion
        }
Ejemplo n.º 2
0
        public void CreateSalaryStandBatch()
        {
            try
            {

                EmployeeSalaryRecordBLL bll = new EmployeeSalaryRecordBLL();
                SalaryStandardItemBLL itemBLL = new SalaryStandardItemBLL();

                string strsolutionall = @"上海神达物流有限公司薪资方案(A类城市)
                                上海酷武供应链管理服务有限公司薪资方案(A类)
                                北京市神通物流有限公司薪资方案(A类城市)
                                南京红之衣物流有限公司薪资方案(B类城市)
                                南宁市神州通货运代理有限公司薪资方案(D类城市)
                                南昌神州通物流有限公司薪资方案(E类城市)
                                合肥神州通物流有限公司薪资方案(D类城市)
                                哈尔滨神达通运输有限责任公司薪资方案(D类城市)
                                天津神州通物流有限公司薪资方案(C类城市)
                                太原市神通物流有限公司薪资方案(E类城市)
                                广州市神通物流有限公司薪资方案(A类城市)
                                成都通神州物流有限公司薪资方案(D类城市)
                                昆明神州通物流有限公司薪资方案(D类城市)
                                杭州新神州通货物运输有限公司薪资方案(B类城市)
                                武汉通神州仓储服务有限责任公司薪资方案(C类城市)
                                沈阳神州通物流有限公司薪资方案(C类城市)
                                济南神州通物流有限公司薪资方案(C类城市)
                                深圳市神州通物流有限公司薪资方案(A类城市)
                                深圳市神州通物流有限公司薪资方案(B类城市)
                                深圳市神州通物流有限公司薪资方案(C类城市)
                                深圳市神州通物流有限公司薪资方案(D类城市)
                                深圳市神州通物流有限公司薪资方案(E类城市)
                                深圳市神州通物流有限公司贵阳分公司(E类城市)
                                深圳市通神州物流公司薪资方案(A类城市)
                                石家庄神州通物流有限公司薪资方案(D类城市)
                                福州市神州通货运代理有限公司薪资方案(C类城市)
                                西安市神之通物流有限公司薪资方案(D类城市)
                                贵阳市神州通物流有限公司(E类城市)
                                郑州市神州通物流有限公司薪资方案(D类城市)
                                重庆新神州通物流有限公司薪资方案(D类城市)
                                长春市神之通物流有限公司薪资方案(D类城市)
                                长沙市神通物流服务有限公司薪资方案(C类城市)
                                青海神之通电子商务有限公司薪资方案(E类)";
                var solutionAll = (from ent in dal.GetObjects<T_HR_SALARYSOLUTION>().Include("T_HR_SALARYSYSTEM")
                                   where ent.SALARYSOLUTIONNAME.Contains(strsolutionall)
                                   && ent.CHECKSTATE == "2"
                                   select ent).ToList();

                foreach (var solutionItem in solutionAll)
                {
                    solution = solutionItem;


                    standtmp = new T_HR_SALARYSTANDARD();
                    standtmp.SALARYSTANDARDID = Guid.NewGuid().ToString();
                    standtmp.CREATECOMPANYID = solution.CREATECOMPANYID;
                    standtmp.CREATEDEPARTMENTID = solution.CREATEDEPARTMENTID;
                    standtmp.CREATEPOSTID = solution.CREATEPOSTID;
                    standtmp.CREATEUSERID = solution.CREATEUSERID;

                    standtmp.OWNERCOMPANYID = solution.OWNERCOMPANYID;
                    standtmp.OWNERDEPARTMENTID = solution.OWNERDEPARTMENTID;
                    standtmp.OWNERID = solution.OWNERID;
                    standtmp.OWNERPOSTID = solution.OWNERPOSTID;
                    //loadbar.Start();

                    // 薪资方案的体系ID
                    string salarySystemID = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMID;
                    //薪资体系名
                    string salarySystemName = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMNAME;
                    // 岗位级别名
                    string postLevelName = "";

                    //薪资方案所属的薪资体系
                    List<T_HR_SALARYLEVEL> salarylevelList = new List<T_HR_SALARYLEVEL>();
                    //薪资方案的薪资项集合
                    List<V_SALARYITEM> salaryItems = new List<V_SALARYITEM>();

                    salarylevelList = (from c in dal.GetObjects<T_HR_SALARYLEVEL>().Include("T_HR_POSTLEVELDISTINCTION")
                                       where c.T_HR_POSTLEVELDISTINCTION.T_HR_SALARYSYSTEM.SALARYSYSTEMID == salarySystemID
                                       select c).ToList().OrderBy(m => m.SALARYLEVEL).OrderBy(x => x.T_HR_POSTLEVELDISTINCTION.POSTLEVEL).ToList();

                    salaryItems = (from n in dal.GetObjects<T_HR_SALARYITEM>()
                                   join m in dal.GetObjects<T_HR_SALARYSOLUTIONITEM>() on n.SALARYITEMID equals m.T_HR_SALARYITEM.SALARYITEMID
                                   where m.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                   select new V_SALARYITEM
                                   {
                                       T_HR_SALARYITEM = n,
                                       ORDERNUMBER = m.ORDERNUMBER
                                   }
                                   ).ToList();

                    //方案所属地区差异补贴
                    List<T_HR_AREAALLOWANCE> areaAllowance = new List<T_HR_AREAALLOWANCE>();
                    areaAllowance = (from c in dal.GetObjects<T_HR_AREAALLOWANCE>()
                                     join b in dal.GetObjects<T_HR_SALARYSOLUTION>().Include("T_HR_AREADIFFERENCE") on c.T_HR_AREADIFFERENCE.AREADIFFERENCEID equals b.T_HR_AREADIFFERENCE.AREADIFFERENCEID
                                     where b.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                     select c).ToList();

                    int num = 0;

                    //dal.BeginTransaction();
                    foreach (var sl in salarylevelList)
                    {
                        var ent = from c in postlevels
                                  join b in salarylevelList on c.Value equals b.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                  where b.SALARYLEVELID == sl.SALARYLEVELID
                                  select c.Key;
                        if (ent.Count() > 0)
                        {
                            postLevelName = ent.FirstOrDefault().ToString();
                        }
                        var ents = (from a in dal.GetObjects<T_HR_SALARYSTANDARD>()
                                    where a.T_HR_SALARYLEVEL.SALARYLEVELID == sl.SALARYLEVELID
                                    && a.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                    select new
                                    {
                                        a.SALARYSTANDARDID,
                                        a.SALARYSTANDARDNAME,
                                        a.T_HR_SALARYLEVEL.SALARYLEVEL
                                    });
                        if (ents.Count() > 0)
                        {
                           

                            var checkEntity = ents.FirstOrDefault();
                            ShowMessage(txtMsg, "薪资标准已存在,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //已存在,跳过生成
                            continue;
                            //if (int.Parse(checkEntity.SALARYLEVEL) > 40)
                            //{
                            //    try { 
                            //    var delentity = (from a in dal.GetObjects<T_HR_SALARYSTANDARD>().Include("T_HR_SALARYSTANDARDITEM")
                            //                     where a.SALARYSTANDARDID
                            //                     == checkEntity.SALARYSTANDARDID
                            //                     select a).FirstOrDefault();
                            //    foreach (var entity in delentity.T_HR_SALARYSTANDARDITEM)
                            //    {
                            //        dal.Delete(entity);
                            //    }
                            //    dal.Delete(delentity);
                            //    ShowMessage(txtMsg, "删除薪资标准成功!" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //        }catch(Exception ex)
                            //    {
                            //        ShowMessage(txtMsg, "薪资标准已被使用,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //        continue;
                            //    }
                            //}
                            //else
                            //{
                            //    ShowMessage(txtMsg, "薪资标准已存在,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //    //已存在,跳过生成
                            //    continue;
                            //}
                        }
                        // 薪资体系的每条记录都对应一个标准 根据sl生成薪资标准
                        T_HR_SALARYSTANDARD stand = new T_HR_SALARYSTANDARD();
                        //薪资标准的薪资项集合
                        List<T_HR_SALARYSTANDARDITEM> standSalaryitems = new List<T_HR_SALARYSTANDARDITEM>();
                        //获取岗位级别名


                        //薪资标准名= 薪资体系名+岗位级别名+"-"+薪资级别名
                        stand.SALARYSTANDARDNAME = salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString();
                        stand.SALARYSTANDARDID = Guid.NewGuid().ToString();
                        // stand.T_HR_SALARYLEVEL = new T_HR_SALARYLEVEL();
                        stand.T_HR_SALARYLEVELReference.EntityKey
                              = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYLEVEL", "SALARYLEVELID", sl.SALARYLEVELID);
                        //  stand.T_HR_SALARYLEVEL.SALARYLEVELID = sl.SALARYLEVELID;
                        stand.SALARYSOLUTIONID = solution.SALARYSOLUTIONID;
                        stand.CHECKSTATE = "2";
                        stand.BASESALARY = sl.SALARYSUM;
                        stand.CREATEDATE = System.DateTime.Now;

                        //有关权限的字段
                        stand.CREATECOMPANYID = standtmp.CREATECOMPANYID;
                        stand.CREATEDEPARTMENTID = standtmp.CREATEDEPARTMENTID;
                        stand.CREATEPOSTID = standtmp.CREATEPOSTID;
                        stand.CREATEUSERID = standtmp.CREATEUSERID;
                        stand.OWNERCOMPANYID = standtmp.OWNERCOMPANYID;
                        stand.OWNERDEPARTMENTID = standtmp.OWNERDEPARTMENTID;
                        stand.OWNERID = standtmp.OWNERID;
                        stand.OWNERPOSTID = standtmp.OWNERPOSTID;


                        //增加排序号
                        stand.PERSONALSIRATIO = num;
                        num++;


                        //标准对应的地区差异补贴(和岗位级别有关)
                        decimal? allowance = 0;
                        if (areaAllowance != null)
                        {
                            allowance = (from al in areaAllowance
                                         where al.POSTLEVEL == sl.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                         select al.ALLOWANCE).FirstOrDefault();
                        }
                        //计算标准的基础数据
                        decimal? BasicData = sl.SALARYSUM;

                        //按照方案的薪资项集合生成薪资标准的薪资项
                        foreach (var item in salaryItems)
                        {
                            T_HR_SALARYSTANDARDITEM standItem = new T_HR_SALARYSTANDARDITEM();
                            standItem.STANDRECORDITEMID = Guid.NewGuid().ToString();
                            standItem.T_HR_SALARYITEMReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYITEM", "SALARYITEMID", item.T_HR_SALARYITEM.SALARYITEMID);
                            // standItem.T_HR_SALARYITEM.SALARYITEMID = item.T_HR_SALARYITEM.SALARYITEMID;
                            standItem.CREATEUSERID = solution.CREATEUSERID;
                            standItem.T_HR_SALARYSTANDARDReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYSTANDARD", "SALARYSTANDARDID", stand.SALARYSTANDARDID);
                            // standItem.T_HR_SALARYSTANDARD.SALARYSTANDARDID = stand.SALARYSTANDARDID;
                            standItem.CREATEDATE = System.DateTime.Now;
                            standItem.ORDERNUMBER = item.ORDERNUMBER;
                            //计算类型是手动输入的 金额是薪资项设置是输入的值
                            if (item.T_HR_SALARYITEM.CALCULATORTYPE == "1" || (item.T_HR_SALARYITEM.CALCULATORTYPE == "4" && item.T_HR_SALARYITEM.GUERDONSUM != null))
                            {
                                standItem.SUM = item.T_HR_SALARYITEM.GUERDONSUM.ToString();
                            }
                            //计算类型是公式计算 而且不是在生成薪资时计算  
                            else if (item.T_HR_SALARYITEM.CALCULATORTYPE == "3" && item.T_HR_SALARYITEM.ISAUTOGENERATE == "0")
                            {
                                standItem.SUM = bll.AutoCalculateItem(item.T_HR_SALARYITEM.SALARYITEMID, Convert.ToDecimal(BasicData), allowance.ToString()).ToString();
                            }
                            //地区差异补贴
                            else if (item.T_HR_SALARYITEM.ENTITYCOLUMNCODE == "AREADIFALLOWANCE")
                            {
                                standItem.SUM = allowance.ToString();
                            }
                            standSalaryitems.Add(standItem);
                        }
                        //SalaryStandardAdd(stand);
                        //itemBLL.SalaryStandardItemsAdd(standSalaryitems);
                        AddSalaryStanderAndItems(stand, standSalaryitems);
                        ShowMessage(txtMsg, "生成薪资标准:" + solution.SALARYSOLUTIONNAME + " " + stand.SALARYSTANDARDNAME + "成功!" + System.Environment.NewLine);
                    }
                }
                //dal.CommitTransaction();
                ShowMessage(txtMsg, "生成所有薪资标准成功!" + System.Environment.NewLine);
                MessageBox.Show("生成所有薪资标准成功!");
            }
            catch (Exception ex)
            {
                //dal.RollbackTransaction();
                MessageBox.Show("生成失败,错误信息:" + ex.ToString());
                SMT.Foundation.Log.Tracer.Debug(ex.Message);
            }
        }
Ejemplo n.º 3
0
 public void SalaryStandardItemUpdate(T_HR_SALARYSTANDARDITEM entity)
 {
     using (SalaryStandardItemBLL bll = new SalaryStandardItemBLL())
     {
         bll.SalaryStandardItemUpdate(entity);
     }
 }
Ejemplo n.º 4
0
 public int SalaryStandardItemAdd(T_HR_SALARYSTANDARDITEM entity)
 {
     using (SalaryStandardItemBLL bll = new SalaryStandardItemBLL())
     {
         return bll.SalaryStandardItemAdd(entity);
     }
 }
Ejemplo n.º 5
0
        void btnNew_Click(object sender, RoutedEventArgs e)
        {
            string filter = "";
            ObservableCollection<object> paras = new ObservableCollection<object>();
                T_HR_SALARYSTANDARDITEM salarystandarditem = new T_HR_SALARYSTANDARDITEM();
                T_HR_SALARYSTANDARD salarystandard = new T_HR_SALARYSTANDARD();
                salarystandard.SALARYSTANDARDID = savesid;
                Dictionary<string, string> cols = new Dictionary<string, string>();
                cols.Add("SALARYITEMNAME", "SALARYITEMNAME");
                cols.Add("GUERDONSUM", "GUERDONSUM");
                cols.Add("CALCULATEFORMULA", "CALCULATEFORMULA");
                RefreshUI(RefreshedTypes.ProgressBar);
                filter += "CREATECOMPANYID==@" + paras.Count().ToString();
                paras.Add(SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID);
                LookupForm lookup = new LookupForm(EntityNames.SalaryItemSet,
                    typeof(List<T_HR_SALARYITEM>), cols, filter,paras);
                lookup.TitleContent = Utility.GetResourceStr("SALARYITEM");
                lookup.SelectedClick += (o, ev) =>
                {
                    T_HR_SALARYITEM ent = lookup.SelectedObj as T_HR_SALARYITEM;
                    if (ent != null)
                    {
                        salarystandarditem.STANDRECORDITEMID = Guid.NewGuid().ToString();
                        salarystandarditem.T_HR_SALARYITEM = ent;
                        salarystandarditem.T_HR_SALARYSTANDARD = salarystandard;
                        salarystandarditem.SUM = ent.GUERDONSUM.ToString();
                        salarystandarditem.REMARK = ent.REMARK;
                        salarystandarditem.CREATEDATE = System.DateTime.Now;
                        salarystandarditem.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                        client.SalaryStandardItemAddAsync(salarystandarditem);
                    }
                };
                lookup.Show<string>(DialogMode.Default, SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot, "", (result) => { });

            #region ----
            //System.Collections.ObjectModel.ObservableCollection<object> paras = new System.Collections.ObjectModel.ObservableCollection<object>();
            ////string filter = "";
            ////filter = "CHECKSTATE==@" + paras.Count;
            //paras.Add(Convert.ToInt16(CheckStates.Approved).ToString());
            //LookupForm lookup = new LookupForm(EntityNames.SalaryStandard,
            //  typeof(List<T_HR_SALARYSTANDARD>), cols, filter, paras);
            #endregion

        }
Ejemplo n.º 6
0
        /// <summary>
        /// 批量生成薪资标准
        /// </summary>
        /// <param name="solution"></param>
        /// <param name="postLevels"></param>
        /// <param name="standModel"></param>
        /// <returns></returns>
        public string CreateSalaryStandBatch(T_HR_SALARYSOLUTION solution, Dictionary <string, string> postLevels, T_HR_SALARYSTANDARD standModel)
        {
            try
            {
                // 检查方案是否已经使用
                var tmpArchives = from ac in dal.GetObjects <T_HR_SALARYARCHIVE>()
                                  where ac.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                  select ac;
                if (tmpArchives.Count() > 0)
                {
                    Tracer.Debug("方案已经在使用中,无法重新生成薪资标准");
                    return("SALARYSOLUTIONINUSED");
                }

                // 薪资方案的体系ID
                string salarySystemID = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMID;
                //薪资体系名
                string salarySystemName = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMNAME;
                // 岗位级别名
                string postLevelName            = "";
                EmployeeSalaryRecordBLL bll     = new EmployeeSalaryRecordBLL();
                SalaryStandardItemBLL   itemBLL = new SalaryStandardItemBLL();

                //薪资方案所属的薪资体系
                List <T_HR_SALARYLEVEL> salarylevelList = new List <T_HR_SALARYLEVEL>();
                //薪资方案的薪资项集合
                List <V_SALARYITEM> salaryItems = new List <V_SALARYITEM>();

                salarylevelList = (from c in dal.GetObjects <T_HR_SALARYLEVEL>().Include("T_HR_POSTLEVELDISTINCTION")
                                   where c.T_HR_POSTLEVELDISTINCTION.T_HR_SALARYSYSTEM.SALARYSYSTEMID == salarySystemID
                                   select c).OrderBy(m => m.SALARYLEVEL).OrderBy(x => x.T_HR_POSTLEVELDISTINCTION.POSTLEVEL).ToList();


                //salaryItems = (from n in DataContext.T_HR_SALARYITEM
                //               join m in DataContext.T_HR_SALARYSOLUTIONITEM on n.SALARYITEMID equals m.T_HR_SALARYITEM.SALARYITEMID
                //               where m.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                //               select n).ToList();
                salaryItems = (from n in dal.GetObjects <T_HR_SALARYITEM>()
                               join m in dal.GetObjects <T_HR_SALARYSOLUTIONITEM>() on n.SALARYITEMID equals m.T_HR_SALARYITEM.SALARYITEMID
                               where m.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                               select new V_SALARYITEM
                {
                    T_HR_SALARYITEM = n,
                    ORDERNUMBER = m.ORDERNUMBER
                }
                               ).ToList();

                //方案所属地区差异补贴
                List <T_HR_AREAALLOWANCE> areaAllowance = new List <T_HR_AREAALLOWANCE>();
                areaAllowance = (from c in dal.GetObjects <T_HR_AREAALLOWANCE>()
                                 join b in dal.GetObjects <T_HR_SALARYSOLUTION>().Include("T_HR_AREADIFFERENCE") on c.T_HR_AREADIFFERENCE.AREADIFFERENCEID equals b.T_HR_AREADIFFERENCE.AREADIFFERENCEID
                                 where b.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                 select c).ToList();

                //新增前删除原有的标准
                SalaryStandardBLL standBLL = new SalaryStandardBLL();
                standBLL.SalaryStandardDeleteBySolutionID(solution.SALARYSOLUTIONID);
                //var enttt = from ccc in salarylevelList where ccc.SALARYSUM>0 select ccc;
                int num = 0;
                #region   薪资标准排序算法
                int numsign    = 0;
                int recordsign = 0;
                for (int x = 0; x < salarylevelList.Count; x++)
                {
                    if (numsign == 0)
                    {
                        recordsign = x;
                    }
                    if ((x + 1 < salarylevelList.Count && salarylevelList[x].T_HR_POSTLEVELDISTINCTION.POSTLEVEL != salarylevelList[x + 1].T_HR_POSTLEVELDISTINCTION.POSTLEVEL) || x == salarylevelList.Count - 1)
                    {
                        numsign++;
                        for (int i = recordsign; i < recordsign + numsign; i++)
                        {
                            for (int j = i + 1; j < recordsign + numsign; j++)
                            {
                                //if (salarylevelList[i].T_HR_POSTLEVELDISTINCTION.POSTLEVEL > 0) break;
                                if (Convert.ToDecimal(salarylevelList[i].SALARYLEVEL) > Convert.ToDecimal(salarylevelList[j].SALARYLEVEL))
                                {
                                    T_HR_SALARYLEVEL t = null;
                                    t = salarylevelList[i];
                                    salarylevelList[i] = salarylevelList[j];
                                    salarylevelList[j] = t;
                                }
                            }
                        }
                        numsign = 0;
                    }
                    else
                    {
                        numsign++;
                    }
                }
                #endregion
                //dal.BeginTransaction();
                foreach (var sl in salarylevelList)
                {
                    // 薪资体系的每条记录都对应一个标准 根据sl生成薪资标准
                    T_HR_SALARYSTANDARD stand = new T_HR_SALARYSTANDARD();
                    //薪资标准的薪资项集合
                    List <T_HR_SALARYSTANDARDITEM> standSalaryitems = new List <T_HR_SALARYSTANDARDITEM>();
                    //获取岗位级别名
                    var ent = from c in postLevels
                              join b in salarylevelList on c.Value equals b.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                  where b.SALARYLEVELID == sl.SALARYLEVELID
                              select c.Key;

                    if (ent.Count() > 0)
                    {
                        postLevelName = ent.FirstOrDefault().ToString();
                    }

                    //薪资标准名= 薪资体系名+岗位级别名+"-"+薪资级别名
                    stand.SALARYSTANDARDNAME = salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString();
                    stand.SALARYSTANDARDID   = Guid.NewGuid().ToString();
                    // stand.T_HR_SALARYLEVEL = new T_HR_SALARYLEVEL();
                    stand.T_HR_SALARYLEVELReference.EntityKey
                        = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYLEVEL", "SALARYLEVELID", sl.SALARYLEVELID);
                    //  stand.T_HR_SALARYLEVEL.SALARYLEVELID = sl.SALARYLEVELID;
                    stand.SALARYSOLUTIONID = solution.SALARYSOLUTIONID;
                    stand.CHECKSTATE       = Convert.ToInt32(CheckStates.Approved).ToString();
                    stand.BASESALARY       = sl.SALARYSUM;
                    stand.CREATEDATE       = System.DateTime.Now;

                    //有关权限的字段
                    stand.CREATECOMPANYID    = standModel.CREATECOMPANYID;
                    stand.CREATEDEPARTMENTID = standModel.CREATEDEPARTMENTID;
                    stand.CREATEPOSTID       = standModel.CREATEPOSTID;
                    stand.CREATEUSERID       = standModel.CREATEUSERID;
                    stand.OWNERCOMPANYID     = standModel.OWNERCOMPANYID;
                    stand.OWNERDEPARTMENTID  = standModel.OWNERDEPARTMENTID;
                    stand.OWNERID            = standModel.OWNERID;
                    stand.OWNERPOSTID        = standModel.OWNERPOSTID;


                    //增加排序号
                    stand.PERSONALSIRATIO = num;
                    num++;


                    //标准对应的地区差异补贴(和岗位级别有关)
                    decimal?allowance = 0;
                    if (areaAllowance != null)
                    {
                        allowance = (from al in areaAllowance
                                     where al.POSTLEVEL == sl.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                     select al.ALLOWANCE).FirstOrDefault();
                    }
                    //计算标准的基础数据
                    decimal?BasicData = sl.SALARYSUM;

                    //按照方案的薪资项集合生成薪资标准的薪资项
                    foreach (var item in salaryItems)
                    {
                        T_HR_SALARYSTANDARDITEM standItem = new T_HR_SALARYSTANDARDITEM();
                        standItem.STANDRECORDITEMID = Guid.NewGuid().ToString();
                        standItem.T_HR_SALARYITEMReference.EntityKey
                            = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYITEM", "SALARYITEMID", item.T_HR_SALARYITEM.SALARYITEMID);
                        // standItem.T_HR_SALARYITEM.SALARYITEMID = item.T_HR_SALARYITEM.SALARYITEMID;
                        standItem.CREATEUSERID = solution.CREATEUSERID;
                        standItem.T_HR_SALARYSTANDARDReference.EntityKey
                            = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYSTANDARD", "SALARYSTANDARDID", stand.SALARYSTANDARDID);
                        // standItem.T_HR_SALARYSTANDARD.SALARYSTANDARDID = stand.SALARYSTANDARDID;
                        standItem.CREATEDATE  = System.DateTime.Now;
                        standItem.ORDERNUMBER = item.ORDERNUMBER;
                        //计算类型是手动输入的 金额是薪资项设置是输入的值
                        if (item.T_HR_SALARYITEM.CALCULATORTYPE == "1" || (item.T_HR_SALARYITEM.CALCULATORTYPE == "4" && item.T_HR_SALARYITEM.GUERDONSUM != null))
                        {
                            standItem.SUM = item.T_HR_SALARYITEM.GUERDONSUM.ToString();
                        }
                        //计算类型是公式计算 而且不是在生成薪资时计算
                        else if (item.T_HR_SALARYITEM.CALCULATORTYPE == "3" && item.T_HR_SALARYITEM.ISAUTOGENERATE == "0")
                        {
                            standItem.SUM = bll.AutoCalculateItem(item.T_HR_SALARYITEM.SALARYITEMID, Convert.ToDecimal(BasicData), allowance.ToString()).ToString();
                        }
                        //地区差异补贴
                        else if (item.T_HR_SALARYITEM.ENTITYCOLUMNCODE == "AREADIFALLOWANCE")
                        {
                            standItem.SUM = allowance.ToString();
                        }
                        standSalaryitems.Add(standItem);
                    }
                    //SalaryStandardAdd(stand);
                    //itemBLL.SalaryStandardItemsAdd(standSalaryitems);
                    AddSalaryStanderAndItems(stand, standSalaryitems);
                }
                //dal.CommitTransaction();
                return("SAVESUCCESSED");
            }
            catch (Exception ex)
            {
                //dal.RollbackTransaction();
                SMT.Foundation.Log.Tracer.Debug(ex.Message);
                return(ex.Message);
            }
        }
Ejemplo n.º 7
0
        public void CreateSalaryStandBatch()
        {
            try
            {
                EmployeeSalaryRecordBLL bll     = new EmployeeSalaryRecordBLL();
                SalaryStandardItemBLL   itemBLL = new SalaryStandardItemBLL();

                string strsolutionall = @"上海神达物流有限公司薪资方案(A类城市)
                                上海酷武供应链管理服务有限公司薪资方案(A类)
                                北京市神通物流有限公司薪资方案(A类城市)
                                南京红之衣物流有限公司薪资方案(B类城市)
                                南宁市神州通货运代理有限公司薪资方案(D类城市)
                                南昌神州通物流有限公司薪资方案(E类城市)
                                合肥神州通物流有限公司薪资方案(D类城市)
                                哈尔滨神达通运输有限责任公司薪资方案(D类城市)
                                天津神州通物流有限公司薪资方案(C类城市)
                                太原市神通物流有限公司薪资方案(E类城市)
                                广州市神通物流有限公司薪资方案(A类城市)
                                成都通神州物流有限公司薪资方案(D类城市)
                                昆明神州通物流有限公司薪资方案(D类城市)
                                杭州新神州通货物运输有限公司薪资方案(B类城市)
                                武汉通神州仓储服务有限责任公司薪资方案(C类城市)
                                沈阳神州通物流有限公司薪资方案(C类城市)
                                济南神州通物流有限公司薪资方案(C类城市)
                                深圳市神州通物流有限公司薪资方案(A类城市)
                                深圳市神州通物流有限公司薪资方案(B类城市)
                                深圳市神州通物流有限公司薪资方案(C类城市)
                                深圳市神州通物流有限公司薪资方案(D类城市)
                                深圳市神州通物流有限公司薪资方案(E类城市)
                                深圳市神州通物流有限公司贵阳分公司(E类城市)
                                深圳市通神州物流公司薪资方案(A类城市)
                                石家庄神州通物流有限公司薪资方案(D类城市)
                                福州市神州通货运代理有限公司薪资方案(C类城市)
                                西安市神之通物流有限公司薪资方案(D类城市)
                                贵阳市神州通物流有限公司(E类城市)
                                郑州市神州通物流有限公司薪资方案(D类城市)
                                重庆新神州通物流有限公司薪资方案(D类城市)
                                长春市神之通物流有限公司薪资方案(D类城市)
                                长沙市神通物流服务有限公司薪资方案(C类城市)
                                青海神之通电子商务有限公司薪资方案(E类)";
                var    solutionAll    = (from ent in dal.GetObjects <T_HR_SALARYSOLUTION>().Include("T_HR_SALARYSYSTEM")
                                         where ent.SALARYSOLUTIONNAME.Contains(strsolutionall) &&
                                         ent.CHECKSTATE == "2"
                                         select ent).ToList();

                foreach (var solutionItem in solutionAll)
                {
                    solution = solutionItem;


                    standtmp = new T_HR_SALARYSTANDARD();
                    standtmp.SALARYSTANDARDID   = Guid.NewGuid().ToString();
                    standtmp.CREATECOMPANYID    = solution.CREATECOMPANYID;
                    standtmp.CREATEDEPARTMENTID = solution.CREATEDEPARTMENTID;
                    standtmp.CREATEPOSTID       = solution.CREATEPOSTID;
                    standtmp.CREATEUSERID       = solution.CREATEUSERID;

                    standtmp.OWNERCOMPANYID    = solution.OWNERCOMPANYID;
                    standtmp.OWNERDEPARTMENTID = solution.OWNERDEPARTMENTID;
                    standtmp.OWNERID           = solution.OWNERID;
                    standtmp.OWNERPOSTID       = solution.OWNERPOSTID;
                    //loadbar.Start();

                    // 薪资方案的体系ID
                    string salarySystemID = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMID;
                    //薪资体系名
                    string salarySystemName = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMNAME;
                    // 岗位级别名
                    string postLevelName = "";

                    //薪资方案所属的薪资体系
                    List <T_HR_SALARYLEVEL> salarylevelList = new List <T_HR_SALARYLEVEL>();
                    //薪资方案的薪资项集合
                    List <V_SALARYITEM> salaryItems = new List <V_SALARYITEM>();

                    salarylevelList = (from c in dal.GetObjects <T_HR_SALARYLEVEL>().Include("T_HR_POSTLEVELDISTINCTION")
                                       where c.T_HR_POSTLEVELDISTINCTION.T_HR_SALARYSYSTEM.SALARYSYSTEMID == salarySystemID
                                       select c).ToList().OrderBy(m => m.SALARYLEVEL).OrderBy(x => x.T_HR_POSTLEVELDISTINCTION.POSTLEVEL).ToList();

                    salaryItems = (from n in dal.GetObjects <T_HR_SALARYITEM>()
                                   join m in dal.GetObjects <T_HR_SALARYSOLUTIONITEM>() on n.SALARYITEMID equals m.T_HR_SALARYITEM.SALARYITEMID
                                   where m.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                   select new V_SALARYITEM
                    {
                        T_HR_SALARYITEM = n,
                        ORDERNUMBER = m.ORDERNUMBER
                    }
                                   ).ToList();

                    //方案所属地区差异补贴
                    List <T_HR_AREAALLOWANCE> areaAllowance = new List <T_HR_AREAALLOWANCE>();
                    areaAllowance = (from c in dal.GetObjects <T_HR_AREAALLOWANCE>()
                                     join b in dal.GetObjects <T_HR_SALARYSOLUTION>().Include("T_HR_AREADIFFERENCE") on c.T_HR_AREADIFFERENCE.AREADIFFERENCEID equals b.T_HR_AREADIFFERENCE.AREADIFFERENCEID
                                     where b.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                     select c).ToList();

                    int num = 0;

                    //dal.BeginTransaction();
                    foreach (var sl in salarylevelList)
                    {
                        var ent = from c in postlevels
                                  join b in salarylevelList on c.Value equals b.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                      where b.SALARYLEVELID == sl.SALARYLEVELID
                                  select c.Key;

                        if (ent.Count() > 0)
                        {
                            postLevelName = ent.FirstOrDefault().ToString();
                        }
                        var ents = (from a in dal.GetObjects <T_HR_SALARYSTANDARD>()
                                    where a.T_HR_SALARYLEVEL.SALARYLEVELID == sl.SALARYLEVELID &&
                                    a.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                    select new
                        {
                            a.SALARYSTANDARDID,
                            a.SALARYSTANDARDNAME,
                            a.T_HR_SALARYLEVEL.SALARYLEVEL
                        });
                        if (ents.Count() > 0)
                        {
                            var checkEntity = ents.FirstOrDefault();
                            ShowMessage(txtMsg, "薪资标准已存在,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //已存在,跳过生成
                            continue;
                            //if (int.Parse(checkEntity.SALARYLEVEL) > 40)
                            //{
                            //    try {
                            //    var delentity = (from a in dal.GetObjects<T_HR_SALARYSTANDARD>().Include("T_HR_SALARYSTANDARDITEM")
                            //                     where a.SALARYSTANDARDID
                            //                     == checkEntity.SALARYSTANDARDID
                            //                     select a).FirstOrDefault();
                            //    foreach (var entity in delentity.T_HR_SALARYSTANDARDITEM)
                            //    {
                            //        dal.Delete(entity);
                            //    }
                            //    dal.Delete(delentity);
                            //    ShowMessage(txtMsg, "删除薪资标准成功!" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //        }catch(Exception ex)
                            //    {
                            //        ShowMessage(txtMsg, "薪资标准已被使用,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //        continue;
                            //    }
                            //}
                            //else
                            //{
                            //    ShowMessage(txtMsg, "薪资标准已存在,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //    //已存在,跳过生成
                            //    continue;
                            //}
                        }
                        // 薪资体系的每条记录都对应一个标准 根据sl生成薪资标准
                        T_HR_SALARYSTANDARD stand = new T_HR_SALARYSTANDARD();
                        //薪资标准的薪资项集合
                        List <T_HR_SALARYSTANDARDITEM> standSalaryitems = new List <T_HR_SALARYSTANDARDITEM>();
                        //获取岗位级别名


                        //薪资标准名= 薪资体系名+岗位级别名+"-"+薪资级别名
                        stand.SALARYSTANDARDNAME = salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString();
                        stand.SALARYSTANDARDID   = Guid.NewGuid().ToString();
                        // stand.T_HR_SALARYLEVEL = new T_HR_SALARYLEVEL();
                        stand.T_HR_SALARYLEVELReference.EntityKey
                            = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYLEVEL", "SALARYLEVELID", sl.SALARYLEVELID);
                        //  stand.T_HR_SALARYLEVEL.SALARYLEVELID = sl.SALARYLEVELID;
                        stand.SALARYSOLUTIONID = solution.SALARYSOLUTIONID;
                        stand.CHECKSTATE       = "2";
                        stand.BASESALARY       = sl.SALARYSUM;
                        stand.CREATEDATE       = System.DateTime.Now;

                        //有关权限的字段
                        stand.CREATECOMPANYID    = standtmp.CREATECOMPANYID;
                        stand.CREATEDEPARTMENTID = standtmp.CREATEDEPARTMENTID;
                        stand.CREATEPOSTID       = standtmp.CREATEPOSTID;
                        stand.CREATEUSERID       = standtmp.CREATEUSERID;
                        stand.OWNERCOMPANYID     = standtmp.OWNERCOMPANYID;
                        stand.OWNERDEPARTMENTID  = standtmp.OWNERDEPARTMENTID;
                        stand.OWNERID            = standtmp.OWNERID;
                        stand.OWNERPOSTID        = standtmp.OWNERPOSTID;


                        //增加排序号
                        stand.PERSONALSIRATIO = num;
                        num++;


                        //标准对应的地区差异补贴(和岗位级别有关)
                        decimal?allowance = 0;
                        if (areaAllowance != null)
                        {
                            allowance = (from al in areaAllowance
                                         where al.POSTLEVEL == sl.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                         select al.ALLOWANCE).FirstOrDefault();
                        }
                        //计算标准的基础数据
                        decimal?BasicData = sl.SALARYSUM;

                        //按照方案的薪资项集合生成薪资标准的薪资项
                        foreach (var item in salaryItems)
                        {
                            T_HR_SALARYSTANDARDITEM standItem = new T_HR_SALARYSTANDARDITEM();
                            standItem.STANDRECORDITEMID = Guid.NewGuid().ToString();
                            standItem.T_HR_SALARYITEMReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYITEM", "SALARYITEMID", item.T_HR_SALARYITEM.SALARYITEMID);
                            // standItem.T_HR_SALARYITEM.SALARYITEMID = item.T_HR_SALARYITEM.SALARYITEMID;
                            standItem.CREATEUSERID = solution.CREATEUSERID;
                            standItem.T_HR_SALARYSTANDARDReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYSTANDARD", "SALARYSTANDARDID", stand.SALARYSTANDARDID);
                            // standItem.T_HR_SALARYSTANDARD.SALARYSTANDARDID = stand.SALARYSTANDARDID;
                            standItem.CREATEDATE  = System.DateTime.Now;
                            standItem.ORDERNUMBER = item.ORDERNUMBER;
                            //计算类型是手动输入的 金额是薪资项设置是输入的值
                            if (item.T_HR_SALARYITEM.CALCULATORTYPE == "1" || (item.T_HR_SALARYITEM.CALCULATORTYPE == "4" && item.T_HR_SALARYITEM.GUERDONSUM != null))
                            {
                                standItem.SUM = item.T_HR_SALARYITEM.GUERDONSUM.ToString();
                            }
                            //计算类型是公式计算 而且不是在生成薪资时计算
                            else if (item.T_HR_SALARYITEM.CALCULATORTYPE == "3" && item.T_HR_SALARYITEM.ISAUTOGENERATE == "0")
                            {
                                standItem.SUM = bll.AutoCalculateItem(item.T_HR_SALARYITEM.SALARYITEMID, Convert.ToDecimal(BasicData), allowance.ToString()).ToString();
                            }
                            //地区差异补贴
                            else if (item.T_HR_SALARYITEM.ENTITYCOLUMNCODE == "AREADIFALLOWANCE")
                            {
                                standItem.SUM = allowance.ToString();
                            }
                            standSalaryitems.Add(standItem);
                        }
                        //SalaryStandardAdd(stand);
                        //itemBLL.SalaryStandardItemsAdd(standSalaryitems);
                        AddSalaryStanderAndItems(stand, standSalaryitems);
                        ShowMessage(txtMsg, "生成薪资标准:" + solution.SALARYSOLUTIONNAME + " " + stand.SALARYSTANDARDNAME + "成功!" + System.Environment.NewLine);
                    }
                }
                //dal.CommitTransaction();
                ShowMessage(txtMsg, "生成所有薪资标准成功!" + System.Environment.NewLine);
                MessageBox.Show("生成所有薪资标准成功!");
            }
            catch (Exception ex)
            {
                //dal.RollbackTransaction();
                MessageBox.Show("生成失败,错误信息:" + ex.ToString());
                SMT.Foundation.Log.Tracer.Debug(ex.Message);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 批量生成薪资标准
        /// </summary>
        /// <param name="solution"></param>
        /// <param name="postLevels"></param>
        /// <param name="standModel"></param>
        /// <returns></returns>
        public string CreateSalaryStandBatch(T_HR_SALARYSOLUTION solution, Dictionary <string, string> postLevels, T_HR_SALARYSTANDARD standModel)
        {
            try
            {
                //T_HR_SalaryStandard->T_HR_SalarySolution
                //T_HR_SalaryStandard->T_HR_SalaryLevel->T_HR_PostLevelDistinction->T_HR_SalarySystem
                Tracer.Debug("通过薪资方案生成薪资标准:方案名:" + solution.SALARYSOLUTIONNAME);
                #region 获取薪资级别信息
                EmployeeSalaryRecordBLL bll     = new EmployeeSalaryRecordBLL();
                SalaryStandardItemBLL   itemBLL = new SalaryStandardItemBLL();
                // 薪资方案的体系ID
                string salarySystemID = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMID;
                //薪资体系名
                string salarySystemName = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMNAME;
                // 岗位级别名
                string postLevelName = "";
                //薪资方案所属的薪资体系
                List <T_HR_SALARYLEVEL> salarylevelList = new List <T_HR_SALARYLEVEL>();
                //薪资体系薪资级别
                salarylevelList = (from c in dal.GetObjects <T_HR_SALARYLEVEL>().Include("T_HR_POSTLEVELDISTINCTION")
                                   where c.T_HR_POSTLEVELDISTINCTION.T_HR_SALARYSYSTEM.SALARYSYSTEMID == salarySystemID
                                   select c).OrderBy(m => m.SALARYLEVEL).OrderBy(x => x.T_HR_POSTLEVELDISTINCTION.POSTLEVEL).ToList();
                if (salarylevelList.Count < 1)
                {
                    Tracer.Debug("生产薪资标准,未获取到薪资等级 T_HR_SALARYLEVEL 信息");
                }
                //薪资方案的薪资项集合
                List <V_SALARYITEM> salaryItems = new List <V_SALARYITEM>();
                salaryItems = (from n in dal.GetObjects <T_HR_SALARYITEM>()
                               join m in dal.GetObjects <T_HR_SALARYSOLUTIONITEM>() on n.SALARYITEMID equals m.T_HR_SALARYITEM.SALARYITEMID
                               where m.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                               select new V_SALARYITEM
                {
                    T_HR_SALARYITEM = n,
                    ORDERNUMBER = m.ORDERNUMBER
                }
                               ).ToList();
                if (salaryItems.Count < 1)
                {
                    Tracer.Debug("生产薪资标准,未获取到薪资方案关联的薪资项目 T_HR_SALARYITEM 信息");
                }
                //方案所属地区差异补贴
                List <T_HR_AREAALLOWANCE> areaAllowance = new List <T_HR_AREAALLOWANCE>();
                areaAllowance = (from c in dal.GetObjects <T_HR_AREAALLOWANCE>()
                                 join b in dal.GetObjects <T_HR_SALARYSOLUTION>().Include("T_HR_AREADIFFERENCE")
                                 on c.T_HR_AREADIFFERENCE.AREADIFFERENCEID equals b.T_HR_AREADIFFERENCE.AREADIFFERENCEID
                                 where b.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                 select c).ToList();
                if (salaryItems.Count < 1)
                {
                    Tracer.Debug("生产薪资标准,未获取到薪资方案关联的地区差异补贴 T_HR_AREAALLOWANCE 信息");
                }
                //薪资方案薪资标准
                List <T_HR_SALARYSTANDARD> standAll = (from a in dal.GetObjects <T_HR_SALARYSTANDARD>().Include("T_HR_SALARYLEVEL").Include("T_HR_SALARYSTANDARDITEM")
                                                       where a.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                                       select a).ToList();
                #endregion
                int num = 0;
                foreach (var sl in salarylevelList)
                {
                    #region 获取薪资标准基本信息
                    //1.获取岗位级别名
                    var ent = from c in postLevels
                              join b in salarylevelList on c.Value equals b.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                  where b.SALARYLEVELID == sl.SALARYLEVELID
                              select c.Key;

                    if (ent.Count() > 0)
                    {
                        postLevelName = ent.FirstOrDefault().ToString();
                    }
                    //2.标准对应的地区差异补贴(和岗位级别有关)
                    decimal?allowance = 0;
                    if (areaAllowance != null)
                    {
                        allowance = (from al in areaAllowance
                                     where al.POSTLEVEL == sl.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                     select al.ALLOWANCE).FirstOrDefault();
                    }
                    //3.计算标准的基础数据
                    decimal?BasicData = sl.SALARYSUM;
                    #endregion

                    var checkEntity = (from a in standAll
                                       where a.T_HR_SALARYLEVEL.SALARYLEVELID == sl.SALARYLEVELID
                                       select a).FirstOrDefault();
                    #region 更新薪资标准
                    if (checkEntity != null)
                    {
                        try
                        {
                            Tracer.Debug("已存在薪资标准,开始更新:" + checkEntity.SALARYSTANDARDNAME);
                            //已存在,需要更新
                            //薪资标准名= 薪资体系名+岗位级别名+"-"+薪资级别名
                            var entity = (from sent in dal.GetObjects <T_HR_SALARYSTANDARD>().Include("T_HR_SALARYSTANDARDITEM")
                                          where sent.SALARYSTANDARDID == checkEntity.SALARYSTANDARDID
                                          select sent).FirstOrDefault();
                            entity.SALARYSTANDARDNAME = salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString();
                            entity.BASESALARY         = sl.SALARYSUM;
                            dal.UpdateFromContext(entity);
                            List <T_HR_SALARYSTANDARDITEM> listItem = entity.T_HR_SALARYSTANDARDITEM.ToList();
                            foreach (var standItem in listItem)
                            {
                                if (!standItem.T_HR_SALARYITEMReference.IsLoaded)
                                {
                                    standItem.T_HR_SALARYITEMReference.Load();
                                }
                                var q = from item in salaryItems
                                        where item.T_HR_SALARYITEM.SALARYITEMID == standItem.T_HR_SALARYITEMReference.EntityKey.EntityKeyValues[0].Value
                                        select item;
                                if (q.Count() > 0)
                                {
                                    var salaryitem = q.FirstOrDefault();
                                    if (salaryitem.T_HR_SALARYITEM.CALCULATORTYPE == "1" || (salaryitem.T_HR_SALARYITEM.CALCULATORTYPE == "4" && salaryitem.T_HR_SALARYITEM.GUERDONSUM != null))
                                    {
                                        standItem.SUM = salaryitem.T_HR_SALARYITEM.GUERDONSUM.ToString();
                                    }//计算类型是公式计算 而且不是在生成薪资时计算
                                    else if (salaryitem.T_HR_SALARYITEM.CALCULATORTYPE == "3" && salaryitem.T_HR_SALARYITEM.ISAUTOGENERATE == "0")
                                    {
                                        standItem.SUM = bll.AutoCalculateItem(salaryitem.T_HR_SALARYITEM.SALARYITEMID, Convert.ToDecimal(BasicData), allowance.ToString()).ToString();
                                    }
                                    //地区差异补贴
                                    else if (salaryitem.T_HR_SALARYITEM.ENTITYCOLUMNCODE == "AREADIFALLOWANCE")
                                    {
                                        standItem.SUM = allowance.ToString();
                                    }
                                }
                                dal.UpdateFromContext(standItem);
                            }
                            dal.SaveContextChanges();
                            Tracer.Debug("更新薪资标准成功!" + entity.SALARYSTANDARDNAME);
                        }
                        catch (Exception ex)
                        {
                            Tracer.Debug("更新薪资标准异常:" + ex.ToString());
                        }
                        continue;
                    }
                    #endregion

                    #region 新增薪资标准
                    try
                    {
                        Tracer.Debug("未找到薪资标准,开始新增薪资标准信息:" + salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString());
                        // 薪资体系的每条记录都对应一个标准 根据sl生成薪资标准
                        T_HR_SALARYSTANDARD stand = new T_HR_SALARYSTANDARD();
                        //薪资标准名= 薪资体系名+岗位级别名+"-"+薪资级别名
                        stand.SALARYSTANDARDNAME = salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString();
                        stand.SALARYSTANDARDID   = Guid.NewGuid().ToString();
                        stand.T_HR_SALARYLEVELReference.EntityKey
                            = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYLEVEL", "SALARYLEVELID", sl.SALARYLEVELID);
                        stand.SALARYSOLUTIONID = solution.SALARYSOLUTIONID;
                        stand.CHECKSTATE       = Convert.ToInt32(CheckStates.Approved).ToString();
                        stand.BASESALARY       = sl.SALARYSUM;
                        stand.CREATEDATE       = System.DateTime.Now;

                        //有关权限的字段
                        stand.CREATECOMPANYID    = standModel.CREATECOMPANYID;
                        stand.CREATEDEPARTMENTID = standModel.CREATEDEPARTMENTID;
                        stand.CREATEPOSTID       = standModel.CREATEPOSTID;
                        stand.CREATEUSERID       = standModel.CREATEUSERID;
                        stand.OWNERCOMPANYID     = standModel.OWNERCOMPANYID;
                        stand.OWNERDEPARTMENTID  = standModel.OWNERDEPARTMENTID;
                        stand.OWNERID            = standModel.OWNERID;
                        stand.OWNERPOSTID        = standModel.OWNERPOSTID;


                        //增加排序号
                        stand.PERSONALSIRATIO = num;
                        num++;

                        //按照方案的薪资项集合生成薪资标准的薪资项
                        //薪资标准的薪资项集合
                        List <T_HR_SALARYSTANDARDITEM> standSalaryitems = new List <T_HR_SALARYSTANDARDITEM>();
                        foreach (var item in salaryItems)
                        {
                            T_HR_SALARYSTANDARDITEM standItem = new T_HR_SALARYSTANDARDITEM();
                            standItem.STANDRECORDITEMID = Guid.NewGuid().ToString();
                            standItem.T_HR_SALARYITEMReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYITEM", "SALARYITEMID", item.T_HR_SALARYITEM.SALARYITEMID);
                            // standItem.T_HR_SALARYITEM.SALARYITEMID = item.T_HR_SALARYITEM.SALARYITEMID;
                            standItem.CREATEUSERID = solution.CREATEUSERID;
                            standItem.T_HR_SALARYSTANDARDReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYSTANDARD", "SALARYSTANDARDID", stand.SALARYSTANDARDID);
                            // standItem.T_HR_SALARYSTANDARD.SALARYSTANDARDID = stand.SALARYSTANDARDID;
                            standItem.CREATEDATE  = System.DateTime.Now;
                            standItem.ORDERNUMBER = item.ORDERNUMBER;
                            //计算类型是手动输入的 金额是薪资项设置是输入的值
                            if (item.T_HR_SALARYITEM.CALCULATORTYPE == "1" || (item.T_HR_SALARYITEM.CALCULATORTYPE == "4" && item.T_HR_SALARYITEM.GUERDONSUM != null))
                            {
                                standItem.SUM = item.T_HR_SALARYITEM.GUERDONSUM.ToString();
                            }
                            //计算类型是公式计算 而且不是在生成薪资时计算
                            else if (item.T_HR_SALARYITEM.CALCULATORTYPE == "3" && item.T_HR_SALARYITEM.ISAUTOGENERATE == "0")
                            {
                                standItem.SUM = bll.AutoCalculateItem(item.T_HR_SALARYITEM.SALARYITEMID, Convert.ToDecimal(BasicData), allowance.ToString()).ToString();
                            }
                            //地区差异补贴
                            else if (item.T_HR_SALARYITEM.ENTITYCOLUMNCODE == "AREADIFALLOWANCE")
                            {
                                standItem.SUM = allowance.ToString();
                            }
                            standSalaryitems.Add(standItem);
                        }
                        AddSalaryStanderAndItems(stand, standSalaryitems);
                        Tracer.Debug("未找到薪资标准,新增薪资标准成功!" + salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString());
                    }
                    catch (Exception ex)
                    {
                        Tracer.Debug("未找到薪资标准,新增薪资标准异常:" + ex.ToString());
                    }
                    #endregion
                }
                return("SAVESUCCESSED");
            }
            catch (Exception ex)
            {
                Tracer.Debug("生成薪资标准异常:" + ex.Message);
                return(ex.Message);
            }
        }