xiejun
2024-09-04 ac3f3629a261770f573f27e5e23f7ec19d096c2a
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebLoServiceImpl.java
@@ -2,18 +2,16 @@
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.vci.client.bof.BOFactoryClient;
import com.vci.client.bof.ClientBusinessObject;
import com.vci.client.bof.ClientLinkObject;
import com.vci.client.bof.ClientLinkObjectOperation;
import com.vci.client.common.oq.OQTool;
import com.vci.common.qt.object.*;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.common.PLException;
import com.vci.corba.omd.data.AttributeValue;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.corba.omd.data.LinkObject;
import com.vci.corba.query.ObjectQueryService;
import com.vci.corba.query.data.BOAndLO;
import com.vci.omd.utils.ObjectTool;
import com.vci.starter.web.constant.QueryOptionConstant;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.DataGrid;
@@ -55,10 +53,6 @@
    */
   private Logger logger = LoggerFactory.getLogger(getClass());
   /**
    * LO操作类
    */
   private ClientLinkObjectOperation loOperation = new ClientLinkObjectOperation();
   @Autowired
   private WebBoServiceI boService;
@@ -95,32 +89,28 @@
      LO_BASE_FIELD_MAP.put("linkTypeName","linkTypeName");
   }
   @Override
   public ClientLinkObjectOperation getLoOption() throws VciBaseException {
      return loOperation;
   }
   @Override
   public List<ClientLinkObject> queryCLO(String linkType,
   public List<LinkObject> queryCLO(String linkType,
                                 Map<String, String> conditionMap) throws VciBaseException {
      return queryCLO(linkType, "", 1, conditionMap);
   }
   @Override
   public List<ClientBusinessObject> queryLinkCbo(String linkType,
                                       String toBtmname, Map<String, String> conditionMap)
   public List<BusinessObject> queryLinkCbo(String linkType,
                                  String toBtmname, Map<String, String> conditionMap)
         throws VciBaseException {
      return queryLinkCbo(linkType, toBtmname, 1, conditionMap);
   }
   @Override
   public List<ClientLinkObject> queryCLO(String linkType, String toBtmName,
   public List<LinkObject> queryCLO(String linkType, String toBtmName,
         int level, Map<String, String> conditionMap) throws VciBaseException {
      return queryCLO(linkType, toBtmName, level, false, conditionMap);
   }
   @Override
   public List<ClientLinkObject> queryCLO(String linkType, String toBtmName,
   public List<LinkObject> queryCLO(String linkType, String toBtmName,
         int level, boolean isDirection,Map<String, String> conditionMap) throws VciBaseException {
      return queryCLO(linkType,toBtmName,level,isDirection,conditionMap,new PageHelper(-1));
   }
@@ -135,9 +125,9 @@
    * @param ph 排序和分页,链接一般不建议分页
    */
   @Override
   public List<ClientLinkObject> queryCLO(String linkType, String toBtmName,
   public List<LinkObject> queryCLO(String linkType, String toBtmName,
         int level, boolean isDirection,Map<String, String> conditionMap,PageHelper ph) throws VciBaseException {
      List<ClientLinkObject> rtnOBJs = new ArrayList<ClientLinkObject>();
      List<LinkObject> rtnOBJs = new ArrayList<LinkObject>();
      QueryTemplate qt = new QueryTemplate();
      qt.setId("queryLO");
      qt.setType(QTConstants.TYPE_LINK);
@@ -192,8 +182,8 @@
         LinkObject[] bos = platformClientUtil.getQueryService().findLTObjects(qt.getId(), OQTool.qtTOXMl(qt).asXML());
         if (bos != null && bos.length > 0) {
            for (LinkObject bo : bos) {
               ClientLinkObject clo = new ClientLinkObject();
               clo.setLinkObject(bo);
               LinkObject clo = new LinkObject();
               clo = bo;
               rtnOBJs.add(clo);
            }
@@ -208,17 +198,17 @@
   @Override
   public List<ClientBusinessObject> queryLinkCbo(String linkType,
   public List<BusinessObject> queryLinkCbo(String linkType,
         String toBtmname, int level, Map<String, String> conditionMap)
         throws VciBaseException {
      return queryLinkCbo(linkType, toBtmname, level, false, conditionMap);
   }
   @Override
   public List<ClientBusinessObject> queryLinkCbo(String linkType,
   public List<BusinessObject> queryLinkCbo(String linkType,
         String toBtmName, int level,boolean isDirection, Map<String, String> conditionMap)
         throws VciBaseException {
      List<ClientBusinessObject> rtnOBJs = new ArrayList<ClientBusinessObject>();
      List<BusinessObject> rtnOBJs = new ArrayList<BusinessObject>();
      QueryTemplate qt = new QueryTemplate();
      qt.setId("queryLO");
      qt.setType(QTConstants.TYPE_LINK);
@@ -246,8 +236,8 @@
         BOAndLO[] bos = platformClientUtil.getQueryService().getBOAndLOS(qt.getId(), OQTool.qtTOXMl(qt).asXML(),btmOid);
         if (bos != null && bos.length > 0) {
            for (BOAndLO blo : bos) {
               ClientBusinessObject cbo = new ClientBusinessObject();
               cbo.setBusinessObject(blo.bo);
               BusinessObject cbo = new BusinessObject();
               cbo = blo.bo;
               rtnOBJs.add(cbo);
            }
            return rtnOBJs;
@@ -258,36 +248,36 @@
      }
      return rtnOBJs;
   }
//
//   @Override
//   public Map<String, BusinessObject> queryLinkedCbo(LinkObject[] lo,
//         boolean isDirection) throws VciBaseException {
//        LinkObject[] clos = new LinkObject[lo.length];
//        for(int i =0 ; i < lo.length; i ++){
//           LinkObject clo = new LinkObject();
//           clo = lo[i];
//           clos[i] = clo;
//        }
//        return queryLinkedCbo(clos,isDirection);
//   }
   @Override
   public Map<String, ClientBusinessObject> queryLinkedCbo(LinkObject[] lo,
         boolean isDirection) throws VciBaseException {
        ClientLinkObject[] clos = new ClientLinkObject[lo.length];
        for(int i =0 ; i < lo.length; i ++){
           ClientLinkObject clo = new ClientLinkObject();
           clo.setLinkObject(lo[i]);
           clos[i] = clo;
        }
        return queryLinkedCbo(clos,isDirection);
   }
   @Override
   public Map<String, ClientBusinessObject> queryLinkedCbo(List los,
   public Map<String, BusinessObject> queryLinkedCbo(List los,
         boolean isDirection) throws VciBaseException {
      return queryLinkedCbo(los,isDirection,new ArrayList<String>());
   }
   @Override
   public Map<String, ClientBusinessObject> queryLinkedCbo(List los,
   public Map<String, BusinessObject> queryLinkedCbo(List los,
         boolean isDirection,List<String> queryColumn) throws VciBaseException {
      ClientLinkObject[] clos = new ClientLinkObject[los.size()];
      LinkObject[] clos = new LinkObject[los.size()];
      for(int i = 0 ; i < los.size(); i ++){
         Object o = los.get(i);
         ClientLinkObject clo = new ClientLinkObject();
         LinkObject clo = new LinkObject();
         if(o instanceof LinkObject){
            clo.setLinkObject((LinkObject)o);
         }else if(o instanceof ClientLinkObject){
            clo = (ClientLinkObject)o;
            clo = (LinkObject)o;
         }else if(o instanceof LinkObject){
            clo = (LinkObject)o;
         }
         clos[i] = clo;
      }
@@ -295,31 +285,31 @@
   }
   @Override
   public Map<String, ClientBusinessObject> queryLinkedCbo(
         ClientLinkObject[] clol, boolean isDirection) throws VciBaseException {
   public Map<String, BusinessObject> queryLinkedCbo(
         LinkObject[] clol, boolean isDirection) throws VciBaseException {
      return queryLinkedCbo(clol,isDirection,new ArrayList<String>());
   }
   /*****
    *
    */
   @Override
   public Map<String, ClientBusinessObject> queryLinkedCbo(
         ClientLinkObject[] clol, boolean isDirection,List<String> queryColumn) throws VciBaseException{
   public Map<String, BusinessObject> queryLinkedCbo(
         LinkObject[] clol, boolean isDirection,List<String> queryColumn) throws VciBaseException{
      Map<String/*t_oid或者f_oid*/,String/*oid*/> linkBoOidMap = new HashMap<String, String>();
      Map<String,String> btmTypeOidMap = new HashMap<String, String>();
      for(int i = 0 ; i < clol.length; i ++){
         ClientLinkObject clo = clol[i];
         LinkObject clo = clol[i];
         if(clo!=null){
            String btmType = "";
            String btmOid = "";
            if(isDirection){
               linkBoOidMap.put(clo.getToOid(),clo.getOid());
               btmType = clo.getToBTMName().toLowerCase().trim();
               btmOid = clo.getToOid();
               linkBoOidMap.put(clo.toOid,clo.oid);
               btmType = clo.toBTName.toLowerCase().trim();
               btmOid = clo.toOid;
            }else{
               linkBoOidMap.put(clo.getFromOid(),clo.getOid());
               btmType = clo.getFromBTMName().toLowerCase().trim();
               btmOid = clo.getFromOid();
               linkBoOidMap.put(clo.fromOid,clo.oid);
               btmType = clo.fromBTName.toLowerCase().trim();
               btmOid = clo.fromOid;
            }
            String oids = "";
            if(btmTypeOidMap.containsKey(btmType)){
@@ -329,7 +319,7 @@
            btmTypeOidMap.put(btmType, oids);
         }
      }
      Map<String,ClientBusinessObject> linkedCboMap = new HashMap<>();
      Map<String,BusinessObject> linkedCboMap = new HashMap<>();
      Iterator<String> it = btmTypeOidMap.keySet().iterator();
      while(it.hasNext()){
         String btmType = it.next();
@@ -346,10 +336,10 @@
         }
         Map<String,String> conditionMap = new HashMap<>();
         conditionMap.put("oid",oids);
         List<ClientBusinessObject> allCbo = boService.queryCBO(btmType, conditionMap,new PageHelper(-1),clauseList);
         List<BusinessObject> allCbo = boService.queryCBO(btmType, conditionMap,new PageHelper(-1),clauseList);
         if(allCbo.size()>0){
            for(ClientBusinessObject cbo : allCbo){
               String linkOid = linkBoOidMap.get(cbo.getOid());
            for(BusinessObject cbo : allCbo){
               String linkOid = linkBoOidMap.get(cbo.oid);
               linkedCboMap.put(linkOid, cbo);
            }
         }
@@ -358,24 +348,24 @@
   }
   @Override
   public List<Map> clos2Map(List<ClientLinkObject> clos) throws VciBaseException {
   public List<Map> clos2Map(List<LinkObject> clos) throws VciBaseException {
      List<Map> allMap = new ArrayList<Map>();
      for(ClientLinkObject clo : clos){
      for(LinkObject clo : clos){
         allMap.add(clo2Map(clo));
      }
      return allMap;
   }
   @Override
   public Map clo2Map(ClientLinkObject clo) throws VciBaseException {
   public Map clo2Map(LinkObject clo) throws VciBaseException {
      Map<String,String> map = new HashMap<String, String>();
      WebUtil.copyValueToMapFromClos(clo, map);
      return map;
   }
   @Override
   public List<ClientLinkObject> map2Clos(List<Map> map) throws VciBaseException {
      List<ClientLinkObject> allClo = new ArrayList<ClientLinkObject>();
   public List<LinkObject> map2Clos(List<Map> map) throws VciBaseException {
      List<LinkObject> allClo = new ArrayList<LinkObject>();
      for(Map m : map){
         allClo.add(map2Clo(m));
      }
@@ -383,8 +373,8 @@
   }
   @Override
   public ClientLinkObject map2Clo(Map map) throws VciBaseException {
      ClientLinkObject clo = new ClientLinkObject();
   public LinkObject map2Clo(Map map) throws VciBaseException {
      LinkObject clo = new LinkObject();
      WebUtil.copyValueToCloFromMap(clo, map);
      return clo;
   }
@@ -397,47 +387,47 @@
    * @throws VciBaseException
    */
   @Override
   public List<ClientLinkObject> saveClientLinkObjects(List<ClientLinkObject> clos) throws VciBaseException {
   public List<LinkObject> saveLinkObjects(List<LinkObject> clos) throws VciBaseException {
      if(clos == null || clos.size()  == 0){
         throw new VciBaseException("没有要保存的业务类型数据");
      }
      List<LinkObject> linkObjects = new ArrayList<LinkObject>();
      for(ClientLinkObject clo : clos){
      for(LinkObject clo : clos){
         //需要看看基本的信息是否有
         if(StringUtils.isBlank(clo.getLoName())){
         if(StringUtils.isBlank(clo.ltName)){
            throw new VciBaseException("链接类型的名称为空");
         }
         if(StringUtils.isBlank(clo.getOid())){
            clo.setOid((new ObjectUtility()).getNewObjectID36());
         if(StringUtils.isBlank(clo.oid)){
            clo.oid = (new ObjectUtility()).getNewObjectID36();
         }
         if(StringUtils.isBlank(clo.getCreator())){
            clo.setCreator(WebUtil.getCurrentUserId());
         if(StringUtils.isBlank(clo.creator)){
            clo.creator = WebUtil.getCurrentUserId();
         }
         if(clo.getCreateTime() == 0){
            clo.setCreateTime(VciDateUtil.getNowTime());
         if(clo.createTime == 0){
            clo.createTime = VciDateUtil.getNowTime();
         }
         if(StringUtils.isBlank(clo.getLastModifier())){
            clo.setLastModifier(clo.getCreator());
         if(StringUtils.isBlank(clo.modifier)){
            clo.modifier = clo.creator;
         }
         if(clo.getLastModifyTime() == 0){
            clo.setLastModifyTime(clo.getCreateTime());
         if(clo.modifyTime == 0){
            clo.modifyTime = clo.createTime;
         }
         if(clo.getTs() == 0){
            clo.setTs(clo.getCreateTime());
         if(clo.ts == 0){
            clo.ts = clo.createTime;
         }
         linkObjects.add(clo.getLinkObject());
         linkObjects.add(clo);
      }
      try {
         LinkObject[] savedLinkObject = BOFactoryClient.getBOFactoryService().batchCreateLinkObject(linkObjects.toArray(new LinkObject[0]));
         List<ClientLinkObject> savedClientLinkObject = new ArrayList<ClientLinkObject>();
         LinkObject[] savedLinkObject = platformClientUtil.getBOFactoryService().batchCreateLinkObject(linkObjects.toArray(new LinkObject[0]));
         List<LinkObject> savedListLinkObject = new ArrayList<LinkObject>();
         if(savedLinkObject != null && savedLinkObject.length > 0){
            for(LinkObject linkObject : savedLinkObject){
               ClientLinkObject clo = new ClientLinkObject();
               clo.setLinkObject(linkObject);
               savedClientLinkObject.add(clo);
               LinkObject clo = new LinkObject();
               clo = linkObject;
               savedListLinkObject.add(clo);
            }
         }
         return savedClientLinkObject;
         return savedListLinkObject;
      } catch (PLException vciError) {
         throw WebUtil.getVciBaseException(vciError);
      }
@@ -451,13 +441,11 @@
    * @throws VciBaseException
    */
   @Override
   public ClientLinkObject createClientLinkObject(String loName) throws VciBaseException {
   public LinkObject createLinkObject(String loName) throws VciBaseException {
      WebUtil.alertNotNull(loName,"链接");
      try {
         return loOperation.createLinkObject(loName,WebUtil.getCurrentUserId());
      } catch (PLException vciError) {
         throw WebUtil.getVciBaseException(vciError);
      }
      return null;
      //todo 在平台里面需要传入对象,现在是字符串,需要看平台如何处理
//         return loOperation.createLinkObject(loName,WebUtil.getCurrentUserId());
   }
   /**
@@ -468,9 +456,9 @@
    * @throws VciBaseException
    */
   @Override
   public ClientLinkObject cloneClientLinkObject(ClientLinkObject clo) throws VciBaseException {
      ClientLinkObject newClo = new ClientLinkObject();
      String JSONString = JSONObject.toJSONStringWithDateFormat(clo.getLinkObject(),VciDateUtil.DateTimeMillFormat,SerializerFeature.WriteDateUseDateFormat);
   public LinkObject cloneLinkObject(LinkObject clo) throws VciBaseException {
      LinkObject newClo = new LinkObject();
      String JSONString = JSONObject.toJSONStringWithDateFormat(clo,VciDateUtil.DateTimeMillFormat,SerializerFeature.WriteDateUseDateFormat);
      LinkObject lo = JSONObject.parseObject(JSONString,LinkObject.class);
      if(lo.newAttrValList == null) {
         lo.newAttrValList = new AttributeValue[0];
@@ -478,13 +466,13 @@
      if(lo.hisAttrValList == null) {
         lo.hisAttrValList =  new AttributeValue[0];
      }
      newClo.setLinkObject(lo);
      newClo.setOid((new ObjectUtility()).getNewObjectID36());
      newClo.setCreator(WebUtil.getCurrentUserId());
      newClo.setCreateTime(VciDateUtil.getNowTime());
      newClo.setLastModifier(newClo.getCreator());
      newClo.setLastModifyTime(newClo.getCreateTime());
      newClo.setTs(newClo.getCreateTime());
      newClo = lo;
      newClo.oid = (new ObjectUtility()).getNewObjectID36();
      newClo.creator = WebUtil.getCurrentUserId();
      newClo.createTime = VciDateUtil.getNowTime();
      newClo.modifier = newClo.creator;
      newClo.modifyTime = newClo.createTime;
      newClo.ts = newClo.createTime;
      return  newClo;
   }
@@ -495,10 +483,10 @@
    * @throws VciBaseException
    */
   @Override
   public void deleteClientLinkObjects(List<ClientLinkObject> clos) throws VciBaseException {
   public void deleteLinkObjects(List<LinkObject> clos) throws VciBaseException {
      if(clos!=null){
         try {
            loOperation.batchdDeleteLinkObject(clos.toArray(new ClientLinkObject[0]));
            platformClientUtil.getBOFactoryService().batchDeleteLinkObject(clos.toArray(new LinkObject[0]));
         } catch (PLException vciError) {
            throw  WebUtil.getVciBaseException(vciError);
         }
@@ -511,10 +499,10 @@
    * @throws VciBaseException
    */
   @Override
   public void updateClientLinkObject(List<ClientLinkObject> clos) throws VciBaseException {
   public void updateLinkObject(List<LinkObject> clos) throws VciBaseException {
      if(clos!=null){
         try {
            loOperation.batchUpdateLinkObject(clos.toArray(new ClientLinkObject[0]));
            platformClientUtil.getBOFactoryService().batchUpdateLinkObject(clos.toArray(new LinkObject[0]));
         } catch (PLException vciError) {
            throw  WebUtil.getVciBaseException(vciError);
         }
@@ -709,8 +697,8 @@
         List<String> finalEnumFields = enumFields;
         final Integer[] total = {totalHolder.value};
         Arrays.stream(linkObjects.returnValue).forEach(lo->{
            ClientLinkObject clo = new ClientLinkObject();
            clo.setLinkObject(lo);
            LinkObject clo = new LinkObject();
            clo = lo;
            Map<String, String> map = new HashMap<>();
            boService.queryEnumText(null,clo, finalEnumFields);
            WebUtil.copyValueToMapFromClos(clo,map);
@@ -744,14 +732,14 @@
               //分页不要超过1000
               Map<String,String> boConditionMap =new HashMap<>();
               boConditionMap.put("oid",QueryOptionConstant.IN + "(" + WebUtil.toInSql(oids.toArray(new String[0])) + ")");
               List<ClientBusinessObject> cbos = boService.queryCBO(btm, boConditionMap, null, fromFieldsFix);
               List<BusinessObject> cbos = boService.queryCBO(btm, boConditionMap, null, fromFieldsFix);
               if(!CollectionUtils.isEmpty(cbos)){
                  cbos.stream().forEach(cbo->{
                     dataGrid.getData().forEach(data->{
                        Map<String, String> map = (Map<String, String>) data;
                        if(map.getOrDefault("f_oid","").equals(cbo.getOid())){
                        if(map.getOrDefault("f_oid","").equals(cbo.oid)){
                           fromFieldsFix.stream().forEach(fromField->{
                              map.put("f_oid." + fromField,cbo.getAttributeValue(fromField));
                              map.put("f_oid." + fromField, ObjectTool.getBOAttributeValue(cbo,fromField));
                           });
                        }
                     });
@@ -768,14 +756,14 @@
               //分页不要超过1000
               Map<String,String> boConditionMap =new HashMap<>();
               boConditionMap.put("oid",QueryOptionConstant.IN + "(" + WebUtil.toInSql(oids.toArray(new String[0])) + ")");
               List<ClientBusinessObject> cbos = boService.queryCBO(btm, boConditionMap, null, toFieldsFix);
               List<BusinessObject> cbos = boService.queryCBO(btm, boConditionMap, null, toFieldsFix);
               if(!CollectionUtils.isEmpty(cbos)){
                  cbos.stream().forEach(cbo->{
                     dataGrid.getData().forEach(data->{
                        Map<String, String> map = (Map<String, String>) data;
                        if(map.getOrDefault("t_oid","").equals(cbo.getOid())){
                        if(map.getOrDefault("t_oid","").equals(cbo.oid)){
                           toFieldsFix.stream().forEach(toField->{
                              map.put("t_oid." + toField,cbo.getAttributeValue(toField));
                              map.put("t_oid." + toField,ObjectTool.getBOAttributeValue(cbo,toField));
                           });
                        }
                     });