msb_37571 8 months ago
parent 8afb8d4941
commit 520345cccd

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

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

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

@ -10,11 +10,10 @@ import com.example.yuanzhoutest.util.SnowflakeIdWorker;
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 java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service @Service
public class ApproveServiceImpl implements ApproveService { public class ApproveServiceImpl implements ApproveService {
@ -24,6 +23,8 @@ public class ApproveServiceImpl implements ApproveService {
@Autowired @Autowired
private SnowflakeIdWorker snowflakeIdWorker; 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 @Override
public List<ApproveList> getApproveListByPage(ApproveRequestVO requestVO) { public List<ApproveList> getApproveListByPage(ApproveRequestVO requestVO) {
@ -40,6 +41,7 @@ public class ApproveServiceImpl implements ApproveService {
return approveMapper.getApproveById(id); return approveMapper.getApproveById(id);
} }
@Override
public List<ApproveListDetail> getApproveDetailListById(Long id) { public List<ApproveListDetail> getApproveDetailListById(Long id) {
List<ApproveListDetail> approveDetailList = approveMapper.getApproveDetailListById(id); List<ApproveListDetail> approveDetailList = approveMapper.getApproveDetailListById(id);
List<Long> detailIds = approveDetailList.stream().map(v -> v.getId()).collect(Collectors.toList()); List<Long> detailIds = approveDetailList.stream().map(v -> v.getId()).collect(Collectors.toList());
@ -48,11 +50,37 @@ public class ApproveServiceImpl implements ApproveService {
Collectors.groupingBy( Collectors.groupingBy(
Coordinate::getDetailId, Collectors.mapping(Function.identity(), Collectors.toList()))); Coordinate::getDetailId, Collectors.mapping(Function.identity(), Collectors.toList())));
approveDetailList.stream().forEach(v -> { 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; 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 @Override
public Long saveApprove(ApproveList approveList) { public Long saveApprove(ApproveList approveList) {
Long id = snowflakeIdWorker.getUUID(); Long id = snowflakeIdWorker.getUUID();

Loading…
Cancel
Save