GlobalData.java 16 KB

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