|
@@ -16,6 +16,7 @@ import com.management.platform.entity.*;
|
|
|
import com.management.platform.entity.vo.*;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.*;
|
|
|
+import com.management.platform.task.DataCollectTask;
|
|
|
import com.management.platform.util.*;
|
|
|
import com.management.platform.webservice.po.ProjectQueryResponse;
|
|
|
import com.management.platform.webservice.po.ProjectTask;
|
|
@@ -46,10 +47,13 @@ import org.apache.poi.xssf.usermodel.*;
|
|
|
import org.assertj.core.util.Lists;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.core.ParameterizedTypeReference;
|
|
|
+import org.springframework.http.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -93,6 +97,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
@Resource
|
|
|
ExcelExportService excelExportService;
|
|
|
@Resource
|
|
|
+ private GtemplateTaskMapper gtemplateTaskMapper;
|
|
|
+ @Resource
|
|
|
+ private GroupTmpstagesMapper groupTmpstagesMapper;
|
|
|
+ @Resource
|
|
|
UserCorpwxTimeMapper userCorpwxTimeMapper;
|
|
|
@Resource
|
|
|
private ProjectNotifyUserService projectNotifyUserService;
|
|
@@ -214,7 +222,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
@Resource
|
|
|
TaskGroupService taskGroupService;
|
|
|
@Resource
|
|
|
- GroupTemplateMapper GroupTemplateMapper;
|
|
|
+ GroupTemplateMapper groupTemplateMapper;
|
|
|
@Resource
|
|
|
WxCorpInfoMapper wxCorpInfoMapper;
|
|
|
@Resource
|
|
@@ -14305,6 +14313,153 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return new HttpRespMsg();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void syncHongHuData(int honghuCompId) {
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ String sumUrl = DataCollectTask.PREFIX_URL+"/dataCollect/getSqlServerProjectDataSum";
|
|
|
+ String listUrl = DataCollectTask.PREFIX_URL+"/dataCollect/getSqlServerProjectDataList";
|
|
|
+ Company company = companyMapper.selectById(honghuCompId);
|
|
|
+ try {
|
|
|
+ ResponseEntity<String> sumResponse = restTemplate.exchange(
|
|
|
+ sumUrl,
|
|
|
+ HttpMethod.GET,
|
|
|
+ null,
|
|
|
+ String.class
|
|
|
+ );
|
|
|
+ Integer totalNum = 0;
|
|
|
+ if (sumResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
+ totalNum = Integer.parseInt(sumResponse.getBody());
|
|
|
+ } else {
|
|
|
+ System.out.println("请求失败,状态码: " + sumResponse.getStatusCode());
|
|
|
+ }
|
|
|
+ if(totalNum > 0){
|
|
|
+ int pageSize = 1000;
|
|
|
+ int offset = 0;
|
|
|
+ List<Project> toAddList = new ArrayList<>();
|
|
|
+ List<Project> toUpdateList = new ArrayList<>();
|
|
|
+ while (offset < totalNum) {
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ Map<String, Object> requestBody = new HashMap<>();
|
|
|
+ requestBody.put("pageNo", offset);
|
|
|
+ requestBody.put("pageSize", pageSize);
|
|
|
+ HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
+ ResponseEntity<List<Project>> listResponse = restTemplate.exchange(
|
|
|
+ listUrl,
|
|
|
+ HttpMethod.POST,
|
|
|
+ requestEntity,
|
|
|
+ new ParameterizedTypeReference<List<Project>>(){}
|
|
|
+ );
|
|
|
+ if (listResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
+ List<Project> dataList = listResponse.getBody();
|
|
|
+ if(org.apache.commons.collections.CollectionUtils.isNotEmpty(dataList)){
|
|
|
+ List<String> collect = dataList.stream().map(Project::getProjectCode).distinct().collect(Collectors.toList());
|
|
|
+ List<String> existIds = projectMapper.getExistIds(collect, honghuCompId);
|
|
|
+ if(!org.springframework.util.CollectionUtils.isEmpty(existIds)){
|
|
|
+ toUpdateList.addAll(dataList.stream().filter(t -> existIds.contains(t.getProjectCode())).collect(Collectors.toList()));
|
|
|
+ toAddList.addAll(dataList.stream().filter(t -> !existIds.contains(t.getProjectCode())).collect(Collectors.toList()));
|
|
|
+ }else{
|
|
|
+ toAddList.addAll(dataList);
|
|
|
+ }
|
|
|
+ if(!org.springframework.util.CollectionUtils.isEmpty(toAddList)){
|
|
|
+ for (Project project : toAddList) {
|
|
|
+ //以项目编码前五为作为分类名称
|
|
|
+ String categoryName = project.getProjectCode().substring(0,5);
|
|
|
+ project.setCategoryName(categoryName);
|
|
|
+ ProjectCategory category = projectCategoryMapper.selectOne(new LambdaQueryWrapper<ProjectCategory>()
|
|
|
+ .eq(ProjectCategory::getCompanyId, honghuCompId)
|
|
|
+ .eq(ProjectCategory::getName, project.getCategoryName())
|
|
|
+ .last(" limit 1 ")
|
|
|
+ );
|
|
|
+ int categoryId;
|
|
|
+ if(null != category){
|
|
|
+ categoryId = category.getId();
|
|
|
+ }else{
|
|
|
+ ProjectCategory tmp = new ProjectCategory();
|
|
|
+ tmp.setName(project.getCategoryName());
|
|
|
+ tmp.setCompanyId(honghuCompId);
|
|
|
+ projectCategoryMapper.insert(tmp);
|
|
|
+ categoryId = tmp.getId();
|
|
|
+ }
|
|
|
+ if(0!= categoryId){
|
|
|
+ project.setCategory(categoryId);
|
|
|
+ projectMapper.insert(project);
|
|
|
+ if (company.getPackageProject() == 1) {
|
|
|
+ initGroup(honghuCompId,project.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!org.springframework.util.CollectionUtils.isEmpty(toUpdateList)){
|
|
|
+ updateBatchById(toUpdateList);
|
|
|
+ }
|
|
|
+ toUpdateList.clear();
|
|
|
+ toAddList.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ offset += pageSize;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("请求发生异常: " + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void initGroup(Integer companyId, Integer projectId) {
|
|
|
+ User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getRoleName, "超级管理员")
|
|
|
+ .last(" limit 1")
|
|
|
+ );
|
|
|
+ List<GroupTemplate> groupTemplates = groupTemplateMapper.selectList(new QueryWrapper<GroupTemplate>()
|
|
|
+ .eq("company_id", companyId).eq("cre_with_pro", true));
|
|
|
+ if (groupTemplates.size()==0){
|
|
|
+ //创建默认分组
|
|
|
+ TaskGroup group = new TaskGroup();
|
|
|
+ group.setProjectId(projectId);
|
|
|
+ //group.setName("项目阶段");
|
|
|
+ group.setName(MessageUtils.message("entry.projectStage"));
|
|
|
+ taskGroupMapper.insert(group);
|
|
|
+ }else{
|
|
|
+ for (GroupTemplate groupTemplate : groupTemplates) {
|
|
|
+ TaskGroup group = new TaskGroup();
|
|
|
+ group.setProjectId(projectId);
|
|
|
+ group.setName(groupTemplate.getName());
|
|
|
+ taskGroupMapper.insert(group);
|
|
|
+ //从模板创建任务列表
|
|
|
+ List<GroupTmpstages> stages = groupTmpstagesMapper.selectList(new QueryWrapper<GroupTmpstages>().eq("template_id", groupTemplate.getId()));
|
|
|
+ List<Stages> batchList = new ArrayList<>();
|
|
|
+ stages.forEach(s->{
|
|
|
+ Stages stageItem = new Stages();
|
|
|
+ stageItem.setGroupId(group.getId());
|
|
|
+ stageItem.setStagesName(s.getStagesName());
|
|
|
+ stageItem.setSequence(s.getSequence());
|
|
|
+ stageItem.setProjectId(projectId);
|
|
|
+ batchList.add(stageItem);
|
|
|
+ });
|
|
|
+ stagesService.saveBatch(batchList);
|
|
|
+ //阶段的任务,里程碑,风险
|
|
|
+ List<GtemplateTask> gtemplateTaskList = gtemplateTaskMapper.selectList(
|
|
|
+ new QueryWrapper<GtemplateTask>().eq("gtemplate_id", groupTemplate.getId())
|
|
|
+ .orderByAsc("seq"));
|
|
|
+ if (gtemplateTaskList.size() > 0) {
|
|
|
+ List<Task> taskList = new ArrayList<>();
|
|
|
+ gtemplateTaskList.forEach(gt->{
|
|
|
+ Task task = gt.toTask();
|
|
|
+ task.setProjectId(projectId);
|
|
|
+ task.setGroupId(group.getId());
|
|
|
+ String sName = stages.stream().filter(s->s.getId().equals(gt.getTstagesId())).findFirst().get().getStagesName();
|
|
|
+ Integer realStageId = batchList.stream().filter(bat->bat.getStagesName().equals(sName)).findFirst().get().getId();
|
|
|
+ task.setStagesId(realStageId);
|
|
|
+ task.setCreaterId(user.getId());
|
|
|
+ task.setCreaterName(user.getName());
|
|
|
+ task.setCreatorColor(user.getColor());
|
|
|
+ taskList.add(task);
|
|
|
+ });
|
|
|
+ taskService.saveBatch(taskList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//导出FTE报表数据
|
|
|
@Override
|
|
|
public HttpRespMsg exportFTEData(String monthStart,String monthEnd, String area,Integer departmentId,HttpServletRequest request) {
|