dangsn
2024-06-11 dba1e53cd7652f1b973ffec118e5b3312278c814
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java
@@ -3,10 +3,12 @@
import com.vci.client.common.providers.ServiceProvider;
import com.vci.common.util.ThreeDES;
import com.vci.corba.common.PLException;
import com.vci.corba.framework.data.UserInfo;
import com.vci.frameworkcore.compatibility.SmUserQueryServiceI;
import com.vci.frameworkcore.pagemodel.SmPasswordStrategyVO;
import com.vci.frameworkcore.pagemodel.SmUserVO;
import com.vci.starter.web.enumpck.BooleanEnum;
import com.vci.starter.web.enumpck.UserSecretEnum;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.starter.web.pagemodel.PageHelper;
@@ -14,7 +16,9 @@
import com.vci.starter.web.pagemodel.TreeQueryObject;
import com.vci.starter.web.util.BeanUtil;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.starter.web.util.VciDateUtil;
import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
import com.vci.web.enumpck.UserTypeEnum;
import com.vci.web.model.SmPasswordStrategyDO;
import com.vci.web.model.SmUserDO;
import com.vci.web.service.WebBoServiceI;
@@ -22,7 +26,6 @@
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -80,13 +83,6 @@
   public static final String QUERY_FIELD_ROLE = "roleUser.plroleuid";
   /**
    * 自引用
    */
   @Autowired(required = false)
   @Lazy
   private SmUserQueryServiceI self;
   /**
     *  根据用户名获取用户的对象,不区分大小写
     * @param userId 用户名
     * @return 用户的显示对象,如果用户不存在则返回null,不会抛出异常
@@ -95,7 +91,41 @@
   @Override
   public SmUserVO getUserByUserId(String userId) throws VciBaseException {
      WebUtil.alertNotNull(userId,"用户名");
      return getUserByField("plusername",userId);
        try {
            UserInfo userInfo = platformClientUtil.getFrameworkService().getUserObjectByUserName(userId);
         return userInfo2VO(userInfo);
        } catch (PLException e) {
            throw new VciBaseException("登录时,获取用户信息失败:"+e.getMessage());
        }
   }
   /**
    * 业务数据转换为显示对象
    * @param userInfo 平台返回的业务数据
    * @return 用户显示对象
    */
   private SmUserVO userInfo2VO(UserInfo userInfo) {
      SmUserVO smUserVO = new SmUserVO();
      smUserVO.setOid(userInfo.id);
      smUserVO.setId(userInfo.userName);
      smUserVO.setName(userInfo.trueName);
      smUserVO.setSecretGrade(userInfo.secretGrade);
      smUserVO.setSecretGradeText(UserSecretEnum.getSecretText(smUserVO.getSecretGrade()));
      smUserVO.setUserType(String.valueOf(userInfo.userType));
      smUserVO.setUserTypeText(UserTypeEnum.getTextByValue(smUserVO.getUserType()));
      smUserVO.setDescription(userInfo.desc);
      smUserVO.setEmail(userInfo.email);
      if(userInfo.status == 0){
         smUserVO.setLockFlag(false);
      }else{
         smUserVO.setLockFlag(true);
      }
      smUserVO.setCreator(userInfo.createUser);
      smUserVO.setCreateTime(VciDateUtil.long2Date(userInfo.createTime));
      smUserVO.setLastModifier(userInfo.updateUser);
      smUserVO.setLastLoginTime(VciDateUtil.long2Date(userInfo.updateTime));
      smUserVO.setLastModifyPasswordTime(VciDateUtil.long2Date(userInfo.pwdUpdateTime));
      return smUserVO;
   }
   /**
@@ -166,7 +196,12 @@
   @Override
   public List<SmUserVO> listUserByUserIds(Collection<String> userIdCollections)throws VciBaseException {
      WebUtil.alertNotNull(userIdCollections,"用户名集合");
      return listUserByField("plusername",userIdCollections);
      try {
         UserInfo[] userInfo = platformClientUtil.getFrameworkService().fetchUserInfoByNames(VciBaseUtil.collection2StrArr(userIdCollections));
         return userInfoArr2VO(userInfo);
      } catch (PLException e) {
         throw new VciBaseException("获取用户失败:"+e.getMessage());
      }
   }
   /**
     * 根据用户主键获取用户的信息
@@ -177,7 +212,12 @@
   @Override
   public SmUserVO getUserByUserOid(String userOid) throws VciBaseException {
      WebUtil.alertNotNull(userOid,"用户主键");
      return getUserByField("pluid",userOid);
        try {
            UserInfo userInfo = platformClientUtil.getFrameworkService().getUserObjectByoid(userOid);
         return userInfo2VO(userInfo);
        } catch (PLException e) {
            throw new VciBaseException("获取用户失败:"+e.getMessage());
        }
   }
    /**
     * 批量获取用户的信息 (根据用户主键)
@@ -189,7 +229,25 @@
   public List<SmUserVO> listUserByUserOids(
         Collection<String> userOidCollections) throws VciBaseException {
      WebUtil.alertNotNull(userOidCollections,"用户主键集合");
      return listUserByField("pluid",userOidCollections);
        try {
            UserInfo[] userInfoArr = platformClientUtil.getFrameworkService().getUserObjectByoids(VciBaseUtil.collection2StrArr(userOidCollections));
         return userInfoArr2VO(userInfoArr);
        } catch (PLException e) {
            throw new VciBaseException("获取用户信息失败:"+e.getMessage());
        }
   }
   /**
    * 业务数据数组转显示对象集合
    * @param userInfoArr 业务数据数组
    * @return 显示对象集合
    */
   private List<SmUserVO> userInfoArr2VO(UserInfo[] userInfoArr) {
      List<SmUserVO> userVOList = new ArrayList<>();
      for(UserInfo userInfo : userInfoArr){
         userVOList.add(userInfo2VO(userInfo));
      }
      return userVOList;
   }
   /**
@@ -351,7 +409,7 @@
     */
   @Override
   public String getUserNameByUserId(String userId) {
      SmUserVO userVO = self.getUserByUserId(userId);
      SmUserVO userVO = getUserByUserId(userId);
      return userVO == null?"":userVO.getName();
   }
    /**
@@ -361,7 +419,7 @@
     */
   @Override
   public String getUserNameByUserOid(String userOid) {
      SmUserVO userVO = self.getUserByUserOid(userOid);
      SmUserVO userVO = getUserByUserOid(userOid);
      return userVO.getName();
   }