xiejun
2023-08-01 87e43c42f5bccbbad9a922ee448834a70088d083
Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeApplyFor410MainPanel.java
@@ -5,10 +5,7 @@
import com.vci.base.ui.swing.VCIOptionPane;
import com.vci.base.ui.swing.components.*;
import com.vci.base.ui.tree.VCIBaseTreeNode;
import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO;
import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO;
import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateVO;
import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO;
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;
@@ -16,6 +13,8 @@
import com.vci.ubcs.codeapply.utils.ConfigUtils;
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 net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
@@ -25,8 +24,11 @@
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.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import java.util.regex.Pattern;
@@ -34,7 +36,7 @@
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";
@@ -141,11 +143,11 @@
      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");
      //String url= ConfigUtils.getConfigValue("410.PDM.rule.url","http://127.0.0.1:36014/codeApplySwingController/getCodeRuleByClassifyFullInfo");
      /**系统只加载代码项  如果libName不为空,直接获取对应的代码项**/
      Map<String,String> condtionMap=new HashMap<>();
      condtionMap.put("codeClassId", rmType.getOid());
      R r=HttpUtil.sendGet(url,condtionMap,new HashMap<>());
      R r=HttpUtil.sendGet(url+"/getCodeRuleByClassifyFullInfo",condtionMap,new HashMap<>());
      CodeRuleVO codeRuleVO=new CodeRuleVO();
      if(r.isSuccess()){
         Object object= r.getData();
@@ -545,6 +547,7 @@
      VCIJComboxBox hisCombo = null;
      try {
         final Map<String, String> secValMap = getSpecialValMap(specialSecVals);
         Map<String,List<String>> secIdTOListValueOidMap=new HashMap<>();
         for(int k = 0;k < secObjs.length; k++) {
            final CodeBasicSecVO secObj = secObjs[k];
            final VCIJComboxBox secCombo = secCombos[k];
@@ -552,27 +555,56 @@
               return;
            }
            if (secObj.getSecType().equals("codeclassifysec")) {// 是分类码
                  continue;
            } else
               // 是固定码
               if (secObj.getSecType() .equals("codefixedsec")) {
            /*   SectionValueClientDelegate codeValDel = new SectionValueClientDelegate(userObj);
               FixCodeValObject[] codeValObjs = codeValDel.fetchFixCodeValBySecId(secObj.getId());// 获取该码段下的所有码段码值对象
               //如果只有一个值,则系统默认选择,不加空值
               if(codeValObjs.length > 1 ) {
                  secCombo.addItem(new FixCodeValObject());
               String  secOid=secObj.getOid();
               String parentClassifySecOid= secObj.getParentClassifySecOid();
               String parentClassifyValueOid="";
               if(secIdTOListValueOidMap.containsKey(parentClassifySecOid)){
                  List<String> parentClassifyValueList= secIdTOListValueOidMap.get(parentClassifySecOid);
                  parentClassifyValueOid= VciBaseUtil.array2String(parentClassifyValueList.toArray(new String[]{}));
               }
               for (int i = 0; i < codeValObjs.length; i++) {
                  secCombo.addItem(codeValObjs[i]);
               Map<String,String> condtionMap=new HashMap<>();
               condtionMap.put("secOid", secOid);
               condtionMap.put("parentClassifyValueOid", parentClassifyValueOid);
               R r=HttpUtil.sendGet(url+"/listCodeClassifyValueBySecOid",condtionMap,new HashMap<>());
               List<CodeClassifyValue> codeClassifyValueList=new ArrayList<>();
               if(r.isSuccess()){
                  Object object= r.getData();
                  if(object!=null) {
                     ObjectMapper objectMapper = new ObjectMapper();
                     try {
                        codeClassifyValueList = objectMapper.readValue(object.toString(), new com.fasterxml.jackson.core.type.TypeReference<List<CodeClassifyValue>>() {});
                     } catch (JsonProcessingException e) {
                        e.printStackTrace();
                     }
                  }
               }else{
                  VCIOptionPane.showMessage(this,r.getMsg());
               }
               *//**当系统选择的是指定码段值时,组别代号的码段系统不显示 Begin**//*
               FixCodeValObject selObj = (FixCodeValObject) secCombo.getSelectedItem();
               if(isSpecialRuleFlag && (secObj.getName().equals(specialControlSecName) && secValMap.containsKey(selObj.getValue())) || secValMap.containsKey(getControlSecSelectValue())) {
                  setComponentStatus(false);
               }else {
                  setComponentStatus(true);
               List<String>valueOidList=new ArrayList<>();
               if(!CollectionUtils.isEmpty(codeClassifyValueList)) {
                  if(codeClassifyValueList.size()>1) {
                     secCombo.addItem(new CodeClassifyValue());
                  }
                  codeClassifyValueList.stream().forEach(codeClassifyValue -> {
                     secCombo.addItem(codeClassifyValue);
                     valueOidList.add(codeClassifyValue.getOid());
                  });
               }
               if (secCombo.getItemCount() > 10){
               secIdTOListValueOidMap.put(secObj.getOid(),valueOidList);
               /**代码项下拉事件**/
               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);
@@ -587,19 +619,51 @@
                  secCombo.setFlag(false);
                  secCombo.getSearchBtn().setVisible(false);
               }*/
            } else
               // 是固定码
               if (secObj.getSecType() .equals("codefixedsec")) {
                  List<CodeFixedValueVO> fixedValueVOList=secObj.getFixedValueVOList();
               //如果只有一个值,则系统默认选择,不加空值
               if(fixedValueVOList.size() >1) {
                  secCombo.addItem(new CodeFixedValue());
               }
               fixedValueVOList.stream().forEach(codeFixedValueVO -> {
                  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")) {
               /*SectionClientDelegate secDel = new SectionClientDelegate(userObj);
               DateSecObject dateObj = secDel.fetchDateSecById(secObj.getId());
               String df = dateObj.getFormat();
               SimpleDateFormat dateFormate = new SimpleDateFormat(df);
               String curDate = dateFormate.format(Calendar.getInstance().getTime());
               secCombo.addItem(curDate);
               if(dateObj.getIsModify().equals("Y")){//可以修改
                  secCombo.setEditable(true);
               }*/
                  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")) {
@@ -630,13 +694,13 @@
               }
            */} else
                  //层级码段码值显示的是选择的代码项的名称
               //层级码段码值显示的是选择的代码项的名称
               if(secObj.getSecType().equals("coderefersec")) {
               /*RMTypeObject rmObj = (RMTypeObject) this.transTreeObject.getCurrentTreeNode().getObj();
               secCombo.addItem(rmObj);*/
            } else {
               secCombo.setEditable(true);
            }
                  CodeClassify rmObj = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
                  secCombo.addItem(rmObj);
               } else {
                  secCombo.setEditable(true);
               }
         }
      }catch (Exception e) {
         e.printStackTrace();
@@ -1003,11 +1067,11 @@
    */
   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");
      //String url= ConfigUtils.getConfigValue("410.PDM.attrKeyValue.url","http://127.0.0.1:36014/codeApplySwingController/listComboboxItems");
      /**系统只加载代码项  如果libName不为空,直接获取对应的代码项**/
      Map<String,String> condtionMap=new HashMap<>();
      condtionMap.put("oid", attrId);
      R r=HttpUtil.sendGet(url,condtionMap,new HashMap<>());
      R r=HttpUtil.sendGet(url+"/listComboboxItems",condtionMap,new HashMap<>());
      List<KeyValue> keyValueList=new ArrayList<>();
      if(r.isSuccess()){
         Object object= r.getData();
@@ -1143,13 +1207,13 @@
      // 流程任务引用
      // 一般的数据录入、修改
      // 不同的来源,需要维护好Owner父
      VCIJDialog ownerDialog = realDialogInstance;
      /*VCIJDialog ownerDialog = realDialogInstance;
      if(ownerDialog == null){
         ownerDialog = new VCIJDialog();
         ownerDialog.setSize(880, 500);
      }
      }*/
      final String referTempId = tempPropObj.getReferBtmId();
      final RMDataReferTempDialog dialog = new RMDataReferTempDialog(ownerDialog, referTempId);
      final RMDataReferTempDialog dialog = new RMDataReferTempDialog(this,tempPropObj);
      dialog.setDialogCallback(new Runnable() {
         @Override
         public void run() {
@@ -1185,9 +1249,9 @@
      //dialog.initDialogSize(ownerDialog.getWidth(), ownerDialog.getHeight());
      Dimension dime = Toolkit.getDefaultToolkit().getScreenSize();
      int x = dime.width/2 - 400;
      int y = dime.height/2 -400;
      int y = dime.height/2 -300;
      dialog.setLocation(x, y);
      dialog.setSize(new Dimension(900, 800));
      dialog.setSize(new Dimension(900, 600));
      dialog.setModal(true);
      dialog.setVisible(true);
   }