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
package cn.ksource.web.facade.wechat.ewyw;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
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.page.PageInfo;
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.DateUtil;
import cn.ksource.core.util.JsonUtil;
import cn.ksource.core.util.StringUtil;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.Constants;
import cn.ksource.web.service.file.FileService;
 
@Service("ewSatisFacade")
public class EwSatisFacadeImpl implements EwSatisFacade {
    
    @Autowired
    private BaseDao baseDao;
    
    @Autowired
    private FileService fileService;
 
    @Override
    public List ewMyMonthCalendar(Map<String, String> params) {
        String year = params.get("year");
        String type = params.get("type");
        long nowTime = DateUtil.getCurrentDate6();
        if(!StringUtil.notEmpty(year)) {
            year = DateUtil.getToday("yyyy");
        }
        //初始化月份数据
        List<Map> allMonth = new ArrayList<Map>();
        List<Map> cardmsg = queryZcsatisCount(params.get("userId"),type);
        Map cacheMap = new HashMap();
        for(Map map:cardmsg){
            cacheMap.put(map.get("CARD_MONTH"), map.get("STATE"));
        }
        
        for(int i=1;i<=12;i++) {
            Map map = new HashMap();
            map.put("year", year);
            String month = i<10?("0"+i):(""+i);
            map.put("month", month);
            System.out.println(year+month);
            long yearMonth = ConvertUtil.obj2Long(year+month);
            if(!StringUtil.isEmpty(ConvertUtil.obj2StrBlank(cacheMap.get(yearMonth)))){
                map.put("state", cacheMap.get(yearMonth));
            }
            int compareTime = 0;
            if(yearMonth>nowTime) {
                compareTime = 1;
            } else if (yearMonth==nowTime) {
                compareTime = 2;
            } else {
                compareTime = 3;
            }
            map.put("compareTime", compareTime);
        
            allMonth.add(map);
        }
        System.err.println(JsonUtil.list2Json(allMonth));
 
        return allMonth;
    }
 
    @Override
    public int queryIncisatisCount(Map<String, String> params) {
        
        StringBuilder sql = new StringBuilder();
        sql.append("SELECT COUNT(WB.ID) ");
        sql.append("FROM SC_WORKFLOW_INCIDENT B,WORKFLOW_BASE WB , ORDER_SATIS_INFO C WHERE C.BUSINESS_ID = WB.ID AND WB.BUSINESS_ID = B.ID  ");
        sql.append("AND  WB.BUSINESSTYPE = :businessType ");
        params.put("businessType",ConvertUtil.obj2StrBlank( Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT));
        String orderName = params.get("name");
        if(StringUtil.notEmpty(orderName)) {
            sql.append(" AND WB.WFNAME LIKE :orderName ");
            params.put("orderName", "%"+orderName+"%");
        }
        return baseDao.queryForInteger(sql.toString(),params);
    }
 
    @Override
    public PageInfo queryIncisatisData(PageInfo pageInfo,Map<String, String> params) {
        
        StringBuilder sql = new StringBuilder();
        sql.append("SELECT WB.ID,WB.ORDER_CODE,WB.ENDTIME,WB.WFNAME,WB.BUSINESSTYPE,WB.CREATERNAME,WB.CREATETIME,WB.WFNOTE,B.CONTACT_NAME,B.CONTACT_PHONE, ");
        sql.append("WB.CURRENT_NODE_ID,WB.CURRENT_NODE_NAME,WB.CUSTOMER_NAME,WB.PROJECT_NAME,WB.CURRENT_DEALER_NAME,WB.BUSINESS_ID,WB.WFSTATE,C.SCORE ");
        sql.append("FROM SC_WORKFLOW_INCIDENT B,WORKFLOW_BASE WB , ORDER_SATIS_INFO C WHERE C.BUSINESS_ID = WB.ID AND WB.BUSINESS_ID = B.ID ");
        sql.append("AND WB.BUSINESSTYPE = :businessType ");
        params.put("businessType", ConvertUtil.obj2StrBlank(Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT));
        String orderName = params.get("name");
        if(StringUtil.notEmpty(orderName)) {
            sql.append(" AND WB.WFNAME LIKE :orderName ");
            params.put("orderName", "%"+orderName+"%");
        }
        sql.append( " ORDER BY WB.CREATETIME DESC ");
        return baseDao.queryforSplitPageInfo(pageInfo,sql.toString(),params);
    }
 
