Commit 5de3e3d7 authored by 史志龙's avatar 史志龙

Merge branch 'dev-szl' into 'dev'

Dev szl

See merge request !17
parents 346944ca c5a6a405
......@@ -2,16 +2,21 @@ package org.jeecg.modules.checkData.equipmentCheckData.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.checkData.equipmentCheckData.dto.MovementRecordsMasterDTO;
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementCourse;
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementCourseInfo;
......@@ -20,18 +25,24 @@ import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementCourseInf
import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementCourseService;
import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementRecordsMasterService;
import org.jeecg.modules.checkData.equipmentCheckData.vo.*;
import org.jeecg.modules.subwayNetwork.entity.LineAlias;
import org.jeecg.modules.subwayNetwork.entity.SubwaySection;
import org.jeecg.modules.subwayNetwork.service.ILineAliasService;
import org.jeecg.modules.subwayNetwork.service.ISubwaySectionService;
import org.jeecg.modules.utils.BeanCopyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import javax.transaction.Transactional;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
......@@ -52,6 +63,8 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
private IMovementCourseInfoService movementCourseInfoService;
@Autowired
private ISubwaySectionService subwaySectionService;
@Autowired
private ILineAliasService lineAliasService;
/**
* 动静态几何尺寸数据-分页列表查询
......@@ -171,7 +184,15 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
if (bean.getSectionEndMileage() != null) {
result.setEndMileage(bean.getSectionEndMileage());
}
if (ObjectUtil.isNotEmpty(bean.getSectionName())) {
result.setSubwaySectionName(bean.getSectionName());
}
if (ObjectUtil.isNotEmpty(bean.getLightRailName())) {
result.setLightRailName(bean.getLightRailName());
}
}
//查询区间起始终点里程
result.setLineAliasName(lineAliasService.getById(lineAliasId).getLineAliasName());
//TODO 后期改造完补充逻辑
result.setRailNum(25);
result.setCurveNum(30);
......@@ -227,6 +248,253 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
return Result.OK("删除成功!");
}
@AutoLog(value = "导入")
@ApiOperation(value = "导入", notes = "导入 ")
@PostMapping(value = "/upload")
@Transactional
public Result<String> uploadFile(MultipartFile file, @ApiParam(name = "动静态几何尺寸主键id") String id) {
try {
String pat = "\\d{4}.\\d{2}.\\d{2}";
Pattern p = Pattern.compile(pat);
//读取第一个sheet页的数据
ExcelReader reader = ExcelUtil.getReader(file.getInputStream(), 0);
//读取Excel中所有的数据,以行保存
List<List<Object>> rowRecords = reader.read();
// 获取excel的列数
int column = rowRecords.get(0).size();
//初始化列的索引
int skipColumnNum = 0;
//int seq = 1; // 第一个
//初始化起始里程
String startingAndEndingMileageStr = "";
//初始化终点里程
String endingMileageStr = "";
//初始化曲线半径
String curveRadius = "";
//初始化超高
String superHigh = "";
//初始化加宽
String widen = "";
//初始化顺坡率
String slopeRatio = "";
//初始化长度
String longExtent = "";
//初始化备注
String remark = "";
//初始化起始里程表主键
String courseId = "";
//获取当前登录人信息
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String realname = user.getRealname();
// 如果做完了一个解析就跳过
MovementCourse movementCourse = new MovementCourse();
List<MovementCourseInfo> resultList = new ArrayList<>();
for (int i = 0; i < column; i++) {
skipColumnNum++;
if (ObjectUtil.isEmpty(startingAndEndingMileageStr)) {
// 1.起止里程
List<Object> startingAndEndingMileage = rowRecords.get(3);
Object mileageObject = startingAndEndingMileage.get(i);
String mileage = mileageObject.toString();
//超高、加宽、顺坡率、线路全长
List<Object> courseList = rowRecords.get(4);
Object courseObject = courseList.get(i);
String courseStr = courseObject.toString();
if (mileage.indexOf("起止里程") != -1) {
//开始里程
String[] start = mileage.split("-");
String s = start[0];
String[] n0 = s.split("\\+");
startingAndEndingMileageStr = n0[1].trim();
//System.out.println(skipColumnNum+"开始里程="+startMileage);
//结束里程
String s1 = start[1];
String[] n1 = s1.split("\\+");
String s2 = n1[1];
endingMileageStr = s2.substring(0, s2.indexOf(" ")).trim();
//System.out.println(skipColumnNum+"结束里程="+endMileage);
//曲线半径
String[] n2 = s2.split("半径 ");
String s3 = n2[1];
curveRadius = s3.substring(0, s3.indexOf(" m")).replace("/", "").trim();
//System.out.println(skipColumnNum+"曲线半径="+bj+";");
//解析超高、加宽、顺坡率、线路全长
String[] n3 = courseStr.split("超高");
String s4 = n3[1];
superHigh = s4.substring(0, s4.indexOf("mm")).replace("/", "").trim();
//System.out.println(skipColumnNum+"超高="+superHigh+";");
//加宽
String[] n4 = courseStr.split("加宽");
String s5 = n4[1];
widen = s5.substring(0, s5.indexOf("mm")).replace("/", "").trim();
//System.out.println(skipColumnNum+"加宽="+widen+";");
//顺坡率
String[] n5 = courseStr.split("顺坡率");
String s6 = n5[1];
slopeRatio = s6.substring(0, s6.indexOf("‰")).replace("/", "").trim();
//System.out.println(skipColumnNum+"顺坡率="+slopeRatio+";");
//线路全长
String[] n6 = courseStr.split("线路全长:");
String s7 = n6[1];
longExtent = s7.substring(0, s7.indexOf("米")).replace("/", "").trim();
//System.out.println(skipColumnNum+"线路全长="+longExtent+";");
//解析备注
remark= rowRecords.get(14).get(i + 3).toString().trim();
movementCourse.setMovementMasterId(id);
movementCourse.setCourseStartingMileage(new BigDecimal(startingAndEndingMileageStr));
movementCourse.setCourseEndMileage(new BigDecimal(endingMileageStr));
if (ObjectUtil.isNotEmpty(curveRadius)) {
movementCourse.setCurveRadius(new BigDecimal(curveRadius));
}
if (ObjectUtil.isNotEmpty(superHigh)) {
movementCourse.setSuperHigh(new BigDecimal(superHigh));
}
if (ObjectUtil.isNotEmpty(widen)) {
movementCourse.setWiden(new BigDecimal(widen));
}
if (ObjectUtil.isNotEmpty(slopeRatio)) {
movementCourse.setSlopeRatio(new BigDecimal(slopeRatio));
}
if (ObjectUtil.isNotEmpty(longExtent)) {
movementCourse.setLongExtent(new BigDecimal(longExtent));
}
courseId = IdWorker.get32UUID();
movementCourse.setId(courseId);
movementCourse.setDelFlag("0");
movementCourse.setCreateTime(new Date());
movementCourse.setUpdateTime(new Date());
movementCourse.setCreateBy(realname);
movementCourse.setUpdateBy(realname);
movementCourse.setRemark(remark);
movementCourseService.save(movementCourse);
}
}
//解析子集
if((skipColumnNum -1)%28 == 0){
continue;
}
if((skipColumnNum -2)%28 == 0){
continue;
}
if (ObjectUtil.isNotEmpty(courseId)) {
MovementCourseInfo movementCourseInfo = new MovementCourseInfo();
movementCourseInfo.setId(IdWorker.get32UUID());
movementCourseInfo.setDelFlag("0");
movementCourseInfo.setMovementMasterId(id);
movementCourseInfo.setMovementCourseId(courseId);
movementCourseInfo.setCreateTime(new Date());
movementCourseInfo.setUpdateTime(new Date());
movementCourseInfo.setCreateBy(realname);
movementCourseInfo.setUpdateBy(realname);
//获取轨号
List<Object> trackCodeList = rowRecords.get(6);
String trackCode = trackCodeList.get(i).toString().trim();
if (ObjectUtil.isNotEmpty(trackCode) && !("检查日期").equals(trackCode) && !("轨号").equals(trackCode)) {
movementCourseInfo.setTrackCode(trackCode);
}
//获取轨距
List<Object> trackGaugeList = rowRecords.get(7);
String trackGauge = trackGaugeList.get(i).toString().trim();
if (ObjectUtil.isNotEmpty(trackGauge)
&& !("轨距").equals(trackGauge) && !p.matcher(trackGauge).matches()) {
movementCourseInfo.setTrackGauge(trackGauge);
}
//获取水平
List<Object> levelList = rowRecords.get(8);
String level = levelList.get(i).toString().trim();
if (ObjectUtil.isNotEmpty(level)
&& !("水平").equals(level) && !p.matcher(level).matches()) {
movementCourseInfo.setLevel(level);
}
//获取三角坑
List<Object> triangularPitList = rowRecords.get(9);
String triangularPit = triangularPitList.get(i).toString().trim();
if (ObjectUtil.isNotEmpty(triangularPit)
&& !("三角坑").equals(triangularPit) && !p.matcher(triangularPit).matches()) {
movementCourseInfo.setTriangularPit(triangularPit);
}
//获取方向
List<Object> directionList = rowRecords.get(10);
String direction = directionList.get(i).toString().trim();
if (ObjectUtil.isNotEmpty(direction)
&& !("方向").equals(direction) && !p.matcher(direction).matches()) {
movementCourseInfo.setDirection(direction);
}
//获取高低
List<Object> heightList = rowRecords.get(11);
String height = heightList.get(i).toString().trim();
if (ObjectUtil.isNotEmpty(height)
&& !("高低").equals(height) && !p.matcher(height).matches()) {
movementCourseInfo.setHeight(height);
}
//获取结构
List<Object> structureList = rowRecords.get(12);
String structure = structureList.get(i).toString().trim();
if (ObjectUtil.isNotEmpty(structure)
&& !("结构").equals(structure) && !p.matcher(structure).matches()) {
movementCourseInfo.setStructure(structure);
}
//获取整改
List<Object> rectificationList = rowRecords.get(13);
String rectification = rectificationList.get(i).toString().trim();
if (ObjectUtil.isNotEmpty(rectification)
&& !("整改").equals(rectification) && !p.matcher(rectification).matches()) {
movementCourseInfo.setRectification(rectification);
}
resultList.add(movementCourseInfo);
}
if ((skipColumnNum+2) % 28 == 0) {
i = i+4;
skipColumnNum =skipColumnNum+4;
startingAndEndingMileageStr = "";
endingMileageStr = "";
curveRadius = "";
superHigh = "";
widen = "";
slopeRatio = "";
longExtent = "";
remark = "";
courseId = "";
movementCourse = new MovementCourse();
}
}
if (resultList != null && resultList.size() > 0) {
movementCourseInfoService.saveBatch(resultList);
}
} catch (Exception e) {
e.getMessage();
}
return Result.ok("操作成功");
}
public static void main(String[] args) {
String aa = "2022.11.07";
String pat = "\\d{4}.\\d{2}.\\d{2}";
Pattern p = Pattern.compile(pat);
if(p.matcher(aa).matches()){
System.out.println("1111");
}else {
System.out.println("2222");
}
}
/**
* 校验参数
......
......@@ -142,8 +142,9 @@ public class RecordsMasterCheckController extends JeecgController<RecordsMasterC
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<RecordsMasterCheck> resultList = this.service.list(new LambdaQueryWrapper<RecordsMasterCheck>()
.like(ObjectUtil.isNotEmpty(recordsMasterCheck.getEkCode()), RecordsMasterCheck::getEkCode, recordsMasterCheck.getEkCode())
.like(ObjectUtil.isNotEmpty(recordsMasterCheck.getSubwaySectionName()), RecordsMasterCheck::getSubwaySectionName, recordsMasterCheck.getSubwaySectionName())
.like(ObjectUtil.isNotEmpty(recordsMasterCheck.getLightRailName()), RecordsMasterCheck::getLightRailName, recordsMasterCheck.getLightRailName())
.eq(ObjectUtil.isNotEmpty(recordsMasterCheck.getSubwaySectionId()), RecordsMasterCheck::getSubwaySectionId, recordsMasterCheck.getSubwaySectionId())
.eq(ObjectUtil.isNotEmpty(recordsMasterCheck.getLightRailId()), RecordsMasterCheck::getLightRailId, recordsMasterCheck.getLightRailId())
.eq(ObjectUtil.isNotEmpty(recordsMasterCheck.getLineAliasId()), RecordsMasterCheck::getLineAliasId, recordsMasterCheck.getLineAliasId())
.orderByAsc(RecordsMasterCheck::getCreateTime));
//导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "道床使用情况检查");
......@@ -164,8 +165,9 @@ public class RecordsMasterCheckController extends JeecgController<RecordsMasterC
public void export(RecordsMasterCheck recordsMasterCheck, HttpServletResponse response) {
List<RecordsMasterCheck> resultList = this.service.list(new LambdaQueryWrapper<RecordsMasterCheck>()
.like(ObjectUtil.isNotEmpty(recordsMasterCheck.getEkCode()), RecordsMasterCheck::getEkCode, recordsMasterCheck.getEkCode())
.like(ObjectUtil.isNotEmpty(recordsMasterCheck.getSubwaySectionName()), RecordsMasterCheck::getSubwaySectionName, recordsMasterCheck.getSubwaySectionName())
.like(ObjectUtil.isNotEmpty(recordsMasterCheck.getLightRailName()), RecordsMasterCheck::getLightRailName, recordsMasterCheck.getLightRailName())
.eq(ObjectUtil.isNotEmpty(recordsMasterCheck.getSubwaySectionId()), RecordsMasterCheck::getSubwaySectionId, recordsMasterCheck.getSubwaySectionId())
.eq(ObjectUtil.isNotEmpty(recordsMasterCheck.getLightRailId()), RecordsMasterCheck::getLightRailId, recordsMasterCheck.getLightRailId())
.eq(ObjectUtil.isNotEmpty(recordsMasterCheck.getLineAliasId()), RecordsMasterCheck::getLineAliasId, recordsMasterCheck.getLineAliasId())
.orderByAsc(RecordsMasterCheck::getCreateTime));
int num = 0;
for (RecordsMasterCheck s : resultList) {
......
......@@ -39,7 +39,7 @@ public class MovementCourseInfoDTO {
private String movementMasterId;
@ApiModelProperty("动静态几何尺寸对应得里程信息主键-》外键")
private BigDecimal movementCourseId;
private String movementCourseId;
@ApiModelProperty("轨号")
private String trackCode;
......
......@@ -60,7 +60,7 @@ public class MovementCourseInfo implements Serializable {
@ApiModelProperty("动静态几何尺寸对应得里程信息主键-》外键")
@TableField("movement_course_id")
private BigDecimal movementCourseId;
private String movementCourseId;
@ApiModelProperty("轨号")
@TableField("track_code")
......
......@@ -11,14 +11,14 @@
<if test="dto.ekCode != null and dto.ekCode != ''">
AND t1.ek_code like concat('%',#{dto.ekCode},'%')
</if>
<if test="dto.subwaySectionName != null and dto.subwaySectionName != ''">
AND t1.subway_section_name like concat('%',#{dto.subwaySectionName},'%')
<if test="dto.subwaySectionId != null and dto.subwaySectionId != ''">
AND t1.subway_section_id = #{dto.subwaySectionId}
</if>
<if test="dto.lightRailName != null and dto.lightRailName != ''">
AND t1.light_rail_name like concat('%',#{dto.lightRailName},'%')
<if test="dto.lightRailId != null and dto.lightRailId != ''">
AND t1.light_rail_id = #{dto.lightRailId}
</if>
<if test="dto.lineAliasName != null and dto.lineAliasName != ''">
AND t1.line_alias_name like concat('%',#{dto.lineAliasName},'%')
<if test="dto.lineAliasId != null and dto.lineAliasId != ''">
AND t1.line_alias_id = #{dto.lineAliasId}
</if>
AND t1.type = #{dto.type}
AND t1.del_flag = '0'
......
......@@ -11,11 +11,11 @@
<if test="dto.ekCode != null and dto.ekCode != ''">
AND t1.ek_code like concat('%',#{dto.ekCode},'%')
</if>
<if test="dto.lightRailName != null and dto.lightRailName != ''">
AND t1.light_rail_name like concat('%',#{dto.lightRailName},'%')
<if test="dto.lightRailId != null and dto.lightRailId != ''">
AND t1.light_rail_id = #{dto.lightRailId}
</if>
<if test="dto.lineAliasName != null and dto.lineAliasName != ''">
AND t1.line_alias_name like concat('%',#{dto.lineAliasName},'%')
<if test="dto.lineAliasId != null and dto.lineAliasId != ''">
AND t1.line_alias_id = #{dto.lineAliasId}
</if>
AND t1.del_flag = '0'
order by t1.create_time desc
......
......@@ -11,14 +11,14 @@
<if test="dto.ekCode != null and dto.ekCode != ''">
AND t1.ek_code like concat('%',#{dto.ekCode},'%')
</if>
<if test="dto.subwaySectionName != null and dto.subwaySectionName != ''">
AND t1.subway_section_name like concat('%',#{dto.subwaySectionName},'%')
<if test="dto.subwaySectionId != null and dto.subwaySectionId != ''">
AND t1.subway_section_id = #{dto.subwaySectionId}
</if>
<if test="dto.lightRailName != null and dto.lightRailName != ''">
AND t1.light_rail_name like concat('%',#{dto.lightRailName},'%')
<if test="dto.lightRailId != null and dto.lightRailId != ''">
AND t1.light_rail_id = #{dto.lightRailId}
</if>
<if test="dto.lineAliasName != null and dto.lineAliasName != ''">
AND t1.line_alias_name like concat('%',#{dto.lineAliasName},'%')
<if test="dto.lineAliasId != null and dto.lineAliasId != ''">
AND t1.line_alias_id = #{dto.lineAliasId}
</if>
AND t1.del_flag = '0'
order by t1.create_time desc
......
......@@ -45,7 +45,7 @@ public class MovementCourseInfoVO {
private String movementMasterId;
@ApiModelProperty("动静态几何尺寸对应得里程信息主键-》外键")
private BigDecimal movementCourseId;
private String movementCourseId;
@ApiModelProperty("轨号")
private String trackCode;
......
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