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 params) { String year = params.get("year"); String type = params.get("type"); long nowTime = DateUtil.getCurrentDate6(); if(!StringUtil.notEmpty(year)) { year = DateUtil.getToday("yyyy"); } //初始化月份数据 List allMonth = new ArrayList(); List 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 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 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 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 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 params) { String year = params.get("year"); String type = params.get("type"); long nowTime = DateUtil.getCurrentDate6(); if(!StringUtil.notEmpty(year)) { year = DateUtil.getToday("yyyy"); } //初始化月份数据 List allMonth = new ArrayList(); Map cardmsg = queryZcSatisSpCount(); List allcard = (List)cardmsg.get("allcard"); List 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 allcard = baseDao.queryForList(sql.toString()); List spcard = baseDao.queryForList(sql1.toString()); Map result = new HashMap(); result.put("allcard", allcard); result.put("spcard", spcard); return result; } }