package cn.ksource.web.facade.customerconfig.question;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import cn.ksource.core.dao.BaseDao;
|
import cn.ksource.core.dao.SqlParameter;
|
import cn.ksource.core.util.ConvertUtil;
|
import cn.ksource.core.util.JsonUtil;
|
import cn.ksource.core.util.StringUtil;
|
import cn.ksource.web.Constants;
|
@Service("questionflowFacade")
|
public class QuestionflowFacadeImpl implements QuestionflowFacade {
|
@Autowired
|
private BaseDao baseDao;
|
/**
|
* 查询问题管理流转策略
|
*/
|
@Override
|
public Map queryQuestionNodeDealConfig(String customerId) {
|
String selectSql = "SELECT * FROM QUESTION_FLOWRULE WHERE CUSTOMER_ID = :customerId ";
|
List<Map> list = baseDao.queryForList(selectSql,new SqlParameter("customerId",customerId));
|
if(null!=list && list.size()>0) {
|
Map lcMap = list.get(0);
|
lcMap.put("isSelf", 1);
|
return lcMap;
|
}else{
|
String sql = "SELECT * FROM QUESTION_FLOWRULE WHERE (CUSTOMER_ID = '' OR CUSTOMER_ID IS NULL)";
|
List<Map> gslist = baseDao.queryForList(sql);
|
if(null!=gslist && gslist.size()>0) {
|
Map lcMap = gslist.get(0);
|
lcMap.put("isSelf", 2);
|
return lcMap;
|
}
|
}
|
return null;
|
}
|
/**
|
* 保存问题管理流转策略
|
*/
|
@Override
|
public void saveQuestionNodeDealConfig(Map<String, String> param) {
|
|
List listwtfq = new ArrayList();
|
if(!StringUtil.isEmpty(param.get("wtfq"))){
|
String[] wtfq= param.get("wtfq").split(",");
|
if(null!=wtfq && wtfq.length>0) {
|
for(String nodeId : wtfq) {
|
String nodeName = Constants.questionNode.get(nodeId);
|
Map map = new HashMap();
|
map.put("nodeId", nodeId);
|
map.put("nodeName", nodeName);
|
listwtfq.add(map);
|
}
|
}
|
}
|
|
|
List listwtsl = new ArrayList();
|
if(!StringUtil.isEmpty(param.get("wtsl"))){
|
String[] wtsl= param.get("wtsl").split(",");
|
if(null!=wtsl && wtsl.length>0) {
|
for(String nodeId : wtsl) {
|
String nodeName = Constants.questionNode.get(nodeId);
|
Map map = new HashMap();
|
map.put("nodeId", nodeId);
|
map.put("nodeName", nodeName);
|
listwtsl.add(map);
|
}
|
}
|
}
|
|
List listwtsh = new ArrayList();
|
if(!StringUtil.isEmpty(param.get("wtsh"))){
|
String[] wtsh= param.get("wtsh").split(",");
|
if(null!=wtsh && wtsh.length>0) {
|
for(String nodeId : wtsh) {
|
String nodeName = Constants.questionNode.get(nodeId);
|
Map map = new HashMap();
|
map.put("nodeId", nodeId);
|
map.put("nodeName", nodeName);
|
listwtsh.add(map);
|
}
|
}
|
}
|
|
List listwtzd = new ArrayList();
|
if(!StringUtil.isEmpty(param.get("wtzd"))){
|
String[] wtzd= param.get("wtzd").split(",");
|
if(null!=wtzd && wtzd.length>0) {
|
for(String nodeId : wtzd) {
|
String nodeName = Constants.questionNode.get(nodeId);
|
Map map = new HashMap();
|
map.put("nodeId", nodeId);
|
map.put("nodeName", nodeName);
|
listwtzd.add(map);
|
}
|
}
|
}
|
|
List listfasp = new ArrayList();
|
if(!StringUtil.isEmpty(param.get("fasp"))){
|
String[] fasp= param.get("fasp").split(",");
|
if(null!=fasp && fasp.length>0) {
|
for(String nodeId : fasp) {
|
String nodeName = Constants.questionNode.get(nodeId);
|
Map map = new HashMap();
|
map.put("nodeId", nodeId);
|
map.put("nodeName", nodeName);
|
listfasp.add(map);
|
}
|
}
|
}
|
|
List listfass = new ArrayList();
|
if(!StringUtil.isEmpty(param.get("fass"))){
|
String[] fass= param.get("fass").split(",");
|
if(null!=fass && fass.length>0) {
|
for(String nodeId : fass) {
|
String nodeName = Constants.questionNode.get(nodeId);
|
Map map = new HashMap();
|
map.put("nodeId", nodeId);
|
map.put("nodeName", nodeName);
|
listfass.add(map);
|
}
|
}
|
}
|
|
List listwthg = new ArrayList();
|
if(!StringUtil.isEmpty(param.get("wthg"))){
|
String[] wthg= param.get("wthg").split(",");
|
if(null!=wthg && wthg.length>0) {
|
for(String nodeId : wthg) {
|
String nodeName = Constants.questionNode.get(nodeId);
|
Map map = new HashMap();
|
map.put("nodeId", nodeId);
|
map.put("nodeName", nodeName);
|
listwthg.add(map);
|
}
|
}
|
}
|
|
List listisclose = new ArrayList();
|
if(!StringUtil.isEmpty(param.get("isclose"))){
|
String[] isclose= param.get("isclose").split(",");
|
if(null!=isclose && isclose.length>0) {
|
for(String nodeId : isclose) {
|
String nodeName = Constants.questionNode.get(nodeId);
|
Map map = new HashMap();
|
map.put("nodeId", nodeId);
|
map.put("nodeName", nodeName);
|
listisclose.add(map);
|
}
|
}
|
}
|
|
List listback = new ArrayList();
|
if(!StringUtil.isEmpty(param.get("isback"))){
|
String[] isback= param.get("isback").split(",");
|
if(null!=isback && isback.length>0) {
|
for(String nodeId : isback) {
|
String nodeName = Constants.questionNode.get(nodeId);
|
Map map = new HashMap();
|
map.put("nodeId", nodeId);
|
map.put("nodeName", nodeName);
|
listback.add(map);
|
}
|
}
|
}
|
|
|
String id = param.get("id");
|
String isSelf = param.get("isSelf");
|
//客户编号
|
String customerId = param.get("customerId");
|
|
String updateSql = "";
|
|
if(!StringUtil.isEmpty(isSelf)){
|
if(ConvertUtil.obj2Integer(isSelf) == 2) {
|
id = StringUtil.getUUID();
|
updateSql = "INSERT INTO QUESTION_FLOWRULE(ID,WTFQ,WTSL,WTSH,WTZD,FASP,FASS,WTHG,CLOSEJD,GOBACKJD,CUSTOMER_ID) VALUES(:id,:wtfq,:wtsl,:wtsh,:wtzd,:fasp,:fass,:wthg,:closejd,:gobackjd,:customer_id)";
|
} else {
|
updateSql = "UPDATE QUESTION_FLOWRULE SET WTFQ = :wtfq,WTSL=:wtsl,WTSH=:wtsh,WTZD=:wtzd,FASP=:fasp,FASS=:fass,WTHG=:wthg,CLOSEJD = :closejd,GOBACKJD = :gobackjd WHERE ID = :id AND CUSTOMER_ID = :customer_id ";
|
}
|
} else {
|
id = StringUtil.getUUID();
|
updateSql = "INSERT INTO QUESTION_FLOWRULE(ID,WTFQ,WTSL,WTSH,WTZD,FASP,FASS,WTHG,CLOSEJD,GOBACKJD,CUSTOMER_ID) VALUES(:id,:wtfq,:wtsl,:wtsh,:wtzd,:fasp,:fass,:wthg,:closejd,:gobackjd,:customer_id)";
|
}
|
|
|
param.put("id", id);
|
param.put("wtfq", JsonUtil.list2Json(listwtfq));
|
param.put("wtsl", JsonUtil.list2Json(listwtsl));
|
param.put("wtsh", JsonUtil.list2Json(listwtsh));
|
param.put("wtzd", JsonUtil.list2Json(listwtzd));
|
param.put("fasp", JsonUtil.list2Json(listfasp));
|
param.put("fass", JsonUtil.list2Json(listfass));
|
param.put("wthg", JsonUtil.list2Json(listwthg));
|
param.put("closejd", JsonUtil.list2Json(listisclose));
|
param.put("gobackjd", JsonUtil.list2Json(listback));
|
param.put("customer_id", customerId);
|
|
baseDao.execute(updateSql, param);
|
}
|
/**
|
* 得到登录用户问题配置的总数 判断是否显示公司默认选项
|
*/
|
@Override
|
public Integer getQuestionNodeDealCount(String customerId) {
|
String selectSql = "SELECT COUNT(*) FROM QUESTION_FLOWRULE WHERE CUSTOMER_ID = :customerId ";
|
Map param = new HashMap();
|
param.put("customerId", customerId);
|
int count = baseDao.queryForInteger(selectSql.toString(),param);
|
return count;
|
}
|
/**
|
* 查询问题管理流程节点配置 除去ID值
|
*/
|
@Override
|
public Map queryQuestionNodeDealNotId(Map<String, String> param) {
|
String selectSql = "SELECT WTFQ,WTSL,WTSH,WTZD,FASP,FASS,WTHG,CLOSEJD,GOBACKJD FROM QUESTION_FLOWRULE WHERE CUSTOMER_ID IS NULL ";
|
Map map = baseDao.queryForMap(selectSql,new SqlParameter());
|
return map;
|
}
|
@Override
|
public void updatelc(Map<String, String> params) {
|
String delsql = "DELETE FROM QUESTION_FLOWRULE WHERE CUSTOMER_ID = :customerId ";
|
baseDao.execute(delsql, params);
|
|
}
|
|
}
|