|
@@ -36,20 +36,13 @@ import org.springblade.meter.service.IContractInventoryFormService;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.meter.service.IInventoryFormMeterService;
|
|
import org.springblade.meter.service.IInventoryFormMeterService;
|
|
import org.springblade.meter.utils.ForestNodeMerger;
|
|
import org.springblade.meter.utils.ForestNodeMerger;
|
|
-import org.springblade.meter.vo.ContractFromVO;
|
|
|
|
-import org.springblade.meter.vo.ContractInventoryFormVO;
|
|
|
|
-import org.springblade.meter.vo.ContractInventoryFormVO2;
|
|
|
|
-import org.springblade.meter.vo.FormTreeVO;
|
|
|
|
-import org.springblade.meter.vo.InventoryFormDetailVO;
|
|
|
|
|
|
+import org.springblade.meter.vo.*;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -616,12 +609,36 @@ public class ContractInventoryFormServiceImpl extends BaseServiceImpl<ContractIn
|
|
@Override
|
|
@Override
|
|
public List<ContractFromVO> getNodeResolveForm(Long contractId, Long id) {
|
|
public List<ContractFromVO> getNodeResolveForm(Long contractId, Long id) {
|
|
List<ContractFromVO> vos = baseMapper.getNodeResolveForm(contractId, id);
|
|
List<ContractFromVO> vos = baseMapper.getNodeResolveForm(contractId, id);
|
|
|
|
+ if (vos.size() > 1){
|
|
|
|
+ Map<String, ContractFromVO> map = vos.stream().collect(Collectors.toMap(ContractFromVO::getFormNumber, l -> l));
|
|
|
|
+ List<String> list = this.getAllFormNumberBySort(contractId);
|
|
|
|
+ for (String s : map.keySet()) {
|
|
|
|
+ ContractFromVO vo = map.get(s);
|
|
|
|
+ vo.setSort(list.indexOf(s));
|
|
|
|
+ }
|
|
|
|
+ vos = vos.stream().sorted(Comparator.comparingInt(ContractFromVO::getSort)).collect(Collectors.toList());
|
|
|
|
+ }
|
|
for (ContractFromVO vo : vos) {
|
|
for (ContractFromVO vo : vos) {
|
|
vo.setResidueNum(vo.getChangeTotal().subtract(vo.getPoseNum()));
|
|
vo.setResidueNum(vo.getChangeTotal().subtract(vo.getPoseNum()));
|
|
}
|
|
}
|
|
return vos;
|
|
return vos;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<String> getAllFormNumberBySort(Long contractId) {
|
|
|
|
+ List<FormNodeSortVO> vos = baseMapper.getAllForm(contractId);
|
|
|
|
+ Long l1 = System.currentTimeMillis();
|
|
|
|
+ List<FormNodeSortVO> list = ForestNodeMerger.merge(vos);
|
|
|
|
+ Long l2 = System.currentTimeMillis();
|
|
|
|
+ System.out.println(l2-l1);
|
|
|
|
+ List<String> forms = new ArrayList<>();
|
|
|
|
+ Long l3 = System.currentTimeMillis();
|
|
|
|
+ gatherSortNode(list,forms);
|
|
|
|
+ Long l4 = System.currentTimeMillis();
|
|
|
|
+ System.out.println(l4-l3);
|
|
|
|
+ return forms;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 判断当前清单是否已经分解或变更过,变更过返回true
|
|
* 判断当前清单是否已经分解或变更过,变更过返回true
|
|
*/
|
|
*/
|
|
@@ -642,5 +659,17 @@ public class ContractInventoryFormServiceImpl extends BaseServiceImpl<ContractIn
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //递归方法
|
|
|
|
+ private void gatherSortNode(List<FormNodeSortVO> list, List<String> forms){
|
|
|
|
+ for (FormNodeSortVO vo : list) {
|
|
|
|
+ if (vo.getChildren().size() == 0 && StringUtils.isNotBlank(vo.getFormNumber())){
|
|
|
|
+ forms.add(vo.getFormNumber());
|
|
|
|
+ continue;
|
|
|
|
+ }else {
|
|
|
|
+ gatherSortNode(vo.getChildren(), forms);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|