Search in sources :

Example 11 with ExtraProduct

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

the class ExtraProductController method loadImg.

/**
 * 根据id和type,获取图片信息 id:增值产品的主键id type: 0表示应用的LOGO图片, 1应用的介绍图片
 *
 * @param response
 * @return
 */
@RequestMapping(value = "/getImage/{id}/{type}")
public String loadImg(@PathVariable("type") Long type, @PathVariable("id") Long id, HttpServletResponse response) {
    String img = null;
    OutputStream os = null;
    FileInputStream fis = null;
    try {
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        ExtraProduct extraProduct = extraProductService.selectByPrimaryKey(id);
        if (null == extraProduct) {
            return "status403";
        }
        if (type == 0) {
            img = extraProduct.getAppLogo();
        } else if (type == 1) {
            img = extraProduct.getAppDesc();
        }
        if (img == null) {
            return "status403";
        }
        File filePath = extraProductService.getFilePathById(id);
        if (!filePath.exists()) {
            filePath.mkdir();
        }
        File file = new File(filePath, img);
        fis = new FileInputStream(file);
        byte[] bb = IOUtils.toByteArray(fis);
        os = response.getOutputStream();
        os.write(bb);
        os.flush();
    } catch (IOException e) {
        // 未找到
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        // 关闭流!
        try {
            if (null != fis) {
                fis.close();
            }
            if (null != os) {
                os.close();
            }
        } catch (IOException e) {
        }
    }
    return null;
}
Also used : ExtraProduct(com.itrus.portal.db.ExtraProduct) OutputStream(java.io.OutputStream) IOException(java.io.IOException) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with ExtraProduct

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

the class ExtraProductController method loadProtocolPdf.

