123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- package com.jtgh.yjpt.common;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Properties;
- import javax.servlet.ServletContext;
- import javax.xml.parsers.DocumentBuilder;
- import javax.xml.parsers.DocumentBuilderFactory;
- import org.springframework.util.StringUtils;
- import org.w3c.dom.Document;
- import org.w3c.dom.Element;
- import org.w3c.dom.NodeList;
- import com.jtgh.qlyg.entity.ApplyFormItem;
- import com.jtgh.yjpt.entity.auth.UserEntity;
- import com.jtgh.yjpt.service.auth.UserService;
- import com.jtgh.yjpt.service.common.CodeService;
- /**
- * 全局信息设置
- */
- public class GlobalData {
- public static int SESSION_TIMEOUT = 1800;
- public static int UPLOAD_FILE_SIZE = 1800;
- public static int UPLOAD_IMAGE_SIZE = 1800;
- public static void init(ServletContext sc) {
- String strTimeout = sc.getInitParameter("session_timeout");
- if (StringUtils.hasLength(strTimeout))
- SESSION_TIMEOUT = Integer.parseInt(strTimeout);
- String strUploadFileSize = sc.getInitParameter("upload_file_size");
- if (StringUtils.hasLength(strUploadFileSize))
- UPLOAD_FILE_SIZE = Integer.parseInt(strUploadFileSize);
- String strUploadImageSize = sc.getInitParameter("upload_image_size");
- if (StringUtils.hasLength(strUploadImageSize))
- UPLOAD_IMAGE_SIZE = Integer.parseInt(strUploadImageSize);
- String strDeployMode = sc.getInitParameter("deploy_mode");
- if (!StringUtils.isEmpty(strDeployMode))
- DEPLOY_MODE = strDeployMode;
- String version = sc.getInitParameter("version");
- if (!StringUtils.isEmpty(version))
- APP_VERSION = version;
- String strCityCode = sc.getInitParameter("city_code");
- if (!StringUtils.isEmpty(strCityCode)) {
- CITY_CODE = strCityCode;
- CodeService codeService = (CodeService) ApplicationContextHelper
- .getBean(CodeService.class);
- DEPT_CODE = codeService.findOne(Long.parseLong(strCityCode))
- .getByzd4() + "JT";
- }
- // String strDeptCode = sc.getInitParameter("dept_code");
- // if (!StringUtils.isEmpty(strDeptCode))
- // DEPT_CODE = strDeptCode;
- String strJaxwsSync = sc.getInitParameter("jaxws_sync");
- if (!StringUtils.isEmpty(strJaxwsSync))
- JAXWS_SYNC = strJaxwsSync;
- String strQlygSync = sc.getInitParameter("qlyg_sync");
- if (!StringUtils.isEmpty(strQlygSync))
- QLYG_SYNC = strQlygSync;
- String strQlygRes = sc.getInitParameter("qlyg_result");
- if (!StringUtils.isEmpty(strQlygRes))
- QLYG_RES = strQlygRes;
- String strOpenMap = sc.getInitParameter("open_map");
- if (!StringUtils.isEmpty(strOpenMap))
- OPEN_MAP = strOpenMap;
- String strProAqpjjg = sc.getInitParameter("pro_aqpjjg");
- if (!StringUtils.isEmpty(strProAqpjjg))
- PRO_AQPJJG = strProAqpjjg;
- String strDefaultPassword = sc.getInitParameter("default_password");
- if (!StringUtils.isEmpty(strDefaultPassword))
- DEFAULT_PASSWORD = strDefaultPassword;
- String strInitMenu = sc.getInitParameter("init_menu");
- if (!StringUtils.isEmpty(strInitMenu))
- INIT_MENU = strInitMenu;
- String tbUser = sc.getInitParameter("tb_user");
- if (!StringUtils.isEmpty(tbUser)) {
- UserService userService = (UserService) ApplicationContextHelper
- .getBean(UserService.class);
- TB_USER = userService.findOne(Long.parseLong(tbUser));
- }
-
- //获得是否启用危险品审批中签章功能的配置信息
- String IsUse_iSignature = sc.getInitParameter("iSignature");
- if(!StringUtils.isEmpty(IsUse_iSignature))
- iSignature = IsUse_iSignature;
-
- try {
- GlobalData.initProperties();
- GlobalData.initApply();
- GlobalData.initApplyItem();
- GlobalData.initApplyForm();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static void initProperties() throws SecurityException,
- NoSuchFieldException, IllegalArgumentException,
- IllegalAccessException {
- // 读取properties属性文件
- InputStream in = GlobalData.class
- .getResourceAsStream("/spring/application.properties");
- Properties p = new Properties();
- try {
- p.load(in);
- } catch (IOException e) {
- e.printStackTrace();
- }
- String prop = "";
- // 省级webservice发布地址
- prop = String.valueOf(p.get("web.province.service.url"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "WEBSERVICE_IP", Constants.class);
- }
- prop = String.valueOf(p.get("web.province.service.port"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "WEBSERVICE_PORT", Constants.class);
- }
- // des密钥
- prop = String.valueOf(p.get("my_yjpt_gkj"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "YJPT_GKJ", Constants.class);
- }
- // birt报表路径
- prop = String.valueOf(p.get("birt.url"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "BIRT_URL", Constants.class);
- }
- prop = String.valueOf(p.get("zysb.time"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "ZYSB_LIMIT", Constants.class);
- }
- prop = String.valueOf(p.get("zysb.version.date"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "ZYSB_VERSION_DATE", Constants.class);
- }
- prop = String.valueOf(p.get("fzns.check.date"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, Integer.parseInt(prop), "FZNS_CHECK_DATE",
- Constants.class);
- }
- prop = String.valueOf(p.get("mapUrl"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "MAP_URL", Constants.class);
- }
- prop = String.valueOf(p.get("jyr.gkyxq"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, Integer.parseInt(prop), "JYR_GKXKZ_WARM",
- Constants.class);
- }
- prop = String.valueOf(p.get("jyr.jzzy.roleType"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "JYR_JZZY_ROLE_TYPE", Constants.class);
- }
- prop = String.valueOf(p.get("dc.sjsp"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "DC_SJSH", Constants.class);
- }
- prop = String.valueOf(p.get("dc.yqzg"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "DC_YQZG", Constants.class);
- }
- prop = String.valueOf(p.get("fz.qrcode"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "FZ_QRCODE", Constants.class);
- }
- prop = String.valueOf(p.get("zysb.check"));
- if(StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "ZYSB_CHECK_72", Constants.class);
- }
- prop = String.valueOf(p.get("password.yxq"));
- if(StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "PASSWORD_YXQ", Constants.class);
- }
- prop = String.valueOf(p.get("api.res.url"));
- if (StringUtils.hasLength(prop)) {
- Utils.setField(null, prop, "API_RES_URL", Constants.class);
- }
-
- }
- /**
- * 初始化权力阳光办件基本信息
- *
- * @throws Exception
- */
- public static void initApply() throws Exception {
- // 得到DOM解析器的工厂实例
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- // 从DOM工厂中获得DOM解析器
- DocumentBuilder dbBuilder = dbFactory.newDocumentBuilder();
- Document doc = null;
- doc = dbBuilder.parse(GlobalData.class.getClassLoader()
- .getResourceAsStream("qlyg/apply.xml"));
- // 得到文档名称为process的元素的节点列表
- NodeList processlist = doc.getElementsByTagName("process");
- if (processlist != null && processlist.getLength() > 0) {
- // 遍历该集合,显示结合中的元素及其子元素的名字
- for (int i = 0; i < processlist.getLength(); i++) {
- Element process = (Element) processlist.item(i);
- String processKey = process.getAttribute("id");
- HashMap<String, Object> processProperties = new HashMap<String, Object>();
- if (processKey != null) {
- NodeList propertyList = process
- .getElementsByTagName("property");
- if (propertyList != null && propertyList.getLength() > 0) {
- // 遍历该集合,显示结合中的元素及其子元素的名字
- for (int j = 0; j < propertyList.getLength(); j++) {
- Element property = (Element) propertyList.item(j);
- if ("int".equals(property.getAttribute("type")))
- processProperties.put(property
- .getAttribute("id"), new Integer(
- property.getAttribute("value")));
- else
- processProperties.put(
- property.getAttribute("id"),
- property.getAttribute("value"));
- }
- }
- qlygApplyMap.put(processKey, processProperties);
- }
- }
- }
- }
- /**
- * 初始化权力阳光办件基本信息
- *
- * @throws Exception
- */
- public static void initApplyItem() throws Exception {
- // 得到DOM解析器的工厂实例
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- // 从DOM工厂中获得DOM解析器
- DocumentBuilder dbBuilder = dbFactory.newDocumentBuilder();
- Document doc = null;
- File baseDir = new File(GlobalData.class.getClassLoader()
- .getResource("qlyg").getPath());
- if (baseDir.exists() && baseDir.isDirectory()) {
- File[] files = baseDir.listFiles();
- if (files != null && files.length > 0) {
- for (File file : files) {
- if (file.getName().startsWith("apply-")) {
- doc = dbBuilder.parse(file);
- // 得到文档名称为process的元素的节点列表
- NodeList processlist = doc
- .getElementsByTagName("process");
- if (processlist != null && processlist.getLength() > 0) {
- setItem(processlist);
- }
- }
- }
- }
- }
- }
- private static void setItem(NodeList processlist) {
- // 遍历该集合,显示结合中的元素及其子元素的名字
- for (int i = 0; i < processlist.getLength(); i++) {
- Element process = (Element) processlist.item(i);
- String processKey = process.getAttribute("id");
- if (processKey != null) {
- HashMap<String, HashMap<String, Object>> applyItemMap = new HashMap<String, HashMap<String, Object>>();
- NodeList applyItemList = process
- .getElementsByTagName("applyItem");
- if (applyItemList != null && applyItemList.getLength() > 0) {
- // 遍历该集合,显示结合中的元素及其子元素的名字
- for (int j = 0; j < applyItemList.getLength(); j++) {
- Element item = (Element) applyItemList.item(j);
- HashMap<String, Object> processProperties = new HashMap<String, Object>();
- NodeList propertyList = item
- .getElementsByTagName("property");
- if (propertyList != null
- && propertyList.getLength() > 0) {
- // 遍历该集合,显示结合中的元素及其子元素的名字
- for (int k = 0; k < propertyList.getLength(); k++) {
- Element property = (Element) propertyList
- .item(k);
- if ("int".equals(property.getAttribute("type"))) {
- processProperties.put(property
- .getAttribute("id"), new Integer(
- property.getAttribute("value")));
- } else if ("long".equals(property
- .getAttribute("type"))) {
- processProperties.put(property
- .getAttribute("id"), new Long(
- property.getAttribute("value")));
- } else {
- processProperties.put(
- property.getAttribute("id"),
- property.getAttribute("value"));
- }
- }
- }
- applyItemMap.put(item.getAttribute("id"),
- processProperties);
- }
- }
- qlygApplyItemMap.put(processKey, applyItemMap);
- }
- }
- }
- /**
- * 初始化流程中需要向权力阳光提交数据的form
- *
- * @throws Exception
- */
- public static void initApplyForm() throws Exception {
- // 得到DOM解析器的工厂实例
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- // 从DOM工厂中获得DOM解析器
- DocumentBuilder dbBuilder = dbFactory.newDocumentBuilder();
- Document doc = null;
- File baseDir = new File(GlobalData.class.getClassLoader()
- .getResource("qlyg").getPath());
- if (baseDir.exists() && baseDir.isDirectory()) {
- File[] files = baseDir.listFiles();
- if (files != null && files.length > 0) {
- for (File file : files) {
- if (file.getName().startsWith("applyForm-")) {
- doc = dbBuilder.parse(file);
- // 得到文档名称为process的元素的节点列表
- NodeList processlist = doc
- .getElementsByTagName("process");
- if (processlist != null && processlist.getLength() > 0) {
- // 遍历该集合,显示结合中的元素及其子元素的名字
- for (int i = 0; i < processlist.getLength(); i++) {
- Element process = (Element) processlist.item(i);
- String processKey = process.getAttribute("id");
- if (processKey != null) {
- List<ApplyFormItem> list = new ArrayList<ApplyFormItem>();
- NodeList formItemList = process
- .getElementsByTagName("formItem");
- if (formItemList != null
- && formItemList.getLength() > 0) {
- // 遍历该集合,显示结合中的元素及其子元素的名字
- for (int j = 0; j < formItemList
- .getLength(); j++) {
- Element item = (Element) formItemList
- .item(j);
- ApplyFormItem formItem = new ApplyFormItem();
- formItem.setId(item
- .getAttribute("id"));
- formItem.setKey(StringUtils.isEmpty(item
- .getAttribute("key")) ? item
- .getAttribute("id") : item
- .getAttribute("key"));
- formItem.setName(item
- .getAttribute("name"));
- formItem.setType(StringUtils.isEmpty(item
- .getAttribute("type")) ? "string"
- : item.getAttribute("type"));
- formItem.setLocale(item
- .getAttribute("locale"));
- list.add(formItem);
- }
- }
- qlygApplyFormMap.put(processKey, list);
- }
- }
- }
- }
- }
- }
- }
- }
- /**
- * 运行模式
- * <p>
- * 0:省级;1:市级
- */
- public static String DEPLOY_MODE = "";
- /** 所在地市 */
- public static String CITY_CODE = "";
- /** 部门编码 */
- public static String DEPT_CODE = "";
- /** 系统版本号 */
- public static String APP_VERSION = "3.5.1";
- /** 是否向权力阳光报送数据 */
- public static String QLYG_SYNC = Constants.YES;
- /** 从web.xml中读取初始化,一般不为0 */
- public static String QLYG_RES = "0";
- /** 是否jax-ws同步 */
- public static String JAXWS_SYNC = Constants.YES;
- /** 是否使用地图资源系统 */
- public static String OPEN_MAP = Constants.YES;
- /** 默认密码 */
- public static String DEFAULT_PASSWORD = "123456";
- /** 是否省级审批安全评价机构备案 */
- public static String PRO_AQPJJG = Constants.NO;
- /**非经营人初始化菜单 */
- public static String INIT_MENU = "003002";
- /** 企业经营人初始化菜单 */
- public static String JJR_MENU = "008001";
- public static boolean isJunit = false;
-
-
- /** 危险品审批是否启用签章,默认不启用*/
- public static String iSignature = Constants.NO;
- /**
- * 超级用户ID
- */
- public static Long adminID = 1l;
- /**
- * 同步到省级统一设置的用户
- */
- public static UserEntity TB_USER = new UserEntity();
- public static String currUserName = "";
- public static String currUsercode = "";
- /** 权力阳光办件基本信息 */
- public static HashMap<String, HashMap<String, Object>> qlygApplyMap = new HashMap<String, HashMap<String, Object>>();
- /** 权力阳光办件过程信息 */
- public static HashMap<String, HashMap<String, HashMap<String, Object>>> qlygApplyItemMap = new HashMap<String, HashMap<String, HashMap<String, Object>>>();
- /** 权力阳光办件form */
- public static HashMap<String, List<ApplyFormItem>> qlygApplyFormMap = new HashMap<String, List<ApplyFormItem>>();
- // /**
- // * web service address
- // */
- // public static String WEB_SERVICE_ADDR = "";
- //
- // /**
- // * web service port
- // */
- // public static String WEB_SERVICE_PORT = "";
- /** session中保存用户信息的key */
- public static final String USER_SESSION_KEY = "USER_SESSION_KEY";
- /** session中保存验证码 */
- public static final String USER_SESSION_CHECK_CODE = "USER_SESSION_CHECK_CODE";
- /** session中保存用户有权限的经营人的ID */
- public static final String USER_SESSION_JYR = "USER_SESSION_JYR";
- /** session中保存用户执行的顺序 */
- public static final String USER_SESSION_STEP = "USER_SESSION_STEP";
- }
|