| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668 |
- package cn.com.lzt.common.util;
- import cn.com.lzt.cost.activiti.costrequest.entity.TBActivitiCostRequestEntity;
- import cn.com.lzt.cost.activiti.payinneruser.entity.TBActivitiCostPayInnerUserDetailEntity;
- import cn.com.lzt.cost.activiti.tmpcompany.entity.TBActivitiCostPayTmpCompanyEntity;
- import cn.com.lzt.cost.type.entity.TBCostTypeEntity;
- import cn.com.lzt.duties.entity.DutiesEntity;
- import cn.com.lzt.holiday.entity.HolidayEntity;
- import cn.com.lzt.message.send.entity.MMessageEntity;
- import cn.com.lzt.personnelbasearchivesmanage.entity.PersonnelBaseArchivesManageEntity;
- import cn.com.lzt.useractiviti.appoint.entity.TBActivitiUserAppointEntity;
- import cn.com.lzt.useractiviti.data.dao.UseractivitiDataDao;
- import cn.com.lzt.useractiviti.data.service.UseractivitiDataServiceI;
- import cn.com.lzt.useractiviti.entity.TBusActivitiUserPersonnelEntity;
- import cn.com.lzt.useractiviti.leave.entity.TBusActivitiLeaveEntity;
- import cn.com.lzt.useractiviti.sameleveltransfer.entity.TBusActivitiSamelevelTransferEntity;
- import org.apache.commons.lang3.StringUtils;
- import org.jeecgframework.core.common.exception.BusinessException;
- import org.jeecgframework.core.constant.Globals;
- import org.jeecgframework.core.util.ApplicationContextUtil;
- import org.jeecgframework.web.system.pojo.base.*;
- import org.jeecgframework.web.system.service.SystemService;
- import org.jeecgframework.web.system.service.UserService;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * cn.com.lzt.common.util.FlowconditionUtil
- * @author Administrator
- *
- */
- public class FlowconditionUtil {
-
- private static List<String> list = null;
-
- /**
- * 判断id员工是一线员工还是管理处员工
- * 1.管理处
- * 0.一线员工
- * @param tableName
- * @param id
- * @return
- */
- public static String isManagerType(String tableName,String id) {
- String managerType = "";
- if(StringUtils.isNotEmpty(id)){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- PersonnelBaseArchivesManageEntity personnerl = systemService.findUniqueByProperty(PersonnelBaseArchivesManageEntity.class, "userid", id);
- if(personnerl != null){
- if("2".equals(personnerl.getManagerType())){
- managerType = "1";
- }else{
- managerType = "0";
- }
- }
- }else{
- throw new BusinessException("传入的参数有问题,请联系管理员");
- }
- return managerType;
- }
- public static String isManagerType(String tableName,String userid,String id) {
- String managerType = "";
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- Map<String,Object> map = systemService.findOneForJdbc(String.format("select manager_type from %s where id='%s'",tableName,id));
- if(map!=null){
- String dbManagerType = (String) map.get("manager_type");
- if(StringUtils.equals(dbManagerType, "2")){
- managerType = "1";
- }else {
- managerType = "0";
- }
- }else{
- throw new BusinessException("传入的参数有问题,请联系管理员");
- }
- return managerType;
- }
-
-
- /**
- * 计算休假时间(天)
- * @param tableName
- * @param id
- * @return
- * @throws ParseException
- */
- public static Integer countDay(String tableName,String id) throws ParseException {
- Integer count = 0;
- if("t_bus_holiday".equals(tableName) && StringUtils.isNotEmpty(id)){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- HolidayEntity holiday = systemService.get(HolidayEntity.class,id);
- if(holiday != null){
-
- count = daysBetween(holiday.getHolidayStime(), holiday.getHolidayEtime());
-
- /*Calendar calendar = Calendar.getInstance();
- calendar.setTime(holiday.getHolidayStime());
-
- Calendar calendar1 = Calendar.getInstance();
- calendar.setTime(holiday.getHolidayEtime());
- count = DateUtils.dateDiff('y', calendar1, calendar);*/
- }
- }else{
- throw new BusinessException("传入的参数有问题,请联系管理员");
- }
- return count;
- }
-
-
- /**
- * 计算两个日期之间相差的天数
- * @param smdate 较小的时间
- * @param bdate 较大的时间
- * @return 相差天数
- * @throws ParseException
- * @throws java.text.ParseException
- */
- public static int daysBetween(Date smdate,Date bdate) throws ParseException
- {
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
- smdate=sdf.parse(sdf.format(smdate));
- bdate=sdf.parse(sdf.format(bdate));
- Calendar cal = Calendar.getInstance();
- cal.setTime(smdate);
- long time1 = cal.getTimeInMillis();
- cal.setTime(bdate);
- long time2 = cal.getTimeInMillis();
- long between_days=(time2-time1)/(1000*3600*24);
-
- return Integer.parseInt(String.valueOf(between_days));
- }
-
-
- /**
- * 判断角色等级是否是项目经理以上级别
- * @param tableName
- * @param id
- * @return
- */
- public static boolean istimeup(String tableName,String id){
- boolean temp = false;
- if("t_bus_correction".equals(tableName) && StringUtils.isNotEmpty(id)){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- PersonnelBaseArchivesManageEntity per = systemService.findUniqueByProperty(PersonnelBaseArchivesManageEntity.class, "userid",id);
- if(per != null && StringUtils.isNotEmpty(per.getManagerType())){
- if("0".equals(per.getManagerType())){
- temp = true;
- }
- }else{
- throw new BusinessException("被申请人不能确认是管理层员工,请联系管理员");
- }
- }else{
- throw new BusinessException("传入的参数有问题,请联系管理员");
- }
- return temp;
- }
-
- /**
- * 判断该员工是属于什么项目
- * @param id
- * @return
- */
- @SuppressWarnings("unchecked")
- public static String isRank(String id){
- String rank = "";
- if(StringUtils.isNotEmpty(id)){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- PersonnelBaseArchivesManageEntity per = systemService.findUniqueByProperty(PersonnelBaseArchivesManageEntity.class, "userid",id);
- TSBaseUser tsBaseUser = systemService.get(TSBaseUser.class, id);
- if(tsBaseUser != null){
- //查看申请人是否为区域经理,如果为区域经理则走职能部门角色
- List<TSRoleUser> roleList = systemService.getSession().createSQLQuery("select * from t_s_role_user where userid = '"+tsBaseUser.getId()+"'").addEntity(TSRoleUser.class).list();
- boolean temp = false;
- if(!roleList.isEmpty()){
- String [] roleStrings = new String[10];
- for (int i = 0; i < roleList.size(); i++) {
- TSRole tsRole = roleList.get(i).getTSRole();
- roleStrings[i] = tsRole.getRoleCode();
- }
- temp = Arrays.asList(roleStrings).contains(Globals.POSITION_TYPE_RE.toString());
- }
- if(temp){
- rank="5";//职能部门
- }else{
- List<TSUserOrg> orgList = systemService.getSession().createSQLQuery("select * from t_s_user_org where user_id = '"+tsBaseUser.getId()+"' and ifpluralism = 0 and status = 0").addEntity(TSUserOrg.class).list();
- if(orgList != null){
- TSDepart tsDepart = orgList.get(0).getTsDepart();
- list = selectById(tsDepart.getId());
- if(!list.isEmpty() && list.size() > 0){
- if(list.get(0).equals(Globals.org_type_5)){
- if(Globals.MANAGETYPE_2.toString().equals(per.getManagerType())){
- rank = "1";//直属项目一线员工
- }else{
- rank = "2";//直属项目管理处员工
- }
- }else{
- if(Globals.MANAGETYPE_2.toString().equals(per.getManagerType())){
- rank = "3";//区域项目一线员工
- }else{
- rank = "4";//区域项目管理处员工
- }
- }
- }else{
- if(Globals.MANAGETYPE_0.toString().equals(per.getManagerType())){
- rank = "5";//职能部门管理员工
- }else{
- rank = "6";//职能部门管理员工
- }
- }
- }
- }
- }
- }else{
- throw new BusinessException("传入的参数有问题,请联系管理员");
- }
- return rank;
- }
-
- /**
- * 递归调用
- * @param id
- * @return
- */
- private static List<String> selectById(String id){
- list = new ArrayList<String>();
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- TSDepart tsDepart = systemService.getEntity(TSDepart.class,id);
- if(Globals.org_type_3.equals(tsDepart.getOrgType())){
- list.add(Globals.org_type_3);
- }else if(Globals.org_type_4.equals(tsDepart.getOrgType())){
- list.add(Globals.org_type_3);
- }else if(Globals.org_type_5.equals(tsDepart.getOrgType())){
- list.add(Globals.org_type_5);
- }else{
- if(tsDepart.getTSPDepart() != null){
- selectById(tsDepart.getTSPDepart().getId());
- }
- }
- return list;
- }
-
- @SuppressWarnings("unchecked")
- public static String isorgType(String id){
- String rank = "";
- if(StringUtils.isNotEmpty(id)){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- TSBaseUser tsBaseUser = systemService.get(TSBaseUser.class, id);
- if(tsBaseUser != null){
- //查看申请人是否为区域经理,如果为区域经理则走职能部门角色
- List<TSRoleUser> roleList = systemService.getSession().createSQLQuery("select * from t_s_role_user where userid = '"+tsBaseUser.getId()+"'").addEntity(TSRoleUser.class).list();
- boolean temp = false;
- if(!roleList.isEmpty()){
- String [] roleStrings = new String[10];
- for (int i = 0; i < roleList.size(); i++) {
- TSRole tsRole = roleList.get(i).getTSRole();
- roleStrings[i] = tsRole.getRoleCode();
- }
- temp = Arrays.asList(roleStrings).contains(Globals.POSITION_TYPE_RE.toString());
- }
- if(temp){
- rank="3";//职能部门
- }else{
- List<TSUserOrg> orgList = systemService.getSession().createSQLQuery("select * from t_s_user_org where user_id = '"+tsBaseUser.getId()+"' and ifpluralism = 0 and status = 0").addEntity(TSUserOrg.class).list();
- if(orgList != null){
- TSDepart tsDepart = orgList.get(0).getTsDepart();
- list = selectById(tsDepart.getId());
- if(!list.isEmpty() && list.size() > 0){
- if(list.get(0).equals(Globals.org_type_5)){
- rank="1";//直属项目
- }else{
- rank="2";//区域项目
- }
- }else{
- rank="3";//职能部门
- }
- }
- }
- }
- }else{
- throw new BusinessException("传入的参数有问题,请联系管理员");
- }
- return rank;
- }
-
- /**
- * 判断该人员是否是项目经理或区域经理助理
- * @param tableName
- * @param id
- * @return
- */
- public static boolean isRegion(String tableName,String id){
- boolean temp = false;
- if("t_bus_correction".equals(tableName) && StringUtils.isNotEmpty(id)){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- TSBaseUser tsBaseUser = systemService.get(TSBaseUser.class, id);
- //PersonnelBaseArchivesManageEntity per = systemService.findUniqueByProperty(PersonnelBaseArchivesManageEntity.class, "userid",id);
- List<TSRoleUser> tsList = systemService.findByProperty(TSRoleUser.class, "TSUser.id", tsBaseUser.getId());
- if(!tsList.isEmpty()){
- String [] reg = {"P_XMJL","P_QYZL"};
- for (TSRoleUser t : tsList) {
- TSRole role = t.getTSRole();
- if(Arrays.asList(reg).contains(role.getRoleCode())){
- temp = true;
- break;
- }
- }
- }
- }
- return temp;
- }
- /**
- *项目人员类型
- * 1 项目人员
- * 0 职能部门人员
- * @return
- */
- public static int projectUserType(String table,String id){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- Map<String,Object> map = systemService.findOneForJdbc("select * from "+table+" where id = ?" , id);
- String createBy = (String) map.get("create_by");
- TSUser user = systemService.findUniqueByProperty(TSUser.class,"userName" , createBy);
- boolean projectUser = UserUtil.isProjectUser(user.getId());
- if(projectUser){
- return 1;
- }
- return 0;
- }
- /**
- * 是否包含某一角色code
- *
- */
- public static boolean isContainRoleCode(String userid,String roleCode){
- if(StringUtils.isBlank(userid)){
- return false;
- }
- if(StringUtils.isBlank(roleCode)){
- return false;
- }
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- List<TSRoleUser> reRoleUsers = systemService.findByProperty(TSRoleUser.class, "TSUser.id", userid);
- boolean flag = false;
- for(TSRoleUser roleUser : reRoleUsers){
- String code = roleUser.getTSRole().getRoleCode();
- if(StringUtils.equals(code, roleCode)){
- flag=true;
- break;
- }
- }
- return flag;
- }
- /**
- * 一线员工分类
- * 0 项目经理
- * 1 内勤
- * 2 一线员工
- * @param userid
- * @return
- */
- public static int normalUserType(String userid){
- boolean type = isContainRoleCode(userid,Globals.POSITION_TYPE_PRO);
- if(type){
- return 0;
- }
- type = isContainRoleCode(userid,Globals.POSITION_TYPE_NQ);
- if(type){
- return 1;
- }
- return 2;
- }
- /**
- * 离职类型
- * @return 0 辞退 1主动离职
- *
- */
- public static int leaveType(String table,String id){
- if(StringUtils.equals(table,"t_bus_activiti_leave" )){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- TBusActivitiLeaveEntity leaveEntity = systemService.getEntity(TBusActivitiLeaveEntity.class, id);
- String leaveType =leaveEntity.getLeaveType();
- if(StringUtils.equals(leaveType,"citui" )){
- return 0;
- }
- return 1;
- }
- return -1;
- }
- /**
- * 是否包含工程物料
- * 采购申请专用
- * */
- public static String hasGongchengGoods(String id) {
- String hasGongcheng = "";
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- Map<String,Object> map = systemService.findOneForJdbc("select count(*) as count "
- + " from t_b_order_products products "
- + " left join t_b_goods_info goods on goods.id = products.goods_id where left(category_code,7) = 'rootA01' and fk_id = ?",id);
- if(map!=null){
- String count = map.get("count").toString();
- if(StringUtils.equals(count, "0")){
- hasGongcheng = "0";
- }else {
- hasGongcheng = "1";
- }
- }else{
- throw new BusinessException("传入的参数有问题,请联系管理员");
- }
- return hasGongcheng;
- }
- /**
- * 职务类型
- * @param table
- * @param id
- * @return
- * 1 一线员工
- * 2部门专员
- * 3项目主管及以上
- * 4部门经理和项目经理
- */
- public static int deutiesType(String table,String id){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- String dutiesId = null;
- if(StringUtils.equals("t_bus_activiti_user_personnel",table)) {//入职审批
- TBusActivitiUserPersonnelEntity entity =systemService.getEntity(TBusActivitiUserPersonnelEntity.class, id);
- dutiesId = entity.getDuty();
- }else if(StringUtils.equals("t_b_activiti_user_appoint",table)){//任免签报
- TBActivitiUserAppointEntity entity = systemService.getEntity(TBActivitiUserAppointEntity.class, id);
- String type = entity.getType();
- if(StringUtils.equals(type,"demotion")){//降职根据当前职务
- dutiesId=entity.getOldDutyId();
- }else {
- dutiesId = entity.getNewDutyId();
- }
- if(StringUtils.isBlank(dutiesId)){//辞退没有new_duty_id
- dutiesId = entity.getOldDutyId();
- }
- }else {
- Map<String,Object> map = systemService.findOneForJdbc("select * from "+table+" where id = ?" , id);
- String userId = (String) map.get("userid");
- PersonnelBaseArchivesManageEntity per = systemService.findUniqueByProperty(PersonnelBaseArchivesManageEntity.class, "userid",userId);
- dutiesId = per.getBelongDutiesid();
- }
- int type = UserUtil.getDutyType(dutiesId);
- return type;
- }
- /**
- * 是否超过编制
- * @return
- */
- public static boolean isOverNeedNum(String table,String id){
- UseractivitiDataServiceI useractivitiDataService = ApplicationContextUtil.getContext().getBean(UseractivitiDataServiceI.class);
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- UseractivitiDataDao dataDao = ApplicationContextUtil.getContext().getBean(UseractivitiDataDao.class);
- String depId = null;
- String postId = null;
- if(StringUtils.equals("t_bus_activiti_user_personnel",table)) {//入职审批
- TBusActivitiUserPersonnelEntity entity =systemService.getEntity(TBusActivitiUserPersonnelEntity.class, id);
- depId = entity.getDepartId();
- String dutiesId = entity.getDuty();
- DutiesEntity duties = systemService.getEntity(DutiesEntity.class,dutiesId );
- postId = duties.getPost();
- }else if(StringUtils.equals("t_bus_activiti_samelevel_transfer",table)){//平调
- TBusActivitiSamelevelTransferEntity entity = systemService.getEntity(TBusActivitiSamelevelTransferEntity.class, id);
- postId = entity.getNewPostid();
- depId = entity.getInUnitPid();
- } else{
- Map<String,Object> map = systemService.findOneForJdbc("select * from "+table+" where id = ?" , id);
- String userId = (String) map.get("userid");
- PersonnelBaseArchivesManageEntity per = systemService.findUniqueByProperty(PersonnelBaseArchivesManageEntity.class, "userid",userId);
- TSDepart depart = dataDao.getUserDep(userId);
- depId = depart.getId();
- postId = per.getInPostid();
- }
- depId =UserUtil.getQueryDepIdByDepId(depId);
- int needNum = useractivitiDataService.getPostNeedNum(depId,postId);
- int userNum = dataDao.getParentDepartPostUserCount(depId,postId );
- return userNum>=needNum;
- }
- //获得调休时长
- public double getExchangeDays(String id){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- String sql = "select max(exchange_time) exchange_time from t_bus_activiti_exchange_detail where 1 = 1 AND eXCHANGE_ID =? ";
- Map<String,Object> map = systemService.findOneForJdbc(sql,id);
- double exchangeTime = (double) map.get("exchange_time");
- return exchangeTime/8;
- }
- /**
- * 判断组织机构类型
- *
- * @param table
- * @param id
- * @see DepartUtil.DepartType
- * @return 1项目 2职能部门
- *
- */
- public int departType(String table,String id){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- Map<String,Object> map = systemService.findOneForJdbc("select * from "+table+" where id = ?" , id);
- String departId = (String) map.get("depart_id");
- if(StringUtils.isBlank(departId)){
- String userid = (String) map.get("userid");
- if(StringUtils.isNotBlank(userid)) {
- UseractivitiDataDao dataDao = ApplicationContextUtil.getContext().getBean(UseractivitiDataDao.class);
- departId = dataDao.getUserDep(userid).getId();
- }
- }
- DepartUtil.DepartType departType = DepartUtil.departType(departId);
- return departType.getTypeCode();
- }
- /**
- * 是否超过申请金额
- * @param table
- * @param id
- * @return
- */
- public boolean isOverRequestMoney(String table,String id){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- if(StringUtils.equals(table,"t_b_activiti_cost_pay_tmp_company")){//临时付款
- TBActivitiCostPayTmpCompanyEntity entity = systemService.getEntity(TBActivitiCostPayTmpCompanyEntity.class,id);
- if(entity.getExpectMoney().compareTo(entity.getPayMoney())<0){
- return true;
- }
- }else if(StringUtils.equals(table,"t_b_activiti_cost_pay_inner_user")){//费用报销
- List<TBActivitiCostPayInnerUserDetailEntity> detailEntityList = systemService.findByProperty(TBActivitiCostPayInnerUserDetailEntity.class,"costPayInnerUserId",id);
- for(TBActivitiCostPayInnerUserDetailEntity detailEntity:detailEntityList){
- if(detailEntity.getExpectMoney().compareTo(detailEntity.getPayMoney())<0){
- return true;
- }
- }
- }
- return false;
- }
- //返回 费用报销或公对公报销【费用类型】的【审批分类】
- public String getCostRequestExamineType(String table,String id){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- if(StringUtils.equals(table,"t_b_activiti_cost_request" )){//费用申请
- TBActivitiCostRequestEntity entity =systemService.getEntity(TBActivitiCostRequestEntity.class, id);
- String costId = entity.getCostType();
- TBCostTypeEntity typeEntity = systemService.getEntity(TBCostTypeEntity.class, costId);
- return typeEntity.getExamineType();
- }
- return null;
- }
- //返回 费用类型信息
- public String getCostRequestInfo(String table,String id,String column){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- if(StringUtils.equals(table,"t_b_activiti_cost_request" )){//费用申请
- TBActivitiCostRequestEntity entity =systemService.getEntity(TBActivitiCostRequestEntity.class, id);
- String costId = entity.getCostType();
- TBCostTypeEntity typeEntity = systemService.getEntity(TBCostTypeEntity.class, costId);
- if(StringUtils.equals(column,"pre_proc")) return typeEntity.getPreProc();
- }
- return null;
- }
- /**
- *
- * @return 返回费用申请中费用类型名称
- */
- public String getCostRequestTypeName(String table,String id){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- if(StringUtils.equals(table,"t_b_activiti_cost_request" )){//费用申请
- TBActivitiCostRequestEntity entity =systemService.getEntity(TBActivitiCostRequestEntity.class, id);
- String costId = entity.getCostType();
- TBCostTypeEntity typeEntity = systemService.getEntity(TBCostTypeEntity.class, costId);
- return typeEntity.getName();
- }
- return null;
- }
- /**
- * 返回消息审批的消息类型
- * @param table
- * @param id
- * @return 会议通知:meeting,其他通知:other,红头文件:red
- */
- public String getMessageNoticeType(String table,String id){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- if(StringUtils.equals(table,"m_message" )){//消息审批
- MMessageEntity entity =systemService.getEntity(MMessageEntity.class, id);
- return entity.getNoticeType();
- }
- return null;
- }
- /**
- * 是否人事部门申请
- * @param table
- * @param id
- * @param checkType 1 制单人,2表单用户
- * @return
- */
- public boolean isHr(String table,String id,int checkType){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- Map<String,Object> map = systemService.findOneForJdbc("select * from "+table+" where id = ?" , id);
- String userId=null;
- if(checkType==1){
- UserService userService = ApplicationContextUtil.getContext().getBean(UserService.class);
- String createBy = (String) map.get("create_by");
- List<TSUser> userList = systemService.findHql("from TSUser where userName=? and deleteFlag=0 ",createBy);
- TSUser user = userList.get(0);
- userId = user.getId();
- }else if(checkType==2) {
- userId = (String) map.get("userid");
- }
- return UserUtil.isHr(userId);
- }
- /**
- * 休假用户类型
- * @param table
- * @param id
- * @return
- * 1 一线人员
- * 2 部门专员
- * 3 部门经理
- * 4 项目经理
- * -1 未知
- */
- public int holidayUserType(String table,String id){
- SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
- Map<String,Object> map = systemService.findOneForJdbc("select * from "+table+" where id = ?" , id);
- String userId = (String) map.get("userid");
- PersonnelBaseArchivesManageEntity per = systemService.findUniqueByProperty(PersonnelBaseArchivesManageEntity.class, "userid",userId);
- String dutiesId = per.getBelongDutiesid();
- int type = UserUtil.getDutyType(dutiesId);
- if(type==1||type==3){
- return 1;
- }else if(type==2){
- return 2;
- }else if(type==4){//部门经理、项目经理
- UserService userService = ApplicationContextUtil.getContext().getBean(UserService.class);
- TSUser user = systemService.getEntity(TSUser.class,userId);
- String userRoleCode = userService.getUserRole(user);
- for(String roleCode :Globals.POSITION_TYPE_SECTION){
- if(userRoleCode.contains(roleCode)){
- return 3;
- }
- }
- if(userRoleCode.contains(Globals.POSITION_TYPE_PRO)){
- return 4;
- }
- }
- return -1;
- }
- }
|