Search in sources :

Example 26 with Project

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

the class SignStatsController method excelExport.

// 导出Excel
@RequestMapping(value = "/excel")
public String excelExport(@RequestParam(value = "cycle_sel", required = false) Integer cycle, @RequestParam(value = "projectName", required = false) Long projectName, @RequestParam(value = "year1_sel", required = false) Integer year1, @RequestParam(value = "year2_sel", required = false) Integer year2, 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 projectName1 = 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 (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);
                if (dt2.before(nowdate)) {
                    month = year1 + "-" + monthList[j];
                    param2.put("month", month);
                    SignStatsRecord ssr = sqlSession.selectOne("com.itrus.portal.db.SignStatsRecordMapper.selectByMonth1", param2);
                    if (null != ssr) {
                        Integer count = ssr.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.SignRecordMapper.selectCountByPeriod", param);
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, year1);
                        list.add(map);
                        SignStatsRecord ssr2 = new SignStatsRecord();
                        ssr2.setMonth1(month);
                        ssr2.setProjectId(projectName);
                        ssr2.setCount1(count);
                        ssr2.setCreateTime(new Date());
                        sqlSession.insert("com.itrus.portal.db.SignStatsRecordMapper.insert", ssr2);
                    }
                } else {
                    param.put("queryDate1", dt1);
                    param.put("queryDate2", dt2);
                    Integer count = sqlSession.selectOne("com.itrus.portal.db.SignRecordMapper.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 (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);
                if (dt2.before(nowdate)) {
                    season = year1 + "-" + seasonList[j / 3];
                    param2.put("season", season);
                    SignStatsRecord ssr = sqlSession.selectOne("com.itrus.portal.db.SignStatsRecordMapper.selectBySeason1", param2);
                    if (null != ssr) {
                        Integer count = ssr.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.SignRecordMapper.selectCountByPeriod", param);
                        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                        map.put(count, year1);
                        list.add(map);
                        SignStatsRecord ssr2 = new SignStatsRecord();
                        ssr2.setSeason1(season);
                        ssr2.setProjectId(projectName);
                        ssr2.setCount1(count);
                        ssr2.setCreateTime(new Date());
                        sqlSession.insert("com.itrus.portal.db.SignStatsRecordMapper.insert", ssr2);
                    }
                } else {
                    param.put("queryDate1", dt1);
                    param.put("queryDate2", dt2);
                    Integer count = sqlSession.selectOne("com.itrus.portal.db.SignRecordMapper.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 (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);
            if (dt2.before(nowdate)) {
                year = year1 + "Y";
                param2.put("year", year);
                SignStatsRecord ssr = sqlSession.selectOne("com.itrus.portal.db.SignStatsRecordMapper.selectByYear1", param2);
                if (null != ssr) {
                    Integer count = ssr.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.SignRecordMapper.selectCountByPeriod", param);
                    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                    map.put(count, year1);
                    list.add(map);
                    SignStatsRecord ssr2 = new SignStatsRecord();
                    ssr2.setYear1(year);
                    ssr2.setProjectId(projectName);
                    ssr2.setCount1(count);
                    ssr2.setCreateTime(new Date());
                    sqlSession.insert("com.itrus.portal.db.SignStatsRecordMapper.insert", ssr2);
                }
            } else {
                param.put("queryDate1", dt1);
                param.put("queryDate2", dt2);
                Integer count = sqlSession.selectOne("com.itrus.portal.db.SignRecordMapper.selectCountByPeriod", param);
                Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                map.put(count, year1);
                list.add(map);
            }
            year1++;
        }
    }
    if (null == projectName || 0 == projectName) {
        projectName1 = "所有项目";
    }
    ArrayList<String> fieldName = signStatsService.excelFieldName();
    ArrayList<ArrayList<String>> fieldDatas = signStatsService.excelFieldData(list, projectName1, cycle);
    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 : OutputStream(java.io.OutputStream) ExcelFileGenerator(com.itrus.portal.utils.ExcelFileGenerator) SignStatsRecord(com.itrus.portal.db.SignStatsRecord) Project(com.itrus.portal.db.Project) java.util(java.util) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with Project

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

the class AdminController method show.

// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
    Admin admin = sqlSession.selectOne("com.itrus.portal.db.AdminMapper.selectByPrimaryKey", id);
    admin.setPassword("");
    uiModel.addAttribute("admin", admin);
    if (admin.getAdminRole() != null) {
        AdminRole adminRole = sqlSession.selectOne("com.itrus.portal.db.AdminRoleMapper.selectByPrimaryKey", admin.getAdminRole());
        uiModel.addAttribute("adminRole", adminRole);
    }
    uiModel.addAttribute("hasAllProject", 0);
    if (admin.getProjects().contains(",")) {
        String[] strs = admin.getProjects().split(",");
        for (String s : strs) {
            if (s.equals("0")) {
                // 包含所有项目
                uiModel.addAttribute("hasAllProject", 1);
                break;
            }
        }
    }
    uiModel.addAttribute("projectMap", adminService.getProjectByAdminId(id));
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", admin.getProject());
    uiModel.addAttribute("project", project);
    return "admins/show";
}
Also used : Project(com.itrus.portal.db.Project) AdminRole(com.itrus.portal.db.AdminRole) Admin(com.itrus.portal.db.Admin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with Project

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

the class AppController method creat.

/**
 * 保存新建数据
 * @return
 */
@RequestMapping(value = "/creat")
public String creat(@Valid App app, @RequestParam(value = "photofile", required = false) MultipartFile photofile, @RequestParam(value = "retpath", required = false) String retpath, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) throws Exception {
    if (bindingResult.hasErrors()) {
        return "apps/create";
    }
    if (!isRightPhoto(httpServletRequest)) {
        uiModel.addAttribute("projects", getProjectMapOfAdmin().values());
        uiModel.addAttribute("photoError", "请设置符合规则的应用图片");
        return "apps/create";
    }
    app.setWindows(app.getWindows() == null ? false : app.getWindows());
    app.setAndroid(app.getAndroid() == null ? false : app.getAndroid());
    app.setIos(app.getIos() == null ? false : app.getIos());
    app.setCreateTime(new Date());
    app.setId(null);
    // 先设置默认的唯一编码和服务密码
    app.setUniqueId(new Date().getTime() + "");
    app.setAuthPass(new Date().getTime() + "");
    sqlSession.insert("com.itrus.portal.db.AppMapper.insert", app);
    if (null != photofile && !photofile.isEmpty()) {
        File logoFile = appService.saveFile(photofile, app.getId(), FILE_TYPE_JPG);
        app.setAppIcon(logoFile.getName());
    }
    app.setUniqueId(UniqueIDUtils.genAppUID(app, null));
    // 应用唯一标识加管理员账号加时间的毫秒的MD5值
    app.setAuthPass(md5Encoder.encodePassword(app.getUniqueId() + getNameOfAdmin() + new Date().getTime(), null).toUpperCase());
    sqlSession.update("com.itrus.portal.db.AppMapper.updateByPrimaryKey", app);
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", app.getProject());
    String oper = "添加应用";
    String info = "项目名称: " + project.getName() + ", 应用名称: " + app.getName() + ", 应用简称: " + app.getShortName();
    LogUtil.adminlog(sqlSession, oper, info);
    if (retpath != null && retpath.length() > 0)
        return retpath;
    else
        return "redirect:/apps";
}
Also used : Project(com.itrus.portal.db.Project) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with Project

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

the class AppController method list.

@RequestMapping(produces = "text/html")
public String list(Model uiModel, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, HttpSession session) {
    Map<Long, Project> projectmap = getProjectMapOfAdmin();
    if (page == null || page < 1) {
        page = 1;
    }
    if (size == null || size < 1) {
        size = 10;
    }
    AppExample appex = new AppExample();
    Integer count = sqlSession.selectOne("com.itrus.portal.db.AppMapper.countByExample", appex);
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    Integer offset = size * (page - 1);
    appex.setOffset(offset);
    appex.setLimit(size);
    List<App> appList = sqlSession.selectList("com.itrus.portal.db.AppMapper.selectByExample", appex);
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    uiModel.addAttribute("projectmap", projectmap);
    uiModel.addAttribute("appList", appList);
    String delMsg = (String) session.getAttribute(APP_DEL_MSG);
    if (StringUtils.isNotBlank(delMsg)) {
        uiModel.addAttribute("message", delMsg);
        session.removeAttribute(APP_DEL_MSG);
    }
    return "apps/list";
}
Also used : App(com.itrus.portal.db.App) Project(com.itrus.portal.db.Project) AppExample(com.itrus.portal.db.AppExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 30 with Project

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

the class ReviewServiceImpl method sendSmsBySHJJ.

// 拒绝后台的订单,发送短信通知
/**
 * 发送审核拒绝短信通知(模版类型:SHJJ)
 *
 * @param billId
 * @return
 */
public boolean sendSmsBySHJJ(Long billId) {
    if (null == billId) {
        return false;
    }
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    if (null == bill) {
        return false;
    }
    // 查询短信模版
    // 查找对应项目的消息模版:SHJJ
    MessageTemplate messageTemplate = messageTemplateService.getMsgTemp(bill.getProject(), "SHJJ");
    if (null == messageTemplate) {
        logger.error("发送短信失败,未找到对应的鉴证审核消息模版");
        return false;
    }
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
    String content = messageTemplate.getMessageContent();
    // 替换特定内容:企业名称:enterpriseName,产品名称:productName,项目名称:projectName,拒绝原因:reason
    if (content.contains("enterpriseName")) {
        content = content.replaceAll("enterpriseName", enterprise.getEnterpriseName());
    }
    if (content.contains("productName")) {
        content = content.replaceAll("productName", product.getName());
    }
    if (content.contains("projectName")) {
        content = content.replaceAll("projectName", project.getName());
    }
    if (content.contains("reason")) {
        content = content.replaceAll("reason", bill.getCancelReason());
    }
    // 发送短信
    try {
        if (smsSendService.sendRefuseReview(userInfo.getmPhone(), content, "SHJJ", project.getId(), userInfo.getUniqueId(), bill.getBillId())) {
            // 发送成功
            return true;
        } else {
            return false;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) Project(com.itrus.portal.db.Project) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) ParseException(java.text.ParseException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

Aggregations

Project (com.itrus.portal.db.Project)77 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)59 HashMap (java.util.HashMap)32 UserInfo (com.itrus.portal.db.UserInfo)24 Enterprise (com.itrus.portal.db.Enterprise)20 ExtraProduct (com.itrus.portal.db.ExtraProduct)17 ProjectExample (com.itrus.portal.db.ProjectExample)16 ArrayList (java.util.ArrayList)15 ProjectKeyInfo (com.itrus.portal.db.ProjectKeyInfo)12 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)12 Product (com.itrus.portal.db.Product)10 Date (java.util.Date)10 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)9 BusinessLicense (com.itrus.portal.db.BusinessLicense)8 IdentityCard (com.itrus.portal.db.IdentityCard)8 OrgCode (com.itrus.portal.db.OrgCode)8 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)8 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)8 List (java.util.List)8 Map (java.util.Map)8