Search in sources :

Example 1 with AppConfig

use of com.itrus.portal.db.AppConfig in project portal by ixinportal.

the class SMSServiceAsync method sendDR.

public Object sendDR(Map param, Integer flag) {
    if (QueueThread.ASYNC_ON == flag) {
        QueueThread.buildTask(sqlSession, this, param);
        return null;
    }
    String authHmac = (String) param.get("authHmac");
    String appid = (String) param.get("appid");
    String mphone = (String) param.get("mphone");
    String content = (String) param.get("content");
    HttpServletRequest request = (HttpServletRequest) param.get("request");
    Map<String, Object> result = new HashMap<String, Object>(2);
    // 验证参数是否完整
    if (StringUtils.isBlank(authHmac) || StringUtils.isBlank(appid) || StringUtils.isBlank(mphone) || StringUtils.isBlank(content)) {
        result.put("retCode", 0);
        result.put("retMsg", "提交的参数信息不完整");
        return result;
    }
    if (content.length() >= 70) {
        result.put("retCode", -1);
        result.put("retMsg", "短信内容过长");
        return result;
    }
    AppConfigExample ace = new AppConfigExample();
    AppConfigExample.Criteria acc = ace.createCriteria();
    acc.andAppIdEqualTo(appid);
    AppConfig ac = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByExample", ace);
    if (null == ac) {
        result.put("retCode", -3);
        result.put("retMsg", "没有此应用");
        return result;
    }
    Smsserver smsserver = sqlSession.selectOne("com.itrus.portal.db.SmsserverMapper.selectByPrimaryKey", ac.getSmsId());
    if (!content.startsWith(smsserver.getSmsSignature())) {
        // 判断短信签名
        result.put("retCode", -2);
        result.put("retMsg", "短信签名错误");
        return result;
    }
    if (ac.getAppStatus() == 1 || !ac.getAppip().contains(request.getRemoteAddr())) {
        LogUtil.syslog(sqlSession, "短信服务", appid + "没有此服务权限,访问ip:" + request.getRemoteAddr());
        result.put("retCode", -4);
        result.put("retMsg", "没有此服务权限");
        return result;
    }
    MessageLog ml;
    String send = "-8";
    // 验证hmac有效性
    try {
        String macVal = Base64.encode(HMACSHA1.getHmacSHA1(appid + content + mphone, ac.getSecretKey()), false);
        if (!authHmac.equals(macVal)) {
            result.put("retCode", -5);
            result.put("retMsg", "服务密钥错误");
            return result;
        }
        ml = new MessageLog();
        ml.setAppId(ac.getId());
        ml.setCellPhone(mphone);
        ml.setContent(content);
        ml.setSendTime(new Date());
        ml.setGate(smsserver.getSmsport());
        // 0亿美 1未来无线
        smsService = SpringContextHolder.getBean("smsClientService" + smsserver.getSmsport());
        // send = smsService.sendSms(smsserver,mphone,content);
        if ("0".equals(send)) {
            ml.setStatus(1);
            // ml.setErrorInfo();
            sqlSession.insert("com.itrus.portal.db.MessageLogMapper.insert", ml);
            result.put("retCode", 1000);
            return result;
        }
    } catch (NoSuchAlgorithmException e) {
        result.put("retCode", -6);
        result.put("retMsg", "Hmac验证错误");
        e.printStackTrace();
        return result;
    } catch (UnsupportedEncodingException e) {
        result.put("retCode", -6);
        result.put("retMsg", "Hmac验证错误");
        e.printStackTrace();
        return result;
    } catch (Exception e) {
        result.put("retCode", -7);
        result.put("retMsg", e.toString());
        e.printStackTrace();
        return result;
    }
    if (null != ml) {
        ml.setStatus(0);
        ml.setErrorInfo("短信接口发送错误,返回" + send);
        sqlSession.insert("com.itrus.portal.db.MessageLogMapper.insert", ml);
    }
    result.put("retCode", send);
    result.put("retMsg", "短信接口发送错误");
    return result;
}
Also used : AppConfig(com.itrus.portal.db.AppConfig) Smsserver(com.itrus.portal.db.Smsserver) HashMap(java.util.HashMap) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Date(java.util.Date) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) HttpServletRequest(javax.servlet.http.HttpServletRequest) AppConfigExample(com.itrus.portal.db.AppConfigExample) MessageLog(com.itrus.portal.db.MessageLog) JSONObject(com.alibaba.fastjson.JSONObject)