/**
 * 根据产品id,返回产品协议的pdf文件
 *
 * @param id
 * @param session
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
@RequestMapping("/loadProtocolPdf/{id}")
public String loadProtocolPdf(@PathVariable("id") Long id, HttpSession session, HttpServletRequest request, HttpServletResponse response) throws Exception {
    // UserInfo webuserInfo = (UserInfo)
    // session.getAttribute("webuserInfo");
    // if (null == webuserInfo) {
    // // 登录状态失效
    // return null;
    // }
    ExtraProduct extraProduct = extraProductService.selectByPrimaryKey(id);
    if (null == extraProduct) {
        return "status403";
    }
    String pdf = extraProduct.getExtraProtocol();
    if (null == pdf) {
        return "status403";
    }
    File filePath = extraProductService.getFilePathById(id);
    if (!filePath.exists()) {
        filePath.mkdir();
    }
    File file = new File(filePath, pdf);
    InputStream proxyIn = null;
    // 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
    try {
        proxyIn = new FileInputStream(file);
        response.reset();
        String filename = "协议书.pdf";
        filename = encodeFilename(filename, request);
        // 设置输出文件为
        response.setHeader("Content-disposition", "filename=" + filename);
        response.setCharacterEncoding("utf-8");
        // 由于导出格式是excel的文件,设置导出文件的响应头部信息
        response.setContentType("application/pdf");
        // 用response对象获取输出流
        OutputStream os = response.getOutputStream();
        byte[] bos = new byte[proxyIn.available()];
        proxyIn.read(bos);
        os.write(bos);
        os.flush();
        // 关闭os
        if (os != null) {
            os.close();
        }
        if (null != proxyIn) {
            proxyIn.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : ExtraProduct(com.itrus.portal.db.ExtraProduct) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with ExtraProduct

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

the class ExtraProductController method updatePage.

// 修改基础信息和产品规格信息页面
@RequestMapping(value = "/update/{id}", produces = "text/html")
public String updatePage(@PathVariable("id") Long id, Model uiModel) throws Exception {
    ExtraProduct extraProduct = extraProductService.selectByPrimaryKey(id);
    uiModel.addAttribute("extraProduct", extraProduct);
    List<ExtraProductSpec> extraProductSpecs = extraProductSpecService.getSpecByProductId(id);
    uiModel.addAttribute("extraProductSpecs", extraProductSpecs);
    // 服务提供商组成的map
    Map<Long, ServiceProvider> serviceProviderMap = serviceProviderService.selectMapByExample(null);
    uiModel.addAttribute("serviceProviderMap", serviceProviderMap);
    // 在线支付的map:微信和支付宝
    List<OnlinePay> onlinepays = sqlSession.selectList("com.itrus.portal.db.OnlinePayMapper.selectByExample", null);
    uiModel.addAttribute("onlinepays", onlinepays);
    // 银行付款的List
    List<Transfer> bankPays = sqlSession.selectList("com.itrus.portal.db.TransferMapper.selectByExample", null);
    uiModel.addAttribute("bankPays", bankPays);
    // 电子发票的list
    List<Ereceipt> einvoices = sqlSession.selectList("com.itrus.portal.db.EreceiptMapper.selectByExample", null);
    uiModel.addAttribute("einvoices", einvoices);
    return "extraproduct/update";
}
Also used : Ereceipt(com.itrus.portal.db.Ereceipt) ExtraProduct(com.itrus.portal.db.ExtraProduct) ServiceProvider(com.itrus.portal.db.ServiceProvider) Transfer(com.itrus.portal.db.Transfer) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) OnlinePay(com.itrus.portal.db.OnlinePay) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with ExtraProduct

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

the class ExtraProductController method delete.

// 删除增值产品
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) throws Exception {
    ExtraProduct extraProduct = extraProductService.selectByPrimaryKey(id);
    if (null == extraProduct) {
        return "未找到要删除的增值产品";
    } else {
        try {
            extraProductService.deleteByPrimaryKey(id);
            LogUtil.adminlog(sqlSession, "增值产品", "删除的增值产品:" + extraProduct.getAppName());
        } catch (Exception e) {
            return "要删除的增值产品存在关联,无法删除";
        }
    }
    return null;
}
Also used : ExtraProduct(com.itrus.portal.db.ExtraProduct) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with ExtraProduct

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

the class ExtraProductReleaseController method updatePage.

// 修改页面
@RequestMapping(value = "/update/{id}", produces = "text/html")
public String updatePage(@PathVariable("id") Long id, Model uiModel) throws Exception {
    Project project = projectService.selectByPrimaryKey(id);
    List<ExtraProductRelease> extraProductReleases = extraProductReleaseService.getByprojectId(id);
    // 所有的增值产品信息,以id为主键.以便页面显示信息
    Map<Long, ExtraProduct> extraProductMap = new HashMap<Long, ExtraProduct>();
    extraProductMap = extraProductService.selectMapByExample(null);
    List<ExtraProduct> allProducts = extraProductService.selectByExample(null);
    // 所有产品list
    uiModel.addAttribute("allProducts", allProducts);
    // 项目信息
    uiModel.addAttribute("project", project);
    // 产品与项目之间的关系
    uiModel.addAttribute("extraProductReleases", extraProductReleases);
    // 所有的产品
    uiModel.addAttribute("extraProductMap", extraProductMap);
    // 显示新建的增值产品,还未与项目产生关联
    ExtraProductExample epe = new ExtraProductExample();
    ExtraProductExample.Criteria epec = epe.createCriteria();
    List<Long> havedProductIds = new ArrayList<>();
    for (ExtraProductRelease epr : extraProductReleases) {
        havedProductIds.add(epr.getExtraProduct());
    }
    if (havedProductIds != null && havedProductIds.size() > 0) {
        epec.andIdNotIn(havedProductIds);
    }
    epe.setOrderByClause("id asc");
    // 没有与该项目产生关联关系的增值产品
    List<ExtraProduct> remainingProducts = extraProductService.selectByExample(epe);
    uiModel.addAttribute("remainingProducts", remainingProducts);
    return "extraproductrelease/update";
}
Also used : Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExtraProductExample(com.itrus.portal.db.ExtraProductExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ExtraProduct (com.itrus.portal.db.ExtraProduct)62 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)44 HashMap (java.util.HashMap)28 ExtraBill (com.itrus.portal.db.ExtraBill)25 Enterprise (com.itrus.portal.db.Enterprise)24 UserInfo (com.itrus.portal.db.UserInfo)24 IOException (java.io.IOException)20 Project (com.itrus.portal.db.Project)17 ArrayList (java.util.ArrayList)16 ExtraProductSpec (com.itrus.portal.db.ExtraProductSpec)14 HttpSession (javax.servlet.http.HttpSession)14 File (java.io.File)13 BusinessLicense (com.itrus.portal.db.BusinessLicense)12 OpenBankInfo (com.itrus.portal.db.OpenBankInfo)12 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)12 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)12 IdentityCard (com.itrus.portal.db.IdentityCard)11 ServiceProvider (com.itrus.portal.db.ServiceProvider)11 OrgCode (com.itrus.portal.db.OrgCode)10 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)10