cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
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);
        
    }
 
}