2 Commits 136d5a143f ... 456c60ae59

Autor SHA1 Mensaje Fecha
  zizg 456c60ae59 作者:张哲 hace 1 año
  zizg 5ca85216fe 作者:张哲 hace 1 año

+ 6 - 0
src/main/java/com/redxun/knowledge/album/entity/dao/AlbumInfo.java

@@ -72,6 +72,12 @@ public class AlbumInfo  extends BaseExtEntity<String> {
     @TableField(exist = false)
     private Integer versionState;
 
+    @TableField(exist = false)
+    private Integer knowledgeTotal;
+
+    @TableField(exist = false)
+    private Integer yelpTotal;
+
 
 
     @Override

+ 1 - 1
src/main/java/com/redxun/knowledge/album/mapper/AlbumInfoMapper.java

@@ -15,7 +15,7 @@ import java.util.Map;
 @Mapper
 public interface AlbumInfoMapper extends BaseDao<AlbumInfo> {
 
-    List<AlbumInfo> findAllAlbumInfo(@Param("params") Map<String, Object> params, @Param("w") Map<String, Object> order);
+    IPage findAllAlbumInfo(IPage<AlbumInfo> page, @Param("params") Map<String, Object> params, @Param("order") String order);
 
     /**
      * 版本收入知识量

+ 34 - 86
src/main/java/com/redxun/knowledge/album/service/AlbumInfoServiceImpl.java

@@ -158,7 +158,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
                     //查询我的专辑
                     IPage page1 = albumInfoMapper.findAllAlbumInfoByOwnerIds(queryFilter.getPage(), queryFilter.getParams(), params);
                     List<AlbumInfo> records = page1.getRecords();
-                    List<AlbumInfoVo> albumInfoVoList = pageInfo(records);
+                    List<AlbumInfoVo> albumInfoVoList = pageInfo(records,null);
                     page1.setRecords(albumInfoVoList);
                     return page1;
                 case "2":
@@ -174,7 +174,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
                     List<AlbumInfo> collect = ownerIdsList.stream().distinct().collect(Collectors.toList());
                     Page page2 = PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(), collect);
                     List<AlbumInfo> recordslist = page2.getRecords();
-                    List<AlbumInfoVo> albumInfoVoListResult = pageInfo(recordslist);
+                    List<AlbumInfoVo> albumInfoVoListResult = pageInfo(recordslist,null);
                     albumInfoVoListResult.stream().filter(e -> !e.getOwnerId().equals(userId)).forEach(h -> h.setVersionState(2));
                     page2.setRecords(albumInfoVoListResult);
                     return page2;
@@ -183,7 +183,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
                     queryFilter.getParams().put("userId", userService.queryLoginUser());
                     IPage page3 = albumInfoMapper.findAllAlbumInfoYelpByUserId(queryFilter.getPage(), queryFilter.getParams(), params);
                     List<AlbumInfo> result = page3.getRecords();
-                    List<AlbumInfoVo> albumInfoVoList3 = pageInfo(result);
+                    List<AlbumInfoVo> albumInfoVoList3 = pageInfo(result,null);
                     //不是我创建的专辑(状态设置为2 已发布)
                     albumInfoVoList3.stream().filter(e -> !e.getOwnerId().equals(userId)).forEach(h -> {
                         h.setVersionState(2);
@@ -193,31 +193,11 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
                     return page3;
             }
         }
-        List<AlbumInfo> collect = albumInfoMapper.findAllAlbumInfo(queryFilter.getParams(), params);
-        //List<AlbumInfo> collect = page.getRecords();
-        List<AlbumInfoVo> albumInfoVoList = pageInfo(collect);
-        if (queryFilter.getParams().containsKey("state")){
-            switch ((String) queryFilter.getParams().get("state")){
-                case "0":
-                    albumInfoVoList = albumInfoVoList.stream().filter(e -> e.getState() == 0).collect(Collectors.toList());
-                    break;
-                case "1":
-                    albumInfoVoList = albumInfoVoList.stream().filter(e -> e.getVersionState() == 1).collect(Collectors.toList());
-                    break;
-                case "2":
-                    albumInfoVoList = albumInfoVoList.stream().filter(e -> e.getVersionState() == 2).collect(Collectors.toList());
-                    break;
-                case "4":
-                    albumInfoVoList = albumInfoVoList.stream().filter(e -> e.getVersionState() == 4).collect(Collectors.toList());
-                    break;
-            }
-        }
-        //排序
-        if (StringUtils.isNotEmpty((String) queryFilter.getParams().get("orderBySql"))){
-            albumInfoVoList = albumInfoSort((String) queryFilter.getParams().get("orderBySql"),albumInfoVoList);
-        }
-        //page.setRecords(albumInfoVoList);
-        return PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(),albumInfoVoList);
+        IPage page = albumInfoMapper.findAllAlbumInfo(queryFilter.getPage(),queryFilter.getParams(), queryFilter.getSortSql());
+        List<AlbumInfo> collect = page.getRecords();
+        List<AlbumInfoVo> albumInfoVoList = pageInfo(collect,"manager");
+        page.setRecords(albumInfoVoList);
+        return page;
     }
 
     /**
@@ -226,7 +206,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
      * @param collect
      * @return
      */
-    private List<AlbumInfoVo> pageInfo(List<AlbumInfo> collect) {
+    private List<AlbumInfoVo> pageInfo(List<AlbumInfo> collect,String manager) {
         String userId = userService.queryLoginUser();
         List<AlbumInfoVo> albumInfoVoList = collect.parallelStream().map(e -> {
             AlbumInfoVo albumInfoVo = new AlbumInfoVo();
@@ -245,38 +225,42 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
             }, threadPoolExecutor);
             //专辑收录知识量(当前生效版本各个目录中知识数量总和)
             CompletableFuture<Void> countKnowledgeCompletableFuture = CompletableFuture.runAsync(() -> {
-                AlbumVersion albumVersion = albumVersionMapper.
-                        selectOne(new LambdaQueryWrapper<AlbumVersion>().
-                                eq(AlbumVersion::getAlbumId, e.getPkId()).
-                                eq(AlbumVersion::getState, 2));
-                //没有生效的专辑(第一次创建专辑时的情况)
-                if (albumVersion == null) {
-                    AlbumVersion albumVersionFirst = albumVersionMapper.
+                if (manager == null) {
+                    AlbumVersion albumVersion = albumVersionMapper.
                             selectOne(new LambdaQueryWrapper<AlbumVersion>().
                                     eq(AlbumVersion::getAlbumId, e.getPkId()).
-                                    eq(AlbumVersion::getState, 1));
-                    if (albumVersionFirst == null) {
-                        AlbumVersion albumVersionFour = albumVersionMapper.
+                                    eq(AlbumVersion::getState, 2));
+                    //没有生效的专辑(第一次创建专辑时的情况)
+                    if (albumVersion == null) {
+                        AlbumVersion albumVersionFirst = albumVersionMapper.
                                 selectOne(new LambdaQueryWrapper<AlbumVersion>().
                                         eq(AlbumVersion::getAlbumId, e.getPkId()).
-                                        eq(AlbumVersion::getState, 4));
-                        Integer countKnowledge = albumInfoMapper.selectCountKnowledge(e.getPkId(), albumVersionFour.getPkId());
-                        albumInfoVo.setKnowledgeTotal(countKnowledge);
+                                        eq(AlbumVersion::getState, 1));
+                        if (albumVersionFirst == null) {
+                            AlbumVersion albumVersionFour = albumVersionMapper.
+                                    selectOne(new LambdaQueryWrapper<AlbumVersion>().
+                                            eq(AlbumVersion::getAlbumId, e.getPkId()).
+                                            eq(AlbumVersion::getState, 4));
+                            Integer countKnowledge = albumInfoMapper.selectCountKnowledge(e.getPkId(), albumVersionFour.getPkId());
+                            albumInfoVo.setKnowledgeTotal(countKnowledge);
+                        } else {
+                            Integer countKnowledge = albumInfoMapper.selectCountKnowledge(e.getPkId(), albumVersionFirst.getPkId());
+                            albumInfoVo.setKnowledgeTotal(countKnowledge);
+                        }
                     } else {
-                        Integer countKnowledge = albumInfoMapper.selectCountKnowledge(e.getPkId(), albumVersionFirst.getPkId());
+                        Integer countKnowledge = albumInfoMapper.selectCountKnowledge(e.getPkId(), albumVersion.getPkId());
                         albumInfoVo.setKnowledgeTotal(countKnowledge);
                     }
-                } else {
-                    Integer countKnowledge = albumInfoMapper.selectCountKnowledge(e.getPkId(), albumVersion.getPkId());
-                    albumInfoVo.setKnowledgeTotal(countKnowledge);
                 }
             }, threadPoolExecutor);
             //专辑点评量(当前专辑中通过审核的点评量总和)
             CompletableFuture<Void> countYelpCompletableFuture = CompletableFuture.runAsync(() -> {
-                Integer countYelp = albumYelpMapper.selectCount(new LambdaQueryWrapper<AlbumYelp>().
-                        eq(AlbumYelp::getAlbumId, e.getPkId()).
-                        eq(AlbumYelp::getState, 1));
-                albumInfoVo.setYelpTotal(countYelp);
+                if (manager == null) {
+                    Integer countYelp = albumYelpMapper.selectCount(new LambdaQueryWrapper<AlbumYelp>().
+                            eq(AlbumYelp::getAlbumId, e.getPkId()).
+                            eq(AlbumYelp::getState, 1));
+                    albumInfoVo.setYelpTotal(countYelp);
+                }
             }, threadPoolExecutor);
             //其他参数
             CompletableFuture<Void> anotherCompletableFuture = CompletableFuture.runAsync(() -> {
@@ -329,42 +313,6 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
         return albumInfoVoList;
     }
 
-    private List<AlbumInfoVo> albumInfoSort(String sort,List<AlbumInfoVo> albumInfoVoList){
-        switch (sort) {
-            case "knowledgeTotal desc":
-                albumInfoVoList = albumInfoVoList.stream().sorted((t1, t2) -> t2.getKnowledgeTotal().compareTo(t1.getKnowledgeTotal())).collect(Collectors.toList());
-                break;
-            case "knowledgeTotal asc":
-                albumInfoVoList = albumInfoVoList.stream().sorted(Comparator.comparing(AlbumInfoVo::getKnowledgeTotal)).collect(Collectors.toList());
-                break;
-            case "yelpTotal desc":
-                albumInfoVoList = albumInfoVoList.stream().sorted((t1, t2) -> t2.getYelpTotal().compareTo(t1.getYelpTotal())).collect(Collectors.toList());
-                break;
-            case "yelpTotal asc":
-                albumInfoVoList = albumInfoVoList.stream().sorted(Comparator.comparing(AlbumInfoVo::getYelpTotal)).collect(Collectors.toList());
-                break;
-            case "views desc":
-                albumInfoVoList = albumInfoVoList.stream().sorted((t1, t2) -> t2.getViews().compareTo(t1.getViews())).collect(Collectors.toList());
-                break;
-            case "views asc":
-                albumInfoVoList = albumInfoVoList.stream().sorted(Comparator.comparing(AlbumInfoVo::getViews)).collect(Collectors.toList());
-                break;
-            case "createTime desc":
-                albumInfoVoList = albumInfoVoList.stream().sorted((t1, t2) -> t2.getCreateTime().compareTo(t1.getCreateTime())).collect(Collectors.toList());
-                break;
-            case "createTime asc":
-                albumInfoVoList = albumInfoVoList.stream().sorted(Comparator.comparing(AlbumInfoVo::getCreateTime)).collect(Collectors.toList());
-                break;
-            case "updateTime desc":
-                albumInfoVoList = albumInfoVoList.stream().sorted((t1, t2) -> t2.getUpdateTime().compareTo(t1.getUpdateTime())).collect(Collectors.toList());
-                break;
-            case "updateTime asc":
-                albumInfoVoList = albumInfoVoList.stream().sorted(Comparator.comparing(AlbumInfoVo::getUpdateTime)).collect(Collectors.toList());
-                break;
-        }
-        return albumInfoVoList;
-    }
-
     /**
      * 专辑详情
      *

+ 1 - 1
src/main/java/com/redxun/knowledge/analysis/mapper/AnalysisSynthesizeMapper.java

@@ -52,5 +52,5 @@ public interface AnalysisSynthesizeMapper {
      * @param module
      * @return
      */
-    List<CreateUserViewLabel> totalUserVisits(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay,@Param("module") String module);
+    List<CreateUserViewLabel> totalUserVisits(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay,@Param("module") String module,@Param("type") String type);
 }

+ 7 - 4
src/main/java/com/redxun/knowledge/analysis/service/AnalysisSynthesizeServiceImpl.java

@@ -175,15 +175,18 @@ public class AnalysisSynthesizeServiceImpl {
         Calendar calendar = Calendar.getInstance();
         int year = calendar.get(Calendar.YEAR);
         if (("total").equals(type)) {
-            createUserViewLabel = analysisSynthesizeMapper.totalUserVisits(null, null, module);
+            createUserViewLabel = analysisSynthesizeMapper.totalUserVisits(null, null, module,"total");
         } else if ("year".equals(type)) {
-            createUserViewLabel = analysisSynthesizeMapper.totalUserVisits(DateUtils.format(DateUtils.getFirstOfYear(year)),
-                    DateUtils.format(DateUtils.getLastOfYear(year)), module);
+            String firstYear = DateUtils.format(DateUtils.getFirstOfYear(1));
+            String lastYear = DateUtils.format(DateUtils.getLastOfYear(1));
+            firstYear = firstYear.substring(0,firstYear.lastIndexOf("-"));
+            lastYear = lastYear.substring(0,lastYear.lastIndexOf("-"));
+            createUserViewLabel = analysisSynthesizeMapper.totalUserVisits(firstYear,lastYear, module,"year");
         } else if ("month".equals(type)) {
             int month = calendar.get(Calendar.MONTH);
             String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
             String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
-            createUserViewLabel = analysisSynthesizeMapper.totalUserVisits(firstOfMonth, lastOfMonth, module);
+            createUserViewLabel = analysisSynthesizeMapper.totalUserVisits(firstOfMonth, lastOfMonth, module,"month");
         }
         int sum = createUserViewLabel.stream().mapToInt(e -> e.getPv() + e.getUv()).sum();
         createUserView.setTotal(sum);

+ 1 - 1
src/main/java/com/redxun/knowledge/controller/KnowledgeController.java

@@ -117,7 +117,7 @@ public class KnowledgeController extends BaseController<Knowledge> {
     public JsonResult deleteKnowledge(@RequestParam("knowledgeId") String knowledgeId){
         Boolean result = knowledgeService.deleteKnowledge(knowledgeId);
         if (!result){
-            return JsonResult.Fail("该知识下还有关联banner,删除失败");
+            return JsonResult.Fail("删除失败,知识已关联其他模块");
         }
         return JsonResult.Success("删除成功!");
     }

+ 16 - 1
src/main/java/com/redxun/knowledge/service/KnowledgeServiceImpl.java

@@ -19,6 +19,8 @@ import com.redxun.common.tool.IdGenerator;
 import com.redxun.common.tool.StringUtils;
 import com.redxun.common.utils.ContextUtil;
 import com.redxun.dto.user.OsUserDto;
+import com.redxun.knowledge.album.entity.dao.AlbumCatalogueKnowledge;
+import com.redxun.knowledge.album.mapper.AlbumCatalogueKnowledgeMapper;
 import com.redxun.knowledge.common.MessageService;
 import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.entity.dao.*;
@@ -27,6 +29,8 @@ import com.redxun.knowledge.entity.vo.KnowledgeApprovalListVo;
 import com.redxun.knowledge.entity.vo.KnowledgeApprovalVo;
 import com.redxun.knowledge.entity.vo.KnowledgeCategoryAdminVo;
 import com.redxun.knowledge.entity.vo.KnowledgeVo;
+import com.redxun.knowledge.map.entity.dao.MapContent;
+import com.redxun.knowledge.map.mapper.MapContentMapper;
 import com.redxun.knowledge.mapper.*;
 import com.redxun.knowledge.utils.DeduplicationUtil;
 import com.redxun.knowledge.utils.PageListUtils;
@@ -86,6 +90,12 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
     @Autowired
     private KnowledgeApproveServiceImpl knowledgeApproveService;
 
+    @Autowired
+    private MapContentMapper mapContentMapper;
+
+    @Autowired
+    private AlbumCatalogueKnowledgeMapper albumCatalogueKnowledgeMapper;
+
 
 
     @Override
@@ -539,8 +549,13 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
      */
     @Transactional(rollbackFor = Exception.class)
     public Boolean deleteKnowledge(String knowledgeId) {
+        Integer count = 0;
         // 查看是否关联着banner
-        Integer count = bannerMapper.selectCount(new QueryWrapper<Banner>().eq("KNOWLEDGE_ID", knowledgeId));
+        count = bannerMapper.selectCount(new QueryWrapper<Banner>().eq("KNOWLEDGE_ID", knowledgeId));
+        //查看是否关联着地图
+        count = mapContentMapper.selectCount(new QueryWrapper<MapContent>().eq("KNOWLEDGE_ID",knowledgeId));
+        //查看是否关联着专辑
+        count = albumCatalogueKnowledgeMapper.selectCount(new QueryWrapper<AlbumCatalogueKnowledge>().eq("KNOWLEDGE_ID",knowledgeId));
         if (count > 0){
             return false;
         }

+ 77 - 10
src/main/resources/mapper/knowledge/album/AlbumInfoMapper.xml

@@ -51,14 +51,73 @@
     </select>
 
     <select id="findAllAlbumInfo" resultType="com.redxun.knowledge.album.entity.dao.AlbumInfo" parameterType="java.util.Map">
-        select
-        <include refid="COLUMNS"/>,FULLNAME_
-        from KM_ALBUM_INFO ai
-        JOIN LEARNING_USER_DEV.OS_USER
+        select pk_id,
+        category_id,
+        name,
+        cover,
+        owner_company_id,
+        owner_department_id,
+        owner_id,
+        state,
+        views,
+        is_del,
+        company_id_,
+        create_dep_id_,
+        tenant_id_,
+        create_by_,
+        create_time_,
+        update_by_,
+        update_time_,
+        nvl(knowledgetotal,0) knowledgeTotal,
+        nvl(yelptotal,0) yelpTotal,
+        fullname_,
+        versionState
+        from (
+        select ai.*, nvl(t2.yelpCount, 0) yelpTotal, s2.FULLNAME_, av.versionState versionState
+        from (
+        select *
+        from (
+        select t1.*
+        --, nvl(t2.yelpCount, 0) yelpTotal
+        from (
+        select av.ALBUM_ID,
+        nvl(sum(nvl(count(*), 0)) over (partition by VERSION_ID), 0) knowledgeTotal,
+        av.STATE                                                     versionStates
+        from (
+        select *
+        from (select b.*,
+        (ROW_NUMBER()
+        OVER (PARTITION BY b.ALBUM_ID ORDER BY b.CREATE_TIME_ desc)) rn
+        from KM_ALBUM_VERSION b
+        where IS_DEL = 0)
+        where rn = 1) av
+        left join KM_ALBUM_CATALOGUE catalogue
+        on av.PK_ID = catalogue.VERSION_ID and catalogue.IS_DEL = 0
+        join KM_ALBUM_CATALOGUE_KNOWLEDGE knowledge
+        ON catalogue.PK_ID = knowledge.CATALOGUE_ID and knowledge.IS_DEL = 0
+        group by VERSION_ID, av.ALBUM_ID, av.STATE) t1) result1
+        right join KM_ALBUM_INFO ai on result1.ALBUM_ID = ai.PK_ID
+        where ai.IS_DEL = 0) ai
+        JOIN LEARNING_USER_DEV.OS_USER s2
         ON OWNER_ID = USER_ID_
+        left join (select ALBUM_ID, count(*) yelpCount
+        from KM_ALBUM_YELP
+        where IS_DEL = 0
+        and STATE = 1
+        group by ALBUM_ID) t2 on ai.PK_ID = t2.ALBUM_ID
+        join (select av.ALBUM_ID,
+        av.STATE versionState
+        from (
+        select *
+        from (select b.*,
+        (ROW_NUMBER()
+        OVER (PARTITION BY b.ALBUM_ID ORDER BY b.CREATE_TIME_ desc)) rn
+        from KM_ALBUM_VERSION b
+        where IS_DEL = 0)
+        where rn = 1) av) av on av.ALBUM_ID = ai.PK_ID)
         <where>
             <if test="@rx.Ognl@isNotEmpty(params.name)">
-                instr(ai.NAME,#{params.name}) > 0
+                instr(name,#{params.name}) > 0
             </if>
             <if test="@rx.Ognl@isNotEmpty(params.categoryId)">
                 and CATEGORY_ID IN (
@@ -69,16 +128,24 @@
             <if test="@rx.Ognl@isNotEmpty(params.ownerName)">
                 and instr(FULLNAME_,#{params.ownerName}) > 0
             </if>
+            <if test="@rx.Ognl@isNotEmpty(params.state) and params.state == 0">
+                and state = #{params.state}
+            </if>
+            <if test="@rx.Ognl@isNotEmpty(params.state) and params.state != 0">
+                and versionState = #{params.state} and state = 1
+            </if>
             <if test="@rx.Ognl@isNotEmpty(params.createTimeStart)">
-                and TO_CHAR(ai.CREATE_TIME_,'yyyy-mm-dd') &gt;= #{params.createTimeStart}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{params.createTimeStart}
             </if>
             <if test="@rx.Ognl@isNotEmpty(params.createTimeEnd)">
-                and TO_CHAR(ai.CREATE_TIME_,'yyyy-mm-dd') &lt;= #{params.createTimeEnd}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{params.createTimeEnd}
             </if>
-            and ai.IS_DEL = 0
         </where>
-        <if test="@rx.Ognl@isEmpty(w.orderBySql)">
-            ORDER BY ai.STATE DESC, ai.CREATE_TIME_ DESC
+        <if test="@rx.Ognl@isEmpty(order)">
+            ORDER BY STATE DESC, CREATE_TIME_ DESC
+        </if>
+        <if test="@rx.Ognl@isNotEmpty(order)">
+            ORDER BY ${order}
         </if>
     </select>
 

+ 29 - 2
src/main/resources/mapper/knowledge/analysis/AnalysisSynthesizeMapper.xml

@@ -10,6 +10,7 @@
                 TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstDay}
                 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastDay}
             </if>
+            and module != '其他'
         </where>
         group by MODULE
     </select>
@@ -125,11 +126,15 @@
                 createTime &gt;= #{firstDay}
                 and createTime &lt;= #{lastDay}
             </if>
+            and module != '其他'
         </where>
         group by MODULE
     </select>
 
     <select id="totalUserVisits" resultType="com.redxun.knowledge.analysis.entity.vo.CreateUserViewLabel">
+        <if test="type != null and type == 'year'">
+            select t2.name,nvl(pv,0) pv,nvl(uv,0) uv from (
+        </if>
         select
         <if test="firstDay == null and lastDay == null">
             concat(concat(substr(to_char(CREATE_TIME_,'yyyy-mm'),1,instr(to_char(CREATE_TIME_,'yyyy-mm'),'-',-1) -
@@ -150,7 +155,11 @@
             <if test="module != null">
                 MODULE = #{module}
             </if>
-            <if test="firstDay != null and lastDay != null">
+            <if test="type != null and type == 'year'">
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm') &gt;= #{firstDay}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm') &lt;= #{lastDay}
+            </if>
+            <if test="firstDay != null and lastDay != null and type != 'year'">
                 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstDay}
                 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastDay}
             </if>
@@ -161,7 +170,11 @@
             <if test="module != null">
                 MODULE = #{module}
             </if>
-            <if test="firstDay != null and lastDay != null">
+            <if test="type != null and type == 'year'">
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm') &gt;= #{firstDay}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm') &lt;= #{lastDay}
+            </if>
+            <if test="firstDay != null and lastDay != null and type != 'year'">
                 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstDay}
                 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastDay}
             </if>
@@ -174,5 +187,19 @@
             group by to_char(CREATE_TIME_,'mm')
             order by to_char(CREATE_TIME_,'mm')
         </if>
+        <if test="type != null and type == 'year'">
+            ) t1
+            right join
+            (select concat(ltrim(to_char(monthlist, 'mm'), '0'), '月') name,monthlist
+            from (
+            SELECT ADD_MONTHS(TO_DATE(#{firstDay}, 'yyyy-MM'), ROWNUM - 1) as monthlist
+            FROM DUAL
+            CONNECT BY ROWNUM &lt;=
+            months_between(to_date(#{lastDay}, 'yyyy-MM'),
+            to_date(#{firstDay}, 'yyyy-MM')) + 1
+            order by monthlist)) t2
+            on t1.name = t2.name
+            order by t2.monthlist
+        </if>
     </select>
 </mapper>