Example 2 with AppConfig

use of com.itrus.portal.db.AppConfig in project portal by ixinportal.

the class PersonalAuthenService method personal.

/**
 * 人像识别接口
 * @return
 * @throws Exception
 */
public static String personal(String authHmac, String appId, String personName, String personNo, String frontPhoto, String personUrl) throws Exception {
    // 验证hmac有效性
    AppConfig ac = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", appId);
    try {
        String macVal = CertService.hmacSha1(ac.getSecretKey().getBytes(), (appId + personName + personNo + frontPhoto).getBytes("utf-8"));
        // Base64.encode(HMACSHA1.getHmacSHA1(csr+billId+uid+userId, sc.getAddressKey()), false);
        if (!authHmac.equals("HMAC-SHA1 " + macVal)) {
            return "status:-2,message:服务密钥错误";
        }
    } catch (Exception e) {
        e.printStackTrace();
        return "status:-3,message:Hmac验证错误";
    }
    // String cx = "http://192.168.102.92:8080/realas/porc/pauthen";
    String cx = personUrl + "/ras/porc/pauthen";
    JSONObject jso = new JSONObject();
    jso.put("appId", appId);
    jso.put("personName", personName);
    jso.put("personNo", personNo);
    jso.put("frontPhoto", frontPhoto);
    String post = PersonalAuthenService.sendPost(cx, "params", jso.toJSONString(), "7cd412f3d580481e9655a0f50fd87312");
    System.err.println(post);
    return post;
}
Also used : AppConfig(com.itrus.portal.db.AppConfig) JSONObject(com.alibaba.fastjson.JSONObject)

Example 3 with AppConfig

use of com.itrus.portal.db.AppConfig in project portal by ixinportal.

the class PersonalAuthenService method pbankreal.

/**
 * 个人银行卡认证接口(三要素)
 * @return
 * @throws Exception
 */
public static String pbankreal(String authHmac, String appId, String personName, String personNo, String bankNo, String personUrl) throws Exception {
    // 验证hmac有效性
    AppConfig ac = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", appId);
    try {
        String macVal = CertService.hmacSha1(ac.getSecretKey().getBytes(), (appId + personName + personNo + bankNo).getBytes("utf-8"));
        // Base64.encode(HMACSHA1.getHmacSHA1(csr+billId+uid+userId, sc.getAddressKey()), false);
        if (!authHmac.equals("HMAC-SHA1 " + macVal)) {
            return "status:-2,message:服务密钥错误";
        }
    } catch (Exception e) {
        e.printStackTrace();
        return "status:-3,message:Hmac验证错误";
    }
    // String sq = "http://localhost:8080/ras/pbank/bankreal";
    // String sq = "http://localhost:8080/realas/bank/cbankreal";
    // String sq = "http://localhost:8080/realas/bank/cbankreal";
    String sq = personUrl + "/ras/pbank/bankreal";
    JSONObject jso = new JSONObject();
    jso.put("personName", personName);
    jso.put("personNo", personNo);
    jso.put("bankNo", bankNo);
    jso.put("appId", appId);
    String post = PersonalAuthenService.sendPost(sq, "params", jso.toJSONString(), "7cd412f3d580481e9655a0f50fd87312");
    System.err.println(post);
    return post;
// }
}
Also used : AppConfig(com.itrus.portal.db.AppConfig) JSONObject(com.alibaba.fastjson.JSONObject)

Example 4 with AppConfig

use of com.itrus.portal.db.AppConfig in project portal by ixinportal.

the class MessageStatsController method excelExport.