    @Override
    public List<Map> queryZcsatisCount(String userId, String type) {
        StringBuilder sql = new StringBuilder();
        sql.append("SELECT C.CARD_MONTH,C.STATE FROM SC_CUSTOMER_ZC_UESR A , AUDITING_SATIS_INFO C  WHERE C.USER_ID = A.USER_ID ");
        Map paramMap = new HashMap();
        if(!"1".equals(type)){
            sql.append(" AND A.USER_ID = :userId ");
            paramMap.put("userId", userId);
        }
        
        sql.append(" GROUP BY C.CARD_MONTH ");
        
        return baseDao.queryForList(sql.toString(), paramMap);
    }
 
    @Override
    public List queryZcsatisData(Map<String, String> params) {
        String year = params.get("year");
        String month = params.get("month");
        String userId = params.get("userId");
        String ismy = params.get("ismy");
        StringBuilder sql = new StringBuilder();
        sql.append("SELECT A.USER_NAME AS ALLUSER,C.*,A.CUSTOMER_ID FROM SC_CUSTOMER_ZC_UESR A , AUDITING_SATIS_INFO C  WHERE C.USER_ID = A.USER_ID ");
        Map paramMap = new HashMap();
        
        String showmonth = year+month;
        if(StringUtil.notEmpty(showmonth)) {
            sql.append(" AND C.CARD_MONTH LIKE :showmonth ");
            paramMap.put("showmonth", "%"+showmonth+"%");
        }
        
        if(StringUtil.notEmpty(ismy)) {
            
            sql.append(" AND A.USER_ID  = :userId ");
            paramMap.put("userId", userId);
        }
        
        sql.append( " ORDER BY C.SUBMIT_TIME DESC  ");
        return baseDao.queryForList(sql.toString(),paramMap);
    }
 
    @Override
    public List ewMonthCalendar(Map<String, String> params) {
        String year = params.get("year");
        String type = params.get("type");
        long nowTime = DateUtil.getCurrentDate6();
        if(!StringUtil.notEmpty(year)) {
            year = DateUtil.getToday("yyyy");
        }
        //初始化月份数据
        List<Map> allMonth = new ArrayList<Map>();
        Map cardmsg = queryZcSatisSpCount();
        List<Map> allcard = (List)cardmsg.get("allcard");
        List<Map> spcard = (List)cardmsg.get("spcard");
        Map cacheMap = new HashMap();
        Map spcacheMap = new HashMap();
        for(Map map:allcard){
            cacheMap.put(map.get("CARD_MONTH"), map.get("NUM"));
        }
        for(Map map:spcard){
            spcacheMap.put(map.get("CARD_MONTH"), map.get("NUM"));
        }
        for(int i=1;i<=12;i++) {
            Map map = new HashMap();
            map.put("year", year);
            String month = i<10?("0"+i):(""+i);
            map.put("month", month);
            System.out.println(year+month);
            long yearMonth = ConvertUtil.obj2Long(year+month);
            if(!StringUtil.isEmpty(ConvertUtil.obj2StrBlank(cacheMap.get(yearMonth)))){
                map.put("state", 1);
                if(!StringUtil.isEmpty(ConvertUtil.obj2StrBlank(spcacheMap.get(yearMonth)))){
                    map.put("num", 1);
                }
            }
            int compareTime = 0;
            if(yearMonth>nowTime) {
                compareTime = 1;
            } else if (yearMonth==nowTime) {
                compareTime = 2;
            } else {
                compareTime = 3;
            }
            map.put("compareTime", compareTime);
        
            allMonth.add(map);
        }
        System.err.println(JsonUtil.list2Json(allMonth));
 
        return allMonth;
    }
    
    @Override
    public Map queryZcSatisSpCount() {
        StringBuilder sql = new StringBuilder();
        sql.append("SELECT C.CARD_MONTH,COUNT(A.ID) NUM FROM SC_CUSTOMER_ZC_UESR A , AUDITING_SATIS_INFO C  WHERE C.USER_ID = A.USER_ID ");
        
        sql.append(" GROUP BY C.CARD_MONTH ");
        StringBuilder sql1 = new StringBuilder();
        sql1.append("SELECT C.CARD_MONTH,COUNT(A.ID) NUM FROM SC_CUSTOMER_ZC_UESR A , AUDITING_SATIS_INFO C  WHERE C.USER_ID = A.USER_ID AND C.STATE = 1 ");
        
        sql1.append(" GROUP BY C.CARD_MONTH ");
    
        List<Map> allcard = baseDao.queryForList(sql.toString());
        List<Map> spcard = baseDao.queryForList(sql1.toString());
        Map result = new HashMap();
        result.put("allcard", allcard);
        result.put("spcard", spcard);
        return result;
    }
 
}