Search in sources :

Example 6 with ExtraProductRelease

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

the class ExtraProductReleaseServiceImpl method getByprojectId.

/**
 * 选择项目下所有的产品信息
 *
 * @param id
 * @return
 * @throws Exception
 */
public List<ExtraProductRelease> getByprojectId(Long id) throws Exception {
    List<ExtraProductRelease> extraProductReleases = new ArrayList<>();
    ExtraProductReleaseExample example = new ExtraProductReleaseExample();
    ExtraProductReleaseExample.Criteria criteria = example.or();
    criteria.andProjectEqualTo(id);
    example.setOrderByClause("priority asc");
    extraProductReleases = selectByExample(example);
    return extraProductReleases;
}
Also used : ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) ArrayList(java.util.ArrayList) ExtraProductReleaseExample(com.itrus.portal.db.ExtraProductReleaseExample)

Example 7 with ExtraProductRelease

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

the class ExtraProductReleaseServiceImpl method getByprojectAndType.

/**
 * 根据项目id,和平台类型,获取对应的发布产品,根据优先级进行排序
 * @param id
 * @param type
 * @return
 * @throws Exception
 */
public List<ExtraProductRelease> getByprojectAndType(Long id, String type) throws Exception {
    List<ExtraProductRelease> extraProductReleases = new ArrayList<>();
    ExtraProductReleaseExample example = new ExtraProductReleaseExample();
    ExtraProductReleaseExample.Criteria criteria = example.or();
    criteria.andProjectEqualTo(id);
    criteria.andAppTypeLike("%" + type + "%");
    example.setOrderByClause("priority ASC");
    example.setOrderByClause("priority ASC");
    extraProductReleases = selectByExample(example);
    return extraProductReleases;
}
Also used : ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) ArrayList(java.util.ArrayList) ExtraProductReleaseExample(com.itrus.portal.db.ExtraProductReleaseExample)

Example 8 with ExtraProductRelease

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

the class ExtraProductReleaseServiceImpl method saveByJson.

/**
 * 1.先判断本次传入的是新增改是修改. 2.判断是不是有的产品的关联关系没有了(原本数据库中有,但是现在没有了的,就是要删除的)
 *
 * @param json
 * @return
 * @throws Exception
 */
public Long saveByJson(String json) throws Exception {
    Long projectId = null;
    JsonNode jsonNodes = null;
    jsonNodes = jsonTool.readTree(json);
    // 查询项目原本的关联的产品
    JsonNode node = jsonNodes.get(0);
    ExtraProductRelease extraProductRe = jsonTool.readValue(node, ExtraProductRelease.class);
    List<ExtraProductRelease> extraProductReleases = new ArrayList<>();
    extraProductReleases = getByprojectId(extraProductRe.getProject());
    projectId = extraProductRe.getProject();
    List<Long> productSet = new ArrayList<Long>();
    if (null != extraProductReleases && !extraProductReleases.isEmpty()) {
        for (ExtraProductRelease extraProductRelease3 : extraProductReleases) {
            productSet.add(extraProductRelease3.getExtraProduct());
        }
    }
    for (JsonNode jsonNode : jsonNodes) {
        ExtraProductRelease extraProductRelease = jsonTool.readValue(jsonNode, ExtraProductRelease.class);
        if (null == extraProductRelease.getId()) {
            extraProductRelease.setCreateTime(new Date());
            insert(extraProductRelease);
        } else {
            ExtraProductRelease epr = selectByPrimaryKey(extraProductRelease.getId());
            extraProductRelease.setCreateTime(epr.getCreateTime());
            extraProductRelease.setModifyTime(new Date());
            updateByPrimaryKey(extraProductRelease);
            // 将还存在的产品从集合中删除,最后剩下的那些就是要删除的
            if (productSet.contains(extraProductRelease.getExtraProduct())) {
                productSet.remove(extraProductRelease.getExtraProduct());
            }
        }
    }
    // 删除信息
    if (null != productSet && !productSet.isEmpty()) {
        ExtraProductReleaseExample example = new ExtraProductReleaseExample();
        ExtraProductReleaseExample.Criteria criteria = example.or();
        criteria.andExtraProductIn(productSet);
        List<ExtraProductRelease> extraProductReleases2 = new ArrayList<>();
        extraProductReleases2 = selectByExample(example);
        if (null != extraProductReleases2 && !extraProductReleases2.isEmpty()) {
            for (ExtraProductRelease extraProductRelease : extraProductReleases2) {
                deleteByPrimaryKey(extraProductRelease.getId());
            }
        }
    }
    return projectId;
}
Also used : ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) ArrayList(java.util.ArrayList) JsonNode(org.codehaus.jackson.JsonNode) ExtraProductReleaseExample(com.itrus.portal.db.ExtraProductReleaseExample) Date(java.util.Date)

Example 9 with ExtraProductRelease

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

