Commit c3e037b5 authored by hkl's avatar hkl

feat:1.人工检查数据导入

parent a6371ce2
...@@ -74,6 +74,10 @@ ...@@ -74,6 +74,10 @@
<properties> <properties>
<package.environment>hkl</package.environment> <package.environment>hkl</package.environment>
</properties> </properties>
<!-- 是否默认 true表示默认-->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile> </profile>
<!-- 测试环境 --> <!-- 测试环境 -->
...@@ -90,10 +94,6 @@ ...@@ -90,10 +94,6 @@
<properties> <properties>
<package.environment>pressure</package.environment> <package.environment>pressure</package.environment>
</properties> </properties>
<!-- 是否默认 true表示默认-->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile> </profile>
<!-- 生成环境环境--> <!-- 生成环境环境-->
......
...@@ -234,6 +234,12 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec ...@@ -234,6 +234,12 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
//循环符合条件的数据项集合 //循环符合条件的数据项集合
for (MovementCourseInfo entity : listResult) { for (MovementCourseInfo entity : listResult) {
//判断项目名称一样 //判断项目名称一样
/* if (code.equals(entity.getTrackCode())) {
//初始化检查项目对应的详情记录的对象
MovementCourseInfoVO infoVo = new MovementCourseInfoVO();
BeanCopyUtil.copyProperties(entity, infoVo);
infoList.add(infoVo);
}*/
if (code.equals(entity.getTrackCode())) { if (code.equals(entity.getTrackCode())) {
//初始化检查项目对应的详情记录的对象 //初始化检查项目对应的详情记录的对象
MovementCourseInfoVO infoVo = new MovementCourseInfoVO(); MovementCourseInfoVO infoVo = new MovementCourseInfoVO();
...@@ -316,19 +322,33 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec ...@@ -316,19 +322,33 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
return Result.OK("删除成功!"); return Result.OK("删除成功!");
} }
@AutoLog(value = "导入") @AutoLog(value = "导入")
@ApiOperation(value = "导入", notes = "导入 ") @ApiOperation(value = "导入", notes = "导入 ")
@PostMapping(value = "/upload") @PostMapping(value = "/upload")
@Transactional @Transactional
public Result<String> uploadFile(MultipartFile file, @ApiParam(name = "动静态几何尺寸主键id") String id) { public Result<String> uploadFile(MultipartFile file, @ApiParam(name = "动静态几何尺寸主键id") String id) {
this.movementRecordsMasterFace.uploadFile(file, id);
return Result.OK("导入成功");
}
@AutoLog(value = "导入")
@ApiOperation(value = "导入", notes = "导入 ")
@PostMapping(value = "/upload2")
@Transactional
public Result<String> uploadFile2(MultipartFile file, @ApiParam(name = "动静态几何尺寸主键id") String id) {
try { try {
//初始化数据模板 //初始化数据模板
QueryWrapper<MovementCourse> courseRemove = new QueryWrapper<>(); movementCourseService.lambdaUpdate()
courseRemove.eq("movement_master_id", id); .eq(MovementCourse::getMovementMasterId, id)
movementCourseService.remove(courseRemove); .remove();
QueryWrapper<MovementCourseInfo> rm = new QueryWrapper<>(); movementCourseInfoService.lambdaUpdate()
rm.eq("movement_master_id", id); .eq(MovementCourseInfo::getMovementMasterId, id)
movementCourseInfoService.remove(rm); .remove();
//时间校验 //时间校验
String pat = "\\d{4}.\\d{2}.\\d{2}"; String pat = "\\d{4}.\\d{2}.\\d{2}";
Pattern p = Pattern.compile(pat); Pattern p = Pattern.compile(pat);
...@@ -380,7 +400,7 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec ...@@ -380,7 +400,7 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
List<Object> courseList = rowRecords.get(4); List<Object> courseList = rowRecords.get(4);
Object courseObject = courseList.get(i); Object courseObject = courseList.get(i);
String courseStr = courseObject.toString(); String courseStr = courseObject.toString();
if (mileage.indexOf("起止里程") != -1) { if (mileage.contains("起止里程")) {
//开始里程 //开始里程
String[] start = mileage.split("-"); String[] start = mileage.split("-");
String s = start[0]; String s = start[0];
...@@ -560,6 +580,7 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec ...@@ -560,6 +580,7 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
return Result.ok("操作成功"); return Result.ok("操作成功");
} }
@AutoLog(value = "人工静态检查数据-保存曲线半径信息") @AutoLog(value = "人工静态检查数据-保存曲线半径信息")
@ApiOperation(value = "人工静态检查数据-保存曲线半径信息", notes = "人工静态检查数据-保存曲线半径信息") @ApiOperation(value = "人工静态检查数据-保存曲线半径信息", notes = "人工静态检查数据-保存曲线半径信息")
@PostMapping(value = "/saveAdditive") @PostMapping(value = "/saveAdditive")
......
package org.jeecg.modules.checkData.face; package org.jeecg.modules.checkData.face;
import org.jeecg.modules.checkData.entity.MovementCourse; import org.jeecg.modules.checkData.entity.MovementCourse;
import org.springframework.web.multipart.MultipartFile;
public interface MovementRecordsMasterFace { public interface MovementRecordsMasterFace {
/** /**
...@@ -16,4 +17,6 @@ public interface MovementRecordsMasterFace { ...@@ -16,4 +17,6 @@ public interface MovementRecordsMasterFace {
* @param record * @param record
*/ */
void updateLabourCheckItem(MovementCourse record); void updateLabourCheckItem(MovementCourse record);
void uploadFile(MultipartFile file, String id);
} }
package org.jeecg.modules.checkData.face.impl; package org.jeecg.modules.checkData.face.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.sax.handler.RowHandler;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.UUIDGenerator; import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.modules.checkData.entity.MovementCourse; import org.jeecg.modules.checkData.entity.MovementCourse;
import org.jeecg.modules.checkData.entity.MovementCourseInfo; import org.jeecg.modules.checkData.entity.MovementCourseInfo;
import org.jeecg.modules.checkData.face.MovementRecordsMasterFace; import org.jeecg.modules.checkData.face.MovementRecordsMasterFace;
import org.jeecg.modules.checkData.service.IMovementCourseInfoService; import org.jeecg.modules.checkData.service.IMovementCourseInfoService;
import org.jeecg.modules.checkData.service.IMovementCourseService; import org.jeecg.modules.checkData.service.IMovementCourseService;
import org.jeecg.modules.utils.RedisLockUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collector;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -72,16 +80,235 @@ public class MovementRecordsMasterFaceImpl implements MovementRecordsMasterFace ...@@ -72,16 +80,235 @@ public class MovementRecordsMasterFaceImpl implements MovementRecordsMasterFace
@Override @Override
public void updateLabourCheckItem(MovementCourse record) { public void updateLabourCheckItem(MovementCourse record) {
movementCourseService.lambdaUpdate() movementCourseService.lambdaUpdate().set(MovementCourse::getCourseStartingMileage, record.getCourseStartingMileage()).set(MovementCourse::getCourseEndMileage, record.getCourseEndMileage()).set(MovementCourse::getCurveRadius, record.getCurveRadius()).set(MovementCourse::getSuperHigh, record.getSuperHigh()).set(MovementCourse::getWiden, record.getWiden()).set(MovementCourse::getSlopeRatio, record.getSlopeRatio()).set(MovementCourse::getLongExtent, record.getLongExtent()).eq(MovementCourse::getId, record.getId()).update();
.set(MovementCourse::getCourseStartingMileage, record.getCourseStartingMileage()) }
.set(MovementCourse::getCourseEndMileage, record.getCourseEndMileage())
.set(MovementCourse::getCurveRadius, record.getCurveRadius()) @Override
.set(MovementCourse::getSuperHigh, record.getSuperHigh()) public void uploadFile(MultipartFile file, String id) {
.set(MovementCourse::getWiden, record.getWiden()) try {
.set(MovementCourse::getSlopeRatio, record.getSlopeRatio()) InputStream inputStream = file.getInputStream();
.set(MovementCourse::getLongExtent, record.getLongExtent()) List<MovementCourse> movementCourseList = new ArrayList<>();
.eq(MovementCourse::getId, record.getId()) List<MovementCourseInfo> movementCourseInfoList = new ArrayList<>();
.update();
// 1.excel导入List<List<Object>> 中
CurrentRowHandler currentRowHandler = new CurrentRowHandler();
ExcelUtil.readBySax(inputStream, 0, currentRowHandler);
// 2.循环列数解析数据
int column = currentRowHandler.rowRecords.get(0).size();
int sort = 0;
int trackCodeCount = 1;
for (int i = 0; i < column; i++) {
// 2.1 解析检查项目 获取 起止里程,曲线半径,超高,加宽,顺坡率,线路全长
// 2.1.1 获取起止里程来判断该条记录是否获取
List<Object> startAndEndColumn = currentRowHandler.rowRecords.get(3);
List<Object> courseColumn = currentRowHandler.rowRecords.get(4);
if (ObjectUtil.isNotEmpty(startAndEndColumn.get(i))) {
String startingAndRowDataStr = startAndEndColumn.get(i).toString();
String courseDataStr = courseColumn.get(i).toString();
// ① 获取起止里程,为空跳过这个表格,不解析
int startIndex = startingAndRowDataStr.indexOf("起止里程:");
int endIndex = startingAndRowDataStr.indexOf(",站线");
String startingAndEndingMileageStr = "";
if (startIndex != -1 && endIndex != -1) {
startingAndEndingMileageStr = startingAndRowDataStr.substring(startIndex + "起止里程:".length(), endIndex).trim();
startingAndEndingMileageStr = startingAndEndingMileageStr.replace(" ", "").replace("/", "");
}
if (ObjectUtil.isEmpty(startingAndEndingMileageStr)) {
continue;
}
String[] mileages = startingAndEndingMileageStr.split("-");
String startMileageStr = mileages[0].replace("K", "").replace("+", "");
String endMileageStr = mileages[1].replace("K", "").replace("+", "");
BigDecimal startMileage = Convert.toBigDecimal(startMileageStr);
BigDecimal endMileage = Convert.toBigDecimal(endMileageStr);
// ② 获取曲线半径,可能为空,‘/’ 视为空
startIndex = startingAndRowDataStr.indexOf("曲线半径");
endIndex = startingAndRowDataStr.indexOf("m");
String curveRadiusStr = "";
if (startIndex != -1 && endIndex != -1) {
curveRadiusStr = startingAndRowDataStr.substring(startIndex + "曲线半径".length(), endIndex);
curveRadiusStr = curveRadiusStr.replace("/", "").trim();
}
BigDecimal curveRadius = Convert.toBigDecimal(curveRadiusStr);
// ③ 获取超高,可能为空,‘/’ 视为空
startIndex = courseDataStr.indexOf("超高");
endIndex = courseDataStr.indexOf("加宽");
String superHighStr = "";
if (startIndex != -1 && endIndex != -1) {
superHighStr = courseDataStr.substring(startIndex + "超高".length(), endIndex);
superHighStr = superHighStr.replace(",", "").replace("mm", "").replace("/", "").trim();
}
BigDecimal superHigh = Convert.toBigDecimal(superHighStr);
// ④ 获取加宽,可能为空,‘/’ 视为空
startIndex = courseDataStr.indexOf("加宽");
endIndex = courseDataStr.indexOf("顺坡率");
String widenStr = "";
if (startIndex != -1 && endIndex != -1) {
widenStr = courseDataStr.substring(startIndex + "加宽".length(), endIndex);
widenStr = widenStr.replace(",", "").replace("mm", "").replace("/", "").trim();
}
BigDecimal widen = Convert.toBigDecimal(widenStr);
// ⑤ 获取顺坡率,可能为空,‘/’ 视为空
startIndex = courseDataStr.indexOf("顺坡率");
endIndex = courseDataStr.indexOf("线路全长");
String slopeRatioStr = "";
if (startIndex != -1 && endIndex != -1) {
slopeRatioStr = courseDataStr.substring(startIndex + "顺坡率".length(), endIndex);
slopeRatioStr = slopeRatioStr.replace(",", "").replace("‰", "").replace("/", "").trim();
}
BigDecimal slopeRatio = Convert.toBigDecimal(slopeRatioStr);
// ⑥ 获取长度,可能为空,‘/’ 视为空
startIndex = courseDataStr.indexOf("线路全长");
String longExtentStr = "";
if (startIndex != -1) {
longExtentStr = courseDataStr.substring(startIndex + "线路全长".length());
longExtentStr = longExtentStr.replace("/", "").replace("米", "").trim();
}
BigDecimal longExtent = Convert.toBigDecimal(longExtentStr);
// ⑦ 解析备注
Object remarkObj = currentRowHandler.rowRecords.get(14).get(i + 3);
String remark = null;
if (ObjectUtil.isNotEmpty(remarkObj)) {
remark = remarkObj.toString();
}
sort++;
MovementCourse movementCourse = new MovementCourse();
movementCourse.setId(UUIDGenerator.generate());
movementCourse.setMovementMasterId(id);
movementCourse.setCourseStartingMileage(startMileage);
movementCourse.setCourseEndMileage(endMileage);
movementCourse.setCurveRadius(curveRadius);
movementCourse.setSuperHigh(superHigh);
movementCourse.setWiden(widen);
movementCourse.setSlopeRatio(slopeRatio);
movementCourse.setLongExtent(longExtent);
movementCourse.setDelFlag("0");
movementCourse.setRemark(remark);
movementCourse.setSort(sort);
movementCourseList.add(movementCourse);
// 2.2.2 解析项目里面的明细
// 2.2.2.1 单独获取轨号
int trackCodeNum = 2;
List<Object> trackCodeList = currentRowHandler.rowRecords.get(6);
Object trackCode = trackCodeList.get(i + trackCodeNum);
// 2.2.2.2 循环获取 轨距,水平,三角坑,方向,高低,结构,整改
int measurePoint = 1;
for (int j = 2; j < 26; j++) {
int position = i + j;
// 获取轨距
List<Object> trackGaugeList = currentRowHandler.rowRecords.get(7);
Object trackGauge = trackGaugeList.get(position);
//获取水平
List<Object> levelList = currentRowHandler.rowRecords.get(8);
Object level = levelList.get(position);
//获取三角坑
List<Object> triangularPitList = currentRowHandler.rowRecords.get(9);
Object triangularPit = triangularPitList.get(position);
//获取方向
List<Object> directionList = currentRowHandler.rowRecords.get(10);
Object direction = directionList.get(position);
//获取高低
List<Object> heightList = currentRowHandler.rowRecords.get(11);
Object height = heightList.get(position);
//获取结构
List<Object> structureList = currentRowHandler.rowRecords.get(12);
Object structure = structureList.get(position);
//获取整改
List<Object> rectificationList = currentRowHandler.rowRecords.get(13);
Object rectification = rectificationList.get(position);
MovementCourseInfo movementCourseInfo = new MovementCourseInfo();
movementCourseInfo.setId(UUIDGenerator.generate());
movementCourseInfo.setDelFlag("0");
movementCourseInfo.setMovementMasterId(id);
movementCourseInfo.setMovementCourseId(movementCourse.getId());
movementCourseInfo.setInfoSort(j - 1);
movementCourseInfo.setMeasurePoint(measurePoint);
movementCourseInfo.setTrackCode(Convert.toStr(trackCode));
movementCourseInfo.setTrackGauge(Convert.toStr(trackGauge));
movementCourseInfo.setLevel(Convert.toStr(level));
movementCourseInfo.setTriangularPit(Convert.toStr(triangularPit));
movementCourseInfo.setDirection(Convert.toStr(direction));
movementCourseInfo.setHeight(Convert.toStr(height));
movementCourseInfo.setStructure(Convert.toStr(structure));
movementCourseInfo.setRectification(Convert.toStr(rectification));
movementCourseInfoList.add(movementCourseInfo);
if (measurePoint % 8 == 0) {
trackCodeCount++;
measurePoint = 1;
trackCodeNum = trackCodeNum + 8;
if (i + trackCodeNum < trackCodeList.size()) {
trackCode = trackCodeList.get(i + trackCodeNum);
// 如果轨号为空,则按照顺序赋值
if (ObjectUtil.isEmpty(trackCode)) {
trackCode = Convert.toStr(trackCodeCount);
}
}
} else {
measurePoint++;
}
}
}
}
// 保存之前先删除
movementCourseService.lambdaUpdate().eq(MovementCourse::getMovementMasterId, id).remove();
movementCourseInfoService.lambdaUpdate().eq(MovementCourseInfo::getMovementMasterId, id).remove();
if (ObjectUtil.isNotEmpty(movementCourseInfoList)) {
movementCourseInfoService.saveBatch(movementCourseInfoList);
}
if (ObjectUtil.isNotEmpty(movementCourseList)) {
movementCourseService.saveBatch(movementCourseList);
}
} catch (IOException e) {
throw JeecgBootException.error(e.getMessage());
}
}
/**
* 当前行处理器
*/
private static class CurrentRowHandler implements RowHandler {
public CurrentRowHandler() {
this.rowRecords = new ArrayList<>();
}
private List<List<Object>> rowRecords;
@Override
public void handle(int sheetIndex, long rowIndex, List<Object> rowList) {
rowRecords.add(rowList);
}
} }
/** /**
...@@ -99,19 +326,12 @@ public class MovementRecordsMasterFaceImpl implements MovementRecordsMasterFace ...@@ -99,19 +326,12 @@ public class MovementRecordsMasterFaceImpl implements MovementRecordsMasterFace
*/ */
private void labourCheckItemSort(String movementMasterId) { private void labourCheckItemSort(String movementMasterId) {
// 检查项目list // 检查项目list
List<MovementCourse> movementCourseList = movementCourseService.lambdaQuery() List<MovementCourse> movementCourseList = movementCourseService.lambdaQuery().eq(MovementCourse::getMovementMasterId, movementMasterId).orderByAsc(MovementCourse::getCourseStartingMileage).list();
.eq(MovementCourse::getMovementMasterId, movementMasterId)
.orderByAsc(MovementCourse::getCourseStartingMileage)
.list();
// 检查项目明细list // 检查项目明细list
List<MovementCourseInfo> movementCourseInfoList = movementCourseInfoService.lambdaQuery() List<MovementCourseInfo> movementCourseInfoList = movementCourseInfoService.lambdaQuery().eq(MovementCourseInfo::getMovementMasterId, movementMasterId).orderByAsc(MovementCourseInfo::getInfoSort).list();
.eq(MovementCourseInfo::getMovementMasterId, movementMasterId) Map<String, List<MovementCourseInfo>> movementCourseInfoMap = movementCourseInfoList.stream().collect(Collectors.groupingBy(MovementCourseInfo::getMovementCourseId));
.orderByAsc(MovementCourseInfo::getInfoSort)
.list();
Map<String, List<MovementCourseInfo>> movementCourseInfoMap = movementCourseInfoList.stream()
.collect(Collectors.groupingBy(MovementCourseInfo::getMovementCourseId));
for (int i = 0; i < movementCourseList.size(); i++) { for (int i = 0; i < movementCourseList.size(); i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment