Search in sources :

Example 71 with Project

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

the class BillServiceImpl method getProjectMapByUserInfoId.

/**
 * 根据用户id查找订单表中对应的projectMap
 *
 * @param userInfo
 * @return
 */
public Map<Long, Project> getProjectMapByUserInfoId(Long userInfo) {
    Map<Long, Project> projectMap = new HashMap<Long, Project>();
    List<Long> projectIds = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectProjectsByUserInfo", userInfo);
    if (null != projectIds && !projectIds.isEmpty()) {
        ProjectExample projectExample = new ProjectExample();
        ProjectExample.Criteria criteria = projectExample.or();
        criteria.andIdIn(projectIds);
        projectMap = sqlSession.selectMap("com.itrus.portal.db.ProjectMapper.selectByExample", projectExample, "id");
    }
    return projectMap;
}
Also used : Project(com.itrus.portal.db.Project) HashMap(java.util.HashMap) ProjectExample(com.itrus.portal.db.ProjectExample)

Example 72 with Project

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

the class BillWebServiceImpl method saveBillAuthenticationItems.

/**
 * 保存订单对应的认证项,并删除之前关联的认证项
 *
 * @param certItems
 *            需要认证的项
 * @param enterpriseNature
 *            企业性质
 * @param billId
 *            订单id
 * @param businessLicense
 *            营业制证
 * @param orgCode
 *            组织机构代码
 * @param taxregisterCert
 *            税务登记
 * @param identityCard
 *            法人
 * @param agent
 *            代理人
 * @param proxy
 *            授权书
 * @param webenterprise
 *            企业
 * @param webuserInfo
 *            用户
 * @throws Exception
 */
public void saveBillAuthenticationItems(String certItems, Integer enterpriseNature, Long billId, BusinessLicense businessLicense, OrgCode orgCode, TaxRegisterCert taxregisterCert, IdentityCard identityCard, Agent agent, Proxy proxy, Enterprise webenterprise, UserInfo webuserInfo) throws Exception {
    // 根据订单id,获取该订单的旧认证项:
    BusinessLicense oldBl = businessService.getBusinessByBillId(billId, null);
    OrgCode oldOc = orgCodeService.getOrgCodeByBillId(billId, null);
    TaxRegisterCert oldTc = taxCertService.getTaxRegisterCertByBillId(billId, null);
    IdentityCard oldIc = identityCardService.getIdentityCardByBillId(billId, null);
    Agent oldAgent = agentService.getAgentByBillId(billId, null);
    Proxy oldProxy = proxyService.getProxyByBillId(billId);
    // 新认证项id置null,便于执行新增处理
    businessLicense.setId(null);
    orgCode.setId(null);
    taxregisterCert.setId(null);
    identityCard.setId(null);
    agent.setId(null);
    proxy.setId(null);
    // 从数据库中删除旧认证项
    if (false) {
        if (null != oldBl) {
            sqlSession.delete("com.itrus.portal.db.BusinessLicenseMapper.deleteByPrimaryKey", oldBl.getId());
        }
        if (null != oldOc) {
            sqlSession.delete("com.itrus.portal.db.OrgCodeMapper.deleteByPrimaryKey", oldOc.getId());
        }
        if (null != oldTc) {
            sqlSession.delete("com.itrus.portal.db.TaxRegisterCertMapper.deleteByPrimaryKey", oldTc.getId());
        }
        if (null != oldIc) {
            sqlSession.delete("com.itrus.portal.db.IdentityCardMapper.deleteByPrimaryKey", oldIc.getId());
        }
        if (null != oldAgent) {
            sqlSession.delete("com.itrus.portal.db.AgentMapper.deleteByPrimaryKey", oldAgent.getId());
        }
        if (null != oldProxy) {
            sqlSession.delete("com.itrus.portal.db.ProxyMapper.deleteByPrimaryKey", oldProxy.getId());
        }
    }
    /**
     * 需要认证的项:0营业执照,1组织机构代码,2税务登记证,3授权书,4法定代表人/经营者 5代理人
     */
    Long[] items = StringTools.getLong(certItems);
    // 是否有营业执照信息,默认false没有
    boolean hasBl = false;
    for (Long item : items) {
        if (ComNames.BUSINESS_ITEM.equals(item) && !enterpriseNature.equals(3)) {
            // 事业单位不填写营业执照
            hasBl = true;
            // 判断新认证项是否是使用旧认证项的图片
            if (null != oldBl && StringUtils.isBlank(businessLicense.getImgFile())) {
                businessLicense.setImgFile(ComNames.USE_OLD_IMG);
            }
            // TODO 验证插入重复数据问题item是否重复了:
            System.out.println("BillWebServiceImpl-insert into businessLicense:item=" + item + ",billId=" + billId + ",enterpriseName=" + webenterprise.getEnterpriseName());
            businessLicense = businessService.saveBusiness1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), businessLicense, ComNames.ITEM_STATUS_1, oldBl);
            if (businessLicense.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                businessLicense.setImgFile(oldBl.getImgFile());
                businessLicense.setImgFileHash(oldBl.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.BusinessLicenseMapper.updateByPrimaryKey", businessLicense);
            }
        } else if (ComNames.ORG_CODE_ITEM.equals(item)) {
            if (hasBl && businessLicense.getBusinessType().equals(1))
                // 五证合一企业不用提交组织机构代码、税务登记信息
                continue;
            // 假如企业性质为2(个体工商户)并且组织机构代码没有填,则不用保存
            if (enterpriseNature.equals(2) && StringUtils.isBlank(orgCode.getOrgCode()))
                continue;
            // 判断是否需要使用旧的认证项图片
            if (null != oldOc && StringUtils.isBlank(orgCode.getImgFile())) {
                if (StringUtils.isBlank(oldOc.getImgFile())) {
                    if (orgCode.getOrgCodeType().equals(1)) {
                        throw new UserInfoServiceException("事业单位法人证书不能为空");
                    } else {
                        throw new UserInfoServiceException("组织机构代码图不能为空");
                    }
                }
                orgCode.setImgFile(ComNames.USE_OLD_IMG);
            } else if (StringUtils.isBlank(orgCode.getImgFile())) {
                if (orgCode.getOrgCodeType().equals(1)) {
                    throw new UserInfoServiceException("事业单位法人证书不能为空");
                } else {
                    throw new UserInfoServiceException("组织机构代码图不能为空");
                }
            }
            orgCode = orgCodeService.saveOrgCode1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), orgCode, ComNames.ITEM_STATUS_1, oldOc);
            if (orgCode.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                orgCode.setImgFile(oldOc.getImgFile());
                orgCode.setImgFileHash(oldOc.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKey", orgCode);
            }
        } else if (ComNames.TAX_CERT_ITEM.equals(item)) {
            if (hasBl && businessLicense.getBusinessType().equals(1))
                // 五证合一企业不用提交组织机构代码、税务登记信息
                continue;
            // 保存税务登记证
            if (enterpriseNature.equals(3))
                // 事业单位不填写税务登记信息
                continue;
            // 判断是否需要使用旧的认证项图片
            if (null != oldTc && StringUtils.isBlank(taxregisterCert.getImgFile())) {
                if (StringUtils.isBlank(oldTc.getImgFile()))
                    throw new UserInfoServiceException("税务登记证不能为空");
                taxregisterCert.setImgFile(ComNames.USE_OLD_IMG);
            }
            taxregisterCert = taxCertService.saveTaxCert1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_1, oldTc);
            if (taxregisterCert.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                taxregisterCert.setImgFile(oldTc.getImgFile());
                taxregisterCert.setImgFileHash(oldTc.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.TaxRegisterCertMapper.updateByPrimaryKey", taxregisterCert);
            }
        } else if (ComNames.IDENTITY_CARD_ITEM.equals(item)) {
            // 判断是否需要使用旧的认证项图片
            if (null != oldIc) {
                if (StringUtils.isBlank(identityCard.getFrontImg())) {
                    identityCard.setFrontImg(ComNames.USE_OLD_IMG);
                    identityCard.setFrontImgHash(oldIc.getFrontImgHash());
                }
                if (StringUtils.isBlank(identityCard.getBackImg()))
                    identityCard.setBackImg(ComNames.USE_OLD_IMG);
            }
            identityCard = identityCardService.saveIdentityCard1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), identityCard, ComNames.ITEM_STATUS_1, oldIc);
            if (identityCard.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
                identityCard.setFrontImg(oldIc.getFrontImg());
                identityCard.setFrontImgHash(oldIc.getFrontImgHash());
                sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKey", identityCard);
            }
            if (identityCard.getBackImg().equals(ComNames.USE_OLD_IMG)) {
                identityCard.setBackImg(oldIc.getBackImg());
                identityCard.setBackImgHash(oldIc.getBackImgHash());
                sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKey", identityCard);
            }
        } else if (ComNames.AGENT_ITEM.equals(item)) {
            // 保存代理人
            if (null != oldAgent) {
                if (StringUtils.isBlank(agent.getFrontImg())) {
                    agent.setFrontImg(ComNames.USE_OLD_IMG);
                    agent.setFrontImgHash(oldAgent.getFrontImgHash());
                }
                if (StringUtils.isBlank(agent.getBackImg()))
                    agent.setBackImg(ComNames.USE_OLD_IMG);
            }
            agent = agentService.saveAgent1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), agent, ComNames.ITEM_STATUS_1, oldAgent);
            if (agent.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
                agent.setFrontImg(oldAgent.getFrontImg());
                agent.setFrontImgHash(oldAgent.getFrontImgHash());
                sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKey", agent);
            }
            if (agent.getBackImg().equals(ComNames.USE_OLD_IMG)) {
                agent.setBackImg(oldAgent.getBackImg());
                agent.setBackImgHash(oldAgent.getBackImgHash());
                sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKey", agent);
            }
        } else if (ComNames.PROXY_ITEM.equals(item)) {
            // 保存授权书
            if (null != oldProxy && StringUtils.isBlank(proxy.getImgFile()))
                proxy.setImgFile(ComNames.USE_OLD_IMG);
            // TODO 验证插入重复数据问题item是否重复了:
            System.out.println("BillWebServiceImpl-insert into proxy:item=" + item + ",billId=" + billId + ",enterpriseName=" + webenterprise.getEnterpriseName());
            Project project = billService.getProjectByBillId(billId);
            proxy = proxyService.saveProxy1(webenterprise.getId(), webuserInfo.getUniqueId(), billId, webuserInfo.getId(), proxy, oldProxy, project);
            if (proxy.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                proxy.setImgFile(oldProxy.getImgFile());
                proxy.setImgFileHash(oldProxy.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.ProxyMapper.updateByPrimaryKey", proxy);
            }
        }
    }
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) Agent(com.itrus.portal.db.Agent) Project(com.itrus.portal.db.Project) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IdentityCard(com.itrus.portal.db.IdentityCard)

