xiejun
2025-01-23 9ac3bd680a350c1cc4baad082d92cd2c5f158f3e
Source/UBCS/ubcs-codeApply/src/main/java/com/vci/rmip/code/client/codeapply/Apply410/CodeApplyFor410Dialog.java
@@ -1,6 +1,5 @@
package com.vci.rmip.code.client.codeapply.Apply410;
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.VCISwingUtil;
@@ -12,7 +11,13 @@
import com.vci.rmip.code.client.codeapply.Apply410.utils.ConfigUtils;
import com.vci.rmip.code.client.codeapply.Apply410.utils.HttpUtil;
import javax.swing.*;
import org.apache.commons.lang.StringUtils;
import java.awt.*;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -32,7 +37,7 @@
   private Map<String, String> attrNameAndValMap = new LinkedHashMap();//存储属性名称(包含内部名称和外部名称)和对应的值
   private String tokenUrl= ConfigUtils.getConfigValue("410.code.token.url","http://127.0.0.1:37000/ubcs-auth/oauth/token");
   private String[] fields;
   private String[] Values;
   private String[] values;
   /**
    * 存储分类的Map,key:分类名称,value:分类值
    */
@@ -50,14 +55,19 @@
   public CodeApplyFor410Dialog(JDialog dialog, String clsfName, String deptName) {
      this(dialog, "pdmUser", clsfName, deptName,new String[]{});
   }
   public CodeApplyFor410Dialog(JDialog dialog, String clsfName, String deptName,String[] fields,String[] values) {
      this(dialog, "pdmUser", clsfName, deptName,new String[]{},fields,values);
   }
   public CodeApplyFor410Dialog(Frame frame, String clsfName, String deptName,String[] fields,String[] values){
      this.setModal(true);
      super(frame, true);
      VCISwingUtil.setClientMainFrame(frame);
      //this.setModal(true);
      parentComponet = frame;
      this.userName = userName;
      this.clsfName = clsfName;
      this.deptName = deptName;
      this.fields=fields;
      this.Values=values;
      this.values=values;
      //this.libName = libName;
      init();
@@ -95,6 +105,23 @@
      }
   }
   public CodeApplyFor410Dialog(JDialog dialog, String userName, String clsfName, String deptName, String[] libName,String[] fields,String[] values) {
      super(dialog, true);
      VCISwingUtil.setClientMainFrame(new Frame());
      try {
         this.setModal(true);
         parentComponet = dialog;
         this.userName = userName;
         this.clsfName = clsfName;
         this.deptName = deptName;
         this.fields     = fields;
         this.values     = values;
         init();
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
   private void initUserInfo() throws Exception {
      /*userOb.set("127.0.0.1");
      userOb.setModules("TC集成代码申请");
@@ -103,8 +130,8 @@
      headerMap.put("Tenant-Id",ConfigUtils.getConfigValue("410.code.token.tenantId","000000"));
      headerMap.put("Authorization",ConfigUtils.getConfigValue("410.code.token.authorization","Basic c3dvcmQ6c3dvcmRfc2VjcmV0"));
      headerMap.put("Content-Type",ConfigUtils.getConfigValue("410.code.token.contentType","application/x-www-form-urlencoded"));
      UserObject userObject=new UserObject();
      String userName=ConfigUtils.getConfigValue("410.code.token.username","pdmUser");
      String password=ConfigUtils.getConfigValue("410.code.token.password","21232f297a57a5a743894a0e4a801fc3");
      Map<String,String> parmarMap=new HashMap<>();
      //userObject.set("Tenant-Id",ConfigUtils.getConfigValue("410.code.token.tenantId","000000"));
      /*userObject.setUsername("admin");
@@ -112,8 +139,9 @@
      userObject.setGrant_type("password");
      userObject.setScope("all");
      Object object = JSONObject.toJSON(userObject);*/
      parmarMap.put("username","admin");
      parmarMap.put("password","21232f297a57a5a743894a0e4a801fc3");
      parmarMap.put("username",userName);
      //password=MD5PassWord(password);
      parmarMap.put("password",password);
      parmarMap.put("scope","all");
      parmarMap.put("grant_type","password");
      String result=HttpUtil.sendFormPost(tokenUrl,parmarMap,headerMap);
@@ -122,6 +150,18 @@
      }else{
         throw  new Exception("验证用户鉴权信息失败!");
      }
   }
   private String MD5PassWord (String passWord){
        try {
            MessageDigest   md = MessageDigest.getInstance("MD5");
            byte[] a=md.digest(passWord.getBytes());
            String codestr = new BigInteger(1,a ).toString(16);
            System.out.println(codestr);
            return codestr;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
      return passWord;
   }
   public void buildDialog() {
@@ -152,7 +192,14 @@
   private void bulidPal() throws Exception {
      this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      this.setTitle("代码申请");
      mainPal = new CodeApplyPanelFor410(this,tokenUserObject, true, clsfName, deptName,libName);
      Map<String , String> displayValues = new HashMap<>();
      if(fields != null && fields.length > 0 && values !=null && values.length > 0){
         for (int i = 0; i < fields.length; i++) {
            displayValues.put(fields[i] , values[i]);
         }
      }
      mainPal = new CodeApplyPanelFor410(this,tokenUserObject, true, clsfName, deptName,libName,displayValues);
      VCIJPanel btnPal = new VCIJPanel();
      btnPal.add(okBtn);