// 导出Excel
@RequestMapping(value = "/excel")
public String excelExport(@RequestParam(value = "cycle_sel", required = false) Integer cycle, @RequestParam(value = "applicationName", required = false) Long applicationName, @RequestParam(value = "year1_sel", required = false) Integer year1, @RequestParam(value = "year2_sel", required = false) Integer year2, @RequestParam(value = "type", required = false) Integer type, @RequestParam(value = "status_sel", required = false) Integer status_sel, Model uiModel, HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map param = new HashMap();
    Map param2 = new HashMap();
    Integer year3 = null;
    if (year1 != null) {
        year3 = year1;
    }
    List<Map<Integer, Integer>> list = new ArrayList<Map<Integer, Integer>>();
    java.util.Date nowdate = new java.util.Date();
    String[] monthList = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
    String[] seasonList = { "S1", "S2", "S3", "S4" };
    String month = null;
    String season = null;
    String year = null;
    Calendar calendar = Calendar.getInstance();
    Calendar calendar2 = Calendar.getInstance();
    String applicationName1 = null;
    if (null != cycle && cycle == 12) {
        while (year1 <= year2) {
            for (int j = 0; j <= 11; j++) {
                calendar.set(Calendar.YEAR, year1);
                calendar.set(Calendar.MONTH, j);
                calendar.set(Calendar.DAY_OF_MONTH, 1);
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE, 0);
                calendar.set(Calendar.SECOND, 0);
                calendar.set(Calendar.MILLISECOND, 0);
                // calendar.add(Calendar.MILLISECOND, -1);
                Date dt1 = calendar.getTime();
                calendar2.set(Calendar.YEAR, year1);
                calendar2.set(Calendar.MONTH, j + 1);
                calendar2.set(Calendar.DAY_OF_MONTH, 1);
                calendar2.set(Calendar.HOUR_OF_DAY, 0);
                calendar2.set(Calendar.MINUTE, 0);
                calendar2.set(Calendar.SECOND, 0);
                calendar2.set(Calendar.MILLISECOND, 0);
                // calendar2.add(Calendar.MILLISECOND, -1);
                Date dt2 = calendar2.getTime();
                if (applicationName != null && applicationName != 0) {
                    AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
                    applicationName1 = application.getAppName();
                    param.put("applicationName", applicationName);
                }
                param2.put("applicationName", applicationName);
                param2.put("type", type);
                if (status_sel != null && status_sel != 2) {
                    param.put("gate", status_sel);
                } else {
                    param.put("gate", null);
                }
                param2.put("gate", status_sel);
                if (dt2.before(nowdate)) {
                    month = year1 + "-" + monthList[j];
                    param2.put("month", month);
                    MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByMonth1", param2);
                    if (null != msr) {
                        Integer count = msr.getCount1();
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, year1);
                        list.add(map);
                    } else {
                        param.put("queryDate1", dt1);
                        param.put("queryDate2", dt2);
                        Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, year1);
                        list.add(map);
                        MsgStatsRecord msr2 = new MsgStatsRecord();
                        msr2.setMonth1(month);
                        msr2.setAppId(applicationName);
                        msr2.setCount1(count);
                        msr2.setType(type);
                        msr2.setGate(status_sel);
                        msr2.setCreateTime(new Date());
                        sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
                    }
                } else {
                    param.put("queryDate1", dt1);
                    param.put("queryDate2", dt2);
                    Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                    map.put(count, year1);
                    list.add(map);
                }
            }
            year1++;
        }
    }
    if (null != cycle && cycle == 4) {
        while (year1 <= year2) {
            for (int j = 0; j <= 9; j = j + 3) {
                calendar.set(Calendar.YEAR, year1);
                calendar.set(Calendar.MONTH, j);
                calendar.set(Calendar.DAY_OF_MONTH, 1);
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE, 0);
                calendar.set(Calendar.SECOND, 0);
                calendar.set(Calendar.MILLISECOND, 0);
                // calendar.add(Calendar.MILLISECOND, -1);
                Date dt1 = calendar.getTime();
                calendar2.set(Calendar.YEAR, year1);
                calendar2.set(Calendar.MONTH, j + 3);
                calendar2.set(Calendar.DAY_OF_MONTH, 1);
                calendar2.set(Calendar.HOUR_OF_DAY, 0);
                calendar2.set(Calendar.MINUTE, 0);
                calendar2.set(Calendar.SECOND, 0);
                calendar2.set(Calendar.MILLISECOND, 0);
                // calendar2.add(Calendar.MILLISECOND, -1);
                Date dt2 = calendar2.getTime();
                if (applicationName != null && applicationName != 0) {
                    AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
                    applicationName1 = application.getAppName();
                    param.put("applicationName", applicationName);
                }
                param2.put("applicationName", applicationName);
                param2.put("type", type);
                if (status_sel != null && status_sel != 2) {
                    param.put("gate", status_sel);
                } else {
                    param.put("gate", null);
                }
                param2.put("gate", status_sel);
                if (dt2.before(nowdate)) {
                    season = year1 + "-" + seasonList[j / 3];
                    param2.put("season", season);
                    MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectBySeason2", param2);
                    if (null != msr) {
                        Integer count = msr.getCount1();
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, year1);
                        list.add(map);
                    } else {
                        param.put("queryDate1", dt1);
                        param.put("queryDate2", dt2);
                        Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, year1);
                        list.add(map);
                        MsgStatsRecord msr2 = new MsgStatsRecord();
                        msr2.setSeason1(season);
                        msr2.setAppId(applicationName);
                        msr2.setCount1(count);
                        msr2.setType(type);
                        msr2.setGate(status_sel);
                        msr2.setCreateTime(new Date());
                        sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
                    }
                } else {
                    param.put("queryDate1", dt1);
                    param.put("queryDate2", dt2);
                    Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                    map.put(count, year1);
                    list.add(map);
                }
            }
            year1++;
        }
    }
    if (null != cycle && cycle == 1) {
        while (year1 <= year2) {
            calendar.set(Calendar.YEAR, year1);
            calendar.set(Calendar.MONTH, 0);
            calendar.set(Calendar.DATE, 1);
            calendar.set(Calendar.HOUR_OF_DAY, 0);
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);
            // calendar.add(Calendar.MILLISECOND, -1);
            Date dt1 = calendar.getTime();
            calendar2.set(Calendar.YEAR, year1 + 1);
            calendar2.set(Calendar.MONTH, 0);
            calendar2.set(Calendar.DAY_OF_MONTH, 1);
            calendar2.set(Calendar.HOUR_OF_DAY, 0);
            calendar2.set(Calendar.MINUTE, 0);
            calendar2.set(Calendar.SECOND, 0);
            calendar2.set(Calendar.MILLISECOND, 0);
            // calendar2.add(Calendar.MILLISECOND, -1);
            Date dt2 = calendar2.getTime();
            if (applicationName != null && applicationName != 0) {
                AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
                applicationName1 = application.getAppName();
                param.put("applicationName", applicationName);
            }
            param2.put("applicationName", applicationName);
            param2.put("type", type);
            if (status_sel != null && status_sel != 2) {
                param.put("gate", status_sel);
            } else {
                param.put("gate", null);
            }
            param2.put("gate", status_sel);
            if (dt2.before(nowdate)) {
                year = year1 + "Y";
                param2.put("year", year);
                MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByYear1", param2);
                if (null != msr) {
                    Integer count = msr.getCount1();
                    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                    map.put(count, year1);
                    list.add(map);
                } else {
                    param.put("queryDate1", dt1);
                    param.put("queryDate2", dt2);
                    Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                    map.put(count, year1);
                    list.add(map);
                    MsgStatsRecord msr2 = new MsgStatsRecord();
                    msr2.setYear1(year);
                    msr2.setAppId(applicationName);
                    msr2.setCount1(count);
                    msr2.setType(type);
                    msr2.setGate(status_sel);
                    msr2.setCreateTime(new Date());
                    sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
                }
            } else {
                param.put("queryDate1", dt1);
                param.put("queryDate2", dt2);
                Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                map.put(count, year1);
                list.add(map);
            }
            year1++;
        }
    }
    if (null == applicationName || 0 == applicationName) {
        applicationName1 = "所有应用";
    }
    String sgName = "";
    if (status_sel == 0)
        sgName = "亿美";
    if (status_sel == 1)
        sgName = "未来无线";
    if (status_sel == 2)
        sgName = "所有端口";
    ArrayList<String> fieldName = messageStatsService.excelFieldName();
    ArrayList<ArrayList<String>> fieldDatas = messageStatsService.excelFieldData(list, applicationName1, cycle, sgName);
    ExcelFileGenerator generator = new ExcelFileGenerator(fieldName, fieldDatas);
    try {
        // 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
        response.reset();
        String filename = "短信统计信息" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + // 设置下载时客户端Excel的名称,此处需要用到encodeFilename()方法来转换编码,否则中文会被过滤掉
        ".xls";
        filename = generator.encodeFilename(filename, request);
        response.setHeader("Content-disposition", "attachment;filename=" + filename);
        response.setCharacterEncoding("utf-8");
        // 由于导出格式是excel的文件,设置导出文件的响应头部信息
        response.setContentType("application/vnd.ms-excel");
        // 生成excel,传递输出流
        // 用response对象获取输出流
        OutputStream os = response.getOutputStream();
        generator.expordExcel(os);
        // 清理刷新缓冲区,将缓存中的数据将数据导出excel
        os.flush();
        // 关闭os
        if (os != null) {
            os.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : AppConfig(com.itrus.portal.db.AppConfig) OutputStream(java.io.OutputStream) MsgStatsRecord(com.itrus.portal.db.MsgStatsRecord) ExcelFileGenerator(com.itrus.portal.utils.ExcelFileGenerator) java.util(java.util) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with AppConfig

use of com.itrus.portal.db.AppConfig in project portal by ixinportal.

the class MessageStatsController method list.

@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "cycle", required = false) Integer cycle, @RequestParam(value = "applicationName", required = false) Long applicationName, @RequestParam(value = "year1", required = false) Integer year1, @RequestParam(value = "year2", required = false) Integer year2, @RequestParam(value = "cycle2", required = false) Integer cycle2, @RequestParam(value = "projectName", required = false) Long projectName, @RequestParam(value = "year3", required = false) Integer year4, @RequestParam(value = "year4", required = false) Integer year5, @RequestParam(value = "type", required = false) Integer type, @RequestParam(value = "status_sel", required = false) Integer status_sel, @RequestParam(value = "status_sel2", required = false) Integer status_sel2, Model uiModel) throws Exception {
    Map param = new HashMap();
    Map param2 = new HashMap();
    String applicationName1 = null;
    String projectName1 = null;
    // List<Integer> years = new ArrayList<Integer>();
    /*       int a = year1 - year2;
        if (a ==0){
            years.add(year1);
        }
        else{
            for (int i =0; i <=a; i++){
                years.add(year1+i);
            }
        } */
    Integer year3 = null;
    if (year1 != null) {
        year3 = year1;
    }
    Integer year6 = null;
    if (year4 != null) {
        year6 = year4;
    }
    List<Map<Integer, Integer>> list = new ArrayList<Map<Integer, Integer>>();
    List<Map<Integer, Integer>> list2 = new ArrayList<Map<Integer, Integer>>();
    java.util.Date nowdate = new java.util.Date();
    String[] monthList = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
    String[] seasonList = { "S1", "S2", "S3", "S4" };
    String month = null;
    String season = null;
    String year = null;
    Calendar calendar = Calendar.getInstance();
    Calendar calendar2 = Calendar.getInstance();
    Integer yr1 = null;
    Integer yr2 = null;
    Integer ccl = null;
    if (null != type && type == 1) {
        yr1 = year1;
        yr2 = year2;
        ccl = cycle;
    }
    if (null != type && type == 2) {
        yr1 = year4;
        yr2 = year5;
        ccl = cycle2;
    }
    if (null != ccl && ccl == 12) {
        while (yr1 <= yr2) {
            for (int j = 0; j <= 11; j++) {
                calendar.set(Calendar.YEAR, yr1);
                calendar.set(Calendar.MONTH, j);
                calendar.set(Calendar.DAY_OF_MONTH, 1);
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE, 0);
                calendar.set(Calendar.SECOND, 0);
                calendar.set(Calendar.MILLISECOND, 0);
                // calendar.add(Calendar.MILLISECOND, -1);
                Date dt1 = calendar.getTime();
                calendar2.set(Calendar.YEAR, yr1);
                calendar2.set(Calendar.MONTH, j + 1);
                calendar2.set(Calendar.DAY_OF_MONTH, 1);
                calendar2.set(Calendar.HOUR_OF_DAY, 0);
                calendar2.set(Calendar.MINUTE, 0);
                calendar2.set(Calendar.SECOND, 0);
                calendar2.set(Calendar.MILLISECOND, 0);
                // calendar2.add(Calendar.MILLISECOND, -1);
                Date dt2 = calendar2.getTime();
                if (type == 1) {
                    if (applicationName != null && applicationName != 0) {
                        AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
                        applicationName1 = application.getAppName();
                        param.put("applicationName", applicationName);
                    }
                    param2.put("applicationName", applicationName);
                    param2.put("type", type);
                    if (status_sel != null && status_sel != 2) {
                        param.put("gate", status_sel);
                    } else {
                        param.put("gate", null);
                    }
                    param2.put("gate", status_sel);
                    if (dt2.before(nowdate)) {
                        month = yr1 + "-" + monthList[j];
                        param2.put("month", month);
                        MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByMonth1", param2);
                        if (null != msr) {
                            Integer count = msr.getCount1();
                            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                            map.put(count, yr1);
                            list.add(map);
                        } else {
                            param.put("queryDate1", dt1);
                            param.put("queryDate2", dt2);
                            Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                            map.put(count, yr1);
                            list.add(map);
                            MsgStatsRecord msr2 = new MsgStatsRecord();
                            msr2.setMonth1(month);
                            msr2.setAppId(applicationName);
                            msr2.setCount1(count);
                            msr2.setType(type);
                            msr2.setGate(status_sel);
                            msr2.setCreateTime(new Date());
                            sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
                        }
                    } else {
                        param.put("queryDate1", dt1);
                        param.put("queryDate2", dt2);
                        Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, yr1);
                        list.add(map);
                    }
                }
                if (type == 2) {
                    if (projectName != null && projectName != 0) {
                        Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectName);
                        projectName1 = project.getName();
                        param.put("projectName", projectName);
                    }
                    param2.put("projectName", projectName);
                    param2.put("type", type);
                    if (status_sel2 != null && status_sel2 != 2) {
                        param.put("gate", status_sel2);
                    } else {
                        param.put("gate", null);
                    }
                    param2.put("gate", status_sel2);
                    if (dt2.before(nowdate)) {
                        month = yr1 + "-" + monthList[j];
                        param2.put("month", month);
                        MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByMonth2", param2);
                        if (null != msr) {
                            Integer count = msr.getCount1();
                            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                            map.put(count, yr1);
                            list2.add(map);
                        } else {
                            param.put("queryDate3", dt1);
                            param.put("queryDate4", dt2);
                            Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
                            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                            map.put(count, yr1);
                            list2.add(map);
                            MsgStatsRecord msr2 = new MsgStatsRecord();
                            msr2.setMonth1(month);
                            msr2.setAppId(projectName);
                            msr2.setCount1(count);
                            msr2.setType(type);
                            msr2.setGate(status_sel2);
                            msr2.setCreateTime(new Date());
                            sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
                        }
                    } else {
                        param.put("queryDate3", dt1);
                        param.put("queryDate4", dt2);
                        Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, yr1);
                        list2.add(map);
                    }
                }
            }
            yr1++;
        }
    }
    if (null != ccl && ccl == 4) {
        while (yr1 <= yr2) {
            for (int j = 0; j <= 9; j = j + 3) {
                calendar.set(Calendar.YEAR, yr1);
                calendar.set(Calendar.MONTH, j);
                calendar.set(Calendar.DAY_OF_MONTH, 1);
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE, 0);
                calendar.set(Calendar.SECOND, 0);
                calendar.set(Calendar.MILLISECOND, 0);
                // calendar.add(Calendar.MILLISECOND, -1);
                Date dt1 = calendar.getTime();
                calendar2.set(Calendar.YEAR, yr1);
                calendar2.set(Calendar.MONTH, j + 3);
                calendar2.set(Calendar.DAY_OF_MONTH, 1);
                calendar2.set(Calendar.HOUR_OF_DAY, 0);
                calendar2.set(Calendar.MINUTE, 0);
                calendar2.set(Calendar.SECOND, 0);
                calendar2.set(Calendar.MILLISECOND, 0);
                // calendar2.add(Calendar.MILLISECOND, -1);
                Date dt2 = calendar2.getTime();
                if (type == 1) {
                    if (applicationName != null && applicationName != 0) {
                        AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
                        applicationName1 = application.getAppName();
                        param.put("applicationName", applicationName);
                    }
                    param2.put("applicationName", applicationName);
                    param2.put("type", type);
                    if (status_sel != null && status_sel != 2) {
                        param.put("gate", status_sel);
                    } else {
                        param.put("gate", null);
                    }
                    param2.put("gate", status_sel);
                    if (dt2.before(nowdate)) {
                        season = yr1 + "-" + seasonList[j / 3];
                        param2.put("season", season);
                        MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectBySeason1", param2);
                        if (null != msr) {
                            Integer count = msr.getCount1();
                            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                            map.put(count, yr1);
                            list.add(map);
                        } else {
                            param.put("queryDate1", dt1);
                            param.put("queryDate2", dt2);
                            Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                            map.put(count, yr1);
                            list.add(map);
                            MsgStatsRecord msr2 = new MsgStatsRecord();
                            msr2.setSeason1(season);
                            msr2.setAppId(applicationName);
                            msr2.setCount1(count);
                            msr2.setType(type);
                            msr2.setGate(status_sel);
                            msr2.setCreateTime(new Date());
                            sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
                        }
                    } else {
                        param.put("queryDate1", dt1);
                        param.put("queryDate2", dt2);
                        Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, yr1);
                        list.add(map);
                    }
                }
                if (type == 2) {
                    if (projectName != null && projectName != 0) {
                        Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectName);
                        projectName1 = project.getName();
                        param.put("projectName", projectName);
                    }
                    param2.put("projectName", projectName);
                    param2.put("type", type);
                    if (status_sel2 != null && status_sel2 != 2) {
                        param.put("gate", status_sel2);
                    } else {
                        param.put("gate", null);
                    }
                    param2.put("gate", status_sel2);
                    if (dt2.before(nowdate)) {
                        season = yr1 + "-" + seasonList[j / 3];
                        param2.put("season", season);
                        MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectBySeason2", param2);
                        if (null != msr) {
                            Integer count = msr.getCount1();
                            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                            map.put(count, yr1);
                            list2.add(map);
                        } else {
                            param.put("queryDate3", dt1);
                            param.put("queryDate4", dt2);
                            Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
                            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                            map.put(count, yr1);
                            list2.add(map);
                            MsgStatsRecord msr2 = new MsgStatsRecord();
                            msr2.setSeason1(season);
                            msr2.setAppId(projectName);
                            msr2.setCount1(count);
                            msr2.setType(type);
                            msr2.setGate(status_sel2);
                            msr2.setCreateTime(new Date());
                            sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
                        }
                    } else {
                        param.put("queryDate3", dt1);
                        param.put("queryDate4", dt2);
                        Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, yr1);
                        list2.add(map);
                    }
                }
            }
            yr1++;
        }
    }
    if (null != ccl && ccl == 1) {
        while (yr1 <= yr2) {
            calendar.set(Calendar.YEAR, yr1);
            calendar.set(Calendar.MONTH, 0);
            calendar.set(Calendar.DAY_OF_MONTH, 1);
            calendar.set(Calendar.HOUR_OF_DAY, 0);
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);
            // calendar.add(Calendar.MILLISECOND, -1);
            Date dt1 = calendar.getTime();
            calendar2.set(Calendar.YEAR, yr1 + 1);
            calendar2.set(Calendar.MONTH, 0);
            calendar2.set(Calendar.DAY_OF_MONTH, 1);
            calendar2.set(Calendar.HOUR_OF_DAY, 0);
            calendar2.set(Calendar.MINUTE, 0);
            calendar2.set(Calendar.SECOND, 0);
            calendar2.set(Calendar.MILLISECOND, 0);
            // calendar2.add(Calendar.MILLISECOND, -1);
            Date dt2 = calendar2.getTime();
            if (type == 1) {
                if (applicationName != null && applicationName != 0) {
                    AppConfig application = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByPrimaryKey", applicationName);
                    applicationName1 = application.getAppName();
                    param.put("applicationName", applicationName);
                }
                param2.put("applicationName", applicationName);
                param2.put("type", type);
                if (status_sel != null && status_sel != 2) {
                    param.put("gate", status_sel);
                } else {
                    param.put("gate", null);
                }
                param2.put("gate", status_sel);
                if (dt2.before(nowdate)) {
                    year = yr1 + "Y";
                    param2.put("year", year);
                    MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByYear1", param2);
                    if (null != msr) {
                        Integer count = msr.getCount1();
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, yr1);
                        list.add(map);
                    } else {
                        param.put("queryDate1", dt1);
                        param.put("queryDate2", dt2);
                        Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, yr1);
                        list.add(map);
                        MsgStatsRecord msr2 = new MsgStatsRecord();
                        msr2.setYear1(year);
                        msr2.setAppId(applicationName);
                        msr2.setCount1(count);
                        msr2.setType(type);
                        // msr2.setGate(status_sel);
                        msr2.setCreateTime(new Date());
                        sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
                    }
                } else {
                    param.put("queryDate1", dt1);
                    param.put("queryDate2", dt2);
                    Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod", param);
                    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                    map.put(count, yr1);
                    list.add(map);
                }
            }
            if (type == 2) {
                if (projectName != null && projectName != 0) {
                    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectName);
                    projectName1 = project.getName();
                    param.put("projectName", projectName);
                }
                param2.put("projectName", projectName);
                param2.put("type", type);
                if (status_sel2 != null && status_sel2 != 2) {
                    param.put("gate", status_sel2);
                } else {
                    param.put("gate", null);
                }
                param2.put("gate", status_sel2);
                if (dt2.before(nowdate)) {
                    year = yr1 + "Y";
                    param2.put("year", year);
                    MsgStatsRecord msr = sqlSession.selectOne("com.itrus.portal.db.MsgStatsRecordMapper.selectByYear2", param2);
                    if (null != msr) {
                        Integer count = msr.getCount1();
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, yr1);
                        list2.add(map);
                    } else {
                        param.put("queryDate3", dt1);
                        param.put("queryDate4", dt2);
                        Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, yr1);
                        list2.add(map);
                        MsgStatsRecord msr2 = new MsgStatsRecord();
                        msr2.setYear1(year);
                        msr2.setAppId(projectName);
                        msr2.setCount1(count);
                        msr2.setType(type);
                        msr2.setGate(status_sel2);
                        msr2.setCreateTime(new Date());
                        sqlSession.insert("com.itrus.portal.db.MsgStatsRecordMapper.insert", msr2);
                    }
                } else {
                    param.put("queryDate3", dt1);
                    param.put("queryDate4", dt2);
                    Integer count = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectCountByPeriod2", param);
                    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                    map.put(count, yr1);
                    list2.add(map);
                }
            }
            yr1++;
        }
    }
    if (null == applicationName || 0 == applicationName) {
        applicationName1 = "所有应用";
    }
    if (null == projectName || 0 == projectName) {
        projectName1 = "所有项目";
    }
    Map<Long, AppConfig> appConfigMap = new HashMap<Long, AppConfig>();
    appConfigMap = sqlSession.selectMap("com.itrus.portal.db.AppConfigMapper.selectByExample", null, "id");
    Map<Long, Project> projectMap = sqlSession.selectMap("com.itrus.portal.db.ProjectMapper.selectByExample", "id");
    uiModel.addAttribute("projectMap", projectMap);
    uiModel.addAttribute("list", list);
    uiModel.addAttribute("year1", year3);
    uiModel.addAttribute("year2", year2);
    uiModel.addAttribute("cycle", cycle);
    uiModel.addAttribute("applicationName", applicationName);
    uiModel.addAttribute("applications", appConfigMap);
    uiModel.addAttribute("applicationN", applicationName1);
    uiModel.addAttribute("list2", list2);
    uiModel.addAttribute("year3", year6);
    uiModel.addAttribute("year4", year5);
    uiModel.addAttribute("cycle2", cycle2);
    uiModel.addAttribute("projectName", projectName);
    uiModel.addAttribute("projectN", projectName1);
    uiModel.addAttribute("projects", getProjectMapOfAdmin());
    uiModel.addAttribute("type", type);
    uiModel.addAttribute("status_sel", status_sel);
    uiModel.addAttribute("status_sel2", status_sel2);
    return "messagestats/list";
}
Also used : AppConfig(com.itrus.portal.db.AppConfig) MsgStatsRecord(com.itrus.portal.db.MsgStatsRecord) Project(com.itrus.portal.db.Project) java.util(java.util) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AppConfig (com.itrus.portal.db.AppConfig)5 JSONObject (com.alibaba.fastjson.JSONObject)3 MsgStatsRecord (com.itrus.portal.db.MsgStatsRecord)2 java.util (java.util)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 AppConfigExample (com.itrus.portal.db.AppConfigExample)1 MessageLog (com.itrus.portal.db.MessageLog)1 Project (com.itrus.portal.db.Project)1 Smsserver (com.itrus.portal.db.Smsserver)1 ExcelFileGenerator (com.itrus.portal.utils.ExcelFileGenerator)1 OutputStream (java.io.OutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1