GlobalData.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. package com.jtgh.yjpt.common;
  2. import java.io.File;
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7. import java.util.List;
  8. import java.util.Properties;
  9. import javax.servlet.ServletContext;
  10. import javax.xml.parsers.DocumentBuilder;
  11. import javax.xml.parsers.DocumentBuilderFactory;
  12. import org.springframework.util.StringUtils;
  13. import org.w3c.dom.Document;
  14. import org.w3c.dom.Element;
  15. import org.w3c.dom.NodeList;
  16. import com.jtgh.qlyg.entity.ApplyFormItem;
  17. import com.jtgh.yjpt.entity.auth.UserEntity;
  18. import com.jtgh.yjpt.service.auth.UserService;
  19. import com.jtgh.yjpt.service.common.CodeService;
  20. /**
  21. * 全局信息设置
  22. */
  23. public class GlobalData {
  24. public static int SESSION_TIMEOUT = 1800;
  25. public static int UPLOAD_FILE_SIZE = 1800;
  26. public static int UPLOAD_IMAGE_SIZE = 1800;
  27. public static void init(ServletContext sc) {
  28. String strTimeout = sc.getInitParameter("session_timeout");
  29. if (StringUtils.hasLength(strTimeout))
  30. SESSION_TIMEOUT = Integer.parseInt(strTimeout);
  31. String strUploadFileSize = sc.getInitParameter("upload_file_size");
  32. if (StringUtils.hasLength(strUploadFileSize))
  33. UPLOAD_FILE_SIZE = Integer.parseInt(strUploadFileSize);
  34. String strUploadImageSize = sc.getInitParameter("upload_image_size");
  35. if (StringUtils.hasLength(strUploadImageSize))
  36. UPLOAD_IMAGE_SIZE = Integer.parseInt(strUploadImageSize);
  37. String strDeployMode = sc.getInitParameter("deploy_mode");
  38. if (!StringUtils.isEmpty(strDeployMode))
  39. DEPLOY_MODE = strDeployMode;
  40. String version = sc.getInitParameter("version");
  41. if (!StringUtils.isEmpty(version))
  42. APP_VERSION = version;
  43. String strCityCode = sc.getInitParameter("city_code");
  44. if (!StringUtils.isEmpty(strCityCode)) {
  45. CITY_CODE = strCityCode;
  46. CodeService codeService = (CodeService) ApplicationContextHelper
  47. .getBean(CodeService.class);
  48. DEPT_CODE = codeService.findOne(Long.parseLong(strCityCode))
  49. .getByzd4() + "JT";
  50. }
  51. // String strDeptCode = sc.getInitParameter("dept_code");
  52. // if (!StringUtils.isEmpty(strDeptCode))
  53. // DEPT_CODE = strDeptCode;
  54. String strJaxwsSync = sc.getInitParameter("jaxws_sync");
  55. if (!StringUtils.isEmpty(strJaxwsSync))
  56. JAXWS_SYNC = strJaxwsSync;
  57. String strQlygSync = sc.getInitParameter("qlyg_sync");
  58. if (!StringUtils.isEmpty(strQlygSync))
  59. QLYG_SYNC = strQlygSync;
  60. String strQlygRes = sc.getInitParameter("qlyg_result");
  61. if (!StringUtils.isEmpty(strQlygRes))
  62. QLYG_RES = strQlygRes;
  63. String strOpenMap = sc.getInitParameter("open_map");
  64. if (!StringUtils.isEmpty(strOpenMap))
  65. OPEN_MAP = strOpenMap;
  66. String strProAqpjjg = sc.getInitParameter("pro_aqpjjg");
  67. if (!StringUtils.isEmpty(strProAqpjjg))
  68. PRO_AQPJJG = strProAqpjjg;
  69. String strDefaultPassword = sc.getInitParameter("default_password");
  70. if (!StringUtils.isEmpty(strDefaultPassword))
  71. DEFAULT_PASSWORD = strDefaultPassword;
  72. String strInitMenu = sc.getInitParameter("init_menu");
  73. if (!StringUtils.isEmpty(strInitMenu))
  74. INIT_MENU = strInitMenu;
  75. String tbUser = sc.getInitParameter("tb_user");
  76. if (!StringUtils.isEmpty(tbUser)) {
  77. UserService userService = (UserService) ApplicationContextHelper
  78. .getBean(UserService.class);
  79. TB_USER = userService.findOne(Long.parseLong(tbUser));
  80. }
  81. //获得是否启用危险品审批中签章功能的配置信息
  82. String IsUse_iSignature = sc.getInitParameter("iSignature");
  83. if(!StringUtils.isEmpty(IsUse_iSignature))
  84. iSignature = IsUse_iSignature;
  85. //获得是否关闭经营人:码头、泊位、储罐、堆场的可编辑功能(增、删、改、复制)
  86. String IsDisableJyrEdit = sc.getInitParameter("JyrDisbleEdit");//从web.xml中读取配置信息
  87. if(!StringUtils.isEmpty(IsDisableJyrEdit)){
  88. JyrDisbleEdit = IsDisableJyrEdit;
  89. }
  90. try {
  91. GlobalData.initProperties();
  92. GlobalData.initApply();
  93. GlobalData.initApplyItem();
  94. GlobalData.initApplyForm();
  95. } catch (Exception e) {
  96. e.printStackTrace();
  97. }
  98. }
  99. public static void initProperties() throws SecurityException,
  100. NoSuchFieldException, IllegalArgumentException,
  101. IllegalAccessException {
  102. // 读取properties属性文件
  103. InputStream in = GlobalData.class
  104. .getResourceAsStream("/spring/application.properties");
  105. Properties p = new Properties();
  106. try {
  107. p.load(in);
  108. } catch (IOException e) {
  109. e.printStackTrace();
  110. }
  111. String prop = "";
  112. // 省级webservice发布地址
  113. prop = String.valueOf(p.get("web.province.service.url"));
  114. if (StringUtils.hasLength(prop)) {
  115. Utils.setField(null, prop, "WEBSERVICE_IP", Constants.class);
  116. }
  117. prop = String.valueOf(p.get("web.province.service.port"));
  118. if (StringUtils.hasLength(prop)) {
  119. Utils.setField(null, prop, "WEBSERVICE_PORT", Constants.class);
  120. }
  121. // des密钥
  122. prop = String.valueOf(p.get("my_yjpt_gkj"));
  123. if (StringUtils.hasLength(prop)) {
  124. Utils.setField(null, prop, "YJPT_GKJ", Constants.class);
  125. }
  126. // birt报表路径
  127. prop = String.valueOf(p.get("birt.url"));
  128. if (StringUtils.hasLength(prop)) {
  129. Utils.setField(null, prop, "BIRT_URL", Constants.class);
  130. }
  131. prop = String.valueOf(p.get("zysb.time"));
  132. if (StringUtils.hasLength(prop)) {
  133. Utils.setField(null, prop, "ZYSB_LIMIT", Constants.class);
  134. }
  135. prop = String.valueOf(p.get("zysb.version.date"));
  136. if (StringUtils.hasLength(prop)) {
  137. Utils.setField(null, prop, "ZYSB_VERSION_DATE", Constants.class);
  138. }
  139. prop = String.valueOf(p.get("fzns.check.date"));
  140. if (StringUtils.hasLength(prop)) {
  141. Utils.setField(null, Integer.parseInt(prop), "FZNS_CHECK_DATE",
  142. Constants.class);
  143. }
  144. prop = String.valueOf(p.get("mapUrl"));
  145. if (StringUtils.hasLength(prop)) {
  146. Utils.setField(null, prop, "MAP_URL", Constants.class);
  147. }
  148. prop = String.valueOf(p.get("jyr.gkyxq"));
  149. if (StringUtils.hasLength(prop)) {
  150. Utils.setField(null, Integer.parseInt(prop), "JYR_GKXKZ_WARM",
  151. Constants.class);
  152. }
  153. prop = String.valueOf(p.get("jyr.jzzy.roleType"));
  154. if (StringUtils.hasLength(prop)) {
  155. Utils.setField(null, prop, "JYR_JZZY_ROLE_TYPE", Constants.class);
  156. }
  157. prop = String.valueOf(p.get("dc.sjsp"));
  158. if (StringUtils.hasLength(prop)) {
  159. Utils.setField(null, prop, "DC_SJSH", Constants.class);
  160. }
  161. prop = String.valueOf(p.get("dc.yqzg"));
  162. if (StringUtils.hasLength(prop)) {
  163. Utils.setField(null, prop, "DC_YQZG", Constants.class);
  164. }
  165. prop = String.valueOf(p.get("fz.qrcode"));
  166. if (StringUtils.hasLength(prop)) {
  167. Utils.setField(null, prop, "FZ_QRCODE", Constants.class);
  168. }
  169. prop = String.valueOf(p.get("zysb.check"));
  170. if(StringUtils.hasLength(prop)) {
  171. Utils.setField(null, prop, "ZYSB_CHECK_72", Constants.class);
  172. }
  173. prop = String.valueOf(p.get("password.yxq"));
  174. if(StringUtils.hasLength(prop)) {
  175. Utils.setField(null, prop, "PASSWORD_YXQ", Constants.class);
  176. }
  177. }
  178. /**
  179. * 初始化权力阳光办件基本信息
  180. *
  181. * @throws Exception
  182. */
  183. public static void initApply() throws Exception {
  184. // 得到DOM解析器的工厂实例
  185. DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
  186. // 从DOM工厂中获得DOM解析器
  187. DocumentBuilder dbBuilder = dbFactory.newDocumentBuilder();
  188. Document doc = null;
  189. doc = dbBuilder.parse(GlobalData.class.getClassLoader()
  190. .getResourceAsStream("qlyg/apply.xml"));
  191. // 得到文档名称为process的元素的节点列表
  192. NodeList processlist = doc.getElementsByTagName("process");
  193. if (processlist != null && processlist.getLength() > 0) {
  194. // 遍历该集合,显示结合中的元素及其子元素的名字
  195. for (int i = 0; i < processlist.getLength(); i++) {
  196. Element process = (Element) processlist.item(i);
  197. String processKey = process.getAttribute("id");
  198. HashMap<String, Object> processProperties = new HashMap<String, Object>();
  199. if (processKey != null) {
  200. NodeList propertyList = process
  201. .getElementsByTagName("property");
  202. if (propertyList != null && propertyList.getLength() > 0) {
  203. // 遍历该集合,显示结合中的元素及其子元素的名字
  204. for (int j = 0; j < propertyList.getLength(); j++) {
  205. Element property = (Element) propertyList.item(j);
  206. if ("int".equals(property.getAttribute("type")))
  207. processProperties.put(property
  208. .getAttribute("id"), new Integer(
  209. property.getAttribute("value")));
  210. else
  211. processProperties.put(
  212. property.getAttribute("id"),
  213. property.getAttribute("value"));
  214. }
  215. }
  216. qlygApplyMap.put(processKey, processProperties);
  217. }
  218. }
  219. }
  220. }
  221. /**
  222. * 初始化权力阳光办件基本信息
  223. *
  224. * @throws Exception
  225. */
  226. public static void initApplyItem() throws Exception {
  227. // 得到DOM解析器的工厂实例
  228. DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
  229. // 从DOM工厂中获得DOM解析器
  230. DocumentBuilder dbBuilder = dbFactory.newDocumentBuilder();
  231. Document doc = null;
  232. File baseDir = new File(GlobalData.class.getClassLoader()
  233. .getResource("qlyg").getPath());
  234. if (baseDir.exists() && baseDir.isDirectory()) {
  235. File[] files = baseDir.listFiles();
  236. if (files != null && files.length > 0) {
  237. for (File file : files) {
  238. if (file.getName().startsWith("apply-")) {
  239. doc = dbBuilder.parse(file);
  240. // 得到文档名称为process的元素的节点列表
  241. NodeList processlist = doc
  242. .getElementsByTagName("process");
  243. if (processlist != null && processlist.getLength() > 0) {
  244. setItem(processlist);
  245. }
  246. }
  247. }
  248. }
  249. }
  250. }
  251. private static void setItem(NodeList processlist) {
  252. // 遍历该集合,显示结合中的元素及其子元素的名字
  253. for (int i = 0; i < processlist.getLength(); i++) {
  254. Element process = (Element) processlist.item(i);
  255. String processKey = process.getAttribute("id");
  256. if (processKey != null) {
  257. HashMap<String, HashMap<String, Object>> applyItemMap = new HashMap<String, HashMap<String, Object>>();
  258. NodeList applyItemList = process
  259. .getElementsByTagName("applyItem");
  260. if (applyItemList != null && applyItemList.getLength() > 0) {
  261. // 遍历该集合,显示结合中的元素及其子元素的名字
  262. for (int j = 0; j < applyItemList.getLength(); j++) {
  263. Element item = (Element) applyItemList.item(j);
  264. HashMap<String, Object> processProperties = new HashMap<String, Object>();
  265. NodeList propertyList = item
  266. .getElementsByTagName("property");
  267. if (propertyList != null
  268. && propertyList.getLength() > 0) {
  269. // 遍历该集合,显示结合中的元素及其子元素的名字
  270. for (int k = 0; k < propertyList.getLength(); k++) {
  271. Element property = (Element) propertyList
  272. .item(k);
  273. if ("int".equals(property.getAttribute("type"))) {
  274. processProperties.put(property
  275. .getAttribute("id"), new Integer(
  276. property.getAttribute("value")));
  277. } else if ("long".equals(property
  278. .getAttribute("type"))) {
  279. processProperties.put(property
  280. .getAttribute("id"), new Long(
  281. property.getAttribute("value")));
  282. } else {
  283. processProperties.put(
  284. property.getAttribute("id"),
  285. property.getAttribute("value"));
  286. }
  287. }
  288. }
  289. applyItemMap.put(item.getAttribute("id"),
  290. processProperties);
  291. }
  292. }
  293. qlygApplyItemMap.put(processKey, applyItemMap);
  294. }
  295. }
  296. }
  297. /**
  298. * 初始化流程中需要向权力阳光提交数据的form
  299. *
  300. * @throws Exception
  301. */
  302. public static void initApplyForm() throws Exception {
  303. // 得到DOM解析器的工厂实例
  304. DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
  305. // 从DOM工厂中获得DOM解析器
  306. DocumentBuilder dbBuilder = dbFactory.newDocumentBuilder();
  307. Document doc = null;
  308. File baseDir = new File(GlobalData.class.getClassLoader()
  309. .getResource("qlyg").getPath());
  310. if (baseDir.exists() && baseDir.isDirectory()) {
  311. File[] files = baseDir.listFiles();
  312. if (files != null && files.length > 0) {
  313. for (File file : files) {
  314. if (file.getName().startsWith("applyForm-")) {
  315. doc = dbBuilder.parse(file);
  316. // 得到文档名称为process的元素的节点列表
  317. NodeList processlist = doc
  318. .getElementsByTagName("process");
  319. if (processlist != null && processlist.getLength() > 0) {
  320. // 遍历该集合,显示结合中的元素及其子元素的名字
  321. for (int i = 0; i < processlist.getLength(); i++) {
  322. Element process = (Element) processlist.item(i);
  323. String processKey = process.getAttribute("id");
  324. if (processKey != null) {
  325. List<ApplyFormItem> list = new ArrayList<ApplyFormItem>();
  326. NodeList formItemList = process
  327. .getElementsByTagName("formItem");
  328. if (formItemList != null
  329. && formItemList.getLength() > 0) {
  330. // 遍历该集合,显示结合中的元素及其子元素的名字
  331. for (int j = 0; j < formItemList
  332. .getLength(); j++) {
  333. Element item = (Element) formItemList
  334. .item(j);
  335. ApplyFormItem formItem = new ApplyFormItem();
  336. formItem.setId(item
  337. .getAttribute("id"));
  338. formItem.setKey(StringUtils.isEmpty(item
  339. .getAttribute("key")) ? item
  340. .getAttribute("id") : item
  341. .getAttribute("key"));
  342. formItem.setName(item
  343. .getAttribute("name"));
  344. formItem.setType(StringUtils.isEmpty(item
  345. .getAttribute("type")) ? "string"
  346. : item.getAttribute("type"));
  347. formItem.setLocale(item
  348. .getAttribute("locale"));
  349. list.add(formItem);
  350. }
  351. }
  352. qlygApplyFormMap.put(processKey, list);
  353. }
  354. }
  355. }
  356. }
  357. }
  358. }
  359. }
  360. }
  361. /**
  362. * 运行模式
  363. * <p>
  364. * 0:省级;1:市级
  365. */
  366. public static String DEPLOY_MODE = "";
  367. /** 所在地市 */
  368. public static String CITY_CODE = "";
  369. /** 部门编码 */
  370. public static String DEPT_CODE = "";
  371. /** 系统版本号 */
  372. public static String APP_VERSION = "3.5.1";
  373. /** 是否向权力阳光报送数据 */
  374. public static String QLYG_SYNC = Constants.YES;
  375. /** 从web.xml中读取初始化,一般不为0 */
  376. public static String QLYG_RES = "0";
  377. /** 是否jax-ws同步 */
  378. public static String JAXWS_SYNC = Constants.YES;
  379. /** 是否使用地图资源系统 */
  380. public static String OPEN_MAP = Constants.YES;
  381. /** 默认密码 */
  382. public static String DEFAULT_PASSWORD = "123456";
  383. /** 是否省级审批安全评价机构备案 */
  384. public static String PRO_AQPJJG = Constants.NO;
  385. /**非经营人初始化菜单 */
  386. public static String INIT_MENU = "003002";
  387. /** 企业经营人初始化菜单 */
  388. public static String JJR_MENU = "008001";
  389. public static boolean isJunit = false;
  390. /** 危险品审批是否启用签章,默认不启用*/
  391. public static String iSignature = Constants.NO;
  392. /** 是否关闭经营人:码头、泊位、储罐、堆场的可编辑功能(增、删、改、复制),默认不关闭 */
  393. public static String JyrDisbleEdit = Constants.NO;
  394. /**
  395. * 超级用户ID
  396. */
  397. public static Long adminID = 1l;
  398. /**
  399. * 同步到省级统一设置的用户
  400. */
  401. public static UserEntity TB_USER = new UserEntity();
  402. public static String currUserName = "";
  403. public static String currUsercode = "";
  404. /** 权力阳光办件基本信息 */
  405. public static HashMap<String, HashMap<String, Object>> qlygApplyMap = new HashMap<String, HashMap<String, Object>>();
  406. /** 权力阳光办件过程信息 */
  407. public static HashMap<String, HashMap<String, HashMap<String, Object>>> qlygApplyItemMap = new HashMap<String, HashMap<String, HashMap<String, Object>>>();
  408. /** 权力阳光办件form */
  409. public static HashMap<String, List<ApplyFormItem>> qlygApplyFormMap = new HashMap<String, List<ApplyFormItem>>();
  410. // /**
  411. // * web service address
  412. // */
  413. // public static String WEB_SERVICE_ADDR = "";
  414. //
  415. // /**
  416. // * web service port
  417. // */
  418. // public static String WEB_SERVICE_PORT = "";
  419. /** session中保存用户信息的key */
  420. public static final String USER_SESSION_KEY = "USER_SESSION_KEY";
  421. /** session中保存验证码 */
  422. public static final String USER_SESSION_CHECK_CODE = "USER_SESSION_CHECK_CODE";
  423. /** session中保存用户有权限的经营人的ID */
  424. public static final String USER_SESSION_JYR = "USER_SESSION_JYR";
  425. /** session中保存用户执行的顺序 */
  426. public static final String USER_SESSION_STEP = "USER_SESSION_STEP";
  427. }