|
|
@ -23,12 +23,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; |
|
|
|
import com.epmet.commons.tools.constant.*; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.scan.param.TextScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.result.SyncScanResult; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.*; |
|
|
|
import com.epmet.constant.*; |
|
|
@ -74,6 +78,7 @@ import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -2790,6 +2795,83 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit |
|
|
|
return baseDao.selectByOriginId(originId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 【社区治理】项目分布分析-左边 |
|
|
|
* @param formDTO |
|
|
|
* @param tokenDto |
|
|
|
* @author zxc |
|
|
|
* @date 2021/12/7 10:02 上午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ProjectDistributionAnalysisLeftResultDTO> projectDistributionAnalysisLeft(ProjectDistributionAnalysisFormDTO formDTO, TokenDto tokenDto) { |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); |
|
|
|
if (null == staffInfo){ |
|
|
|
throw new EpmetException("未查询到此工作人员的所属组织信息..."); |
|
|
|
} |
|
|
|
Result<List<CategoryListResultDTO>> listResult = govIssueOpenFeignClient.selectCategoryOneLevelListByCustomerId(tokenDto); |
|
|
|
if (!listResult.success()){ |
|
|
|
throw new EpmetException("查询1级分类列表失败..."); |
|
|
|
} |
|
|
|
List<ProjectCategoryByDateDTO> projectCategoryByDateDTOS = baseDao.selectProjectCategoryByDate(formDTO.getDate(), staffInfo.getAgencyId(), listResult.getData().get(NumConstant.ZERO).getCodeLength()); |
|
|
|
if (CollectionUtils.isEmpty(projectCategoryByDateDTOS)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
return disposeTimeInterval(projectCategoryByDateDTOS, formDTO.getDate(), listResult.getData()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 区间项目分类数量处理 |
|
|
|
* @param categories |
|
|
|
* @param date |
|
|
|
* @param listResult |
|
|
|
* @author zxc |
|
|
|
* @date 2021/12/8 9:45 上午 |
|
|
|
*/ |
|
|
|
public List<ProjectDistributionAnalysisLeftResultDTO> disposeTimeInterval(List<ProjectCategoryByDateDTO> categories, String date,List<CategoryListResultDTO> listResult){ |
|
|
|
List<String> intervalTimeList = getIntervalTimeList("00:00", "24:00", 240); |
|
|
|
List<ProjectDistributionAnalysisLeftResultDTO> result = new ArrayList<>(); |
|
|
|
Map<String, List<ProjectCategoryByDateDTO>> groupByCode = categories.stream().collect(Collectors.groupingBy(ProjectCategoryByDateDTO::getCategoryCode)); |
|
|
|
for (int i = 0; i < intervalTimeList.size(); i++) { |
|
|
|
ProjectDistributionAnalysisLeftResultDTO dto = new ProjectDistributionAnalysisLeftResultDTO(); |
|
|
|
dto.setTime(intervalTimeList.get(i)); |
|
|
|
dto.setCategoryList(ConvertUtils.sourceToTarget(listResult,CategoryListDTO.class)); |
|
|
|
String concat = date.concat(" ").concat(intervalTimeList.get(i)).concat(":00"); |
|
|
|
long end = DateUtils.stringToDate(DateUtils.DATE_TIME_PATTERN, concat).getTime(); |
|
|
|
if (i == NumConstant.ZERO){ |
|
|
|
dto.getCategoryList().forEach(cate -> { |
|
|
|
AtomicReference<Integer> count = new AtomicReference<>(cate.getCount()); |
|
|
|
groupByCode.forEach((k,v) -> { |
|
|
|
if (cate.getCategoryCode().equals(k)){ |
|
|
|
v.forEach(l -> { |
|
|
|
if (l.getCreatedTime().getTime() < end){ |
|
|
|
cate.setCount(count.getAndSet(count.get() + NumConstant.ONE)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}else if (i == intervalTimeList.size() - NumConstant.ONE){ |
|
|
|
break; |
|
|
|
}else { |
|
|
|
String startStr = date.concat(" ").concat(intervalTimeList.get(i - NumConstant.ONE)).concat(":00"); |
|
|
|
long start = DateUtils.stringToDate(DateUtils.DATE_TIME_PATTERN, startStr).getTime(); |
|
|
|
dto.getCategoryList().forEach(cate -> { |
|
|
|
AtomicReference<Integer> count = new AtomicReference<>(cate.getCount()); |
|
|
|
groupByCode.forEach((k,v) -> { |
|
|
|
if (cate.getCategoryCode().equals(k)){ |
|
|
|
v.forEach(l -> { |
|
|
|
if (l.getCreatedTime().getTime() < end && l.getCreatedTime().getTime() >= start){ |
|
|
|
cate.setCount(count.getAndSet(count.get() + NumConstant.ONE)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
result.add(dto); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 获取固定时间段之间固定时间的集合 |
|
|
@ -2799,7 +2881,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit |
|
|
|
* @author zxc |
|
|
|
* @date 2021/11/22 3:48 下午 |
|
|
|
*/ |
|
|
|
public static List<String> getIntervalTimeList(String start,String end,Integer interval) { |
|
|
|
public List<String> getIntervalTimeList(String start,String end,Integer interval) { |
|
|
|
Date startDate = convertStringToDate("HH:mm", start); |
|
|
|
Date endDate = convertStringToDate("HH:mm", end); |
|
|
|
List<String> list = new ArrayList<>(); |
|
|
@ -2820,11 +2902,12 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit |
|
|
|
} |
|
|
|
list.remove(list.size() - NumConstant.ONE); |
|
|
|
list.add(list.size(),"24:00"); |
|
|
|
list.remove(NumConstant.ZERO); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Date convertStringToDate(String format, String dateStr) { |
|
|
|
public Date convertStringToDate(String format, String dateStr) { |
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); |
|
|
|
try { |
|
|
|
Date date = simpleDateFormat.parse(dateStr); |
|
|
@ -2835,7 +2918,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public static String convertDateToString(String format, Date date) { |
|
|
|
public String convertDateToString(String format, Date date) { |
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); |
|
|
|
return simpleDateFormat.format(date); |
|
|
|
} |
|
|
|