package com.sinosoft.em.evaluate.targetManage.service; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.ProduceMime; import org.apache.log4j.Logger; import com.formaction.Utils; import com.persistence.service.assitant.generator.IdentityGenerator; import com.sinosoft.common.excel.JsonPluginsUtil; import com.sinosoft.em.evaluate.EvalUtils; import com.sinosoft.em.evaluate.scoreGrade.dao.ScoreDao; import com.sinosoft.em.evaluate.targetManage.dao.TagManagerDao; import com.sinosoft.lz.system.util.JsonUtil; @Path("/ManageService/") public class ManageServiceImp implements ManageService { private Logger log = Logger.getLogger(this.getClass()); @ProduceMime("application/json") @POST @Path("/queryById") @Override public String queryById(String params) { // TODO Auto-generated method stub return null; } /** * 创建分值类型,如:四项0-1-2-3 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/createEvalScore") public String createEvalScore(String params) { String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter("json", params); log.info(json); String fd_objectid = ""; String mainName = ""; TagManagerDao mdao = new TagManagerDao(); List> lists = JsonPluginsUtil.jsonToMapList(json); if(!lists.isEmpty()){ List listmain = new ArrayList(); fd_objectid = IdentityGenerator.getIdentityGenerator().gerenalIdentity(780); listmain.add(fd_objectid); listmain.add(""); listmain.add(""); listmain.add("0"); listmain.add("0"); mainName = NumbToChina(lists.size())+"项"; for(int i=0;i list = lists.get(i); List listdata = new ArrayList(); String fd_id = IdentityGenerator.getIdentityGenerator().gerenalIdentity(780); listdata.add(fd_id); listdata.add(list.get("score")); listdata.add(list.get("sort")); listdata.add(fd_objectid); listdata.add("0"); listdata.add(""); mdao.insertEmEvalScore(listdata.toArray()); mainName += list.get("score"); if(i!=lists.size()-1){ mainName += "-"; } } listmain.add(mainName); mdao.insertEmEvalScore(listmain.toArray()); } String result = mdao.queryEmEvalScore(); log.info(result); return "{\"data\":"+result+",\"value\":\""+fd_objectid+"\",\"key\":\""+mainName+"\"}"; } public String NumbToChina(int numb){ String result = ""; switch (numb) { case 1: result = "一"; break; case 2: result = "两"; break; case 3: result = "三"; break; case 4: result = "四"; break; case 5: result = "五"; break; case 6: result = "六"; break; case 7: result = "七"; break; case 8: result = "八"; break; case 9: result = "九"; break; case 10: result = "十"; break; default: break; } return result; } /** * 获取得分标准的下拉框数据 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/getEvalScore") public String getEvalScore(String params) { return new TagManagerDao().queryEmEvalScore(); } /** * 通过id获取树的每项内容 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/getNodeDataById") public String getNodeDataById(String params) { String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params); String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params); TagManagerDao tmdao = new TagManagerDao(); List> nodedata = tmdao.getNodeDataById(fd_id,type); List> list = new ArrayList>(); if("1".equals(type) && !nodedata.isEmpty()){ Map map = nodedata.get(0); if("1".equals(map.get("IS_CONECTION"))){ map.put("CONECTION_ID_SHOW", tmdao.getBaoZhunName(map.get("CONECTION_ID"),"2")); list.add(map); }else{ list = nodedata; } }else{ list = nodedata; } return JsonUtil.list2json(list); } /** * 配置体系获取现有的tree数据 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/getTiXiTree") public String getTiXiTree(String params) { String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params); TagManagerDao tmdao = new TagManagerDao(); List> tixi = tmdao.queryTiXiById(fd_id); List> result = new ArrayList>(); if(!tixi.isEmpty()){ String type = tixi.get(0).get("TYPE"); String level_num = tixi.get(0).get("LEVEL_NUM"); Map map = new HashMap(); map.put("id", tixi.get(0).get("FD_OBJECTID")); map.put("name", tixi.get(0).get("NAME")); map.put("parentId", "0"); map.put("sort", "1"); map.put("open", "true"); map.put("chkDisabled", "false"); map.put("stripe", ""); map.put("menuType", "root"); map.put("clickType", "0"); map.put("is_end", "0"); map.put("path_id", ""); result.add(map); List> treedata = tmdao.queryTiXiTree(fd_id, type,level_num); for(int i=0;i> tixi = tmdao.queryTiXiById(fd_id); return JsonUtil.list2json(tixi); } /** * 添加/修改评分配置数据 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/insertEval") public String insertEval(String params) { String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params); String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params); String formParams = Utils.getParameter("formParams", params) == null ? "" : Utils.getParameter("formParams", params); List> list = new ArrayList>(); String result = "error"; TagManagerDao tmdao = new TagManagerDao(); if("2".equals(type)){ if("".equals(fd_id)){ fd_id = IdentityGenerator.getIdentityGenerator().gerenalIdentity(718); //fd_id = EvalUtils.getMyFdObjectId(); result = tmdao.insertForm("EM_EVAL_TYPE_TWO",fd_id,EvalUtils.urldecode(formParams)); }else{ result = tmdao.updateForm("EM_EVAL_TYPE_TWO",fd_id,EvalUtils.urldecode(formParams)); } }else{ if("".equals(fd_id)){ fd_id = IdentityGenerator.getIdentityGenerator().gerenalIdentity(719); //fd_id = EvalUtils.getMyFdObjectId(); result = tmdao.insertForm("EM_EVAL_TYPE_ONE",fd_id,EvalUtils.urldecode(formParams)); }else{ result = tmdao.updateForm("EM_EVAL_TYPE_ONE",fd_id,EvalUtils.urldecode(formParams)); } } if(!"error".equals(result)){ Map map = EvalUtils.paramsToList(EvalUtils.urldecode(formParams)); map.put("FD_OBJECTID", fd_id); list.add(map); } return JsonUtil.list2json(list); } /** * 树形表拖动时排序更新 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/updateSort") public String updateSort(String params) { String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter("json", params); String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params); List> lists = JsonPluginsUtil.jsonToMapList(json); String result = "error"; TagManagerDao tmdao = new TagManagerDao(); if("2".equals(type)){ result = tmdao.updateForm("EM_EVAL_TYPE_TWO",lists); }else{ result = tmdao.updateForm("EM_EVAL_TYPE_ONE",lists); } return "[{\"result\":\""+result+"\"}]"; } /** * 测试使用 * @param params * @return */ /*@ProduceMime("application/json") @POST @Path("/test") public String test(String params) { TagManagerDao tmdao = new TagManagerDao(); tmdao.updateObjStripe(1,"799149783830440000000004100000"); tmdao.updateObjStripe(2,"799149783830440000000004100000"); tmdao.updateObjStripe(3,"799149783830440000000004100000"); tmdao.updateObjStripe(4,"799149783830440000000004100000"); return "[{}]"; }*/ /** * 树形表删除操作 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/delectSevNode") public String delectSevNode(String params) { String ids = Utils.getParameter("ids", params) == null ? "" : Utils.getParameter("ids", params); String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params); String result = "error"; String [] idsArr = ids.split(","); TagManagerDao tmdao = new TagManagerDao(); if("2".equals(type)){ result = tmdao.delectSevNode("EM_EVAL_TYPE_TWO",idsArr); }else{ result = tmdao.delectSevNode("EM_EVAL_TYPE_ONE",idsArr); } return "[{\"result\":\""+result+"\"}]"; } /** * 添加评分依据操作 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/addBasis") public String addBasis(String params) { String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter("json", params); String delectIds = Utils.getParameter("delectIds", params) == null ? "" : Utils.getParameter("delectIds", params); String business_id = Utils.getParameter("business_id", params) == null ? "" : Utils.getParameter("business_id", params); String delresult = "error"; String addresult = "error"; List> lists = JsonPluginsUtil.jsonToMapList(json); TagManagerDao tmdao = new TagManagerDao(); if(!"".equals(delectIds)){ delresult = tmdao.delectBasis(delectIds); }else{ addresult = tmdao.addBasis(lists,business_id); } return "[{\"delresult\":\""+delresult+"\"},{\"addresult\":\""+addresult+"\"}]"; } /** * 通过业务id获取全部评分依据 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/getBasisByBusiId") public String getBasisByBusiId(String params) { String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params); //String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params); TagManagerDao tmdao = new TagManagerDao(); List> list = tmdao.getBasisByBusiId(fd_id); return JsonUtil.list2json(list); } /** * 获取所有外部体系列表 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/getOutTixiData") public String getOutTixiData(String params) { TagManagerDao tmdao = new TagManagerDao(); String sys_id = Utils.getParameter("sys_id", params) == null ? "" : Utils.getParameter("sys_id", params); List> list = tmdao.getOutTixiData(sys_id); return JsonUtil.list2json(list); } /** * 通过业务id获取全部评分依据 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/getOuterBasisByMainId") public String getOuterBasisByMainId(String params) { String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params); //String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type", params); TagManagerDao tmdao = new TagManagerDao(); List> list = tmdao.getOuterBasisByMainId(fd_id); return JsonUtil.list2json(list); } /** * 插入外部连接数据 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/insertConnect") public String insertConnect(String params) { String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params); String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter("json", params); String delectBasisIds = Utils.getParameter("delectBasisIds", params) == null ? "" : Utils.getParameter("delectBasisIds", params); TagManagerDao tmdao = new TagManagerDao(); List> conectionids = tmdao.getConectionById(fd_id); String result = "error"; if(!conectionids.isEmpty() && conectionids.get(0).get("CONECTION_ID")!=null && !"".equals(conectionids.get(0).get("CONECTION_ID"))){ String [] delectArr = delectBasisIds.split(","); int n = tmdao.delectBasisByMainId(delectArr,fd_id); String [] jsonArr = json.split(","); result = tmdao.updateOuterBasis(fd_id, jsonArr); }else{ int n = tmdao.delectBasisAll(fd_id); result = "update"; } return "[{\"result\":\""+result+"\"}]"; } /** * 插入外部连接数据 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/getCurrentConnData") public String getCurrentConnData(String params) { String fd_ids = Utils.getParameter("fd_ids", params) == null ? "" : Utils.getParameter("fd_ids", params); TagManagerDao tmdao = new TagManagerDao(); fd_ids = fd_ids.replaceAll(",", "','"); List> list = tmdao.getCurrentConnData(fd_ids); return JsonUtil.list2json(list); } }