|
@@ -1,13 +1,23 @@
|
|
package com.huashe.park.core.service.impl;
|
|
package com.huashe.park.core.service.impl;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import com.huashe.common.utils.StringUtils;
|
|
import com.huashe.park.core.mapper.PileMachineInfoMapper;
|
|
import com.huashe.park.core.mapper.PileMachineInfoMapper;
|
|
|
|
+import com.huashe.park.core.service.IConsUnitInfoService;
|
|
import com.huashe.park.core.service.IPileMachineInfoService;
|
|
import com.huashe.park.core.service.IPileMachineInfoService;
|
|
|
|
+import com.huashe.park.core.service.IProjectCoordinateInfoService;
|
|
|
|
+import com.huashe.park.domain.dto.cons.ConstUnitNode;
|
|
|
|
+import com.huashe.park.domain.entity.ConsUnitInfo;
|
|
import com.huashe.park.domain.entity.PileMachineInfo;
|
|
import com.huashe.park.domain.entity.PileMachineInfo;
|
|
|
|
+import com.huashe.park.domain.entity.ProjectCoordinateInfo;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 施工桩机信息Service业务层处理
|
|
* 施工桩机信息Service业务层处理
|
|
@@ -20,6 +30,12 @@ public class PileMachineInfoServiceImpl implements IPileMachineInfoService {
|
|
@Autowired
|
|
@Autowired
|
|
private PileMachineInfoMapper pileMachineInfoMapper;
|
|
private PileMachineInfoMapper pileMachineInfoMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IConsUnitInfoService consUnitInfoService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IProjectCoordinateInfoService projectCoordinateInfoService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询施工桩机信息
|
|
* 查询施工桩机信息
|
|
*
|
|
*
|
|
@@ -87,4 +103,65 @@ public class PileMachineInfoServiceImpl implements IPileMachineInfoService {
|
|
public int deletePileMachineInfoById(Long id) {
|
|
public int deletePileMachineInfoById(Long id) {
|
|
return pileMachineInfoMapper.deletePileMachineInfoById(id);
|
|
return pileMachineInfoMapper.deletePileMachineInfoById(id);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<ConstUnitNode> qryMachineAssignedUnit(Long machineId) {
|
|
|
|
+ List<ConsUnitInfo> consUnitInfos = consUnitInfoService.machineAssignedUnit(machineId);
|
|
|
|
+ List<ProjectCoordinateInfo> projectCoordinateInfos = projectCoordinateInfoService
|
|
|
|
+ .selectProjectCoordinateInfoList(new ProjectCoordinateInfo());
|
|
|
|
+ ProjectCoordinateInfo projectCoordinateInfo = projectCoordinateInfos.get(0);
|
|
|
|
+ // 将 consUnitInfos 使用BeanUtils将子类转换成ConstUnitNode
|
|
|
|
+ List<ConstUnitNode> constUnitNodes = new ArrayList<>();
|
|
|
|
+ consUnitInfos.forEach((item) -> {
|
|
|
|
+ ConstUnitNode constUnitNode = new ConstUnitNode();
|
|
|
|
+ BeanUtils.copyProperties(item, constUnitNode);
|
|
|
|
+ constUnitNodes.add(constUnitNode);
|
|
|
|
+ });
|
|
|
|
+ List<ConstUnitNode> tree = buildConsUnitTree(constUnitNodes);
|
|
|
|
+ tree.forEach(item -> item.setCoordinateModel(projectCoordinateInfo));
|
|
|
|
+ return tree;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<ConstUnitNode> buildConsUnitTree(List<ConstUnitNode> consUnitInfos) {
|
|
|
|
+ List<ConstUnitNode> returnList = new ArrayList<>();
|
|
|
|
+ List<Long> tempList = consUnitInfos.stream().map(ConstUnitNode::getId).collect(Collectors.toList());
|
|
|
|
+ for (ConstUnitNode dept : consUnitInfos) {
|
|
|
|
+ // 如果是顶级节点, 遍历该父节点的所有子节点
|
|
|
|
+ if (!tempList.contains(dept.getParentId())) {
|
|
|
|
+ recursionFn(consUnitInfos, dept);
|
|
|
|
+ returnList.add(dept);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (returnList.isEmpty()) {
|
|
|
|
+ returnList = consUnitInfos;
|
|
|
|
+ }
|
|
|
|
+ return returnList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void recursionFn(List<ConstUnitNode> list, ConstUnitNode t) {
|
|
|
|
+ // 得到子节点列表
|
|
|
|
+ List<ConstUnitNode> childList = getChildList(list, t);
|
|
|
|
+ t.setChild(childList);
|
|
|
|
+ for (ConstUnitNode tChild : childList) {
|
|
|
|
+ if (hasChild(list, tChild)) {
|
|
|
|
+ recursionFn(list, tChild);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<ConstUnitNode> getChildList(List<ConstUnitNode> list, ConstUnitNode t) {
|
|
|
|
+ List<ConstUnitNode> tlist = new ArrayList<>();
|
|
|
|
+ Iterator<ConstUnitNode> it = list.iterator();
|
|
|
|
+ while (it.hasNext()) {
|
|
|
|
+ ConstUnitNode n = it.next();
|
|
|
|
+ if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue()) {
|
|
|
|
+ tlist.add(n);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return tlist;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean hasChild(List<ConstUnitNode> list, ConstUnitNode t) {
|
|
|
|
+ return !getChildList(list, t).isEmpty();
|
|
|
|
+ }
|
|
}
|
|
}
|