¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import com.sun.jnlp.ApiDialog; |
| | | import com.vci.client.mw.ClientContextVariable; |
| | | import com.vci.common.utility.ObjectUtility; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.portal.PortalService; |
| | | import com.vci.corba.portal.data.*; |
| | | import com.vci.pagemodel.PLUILayoutCloneVO; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseQueryObject; |
| | | import com.vci.starter.web.pagemodel.DataGrid; |
| | | import com.vci.starter.web.pagemodel.SessionInfo; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.web.util.WebThreadLocalUtil; |
| | | import com.vci.web.service.UIManagerServiceI; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.UITools; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * UIå®ä¹æå¡çé¢ç¸å
³æ¥å£ |
| | | * @author ludc |
| | | * @date 2024/8/28 17:05 |
| | | */ |
| | | @Service |
| | | public class UIManagerServiceImpl implements UIManagerServiceI { |
| | | |
| | | /** |
| | | * å¹³å°çè°ç¨å·¥å
·ç±» |
| | | */ |
| | | @Resource |
| | | private PlatformClientUtil platformClientUtil; |
| | | /** |
| | | * æ¥å¿ |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | /** |
| | | * æåºæ¯è¾å¨ |
| | | */ |
| | | private Comparator<PLUILayout> pageLayoutComparator = new Comparator<PLUILayout>() { |
| | | @Override |
| | | public int compare(PLUILayout o1, PLUILayout o2) { |
| | | return o1.plCode.compareTo(o2.plCode); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * æ ¹æ®ä¸å¡ç±»ååæ¥è¯¢uiä¸ä¸ææ°æ® |
| | | * @param baseQueryObject |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public DataGrid gridUIContextData(BaseQueryObject baseQueryObject) throws PLException { |
| | | VciBaseUtil.alertNotNull(baseQueryObject,"æ¡ä»¶å¯¹è±¡"); |
| | | int page = baseQueryObject.getPage(); |
| | | int limit = baseQueryObject.getLimit(); |
| | | Map<String, String> conditionMap = baseQueryObject.getConditionMap(); |
| | | String btmName = conditionMap.getOrDefault("btmName",""); |
| | | if(Func.isEmpty(conditionMap) || Func.isBlank(btmName)){ |
| | | throw new PLException("500",new String[]{"æªè·åå°ä¸å¡ç±»ååç§°ï¼"}); |
| | | } |
| | | String txtName = conditionMap.getOrDefault("txtName","").trim(); |
| | | String txtCode = conditionMap.getOrDefault("txtCode","").trim(); |
| | | PortalService.GetPLUILayoutsByRelatedTypeAndQueryInfoResult result = platformClientUtil.getUIService() |
| | | .getPLUILayoutsByRelatedTypeAndQueryInfo(btmName, txtName, txtCode, page, limit); |
| | | DataGrid<PLUILayout> dataGrid = new DataGrid<>(); |
| | | int total = (int)result.total; |
| | | dataGrid.setTotal(total); |
| | | dataGrid.setLimit(limit); |
| | | dataGrid.setPage(page); |
| | | PLUILayout[] res = result.returnValue; |
| | | Arrays.sort(res,pageLayoutComparator); |
| | | List<PLUILayout> pluiLayouts = Arrays.asList(res); |
| | | dataGrid.setData(pluiLayouts); |
| | | return dataGrid; |
| | | } |
| | | |
| | | /** |
| | | * ç»ä¸å¡ç±»å䏿·»å uiä¸ä¸æ |
| | | * @param pluiLayout |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public boolean saveUIContextData(PLUILayout pluiLayout) throws VciBaseException { |
| | | try { |
| | | //uiä¸ä¸æå¯¹è±¡æ ¡éª |
| | | canContinue(pluiLayout); |
| | | |
| | | String code = pluiLayout.plCode; |
| | | String name = pluiLayout.plName; |
| | | boolean isExist = nameOrCodeIsExist(pluiLayout, false); |
| | | //æ¯å¦å卿 ¡éª |
| | | if (isExist){ |
| | | throw new VciBaseException("ä¸ä¸æç¼ç æåç§°å·²ç»åå¨ï¼è¯·æ£æ¥ï¼"); |
| | | } |
| | | |
| | | PLUILayout pld = new PLUILayout(); |
| | | pld.plOId = ObjectUtility.getNewObjectID36(); |
| | | pld.plCode = code; |
| | | pld.plName = name; |
| | | pld.plRelatedType = pluiLayout.plRelatedType; |
| | | pld.plDesc = pluiLayout.plDesc; |
| | | SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread(); |
| | | pld.plCreateUser = sessionInfo.getUserId(); |
| | | pld.plModifyUser = sessionInfo.getUserId(); |
| | | //导èªåº |
| | | pld.plIsShowForm = pluiLayout.plIsShowForm; |
| | | //æ§å¶åº |
| | | pld.plIsShowNavigator = pluiLayout.plIsShowNavigator; |
| | | //æä½åº |
| | | pld.plIsShowTab = pluiLayout.plIsShowTab; |
| | | //æ§è¡ä¿å |
| | | return platformClientUtil.getUIService().savePLUILayout(pld); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | throw new VciBaseException(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹uiä¸ä¸æ |
| | | * @param pluiLayout |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public boolean updateUIContextData(PLUILayout pluiLayout) throws VciBaseException { |
| | | this.canContinue(pluiLayout); |
| | | try { |
| | | String code = pluiLayout.plCode; |
| | | String name = pluiLayout.plName; |
| | | boolean isExist = nameOrCodeIsExist(pluiLayout, true); |
| | | if (isExist){ |
| | | throw new VciBaseException("ä¸ä¸æç¼ç æåç§°å·²ç»åå¨ï¼è¯·æ£æ¥ï¼"); |
| | | } |
| | | |
| | | PLUILayout pld = new PLUILayout(); |
| | | pld.plOId = pluiLayout.plOId; |
| | | pld.plCode = code; |
| | | pld.plName = name; |
| | | pld.plRelatedType = pluiLayout.plRelatedType; |
| | | pld.plDesc = pluiLayout.plDesc; |
| | | pld.plCreateUser = pluiLayout.plCreateUser; |
| | | pld.plModifyUser = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | |
| | | //导èªåº |
| | | pld.plIsShowForm = pluiLayout.plIsShowForm; |
| | | //æ§å¶åº |
| | | pld.plIsShowNavigator = pluiLayout.plIsShowNavigator; |
| | | //æä½åº |
| | | pld.plIsShowTab = pluiLayout.plIsShowTab; |
| | | //æ§è¡ä¿®æ¹ |
| | | return platformClientUtil.getUIService().updatePLUILayout(pld); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | throw new VciBaseException(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ä¸»é®åä¸å¡ç±»åoidå é¤uiä¸ä¸ææ°æ® |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean delUIContextData(String[] oids) throws PLException { |
| | | VciBaseUtil.alertNotNull(oids,"å¾
å é¤ç对象å表"); |
| | | //å 餿¹æ³ä¸æå
³èæ°æ®å é¤çæä½é»è¾ |
| | | return platformClientUtil.getUIService().deletePLUILayoutByOidsForCascade(oids); |
| | | } |
| | | |
| | | /** |
| | | * å
éuiä¸ä¸æï¼å
·å¤å
³èæ°æ®çå
éï¼ |
| | | * @param pluiLayoutCloneVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean cloneUiContextData(PLUILayoutCloneVO pluiLayoutCloneVO) throws PLException { |
| | | VciBaseUtil.alertNotNull( |
| | | pluiLayoutCloneVO,"å
éåæ°å¯¹è±¡", |
| | | pluiLayoutCloneVO.getSourcePLUILayout(),"å
éçæºå¯¹è±¡ä¿¡æ¯", |
| | | pluiLayoutCloneVO.getCloneName(),"å
éç对象åç§°", |
| | | pluiLayoutCloneVO.getCloneContextCode(),"å
éç对象ä¸ä¸æç¼ç " |
| | | ); |
| | | PLUILayout pluiLayout = new PLUILayout(); |
| | | PLUILayout sourcePLUILayout = pluiLayoutCloneVO.getSourcePLUILayout(); |
| | | //妿鿩å
éç®æ ï¼åå
éå°éæ©çç±»åä¸ï¼å¦ææ²¡æéæ©å
éç®æ ï¼åå
éå°å½åç±»åä¸ |
| | | if(Func.isBlank(pluiLayoutCloneVO.getCloneTargetOid())){ |
| | | pluiLayout.plRelatedType = sourcePLUILayout.plRelatedType; |
| | | } |
| | | //å
éçåç§°åuiä¸ä¸æç¼å·æ¥é |
| | | String cloneName = pluiLayoutCloneVO.getCloneName(); |
| | | String cloneContextCode = pluiLayoutCloneVO.getCloneContextCode(); |
| | | pluiLayout.plOId = ObjectUtility.getNewObjectID36(); |
| | | pluiLayout.plName = cloneName; |
| | | pluiLayout.plCode = cloneContextCode; |
| | | pluiLayout.plIsShowTab = sourcePLUILayout.plIsShowTab; |
| | | pluiLayout.plIsShowNavigator = sourcePLUILayout.plIsShowNavigator; |
| | | pluiLayout.plIsShowForm = sourcePLUILayout.plIsShowForm; |
| | | pluiLayout.plDesc = sourcePLUILayout.plDesc; |
| | | SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread(); |
| | | pluiLayout.plCreateUser = sessionInfo.getUserId(); |
| | | pluiLayout.plModifyUser = sessionInfo.getUserId(); |
| | | //å
éç®æ ä¸uiåç§°åç¼å·æ¥é |
| | | this.checkCodeName(pluiLayout); |
| | | //1ãå
ä¿åuiä¸ä¸æ |
| | | boolean res = platformClientUtil.getUIService().savePLUILayout(pluiLayout); |
| | | //2ãåèèåèç¹çå
é |
| | | PLTabPage[] pages = platformClientUtil.getUIService().getPLTabPagesByPageDefinationOId(sourcePLUILayout.plOId); //æ§å¶åºèç¹åå
¶åèç¹çå
é |
| | | if(pages == null){ |
| | | return true; |
| | | } |
| | | try { |
| | | for (PLTabPage page : pages) { |
| | | savePlpageLayoutDefinationRelation(page,pluiLayout.plOId); |
| | | } |
| | | return true; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | throw new VciBaseException(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void expUiContextData(String[] oids, HttpServletResponse response) throws PLException, IOException { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * æ§å¶åºèç¹åå
¶åèç¹çå
é |
| | | * @param obj |
| | | */ |
| | | private void savePlpageLayoutDefinationRelation(Object obj,String plUILayoutId) { |
| | | PLTabPage tabPage = (PLTabPage)obj; |
| | | try { |
| | | |
| | | PLPageDefination[] pLPageDefinations = platformClientUtil.getUIService().getPLPageDefinationsByPageContextOId(tabPage.plOId); |
| | | |
| | | tabPage.plOId = ObjectUtility.getNewObjectID36(); |
| | | tabPage.plContextOId = plUILayoutId; |
| | | //add by caill start 2016.8.15 导èªåºãæ§å¶åºãæä½åºå¨æ²¡æåèç¹çæ
åµä¸çå
é |
| | | if(pLPageDefinations.length==0){ |
| | | platformClientUtil.getUIService().savePLTabPage(tabPage); |
| | | } |
| | | //add by caill end |
| | | for(int j=0;j<pLPageDefinations.length;j++){ |
| | | PLPageDefination plPageDef = pLPageDefinations[j]; |
| | | |
| | | platformClientUtil.getUIService().savePLTabPage(tabPage); |
| | | PLTabButton[] pLTabButtons = platformClientUtil.getUIService().getPLTabButtonsByTableOId(plPageDef.plOId); |
| | | |
| | | plPageDef.plOId = ObjectUtility.getNewObjectID36(); |
| | | plPageDef.plTabPageOId = tabPage.plOId; |
| | | platformClientUtil.getUIService().savePLPageDefination(plPageDef); |
| | | |
| | | for(int b=0;b<pLTabButtons.length;b++){ |
| | | PLTabButton plTabButton = pLTabButtons[b]; |
| | | PLCommandParameter[] pLCommandParameters = platformClientUtil.getUIService().getPLCommandParametersByCommandOId(plTabButton.plOId); |
| | | |
| | | plTabButton.plOId = ObjectUtility.getNewObjectID36(); |
| | | plTabButton.plTableOId = plPageDef.plOId; |
| | | platformClientUtil.getUIService().savePLTabButton(plTabButton); |
| | | |
| | | for(int c=0;c<pLCommandParameters.length;c++){ |
| | | final PLCommandParameter plCommandParameter = pLCommandParameters[c]; |
| | | plCommandParameter.plOId = ObjectUtility.getNewObjectID36(); |
| | | plCommandParameter.plCommandOId = plTabButton.plOId; |
| | | platformClientUtil.getUIService().savePLCommandParameter(plCommandParameter); |
| | | } |
| | | } |
| | | } |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æªåå¤ç©ºå¤çï¼è°ç¨å请ä¿è¯objä¸ä¸ºç©º |
| | | * @param obj |
| | | * @throws PLException |
| | | */ |
| | | public void checkCodeName(PLUILayout obj) throws PLException { |
| | | PLUILayout[] plUILayouts = platformClientUtil.getUIService().getPLUILayoutsByRelatedType(obj.plRelatedType); |
| | | int length = plUILayouts.length; |
| | | String code = obj.plCode; |
| | | String name = obj.plName; |
| | | |
| | | if (Func.isNotBlank(name) || Func.isNotBlank(code)){ |
| | | for (int i =0;i<length;i++){//循ç¯èç¹çUI䏿ååç§° |
| | | if (plUILayouts[i].plCode.equalsIgnoreCase(code) || plUILayouts[i].plName.equals(name)){ |
| | | throw new VciBaseException("ä¸å¡ç±»åä¸UIåç§°æUIä¸ä¸æç¼ç å·²åå¨ï¼"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * uiä¸ä¸ææ°å¢ä¿®æ¹åæ£æ¥ |
| | | * @param pluiLayout |
| | | */ |
| | | private void canContinue(PLUILayout pluiLayout){ |
| | | String code = pluiLayout.plCode; |
| | | String name = pluiLayout.plName; |
| | | if(Func.isBlank(code)){ |
| | | throw new VciBaseException("ä¸ä¸æç¼ç ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | if(Func.isBlank(name)){ |
| | | throw new VciBaseException("åç§°ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | if((pluiLayout.plIsShowNavigator == 0) && (pluiLayout.plIsShowForm == 0) && (pluiLayout.plIsShowTab == 0)){ |
| | | throw new VciBaseException("ä¸ä¸æè³å°è¦å
å«ä¸ä¸ªåºåï¼"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥åç§°æè
ç¼ç æ¯å¦å·²åå¨ |
| | | * @param pluiLayout |
| | | * @param isEdit |
| | | * @return |
| | | * @throws VciBaseException |
| | | */ |
| | | private boolean nameOrCodeIsExist(PLUILayout pluiLayout, boolean isEdit) throws PLException { |
| | | boolean res = false; |
| | | //æ¥è¯¢åä¸ä¸å¡ç±»åä¸çuiä¸ä¸æï¼ç¶åæ¥é |
| | | PLUILayout[] plpagelayoutdefinations = platformClientUtil.getUIService().getPLUILayoutsByRelatedType(pluiLayout.plRelatedType); |
| | | int length = plpagelayoutdefinations.length; |
| | | for (int i =0;i<length;i++){ |
| | | String code = plpagelayoutdefinations[i].plCode; |
| | | String name = plpagelayoutdefinations[i].plName; |
| | | String ids = plpagelayoutdefinations[i].plOId; |
| | | if(isEdit){ |
| | | if(!ids.equals(pluiLayout.plOId)){ |
| | | if (pluiLayout.plCode.equalsIgnoreCase(code) || pluiLayout.plName.equals(name)){ |
| | | res = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | else { |
| | | if (code.equalsIgnoreCase(code) || name.equals(name)){ |
| | | res = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | } |