Search in sources :

Example 1 with EnterpriseExample

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

the class UserInfoController method detail.

/**
 * 查看用户详情
 *
 * @param id
 *            用户id
 * @param item
 *            用户关联的项(0企业、1证书、2订单、3认证)
 * @param page
 * @param size
 * @param uiModel
 * @return
 */
@RequestMapping("/detail")
public String detail(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "item", required = false) Integer item, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", id);
    // 判断查询的用户是否属于当前管理员所管理的范围
    Long[] manageProjectIds = getProjectLongIdsOfAdmin();
    // 默认不属于当前管理员管理范围
    boolean flag = false;
    for (Long projectId : manageProjectIds) {
        if (userInfo.getProject() == projectId) {
            flag = true;
        }
    }
    if (!flag) {
        // 没有管理权限
        return "status403";
    }
    // 根据省市区code值获取省市区最新名称
    String regionCodes = userInfo.getRegionCodes();
    String userAdds = userInfo.getUserAdds();
    if (StringUtils.isNotBlank(regionCodes) && regionCodes.indexOf("@") >= 0) {
        String[] codes = regionCodes.split("@");
        String regionName = sysRegionService.getAllName(codes[1], codes[2], codes[3]);
        userAdds = regionName + userAdds;
        userInfo.setUserAdds(userAdds);
    }
    uiModel.addAttribute("userInfo", userInfo);
    if (page == null || page < 1) {
        page = 1;
    }
    if (size == null || size < 1) {
        size = 10;
    }
    // 总记录数
    Integer count = 0;
    // 当前页记录数
    Integer itemcount = 0;
    // null、0关联企业,1证书信息,2订单列表
    if (null == item || 0 == item) {
        item = 0;
        // 关联企业
        List<Enterprise> enterprises = new ArrayList<Enterprise>();
        List<Long> enterpriseIds = userInfoEnterpriseService.getEnterpriseByUserInfo(userInfo.getId());
        if (null != enterpriseIds && !enterpriseIds.isEmpty()) {
            count = enterpriseIds.size();
            EnterpriseExample enterpriseExample = new EnterpriseExample();
            EnterpriseExample.Criteria criteria = enterpriseExample.or();
            criteria.andIdIn(enterpriseIds);
            if (page > 1 && size * (page - 1) >= count) {
                page = (count + size - 1) / size;
            }
            Integer offset = size * (page - 1);
            enterpriseExample.setOffset(offset);
            enterpriseExample.setLimit(size);
            enterpriseExample.setOrderByClause("create_time desc");
            enterprises = sqlSession.selectList("com.itrus.portal.db.EnterpriseMapper.selectByExample", enterpriseExample);
        }
        itemcount = enterprises.size();
        uiModel.addAttribute("enterprises", enterprises);
    } else if (1 == item) {
        item = 1;
        // TODO 证书信息
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", userInfo.getId());
        count = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.countByUserInfoID", userInfo.getId());
        if (page > 1 && size * (page - 1) >= count) {
            page = (count + size - 1) / size;
        }
        Integer offset = size * (page - 1);
        map.put("offset", offset);
        map.put("limit", size);
        List<UserCert> userCertList = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByUserInfoID", map);
        itemcount = userCertList.size();
        uiModel.addAttribute("userCertList", userCertList);
    } else if (2 == item) {
        item = 2;
        // 订单列表
        BillExample billExample = new BillExample();
        BillExample.Criteria criteria = billExample.or();
        criteria.andUniqueIdEqualTo(userInfo.getId());
        // criteria.andIsDeleteEqualTo(false);
        count = sqlSession.selectOne("com.itrus.portal.db.BillMapper.countByExample", billExample);
        if (page > 1 && size * (page - 1) >= count) {
            page = (count + size - 1) / size;
        }
        Integer offset = size * (page - 1);
        billExample.setOffset(offset);
        billExample.setLimit(size);
        billExample.setOrderByClause("create_time desc");
        List<Bill> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExample);
        itemcount = billList.size();
        uiModel.addAttribute("billList", billList);
        Map<Long, Project> projectMap = billService.getProjectMapByUserInfoId(userInfo.getId());
        uiModel.addAttribute("projectMap", projectMap);
        Map<Long, Product> productMap = billService.getProductMapByUserInfoId(userInfo.getId());
        uiModel.addAttribute("productMap", productMap);
        Map<Long, Enterprise> enterpriseMap = billService.getEnterpriseMapByUserInfoId(userInfo.getId());
        uiModel.addAttribute("enterpriseMap", enterpriseMap);
    } else if (3 == item) {
        item = 3;
        Agent agent = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectNewAgentByUserId", id);
        uiModel.addAttribute("agent", agent);
    }
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    uiModel.addAttribute("itemcount", itemcount);
    uiModel.addAttribute("item", item);
    return "userInfo/detail";
}
Also used : ArrayList(java.util.ArrayList) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) BillExample(com.itrus.portal.db.BillExample) ArrayList(java.util.ArrayList) List(java.util.List) Agent(com.itrus.portal.db.Agent) Project(com.itrus.portal.db.Project) EnterpriseExample(com.itrus.portal.db.EnterpriseExample) Enterprise(com.itrus.portal.db.Enterprise) Bill(com.itrus.portal.db.Bill) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with EnterpriseExample

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

the class EnterpriseServiceImpl method updateEnterpriseSn.

/**
 * 更新企业唯一标识
 *
 * @param enterprise
 * @return
 * @throws UserInfoServiceException
 */
public Enterprise updateEnterpriseSn(Enterprise enterprise) throws UserInfoServiceException {
    // 根据企业名称查找企业
    EnterpriseExample example = new EnterpriseExample();
    EnterpriseExample.Criteria criteria = example.or();
    criteria.andEnterpriseSnEqualTo(enterprise.getEnterpriseSn());
    Enterprise enterprise0 = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByExample", example);
    if (null != enterprise0) {
        if (!enterprise.getEnterpriseName().equals(enterprise0.getEnterpriseName()) && enterprise.getEnterpriseSn().equals(enterprise0.getEnterpriseSn())) {
            // 已经存在相同企业标识了(企业名称不同企业标识相同):
            if (enterprise.getEnterpriseNature().equals(3)) {
                throw new UserInfoServiceException("组织机构代码已被其他公司注册,请确认输入是否有误");
            } else {
                throw new UserInfoServiceException("营业执照号或统一社会信用代码已被其他公司注册,请确认输入是否有误");
            }
        }
    }
    sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKey", enterprise);
    sqlSession.flushStatements();
    return enterprise;
}
Also used : EnterpriseExample(com.itrus.portal.db.EnterpriseExample) Enterprise(com.itrus.portal.db.Enterprise) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

Example 3 with EnterpriseExample

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

the class EnterpriseServiceImpl method getEnterpriseListByIds.

/**
 * 根据企业ids查询企业list
 *
 * @param enterpriseIds
 * @return
 */
public List<Enterprise> getEnterpriseListByIds(List<Long> enterpriseIds) {
    EnterpriseExample example = new EnterpriseExample();
    EnterpriseExample.Criteria criteria = example.or();
    criteria.andIdIn(enterpriseIds);
    List<Enterprise> enterpriseList = sqlSession.selectList("com.itrus.portal.db.EnterpriseMapper.selectByExample", example);
    return enterpriseList;
}
Also used : EnterpriseExample(com.itrus.portal.db.EnterpriseExample) Enterprise(com.itrus.portal.db.Enterprise)

Example 4 with EnterpriseExample

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

the class BillServiceImpl method getEnterpriseMapByBills.

/**
 * 根据订单list获取对应的企业Map
 *
 * @param bills
 * @return
 */
public Map<Long, Enterprise> getEnterpriseMapByBills(List<Bill> bills) {
    Map<Long, Enterprise> enterpriseMap = new HashMap<Long, Enterprise>();
    List<Long> enterpriseIds = new ArrayList<Long>();
    for (Bill bill : bills) {
        enterpriseIds.add(bill.getEnterprise());
    }
    if (!enterpriseIds.isEmpty()) {
        EnterpriseExample example = new EnterpriseExample();
        EnterpriseExample.Criteria criteria = example.or();
        criteria.andIdIn(enterpriseIds);
        enterpriseMap = sqlSession.selectMap("com.itrus.portal.db.EnterpriseMapper.selectByExample", example, "id");
    }
    return enterpriseMap;
}
Also used : EnterpriseExample(com.itrus.portal.db.EnterpriseExample) HashMap(java.util.HashMap) Enterprise(com.itrus.portal.db.Enterprise) ArrayList(java.util.ArrayList) Bill(com.itrus.portal.db.Bill)

Example 5 with EnterpriseExample

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

the class EnterpriseController method list.

/**
 * 列表
 *
 * @param enterpriseName
 *            企业名称
 * @param enterpriseSn
 *            企业标识
 * @param authenticationLevel
 *            认证等级
 * @param enterpriseNature
 *            企业性质
 * @param page
 * @param size
 * @param queryDate1
 * @param queryDate2
 * @param uiModel
 * @return
 */
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "enterpriseName", required = false) String enterpriseName, @RequestParam(value = "enterpriseSn", required = false) String enterpriseSn, @RequestParam(value = "authenticationLevel", required = false) Long authenticationLevel, @RequestParam(value = "enterpriseNature", required = false) Integer enterpriseNature, @RequestParam(value = "orgIndustry", required = false) Integer orgIndustry, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "queryDate1", required = false) Date queryDate1, @RequestParam(value = "queryDate2", required = false) Date queryDate2, Model uiModel) {
    if (queryDate1 == null && queryDate2 == null) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(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);
        queryDate2 = calendar.getTime();
        calendar.add(Calendar.MILLISECOND, 1);
        calendar.add(Calendar.MONTH, -1);
        queryDate1 = calendar.getTime();
    }
    // 查询认证等级map
    Map<Long, Certification> certificationMap = sqlSession.selectMap("com.itrus.portal.db.CertificationMapper.selectByExample", "id");
    uiModel.addAttribute("certificationMap", certificationMap);
    uiModel.addAttribute("enterpriseName", enterpriseName);
    uiModel.addAttribute("enterpriseSn", enterpriseSn);
    uiModel.addAttribute("authenticationLevel", authenticationLevel);
    uiModel.addAttribute("enterpriseNature", enterpriseNature);
    uiModel.addAttribute("orgIndustry", orgIndustry);
    uiModel.addAttribute("queryDate1", queryDate1);
    uiModel.addAttribute("queryDate2", queryDate2);
    if (page == null || page < 1) {
        page = 1;
    }
    if (size == null || size < 1) {
        size = 10;
    }
    // 管理员可查看所有企业信息
    EnterpriseExample enterpriseExample = new EnterpriseExample();
    EnterpriseExample.Criteria criteria = enterpriseExample.or();
    // enterpriseName
    if (StringUtils.isNotBlank(enterpriseName)) {
        criteria.andEnterpriseNameLike("%" + enterpriseName + "%");
    }
    // enterpriseSn
    if (StringUtils.isNotBlank(enterpriseSn)) {
        criteria.andEnterpriseSnLike("%" + enterpriseSn + "%");
    }
    // authenticationLevel
    if (null != authenticationLevel && 0 != authenticationLevel) {
        criteria.andAuthenticationLevelEqualTo(authenticationLevel);
    }
    // enterpriseNature
    if (null != enterpriseNature && 0 != enterpriseNature) {
        criteria.andEnterpriseNatureEqualTo(enterpriseNature);
    }
    // orgIndustry
    if (null != orgIndustry && 0 != orgIndustry) {
        criteria.andOrgIndustryEqualTo(orgIndustry);
    }
    // queryDate1
    if (null != queryDate1) {
        criteria.andCreateTimeGreaterThanOrEqualTo(queryDate1);
    }
    if (null != queryDate2) {
        criteria.andCreateTimeLessThanOrEqualTo(queryDate2);
    }
    Integer count = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.countByExample", enterpriseExample);
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    Integer offset = size * (page - 1);
    enterpriseExample.setOffset(offset);
    enterpriseExample.setLimit(size);
    enterpriseExample.setOrderByClause("create_time desc");
    List<Enterprise> enterPriseList = sqlSession.selectList("com.itrus.portal.db.EnterpriseMapper.selectByExample", enterpriseExample);
    uiModel.addAttribute("enterPriseList", enterPriseList);
    uiModel.addAttribute("itemcount", enterPriseList.size());
    return "enterprise/list";
}
Also used : EnterpriseExample(com.itrus.portal.db.EnterpriseExample) Calendar(java.util.Calendar) Enterprise(com.itrus.portal.db.Enterprise) Certification(com.itrus.portal.db.Certification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EnterpriseExample (com.itrus.portal.db.EnterpriseExample)11 Enterprise (com.itrus.portal.db.Enterprise)10 HashMap (java.util.HashMap)3 Bill (com.itrus.portal.db.Bill)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Agent (com.itrus.portal.db.Agent)1 BillExample (com.itrus.portal.db.BillExample)1 Certification (com.itrus.portal.db.Certification)1 Product (com.itrus.portal.db.Product)1 Project (com.itrus.portal.db.Project)1 UserInfo (com.itrus.portal.db.UserInfo)1 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)1 Calendar (java.util.Calendar)1 List (java.util.List)1 Map (java.util.Map)1