0e38cbe37858111bd8087485197ff8d6e1725fa4.svn-base 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. package com.sinosoft.am.org.linkerHistory.service;
  2. import java.io.UnsupportedEncodingException;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Date;
  5. import javax.ws.rs.POST;
  6. import javax.ws.rs.Path;
  7. import javax.ws.rs.ProduceMime;
  8. import com.sinosoft.am.org.linkerHistory.dao.HistoryLinkerDao;
  9. import com.sinosoft.lz.system.Utils;
  10. @Path("/HistoryLinkerService/")
  11. public class HistoryLinkerService {
  12. /**
  13. * 组织机构管理/机构人员信息/保存按钮
  14. *
  15. * @param params
  16. * @return
  17. */
  18. @ProduceMime("application/json")
  19. @POST
  20. @Path("/insertHistoryLinker/")
  21. public String insertHistoryLinker(String params) {
  22. try {
  23. params = java.net.URLDecoder.decode(params, "UTF-8");
  24. } catch (UnsupportedEncodingException e) {
  25. e.printStackTrace();
  26. }
  27. String condition = Utils.getParameter("condition", params) == null ? "" : Utils.getParameter("condition", params);//查询条件
  28. String madeMan = Utils.getParameter("madeMan", params) == null ? "" : Utils.getParameter("madeMan", params);//操作人
  29. String madeManId = Utils.getParameter("madeManId", params) == null ? "" : Utils.getParameter("madeManId", params);//操作人ID
  30. String madeManPhone = Utils.getParameter("madeManPhone", params) == null ? "" : Utils.getParameter("madeManPhone", params);//操作人电话
  31. String deptName = Utils.getParameter("deptName", params) == null ? "" : Utils.getParameter("deptName", params);//单位名称
  32. String isIssue = Utils.getParameter("isIssue", params) == null ? "" : Utils.getParameter("isIssue", params);//保存-0或发布-1
  33. //System.out.println("+++++"+madeMan+"+++++++"+madeManId+"++++++++"+madeManPhone+"++++++++"+condition);
  34. /**
  35. * 将Date格式化为String
  36. */
  37. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  38. SimpleDateFormat sdf1 = new SimpleDateFormat("yy-M-d hh(a):mm:ss");
  39. Date dd2 = new Date();
  40. String dateStr = sdf.format(dd2);
  41. //System.out.println("++++++++++++++++++++++++++++"+dateStr);//2016-07-31 10:58:35
  42. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  43. int l = -1;
  44. int m = -1;
  45. int n = -1;
  46. //1-如果是发布(即isIssue的值为1),要把EMC_AM_ORG_INLINK_HISTORY表中其他已发布的记录的改为未发布
  47. if("1".equals(isIssue)){
  48. l = hisLinkerDao.updateDataOfInlinkHistory(condition);
  49. }
  50. //2-把EMC_AM_ORG_INLINK表中查出来要发布的数据加入到表EMC_AM_ORG_INLINK_HISTORY中
  51. int a = hisLinkerDao.addDataToTable1(condition, dateStr ,madeMan,madeManId,madeManPhone,deptName,isIssue);//a为插入到表EMC_AM_ORG_INLINK_HISTORY中数据的条数
  52. //System.out.println("+++++++++++++++++++++++插入数据"+ a+ "条");
  53. if("1".equals(isIssue)){
  54. //3-如果是发布(即isIssue的值为1),要先把表EMC_AM_ORG_INLINK中的信息删掉,
  55. m = hisLinkerDao.delDatatoInlink(condition);
  56. //4-再把表EMC_AM_ORG_INLINK_HISTORY中发布的信息添加到表EMC_AM_ORG_INLINK中
  57. n = hisLinkerDao.addDatatoInlink(condition);
  58. }
  59. return a+"";
  60. }
  61. @ProduceMime("application/json")
  62. @POST
  63. @Path("/selectSimpleData/")
  64. public String selectSimpleData(String params) {
  65. try {
  66. params = java.net.URLDecoder.decode(params, "UTF-8");
  67. } catch (UnsupportedEncodingException e) {
  68. e.printStackTrace();
  69. }
  70. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  71. String str = "";
  72. str = hisLinkerDao.getSimpleData();//
  73. //System.out.println("+++++++++++++++++++++++插入数据"+ a+ "条");
  74. return str;
  75. }
  76. @ProduceMime("application/json")
  77. @POST
  78. @Path("/selectPeopleMsg/")
  79. public String selectPeopleMsg(String params) {
  80. try {
  81. params = java.net.URLDecoder.decode(params, "UTF-8");
  82. } catch (UnsupportedEncodingException e) {
  83. e.printStackTrace();
  84. }
  85. String updatedate = Utils.getParameter("updatedate", params) == null ? "" : Utils.getParameter("updatedate", params);
  86. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  87. String str = "";
  88. str = hisLinkerDao.getPeopleMsg(updatedate);//
  89. //System.out.println("+++++++++++++++++++++++插入数据"+ a+ "条");
  90. return str;
  91. }
  92. @ProduceMime("application/json")
  93. @POST
  94. @Path("/issueLinkerMsg/")
  95. public String issueLinkerMsg(String params) {
  96. try {
  97. params = java.net.URLDecoder.decode(params, "UTF-8");
  98. } catch (UnsupportedEncodingException e) {
  99. e.printStackTrace();
  100. }
  101. String updatedate = Utils.getParameter("updateDate", params) == null ? "" : Utils.getParameter("updateDate", params);//dd84a5d4d4b046cca28a52a2445ee55b,2018-03-18 18:38:41
  102. String issueState = Utils.getParameter("issueState", params) == null ? "" : Utils.getParameter("issueState", params);
  103. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  104. /**
  105. * 将Date格式化为String
  106. */
  107. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  108. SimpleDateFormat sdf1 = new SimpleDateFormat("yy-M-d hh(a):mm:ss");
  109. Date dd2 = new Date();
  110. String dateStr = sdf.format(dd2);
  111. //System.out.println("++++++++++++++++++++++++++++"+dateStr);//2016-07-31 10:58:35
  112. //1-把表EMC_AM_ORG_INLINK_HISTORY中之前已发布的数据状态都改为未发布
  113. //update EMC_AM_ORG_INLINK_HISTORY set is_issue='0' where is_del='0' and updatedate='' and VIRTUAL_ORG_ID='';
  114. int m = hisLinkerDao.updateIssueStateTo0(updatedate);
  115. System.out.println("+++++++++++++++++++++++第一步:把表EMC_AM_ORG_INLINK_HISTORY中之前已发布的数据状态都改为未发布,共"+ m + "条");
  116. //2-修改表EMC_AM_ORG_INLINK_HISTORY中相应的信息为发布状态
  117. //update EMC_AM_ORG_INLINK_HISTORY set IS_ISSUE='"+issueState+"' where updatedate in ("+updatedate+")
  118. int n = hisLinkerDao.updateIssueState(updatedate,issueState,dateStr);//
  119. System.out.println("+++++++++++++++++++++++第二步:修改表EMC_AM_ORG_INLINK_HISTORY中相应的信息为发布状态,共"+ n + "条");
  120. //3-删除表EMC_AM_ORG_INLINK中在列表显示的数据
  121. //update EMC_AM_ORG_INLINK set is_del='1' where is_del='0' and and VIRTUAL_ORG_ID=''
  122. //delete from EMC_AM_ORG_INLINK where is_del='0' and and VIRTUAL_ORG_ID=''
  123. int a = hisLinkerDao.deleteInlinkDate(updatedate);
  124. System.out.println("+++++++++++++++++++++++第三步:删除表EMC_AM_ORG_INLINK中在列表显示的数据,共"+ a + "条");
  125. //4-把表EMC_AM_ORG_INLINK_HISTORY中已发布的信息添加到表EMC_AM_ORG_INLINK中
  126. int b = hisLinkerDao.insertDataToInlink(updatedate,issueState);
  127. System.out.println("+++++++++++++++++++++++第四步:把表EMC_AM_ORG_INLINK_HISTORY中已发布的信息添加到表EMC_AM_ORG_INLINK中,共"+ b+ "条");
  128. return n+"";
  129. }
  130. }