Example 73 with Project

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

the class AdminServiceImpl method getProjectByAdminId.

/**
 * 根据管理员id获取管理的项目list
 *
 * @param adminId
 * @return
 */
public List<Project> getProjectByAdminId(Long adminId) {
    List<Project> projects = new ArrayList<Project>();
    Admin admin = sqlSession.selectOne("com.itrus.portal.db.AdminMapper.selectByPrimaryKey", adminId);
    if (null != projects && StringUtils.isNotBlank(admin.getProjects())) {
        String[] projectIds = admin.getProjects().split(",");
        Long[] projectIdsLong = new Long[projectIds.length];
        for (int i = 0; i < projectIds.length; i++) {
            if ("0".equals(projectIds[i])) {
                // 返回所有项目id
                List<Long> allProject = sqlSession.selectList("com.itrus.portal.db.ProjectMapper.selectAllProjectIds");
                projectIdsLong = new Long[allProject.size()];
                for (int j = 0; j < allProject.size(); j++) {
                    projectIdsLong[j] = allProject.get(j);
                }
                break;
            }
            projectIdsLong[i] = Long.parseLong(projectIds[i]);
        }
        ProjectExample projectExample = new ProjectExample();
        ProjectExample.Criteria criteria = projectExample.or();
        criteria.andIdIn(Arrays.asList(projectIdsLong));
        projects = sqlSession.selectList("com.itrus.portal.db.ProjectMapper.selectByExample", projectExample);
    }
    return projects;
}
Also used : Project(com.itrus.portal.db.Project) ProjectExample(com.itrus.portal.db.ProjectExample) ArrayList(java.util.ArrayList) Admin(com.itrus.portal.db.Admin)

Example 74 with Project

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

the class ReviewServiceImpl method agreeBillReview.

/**
 * pfx证书,当不要审核的时候,自动生成审核记录
 * @param bill
 */
