123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- 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<Map<String, String>> lists = JsonPluginsUtil.jsonToMapList(json);
- if(!lists.isEmpty()){
- List<String> listmain = new ArrayList<String>();
- 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<lists.size();i++){
- Map<String, String> list = lists.get(i);
- List<String> listdata = new ArrayList<String>();
- 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<Map<String, String>> nodedata = tmdao.getNodeDataById(fd_id,type);
- List<Map<String, String>> list = new ArrayList<Map<String,String>>();
- if("1".equals(type) && !nodedata.isEmpty()){
- Map<String, String> 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<Map<String, String>> tixi = tmdao.queryTiXiById(fd_id);
- List<Map<String, String>> result = new ArrayList<Map<String,String>>();
- if(!tixi.isEmpty()){
- String type = tixi.get(0).get("TYPE");
- String level_num = tixi.get(0).get("LEVEL_NUM");
- Map<String,String> map = new HashMap<String, String>();
- 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<Map<String, String>> treedata = tmdao.queryTiXiTree(fd_id, type,level_num);
- for(int i=0;i<treedata.size();i++){
- result.add(treedata.get(i));
- }
- }
-
- String resultString = "{\"treeData\":" + JsonUtil.list2json(result) + ",\"tixiData\":" + JsonUtil.list2json(tixi) +"}";
- log.info(resultString);
- return resultString.replace("\"true\"", "true").replace("\"false\"", "false");
- }
-
- /**
- * 根据fd_id获取体系内容
- * @param params
- * @return
- */
- @ProduceMime("application/json")
- @POST
- @Path("/getTiXiById")
- public String getTiXiById(String params) {
- String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils.getParameter("fd_id", params);
- TagManagerDao tmdao = new TagManagerDao();
- List<Map<String, String>> 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<Map<String,String>> list = new ArrayList<Map<String,String>>();
- 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<String,String> 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<Map<String, String>> 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<Map<String, String>> 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<Map<String,String>> 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<Map<String,String>> 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<Map<String,String>> 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<Map<String,String>> 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<Map<String,String>> list = tmdao.getCurrentConnData(fd_ids);
- return JsonUtil.list2json(list);
- }
-
- }
|