the class ExtraProductServiceImpl method getproductByEPR.

/**
 * 根据项目产品的发布,获取项目产品,根据发布的优先级进行排序
 * @param extraProductReleases
 * @return
 * @throws Exception
 */
public List<ExtraProduct> getproductByEPR(List<ExtraProductRelease> extraProductReleases) throws Exception {
    if (null == extraProductReleases) {
        return null;
    }
    List<ExtraProduct> extraProducts = new ArrayList<>();
    for (ExtraProductRelease extraProductRelease : extraProductReleases) {
        ExtraProduct extraProduct = new ExtraProduct();
        extraProduct = selectByPrimaryKey(extraProductRelease.getExtraProduct());
        extraProducts.add(extraProduct);
    }
    return extraProducts;
}
Also used : ExtraProduct(com.itrus.portal.db.ExtraProduct) ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) ArrayList(java.util.ArrayList)

Example 10 with ExtraProductRelease

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

the class ExtraProductReleaseController method list.

// 遍历页面
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "project", required = false) Long project, @RequestParam(value = "extraProduct", required = false) Long extraProduct, @RequestParam(value = "appType", required = false) Long appType, @RequestParam(value = "appTypeExt", required = false) Long appTypeExt, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) throws Exception {
    if (page == null || page < 1)
        page = 1;
    if (size == null || size < 1)
        size = 10;
    Integer offset = size * (page - 1);
    ExtraProductReleaseExample example = new ExtraProductReleaseExample();
    example.setLimit(size);
    example.setOffset(offset);
    // 所有的项目信息,以id为主键.以便页面显示信息
    Map<Long, Project> projectMap = new HashMap<Long, Project>();
    projectMap = projectService.getProjectMapByExample(null);
    // 所有的增值产品信息,以id为主键.以便页面显示信息
    Map<Long, ExtraProduct> extraProductMap = new HashMap<Long, ExtraProduct>();
    extraProductMap = extraProductService.selectMapByExample(null);
    Criteria criteria = example.createCriteria();
    if (project != null) {
        criteria.andProjectEqualTo(project);
    }
    if (extraProduct != null) {
        criteria.andExtraProductEqualTo(extraProduct);
    }
    criteria.andAppTypeIsNotNull();
    criteria.andAppTypeNotEqualTo("");
    if (appType != null) {
        criteria.andAppTypeLike("%" + appType + "%");
    }
    List<ExtraProductRelease> extraProductReleases = extraProductReleaseService.selectByExample(example);
    // 去除不包含所选 发布平台的记录
    if (appType != null) {
        Iterator<ExtraProductRelease> it = extraProductReleases.iterator();
        while (it.hasNext()) {
            ExtraProductRelease epr = it.next();
            String appTypes = epr.getAppType();
            boolean isHas = false;
            for (String at : appTypes.split(",")) {
                if (appType.toString().equals(at)) {
                    isHas = true;
                    break;
                }
            }
            if (!isHas) {
                it.remove();
            }
        }
    }
    Integer count = extraProductReleases.size();
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    // page, size
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    uiModel.addAttribute("projectCur", project);
    uiModel.addAttribute("extraProductCur", extraProduct);
    uiModel.addAttribute("appTypesCur", appType);
    uiModel.addAttribute("appTypeExt", appTypeExt);
    uiModel.addAttribute("projectMap", projectMap);
    uiModel.addAttribute("extraProductMap", extraProductMap);
    uiModel.addAttribute("extraProductReleases", extraProductReleases);
    return "extraproductrelease/list";
}
Also used : HashMap(java.util.HashMap) ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) Criteria(com.itrus.portal.db.ExtraProductReleaseExample.Criteria) ExtraProductReleaseExample(com.itrus.portal.db.ExtraProductReleaseExample) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ExtraProductRelease (com.itrus.portal.db.ExtraProductRelease)14 ArrayList (java.util.ArrayList)9 ExtraProduct (com.itrus.portal.db.ExtraProduct)8 Project (com.itrus.portal.db.Project)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ExtraProductReleaseExample (com.itrus.portal.db.ExtraProductReleaseExample)5 HashMap (java.util.HashMap)5 Enterprise (com.itrus.portal.db.Enterprise)2 ExtraProductExample (com.itrus.portal.db.ExtraProductExample)2 ExtraProductReleaseMapper (com.itrus.portal.db.ExtraProductReleaseMapper)2 UserInfo (com.itrus.portal.db.UserInfo)2 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)2 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)2 IOException (java.io.IOException)2 Date (java.util.Date)2 LinkedHashSet (java.util.LinkedHashSet)2 App (com.itrus.portal.db.App)1 AppExample (com.itrus.portal.db.AppExample)1 BusinessLicense (com.itrus.portal.db.BusinessLicense)1 Criteria (com.itrus.portal.db.ExtraProductReleaseExample.Criteria)1