public void agreeBillReview(Bill bill) {
    if (null == bill) {
        return;
    }
    // 填充营业执照运营时间
    Enterprise enterpriseInBill = enterpriseService.getEnterpriseByBillId(bill.getId());
    String soperationStart = null;
    String soperationEnd = null;
    List<BusinessLicense> oldBusinessLicenses = businessService.getBusinessLicensesNews(bill.getEnterprise());
    if (null != oldBusinessLicenses && !oldBusinessLicenses.isEmpty()) {
        for (BusinessLicense businessLicense1 : oldBusinessLicenses) {
            if (null != businessLicense1.getOperationStart() || null != businessLicense1.getOperationEnd()) {
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                if (null != businessLicense1.getOperationStart()) {
                    soperationStart = format.format(businessLicense1.getOperationStart());
                }
                if (null != businessLicense1.getOperationEnd()) {
                    soperationEnd = format.format(businessLicense1.getOperationEnd());
                }
                break;
            }
        }
    }
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    DigitalCert cert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
    Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", product.getAuthentication());
    Project project = billService.getProjectByBillId(bill.getId());
    BusinessLicense businessLicense = businessService.getBusinessByBillId(bill.getId(), null);
    OrgCode orgCode = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
    TaxRegisterCert taxregisterCert = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
    IdentityCard identityCard = identityCardService.getIdentityCardByBillId(bill.getId(), null);
    Agent agent = agentService.getAgentByBillId(bill.getId(), null);
    Proxy proxy = proxyService.getProxyByBillId(bill.getId());
    // 更新管理员提交的认证项资料信息
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        Long businessId = null;
        Long orgCodeId = null;
        Long taxregisterId = null;
        Long identityCardId = null;
        Long agentId = null;
        Long proxyId = null;
        // 更新营业执照信息
        if (null != businessLicense && null != businessLicense.getId()) {
            businessLicense = businessService.updateBusinessLicense(soperationStart, soperationEnd, businessLicense, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            businessId = businessLicense.getId();
        }
        // 更新组织机构代码
        if (null != orgCode && null != orgCode.getId()) {
            orgCode = orgCodeService.updateOrgCode(orgCode, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            orgCodeId = orgCode.getId();
        }
        // 更新税务登记
        if (null != taxregisterCert && null != taxregisterCert.getId()) {
            taxregisterCert = taxCertService.updateTaxRegisterCert(taxregisterCert, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            taxregisterId = taxregisterCert.getId();
        }
        // 更新法定代表人
        if (null != identityCard && null != identityCard.getId()) {
            identityCard = identityCardService.updateIdentityCard(identityCard, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            identityCardId = identityCard.getId();
        }
        // 更新代理人
        if (null != agent && null != agent.getId()) {
            agent = agentService.updateAgent(agent, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            agentId = agent.getId();
        }
        // 更新授权书
        if (null != proxy && null != proxy.getId()) {
            proxy = proxyService.updateProxy(proxy, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null, project);
            proxyId = proxy.getId();
        }
        // 设置第一个admin账号
        AdminExample adminExample = new AdminExample();
        adminExample.setOrderByClause("create_time ASC");
        List<Admin> admins = sqlSession.selectList("com.itrus.portal.db.AdminMapper.selectByExample", adminExample);
        // 更新企业信息
        Enterprise enterprise = enterpriseService.updateEnterprise(bill.getEnterprise(), certification.getId(), businessId, orgCodeId, taxregisterId, identityCardId, agentId);
        // 生成认证记录
        reviewLogService.saveReviewLog(2, admins.get(0).getId(), 1, null, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), businessId, orgCodeId, taxregisterId, identityCardId, agentId, proxyId);
        bill.setCheckTime(new Date());
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
        transactionManager.commit(status);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
}
Also used : Agent(com.itrus.portal.db.Agent) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Product(com.itrus.portal.db.Product) TransactionStatus(org.springframework.transaction.TransactionStatus) Admin(com.itrus.portal.db.Admin) Certification(com.itrus.portal.db.Certification) Date(java.util.Date) ParseException(java.text.ParseException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) DigitalCert(com.itrus.portal.db.DigitalCert) Project(com.itrus.portal.db.Project) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) Enterprise(com.itrus.portal.db.Enterprise) SimpleDateFormat(java.text.SimpleDateFormat) AdminExample(com.itrus.portal.db.AdminExample) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard)

Example 75 with Project

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

the class ProjectServiceImpl method getProjectByName.

/**
 * 根据项目名称,获取项目
 * @param name
 * @return
 */
public Project getProjectByName(String name) {
    Project project = null;
    ProjectExample example = new ProjectExample();
    ProjectExample.Criteria criteria = example.or();
    criteria.andNameEqualTo(name);
    project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByExample", example);
    return project;
}
Also used : Project(com.itrus.portal.db.Project) ProjectExample(com.itrus.portal.db.ProjectExample)

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