|
|
|
@ -10,11 +10,10 @@ import com.example.yuanzhoutest.util.SnowflakeIdWorker;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class ApproveServiceImpl implements ApproveService {
|
|
|
|
@ -24,6 +23,8 @@ public class ApproveServiceImpl implements ApproveService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private SnowflakeIdWorker snowflakeIdWorker;
|
|
|
|
|
|
|
|
|
|
private String[] coorCodes = new String[]{"0.00", "-0.25", "-0.50", "-0.75", "-1.00", "-1.25", "-1.50", "-1.75", "-2.00", "-2.25"};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<ApproveList> getApproveListByPage(ApproveRequestVO requestVO) {
|
|
|
|
@ -40,6 +41,7 @@ public class ApproveServiceImpl implements ApproveService {
|
|
|
|
|
return approveMapper.getApproveById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<ApproveListDetail> getApproveDetailListById(Long id) {
|
|
|
|
|
List<ApproveListDetail> approveDetailList = approveMapper.getApproveDetailListById(id);
|
|
|
|
|
List<Long> detailIds = approveDetailList.stream().map(v -> v.getId()).collect(Collectors.toList());
|
|
|
|
@ -48,11 +50,37 @@ public class ApproveServiceImpl implements ApproveService {
|
|
|
|
|
Collectors.groupingBy(
|
|
|
|
|
Coordinate::getDetailId, Collectors.mapping(Function.identity(), Collectors.toList())));
|
|
|
|
|
approveDetailList.stream().forEach(v -> {
|
|
|
|
|
v.setCoordinateList(coordinateMap.get(v.getId()));
|
|
|
|
|
List<Coordinate> coordinateList = coordinateMap.get(v.getId());
|
|
|
|
|
List<Coordinate> coordinateListResult = initCoordinate(coordinateList);
|
|
|
|
|
v.setCoordinateList(coordinateListResult);
|
|
|
|
|
});
|
|
|
|
|
return approveDetailList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Coordinate> initCoordinate(List<Coordinate> coordinateList) {
|
|
|
|
|
List<Coordinate> coordinateListAll = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i <= coorCodes.length - 1; i++) {
|
|
|
|
|
for (int t = 0; t <= coorCodes.length - 1; t++) {
|
|
|
|
|
Coordinate coordinate = new Coordinate(coorCodes[i], coorCodes[t]);
|
|
|
|
|
coordinateListAll.add(coordinate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
coordinateListAll.addAll(coordinateList);
|
|
|
|
|
Map<String, List<Coordinate>> coordinateMap = coordinateListAll.stream().collect(Collectors.groupingBy(
|
|
|
|
|
v-> v.getXcode() + v.getYcode(), Collectors.mapping(Function.identity(), Collectors.toList())));
|
|
|
|
|
List<Coordinate> coordinateListResult = coordinateMap.entrySet().stream().map(v -> {
|
|
|
|
|
List<Coordinate> coordinates = v.getValue();
|
|
|
|
|
Coordinate coordinate = coordinates.get(0);
|
|
|
|
|
if (coordinates.size() > 1) {
|
|
|
|
|
coordinate = coordinates.stream().filter(t -> t.getNum() != null).findAny().get();
|
|
|
|
|
}
|
|
|
|
|
return coordinate;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return coordinateListResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long saveApprove(ApproveList approveList) {
|
|
|
|
|
Long id = snowflakeIdWorker.getUUID();
|
|
|
|
|