msb_37571 8 months ago
parent 8afb8d4941
commit 520345cccd

@ -19,6 +19,17 @@ public class ApproveListDetail {
private String model;
private String twoDmodel;
private String qualityRequire;
/**
*
*/
private String supplierCode;
/**
*
*/
private String supplierName;
private String remark;
private Long num;
private List<Coordinate> coordinateList;
}

@ -13,4 +13,11 @@ public class Coordinate {
private Boolean isTotal;
private Long num;
public Coordinate(String xcode, String ycode) {
this.xcode = xcode;
this.ycode = ycode;
}
public Coordinate() {
}
}

@ -186,8 +186,8 @@
num,
remark)
values
<foreach item="param" index="index" collection="approveDetailList" open="(" close=")" separator=",">
#{param.id},
<foreach item="param" index="index" collection="approveDetailList" separator=",">
(#{param.id},
#{param.approveId},
#{param.inventionId},
#{param.inventionCode},
@ -199,7 +199,7 @@
#{param.supplierCode},
#{param.supplierName},
#{param.num},
#{param.remark}
#{param.remark})
</foreach>
</insert>
@ -213,12 +213,12 @@
ycode,
num)
values
<foreach item="param" index="index" collection="coordinateList" open="(" close=")" separator=",">
#{param.id},
<foreach item="param" index="index" collection="coordinateList" separator=",">
(#{param.id},
#{param.detailId},
#{param.xcode},
#{param.ycode},
#{param.num}
#{param.num})
</foreach>
</insert>
</mapper>

@ -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();

Loading…
Cancel
Save