|
@@ -33,7 +33,6 @@ import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.net.URL;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -56,15 +55,14 @@ public class AchievementServiceImpl implements AchievementService {
|
|
|
@Resource
|
|
|
private SiteInfoMapper siteInfoMapper;
|
|
|
|
|
|
- @Resource
|
|
|
- private BerthingPointMapper berthingPointMapper;
|
|
|
-
|
|
|
@Resource
|
|
|
private SiteService siteService;
|
|
|
|
|
|
@Autowired
|
|
|
private BerthingPointConfigMapper berthingPointConfigMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MeasureUploadMapper measureUploadMapper;
|
|
|
|
|
|
@Override
|
|
|
public Page<TaskResult> queryAchievement(AchievementQuery achievementQuery){
|
|
@@ -118,21 +116,29 @@ public class AchievementServiceImpl implements AchievementService {
|
|
|
if (siteConfig == null){
|
|
|
throw new BaseException("该站点配置不存在");
|
|
|
}
|
|
|
-
|
|
|
//拿断面数据
|
|
|
- BerthingPoint berthingPoint = berthingPointMapper.queryById(taskResult.getBerthingId());
|
|
|
- if (berthingPoint == null){
|
|
|
- throw new BaseException("断面不存在");
|
|
|
- }
|
|
|
+// BerthingPoint berthingPoint = berthingPointMapper.queryById(taskResult.getBerthingId());
|
|
|
+// if (berthingPoint == null){
|
|
|
+// throw new BaseException("断面不存在");
|
|
|
+// }
|
|
|
//拿停泊点数据
|
|
|
BerthingPointConfig berthingPointConfig = berthingPointConfigMapper.queryById(taskResult.getStopId());
|
|
|
if (berthingPointConfig == null){
|
|
|
throw new BaseException("停泊点配置不存在");
|
|
|
}
|
|
|
|
|
|
+ //拿有水位的启点距和高程
|
|
|
+ List<BigDecimal> positionsList = JSONUtil.toList(taskResult.getPositions(), BigDecimal.class);
|
|
|
+ List<BigDecimal> elevationsList = JSONUtil.toList(taskResult.getElevations(), BigDecimal.class);
|
|
|
+ if (positionsList.size() < 5){
|
|
|
+ throw new BaseException("启点距少于5个不支持导出");
|
|
|
+ } else if (positionsList.size() > 50){
|
|
|
+ throw new BaseException("启点距大于50个点暂不支持导出");
|
|
|
+ }
|
|
|
+
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
// 模版文件
|
|
|
- ClassPathResource classPathResource = new ClassPathResource("excel/test.xlsx");
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource(String.format("excel/test%s.xlsx", positionsList.size()));
|
|
|
InputStream inputStream = classPathResource.getStream();
|
|
|
excelWriter = EasyExcel.write(outputStream).withTemplate(inputStream).excelType(ExcelTypeEnum.XLSX).autoCloseStream(Boolean.FALSE).build();
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
|
@@ -166,12 +172,11 @@ public class AchievementServiceImpl implements AchievementService {
|
|
|
excelWriter.fill(map, writeSheet);
|
|
|
|
|
|
//拿断面数据
|
|
|
- List<PrintExcelDTO> positionsList = JSONUtil.toList(berthingPoint.getPositions(), PrintExcelDTO.class);
|
|
|
+ List<PrintExcelDTO> berthingPointList = JSONUtil.toList(berthingPointConfig.getPositions(), PrintExcelDTO.class);
|
|
|
+
|
|
|
//组装列表
|
|
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
List<Map<String, Object>> pgList = new ArrayList<>();
|
|
|
- List<Double> taskX = JSONUtil.toList(taskResult.getPositions(), Double.class);
|
|
|
- List<Double> taskY = JSONUtil.toList(taskResult.getElevations(), Double.class);
|
|
|
List<String> pointConfigfactors = JSONUtil.toList(berthingPointConfig.getFactors(), String.class);
|
|
|
List<String> taskWspeeds = JSONUtil.toList(taskResult.getWspeeds(), String.class);
|
|
|
List<String> taskStopwspeeds = JSONUtil.toList(taskResult.getStopwspeeds(), String.class);
|
|
@@ -179,6 +184,9 @@ public class AchievementServiceImpl implements AchievementService {
|
|
|
List<String> acreages = JSONUtil.toList(taskResult.getAcreages(), String.class);
|
|
|
List<String> taskFlows = JSONUtil.toList(taskResult.getFlows(), String.class);
|
|
|
|
|
|
+ //查询任务时间
|
|
|
+ List<MeasureUpload> measureUploadList = measureUploadMapper.queryBySiteIdTime(taskResult.getSiteId(), null , taskResult.getTaskid());
|
|
|
+
|
|
|
int pnIndex = 0;
|
|
|
for (int i = 0; i < positionsList.size(); i++) {
|
|
|
Map<String, Object> data = MapUtils.newHashMap();
|
|
@@ -191,18 +199,36 @@ public class AchievementServiceImpl implements AchievementService {
|
|
|
} else {
|
|
|
data.put("index", String.valueOf(i));
|
|
|
}
|
|
|
- data.put("x", positionsList.get(i).getX().toString());
|
|
|
- data.put("y", positionsList.get(i).getY().toString());
|
|
|
+ data.put("x", positionsList.get(i).toString());
|
|
|
+ data.put("y", elevationsList.get(i).toString());
|
|
|
data.put("waterlevel",taskResult.getWaterlevel());
|
|
|
- data.put("subWlevel",BigDecimal.valueOf(taskResult.getWaterlevel()).subtract(BigDecimal.valueOf(positionsList.get(i).getY())));
|
|
|
+ data.put("subWlevel",BigDecimal.valueOf(taskResult.getWaterlevel()).subtract(elevationsList.get(i)));
|
|
|
|
|
|
- if (pnIndex < taskX.size()) {
|
|
|
- if (taskX.get(pnIndex).equals(positionsList.get(i).getX()) && taskY.get(pnIndex).equals(positionsList.get(i).getY())) {
|
|
|
+ if (pnIndex < berthingPointList.size()) {
|
|
|
+ BigDecimal position = positionsList.get(i).setScale(4, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal berthingPoint = new BigDecimal(String.valueOf(berthingPointList.get(pnIndex).getX())).setScale(4, RoundingMode.HALF_UP);
|
|
|
+ if (position.equals(berthingPoint)) {
|
|
|
data.put("speed", String.valueOf(pnIndex + 1));
|
|
|
- data.put("time", "12:00");
|
|
|
+ if (pnIndex <= measureUploadList.size() - 1) {
|
|
|
+ data.put("time", measureUploadList.get(pnIndex).getCreateTime());
|
|
|
+ } else {
|
|
|
+ data.put("time", "");
|
|
|
+ }
|
|
|
data.put("factors", pointConfigfactors.get(pnIndex));
|
|
|
- data.put("wspeeds", taskWspeeds.get(pnIndex));
|
|
|
- data.put("stopwspeeds", taskStopwspeeds.get(pnIndex));
|
|
|
+ if (pnIndex < taskFlows.size()) {
|
|
|
+ if (pnIndex < taskWspeeds.size()) {
|
|
|
+ data.put("wspeeds", taskWspeeds.get(pnIndex));
|
|
|
+ } else {
|
|
|
+ data.put("wspeeds", "");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data.put("wspeeds", "");
|
|
|
+ }
|
|
|
+ if (pnIndex < tasKPartwspeeds.size()) {
|
|
|
+ data.put("partwspeeds", tasKPartwspeeds.get(pnIndex));
|
|
|
+ } else {
|
|
|
+ data.put("partwspeeds", "");
|
|
|
+ }
|
|
|
pnIndex = pnIndex + 1;
|
|
|
} else {
|
|
|
data.put("speed", "");
|
|
@@ -225,9 +251,15 @@ public class AchievementServiceImpl implements AchievementService {
|
|
|
for (int i = 0; i < positionsList.size(); i++) {
|
|
|
Map<String, Object> pgData = MapUtils.newHashMap();
|
|
|
if (i < positionsList.size() - 1) {
|
|
|
- if (pnIndex < taskX.size()) {
|
|
|
- if (taskX.get(pnIndex).equals(positionsList.get(i).getX()) && taskY.get(pnIndex).equals(positionsList.get(i).getY())) {
|
|
|
- pgData.put("partwspeeds", tasKPartwspeeds.get(pnIndex));
|
|
|
+ if (pnIndex < berthingPointList.size()) {
|
|
|
+ BigDecimal position = positionsList.get(i).setScale(4, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal berthingPoint = new BigDecimal(String.valueOf(berthingPointList.get(pnIndex).getX())).setScale(4, RoundingMode.HALF_UP);
|
|
|
+ if (position.equals(berthingPoint)) {
|
|
|
+ if (pnIndex < tasKPartwspeeds.size()) {
|
|
|
+ pgData.put("partwspeeds", tasKPartwspeeds.get(pnIndex));
|
|
|
+ } else {
|
|
|
+ pgData.put("partwspeeds", "");
|
|
|
+ }
|
|
|
if (i < 2) {
|
|
|
pgData.put("add", acreages.get(0));//部分
|
|
|
} else {
|
|
@@ -236,11 +268,16 @@ public class AchievementServiceImpl implements AchievementService {
|
|
|
BigDecimal add = bd1.add(bd2);
|
|
|
pgData.put("add", add.toString());
|
|
|
}
|
|
|
- pgData.put("flows", taskFlows.get(pnIndex));//部分流量
|
|
|
+// pgData.put("flows", taskFlows.get(pnIndex));//部分流量
|
|
|
pnIndex = pnIndex + 1;
|
|
|
} else {
|
|
|
- pgData.put("partwspeeds","");
|
|
|
+ pgData.put("partwspeeds", "");
|
|
|
pgData.put("add", "");
|
|
|
+// pgData.put("flows", "");
|
|
|
+ }
|
|
|
+ if (i < taskFlows.size()) {
|
|
|
+ pgData.put("flows", taskFlows.get(i));
|
|
|
+ } else {
|
|
|
pgData.put("flows", "");
|
|
|
}
|
|
|
}
|