dangsn
2024-06-05 72c7bbd66b8456db7dabf0dbc15f7aa9c2af2b9d
Source/platformProject/vci-platform-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java
@@ -1,10 +1,11 @@
package com.vci.frameworkcore.compatibility.impl;
import com.vci.corba.common.VCIError;
import com.vci.client.common.providers.ServiceProvider;
import com.vci.common.util.ThreeDES;
import com.vci.corba.common.PLException;
import com.vci.frameworkcore.compatibility.SmUserQueryServiceI;
import com.vci.frameworkcore.pagemodel.SmPasswordStrategyVO;
import com.vci.frameworkcore.pagemodel.SmUserVO;
import com.vci.rmip.allcommon.ThreeDES;
import com.vci.starter.web.enumpck.BooleanEnum;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.DataGrid;
@@ -21,20 +22,17 @@
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import plm.bs.bom.clientobject.ClientBusinessObject;
import java.util.*;
import java.util.stream.Collectors;
import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST;
import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE;
import static com.vci.web.constant.CacheNameConstant.VCI_USER;
import static com.vci.web.util.WebUtil.arryAndSqlToClientBusinessObject;
/**
 * 用户的查询相关的服务,可以兼容老平台和老的pdm
@@ -89,7 +87,7 @@
   @Autowired(required = false)
   @Lazy
   private SmUserQueryServiceI self;
   /**
     *  根据用户名获取用户的对象,不区分大小写
     * @param userId 用户名
@@ -121,10 +119,14 @@
            + " left join pluserdept up on " + queryWrapper.getTableNick() + ".pluid = up.pluseruid left join pldept pkDepartment on  up.pldeptuid = pkDepartment.pluid " +
            " left join PLUSERPASSWORDSTRATEGY pkUserPassword on  " +queryWrapper.getTableNick() + ".pluid = pkUserPassword.pluseruid " +
            queryWrapper.getLinkTableSql() + (StringUtils.isNotBlank(queryWrapper.getWhereSql())?(" where " + queryWrapper.getWhereSql()):"");
      List<ClientBusinessObject> dataList = boService.queryBySql(sql + fromSql, null);
      if(!CollectionUtils.isEmpty(dataList)){
         ClientBusinessObject cbo = dataList.get(0);
         return cbo2VO(cbo);
      try{
         String[][] sqlQueryResult = ServiceProvider.getBOFService().getSqlQueryResult(sql + fromSql, null);
         if(sqlQueryResult.length>0){
            com.vci.client.bof.ClientBusinessObject cbo = arryAndSqlToClientBusinessObject(queryWrapper.getSelectFieldSql(),sqlQueryResult[0]);
            return cbo2VO(cbo);
         }
      }catch (Exception e){
         throw new VciBaseException("数据解析错误:" + e );
      }
      return null;
   }
@@ -148,7 +150,7 @@
               + " left join pluserdept up on " + queryWrapper.getTableNick() + ".pluid = up.pluseruid left join pldept pkDepartment on  up.pldeptuid = pkDepartment.pluid " +
               " left join PLUSERPASSWORDSTRATEGY pkUserPassword on  " +queryWrapper.getTableNick() + ".pluid = pkUserPassword.pluseruid " +
               queryWrapper.getLinkTableSql() + (StringUtils.isNotBlank(queryWrapper.getWhereSql())?(" where " + queryWrapper.getWhereSql()):"");
         List<ClientBusinessObject> dataList = boService.queryBySql(sql + fromSql, null);
         List<com.vci.client.bof.ClientBusinessObject> dataList = boService.queryBySql(sql + fromSql, null);
         if(!CollectionUtils.isEmpty(dataList)){
            dataList.stream().forEach(cbo->{
               userVOList.add(cbo2VO(cbo));
@@ -229,7 +231,7 @@
            + " left join pluserdept up on " + queryWrapper.getTableNick() + ".pluid = up.pluseruid left join pldept pkDepartment on  up.pldeptuid = pkDepartment.pluid " +
            " left join PLUSERPASSWORDSTRATEGY pkUserPassword on  " +queryWrapper.getTableNick() + ".pluid = pkUserPassword.pluseruid " + (QUERY_FIELD_ROLE.equalsIgnoreCase(queryField)?roleSql:"") +
            queryWrapper.getLinkTableSql() + (StringUtils.isNotBlank(queryWrapper.getWhereSql())?(" where " + queryWrapper.getWhereSql()):"");
      List<ClientBusinessObject> dataList = boService.queryBySql(sql + fromSql, null);
      List<com.vci.client.bof.ClientBusinessObject> dataList = boService.queryBySql(sql + fromSql, null);
      if(!CollectionUtils.isEmpty(dataList)){
         dataList.stream().forEach(cbo->{
            userVOList.add(cbo2VO(cbo));
@@ -243,7 +245,7 @@
    * @param cbo 业务数据
    * @return 显示对象
    */
   private SmUserVO cbo2VO(ClientBusinessObject cbo){
   private SmUserVO cbo2VO(com.vci.client.bof.ClientBusinessObject cbo){
      SmUserDO userDO = new SmUserDO();
      SmUserVO userVO = new SmUserVO();
      WebUtil.copyValueToObjectFromCbos(cbo,userDO);
@@ -297,7 +299,7 @@
            }
         }
      }
      List<ClientBusinessObject> dataList = boService.queryBySql((isPage?("select " + pageSelectList.stream().collect(Collectors.joining(","))+ " from (select A.*,rownum RN from ( "):"") + sql + fromSql + (isPage?pageSubfix:""), null);
      List<com.vci.client.bof.ClientBusinessObject> dataList = boService.queryBySql((isPage?("select " + pageSelectList.stream().collect(Collectors.joining(","))+ " from (select A.*,rownum RN from ( "):"") + sql + fromSql + (isPage?pageSubfix:""), null);
      if(!CollectionUtils.isEmpty(dataList)){
         dataList.stream().forEach(cbo->{
            userVOList.add(cbo2VO(cbo));
@@ -613,7 +615,7 @@
            + " left join pluserdept up on " + queryWrapper.getTableNick() + ".pluid = up.pluseruid left join pldept pkDepartment on  up.pldeptuid = pkDepartment.pluid " +
            " left join PLUSERPASSWORDSTRATEGY pkUserPassword on  " +queryWrapper.getTableNick() + ".pluid = pkUserPassword.pluseruid " +
            queryWrapper.getLinkTableSql() + (StringUtils.isNotBlank(queryWrapper.getWhereSql())?(" where " + queryWrapper.getWhereSql()):"");
      List<ClientBusinessObject> dataList = boService.queryBySql(sql + fromSql, null);
      List<com.vci.client.bof.ClientBusinessObject> dataList = boService.queryBySql(sql + fromSql, null);
      List<Tree> treeList = new ArrayList<>();
      if(!CollectionUtils.isEmpty(dataList)){
         dataList.stream().forEach(cbo->{
@@ -643,7 +645,7 @@
      String sql = " select plpassword from pluser where pluid = :userOid";
      Map<String,String> conditionMap = new HashMap<>();
      conditionMap.put("userOid",userOid.trim());
      List<ClientBusinessObject> clientBusinessObjectList = boService.queryBySql(sql, conditionMap);
      List<com.vci.client.bof.ClientBusinessObject> clientBusinessObjectList = boService.queryBySql(sql, conditionMap);
      if(CollectionUtils.isEmpty(clientBusinessObjectList)){
         return  false;
      }
@@ -686,7 +688,7 @@
   public SmPasswordStrategyVO getPasswordStrategyVOByOid(String oid){
      VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(null, SmPasswordStrategyDO.class);
      queryWrapperForDO.eq("oid",oid.trim());
      List<ClientBusinessObject> cboList = boService.queryBySql(queryWrapperForDO.getSelectFieldSql() + " from plpasswordstrategy " +
      List<com.vci.client.bof.ClientBusinessObject> cboList = boService.queryBySql(queryWrapperForDO.getSelectFieldSql() + " from plpasswordstrategy " +
            queryWrapperForDO.getTableNick() + queryWrapperForDO.getLinkTableSql() +
            (StringUtils.isBlank(queryWrapperForDO.getWhereSql()) ? "" : (" where " + queryWrapperForDO.getWhereSql())), null);
      if(!CollectionUtils.isEmpty(cboList)){
@@ -748,7 +750,7 @@
      String sql = "update pllogoninfo set plwrongnum = 0 where pluserid in (select pluid from pluser where plusername='" + userId + "')";
      try {
         platformClientUtil.getBOFactoryService().executeUpdateSql(sql);
      } catch (VCIError vciError) {
      } catch (PLException vciError) {
         throw WebUtil.getVciBaseException(vciError);
      }
   }
@@ -771,7 +773,7 @@
      String sql = "update pluser set plpassword = '" + encPassword + "' where pluid = '" + userOid.trim() + "'";
      try {
         platformClientUtil.getBOFactoryService().executeUpdateSql(sql);
      } catch (VCIError vciError) {
      } catch (PLException vciError) {
         throw WebUtil.getVciBaseException(vciError);
      }
   }
@@ -788,7 +790,7 @@
      String sql = "update pllogoninfo set plwrongnum = " + wrongCount +" where pluserid ='" + userOid + "'";
      try {
         platformClientUtil.getBOFactoryService().executeUpdateSql(sql);
      } catch (VCIError vciError) {
      } catch (PLException vciError) {
         throw WebUtil.getVciBaseException(vciError);
      }
   }
@@ -803,7 +805,7 @@
      String sql = "update pllogoninfo set pllogontime = sysdate where pluserid ='" + userOid + "'";
      try {
         platformClientUtil.getBOFactoryService().executeUpdateSql(sql);
      } catch (VCIError vciError) {
      } catch (PLException vciError) {
         throw WebUtil.getVciBaseException(vciError);
      }
   }