Browse Source

Merge remote-tracking branch 'remotes/origin/dev'

master
jianjun 4 years ago
parent
commit
9ed1518d85
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/distributedlock/DistributedLock.java
  2. 6
      epmet-gateway/src/main/java/com/epmet/GatewayApplication.java
  3. 21
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  4. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridAndOrgDailyServiceImpl.java
  5. 205
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java
  6. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/BaseReportServiceImpl.java
  7. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/distributedlock/DistributedLock.java

@ -18,7 +18,7 @@ import java.util.concurrent.TimeUnit;
@Component
public class DistributedLock {
@Autowired
@Autowired(required = false)
private RedissonClient redissonClient;
/**

6
epmet-gateway/src/main/java/com/epmet/GatewayApplication.java

@ -9,9 +9,9 @@
package com.epmet;
import com.epmet.commons.tools.aspect.ServletExceptionHandler;
import com.epmet.commons.tools.config.RedissonConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
@ -23,11 +23,11 @@ import org.springframework.context.annotation.FilterType;
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@SpringBootApplication()
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
//@ServletComponentScan
@ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {ServletExceptionHandler.class}))
@ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RedissonConfig.class, ServletExceptionHandler.class}))
public class GatewayApplication {
public static void main(String[] args) {

21
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java

@ -1231,35 +1231,28 @@ public class DataStatsServiceImpl implements DataStatsService {
}
//1.查询当前组织的直属下级组织信息【机关维度】
List<DimAgencyEntity> subAgencyList = dataStatsDao.getSubAgencyList(formDTO.getAgencyId());
List<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), null);
if (subAgencyList.size() < NumConstant.ONE) {
return resultList;
}
List<String> agencyIds = subAgencyList.stream().map(DimAgencyEntity::getId).collect(Collectors.toList());
List<String> agencyIds = subAgencyList.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList());
ScreenCustomerAgencyDTO agencyDTO = indexService.getAgencyInfo(formDTO.getAgencyId());
if (CollectionUtils.isNotEmpty(customerRelation.haveSubCustomer(agencyDTO.getCustomerId()))) {
List<ScreenCustomerAgencyDTO> subAgencies = indexService.getSubAgencyList(formDTO.getAgencyId(), agencyDTO.getAreaCode());
agencyIds = subAgencies.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList());
subAgencyList = subAgencies.stream().map(item -> {
DimAgencyEntity entity = new DimAgencyEntity();
entity.setId(item.getAgencyId());
entity.setAgencyName(item.getAgencyName());
entity.setLevel(item.getLevel());
return entity;
}).collect(Collectors.toList());
subAgencyList = indexService.getSubAgencyList(formDTO.getAgencyId(), agencyDTO.getAreaCode());
agencyIds = subAgencyList.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList());
}
//2.按日期查询所有下级组织的事件治理指数
List<AgencyGovrnResultDTO> list = dataStatsDao.getAgencyGovern(agencyIds, formDTO.getDateId());
//3.封装数据
for (DimAgencyEntity sub : subAgencyList) {
for (ScreenCustomerAgencyDTO sub : subAgencyList) {
AgencyGovrnResultDTO dto = new AgencyGovrnResultDTO();
dto.setAgencyId(sub.getId());
dto.setAgencyId(sub.getAgencyId());
dto.setAgencyName(sub.getAgencyName());
dto.setLevel(sub.getLevel());
for (AgencyGovrnResultDTO re : list) {
if (sub.getId().equals(re.getAgencyId())) {
if (sub.getAgencyId().equals(re.getAgencyId())) {
dto.setProblemResolvedCount(re.getProblemResolvedCount());
dto.setGroupSelfGovernRatio(re.getGroupSelfGovernRatio());
dto.setGridSelfGovernRatio(re.getGridSelfGovernRatio());

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridAndOrgDailyServiceImpl.java

@ -148,6 +148,9 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr
if (CollectionUtils.isEmpty(relationInfo)){
// one customer
List<ScreenProjectOrgDailyDTO> agencies = screenCustomerAgencyDao.selectAgencyByCustomer(customerId);
if (CollectionUtils.isEmpty(agencies)){
return;
}
List<GridAndOrgCategoryCountResultDTO> allAgencies = ConvertUtils.sourceToTarget(agencies, GridAndOrgCategoryCountResultDTO.class);
result = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies);

205
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java

@ -33,11 +33,11 @@ import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectImgDataDao;
import com.epmet.dto.screen.ScreenProjectDataDTO;
import com.epmet.dto.screen.ScreenProjectImgDataDTO;
import com.epmet.dto.screen.form.ScreenProjectDataInfoFormDTO;
import com.epmet.dto.screencoll.ScreenCollFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectImgDataEntity;
import com.epmet.entity.stats.CustomerProjectCategoryDictEntity;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
@ -47,6 +47,7 @@ import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryService;
import com.epmet.service.evaluationindex.screen.ScreenProjectDataService;
import com.epmet.service.stats.CustomerProjectCategoryDictService;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
@ -56,7 +57,6 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -66,6 +66,7 @@ import java.util.stream.Collectors;
* @author qu qu@elink-cn.com
* @since v1.0.0 2021-02-23
*/
@Slf4j
@Service
@DataSource(value = DataSourceConstant.EVALUATION_INDEX)
public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectDataDao, ScreenProjectDataEntity> implements ScreenProjectDataService {
@ -136,76 +137,13 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
}
@Override
@Transactional(rollbackFor = Exception.class)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
public void collect(ScreenCollFormDTO<ScreenProjectDataInfoFormDTO> param) {
/*if (param.getIsFirst()) {
int affectedRows = baseDao.deleteByDateIdAndCustomerId(param.getCustomerId(), param.getDateId());
while (affectedRows > 0) {
affectedRows = baseDao.deleteByDateIdAndCustomerId(param.getCustomerId(), param.getDateId());
}
}*/
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date today = new Date();
List<ScreenProjectDataEntity> projectList = new ArrayList<>();
param.getDataList().forEach(item -> {
String projectStatusCode = item.getProjectStatusCode();
//2021.3.8 epmet中,调用方传level,这边不再计算
if(item.getProjectLevel() == null){
//todo 动态获取超时时间
//如果结案 结案时间立项时间;
if ("closed_case".equals(projectStatusCode)) {
Date createTime = item.getProjectCreateTime();
Date closeCaseTime = item.getCloseCaseTime();
if (closeCaseTime.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 4) {
//如果结案时间-立项时间小于等于4天 未超期 level3
item.setProjectLevel(3);
} else if (closeCaseTime.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 5) {
//如果结案时间-立项时间大于4天小于5天 即将超期 level2
item.setProjectLevel(2);
} else {
//大于5天 已超期 level1
item.setProjectLevel(1);
}
} else if ("pending".equals(projectStatusCode)) {
//如果处理中 当前时间-立项时间;
Date createTime = item.getProjectCreateTime();
if (today.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 4) {
//如果当前时间-立项时间小于等于4天 未超期 level3
item.setProjectLevel(3);
} else if (today.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 5) {
//如果当前时间-立项时间大于4天小于5天 即将超期 level2
item.setProjectLevel(2);
} else {
//大于5天 已超期 level1
item.setProjectLevel(1);
}
}
}
//先删除该projectId对应的旧数据
baseDao.deleteByProjectId(param.getCustomerId(), item.getProjectId());
screenProjectImgDataDao.deleteByProjectId(param.getCustomerId(), item.getProjectId());
//如果orgType未知,获取一下
// if ("unknown".equals(item.getOrgType())){
// ScreenCustomerAgencyEntity screenCustomerAgencyEntity = agencyDao.selectById(item.getOrgId());
// if (screenCustomerAgencyEntity != null){
// item.setOrgType("agency");
// }else {
// ScreenCustomerDeptEntity screenCustomerDeptEntity = deptDao.selectById(item.getOrgId());
// if (screenCustomerDeptEntity!=null){
// item.setOrgType("department");
// }else {
// ScreenCustomerGridEntity screenCustomerGridEntity = gridDao.selectById(item.getOrgId());
// if (screenCustomerGridEntity != null){
// item.setOrgType("grid");
// }
// }
// }
// }
setLevelByCreateTime(item, projectStatusCode);
//插入项目表
ScreenProjectDataEntity screenProjectDataEntity = ConvertUtils.sourceToTarget(item, ScreenProjectDataEntity.class);
@ -215,23 +153,67 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
if(StringUtils.isNotBlank(agencyId)) {
screenProjectDataEntity.setAllParentIds(agencyId.concat(StrConstant.COMMA).concat(screenProjectDataEntity.getAllParentIds()));
}
baseDao.insert(screenProjectDataEntity);
projectList.add(screenProjectDataEntity);
//插入图片表
String[] projectImgUrl = item.getProjectImgUrl();
if (ArrayUtils.isNotEmpty(projectImgUrl)) {
for (int i = 0; i < projectImgUrl.length; i++) {
ScreenProjectImgDataEntity screenProjectImgDataEntity = new ScreenProjectImgDataEntity();
screenProjectImgDataEntity.setCustomerId(param.getCustomerId());
screenProjectImgDataEntity.setProjectId(item.getProjectId());
screenProjectImgDataEntity.setProjectImgUrl(projectImgUrl[i]);
screenProjectImgDataEntity.setSort(i);
screenProjectImgDataDao.insert(screenProjectImgDataEntity);
}
}
//删除 并插入新的项目数据
delAndInsertProjectData(param, item, screenProjectDataEntity);
});
}
@Transactional(rollbackFor = Exception.class)
public void delAndInsertProjectData(ScreenCollFormDTO<ScreenProjectDataInfoFormDTO> param, ScreenProjectDataInfoFormDTO item, ScreenProjectDataEntity screenProjectDataEntity) {
//先删除该projectId对应的旧数据
baseDao.deleteByProjectId(param.getCustomerId(), item.getProjectId());
screenProjectImgDataDao.deleteByProjectId(param.getCustomerId(), item.getProjectId());
baseDao.insert(screenProjectDataEntity);
saveCategory(param.getCustomerId(), Collections.singletonList(screenProjectDataEntity))
//插入该项目图片表
String[] projectImgUrl = item.getProjectImgUrl();
if (ArrayUtils.isNotEmpty(projectImgUrl)) {
List<ScreenProjectImgDataDTO> imgList = new ArrayList<>();
for (int i = 0; i < projectImgUrl.length; i++) {
ScreenProjectImgDataDTO screenProjectImgDataEntity = new ScreenProjectImgDataDTO();
screenProjectImgDataEntity.setCustomerId(param.getCustomerId());
screenProjectImgDataEntity.setProjectId(item.getProjectId());
screenProjectImgDataEntity.setProjectImgUrl(projectImgUrl[i]);
screenProjectImgDataEntity.setSort(i);
imgList.add(screenProjectImgDataEntity)
}
screenProjectImgDataDao.insertBatch(imgList);
}
}
saveCategory(param.getCustomerId(), projectList);
private void setLevelByCreateTime(ScreenProjectDataInfoFormDTO item, String projectStatusCode) {
if(item.getProjectLevel() == null){
//todo 动态获取超时时间
//如果结案 结案时间立项时间;
if ("closed_case".equals(projectStatusCode)) {
Date createTime = item.getProjectCreateTime();
Date closeCaseTime = item.getCloseCaseTime();
if (closeCaseTime.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 4L) {
//如果结案时间-立项时间小于等于4天 未超期 level3
item.setProjectLevel(3);
} else if (closeCaseTime.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 5L) {
//如果结案时间-立项时间大于4天小于5天 即将超期 level2
item.setProjectLevel(2);
} else {
//大于5天 已超期 level1
item.setProjectLevel(1);
}
} else if ("pending".equals(projectStatusCode)) {
//如果处理中 当前时间-立项时间;
Date createTime = item.getProjectCreateTime();
Date today = new Date();
if (today.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 4L) {
//如果当前时间-立项时间小于等于4天 未超期 level3
item.setProjectLevel(3);
} else if (today.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 5L) {
//如果当前时间-立项时间大于4天小于5天 即将超期 level2
item.setProjectLevel(2);
} else {
//大于5天 已超期 level1
item.setProjectLevel(1);
}
}
}
}
@ -278,7 +260,7 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
//复采集时数不会重复
if(!CollectionUtils.isEmpty(meta)){
int affectedRows = baseDao.deleteByProjectTimeAndCustomerId(customerId,dateId);
while (affectedRows > 0) {
while (affectedRows > NumConstant.ZERO) {
affectedRows = baseDao.deleteByProjectTimeAndCustomerId(customerId, dateId);
}
List<List<ScreenProjectDataDTO>> partition = ListUtils.partition(meta, NumConstant.ONE_HUNDRED);
@ -359,32 +341,43 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
List<ScreenProjectCategoryEntity> projectCategoryList = new ArrayList<>();
projectList.forEach(project -> {
//分类为空不作处理
if (StringUtils.isNotBlank(project.getCategoryCode())) {
List<String> categoryList = Arrays.asList(project.getCategoryCode().split(StrConstant.COMMA));
categoryList.forEach(category -> {
ScreenProjectCategoryEntity entity = new ScreenProjectCategoryEntity();
entity.setCustomerId(customerId);
entity.setProjectId(project.getProjectId());
entity.setOriginCategoryCode(category);
CustomerProjectCategoryDictEntity categoryEntity = customerProjectCategoryDictService.getByCategoryCode(customerId, category);
if (null != categoryEntity) {
//
if ("external".equals(categoryEntity.getCustomerType())) {
entity.setCategoryCode(categoryEntity.getEpmetCategoryCode());
CustomerProjectCategoryDictEntity parent = customerProjectCategoryDictService.getByCategoryCode(parentCustomer.getData(), categoryEntity.getEpmetCategoryCode());
entity.setParentCategoryCode(parent.getParentCategoryCode());
entity.setLevel(parent.getLevel());
} else {
entity.setCategoryCode(categoryEntity.getCategoryCode());
entity.setParentCategoryCode(categoryEntity.getParentCategoryCode());
entity.setLevel(categoryEntity.getLevel());
}
}
projectCategoryList.add(entity);
});
if (StringUtils.isBlank(project.getCategoryCode())) {
return;
}
List<String> categoryList = Arrays.asList(project.getCategoryCode().split(StrConstant.COMMA));
categoryList.forEach(category -> {
ScreenProjectCategoryEntity entity = new ScreenProjectCategoryEntity();
entity.setCustomerId(customerId);
entity.setProjectId(project.getProjectId());
entity.setOriginCategoryCode(category);
CustomerProjectCategoryDictEntity categoryEntity = customerProjectCategoryDictService.getByCategoryCode(customerId, category);
if (null != categoryEntity) {
log.error("customerId:{} categoryCode:{} is not exist in ProjectCategoryDict", customerId, category);
return;
}
if ("external".equals(categoryEntity.getCustomerType())) {
entity.setCategoryCode(categoryEntity.getEpmetCategoryCode());
CustomerProjectCategoryDictEntity parent = customerProjectCategoryDictService.getByCategoryCode(parentCustomer.getData(), categoryEntity.getEpmetCategoryCode());
entity.setParentCategoryCode(parent.getParentCategoryCode());
entity.setLevel(parent.getLevel());
} else {
entity.setCategoryCode(categoryEntity.getCategoryCode());
entity.setParentCategoryCode(categoryEntity.getParentCategoryCode());
entity.setLevel(categoryEntity.getLevel());
}
projectCategoryList.add(entity);
//如果分类数据已经超过100了 就插入一批
if (projectCategoryList.size() > NumConstant.ONE_HUNDRED){
screenProjectCategoryService.insertBatch(projectCategoryList);
projectCategoryList.clear();
}
});
});
screenProjectCategoryService.insertBatch(projectCategoryList);
//如果不为空 则插入剩余的那一部分
if (projectCategoryList.size() > NumConstant.ZERO){
screenProjectCategoryService.insertBatch(projectCategoryList);
}
}
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/BaseReportServiceImpl.java

@ -1,7 +1,6 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.constant.BaseReportConstant;
import com.epmet.dao.stats.BaseReportDao;
import com.epmet.dto.basereport.form.*;
import com.epmet.service.BaseReportService;
@ -60,7 +59,8 @@ public class BaseReportServiceImpl implements BaseReportService {
} while (deleteNum > NumConstant.ZERO);
}
if (!CollectionUtils.isEmpty(formDTO.getDataList())) {
baseReportDao.insertBatchAgencyRegUser(formDTO.getDataList());
ListUtils.partition(formDTO.getDataList(),NumConstant.ONE_HUNDRED)
.forEach(part->baseReportDao.insertBatchAgencyRegUser(part);
}
}

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml

@ -88,6 +88,7 @@
WHERE
CG.CUSTOMER_ID =#{customerId}
and cg.del_flag='0'
AND cg.SYNC_FLAG = '1'
</select>
<select id="getCustomerStaffGridList" resultType="com.epmet.dto.org.CustomerStaffGridDTO">
SELECT

Loading…
Cancel
Save