|
@@ -5,6 +5,8 @@ import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.company.constant.CompanyTrafficConstants;
|
|
|
import com.fs.company.domain.Company;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
|
+import com.fs.company.service.ICompanyTrafficRecordService;
|
|
|
+import com.fs.company.service.impl.CompanyTrafficRecordServiceImpl;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.hisStore.config.MedicalMallConfig;
|
|
|
import com.fs.statis.StatisticsRedisConstant;
|
|
@@ -13,7 +15,9 @@ import com.fs.statis.param.StatisticsDeptCompanyParam;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.system.service.ISysDeptService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -30,6 +34,7 @@ import static com.fs.statis.StatisticsRedisConstant.*;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/index/statistics")
|
|
|
+@Slf4j
|
|
|
public class IndexStatisticsController {
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
@@ -181,11 +186,10 @@ public class IndexStatisticsController {
|
|
|
}
|
|
|
String configValue = sysConfig.getConfigValue();
|
|
|
result.setTraffic(configValue);
|
|
|
- }
|
|
|
- if(param.getCompanyId() != null){
|
|
|
+ }else if(param.getCompanyId() != null){
|
|
|
Company company = companyService.selectCompanyById(param.getCompanyId());
|
|
|
getTrafficLogResult(result,CompanyTrafficConstants.CACHE_KEY+":"+company.getDeptId()+":"+param.getCompanyId());
|
|
|
- }else if(param.getDeptId() != null) {
|
|
|
+ }else{
|
|
|
getTrafficLogResult(result,CompanyTrafficConstants.CACHE_KEY+":"+param.getDeptId());
|
|
|
}
|
|
|
return R.ok().put("data",result);
|
|
@@ -198,15 +202,19 @@ public class IndexStatisticsController {
|
|
|
Object todayCount = redisCache.getCacheObject(key+":"+LocalDate.now());
|
|
|
Object thisMonthCount = redisCache.getCacheObject(key+":"+YearMonth.now());
|
|
|
Object traffic = redisCache.getCacheObject(key);
|
|
|
- result.setYesterday((yesterdayCount == null)?0L:((Integer)yesterdayCount).longValue());
|
|
|
+ result.setYesterday(parseRedisNumberValueToLong(yesterdayCount));
|
|
|
//今天
|
|
|
- result.setToday(todayCount == null?0L:((Integer)todayCount).longValue());
|
|
|
+ result.setToday(parseRedisNumberValueToLong(todayCount));
|
|
|
//本月
|
|
|
- result.setThisMonth(thisMonthCount == null?0L:((Integer)thisMonthCount).longValue());
|
|
|
+ result.setThisMonth(parseRedisNumberValueToLong(thisMonthCount));
|
|
|
//剩余
|
|
|
result.setTraffic(traffic == null?"0":traffic.toString());
|
|
|
}
|
|
|
|
|
|
+ private Long parseRedisNumberValueToLong(Object value){
|
|
|
+ return value == null ? 0 : Long.parseLong(value.toString());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 观看趋势
|
|
|
*/
|
|
@@ -667,6 +675,7 @@ public class IndexStatisticsController {
|
|
|
*/
|
|
|
@GetMapping("/authorizationInfo")
|
|
|
public R authorizationInfo(StatisticsDeptCompanyParam param){
|
|
|
+ AuthorizationInfoDTO authorizationInfoDTO = new AuthorizationInfoDTO();
|
|
|
if (!"1".equals(medicalMallConfig.getStatics()) || (param.getCompanyId() == null && param.getDeptId() == null) || (param.getCompanyId() == null && param.getDeptId() == 1)){
|
|
|
return R.ok().put("data", redisCache.getCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO));
|
|
|
}else if(param.getCompanyId() != null){
|
|
@@ -674,24 +683,24 @@ public class IndexStatisticsController {
|
|
|
}else{
|
|
|
Company company = new Company();
|
|
|
company.setDeptId(param.getDeptId());
|
|
|
- AuthorizationInfoDTO authorizationInfoDTO = new AuthorizationInfoDTO();
|
|
|
+ AuthorizationInfoDTO authorizationInfoDTO1 = new AuthorizationInfoDTO();
|
|
|
Long[] companyIds = companyService.selectCompanyList(company).stream().map(Company::getCompanyId).toArray(Long[]::new);
|
|
|
for(Long companyId : companyIds) {
|
|
|
AuthorizationInfoDTO companyDTO = redisCache.getCacheObject(String.format("%s:%d", DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO, companyId));
|
|
|
+ log.info("授权信息:{}", authorizationInfoDTO);
|
|
|
if (companyDTO != null) {
|
|
|
- authorizationInfoDTO.setTodayWatchUserCount(
|
|
|
- (authorizationInfoDTO.getTodayWatchUserCount() == null ? 0 : authorizationInfoDTO.getTodayWatchUserCount()) +
|
|
|
+ authorizationInfoDTO1.setTodayWatchUserCount(
|
|
|
+ (authorizationInfoDTO1.getTodayWatchUserCount() == null ? 0 : authorizationInfoDTO1.getTodayWatchUserCount()) +
|
|
|
(companyDTO.getTodayWatchUserCount() == null ? 0 : companyDTO.getTodayWatchUserCount())
|
|
|
);
|
|
|
|
|
|
- authorizationInfoDTO.setVersionLimit(
|
|
|
- (authorizationInfoDTO.getVersionLimit() == null ? 0 : authorizationInfoDTO.getVersionLimit()) +
|
|
|
+ authorizationInfoDTO1.setVersionLimit(
|
|
|
+ (authorizationInfoDTO1.getVersionLimit() == null ? 0 : authorizationInfoDTO1.getVersionLimit()) +
|
|
|
(companyDTO.getVersionLimit() == null ? 0 : companyDTO.getVersionLimit())
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- AuthorizationInfoDTO authorizationInfoDTO = redisCache.getCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO);
|
|
|
|
|
|
return R.ok().put("data", authorizationInfoDTO);
|
|
|
}
|