| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.util.ZipUtil; |
| | | import com.vci.bo.ItemSeniorQueryBO; |
| | | import com.vci.common.utility.ObjectUtility; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.omd.qtm.QTD; |
| | | import com.vci.corba.omd.qtm.QTInfo; |
| | | import com.vci.corba.portal.PortalService.GetPagePortalVIArrayByPageInfoResult; |
| | | import com.vci.corba.portal.data.PortalVI; |
| | | import com.vci.dto.PRMDTO; |
| | | import com.vci.dto.PRMItemDTO; |
| | | import com.vci.dto.PortalVIDTO; |
| | | import com.vci.dto.*; |
| | | import com.vci.model.*; |
| | | import com.vci.pagemodel.*; |
| | | import com.vci.starter.poi.bo.WriteExcelData; |
| | | import com.vci.starter.poi.bo.WriteExcelOption; |
| | | import com.vci.starter.poi.util.ExcelUtil; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseQueryObject; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.starter.web.pagemodel.DataGrid; |
| | | import com.vci.starter.web.util.LocalFileUtil; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.word.bo.WordMergeStartTableDataBO; |
| | | import com.vci.starter.word.util.WordUtil; |
| | | import com.vci.web.enumpck.ItemTypeEnum; |
| | | import com.vci.web.enumpck.PortalVIType; |
| | | import com.vci.web.enumpck.PortalVITypeFlag; |
| | | import com.vci.web.service.OsAttributeServiceI; |
| | | import com.vci.web.service.OsPortalVIServiceI; |
| | | import com.vci.web.service.OsQuereyTemplateServiceI; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.UITools; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.io.*; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /* |
| | |
| | | @Service |
| | | public class OsPortalVIServiceImpl implements OsPortalVIServiceI { |
| | | /** |
| | | * 日志 |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | /** |
| | | * 加载自身 |
| | | */ |
| | | @Autowired(required = false) |
| | | @Lazy |
| | | private OsPortalVIServiceI self; |
| | | |
| | | /** |
| | | * 加载自身 |
| | | */ |
| | | @Autowired(required = false) |
| | | private OsAttributeServiceI osAttributeService; |
| | | /** |
| | | * 平台的调用工具类 |
| | | */ |
| | | @Autowired |
| | | private PlatformClientUtil platformClientUtil; |
| | | |
| | | /** |
| | | * 查询模板服务 |
| | | */ |
| | | @Autowired |
| | | private OsQuereyTemplateServiceI quereyTemplateServiceI; |
| | | @Override |
| | | public void clearCache() { |
| | | |
| | |
| | | } |
| | | String viName=StringUtils.isBlank(conditionMap.get("viName"))?"":conditionMap.get("viName"); |
| | | String viTypeLabel=StringUtils.isBlank(conditionMap.get("viType"))?"":conditionMap.get("viType"); |
| | | PortalVIType portalVIType= PortalVIType.getByLabel(viTypeLabel); |
| | | PortalVIType portalVIType= PortalVIType.getByName(viTypeLabel); |
| | | Short viType=-1; |
| | | if(portalVIType!=null){ |
| | | viType=portalVIType.getIntVal(); |
| | | } |
| | | String viTypeFlagLabel=StringUtils.isBlank(conditionMap.get("viTypeFlag"))?"":conditionMap.get("viTypeFlag"); |
| | | PortalVITypeFlag portalVITypeFlag= PortalVITypeFlag.getByLabel(viTypeFlagLabel); |
| | | PortalVITypeFlag portalVITypeFlag= PortalVITypeFlag.getByName(viTypeFlagLabel); |
| | | Short viTypeFlag=-1; |
| | | if(portalVITypeFlag!=null){ |
| | | viTypeFlag=portalVITypeFlag.getIntVal(); |
| | | } |
| | | long pageIndex=baseQueryObject.getPage(); |
| | | long pageSize=baseQueryObject.getLimit(); |
| | | if(pageSize==-1){ |
| | | pageSize=25; |
| | | } |
| | | DataGrid<PortalVIVO> dataGrid = new DataGrid<>(); |
| | | try { |
| | | GetPagePortalVIArrayByPageInfoResult pagePortalVIArrayByPageInfoResult= platformClientUtil.getPortalService().getPagePortalVIArrayByPageInfo(typeName,viName,viType,viTypeFlag,pageIndex,pageSize); |
| | |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public BaseResult add(PortalVIDTO portalVIDTO) throws VciBaseException { |
| | | public BaseResult addSave(PortalVIDTO portalVIDTO) throws VciBaseException { |
| | | return savePortalVIDTO(portalVIDTO,false); |
| | | } |
| | | |
| | | /** |
| | | * 根据表单id获取具体数据 |
| | | * @param id |
| | | * @param viType |
| | | * @return |
| | | * @throws VciBaseException |
| | | */ |
| | | @Override |
| | | public PortalVIVO getPortalVIById(String id,String viType) throws PLException { |
| | | VciBaseUtil.alertNotNull(id,"主键"); |
| | | String lableName=PortalVIType.Form.getLabel(); |
| | | if(PortalVIType.Table.getName()==viType){ |
| | | lableName=PortalVIType.Table.getLabel(); |
| | | } |
| | | PortalVIVO portalVIVO=new PortalVIVO(); |
| | | PortalVI portalVI= platformClientUtil.getPortalService().getPortalVIById(id); |
| | | portalVIVO=portalVIDOO2VO(portalVI); |
| | | return portalVIVO; |
| | | } |
| | | |
| | | /*** |
| | | * 表单/表格更改 |
| | | * @param portalVIDTO |
| | |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public BaseResult edit(PortalVIDTO portalVIDTO) throws VciBaseException { |
| | | public BaseResult editSave(PortalVIDTO portalVIDTO) throws VciBaseException { |
| | | return savePortalVIDTO(portalVIDTO,true); |
| | | } |
| | | |
| | | @Override |
| | | public boolean delete(DeletePortalVIDTOList portalVIDTOList) throws PLException { |
| | | if(portalVIDTOList==null||CollectionUtils.isEmpty(portalVIDTOList.getPortalVIDTOList())){ |
| | | // VciBaseUtil.alertNotNull("删除的对象"); |
| | | throw new PLException("1001",new String[]{"请选择要删除的对象!}"}); |
| | | } |
| | | try { |
| | | for(PortalVIDTO portalVIDTO:portalVIDTOList.getPortalVIDTOList()) { |
| | | boolean formFlag = false; |
| | | short viType = portalVIDTO.getViType(); |
| | | String typeName = portalVIDTO.getTypeName(); |
| | | String viewName = portalVIDTO.getViName(); |
| | | String id = portalVIDTO.getId(); |
| | | if (viType == PortalVIType.Form.getIntVal()) { |
| | | // 判断该表单是否在表格中被引用 |
| | | formFlag = platformClientUtil.getPortalService().judgeDeleteButton(id, typeName); |
| | | if (formFlag) { |
| | | throw new Throwable(viewName + "表单已经在表格中被引用,请重新选择要删除的对象!"); |
| | | } |
| | | } |
| | | // 判断该表单或表格是否在UI定义时被引用 |
| | | formFlag = platformClientUtil.getPortalService().judgeUpdateButton(viType, viewName, typeName); |
| | | if (formFlag) { |
| | | throw new Throwable(viewName + "数据已经被UI组件引用,请重新选择要删除的对象!"); |
| | | } |
| | | UITools.getService().deletePortalVIByID(id); |
| | | } |
| | | }catch (Throwable e){ |
| | | String exceptionMessage = "删除表单时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | throw new PLException("100",new String[]{exceptionMessage}); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean delete(String ids) throws PLException { |
| | | VciBaseUtil.alertNotNull(ids,"主键"); |
| | | List<String> idsList= VciBaseUtil.str2List(ids); |
| | | List<PortalVI> PortalVIList= new ArrayList<>(); |
| | | DeletePortalVIDTOList portalVIDTOList=new DeletePortalVIDTOList(); |
| | | idsList.stream().forEach(id->{ |
| | | PortalVI portalVI= null; |
| | | try { |
| | | portalVI = platformClientUtil.getPortalService().getPortalVIById(id); |
| | | PortalVIList.add(portalVI); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | portalVIDTOList.setPortalVIDTOList(portalVIO2DTOS(PortalVIList)); |
| | | return delete(portalVIDTOList); |
| | | } |
| | | |
| | | /** |
| | | * 表单/表格克隆 |
| | | * @param clonePortalVIDTOList |
| | | * @return |
| | | * @throws VciBaseException |
| | | */ |
| | | @Override |
| | | public boolean clone(ClonePortalVIDTOList clonePortalVIDTOList) throws VciBaseException { |
| | | if(clonePortalVIDTOList==null||CollectionUtils.isEmpty(clonePortalVIDTOList.getClonePortalVIDTOList())){ |
| | | throw new VciBaseException("请选择要克隆的对象!"); |
| | | } |
| | | try { |
| | | String typeName=clonePortalVIDTOList.getClonePortalVIDTOList().get(0).getTypeName(); |
| | | PortalVI[] portalVIS= platformClientUtil.getPortalService().getPortalVIArrayByTypeName(typeName); |
| | | Map<String, PortalVIVO> PortalVIMap=new HashMap<>(); |
| | | if(!CollectionUtils.isEmpty(Arrays.asList(portalVIS))) { |
| | | List<PortalVIVO> portalVIVOS = portalVIDOO2VOS(Arrays.asList(portalVIS)); |
| | | PortalVIMap =portalVIVOS.stream().collect(Collectors.toMap(PortalVIVO::getViName, Function.identity())); |
| | | } |
| | | List<PortalVI> portalVIList=new ArrayList<>(); |
| | | for (ClonePortalVIDTO clonedestObject : clonePortalVIDTOList.getClonePortalVIDTOList()) { |
| | | String viName = clonedestObject.getViName(); |
| | | PortalVIDTO portalVIDTO = clonedestObject.getOldPortalVIDTO(); |
| | | short typeFlag = clonedestObject.getTypeFlag(); |
| | | if (viName != null) { |
| | | VciBaseUtil.alertNotNull(viName, "克隆名称不允许为空"); |
| | | //throw new PLException("1001",new String[]{"请选择要删除的对象!}"}); |
| | | if( PortalVIMap.containsKey(viName)){ |
| | | throw new VciBaseException("克隆名称"+viName+"已存在,请核对!"); |
| | | } |
| | | PortalVI portalVI = UITools.getService().getPortalVIById(portalVIDTO.getId()); |
| | | portalVI.id = ObjectUtility.getNewObjectID36(); |
| | | portalVI.viName = viName; |
| | | //如果克隆选择了业务类型则拷贝到新的业务类型下 |
| | | if (StringUtils.isNotBlank(typeName)) { |
| | | portalVI.typeName = typeName; |
| | | } |
| | | if (typeFlag == PortalVITypeFlag.BtmType.getIntVal() || typeFlag == PortalVITypeFlag.LinkType.getIntVal()) { |
| | | portalVI.typeFlag = typeFlag; |
| | | } |
| | | platformClientUtil.getPortalService().savePortalVI(portalVI); |
| | | portalVIList.add(portalVI); |
| | | } |
| | | } |
| | | }catch (PLException e){ |
| | | throw new VciBaseException("克隆出现异常:"+e.getMessage()); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public String exportToExcel(Collection<String> idList) { |
| | | String defaultTempFolder = LocalFileUtil.getDefaultTempFolder(); |
| | | String xfileName="export.xls"; |
| | | List<WriteExcelData> rowDataList = new ArrayList<>(); |
| | | List<WriteExcelData> qtRowDataList = new ArrayList<>(); |
| | | //VciBaseUtil.alertNotNull(idList); |
| | | List<PortalVIDTO> portalVIDTOList= listByIds(idList); |
| | | final int index=0; |
| | | |
| | | String excelFileName = defaultTempFolder + File.separator + xfileName; |
| | | File excelFile = new File(excelFileName); |
| | | try { |
| | | excelFile.createNewFile(); |
| | | }catch (Throwable e){ |
| | | String msg = "在创建excel文件的时候出现了错误"; |
| | | if(logger.isErrorEnabled()){ |
| | | logger.error(msg,e); |
| | | } |
| | | throw new VciBaseException(msg+",{0}",new String[]{excelFileName},e); |
| | | } |
| | | |
| | | |
| | | rowDataList.add(new WriteExcelData(index, 0, "业务类型名称")); |
| | | rowDataList.add(new WriteExcelData(index, 1, "名称")); |
| | | rowDataList.add(new WriteExcelData(index, 2, "业务类型")); |
| | | rowDataList.add(new WriteExcelData(index, 3, "表单类型")); |
| | | rowDataList.add(new WriteExcelData(index, 4, "配置文本")); |
| | | rowDataList.add(new WriteExcelData(index, 5, "属性")); |
| | | rowDataList.add(new WriteExcelData(index, 6, "查询模板名称")); |
| | | rowDataList.add(new WriteExcelData(index, 7, "查询模板配置文本")); |
| | | rowDataList.add(new WriteExcelData(index, 8, "查询模板业务类型")); |
| | | |
| | | |
| | | qtRowDataList.add(new WriteExcelData(index, 0, "业务类型名称")); |
| | | qtRowDataList.add(new WriteExcelData(index, 1, "链接类型名称")); |
| | | qtRowDataList.add(new WriteExcelData(index, 2, "查询模板定义名称")); |
| | | qtRowDataList.add(new WriteExcelData(index, 3, "属性")); |
| | | |
| | | if(!CollectionUtils.isEmpty(portalVIDTOList)){ |
| | | final int[] rowIndex = {1}; |
| | | boolean isLink=PortalVITypeFlag.LinkType.getIntVal()== portalVIDTOList.get(0).getTypeFlag()?true:false; |
| | | try { |
| | | BaseResult baseResult= quereyTemplateServiceI.queryTemplateList( portalVIDTOList.get(0).getTypeName(),isLink); |
| | | if(baseResult.isSuccess()){ |
| | | final int[] rowIndex1 = {1}; |
| | | Collection< QTD> qtdList= baseResult.getData(); |
| | | if(!CollectionUtils.isEmpty(qtdList)){ |
| | | qtdList.stream().forEach(qtd -> { |
| | | qtRowDataList.add(new WriteExcelData(rowIndex1[0], 0, qtd.btmName)); |
| | | qtRowDataList.add(new WriteExcelData(rowIndex1[0], 1, qtd.linkTypeName)); |
| | | qtRowDataList.add(new WriteExcelData(rowIndex1[0], 2, qtd.name)); |
| | | qtRowDataList.add(new WriteExcelData(rowIndex1[0], 3, VciBaseUtil.array2String(qtd.abNames))); |
| | | rowIndex1[0]++; |
| | | }); |
| | | |
| | | } |
| | | } |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | portalVIDTOList.stream().forEach(portalVIDTO -> { |
| | | //先是名称 |
| | | rowDataList.add(new WriteExcelData(rowIndex[0], 0, portalVIDTO.getTypeName()));//业务类型名称 |
| | | rowDataList.add(new WriteExcelData(rowIndex[0], 1, portalVIDTO.getViName()));//名称 |
| | | rowDataList.add(new WriteExcelData(rowIndex[0], 2, PortalVITypeFlag.getByIntVal(portalVIDTO.getTypeFlag()).getLabel()));//业务类型 |
| | | rowDataList.add(new WriteExcelData(rowIndex[0], 3,PortalVIType.getByIntVal(portalVIDTO.getViType()).getLabel()));//表单类型 |
| | | try { |
| | | String prmText=UITools.getPRMText(prmDOO2VIS(portalVIDTO.getPrm(),portalVIDTO.getViType())); |
| | | String prmTextFileName= ObjectUtility.getNewObjectID36() + ".txt"; |
| | | String prmTextFileNameAllName = xfileName + "." + prmTextFileName; |
| | | writeDataToFile(defaultTempFolder,prmTextFileNameAllName,prmText); |
| | | rowDataList.add(new WriteExcelData(rowIndex[0], 4,prmTextFileName));//配置文本 |
| | | |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String attributeStr=""; |
| | | try { |
| | | List<OsAttributeVO> osAttributeVOList=osAttributeService.getOsAttributeVOSByBtName(portalVIDTO.getTypeName(),portalVIDTO.getTypeFlag()); |
| | | if(!CollectionUtils.isEmpty(osAttributeVOList)){ |
| | | List<String> filedList= osAttributeVOList.stream().map(OsAttributeVO::getId).collect(Collectors.toList()); |
| | | attributeStr=VciBaseUtil.array2String(filedList.toArray(new String[]{})); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | rowDataList.add(new WriteExcelData(rowIndex[0], 5, attributeStr));//属性 |
| | | String qtName=""; |
| | | try { |
| | | QTInfo qt = platformClientUtil.getQTDService().getQT(portalVIDTO.getPrm().getFormQtName()); |
| | | qtName=qt.qtName; |
| | | rowDataList.add(new WriteExcelData(rowIndex[0], 6,qtName));//查询模板名称 |
| | | String qtFileName = ObjectUtility.getNewObjectID36() + ".txt"; |
| | | String qtFileNameAllName = xfileName + "." + qtFileName; |
| | | writeDataToFile(defaultTempFolder,qtFileNameAllName,qt.qtText); |
| | | rowDataList.add(new WriteExcelData(rowIndex[0], 7, qtFileName));//查询模板配置文本 |
| | | rowDataList.add(new WriteExcelData(rowIndex[0], 8, qt.btmName));//查询模板业务类型 |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | rowIndex[0]++; |
| | | }); |
| | | } |
| | | |
| | | |
| | | /* String excelTemplateFileName = "/excelTemplate/dataBaseExport.xls"; |
| | | if(this.getClass().getResource(excelTemplateFileName) == null){ |
| | | throw new VciBaseException("请联系管理员,系统中缺少{0}这个模板文件",new String[]{excelTemplateFileName}); |
| | | } |
| | | try { |
| | | ExcelUtil.copyFileFromJar(excelTemplateFileName,excelFile); |
| | | //这个方法会关闭文件流 |
| | | }catch (Throwable e){ |
| | | String msg = "从模板文件拷贝到目标文件出现了错误"; |
| | | if(logger.isErrorEnabled()){ |
| | | logger.error(msg,e); |
| | | } |
| | | throw new VciBaseException(msg+",{0}",new String[]{excelFileName},e); |
| | | }*/ |
| | | try{ |
| | | WriteExcelOption excelOption = new WriteExcelOption(); |
| | | excelOption.addSheetDataList("portalvi",rowDataList); |
| | | excelOption.addSheetDataList("QTD",qtRowDataList); |
| | | ExcelUtil.writeDataToFile(excelFile,excelOption); |
| | | }catch (Throwable e){ |
| | | String msg = "把数据写入到excel文件中出现错误"; |
| | | if(logger.isErrorEnabled()){ |
| | | logger.error(msg,e); |
| | | } |
| | | throw new VciBaseException(msg+",{0}",new String[]{excelFileName},e); |
| | | } |
| | | File zip = ZipUtil.zip(defaultTempFolder); |
| | | FileUtil.del(defaultTempFolder + File.separator); |
| | | //最后返回excel文件名称 |
| | | return zip.getAbsoluteFile().getAbsolutePath(); |
| | | } |
| | | |
| | | /** |
| | | * 拷贝数据到word模板中 |
| | | * @param fileName 要写入的数据 |
| | | * @return word 文件路径 |
| | | */ |
| | | public String writeDataToFile(String defaultTempFolder,String fileName,String str){ |
| | | String tempFolder = LocalFileUtil.getDefaultTempFolder(); |
| | | //拷贝文件 |
| | | String filePath = tempFolder + File.separator + fileName; |
| | | File file = new File(filePath); |
| | | FileOutputStream out = null; |
| | | try { |
| | | file.createNewFile(); |
| | | out= new FileOutputStream(file); |
| | | IOUtils.write(str,out); |
| | | }catch (Throwable e){ |
| | | IOUtils.closeQuietly(out); |
| | | String msg = "在创建文件的时候出现了错误"; |
| | | if(logger.isErrorEnabled()){ |
| | | logger.error(msg,e); |
| | | } |
| | | throw new VciBaseException(msg+",{0}",new String[]{filePath},e); |
| | | }finally { |
| | | IOUtils.closeQuietly(out); |
| | | //移动属性到链接类型文件夹里面去 |
| | | FileUtil.move(file, new File(defaultTempFolder),true); |
| | | FileUtil.del(tempFolder); |
| | | } |
| | | return filePath; |
| | | } |
| | | public List<PortalVIDTO> listByIds(Collection idList){ |
| | | List<PortalVIDTO> portalVIVOList=new ArrayList<>(); |
| | | if(CollectionUtils.isEmpty(idList)){ |
| | | throw new VciBaseException("请选择需要导出的数据"); |
| | | } |
| | | List<PortalVI> portalVIList=new ArrayList<>(); |
| | | idList.stream().forEach(id->{ |
| | | try { |
| | | PortalVI portalVI= platformClientUtil.getPortalService().getPortalVIById(id.toString()); |
| | | portalVIList.add(portalVI); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | portalVIVOList= portalVIO2DTOS(portalVIList); |
| | | return portalVIVOList; |
| | | } |
| | | private BaseResult savePortalVIDTO(PortalVIDTO portalVIDTO,boolean isEdit) { |
| | | |
| | |
| | | throw new Throwable("该"+labelName+"已经被引用,不能修改名称!"); |
| | | } |
| | | } catch (PLException e) { |
| | | throw new Throwable("查询"); |
| | | throw new Throwable("查询原有表单出现异常:"+e.getMessage()); |
| | | } |
| | | if (!portalVI.id.equals(portalVIDTO.getId())) { |
| | | if (portalVI.viName.equals(portalVIDTO.getViName())) { |
| | |
| | | }else{ |
| | | flag=platformClientUtil.getPortalService().judgeUpdateButton(portalVIDTO.getTypeFlag(), portalVIDTO.getViName(), portalVIDTO.getTypeName()); |
| | | } |
| | | flag= saveForm(portalVIDTO,isEdit); |
| | | PortalVI pvi=portalVIDTOO2VI(portalVIDTO); |
| | | if (!isEdit) { |
| | | flag= platformClientUtil.getPortalService().savePortalVI(pvi); |
| | | } else { |
| | | flag= platformClientUtil.getPortalService().updatePortalVI(pvi); |
| | | } |
| | | if(flag){ |
| | | return BaseResult.success("保存"+labelName+"成功!"); |
| | | }else{ |
| | | new Throwable("保存"+labelName+"失败!"); |
| | | } |
| | | } catch (Throwable e) { |
| | | // throw new VciBaseException("保存表单出现异常:"+e.getMessage()); |
| | | return BaseResult.fail("保存"+labelName+"出现异常:"+e.getMessage()); |
| | | String exceptionMessage = "保存"+labelName+"出现异常:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | |
| | | } |
| | | return BaseResult.success("保存"+labelName+"成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 表单/表格 |
| | | * @param portalVIDTO |
| | | * @param isEdit |
| | | * @return |
| | | */ |
| | | private boolean saveForm(PortalVIDTO portalVIDTO,boolean isEdit) { |
| | | List<PRMItemDO> prmItemList = new ArrayList<PRMItemDO>(); |
| | | try { |
| | | PortalVI pvi=portalVIDTOO2VI(portalVIDTO); |
| | | boolean res=false; |
| | | if (!isEdit) { |
| | | res= platformClientUtil.getPortalService().savePortalVI(pvi); |
| | | } else { |
| | | res= platformClientUtil.getPortalService().updatePortalVI(pvi); |
| | | } |
| | | return res; |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, PortalVIVO> selectAllPortalVIMap() throws VciBaseException { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 判断每页行数定义是否正确 |
| | |
| | | }); |
| | | return portalVIS; |
| | | } |
| | | /** |
| | | * 表单的数据对象转换为显示对象 |
| | | * @param PortalVIS 表单的对象 |
| | | * @return 显示对象 |
| | | */ |
| | | @Override |
| | | public List<PortalVIDTO> portalVIO2DTOS(Collection<PortalVI> PortalVIS) { |
| | | List<PortalVIDTO>PortalVIDTOS = new ArrayList<>(); |
| | | Optional.ofNullable(PortalVIS).orElseGet(()->new ArrayList<>()).stream().forEach(PortalVI -> { |
| | | PortalVIDTO PPortalVIDTO = portalVIO2DTO(PortalVI); |
| | | PortalVIDTOS.add(PPortalVIDTO); |
| | | }); |
| | | return PortalVIDTOS; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 表单的数据对象转换为显示对象 |
| | |
| | | } |
| | | return portalVI; |
| | | } |
| | | |
| | | /** |
| | | * 表单的数据对象转换为显示对象 |
| | | * @param portalVI |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PortalVIDTO portalVIO2DTO(PortalVI portalVI) { |
| | | PortalVIDTO portalVIDTO=new PortalVIDTO(); |
| | | portalVIDTO.setId(portalVI.id); |
| | | portalVIDTO.setTypeFlag(portalVI.typeFlag); |
| | | portalVIDTO.setTypeName(portalVI.typeName); |
| | | portalVIDTO.setViName(portalVI.viName); |
| | | portalVIDTO.setViType(portalVI.viType); |
| | | short viType =portalVIDTO.getViType(); |
| | | PRMDO prmdo= UITools.getPRM(portalVI.prm); |
| | | portalVIDTO.setPrm(prmDOO2DTOS(prmdo,viType)); |
| | | return portalVIDTO; |
| | | } |
| | | /** |
| | | * 表单数据对象转换 |
| | | * @param prmdto |
| | |
| | | return prmdo; |
| | | } |
| | | |
| | | /** |
| | | * 表单数据对象转换 |
| | | * @param prmdo |
| | | * @param viType |
| | | * @return |
| | | */ |
| | | private PRMDTO prmDOO2DTOS( PRMDO prmdo, short viType) { |
| | | PRMDTO prmdto=new PRMDTO(); |
| | | prmdto.setShowCols(prmdo.getShowCols()); |
| | | prmdto.setFormQtName(prmdo.getFormQtName()); |
| | | prmdto.setPrmItemList(pRMItemDOO2DTOS(prmdo.getPrmItemList(),viType)); |
| | | return prmdto; |
| | | } |
| | | |
| | | @Override |
| | | public PortalVIVO portalVIDOO2VO(PortalVI portalVI) { |
| | | PortalVIVO portalVIVO=new PortalVIVO(); |
| | | portalVIVO.setId(portalVI.id); |
| | | portalVIVO.setTypeFlagText(PortalVITypeFlag.getByIntVal(portalVI.typeFlag).getLabel()); |
| | | portalVIVO.setTypeFlag(portalVI.typeFlag); |
| | | portalVIVO.setTypeName(portalVI.typeName); |
| | | portalVIVO.setViName(portalVI.viName); |
| | | portalVIVO.setViType(portalVI.viType); |
| | | portalVIVO.setViTypeText(PortalVIType.getByIntVal(portalVI.viType).getLabel()); |
| | | |
| | | String prm= portalVI.prm; |
| | | PRMDO prmdo= UITools.getPRM(prm); |
| | | portalVIVO.setPrm(prmDOO2VOS(prmdo,portalVI.viType)); |
| | | if(StringUtils.isNotBlank(prm)) { |
| | | PRMDO prmdo = UITools.getPRM(prm); |
| | | portalVIVO.setPrm(prmDOO2VOS(prmdo, portalVI.viType)); |
| | | } |
| | | return portalVIVO; |
| | | } |
| | | private PRMVO prmDOO2VOS(PRMDO prmdo,short viType){ |
| | |
| | | Optional.ofNullable(prmItemDTOS).orElseGet(()->new ArrayList<>()).stream().forEach(PRMItemDTO -> { |
| | | PRMItemDO PRMItemDO = pRMItemDTOO2DO(PRMItemDTO,viType); |
| | | portalVIVOS.add(PRMItemDO); |
| | | }); |
| | | return portalVIVOS; |
| | | } |
| | | |
| | | public List<PRMItemDTO> pRMItemDOO2DTOS(Collection<PRMItemDO> prmItemDOS,short viType) { |
| | | List<PRMItemDTO> portalVIVOS = new ArrayList<>(); |
| | | Optional.ofNullable(prmItemDOS).orElseGet(()->new ArrayList<>()).stream().forEach(prmItemDO -> { |
| | | PRMItemDTO prmItemDTO = pRMItemDOO2DTO(prmItemDO,viType); |
| | | portalVIVOS.add(prmItemDTO); |
| | | }); |
| | | return portalVIVOS; |
| | | } |
| | |
| | | } |
| | | return prmItemVO; |
| | | } |
| | | |
| | | /** |
| | | * 数据对象转换 |
| | | * @param prmItemDO 数据对象 |
| | | * @param viType 表单类型 |
| | | * @return |
| | | */ |
| | | private PRMItemDTO pRMItemDOO2DTO(PRMItemDO prmItemDO,short viType) { |
| | | PRMItemDTO prmItemDTO=new PRMItemDTO(); |
| | | prmItemDTO.setItemBat(prmItemDO.getItemBat()); |
| | | prmItemDTO.setItemCols(prmItemDO.getItemCols()); |
| | | prmItemDTO.setItemEQ(prmItemDO.getItemEQ()); |
| | | prmItemDTO.setItemDbl(prmItemDO.getItemDbl()); |
| | | prmItemDTO.setItemCut(prmItemDO.getItemCut()); |
| | | prmItemDTO.setItemOR(prmItemDO.getItemOR()); |
| | | prmItemDTO.setItemAddFilter(prmItemDO.getItemAddFilter()); |
| | | prmItemDTO.setItemField(prmItemDO.getItemField()); |
| | | prmItemDTO.setItemImgWH(prmItemDO.getItemImgWH()); |
| | | prmItemDTO.setItemCtrlDisplyCol(prmItemDO.getItemCtrlDisplyCol());//控制显示列 |
| | | prmItemDTO.setItemDateFormat(prmItemDO.getItemDateFormat());// 数据为日期类型时的格式化字符串 如 yyyy-MM-dd HH:mm:ss |
| | | prmItemDTO.setItemInObj(prmItemDO.getItemInObj()); |
| | | prmItemDTO.setItemName(prmItemDO.getItemName()); |
| | | prmItemDTO.setItemCustomClass(prmItemDO.getItemCustomClass());//自定义类路径 |
| | | prmItemDTO.setItemIsHidden(prmItemDO.getItemIsHidden()); |
| | | prmItemDTO.setItemIsEditable(prmItemDO.getItemIsEditable()); |
| | | prmItemDTO.setItemIsRequired(prmItemDO.getItemIsRequired()); |
| | | prmItemDTO.setItemFieldWidth(prmItemDO.getItemFieldWidth()); |
| | | prmItemDTO.setItemTxf(prmItemDO.getItemTxf()); |
| | | prmItemDTO.setItemRows(prmItemDO.getItemRows()); |
| | | prmItemDTO.setItemHrefConf(prmItemDO.getItemHrefConf());//超链接配置 |
| | | prmItemDTO.setItemTips(prmItemDO.getItemTips()); |
| | | prmItemDTO.setItemTrim(prmItemDO.getItemTrim()); |
| | | prmItemDTO.setItemDateFormat(prmItemDO.getItemDateFormat()); |
| | | prmItemDTO.setItemCtrlDisplyCondition(prmItemDO.getItemCtrlDisplyCondition());////控制显示条件 |
| | | prmItemDTO.setItemEditableProgram(prmItemDO.getItemEditableProgram()); |
| | | prmItemDTO.setItemEditCondition(prmItemDO.getItemEditCondition()); |
| | | prmItemDTO.setItemHrefFields(prmItemDO.getItemHrefFields());//超链接字段 |
| | | prmItemDTO.setItemValueList(prmItemDO.getItemValueList()); |
| | | prmItemDTO.setItemValue(prmItemDO.getItemValue()); |
| | | prmItemDTO.setItemStyle(prmItemDO.getItemStyle()); |
| | | prmItemDTO.setItemShowExpression(prmItemDO.getItemShowExpression());// 显示表达式 ${aa}-${bb} |
| | | prmItemDTO.setItemSeniorQueryColsCounts(prmItemDO.getItemSeniorQueryColsCounts());//高级查询各列使用次数 |
| | | prmItemDTO.setItemQuerySql(prmItemDO.getItemQuerySql());//高级查询sql |
| | | prmItemDTO.setItemType(prmItemDO.getItemType());//属性基本类型 |
| | | prmItemDTO.setItemTypeText(ItemTypeEnum.getTextByValue(prmItemDO.getItemType()));//属性基本类型显示值 |
| | | prmItemDTO.setItemScript(prmItemDO.getItemScript()); |
| | | prmItemDTO.setItemRight(prmItemDO.getItemRight()); |
| | | prmItemDTO.setItemQueryRefFields(prmItemDO.getItemQueryRefFields());//查询关联列 |
| | | prmItemDTO.setItemQtName(prmItemDO.getItemQtName()); |
| | | prmItemDTO.setItemParentFolderName(prmItemDO.getItemParentFolderName());//父文件夹名称 |
| | | prmItemDTO.setItemPageSize(prmItemDO.getItemPageSize()); |
| | | prmItemDTO.setItemOutType(prmItemDO.getItemOutType()); |
| | | prmItemDTO.setItemOutFields(prmItemDO.getItemOutFields()); |
| | | prmItemDTO.setItemListVal(prmItemDO.getItemListVal());//参照值 |
| | | prmItemDTO.setItemListTxt(prmItemDO.getItemListTxt()); |
| | | prmItemDTO.setItemListTable(prmItemDO.getItemListTable()); |
| | | prmItemDTO.setItemKeyFields(prmItemDO.getItemKeyFields()); |
| | | prmItemDTO.setItemIsShowFolder(prmItemDO.getItemIsShowFolder());//是否显示文件夹 |
| | | prmItemDTO.setItemIsNavigatorExpand(prmItemDO.getItemIsNavigatorExpand());////查询区域显示控制 |
| | | prmItemDTO.setItemIsHttpSave(prmItemDO.getItemIsHttpSave()); |
| | | prmItemDTO.setItemHttpVolumnPath(prmItemDO.getItemHttpVolumnPath()); |
| | | prmItemDTO.setItemHttpPathField(prmItemDO.getItemHttpPathField()); |
| | | if(viType==PortalVIType.Table.getIntVal()) {//如果是表格 |
| | | initTableConfigDOO2VOData(prmItemDTO,prmItemDO); |
| | | } |
| | | return prmItemDTO; |
| | | } |
| | | /** |
| | | * 初始化表格所用特殊字段配置 |
| | | * @param prmItemVO |
| | |
| | | private void initTableConfigDOO2VOData(PRMItemVO prmItemVO,PRMItemDO prmItemDO){ |
| | | prmItemVO.setItemFieldWidthList(initItemFieldWidthList(prmItemDO.getItemOutFields(),prmItemDO.getItemFieldWidth()));//列显示宽段 itemOutFieldList 相匹配 |
| | | prmItemVO.setItemSeniorQueryBOS(initItemSeniorQueryBOData(prmItemDO.getItemSeniorQueryCols(),prmItemDO.getItemSeniorQueryColsCounts(),prmItemDO.getItemQuerySql()));//高级查询对象 |
| | | List<String> allKeyList= getRefFormVIName(prmItemVO.getItemInObj()); |
| | | List<String> itemOutFieldList =VciBaseUtil.str2List(prmItemVO.getItemOutFields()); |
| | | List<String> itemKeyFieldList =VciBaseUtil.str2List(prmItemVO.getItemKeyFields()); |
| | | List<String> allKeyList= getRefFormVIName(prmItemDO.getItemInObj()); |
| | | List<String> itemOutFieldList =VciBaseUtil.str2List(prmItemDO.getItemOutFields()); |
| | | List<String> itemKeyFieldList =VciBaseUtil.str2List(prmItemDO.getItemKeyFields()); |
| | | List<String> itemSelectoutFieldList= allKeyList.stream().filter(s ->!itemOutFieldList.stream().map(s1 -> s1).collect(Collectors.toList()).contains(s) ).collect(Collectors.toList()); |
| | | prmItemVO.setItemSelectoutFieldList(itemSelectoutFieldList);//待选择的属性字段 |
| | | prmItemVO.setItemOutFieldList(itemOutFieldList);//需要使用的集合 |
| | | List<String> itemSearchFieldList= itemOutFieldList.stream().filter(s ->!itemKeyFieldList.stream().map(s1 -> s1).collect(Collectors.toList()).contains(s) ).collect(Collectors.toList()); |
| | | // List<String> itemSearchFieldList= itemOutFieldList.stream().filter(s ->!CollectionUtils.isEmpty(itemKeyFieldList).stream().map(s1 -> s1).collect(Collectors.toList()).contains(s) ).collect(Collectors.toList()); |
| | | List<String> itemSearchFieldList=new ArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(itemKeyFieldList)){ |
| | | itemSearchFieldList= itemOutFieldList.stream().filter(s ->!itemKeyFieldList.contains(s)).collect(Collectors.toList()); |
| | | }else{ |
| | | itemSearchFieldList=itemOutFieldList; |
| | | } |
| | | prmItemVO.setItemSearchFieldList(itemSearchFieldList);//待搜索字段 |
| | | prmItemVO.setItemKeyFieldList(itemKeyFieldList);//搜索字段 |
| | | } |
| | | /** |
| | | * 初始化表格所用特殊字段配置 |
| | | * @param prmItemDTO |
| | | * @param prmItemDO |
| | | */ |
| | | private void initTableConfigDOO2VOData(PRMItemDTO prmItemDTO,PRMItemDO prmItemDO){ |
| | | prmItemDTO.setItemFieldWidthList(initItemFieldWidthList(prmItemDO.getItemOutFields(),prmItemDO.getItemFieldWidth()));//列显示宽段 itemOutFieldList 相匹配 |
| | | prmItemDTO.setItemSeniorQueryBOS(initItemSeniorQueryBOData(prmItemDO.getItemSeniorQueryCols(),prmItemDO.getItemSeniorQueryColsCounts(),prmItemDO.getItemQuerySql()));//高级查询对象 |
| | | List<String> allKeyList= getRefFormVIName(prmItemDO.getItemInObj()); |
| | | List<String> itemOutFieldList =VciBaseUtil.str2List(prmItemDO.getItemOutFields()); |
| | | List<String> itemKeyFieldList =VciBaseUtil.str2List(prmItemDO.getItemKeyFields()); |
| | | List<String> itemSelectoutFieldList= allKeyList.stream().filter(s ->!itemOutFieldList.stream().map(s1 -> s1).collect(Collectors.toList()).contains(s) ).collect(Collectors.toList()); |
| | | prmItemDTO.setItemSelectoutFieldList(itemSelectoutFieldList);//待选择的属性字段 |
| | | prmItemDTO.setItemOutFieldList(itemOutFieldList);//需要使用的集合 |
| | | List<String> itemSearchFieldList=new ArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(itemKeyFieldList)){ |
| | | itemSearchFieldList= itemOutFieldList.stream().filter(s ->!itemKeyFieldList.contains(s)).collect(Collectors.toList()); |
| | | }else{ |
| | | itemSearchFieldList=itemOutFieldList; |
| | | } prmItemDTO.setItemSearchFieldList(itemSearchFieldList);//待搜索字段 |
| | | prmItemDTO.setItemKeyFieldList(itemKeyFieldList);//搜索字段 |
| | | } |
| | | /** |
| | | * 初始化表格所用特殊字段配置 |
| | |
| | | private void initTableConfigDTOO2DOData(PRMItemDO prmItemDO,PRMItemDTO prmItemDTO){ |
| | | |
| | | prmItemDO.setItemOutFields(VciBaseUtil.array2String(prmItemDTO.getItemOutFieldList().toArray(new String[]{})));//需要使用的字段 |
| | | prmItemDO.setItemKeyFields(VciBaseUtil.array2String(prmItemDTO.getItemKeyFieldList().toArray(new String[]{})));//需要搜索的字段 |
| | | prmItemDO.setItemKeyFields(CollectionUtils.isEmpty(prmItemDTO.getItemKeyFieldList())?"":VciBaseUtil.array2String(prmItemDTO.getItemKeyFieldList().toArray(new String[]{})));//需要搜索的字段 |
| | | List<String> newItemFieldWidthList=prmItemDTO.getItemFieldWidthList().stream().map(KeyValue::getValue).distinct().collect(Collectors.toList()); |
| | | prmItemDO.setItemFieldWidth(VciBaseUtil.array2String(newItemFieldWidthList.toArray(new String[]{}),":"));//字段宽度 |
| | | List<ItemSeniorQueryBO> itemSeniorQueryBOS= prmItemDTO.getItemSeniorQueryBOS(); |
| | |
| | | private List<KeyValue> initItemFieldWidthList(String itemOutFields,String itemFieldWidth){ |
| | | List<KeyValue> keyValueList=new ArrayList<>(); |
| | | List<String>itemOutFieldList= VciBaseUtil.str2List(itemOutFields); |
| | | List<String>itemFieldWidthList= VciBaseUtil.str2List(itemFieldWidth); |
| | | List<String>itemFieldWidthList= VciBaseUtil.str2List(itemFieldWidth,","); |
| | | if(itemOutFieldList.size()>0) { |
| | | for (int i = 0; i < itemOutFieldList.size(); i++) { |
| | | KeyValue keyValue = new KeyValue(); |
| | | String with = itemFieldWidthList.get(i); |
| | | String with="250"; |
| | | if(i<itemFieldWidthList.size()) { |
| | | with = itemFieldWidthList.get(i); |
| | | } |
| | | keyValue.setKey(itemOutFieldList.get(i)); |
| | | keyValue.setValue(StringUtils.isBlank(with) ? "250" : with); |
| | | keyValueList.add(keyValue); |