示例#1
0
        private InsToDo BuilderInsToDo(CfgBillWriteBackRule rule, FapDynamicObject billData, Employee empInfo, string caseUid)
        {
            //影响此保险组
            InsToDo insToDo = new InsToDo();

            insToDo.EmpUid     = empInfo.Fid;
            insToDo.EmpCode    = empInfo.EmpCode;
            insToDo.DeptUid    = empInfo.DeptUid;
            insToDo.DeptCode   = empInfo.DeptCode;
            insToDo.CaseUid    = caseUid;                                                                                                 //受影响保险组
            insToDo.TableUid   = rule.DocEntityUid;                                                                                       //单据实体
            insToDo.BizDate    = DateTimeUtils.CurrentDateStr;                                                                            //业务日期--当前时间
            insToDo.OperEmpUid = billData.Get("BillEmpUid") == null ? _applicationContext.EmpUid : billData.Get("BillEmpUid").ToString(); //变动处理人--制单人
            insToDo.OperFlag   = "0";                                                                                                     //变动应用 默认为0
            insToDo.TransID    = billData.Get("Id").ToString();                                                                           //单据ID
            return(insToDo);
        }
示例#2
0
        public void UseInsPending(InsToDo insToDo)
        {
            //保险组
            InsCase insCase = _dbContext.Get <InsCase>(insToDo.CaseUid);
            //员工
            Employee employee = _dbContext.Get <Employee>(insToDo.EmpUid);
            //检查员工是否在保险组
            var caseEmployee = _dbContext.QueryFirstOrDefault($"select * from {insCase.TableName} where EmpUid=@EmpUid", new DynamicParameters(new { EmpUid = employee.Fid }));

            if (caseEmployee != null)
            {
                if (employee.EmpStatus == EmployeeStatus.Former)
                {
                    DeleteEmployeeFromInsCase();
                }
                else
                {
                    UpdateEmployeeToInsCase();
                }
            }
            else if (employee.EmpStatus == EmployeeStatus.Current)
            {
                AddEmployeeToInsCase();
            }
            MarkInsTodo();
            void MarkInsTodo()
            {
                insToDo.OperDate   = DateTimeUtils.CurrentDateTimeStr;
                insToDo.OperEmpUid = _applicationContext.EmpUid;
                insToDo.OperFlag   = "1";
                _dbContext.Update(insToDo);
            }

            void DeleteEmployeeFromInsCase()
            {
                string sql = $"delete from {insCase.TableName} where Fid=@Fid";

                _dbContext.ExecuteOriginal(sql, new DynamicParameters(new { Fid = caseEmployee.Fid }));
            }

            void UpdateEmployeeToInsCase()
            {
                string sql = $"update {insCase.TableName} set EmpCode='{employee.EmpCode}',EmpCategory='{employee.EmpCategory}',DeptUid='{employee.DeptUid}' where Fid=@Fid";

                _dbContext.ExecuteOriginal(sql, new DynamicParameters(new { Fid = caseEmployee.Fid }));
            }

            void AddEmployeeToInsCase()
            {
                FapDynamicObject caseEmp = new FapDynamicObject(_dbContext.Columns(insCase.TableName));

                //将此人的放入薪资套
                caseEmp.SetValue("EmpUid", employee.Fid);
                caseEmp.SetValue("EmpCode", employee.EmpCode);
                caseEmp.SetValue("EmpCategory", employee.EmpCategory);
                caseEmp.SetValue("DeptUid", employee.DeptUid);
                caseEmp.SetValue("InsCaseUid", insCase.Fid);
                caseEmp.SetValue("InsmentTimes", 1);
                caseEmp.SetValue("InsConfirm", 0);

                if (insCase.InsYM.IsPresent())
                {
                    caseEmp.SetValue("InsYM", insCase.InsYM);
                }
                else
                {
                    caseEmp.SetValue("InsYM", insCase.InitYM);
                }
                _dbContext.InsertDynamicData(caseEmp);
            }
        }