Search in sources :

Example 1 with ServiceExample

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

the class ThirdPartyController method customerService.

/**
 * 进入常见问题页面
 * @param product
 * @param uiModel
 * @param request
 * @return
 */
@RequestMapping("/s/{product}/help")
public String customerService(@PathVariable("product") String product, Model uiModel, HttpServletRequest request) {
    HttpSession session = request.getSession();
    Product pro = productService.getProductByproName(product);
    if (pro != null) {
        // 查询企业客服
        EnterpriseQqExample enterprise = new EnterpriseQqExample();
        EnterpriseQqExample.Criteria qqEx = enterprise.createCriteria();
        qqEx.andProjectIdEqualTo(pro.getProject());
        EnterpriseQq enterpriseqq = enterpriseqqService.selectByEnterpriseQq(enterprise);
        // 查询发布文件
        FileIssueExample fileIssueExample = new FileIssueExample();
        FileIssueExample.Criteria cec = fileIssueExample.createCriteria();
        cec.andProjectEqualTo(pro.getProject());
        List<FileIssue> FileIssues = configServiceImpl.getList(fileIssueExample);
        Long questionId = 0L;
        ServiceExample serviceExample = new ServiceExample();
        ServiceExample.Criteria srCriteria = serviceExample.createCriteria();
        serviceExample.clear();
        serviceExample.setLimit(null);
        srCriteria = serviceExample.createCriteria();
        srCriteria.andProjectEqualTo(pro.getProject());
        srCriteria.andTypeEqualTo(1);
        Service service = questionService.getService(serviceExample);
        if (null == service && (enterpriseqq == null || FileIssues.size() == 0)) {
            serviceExample.clear();
            srCriteria = serviceExample.createCriteria();
            srCriteria.andNameEqualTo("缺省项目");
            srCriteria.andTypeEqualTo(1);
            Service service2 = questionService.getService(serviceExample);
            questionId = service2.getId();
        } else {
            questionId = service.getId();
        }
        // 查询是否存在
        Service service1 = questionService.getService(questionId);
        // Service pService = sqlSession.selectOne("com.itrus.portal.db.ServiceMapper.selectByPrimaryKey", service.getParentId());
        uiModel.addAttribute("service", service1);
        // uiModel.addAttribute("pService", pService);
        // 查询子节点
        ServiceExample serviceExample2 = new ServiceExample();
        ServiceExample.Criteria srCriteria2 = serviceExample2.createCriteria();
        serviceExample2.clear();
        serviceExample2.setLimit(null);
        srCriteria2 = serviceExample2.createCriteria();
        srCriteria2.andParentIdEqualTo(questionId);
        Map<Long, Service> childSR = questionService.getChildSR(serviceExample2);
        uiModel.addAttribute("childSR", childSR);
        // 若没有子节点,直接返回
        if (childSR == null || childSR.isEmpty()) {
            return null;
        }
        Map<Integer, Long> idMap = new HashMap<>();
        // 查询子节点是否包含下级节点
        serviceExample2.clear();
        srCriteria2 = serviceExample2.createCriteria();
        srCriteria2.andParentIdIn(new ArrayList<Long>(childSR.keySet()));
        Map<Long, Object> childNumMap = questionService.getChildNumMap(serviceExample2);
        // 组装子节点信息
        // List<Map<String,Object>> childList = new ArrayList<Map<String, Object>>();
        // 对节点按照id顺序排序
        List<List<Service>> childrenList = new ArrayList<List<Service>>();
        List<Service> typeList = questionService.sortTypesMap(childSR);
        List<Service> childList = new ArrayList<Service>();
        int i = 1;
        for (Service sr : typeList) {
            if (childNumMap != null && childNumMap.containsKey(sr.getId())) {
                serviceExample2.clear();
                serviceExample2.setLimit(null);
                srCriteria2 = serviceExample2.createCriteria();
                srCriteria2.andParentIdEqualTo(sr.getId());
                Map<Long, Service> childMap = questionService.getChildSR(serviceExample2);
                childList = questionService.sortTypesMap(childMap);
                childrenList.add(childList);
            } else {
                childrenList.add(childList);
            }
            idMap.put(i, sr.getId());
            i++;
        }
        uiModel.addAttribute("childNumMap", childNumMap);
        uiModel.addAttribute("childrenList", childrenList);
        uiModel.addAttribute("idMap", idMap);
        uiModel.addAttribute("pid", questionId);
        serviceExample2.clear();
        srCriteria = serviceExample2.createCriteria();
        srCriteria.andTypeEqualTo(2);
        srCriteria.andParentIdEqualTo(service1.getId());
        List<Service> serviceList1 = questionService.getServiceList(serviceExample2);
        Long sId = serviceList1.get(0).getId();
        serviceExample2.clear();
        srCriteria = serviceExample2.createCriteria();
        srCriteria.andTypeEqualTo(3);
        srCriteria.andParentIdEqualTo(sId);
        List<Service> serviceList2 = questionService.getServiceList(serviceExample2);
        Long gsId = serviceList2.get(0).getId();
        uiModel.addAttribute("gsid", gsId);
        uiModel.addAttribute("tab", "kehufuwu");
        if (enterpriseqq != null && enterpriseqq.getId() != null) {
            uiModel.addAttribute("eid", enterpriseqq.getId());
            session.setAttribute("enterpriseqqE", enterpriseqq.getEnterpriseQqLinks());
        }
        return "ixinweb/kehufuwu_changjianwenti";
    }
    uiModel.addAttribute("tab", "kehufuwu");
    return "ixinweb/kehufuwu_xuanzexiangmu";
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Product(com.itrus.portal.db.Product) FileIssueExample(com.itrus.portal.db.FileIssueExample) EnterpriseQqExample(com.itrus.portal.db.EnterpriseQqExample) ArrayList(java.util.ArrayList) List(java.util.List) FileIssue(com.itrus.portal.db.FileIssue) HttpSession(javax.servlet.http.HttpSession) Service(com.itrus.portal.db.Service) EnterpriseQq(com.itrus.portal.db.EnterpriseQq) ServiceExample(com.itrus.portal.db.ServiceExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EnterpriseQq (com.itrus.portal.db.EnterpriseQq)1 EnterpriseQqExample (com.itrus.portal.db.EnterpriseQqExample)1 FileIssue (com.itrus.portal.db.FileIssue)1 FileIssueExample (com.itrus.portal.db.FileIssueExample)1 Product (com.itrus.portal.db.Product)1 Service (com.itrus.portal.db.Service)1 ServiceExample (com.itrus.portal.db.ServiceExample)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 HttpSession (javax.servlet.http.HttpSession)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1