|
@@ -1,16 +1,28 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.context.AnalysisContext;
|
|
|
import com.alibaba.excel.read.listener.ReadListener;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ruoyi.common.exception.base.BaseException;
|
|
|
+import com.ruoyi.system.domain.BerthingPoint;
|
|
|
+import com.ruoyi.system.domain.SiteInfo;
|
|
|
+import com.ruoyi.system.dto.BerthingPointDTO;
|
|
|
import com.ruoyi.system.dto.PrintExcelDTO;
|
|
|
+import com.ruoyi.system.mapper.BerthingPointMapper;
|
|
|
+import com.ruoyi.system.mapper.SiteInfoMapper;
|
|
|
+import com.ruoyi.system.paramet.BerthingPointQuery;
|
|
|
import com.ruoyi.system.service.BerthingService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -21,6 +33,14 @@ import java.util.Comparator;
|
|
|
@Slf4j
|
|
|
public class BerthingServiceImpl implements BerthingService {
|
|
|
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SiteInfoMapper siteInfoMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BerthingPointMapper berthingPointMapper;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public ArrayList<PrintExcelDTO> uploadFile(MultipartFile file) {
|
|
|
ArrayList<PrintExcelDTO> excelDateList = new ArrayList<>();
|
|
@@ -48,6 +68,51 @@ public class BerthingServiceImpl implements BerthingService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean insertBerthing(BerthingPointDTO berthingPointDTO){
|
|
|
+ SiteInfo siteInfo = siteInfoMapper.queryById(berthingPointDTO.getSiteId());
|
|
|
+ if (siteInfo == null) {
|
|
|
+ throw new BaseException("站点不存在");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ ArrayList<PrintExcelDTO> positions = berthingPointDTO.getPositions();
|
|
|
+ positions.sort(Comparator.comparingDouble(PrintExcelDTO::getX));
|
|
|
+ //设置他断面状态为无效
|
|
|
+ berthingPointMapper.setBerthingStatus(siteInfo.getSiteId());
|
|
|
+ BerthingPoint berthingPoint = new BerthingPoint();
|
|
|
+ berthingPoint.setBerthingName(berthingPointDTO.getBerthingName());
|
|
|
+ berthingPoint.setPositions(JSONUtil.toJsonStr(positions));
|
|
|
+ berthingPoint.setSiteId(siteInfo.getSiteId());
|
|
|
+ berthingPoint.setBerthingId(0L);
|
|
|
+ berthingPoint.setCreateTime(new Date());
|
|
|
+ berthingPoint.setIsDel(0);
|
|
|
+ berthingPoint.setId(siteInfo.getId());
|
|
|
+ berthingPoint.setStatus(1);
|
|
|
+ return berthingPointMapper.insert(berthingPoint) > 0;
|
|
|
+ //TODO 配置下发
|
|
|
+ } catch (Exception e){
|
|
|
+ log.error("新增断面错误", e);
|
|
|
+ throw new BaseException("新增断面错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<BerthingPoint> queryBerthing(BerthingPointQuery berthingPointQuery) {
|
|
|
+ try {
|
|
|
+ if (berthingPointQuery.getPage() == null || berthingPointQuery.getSize() == null) {
|
|
|
+ berthingPointQuery.setPage(1L);
|
|
|
+ berthingPointQuery.setSize(10L);
|
|
|
+ }
|
|
|
+ Page<SiteInfo> page = new Page<>(berthingPointQuery.getPage(), berthingPointQuery.getSize());
|
|
|
+ return berthingPointMapper.queryAllByLimit(berthingPointQuery, page);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询站点错误", e);
|
|
|
+ throw new BaseException("查询站点错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|