|
@@ -6,18 +6,31 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.jeecg.common.dto.report.CostAccountingReqDTO;
|
|
|
import org.jeecg.common.dto.report.CostAccountingRespDTO;
|
|
|
import org.jeecg.common.dto.report.ProStatisticsRespDTO;
|
|
|
+import org.jeecg.common.dto.report.ProStatisticsThreeRespDTO;
|
|
|
+import org.jeecg.common.dto.report.ProStatisticsTwoRespDTO;
|
|
|
import org.jeecg.modules.archives.entity.ProjectManageArchives;
|
|
|
import org.jeecg.modules.archives.entity.ProjectManageArchivesAndBusiness;
|
|
|
+import org.jeecg.modules.archives.entity.ProjectManageBusinessOther;
|
|
|
import org.jeecg.modules.archives.service.ProjectManageArchivesAndBusinessService;
|
|
|
import org.jeecg.modules.archives.service.ProjectManageArchivesService;
|
|
|
+import org.jeecg.modules.archives.service.ProjectManageBusinessOtherService;
|
|
|
+import org.jeecg.modules.basedata.service.IBaseArchivesCollectionLineService;
|
|
|
+import org.jeecg.modules.prowork.entity.ProWorkLogic;
|
|
|
+import org.jeecg.modules.prowork.entity.ProWorkMilestone;
|
|
|
+import org.jeecg.modules.prowork.service.ProWorkLogicService;
|
|
|
+import org.jeecg.modules.prowork.service.ProWorkMilestoneService;
|
|
|
+import org.jeecg.modules.report.entity.MeberDepartEnum;
|
|
|
import org.jeecg.modules.report.mapper.ProReportMapper;
|
|
|
import org.jeecg.modules.report.service.ProReportService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
- /**
|
|
|
+/**
|
|
|
* @Author jihaosen
|
|
|
* @date 2021/3/11
|
|
|
*/
|
|
@@ -29,7 +42,14 @@ public class ProReportServiceImpl implements ProReportService {
|
|
|
private ProjectManageArchivesAndBusinessService projectManageArchivesAndBusinessService;
|
|
|
@Autowired
|
|
|
private ProReportMapper proReportMapper;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IBaseArchivesCollectionLineService baseArchivesCollectionLineService;
|
|
|
+ @Autowired
|
|
|
+ private ProjectManageBusinessOtherService projectManageBusinessOtherService;
|
|
|
+ @Autowired
|
|
|
+ private ProWorkLogicService proWorkLogicService;
|
|
|
+ @Autowired
|
|
|
+ private ProWorkMilestoneService proWorkMilestoneService;
|
|
|
/**
|
|
|
* @desc 获取成本核算数据
|
|
|
*/
|
|
@@ -56,21 +76,207 @@ public class ProReportServiceImpl implements ProReportService {
|
|
|
if(StringUtils.isNotBlank(reqDTO.getPkOrg())){
|
|
|
queryWrapper.eq("pk_org", reqDTO.getPkOrg());
|
|
|
}
|
|
|
+ List<ProjectManageArchives> archives = projectManageArchivesService.list(queryWrapper);
|
|
|
+ //获取树形数据
|
|
|
+ return getProStatisticsDatas(archives, reqDTO.getId());
|
|
|
+ }
|
|
|
|
|
|
- ProjectManageArchives projectManageArchives = projectManageArchivesService.getOne(queryWrapper);
|
|
|
+ /**
|
|
|
+ * @desc 获取树形数据
|
|
|
+ */
|
|
|
+ private List<ProStatisticsRespDTO> getProStatisticsDatas( List<ProjectManageArchives> archives, String id) {
|
|
|
+ //获取项目档案里程碑信息表数据
|
|
|
+ List<ProjectManageArchivesAndBusiness> businesses = getBusinessData(id);
|
|
|
+ //项目档案计划信息表Map
|
|
|
+ Map<String, List<ProjectManageArchivesAndBusiness>> businessMap = businesses.stream().collect(Collectors.groupingBy(t -> t.getPlanType()+"&"+t.getPlanId()));
|
|
|
+ //获取收付款条线
|
|
|
+ Map<String, String> CoLineMap = baseArchivesCollectionLineService.getDataMap();
|
|
|
+ //获取项目档案计划信息表数据
|
|
|
+ List<ProjectManageBusinessOther> otherList = projectManageBusinessOtherService.getAll(new ProjectManageBusinessOther(id));
|
|
|
+
|
|
|
+ //项目日志
|
|
|
+ Map<String, List<ProWorkLogic>> logicMap = getProLogic(id);
|
|
|
|
|
|
- List<ProStatisticsRespDTO> respDTOS = getProStatisticsData(projectManageArchives);
|
|
|
- return respDTOS;
|
|
|
+ List<ProStatisticsRespDTO> list = Lists.newArrayList();
|
|
|
+ for(ProjectManageArchives projectManageArchives : archives){
|
|
|
+ ProStatisticsRespDTO respDTO = new ProStatisticsRespDTO(projectManageArchives.getId(), projectManageArchives.getProName(),
|
|
|
+ projectManageArchives.getProCode(), projectManageArchives.getProName(), "0");
|
|
|
+ //配置收付款条线数据
|
|
|
+ setSecondChildren(businesses, respDTO, CoLineMap, otherList, businessMap, logicMap);
|
|
|
+ list.add(respDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
- private List<ProStatisticsRespDTO> getProStatisticsData(ProjectManageArchives projectManageArchives) {
|
|
|
- QueryWrapper<ProjectManageArchivesAndBusiness> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("del_flag", "0")
|
|
|
- .eq("pro_archives_id", projectManageArchives.getId());
|
|
|
- List<ProStatisticsRespDTO> respDTOS = projectManageArchivesService.getBusinessData(queryWrapper);
|
|
|
+ /**
|
|
|
+ * @desc 日志map
|
|
|
+ */
|
|
|
+ private Map<String, List<ProWorkLogic>> getProLogic(String id) {
|
|
|
+ QueryWrapper<ProWorkLogic> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("del_flag", "0");
|
|
|
+ queryWrapper.eq("pro_id", id);
|
|
|
+ queryWrapper.orderByAsc("create_time");
|
|
|
+ List<ProWorkLogic> list = proWorkLogicService.list(queryWrapper);
|
|
|
+ //1.开发 2.实施 3.服务
|
|
|
+ return list.stream().collect(Collectors.groupingBy(t -> t.getType()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc 配置收付款线条数据
|
|
|
+ */
|
|
|
+ private void setSecondChildren(List<ProjectManageArchivesAndBusiness> businesses, ProStatisticsRespDTO respDTO, Map<String, String> CoLineMap,
|
|
|
+ List<ProjectManageBusinessOther> otherList, Map<String, List<ProjectManageArchivesAndBusiness>> otherMap, Map<String, List<ProWorkLogic>> logicMap) {
|
|
|
+ List<ProStatisticsTwoRespDTO> list = Lists.newArrayList();
|
|
|
+ //i: 1代表实施, 2代表开发, 3代表服务
|
|
|
+ for(int i = 1; i <=4 ; i++) {
|
|
|
+ if(!CollectionUtils.isEmpty(businesses)){
|
|
|
+ List<ProjectManageArchivesAndBusiness> businesseses = selectSecondChildren(i, businesses);
|
|
|
+
|
|
|
+ for(ProjectManageArchivesAndBusiness business : businesseses){
|
|
|
+ //只处理收款计划
|
|
|
+ if(business.getPlanType() == 3){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotBlank(business.getMileId1())){
|
|
|
+ ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, MeberDepartEnum.match(i).getName(), respDTO.getId());
|
|
|
+ twoRespDTO.setCoArchivesCode(CoLineMap.get(business.getPlanId()));
|
|
|
+ twoRespDTO.setMileId(business.getMileId1());
|
|
|
+ List<ProjectManageArchivesAndBusiness> others = otherMap.get("3&"+business.getPlanId());
|
|
|
+ if(!CollectionUtils.isEmpty(others)){
|
|
|
+ twoRespDTO.setMileCoPrice(others.get(0).getPrice1());
|
|
|
+ }
|
|
|
+
|
|
|
+ twoRespDTO.setMilePrice(business.getPrice1());
|
|
|
+
|
|
|
+ setThreeChildren(twoRespDTO, otherList, i, logicMap);
|
|
|
+ list.add(twoRespDTO);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(business.getMileId2())){
|
|
|
+ ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, MeberDepartEnum.match(i).getName(), respDTO.getId());
|
|
|
+ twoRespDTO.setCoArchivesCode(CoLineMap.get(business.getPlanId()));
|
|
|
+ twoRespDTO.setMileId(business.getMileId2());
|
|
|
+ List<ProjectManageArchivesAndBusiness> others = otherMap.get("3&"+business.getPlanId());
|
|
|
+ if(!CollectionUtils.isEmpty(others)){
|
|
|
+ twoRespDTO.setMileCoPrice(others.get(0).getPrice2());
|
|
|
+ }
|
|
|
+ setThreeChildren(twoRespDTO, otherList, i, logicMap);
|
|
|
+ list.add(twoRespDTO);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(business.getMileId3())){
|
|
|
+ ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, MeberDepartEnum.match(i).getName(), respDTO.getId());
|
|
|
+ twoRespDTO.setCoArchivesCode(CoLineMap.get(business.getPlanId()));
|
|
|
+ twoRespDTO.setMileId(business.getMileId3());
|
|
|
+ twoRespDTO.setMilePrice(business.getPrice3());
|
|
|
+ List<ProjectManageArchivesAndBusiness> others = otherMap.get("3&"+business.getPlanId());
|
|
|
+ if(!CollectionUtils.isEmpty(others)){
|
|
|
+ twoRespDTO.setMileCoPrice(others.get(0).getPrice3());
|
|
|
+ }
|
|
|
+ setThreeChildren(twoRespDTO, otherList, i, logicMap);
|
|
|
+ list.add(twoRespDTO);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(business.getMileId4())){
|
|
|
+ ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, MeberDepartEnum.match(i).getName(), respDTO.getId());
|
|
|
+ twoRespDTO.setCoArchivesCode(CoLineMap.get(business.getPlanId()));
|
|
|
+ twoRespDTO.setMileId(business.getMileId4());
|
|
|
+ List<ProjectManageArchivesAndBusiness> others = otherMap.get("3&"+business.getPlanId());
|
|
|
+ if(!CollectionUtils.isEmpty(others)) {
|
|
|
+ twoRespDTO.setMileCoPrice(others.get(0).getPrice4());
|
|
|
+ }
|
|
|
+ setThreeChildren(twoRespDTO, otherList, i, logicMap);
|
|
|
+ list.add(twoRespDTO);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(business.getMileId5())){
|
|
|
+ ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, MeberDepartEnum.match(i).getName(), respDTO.getId());
|
|
|
+ twoRespDTO.setCoArchivesCode(CoLineMap.get(business.getPlanId()));
|
|
|
+ twoRespDTO.setMileId(business.getMileId5());
|
|
|
+ twoRespDTO.setMilePrice(business.getPrice5());
|
|
|
+ List<ProjectManageArchivesAndBusiness> others = otherMap.get("3&"+business.getPlanId());
|
|
|
+ if(!CollectionUtils.isEmpty(others)) {
|
|
|
+
|
|
|
+ twoRespDTO.setMileCoPrice(others.get(0).getPrice5());
|
|
|
+ }
|
|
|
+ setThreeChildren(twoRespDTO, otherList, i, logicMap);
|
|
|
+ list.add(twoRespDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- //TODO 待定
|
|
|
- return respDTOS;
|
|
|
+ } else {
|
|
|
+ respDTO.setChildren(null);
|
|
|
+ respDTO.setIsLeaf(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ respDTO.setChildren(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //配置计划信息表的数据
|
|
|
+
|
|
|
+ private void setThreeChildren(ProStatisticsTwoRespDTO twoRespDTO, List<ProjectManageBusinessOther> otherList, int i,
|
|
|
+ Map<String, List<ProWorkLogic>> logicMap) {
|
|
|
+ //计划类型 1.商务 2.实施 3.开发 4.服务
|
|
|
+ ++i;
|
|
|
+ for(ProjectManageBusinessOther other : otherList){
|
|
|
+ if(other.getPlanType() == i && other.getMuilesId().equals(twoRespDTO.getMileId())){
|
|
|
+ ProStatisticsThreeRespDTO threeRespDTO = new ProStatisticsThreeRespDTO(other, twoRespDTO);
|
|
|
+ //获取实际开始时间
|
|
|
+ String planType = choosePlanType(i);
|
|
|
+ List<ProWorkLogic> logics = logicMap.get(planType);
|
|
|
+ if(!CollectionUtils.isEmpty(logics)){
|
|
|
+ threeRespDTO.setMileRealStartDate(logics.get(0).getStartDate());
|
|
|
+ }
|
|
|
+ //TODO 确认单 , 销售发票等
|
|
|
+ } else {
|
|
|
+ twoRespDTO.setLeaf(true);
|
|
|
+ twoRespDTO.setChildren(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc 选择计划类型 1.开发 2.实施 3.服务
|
|
|
+ */
|
|
|
+ private String choosePlanType(int i) {
|
|
|
+ switch(i){
|
|
|
+ //代表实施
|
|
|
+ case 1:
|
|
|
+ return "2";
|
|
|
+ case 2:
|
|
|
+ return "1";
|
|
|
+ case 3:
|
|
|
+ return "3";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据首付款条线获取指定的数据
|
|
|
+ private List<ProjectManageArchivesAndBusiness> selectSecondChildren(int i, List<ProjectManageArchivesAndBusiness> businesses) {
|
|
|
+ switch(i){
|
|
|
+ //代表实施
|
|
|
+ case 1:
|
|
|
+ return businesses.stream().filter(t -> t.getPlanName().indexOf("实施") == -1).collect(Collectors.toList());
|
|
|
+ case 2:
|
|
|
+ return businesses.stream().filter(t -> t.getPlanName().indexOf("开发") == -1).collect(Collectors.toList());
|
|
|
+ case 3:
|
|
|
+ return businesses.stream().filter(t -> t.getPlanName().indexOf("服务") == -1).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc 获取项目档案里程碑信息表数据
|
|
|
+ */
|
|
|
+ private List<ProjectManageArchivesAndBusiness> getBusinessData(String id) {
|
|
|
+ QueryWrapper<ProjectManageArchivesAndBusiness> queryWrapper = new QueryWrapper<>();
|
|
|
+ Integer[] planTypeArr = {1, 2};
|
|
|
+ queryWrapper.eq("del_flag", "0").eq("pro_archives_id", id).in("plan_type", planTypeArr);
|
|
|
+ List<ProjectManageArchivesAndBusiness> list = projectManageArchivesAndBusinessService.list(queryWrapper);
|
|
|
+ return list;
|
|
|
}
|
|
|
}
|
|
|
|