From 8b34692ac1b7cf58a1e1ead92b930d9acb9f86f6 Mon Sep 17 00:00:00 2001 From: xiejun <xj@2023> Date: 星期三, 02 八月 2023 00:18:29 +0800 Subject: [PATCH] PDM集成swing界面相关功能开发 --- Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeDataMainPanelDataProvider.java | 92 ++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 81 insertions(+), 11 deletions(-) diff --git a/Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeDataMainPanelDataProvider.java b/Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeDataMainPanelDataProvider.java index 2f8e824..9faf71a 100644 --- a/Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeDataMainPanelDataProvider.java +++ b/Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeDataMainPanelDataProvider.java @@ -1,20 +1,32 @@ package com.vci.ubcs.codeapply; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSONObject; import com.vci.base.ui.swing.components.table.AbstractVCIJTableDataProvider; import com.vci.base.ui.swing.components.table.VCIJTableNode; +import com.vci.ubcs.codeapply.object.BaseModel; +import com.vci.ubcs.codeapply.object.Page; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.vci.base.ui.swing.VCIOptionPane; import com.vci.ubcs.code.vo.webserviceModel.coderule.CodeShowFieldConfigVO; +import com.vci.ubcs.code.vo.webserviceModel.coderule.CodeSrchCondConfigVO; +import com.vci.ubcs.codeapply.object.R; import com.vci.ubcs.codeapply.object.UIFormRefer; -import com.vci.ubcs.codeapply.object.UIFormRefers; -import com.vci.ubcs.starter.web.pagemodel.UITableFieldVO; -import org.apache.poi.ss.formula.functions.T; +import com.vci.ubcs.codeapply.utils.ConfigUtils; +import com.vci.ubcs.codeapply.utils.HttpUtil; +import com.vci.ubcs.starter.web.util.VciBaseUtil; +import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; +import org.apache.commons.collections4.CollectionUtils; -import java.util.LinkedList; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; -public class CodeDataMainPanelDataProvider extends AbstractVCIJTableDataProvider<T> { +public class CodeDataMainPanelDataProvider extends AbstractVCIJTableDataProvider<BaseModel> { private CodeDataMainPanel ownerPanel; private String[] specialColumns = {}; - + private String url= ConfigUtils.getConfigValue("410.code.url","http://127.0.0.1:36014/codeApplySwingController"); + private String[] fields = {}; public CodeDataMainPanelDataProvider(CodeDataMainPanel ownerPanel) { this.ownerPanel=ownerPanel; @@ -32,6 +44,7 @@ fieldList.add(field); }); specialColumns = nameList.toArray(new String[]{}); + fields = fieldList.toArray(new String[]{}); return specialColumns; } @@ -41,13 +54,70 @@ } @Override - public VCIJTableNode<T> getNewRowNode(T t) { - return null; + public VCIJTableNode<BaseModel> getNewRowNode(BaseModel model) { + Map<String,String> dataMap= model.getData(); + Map<String, String> defaultDataMap= VciBaseUtil.objectToMapString(model); + defaultDataMap.putAll(dataMap); + VCIJTableNode<BaseModel> res = new VCIJTableNode<BaseModel>(model); + int i=dataColumnStartIndex; + for (String field:fields){ + String data=defaultDataMap.getOrDefault(field,""); + res.setPropertyValue(getColumns()[i++], data); + } + return res; } @Override - public T[] getDatas(int pageIndex, int pageSize) { + public BaseModel[] getDatas(int pageIndex, int pageSize) { + /**绯荤粺鍙姞杞戒唬鐮侀」 濡傛灉libName涓嶄负绌猴紝鐩存帴鑾峰彇瀵瑰簲鐨勪唬鐮侀」**/ + Map<String,String> condtionMap=new HashMap<>(); + Page<BaseModel> iPage= new Page<BaseModel>() {}; + try{ + UIFormRefer uiFormRefer= this.ownerPanel.getUiFormRefer(); + condtionMap.put("referType", StringUtils.isBlank(uiFormRefer.getReferType())?"":uiFormRefer.getReferType()); + condtionMap.put("page",pageIndex+""); + condtionMap.put("limit",pageSize+""); - return new T[0]; + List<CodeSrchCondConfigVO> codeSrchCondConfigVOS=uiFormRefer.getCodeSrchCondConfigVOS(); + JSONObject jsonObject=new JSONObject(); + if(!CollectionUtils.isEmpty(codeSrchCondConfigVOS)){ + codeSrchCondConfigVOS.stream().forEach(codeSrchCondConfigVO -> { + String field=codeSrchCondConfigVO.getFilterField(); + String value=codeSrchCondConfigVO.getFilterValue(); + String filterType= codeSrchCondConfigVO.getFilterType(); + condtionMap.put("conditionMap["+field+"]",value); + }); + } + Map<String, String> customCondtionMap=ownerPanel.getCustomCondtionMap(); + if(customCondtionMap!=null&&customCondtionMap.size()>0){ + customCondtionMap.forEach((field, value) -> { + condtionMap.put("conditionMap["+field+"]",value); + }); + + } + Map<String,String> headers=new HashMap<>(); + + R r= HttpUtil.sendGet(url+"/defaultReferDataGrid",condtionMap,new HashMap<>()); + + if(r.isSuccess()){ + Object object= r.getData(); + if(object!=null) { + ObjectMapper objectMapper = new ObjectMapper(); + iPage = objectMapper.readValue(object.toString(), Page.class); + } + }else{ + VCIOptionPane.showMessage(this.ownerPanel,r.getMsg()); + } + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + this.total= new Long(iPage.getTotal()).intValue(); + List dataList= iPage.getRecords(); + BaseModel [] baseModels=new BaseModel[]{}; + if(!CollectionUtils.isEmpty(dataList)) { + List<BaseModel> hostInfos = (List<BaseModel>) dataList.stream().map(entity -> JSONUtil.toBean(JSONUtil.parseObj(entity), BaseModel.class)).collect(Collectors.toList()); + baseModels = hostInfos.toArray(new BaseModel[]{}); + } + return baseModels; } } -- Gitblit v1.9.3