ProjectMapper.java 10.1 KB
package pwc.taxtech.atms.dao;

import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.dpo.ProjectAnaylsisDto;
import pwc.taxtech.atms.dpo.ProjectDisplayDto;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.ProjectExample;
import pwc.taxtech.atms.entity.ProjectStatusManage;

import java.util.List;

@Mapper
public interface ProjectMapper extends MyMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    long countByExample(ProjectExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int deleteByExample(ProjectExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int deleteByPrimaryKey(String id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int insert(Project record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int insertSelective(Project record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    List<Project> selectByExampleWithRowbounds(ProjectExample example, RowBounds rowBounds);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    List<Project> selectByExample(ProjectExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    Project selectByPrimaryKey(String id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int updateByExampleSelective(@Param("record") Project record, @Param("example") ProjectExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int updateByExample(@Param("record") Project record, @Param("example") ProjectExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int updateByPrimaryKeySelective(Project record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int updateByPrimaryKey(Project record);

    @Select("<script>" +
            "SELECT DISTINCT " +
            "    p.create_time AS CreateTime, " +
            "    p.is_active AS IsActive, " +
            "    p.organization_id AS OrganizationID, " +
            "    p.name AS Name, " +
            "    p.code AS Code, " +
            "    p.id AS id, " +
            "    p.industry_id AS IndustryID, " +
            "    p.year AS Year, " +
            "    p.region_id AS RegionID, " +
            "    region.short_name AS RegionName, " +
            "    p.rule_type AS RuleType, " +
            "    projectServiceType.service_type_id AS ServiceTypeID, " +
            "    p.update_time AS UpdateTime, " +
            "    serviceType.name AS ServiceTypeName, " +
            "    organization.name AS OrganizationName, " +
            "    industry.name AS IndustryName, " +
            "    projectServiceType.template_group_id AS TemplateGroupID, " +
            "    templateGroup.name AS TemplateGroupName, " +
            "    p.client_code AS ClientCode, " +
            "    p.db_name AS DbName, " +
            "    1 AS HaveCreateProject, " +
            "    p.enterprise_account_set_id AS EnterpriseAccountSetID, " +
            "    p.start_period AS StartPeriod, " +
            "    p.end_period AS EndPeriod " +
            "FROM " +
            "    project p " +
            "        JOIN " +
            "    organization org ON p.organization_id = org.id " +
            "        JOIN " +
            "    project_service_type projectServiceType ON p.id = projectServiceType.project_id " +
            "        JOIN " +
            "    organization organization ON p.organization_id = organization.id " +
            "        JOIN " +
            "    service_type serviceType ON projectServiceType.service_type_id = serviceType.id " +
            "        JOIN " +
            "    industry industry ON p.industry_id = industry.id " +
            "        JOIN " +
            "    template_group templateGroup ON projectServiceType.template_group_id = templateGroup.id " +
            "        JOIN " +
            "    region region ON p.region_id = region.id " +
            "        JOIN " +
            "    enterprise_account_set_org enterOrg ON p.enterprise_account_set_id = enterOrg.enterprise_account_set_id" +
            "   <where>" +
            "       p.is_active=1 and serviceType.is_active=1 and p.organization_id = enterOrg.organization_id" +
            "       <if test=\"orgId != null and orgId !='' \">AND org.id=#{orgId}</if>" +
//            "       <if test=\"serverId != null and serverId !='' \">AND p.serviceType=#{serverId}</if>" +
            "       <if test=\"projectYear != null\">AND p.Year=#{projectYear}</if>" +
            "   </where>" +
            "</script>")
    List<ProjectDisplayDto> getProjectList(@Param("orgId") String orgId, @Param("serverId") String serviceId,
                                           @Param("projectYear") Integer projectYear);

    @Select("SELECT  " +
            "    p.period_id AS periodId, p.status AS status " +
            "FROM " +
            "    project_status_manage p " +
            "WHERE " +
            "    p.project_id = #{projectId} " +
            "ORDER BY period_id , status")
    List<ProjectStatusManage> getStatusesByProjectId(String projectId);

    @Select("<script>" +
            "SELECT   " +
            "    SYSDATE() AS CreateTime,  " +
            "    1 AS IsActive,  " +
            "    org.id AS OrganizationID,  " +
            "    org.name AS Name,  " +
            "    org.code AS Code,  " +
            "    UUID() AS id,  " +
            "    org.industry_id AS IndustryID,  " +
            "    0 AS Year,  " +
            "    org.region_id AS RegionID,  " +
            "    0 AS RuleType,  " +
            "    st.id AS ServiceTypeID,  " +
            "    reg.short_name AS RegionName,  " +
            "    SYSDATE() AS UpdateTime,  " +
            "    st.name AS ServiceTypeName,  " +
            "    org.name AS OrganizationName,  " +
            "    ind.name AS IndustryName,  " +
            "    ostg.template_group_id AS TemplateGroupID,  " +
            "    \"\" AS TemplateGroupName,  " +
            "    org.client_code AS ClientCode,  " +
            "    \"\" AS DbName,  " +
            "    0 AS HaveCreateProject,  " +
            "    ea.enterprise_account_set_id AS EnterpriseAccountSetID,  " +
            "    1 AS StartPeriod,  " +
            "    12 AS EndPeriod,  " +
            "    ea.effective_date AS EffectiveDate,  " +
            "    ea.expired_date AS ExpiredDate  " +
            "FROM  " +
            "    organization org  " +
            "        JOIN  " +
            "    enterprise_account_set_org ea ON org.id = ea.organization_id  " +
            "        JOIN  " +
            "    organization_service_template_group ostg ON org.id = ostg.organization_id  " +
            "        JOIN  " +
            "    service_type st ON ostg.service_type_id = st.id  " +
            "        JOIN  " +
            "    industry ind ON org.industry_id = ind.id  " +
            "        JOIN  " +
            "    region reg ON org.region_id = reg.id " +
            "WHERE " +
            "  1=1" +
            "       <if test=\"orgId != null and orgId !='' \">AND org.id=#{orgId}</if>" +
            "        AND org.is_active = 1 " +
            "        AND st.is_active = 1 " +
            "       <if test=\"serviceId != null and serviceId !='' \">AND ostg.ServiceTypeID=#{serviceId}</if>" +
            "ORDER BY ea.effective_date,org.code" +
            "</script>")
    List<ProjectDisplayDto> getProjectFromEnterpriseAccountSetOrg(@Param("orgId") String orgId, @Param("serviceId") String serviceId);

    @Select("SELECT  " +
            "    period_id AS periodId, status AS status " +
            "FROM " +
            "    project_status_manage p " +
            "WHERE " +
            "    p.project_id = #{projectId} " +
            "ORDER BY period_id , status")
    List<ProjectStatusManage> selectProjectAllStatus(String projectId);

    @Select("SELECT max(db_name) as db_name FROM project WHERE year=#{year}")
    String maxDbName(Integer year);

    @Select("SELECT " +
            "  template_group_id " +
            "FROM project a " +
            "  JOIN organization_service_template_group b " +
            "    ON a.organization_id = b.organization_id " +
            "WHERE a.id = #{projectId} " +
            "    AND b.service_type_id = #{serviceType}")
    Long getTemplateGroupIdByProject(@Param("projectId") String projectId, @Param("serviceType") Integer serviceType);

    List<ProjectAnaylsisDto> getTemlateWithServiceType(@Param("list") List<String> orgIds, @Param("year") Integer year, @Param("month") Integer month,@Param("reportName")String reportName);

    List<ProjectAnaylsisDto> getTemlateWithServiceType2(@Param("orgId")String orgId, @Param("year") Integer year, @Param("month") Integer month,@Param("code")String code);

    List<Project> queryChildOrgAndProjectByOrgId(@Param("year")Integer year ,@Param("orgId")String orgId);
}