d69d0b555493f3975b7a00cc316b3018c96bf1fd.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. package com.sinosoft.em.evaluate.targetManage.service;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import javax.ws.rs.POST;
  7. import javax.ws.rs.Path;
  8. import javax.ws.rs.ProduceMime;
  9. import org.apache.log4j.Logger;
  10. import com.formaction.Utils;
  11. import com.persistence.service.assitant.generator.IdentityGenerator;
  12. import com.sinosoft.common.excel.JsonPluginsUtil;
  13. import com.sinosoft.em.evaluate.EvalUtils;
  14. import com.sinosoft.em.evaluate.scoreGrade.dao.ScoreDao;
  15. import com.sinosoft.em.evaluate.targetManage.dao.TagManagerDao;
  16. import com.sinosoft.lz.system.util.JsonUtil;
  17. @Path("/ManageService/")
  18. public class ManageServiceImp implements ManageService {
  19. private Logger log = Logger.getLogger(this.getClass());
  20. @ProduceMime("application/json")
  21. @POST
  22. @Path("/queryById")
  23. @Override
  24. public String queryById(String params) {
  25. // TODO Auto-generated method stub
  26. return null;
  27. }
  28. /**
  29. * 创建分值类型,如:四项0-1-2-3
  30. * @param params
  31. * @return
  32. */
  33. @ProduceMime("application/json")
  34. @POST
  35. @Path("/createEvalScore")
  36. public String createEvalScore(String params) {
  37. String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter("json", params);
  38. log.info(json);
  39. String fd_objectid = "";
  40. String mainName = "";
  41. TagManagerDao mdao = new TagManagerDao();
  42. List<Map<String, String>> lists = JsonPluginsUtil.jsonToMapList(json);
  43. if(!lists.isEmpty()){
  44. List<String> listmain = new ArrayList<String>();
  45. fd_objectid = IdentityGenerator.getIdentityGenerator().gerenalIdentity(780);
  46. listmain.add(fd_objectid);
  47. listmain.add("");
  48. listmain.add("");
  49. listmain.add("0");
  50. listmain.add("0");
  51. mainName = NumbToChina(lists.size())+"项";
  52. for(int i=0;i<lists.size();i++){
  53. Map<String, String> list = lists.get(i);
  54. List<String> listdata = new ArrayList<String>();
  55. String fd_id = IdentityGenerator.getIdentityGenerator().gerenalIdentity(780);
  56. listdata.add(fd_id);
  57. listdata.add(list.get("score"));
  58. listdata.add(list.get("sort"));
  59. listdata.add(fd_objectid);
  60. listdata.add("0");
  61. listdata.add("");
  62. mdao.insertEmEvalScore(listdata.toArray());
  63. mainName += list.get("score");
  64. if(i!=lists.size()-1){
  65. mainName += "-";
  66. }
  67. }
  68. listmain.add(mainName);
  69. mdao.insertEmEvalScore(listmain.toArray());
  70. }
  71. String result = mdao.queryEmEvalScore();
  72. log.info(result);
  73. return "{\"data\":"+result+",\"value\":\""+fd_objectid+"\",\"key\":\""+mainName+"\"}";
  74. }
  75. public String NumbToChina(int numb){
  76. String result = "";
  77. switch (numb) {
  78. case 1: result = "一"; break;
  79. case 2: result = "两"; break;
  80. case 3: result = "三"; break;
  81. case 4: result = "四"; break;
  82. case 5: result = "五"; break;
  83. case 6: result = "六"; break;
  84. case 7: result = "七"; break;
  85. case 8: result = "八"; break;
  86. case 9: result = "九"; break;
  87. case 10: result = "十"; break;
  88. default: break;
  89. }
  90. return result;
  91. }
  92. /**
  93. * 获取得分标准的下拉框数据
  94. * @param params
  95. * @return
  96. */
  97. @ProduceMime("application/json")
  98. @POST
  99. @Path("/getEvalScore")
  100. public String getEvalScore(String params) {
  101. return new TagManagerDao().queryEmEvalScore();
  102. }
  103. /**
  104. * 通过id获取树的每项内容
  105. * @param params
  106. * @return
  107. */
  108. @ProduceMime("application/json")
  109. @POST
  110. @Path("/getNodeDataById")
  111. public String getNodeDataById(String params) {
  112. String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params);
  113. String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params);
  114. TagManagerDao tmdao = new TagManagerDao();
  115. List<Map<String, String>> nodedata = tmdao.getNodeDataById(fd_id,type);
  116. List<Map<String, String>> list = new ArrayList<Map<String,String>>();
  117. if("1".equals(type) && !nodedata.isEmpty()){
  118. Map<String, String> map = nodedata.get(0);
  119. if("1".equals(map.get("IS_CONECTION"))){
  120. map.put("CONECTION_ID_SHOW", tmdao.getBaoZhunName(map.get("CONECTION_ID"),"2"));
  121. list.add(map);
  122. }else{
  123. list = nodedata;
  124. }
  125. }else{
  126. list = nodedata;
  127. }
  128. return JsonUtil.list2json(list);
  129. }
  130. /**
  131. * 配置体系获取现有的tree数据
  132. * @param params
  133. * @return
  134. */
  135. @ProduceMime("application/json")
  136. @POST
  137. @Path("/getTiXiTree")
  138. public String getTiXiTree(String params) {
  139. String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params);
  140. TagManagerDao tmdao = new TagManagerDao();
  141. List<Map<String, String>> tixi = tmdao.queryTiXiById(fd_id);
  142. List<Map<String, String>> result = new ArrayList<Map<String,String>>();
  143. if(!tixi.isEmpty()){
  144. String type = tixi.get(0).get("TYPE");
  145. String level_num = tixi.get(0).get("LEVEL_NUM");
  146. Map<String,String> map = new HashMap<String, String>();
  147. map.put("id", tixi.get(0).get("FD_OBJECTID"));
  148. map.put("name", tixi.get(0).get("NAME"));
  149. map.put("parentId", "0");
  150. map.put("sort", "1");
  151. map.put("open", "true");
  152. map.put("chkDisabled", "false");
  153. map.put("stripe", "");
  154. map.put("menuType", "root");
  155. map.put("clickType", "0");
  156. map.put("is_end", "0");
  157. map.put("path_id", "");
  158. result.add(map);
  159. List<Map<String, String>> treedata = tmdao.queryTiXiTree(fd_id, type,level_num);
  160. for(int i=0;i<treedata.size();i++){
  161. result.add(treedata.get(i));
  162. }
  163. }
  164. String resultString = "{\"treeData\":" + JsonUtil.list2json(result) + ",\"tixiData\":" + JsonUtil.list2json(tixi) +"}";
  165. log.info(resultString);
  166. return resultString.replace("\"true\"", "true").replace("\"false\"", "false");
  167. }
  168. /**
  169. * 根据fd_id获取体系内容
  170. * @param params
  171. * @return
  172. */
  173. @ProduceMime("application/json")
  174. @POST
  175. @Path("/getTiXiById")
  176. public String getTiXiById(String params) {
  177. String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params);
  178. TagManagerDao tmdao = new TagManagerDao();
  179. List<Map<String, String>> tixi = tmdao.queryTiXiById(fd_id);
  180. return JsonUtil.list2json(tixi);
  181. }
  182. /**
  183. * 添加/修改评分配置数据
  184. * @param params
  185. * @return
  186. */
  187. @ProduceMime("application/json")
  188. @POST
  189. @Path("/insertEval")
  190. public String insertEval(String params) {
  191. String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params);
  192. String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params);
  193. String formParams = Utils.getParameter("formParams", params) == null ? "" : Utils.getParameter("formParams", params);
  194. List<Map<String,String>> list = new ArrayList<Map<String,String>>();
  195. String result = "error";
  196. TagManagerDao tmdao = new TagManagerDao();
  197. if("2".equals(type)){
  198. if("".equals(fd_id)){
  199. fd_id = IdentityGenerator.getIdentityGenerator().gerenalIdentity(718);
  200. //fd_id = EvalUtils.getMyFdObjectId();
  201. result = tmdao.insertForm("EM_EVAL_TYPE_TWO",fd_id,EvalUtils.urldecode(formParams));
  202. }else{
  203. result = tmdao.updateForm("EM_EVAL_TYPE_TWO",fd_id,EvalUtils.urldecode(formParams));
  204. }
  205. }else{
  206. if("".equals(fd_id)){
  207. fd_id = IdentityGenerator.getIdentityGenerator().gerenalIdentity(719);
  208. //fd_id = EvalUtils.getMyFdObjectId();
  209. result = tmdao.insertForm("EM_EVAL_TYPE_ONE",fd_id,EvalUtils.urldecode(formParams));
  210. }else{
  211. result = tmdao.updateForm("EM_EVAL_TYPE_ONE",fd_id,EvalUtils.urldecode(formParams));
  212. }
  213. }
  214. if(!"error".equals(result)){
  215. Map<String,String> map = EvalUtils.paramsToList(EvalUtils.urldecode(formParams));
  216. map.put("FD_OBJECTID", fd_id);
  217. list.add(map);
  218. }
  219. return JsonUtil.list2json(list);
  220. }
  221. /**
  222. * 树形表拖动时排序更新
  223. * @param params
  224. * @return
  225. */
  226. @ProduceMime("application/json")
  227. @POST
  228. @Path("/updateSort")
  229. public String updateSort(String params) {
  230. String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter("json", params);
  231. String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params);
  232. List<Map<String, String>> lists = JsonPluginsUtil.jsonToMapList(json);
  233. String result = "error";
  234. TagManagerDao tmdao = new TagManagerDao();
  235. if("2".equals(type)){
  236. result = tmdao.updateForm("EM_EVAL_TYPE_TWO",lists);
  237. }else{
  238. result = tmdao.updateForm("EM_EVAL_TYPE_ONE",lists);
  239. }
  240. return "[{\"result\":\""+result+"\"}]";
  241. }
  242. /**
  243. * 测试使用
  244. * @param params
  245. * @return
  246. */
  247. /*@ProduceMime("application/json")
  248. @POST
  249. @Path("/test")
  250. public String test(String params) {
  251. TagManagerDao tmdao = new TagManagerDao();
  252. tmdao.updateObjStripe(1,"799149783830440000000004100000");
  253. tmdao.updateObjStripe(2,"799149783830440000000004100000");
  254. tmdao.updateObjStripe(3,"799149783830440000000004100000");
  255. tmdao.updateObjStripe(4,"799149783830440000000004100000");
  256. return "[{}]";
  257. }*/
  258. /**
  259. * 树形表删除操作
  260. * @param params
  261. * @return
  262. */
  263. @ProduceMime("application/json")
  264. @POST
  265. @Path("/delectSevNode")
  266. public String delectSevNode(String params) {
  267. String ids = Utils.getParameter("ids", params) == null ? "" : Utils.getParameter("ids", params);
  268. String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params);
  269. String result = "error";
  270. String [] idsArr = ids.split(",");
  271. TagManagerDao tmdao = new TagManagerDao();
  272. if("2".equals(type)){
  273. result = tmdao.delectSevNode("EM_EVAL_TYPE_TWO",idsArr);
  274. }else{
  275. result = tmdao.delectSevNode("EM_EVAL_TYPE_ONE",idsArr);
  276. }
  277. return "[{\"result\":\""+result+"\"}]";
  278. }
  279. /**
  280. * 添加评分依据操作
  281. * @param params
  282. * @return
  283. */
  284. @ProduceMime("application/json")
  285. @POST
  286. @Path("/addBasis")
  287. public String addBasis(String params) {
  288. String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter("json", params);
  289. String delectIds = Utils.getParameter("delectIds", params) == null ? "" : Utils.getParameter("delectIds", params);
  290. String business_id = Utils.getParameter("business_id", params) == null ? "" : Utils.getParameter("business_id", params);
  291. String delresult = "error";
  292. String addresult = "error";
  293. List<Map<String, String>> lists = JsonPluginsUtil.jsonToMapList(json);
  294. TagManagerDao tmdao = new TagManagerDao();
  295. if(!"".equals(delectIds)){
  296. delresult = tmdao.delectBasis(delectIds);
  297. }else{
  298. addresult = tmdao.addBasis(lists,business_id);
  299. }
  300. return "[{\"delresult\":\""+delresult+"\"},{\"addresult\":\""+addresult+"\"}]";
  301. }
  302. /**
  303. * 通过业务id获取全部评分依据
  304. * @param params
  305. * @return
  306. */
  307. @ProduceMime("application/json")
  308. @POST
  309. @Path("/getBasisByBusiId")
  310. public String getBasisByBusiId(String params) {
  311. String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params);
  312. //String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params);
  313. TagManagerDao tmdao = new TagManagerDao();
  314. List<Map<String,String>> list = tmdao.getBasisByBusiId(fd_id);
  315. return JsonUtil.list2json(list);
  316. }
  317. /**
  318. * 获取所有外部体系列表
  319. * @param params
  320. * @return
  321. */
  322. @ProduceMime("application/json")
  323. @POST
  324. @Path("/getOutTixiData")
  325. public String getOutTixiData(String params) {
  326. TagManagerDao tmdao = new TagManagerDao();
  327. String sys_id = Utils.getParameter("sys_id", params) == null ? "" : Utils.getParameter("sys_id", params);
  328. List<Map<String,String>> list = tmdao.getOutTixiData(sys_id);
  329. return JsonUtil.list2json(list);
  330. }
  331. /**
  332. * 通过业务id获取全部评分依据
  333. * @param params
  334. * @return
  335. */
  336. @ProduceMime("application/json")
  337. @POST
  338. @Path("/getOuterBasisByMainId")
  339. public String getOuterBasisByMainId(String params) {
  340. String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params);
  341. //String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params);
  342. TagManagerDao tmdao = new TagManagerDao();
  343. List<Map<String,String>> list = tmdao.getOuterBasisByMainId(fd_id);
  344. return JsonUtil.list2json(list);
  345. }
  346. /**
  347. * 插入外部连接数据
  348. * @param params
  349. * @return
  350. */
  351. @ProduceMime("application/json")
  352. @POST
  353. @Path("/insertConnect")
  354. public String insertConnect(String params) {
  355. String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params);
  356. String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter("json", params);
  357. String delectBasisIds = Utils.getParameter("delectBasisIds", params) == null ? "" : Utils.getParameter("delectBasisIds", params);
  358. TagManagerDao tmdao = new TagManagerDao();
  359. List<Map<String,String>> conectionids = tmdao.getConectionById(fd_id);
  360. String result = "error";
  361. if(!conectionids.isEmpty() && conectionids.get(0).get("CONECTION_ID")!=null && !"".equals(conectionids.get(0).get("CONECTION_ID"))){
  362. String [] delectArr = delectBasisIds.split(",");
  363. int n = tmdao.delectBasisByMainId(delectArr,fd_id);
  364. String [] jsonArr = json.split(",");
  365. result = tmdao.updateOuterBasis(fd_id, jsonArr);
  366. }else{
  367. int n = tmdao.delectBasisAll(fd_id);
  368. result = "update";
  369. }
  370. return "[{\"result\":\""+result+"\"}]";
  371. }
  372. /**
  373. * 插入外部连接数据
  374. * @param params
  375. * @return
  376. */
  377. @ProduceMime("application/json")
  378. @POST
  379. @Path("/getCurrentConnData")
  380. public String getCurrentConnData(String params) {
  381. String fd_ids = Utils.getParameter("fd_ids", params) == null ? "" : Utils.getParameter("fd_ids", params);
  382. TagManagerDao tmdao = new TagManagerDao();
  383. fd_ids = fd_ids.replaceAll(",", "','");
  384. List<Map<String,String>> list = tmdao.getCurrentConnData(fd_ids);
  385. return JsonUtil.list2json(list);
  386. }
  387. }