PageRenderTime 193ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 3ms

/hospsys/hospsys/insurance/core/javasrc/com/hospital/HospitalServiceImpl.java

https://bitbucket.org/dkhaliunaa/mal-emneleg
Java | 6998 lines | 5771 code | 1049 blank | 178 comment | 2910 complexity | 6d19225d2d1870b83585b46340c2c348 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. package com.hospital;
  2. import com.auth.HospService;
  3. import com.enumclass.ErrorType;
  4. import com.google.gson.internal.LinkedTreeMap;
  5. import com.hospital.app.*;
  6. import com.model.FavoritePages;
  7. import com.model.Role;
  8. import com.model.User;
  9. import com.model.hos.*;
  10. import com.mongodb.BasicDBObject;
  11. import com.rpc.RpcHandler;
  12. import org.bson.types.ObjectId;
  13. import java.math.BigDecimal;
  14. import java.text.SimpleDateFormat;
  15. import java.time.format.DateTimeFormatter;
  16. import java.util.*;
  17. public class HospitalServiceImpl extends HospService implements HospitalService {
  18. private CheckUserRoleControl roleControl = null;
  19. private ErrorEntity errorEntity = null;
  20. private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  21. public HospitalServiceImpl() {
  22. handler = new RpcHandler<>(this, HospitalService.class);
  23. }
  24. @Override
  25. public BasicDBObject checkSession(String sessionId) {
  26. BasicDBObject basicDBObject = new BasicDBObject();
  27. User loginUser = getUserInfo(sessionId);
  28. basicDBObject.put("session", true);
  29. if (loginUser == null) {
  30. basicDBObject.put("session", false);
  31. }
  32. return basicDBObject;
  33. }
  34. @Override
  35. public List<BasicDBObject> getRoles(String sessionId) {
  36. User user = sessionUser.get(sessionId);
  37. if (user == null) return null;
  38. try {
  39. //Check Role
  40. roleControl = new CheckUserRoleControl(super.conn);
  41. if (roleControl == null) {
  42. return null;
  43. }
  44. return roleControl.getUserAccessMenuList(user);
  45. //End Check Role
  46. } catch (Exception ex) {
  47. ex.printStackTrace();
  48. } finally {
  49. }
  50. return null;
  51. }
  52. @Override
  53. public List<NewsEntity> getNewsData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  54. System.out.println("Hospital Service Implament ::: get news data");
  55. try {
  56. INewsService newsService = new NewsServiceImpl(super.conn);
  57. User user = sessionUser.get(sessionId);
  58. NewsEntity newsEntity = new NewsEntity();
  59. Iterator it = criteria.entrySet().iterator();
  60. while (it.hasNext()) {
  61. Map.Entry pairs = (Map.Entry) it.next();
  62. try {
  63. if (pairs.getKey().equals(newsEntity.ID)) {
  64. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  65. newsEntity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  66. } else if (pairs.getKey().equals(newsEntity.TITLE)) {
  67. newsEntity.setTitle(String.valueOf(pairs.getValue()));
  68. } else if (pairs.getKey().equals(newsEntity.CONTENT)) {
  69. newsEntity.setContent(String.valueOf(pairs.getValue()));
  70. }
  71. } catch (NullPointerException ex) {
  72. ex.printStackTrace();
  73. } catch (Exception ex) {
  74. ex.printStackTrace();
  75. }
  76. }//end while
  77. Date utilDate = new Date();
  78. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  79. try {
  80. newsEntity.setCreby(user.getUsername());
  81. } catch (Exception e) {
  82. newsEntity.setCreby("");
  83. }
  84. if (newsEntity != null) {
  85. return newsService.getListData(newsEntity);
  86. }
  87. } catch (Exception ex) {
  88. ex.printStackTrace();
  89. } finally {
  90. }
  91. return null;
  92. }
  93. @Override
  94. public ErrorEntity setNewsData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  95. System.out.println("Hospital Service Implament ::: set news data");
  96. try {
  97. String command = "EDT";
  98. INewsService newsService = new NewsServiceImpl(super.conn);
  99. User user = sessionUser.get(sessionId);
  100. NewsEntity newsEntity = new NewsEntity();
  101. Iterator it = criteria.entrySet().iterator();
  102. while (it.hasNext()) {
  103. Map.Entry pairs = (Map.Entry) it.next();
  104. try {
  105. if (pairs.getKey().equals(newsEntity.ID)) {
  106. String tmpId = "";
  107. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  108. if (pairs.getValue().toString().contains(".")) {
  109. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  110. }
  111. newsEntity.setId(Long.parseLong(String.valueOf(tmpId)));
  112. }
  113. } else if (pairs.getKey().equals(newsEntity.TITLE)) {
  114. newsEntity.setTitle(String.valueOf(pairs.getValue()));
  115. } else if (pairs.getKey().equals(newsEntity.CONTENT)) {
  116. newsEntity.setContent(String.valueOf(pairs.getValue()));
  117. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  118. command = String.valueOf(pairs.getValue());
  119. }
  120. } catch (NullPointerException ex) {
  121. ex.printStackTrace();
  122. } catch (Exception ex) {
  123. ex.printStackTrace();
  124. }
  125. }//end while
  126. if (command.equalsIgnoreCase("INS")) {
  127. newsEntity.setDelflg("N");
  128. newsEntity.setActflg("Y");
  129. try {
  130. newsEntity.setCreby(user.getUsername());
  131. newsEntity.setModby(user.getUsername());
  132. } catch (NullPointerException e) {
  133. newsEntity.setCreby("");
  134. newsEntity.setModby("");
  135. }
  136. Date utilDate = new Date();
  137. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  138. newsEntity.setCreat(sqlDate);
  139. newsEntity.setModAt(sqlDate);
  140. errorEntity = newsService.insertNewData(newsEntity);
  141. } else if (command.equalsIgnoreCase("EDT") ||
  142. command.equalsIgnoreCase("DEL") ||
  143. command.equalsIgnoreCase("ACT")) {
  144. int quality = 2;
  145. if (command.equalsIgnoreCase("DEL")) {
  146. newsEntity.setDelflg("Y");
  147. quality = 3;
  148. } else if (command.equalsIgnoreCase("ACT")) {
  149. newsEntity.setActflg("N");
  150. }
  151. errorEntity = newsService.updateData(newsEntity);
  152. }
  153. } catch (Exception ex) {
  154. ex.printStackTrace();
  155. } finally {
  156. }
  157. return errorEntity;
  158. }
  159. @Override
  160. public List<Form08Entity> getForm08Data(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  161. System.out.println("Hospital Service Implament ::: get form 08 data");
  162. try {
  163. IForm08Service form08Service = new Form08ServiceImpl(super.conn);
  164. User user = sessionUser.get(sessionId);
  165. Form08Entity form08Entity = new Form08Entity();
  166. Iterator it = criteria.entrySet().iterator();
  167. //Check Role
  168. roleControl = new CheckUserRoleControl(super.conn);
  169. if (roleControl == null) {
  170. return null;
  171. }
  172. menuid = menuid.replaceAll("#", "");
  173. if (!roleControl.checkRole(user, menuid, 1)) {
  174. return null;
  175. }
  176. //End Check Role
  177. while (it.hasNext()) {
  178. Map.Entry pairs = (Map.Entry) it.next();
  179. try {
  180. if (pairs.getKey().equals(form08Entity.ID)) {
  181. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  182. form08Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  183. } else if (pairs.getKey().equals(form08Entity.AIMAG)) {
  184. form08Entity.setAimag(String.valueOf(pairs.getValue()));
  185. } else if (pairs.getKey().equals(form08Entity.SUM)) {
  186. form08Entity.setSum(String.valueOf(pairs.getValue()));
  187. } else if (pairs.getKey().equals(form08Entity.MALTURUL)) {
  188. form08Entity.setMalTurul(String.valueOf(pairs.getValue()));
  189. } else if (pairs.getKey().equals(form08Entity.ARGA_HEMJEE_NER)) {
  190. form08Entity.setArgaHemjeeNer(String.valueOf(pairs.getValue()));
  191. } else if (pairs.getKey().equals(form08Entity.NER)) {
  192. form08Entity.setNer(String.valueOf(pairs.getValue()));
  193. } else if (pairs.getKey().equals(form08Entity.ZARTSUULSAN_HEMJEE)) {
  194. form08Entity.setZartsuulsanHemjee(String.valueOf(pairs.getValue()));
  195. } else if (pairs.getKey().equals(form08Entity.TOLOVLOGOO)) {
  196. form08Entity.setTolovlogoo(String.valueOf(pairs.getValue()));
  197. } else if (pairs.getKey().equals(form08Entity.GUITSETGEL)) {
  198. form08Entity.setGuitsetgel(String.valueOf(pairs.getValue()));
  199. } else if (pairs.getKey().equals(form08Entity.HUVI)) {
  200. form08Entity.setHuvi(String.valueOf(pairs.getValue()));
  201. } else if (pairs.getKey().equals(form08Entity.OLGOSON_TUN)) {
  202. try {
  203. form08Entity.setOLGOSON_TUN(Long.valueOf(pairs.getValue().toString()));
  204. } catch (NumberFormatException e) {
  205. form08Entity.setOLGOSON_TUN(Long.parseLong("0"));
  206. }
  207. } else if (pairs.getKey().equals(form08Entity.HEREGLESEN_TUN)) {
  208. try {
  209. form08Entity.setHEREGLESEN_TUN(Long.valueOf(pairs.getValue().toString()));
  210. } catch (NumberFormatException e) {
  211. form08Entity.setHEREGLESEN_TUN(Long.parseLong("0"));
  212. }
  213. } else if (pairs.getKey().equals(form08Entity.USTGASAN_TUN)) {
  214. try {
  215. form08Entity.setUSTGASAN_TUN(Long.valueOf(pairs.getValue().toString()));
  216. } catch (NumberFormatException e) {
  217. form08Entity.setUSTGASAN_TUN(Long.parseLong("0"));
  218. }
  219. } else if (pairs.getKey().equals(form08Entity.NUUTSULSEN_TUN)) {
  220. try {
  221. form08Entity.setNUUTSULSEN_TUN(Long.valueOf(pairs.getValue().toString()));
  222. } catch (NumberFormatException e) {
  223. form08Entity.setNUUTSULSEN_TUN(Long.parseLong("0"));
  224. }
  225. } else if (pairs.getKey().equals(form08Entity.RECORD_DATE)) {
  226. String dv = String.valueOf(pairs.getValue());
  227. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  228. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  229. form08Entity.setRecordDate(sqlDate);
  230. } else if (pairs.getKey().equals(form08Entity.SEARCH_RECORD_DATE)) {
  231. String dv = String.valueOf(pairs.getValue());
  232. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  233. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  234. form08Entity.setSearchRecordDate(sqlDate);
  235. }
  236. } catch (NullPointerException ex) {
  237. ex.printStackTrace();
  238. } catch (Exception ex) {
  239. ex.printStackTrace();
  240. }
  241. }//end while
  242. Date utilDate = new Date();
  243. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  244. if (form08Entity.getRecordDate() == null) form08Entity.setRecordDate(sqlDate);
  245. if (form08Entity.getSearchRecordDate() == null) form08Entity.setSearchRecordDate(sqlDate);
  246. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  247. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  248. form08Entity.setCreby(user.getUsername());
  249. }
  250. if (form08Entity != null && form08Entity.getRecordDate() != null && form08Entity.getSearchRecordDate() != null) {
  251. return form08Service.getListData(form08Entity);
  252. }
  253. } catch (Exception ex) {
  254. ex.printStackTrace();
  255. } finally {
  256. }
  257. return null;
  258. }
  259. @Override
  260. public ErrorEntity setForm08Data(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  261. System.out.println("Hospital Service Implament ::: get form 08 data");
  262. try {
  263. String command = "EDT";
  264. IForm08Service form08Service = new Form08ServiceImpl(super.conn);
  265. //Begin Check Role Step 1
  266. roleControl = new CheckUserRoleControl(super.conn);
  267. if (roleControl == null) {
  268. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  269. return errorEntity;
  270. }
  271. //End Check Role Step 1
  272. menuid = menuid.replaceAll("#", "");
  273. User user = sessionUser.get(sessionId);
  274. Form08Entity form08Entity = new Form08Entity();
  275. Iterator it = criteria.entrySet().iterator();
  276. while (it.hasNext()) {
  277. Map.Entry pairs = (Map.Entry) it.next();
  278. try {
  279. if (pairs.getKey().equals(form08Entity.ID)) {
  280. String tmpId = "";
  281. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  282. if (pairs.getValue().toString().contains(".")) {
  283. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  284. }
  285. form08Entity.setId(Long.parseLong(String.valueOf(tmpId)));
  286. }
  287. } else if (pairs.getKey().equals(form08Entity.ARGA_HEMJEE_NER)) {
  288. form08Entity.setArgaHemjeeNer(String.valueOf(pairs.getValue()));
  289. } else if (pairs.getKey().equals(form08Entity.AIMAG)) {
  290. form08Entity.setAimag(String.valueOf(pairs.getValue()));
  291. } else if (pairs.getKey().equals(form08Entity.SUM)) {
  292. form08Entity.setSum(String.valueOf(pairs.getValue()));
  293. } else if (pairs.getKey().equals(form08Entity.NER)) {
  294. form08Entity.setNer(String.valueOf(pairs.getValue()));
  295. } else if (pairs.getKey().equals(form08Entity.ZARTSUULSAN_HEMJEE)) {
  296. form08Entity.setZartsuulsanHemjee(String.valueOf(pairs.getValue()));
  297. } else if (pairs.getKey().equals(form08Entity.MALTURUL)) {
  298. form08Entity.setMalTurul(String.valueOf(pairs.getValue()));
  299. } else if (pairs.getKey().equals(form08Entity.TOLOVLOGOO)) {
  300. form08Entity.setTolovlogoo(String.valueOf(pairs.getValue()));
  301. } else if (pairs.getKey().equals(form08Entity.GUITSETGEL)) {
  302. form08Entity.setGuitsetgel(String.valueOf(pairs.getValue()));
  303. } else if (pairs.getKey().equals(form08Entity.HUVI)) {
  304. form08Entity.setHuvi(String.valueOf(pairs.getValue()));
  305. } else if (pairs.getKey().equals(form08Entity.OLGOSON_TUN)) {
  306. try {
  307. form08Entity.setOLGOSON_TUN(Long.valueOf(pairs.getValue().toString()));
  308. } catch (NumberFormatException e) {
  309. form08Entity.setOLGOSON_TUN(Long.parseLong("0"));
  310. }
  311. } else if (pairs.getKey().equals(form08Entity.HEREGLESEN_TUN)) {
  312. try {
  313. form08Entity.setHEREGLESEN_TUN(Long.valueOf(pairs.getValue().toString()));
  314. } catch (NumberFormatException e) {
  315. form08Entity.setHEREGLESEN_TUN(Long.parseLong("0"));
  316. }
  317. } else if (pairs.getKey().equals(form08Entity.USTGASAN_TUN)) {
  318. try {
  319. form08Entity.setUSTGASAN_TUN(Long.valueOf(pairs.getValue().toString()));
  320. } catch (NumberFormatException e) {
  321. form08Entity.setUSTGASAN_TUN(Long.parseLong("0"));
  322. }
  323. } else if (pairs.getKey().equals(form08Entity.NUUTSULSEN_TUN)) {
  324. try {
  325. form08Entity.setNUUTSULSEN_TUN(Long.valueOf(pairs.getValue().toString()));
  326. } catch (NumberFormatException e) {
  327. form08Entity.setNUUTSULSEN_TUN(Long.parseLong("0"));
  328. }
  329. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  330. command = String.valueOf(pairs.getValue());
  331. } else if (pairs.getKey().equals(form08Entity.RECORD_DATE)) {
  332. String dv = String.valueOf(pairs.getValue());
  333. if (!dv.isEmpty() && dv.length() >= 8) {
  334. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  335. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  336. form08Entity.setRecordDate(sqlDate);
  337. }
  338. }
  339. } catch (NullPointerException ex) {
  340. ex.printStackTrace();
  341. } catch (Exception ex) {
  342. ex.printStackTrace();
  343. }
  344. }//end while
  345. if (command.equalsIgnoreCase("INS")) {
  346. form08Entity.setDelflg("N");
  347. form08Entity.setActflg("Y");
  348. if (user != null && (user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  349. || user.getRoleCode().equalsIgnoreCase("ADMIN"))) {
  350. //Aimag songoh shaardlagagui
  351. } else {
  352. form08Entity.setAimag(user.getCity());
  353. }
  354. //form08Entity.setSum(user.getSum());
  355. form08Entity.setCreby(user.getUsername());
  356. Date utilDate = new Date();
  357. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  358. form08Entity.setCreat(sqlDate);
  359. if (form08Entity.getRecordDate() == null) form08Entity.setCreat(sqlDate);
  360. //Begin Check Role Step 2
  361. if (roleControl.checkRole(user, menuid, 2)) {
  362. errorEntity = form08Service.insertNewData(form08Entity);
  363. } else {
  364. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  365. }
  366. //End Check Role Step 2
  367. } else if (command.equalsIgnoreCase("EDT") ||
  368. command.equalsIgnoreCase("DEL") ||
  369. command.equalsIgnoreCase("ACT")) {
  370. int quality = 2;
  371. if (command.equalsIgnoreCase("DEL")) {
  372. form08Entity.setDelflg("Y");
  373. quality = 3;
  374. } else if (command.equalsIgnoreCase("ACT")) {
  375. form08Entity.setActflg("N");
  376. }
  377. //Begin Check Role Step 2
  378. if (roleControl.checkRole(user, menuid, quality)) {
  379. errorEntity = form08Service.updateData(form08Entity);
  380. } else {
  381. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  382. }
  383. //End Check Role Step 2
  384. }
  385. } catch (Exception ex) {
  386. ex.printStackTrace();
  387. } finally {
  388. }
  389. return errorEntity;
  390. }
  391. // Begin-form09
  392. @Override
  393. public List<Form09Entity> getForm09Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  394. System.out.println("Hospital Service Implament ::: get form 09 data");
  395. try {
  396. IForm09Service form09Service = new Form09ServiceImpl(super.conn);
  397. User user = sessionUser.get(sessionId);
  398. Form09Entity form09Entity = new Form09Entity();
  399. Iterator it = criteria.entrySet().iterator();
  400. while (it.hasNext()) {
  401. Map.Entry pairs = (Map.Entry) it.next();
  402. try {
  403. if (pairs.getKey().equals(form09Entity.ID)) {
  404. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  405. form09Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  406. } else if (pairs.getKey().equals(form09Entity.AIMAG)) {
  407. form09Entity.setAimag(String.valueOf(pairs.getValue()));
  408. } else if (pairs.getKey().equals(form09Entity.SUM)) {
  409. form09Entity.setSum(form09Entity.SUM);
  410. } else if (pairs.getKey().equals(form09Entity.MALTURUL)) {
  411. form09Entity.setMalTurul(String.valueOf(pairs.getValue()));
  412. } else if (pairs.getKey().equals(form09Entity.TARILGANER)) {
  413. form09Entity.setTarilgaNer(String.valueOf(pairs.getValue()));
  414. } else if (pairs.getKey().equals(form09Entity.NER)) {
  415. form09Entity.setNer(String.valueOf(pairs.getValue()));
  416. } else if (pairs.getKey().equals(form09Entity.ZARTSUULSANHEMJEE)) {
  417. form09Entity.setZartsuulsanHemjee(String.valueOf(pairs.getValue()));
  418. } else if (pairs.getKey().equals(form09Entity.TOLOVLOGOO)) {
  419. form09Entity.setTolovlogoo(String.valueOf(pairs.getValue()));
  420. } else if (pairs.getKey().equals(form09Entity.GUITSETGEL)) {
  421. form09Entity.setGuitsetgel(String.valueOf(pairs.getValue()));
  422. } else if (pairs.getKey().equals(form09Entity.HUVI)) {
  423. form09Entity.setHuvi(String.valueOf(pairs.getValue()));
  424. } else if (pairs.getKey().equals(form09Entity.OLGOSON_TUN)) {
  425. try {
  426. form09Entity.setOLGOSON_TUN(Long.valueOf(pairs.getValue().toString()));
  427. } catch (NumberFormatException e) {
  428. form09Entity.setOLGOSON_TUN(Long.parseLong("0"));
  429. }
  430. } else if (pairs.getKey().equals(form09Entity.HEREGLESEN_TUN)) {
  431. try {
  432. form09Entity.setHEREGLESEN_TUN(Long.valueOf(pairs.getValue().toString()));
  433. } catch (NumberFormatException e) {
  434. form09Entity.setHEREGLESEN_TUN(Long.parseLong("0"));
  435. }
  436. } else if (pairs.getKey().equals(form09Entity.USTGASAN_TUN)) {
  437. try {
  438. form09Entity.setUSTGASAN_TUN(Long.valueOf(pairs.getValue().toString()));
  439. } catch (NumberFormatException e) {
  440. form09Entity.setUSTGASAN_TUN(Long.parseLong("0"));
  441. }
  442. } else if (pairs.getKey().equals(form09Entity.NUUTSULSEN_TUN)) {
  443. try {
  444. form09Entity.setNUUTSULSEN_TUN(Long.valueOf(pairs.getValue().toString()));
  445. } catch (NumberFormatException e) {
  446. form09Entity.setNUUTSULSEN_TUN(Long.parseLong("0"));
  447. }
  448. } else if (pairs.getKey().equals(form09Entity.RECORD_DATE)) {
  449. String dv = String.valueOf(pairs.getValue());
  450. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  451. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  452. form09Entity.setRecordDate(sqlDate);
  453. } else if (pairs.getKey().equals(form09Entity.SEARCH_RECORD_DATE)) {
  454. String dv = String.valueOf(pairs.getValue());
  455. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  456. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  457. form09Entity.setSearchRecordDate(sqlDate);
  458. }
  459. } catch (NullPointerException ex) {
  460. ex.printStackTrace();
  461. } catch (Exception ex) {
  462. ex.printStackTrace();
  463. }
  464. }//end while
  465. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  466. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  467. form09Entity.setCreby(user.getUsername());
  468. }
  469. return form09Service.getListData(form09Entity);
  470. } catch (Exception ex) {
  471. ex.printStackTrace();
  472. } finally {
  473. }
  474. return null;
  475. }
  476. @Override
  477. public ErrorEntity setForm09Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  478. System.out.println("Hospital Service Implament ::: get form 09 data");
  479. try {
  480. String command = "EDT";
  481. IForm09Service form09Service = new Form09ServiceImpl(super.conn);
  482. User user = sessionUser.get(sessionId);
  483. Form09Entity form09Entity = new Form09Entity();
  484. Iterator it = criteria.entrySet().iterator();
  485. while (it.hasNext()) {
  486. Map.Entry pairs = (Map.Entry) it.next();
  487. try {
  488. if (pairs.getKey().equals(form09Entity.ID)) {
  489. String tmpId = "";
  490. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  491. if (pairs.getValue().toString().contains(".")) {
  492. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  493. }
  494. form09Entity.setId(Long.parseLong(String.valueOf(tmpId)));
  495. }
  496. } else if (pairs.getKey().equals(form09Entity.TARILGANER)) {
  497. form09Entity.setTarilgaNer(String.valueOf(pairs.getValue()));
  498. } else if (pairs.getKey().equals(form09Entity.NER)) {
  499. form09Entity.setNer(String.valueOf(pairs.getValue()));
  500. } else if (pairs.getKey().equals(form09Entity.ZARTSUULSANHEMJEE)) {
  501. form09Entity.setZartsuulsanHemjee(String.valueOf(pairs.getValue()));
  502. } else if (pairs.getKey().equals(form09Entity.MALTURUL)) {
  503. form09Entity.setMalTurul(String.valueOf(pairs.getValue()));
  504. } else if (pairs.getKey().equals(form09Entity.TOLOVLOGOO)) {
  505. form09Entity.setTolovlogoo(String.valueOf(pairs.getValue()));
  506. } else if (pairs.getKey().equals(form09Entity.GUITSETGEL)) {
  507. form09Entity.setGuitsetgel(String.valueOf(pairs.getValue()));
  508. } else if (pairs.getKey().equals(form09Entity.HUVI)) {
  509. form09Entity.setHuvi(String.valueOf(pairs.getValue()));
  510. } else if (pairs.getKey().equals(form09Entity.OLGOSON_TUN)) {
  511. try {
  512. form09Entity.setOLGOSON_TUN(Long.valueOf(pairs.getValue().toString()));
  513. } catch (NumberFormatException e) {
  514. form09Entity.setOLGOSON_TUN(Long.parseLong("0"));
  515. }
  516. } else if (pairs.getKey().equals(form09Entity.HEREGLESEN_TUN)) {
  517. try {
  518. form09Entity.setHEREGLESEN_TUN(Long.valueOf(pairs.getValue().toString()));
  519. } catch (NumberFormatException e) {
  520. form09Entity.setHEREGLESEN_TUN(Long.parseLong("0"));
  521. }
  522. } else if (pairs.getKey().equals(form09Entity.USTGASAN_TUN)) {
  523. try {
  524. form09Entity.setUSTGASAN_TUN(Long.valueOf(pairs.getValue().toString()));
  525. } catch (NumberFormatException e) {
  526. form09Entity.setUSTGASAN_TUN(Long.parseLong("0"));
  527. }
  528. } else if (pairs.getKey().equals(form09Entity.NUUTSULSEN_TUN)) {
  529. try {
  530. form09Entity.setNUUTSULSEN_TUN(Long.valueOf(pairs.getValue().toString()));
  531. } catch (NumberFormatException e) {
  532. form09Entity.setNUUTSULSEN_TUN(Long.parseLong("0"));
  533. }
  534. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  535. command = String.valueOf(pairs.getValue());
  536. } else if (pairs.getKey().equals(form09Entity.RECORD_DATE)) {
  537. String dv = String.valueOf(pairs.getValue());
  538. if (!dv.isEmpty() && dv.length() >= 8) {
  539. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  540. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  541. form09Entity.setRecordDate(sqlDate);
  542. }
  543. }
  544. } catch (NullPointerException ex) {
  545. ex.printStackTrace();
  546. } catch (Exception ex) {
  547. ex.printStackTrace();
  548. }
  549. }//end while
  550. if (command.equalsIgnoreCase("INS")) {
  551. form09Entity.setDelflg("N");
  552. form09Entity.setActflg("Y");
  553. form09Entity.setAimag(user.getCity());
  554. form09Entity.setSum(user.getSum());
  555. form09Entity.setCreby(user.getUsername());
  556. Date utilDate = new Date();
  557. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  558. form09Entity.setCreat(sqlDate);
  559. if (form09Entity.getRecordDate() == null) form09Entity.setCreat(sqlDate);
  560. errorEntity = form09Service.insertNewData(form09Entity);
  561. } else if (command.equalsIgnoreCase("EDT") ||
  562. command.equalsIgnoreCase("DEL") ||
  563. command.equalsIgnoreCase("ACT")) {
  564. if (command.equalsIgnoreCase("DEL")) {
  565. form09Entity.setDelflg("Y");
  566. } else if (command.equalsIgnoreCase("ACT")) {
  567. form09Entity.setActflg("N");
  568. }
  569. errorEntity = form09Service.updateData(form09Entity);
  570. }
  571. } catch (Exception ex) {
  572. ex.printStackTrace();
  573. } finally {
  574. }
  575. return errorEntity;
  576. }
  577. // end-form09
  578. @Override
  579. public List<Form11Entity> getForm11Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  580. System.out.println("Hospital Service Implament ::: get form 11 data");
  581. try {
  582. IForm11Service form11Service = new Form11ServiceImpl(super.conn);
  583. User user = sessionUser.get(sessionId);
  584. Form11Entity form11Entity = new Form11Entity();
  585. Iterator it = criteria.entrySet().iterator();
  586. while (it.hasNext()) {
  587. Map.Entry pairs = (Map.Entry) it.next();
  588. try {
  589. if (pairs.getKey().equals(form11Entity.ID)) {
  590. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  591. form11Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  592. }
  593. } else if (pairs.getKey().equals(form11Entity.AIMAG)) {
  594. form11Entity.setAimag(String.valueOf(pairs.getValue()));
  595. } else if (pairs.getKey().equals(form11Entity.SUM)) {
  596. form11Entity.setSum(String.valueOf(pairs.getValue()));
  597. } else if (pairs.getKey().equals(form11Entity.BAGCODE)) {
  598. form11Entity.setBagCode(String.valueOf(pairs.getValue()));
  599. } else if (pairs.getKey().equals(form11Entity.MALTURUL)) {
  600. form11Entity.setMalTurul(String.valueOf(pairs.getValue()));
  601. } else if (pairs.getKey().equals(form11Entity.DEEJIINTURUL)) {
  602. form11Entity.setDeejiinTurul(String.valueOf(pairs.getValue()));
  603. } else if (pairs.getKey().equals(form11Entity.SUMBAGNER)) {
  604. form11Entity.setSumBagNer(String.valueOf(pairs.getValue()));
  605. } else if (pairs.getKey().equals(form11Entity.TOOTOLGOI)) {
  606. try {
  607. form11Entity.setTooTolgoi(Long.parseLong(String.valueOf(pairs.getValue())));
  608. } catch (Exception e) {
  609. form11Entity.setTooTolgoi(Long.parseLong(String.valueOf("0")));
  610. }
  611. } else if (pairs.getKey().equals(form11Entity.HAANASHINJILSEN)) {
  612. form11Entity.setHaanaShinjilsen(String.valueOf(pairs.getValue()));
  613. } else if (pairs.getKey().equals(form11Entity.SHINJILSENARGA)) {
  614. form11Entity.setShinjilsenArga(String.valueOf(pairs.getValue()));
  615. } else if (pairs.getKey().equals(form11Entity.ERUUL)) {
  616. try {
  617. form11Entity.setEruul(Long.parseLong(String.valueOf(pairs.getValue())));
  618. } catch (Exception e) {
  619. form11Entity.setEruul(Long.parseLong(String.valueOf("0")));
  620. }
  621. } else if (pairs.getKey().equals(form11Entity.UVCHTEI)) {
  622. try {
  623. form11Entity.setUvchtei(Long.parseLong(String.valueOf(pairs.getValue())));
  624. } catch (Exception e) {
  625. form11Entity.setUvchtei(Long.parseLong(String.valueOf("0")));
  626. }
  627. } else if (pairs.getKey().equals(form11Entity.ONOSH)) {
  628. try {
  629. form11Entity.setOnosh(Long.parseLong(String.valueOf(pairs.getValue())));
  630. } catch (Exception e) {
  631. form11Entity.setOnosh(Long.parseLong(String.valueOf("0")));
  632. }
  633. } else if (pairs.getKey().equals(form11Entity.RECORD_DATE)) {
  634. String dv = String.valueOf(pairs.getValue());
  635. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  636. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  637. form11Entity.setRecordDate(sqlDate);
  638. } else if (pairs.getKey().equals(form11Entity.SEARCH_RECORD_DATE)) {
  639. String dv = String.valueOf(pairs.getValue());
  640. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  641. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  642. form11Entity.setSearchRecordDate(sqlDate);
  643. }
  644. } catch (NullPointerException ex) {
  645. ex.printStackTrace();
  646. } catch (Exception ex) {
  647. ex.printStackTrace();
  648. }
  649. }//end while
  650. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  651. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  652. form11Entity.setCreby(user.getUsername());
  653. }
  654. if (form11Entity != null && form11Entity.getRecordDate() != null && form11Entity.getSearchRecordDate() != null) {
  655. return form11Service.getListData(form11Entity);
  656. }
  657. } catch (Exception ex) {
  658. ex.printStackTrace();
  659. } finally {
  660. }
  661. return null;
  662. }
  663. @Override
  664. public ErrorEntity setForm11Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  665. System.out.println("Hospital Service Implament ::: get form 11 data");
  666. try {
  667. String command = "EDT";
  668. IForm11Service form11Service = new Form11ServiceImpl(super.conn);
  669. User user = sessionUser.get(sessionId);
  670. Form11Entity form11Entity = new Form11Entity();
  671. Iterator it = criteria.entrySet().iterator();
  672. while (it.hasNext()) {
  673. Map.Entry pairs = (Map.Entry) it.next();
  674. try {
  675. if (pairs.getKey().equals(form11Entity.ID)) {
  676. String tmpId = "";
  677. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  678. if (pairs.getValue().toString().contains(".")) {
  679. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  680. }
  681. form11Entity.setId(Long.parseLong(String.valueOf(tmpId)));
  682. }
  683. } else if (pairs.getKey().equals(form11Entity.DEEJIINTURUL)) {
  684. form11Entity.setDeejiinTurul(String.valueOf(pairs.getValue()));
  685. } else if (pairs.getKey().equals(form11Entity.AIMAG)) {
  686. form11Entity.setAimag(String.valueOf(pairs.getValue()));
  687. } else if (pairs.getKey().equals(form11Entity.SUMBAGNER)) {
  688. form11Entity.setSumBagNer(String.valueOf(pairs.getValue()));
  689. } else if (pairs.getKey().equals(form11Entity.SUM)) {
  690. form11Entity.setSum(String.valueOf(pairs.getValue()));
  691. } else if (pairs.getKey().equals(form11Entity.BAGCODE)) {
  692. form11Entity.setBagCode(String.valueOf(pairs.getValue()));
  693. } else if (pairs.getKey().equals(form11Entity.MALTURUL)) {
  694. form11Entity.setMalTurul(String.valueOf(pairs.getValue()));
  695. } else if (pairs.getKey().equals(form11Entity.TOOTOLGOI)) {
  696. form11Entity.setTooTolgoi(Long.parseLong(String.valueOf(pairs.getValue())));
  697. } else if (pairs.getKey().equals(form11Entity.HAANASHINJILSEN)) {
  698. form11Entity.setHaanaShinjilsen(String.valueOf(pairs.getValue()));
  699. } else if (pairs.getKey().equals(form11Entity.SHINJILSENARGA)) {
  700. form11Entity.setShinjilsenArga(String.valueOf(pairs.getValue()));
  701. } else if (pairs.getKey().equals(form11Entity.ERUUL)) {
  702. form11Entity.setEruul(Long.parseLong(String.valueOf(pairs.getValue())));
  703. } else if (pairs.getKey().equals(form11Entity.UVCHTEI)) {
  704. form11Entity.setUvchtei(Long.parseLong(String.valueOf(pairs.getValue())));
  705. } else if (pairs.getKey().equals(form11Entity.ONOSH)) {
  706. form11Entity.setOnosh(Long.parseLong(String.valueOf(pairs.getValue())));
  707. } else if (pairs.getKey().equals(form11Entity.RECORD_DATE)) {
  708. String dv = String.valueOf(pairs.getValue());
  709. if (!dv.isEmpty() && dv.length() >= 8) {
  710. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  711. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  712. form11Entity.setRecordDate(sqlDate);
  713. }
  714. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  715. command = String.valueOf(pairs.getValue());
  716. }
  717. } catch (NullPointerException ex) {
  718. ex.printStackTrace();
  719. } catch (Exception ex) {
  720. ex.printStackTrace();
  721. }
  722. }//end while
  723. Date utilDate = new Date();
  724. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  725. form11Entity.setModby(user.getUsername());
  726. form11Entity.setModAt(sqlDate);
  727. if (command.equalsIgnoreCase("INS")) {
  728. form11Entity.setDelflg("N");
  729. form11Entity.setActflg("Y");
  730. if (user != null && (user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  731. || user.getRoleCode().equalsIgnoreCase("ADMIN"))) {
  732. //Aimag songoh shaardlagagui
  733. } else {
  734. form11Entity.setAimag(user.getCity());
  735. }
  736. //form11Entity.setSum(user.getSum());
  737. form11Entity.setCreby(user.getUsername());
  738. form11Entity.setCreat(sqlDate);
  739. if (form11Entity.getRecordDate() == null) form11Entity.setCreat(sqlDate);
  740. errorEntity = form11Service.insertNewData(form11Entity);
  741. } else if (command.equalsIgnoreCase("EDT") ||
  742. command.equalsIgnoreCase("DEL") ||
  743. command.equalsIgnoreCase("ACT")) {
  744. if (command.equalsIgnoreCase("DEL")) {
  745. form11Entity.setDelflg("Y");
  746. } else if (command.equalsIgnoreCase("ACT")) {
  747. form11Entity.setActflg("N");
  748. }
  749. errorEntity = form11Service.updateData(form11Entity);
  750. }
  751. } catch (Exception ex) {
  752. ex.printStackTrace();
  753. } finally {
  754. }
  755. return errorEntity;
  756. }
  757. // Begin-form14
  758. @Override
  759. public List<Form14Entity> getForm14Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  760. System.out.println("Hospital Service Implament ::: get form 14 data");
  761. try {
  762. IForm14Service form14Service = new Form14ServiceImpl(super.conn);
  763. User user = sessionUser.get(sessionId);
  764. Form14Entity form14Entity = new Form14Entity();
  765. Iterator it = criteria.entrySet().iterator();
  766. while (it.hasNext()) {
  767. Map.Entry pairs = (Map.Entry) it.next();
  768. try {
  769. if (pairs.getKey().equals(form14Entity.ID)) {
  770. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  771. form14Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  772. } else if (pairs.getKey().equals(form14Entity.AIMAG)) {
  773. form14Entity.setAimag(String.valueOf(pairs.getValue()));
  774. } else if (pairs.getKey().equals(form14Entity.SUM)) {
  775. form14Entity.setSum(String.valueOf(pairs.getValue()));
  776. } else if (pairs.getKey().equals(form14Entity.SHALGAHGAZAR)) {
  777. form14Entity.setShalgahGazar(String.valueOf(pairs.getValue()));
  778. } else if (pairs.getKey().equals(form14Entity.UZLEGTOO)) {
  779. try {
  780. form14Entity.setUzlegToo(Long.valueOf(pairs.getValue().toString()));
  781. } catch (NumberFormatException e) {
  782. form14Entity.setUzlegToo(Long.valueOf("0"));
  783. }
  784. } else if (pairs.getKey().equals(form14Entity.BAIGUULLAGATOO)) {
  785. try {
  786. form14Entity.setBaiguullagaToo(Long.valueOf(pairs.getValue().toString()));
  787. } catch (NumberFormatException e) {
  788. form14Entity.setBaiguullagaToo(Long.valueOf("0"));
  789. }
  790. } else if (pairs.getKey().equals(form14Entity.AJAHUINNEGJTOO)) {
  791. try {
  792. form14Entity.setAjAhuinNegjToo(Long.valueOf(pairs.getValue().toString()));
  793. } catch (NumberFormatException e) {
  794. form14Entity.setAjAhuinNegjToo(Long.valueOf("0"));
  795. }
  796. } else if (pairs.getKey().equals(form14Entity.IRGEDTOO)) {
  797. try {
  798. form14Entity.setIrgedToo(Long.valueOf(pairs.getValue().toString()));
  799. } catch (NumberFormatException e) {
  800. form14Entity.setIrgedToo(Long.valueOf("0"));
  801. }
  802. } else if (pairs.getKey().equals(form14Entity.HUULIINBAIGSHILJSEN)) {
  803. try {
  804. form14Entity.setHuuliinBaigShiljsen(Long.valueOf(pairs.getValue().toString()));
  805. } catch (NumberFormatException e) {
  806. form14Entity.setHuuliinBaigShiljsen(Long.valueOf("0"));
  807. }
  808. } else if (pairs.getKey().equals(form14Entity.ZAHIRGAAHARITOO)) {
  809. try {
  810. form14Entity.setZahirgaaHariToo(Long.valueOf(pairs.getValue().toString()));
  811. } catch (NumberFormatException e) {
  812. form14Entity.setZahirgaaHariToo(Long.valueOf("0"));
  813. }
  814. } else if (pairs.getKey().equals(form14Entity.TORGUULIHEMJEE)) {
  815. try {
  816. form14Entity.setTorguuliHemjee(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  817. } catch (NumberFormatException e) {
  818. form14Entity.setTorguuliHemjee(BigDecimal.valueOf(Long.parseLong("0")));
  819. }
  820. } else if (pairs.getKey().equals(form14Entity.TOLBOR)) {
  821. try {
  822. form14Entity.setTolbor(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  823. } catch (NumberFormatException e) {
  824. form14Entity.setTolbor(BigDecimal.valueOf(Long.parseLong("0")));
  825. }
  826. } else if (pairs.getKey().equals(form14Entity.TORGUULIAR)) {
  827. try {
  828. form14Entity.setTorguuliar(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  829. } catch (NumberFormatException e) {
  830. form14Entity.setTorguuliar(BigDecimal.valueOf(Long.parseLong("0")));
  831. }
  832. } else if (pairs.getKey().equals(form14Entity.TOLBOROOR)) {
  833. try {
  834. form14Entity.setTolboroor(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  835. } catch (NumberFormatException e) {
  836. form14Entity.setTolboroor(BigDecimal.valueOf(Long.parseLong("0")));
  837. }
  838. } else if (pairs.getKey().equals(form14Entity.RECORD_DATE)) {
  839. String dv = String.valueOf(pairs.getValue());
  840. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  841. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  842. form14Entity.setRecordDate(sqlDate);
  843. } else if (pairs.getKey().equals(form14Entity.SEARCH_RECORD_DATE)) {
  844. String dv = String.valueOf(pairs.getValue());
  845. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  846. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  847. form14Entity.setSearchRecordDate(sqlDate);
  848. }
  849. } catch (NullPointerException ex) {
  850. ex.printStackTrace();
  851. } catch (Exception ex) {
  852. ex.printStackTrace();
  853. }
  854. }//end while
  855. return form14Service.getListData(form14Entity);
  856. } catch (Exception ex) {
  857. ex.printStackTrace();
  858. } finally {
  859. }
  860. return null;
  861. }
  862. @Override
  863. public ErrorEntity setForm14Data(LinkedTreeMap criteria, String sessi

Large files files are truncated, but you can click here to view the full file