| | |
| | | package com.vci.ubcs.codeapply; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.vci.base.ui.swing.VCIOptionPane; |
| | | import com.vci.base.ui.swing.components.VCIJComboBox; |
| | | import com.vci.ubcs.code.dto.CodeOrderDTO; |
| | | import com.vci.ubcs.code.dto.CodeOrderSecDTO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; |
| | | import com.vci.ubcs.codeapply.object.CodeClassify; |
| | | import com.vci.ubcs.codeapply.object.R; |
| | | import com.vci.ubcs.codeapply.utils.ConfigUtils; |
| | | import com.vci.ubcs.codeapply.utils.HttpUtil; |
| | | import com.vci.ubcs.starter.web.pagemodel.KeyValue; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.text.JTextComponent; |
| | | import javax.swing.tree.TreePath; |
| | | import java.awt.event.ActionEvent; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.*; |
| | | |
| | | public class CodeApplyPanelFor410ActionListener extends CommonActionListener { |
| | | private CodeApplyPanelFor410 owner = null; |
| | | private LinkedHashMap<String, Runnable> actionMaps = new LinkedHashMap<String, Runnable>(); |
| | | |
| | | boolean codeAlreadExist = false; |
| | | private String url= ConfigUtils.getConfigValue("410.code.url","http://127.0.0.1:36014/codeApplySwingController"); |
| | | public CodeApplyPanelFor410ActionListener(CodeApplyPanelFor410 owner){ |
| | | this.owner = owner; |
| | | this.initActionMap(); |
| | |
| | | //batchApply();//批量导入申请代码 |
| | | }}); |
| | | actionMaps.put("apply", new Runnable() { public void run() { |
| | | //apply();//码值申请 |
| | | apply();//码值申请 |
| | | }}); |
| | | actionMaps.put("btnSearch", new Runnable() { public void run() { |
| | | //search();//代码查询 |
| | | search();//代码查询 |
| | | }}); |
| | | actionMaps.put("clear", new Runnable() { public void run() { |
| | | // clear();//清空属性 |
| | | clear();//清空属性 |
| | | }}); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | actionMaps.get(key).run(); |
| | | } |
| | | } |
| | | private void apply() { |
| | | codeAlreadExist = false; |
| | | if(null == this.owner.getTransmitTreeObject().getCurrentTreeNode()) { |
| | | return; |
| | | } |
| | | CodeClassify codeClassify = (CodeClassify) this.owner.getTransmitTreeObject().getCurrentTreeNode().getObj(); |
| | | if(codeClassify == null || "".equals(codeClassify.getOid())){ |
| | | VCIOptionPane.showMessage(this.owner, "请选择编码项分类!"); |
| | | return; |
| | | } |
| | | CodeClassifyTemplateVO codeClassifyTemplateVO = this.owner.getCurrentCodeClassifyTemplateVO(); |
| | | if(codeClassifyTemplateVO!=null&&"".equals(codeClassifyTemplateVO.getOid())) { |
| | | VCIOptionPane.showMessageDialog(this.owner, "代码项没有配置模板,不允许申请!"); |
| | | return; |
| | | } |
| | | CodeRuleVO codeRuleVO= this.owner.getRightMainPanel().getCodeRuleVO(); |
| | | /**选择的分类是否包含规则的校验**/ |
| | | if(codeRuleVO==null||"".equals(codeRuleVO.getOid())) { |
| | | VCIOptionPane.showMessage(this.owner, "分类:" + codeClassify.getName() + " 没有包含规则,无法申请!"); |
| | | return; |
| | | } |
| | | //校验规则是否填写合格 |
| | | if(!this.owner.getRightMainPanel().checkIsAllowed()) { |
| | | return; |
| | | } |
| | | |
| | | // 检查模板各属性的输入值是否满足要求 |
| | | String[][] inputValues = this.owner.getRightMainPanel().checkInputValues(); |
| | | String[] fields = inputValues[0]; |
| | | String[] values = inputValues[1]; |
| | | String[] dataTypes = inputValues[2]; |
| | | String[] outNames = inputValues[3]; |
| | | Map<String,String> dataMap=new HashMap<>(); |
| | | for (int i=0;i<fields.length;i++){ |
| | | dataMap.put(fields[i],values[i]); |
| | | } |
| | | List<KeyValue> keyValueList= this.owner.getRightMainPanel().getSectionValues(); |
| | | if(CollectionUtils.isEmpty(keyValueList)){ |
| | | VCIOptionPane.showMessage(this.owner, "分类:" + codeClassify.getName() + " 没有获取规则码段选择值信息,无法申请!"); |
| | | return; |
| | | } |
| | | CodeOrderDTO codeOrderDTO=new CodeOrderDTO(); |
| | | /**系统只加载代码项 如果libName不为空,直接获取对应的代码项**/ |
| | | codeOrderDTO.setCodeClassifyOid(codeClassify.getOid()); |
| | | codeOrderDTO.setTemplateOid(codeClassifyTemplateVO.getOid()); |
| | | codeOrderDTO.setCodeRuleOid(codeRuleVO.getOid()); |
| | | List<CodeOrderSecDTO> secDTOList=new ArrayList<>(); |
| | | keyValueList.stream().forEach(keyValue -> { |
| | | CodeOrderSecDTO codeOrderSecDTO=new CodeOrderSecDTO(); |
| | | codeOrderSecDTO.setSecOid(keyValue.getKey()); |
| | | codeOrderSecDTO.setSecValue(keyValue.getValue()); |
| | | secDTOList.add(codeOrderSecDTO); |
| | | }); |
| | | codeOrderDTO.setSecDTOList(secDTOList); |
| | | codeOrderDTO.setData(dataMap); |
| | | Object object = JSONObject.toJSON(codeOrderDTO); |
| | | Map<String,String> headerMap=new HashMap<>(); |
| | | headerMap.put("content-type","application/json"); |
| | | R r= HttpUtil.sendPost(url+"/addSaveCode",object.toString(),headerMap); |
| | | String code=""; |
| | | if(r.isSuccess()){ |
| | | code=r.getData().toString(); |
| | | this.owner.setApplyCode(code); |
| | | |
| | | }else{ |
| | | VCIOptionPane.showMessage(this.owner,r.getMsg()); |
| | | } |
| | | |
| | | } |
| | | /*** |
| | | * 清空属性 |
| | | */ |
| | | private void clear(){ |
| | | CodeApplyFor410MainPanel rightMainPanel2 = this.owner.getRightMainPanel(); |
| | | LinkedHashMap<String, JComponent> attrInnerNameToCtrlMaps = rightMainPanel2.getAttrInnerNameToCtrlMaps(); |
| | | if(attrInnerNameToCtrlMaps!=null&&attrInnerNameToCtrlMaps.size()>0){ |
| | | attrInnerNameToCtrlMaps.forEach((key,component)->{ |
| | | if(component instanceof JTextComponent){ |
| | | if(((JTextComponent) component).isEnabled()) |
| | | ((JTextComponent) component).setText(""); |
| | | }else if(component instanceof VCIJComboBox){ |
| | | if(((VCIJComboBox) component).isEnabled()) |
| | | ((VCIJComboBox) component).setSelectedIndex(0); |
| | | } |
| | | }); |
| | | } |
| | | String applyCode = this.owner.getApplyCode(); |
| | | if(StringUtils.isBlank(applyCode)) { |
| | | this.owner.setApplyCode(""); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 查询代码 |
| | | */ |
| | | private void search(){ |
| | | if(null == this.owner.getRightMainPanel().getTransTreeObject().getCurrentTreeNode()) { |
| | | return; |
| | | } |
| | | CodeClassify rmType = (CodeClassify) this.owner.getRightMainPanel().getTransTreeObject().getCurrentTreeNode().getObj(); |
| | | if(rmType == null || "".equals(rmType.getId())){ |
| | | VCIOptionPane.showMessage(this.owner, "请选择代码项分类!"); |
| | | return; |
| | | } |
| | | |
| | | CodeApplyFor410SearchDialog dialog = new CodeApplyFor410SearchDialog(this.owner); |
| | | String str = dialog.getStr(); |
| | | if (!str.equals("")) { |
| | | owner.applyTxt.setText(str); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |