package com.vci.rmip.code.client.codeapply.Apply410; import com.vci.base.ui.swing.VCIOptionPane; import com.vci.base.ui.swing.components.*; import com.vci.base.ui.tree.VCIBaseTreeNode; import com.vci.rmip.code.client.codeapply.Apply410.enums.VciFieldTypeEnum; import com.vci.rmip.code.client.codeapply.Apply410.object.*; import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.vo.CodeBasicSecVO; import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.vo.CodeClassifyTemplateAttrVO; import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.vo.CodeFixedValueVO; import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.vo.CodeRuleVO; import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.vo.KeyValue; import com.vci.rmip.code.client.codeapply.Apply410.swing.IntegerTextField; import com.vci.rmip.code.client.codeapply.Apply410.swing.RealTextField; import com.vci.rmip.code.client.codeapply.Apply410.swing.VCIJComboxBox; import com.vci.rmip.code.client.codeapply.Apply410.utils.BeanUtilForVCI; import com.vci.rmip.code.client.codeapply.Apply410.utils.ConfigUtils; import com.vci.rmip.code.client.codeapply.Apply410.utils.HttpUtil; import com.vci.rmip.code.client.codeapply.Apply410.utils.VciBaseUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.codehaus.jackson.JsonProcessingException; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.type.TypeReference; import javax.swing.*; import javax.swing.text.JTextComponent; import javax.swing.tree.TreeNode; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.List; import java.util.regex.Pattern; public class CodeApplyFor410MainPanel extends VCIJPanel { private String url=ConfigUtils.getConfigValue("410.code.url","http://127.0.0.1:36014/codeApplySwingController"); //410新需求 private final String SPECIAL_RULE_NAME="Special.rule.name"; private final String SPECIAL_SECTION_NAME = "Special.section.name"; private final String SPECIAL_CONTROL_SECTION_NAME = "Special.control.other.section.name"; private final String SPECIAL_SECTION_VALUE = "Special.section.val"; Map secMap = new LinkedHashMap(); Map comMap = new LinkedHashMap(); Map secPositionMap = new LinkedHashMap(); private final String MAX_ATTR_IN_LINE_KEY = "RMData.MaxAttrInLine"; private final String TEXTAREA_ENABLE_KEY = "RMData.TextArea.Enable"; private final String MAX_STRING_LENGTH_KEY = "RMData.MaxStringLength"; private final String TEXTAREA_PRE_SIZE_WIDTH = "RMData.TextArea.PreferredSize.Width"; private final String TEXTAREA_PRE_SIZE_HEIGHT = "RMData.TextArea.PreferredSize.Height"; private final String TEXTAREA_MIN_SIZE_WIDTH = "RMData.TextArea.MinimumSize.Width"; private final String TEXTAREA_MIN_SIZE_HEIGHT = "RMData.TextArea.MinimumSize.Height"; private final String TEXTAREA_MAX_SIZE_WIDTH = "RMData.TextArea.MaximumSize.Width"; private final String TEXTAREA_MAX_SIZE_HEIGHT = "RMData.TextArea.MaximumSize.Height"; // 是否启用属性长度过长时,用TextArea显示,true:启用 false:不启用,默认值true private boolean isEnableTextArea = false; // 启用了TextArea后,此TextArea的PreferredSize、MinimumSize、MaximumSize的Width、Height private int textAreaPreSizeWidth = 100; private int textAreaPreSizeHeight = 50; private int textAreaMinSizeWidth = 100; private int textAreaMinSizeHeight = 30; private int textAreaMaxSizeWidth = 100; private int textAreaMaxSizeHeight = 80; // 同一行内,最多加载的属性个数,一行为一组,即一组内最多加载的属性个数,默认值2 private int maxAttrInLine = 2; // 当String类型的属性值的长度大于此值时,该属性就需要用TextArea显示,并占用整行,默认值100 private int maxStringLength = 100; private int levelPositon = -1; private TransmitTreeObject transTreeObject = new TransmitTreeObject(); private TokenUserObject tokenUserObject; private String deptName; //存储每个实际 码段列对应的码段对象 protected Map columnSecMap = new LinkedHashMap(); private LinkedHashMap compMaps = new LinkedHashMap(); private Map secAndComMap = new LinkedHashMap(); private Map comtMap = new LinkedHashMap(); private Map secNameAndComtMap = new LinkedHashMap(); private Map secIndexAndNameMap = new LinkedHashMap(); private List specSecList = new ArrayList(); private boolean isSpecialRuleFlag = false; private String specialSectioName = ""; private VCIJPanel rulePal = new VCIJPanel(); private StringBuffer tempStr= new StringBuffer();//可变码段的值; private String levelRes=""; private String[] specialSecVals = new String[0]; private RMDataTransmitObject transmitForRMData = new RMDataTransmitObject(); private CodeRuleVO codeRuleVO=null; /** * 存储属性和值的Map,key,用于默认值的显示 */ private Map displayValues = new HashMap<>(); /** * 属性ID与属性对应的控件之间的映射MAP */ private LinkedHashMap attrIdToCtrlMaps = new LinkedHashMap(); /** * 属性的内部名称与属性对应的控件之间的映射MAP */ private LinkedHashMap attrInnerNameToCtrlMaps = new LinkedHashMap(); /** * 引用玛段码值与combox元素位置的映射MAP */ private LinkedHashMap refSecValueToCombxindex = new LinkedHashMap(); /** * 码段id与分类码段码值描述对象对应的控件之间的映射MAP */ private LinkedHashMap secIdToClsfIdMap = new LinkedHashMap(); private List textCompts = new LinkedList(); /** * 当前选择的分类的模板 */ private CodeClassifyTemplateVO currentCodeClassifyTemplateVO; // 实际的 private VCIJDialog realDialogInstance = null; public CodeApplyFor410MainPanel(TransmitTreeObject transTreeObject, TokenUserObject tokenUserObject, CodeClassifyTemplateVO currentCodeClassifyTemplateVO) { this.transTreeObject = transTreeObject; this.tokenUserObject = tokenUserObject; this.currentCodeClassifyTemplateVO=currentCodeClassifyTemplateVO; } public CodeApplyFor410MainPanel(TransmitTreeObject transTreeObject,TokenUserObject tokenUserObject,String deptName,CodeClassifyTemplateVO currentCodeClassifyTemplateVO,Map displayValues) { this.transTreeObject = transTreeObject; this.tokenUserObject = tokenUserObject; this.deptName = deptName; this.currentCodeClassifyTemplateVO=currentCodeClassifyTemplateVO; this.displayValues = displayValues; } /** * * @param type, 1代表申请,2设置流水 */ public void buildMainPanel(int type) { try { init(type); if (type == 2) { return; } this.initRMTypeTreeMaps(); this.initContents(); }catch (Exception e){ VCIOptionPane.showMessage(this,e.getMessage()); } } private void init(int type){ this.loadTextAreaEnableEnv(); //add by liujw //this.loadSpecialRuleConfig(); CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj(); //String url= ConfigUtils.getConfigValue("410.PDM.rule.url","http://127.0.0.1:36014/codeApplySwingController/getCodeRuleByClassifyFullInfo"); /**系统只加载代码项 如果libName不为空,直接获取对应的代码项**/ Map condtionMap=new HashMap<>(); condtionMap.put("codeClassId", rmType.getOid()); Map headerMap=new HashMap<>(); headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token()); R r= HttpUtil.sendGet(url+"/getCodeRuleByClassifyFullInfo",condtionMap,headerMap); codeRuleVO=new CodeRuleVO(); if(r.isSuccess()){ Object object= r.getData(); if(object!=null) { ObjectMapper objectMapper = new ObjectMapper(); try { codeRuleVO = objectMapper.readValue(object.toString(),CodeRuleVO.class); } catch (IOException e) { e.printStackTrace(); } } }else{ /* if(!r.getMsg().equals("当前主题库分类,以及它的所有的上级分类都没有设置编码规则")){ VCIOptionPane.showMessage(this,r.getMsg()); }*/ } /**加载规则对应的码段信息**/ if(codeRuleVO!=null){ List codeBasicSecVOList=codeRuleVO.getSecVOList(); if(!CollectionUtils.isEmpty(codeBasicSecVOList) ){ /**初始化码段panel**/ initSectionPanel(codeBasicSecVOList, codeRuleVO.getOid(), type);//初始化规则码段 } } this.setLayout(new BorderLayout()); this.add(rulePal,BorderLayout.CENTER); } /** * 规则码段主界面 *

Description:

* * @author Administrator * @time 2012-8-7 * @param objs * @param cRuleId */ private void initSectionPanel(List objs, String cRuleId, int type) { //循环获取列名 int column = 0; for(int i = 0; i < objs.size(); i++) { if(objs.get(i).getSecType().equals("codeserialsec")){//流水码段不在TABLE里显示 if (type == 1) { continue; } else if (type == 2) { break; } } columnSecMap.put(column++,objs.get(i)); } createSectionPanel(objs, type); } private void createSectionPanel(List secObjs, int type) { /**每次选择代码项后,自动加载规则码段和模板属性信息,清除原来的码段信息**/ rulePal.removeAll(); rulePal.updateUI(); /**根据规则获取码段信息界面**/ VCIJPanel sectionPal = new VCIJPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); int x = 0; int y = 0; int maxAttrInLine = 1; int column = 2; List secList = new ArrayList(); List comList = new ArrayList(); compMaps.clear(); secAndComMap.clear(); secIdToClsfIdMap.clear(); secNameAndComtMap.clear(); secIndexAndNameMap.clear(); // 加载码段列表 boolean isBreak = false; for(int secIndex = 0; secIndex < secObjs.size(); secIndex += maxAttrInLine){//for1 for(int columnIndex = 0; columnIndex < maxAttrInLine; columnIndex++){ //for2 if(secIndex + columnIndex >= secObjs.size()){ break; } if(secObjs.get(secIndex).getSecType().equals("codeserialsec")){//流水码段不在TABLE里显示 if (type == 1) { continue; } else { isBreak = true; break; } } /*else if (secObjs[secIndex].getSecType() == SectionConstant.SectionType.SECCHAR){//是分隔符 continue; }*/ CodeBasicSecVO secObj = secObjs.get(secIndex+columnIndex); VCIJLabel lbl = new VCIJLabel(secObj.getName() + ":"); lbl.setForeground(new Color(129, 0, 0)); JComponent compt = null;//码段名称 VCIJComboxBox cbx = new VCIJComboxBox(); compt = cbx; secList.add(secObj); comList.add(cbx); compMaps.put(column, compt); secNameAndComtMap.put(secObj.getName(), cbx); secIndexAndNameMap.put(column, secObj.getName()); /**层级码段需要特殊处理:如果是层级码段,下拉框不能编辑,显示的值是选中的树节点的分类名称和代号**/ if(secObj.getSecType().equals ("codelevelsec")) {//层级码段 levelPositon = column; compt.setEnabled(false); } // relationMap.put(secIndex, column); secAndComMap.put(secObj.getId(), cbx); column++; c.gridx = x++; c.gridy = y; c.gridheight = 1; c.gridwidth = 1; c.weightx = 0d; c.weighty = 0d; // c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; c.insets = new Insets(1, 1, 10, 10); c.ipadx = 3; c.ipady = 3; lbl.setPreferredSize(new Dimension(100,25)); sectionPal.add(lbl, c); c.gridx = x++; c.weightx = 0d; c.fill = GridBagConstraints.CENTER; c.anchor = GridBagConstraints.WEST; compt.setPreferredSize(new Dimension(200,25)); sectionPal.add(compt, c); //如果当前码段是需要特殊处理的码段,系统进行记录处理 if(isSpecialRuleFlag && specialSectioName.equals(secObj.getName())) { specSecList.add(lbl); specSecList.add(compt); } /**分类码段添加描述信息 410新需求:分类码段码值增加'码值描述'字段 BEGIN***/ if(secObj.getSecType().equals("codeclassifysec")) { VCIJLabel lblDesc = new VCIJLabel("描述:"); c.gridx = x++; c.weightx = 0d; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; lblDesc.setPreferredSize(new Dimension(40,25)); sectionPal.add(lblDesc, c); VCIJTextField txtDesc = new VCIJTextField(""); c.gridx = x++; c.weightx = 0d; c.fill = GridBagConstraints.CENTER; c.anchor = GridBagConstraints.WEST; txtDesc.setPreferredSize(new Dimension(200,25)); txtDesc.setEditable(false); sectionPal.add(txtDesc, c); secIdToClsfIdMap.put(secObj.getId(), txtDesc); //详细描述信息的查看 VCIJLabel clsfDescLbl = new VCIJLabel(); clsfDescLbl.setText(""+"详细描述"+""); clsfDescLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); clsfDescLbl.setForeground(Color.RED); comtMap.put(clsfDescLbl,txtDesc); clsfDescLbl.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e){ clsfValDescActionListener(e); } }); c.gridx = x++; c.weightx = 0d; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; // lblDesc.setPreferredSize(new Dimension(100,25)); sectionPal.add(clsfDescLbl, c); //如果当前码段是需要特殊处理的码段,系统进行记录处理 if(isSpecialRuleFlag && specialSectioName.equals(secObj.getName())) { specSecList.add(lblDesc); specSecList.add(txtDesc); specSecList.add(clsfDescLbl); } } /****************************END**********************************/ }// for 2 if (isBreak) { break; } x = 0; y += 1; }// for 1 rulePal.setLayout(new BorderLayout()); rulePal.add(sectionPal,BorderLayout.CENTER); if (type == 1) { rulePal.add(createAttrPal(),BorderLayout.SOUTH); } initCurrentRow(secList.toArray(new CodeBasicSecVO[0]),comList.toArray(new VCIJComboxBox[0])); } /**加载模板属性信息面板**/ private VCIJPanel createAttrPal() { VCIJPanel attrPal = new VCIJPanel(); CodeClassify rmTypeObj = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj(); /**选择了代码项**/ if(rmTypeObj != null) { transmitForRMData = loadTemplateAttributes("",rmTypeObj.getId(),""); /**代码项下的模板包含属性**/ if(transmitForRMData.getTempPropObjsList().size() > 0) { attrPal = createTemplateAttributePanel(transmitForRMData); } } return attrPal; } private void loadSpecialRuleConfig() { /******added by ligang 是否是特殊规则的判断Begin******/ /*CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj(); RuleManagerObject ruleObj = ruleDel.getRuleManagerById(rmType.getRuleOid()); String specialRuleName = ConfigUtils.getConfigValue(SPECIAL_RULE_NAME); isSpecialRuleFlag = ruleObj.getPlname().toUpperCase().equals(specialRuleName.toUpperCase()) ? true : false; specialControlSecName = ConfigUtils.getConfigValue(SPECIAL_CONTROL_SECTION_NAME); specialSectioName = ConfigUtils.getConfigValue(SPECIAL_SECTION_NAME); specialSecVals = ConfigUtils.getConfigValue(SPECIAL_SECTION_VALUE).split(",");*/ /*********************End*************************/ } /** * 加载是否启用TextArea环境参数 *

* Description: *

* @author liujw * @throws * @time 2013-4-16 */ private void loadTextAreaEnableEnv() { String textAreaEnable = ConfigUtils.getConfigValue(TEXTAREA_ENABLE_KEY); String strAttrInLine = ConfigUtils.getConfigValue(MAX_ATTR_IN_LINE_KEY); if (isNumber(strAttrInLine)) { Integer iLength = Integer.valueOf(strAttrInLine); if (iLength > 0) { this.maxAttrInLine = iLength; } } if (textAreaEnable.toLowerCase().equals("true")) { this.isEnableTextArea = true; } if(this.isEnableTextArea){ String cfgValue = ""; cfgValue = ConfigUtils.getConfigValue(MAX_STRING_LENGTH_KEY); if (isNumber(cfgValue)) { Integer iLength = Integer.valueOf(cfgValue); if (iLength > 0) { this.maxStringLength = iLength; } } cfgValue = ConfigUtils.getConfigValue(TEXTAREA_PRE_SIZE_WIDTH); if (isNumber(cfgValue)) { Integer iValue = Integer.valueOf(cfgValue); if (iValue > 0) { this.textAreaPreSizeWidth = iValue; } } cfgValue = ConfigUtils.getConfigValue(TEXTAREA_PRE_SIZE_HEIGHT); if (isNumber(cfgValue)) { Integer iValue = Integer.valueOf(cfgValue); if (iValue > 0) { this.textAreaPreSizeHeight = iValue; } } cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MIN_SIZE_WIDTH); if (isNumber(cfgValue)) { Integer iValue = Integer.valueOf(cfgValue); if (iValue > 0) { this.textAreaMinSizeWidth = iValue; } } cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MIN_SIZE_HEIGHT); if (isNumber(cfgValue)) { Integer iValue = Integer.valueOf(cfgValue); if (iValue > 0) { this.textAreaMinSizeHeight = iValue; } } cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MAX_SIZE_WIDTH); if (isNumber(cfgValue)) { Integer iLength = Integer.valueOf(cfgValue); if (iLength > 0) { this.textAreaMaxSizeWidth = iLength; } } cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MAX_SIZE_HEIGHT); if (isNumber(cfgValue)) { Integer iLength = Integer.valueOf(cfgValue); if (iLength > 0) { this.textAreaMaxSizeHeight = iLength; } } } } /** * 分类层级注入功能的完善 *

Description:

* * @author ligang * @time 2013-5-7 */ private void initContents() { Iterator keys = transmitForRMData.getTempPropObjsMap().keySet().iterator(); while(keys.hasNext()){ String key = keys.next(); CodeClassifyTemplateAttrVO tempPropObj = transmitForRMData.getTempPropObjsMap().get(key); String referConfig=tempPropObj.getReferConfig();//参照配置 String componentRule=tempPropObj.getComponentRule();//组合规则 String innerName = tempPropObj.getId(); if (attrInnerNameToCtrlMaps.containsKey(innerName)) { String classifyLevel = tempPropObj.getClassifyInvokeLevel(); String classifyInvokeAttr= tempPropObj.getClassifyInvokeAttr(); JComponent compt = attrInnerNameToCtrlMaps.get(innerName); if(StringUtils.isNotBlank(classifyLevel)&&!classifyLevel.equals("none")) { compt.setEnabled(false); //ClassifyLevel classifyLevelObj=new ClassifyLevel(); //ObjectMapper objectMapper = new ObjectMapper(); String value = ""; /*classifyLevelObj = objectMapper.readValue(classifyLevel.toString(), ClassifyLevel.class); String set=classifyLevelObj.getSet(); String type=classifyLevelObj.getType();*/ if (classifyLevel.equals("min")) { CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj(); if ("name".equals(classifyInvokeAttr)) { value = rmType.getName(); } else if ("id".equals(classifyInvokeAttr)) { value = rmType.getId(); } } else { int intLevel = Integer.parseInt(classifyLevel); if (rmTypeTreeMaps.containsKey(intLevel)) { CodeClassify rmType = rmTypeTreeMaps.get(intLevel); if ("name".equals(classifyInvokeAttr)) { value = rmType.getName(); } else if ("id".equals(classifyInvokeAttr)) { value = rmType.getId(); } } } if (compt instanceof JTextComponent) { ((JTextComponent) compt).setText(value); } } //参照配置的设置成只读模式 if(StringUtils.isNotBlank(referConfig)||StringUtils.isNotBlank(componentRule)){ compt.setEnabled(false); } } } } /** * 分类树中的分类对象map */ private LinkedHashMap rmTypeTreeMaps = new LinkedHashMap(); private void initRMTypeTreeMaps(){ if(transTreeObject != null){ TreeNode[] nodes = transTreeObject.getTreeModel().getPathToRoot(transTreeObject.getCurrentTreeNode()); int level = 1; int start = 1; for(int i = start; i < nodes.length; i++){ TreeNode node = nodes[i]; if(node instanceof VCIBaseTreeNode){ VCIBaseTreeNode treeNode = (VCIBaseTreeNode) node; Object obj = treeNode.getObj(); if((treeNode.isRoot() || (obj instanceof String))){ // }else if(obj instanceof CodeClassify){ CodeClassify rmType = (CodeClassify)obj; rmTypeTreeMaps.put(level++, rmType); } } } } } /** * 初始化个码段码值,如果是分类码只加载父分类的分类码值,子分类不加载 * @param secObjs */ public void initCurrentRow(CodeBasicSecVO[] secObjs,VCIJComboxBox[] secCombos) { CodeBasicSecVO lastSecObj = null; VCIJComboxBox hisCombo = null; try { final Map sOecValMap = getSpecialValMap(specialSecVals); Map> secIdTOListValueOidMap=new HashMap<>(); for(int k = 0;k < secObjs.length; k++) { final CodeBasicSecVO secObj = secObjs[k]; final VCIJComboxBox secCombo = secCombos[k]; if(null == secObj) { return; } if (secObj.getSecType().equals("codeclassifysec")) {// 是分类码 String secOid=secObj.getOid(); String parentClassifySecOid= secObj.getParentClassifySecOid(); if(lastSecObj != null) { lastSecObj = secMap.get(secObj.getParentClassifySecOid()); hisCombo = comMap.get(secObj.getParentClassifySecOid()); } if(lastSecObj != null && lastSecObj.getSecType().equals("codeclassifysec") && secObj.getParentClassifySecOid().equals(lastSecObj.getOid())) { hisCombo.addActionListener(new NextComboAction(secPositionMap.get(secObj.getParentClassifySecOid()), comMap.get(secObj.getParentClassifySecOid()),secCombos)); initNextCombo(k,secCombo,(CodeClassifyValue)comMap.get(secObj.getParentClassifySecOid()).getSelectedItem(),secPositionMap.get(secObj.getParentClassifySecOid()),secCombos); //多级分类码段码值加载错误的Bug修复 lastSecObj = secObj; hisCombo = secCombo; secMap.put(secObj.getOid(), secObj); comMap.put(secObj.getOid(), secCombo); secPositionMap.put(secObj.getOid(),k); continue; } String parentClassifyValueOid=""; if(secIdTOListValueOidMap.containsKey(parentClassifySecOid)){ List parentClassifyValueList= secIdTOListValueOidMap.get(parentClassifySecOid); parentClassifyValueOid= VciBaseUtil.array2String(parentClassifyValueList.toArray(new String[]{})); } Map condtionMap=new HashMap<>(); condtionMap.put("secOid", secOid); condtionMap.put("parentClassifyValueOid", parentClassifyValueOid); Map headerMap=new HashMap<>(); headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token()); R r=HttpUtil.sendGet(url+"/listCodeClassifyValueBySecOid",condtionMap,headerMap); List codeClassifyValueList=new ArrayList<>(); if(r.isSuccess()){ Object object= r.getData(); if(object!=null) { ObjectMapper objectMapper = new ObjectMapper(); try { codeClassifyValueList = objectMapper.readValue(object.toString(), new TypeReference>() {}); } catch (JsonProcessingException e) { e.printStackTrace(); } } }else{ VCIOptionPane.showMessage(this,r.getMsg()); } ListvalueOidList=new ArrayList<>(); if(!CollectionUtils.isEmpty(codeClassifyValueList)) { if(codeClassifyValueList.size()>1) { secCombo.addItem(new CodeClassifyValue()); } for (CodeClassifyValue codeClassifyValue : codeClassifyValueList) { secCombo.addItem(codeClassifyValue); valueOidList.add(codeClassifyValue.getOid()); } } secIdTOListValueOidMap.put(secObj.getOid(),valueOidList); lastSecObj = secObj; hisCombo = secCombo; secMap.put(secObj.getOid(), secObj); comMap.put(secObj.getOid(), secCombo); secPositionMap.put(secObj.getOid(),k); /**代码项下拉事件**/ secCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(secCombo.getSelectedIndex() == -1) { return; } if(secIdToClsfIdMap.containsKey(secObj.getId())){ VCIJTextField secDescVcijTextField=(VCIJTextField)secIdToClsfIdMap.get(secObj.getId()); CodeClassifyValue codeClassifyValue= (CodeClassifyValue) secCombo.getSelectedItem(); secDescVcijTextField.setText(codeClassifyValue.getName()); } } }); /*if (secCombo.getItemCount() > 10){ if (!secCombo.isFlag()){ secCombo.setFlag(true); secCombo.getSearchBtn().setVisible(true); secCombo.getSearchBtn().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSearch(secCombo); } }); } }else { secCombo.setFlag(false); secCombo.getSearchBtn().setVisible(false); }*/ } else // 是固定码 if (secObj.getSecType() .equals("codefixedsec")) { List fixedValueVOList=secObj.getFixedValueVOList(); //如果只有一个值,则系统默认选择,不加空值 if(fixedValueVOList.size() >1) { secCombo.addItem(new CodeFixedValue()); } for (CodeFixedValueVO codeFixedValueVO : fixedValueVOList) { CodeFixedValue codeFixedValue=new CodeFixedValue(); BeanUtilForVCI.copyPropertiesIgnoreCase(codeFixedValueVO,codeFixedValue); secCombo.addItem(codeFixedValue); } /**当系统选择的是指定码段值时,组别代号的码段系统不显示 Begin**/ /*FixCodeValObject selObj = (FixCodeValObject) secCombo.getSelectedItem(); if(isSpecialRuleFlag && (secObj.getName().equals(specialControlSecName) && secValMap.containsKey(selObj.getValue())) || secValMap.containsKey(getControlSecSelectValue())) { setComponentStatus(false); }else { setComponentStatus(true); }*/ /*if (secCombo.getItemCount() > 10){ if (!secCombo.isFlag()){ secCombo.setFlag(true); secCombo.getSearchBtn().setVisible(true); secCombo.getSearchBtn().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSearch(secCombo); } }); } }else { secCombo.setFlag(false); secCombo.getSearchBtn().setVisible(false); }*/ } else // 是日期码段 if (secObj.getSecType().equals("codedatesec")) { String df =secObj.getCodeDateFormatStr(); SimpleDateFormat dateFormate = new SimpleDateFormat(df); String curDate = dateFormate.format(Calendar.getInstance().getTime()); secCombo.addItem(curDate); /*if(dateObj.getIsModify().equals("Y")){//可以修改 secCombo.setEditable(true); }*/ } else //是引用码段 if (secObj.getSecType().equals("coderefersec")) { if (!secCombo.isFlag()){ secCombo.setFlag(true); secCombo.getSearchBtn().setVisible(true); secCombo.getSearchBtn().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSearch(secCombo,secObj); } }); } /*RefSecObject refObj = getRefSecObj(secObj.getId()); DefaultComboBoxModel aModel = getRefSecComboBox(refObj); secCombo.setModel(aModel); if(deptName != null && !("".equals(deptName))){ Integer index = refSecValueToCombxindex.get(deptName); if(index !=null){ secCombo.setSelectedIndex(index); } } if (secCombo.getItemCount() > 10){ if (!secCombo.isFlag()){ secCombo.setFlag(true); secCombo.getSearchBtn().setVisible(true); secCombo.getSearchBtn().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSearch(secCombo); } }); } }else { secCombo.setFlag(false); secCombo.getSearchBtn().setVisible(false); } */} else //层级码段码值显示的是选择的代码项的名称 if(secObj.getSecType().equals("codelevelsec")) { CodeClassify rmObj = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj(); secCombo.addItem(rmObj); } else { secCombo.setEditable(true); } } }catch (Exception e) { e.printStackTrace(); VCIOptionPane.showError(this, "初始化码段码值出现错误!"); } } /** * 加载模板的定义的属性、属性数据 *

Description:

* * @author xchao * @time 2012-6-7 * @param libId * @param classifyId * @param templateId * @return */ public RMDataTransmitObject loadTemplateAttributes(String libId, String classifyId, String templateId) { RMDataTransmitObject transmit=new RMDataTransmitObject(); transmit.setLibId(libId); transmit.setClassifyId(classifyId); CodeClassify codeClassify = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj(); transmit.setRmTypeObject(codeClassify); if(currentCodeClassifyTemplateVO!=null) { transmit.setTemplateId(templateId); Map tempPropObjMapsByInnerName = new HashMap<>(); for (CodeClassifyTemplateAttrVO attribute : currentCodeClassifyTemplateVO.getAttributes()) { tempPropObjMapsByInnerName.put(attribute.getId().toLowerCase(Locale.ROOT),attribute); } transmit.setClassifyCode(codeClassify.getId()); transmit.setTempPropObjMapsByInnerName(tempPropObjMapsByInnerName); Map tempPropObjsMap = new HashMap<>(); for (CodeClassifyTemplateAttrVO attribute : currentCodeClassifyTemplateVO.getAttributes()) { tempPropObjsMap.put(attribute.getOid().toLowerCase(Locale.ROOT),attribute); } transmit.setTempPropObjsMap(tempPropObjsMap); transmit.setTemplateObject(currentCodeClassifyTemplateVO); transmit.setTempPropObjsList(this.currentCodeClassifyTemplateVO.getAttributes()); } return transmit; } /**** * 加载代码项对应的模板属性信息列表 *

Description:

* * @author Administrator * @time 2013-3-23 * @param transmitForRMData :模板属性,分类等信息 * @return */ private VCIJPanel createTemplateAttributePanel(final RMDataTransmitObject transmitForRMData) { //int maxAttrInLine = 2; VCIJPanel pal = new VCIJPanel(); pal.setLayout(new GridBagLayout()); int gridx = -1; int gridy = -1; int gridwidth = 1; double weighty = 0.0; CodeClassifyTemplateAttrVO[] realAttrs = getRealAttributeObjects(transmitForRMData); Map attrMaps = getTempPropMap(transmitForRMData); attrIdToCtrlMaps.clear(); attrInnerNameToCtrlMaps.clear(); for (int attrIndex = 0; attrIndex < realAttrs.length; attrIndex += maxAttrInLine) {// for1 gridx = 0; gridy += 1; boolean leastNewLine = checkLeastNewLine(attrIndex, maxAttrInLine,attrMaps,realAttrs); for (int columnIndex = 0; columnIndex < maxAttrInLine; columnIndex++) { // for2 int index = columnIndex + attrIndex; if (index >= realAttrs.length) { break; } final CodeClassifyTemplateAttrVO attrObj = realAttrs[index]; /***如果模板配置了引用模板,属性名称列表添加链接进行处理 BEGIN**/ //ADD BY liujw VCIJLabel lbl = null; if(StringUtils.isNotBlank(attrObj.getReferConfig())) {//引用模板属性值 lbl = new VCIJLabel(""+(attrObj.getName() + ":")+""); lbl.setForeground(Color.MAGENTA); lbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lbl.setToolTipText("点击此处加载引用模板属性数据"); lbl.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e){ getReferTempRMData(attrObj,attrIdToCtrlMaps,transmitForRMData.getTempPropObjsList()); } }); } else if(!"".equals(attrObj.getComponentRule())) {//模板规则的组合 String lblName = "☆"+attrObj.getName() + "☆:"; lbl = new VCIJLabel(""+lblName+""); lbl.setForeground(Color.BLUE); lbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lbl.setToolTipText("点击此处获取模板对应规则的值"); lbl.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e){ getComptAttrValue(attrObj,attrIdToCtrlMaps); } }); } else if(attrObj.getKeyAttrFlag().equals("true")) {//关键属性 lbl = new VCIJLabel(attrObj.getName() + ":"); lbl.setForeground(new Color(255, 0, 0)); } else { lbl = new VCIJLabel(attrObj.getName() + ":"); lbl.setForeground(attrObj.getRequireFlag().equals("true") ? new Color(0, 120, 0) : new Color(129, 0, 0)); } JComponent compt = createComponent(attrObj); JComponent comptAddToPanel = compt; //by liujw boolean isMultiLineFlag = attrObj.getTextAreaFlag().equals("true") ? true : false; if (this.isEnableTextArea && isMultiLineFlag // 启用TextArea显示处理,且属性长度超过一定范围 && attrObj.getAttributeDataType().toUpperCase().equals("VTstring".toUpperCase()) // String类型 ) { VCIJTextArea textArea = new VCIJTextArea("", attrObj.getRequireFlag().equals("true")); VCIJScrollPane textAreaScroll = createTextAreaScrollPane(textArea); textArea.setEnabled(compt.isEnabled()); comptAddToPanel = textAreaScroll; if(compt instanceof JTextComponent){ textArea.setText(((JTextComponent)compt).getText()); } compt = textArea; } /** * 方案:V1 属性组件加载、显示策略 1、每行(一组)最多显示maxAttrInLine个属性 * 2、如果isEnableTextArea为true,则是启用TextArea * 3、启用TextArea后,如果一组内的属性,只要任意一个属性定义的属性长度大于或等于maxStringLength * ,则该组内的每个属性都将独占一整行 * 此方案存在的问题:因为除TextArea之外的属性也将占整行显示,如果一组内的属性个数较多 * (大于2)时,界面显示层面不太,友好,尤其是连续出现多个TextArea时此现象更加明显 * 因此建议配置:启用TextArea时,RMData.MaxAttrInLine=2,即一组内最多加载两个属性。 */ // 一组至少存在着一个TextArea时,该组内其它属性也将占整个宽度(独占一行), if (leastNewLine) { gridwidth = maxAttrInLine * 2; gridx = 0; gridy += 1; // weighty = 1.0; weighty = 0.0; } else { gridwidth = 1; weighty = 0.0; } pal.add(lbl,createGridBagConstraints(gridx, gridy, 1, 1, 0.0, 0.0,GridBagConstraints.NORTHEAST,GridBagConstraints.NONE)); pal.add(comptAddToPanel,createGridBagConstraints(gridx + 1, gridy, gridwidth,1, 1.0, weighty, GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH)); // 如果这一组内不存在着需要占整行显示的,则计算横坐标 //gridx += 2; if (!leastNewLine) { gridx += 2; } /*********************** 方案:V1 End ***********************/ // 缓存各属性对应的控&组件 String key = attrObj.getId(); if (!attrIdToCtrlMaps.containsKey(key)) { attrIdToCtrlMaps.put(key, compt); } // 存储属性内部名称与控件的关系 key = attrObj.getId(); if (!attrInnerNameToCtrlMaps.containsKey(key)) { attrInnerNameToCtrlMaps.put(key, compt); } }// for 2 }// for 1 // 在底部添加一行,占据全部的空余区域,其它控件自动从对齐到顶部 pal.add(new VCIJLabel(""),createGridBagConstraints(0, gridy + 1, maxAttrInLine * 2, 1,1.0, 10.0, GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH)); this.setTextComptList(textCompts); return pal; } /** * 获取真实的、实际的需要加载到UI的属性列表 *

* Description: *

* * @author xchao * @time 2012-11-6 * @param transmitForRMData * 当前上下数据传递对象 * @return */ private CodeClassifyTemplateAttrVO[] getRealAttributeObjects(RMDataTransmitObject transmitForRMData) { // 取模板的属性 CodeClassifyTemplateAttrVO[] tempAttrs = transmitForRMData.getTempPropObjsList().toArray(new CodeClassifyTemplateAttrVO[0]); LinkedList attrsList = new LinkedList(); // 进行过滤,隐藏的不显示,企业代码不显示,其它的允许录入 for (CodeClassifyTemplateAttrVO attrObj : tempAttrs) { String attrId = attrObj.getOid(); // 判断属性是否隐藏,隐藏的不需要提供录入项 if (attrObj.getFormDisplayFlag().equals("false")) { continue; } // 如果是代码列,则也隐藏,通过代码申请框架录入 else if (attrObj.getId().toUpperCase().equals("id".toUpperCase())) { continue; } attrsList.add(attrObj); } // 有效的、需要显示录入框的属性列表 CodeClassifyTemplateAttrVO[] attrs = attrsList.toArray(new CodeClassifyTemplateAttrVO[] {}); return attrs; } /** * 创建属性在UI中呈现的组件 *

* Description: *

* * @author xchao * @time 2012-11-6 * @param attrObj * 属性在模板中对应的属性对象 * @return */ private JComponent createComponent(CodeClassifyTemplateAttrVO attrObj) { JComponent compt = null; String attrId = attrObj.getId(); // 查出属性的取值范围 if(StringUtils.isNotBlank(attrObj.getEnumString())||StringUtils.isNotBlank(attrObj.getEnumId())){ KeyValue[] keyValues = getAttrRangeObjects(attrObj.getOid()); // 如果存在取值范围,只能从取值范围里选择 if (keyValues.length != 0) { AttrRangObjectWarper[] objs = new AttrRangObjectWarper[keyValues.length]; VCIJComboBox cbx = new VCIJComboBox(); DefaultComboBoxModel model = new DefaultComboBoxModel(); //存在取值范围,如果可以为空,则添加一个空值 int comboBoxIndex = 1; KeyValue keyValue = new KeyValue(); keyValue.setValue(""); keyValue.setKey(""); AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue); model.addElement(wrapper); /*** 如果模板属性不是必填项,加入空值后修改时功能的完善 **/ LinkedHashMap specMap = new LinkedHashMap(); for (int i = 0; i < objs.length; i++) { objs[i] = new AttrRangObjectWarper(keyValues[i]); model.addElement(objs[i]); specMap.put(objs[i].toString(), comboBoxIndex++); } cbx.setModel(model); if(displayValues.containsKey(attrObj.getId())){ // cbx.setSelectedItem(displayValues.get(attrObj.getId())); // cbx.setSelectedIndex(3); for (int i = 0; i < objs.length; i++) { if(objs[i].getKeyValue().getKey().equals(displayValues.get(attrObj.getId()))){ cbx.setSelectedIndex(i); } } cbx.setEnabled(false); } compt = cbx; } } else if(StringUtils.isNotBlank(attrObj.getReferConfig())){//参照的需要设置成下拉框,并且只读 VCIJComboBox cbx = new VCIJComboBox(); DefaultComboBoxModel model = new DefaultComboBoxModel(); KeyValue keyValue = new KeyValue(); keyValue.setValue(""); keyValue.setKey(""); AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue); model.addElement(wrapper); cbx.setModel(model); compt = cbx; } else { // 不存在取值范围则按类型生成不同的控件 if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTBoolean.toString())) { // Boolean类型 VCIJComboBox cbx = new VCIJComboBox(); DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement("0"); model.addElement("1"); cbx.setModel(model); if(displayValues.containsKey(attrObj.getId())){ cbx.setSelectedIndex(Integer.parseInt(displayValues.get(attrObj.getId()))); cbx.setEnabled(false); return cbx; } compt = cbx; } else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDate.toString())) { // 日期类型 VCIJCalendarPanel aTrue = new VCIJCalendarPanel("yyyy-MM-dd", attrObj.getRequireFlag().equals("true"), true, false); if(displayValues.containsKey(attrObj.getId())){ aTrue.setDateString(displayValues.get(attrObj.getId())); aTrue.setEnabled(false); return aTrue; } compt = aTrue; } else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDateTime.toString())) { // 日期类型 VCIJCalendarPanel aTrue = new VCIJCalendarPanel("yyyy-MM-dd HH:mm:ss", attrObj.getRequireFlag().equals("true"), true, false); if(displayValues.containsKey(attrObj.getId())){ aTrue.setDateString(displayValues.get(attrObj.getId())); aTrue.setEnabled(false); return aTrue; } compt = aTrue; }else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTTime.toString())) { // 日期类型 VCIJCalendarPanel aTrue = new VCIJCalendarPanel("HH:mm:ss", attrObj.getRequireFlag().equals("true"), true, false); if(displayValues.containsKey(attrObj.getId())){ aTrue.setDateString(displayValues.get(attrObj.getId())); aTrue.setEnabled(false); return aTrue; } compt = aTrue; } else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDouble.toString())||attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTLong.toString())) { // Real类型 RealTextField txt = new RealTextField(""); txt.setRequired(attrObj.getRequireFlag().equals("true")); if(displayValues.containsKey(attrObj.getId())){ txt.setText(displayValues.get(attrObj.getId())); txt.setEditable(false); } compt = txt; } else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTInteger.toString())) { // Integer类型 IntegerTextField txt = new IntegerTextField(""); txt.setRequired(attrObj.getRequireFlag().equals("true")); if(displayValues.containsKey(attrObj.getId())){ txt.setText(displayValues.get(attrObj.getId())); txt.setEditable(false); } compt = txt; } else{ VCIJTextField txt = new VCIJTextField(this,attrObj.getRequireFlag().equals("true")); if(displayValues.containsKey(attrObj.getId())){ txt.setText(displayValues.get(attrObj.getId())); txt.setEditable(false); } compt = txt; textCompts.add(txt); } boolean enabled = true; // 集团代码、集团附加码不可以手工录入数据 if (attrObj.getId().toLowerCase().equals("groupcode")) { enabled = false; } compt.setEnabled(enabled); } return compt; } /** * 处理下拉框的事件 * @author Administrator * */ class NextComboAction implements ActionListener { private int column = 0; private VCIJComboxBox curCombo = null; private VCIJComboxBox[] secCombos = null; public NextComboAction(int column,VCIJComboxBox curCombo,VCIJComboxBox[] secCombos) { this.column = column; this.curCombo = curCombo; this.secCombos = secCombos; } public void actionPerformed(ActionEvent e) { VCIJComboxBox nextCombo = secCombos[column+1]; if(curCombo.getSelectedIndex() != -1){ CodeClassifyValue obj = (CodeClassifyValue)curCombo.getSelectedItem(); initNextCombo(column+1, nextCombo, obj, column,secCombos); } } } /** * 初始化下一个下拉列表 * @param column * @param curCombo * @param lastObj 上一个选中的分类码段码值的对象(只针对分类码) */ public void initNextCombo(int column,VCIJComboxBox curCombo,CodeClassifyValue lastObj,int lastColumn,VCIJComboxBox[] secCombos) { final VCIJComboxBox nextCombo = curCombo; CodeBasicSecVO lastSecObj = columnSecMap.get(lastColumn); final CodeBasicSecVO nextSecObj = columnSecMap.get(column); if(nextSecObj == null) {//如果后面没有对象,则返回 return; } boolean isContinue = false; if(nextSecObj.getSecType().equals("codeclassifysec")){//如果当前是分类码 CodeBasicSecVO curObj =nextSecObj; if(lastSecObj.getSecType().equals("codeclassifysec") && curObj.getParentClassifySecOid().equals(lastSecObj.getOid())){ isContinue = true; } } if(lastObj == null || !isContinue){//如果当前列的下拉框已经初始过,并且上一分类码不是当前分类码的父 return; } VCIJComboxBox lastColumnComboxBox= secCombos[lastColumn]; if(nextSecObj.getSecType().equals("codeclassifysec")){//分类码 CodeClassifyValue[] clsfCodeVals = new CodeClassifyValue[]{}; //如果上一个是分类码,并且是当前分类码的父 /*if (isContinue) { clsfCodeVals = clsfCodeValDel.getChildClsfCodeVal(lastObj.getOid()); } else { clsfCodeVals = clsfCodeValDel.getSecRootClsfCodeVal(nextSecObj.getOid());//获取该码段下的所有码段码值对象 }*/ String parentClassifyValueOid=""; if(lastColumnComboxBox!=null){ CodeClassifyValue selectedItem = (CodeClassifyValue)lastColumnComboxBox.getSelectedItem(); if(selectedItem!=null) parentClassifyValueOid= selectedItem.getOid(); } Map condtionMap=new HashMap<>(); condtionMap.put("secOid", nextSecObj.getOid()); condtionMap.put("parentClassifyValueOid",parentClassifyValueOid); Map headerMap=new HashMap<>(); headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token()); R r=HttpUtil.sendGet(url+"/listCodeClassifyValueBySecOid",condtionMap,headerMap); List codeClassifyValueList=new ArrayList<>(); if(r.isSuccess()){ Object object= r.getData(); if(object!=null) { ObjectMapper objectMapper = new ObjectMapper(); try { codeClassifyValueList = objectMapper.readValue(object.toString(), new TypeReference>() {}); } catch (JsonProcessingException e) { e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }else{ VCIOptionPane.showMessage(this,r.getMsg()); } DefaultComboBoxModel model = new DefaultComboBoxModel(); for(int i = 0;i< codeClassifyValueList.size();i++) { /*if(!codeClassifyValueList.get(i).getOid().equals(nextSecObj.getOid())) { continue; }*/ model.addElement(codeClassifyValueList.get(i)); } /*Map secValMap = getSpecialValMap(specialSecVals); if(isSpecialRuleFlag && (lastSecObj.getName().equals(specialControlSecName) && secValMap.containsKey(lastObj.getValue())) || secValMap.containsKey(getControlSecSelectValue())) { setComponentStatus(false); }else { setComponentStatus(true); }*/ /******************END************************/ nextCombo.setModel(model); nextCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { ((VCIJTextField)secIdToClsfIdMap.get(nextSecObj.getId())).setText(((CodeClassifyValue)nextCombo.getSelectedItem()).getName()); } }); if(nextCombo.getSelectedItem() != null) { ((VCIJTextField)secIdToClsfIdMap.get(lastSecObj.getId())).setText(lastObj.getName()); ((VCIJTextField)secIdToClsfIdMap.get(nextSecObj.getId())).setText(((CodeClassifyValue)nextCombo.getSelectedItem()).getName()); } //修复选择分类码段码值后,所有的子分类的码段码值不能更新的问题 int k = column + 1; if(k < columnSecMap.size() && columnSecMap.get(k).getSecType().equals("codeclassifysec")) { CodeBasicSecVO currentSecObj = columnSecMap.get(k); // SortSecObject curObj = new SectionClientDelegate(userObj).fetchSortSecById(currentSecObj.getId()); if (secPositionMap.get(currentSecObj.getParentClassifySecOid()) != null) { // secCombos[column].addActionListener(new NextComboAction(secPositionMap.get(curObj.getId()), comMap.get(curObj.getId()),secCombos)); CodeClassifyValue nextClsfCodeValObj = (CodeClassifyValue)comMap.get(currentSecObj.getParentClassifySecOid()).getSelectedItem() == null ? new CodeClassifyValue():(CodeClassifyValue)comMap.get(currentSecObj.getParentClassifySecOid()).getSelectedItem(); initNextCombo(k,secCombos[k],nextClsfCodeValObj,secPositionMap.get(currentSecObj.getParentClassifySecOid()),secCombos); } // k++; } /*if (nextCombo.getItemCount() > 10){ if (!nextCombo.isFlag()){ nextCombo.setFlag(true); nextCombo.getSearchBtn().setVisible(true); nextCombo.getSearchBtn().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSearch(nextCombo); } }); } }else { nextCombo.setFlag(false); nextCombo.getSearchBtn().setVisible(false); }*/ }else if(nextSecObj.getSecType().equals("codefixedsec")){//固定码 Map secValMap = getSpecialValMap(specialSecVals); /*if(isSpecialRuleFlag && (lastSecObj.getName().equals(specialControlSecName) && secValMap.containsKey(lastObj.getValue())) || secValMap.containsKey(getControlSecSelectValue())) { setComponentStatus(false); }else { setComponentStatus(true); }*/ /******************END************************/ // SectionValueClientDelegate codeValDel = new SectionValueClientDelegate(userObj); //FixCodeValObject[] codeValObjs = codeValDel.fetchFixCodeValBySecId(nextSecObj.getId());//获取该码段下的所有码段码值对象 List fixedValueVOList=nextSecObj.getFixedValueVOList(); for(int i = 0;i< fixedValueVOList.size();i++) { nextCombo.addItem(fixedValueVOList.get(i)); } /*if (nextCombo.getItemCount() > 10){ if (!nextCombo.isFlag()){ nextCombo.setFlag(true); nextCombo.getSearchBtn().setVisible(true); nextCombo.getSearchBtn().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSearch(nextCombo); } }); } }else { nextCombo.setFlag(false); nextCombo.getSearchBtn().setVisible(false); }*/ }else if(nextSecObj.getSecType().equals("codedatesec")){//日期码段 // DateSecObject dateObj = secDel.fetchDateSecById(nextSecObj.getId()); String df =nextSecObj.getCodeDateFormatStr(); String CodeDateValue= nextSecObj.getCodeDateValue(); SimpleDateFormat dateFormate = new SimpleDateFormat(df); if(StringUtils.isBlank(CodeDateValue)){ CodeDateValue= dateFormate.format(Calendar.getInstance().getTime()); } nextCombo.addItem(CodeDateValue); /*if(dateObj.getIsModify().equals("Y")){ nextCombo.setEditable(true); }*/ }/*else if(nextSecObj.getSecType() equals("")){//分隔符 nextCombo.addItem(nextSecObj.getId());}*/ else if (nextSecObj.getSecType().equals("coderefersec")) { if (!nextCombo.isFlag()){ nextCombo.setFlag(true); nextCombo.getSearchBtn().setVisible(true); nextCombo.getSearchBtn().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSearch(nextCombo,nextSecObj); } }); } }else { nextCombo.setEditable(true); } } /**** * 根据属性id获取属性取值范围的值 *

Description:

* * @author Administrator * @time 2013-3-23 * @param attrId * @return */ private KeyValue[] getAttrRangeObjects(String attrId){ KeyValue[] res = new KeyValue[0]; //String url= ConfigUtils.getConfigValue("410.PDM.attrKeyValue.url","http://127.0.0.1:36014/codeApplySwingController/listComboboxItems"); /**系统只加载代码项 如果libName不为空,直接获取对应的代码项**/ Map condtionMap=new HashMap<>(); condtionMap.put("oid", attrId); Map headerMap=new HashMap<>(); headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token()); R r=HttpUtil.sendGet(url+"/listComboboxItems",condtionMap,headerMap); List keyValueList=new ArrayList<>(); if(r.isSuccess()){ Object object= r.getData(); if(object!=null) { ObjectMapper objectMapper = new ObjectMapper(); try { keyValueList = objectMapper.readValue(object.toString(), new TypeReference>() { }); } catch (IOException e) { e.printStackTrace(); } } }else{ VCIOptionPane.showMessage(this,r.getMsg()); } return keyValueList.toArray(new KeyValue[]{}); } /** * 检查需要在一行中显示的那些组件(控件)中,是否至少存在着一个需要换行(占整行)显示的组件 *

* Description: *

* * @author liujw * @time 2013-4-16 * @param attrIndex * 循环属性的索引 * @param maxAttrInLine * 需要换行显示的判断条件,属性的长度 * @param realAttrs * 真实的需要加载的属性列表 * @return */ private boolean checkLeastNewLine(int attrIndex, int maxAttrInLine,Map attrMaps, CodeClassifyTemplateAttrVO[] realAttrs){ boolean res = false; int attrsLength = realAttrs.length; for(int columnIndex = 0; columnIndex < maxAttrInLine; columnIndex++){ int index = attrIndex + columnIndex; if(index < attrsLength){ CodeClassifyTemplateAttrVO attrObj = realAttrs[index]; boolean isStringType = attrObj.getAttributeDataType().toUpperCase().equals("VTstring".toUpperCase()); // 启用TextArea时才进行判断 if(this.isEnableTextArea && isStringType && attrMaps.size() > 0 && attrMaps.containsKey(attrObj.getId())){ res = true; break; } } } return res; } /***获取属性模板对象 @author liujw**/ private Map getTempPropMap(RMDataTransmitObject transmitForRMData) { Map map = new LinkedHashMap(); List propObjs = transmitForRMData.getTempPropObjsList(); for(CodeClassifyTemplateAttrVO obj : propObjs) { if(obj.getTextAreaFlag().equals("true")) { map.put(obj.getOid(), "Y"); } } return map; } /**码段码值描述信息的详细说明**/ private void clsfValDescActionListener(MouseEvent e) { VCIJTextField txt = (VCIJTextField) comtMap.get(e.getComponent()); DescViewDialog dialog = new DescViewDialog(this, txt.getText()); dialog.bulidDialog(); dialog.setVisible(true); } /** * 创建与TextArea相关联的ScrollPane对象 *

* Description: *

* * @author liujw * @time 2013-4-16 * @param txtArea * VCIJTextArea * @return */ private VCIJScrollPane createTextAreaScrollPane(VCIJTextArea txtArea) { txtArea.setWrapStyleWord(true); txtArea.setLineWrap(true); VCIJScrollPane txtScroll = new VCIJScrollPane(); txtScroll.getViewport().add(txtArea); txtScroll.setPreferredSize(new Dimension(textAreaPreSizeWidth, textAreaPreSizeHeight)); txtScroll.setMinimumSize(new Dimension(textAreaMinSizeWidth, textAreaMinSizeHeight)); txtScroll.setMaximumSize(new Dimension(textAreaMaxSizeWidth, textAreaMaxSizeHeight)); txtScroll.setBorder(null); return txtScroll; } /** * 返回GridBagLayout布局管理的Constraints对象 *

* Description: *

* * @author xchao * @time 2012-11-6 * @param gridx * @param gridy * @param gridwidth * @param gridheight * @param weightx * @param weighty * @param anchor * @param fill * @return */ private GridBagConstraints createGridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty,int anchor, int fill) { int padxy = 5; return new GridBagConstraints(gridx, gridy, gridwidth, gridheight,weightx, weighty, anchor, fill, new Insets(padxy, padxy, padxy,padxy), padxy, padxy); } /**根据属性组合规则获取属性的值 **/ private void getComptAttrValue( CodeClassifyTemplateAttrVO tempPropObj, LinkedHashMap attrIdToCtrlMaps) { Map dataMap=new HashMap<>(); Map condtionMap=new HashMap<>(); for(String key: attrIdToCtrlMaps.keySet()){ JComponent compt = attrIdToCtrlMaps.get(key); String value = ""; if (compt instanceof JTextComponent) { value = ((JTextComponent) compt).getText(); } else if (compt instanceof VCIJCalendarPanel) { value = ((VCIJCalendarPanel) compt).getDateString(); value = value == null ? "" : value; } else if (compt instanceof VCIJComboBox) { Object objItem = ((VCIJComboBox) compt).getSelectedItem(); if (objItem instanceof AttrRangObjectWarper) { // 属性取值范围 value = ((AttrRangObjectWarper) objItem).getKeyValue().getValue(); } else if (objItem instanceof String) { // Boolean类型的会提供0\1选择 value = (String) objItem; } } dataMap.put(key,value); condtionMap.put("dataMap["+key+"]",value); } condtionMap.put("componentRuleValue",tempPropObj.getComponentRule()); Map headerMap=new HashMap<>(); headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token()); R r= HttpUtil.sendGet(url+"/getValueByFormula",condtionMap,headerMap); String value=""; if(r.isSuccess()){ value= r.getData().toString(); if(attrIdToCtrlMaps.containsKey(tempPropObj.getId())){ JComponent comp = attrInnerNameToCtrlMaps.get(tempPropObj.getId()); if(comp instanceof JTextComponent) { ((JTextComponent) comp).setText(value); } } Object object= r.getData(); if(object!=null) { value= object.toString(); } }else{ VCIOptionPane.showMessage(this,r.getMsg()); } } /** * 根据引用模板的id获取引用模板对象包含的数据 *

Description:

* * @author liujw * @time 2012-11-29 * @param //referTempId 引用模板id */ private void getReferTempRMData(final CodeClassifyTemplateAttrVO tempPropObj,final LinkedHashMap attrIdToCtrlMaps, final List tempPropList) { // 本空窗口调用 有可能来自两处 // 流程任务引用 // 一般的数据录入、修改 // 不同的来源,需要维护好Owner父 /*VCIJDialog ownerDialog = realDialogInstance; if(ownerDialog == null){ ownerDialog = new VCIJDialog(); ownerDialog.setSize(880, 500); }*/ //final String referTempId = tempPropObj.getReferBtmId(); if(StringUtils.isBlank(tempPropObj.getReferConfig())){ VCIOptionPane.showMessage(this,"参照配置信息不正确,请核对!"); return; } final RMDataReferTempDialog dialog = new RMDataReferTempDialog(this,tempPropObj.getReferConfig()); dialog.setDialogCallback(new Runnable() { @Override public void run() { KeyValue keyValue=new KeyValue(); /*if(dialog.isFromTableDoubleClick()){ int index = dialog.getRMDataMainPanel().getTablePanel().getTable().getSelectedRow(); list.clear(); list.add(dialog.getRMDataMainPanel().getTablePanel().getTableModel().getList().get(index).getObject()); }*/ keyValue= dialog.getKeyValue(); //for(CodeClassifyTemplateAttrVO obj : tempPropList) { if(attrIdToCtrlMaps.containsKey(tempPropObj.getId())) { JComponent comp = attrIdToCtrlMaps.get(tempPropObj.getId()); /*if(comp instanceof VCIJTextField) { int index = innnerNamesMaps.get(tempPropObj.getInternalname()); ((VCIJTextField) comp).setText(datas[index]); }else if (comp instanceof VCIJCalendarPanel) { int index = innnerNamesMaps.get(tempPropObj.getInternalname()); ((VCIJCalendarPanel) comp).setDateString(datas[index]); } else */ if (comp instanceof VCIJComboBox) { //DefaultComboBoxModel model = new DefaultComboBoxModel(); if(keyValue!=null) { AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue); ((VCIJComboBox) comp).getModel().setSelectedItem(wrapper); } //model.addElement(wrapper); //((VCIJComboBox) comp).setModel(model); } } //} } }); //dialog.initDialogSize(ownerDialog.getWidth(), ownerDialog.getHeight()); Dimension dime = Toolkit.getDefaultToolkit().getScreenSize(); int x = dime.width/2 - 400; int y = dime.height/2 -300; dialog.setLocation(x, y); dialog.setSize(new Dimension(900, 600)); dialog.setModal(true); dialog.setVisible(true); } private void doSearch(final VCIJComboxBox comboxBox, CodeBasicSecVO secObj){ if(StringUtils.isBlank(secObj.getReferConfig())){ VCIOptionPane.showMessage(this,"参照配置信息不正确,请核对!"); return; } final RMDataReferTempDialog dialog = new RMDataReferTempDialog(this,secObj.getReferConfig()); dialog.setDialogCallback(new Runnable() { @Override public void run() { KeyValue keyValue=new KeyValue(); keyValue= dialog.getKeyValue(); //for(CodeClassifyTemplateAttrVO obj : tempPropList) { if (keyValue != null) { AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue); comboxBox.getModel().setSelectedItem(wrapper); } } }); //dialog.initDialogSize(ownerDialog.getWidth(), ownerDialog.getHeight()); Dimension dime = Toolkit.getDefaultToolkit().getScreenSize(); int x = dime.width/2 - 400; int y = dime.height/2 -300; dialog.setLocation(x, y); dialog.setSize(new Dimension(900, 600)); dialog.setModal(true); dialog.setVisible(true); } /** * 检查申请码值的数据填写是否完整 * 1.检查各个码段的值是否已经填写 * 2.如果有日期码段,并且日期码段的值为可修改,需校验修改后的日期的格式是否符合 * @return */ public boolean checkIsAllowed(){ Iterator ite = compMaps.keySet().iterator(); JComponent compt = null; /**校验1:检查各个码段的值是否已经填写完成**/ while(ite.hasNext()) { int k = ite.next(); //如果是层级码,跳出不进行判断 if(k == levelPositon) { continue; } compt = compMaps.get(k); if(compt instanceof VCIJComboBox) { Object obj = ((VCIJComboBox) compt).getSelectedItem(); if(obj == null || "".equals(obj)) { VCIOptionPane.showMessageDialog(this, "请将信息填写完整!"); return false; } } } int len = columnSecMap.size(); for (int i = 0; i < len; i++) { CodeBasicSecVO secObj = columnSecMap.get(i); String cType = secObj.getSecType(); /**校验2:如果有日期码段,并且日期码段的值为可修改,需校验修改后的日期的格式是否符合**/ if (cType.equals("codedatesec")) { String df =secObj.getCodeDateFormatStr(); SimpleDateFormat dateFormate = new SimpleDateFormat(df); //String curDate = dateFormate.format(Calendar.getInstance().getTime()); dateFormate.setLenient(false);//设置严格校验 String dateStr = (String) ((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem(); try { dateFormate.parse(dateStr); } catch (ParseException e) { VCIOptionPane.showMessageDialog(this, "修改后的日期格式跟日期码段设置的格式不匹配,请修改!"); return false; } /**校验三:可变码段的校验**/ } else if (cType .equals( "codevariablesec")) { tempStr = new StringBuffer(); String codeSecLength =secObj.getCodeSecLength(); int secLen= Integer.parseInt(codeSecLength); //取出用户输入的值 String varStr = (String) ((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem(); if(varStr.length() >secLen){ VCIOptionPane.showMessageDialog(this, "输入的可变码值超出了该码段的定义长度"+codeSecLength+"请修改"); return false; } //如果是固定长度,则需要考虑填充和补位 // if(varObj.getLenType() == SectionConstant.SectionLengthType.VARLEN) { if(varStr.length() < secLen) {//没有达到最大长度 if(secObj.getCodeFillType().equals("L")) {//如果需要左填充 tempStr = new StringBuffer(); for(int j=0;j parentTreeNodeListDesc = new LinkedList(); private LinkedList parentTreeNodeListAsc = new LinkedList(); private String getRuleLevelCodeFromTree(int level){ String res = null; TransmitTreeObject CodeClassifyTreeObj = this.transTreeObject; if(CodeClassifyTreeObj != null){ VCIBaseTreeNode node = CodeClassifyTreeObj.getCurrentTreeNode(); parentTreeNodeListDesc.clear(); //每次进行申请时都重新初始化存储树结构的对象 parentTreeNodeListAsc.clear(); calcParentTreeNode(node); for(int i = parentTreeNodeListDesc.size() - 1; i >=0; i--){ parentTreeNodeListAsc.add(parentTreeNodeListDesc.get(i)); } /***校验:申请码值时,层级的处理 level = 0 标示任意层,level = 99 标示最小层 ,其它指指定层BEGIN**/ if(level == 0) { res = ((CodeClassify)node.getObj()).getId(); /***level == 99 并且是叶子节点时,才允许进行编码申请**/ } else if(level == 99) { if(checkIsHasSonCodeClassify(node)) { res = ((CodeClassify)node.getObj()).getId(); }else { res = ""; } } else if(level == 99 && !checkIsHasSonCodeClassify(node)){ res = ""; } else if(parentTreeNodeListAsc.size() > level + 1) { VCIBaseTreeNode levelNode = parentTreeNodeListAsc.get(level + 1); CodeClassify codeClassify = (CodeClassify) levelNode.getObj(); res = codeClassify.getId(); } else { res = ""; } /**************************************END**********************************/ } return res; } /** * 检查选择的当前分类是否有子分类 *

Description:

* * @author Administrator * @time 2013-4-10 * @return */ public boolean checkIsHasSonCodeClassify(VCIBaseTreeNode node) { int count = 0; if(node.isExpand()) { count = node.getChildCount(); } else { //则需要去查询下面的是否存在 CodeClassify codeClassify = (CodeClassify) node.getObj(); codeClassify.getOid(); Map condtionMap=new HashMap<>(); condtionMap.put("codeClassId", codeClassify.getOid()); Map headerMap=new HashMap<>(); headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token()); R r= HttpUtil.sendGet(url+"/countChildrenByClassifyOid",condtionMap,headerMap); if(r.isSuccess()){ Object object= r.getData(); count=(int)object; } } if(count <= 0) { return true; } return false; } /** * 提供调用者获取各个码段的拼接值 *

Description:

* * @author xf * @time 2012-5-28 * @return */ public List getSectionValues(){ List keyValueList=new ArrayList<>(); if(getCodeRuleVO()!=null) { List codeBasicSecVOList = this.getCodeRuleVO().getSecVOList(); if (!CollectionUtils.isEmpty(codeBasicSecVOList)) { for (int i = 0; i < codeBasicSecVOList.size(); i++) { CodeBasicSecVO secObj=codeBasicSecVOList.get(i); KeyValue keyValue = new KeyValue(); String cVal = ""; String secObjOid = secObj.getOid(); String secType = secObj.getSecType(); /***如果系统选择的是特殊规则,即工装图样代码规则,组别代号码段自动设置为空**Begin***/ if (isSpecialRuleFlag && secObj.getName().equals(specialSectioName)) { cVal = ""; /**********************************End************************/ } else if (secType.equals("codedatesec")) {//日期码段的值 cVal = (String) ((VCIJComboBox) secAndComMap.get(secObj.getId())).getSelectedItem(); } else if (secType.equals("codevariablesec")) {//可变码段的值 // cVal = (String) ((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem(); cVal = tempStr.toString(); } else if (secType.equals("codeclassifysec")) {//分类码段码值 cVal = ((CodeClassifyValue) ((VCIJComboBox) secAndComMap.get(secObj.getId())).getSelectedItem()).getOid(); } else if (secType.equals( "codefixedsec")) {//固定码段码值 cVal = ((CodeFixedValueVO) ((VCIJComboBox) secAndComMap.get(secObj.getId())).getSelectedItem()).getId(); } else if (secType.equals("coderefersec")) {//引用码段码值 // cVal = ((CodeValueObject)((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem()).getPlcodeval(); KeyValue newKeyValue = ((AttrRangObjectWarper) ((VCIJComboBox) secAndComMap.get(secObj.getId())).getSelectedItem()).getKeyValue(); cVal=newKeyValue.getKey(); /*} else if (secType == SectionConstant.SectionType.SECCHAR) {//分隔符 cVal = secObj.getName();*/ } else if (secType.equals("codelevelsec")) {//层级码段 cVal = levelRes; } else if (secType.equals("codeserialsec")) { continue; } else { cVal = (String) ((VCIJComboBox) secAndComMap.get(secObj.getId())).getSelectedItem(); } keyValue.setKey(secObjOid); keyValue.setValue(cVal); keyValueList.add(keyValue); } } } return keyValueList; } /** * 校验模板属性信息是否正确 *

Description:

* * @author Administrator * @time 2013-3-23 * @return */ public String[][] checkInputValues() { Map attrNameMap = new LinkedHashMap(); Map tempProMap = new LinkedHashMap(); // 各属性的内部名称 LinkedList listInnerNames = new LinkedList(); // 存储属性的外部名称 LinkedList listOutNames = new LinkedList(); // 各属性对应的数据值 LinkedList listValues = new LinkedList(); // 各属性的类型 LinkedList listDataTypes = new LinkedList(); Map codeClassifyTemplateAttrVOMap = new HashMap<>(); for (CodeClassifyTemplateAttrVO codeClassifyTemplateAttrVO : transmitForRMData.getTempPropObjsList()) { codeClassifyTemplateAttrVOMap.put(codeClassifyTemplateAttrVO.getId(),codeClassifyTemplateAttrVO); } Iterator keys = attrIdToCtrlMaps.keySet().iterator(); JComponent compt = null; JComponent firstCompt = null; while (keys.hasNext()) { String attrOid = keys.next(); compt = attrIdToCtrlMaps.get(attrOid); String value = ""; CodeClassifyTemplateAttrVO propObj = codeClassifyTemplateAttrVOMap.get(attrOid); boolean isExistError = false; String message = ""; if (compt instanceof JTextComponent) { value = ((JTextComponent) compt).getText(); } else if (compt instanceof VCIJCalendarPanel) { value = ((VCIJCalendarPanel) compt).getDateString(); value = value == null ? "" : value; } else if (compt instanceof VCIJComboBox) { Object objItem = ((VCIJComboBox) compt).getSelectedItem(); if (objItem instanceof AttrRangObjectWarper) { // 属性取值范围 value = ((AttrRangObjectWarper) objItem).getKeyValue().getKey(); } else if (objItem instanceof String) { // Boolean类型的会提供0\1选择 value = (String) objItem; } } boolean checkNullInput = true; if (checkNullInput) { // 检查属性是否可以为空 isNull=0 表示不能为空,isNull=1表示可以为空 if ("true".equals(propObj.getRequireFlag())) {// 不能为空时需要判断输入的值是否为空 if ((value == null) || (value != null && value.trim().length() == 0)) { isExistError = true; compt.requestFocus(); message = propObj.getName() + " 不能为空,请重新输入!"; } } // 校验长度 else if ((value != null && !value.equals("")) && value.length() > Integer.valueOf(propObj.getControlLength()) && !(propObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDate.name())|| propObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDateTime.name())) ) { isExistError = true; compt.requestFocus(); message = propObj.getName() + " 的属性值 " + value + " 的长度不能超过" + propObj.getControlLength(); } // 检查输入的值是否满足属性校验规则(如果存在) if (!isExistError && !propObj.getComponentRule().equals("")) { // 存在着属性校验规则 // 日期类型的不检查属性校验规则 // if (propObj.getAttributeDataType().toUpperCase().equals(Constants.DATA_TYPE_DATE)|| (compt instanceof VCIJComboBox)) { // // 不做检查 // } else { // initAllAttrRuleMaps(); // // 做检查 // if (!value.equals("") && allAttrRulesMap.containsKey(propObj.getAttrRuleId())) { // // TODO 调用属性校验规则的接口,校验当前输入的值是否满足规则条件 // AttrRuleObject attrRuleObj = allAttrRulesMap.get(attrObj.getAttrRuleId()); // String regex = attrRuleObj.getRule(); // Pattern p = Pattern.compile(regex); // if (!p.matcher(value).matches()) { // // 不匹配 // // isExistError = true; // compt.requestFocus(); // message = attrObj.getName() + "的输入值 " + value // + " 不满足该属性定义的校验规则 \n\n" + "" // + attrRuleObj.getRuleName() + ":\t" // + attrRuleObj.getRule() + "\n\n" // + "请重新输入!"; // } // } // } } } // 是否存在错误 if (isExistError) { //setErrorMessageFlag(true); listInnerNames.clear(); listOutNames.clear(); listValues.clear(); listDataTypes.clear(); VCIOptionPane.showMessage(this, message); break; } else { //setErrorMessageFlag(false); // 如果是日期类型,且属性可空,又没有选择日期值,则给个默认值 if (value == null && propObj.getAttributeDataType().toUpperCase().equals(VciFieldTypeEnum.VTDate)) { SimpleDateFormat sdfDateAndTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); value = sdfDateAndTime.format(new Date()); }else if(value == null&&propObj.getAttributeDataType().toUpperCase().equals(VciFieldTypeEnum.VTDateTime)){ SimpleDateFormat sdfDateAndTime = new SimpleDateFormat("HH:mm:ss"); value = sdfDateAndTime.format(new Date()); } // 全部验证通过 value = value.trim(); listInnerNames.add(propObj.getId()); listOutNames.add(propObj.getName()); listValues.add(value); if(propObj.getAttributeDataType().equals(VciFieldTypeEnum.VTFilePath)){ listDataTypes.add("String"); }else{ listDataTypes.add(propObj.getAttributeDataType()); } attrNameMap.put(propObj.getName(), value); tempProMap.put(propObj.getId(), propObj.getId()); } // update by xchao 2012.07.11 if (firstCompt == null) { firstCompt = compt; } }// end while(keys.hadNext()) LinkedList res = new LinkedList(); res.add(listInnerNames.toArray(new String[] {})); res.add(listValues.toArray(new String[] {})); res.add(listDataTypes.toArray(new String[] {})); res.add(listOutNames.toArray(new String[]{})); return res.toArray(new String[][] {}); } private void calcParentTreeNode(VCIBaseTreeNode node){ parentTreeNodeListDesc.add(node); if(node.getParent() != null){ calcParentTreeNode((VCIBaseTreeNode)node.getParent()); } else{ // 根节点 // 来自专用库(带分类显示的) // 由于专用库(带分类显示的)将库节点向上提升了一级,库节点就是根节点 // 因此为保持统计,方便根据层级取分类码(代号),在此将原因的根添加到集合 if(node.getObj() instanceof CodeClassify){ parentTreeNodeListDesc.add(new VCIBaseTreeNode("所有资源数据", "root")); } } } //获取系统配置的码段码值 private Map getSpecialValMap(String[] vals) { Map map = new LinkedHashMap(); for (String val : vals) { map.put(val, "Y"); } return map; } private boolean isNumber(String value) { return Pattern.matches("[0-9]+", value); } public LinkedHashMap getAttrIdToCtrlMaps() { return attrIdToCtrlMaps; } public void setAttrIdToCtrlMaps(LinkedHashMap attrIdToCtrlMaps) { this.attrIdToCtrlMaps = attrIdToCtrlMaps; } public LinkedHashMap getAttrInnerNameToCtrlMaps() { return attrInnerNameToCtrlMaps; } public void setAttrInnerNameToCtrlMaps(LinkedHashMap attrInnerNameToCtrlMaps) { this.attrInnerNameToCtrlMaps = attrInnerNameToCtrlMaps; } public TransmitTreeObject getTransTreeObject() { return transTreeObject; } public void setTransTreeObject(TransmitTreeObject transTreeObject) { this.transTreeObject = transTreeObject; } public CodeRuleVO getCodeRuleVO() { return codeRuleVO; } public void setCodeRuleVO(CodeRuleVO codeRuleVO) { this.codeRuleVO = codeRuleVO; } public TokenUserObject getTokenUserObject() { return tokenUserObject; } public void setTokenUserObject(TokenUserObject tokenUserObject) { this.tokenUserObject = tokenUserObject; } }