Commit ca7c3213 by 吴博

fix 1002907

parent c78253b2
......@@ -1612,8 +1612,14 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
log.error("该书没有匹配的分类权益,bookId=" + bookId);
return new RightsSettingDto();
}
List<RightsReadType> rightsReadTypes = rightsReadTypeMapper.getByRightsSettingId(rightsSettingDto.getId());
ReadTypeCountDTO readTypeCountDTO = rightsSettingTitleMapper.getCount4Title(rightsSettingDto.getId());
Long rightsSettingId = rightsSettingDto.getId();
List<RightsReadType> rightsReadTypes = rightsReadTypeMapper.getByRightsSettingId(rightsSettingId);
ReadTypeCountDTO readTypeCountDTO = new ReadTypeCountDTO();
readTypeCountDTO.setRightsSettingId(rightsSettingId);
ReadTypeCountDTO readTypeCountDTO4Title = rightsSettingTitleMapper.getCount4Title(rightsSettingId);
ReadTypeCountDTO readTypeCountDTO4Item = rightsSettingItemDao.getCount4Item(rightsSettingId);
ReadTypeCountDTO readTypeCountDTO4Group = rightsItemGroupDao.getCount4Group(rightsSettingId);
getAllCount(readTypeCountDTO, readTypeCountDTO4Title, readTypeCountDTO4Item, readTypeCountDTO4Group);
setReadType(rightsSettingDto, readTypeCountDTO, rightsReadTypes);
rightsSettingDto.setChooseReadType(chooseReadType);
}
......@@ -1621,6 +1627,30 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
return rightsSettingDto;
}
private void getAllCount(ReadTypeCountDTO readTypeCountDTO, ReadTypeCountDTO readTypeCountDTO4Title,
ReadTypeCountDTO readTypeCountDTO4Item, ReadTypeCountDTO readTypeCountDTO4Group) {
readTypeCountDTO.setEasyReadCount(0);
readTypeCountDTO.setEfficientReadCount(0);
readTypeCountDTO.setDeepReadCount(0);
if (null != readTypeCountDTO4Title) {
readTypeCountDTO.setEasyReadCount(readTypeCountDTO4Title.getEasyReadCount());
readTypeCountDTO.setEfficientReadCount(readTypeCountDTO4Title.getEfficientReadCount());
readTypeCountDTO.setDeepReadCount(readTypeCountDTO4Title.getDeepReadCount());
}
if (null != readTypeCountDTO4Item) {
readTypeCountDTO.setEasyReadCount(readTypeCountDTO.getEasyReadCount() + readTypeCountDTO4Item.getEasyReadCount());
readTypeCountDTO
.setEfficientReadCount(readTypeCountDTO.getEfficientReadCount() + readTypeCountDTO4Item.getEfficientReadCount());
readTypeCountDTO.setDeepReadCount(readTypeCountDTO.getDeepReadCount() + readTypeCountDTO4Item.getDeepReadCount());
}
if (null != readTypeCountDTO4Group) {
readTypeCountDTO.setEasyReadCount(readTypeCountDTO.getEasyReadCount() + readTypeCountDTO4Group.getEasyReadCount());
readTypeCountDTO
.setEfficientReadCount(readTypeCountDTO.getEfficientReadCount() + readTypeCountDTO4Group.getEfficientReadCount());
readTypeCountDTO.setDeepReadCount(readTypeCountDTO.getDeepReadCount() + readTypeCountDTO4Group.getDeepReadCount());
}
}
private void setReadType(RightsSettingDto rightsSettingDto, ReadTypeCountDTO readTypeCountDTO, List<RightsReadType> rightsReadTypes) {
if (!ListUtils.isEmpty(rightsReadTypes) && null != readTypeCountDTO && (
!Objects.equals(BookConstant.zero,readTypeCountDTO.getEasyReadCount()) ||
......
package com.pcloud.book.rightsSetting.dao;
import com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.common.core.dao.BaseDao;
......@@ -19,4 +20,6 @@ public interface RightsItemGroupDao extends BaseDao<RightsItemGroup> {
void deleteByRightsSettingId(Long rightsSettingId);
List<RightsItemGroup> getListByRightSettingId(Long rightsSettingId, Integer readType);
ReadTypeCountDTO getCount4Group(Long rightsSettingId);
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.dao;
import com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
import com.pcloud.common.core.dao.BaseDao;
......@@ -42,4 +43,6 @@ public interface RightsSettingItemDao extends BaseDao<RightsSettingItem>{
List<RightsSettingItem> getItemByRightsIdAndType(Long rightsSettingId, String rightsType);
List<RightsSettingItem> getItemsByRightsSettingId4Read(Long rightsSettingId, String rightsType);
ReadTypeCountDTO getCount4Item(Long rightsSettingId);
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.dao.impl;
import com.pcloud.book.rightsSetting.dao.RightsItemGroupDao;
import com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
......@@ -36,4 +37,9 @@ public class RightsItemGroupDaoImpl extends BaseDaoImpl<RightsItemGroup> impleme
map.put("readType",readType);
return super.getSqlSession().selectList(getStatement("getListByRightSettingId"),map);
}
@Override
public ReadTypeCountDTO getCount4Group(Long rightsSettingId) {
return getSessionTemplate().selectOne(getStatement("getCount4Group"),rightsSettingId);
}
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.dao.impl;
import com.pcloud.book.rightsSetting.dao.RightsSettingItemDao;
import com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
import com.pcloud.common.core.dao.BaseDaoImpl;
......@@ -54,4 +55,9 @@ public class RightsSettingItemDaoImpl extends BaseDaoImpl<RightsSettingItem> imp
map.put("rightsType",rightsType);
return getSessionTemplate().selectList(getStatement("getItemsByRightsSettingId4Read"), map);
}
@Override
public ReadTypeCountDTO getCount4Item(Long rightsSettingId) {
return getSessionTemplate().selectOne(getStatement("getCount4Item"),rightsSettingId);
}
}
......@@ -97,4 +97,18 @@
</choose>
</select>
<select id="getCount4Group" parameterType="long" resultType="com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO">
SELECT
rights_setting_id rightsSettingId,
SUM(IFNULL(easy_read, 0)) easyReadCount,
SUM(IFNULL(efficient_read, 0)) efficientReadCount,
SUM(IFNULL(deep_read, 0)) deepReadCount
FROM
rights_item_group
GROUP BY
rights_setting_id
HAVING
rights_setting_id = #{rightsSettingId};
</select>
</mapper>
\ No newline at end of file
......@@ -124,4 +124,19 @@
order by i.id asc
</select>
<select id="getCount4Item" parameterType="long" resultType="com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO">
SELECT
rights_setting_id rightsSettingId,
SUM(IFNULL(easy_read, 0)) easyReadCount,
SUM(IFNULL(efficient_read, 0)) efficientReadCount,
SUM(IFNULL(deep_read, 0)) deepReadCount
FROM
rights_setting_item
GROUP BY
rights_setting_id
HAVING
rights_setting_id = #{rightsSettingId};
</select>
</mapper>
\ No newline at end of file
......@@ -201,7 +201,7 @@
SUM(IFNULL(efficient_read, 0)) efficientReadCount,
SUM(IFNULL(deep_read, 0)) deepReadCount
FROM
`rights_setting_title`
rights_setting_title
GROUP BY
rights_setting_id
HAVING
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment