| | |
| | | import com.vci.corba.portal.data.*; |
| | | import com.vci.dto.RoleRightDTO; |
| | | import com.vci.dto.UIAuthorDTO; |
| | | import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI; |
| | | import com.vci.model.PLDefination; |
| | | import com.vci.pagemodel.PLDefinationVO; |
| | | import com.vci.pagemodel.PLTabButtonVO; |
| | | import com.vci.pagemodel.PLUILayoutCloneVO; |
| | | import com.vci.pagemodel.RoleRightVO; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.swing.*; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | return plDefinationVOList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加页面定义 |
| | | * @param pdVO |
| | |
| | | */ |
| | | @Override |
| | | public boolean updatePageDefination(PLDefinationVO pdVO) throws Throwable { |
| | | /*PLPageDefination pd = getPageDefination(); |
| | | |
| | | PLDefination d = UITools.getPLDefination(pd.plDefination); |
| | | VciBaseUtil.alertNotNull(pdVO,"页面定义对象",pdVO.getSeq(),"编号",pdVO.getName(),"名称"); |
| | | PLPageDefination pd = new PLPageDefination(); |
| | | PLDefination d = new PLDefination(); |
| | | BeanUtil.copy(pdVO,d); |
| | | |
| | | //不能为空属性检查 |
| | | if(!this.baseInfoIsOk(pd,true)){ |
| | | return false; |
| | | } |
| | | setUIValueToObject(pd, d); |
| | | pd.name = pdVO.getName().trim(); |
| | | pd.seq = Short.valueOf(pdVO.getSeq().trim()); |
| | | pd.desc = pdVO.getDescription(); |
| | | pd.plType = Short.parseShort(pdVO.getTemplateType()); |
| | | |
| | | d.setName(pdVO.getName().trim()); |
| | | d.setUiParser(pdVO.getUiParser().trim()); |
| | | d.setExtAttr(pdVO.getExtAttr().trim()); |
| | | d.setTemplateType(pdVO.getTemplateType()); |
| | | |
| | | this.newPLDefinationIsOk(pdVO, true); |
| | | |
| | |
| | | break; |
| | | } |
| | | |
| | | d = comptPanel.getNewPLDefination(d); |
| | | d = setEventDataToPLDefination(d,pdVO); |
| | | pd.plDefination = UITools.getPLDefinationText(d);*/ |
| | | pd.plDefination = UITools.getPLDefinationText(d); |
| | | |
| | | boolean res = true;//platformClientUtil.getUIService().updatePLPageDefination(pd); |
| | | return platformClientUtil.getUIService().updatePLPageDefination(pd); |
| | | } |
| | | |
| | | /** |
| | | * 删除页面定义 |
| | | * @param oids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean delPageDefination(String[] oids) throws PLException { |
| | | VciBaseUtil.alertNotNull(oids,"删除的页面定义主键"); |
| | | boolean res = platformClientUtil.getUIService().deletePLUILayoutByOidsForCascade(oids); |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * 获取页签区域按钮配置信息 |
| | | * @param pageDefinationOid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PLTabButtonVO> getTabButton(String pageDefinationOid) { |
| | | VciBaseUtil.alertNotNull(pageDefinationOid,"页面定义主键"); |
| | | List<PLTabButton> buttonList = new ArrayList<>(); |
| | | try { |
| | | PLTabButton[] plTabButtons = platformClientUtil.getUIService().getPLTabButtonsByTableOId(pageDefinationOid); |
| | | buttonList = Arrays.asList(plTabButtons); |
| | | return this.tabButton2TabButtonVOS(buttonList); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new VciBaseException("加载页签区域按钮配置信息异常:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 多个按钮配置DO对象转多个VO对象 |
| | | * @param listDO |
| | | * @return |
| | | */ |
| | | private List<PLTabButtonVO> tabButton2TabButtonVOS(List<PLTabButton> listDO){ |
| | | List<PLTabButtonVO> plTabButtonVOList = new ArrayList<PLTabButtonVO>(); |
| | | if(Func.isEmpty(listDO)){ |
| | | return plTabButtonVOList; |
| | | } |
| | | listDO.stream().forEach(item->{ |
| | | try { |
| | | PLTabButtonVO plTabButtonVO = this.tabButton2TabButtonVO(item); |
| | | plTabButtonVOList.add(plTabButtonVO); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String errorLog = "按钮配置DO TO VO时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorLog); |
| | | throw new VciBaseException(errorLog); |
| | | } |
| | | |
| | | }); |
| | | return plTabButtonVOList; |
| | | } |
| | | |
| | | /** |
| | | * 按钮配置DO对象转VO对象 |
| | | * @param tabButtonDO |
| | | * @return |
| | | */ |
| | | private PLTabButtonVO tabButton2TabButtonVO(PLTabButton tabButtonDO) throws PLException { |
| | | PLTabButtonVO plTabButtonVO = new PLTabButtonVO(); |
| | | if(Func.isEmpty(tabButtonDO) && Func.isBlank(tabButtonDO.plOId)){ |
| | | return plTabButtonVO; |
| | | } |
| | | plTabButtonVO.setOId(tabButtonDO.plOId); |
| | | plTabButtonVO.setTableOId(tabButtonDO.plTableOId); |
| | | plTabButtonVO.setPageOId(tabButtonDO.plPageOId); |
| | | plTabButtonVO.setActionOId(tabButtonDO.plActionOId); |
| | | plTabButtonVO.setLabel(tabButtonDO.plLabel); |
| | | plTabButtonVO.setAreaType(tabButtonDO.plAreaType); |
| | | plTabButtonVO.setDesc(tabButtonDO.plDesc); |
| | | plTabButtonVO.setSeq(tabButtonDO.plSeq); |
| | | plTabButtonVO.setCreateUser(tabButtonDO.plCreateUser); |
| | | plTabButtonVO.setCreateTime(tabButtonDO.plCreateTime); |
| | | plTabButtonVO.setModifyUser(tabButtonDO.plModifyUser); |
| | | plTabButtonVO.setModifyTime(tabButtonDO.plModifyTime); |
| | | plTabButtonVO.setLicensOrs(tabButtonDO.plLicensOrs); |
| | | plTabButtonVO.setParentOid(tabButtonDO.plParentOid); |
| | | plTabButtonVO.setDisplayMode(tabButtonDO.displayMode); |
| | | plTabButtonVO.setIconPath(tabButtonDO.iconPath); |
| | | plTabButtonVO.setAuthorization(tabButtonDO.authorization); |
| | | plTabButtonVO.setShow(tabButtonDO.show); |
| | | //参数信息回填 |
| | | PLCommandParameter[] parameters = platformClientUtil.getUIService().getPLCommandParametersByCommandOId(tabButtonDO.plOId); |
| | | if(Func.isNotEmpty(parameters)){ |
| | | LinkedHashMap<String, String> parameterMap = (LinkedHashMap<String, String>)Arrays.stream(parameters).collect(Collectors.toMap(parm -> parm.plKey, parm -> parm.plValue)); |
| | | plTabButtonVO.setButtonParams(parameterMap); |
| | | } |
| | | return plTabButtonVO; |
| | | } |
| | | |
| | | /** |
| | | * 按钮配置VO对象转DO对象 |
| | | * @param tabButtonVO |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | private PLTabButton tabButtonVO2TabButton(PLTabButton plTabButton,PLTabButtonVO tabButtonVO) { |
| | | plTabButton.plOId = tabButtonVO.getOId(); |
| | | plTabButton.plTableOId = tabButtonVO.getTableOId(); |
| | | plTabButton.plPageOId = tabButtonVO.getPageOId(); |
| | | plTabButton.plActionOId = tabButtonVO.getActionOId(); |
| | | plTabButton.plLabel = tabButtonVO.getLabel(); |
| | | plTabButton.plAreaType = tabButtonVO.getAreaType(); |
| | | plTabButton.plDesc = tabButtonVO.getDesc(); |
| | | plTabButton.plSeq = tabButtonVO.getSeq(); |
| | | plTabButton.plCreateUser = tabButtonVO.getCreateUser(); |
| | | plTabButton.plCreateTime = tabButtonVO.getCreateTime(); |
| | | plTabButton.plModifyUser = tabButtonVO.getModifyUser(); |
| | | plTabButton.plModifyTime = tabButtonVO.getModifyTime(); |
| | | plTabButton.plLicensOrs = tabButtonVO.getLicensOrs(); |
| | | plTabButton.plParentOid = tabButtonVO.getParentOid(); |
| | | plTabButton.displayMode = tabButtonVO.getDisplayMode(); |
| | | plTabButton.iconPath = tabButtonVO.getIconPath(); |
| | | plTabButton.authorization = tabButtonVO.getAuthorization(); |
| | | plTabButton.show = tabButtonVO.getShow(); |
| | | return plTabButton; |
| | | } |
| | | |
| | | /** |
| | | * 添加按钮配置信息 |
| | | * @param tabButtonVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public BaseResult addTapButton(PLTabButtonVO tabButtonVO) { |
| | | boolean res = this.saveOrUpdateTapButton(tabButtonVO, true); |
| | | return res ? BaseResult.success("按钮配置添加成功!"):BaseResult.success("按钮配置添加失败!"); |
| | | } |
| | | |
| | | /** |
| | | * 修改按钮配置信息 |
| | | * @param tabButtonVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public BaseResult updateTapButton(PLTabButtonVO tabButtonVO) { |
| | | boolean res = this.saveOrUpdateTapButton(tabButtonVO, false); |
| | | return res ? BaseResult.success("按钮配置修改成功!"):BaseResult.success("按钮配置修改失败!"); |
| | | } |
| | | |
| | | /** |
| | | * 保存或修改按钮配置信息 |
| | | * @param tabButtonVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveOrUpdateTapButton(PLTabButtonVO tabButtonVO,boolean isAdd){ |
| | | VciBaseUtil.alertNotNull(tabButtonVO,"按钮配置对象",tabButtonVO.getLabel(),"参数名称"); |
| | | //检查当前添加的列表是否重复,但是这儿只支持单条数据保存,所有当前列表判重可以前端来做 |
| | | //String btnParamValidate = this.geCheckRes(); |
| | | |
| | | if (tabButtonVO.getSeq() < 1 || tabButtonVO.getSeq() > 63) { |
| | | throw new VciBaseException("按序号超出范围,请修改,按钮【编号】只能在【1-63】范围内。"); |
| | | } |
| | | //当前登录用户的信息 |
| | | SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread(); |
| | | //VO2DO |
| | | PLTabButton plTabButton = this.tabButtonVO2TabButton(new PLTabButton(), tabButtonVO); |
| | | if(isAdd) { |
| | | //如果是增加操作,直接创建PLTabButton对象 |
| | | plTabButton.plOId = ObjectUtility.getNewObjectID36(); |
| | | plTabButton.plCreateUser = sessionInfo.getUserId(); |
| | | plTabButton.plModifyUser = sessionInfo.getUserId(); |
| | | } else { |
| | | //修改操作 |
| | | plTabButton.plModifyUser = sessionInfo.getUserId(); |
| | | } |
| | | |
| | | try { |
| | | if(isAdd){ |
| | | boolean success = platformClientUtil.getUIService().savePLTabButton(plTabButton); |
| | | if(success == false) { |
| | | throw new VciBaseException("编号重复,编号已经在当前页签下存在!"); |
| | | } |
| | | } else if(!isAdd){ |
| | | platformClientUtil.getUIService().updatePLTabButton(plTabButton); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | String errorLog = "保存按钮信息时发生异常:" + e.getMessage(); |
| | | logger.error(errorLog); |
| | | throw new VciBaseException(errorLog); |
| | | } |
| | | //复用以前的代码,对于参数一条一条删除,一条一条创建 |
| | | //数据量及并发较少,暂时这么处理没有什么问题 |
| | | if(!isAdd) { |
| | | try { |
| | | platformClientUtil.getUIService().deletePLCommandParameterByTabButtonId(plTabButton.plOId); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | LinkedHashMap<String, String> buttonParams = tabButtonVO.getButtonParams(); |
| | | if(!buttonParams.isEmpty()) { |
| | | Iterator<Map.Entry<String, String>> iterator = buttonParams.entrySet().iterator(); |
| | | while(iterator.hasNext()){ |
| | | Map.Entry<String, String> next = iterator.next(); |
| | | if(StringUtils.isEmpty(next.getKey()) || StringUtils.isEmpty(next.getValue())){ |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | if(!buttonParams.isEmpty()){ |
| | | Iterator<Map.Entry<String, String>> kvItor = buttonParams.entrySet().iterator(); |
| | | while(kvItor.hasNext()){ |
| | | Map.Entry<String, String> next = kvItor.next(); |
| | | PLCommandParameter plCommandParameter = new PLCommandParameter(); |
| | | plCommandParameter.plOId = ObjectUtility.getNewObjectID36(); |
| | | plCommandParameter.plCommandOId = plTabButton.plOId; |
| | | plCommandParameter.plKey = next.getKey(); |
| | | plCommandParameter.plValue = next.getValue(); |
| | | plCommandParameter.plCreateUser = sessionInfo.getUserId(); |
| | | plCommandParameter.plModifyUser = sessionInfo.getUserId(); |
| | | try { |
| | | platformClientUtil.getUIService().savePLCommandParameter(plCommandParameter); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | throw new VciBaseException("保存按钮信息时发生异常:"+ e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理配置的event事件 |
| | |
| | | } else { |
| | | res = true; |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * 删除页面定义 |
| | | * @param oids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean delPageDefination(String[] oids) throws PLException { |
| | | VciBaseUtil.alertNotNull(oids,"删除的页面定义主键"); |
| | | boolean res = platformClientUtil.getUIService().deletePLUILayoutByOidsForCascade(oids); |
| | | return res; |
| | | } |
| | | |