| | |
| | | package com.vci.ubcs.codeapply; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.vci.base.ui.swing.VCIOptionPane; |
| | | import com.vci.base.ui.swing.components.*; |
| | | import com.vci.base.ui.tree.VCIBaseTreeNode; |
| | | import com.vci.corba.common.VCIError; |
| | | import com.vci.ubcs.code.vo.pagemodel.*; |
| | | import com.vci.ubcs.codeapply.object.*; |
| | | import com.vci.ubcs.codeapply.swing.IntegerTextField; |
| | | import com.vci.ubcs.codeapply.swing.RealTextField; |
| | | import com.vci.ubcs.codeapply.swing.VCIJComboxBox; |
| | | import com.vci.ubcs.codeapply.utils.ConfigUtils; |
| | | import com.vci.ubcs.codeapply.utils.HttpUtil; |
| | | import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum; |
| | | import com.vci.ubcs.starter.web.pagemodel.KeyValue; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.system.user.entity.User; |
| | | import net.bytebuddy.implementation.bytecode.Throw; |
| | | import io.swagger.models.auth.In; |
| | | import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | |
| | |
| | | import java.awt.event.ActionListener; |
| | | import java.awt.event.MouseAdapter; |
| | | import java.awt.event.MouseEvent; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.List; |
| | |
| | | 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 = null; |
| | | |
| | | private CodeRuleVO codeRuleVO=null; |
| | | /** |
| | | * 属性ID与属性对应的控件之间的映射MAP |
| | | */ |
| | |
| | | /**系统只加载代码项 如果libName不为空,直接获取对应的代码项**/ |
| | | Map<String,String> condtionMap=new HashMap<>(); |
| | | condtionMap.put("codeClassId", rmType.getOid()); |
| | | R r=HttpUtil.sendGet(url+"/getCodeRuleByClassifyFullInfo",condtionMap,new HashMap<>()); |
| | | CodeRuleVO codeRuleVO=new CodeRuleVO(); |
| | | R r= HttpUtil.sendGet(url+"/getCodeRuleByClassifyFullInfo",condtionMap,new HashMap<>()); |
| | | codeRuleVO=new CodeRuleVO(); |
| | | if(r.isSuccess()){ |
| | | Object object= r.getData(); |
| | | if(object!=null) { |
| | |
| | | } 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); |
| | |
| | | |
| | | */} else |
| | | //层级码段码值显示的是选择的代码项的名称 |
| | | if(secObj.getSecType().equals("coderefersec")) { |
| | | if(secObj.getSecType().equals("codelevelsec")) { |
| | | CodeClassify rmObj = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj(); |
| | | secCombo.addItem(rmObj); |
| | | } else { |
| | |
| | | RMDataTransmitObject transmit=new RMDataTransmitObject(); |
| | | transmit.setLibId(libId); |
| | | transmit.setClassifyId(classifyId); |
| | | CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj(); |
| | | transmit.setRmTypeObject(rmType); |
| | | CodeClassify codeClassify = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj(); |
| | | transmit.setRmTypeObject(codeClassify); |
| | | if(currentCodeClassifyTemplateVO!=null) { |
| | | transmit.setTemplateId(templateId); |
| | | Map<String, CodeClassifyTemplateAttrVO> tempPropObjMapsByInnerName = currentCodeClassifyTemplateVO.getAttributes().stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | transmit.setClassifyCode(rmType.getId()); |
| | | transmit.setClassifyCode(codeClassify.getId()); |
| | | transmit.setTempPropObjMapsByInnerName(tempPropObjMapsByInnerName); |
| | | Map<String, CodeClassifyTemplateAttrVO> tempPropObjsMap = currentCodeClassifyTemplateVO.getAttributes().stream().collect(Collectors.toMap(s -> s.getOid().toLowerCase(Locale.ROOT), t -> t)); |
| | | transmit.setTempPropObjsMap(tempPropObjsMap); |
| | |
| | | lbl.setToolTipText("点击此处获取模板对应规则的值"); |
| | | lbl.addMouseListener(new MouseAdapter() { |
| | | public void mouseClicked(MouseEvent e){ |
| | | // getComptAttrValue(attrObj,attrIdToCtrlMaps,transmitForRMData.getTempPropObjsList()); |
| | | getComptAttrValue(attrObj,attrIdToCtrlMaps); |
| | | |
| | | } |
| | | }); |
| | |
| | | pal.add(new VCIJLabel(""),createGridBagConstraints(0, gridy + 1, maxAttrInLine * 2, 1,1.0, 10.0, GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH)); |
| | | this.setTextComptList(textCompts); |
| | | return pal; |
| | | } |
| | | /**根据属性组合规则获取属性的值 **/ |
| | | //add by liujw |
| | | private void getComptAttrValue(CodeClassifyTemplateAttrVO attrObj, LinkedHashMap<String, JComponent> attrIdToCtrlMaps) { |
| | | Map<String, String> attrNameMap = new LinkedHashMap<String, String>(); |
| | | Map<String, String> tempProMap = new LinkedHashMap<String, String>(); |
| | | |
| | | // 各属性的内部名称 |
| | | LinkedList<String> listInnerNames = new LinkedList<String>(); |
| | | // 各属性对应的数据值 |
| | | LinkedList<String> listValues = new LinkedList<String>(); |
| | | // 各属性的类型 |
| | | LinkedList<String> listDataTypes = new LinkedList<String>(); |
| | | |
| | | Iterator<String> keys = attrIdToCtrlMaps.keySet().iterator(); |
| | | JComponent compt = null; |
| | | while (keys.hasNext()) { |
| | | String attrOid = keys.next(); |
| | | compt = attrIdToCtrlMaps.get(attrOid); |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | // 全部验证通过 |
| | | listInnerNames.add(attrObj.getId()); |
| | | listValues.add(value); |
| | | listDataTypes.add(attrObj.getAttributeDataType()); |
| | | |
| | | /**修复属性定义中'/'不能支持的bug**/ |
| | | String attrName = attrObj.getName(); |
| | | if(attrName.indexOf("/") != -1) { |
| | | attrName = attrObj.getName().replaceAll("/", "_"); |
| | | } |
| | | |
| | | attrNameMap.put(attrName, value); |
| | | /****************End******************/ |
| | | tempProMap.put(attrObj.getOid(), attrObj.getId()); |
| | | } |
| | | /**根据模板中配置的属性规则,根据规则对属性数据进行组合或者拆分 BEGIN***/ |
| | | List<CodeClassifyTemplateAttrVO> list = transmitForRMData.getTempPropObjsList(); |
| | | for(CodeClassifyTemplateAttrVO obj : list) { |
| | | if(!"".equals(obj.getComponentRule())) { |
| | | try { |
| | | /**修复属性定义中'/'不能支持的bug Begin**/ |
| | | String tempRule = obj.getComponentRule(); |
| | | if(tempRule.indexOf("/") != -1) { |
| | | tempRule = obj.getComponentRule().replaceAll("/", "_"); |
| | | } |
| | | String value = "";//FreeMarkerCommon.getValueByTempRule(attrNameMap,tempRule); |
| | | /****************End******************/ |
| | | JComponent comp = attrInnerNameToCtrlMaps.get(tempProMap.get(obj.getOid())); |
| | | if(comp instanceof JTextComponent) { |
| | | ((JTextComponent) comp).setText(value); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | /** |
| | | * 获取真实的、实际的需要加载到UI的属性列表 |
| | |
| | | cbx.setModel(model); |
| | | 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)) { // Boolean类型 |
| | | VCIJComboBox cbx = new VCIJComboBox(); |
| | |
| | | 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<String, JComponent> attrIdToCtrlMaps) { |
| | | Map<String,String> dataMap=new HashMap<>(); |
| | | Map<String,String> condtionMap=new HashMap<>(); |
| | | attrIdToCtrlMaps.forEach((key,compt)->{ |
| | | 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()); |
| | | R r= HttpUtil.sendGet(url+"/getValueByFormula",condtionMap,new HashMap<>()); |
| | | 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(); |
| | | |
| | | |
| | | /** |
| | | * 根据引用模板的id获取引用模板对象包含的数据 |
| | | * <p>Description: </p> |
| | | * |
| | | * @author liujw |
| | | * @time 2012-11-29 |
| | | * @param //referTempId 引用模板id |
| | | */ |
| | | } |
| | | }else{ |
| | | VCIOptionPane.showMessage(this,r.getMsg()); |
| | | } |
| | | } |
| | | /** |
| | | * 根据引用模板的id获取引用模板对象包含的数据 |
| | | * <p>Description: </p> |
| | | * |
| | | * @author liujw |
| | | * @time 2012-11-29 |
| | | * @param //referTempId 引用模板id |
| | | */ |
| | | private void getReferTempRMData(final CodeClassifyTemplateAttrVO tempPropObj,final LinkedHashMap<String, JComponent> attrIdToCtrlMaps, |
| | | final List<CodeClassifyTemplateAttrVO> tempPropList) { |
| | | // 本空窗口调用 有可能来自两处 |
| | |
| | | ownerDialog = new VCIJDialog(); |
| | | ownerDialog.setSize(880, 500); |
| | | }*/ |
| | | final String referTempId = tempPropObj.getReferBtmId(); |
| | | final RMDataReferTempDialog dialog = new RMDataReferTempDialog(this,tempPropObj); |
| | | //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() { |
| | | /*LinkedList<RMDataObject> list = dialog.getRMDataMainPanel().getTablePanel().getSelectedRowObjects(); |
| | | if(dialog.isFromTableDoubleClick()){ |
| | | 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()); |
| | | } |
| | | |
| | | RMDataObject rmDataObj = list.get(0);//选择的引用模板数据 |
| | | LinkedHashMap<String, Integer> innnerNamesMaps = rmDataObj.getInnerNameIndexMap(); |
| | | String[] datas = rmDataObj.getDatas(); |
| | | for(CodeClassifyTemplateAttrVO obj : tempPropList) { |
| | | if(obj.getReferTempId().equals(referTempId)) { |
| | | AttributeObject attrObj = getAttrObjById(obj.getReferAttrId()); |
| | | JComponent comp = attrIdToCtrlMaps.get(obj.getId()); |
| | | if(comp instanceof VCIJTextField) { |
| | | int index = innnerNamesMaps.get(attrObj.getInternalname()); |
| | | }*/ |
| | | 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(attrObj.getInternalname()); |
| | | int index = innnerNamesMaps.get(tempPropObj.getInternalname()); |
| | | ((VCIJCalendarPanel) comp).setDateString(datas[index]); |
| | | } else if (comp instanceof VCIJComboBox) { |
| | | int index = innnerNamesMaps.get(attrObj.getId()); |
| | | ((VCIJComboBox) comp).setSelectedIndex(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.setVisible(true); |
| | | } |
| | | |
| | | private void doSearch(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<Integer> 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<secLen - varStr.length();j++) { |
| | | tempStr.append(secObj.getCodeFillSeparator()); |
| | | } |
| | | tempStr.append(varStr); |
| | | } else if(secObj.getCodeFillType().equals("R")) {//如果需要右填充 |
| | | tempStr = new StringBuffer(); |
| | | tempStr.append(varStr); |
| | | for(int j=0;j<secLen- varStr.length();j++) { |
| | | tempStr.append(secObj.getCodeFillSeparator()); |
| | | } |
| | | } else { |
| | | tempStr = new StringBuffer(); |
| | | tempStr.append(varStr); |
| | | } |
| | | } else { |
| | | tempStr = new StringBuffer(); |
| | | tempStr.append(varStr); |
| | | } |
| | | // } |
| | | /**层级码段的校验**/ |
| | | } else if (cType.equals("codelevelsec")) { |
| | | Integer levelVal= secObj.getCodeLevelValue(); |
| | | levelRes = getRuleLevelCodeFromTree(secObj.getCodeLevelValue()); |
| | | if("".equals(levelRes)) { |
| | | // setBuildingHasError(true); |
| | | if(secObj.getCodeLevelType().equals("min")) { |
| | | VCIOptionPane.showError(this, "当前编码项规则中包含层级码段,并且层级设置为最小层,选择的当前节点包含子节点,不允许在当前分类下进行码值申请!"); |
| | | }else { |
| | | VCIOptionPane.showError(this, "请至少在第 " + levelVal + "层(分类)添加数据!(编码项节点不算)" + |
| | | "\n(注意:如果算上编码项节点,则至少应该在第 " + (levelVal + 1) + " 层(分类)添加数据!)"); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | } else if(cType .equals("codeclassifysec")) {//分类码段码值添加了空值,需要特殊判断一下 |
| | | // update by xchao 2013.07.09 |
| | | // ClsfCodeValObject obj = (ClsfCodeValObject) ((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem(); |
| | | // 分类码码值为空时,也可以申请编码 |
| | | // if("".equals(obj.getValue())) { |
| | | // VCIOptionPane.showMessageDialog(this, "请选择码段:"+secObj.getName()+" 对应的码值"); |
| | | // return false; |
| | | // } |
| | | } else if(cType .equals( "codefixedsec")) {//固定码段码值添加了空值,需要特殊判断一下 |
| | | CodeFixedValueVO obj = (CodeFixedValueVO) ((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem(); |
| | | if("".equals(obj.getId())) { |
| | | VCIOptionPane.showMessageDialog(this, "请选择码段:"+secObj.getName()+" 对应的码值"); |
| | | return false; |
| | | } |
| | | } else if(cType.equals("coderefersec")) {//引用码段码值添加了空值,需要特殊判断一下 |
| | | KeyValue keyValue = ((AttrRangObjectWarper)((VCIJComboBox)secAndComMap.get(secObj.getId())).getSelectedItem()).getKeyValue(); |
| | | if(keyValue!=null&&("".equals(keyValue.getValue()))) { |
| | | VCIOptionPane.showMessageDialog(this, "请选择码段:"+secObj.getName()+" 对应的码值"); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | private LinkedList<VCIBaseTreeNode> parentTreeNodeListDesc = new LinkedList<VCIBaseTreeNode>(); |
| | | private LinkedList<VCIBaseTreeNode> parentTreeNodeListAsc = new LinkedList<VCIBaseTreeNode>(); |
| | | 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; |
| | | } |
| | | /** |
| | | * 检查选择的当前分类是否有子分类 |
| | | * <p>Description: </p> |
| | | * |
| | | * @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<String,String> condtionMap=new HashMap<>(); |
| | | condtionMap.put("codeClassId", codeClassify.getOid()); |
| | | R r= HttpUtil.sendGet(url+"/countChildrenByClassifyOid",condtionMap,new HashMap<>()); |
| | | if(r.isSuccess()){ |
| | | Object object= r.getData(); |
| | | count=(int)object; |
| | | } |
| | | } |
| | | if(count <= 0) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 提供调用者获取各个码段的拼接值 |
| | | * <p>Description: </p> |
| | | * |
| | | * @author xf |
| | | * @time 2012-5-28 |
| | | * @return |
| | | */ |
| | | public List<KeyValue> getSectionValues(){ |
| | | List<KeyValue> keyValueList=new ArrayList<>(); |
| | | if(getCodeRuleVO()!=null) { |
| | | List<CodeBasicSecVO> 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.getValue(); |
| | | /*} 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; |
| | | } |
| | | /** |
| | | * 校验模板属性信息是否正确 |
| | | * <p>Description: </p> |
| | | * |
| | | * @author Administrator |
| | | * @time 2013-3-23 |
| | | * @return |
| | | */ |
| | | public String[][] checkInputValues() { |
| | | Map<String, String> attrNameMap = new LinkedHashMap<String, String>(); |
| | | Map<String, String> tempProMap = new LinkedHashMap<String, String>(); |
| | | |
| | | // 各属性的内部名称 |
| | | LinkedList<String> listInnerNames = new LinkedList<String>(); |
| | | // 存储属性的外部名称 |
| | | LinkedList<String> listOutNames = new LinkedList<String>(); |
| | | // 各属性对应的数据值 |
| | | LinkedList<String> listValues = new LinkedList<String>(); |
| | | // 各属性的类型 |
| | | LinkedList<String> listDataTypes = new LinkedList<String>(); |
| | | Map<String,CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOMap=transmitForRMData.getTempPropObjsList().stream().collect(Collectors.toMap(s -> s.getId(), t -> t)); |
| | | Iterator<String> 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().getValue(); |
| | | } 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().toUpperCase().equals(VciFieldTypeEnum.VTDate)|| |
| | | propObj.getAttributeDataType().toUpperCase().equals(VciFieldTypeEnum.VTDateTime)) |
| | | ) { |
| | | 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<String[]> res = new LinkedList<String[]>(); |
| | | |
| | | 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<String, String> getSpecialValMap(String[] vals) { |
| | |
| | | private boolean isNumber(String value) { |
| | | return Pattern.matches("[0-9]+", value); |
| | | } |
| | | |
| | | public LinkedHashMap<String, JComponent> getAttrIdToCtrlMaps() { |
| | | return attrIdToCtrlMaps; |
| | | } |
| | | |
| | | public void setAttrIdToCtrlMaps(LinkedHashMap<String, JComponent> attrIdToCtrlMaps) { |
| | | this.attrIdToCtrlMaps = attrIdToCtrlMaps; |
| | | } |
| | | |
| | | public LinkedHashMap<String, JComponent> getAttrInnerNameToCtrlMaps() { |
| | | return attrInnerNameToCtrlMaps; |
| | | } |
| | | |
| | | public void setAttrInnerNameToCtrlMaps(LinkedHashMap<String, JComponent> 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; |
| | | } |
| | | } |